@@ -116,7 +116,6 @@ public class KeyguardViewMediator implements KeyguardViewCallback,
116116 private static final int KEYGUARD_DONE_AUTHENTICATING = 11 ;
117117 private static final int SET_HIDDEN = 12 ;
118118 private static final int KEYGUARD_TIMEOUT = 13 ;
119- private static final int REPORT_SHOW_DONE = 14 ;
120119
121120 /**
122121 * The default amount of time we stay awake (used for all key input)
@@ -239,8 +238,6 @@ public class KeyguardViewMediator implements KeyguardViewCallback,
239238
240239 private boolean mScreenOn = false ;
241240
242- private boolean mShowPending = false ;
243-
244241 // last known state of the cellular connection
245242 private String mPhoneState = TelephonyManager .EXTRA_STATE_IDLE ;
246243
@@ -383,32 +380,20 @@ public void onScreenTurnedOff(int why) {
383380 } else if (why == WindowManagerPolicy .OFF_BECAUSE_OF_PROX_SENSOR ) {
384381 // Do not enable the keyguard if the prox sensor forced the screen off.
385382 } else {
386- if (!doKeyguardLocked () && why == WindowManagerPolicy .OFF_BECAUSE_OF_USER ) {
387- // The user has explicitly turned off the screen, causing it
388- // to lock. We want to block here until the keyguard window
389- // has shown, so the power manager won't complete the screen
390- // off flow until that point, so we know it won't turn *on*
391- // the screen until this is done.
392- while (mShowPending ) {
393- try {
394- wait ();
395- } catch (InterruptedException e ) {
396- }
397- }
398- }
383+ doKeyguardLocked ();
399384 }
400385 }
401386 }
402387
403388 /**
404389 * Let's us know the screen was turned on.
405390 */
406- public void onScreenTurnedOn () {
391+ public void onScreenTurnedOn (KeyguardViewManager . ShowListener showListener ) {
407392 synchronized (this ) {
408393 mScreenOn = true ;
409394 mDelayedShowingSequence ++;
410395 if (DEBUG ) Log .d (TAG , "onScreenTurnedOn, seq = " + mDelayedShowingSequence );
411- notifyScreenOnLocked ();
396+ notifyScreenOnLocked (showListener );
412397 }
413398 }
414399
@@ -573,7 +558,7 @@ public boolean doLidChangeTq(boolean isLidOpen) {
573558 * work that will happen is done; returns false if the caller can wait for
574559 * the keyguard to be shown.
575560 */
576- private boolean doKeyguardLocked () {
561+ private void doKeyguardLocked () {
577562 // if another app is disabling us, don't show
578563 if (!mExternallyEnabled ) {
579564 if (DEBUG ) Log .d (TAG , "doKeyguard: not showing because externally disabled" );
@@ -587,13 +572,13 @@ private boolean doKeyguardLocked() {
587572 // ends (see the broadcast receiver below)
588573 // TODO: clean this up when we have better support at the window manager level
589574 // for apps that wish to be on top of the keyguard
590- return true ;
575+ return ;
591576 }
592577
593578 // if the keyguard is already showing, don't bother
594579 if (mKeyguardViewManager .isShowing ()) {
595580 if (DEBUG ) Log .d (TAG , "doKeyguard: not showing because it is already showing" );
596- return true ;
581+ return ;
597582 }
598583
599584 // if the setup wizard hasn't run yet, don't show
@@ -609,18 +594,16 @@ private boolean doKeyguardLocked() {
609594 if (!lockedOrMissing && !provisioned ) {
610595 if (DEBUG ) Log .d (TAG , "doKeyguard: not showing because device isn't provisioned"
611596 + " and the sim is not locked or missing" );
612- return true ;
597+ return ;
613598 }
614599
615600 if (mLockPatternUtils .isLockScreenDisabled ()) {
616601 if (DEBUG ) Log .d (TAG , "doKeyguard: not showing because lockscreen is off" );
617- return true ;
602+ return ;
618603 }
619604
620605 if (DEBUG ) Log .d (TAG , "doKeyguard: showing the lock screen" );
621- mShowPending = true ;
622606 showLocked ();
623- return false ;
624607 }
625608
626609 /**
@@ -658,9 +641,10 @@ private void notifyScreenOffLocked() {
658641 * @see #onScreenTurnedOn()
659642 * @see #handleNotifyScreenOn
660643 */
661- private void notifyScreenOnLocked () {
644+ private void notifyScreenOnLocked (KeyguardViewManager . ShowListener showListener ) {
662645 if (DEBUG ) Log .d (TAG , "notifyScreenOnLocked" );
663- mHandler .sendEmptyMessage (NOTIFY_SCREEN_ON );
646+ Message msg = mHandler .obtainMessage (NOTIFY_SCREEN_ON , showListener );
647+ mHandler .sendMessage (msg );
664648 }
665649
666650 /**
@@ -974,7 +958,7 @@ public void handleMessage(Message msg) {
974958 handleNotifyScreenOff ();
975959 return ;
976960 case NOTIFY_SCREEN_ON :
977- handleNotifyScreenOn ();
961+ handleNotifyScreenOn (( KeyguardViewManager . ShowListener ) msg . obj );
978962 return ;
979963 case WAKE_WHEN_READY :
980964 handleWakeWhenReady (msg .arg1 );
@@ -996,12 +980,6 @@ public void handleMessage(Message msg) {
996980 doKeyguardLocked ();
997981 }
998982 break ;
999- case REPORT_SHOW_DONE :
1000- synchronized (KeyguardViewMediator .this ) {
1001- mShowPending = false ;
1002- KeyguardViewMediator .this .notifyAll ();
1003- }
1004- break ;
1005983 }
1006984 }
1007985 };
@@ -1113,12 +1091,6 @@ private void handleShow() {
11131091 playSounds (true );
11141092
11151093 mShowKeyguardWakeLock .release ();
1116-
1117- // We won't say the show is done yet because the view hierarchy
1118- // still needs to do the traversal. Posting this message allows
1119- // us to hold off until that is done.
1120- Message msg = mHandler .obtainMessage (REPORT_SHOW_DONE );
1121- mHandler .sendMessage (msg );
11221094 }
11231095 }
11241096
@@ -1284,10 +1256,10 @@ private void handleNotifyScreenOff() {
12841256 * Handle message sent by {@link #notifyScreenOnLocked()}
12851257 * @see #NOTIFY_SCREEN_ON
12861258 */
1287- private void handleNotifyScreenOn () {
1259+ private void handleNotifyScreenOn (KeyguardViewManager . ShowListener showListener ) {
12881260 synchronized (KeyguardViewMediator .this ) {
12891261 if (DEBUG ) Log .d (TAG , "handleNotifyScreenOn" );
1290- mKeyguardViewManager .onScreenTurnedOn ();
1262+ mKeyguardViewManager .onScreenTurnedOn (showListener );
12911263 }
12921264 }
12931265
0 commit comments