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

Commit ecb07b0c authored by Nate Myren's avatar Nate Myren
Browse files

More robust null check in isTrustedVoiceServiceProxy

Ensure that the component name unflattening does not result in a null
value before getting the package name.

Fixes: 172854122
Test: Manual
Change-Id: Icbcacc87308bdb87fd45e055240fd72458e478f5
parent 6465c1ea
Loading
Loading
Loading
Loading
+7 −5
Original line number Diff line number Diff line
@@ -7618,16 +7618,18 @@ public class AppOpsManager {
                mContext.getContentResolver(), Settings.Secure.VOICE_INTERACTION_SERVICE);

        final String voiceRecognitionServicePackageName =
                voiceRecognitionComponent != null ? ComponentName.unflattenFromString(
                        voiceRecognitionComponent).getPackageName() : "";
                getComponentPackageNameFromString(voiceRecognitionComponent);
        final String voiceInteractionServicePackageName =
                voiceInteractionComponent != null ? ComponentName.unflattenFromString(
                        voiceInteractionComponent).getPackageName() : "";

                getComponentPackageNameFromString(voiceInteractionComponent);
        return Objects.equals(packageName, voiceRecognitionServicePackageName) && Objects.equals(
                voiceRecognitionServicePackageName, voiceInteractionServicePackageName);
    }

    private String getComponentPackageNameFromString(String from) {
        ComponentName componentName = from != null ? ComponentName.unflattenFromString(from) : null;
        return componentName != null ? componentName.getPackageName() : "";
    }

    /**
     * Do a quick check for whether an application might be able to perform an operation.
     * This is <em>not</em> a security check; you must use {@link #noteOp(String, int, String,
+7 −4
Original line number Diff line number Diff line
@@ -3026,15 +3026,18 @@ public class AppOpsService extends IAppOpsService.Stub {
                mContext.getContentResolver(), Settings.Secure.VOICE_INTERACTION_SERVICE);

        final String voiceRecognitionServicePackageName =
                voiceRecognitionComponent != null ? ComponentName.unflattenFromString(
                        voiceRecognitionComponent).getPackageName() : "";
                getComponentPackageNameFromString(voiceRecognitionComponent);
        final String voiceInteractionServicePackageName =
                voiceInteractionComponent != null ? ComponentName.unflattenFromString(
                        voiceInteractionComponent).getPackageName() : "";
                getComponentPackageNameFromString(voiceInteractionComponent);
        return Objects.equals(packageName, voiceRecognitionServicePackageName) && Objects.equals(
                voiceRecognitionServicePackageName, voiceInteractionServicePackageName);
    }

    private String getComponentPackageNameFromString(String from) {
        ComponentName componentName = from != null ? ComponentName.unflattenFromString(from) : null;
        return componentName != null ? componentName.getPackageName() : "";
    }

    @Override
    public int noteProxyOperation(int code, int proxiedUid, String proxiedPackageName,
            String proxiedAttributionTag, int proxyUid, String proxyPackageName,