summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorJoanne Chung <joannechung@google.com>2022-03-15 20:59:51 +0800
committerJoanne Chung <joannechung@google.com>2022-03-17 19:36:08 +0800
commit28faf49c0b893fb54b9d5166b4c4b5e193c44a8c (patch)
tree68c269edbdd186f6e42118a452a3e0a32d0e8a55 /core
parentb8c2da258756b6d87d7ce7e9902cd39d60c18314 (diff)
Add hotword detection metrics.
Bug: 207717787 Test: build & boot pass. Test: manual. Both trust and no-trust still work. Test: manual. In nornal case, log with expected values, see bug for details. Log expected value for some error cases (not all are tested) by local changes. Android Metrics Design Review : eldar/276723226 Merged-in: Iaa778616eca4cfad83a94297d9cd6116bb9577e7 Change-Id: I98fde2467e09564569cdbf10b20e9defece65cbf (cherry picked from commit e4b76fc200814bf4a12987ef448db34240b83c49)
Diffstat (limited to 'core')
-rw-r--r--core/java/android/service/voice/AbstractHotwordDetector.java12
-rw-r--r--core/java/android/service/voice/AlwaysOnHotwordDetector.java7
-rw-r--r--core/java/android/service/voice/HotwordDetector.java37
-rw-r--r--core/java/android/service/voice/SoftwareHotwordDetector.java5
-rw-r--r--core/java/com/android/internal/app/IVoiceInteractionManagerService.aidl4
5 files changed, 56 insertions, 9 deletions
diff --git a/core/java/android/service/voice/AbstractHotwordDetector.java b/core/java/android/service/voice/AbstractHotwordDetector.java
index dbe108974684..192260791a8b 100644
--- a/core/java/android/service/voice/AbstractHotwordDetector.java
+++ b/core/java/android/service/voice/AbstractHotwordDetector.java
@@ -44,14 +44,17 @@ abstract class AbstractHotwordDetector implements HotwordDetector {
private final IVoiceInteractionManagerService mManagerService;
private final Handler mHandler;
private final HotwordDetector.Callback mCallback;
+ private final int mDetectorType;
AbstractHotwordDetector(
IVoiceInteractionManagerService managerService,
- HotwordDetector.Callback callback) {
+ HotwordDetector.Callback callback,
+ int detectorType) {
mManagerService = managerService;
// TODO: this needs to be supplied from above
mHandler = new Handler(Looper.getMainLooper());
mCallback = callback;
+ mDetectorType = detectorType;
}
/**
@@ -104,19 +107,20 @@ abstract class AbstractHotwordDetector implements HotwordDetector {
Slog.d(TAG, "updateState()");
}
synchronized (mLock) {
- updateStateLocked(options, sharedMemory, null /* callback */);
+ updateStateLocked(options, sharedMemory, null /* callback */, mDetectorType);
}
}
protected void updateStateLocked(@Nullable PersistableBundle options,
- @Nullable SharedMemory sharedMemory, IHotwordRecognitionStatusCallback callback) {
+ @Nullable SharedMemory sharedMemory, IHotwordRecognitionStatusCallback callback,
+ int detectorType) {
if (DEBUG) {
Slog.d(TAG, "updateStateLocked()");
}
Identity identity = new Identity();
identity.packageName = ActivityThread.currentOpPackageName();
try {
- mManagerService.updateState(identity, options, sharedMemory, callback);
+ mManagerService.updateState(identity, options, sharedMemory, callback, detectorType);
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
diff --git a/core/java/android/service/voice/AlwaysOnHotwordDetector.java b/core/java/android/service/voice/AlwaysOnHotwordDetector.java
index face870ca1b4..c9daf52b5685 100644
--- a/core/java/android/service/voice/AlwaysOnHotwordDetector.java
+++ b/core/java/android/service/voice/AlwaysOnHotwordDetector.java
@@ -578,7 +578,9 @@ public class AlwaysOnHotwordDetector extends AbstractHotwordDetector {
IVoiceInteractionManagerService modelManagementService, int targetSdkVersion,
boolean supportHotwordDetectionService, @Nullable PersistableBundle options,
@Nullable SharedMemory sharedMemory) {
- super(modelManagementService, callback);
+ super(modelManagementService, callback,
+ supportHotwordDetectionService ? DETECTOR_TYPE_TRUSTED_HOTWORD_DSP
+ : DETECTOR_TYPE_NORMAL);
mHandler = new MyHandler();
mText = text;
@@ -590,7 +592,8 @@ public class AlwaysOnHotwordDetector extends AbstractHotwordDetector {
mTargetSdkVersion = targetSdkVersion;
mSupportHotwordDetectionService = supportHotwordDetectionService;
if (mSupportHotwordDetectionService) {
- updateStateLocked(options, sharedMemory, mInternalCallback);
+ updateStateLocked(options, sharedMemory, mInternalCallback,
+ DETECTOR_TYPE_TRUSTED_HOTWORD_DSP);
}
try {
Identity identity = new Identity();
diff --git a/core/java/android/service/voice/HotwordDetector.java b/core/java/android/service/voice/HotwordDetector.java
index e2478195bdde..969ec22beb97 100644
--- a/core/java/android/service/voice/HotwordDetector.java
+++ b/core/java/android/service/voice/HotwordDetector.java
@@ -37,6 +37,27 @@ import android.os.SharedMemory;
public interface HotwordDetector {
/**
+ * Indicates that it is a non-trusted hotword detector.
+ *
+ * @hide
+ */
+ int DETECTOR_TYPE_NORMAL = 0;
+
+ /**
+ * Indicates that it is a DSP trusted hotword detector.
+ *
+ * @hide
+ */
+ int DETECTOR_TYPE_TRUSTED_HOTWORD_DSP = 1;
+
+ /**
+ * Indicates that it is a software trusted hotword detector.
+ *
+ * @hide
+ */
+ int DETECTOR_TYPE_TRUSTED_HOTWORD_SOFTWARE = 2;
+
+ /**
* Starts hotword recognition.
* <p>
* On calling this, the system streams audio from the device microphone to this application's
@@ -98,6 +119,22 @@ public interface HotwordDetector {
void updateState(@Nullable PersistableBundle options, @Nullable SharedMemory sharedMemory);
/**
+ * @hide
+ */
+ static String detectorTypeToString(int detectorType) {
+ switch (detectorType) {
+ case DETECTOR_TYPE_NORMAL:
+ return "normal";
+ case DETECTOR_TYPE_TRUSTED_HOTWORD_DSP:
+ return "trusted_hotword_dsp";
+ case DETECTOR_TYPE_TRUSTED_HOTWORD_SOFTWARE:
+ return "trusted_hotword_software";
+ default:
+ return Integer.toString(detectorType);
+ }
+ }
+
+ /**
* The callback to notify of detection events.
*/
interface Callback {
diff --git a/core/java/android/service/voice/SoftwareHotwordDetector.java b/core/java/android/service/voice/SoftwareHotwordDetector.java
index f7a3415259fd..512a654adbab 100644
--- a/core/java/android/service/voice/SoftwareHotwordDetector.java
+++ b/core/java/android/service/voice/SoftwareHotwordDetector.java
@@ -60,14 +60,15 @@ class SoftwareHotwordDetector extends AbstractHotwordDetector {
PersistableBundle options,
SharedMemory sharedMemory,
HotwordDetector.Callback callback) {
- super(managerService, callback);
+ super(managerService, callback, DETECTOR_TYPE_TRUSTED_HOTWORD_SOFTWARE);
mManagerService = managerService;
mAudioFormat = audioFormat;
mCallback = callback;
mHandler = new Handler(Looper.getMainLooper());
updateStateLocked(options, sharedMemory,
- new InitializationStateListener(mHandler, mCallback));
+ new InitializationStateListener(mHandler, mCallback),
+ DETECTOR_TYPE_TRUSTED_HOTWORD_SOFTWARE);
}
@RequiresPermission(RECORD_AUDIO)
diff --git a/core/java/com/android/internal/app/IVoiceInteractionManagerService.aidl b/core/java/com/android/internal/app/IVoiceInteractionManagerService.aidl
index 998526209c72..61c9128e499e 100644
--- a/core/java/com/android/internal/app/IVoiceInteractionManagerService.aidl
+++ b/core/java/com/android/internal/app/IVoiceInteractionManagerService.aidl
@@ -242,12 +242,14 @@ interface IVoiceInteractionManagerService {
* {@link HotwordDetectionService}. Use this to provide the hotword models data or other
* such data to the trusted process.
* @param callback Use this to report {@link HotwordDetectionService} status.
+ * @param detectorType Indicate which detector is used.
*/
void updateState(
in Identity originatorIdentity,
in PersistableBundle options,
in SharedMemory sharedMemory,
- in IHotwordRecognitionStatusCallback callback);
+ in IHotwordRecognitionStatusCallback callback,
+ int detectorType);
/**
* Requests to shutdown hotword detection service.