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:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user