Merge "AOD: Introduce night brightness bucket" into oc-dr1-dev
am: 6b978e0106
Change-Id: Ic38d249c68646a4ae4c4d34d0f4a612f75d5bbbd
diff --git a/packages/SystemUI/res/values/config.xml b/packages/SystemUI/res/values/config.xml
index ed200ad..5917dc5 100644
--- a/packages/SystemUI/res/values/config.xml
+++ b/packages/SystemUI/res/values/config.xml
@@ -267,14 +267,15 @@
<!-- Doze: alpha to apply to small icons when dozing -->
<integer name="doze_small_icon_alpha">222</integer><!-- 87% of 0xff -->
- <!-- Doze: the brightness value to use for the lower brightness AOD mode -->
- <integer name="config_doze_aod_brightness_low">5</integer>
-
- <!-- Doze: the brightness value to use for the higher brightness AOD mode -->
- <integer name="config_doze_aod_brightness_high">27</integer>
-
- <!-- Doze: the brightness value to use for the sunlight AOD mode -->
- <integer name="config_doze_aod_brightness_sunlight">28</integer>
+ <!-- Doze: Table that translates sensor values from the doze_brightness_sensor_type sensor
+ to brightness values; -1 means keeping the current brightness. -->
+ <integer-array name="config_doze_brightness_sensor_to_brightness">
+ <item>-1</item> <!-- 0: OFF -->
+ <item>2</item> <!-- 1: NIGHT -->
+ <item>5</item> <!-- 2: LOW -->
+ <item>27</item> <!-- 3: HIGH -->
+ <item>28</item> <!-- 4: SUN -->
+ </integer-array>
<!-- Doze: whether the double tap sensor reports 2D touch coordinates -->
<bool name="doze_double_tap_reports_touch_coordinates">false</bool>
diff --git a/packages/SystemUI/src/com/android/systemui/doze/DozeScreenBrightness.java b/packages/SystemUI/src/com/android/systemui/doze/DozeScreenBrightness.java
index ed4b131..32baf94 100644
--- a/packages/SystemUI/src/com/android/systemui/doze/DozeScreenBrightness.java
+++ b/packages/SystemUI/src/com/android/systemui/doze/DozeScreenBrightness.java
@@ -35,12 +35,9 @@
private final Handler mHandler;
private final SensorManager mSensorManager;
private final Sensor mLightSensor;
+ private final int[] mSensorToBrightness;
private boolean mRegistered;
- private final int mHighBrightness;
- private final int mLowBrightness;
- private final int mSunlightBrightness;
-
public DozeScreenBrightness(Context context, DozeMachine.Service service,
SensorManager sensorManager, Sensor lightSensor, Handler handler) {
mContext = context;
@@ -49,12 +46,8 @@
mLightSensor = lightSensor;
mHandler = handler;
- mLowBrightness = context.getResources().getInteger(
- R.integer.config_doze_aod_brightness_low);
- mHighBrightness = context.getResources().getInteger(
- R.integer.config_doze_aod_brightness_high);
- mSunlightBrightness = context.getResources().getInteger(
- R.integer.config_doze_aod_brightness_sunlight);
+ mSensorToBrightness = context.getResources().getIntArray(
+ R.array.config_doze_brightness_sensor_to_brightness);
}
@Override
@@ -81,21 +74,18 @@
@Override
public void onSensorChanged(SensorEvent event) {
if (mRegistered) {
- mDozeService.setDozeScreenBrightness(computeBrightness((int) event.values[0]));
+ int brightness = computeBrightness((int) event.values[0]);
+ if (brightness > 0) {
+ mDozeService.setDozeScreenBrightness(brightness);
+ }
}
}
private int computeBrightness(int sensorValue) {
- // The sensor reports 0 for off, 1 for low brightness, 2 for high brightness, and 3 for
- // sunlight. We currently use DozeScreenState for screen off, so we treat off as low
- // brightness.
- if (sensorValue >= 3) {
- return mSunlightBrightness;
- } else if (sensorValue == 2) {
- return mHighBrightness;
- } else {
- return mLowBrightness;
+ if (sensorValue < 0 || sensorValue >= mSensorToBrightness.length) {
+ return -1;
}
+ return mSensorToBrightness[sensorValue];
}
@Override