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

Commit 70bbc8e6 authored by Joanne Chung's avatar Joanne Chung Committed by Android (Google) Code Review
Browse files

Merge "Add HotwordMetricsLogger for statistics logging." into tm-dev

parents 2d7e74c5 e13c17d2
Loading
Loading
Loading
Loading
+69 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2022 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.voiceinteraction;

import com.android.internal.util.FrameworkStatsLog;

/**
 * A utility class for logging hotword statistics event.
 */
public final class HotwordMetricsLogger {

    private HotwordMetricsLogger() {
        // Class only contains static utility functions, and should not be instantiated
    }

    /**
     * Logs information related to create hotword detector.
     */
    public static void writeDetectorCreateEvent(int detectorType, boolean isCreated, int uid) {
        FrameworkStatsLog.write(FrameworkStatsLog.HOTWORD_DETECTOR_CREATE_REQUESTED, detectorType,
                isCreated, uid);
    }

    /**
     * Logs information related to hotword detection service init result.
     */
    public static void writeServiceInitResultEvent(int detectorType, int result) {
        FrameworkStatsLog.write(FrameworkStatsLog.HOTWORD_DETECTION_SERVICE_INIT_RESULT_REPORTED,
                detectorType, result);
    }

    /**
     * Logs information related to hotword detection service restarting.
     */
    public static void writeServiceRestartEvent(int detectorType, int reason) {
        FrameworkStatsLog.write(FrameworkStatsLog.HOTWORD_DETECTION_SERVICE_RESTARTED,
                detectorType, reason);
    }

    /**
     * Logs information related to keyphrase trigger.
     */
    public static void writeKeyphraseTriggerEvent(int detectorType, int result) {
        FrameworkStatsLog.write(FrameworkStatsLog.HOTWORD_DETECTOR_KEYPHRASE_TRIGGERED,
                detectorType, result);
    }

    /**
     * Logs information related to hotword detector events.
     */
    public static void writeDetectorEvent(int detectorType, int event, int uid) {
        FrameworkStatsLog.write(FrameworkStatsLog.HOTWORD_DETECTOR_EVENTS,
                detectorType, event, uid);
    }
}