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

Commit 6dd08fdd authored by Amith Yamasani's avatar Amith Yamasani Committed by Android (Google) Code Review
Browse files

Merge "Show a user switching dialog before starting the user switch" into lmp-dev

parents 12eec234 7805a10c
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -2869,7 +2869,7 @@
                android:label="@string/managed_profile_label">
        </activity-alias>
        <activity android:name="com.android.internal.app.HeavyWeightSwitcherActivity"
                android:theme="@style/Theme.Holo.Dialog"
                android:theme="@style/Theme.Material.Dialog"
                android:label="@string/heavy_weight_switcher_title"
                android:finishOnCloseSystemDialogs="true"
                android:excludeFromRecents="true"
+2 −0
Original line number Diff line number Diff line
@@ -4543,6 +4543,8 @@
    <string name="enable_accessibility_canceled">Accessibility canceled.</string>
    <!-- Text spoken when the current user is switched if accessibility is enabled. [CHAR LIMIT=none] -->
    <string name="user_switched">Current user <xliff:g id="name" example="Bob">%1$s</xliff:g>.</string>
    <!-- Message shown when switching to a user [CHAR LIMIT=none] -->
    <string name="user_switching_message">Switching to user <xliff:g id="name" example="Bob">%1$s</xliff:g></string>
    <!-- Default name of the owner user [CHAR LIMIT=20] -->
    <string name="owner_name" msgid="3879126011135546571">Owner</string>
    <!-- Error message title [CHAR LIMIT=35] -->
+1 −0
Original line number Diff line number Diff line
@@ -836,6 +836,7 @@
  <java-symbol type="string" name="time_picker_increment_set_pm_button" />
  <java-symbol type="string" name="upload_file" />
  <java-symbol type="string" name="user_switched" />
  <java-symbol type="string" name="user_switching_message" />
  <java-symbol type="string" name="volume_alarm" />
  <java-symbol type="string" name="volume_icon_description_bluetooth" />
  <java-symbol type="string" name="volume_icon_description_incall" />
+0 −1
Original line number Diff line number Diff line
@@ -246,7 +246,6 @@ public class UserSwitcherController {

    private void switchToUserId(int id) {
        try {
            WindowManagerGlobal.getWindowManagerService().lockNow(null);
            ActivityManagerNative.getDefault().switchUser(id);
        } catch (RemoteException e) {
            Log.e(TAG, "Couldn't switch user.", e);
+37 −1
Original line number Diff line number Diff line
@@ -1179,6 +1179,7 @@ public final class ActivityManagerService extends ActivityManagerNative
    static final int SYSTEM_USER_CURRENT_MSG = 43;
    static final int ENTER_ANIMATION_COMPLETE_MSG = 44;
    static final int ENABLE_SCREEN_AFTER_BOOT_MSG = 45;
    static final int START_USER_SWITCH_MSG = 46;
    static final int FIRST_ACTIVITY_STACK_MSG = 100;
    static final int FIRST_BROADCAST_QUEUE_MSG = 200;
@@ -1771,6 +1772,10 @@ public final class ActivityManagerService extends ActivityManagerNative
                thread.start();
                break;
            }
            case START_USER_SWITCH_MSG: {
                showUserSwitchDialog(msg.arg1, (String) msg.obj);
                break;
            }
            case REPORT_USER_SWITCH_MSG: {
                dispatchUserSwitch((UserStartedState) msg.obj, msg.arg1, msg.arg2);
                break;
@@ -17442,6 +17447,15 @@ public final class ActivityManagerService extends ActivityManagerNative
        return startUser(userId, /* foreground */ false);
    }
    /**
     * Start user, if its not already running, and bring it to foreground.
     */
    boolean startUserInForeground(final int userId, Dialog dlg) {
        boolean result = startUser(userId, /* foreground */ true);
        dlg.dismiss();
        return result;
    }
    /**
     * Refreshes the list of users related to the current user when either a
     * user switch happens or when a new related user is started in the
@@ -17480,7 +17494,29 @@ public final class ActivityManagerService extends ActivityManagerNative
    @Override
    public boolean switchUser(final int userId) {
        return startUser(userId, /* foregound */ true);
        String userName;
        synchronized (this) {
            UserInfo userInfo = getUserManagerLocked().getUserInfo(userId);
            if (userInfo == null) {
                Slog.w(TAG, "No user info for user #" + userId);
                return false;
            }
            if (userInfo.isManagedProfile()) {
                Slog.w(TAG, "Cannot switch to User #" + userId + ": not a full user");
                return false;
            }
            userName = userInfo.name;
        }
        mHandler.removeMessages(START_USER_SWITCH_MSG);
        mHandler.sendMessage(mHandler.obtainMessage(START_USER_SWITCH_MSG, userId, 0, userName));
        return true;
    }
    private void showUserSwitchDialog(int userId, String userName) {
        // The dialog will show and then initiate the user switch by calling startUserInForeground
        Dialog d = new UserSwitchingDialog(this, mContext, userId, userName,
                true /* above system */);
        d.show();
    }
    private boolean startUser(final int userId, boolean foreground) {
Loading