Merge "bypass INTERACT_ACROSS_USERS permission check when binding to singleton service for non-0 userId" into rvc-dev am: 4cdb5ddeb4

Original change: undetermined

Change-Id: Ie05b2a3cae65663eed824822c0bc3819235423c1
This commit is contained in:
Songchun Fan
2020-06-01 21:37:32 +00:00
committed by Automerger Merge Worker

View File

@@ -2460,16 +2460,22 @@ public final class ActiveServices {
&& mAm.isValidSingletonCall(callingUid, sInfo.applicationInfo.uid)) {
userId = 0;
smap = getServiceMapLocked(0);
ResolveInfo rInfoForUserId0 =
mAm.getPackageManagerInternalLocked().resolveService(service,
resolvedType, flags, userId, callingUid);
if (rInfoForUserId0 == null) {
Slog.w(TAG_SERVICE,
"Unable to resolve service " + service + " U=" + userId
+ ": not found");
return null;
// Bypass INTERACT_ACROSS_USERS permission check
final long token = Binder.clearCallingIdentity();
try {
ResolveInfo rInfoForUserId0 =
mAm.getPackageManagerInternalLocked().resolveService(service,
resolvedType, flags, userId, callingUid);
if (rInfoForUserId0 == null) {
Slog.w(TAG_SERVICE,
"Unable to resolve service " + service + " U=" + userId
+ ": not found");
return null;
}
sInfo = rInfoForUserId0.serviceInfo;
} finally {
Binder.restoreCallingIdentity(token);
}
sInfo = rInfoForUserId0.serviceInfo;
}
sInfo = new ServiceInfo(sInfo);
sInfo.applicationInfo = mAm.getAppInfoForUser(sInfo.applicationInfo, userId);