Merge "Make sure callingPackage belongs to callingUid when checking BG-FGS restrictions." into rvc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
a70add46f3
@@ -4983,10 +4983,17 @@ public final class ActiveServices {
|
||||
return true;
|
||||
}
|
||||
|
||||
final boolean isWhiteListedPackage =
|
||||
mWhiteListAllowWhileInUsePermissionInFgs.contains(callingPackage);
|
||||
if (isWhiteListedPackage) {
|
||||
return true;
|
||||
|
||||
if (verifyPackage(callingPackage, callingUid)) {
|
||||
final boolean isWhiteListedPackage =
|
||||
mWhiteListAllowWhileInUsePermissionInFgs.contains(callingPackage);
|
||||
if (isWhiteListedPackage) {
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
EventLog.writeEvent(0x534e4554, "215003903", callingUid,
|
||||
"callingPackage:" + callingPackage + " does not belong to callingUid:"
|
||||
+ callingUid);
|
||||
}
|
||||
|
||||
// Is the calling UID a device owner app?
|
||||
@@ -5025,4 +5032,21 @@ public final class ActiveServices {
|
||||
r.mAllowWhileInUsePermissionInFgs = false;
|
||||
r.mLastSetFgsRestrictionTime = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if a given packageName belongs to a given uid.
|
||||
* @param packageName the package of the caller
|
||||
* @param uid the uid of the caller
|
||||
* @return true or false
|
||||
*/
|
||||
private boolean verifyPackage(String packageName, int uid) {
|
||||
if (uid == ROOT_UID || uid == SYSTEM_UID) {
|
||||
//System and Root are always allowed
|
||||
return true;
|
||||
}
|
||||
final int userId = UserHandle.getUserId(uid);
|
||||
final int packageUid = mAm.getPackageManagerInternalLocked()
|
||||
.getPackageUid(packageName, PackageManager.MATCH_DEBUG_TRIAGED_MISSING, userId);
|
||||
return UserHandle.isSameApp(uid, packageUid);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user