Add HotwordMetricsLogger for statistics logging.

This change only provide a utilility class to help hotword dection
metrics logging. The log writing will on the follow up changes.

Android Metrics Design Review : eldar/276723226

Bug: 207717787
Test: build pass can boot success
Change-Id: I3f9f597554aa9e65a20076cc1b58072c8e390e30
Merged-in: If436aae1b4ebdb06c7bd5a1c0b8d6df4e94488cd
(cherry picked from commit e13c17d233)
This commit is contained in:
Joanne Chung
2022-03-15 11:07:52 +00:00
parent adc12a6263
commit b8c2da2587

View File

@@ -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);
}
}