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

Commit 6a2480d9 authored by Hai Zhang's avatar Hai Zhang
Browse files

Fix performance issue from refreshing runtime permission state before write.

- The writeRuntimePermissionsForUserLPr() call in
  installPackageFromSystemLIF() doesn't seem necessary at all.
- Call writeLegacyPermissionStateTEMP() only once for all users in
  writePermissionSettings().

Fixes: 172297495
Test: presubmit
Change-Id: I459bc853cd4f72b70fad84bae9fb189dd974cfbf
parent fd4623c3
Loading
Loading
Loading
Loading
+2 −14
Original line number Diff line number Diff line
@@ -19605,8 +19605,6 @@ public class PackageManagerService extends IPackageManager.Stub
                    if (installed) {
                        ps.setUninstallReason(UNINSTALL_REASON_UNKNOWN, userId);
                    }
                    writeRuntimePermissionsForUserLPrTEMP(userId, false);
                }
                // Regardless of writeSettings we need to ensure that this restriction
                // state propagation is persisted
@@ -25751,8 +25749,9 @@ public class PackageManagerService extends IPackageManager.Stub
        @Override
        public void writePermissionSettings(int[] userIds, boolean async) {
            synchronized (mLock) {
                mPermissionManager.writeLegacyPermissionStateTEMP();
                for (int userId : userIds) {
                    writeRuntimePermissionsForUserLPrTEMP(userId, !async);
                    mSettings.writeRuntimePermissionsForUserLPr(userId, !async);
                }
            }
        }
@@ -26401,17 +26400,6 @@ 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) {