Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 3013b6f1 authored by Yara Hassan's avatar Yara Hassan
Browse files

Add AccessibilityCheckerStatsdLogger

Bug: 326385939
Test: th
Flag: com.android.server.accessibility.enable_a11y_checker_logging
Change-Id: I28c970c62c409fbfd015f68d2a4f6c3a281f81a6
parent cdceb40d
Loading
Loading
Loading
Loading
+10 −1
Original line number Diff line number Diff line
@@ -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"],
}
+56 −0
Original line number Diff line number Diff line
/*
 * 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());
        }
    }
}