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
This commit is contained in:
Jeff Sharkey
2015-07-17 15:12:39 -07:00
parent f80b52b08a
commit b3cf953345

View File

@@ -740,15 +740,20 @@ class MountService extends IMountService.Stub
*/
@Deprecated
private void killMediaProvider() {
final ProviderInfo provider = mPms.resolveContentProvider(MediaStore.AUTHORITY, 0,
UserHandle.USER_OWNER);
if (provider != null) {
final IActivityManager am = ActivityManagerNative.getDefault();
try {
am.killApplicationWithAppId(provider.applicationInfo.packageName,
UserHandle.getAppId(provider.applicationInfo.uid), "vold reset");
} catch (RemoteException e) {
final long token = Binder.clearCallingIdentity();
try {
final ProviderInfo provider = mPms.resolveContentProvider(MediaStore.AUTHORITY, 0,
UserHandle.USER_OWNER);
if (provider != null) {
final IActivityManager am = ActivityManagerNative.getDefault();
try {
am.killApplicationWithAppId(provider.applicationInfo.packageName,
UserHandle.getAppId(provider.applicationInfo.uid), "vold reset");
} catch (RemoteException e) {
}
}
} finally {
Binder.restoreCallingIdentity(token);
}
}