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

Commit defed6c1 authored by Hai Zhang's avatar Hai Zhang
Browse files

Retain ROLE and USER_SET for app-op permissions in UPS.

This is a follow-up to b/282997218.

Fixes: 283149512
Test: PermissionFlagsTest#nonRuntimePermissionFlagsPreservedAfterReinstall
Change-Id: I02af94874d3e5aafaabe2099fd3983aefd66ac4e
parent 70e8d8e8
Loading
Loading
Loading
Loading
+11 −1
Original line number Diff line number Diff line
@@ -749,12 +749,17 @@ class AppIdPermissionPolicy : SchemePolicy() {
                // If this is an existing, non-system package,
                // then we can't add any new permissions to it.
                // Except if this is a permission that was added to the platform
                val newFlags = if (!wasRevoked || isRequestedByInstalledPackage ||
                var newFlags = if (!wasRevoked || isRequestedByInstalledPackage ||
                    isRequestedBySystemPackage || isCompatibilityPermission) {
                    PermissionFlags.INSTALL_GRANTED
                } else {
                    PermissionFlags.INSTALL_REVOKED
                }
                if (permission.isAppOp) {
                    newFlags = newFlags or (
                        oldFlags and (PermissionFlags.ROLE or PermissionFlags.USER_SET)
                    )
                }
                setPermissionFlags(appId, userId, permissionName, newFlags)
            }
        } else if (permission.isSignature || permission.isInternal) {
@@ -784,6 +789,11 @@ class AppIdPermissionPolicy : SchemePolicy() {
                    0
                }
            }
            if (permission.isAppOp) {
                newFlags = newFlags or (
                    oldFlags and (PermissionFlags.ROLE or PermissionFlags.USER_SET)
                )
            }
            // Different from the old implementation, which seemingly allows granting an
            // unallowlisted privileged permission via development or role but revokes it upon next
            // reconciliation, we now properly allows that because the privileged protection flag