Merge "Update brightness percentage display logic to match sysui." into pi-dev am: 69d12406f0
am: e9045a7a41
Change-Id: I20c27b31caa7a44b6d114780a0b7b18206f75d12
diff --git a/src/com/android/settings/display/BrightnessLevelPreferenceController.java b/src/com/android/settings/display/BrightnessLevelPreferenceController.java
index e0aeda1..be79f66 100644
--- a/src/com/android/settings/display/BrightnessLevelPreferenceController.java
+++ b/src/com/android/settings/display/BrightnessLevelPreferenceController.java
@@ -13,6 +13,9 @@
*/
package com.android.settings.display;
+import static com.android.settingslib.display.BrightnessUtils.GAMMA_SPACE_MAX;
+import static com.android.settingslib.display.BrightnessUtils.convertLinearToGamma;
+
import android.content.ContentResolver;
import android.content.Context;
import android.database.ContentObserver;
@@ -63,12 +66,12 @@
}
private ContentObserver mBrightnessObserver =
- new ContentObserver(new Handler(Looper.getMainLooper())) {
- @Override
- public void onChange(boolean selfChange) {
- updatedSummary(mPreference);
- }
- };
+ new ContentObserver(new Handler(Looper.getMainLooper())) {
+ @Override
+ public void onChange(boolean selfChange) {
+ updatedSummary(mPreference);
+ }
+ };
public BrightnessLevelPreferenceController(Context context, Lifecycle lifecycle) {
super(context);
@@ -103,6 +106,7 @@
public void updateState(Preference preference) {
updatedSummary(preference);
}
+
@Override
public void onStart() {
mContentResolver.registerContentObserver(BRIGHTNESS_URI, false, mBrightnessObserver);
@@ -122,15 +126,18 @@
}
private double getCurrentBrightness() {
+ final int value;
if (isInVrMode()) {
- final double value = System.getInt(mContentResolver, System.SCREEN_BRIGHTNESS_FOR_VR,
- mMaxBrightness);
- return getPercentage(value, mMinVrBrightness, mMaxVrBrightness);
+ value = convertLinearToGamma(System.getInt(mContentResolver,
+ System.SCREEN_BRIGHTNESS_FOR_VR, mMaxBrightness),
+ mMinVrBrightness, mMaxVrBrightness);
} else {
- final double value = Settings.System.getInt(mContentResolver, System.SCREEN_BRIGHTNESS,
- mMinBrightness);
- return getPercentage(value, mMinBrightness, mMaxBrightness);
+ value = convertLinearToGamma(Settings.System.getInt(mContentResolver,
+ System.SCREEN_BRIGHTNESS, mMinBrightness),
+ mMinBrightness, mMaxBrightness);
+
}
+ return getPercentage(value, 0, GAMMA_SPACE_MAX);
}
private double getPercentage(double value, int min, int max) {
diff --git a/tests/robotests/src/com/android/settings/display/BrightnessLevelPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/display/BrightnessLevelPreferenceControllerTest.java
index 8980a50..b758531 100644
--- a/tests/robotests/src/com/android/settings/display/BrightnessLevelPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/display/BrightnessLevelPreferenceControllerTest.java
@@ -122,7 +122,7 @@
mController.updateState(mPreference);
- verify(mPreference).setSummary("85%");
+ verify(mPreference).setSummary("97%");
}
@Test
@@ -135,7 +135,7 @@
mController.updateState(mPreference);
- verify(mPreference).setSummary("31%");
+ verify(mPreference).setSummary("78%");
}
@Test
@@ -148,7 +148,7 @@
mController.updateState(mPreference);
- verify(mPreference).setSummary("45%");
+ verify(mPreference).setSummary("85%");
}
@Test