Skip to content

Commit fb49cd9

Browse files
Dianne HackbornAndroid (Google) Code Review
authored andcommitted
Merge "Fix issue #5355844: PowerManager does not call screenTurningOn after boot."
2 parents 5840639 + 4001109 commit fb49cd9

2 files changed

Lines changed: 47 additions & 23 deletions

File tree

policy/src/com/android/internal/policy/impl/PhoneWindowManager.java

Lines changed: 39 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -716,6 +716,13 @@ public void init(Context context, IWindowManager windowManager,
716716

717717
// Controls rotation and the like.
718718
initializeHdmiState();
719+
720+
// Match current screen state.
721+
if (mPowerManager.isScreenOn()) {
722+
screenTurningOn(null);
723+
} else {
724+
screenTurnedOff(WindowManagerPolicy.OFF_BECAUSE_OF_USER);
725+
}
719726
}
720727

721728
public void setInitialDisplaySize(int width, int height) {
@@ -2780,31 +2787,42 @@ public void screenTurnedOff(int why) {
27802787
/** {@inheritDoc} */
27812788
public void screenTurningOn(final ScreenOnListener screenOnListener) {
27822789
EventLog.writeEvent(70000, 1);
2783-
//Slog.i(TAG, "Screen turning on...");
2784-
mKeyguardMediator.onScreenTurnedOn(new KeyguardViewManager.ShowListener() {
2785-
@Override public void onShown(IBinder windowToken) {
2786-
if (windowToken != null) {
2787-
try {
2788-
mWindowManager.waitForWindowDrawn(windowToken, new IRemoteCallback.Stub() {
2789-
@Override public void sendResult(Bundle data) {
2790-
Slog.i(TAG, "Lock screen displayed!");
2791-
screenOnListener.onScreenOn();
2792-
synchronized (mLock) {
2793-
mScreenOnFully = true;
2790+
if (false) {
2791+
RuntimeException here = new RuntimeException("here");
2792+
here.fillInStackTrace();
2793+
Slog.i(TAG, "Screen turning on...", here);
2794+
}
2795+
if (screenOnListener != null) {
2796+
mKeyguardMediator.onScreenTurnedOn(new KeyguardViewManager.ShowListener() {
2797+
@Override public void onShown(IBinder windowToken) {
2798+
if (windowToken != null) {
2799+
try {
2800+
mWindowManager.waitForWindowDrawn(windowToken,
2801+
new IRemoteCallback.Stub() {
2802+
@Override public void sendResult(Bundle data) {
2803+
Slog.i(TAG, "Lock screen displayed!");
2804+
screenOnListener.onScreenOn();
2805+
synchronized (mLock) {
2806+
mScreenOnFully = true;
2807+
}
27942808
}
2795-
}
2796-
});
2797-
} catch (RemoteException e) {
2798-
}
2799-
} else {
2800-
Slog.i(TAG, "No lock screen!");
2801-
screenOnListener.onScreenOn();
2802-
synchronized (mLock) {
2803-
mScreenOnFully = true;
2809+
});
2810+
} catch (RemoteException e) {
2811+
}
2812+
} else {
2813+
Slog.i(TAG, "No lock screen!");
2814+
screenOnListener.onScreenOn();
2815+
synchronized (mLock) {
2816+
mScreenOnFully = true;
2817+
}
28042818
}
28052819
}
2820+
});
2821+
} else {
2822+
synchronized (mLock) {
2823+
mScreenOnFully = true;
28062824
}
2807-
});
2825+
}
28082826
synchronized (mLock) {
28092827
mScreenOnEarly = true;
28102828
updateOrientationListenerLp();

services/java/com/android/server/PowerManagerService.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -564,6 +564,7 @@ protected void onLooperPrepared() {
564564
// We make sure to start out with the screen on due to user activity.
565565
// (They did just boot their device, after all.)
566566
forceUserActivityLocked();
567+
mInitialized = true;
567568
}
568569
}
569570

@@ -1330,6 +1331,13 @@ private void sendNotificationLocked(boolean on, int why) {
13301331
// (And also do not send needless broadcasts about the screen.)
13311332
return;
13321333
}
1334+
1335+
if (DEBUG_SCREEN_ON) {
1336+
RuntimeException here = new RuntimeException("here");
1337+
here.fillInStackTrace();
1338+
Slog.i(TAG, "sendNotificationLocked: " + on, here);
1339+
}
1340+
13331341
if (!on) {
13341342
mStillNeedSleepNotification = false;
13351343
}
@@ -1845,8 +1853,6 @@ private void setPowerState(int newState, boolean noChangeLights, int reason)
18451853
mPowerState = (mPowerState & ~LIGHTS_MASK) | (newState & LIGHTS_MASK);
18461854

18471855
updateNativePowerStateLocked();
1848-
1849-
mInitialized = true;
18501856
}
18511857
}
18521858

0 commit comments

Comments
 (0)