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

Commit 85f3402d authored by Fyodor Kupolov's avatar Fyodor Kupolov Committed by Android (Google) Code Review
Browse files

Merge "Check multi-user support in isUserSwitcherEnabled"

parents 12f63ce6 cd86ebf1
Loading
Loading
Loading
Loading
+11 −0
Original line number Diff line number Diff line
@@ -2437,6 +2437,17 @@ public class DevicePolicyManager {
        return false;
    }

    /**
     * Determine whether or not creating a guest user has been disabled for the device
     *
     * @hide
     */
    public boolean getGuestUserDisabled(@Nullable ComponentName admin) {
        // Currently guest users can always be created if multi-user is enabled
        // TODO introduce a policy for guest user creation
        return false;
    }

    /**
     * Called by a device/profile owner to set whether the screen capture is disabled. Disabling
     * screen capture also prevents the content from being shown on display devices that do not have
+8 −4
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@ import android.annotation.Nullable;
import android.annotation.SystemApi;
import android.app.ActivityManager;
import android.app.ActivityManagerNative;
import android.app.admin.DevicePolicyManager;
import android.content.Context;
import android.content.pm.UserInfo;
import android.content.res.Resources;
@@ -1337,12 +1338,15 @@ public class UserManager {
    }

    /**
     * Returns true if the user switcher should be shown, this will be if there
     * are multiple users that aren't managed profiles.
     * Returns true if the user switcher should be shown, this will be if device supports multi-user
     * and there are at least 2 users available that are not managed profiles.
     * @hide
     * @return true if user switcher should be shown.
     */
    public boolean isUserSwitcherEnabled() {
        if (!supportsMultipleUsers()) {
            return false;
        }
        List<UserInfo> users = getUsers(true);
        if (users == null) {
           return false;
@@ -1353,8 +1357,8 @@ public class UserManager {
                ++switchableUserCount;
            }
        }
        final boolean guestEnabled = Settings.Global.getInt(mContext.getContentResolver(),
                Settings.Global.GUEST_USER_ENABLED, 0) == 1;
        final boolean guestEnabled = !mContext.getSystemService(DevicePolicyManager.class)
                .getGuestUserDisabled(null);
        return switchableUserCount > 1 || guestEnabled;
    }

+0 −8
Original line number Diff line number Diff line
@@ -7688,14 +7688,6 @@ public final class Settings {
         */
        public static final String DEVICE_NAME = "device_name";

        /**
         * Whether it should be possible to create a guest user on the device.
         * <p>
         * Type: int (0 for disabled, 1 for enabled)
         * @hide
         */
        public static final String GUEST_USER_ENABLED = "guest_user_enabled";

        /**
         * Whether the NetworkScoringService has been first initialized.
         * <p>
+0 −3
Original line number Diff line number Diff line
@@ -204,9 +204,6 @@
    <!-- Default for Settings.Secure.WAKE_GESTURE_ENABLED -->
    <bool name="def_wake_gesture_enabled">true</bool>

    <!-- Default for Settings.Global.GUEST_USER_ENABLED -->
    <bool name="def_guest_user_enabled">true</bool>

    <!-- Default state of tap to wake -->
    <bool name="def_double_tap_to_wake">true</bool>

+1 −16
Original line number Diff line number Diff line
@@ -1693,20 +1693,7 @@ class DatabaseHelper extends SQLiteOpenHelper {
        }

        if (upgradeVersion < 105) {
            if (mUserHandle == UserHandle.USER_SYSTEM) {
                db.beginTransaction();
                SQLiteStatement stmt = null;
                try {
                    stmt = db.compileStatement("INSERT OR IGNORE INTO global(name,value)"
                            + " VALUES(?,?);");
                    loadBooleanSetting(stmt, Settings.Global.GUEST_USER_ENABLED,
                            R.bool.def_guest_user_enabled);
                    db.setTransactionSuccessful();
                } finally {
                    db.endTransaction();
                    if (stmt != null) stmt.close();
                }
            }
            // No-op: GUEST_USER_ENABLED setting was removed
            upgradeVersion = 105;
        }

@@ -2705,8 +2692,6 @@ class DatabaseHelper extends SQLiteOpenHelper {

            loadSetting(stmt, Settings.Global.DEVICE_NAME, getDefaultDeviceName());

            loadBooleanSetting(stmt, Settings.Global.GUEST_USER_ENABLED,
                    R.bool.def_guest_user_enabled);
            loadSetting(stmt, Settings.Global.ENHANCED_4G_MODE_ENABLED,
                    ImsConfig.FeatureValueConstants.ON);

Loading