Prevent ST clients from auto-attach to fake HAL
The current behavior is to pick the first ST module. Right now, on devices with no HAL, clients use the fact that the module fails to attach to detect lack of DSP presence. We must retain this behavior when we add a second ST module for testing, which is available on all devices. Only select HALs not implemented by android for default construction. Test: NowPlaying/HeyG attach verification Test: When fake STHAL is added, NowPlaying/HeyG do NOT attach to it Test: When real STHAL disabled, same as above Test: getDspModuleProperties/getModuleProperties returns null on no real HAL Bug: 271345481 Change-Id: Ie739eef56c4dedc2f7a79ec49f35793c95ca1658
This commit is contained in:
@@ -78,6 +78,11 @@ public class SoundTrigger {
|
||||
private SoundTrigger() {
|
||||
}
|
||||
|
||||
/**
|
||||
* @hide
|
||||
*/
|
||||
public static final String FAKE_HAL_ARCH = "injection";
|
||||
|
||||
/**
|
||||
* Status code used when the operation succeeded
|
||||
*/
|
||||
|
||||
@@ -805,11 +805,13 @@ public class AlwaysOnHotwordDetector extends AbstractDetector {
|
||||
Identity identity = new Identity();
|
||||
identity.packageName = ActivityThread.currentOpPackageName();
|
||||
if (moduleProperties == null) {
|
||||
List<SoundTrigger.ModuleProperties> modulePropList =
|
||||
mModelManagementService.listModuleProperties(identity);
|
||||
if (modulePropList.size() > 0) {
|
||||
moduleProperties = modulePropList.get(0);
|
||||
}
|
||||
moduleProperties = mModelManagementService
|
||||
.listModuleProperties(identity)
|
||||
.stream()
|
||||
.filter(prop -> !prop.getSupportedModelArch()
|
||||
.equals(SoundTrigger.FAKE_HAL_ARCH))
|
||||
.findFirst()
|
||||
.orElse(null);
|
||||
// (@atneya) intentionally let a null moduleProperties through until
|
||||
// all CTS tests are fixed
|
||||
}
|
||||
|
||||
@@ -94,12 +94,17 @@ public final class SoundTriggerManager {
|
||||
originatorIdentity.packageName = ActivityThread.currentOpPackageName();
|
||||
|
||||
try (SafeCloseable ignored = ClearCallingIdentityContext.create()) {
|
||||
List<ModuleProperties> modulePropertiesList = soundTriggerService
|
||||
.listModuleProperties(originatorIdentity);
|
||||
if (!modulePropertiesList.isEmpty()) {
|
||||
ModuleProperties moduleProperties = soundTriggerService
|
||||
.listModuleProperties(originatorIdentity)
|
||||
.stream()
|
||||
.filter(prop -> !prop.getSupportedModelArch()
|
||||
.equals(SoundTrigger.FAKE_HAL_ARCH))
|
||||
.findFirst()
|
||||
.orElse(null);
|
||||
if (moduleProperties != null) {
|
||||
mSoundTriggerSession = soundTriggerService.attachAsOriginator(
|
||||
originatorIdentity,
|
||||
modulePropertiesList.get(0),
|
||||
moduleProperties,
|
||||
mBinderToken);
|
||||
} else {
|
||||
mSoundTriggerSession = null;
|
||||
|
||||
Reference in New Issue
Block a user