Merge "Make sure callingPackage belongs to callingUid when checking BG-FGS restrictions." into sc-dev
This commit is contained in:
@@ -5992,10 +5992,16 @@ public final class ActiveServices {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (ret == REASON_DENIED) {
|
if (ret == REASON_DENIED) {
|
||||||
final boolean isAllowedPackage =
|
if (verifyPackage(callingPackage, callingUid)) {
|
||||||
mAllowListWhileInUsePermissionInFgs.contains(callingPackage);
|
final boolean isAllowedPackage =
|
||||||
if (isAllowedPackage) {
|
mAllowListWhileInUsePermissionInFgs.contains(callingPackage);
|
||||||
ret = REASON_ALLOWLISTED_PACKAGE;
|
if (isAllowedPackage) {
|
||||||
|
ret = REASON_ALLOWLISTED_PACKAGE;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
EventLog.writeEvent(0x534e4554, "215003903", callingUid,
|
||||||
|
"callingPackage:" + callingPackage + " does not belong to callingUid:"
|
||||||
|
+ callingUid);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -6378,4 +6384,21 @@ 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;
|
||||||
|
}
|
||||||
|
final int userId = UserHandle.getUserId(uid);
|
||||||
|
final int packageUid = mAm.getPackageManagerInternal()
|
||||||
|
.getPackageUid(packageName, PackageManager.MATCH_DEBUG_TRIAGED_MISSING, userId);
|
||||||
|
return UserHandle.isSameApp(uid, packageUid);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user