diff options
| -rw-r--r-- | services/voiceinteraction/java/com/android/server/voiceinteraction/HotwordMetricsLogger.java | 69 | 
1 files changed, 69 insertions, 0 deletions
diff --git a/services/voiceinteraction/java/com/android/server/voiceinteraction/HotwordMetricsLogger.java b/services/voiceinteraction/java/com/android/server/voiceinteraction/HotwordMetricsLogger.java new file mode 100644 index 000000000000..de0b9606045e --- /dev/null +++ b/services/voiceinteraction/java/com/android/server/voiceinteraction/HotwordMetricsLogger.java @@ -0,0 +1,69 @@ +/* + * 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); +    } +}  |