diff options
| author | 2021-06-02 01:45:11 +0000 | |
|---|---|---|
| committer | 2021-06-02 04:50:02 +0000 | |
| commit | 2d69ab87f0c097feb0ce485a69ad3bb7242c4cc7 (patch) | |
| tree | 705a23be8738dde52ea1bc3ce6c06587fd9009bb | |
| parent | 21eeb8c97676cc31fd93e8f932ff4a0c9e17977e (diff) | |
Make package handling in openContentUri more robust
Test: manual
bug: 185455561
Change-Id: Id66c5d41e2c456a8d68c23d10ccd8e86b539e6a5
| -rw-r--r-- | services/core/java/com/android/server/am/ActivityManagerService.java | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/services/core/java/com/android/server/am/ActivityManagerService.java b/services/core/java/com/android/server/am/ActivityManagerService.java index 6e500e4ea5ea..61172e38cbd8 100644 --- a/services/core/java/com/android/server/am/ActivityManagerService.java +++ b/services/core/java/com/android/server/am/ActivityManagerService.java @@ -6216,8 +6216,20 @@ public class ActivityManagerService extends IActivityManager.Stub // 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 // in the same security/privacy sandbox. - final AndroidPackage androidPackage = mPackageManagerInt - .getPackage(Binder.getCallingUid()); + final int uid = 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( Binder.getCallingUid(), androidPackage.getPackageName(), null); pfd = cph.provider.openFile(attributionSource, uri, "r", null); |