Merge "AOD: Introduce night brightness bucket" into oc-dr1-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
6b978e0106
@@ -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>
|
||||
|
||||
@@ -35,12 +35,9 @@ public class DozeScreenBrightness implements DozeMachine.Part, SensorEventListen
|
||||
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 @@ public class DozeScreenBrightness implements DozeMachine.Part, SensorEventListen
|
||||
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 @@ public class DozeScreenBrightness implements DozeMachine.Part, SensorEventListen
|
||||
@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
|
||||
|
||||
Reference in New Issue
Block a user