diff options
| author | 2018-02-22 15:57:17 +0800 | |
|---|---|---|
| committer | 2018-02-22 15:58:18 +0800 | |
| commit | 5c0df23e76b65977d6ec036cca7c1227ca2bef71 (patch) | |
| tree | 02777eb9d21386ca0ed9da2b68c2bb1fed4e81a9 | |
| parent | 61b44dca6e002389fd75b36d0d04e99294dc1f4a (diff) | |
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
| -rw-r--r-- | services/core/java/com/android/server/am/ActivityManagerShellCommand.java | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/services/core/java/com/android/server/am/ActivityManagerShellCommand.java b/services/core/java/com/android/server/am/ActivityManagerShellCommand.java index fa0df562b6c6..dc98cb42af40 100644 --- a/services/core/java/com/android/server/am/ActivityManagerShellCommand.java +++ b/services/core/java/com/android/server/am/ActivityManagerShellCommand.java @@ -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; |