Merge "Set backlight brightness in correct order." into jb-mr1-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
86e85efe9b
@@ -239,6 +239,7 @@ final class DisplayPowerState {
|
|||||||
private void apply() {
|
private void apply() {
|
||||||
if (mDirty != 0) {
|
if (mDirty != 0) {
|
||||||
if ((mDirty & DIRTY_SCREEN_ON) != 0 && !mScreenOn) {
|
if ((mDirty & DIRTY_SCREEN_ON) != 0 && !mScreenOn) {
|
||||||
|
mScreenBrightnessModulator.setBrightness(0, true /*sync*/);
|
||||||
PowerManagerService.nativeSetScreenState(false);
|
PowerManagerService.nativeSetScreenState(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -246,15 +247,16 @@ final class DisplayPowerState {
|
|||||||
mElectronBeam.draw(mElectronBeamLevel);
|
mElectronBeam.draw(mElectronBeamLevel);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((mDirty & (DIRTY_BRIGHTNESS | DIRTY_SCREEN_ON | DIRTY_ELECTRON_BEAM)) != 0) {
|
|
||||||
mScreenBrightnessModulator.setBrightness(mScreenOn ?
|
|
||||||
(int)(mScreenBrightness * mElectronBeamLevel) : 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((mDirty & DIRTY_SCREEN_ON) != 0 && mScreenOn) {
|
if ((mDirty & DIRTY_SCREEN_ON) != 0 && mScreenOn) {
|
||||||
PowerManagerService.nativeSetScreenState(true);
|
PowerManagerService.nativeSetScreenState(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ((mDirty & (DIRTY_BRIGHTNESS | DIRTY_SCREEN_ON | DIRTY_ELECTRON_BEAM)) != 0
|
||||||
|
&& mScreenOn) {
|
||||||
|
mScreenBrightnessModulator.setBrightness(
|
||||||
|
(int)(mScreenBrightness * mElectronBeamLevel), false /*sync*/);
|
||||||
|
}
|
||||||
|
|
||||||
mDirty = 0;
|
mDirty = 0;
|
||||||
|
|
||||||
if (mCleanListener != null) {
|
if (mCleanListener != null) {
|
||||||
|
|||||||
@@ -49,11 +49,12 @@ final class PhotonicModulator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Asynchronously sets the backlight brightness.
|
* Sets the backlight brightness, synchronously or asynchronously.
|
||||||
*
|
*
|
||||||
* @param lightValue The new light value, from 0 to 255.
|
* @param lightValue The new light value, from 0 to 255.
|
||||||
|
* @param sync If true, waits for the brightness change to complete before returning.
|
||||||
*/
|
*/
|
||||||
public void setBrightness(int lightValue) {
|
public void setBrightness(int lightValue, boolean sync) {
|
||||||
synchronized (mLock) {
|
synchronized (mLock) {
|
||||||
if (lightValue != mPendingLightValue) {
|
if (lightValue != mPendingLightValue) {
|
||||||
mPendingLightValue = lightValue;
|
mPendingLightValue = lightValue;
|
||||||
@@ -63,6 +64,15 @@ final class PhotonicModulator {
|
|||||||
mExecutor.execute(mTask);
|
mExecutor.execute(mTask);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (sync) {
|
||||||
|
while (mPendingChange) {
|
||||||
|
try {
|
||||||
|
mLock.wait();
|
||||||
|
} catch (InterruptedException ex) {
|
||||||
|
// ignore it
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -76,6 +86,7 @@ final class PhotonicModulator {
|
|||||||
if (newLightValue == mActualLightValue) {
|
if (newLightValue == mActualLightValue) {
|
||||||
mSuspendBlocker.release();
|
mSuspendBlocker.release();
|
||||||
mPendingChange = false;
|
mPendingChange = false;
|
||||||
|
mLock.notifyAll();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
mActualLightValue = newLightValue;
|
mActualLightValue = newLightValue;
|
||||||
|
|||||||
Reference in New Issue
Block a user