Skip to content

Commit b3cf953

Browse files
committed
Clear identity when killing media provider.
Otherwise various shell "sm" commands fail because they don't hold the right permissions. Bug: 22564405 Change-Id: I88081e8a9b27ee43904d3ea6f745aba3af4e2150
1 parent f80b52b commit b3cf953

1 file changed

Lines changed: 13 additions & 8 deletions

File tree

services/core/java/com/android/server/MountService.java

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -740,15 +740,20 @@ private void handleSystemReady() {
740740
*/
741741
@Deprecated
742742
private void killMediaProvider() {
743-
final ProviderInfo provider = mPms.resolveContentProvider(MediaStore.AUTHORITY, 0,
744-
UserHandle.USER_OWNER);
745-
if (provider != null) {
746-
final IActivityManager am = ActivityManagerNative.getDefault();
747-
try {
748-
am.killApplicationWithAppId(provider.applicationInfo.packageName,
749-
UserHandle.getAppId(provider.applicationInfo.uid), "vold reset");
750-
} catch (RemoteException e) {
743+
final long token = Binder.clearCallingIdentity();
744+
try {
745+
final ProviderInfo provider = mPms.resolveContentProvider(MediaStore.AUTHORITY, 0,
746+
UserHandle.USER_OWNER);
747+
if (provider != null) {
748+
final IActivityManager am = ActivityManagerNative.getDefault();
749+
try {
750+
am.killApplicationWithAppId(provider.applicationInfo.packageName,
751+
UserHandle.getAppId(provider.applicationInfo.uid), "vold reset");
752+
} catch (RemoteException e) {
753+
}
751754
}
755+
} finally {
756+
Binder.restoreCallingIdentity(token);
752757
}
753758
}
754759

0 commit comments

Comments
 (0)