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

This commit is contained in:
Songchun Fan
2020-06-01 21:19:26 +00:00
committed by Android (Google) Code Review

View File

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