Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 1b1c07af authored by Jason Chiu's avatar Jason Chiu
Browse files

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
parent 98fa9deb
Loading
Loading
Loading
Loading
+11 −1
Original line number Diff line number Diff line
@@ -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 {
            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;
+10 −1
Original line number Diff line number Diff line
@@ -20,6 +20,8 @@ import static android.provider.Settings.ACTION_SETTINGS_EMBED_DEEP_LINK_ACTIVITY
import static android.provider.Settings.EXTRA_SETTINGS_EMBEDDED_DEEP_LINK_HIGHLIGHT_MENU_KEY;
import static android.provider.Settings.EXTRA_SETTINGS_EMBEDDED_DEEP_LINK_INTENT_URI;

import static com.android.settings.SettingsActivity.EXTRA_USER_HANDLE;

import android.animation.LayoutTransition;
import android.app.ActivityManager;
import android.app.settings.SettingsEnums;
@@ -27,6 +29,7 @@ import android.content.ComponentName;
import android.content.Intent;
import android.content.res.Configuration;
import android.os.Bundle;
import android.os.UserHandle;
import android.text.TextUtils;
import android.util.ArraySet;
import android.util.FeatureFlagUtils;
@@ -449,8 +452,14 @@ public class SettingsHomepageActivity extends FragmentActivity implements
                SplitRule.FINISH_ALWAYS,
                SplitRule.FINISH_ALWAYS,
                true /* clearTop */);

        final UserHandle user = intent.getParcelableExtra(EXTRA_USER_HANDLE, UserHandle.class);
        if (user != null) {
            startActivityAsUser(targetIntent, user);
        } else {
            startActivity(targetIntent);
        }
    }

    private String getHighlightMenuKey() {
        final Intent intent = getIntent();