From 8d81aca23a54414d0729b216b3e75b213371f340 Mon Sep 17 00:00:00 2001 From: Rupesh Bansal Date: Mon, 12 Sep 2022 10:27:44 +0000 Subject: [PATCH] Making the config_screenThresholdLevels a float array to fix the issue where it was always greater than all possible brightness values config_screenThresholdLevels is an integer array, which is internally compared with brightness in [0.0f,1.0f] to get the right index on which the brightening and darkening thresholds are to be applied. This means no matter what we have in the array, it will always be the first index that will win, and we will always apply the first brightening and darkening thresholds. To keep the settings backward compatible, we still accept the integer array for this threshold, and divide those thresholds with the scale range(255). Bug: 245746705 Test: Manual Test: adb shell dumpsys display | grep HysteresisLevels -A 5 Change-Id: I177d7a1aa48bdfb3385780f0eee7af689755efb4 --- core/res/res/values/config.xml | 9 ++- .../display/DisplayPowerController.java | 4 +- .../server/display/HysteresisLevels.java | 58 ++++++++++++++++++- 3 files changed, 64 insertions(+), 7 deletions(-) diff --git a/core/res/res/values/config.xml b/core/res/res/values/config.xml index b94bd83aac120..5d1acbc5a07ab 100644 --- a/core/res/res/values/config.xml +++ b/core/res/res/values/config.xml @@ -1662,13 +1662,18 @@ darkening hysteresis constraint value is the n-th element of config_screenDarkeningThresholds. + Historically, it has been assumed that this will be an integer array with values in the + range of [0, 255]. However, it is now assumed to be a float array with values in the + range of [0, 1]. To accommodate both the possibilities, we internally check the scale on + which the thresholds are defined, and calibrate it accordingly. + The (zero-based) index is calculated as follows: (MAX is the largest index of the array) condition calculated index value < level[0] 0 level[n] <= value < level[n+1] n+1 level[MAX] <= value MAX+1 --> - - + +