Merge "Clear calling identity in StorageManagerService#onAppopsChanged" into rvc-dev am: a38ba93e26

Change-Id: I150d4ff01e67612d75691ef13e4ab2212ace8679
This commit is contained in:
Automerger Merge Worker
2020-03-02 14:47:00 +00:00

View File

@@ -4503,42 +4503,42 @@ class StorageManagerService extends IStorageManager.Stub
} }
public void onAppOpsChanged(int code, int uid, @Nullable String packageName, int mode) { public void onAppOpsChanged(int code, int uid, @Nullable String packageName, int mode) {
if (mIsFuseEnabled) { final long token = Binder.clearCallingIdentity();
// When using FUSE, we may need to kill the app if the op changes try {
switch(code) { if (mIsFuseEnabled) {
case OP_REQUEST_INSTALL_PACKAGES: // When using FUSE, we may need to kill the app if the op changes
// Always kill regardless of op change, to remount apps /storage switch(code) {
killAppForOpChange(code, uid, packageName); case OP_REQUEST_INSTALL_PACKAGES:
return; // Always kill regardless of op change, to remount apps /storage
case OP_MANAGE_EXTERNAL_STORAGE:
if (mode != MODE_ALLOWED) {
// Only kill if op is denied, to lose external_storage gid
// Killing when op is granted to pickup the gid automatically, results
// in a bad UX, especially since the gid only gives access to unreliable
// volumes, USB OTGs that are rarely mounted. The app will get the
// external_storage gid on next organic restart.
killAppForOpChange(code, uid, packageName); killAppForOpChange(code, uid, packageName);
} return;
return; case OP_MANAGE_EXTERNAL_STORAGE:
case OP_LEGACY_STORAGE: if (mode != MODE_ALLOWED) {
updateLegacyStorageApps(packageName, uid, mode == MODE_ALLOWED); // Only kill if op is denied, to lose external_storage gid
return; // Killing when op is granted to pickup the gid automatically,
// results in a bad UX, especially since the gid only gives access
// to unreliable volumes, USB OTGs that are rarely mounted. The app
// will get the external_storage gid on next organic restart.
killAppForOpChange(code, uid, packageName);
}
return;
case OP_LEGACY_STORAGE:
updateLegacyStorageApps(packageName, uid, mode == MODE_ALLOWED);
return;
}
} }
}
if (mode == MODE_ALLOWED && (code == OP_READ_EXTERNAL_STORAGE if (mode == MODE_ALLOWED && (code == OP_READ_EXTERNAL_STORAGE
|| code == OP_WRITE_EXTERNAL_STORAGE || code == OP_WRITE_EXTERNAL_STORAGE
|| code == OP_REQUEST_INSTALL_PACKAGES)) { || code == OP_REQUEST_INSTALL_PACKAGES)) {
final long token = Binder.clearCallingIdentity();
try {
final UserManagerInternal userManagerInternal = final UserManagerInternal userManagerInternal =
LocalServices.getService(UserManagerInternal.class); LocalServices.getService(UserManagerInternal.class);
if (userManagerInternal.isUserInitialized(UserHandle.getUserId(uid))) { if (userManagerInternal.isUserInitialized(UserHandle.getUserId(uid))) {
onExternalStoragePolicyChanged(uid, packageName); onExternalStoragePolicyChanged(uid, packageName);
} }
} finally {
Binder.restoreCallingIdentity(token);
} }
} finally {
Binder.restoreCallingIdentity(token);
} }
} }
} }