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

Commit 61a65426 authored by Oleg Blinnikov's avatar Oleg Blinnikov Committed by Android (Google) Code Review
Browse files

Merge "Get brightness adb command" into main

parents 90735ac4 1661d5da
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":
@@ -313,6 +315,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) {