From 33a88ec88008ce6261c2d08a6282e2fd037f742f Mon Sep 17 00:00:00 2001
From: Chenyang Zhong <zhongcy95@gmail.com>
Date: Wed, 10 Aug 2022 09:21:04 -0400
Subject: [PATCH] mars: overlay: also set config_screenBrightnessDozeFloat

The PowerManagerService reads config_screenBrightnessDozeFloat first
and later falls back to config_screenBrightnessDim if the float
value is INVALID_BRIGHTNESS_IN_CONFIG [1]. The problem is that
config_screenBrightnessDozeFloat is set to 0.0 by default on the
frameworks side [2], so it will never be INVALID_BRIGHTNESS_IN_CONFIG.

As a result, mScreenBrightnessDoze is always initialized to 0.0f
if the device does not set config_screenBrightnessDozeFloat in an
overlay, which then causes BRIGHTNESS_CONSTRAINT_TYPE_DOZE to
always return 0.0f.

To prevent other framework components from getting an incorrect
doze config value, set this float in overlay as well.

[1] https://android.googlesource.com/platform/frameworks/base/+/refs/tags/android-12.1.0_r10/services/core/java/com/android/server/power/PowerManagerService.java#991
[2] https://android.googlesource.com/platform/frameworks/base/+/refs/tags/android-12.1.0_r10/core/res/res/values/config.xml#1333

Change-Id: If79a05c167aff39b38e234fea906cb7bbeed6381
Signed-off-by: Chenyang Zhong <zhongcy95@gmail.com>
---
 overlay/frameworks/base/core/res/res/values/config.xml | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/overlay/frameworks/base/core/res/res/values/config.xml b/overlay/frameworks/base/core/res/res/values/config.xml
index a0d4c24..80da1ef 100644
--- a/overlay/frameworks/base/core/res/res/values/config.xml
+++ b/overlay/frameworks/base/core/res/res/values/config.xml
@@ -393,6 +393,8 @@
          May be less than the minimum allowed brightness setting
          that can be set by the user. -->
     <integer name="config_screenBrightnessDoze">17</integer>
+    <!-- 16/254 = 0.06299212598 -->
+    <item name="config_screenBrightnessDozeFloat" format="float" type="dimen">0.062992</item>
 
     <!-- Screen brightness used to dim the screen when the user activity
          timeout expires.  May be less than the minimum allowed brightness setting
-- 
GitLab