Merge "Throw if AOHD is inited without a underlying DSP" into udc-dev
This commit is contained in:
@@ -30,6 +30,8 @@ import android.annotation.SystemApi;
|
||||
import android.annotation.TestApi;
|
||||
import android.app.ActivityThread;
|
||||
import android.app.compat.CompatChanges;
|
||||
import android.compat.annotation.ChangeId;
|
||||
import android.compat.annotation.EnabledSince;
|
||||
import android.compat.annotation.UnsupportedAppUsage;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
@@ -257,6 +259,16 @@ public class AlwaysOnHotwordDetector extends AbstractDetector {
|
||||
})
|
||||
public @interface ModelParams {}
|
||||
|
||||
/**
|
||||
* Gates returning {@code IllegalStateException} in {@link #initialize(
|
||||
* PersistableBundle, SharedMemory, SoundTrigger.ModuleProperties)} when no DSP module
|
||||
* is available. If the change is not enabled, the existing behavior of not throwing an
|
||||
* exception and delivering {@link STATE_HARDWARE_UNAVAILABLE} is retained.
|
||||
*/
|
||||
@ChangeId
|
||||
@EnabledSince(targetSdkVersion = Build.VERSION_CODES.UPSIDE_DOWN_CAKE)
|
||||
static final long THROW_ON_INITIALIZE_IF_NO_DSP = 269165460L;
|
||||
|
||||
/**
|
||||
* Controls the sensitivity threshold adjustment factor for a given model.
|
||||
* Negative value corresponds to less sensitive model (high threshold) and
|
||||
@@ -870,8 +882,10 @@ public class AlwaysOnHotwordDetector extends AbstractDetector {
|
||||
.equals(SoundTrigger.FAKE_HAL_ARCH))
|
||||
.findFirst()
|
||||
.orElse(null);
|
||||
// (@atneya) intentionally let a null moduleProperties through until
|
||||
// all CTS tests are fixed
|
||||
if (CompatChanges.isChangeEnabled(THROW_ON_INITIALIZE_IF_NO_DSP) &&
|
||||
moduleProperties == null) {
|
||||
throw new IllegalStateException("No DSP module available to attach to");
|
||||
}
|
||||
}
|
||||
mSoundTriggerSession =
|
||||
mModelManagementService.createSoundTriggerSessionAsOriginator(
|
||||
@@ -1753,17 +1767,19 @@ public class AlwaysOnHotwordDetector extends AbstractDetector {
|
||||
}
|
||||
}
|
||||
|
||||
ModuleProperties dspModuleProperties;
|
||||
try {
|
||||
dspModuleProperties =
|
||||
mSoundTriggerSession.getDspModuleProperties();
|
||||
} catch (RemoteException e) {
|
||||
throw e.rethrowFromSystemServer();
|
||||
}
|
||||
if (!CompatChanges.isChangeEnabled(THROW_ON_INITIALIZE_IF_NO_DSP)) {
|
||||
ModuleProperties dspModuleProperties;
|
||||
try {
|
||||
dspModuleProperties =
|
||||
mSoundTriggerSession.getDspModuleProperties();
|
||||
} catch (RemoteException e) {
|
||||
throw e.rethrowFromSystemServer();
|
||||
}
|
||||
|
||||
// No DSP available
|
||||
if (dspModuleProperties == null) {
|
||||
return STATE_HARDWARE_UNAVAILABLE;
|
||||
// No DSP available
|
||||
if (dspModuleProperties == null) {
|
||||
return STATE_HARDWARE_UNAVAILABLE;
|
||||
}
|
||||
}
|
||||
|
||||
return STATE_NOT_READY;
|
||||
|
||||
@@ -463,6 +463,10 @@ public class VoiceInteractionService extends Service {
|
||||
* @param callback The callback to notify of detection events.
|
||||
* @return An always-on hotword detector for the given keyphrase and locale.
|
||||
*
|
||||
* @throws SecurityException if the caller does not hold required permissions
|
||||
* @throws IllegalStateException if there is no DSP hardware support when a caller has a
|
||||
* target SDK of API level 34 or above.
|
||||
*
|
||||
* @deprecated Use {@link #createAlwaysOnHotwordDetector(String, Locale, Executor,
|
||||
* AlwaysOnHotwordDetector.Callback)} instead.
|
||||
* @hide
|
||||
@@ -500,6 +504,10 @@ public class VoiceInteractionService extends Service {
|
||||
* @param callback The callback to notify of detection events.
|
||||
* @return An always-on hotword detector for the given keyphrase and locale.
|
||||
*
|
||||
* @throws SecurityException if the caller does not hold required permissions
|
||||
* @throws IllegalStateException if there is no DSP hardware support when a caller has a
|
||||
* target SDK of API level 34 or above.
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
@SystemApi
|
||||
@@ -581,6 +589,11 @@ public class VoiceInteractionService extends Service {
|
||||
* @param callback The callback to notify of detection events.
|
||||
* @return An always-on hotword detector for the given keyphrase and locale.
|
||||
*
|
||||
* @throws SecurityException if the caller does not hold required permissions
|
||||
* @throws IllegalStateException if the hotword detection service is not set, isolated process
|
||||
* is not set, or there is no DSP hardware support when a caller has a target SDK of API
|
||||
* level 34 or above.
|
||||
*
|
||||
* @deprecated Use {@link #createAlwaysOnHotwordDetector(String, Locale, PersistableBundle,
|
||||
* SharedMemory, Executor, AlwaysOnHotwordDetector.Callback)} instead.
|
||||
* @hide
|
||||
@@ -631,6 +644,11 @@ public class VoiceInteractionService extends Service {
|
||||
* @param callback The callback to notify of detection events.
|
||||
* @return An always-on hotword detector for the given keyphrase and locale.
|
||||
*
|
||||
* @throws SecurityException if the caller does not hold required permissions
|
||||
* @throws IllegalStateException if the hotword detection service is not set, isolated process
|
||||
* is not set, or there is no DSP hardware support when a caller has a target SDK of API level
|
||||
* 34 or above.
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
@SystemApi
|
||||
|
||||
Reference in New Issue
Block a user