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

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

Refresh legacy state before writing to runtime permission persistence.

This was done for writing all the package settings, but not when
writing runtime permissions only, so we need to do the same thing
before we eventually migrate to new persistence.

Test: manual
Fixes: 171755668
Change-Id: I05666c62830b0cc766ed7ea62af4ca65102a8951
parent 0295b66b
Loading
Loading
Loading
Loading
+13 −2
Original line number Diff line number Diff line
@@ -19577,7 +19577,7 @@ public class PackageManagerService extends IPackageManager.Stub
                        ps.setUninstallReason(UNINSTALL_REASON_UNKNOWN, userId);
                    }
                    mSettings.writeRuntimePermissionsForUserLPr(userId, false);
                    writeRuntimePermissionsForUserLPrTEMP(userId, false);
                }
                // Regardless of writeSettings we need to ensure that this restriction
                // state propagation is persisted
@@ -25723,7 +25723,7 @@ public class PackageManagerService extends IPackageManager.Stub
        public void writePermissionSettings(int[] userIds, boolean async) {
            synchronized (mLock) {
                for (int userId : userIds) {
                    mSettings.writeRuntimePermissionsForUserLPr(userId, !async);
                    writeRuntimePermissionsForUserLPrTEMP(userId, !async);
                }
            }
        }
@@ -26371,6 +26371,17 @@ public class PackageManagerService extends IPackageManager.Stub
        mSettings.writeLPr();
    }
    /**
     * Temporary method that wraps mSettings.writeRuntimePermissionsForUserLPr() and calls
     * mPermissionManager.writeLegacyPermissionStateTEMP() beforehand.
     *
     * TODO(zhanghai): This should be removed once we finish migration of permission storage.
     */
    private void writeRuntimePermissionsForUserLPrTEMP(@UserIdInt int userId, boolean async) {
        mPermissionManager.writeLegacyPermissionStateTEMP();
        mSettings.writeRuntimePermissionsForUserLPr(userId, async);
    }
    @Override
    public IBinder getHoldLockToken() {
        if (!Build.IS_DEBUGGABLE) {