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

Commit c6dd4f0c authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Add AccessibilityCheckerStatsdLogger" into main

parents 18b60764 3013b6f1
Loading
Loading
Loading
Loading
+10 −1
Original line number Original line Diff line number Diff line
@@ -26,6 +26,7 @@ java_library_static {
    },
    },
    srcs: [
    srcs: [
        ":services.accessibility-sources",
        ":services.accessibility-sources",
        ":statslog-accessibility-java-gen",
        "//frameworks/base/packages/SettingsLib/RestrictedLockUtils:SettingsLibRestrictedLockUtilsSrc",
        "//frameworks/base/packages/SettingsLib/RestrictedLockUtils:SettingsLibRestrictedLockUtilsSrc",
    ],
    ],
    libs: [
    libs: [
@@ -37,7 +38,6 @@ java_library_static {
        "a11ychecker-protos-java-proto-lite",
        "a11ychecker-protos-java-proto-lite",
        "com_android_server_accessibility_flags_lib",
        "com_android_server_accessibility_flags_lib",
        "//frameworks/base/packages/SystemUI/aconfig:com_android_systemui_flags_lib",
        "//frameworks/base/packages/SystemUI/aconfig:com_android_systemui_flags_lib",

    ],
    ],
}
}


@@ -81,3 +81,12 @@ java_library_static {
        "java/**/a11ychecker/proto/*.proto",
        "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 Original line 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());
        }
    }
}