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

Commit 42e0ab06 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Create a new user restriction to disallow user switching"

parents 60770439 ff66fa9e
Loading
Loading
Loading
Loading
+1 −0
Original line number Original line Diff line number Diff line
@@ -31987,6 +31987,7 @@ package android.os {
    field public static final java.lang.String DISALLOW_UNINSTALL_APPS = "no_uninstall_apps";
    field public static final java.lang.String DISALLOW_UNINSTALL_APPS = "no_uninstall_apps";
    field public static final java.lang.String DISALLOW_UNMUTE_MICROPHONE = "no_unmute_microphone";
    field public static final java.lang.String DISALLOW_UNMUTE_MICROPHONE = "no_unmute_microphone";
    field public static final java.lang.String DISALLOW_USB_FILE_TRANSFER = "no_usb_file_transfer";
    field public static final java.lang.String DISALLOW_USB_FILE_TRANSFER = "no_usb_file_transfer";
    field public static final java.lang.String DISALLOW_USER_SWITCH = "no_user_switch";
    field public static final java.lang.String ENSURE_VERIFY_APPS = "ensure_verify_apps";
    field public static final java.lang.String ENSURE_VERIFY_APPS = "ensure_verify_apps";
    field public static final java.lang.String KEY_RESTRICTIONS_PENDING = "restrictions_pending";
    field public static final java.lang.String KEY_RESTRICTIONS_PENDING = "restrictions_pending";
    field public static final int USER_CREATION_FAILED_NOT_PERMITTED = 1; // 0x1
    field public static final int USER_CREATION_FAILED_NOT_PERMITTED = 1; // 0x1
+1 −0
Original line number Original line Diff line number Diff line
@@ -34840,6 +34840,7 @@ package android.os {
    field public static final java.lang.String DISALLOW_UNINSTALL_APPS = "no_uninstall_apps";
    field public static final java.lang.String DISALLOW_UNINSTALL_APPS = "no_uninstall_apps";
    field public static final java.lang.String DISALLOW_UNMUTE_MICROPHONE = "no_unmute_microphone";
    field public static final java.lang.String DISALLOW_UNMUTE_MICROPHONE = "no_unmute_microphone";
    field public static final java.lang.String DISALLOW_USB_FILE_TRANSFER = "no_usb_file_transfer";
    field public static final java.lang.String DISALLOW_USB_FILE_TRANSFER = "no_usb_file_transfer";
    field public static final java.lang.String DISALLOW_USER_SWITCH = "no_user_switch";
    field public static final java.lang.String ENSURE_VERIFY_APPS = "ensure_verify_apps";
    field public static final java.lang.String ENSURE_VERIFY_APPS = "ensure_verify_apps";
    field public static final java.lang.String KEY_RESTRICTIONS_PENDING = "restrictions_pending";
    field public static final java.lang.String KEY_RESTRICTIONS_PENDING = "restrictions_pending";
    field public static final int RESTRICTION_NOT_SET = 0; // 0x0
    field public static final int RESTRICTION_NOT_SET = 0; // 0x0
+1 −0
Original line number Original line Diff line number Diff line
@@ -32255,6 +32255,7 @@ package android.os {
    field public static final java.lang.String DISALLOW_UNINSTALL_APPS = "no_uninstall_apps";
    field public static final java.lang.String DISALLOW_UNINSTALL_APPS = "no_uninstall_apps";
    field public static final java.lang.String DISALLOW_UNMUTE_MICROPHONE = "no_unmute_microphone";
    field public static final java.lang.String DISALLOW_UNMUTE_MICROPHONE = "no_unmute_microphone";
    field public static final java.lang.String DISALLOW_USB_FILE_TRANSFER = "no_usb_file_transfer";
    field public static final java.lang.String DISALLOW_USB_FILE_TRANSFER = "no_usb_file_transfer";
    field public static final java.lang.String DISALLOW_USER_SWITCH = "no_user_switch";
    field public static final java.lang.String ENSURE_VERIFY_APPS = "ensure_verify_apps";
    field public static final java.lang.String ENSURE_VERIFY_APPS = "ensure_verify_apps";
    field public static final java.lang.String KEY_RESTRICTIONS_PENDING = "restrictions_pending";
    field public static final java.lang.String KEY_RESTRICTIONS_PENDING = "restrictions_pending";
    field public static final int USER_CREATION_FAILED_NOT_PERMITTED = 1; // 0x1
    field public static final int USER_CREATION_FAILED_NOT_PERMITTED = 1; // 0x1
+20 −2
Original line number Original line Diff line number Diff line
@@ -791,6 +791,19 @@ public class UserManager {
     */
     */
    public static final String DISALLOW_AUTOFILL = "no_autofill";
    public static final String DISALLOW_AUTOFILL = "no_autofill";


    /**
     * Specifies if user switching is blocked on the current user.
     *
     * <p> This restriction can only be set by the device owner, it will be applied to all users.
     *
     * <p>The default value is <code>false</code>.
     *
     * @see DevicePolicyManager#addUserRestriction(ComponentName, String)
     * @see DevicePolicyManager#clearUserRestriction(ComponentName, String)
     * @see #getUserRestrictions()
     */
    public static final String DISALLOW_USER_SWITCH = "no_user_switch";

    /**
    /**
     * Application restriction key that is used to indicate the pending arrival
     * Application restriction key that is used to indicate the pending arrival
     * of real restrictions for the app.
     * of real restrictions for the app.
@@ -917,7 +930,7 @@ public class UserManager {
    /**
    /**
     * Returns whether switching users is currently allowed.
     * Returns whether switching users is currently allowed.
     * <p>For instance switching users is not allowed if the current user is in a phone call,
     * <p>For instance switching users is not allowed if the current user is in a phone call,
     * or system user hasn't been unlocked yet
     * system user hasn't been unlocked yet, or {@link #DISALLOW_USER_SWITCH} is set.
     * @hide
     * @hide
     */
     */
    public boolean canSwitchUsers() {
    public boolean canSwitchUsers() {
@@ -927,7 +940,9 @@ public class UserManager {
        boolean isSystemUserUnlocked = isUserUnlocked(UserHandle.SYSTEM);
        boolean isSystemUserUnlocked = isUserUnlocked(UserHandle.SYSTEM);
        boolean inCall = TelephonyManager.getDefault().getCallState()
        boolean inCall = TelephonyManager.getDefault().getCallState()
                != TelephonyManager.CALL_STATE_IDLE;
                != TelephonyManager.CALL_STATE_IDLE;
        return (allowUserSwitchingWhenSystemUserLocked || isSystemUserUnlocked) && !inCall;
        boolean isUserSwitchDisallowed = hasUserRestriction(DISALLOW_USER_SWITCH);
        return (allowUserSwitchingWhenSystemUserLocked || isSystemUserUnlocked) && !inCall
                && !isUserSwitchDisallowed;
    }
    }


    /**
    /**
@@ -2298,6 +2313,9 @@ public class UserManager {
        if (!supportsMultipleUsers()) {
        if (!supportsMultipleUsers()) {
            return false;
            return false;
        }
        }
        if (hasUserRestriction(DISALLOW_USER_SWITCH)) {
            return false;
        }
        // If Demo Mode is on, don't show user switcher
        // If Demo Mode is on, don't show user switcher
        if (isDeviceInDemoMode(mContext)) {
        if (isDeviceInDemoMode(mContext)) {
            return false;
            return false;
+3 −1
Original line number Original line Diff line number Diff line
@@ -338,7 +338,9 @@ public class QSFooterImpl extends FrameLayout implements QSFooter,


        final boolean isDemo = UserManager.isDeviceInDemoMode(mContext);
        final boolean isDemo = UserManager.isDeviceInDemoMode(mContext);


        mMultiUserSwitch.setVisibility(mExpanded && mMultiUserSwitch.hasMultipleUsers() && !isDemo

        mMultiUserSwitch.setVisibility(mExpanded
                && UserManager.get(mContext).isUserSwitcherEnabled()
                ? View.VISIBLE : View.INVISIBLE);
                ? View.VISIBLE : View.INVISIBLE);


        mEdit.setVisibility(isDemo || !mExpanded ? View.INVISIBLE : View.VISIBLE);
        mEdit.setVisibility(isDemo || !mExpanded ? View.INVISIBLE : View.VISIBLE);
Loading