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
This commit is contained in:
Hai Zhang
2020-10-30 17:10:25 -07:00
parent 0295b66bee
commit fea3a1709f

View File

@@ -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) {