Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 4f663d81 authored by Atneya Nair's avatar Atneya Nair Committed by Automerger Merge Worker
Browse files

Merge "Prevent ST clients from auto-attach to fake HAL" into udc-dev am: 9a80b65e

parents 0f517a89 9a80b65e
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -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
     */
+7 −5
Original line number Diff line number Diff line
@@ -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
            }
+9 −4
Original line number Diff line number Diff line
@@ -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;