Loading services/core/java/com/android/server/pm/UserManagerServiceShellCommand.java +37 −0 Original line number Diff line number Diff line Loading @@ -36,6 +36,7 @@ import android.os.UserManager; import android.util.IndentingPrintWriter; import android.util.Slog; import com.android.internal.os.RoSystemProperties; import com.android.internal.widget.LockPatternUtils; import com.android.server.LocalServices; import com.android.server.UiThread; Loading Loading @@ -100,6 +101,11 @@ public class UserManagerServiceShellCommand extends ShellCommand { pw.println(" --reboot (which does a full reboot) or"); pw.println(" --no-restart (which requires a manual restart)"); pw.println(); pw.println(" is-headless-system-user-mode [-v | --verbose]"); pw.println(" Checks whether the device uses headless system user mode."); pw.println(" It returns the effective mode, even when using emulation"); pw.println(" (to get the real mode as well, use -v or --verbose)"); pw.println(); pw.println(" is-user-visible [--display DISPLAY_ID] <USER_ID>"); pw.println(" Checks if the given user is visible in the given display."); pw.println(" If the display option is not set, it uses the user's context to check"); Loading @@ -121,6 +127,8 @@ public class UserManagerServiceShellCommand extends ShellCommand { return runReportPackageAllowlistProblems(); case "set-system-user-mode-emulation": return runSetSystemUserModeEmulation(); case "is-headless-system-user-mode": return runIsHeadlessSystemUserMode(); case "is-user-visible": return runIsUserVisible(); default: Loading Loading @@ -407,6 +415,35 @@ public class UserManagerServiceShellCommand extends ShellCommand { return 0; } private int runIsHeadlessSystemUserMode() { PrintWriter pw = getOutPrintWriter(); boolean verbose = false; String opt; while ((opt = getNextOption()) != null) { switch (opt) { case "-v": case "--verbose": verbose = true; break; default: pw.println("Invalid option: " + opt); return -1; } } boolean isHsum = mService.isHeadlessSystemUserMode(); if (!verbose) { // NOTE: do not change output below, as it's used by ITestDevice // (it's ok to change the verbose option though) pw.println(isHsum); } else { pw.printf("effective=%b real=%b\n", isHsum, RoSystemProperties.MULTIUSER_HEADLESS_SYSTEM_USER); } return 0; } /** * Gets the {@link UserManager} associated with the context of the given user. */ Loading Loading
services/core/java/com/android/server/pm/UserManagerServiceShellCommand.java +37 −0 Original line number Diff line number Diff line Loading @@ -36,6 +36,7 @@ import android.os.UserManager; import android.util.IndentingPrintWriter; import android.util.Slog; import com.android.internal.os.RoSystemProperties; import com.android.internal.widget.LockPatternUtils; import com.android.server.LocalServices; import com.android.server.UiThread; Loading Loading @@ -100,6 +101,11 @@ public class UserManagerServiceShellCommand extends ShellCommand { pw.println(" --reboot (which does a full reboot) or"); pw.println(" --no-restart (which requires a manual restart)"); pw.println(); pw.println(" is-headless-system-user-mode [-v | --verbose]"); pw.println(" Checks whether the device uses headless system user mode."); pw.println(" It returns the effective mode, even when using emulation"); pw.println(" (to get the real mode as well, use -v or --verbose)"); pw.println(); pw.println(" is-user-visible [--display DISPLAY_ID] <USER_ID>"); pw.println(" Checks if the given user is visible in the given display."); pw.println(" If the display option is not set, it uses the user's context to check"); Loading @@ -121,6 +127,8 @@ public class UserManagerServiceShellCommand extends ShellCommand { return runReportPackageAllowlistProblems(); case "set-system-user-mode-emulation": return runSetSystemUserModeEmulation(); case "is-headless-system-user-mode": return runIsHeadlessSystemUserMode(); case "is-user-visible": return runIsUserVisible(); default: Loading Loading @@ -407,6 +415,35 @@ public class UserManagerServiceShellCommand extends ShellCommand { return 0; } private int runIsHeadlessSystemUserMode() { PrintWriter pw = getOutPrintWriter(); boolean verbose = false; String opt; while ((opt = getNextOption()) != null) { switch (opt) { case "-v": case "--verbose": verbose = true; break; default: pw.println("Invalid option: " + opt); return -1; } } boolean isHsum = mService.isHeadlessSystemUserMode(); if (!verbose) { // NOTE: do not change output below, as it's used by ITestDevice // (it's ok to change the verbose option though) pw.println(isHsum); } else { pw.printf("effective=%b real=%b\n", isHsum, RoSystemProperties.MULTIUSER_HEADLESS_SYSTEM_USER); } return 0; } /** * Gets the {@link UserManager} associated with the context of the given user. */ Loading