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

Commit 5c0df23e authored by Alex Chau's avatar Alex Chau
Browse files

Block am switch-user when user switching is disallowed

Bug: 71631446
Test: Cannot switch user via am switch-user when DISALLOW_SWITCH_USER is set
Change-Id: Ia84b360940318963c8be7c07768fbe542205f34e
parent 61b44dca
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -52,6 +52,7 @@ import android.os.StrictMode;
import android.os.SystemClock;
import android.os.SystemProperties;
import android.os.UserHandle;
import android.os.UserManager;
import android.text.TextUtils;
import android.util.ArrayMap;
import android.util.DebugUtils;
@@ -1621,6 +1622,11 @@ final class ActivityManagerShellCommand extends ShellCommand {
    }

    int runSwitchUser(PrintWriter pw) throws RemoteException {
        UserManager userManager = mInternal.mContext.getSystemService(UserManager.class);
        if (!userManager.canSwitchUsers()) {
            getErrPrintWriter().println("Error: disallowed switching user");
            return -1;
        }
        String user = getNextArgRequired();
        mInterface.switchUser(Integer.parseInt(user));
        return 0;