Merge "Unhide api for setHotwordDetectionServiceConfig" into sc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
d5dc9e47a4
@@ -10356,6 +10356,7 @@ package android.service.voice {
|
||||
method @RequiresPermission(allOf={android.Manifest.permission.RECORD_AUDIO, android.Manifest.permission.CAPTURE_AUDIO_HOTWORD}) public int setParameter(int, int);
|
||||
method @RequiresPermission(allOf={android.Manifest.permission.RECORD_AUDIO, android.Manifest.permission.CAPTURE_AUDIO_HOTWORD}) public boolean startRecognition(int);
|
||||
method @RequiresPermission(allOf={android.Manifest.permission.RECORD_AUDIO, android.Manifest.permission.CAPTURE_AUDIO_HOTWORD}) public boolean stopRecognition();
|
||||
method public final void updateState(@Nullable android.os.PersistableBundle, @Nullable android.os.SharedMemory);
|
||||
field public static final int AUDIO_CAPABILITY_ECHO_CANCELLATION = 1; // 0x1
|
||||
field public static final int AUDIO_CAPABILITY_NOISE_SUPPRESSION = 2; // 0x2
|
||||
field public static final int MODEL_PARAM_THRESHOLD_FACTOR = 0; // 0x0
|
||||
|
||||
@@ -557,7 +557,7 @@ public class AlwaysOnHotwordDetector {
|
||||
mTargetSdkVersion = targetSdkVersion;
|
||||
mSupportHotwordDetectionService = supportHotwordDetectionService;
|
||||
if (mSupportHotwordDetectionService) {
|
||||
setHotwordDetectionServiceConfig(options, sharedMemory);
|
||||
updateState(options, sharedMemory);
|
||||
}
|
||||
try {
|
||||
Identity identity = new Identity();
|
||||
@@ -573,30 +573,28 @@ public class AlwaysOnHotwordDetector {
|
||||
/**
|
||||
* Set configuration and pass read-only data to hotword detection service.
|
||||
*
|
||||
* @param options Application configuration data provided by the
|
||||
* {@link VoiceInteractionService}. PersistableBundle does not allow any remotable objects or
|
||||
* @param options Application configuration data to provide to the
|
||||
* {@link HotwordDetectionService}. PersistableBundle does not allow any remotable objects or
|
||||
* other contents that can be used to communicate with other processes.
|
||||
* @param sharedMemory The unrestricted data blob provided by the
|
||||
* {@link VoiceInteractionService}. Use this to provide the hotword models data or other
|
||||
* @param sharedMemory The unrestricted data blob to provide to the
|
||||
* {@link HotwordDetectionService}. Use this to provide the hotword models data or other
|
||||
* such data to the trusted process.
|
||||
*
|
||||
* @throws IllegalStateException if it doesn't support hotword detection service.
|
||||
*
|
||||
* @hide
|
||||
* @throws IllegalStateException if this AlwaysOnHotwordDetector wasn't specified to use a
|
||||
* {@link HotwordDetectionService} when it was created.
|
||||
*/
|
||||
public final void setHotwordDetectionServiceConfig(@Nullable PersistableBundle options,
|
||||
public final void updateState(@Nullable PersistableBundle options,
|
||||
@Nullable SharedMemory sharedMemory) {
|
||||
if (DBG) {
|
||||
Slog.d(TAG, "setHotwordDetectionServiceConfig()");
|
||||
Slog.d(TAG, "updateState()");
|
||||
}
|
||||
if (!mSupportHotwordDetectionService) {
|
||||
throw new IllegalStateException(
|
||||
"setHotwordDetectionServiceConfig called, but it doesn't support hotword"
|
||||
+ " detection service");
|
||||
"updateState called, but it doesn't support hotword detection service");
|
||||
}
|
||||
|
||||
try {
|
||||
mModelManagementService.setHotwordDetectionServiceConfig(options, sharedMemory);
|
||||
mModelManagementService.updateState(options, sharedMemory);
|
||||
} catch (RemoteException e) {
|
||||
throw e.rethrowFromSystemServer();
|
||||
}
|
||||
|
||||
@@ -82,10 +82,10 @@ public abstract class HotwordDetectionService extends Service {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setConfig(PersistableBundle options, SharedMemory sharedMemory)
|
||||
public void updateState(PersistableBundle options, SharedMemory sharedMemory)
|
||||
throws RemoteException {
|
||||
if (DBG) {
|
||||
Log.d(TAG, "#setConfig");
|
||||
Log.d(TAG, "#updateState");
|
||||
}
|
||||
mHandler.sendMessage(obtainMessage(HotwordDetectionService::onUpdateState,
|
||||
HotwordDetectionService.this,
|
||||
@@ -139,14 +139,14 @@ public abstract class HotwordDetectionService extends Service {
|
||||
/**
|
||||
* Called when the {@link VoiceInteractionService#createAlwaysOnHotwordDetector(String, Locale,
|
||||
* PersistableBundle, SharedMemory, AlwaysOnHotwordDetector.Callback)} or
|
||||
* {@link AlwaysOnHotwordDetector#setHotwordDetectionServiceConfig(PersistableBundle,
|
||||
* SharedMemory)} requests an update of the hotword detection parameters.
|
||||
* {@link AlwaysOnHotwordDetector#updateState(PersistableBundle, SharedMemory)} requests an
|
||||
* update of the hotword detection parameters.
|
||||
*
|
||||
* @param options Application configuration data provided by the
|
||||
* {@link VoiceInteractionService}. PersistableBundle does not allow any remotable objects or
|
||||
* @param options Application configuration data to provide to the
|
||||
* {@link HotwordDetectionService}. PersistableBundle does not allow any remotable objects or
|
||||
* other contents that can be used to communicate with other processes.
|
||||
* @param sharedMemory The unrestricted data blob provided by the
|
||||
* {@link VoiceInteractionService}. Use this to provide the hotword models data or other
|
||||
* @param sharedMemory The unrestricted data blob to provide to the
|
||||
* {@link HotwordDetectionService}. Use this to provide the hotword models data or other
|
||||
* such data to the trusted process.
|
||||
*
|
||||
* @hide
|
||||
|
||||
@@ -34,5 +34,5 @@ oneway interface IHotwordDetectionService {
|
||||
long timeoutMillis,
|
||||
in IDspHotwordDetectionCallback callback);
|
||||
|
||||
void setConfig(in PersistableBundle options, in SharedMemory sharedMemory);
|
||||
void updateState(in PersistableBundle options, in SharedMemory sharedMemory);
|
||||
}
|
||||
|
||||
@@ -229,15 +229,14 @@ interface IVoiceInteractionManagerService {
|
||||
/**
|
||||
* Set configuration and pass read-only data to hotword detection service.
|
||||
*
|
||||
* @param options Application configuration data provided by the
|
||||
* {@link VoiceInteractionService}. PersistableBundle does not allow any remotable objects or
|
||||
* @param options Application configuration data to provide to the
|
||||
* {@link HotwordDetectionService}. PersistableBundle does not allow any remotable objects or
|
||||
* other contents that can be used to communicate with other processes.
|
||||
* @param sharedMemory The unrestricted data blob provided by the
|
||||
* {@link VoiceInteractionService}. Use this to provide the hotword models data or other
|
||||
* @param sharedMemory The unrestricted data blob to provide to the
|
||||
* {@link HotwordDetectionService}. Use this to provide the hotword models data or other
|
||||
* such data to the trusted process.
|
||||
*/
|
||||
void setHotwordDetectionServiceConfig(
|
||||
in PersistableBundle options, in SharedMemory sharedMemory);
|
||||
void updateState(in PersistableBundle options, in SharedMemory sharedMemory);
|
||||
|
||||
/**
|
||||
* Requests to shutdown hotword detection service.
|
||||
|
||||
@@ -96,10 +96,10 @@ final class HotwordDetectionConnection {
|
||||
mBound = connected;
|
||||
if (connected) {
|
||||
try {
|
||||
service.setConfig(options, sharedMemory);
|
||||
service.updateState(options, sharedMemory);
|
||||
} catch (RemoteException e) {
|
||||
// TODO: (b/181842909) Report an error to voice interactor
|
||||
Slog.w(TAG, "Failed to setConfig for HotwordDetectionService", e);
|
||||
Slog.w(TAG, "Failed to updateState for HotwordDetectionService", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -129,9 +129,9 @@ final class HotwordDetectionConnection {
|
||||
}
|
||||
}
|
||||
|
||||
void setConfigLocked(PersistableBundle options, SharedMemory sharedMemory) {
|
||||
void updateStateLocked(PersistableBundle options, SharedMemory sharedMemory) {
|
||||
mRemoteHotwordDetectionService.run(
|
||||
service -> service.setConfig(options, sharedMemory));
|
||||
service -> service.updateState(options, sharedMemory));
|
||||
}
|
||||
|
||||
private void detectFromDspSource(SoundTrigger.KeyphraseRecognitionEvent recognitionEvent,
|
||||
|
||||
@@ -984,21 +984,19 @@ public class VoiceInteractionManagerService extends SystemService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setHotwordDetectionServiceConfig(@Nullable PersistableBundle options,
|
||||
public void updateState(@Nullable PersistableBundle options,
|
||||
@Nullable SharedMemory sharedMemory) {
|
||||
enforceCallingPermission(Manifest.permission.MANAGE_HOTWORD_DETECTION);
|
||||
synchronized (this) {
|
||||
enforceIsCurrentVoiceInteractionService();
|
||||
|
||||
if (mImpl == null) {
|
||||
Slog.w(TAG,
|
||||
"setHotwordDetectionServiceConfig without running voice"
|
||||
+ " interaction service");
|
||||
Slog.w(TAG, "updateState without running voice interaction service");
|
||||
return;
|
||||
}
|
||||
final long caller = Binder.clearCallingIdentity();
|
||||
try {
|
||||
mImpl.setHotwordDetectionServiceConfigLocked(options, sharedMemory);
|
||||
mImpl.updateStateLocked(options, sharedMemory);
|
||||
} finally {
|
||||
Binder.restoreCallingIdentity(caller);
|
||||
}
|
||||
|
||||
@@ -401,10 +401,10 @@ class VoiceInteractionManagerServiceImpl implements VoiceInteractionSessionConne
|
||||
return mInfo.getSupportsLocalInteraction();
|
||||
}
|
||||
|
||||
public void setHotwordDetectionServiceConfigLocked(@Nullable PersistableBundle options,
|
||||
public void updateStateLocked(@Nullable PersistableBundle options,
|
||||
@Nullable SharedMemory sharedMemory) {
|
||||
if (DEBUG) {
|
||||
Slog.d(TAG, "setHotwordDetectionServiceConfigLocked");
|
||||
Slog.d(TAG, "updateStateLocked");
|
||||
}
|
||||
if (mHotwordDetectionComponentName == null) {
|
||||
Slog.w(TAG, "Hotword detection service name not found");
|
||||
@@ -426,7 +426,7 @@ class VoiceInteractionManagerServiceImpl implements VoiceInteractionSessionConne
|
||||
mHotwordDetectionComponentName, mUser, /* bindInstantServiceAllowed= */ false,
|
||||
options, sharedMemory);
|
||||
} else {
|
||||
mHotwordDetectionConnection.setConfigLocked(options, sharedMemory);
|
||||
mHotwordDetectionConnection.updateStateLocked(options, sharedMemory);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user