Android 9.0 亮度调节不线性,是因为伽马曲线的原因,去掉就行
亮度调节时,部分亮度值,屏幕亮度显示一致
如:0%–11%、12%-- 25%、26%–34%…
--- a/frameworks/base/packages/SettingsLib/src/com/android/settingslib/display/BrightnessUtils.java
+++ b/frameworks/base/packages/SettingsLib/src/com/android/settingslib/display/BrightnessUtils.java
@@ -21,6 +21,7 @@ import android.util.MathUtils;
public class BrightnessUtils {
public static final int GAMMA_SPACE_MAX = 1023;
+ public static final boolean ENABLE_GAMMA = false;
// Hybrid Log Gamma constant values
private static final float R = 0.5f;
@@ -51,6 +52,10 @@ public class BrightnessUtils {
* @return The corresponding setting value.
*/
public static final int convertGammaToLinear(int val, int min, int max) {
+ if(!ENABLE_GAMMA){
+ float ratio = (float)val / GAMMA_SPACE_MAX;
+ return min + (int)(ratio * (max - min));
+ }
final float normalizedVal = MathUtils.norm(0, GAMMA_SPACE_MAX, val);
final float ret;
if (normalizedVal <= R) {
@@ -87,6 +92,10 @@ public class BrightnessUtils {
* @return The corresponding slider value
*/
public static final int convertLinearToGamma(int val, int min, int max) {
+ if(!ENABLE_GAMMA){
+ float ratio = (float)(val - min)/ (max - min);
+ return (int)(ratio * GAMMA_SPACE_MAX);
+ }
// 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;
(END)