Merge "Enforce package visibility to the api checkUriPermission" into sc-dev am: 293b6bf6a2
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/15065730 Change-Id: I9d5fc9d13fa7bcb8599f181db77624cc2938f722
This commit is contained in:
@@ -5690,6 +5690,16 @@ public class ActivityManagerService extends IActivityManager.Stub
|
||||
if (pid == MY_PID) {
|
||||
return PackageManager.PERMISSION_GRANTED;
|
||||
}
|
||||
try {
|
||||
if (uid != 0) { // bypass the root
|
||||
final String[] packageNames = getPackageManager().getPackagesForUid(uid);
|
||||
if (ArrayUtils.isEmpty(packageNames)) {
|
||||
// The uid is not existed or not visible to the caller.
|
||||
return PackageManager.PERMISSION_DENIED;
|
||||
}
|
||||
}
|
||||
} catch (RemoteException e) {
|
||||
}
|
||||
return mUgmInternal.checkUriPermission(new GrantUri(userId, uri, modeFlags), uid, modeFlags)
|
||||
? PackageManager.PERMISSION_GRANTED : PackageManager.PERMISSION_DENIED;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user