Connect my plumbing to dsandler's awesome lights out mode.

It took a little bit of refactoring to move the authoritative state
about whether the lights are on or not into the StatusBarManagerService,
so that if the system ui process crashes, the bar comes up in the
right mode.

Change-Id: I95cfaf8f78ca4443ded5262272ea755d44dc5d17
This commit is contained in:
Joe Onorato
2010-09-12 17:03:19 -04:00
parent 9305647eb6
commit f63b0f44eb
4 changed files with 83 additions and 44 deletions

View File

@ -246,27 +246,53 @@ public class StatusBarManagerService extends IStatusBarService.Stub
}
}
/**
* This is used for the automatic version of lights-out mode. Only call this from
* the window manager.
*
* @see setLightsOn(boolean)
*/
public void setActiveWindowIsFullscreen(boolean fullscreen) {
// We could get away with a separate permission here, but STATUS_BAR is
// signatureOrSystem which is probably good enough. There is no public API
// for this, so the question is a security issue, not an API compatibility issue.
enforceStatusBar();
final boolean lightsOn = !fullscreen;
synchronized (mLock) {
if (mLightsOn != lightsOn) {
mLightsOn = lightsOn;
mHandler.post(new Runnable() {
public void run() {
if (mBar != null) {
try {
mBar.setLightsOn(lightsOn);
} catch (RemoteException ex) {
}
updateLightsOnLocked(!fullscreen);
}
}
/**
* This is used for the user-controlled version of lights-out mode. Only call this from
* the status bar itself.
*
* We have two different functions here, because I think we're going to want to
* tweak the behavior when the user keeps turning lights-out mode off and the
* app keeps trying to turn it on. For now they can just fight it out. Having
* these two separte inputs will allow us to keep that change local to here. --joeo
*/
public void setLightsOn(boolean lightsOn) {
enforceStatusBarService();
synchronized (mLock) {
updateLightsOnLocked(lightsOn);
}
}
private void updateLightsOnLocked(final boolean lightsOn) {
if (mLightsOn != lightsOn) {
mLightsOn = lightsOn;
mHandler.post(new Runnable() {
public void run() {
if (mBar != null) {
try {
mBar.setLightsOn(lightsOn);
} catch (RemoteException ex) {
}
}
});
}
}
});
}
}