Merge "Fix issue #5355844: PowerManager does not call screenTurningOn after boot."

This commit is contained in:
Dianne Hackborn
2011-09-22 15:06:23 -07:00
committed by Android (Google) Code Review
2 changed files with 47 additions and 23 deletions

View File

@@ -716,6 +716,13 @@ public class PhoneWindowManager implements WindowManagerPolicy {
// Controls rotation and the like. // Controls rotation and the like.
initializeHdmiState(); initializeHdmiState();
// Match current screen state.
if (mPowerManager.isScreenOn()) {
screenTurningOn(null);
} else {
screenTurnedOff(WindowManagerPolicy.OFF_BECAUSE_OF_USER);
}
} }
public void setInitialDisplaySize(int width, int height) { public void setInitialDisplaySize(int width, int height) {
@@ -2780,31 +2787,42 @@ public class PhoneWindowManager implements WindowManagerPolicy {
/** {@inheritDoc} */ /** {@inheritDoc} */
public void screenTurningOn(final ScreenOnListener screenOnListener) { public void screenTurningOn(final ScreenOnListener screenOnListener) {
EventLog.writeEvent(70000, 1); EventLog.writeEvent(70000, 1);
//Slog.i(TAG, "Screen turning on..."); if (false) {
mKeyguardMediator.onScreenTurnedOn(new KeyguardViewManager.ShowListener() { RuntimeException here = new RuntimeException("here");
@Override public void onShown(IBinder windowToken) { here.fillInStackTrace();
if (windowToken != null) { Slog.i(TAG, "Screen turning on...", here);
try { }
mWindowManager.waitForWindowDrawn(windowToken, new IRemoteCallback.Stub() { if (screenOnListener != null) {
@Override public void sendResult(Bundle data) { mKeyguardMediator.onScreenTurnedOn(new KeyguardViewManager.ShowListener() {
Slog.i(TAG, "Lock screen displayed!"); @Override public void onShown(IBinder windowToken) {
screenOnListener.onScreenOn(); if (windowToken != null) {
synchronized (mLock) { try {
mScreenOnFully = true; mWindowManager.waitForWindowDrawn(windowToken,
new IRemoteCallback.Stub() {
@Override public void sendResult(Bundle data) {
Slog.i(TAG, "Lock screen displayed!");
screenOnListener.onScreenOn();
synchronized (mLock) {
mScreenOnFully = true;
}
} }
} });
}); } catch (RemoteException e) {
} catch (RemoteException e) { }
} } else {
} else { Slog.i(TAG, "No lock screen!");
Slog.i(TAG, "No lock screen!"); screenOnListener.onScreenOn();
screenOnListener.onScreenOn(); synchronized (mLock) {
synchronized (mLock) { mScreenOnFully = true;
mScreenOnFully = true; }
} }
} }
});
} else {
synchronized (mLock) {
mScreenOnFully = true;
} }
}); }
synchronized (mLock) { synchronized (mLock) {
mScreenOnEarly = true; mScreenOnEarly = true;
updateOrientationListenerLp(); updateOrientationListenerLp();

View File

@@ -564,6 +564,7 @@ public class PowerManagerService extends IPowerManager.Stub
// We make sure to start out with the screen on due to user activity. // We make sure to start out with the screen on due to user activity.
// (They did just boot their device, after all.) // (They did just boot their device, after all.)
forceUserActivityLocked(); forceUserActivityLocked();
mInitialized = true;
} }
} }
@@ -1330,6 +1331,13 @@ public class PowerManagerService extends IPowerManager.Stub
// (And also do not send needless broadcasts about the screen.) // (And also do not send needless broadcasts about the screen.)
return; return;
} }
if (DEBUG_SCREEN_ON) {
RuntimeException here = new RuntimeException("here");
here.fillInStackTrace();
Slog.i(TAG, "sendNotificationLocked: " + on, here);
}
if (!on) { if (!on) {
mStillNeedSleepNotification = false; mStillNeedSleepNotification = false;
} }
@@ -1845,8 +1853,6 @@ public class PowerManagerService extends IPowerManager.Stub
mPowerState = (mPowerState & ~LIGHTS_MASK) | (newState & LIGHTS_MASK); mPowerState = (mPowerState & ~LIGHTS_MASK) | (newState & LIGHTS_MASK);
updateNativePowerStateLocked(); updateNativePowerStateLocked();
mInitialized = true;
} }
} }