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

Commit 40683b71 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Automerger Merge Worker
Browse files

Merge "Re-grant install permissions on build fingerprint change." into sc-dev am: 54c39c71

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/14064891

Change-Id: Ia2bfcc509dea31783575b0a6551e4b35431f482d
parents 933e49fd 54c39c71
Loading
Loading
Loading
Loading
+11 −11
Original line number Diff line number Diff line
@@ -6880,19 +6880,18 @@ public class PackageManagerService extends IPackageManager.Stub
                    + " seconds");
            mPermissionManager.readLegacyPermissionStateTEMP();
            // If the platform SDK has changed since the last time we booted,
            // If the build fingerprint has changed since the last time we booted,
            // we need to re-grant app permission to catch any new ones that
            // appear.  This is really a hack, and means that apps can in some
            // cases get permissions that the user didn't initially explicitly
            // allow...  it would be nice to have some better way to handle
            // this situation.
            final boolean sdkUpdated = (ver.sdkVersion != mSdkVersion);
            if (sdkUpdated) {
                Slog.i(TAG, "Platform changed from " + ver.sdkVersion + " to "
                        + mSdkVersion + "; regranting permissions for internal storage");
            if (mIsUpgrade) {
                Slog.i(TAG, "Build fingerprint changed from " + ver.fingerprint + " to "
                        + Build.FINGERPRINT + "; regranting permissions for internal storage");
            }
            mPermissionManager.onStorageVolumeMounted(
                    StorageManager.UUID_PRIVATE_INTERNAL, sdkUpdated);
                    StorageManager.UUID_PRIVATE_INTERNAL, mIsUpgrade);
            ver.sdkVersion = mSdkVersion;
            // If this is the first boot or an update from pre-M, and it is a normal
@@ -24608,12 +24607,13 @@ public class PackageManagerService extends IPackageManager.Stub
        }
        synchronized (mLock) {
            final boolean sdkUpdated = (ver.sdkVersion != mSdkVersion);
            if (sdkUpdated) {
                logCriticalInfo(Log.INFO, "Platform changed from " + ver.sdkVersion + " to "
                        + mSdkVersion + "; regranting permissions for " + volumeUuid);
            final boolean isUpgrade = !Build.FINGERPRINT.equals(ver.fingerprint);
            if (isUpgrade) {
                logCriticalInfo(Log.INFO, "Build fingerprint changed from " + ver.fingerprint
                        + " to " + Build.FINGERPRINT + "; regranting permissions for "
                        + volumeUuid);
            }
            mPermissionManager.onStorageVolumeMounted(volumeUuid, sdkUpdated);
            mPermissionManager.onStorageVolumeMounted(volumeUuid, isUpgrade);
            // Yay, everything is now upgraded
            ver.forceCurrent();
+6 −6
Original line number Diff line number Diff line
@@ -3962,14 +3962,14 @@ public class PermissionManagerService extends IPermissionManager.Stub {
     * </ol>
     *
     * @param volumeUuid The volume UUID of the packages to be updated
     * @param sdkVersionChanged whether the current SDK version is different from what it was when
     *                          this volume was last mounted
     * @param fingerprintChanged whether the current build fingerprint is different from what it was
     *                           when this volume was last mounted
     */
    private void updateAllPermissions(@NonNull String volumeUuid, boolean sdkVersionChanged) {
    private void updateAllPermissions(@NonNull String volumeUuid, boolean fingerprintChanged) {
        PackageManager.corkPackageInfoCache();  // Prevent invalidation storm
        try {
            final int flags = UPDATE_PERMISSIONS_ALL |
                    (sdkVersionChanged
                    (fingerprintChanged
                            ? UPDATE_PERMISSIONS_REPLACE_PKG | UPDATE_PERMISSIONS_REPLACE_ALL
                            : 0);
            updatePermissions(null, null, volumeUuid, flags, mDefaultPermissionCallback);
@@ -4944,8 +4944,8 @@ public class PermissionManagerService extends IPermissionManager.Stub {
            return PermissionManagerService.this.getAppOpPermissionPackagesInternal(permissionName);
        }
        @Override
        public void onStorageVolumeMounted(@Nullable String volumeUuid, boolean sdkVersionChanged) {
            updateAllPermissions(volumeUuid, sdkVersionChanged);
        public void onStorageVolumeMounted(@Nullable String volumeUuid, boolean fingerprintChanged) {
            updateAllPermissions(volumeUuid, fingerprintChanged);
        }
        @Override
        public void resetRuntimePermissions(@NonNull AndroidPackage pkg, @UserIdInt int userId) {
+3 −3
Original line number Diff line number Diff line
@@ -210,11 +210,11 @@ public interface PermissionManagerServiceInternal extends PermissionManagerInter
     * Callback when a storage volume is mounted, so that all packages on it become available.
     *
     * @param volumeUuid the UUID of the storage volume
     * @param sdkVersionChanged whether the current SDK version is different from what it was when
     *                          this volume was last mounted
     * @param fingerprintChanged whether the current build fingerprint is different from what it was
     *                           when this volume was last mounted
     */
    //@SystemApi(client = SystemApi.Client.SYSTEM_SERVER)
    void onStorageVolumeMounted(@NonNull String volumeUuid, boolean sdkVersionChanged);
    void onStorageVolumeMounted(@NonNull String volumeUuid, boolean fingerprintChanged);

    /**
     * Callback when a user has been created.