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

Commit 66131395 authored by Ben Murdoch's avatar Ben Murdoch
Browse files

Add config resource to control simple user switcher state.

Additionally, allow adding users and guest account with the
simple user switcher.

Bug: 136122305
Test: Apply RRO to toggle config overlay, observe change
Change-Id: I95b49d3b8dd931fc107ba91baa6a073309dd0658
parent 9d6c0718
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -4343,4 +4343,7 @@
         Determines whether the specified key groups can be used to wake up the device. -->
    <bool name="config_wakeOnDpadKeyPress">true</bool>
    <bool name="config_wakeOnAssistKeyPress">true</bool>

    <!-- Whether to default to an expanded list of users on the lock screen user switcher. -->
    <bool name="config_expandLockScreenUserSwitcher">false</bool>
</resources>
+3 −0
Original line number Diff line number Diff line
@@ -3863,4 +3863,7 @@

  <!-- Toast message for background started foreground service while-in-use permission restriction feature -->
  <java-symbol type="string" name="allow_while_in_use_permission_in_fgs" />

  <!-- Whether to expand the lock screen user switcher by default -->
  <java-symbol type="bool" name="config_expandLockScreenUserSwitcher" />
</resources>
+22 −15
Original line number Diff line number Diff line
@@ -134,6 +134,8 @@ public class UserSwitcherController implements Dumpable {
        mBroadcastDispatcher.registerReceiver(
                mReceiver, filter, null /* handler */, UserHandle.SYSTEM);

        mSimpleUserSwitcher = shouldUseSimpleUserSwitcher();

        mSecondaryUserServiceIntent = new Intent(context, SystemUISecondaryUserService.class);

        filter = new IntentFilter();
@@ -258,7 +260,6 @@ public class UserSwitcherController implements Dumpable {
                        && mUserManager.canAddMoreUsers();
                boolean createIsRestricted = !addUsersWhenLocked;

                if (!mSimpleUserSwitcher) {
                if (guestRecord == null) {
                    if (canCreateGuest) {
                        guestRecord = new UserRecord(null /* info */, null /* picture */,
@@ -271,9 +272,8 @@ public class UserSwitcherController implements Dumpable {
                    int index = guestRecord.isCurrent ? 0 : records.size();
                    records.add(index, guestRecord);
                }
                }

                if (!mSimpleUserSwitcher && canCreateUser) {
                if (canCreateUser) {
                    UserRecord addUserRecord = new UserRecord(null /* info */, null /* picture */,
                            false /* isGuest */, false /* isCurrent */, true /* isAddUser */,
                            createIsRestricted, canSwitchUsers);
@@ -562,8 +562,7 @@ public class UserSwitcherController implements Dumpable {

    private final ContentObserver mSettingsObserver = new ContentObserver(new Handler()) {
        public void onChange(boolean selfChange) {
            mSimpleUserSwitcher = Settings.Global.getInt(mContext.getContentResolver(),
                    SIMPLE_USER_SWITCHER_GLOBAL_SETTING, 0) != 0;
            mSimpleUserSwitcher = shouldUseSimpleUserSwitcher();
            mAddUsersWhenLocked = Settings.Global.getInt(mContext.getContentResolver(),
                    Settings.Global.ADD_USERS_WHEN_LOCKED, 0) != 0;
            refreshUsers(UserHandle.USER_NULL);
@@ -579,6 +578,7 @@ public class UserSwitcherController implements Dumpable {
            final UserRecord u = mUsers.get(i);
            pw.print("    "); pw.println(u.toString());
        }
        pw.println("mSimpleUserSwitcher=" + mSimpleUserSwitcher);
    }

    public String getCurrentUserName(Context context) {
@@ -717,6 +717,13 @@ public class UserSwitcherController implements Dumpable {
        }
    }

    private boolean shouldUseSimpleUserSwitcher() {
        int defaultSimpleUserSwitcher = mContext.getResources().getBoolean(
                com.android.internal.R.bool.config_expandLockScreenUserSwitcher) ? 1 : 0;
        return Settings.Global.getInt(mContext.getContentResolver(),
                SIMPLE_USER_SWITCHER_GLOBAL_SETTING, defaultSimpleUserSwitcher) != 0;
    }

    public void startActivity(Intent intent) {
        mActivityStarter.startActivity(intent, true);
    }