Merge "Re-grant install permissions on build fingerprint change." into sc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
54c39c71a9
@@ -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
|
||||
@@ -24612,12 +24611,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();
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user