Skip to content

Commit

Permalink
Get brightness adb command
Browse files Browse the repository at this point in the history
Change-Id: I78dd79dfc49732da65c9af02fd4357598698b996
Bug: 349946564
Test: atest BrightnessTest
Flag: NONE not needed for the new adb command used in cts test
  • Loading branch information
osblinnikov authored and NurKeinNeid committed Dec 11, 2024
1 parent 0fb89bc commit 05894aa
Showing 1 changed file with 21 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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":
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 05894aa

Please sign in to comment.