38 lines
1.7 KiB
Diff
38 lines
1.7 KiB
Diff
From 677389d4f112ca9368d55e1eb661727e5974eeb1 Mon Sep 17 00:00:00 2001
|
|
From: Pierre-Hugues Husson <phh@phh.me>
|
|
Date: Sun, 11 Aug 2019 10:30:37 +0200
|
|
Subject: [PATCH 29/36] Add property to use linear brightness slider
|
|
|
|
---
|
|
.../com/android/settingslib/display/BrightnessUtils.java | 6 ++++++
|
|
1 file changed, 6 insertions(+)
|
|
|
|
diff --git a/packages/SettingsLib/src/com/android/settingslib/display/BrightnessUtils.java b/packages/SettingsLib/src/com/android/settingslib/display/BrightnessUtils.java
|
|
index 55723f9d8ed..da8ce4a67e9 100644
|
|
--- a/packages/SettingsLib/src/com/android/settingslib/display/BrightnessUtils.java
|
|
+++ b/packages/SettingsLib/src/com/android/settingslib/display/BrightnessUtils.java
|
|
@@ -50,7 +50,12 @@ public class BrightnessUtils {
|
|
* @param max The maximum acceptable value for the setting.
|
|
* @return The corresponding setting value.
|
|
*/
|
|
+ private static final boolean useLinearBrightness = android.os.SystemProperties.getBoolean("persist.sys.phh.linear_brightness", false);
|
|
public static final int convertGammaToLinear(int val, int min, int max) {
|
|
+ if(useLinearBrightness) {
|
|
+ if(val < 4) return 1;
|
|
+ return val/4;
|
|
+ }
|
|
final float normalizedVal = MathUtils.norm(0, GAMMA_SPACE_MAX, val);
|
|
final float ret;
|
|
if (normalizedVal <= R) {
|
|
@@ -87,6 +92,7 @@ public class BrightnessUtils {
|
|
* @return The corresponding slider value
|
|
*/
|
|
public static final int convertLinearToGamma(int val, int min, int max) {
|
|
+ if(useLinearBrightness) return val*4;
|
|
// For some reason, HLG normalizes to the range [0, 12] rather than [0, 1]
|
|
final float normalizedVal = MathUtils.norm(min, max, val) * 12;
|
|
final float ret;
|
|
--
|
|
2.17.1
|
|
|