Allowing system uid to embed Task on secondary user

Settings app was unable to embed task on secondary user
because the uid of Settings was composed with user_id
and app_id, which was not 1000.

Allowing task embedding for system uid on all users.
Also specify the user id while starting activity in
TaskFragments.

Bug: 201738029
Test: start Settings on secondary user
Change-Id: I404379ed049f15abf53084d381c169d3d4cb1166
This commit is contained in:
Louis Chang
2021-10-07 23:14:55 +08:00
parent b9ee2b5eca
commit 5c313cb300
2 changed files with 4 additions and 1 deletions

View File

@@ -501,6 +501,8 @@ public class ActivityStartController {
int startActivityInTaskFragment(@NonNull TaskFragment taskFragment,
@NonNull Intent activityIntent, @Nullable Bundle activityOptions,
@Nullable IBinder resultTo) {
final ActivityRecord caller =
resultTo != null ? ActivityRecord.forTokenLocked(resultTo) : null;
return obtainStarter(activityIntent, "startActivityInTaskFragment")
.setActivityOptions(activityOptions)
.setInTaskFragment(taskFragment)
@@ -508,6 +510,7 @@ public class ActivityStartController {
.setRequestCode(-1)
.setCallingUid(Binder.getCallingUid())
.setCallingPid(Binder.getCallingPid())
.setUserId(caller != null ? caller.mUserId : mService.getCurrentUserId())
.execute();
}

View File

@@ -1979,7 +1979,7 @@ class ActivityStarter {
// Allowing the embedding if the task is owned by system.
final int hostUid = hostTask.effectiveUid;
if (hostUid == Process.SYSTEM_UID) {
if (UserHandle.getAppId(hostUid) == Process.SYSTEM_UID) {
return true;
}