Hotword: Add uid into the original metrics
We add new uid filed in HotwordDetectionServiceInitResultReported, HotwordDetectionServiceRestarted and HotwordDetectorKeyphraseTriggered. Update the metrics to log it. Test: statsd_testdrive Bug: 261793715 Change-Id: Ia49d5981be296c1143074774cc6c00fcc25671e6
This commit is contained in:
@@ -106,12 +106,14 @@ final class DspTrustedHotwordDetectorSession extends HotwordDetectorSession {
|
|||||||
}
|
}
|
||||||
HotwordMetricsLogger.writeKeyphraseTriggerEvent(
|
HotwordMetricsLogger.writeKeyphraseTriggerEvent(
|
||||||
HotwordDetector.DETECTOR_TYPE_TRUSTED_HOTWORD_DSP,
|
HotwordDetector.DETECTOR_TYPE_TRUSTED_HOTWORD_DSP,
|
||||||
HOTWORD_DETECTOR_KEYPHRASE_TRIGGERED__RESULT__DETECTED);
|
HOTWORD_DETECTOR_KEYPHRASE_TRIGGERED__RESULT__DETECTED,
|
||||||
|
mVoiceInteractionServiceUid);
|
||||||
if (!mValidatingDspTrigger) {
|
if (!mValidatingDspTrigger) {
|
||||||
Slog.i(TAG, "Ignoring #onDetected due to a process restart");
|
Slog.i(TAG, "Ignoring #onDetected due to a process restart");
|
||||||
HotwordMetricsLogger.writeKeyphraseTriggerEvent(
|
HotwordMetricsLogger.writeKeyphraseTriggerEvent(
|
||||||
HotwordDetector.DETECTOR_TYPE_TRUSTED_HOTWORD_DSP,
|
HotwordDetector.DETECTOR_TYPE_TRUSTED_HOTWORD_DSP,
|
||||||
METRICS_KEYPHRASE_TRIGGERED_DETECT_UNEXPECTED_CALLBACK);
|
METRICS_KEYPHRASE_TRIGGERED_DETECT_UNEXPECTED_CALLBACK,
|
||||||
|
mVoiceInteractionServiceUid);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
mValidatingDspTrigger = false;
|
mValidatingDspTrigger = false;
|
||||||
@@ -122,7 +124,8 @@ final class DspTrustedHotwordDetectorSession extends HotwordDetectorSession {
|
|||||||
Slog.i(TAG, "Ignoring #onDetected due to a SecurityException", e);
|
Slog.i(TAG, "Ignoring #onDetected due to a SecurityException", e);
|
||||||
HotwordMetricsLogger.writeKeyphraseTriggerEvent(
|
HotwordMetricsLogger.writeKeyphraseTriggerEvent(
|
||||||
HotwordDetector.DETECTOR_TYPE_TRUSTED_HOTWORD_DSP,
|
HotwordDetector.DETECTOR_TYPE_TRUSTED_HOTWORD_DSP,
|
||||||
METRICS_KEYPHRASE_TRIGGERED_DETECT_SECURITY_EXCEPTION);
|
METRICS_KEYPHRASE_TRIGGERED_DETECT_SECURITY_EXCEPTION,
|
||||||
|
mVoiceInteractionServiceUid);
|
||||||
externalCallback.onError(CALLBACK_ONDETECTED_GOT_SECURITY_EXCEPTION);
|
externalCallback.onError(CALLBACK_ONDETECTED_GOT_SECURITY_EXCEPTION);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -157,12 +160,14 @@ final class DspTrustedHotwordDetectorSession extends HotwordDetectorSession {
|
|||||||
}
|
}
|
||||||
HotwordMetricsLogger.writeKeyphraseTriggerEvent(
|
HotwordMetricsLogger.writeKeyphraseTriggerEvent(
|
||||||
HotwordDetector.DETECTOR_TYPE_TRUSTED_HOTWORD_DSP,
|
HotwordDetector.DETECTOR_TYPE_TRUSTED_HOTWORD_DSP,
|
||||||
HOTWORD_DETECTOR_KEYPHRASE_TRIGGERED__RESULT__REJECTED);
|
HOTWORD_DETECTOR_KEYPHRASE_TRIGGERED__RESULT__REJECTED,
|
||||||
|
mVoiceInteractionServiceUid);
|
||||||
if (!mValidatingDspTrigger) {
|
if (!mValidatingDspTrigger) {
|
||||||
Slog.i(TAG, "Ignoring #onRejected due to a process restart");
|
Slog.i(TAG, "Ignoring #onRejected due to a process restart");
|
||||||
HotwordMetricsLogger.writeKeyphraseTriggerEvent(
|
HotwordMetricsLogger.writeKeyphraseTriggerEvent(
|
||||||
HotwordDetector.DETECTOR_TYPE_TRUSTED_HOTWORD_DSP,
|
HotwordDetector.DETECTOR_TYPE_TRUSTED_HOTWORD_DSP,
|
||||||
METRICS_KEYPHRASE_TRIGGERED_REJECT_UNEXPECTED_CALLBACK);
|
METRICS_KEYPHRASE_TRIGGERED_REJECT_UNEXPECTED_CALLBACK,
|
||||||
|
mVoiceInteractionServiceUid);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
mValidatingDspTrigger = false;
|
mValidatingDspTrigger = false;
|
||||||
@@ -187,7 +192,8 @@ final class DspTrustedHotwordDetectorSession extends HotwordDetectorSession {
|
|||||||
Slog.w(TAG, "Timed out on #detectFromDspSource");
|
Slog.w(TAG, "Timed out on #detectFromDspSource");
|
||||||
HotwordMetricsLogger.writeKeyphraseTriggerEvent(
|
HotwordMetricsLogger.writeKeyphraseTriggerEvent(
|
||||||
HotwordDetector.DETECTOR_TYPE_TRUSTED_HOTWORD_DSP,
|
HotwordDetector.DETECTOR_TYPE_TRUSTED_HOTWORD_DSP,
|
||||||
HOTWORD_DETECTOR_KEYPHRASE_TRIGGERED__RESULT__DETECT_TIMEOUT);
|
HOTWORD_DETECTOR_KEYPHRASE_TRIGGERED__RESULT__DETECT_TIMEOUT,
|
||||||
|
mVoiceInteractionServiceUid);
|
||||||
try {
|
try {
|
||||||
externalCallback.onError(CALLBACK_DETECT_TIMEOUT);
|
externalCallback.onError(CALLBACK_DETECT_TIMEOUT);
|
||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
||||||
@@ -220,7 +226,8 @@ final class DspTrustedHotwordDetectorSession extends HotwordDetectorSession {
|
|||||||
mCallback.onRejected(new HotwordRejectedResult.Builder().build());
|
mCallback.onRejected(new HotwordRejectedResult.Builder().build());
|
||||||
HotwordMetricsLogger.writeKeyphraseTriggerEvent(
|
HotwordMetricsLogger.writeKeyphraseTriggerEvent(
|
||||||
HotwordDetector.DETECTOR_TYPE_TRUSTED_HOTWORD_DSP,
|
HotwordDetector.DETECTOR_TYPE_TRUSTED_HOTWORD_DSP,
|
||||||
HOTWORD_DETECTOR_KEYPHRASE_TRIGGERED__RESULT__REJECTED_FROM_RESTART);
|
HOTWORD_DETECTOR_KEYPHRASE_TRIGGERED__RESULT__REJECTED_FROM_RESTART,
|
||||||
|
mVoiceInteractionServiceUid);
|
||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
||||||
Slog.w(TAG, "Failed to call #rejected");
|
Slog.w(TAG, "Failed to call #rejected");
|
||||||
HotwordMetricsLogger.writeDetectorEvent(
|
HotwordMetricsLogger.writeDetectorEvent(
|
||||||
|
|||||||
@@ -165,7 +165,8 @@ final class HotwordDetectionConnection {
|
|||||||
synchronized (mLock) {
|
synchronized (mLock) {
|
||||||
restartProcessLocked();
|
restartProcessLocked();
|
||||||
HotwordMetricsLogger.writeServiceRestartEvent(mDetectorType,
|
HotwordMetricsLogger.writeServiceRestartEvent(mDetectorType,
|
||||||
HOTWORD_DETECTION_SERVICE_RESTARTED__REASON__SCHEDULE);
|
HOTWORD_DETECTION_SERVICE_RESTARTED__REASON__SCHEDULE,
|
||||||
|
mVoiceInteractionServiceUid);
|
||||||
}
|
}
|
||||||
}, mReStartPeriodSeconds, mReStartPeriodSeconds, TimeUnit.SECONDS);
|
}, mReStartPeriodSeconds, mReStartPeriodSeconds, TimeUnit.SECONDS);
|
||||||
}
|
}
|
||||||
@@ -200,7 +201,8 @@ final class HotwordDetectionConnection {
|
|||||||
// conditions with audio reading in the service.
|
// conditions with audio reading in the service.
|
||||||
restartProcessLocked();
|
restartProcessLocked();
|
||||||
HotwordMetricsLogger.writeServiceRestartEvent(mDetectorType,
|
HotwordMetricsLogger.writeServiceRestartEvent(mDetectorType,
|
||||||
HOTWORD_DETECTION_SERVICE_RESTARTED__REASON__AUDIO_SERVICE_DIED);
|
HOTWORD_DETECTION_SERVICE_RESTARTED__REASON__AUDIO_SERVICE_DIED,
|
||||||
|
mVoiceInteractionServiceUid);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -364,11 +366,13 @@ final class HotwordDetectionConnection {
|
|||||||
static final class SoundTriggerCallback extends IRecognitionStatusCallback.Stub {
|
static final class SoundTriggerCallback extends IRecognitionStatusCallback.Stub {
|
||||||
private final HotwordDetectionConnection mHotwordDetectionConnection;
|
private final HotwordDetectionConnection mHotwordDetectionConnection;
|
||||||
private final IHotwordRecognitionStatusCallback mExternalCallback;
|
private final IHotwordRecognitionStatusCallback mExternalCallback;
|
||||||
|
private final int mVoiceInteractionServiceUid;
|
||||||
|
|
||||||
SoundTriggerCallback(IHotwordRecognitionStatusCallback callback,
|
SoundTriggerCallback(IHotwordRecognitionStatusCallback callback,
|
||||||
HotwordDetectionConnection connection) {
|
HotwordDetectionConnection connection, int uid) {
|
||||||
mHotwordDetectionConnection = connection;
|
mHotwordDetectionConnection = connection;
|
||||||
mExternalCallback = callback;
|
mExternalCallback = callback;
|
||||||
|
mVoiceInteractionServiceUid = uid;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -381,13 +385,15 @@ final class HotwordDetectionConnection {
|
|||||||
if (useHotwordDetectionService) {
|
if (useHotwordDetectionService) {
|
||||||
HotwordMetricsLogger.writeKeyphraseTriggerEvent(
|
HotwordMetricsLogger.writeKeyphraseTriggerEvent(
|
||||||
HOTWORD_DETECTOR_KEYPHRASE_TRIGGERED__DETECTOR_TYPE__TRUSTED_DETECTOR_DSP,
|
HOTWORD_DETECTOR_KEYPHRASE_TRIGGERED__DETECTOR_TYPE__TRUSTED_DETECTOR_DSP,
|
||||||
HOTWORD_DETECTOR_KEYPHRASE_TRIGGERED__RESULT__KEYPHRASE_TRIGGER);
|
HOTWORD_DETECTOR_KEYPHRASE_TRIGGERED__RESULT__KEYPHRASE_TRIGGER,
|
||||||
|
mVoiceInteractionServiceUid);
|
||||||
mHotwordDetectionConnection.detectFromDspSource(
|
mHotwordDetectionConnection.detectFromDspSource(
|
||||||
recognitionEvent, mExternalCallback);
|
recognitionEvent, mExternalCallback);
|
||||||
} else {
|
} else {
|
||||||
HotwordMetricsLogger.writeKeyphraseTriggerEvent(
|
HotwordMetricsLogger.writeKeyphraseTriggerEvent(
|
||||||
HOTWORD_DETECTOR_KEYPHRASE_TRIGGERED__DETECTOR_TYPE__NORMAL_DETECTOR,
|
HOTWORD_DETECTOR_KEYPHRASE_TRIGGERED__DETECTOR_TYPE__NORMAL_DETECTOR,
|
||||||
HOTWORD_DETECTOR_KEYPHRASE_TRIGGERED__RESULT__KEYPHRASE_TRIGGER);
|
HOTWORD_DETECTOR_KEYPHRASE_TRIGGERED__RESULT__KEYPHRASE_TRIGGER,
|
||||||
|
mVoiceInteractionServiceUid);
|
||||||
mExternalCallback.onKeyphraseDetected(recognitionEvent, null);
|
mExternalCallback.onKeyphraseDetected(recognitionEvent, null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -238,7 +238,7 @@ abstract class HotwordDetectorSession {
|
|||||||
try {
|
try {
|
||||||
mCallback.onStatusReported(status);
|
mCallback.onStatusReported(status);
|
||||||
HotwordMetricsLogger.writeServiceInitResultEvent(getDetectorType(),
|
HotwordMetricsLogger.writeServiceInitResultEvent(getDetectorType(),
|
||||||
initResultMetricsResult);
|
initResultMetricsResult, mVoiceInteractionServiceUid);
|
||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
||||||
Slog.w(TAG, "Failed to report initialization status: " + e);
|
Slog.w(TAG, "Failed to report initialization status: " + e);
|
||||||
HotwordMetricsLogger.writeDetectorEvent(getDetectorType(),
|
HotwordMetricsLogger.writeDetectorEvent(getDetectorType(),
|
||||||
@@ -269,7 +269,7 @@ abstract class HotwordDetectorSession {
|
|||||||
try {
|
try {
|
||||||
mCallback.onStatusReported(INITIALIZATION_STATUS_UNKNOWN);
|
mCallback.onStatusReported(INITIALIZATION_STATUS_UNKNOWN);
|
||||||
HotwordMetricsLogger.writeServiceInitResultEvent(getDetectorType(),
|
HotwordMetricsLogger.writeServiceInitResultEvent(getDetectorType(),
|
||||||
METRICS_INIT_UNKNOWN_TIMEOUT);
|
METRICS_INIT_UNKNOWN_TIMEOUT, mVoiceInteractionServiceUid);
|
||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
||||||
Slog.w(TAG, "Failed to report initialization status UNKNOWN", e);
|
Slog.w(TAG, "Failed to report initialization status UNKNOWN", e);
|
||||||
HotwordMetricsLogger.writeDetectorEvent(getDetectorType(),
|
HotwordMetricsLogger.writeDetectorEvent(getDetectorType(),
|
||||||
|
|||||||
@@ -64,28 +64,28 @@ public final class HotwordMetricsLogger {
|
|||||||
/**
|
/**
|
||||||
* Logs information related to hotword detection service init result.
|
* Logs information related to hotword detection service init result.
|
||||||
*/
|
*/
|
||||||
public static void writeServiceInitResultEvent(int detectorType, int result) {
|
public static void writeServiceInitResultEvent(int detectorType, int result, int uid) {
|
||||||
int metricsDetectorType = getInitMetricsDetectorType(detectorType);
|
int metricsDetectorType = getInitMetricsDetectorType(detectorType);
|
||||||
FrameworkStatsLog.write(FrameworkStatsLog.HOTWORD_DETECTION_SERVICE_INIT_RESULT_REPORTED,
|
FrameworkStatsLog.write(FrameworkStatsLog.HOTWORD_DETECTION_SERVICE_INIT_RESULT_REPORTED,
|
||||||
metricsDetectorType, result);
|
metricsDetectorType, result, uid);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Logs information related to hotword detection service restarting.
|
* Logs information related to hotword detection service restarting.
|
||||||
*/
|
*/
|
||||||
public static void writeServiceRestartEvent(int detectorType, int reason) {
|
public static void writeServiceRestartEvent(int detectorType, int reason, int uid) {
|
||||||
int metricsDetectorType = getRestartMetricsDetectorType(detectorType);
|
int metricsDetectorType = getRestartMetricsDetectorType(detectorType);
|
||||||
FrameworkStatsLog.write(FrameworkStatsLog.HOTWORD_DETECTION_SERVICE_RESTARTED,
|
FrameworkStatsLog.write(FrameworkStatsLog.HOTWORD_DETECTION_SERVICE_RESTARTED,
|
||||||
metricsDetectorType, reason);
|
metricsDetectorType, reason, uid);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Logs information related to keyphrase trigger.
|
* Logs information related to keyphrase trigger.
|
||||||
*/
|
*/
|
||||||
public static void writeKeyphraseTriggerEvent(int detectorType, int result) {
|
public static void writeKeyphraseTriggerEvent(int detectorType, int result, int uid) {
|
||||||
int metricsDetectorType = getKeyphraseMetricsDetectorType(detectorType);
|
int metricsDetectorType = getKeyphraseMetricsDetectorType(detectorType);
|
||||||
FrameworkStatsLog.write(FrameworkStatsLog.HOTWORD_DETECTOR_KEYPHRASE_TRIGGERED,
|
FrameworkStatsLog.write(FrameworkStatsLog.HOTWORD_DETECTOR_KEYPHRASE_TRIGGERED,
|
||||||
metricsDetectorType, result);
|
metricsDetectorType, result, uid);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -101,12 +101,14 @@ final class SoftwareTrustedHotwordDetectorSession extends HotwordDetectorSession
|
|||||||
synchronized (mLock) {
|
synchronized (mLock) {
|
||||||
HotwordMetricsLogger.writeKeyphraseTriggerEvent(
|
HotwordMetricsLogger.writeKeyphraseTriggerEvent(
|
||||||
HotwordDetector.DETECTOR_TYPE_TRUSTED_HOTWORD_SOFTWARE,
|
HotwordDetector.DETECTOR_TYPE_TRUSTED_HOTWORD_SOFTWARE,
|
||||||
HOTWORD_DETECTOR_KEYPHRASE_TRIGGERED__RESULT__DETECTED);
|
HOTWORD_DETECTOR_KEYPHRASE_TRIGGERED__RESULT__DETECTED,
|
||||||
|
mVoiceInteractionServiceUid);
|
||||||
if (!mPerformingSoftwareHotwordDetection) {
|
if (!mPerformingSoftwareHotwordDetection) {
|
||||||
Slog.i(TAG, "Hotword detection has already completed");
|
Slog.i(TAG, "Hotword detection has already completed");
|
||||||
HotwordMetricsLogger.writeKeyphraseTriggerEvent(
|
HotwordMetricsLogger.writeKeyphraseTriggerEvent(
|
||||||
HotwordDetector.DETECTOR_TYPE_TRUSTED_HOTWORD_SOFTWARE,
|
HotwordDetector.DETECTOR_TYPE_TRUSTED_HOTWORD_SOFTWARE,
|
||||||
METRICS_KEYPHRASE_TRIGGERED_DETECT_UNEXPECTED_CALLBACK);
|
METRICS_KEYPHRASE_TRIGGERED_DETECT_UNEXPECTED_CALLBACK,
|
||||||
|
mVoiceInteractionServiceUid);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
mPerformingSoftwareHotwordDetection = false;
|
mPerformingSoftwareHotwordDetection = false;
|
||||||
@@ -115,7 +117,8 @@ final class SoftwareTrustedHotwordDetectorSession extends HotwordDetectorSession
|
|||||||
} catch (SecurityException e) {
|
} catch (SecurityException e) {
|
||||||
HotwordMetricsLogger.writeKeyphraseTriggerEvent(
|
HotwordMetricsLogger.writeKeyphraseTriggerEvent(
|
||||||
HotwordDetector.DETECTOR_TYPE_TRUSTED_HOTWORD_SOFTWARE,
|
HotwordDetector.DETECTOR_TYPE_TRUSTED_HOTWORD_SOFTWARE,
|
||||||
METRICS_KEYPHRASE_TRIGGERED_DETECT_SECURITY_EXCEPTION);
|
METRICS_KEYPHRASE_TRIGGERED_DETECT_SECURITY_EXCEPTION,
|
||||||
|
mVoiceInteractionServiceUid);
|
||||||
mSoftwareCallback.onError();
|
mSoftwareCallback.onError();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -144,7 +147,8 @@ final class SoftwareTrustedHotwordDetectorSession extends HotwordDetectorSession
|
|||||||
}
|
}
|
||||||
HotwordMetricsLogger.writeKeyphraseTriggerEvent(
|
HotwordMetricsLogger.writeKeyphraseTriggerEvent(
|
||||||
HotwordDetector.DETECTOR_TYPE_TRUSTED_HOTWORD_SOFTWARE,
|
HotwordDetector.DETECTOR_TYPE_TRUSTED_HOTWORD_SOFTWARE,
|
||||||
HOTWORD_DETECTOR_KEYPHRASE_TRIGGERED__RESULT__REJECTED);
|
HOTWORD_DETECTOR_KEYPHRASE_TRIGGERED__RESULT__REJECTED,
|
||||||
|
mVoiceInteractionServiceUid);
|
||||||
// onRejected isn't allowed here, and we are not expecting it.
|
// onRejected isn't allowed here, and we are not expecting it.
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -730,7 +730,7 @@ class VoiceInteractionManagerServiceImpl implements VoiceInteractionSessionConne
|
|||||||
Slog.d(TAG, "createSoundTriggerCallbackLocked");
|
Slog.d(TAG, "createSoundTriggerCallbackLocked");
|
||||||
}
|
}
|
||||||
return new HotwordDetectionConnection.SoundTriggerCallback(callback,
|
return new HotwordDetectionConnection.SoundTriggerCallback(callback,
|
||||||
mHotwordDetectionConnection);
|
mHotwordDetectionConnection, mInfo.getServiceInfo().applicationInfo.uid);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static ServiceInfo getServiceInfoLocked(@NonNull ComponentName componentName,
|
private static ServiceInfo getServiceInfoLocked(@NonNull ComponentName componentName,
|
||||||
|
|||||||
Reference in New Issue
Block a user