Merge "Fixing tabOwnerUserHandle population." into udc-dev

This commit is contained in:
Himanshu Gupta
2023-02-20 10:18:51 +00:00
committed by Android (Google) Code Review

View File

@@ -739,6 +739,11 @@ public class ResolverActivity extends Activity implements
} }
protected UserHandle fetchPersonalProfileUserHandle() { protected UserHandle fetchPersonalProfileUserHandle() {
// ActivityManager.getCurrentUser() refers to the current Foreground user. When clone/work
// profile is active, we always make the personal tab from the foreground user.
// Outside profiles, current foreground user is potentially the same as the sharesheet
// process's user (UserHandle.myUserId()), so we continue to create personal tab with the
// current foreground user.
mPersonalProfileUserHandle = UserHandle.of(ActivityManager.getCurrentUser()); mPersonalProfileUserHandle = UserHandle.of(ActivityManager.getCurrentUser());
return mPersonalProfileUserHandle; return mPersonalProfileUserHandle;
} }
@@ -768,10 +773,11 @@ public class ResolverActivity extends Activity implements
} }
private UserHandle fetchTabOwnerUserHandleForLaunch() { private UserHandle fetchTabOwnerUserHandleForLaunch() {
if (isLaunchedAsCloneProfile()) { // If we are in work profile's process, return WorkProfile user as owner, otherwise we
return getPersonalProfileUserHandle(); // always return PersonalProfile user as owner
} return UserHandle.of(UserHandle.myUserId()).equals(getWorkProfileUserHandle())
return mLaunchedFromUserHandle; ? getWorkProfileUserHandle()
: getPersonalProfileUserHandle();
} }
private boolean hasWorkProfile() { private boolean hasWorkProfile() {