summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorJoanne Chung <joannechung@google.com>2022-03-18 10:02:36 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2022-03-18 10:02:36 +0000
commit0f608efde92f423c080272384c80f94d681e6018 (patch)
treee84ee8abed9ca26b40c0a65f901885c3a19af9ab /core
parent44ac2e0c01a5e179bea491e00718262f38549169 (diff)
parent28faf49c0b893fb54b9d5166b4c4b5e193c44a8c (diff)
Merge changes from topic "presubmit-am-08bbcb587d4e47b6afcc900c23899344" into sc-v2-dev
* changes: Add hotword detection metrics. Add HotwordMetricsLogger for statistics logging.
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.