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

Commit fc31ea6d authored by Riddle Hsu's avatar Riddle Hsu
Browse files

Fix command format of wm density

The getNextOption consumes an argument, which causes the format
becomes "wm density -d -d 2".

So change to not read the next argument too early. It only need
to get if a "-d" option is found.

Bug: 186124236
Flag: EXEMPT bugfix
Test: Create a virtual display.
      adb shell wm density -d 2
      It should output the density of the display
Change-Id: I41f7c4301693e189d2f819643dc9bea2e7d15439
parent bd5e0d91
Loading
Loading
Loading
Loading
+4 −6
Original line number Diff line number Diff line
@@ -284,30 +284,28 @@ public class WindowManagerShellCommand extends ShellCommand {

    private int runDisplayDensity(PrintWriter pw) throws RemoteException {
        String densityStr = getNextArg();
        String option = getNextOption();
        String arg = getNextArg();
        int density;
        int displayId = Display.DEFAULT_DISPLAY;
        if ("-d".equals(option) && arg != null) {
        if ("-d".equals(densityStr) && arg != null) {
            try {
                displayId = Integer.parseInt(arg);
            } catch (NumberFormatException e) {
                getErrPrintWriter().println("Error: bad number " + e);
            }
        } else if ("-u".equals(option) && arg != null) {
            densityStr = getNextArg();
        } else if ("-u".equals(densityStr) && arg != null) {
            displayId = mInterface.getDisplayIdByUniqueId(arg);
            if (displayId == Display.INVALID_DISPLAY) {
                getErrPrintWriter().println("Error: the uniqueId is invalid ");
                return -1;
            }
            densityStr = getNextArg();
        }

        if (densityStr == null) {
            printInitialDisplayDensity(pw, displayId);
            return 0;
        } else if ("-d".equals(densityStr)) {
            printInitialDisplayDensity(pw, displayId);
            return 0;
        } else if ("reset".equals(densityStr)) {
            density = -1;
        } else {