From 42df15e93d3eb70846270b26c024f1575e82fa06 Mon Sep 17 00:00:00 2001 From: Jim Miller Date: Wed, 5 Dec 2012 15:15:00 -0800 Subject: [PATCH] Fix password field focus in keyguard This fixes a bug introduced in Change-Id: I34b7db402401a824f463d35d7546c05dc2979243 where the top-most view was allowed to capture focus in order to ensure the device handled volume key events. This resolves the issue by restoring previous behavior and ensures we still handle media keys, regardless of focus. Fixes bug 7676996 Change-Id: Id2d1200be81640e4b4b7b5e3a0af099d6fc2d259 --- .../policy/impl/keyguard/KeyguardHostView.java | 5 ----- .../impl/keyguard/KeyguardViewManager.java | 17 ++++++++++++----- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/policy/src/com/android/internal/policy/impl/keyguard/KeyguardHostView.java b/policy/src/com/android/internal/policy/impl/keyguard/KeyguardHostView.java index 801b6275cbf9e..f1bc0f620ff5a 100644 --- a/policy/src/com/android/internal/policy/impl/keyguard/KeyguardHostView.java +++ b/policy/src/com/android/internal/policy/impl/keyguard/KeyguardHostView.java @@ -288,11 +288,6 @@ public class KeyguardHostView extends KeyguardViewBase { showPrimarySecurityScreen(false); updateSecurityViews(); - - // Make sure at least this view is focusable in case nothing below it is. Otherwise, - // requestFocus() on this view will fail and allow events, such as volume keys, to be - // handled by the fallback handler. See bug 7546960 for details. - setFocusableInTouchMode(true); } private boolean shouldEnableAddWidget() { diff --git a/policy/src/com/android/internal/policy/impl/keyguard/KeyguardViewManager.java b/policy/src/com/android/internal/policy/impl/keyguard/KeyguardViewManager.java index dac852a862bb0..b6cf4dab77ab1 100644 --- a/policy/src/com/android/internal/policy/impl/keyguard/KeyguardViewManager.java +++ b/policy/src/com/android/internal/policy/impl/keyguard/KeyguardViewManager.java @@ -153,11 +153,18 @@ public class KeyguardViewManager { @Override public boolean dispatchKeyEvent(KeyEvent event) { - if (event.getAction() == KeyEvent.ACTION_DOWN && mKeyguardView != null) { - int keyCode = event.getKeyCode(); - if (keyCode == KeyEvent.KEYCODE_BACK && mKeyguardView.handleBackKey()) { - return true; - } else if (keyCode == KeyEvent.KEYCODE_MENU && mKeyguardView.handleMenuKey()) { + if (mKeyguardView != null) { + // Always process back and menu keys, regardless of focus + if (event.getAction() == KeyEvent.ACTION_DOWN) { + int keyCode = event.getKeyCode(); + if (keyCode == KeyEvent.KEYCODE_BACK && mKeyguardView.handleBackKey()) { + return true; + } else if (keyCode == KeyEvent.KEYCODE_MENU && mKeyguardView.handleMenuKey()) { + return true; + } + } + // Always process media keys, regardless of focus + if (mKeyguardView.dispatchKeyEvent(event)) { return true; } }