Merge "Invoke BrightnessSetting callbacks even with identical brightness." into tm-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
aabe27b7a4
@@ -102,13 +102,15 @@ public class BrightnessSetting {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
synchronized (mSyncRoot) {
|
synchronized (mSyncRoot) {
|
||||||
if (brightness == mBrightness) {
|
// If the brightness is the same, we still need to update any listeners as the act of
|
||||||
return;
|
// setting the brightness alone has side effects, like clearing any temporary
|
||||||
}
|
// brightness. We can skip persisting to disk, however, since it hasn't actually
|
||||||
|
// changed.
|
||||||
mBrightness = brightness;
|
if (brightness != mBrightness) {
|
||||||
mPersistentDataStore.setBrightness(mLogicalDisplay.getPrimaryDisplayDeviceLocked(),
|
mPersistentDataStore.setBrightness(mLogicalDisplay.getPrimaryDisplayDeviceLocked(),
|
||||||
brightness);
|
brightness);
|
||||||
|
}
|
||||||
|
mBrightness = brightness;
|
||||||
int toSend = Float.floatToIntBits(mBrightness);
|
int toSend = Float.floatToIntBits(mBrightness);
|
||||||
Message msg = mHandler.obtainMessage(MSG_BRIGHTNESS_CHANGED, toSend, 0);
|
Message msg = mHandler.obtainMessage(MSG_BRIGHTNESS_CHANGED, toSend, 0);
|
||||||
mHandler.sendMessage(msg);
|
mHandler.sendMessage(msg);
|
||||||
|
|||||||
@@ -3349,7 +3349,7 @@ public final class DisplayManagerService extends SystemService {
|
|||||||
synchronized (mSyncRoot) {
|
synchronized (mSyncRoot) {
|
||||||
DisplayPowerController dpc = mDisplayPowerControllers.get(displayId);
|
DisplayPowerController dpc = mDisplayPowerControllers.get(displayId);
|
||||||
if (dpc != null) {
|
if (dpc != null) {
|
||||||
dpc.putScreenBrightnessSetting(brightness);
|
dpc.setBrightness(brightness);
|
||||||
}
|
}
|
||||||
mPersistentDataStore.saveIfNeeded();
|
mPersistentDataStore.saveIfNeeded();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1345,7 +1345,7 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call
|
|||||||
if (mAppliedAutoBrightness && !autoBrightnessAdjustmentChanged) {
|
if (mAppliedAutoBrightness && !autoBrightnessAdjustmentChanged) {
|
||||||
slowChange = true; // slowly adapt to auto-brightness
|
slowChange = true; // slowly adapt to auto-brightness
|
||||||
}
|
}
|
||||||
updateScreenBrightnessSetting = true;
|
updateScreenBrightnessSetting = mCurrentScreenBrightnessSetting != brightnessState;
|
||||||
mAppliedAutoBrightness = true;
|
mAppliedAutoBrightness = true;
|
||||||
mBrightnessReasonTemp.setReason(BrightnessReason.REASON_AUTOMATIC);
|
mBrightnessReasonTemp.setReason(BrightnessReason.REASON_AUTOMATIC);
|
||||||
} else {
|
} else {
|
||||||
@@ -1415,7 +1415,7 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call
|
|||||||
// before applying the low power or dim transformations so that the slider
|
// before applying the low power or dim transformations so that the slider
|
||||||
// accurately represents the full possible range, even if they range changes what
|
// accurately represents the full possible range, even if they range changes what
|
||||||
// it means in absolute terms.
|
// it means in absolute terms.
|
||||||
putScreenBrightnessSetting(brightnessState, /* updateCurrent */ true);
|
updateScreenBrightnessSetting(brightnessState);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Apply dimming by at least some minimum amount when user activity
|
// Apply dimming by at least some minimum amount when user activity
|
||||||
@@ -2288,17 +2288,18 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call
|
|||||||
return clampScreenBrightnessForVr(brightnessFloat);
|
return clampScreenBrightnessForVr(brightnessFloat);
|
||||||
}
|
}
|
||||||
|
|
||||||
void putScreenBrightnessSetting(float brightnessValue) {
|
void setBrightness(float brightnessValue) {
|
||||||
putScreenBrightnessSetting(brightnessValue, false);
|
// Update the setting, which will eventually call back into DPC to have us actually update
|
||||||
|
// the display with the new value.
|
||||||
|
mBrightnessSetting.setBrightness(brightnessValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void putScreenBrightnessSetting(float brightnessValue, boolean updateCurrent) {
|
private void updateScreenBrightnessSetting(float brightnessValue) {
|
||||||
if (!isValidBrightnessValue(brightnessValue)) {
|
if (!isValidBrightnessValue(brightnessValue)
|
||||||
|
|| brightnessValue == mCurrentScreenBrightnessSetting) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (updateCurrent) {
|
|
||||||
setCurrentScreenBrightness(brightnessValue);
|
setCurrentScreenBrightness(brightnessValue);
|
||||||
}
|
|
||||||
mBrightnessSetting.setBrightness(brightnessValue);
|
mBrightnessSetting.setBrightness(brightnessValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user