From 05894aa2d24fd1cf7d4987d6a3a42356751c7fa8 Mon Sep 17 00:00:00 2001 From: Oleg Blinnikov Date: Mon, 8 Jul 2024 14:59:48 +0000 Subject: [PATCH] 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 --- .../display/DisplayManagerShellCommand.java | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/services/core/java/com/android/server/display/DisplayManagerShellCommand.java b/services/core/java/com/android/server/display/DisplayManagerShellCommand.java index d973b71366b1..2fea5dc7234d 100644 --- a/services/core/java/com/android/server/display/DisplayManagerShellCommand.java +++ b/services/core/java/com/android/server/display/DisplayManagerShellCommand.java @@ -62,6 +62,8 @@ public int onCommand(String cmd) { 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 @@ private int cancelNotifications() { 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) {