需求:
Rockchip-android11和android12系统亮度调节框调节亮度是曲线调节,需改为像低版本系统一样的线性调节效果(亮度递增效果)
解决方法:
代码路径:frameworks/base/packages/SettingsLib/src/com/android/settingslib/display/BrightnessUtils.java
--- a/packages/SettingsLib/src/com/android/settingslib/display/BrightnessUtils.java
+++ b/packages/SettingsLib/src/com/android/settingslib/display/BrightnessUtils.java
@@ -22,6 +22,7 @@ public class BrightnessUtils {
public static final int GAMMA_SPACE_MIN = 0;
public static final int GAMMA_SPACE_MAX = 65535;
+ public static final boolean ENABLE_GAMMA = false;
// Hybrid Log Gamma constant values
private static final float R = 0.5f;
@@ -75,6 +76,11 @@ public class BrightnessUtils {
* @return The corresponding setting value.
*/
public static final float convertGammaToLinearFloat(int val, float min, float max) {
+ if(!ENABLE_GAMMA){
+ float ratio = (float)val / GAMMA_SPACE_MAX;
+ return min + (float)(ratio * (max - min));
+ }
final float normalizedVal = MathUtils.norm(GAMMA_SPACE_MIN, GAMMA_SPACE_MAX, val);
final float ret;
if (normalizedVal <= R) {
@@ -127,6 +133,11 @@ public class BrightnessUtils {
* @return The corresponding slider value
*/
public static final int convertLinearToGammaFloat(float val, float min, float 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;