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

Commit a4b3863c authored by Atneya Nair's avatar Atneya Nair
Browse files

Reset identity context in STService

Middleware service uses binder identity to validate permissions.

For now, clear the binder identity before calling downwards.

In the future, remove this behavior in middleware service.

Test: AGSA starts recognition successfully
Bug: 269765333
Change-Id: Ie33ffbbb6d2aa84d3da9ec6f5f8af0ab3a12af75
parent 6da7746a
Loading
Loading
Loading
Loading
+9 −6
Original line number Diff line number Diff line
@@ -1647,13 +1647,16 @@ public class SoundTriggerService extends SystemService {

        @Override
        public List<ModuleProperties> listModuleProperties(Identity originatorIdentity) {
            Identity identity = new Identity();
            identity.packageName = ActivityThread.currentOpPackageName();
            ArrayList<ModuleProperties> moduleList = new ArrayList<>();
            // Overwrite with our own identity to fix permission issues.
            // VIMService always does its own validation, so this is fine.
            // TODO(b/269765333)
            SoundTrigger.listModulesAsOriginator(moduleList, identity);
            try (SafeCloseable ignored = PermissionUtil.establishIdentityDirect(
                    originatorIdentity)) {
                Identity middlemanIdentity = new Identity();
                middlemanIdentity.uid = Binder.getCallingUid();
                middlemanIdentity.pid = Binder.getCallingPid();
                middlemanIdentity.packageName = ActivityThread.currentOpPackageName();
                SoundTrigger.listModulesAsMiddleman(moduleList, middlemanIdentity,
                                                originatorIdentity);
            }
            return moduleList;
        }