?动背光调节主要过程是通过监听 light sensor 数据,得到对应的 Lux 值,再通过配置的背光曲线计算出当前的亮度,然后设置亮度值。
Settings.System.putInt(mContext.getContentResolver(), SCREEN_BRIGHTNESS_MODE,(isAuto ? 1 : 0) );//把设置的值写入
DisplayManagerService.java
@Override
public void initPowerManagement(final DisplayPowerCallbacks callbacks, Handler handler,
SensorManager sensorManager) {
synchronized (mSyncRoot) {
DisplayBlanker blanker = new DisplayBlanker() {
@Override
public void requestDisplayState(int state, float brightness) {
// The order of operations is important for legacy reasons.
if (state == Display.STATE_OFF) {
requestGlobalDisplayStateInternal(state, brightness);
}
callbacks.onDisplayStateChange(state);
|