Support the managed profile deep links for large screen

Homepage is not allowed to be started as a non-primary user.

In the managed profile deep link case, we create a bridge to start the
homepage as the primary user, and then start the target page as the
given managed user.

Bug: 222447112
Test: manual, robotest
Change-Id: I07dbec3b7eaff983f9860480a0a2f7b0e6f1fb43
This commit is contained in:
Jason Chiu
2022-05-13 16:42:07 +08:00
parent 98fa9deb4a
commit 1b1c07afc4
2 changed files with 21 additions and 2 deletions

View File

@@ -34,6 +34,7 @@ import android.content.SharedPreferences;
import android.content.pm.ActivityInfo;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
import android.content.pm.UserInfo;
import android.content.res.Resources;
import android.content.res.Resources.Theme;
import android.graphics.drawable.Icon;
@@ -152,6 +153,8 @@ public class SettingsActivity extends SettingsBaseActivity
*/
public static final String EXTRA_IS_FROM_SLICE = "is_from_slice";
public static final String EXTRA_USER_HANDLE = "user_handle";
/**
* Personal or Work profile tab of {@link ProfileSelectFragment}
* <p>0: Personal tab.
@@ -427,7 +430,14 @@ public class SettingsActivity extends SettingsBaseActivity
}
try {
startActivity(trampolineIntent);
final UserManager um = getSystemService(UserManager.class);
final UserInfo userInfo = um.getUserInfo(getUser().getIdentifier());
if (userInfo.isManagedProfile()) {
trampolineIntent.putExtra(EXTRA_USER_HANDLE, getUser());
startActivityAsUser(trampolineIntent, um.getPrimaryUser().getUserHandle());
} else {
startActivity(trampolineIntent);
}
} catch (ActivityNotFoundException e) {
Log.e(LOG_TAG, "Deep link homepage is not available to show 2-pane UI");
return false;