Merge "Fix how we get provider pkgs" into pi-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
860a3640d4
@@ -42,6 +42,7 @@ import android.content.Intent;
|
|||||||
import android.content.IntentFilter;
|
import android.content.IntentFilter;
|
||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
import android.content.pm.PackageManagerInternal;
|
import android.content.pm.PackageManagerInternal;
|
||||||
|
import android.content.pm.ProviderInfo;
|
||||||
import android.content.pm.ResolveInfo;
|
import android.content.pm.ResolveInfo;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Binder;
|
import android.os.Binder;
|
||||||
@@ -395,30 +396,11 @@ public class SliceManagerService extends ISliceManager.Stub {
|
|||||||
private String getProviderPkg(Uri uri, int user) {
|
private String getProviderPkg(Uri uri, int user) {
|
||||||
long ident = Binder.clearCallingIdentity();
|
long ident = Binder.clearCallingIdentity();
|
||||||
try {
|
try {
|
||||||
IBinder token = new Binder();
|
|
||||||
IActivityManager activityManager = ActivityManager.getService();
|
|
||||||
ContentProviderHolder holder = null;
|
|
||||||
String providerName = getUriWithoutUserId(uri).getAuthority();
|
String providerName = getUriWithoutUserId(uri).getAuthority();
|
||||||
try {
|
ProviderInfo provider = mContext.getPackageManager().resolveContentProviderAsUser(
|
||||||
try {
|
providerName, 0, getUserIdFromUri(uri, user));
|
||||||
holder = activityManager.getContentProviderExternal(
|
return provider.packageName;
|
||||||
providerName, getUserIdFromUri(uri, user), token);
|
|
||||||
if (holder != null && holder.info != null) {
|
|
||||||
return holder.info.packageName;
|
|
||||||
} else {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
} finally {
|
} finally {
|
||||||
if (holder != null && holder.provider != null) {
|
|
||||||
activityManager.removeContentProviderExternal(providerName, token);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (RemoteException e) {
|
|
||||||
// Can't happen.
|
|
||||||
throw e.rethrowAsRuntimeException();
|
|
||||||
}
|
|
||||||
} finally {
|
|
||||||
// I know, the double finally seems ugly, but seems safest for the identity.
|
|
||||||
Binder.restoreCallingIdentity(ident);
|
Binder.restoreCallingIdentity(ident);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user