4343
4444/**
4545 * Manages creating, showing, hiding and resetting the keyguard. Calls back
46- * via {@link com.android.internal.policy.impl.KeyguardViewCallback } to poke
46+ * via {@link KeyguardViewMediator.ViewMediatorCallback } to poke
4747 * the wake lock and report that the keyguard is done, which is in turn,
4848 * reported to this class by the current {@link KeyguardViewBase}.
4949 */
@@ -233,6 +233,7 @@ private void inflateKeyguardView(Bundle options) {
233233
234234 if (mScreenOn ) {
235235 mKeyguardView .show ();
236+ mKeyguardView .requestFocus ();
236237 }
237238 }
238239
@@ -314,22 +315,25 @@ public synchronized void onScreenTurnedOn(
314315
315316 // Caller should wait for this window to be shown before turning
316317 // on the screen.
317- if (mKeyguardHost .getVisibility () == View .VISIBLE ) {
318- // Keyguard may be in the process of being shown, but not yet
319- // updated with the window manager... give it a chance to do so.
320- mKeyguardHost .post (new Runnable () {
321- public void run () {
322- if (mKeyguardHost .getVisibility () == View .VISIBLE ) {
323- showListener .onShown (mKeyguardHost .getWindowToken ());
324- } else {
325- showListener .onShown (null );
318+ if (showListener != null ) {
319+ if (mKeyguardHost .getVisibility () == View .VISIBLE ) {
320+ // Keyguard may be in the process of being shown, but not yet
321+ // updated with the window manager... give it a chance to do so.
322+ mKeyguardHost .post (new Runnable () {
323+ @ Override
324+ public void run () {
325+ if (mKeyguardHost .getVisibility () == View .VISIBLE ) {
326+ showListener .onShown (mKeyguardHost .getWindowToken ());
327+ } else {
328+ showListener .onShown (null );
329+ }
326330 }
327- }
328- });
329- } else {
330- showListener . onShown ( null );
331+ });
332+ } else {
333+ showListener . onShown ( null );
334+ }
331335 }
332- } else {
336+ } else if ( showListener != null ) {
333337 showListener .onShown (null );
334338 }
335339 }
@@ -356,10 +360,9 @@ public boolean wakeWhenReadyTq(int keyCode) {
356360 if (mKeyguardView != null ) {
357361 mKeyguardView .wakeWhenReadyTq (keyCode );
358362 return true ;
359- } else {
360- Log .w (TAG , "mKeyguardView is null in wakeWhenReadyTq" );
361- return false ;
362363 }
364+ Log .w (TAG , "mKeyguardView is null in wakeWhenReadyTq" );
365+ return false ;
363366 }
364367
365368 /**
@@ -382,6 +385,7 @@ public synchronized void hide() {
382385 final KeyguardViewBase lastView = mKeyguardView ;
383386 mKeyguardView = null ;
384387 mKeyguardHost .postDelayed (new Runnable () {
388+ @ Override
385389 public void run () {
386390 synchronized (KeyguardViewManager .this ) {
387391 lastView .cleanUp ();
0 commit comments