Skip to content

Commit 0a34d9e

Browse files
author
Jim Miller
committed
Fix unresponsive back button in keyguard.
When keyguard doesn't have focus, events weren't being propagated to keyguard properly. The fix is to grab the back-button event from the top-level view and handle it there. Change-Id: Ied9761919cff30173f43f03e4c2a1732387e618e
1 parent f5e2b2c commit 0a34d9e

File tree

2 files changed

+20
-11
lines changed

2 files changed

+20
-11
lines changed

policy/src/com/android/internal/policy/impl/keyguard/KeyguardHostView.java

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -254,17 +254,6 @@ private void showDialog(String title, String message) {
254254
dialog.show();
255255
}
256256

257-
@Override
258-
public boolean dispatchKeyEvent(KeyEvent event) {
259-
if (event.getAction() == KeyEvent.ACTION_UP
260-
&& event.getKeyCode() == KeyEvent.KEYCODE_BACK
261-
&& mCurrentSecuritySelection != SecurityMode.None) {
262-
mCallback.dismiss(false);
263-
return true;
264-
}
265-
return super.dispatchKeyEvent(event);
266-
}
267-
268257
private void showTimeoutDialog() {
269258
int timeoutInSeconds = (int) LockPatternUtils.FAILED_ATTEMPT_TIMEOUT_MS / 1000;
270259
int messageId = 0;
@@ -856,4 +845,12 @@ public void goToUserSwitcher() {
856845
mAppWidgetContainer.setCurrentPage(getWidgetPosition(R.id.keyguard_multi_user_selector));
857846
}
858847

848+
public boolean handleBackKey() {
849+
if (mCurrentSecuritySelection != SecurityMode.None) {
850+
mCallback.dismiss(false);
851+
return true;
852+
}
853+
return false;
854+
}
855+
859856
}

policy/src/com/android/internal/policy/impl/keyguard/KeyguardViewManager.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,18 @@ protected void onConfigurationChanged(Configuration newConfig) {
126126
super.onConfigurationChanged(newConfig);
127127
maybeCreateKeyguardLocked(shouldEnableScreenRotation(), null);
128128
}
129+
130+
@Override
131+
public boolean dispatchKeyEvent(KeyEvent event) {
132+
if (event.getAction() == KeyEvent.ACTION_DOWN
133+
&& event.getKeyCode() == KeyEvent.KEYCODE_BACK
134+
&& mKeyguardView != null) {
135+
if (mKeyguardView.handleBackKey()) {
136+
return true;
137+
}
138+
}
139+
return super.dispatchKeyEvent(event);
140+
}
129141
}
130142

131143
SparseArray<Parcelable> mStateContainer = new SparseArray<Parcelable>();

0 commit comments

Comments
 (0)