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

Commit 254b3fe3 authored by Suprabh Shukla's avatar Suprabh Shukla
Browse files

Do not reset per package appop modes for permissions

Settings currently sets modes per package for some special access
permissions like SYSTEM_ALERT_WINDOW and REQUEST_INSTALL_PACKAGES. They
would get reset whenever this is called.

Test: atest --test-mapping
Manually, check that special access permissions do no reset after
installing a package or reboot. Or, use shell commands, e.g.:
1. adb shell appops set com.android.chrome REQUEST_INSTALL_PACAKGES \
allow
2. adb reboot
3. Verify that
adb shell appops get com.android.chrome REQUEST_INSTALL_PACKAGES
returns allow.

Bug: 123581307
Change-Id: Ia839f7acd1b44b279552828427a17c6eb239c002
parent 7ae19ece
Loading
Loading
Loading
Loading
+0 −12
Original line number Diff line number Diff line
@@ -1480,18 +1480,6 @@ public class PermissionManagerService {
            for (int i = 0; i < numPerms; i++) {
                String permission = pkg.requestedPermissions.get(i);

                int op = permissionToOpCode(permission);
                if (op == OP_NONE) {
                    continue;
                }

                // Runtime permissions are per uid, not per package, hence per package app-op
                // modes should never have been set. It is possible to set them via the shell
                // though. Revert such settings during boot to get the device back into a good
                // state.
                LocalServices.getService(AppOpsManagerInternal.class).setAllPkgModesToDefault(
                        op, getUid(userId, getAppId(pkg.applicationInfo.uid)));

                // For pre-M apps the runtime permission do not store the state
                if (pkg.applicationInfo.targetSdkVersion < Build.VERSION_CODES.M) {
                    continue;