Merge "Make package handling in openContentUri more robust" into sc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
3ff294cd82
@@ -6216,8 +6216,20 @@ public class ActivityManagerService extends IActivityManager.Stub
|
|||||||
// signature we just use the first package in the UID. For shared
|
// signature we just use the first package in the UID. For shared
|
||||||
// UIDs we may blame the wrong app but that is Okay as they are
|
// UIDs we may blame the wrong app but that is Okay as they are
|
||||||
// in the same security/privacy sandbox.
|
// in the same security/privacy sandbox.
|
||||||
final AndroidPackage androidPackage = mPackageManagerInt
|
final int uid = Binder.getCallingUid();
|
||||||
.getPackage(Binder.getCallingUid());
|
// Here we handle some of the special UIDs (mediaserver, systemserver, etc)
|
||||||
|
final String packageName = AppOpsManager.resolvePackageName(uid,
|
||||||
|
/*packageName*/ null);
|
||||||
|
final AndroidPackage androidPackage;
|
||||||
|
if (packageName != null) {
|
||||||
|
androidPackage = mPackageManagerInt.getPackage(packageName);
|
||||||
|
} else {
|
||||||
|
androidPackage = mPackageManagerInt.getPackage(uid);
|
||||||
|
}
|
||||||
|
if (androidPackage == null) {
|
||||||
|
Log.e(TAG, "Cannot find package for uid: " + uid);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
final AttributionSource attributionSource = new AttributionSource(
|
final AttributionSource attributionSource = new AttributionSource(
|
||||||
Binder.getCallingUid(), androidPackage.getPackageName(), null);
|
Binder.getCallingUid(), androidPackage.getPackageName(), null);
|
||||||
pfd = cph.provider.openFile(attributionSource, uri, "r", null);
|
pfd = cph.provider.openFile(attributionSource, uri, "r", null);
|
||||||
|
|||||||
Reference in New Issue
Block a user