diff options
author | 2024-07-23 18:40:29 +0100 | |
---|---|---|
committer | 2024-07-23 18:47:06 +0100 | |
commit | 3013b6f1d4a82403ae00aa81a98597b10adc747d (patch) | |
tree | df22df629bd1e12d244fcff175bb5253a8996dd0 | |
parent | cdceb40d7d11f2d2238f506748344d8bf348d3c0 (diff) |
Add AccessibilityCheckerStatsdLogger
Bug: 326385939
Test: th
Flag: com.android.server.accessibility.enable_a11y_checker_logging
Change-Id: I28c970c62c409fbfd015f68d2a4f6c3a281f81a6
-rw-r--r-- | services/accessibility/Android.bp | 11 | ||||
-rw-r--r-- | services/accessibility/java/com/android/server/accessibility/a11ychecker/AccessibilityCheckerStatsdLogger.java | 56 |
2 files changed, 66 insertions, 1 deletions
diff --git a/services/accessibility/Android.bp b/services/accessibility/Android.bp index 311addb90298..efa13971bce3 100644 --- a/services/accessibility/Android.bp +++ b/services/accessibility/Android.bp @@ -26,6 +26,7 @@ java_library_static { }, srcs: [ ":services.accessibility-sources", + ":statslog-accessibility-java-gen", "//frameworks/base/packages/SettingsLib/RestrictedLockUtils:SettingsLibRestrictedLockUtilsSrc", ], libs: [ @@ -37,7 +38,6 @@ java_library_static { "a11ychecker-protos-java-proto-lite", "com_android_server_accessibility_flags_lib", "//frameworks/base/packages/SystemUI/aconfig:com_android_systemui_flags_lib", - ], } @@ -81,3 +81,12 @@ java_library_static { "java/**/a11ychecker/proto/*.proto", ], } + +genrule { + name: "statslog-accessibility-java-gen", + tools: ["stats-log-api-gen"], + cmd: "$(location stats-log-api-gen) --java $(out) --module accessibility" + + " --javaPackage com.android.server.accessibility.a11ychecker" + + " --javaClass AccessibilityCheckerStatsLog --minApiLevel 34", + out: ["java/com/android/server/accessibility/a11ychecker/AccessibilityCheckerStatsLog.java"], +} diff --git a/services/accessibility/java/com/android/server/accessibility/a11ychecker/AccessibilityCheckerStatsdLogger.java b/services/accessibility/java/com/android/server/accessibility/a11ychecker/AccessibilityCheckerStatsdLogger.java new file mode 100644 index 000000000000..1b3ec5a5e6c2 --- /dev/null +++ b/services/accessibility/java/com/android/server/accessibility/a11ychecker/AccessibilityCheckerStatsdLogger.java @@ -0,0 +1,56 @@ +/* + * Copyright 2024 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.server.accessibility.a11ychecker; + +import android.util.Slog; + +import com.android.server.accessibility.a11ychecker.A11yCheckerProto.AccessibilityCheckResultReported; + +import java.util.Set; + + +/** + * Wraps the StatsdLogger for AccessibilityCheckResultReported. + * + * @hide + */ +public class AccessibilityCheckerStatsdLogger { + private static final int ATOM_ID = 910; + private static final String LOG_TAG = "AccessibilityCheckerStatsdLogger"; + + /** + * Writes results to statsd. + */ + public static void logResults(Set<AccessibilityCheckResultReported> results) { + Slog.i(LOG_TAG, String.format("Writing %d AccessibilityCheckResultReported events", + results.size())); + + for (AccessibilityCheckResultReported result : results) { + AccessibilityCheckerStatsLog.write(ATOM_ID, + result.getPackageName(), + result.getAppVersionCode(), + result.getUiElementPath(), + result.getActivityName(), + result.getWindowTitle(), + result.getSourceComponentName(), + result.getSourceVersionCode(), + result.getResultCheckClass().getNumber(), + result.getResultType().getNumber(), + result.getResultId()); + } + } +} |