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

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

Merge "Block am switch-user when user switching is disallowed"

parents a986a96d 5c0df23e
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -62,6 +62,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;
@@ -1638,6 +1639,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;