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

Commit 1661d5da authored by Oleg Blinnikov's avatar Oleg Blinnikov
Browse files

Get brightness adb command

Change-Id: I78dd79dfc49732da65c9af02fd4357598698b996
Bug: 349946564
Test: atest BrightnessTest
Flag: NONE not needed for the new adb command used in cts test
parent 5cfb9787
Loading
Loading
Loading
Loading
+21 −0
Original line number Diff line number Diff line
@@ -62,6 +62,8 @@ class DisplayManagerShellCommand extends ShellCommand {
                return showNotification();
            case "cancel-notifications":
                return cancelNotifications();
            case "get-brightness":
                return getBrightness();
            case "set-brightness":
                return setBrightness();
            case "reset-brightness-configuration":
@@ -309,6 +311,25 @@ class DisplayManagerShellCommand extends ShellCommand {
        return 0;
    }

    private int getBrightness() {
        String displayIdString = getNextArg();
        if (displayIdString == null) {
            getErrPrintWriter().println("Error: no display id specified");
            return 1;
        }
        int displayId;
        try {
            displayId = Integer.parseInt(displayIdString);
        } catch (NumberFormatException e) {
            getErrPrintWriter().println("Error: invalid displayId=" + displayIdString + " not int");
            return 1;
        }
        final Context context = mService.getContext();
        final DisplayManager dm = context.getSystemService(DisplayManager.class);
        getOutPrintWriter().println(dm.getBrightness(displayId));
        return 0;
    }

    private int setBrightness() {
        String brightnessText = getNextArg();
        if (brightnessText == null) {