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

Change-Id: Ib7d489211b75a1fdca0076b21773bc93e0d80d1f
This commit is contained in:
Automerger Merge Worker
2020-03-02 15:11:25 +00:00

View File

@@ -4503,6 +4503,8 @@ 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) {
final long token = Binder.clearCallingIdentity();
try {
if (mIsFuseEnabled) { if (mIsFuseEnabled) {
// When using FUSE, we may need to kill the app if the op changes // When using FUSE, we may need to kill the app if the op changes
switch(code) { switch(code) {
@@ -4513,10 +4515,10 @@ class StorageManagerService extends IStorageManager.Stub
case OP_MANAGE_EXTERNAL_STORAGE: case OP_MANAGE_EXTERNAL_STORAGE:
if (mode != MODE_ALLOWED) { if (mode != MODE_ALLOWED) {
// Only kill if op is denied, to lose external_storage gid // Only kill if op is denied, to lose external_storage gid
// Killing when op is granted to pickup the gid automatically, results // Killing when op is granted to pickup the gid automatically,
// in a bad UX, especially since the gid only gives access to unreliable // results in a bad UX, especially since the gid only gives access
// volumes, USB OTGs that are rarely mounted. The app will get the // to unreliable volumes, USB OTGs that are rarely mounted. The app
// external_storage gid on next organic restart. // will get the external_storage gid on next organic restart.
killAppForOpChange(code, uid, packageName); killAppForOpChange(code, uid, packageName);
} }
return; return;
@@ -4529,17 +4531,15 @@ class StorageManagerService extends IStorageManager.Stub
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 { } finally {
Binder.restoreCallingIdentity(token); Binder.restoreCallingIdentity(token);
} }
} }
} }
} }
}