Filter instant app resolution based on logical UID
Test: cts-tradefed run cts-dev -m CtsAppSecurityHostTestCases
-t android.appsecurity.cts.EphemeralTest
cts-tradefed run cts-dev -m CtsActivityManagerDeviceTestCases
bug: 79487366
Change-Id: I51157410d944bc3252de29b4143bb2c7fe7fcefe
This commit is contained in:
committed by
Svetoslav Ganov
parent
afb6f3b046
commit
cbcbf66f6a
@@ -339,7 +339,8 @@ public class ActivityStartController {
|
||||
|
||||
// Collect information about the target of the Intent.
|
||||
ActivityInfo aInfo = mSupervisor.resolveActivity(intent, resolvedTypes[i], 0,
|
||||
null, userId, realCallingUid);
|
||||
null, userId, ActivityStarter.computeResolveFilterUid(
|
||||
callingUid, realCallingUid));
|
||||
// TODO: New, check if this is correct
|
||||
aInfo = mService.getActivityInfoForUser(aInfo, userId);
|
||||
|
||||
|
||||
@@ -791,7 +791,8 @@ class ActivityStarter {
|
||||
callingUid = realCallingUid;
|
||||
callingPid = realCallingPid;
|
||||
|
||||
rInfo = mSupervisor.resolveIntent(intent, resolvedType, userId, 0, realCallingUid);
|
||||
rInfo = mSupervisor.resolveIntent(intent, resolvedType, userId, 0,
|
||||
computeResolveFilterUid(callingUid, realCallingUid));
|
||||
aInfo = mSupervisor.resolveActivity(intent, rInfo, startFlags,
|
||||
null /*profilerInfo*/);
|
||||
|
||||
@@ -955,6 +956,16 @@ class ActivityStarter {
|
||||
final int realCallingPid = Binder.getCallingPid();
|
||||
final int realCallingUid = Binder.getCallingUid();
|
||||
|
||||
int callingPid;
|
||||
if (callingUid >= 0) {
|
||||
callingPid = -1;
|
||||
} else if (caller == null) {
|
||||
callingPid = realCallingPid;
|
||||
callingUid = realCallingUid;
|
||||
} else {
|
||||
callingPid = callingUid = -1;
|
||||
}
|
||||
|
||||
// Save a copy in case ephemeral needs it
|
||||
final Intent ephemeralIntent = new Intent(intent);
|
||||
// Don't modify the client's object!
|
||||
@@ -973,7 +984,7 @@ class ActivityStarter {
|
||||
}
|
||||
|
||||
ResolveInfo rInfo = mSupervisor.resolveIntent(intent, resolvedType, userId,
|
||||
0 /* matchFlags */, realCallingUid);
|
||||
0 /* matchFlags */, computeResolveFilterUid(callingUid, realCallingUid));
|
||||
if (rInfo == null) {
|
||||
UserInfo userInfo = mSupervisor.getUserInfo(userId);
|
||||
if (userInfo != null && userInfo.isManagedProfile()) {
|
||||
@@ -995,7 +1006,7 @@ class ActivityStarter {
|
||||
rInfo = mSupervisor.resolveIntent(intent, resolvedType, userId,
|
||||
PackageManager.MATCH_DIRECT_BOOT_AWARE
|
||||
| PackageManager.MATCH_DIRECT_BOOT_UNAWARE,
|
||||
realCallingUid);
|
||||
computeResolveFilterUid(callingUid, realCallingUid));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1003,16 +1014,6 @@ class ActivityStarter {
|
||||
ActivityInfo aInfo = mSupervisor.resolveActivity(intent, rInfo, startFlags, profilerInfo);
|
||||
|
||||
synchronized (mService) {
|
||||
int callingPid;
|
||||
if (callingUid >= 0) {
|
||||
callingPid = -1;
|
||||
} else if (caller == null) {
|
||||
callingPid = realCallingPid;
|
||||
callingUid = realCallingUid;
|
||||
} else {
|
||||
callingPid = callingUid = -1;
|
||||
}
|
||||
|
||||
final ActivityStack stack = mSupervisor.mFocusedStack;
|
||||
stack.mConfigWillChange = globalConfig != null
|
||||
&& mService.getGlobalConfiguration().diff(globalConfig) != 0;
|
||||
@@ -1077,7 +1078,8 @@ class ActivityStarter {
|
||||
callingPid = Binder.getCallingPid();
|
||||
componentSpecified = true;
|
||||
rInfo = mSupervisor.resolveIntent(intent, null /*resolvedType*/, userId,
|
||||
0 /* matchFlags */, realCallingUid);
|
||||
0 /* matchFlags */, computeResolveFilterUid(callingUid,
|
||||
realCallingUid));
|
||||
aInfo = rInfo != null ? rInfo.activityInfo : null;
|
||||
if (aInfo != null) {
|
||||
aInfo = mService.getActivityInfoForUser(aInfo, userId);
|
||||
@@ -1164,6 +1166,19 @@ class ActivityStarter {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Compute the logical UID based on which the package manager would filter
|
||||
* app components i.e. based on which the instant app policy would be applied
|
||||
* because it is the logical calling UID.
|
||||
*
|
||||
* @param customCallingUid The UID on whose behalf to make the call.
|
||||
* @param actualCallingUid The UID actually making the call.
|
||||
* @return The logical UID making the call.
|
||||
*/
|
||||
static int computeResolveFilterUid(int customCallingUid, int actualCallingUid) {
|
||||
return customCallingUid >= 0 ? customCallingUid : actualCallingUid;
|
||||
}
|
||||
|
||||
private int startActivity(final ActivityRecord r, ActivityRecord sourceRecord,
|
||||
IVoiceInteractionSession voiceSession, IVoiceInteractor voiceInteractor,
|
||||
int startFlags, boolean doResume, ActivityOptions options, TaskRecord inTask,
|
||||
|
||||
Reference in New Issue
Block a user