Use -1.0f in SurfaceControl to turn off brightness
-1.0f is sent to SurfaceControl if the brightess is equal to 0.
0 was originally used; -1.0f is being used in preparation for using floating
point brightness in the whole framework.
Test: Manual
Bug: b/139959979
Change-Id: I7d72a8c39d1c225ea9c2a2651366111df3be355d
diff --git a/services/core/java/com/android/server/lights/LightsService.java b/services/core/java/com/android/server/lights/LightsService.java
index ac906bb..eaae2ed 100644
--- a/services/core/java/com/android/server/lights/LightsService.java
+++ b/services/core/java/com/android/server/lights/LightsService.java
@@ -84,8 +84,12 @@
if (DEBUG) {
Slog.d(TAG, "Using new setBrightness path!");
}
- SurfaceControl.setDisplayBrightness(mDisplayToken,
- (float) brightness / mSurfaceControlMaximumBrightness);
+ if (brightness == 0) {
+ SurfaceControl.setDisplayBrightness(mDisplayToken, -1.0f);
+ } else {
+ SurfaceControl.setDisplayBrightness(mDisplayToken,
+ (float) (brightness - 1) / (mSurfaceControlMaximumBrightness - 1));
+ }
} else {
int color = brightness & 0x000000ff;
color = 0xff000000 | (color << 16) | (color << 8) | color;