Merge "Make sure callingPackage belongs to callingUid when checking BG-FGS restrictions." into tm-dev
This commit is contained in:
@@ -6475,7 +6475,7 @@ public final class ActiveServices {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ret == REASON_DENIED) {
|
if (ret == REASON_DENIED && verifyPackage(callingPackage, callingUid)) {
|
||||||
final boolean isAllowedPackage =
|
final boolean isAllowedPackage =
|
||||||
mAllowListWhileInUsePermissionInFgs.contains(callingPackage);
|
mAllowListWhileInUsePermissionInFgs.contains(callingPackage);
|
||||||
if (isAllowedPackage) {
|
if (isAllowedPackage) {
|
||||||
@@ -6882,4 +6882,19 @@ public final class ActiveServices {
|
|||||||
/* allowBackgroundActivityStarts */ false)
|
/* allowBackgroundActivityStarts */ false)
|
||||||
!= REASON_DENIED;
|
!= REASON_DENIED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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;
|
||||||
|
}
|
||||||
|
return mAm.getPackageManagerInternal().isSameApp(packageName, uid,
|
||||||
|
UserHandle.getUserId(uid));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user