Unhide api for setHotwordDetectionServiceConfig

We also changed API from setHotwordDetectionServiceConfig
to updateState.

Bug: 182951186
CTS-Coverage-Bug: 183425641
Test: Test: atest CtsVoiceInteractionTestCases
Test: atest CtsVoiceInteractionTestCases --instant
Change-Id: I29ed0736f9502d3ac5a29ea26a8386bce7113e54
This commit is contained in:
lpeter
2021-03-23 18:32:28 +08:00
parent 98ffa1355d
commit 247d69aa7e
8 changed files with 36 additions and 40 deletions

View File

@@ -10331,6 +10331,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

View File

@@ -508,7 +508,7 @@ public class AlwaysOnHotwordDetector {
mTargetSdkVersion = targetSdkVersion;
mSupportHotwordDetectionService = supportHotwordDetectionService;
if (mSupportHotwordDetectionService) {
setHotwordDetectionServiceConfig(options, sharedMemory);
updateState(options, sharedMemory);
}
try {
Identity identity = new Identity();
@@ -524,30 +524,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();
}

View File

@@ -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

View File

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

View File

@@ -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.

View File

@@ -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,

View File

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

View File

@@ -402,10 +402,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");
@@ -427,7 +427,7 @@ class VoiceInteractionManagerServiceImpl implements VoiceInteractionSessionConne
mHotwordDetectionComponentName, mUser, /* bindInstantServiceAllowed= */ false,
options, sharedMemory);
} else {
mHotwordDetectionConnection.setConfigLocked(options, sharedMemory);
mHotwordDetectionConnection.updateStateLocked(options, sharedMemory);
}
}