diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardHostViewController.java b/packages/SystemUI/src/com/android/keyguard/KeyguardHostViewController.java index 3fafa5c606bd4..ea60f0d403690 100644 --- a/packages/SystemUI/src/com/android/keyguard/KeyguardHostViewController.java +++ b/packages/SystemUI/src/com/android/keyguard/KeyguardHostViewController.java @@ -374,6 +374,17 @@ public class KeyguardHostViewController extends ViewController return !configDisabled || isTestHarness || fileOverride; } + /** + * @return true if the current bouncer is password + */ + public boolean dispatchBackKeyEventPreIme() { + if (mKeyguardSecurityContainerController.getCurrentSecurityMode() + == SecurityMode.Password) { + return true; + } + return false; + } + /** * Allows the media keys to work when the keyguard is showing. * The media keys should be of no interest to the actual keyguard view(s), diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBouncer.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBouncer.java index db0713cf0b7a8..7c7c6e62f45fb 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBouncer.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBouncer.java @@ -494,6 +494,14 @@ public class KeyguardBouncer { return mKeyguardViewController.interceptMediaKey(event); } + /** + * @return true if the pre IME back event should be handled + */ + public boolean dispatchBackKeyEventPreIme() { + ensureView(); + return mKeyguardViewController.dispatchBackKeyEventPreIme(); + } + public void notifyKeyguardAuthenticated(boolean strongAuth) { ensureView(); mKeyguardViewController.finish(strongAuth, KeyguardUpdateMonitor.getCurrentUser()); diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationShadeWindowView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationShadeWindowView.java index a4fc3a39c706a..619aadba9da05 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationShadeWindowView.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationShadeWindowView.java @@ -162,6 +162,11 @@ public class NotificationShadeWindowView extends FrameLayout { return mInteractionEventHandler.dispatchKeyEvent(event); } + @Override + public boolean dispatchKeyEventPreIme(KeyEvent event) { + return mInteractionEventHandler.dispatchKeyEventPreIme(event); + } + protected void setInteractionEventHandler(InteractionEventHandler listener) { mInteractionEventHandler = listener; } @@ -361,6 +366,8 @@ public class NotificationShadeWindowView extends FrameLayout { boolean interceptMediaKey(KeyEvent event); boolean dispatchKeyEvent(KeyEvent event); + + boolean dispatchKeyEventPreIme(KeyEvent event); } /** diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationShadeWindowViewController.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationShadeWindowViewController.java index 2ac9f301a89ab..5595ae7ed820a 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationShadeWindowViewController.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationShadeWindowViewController.java @@ -347,6 +347,11 @@ public class NotificationShadeWindowViewController { return mService.interceptMediaKey(event); } + @Override + public boolean dispatchKeyEventPreIme(KeyEvent event) { + return mService.dispatchKeyEventPreIme(event); + } + @Override public boolean dispatchKeyEvent(KeyEvent event) { boolean down = event.getAction() == KeyEvent.ACTION_DOWN; diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java index a18d87c301964..a991d3615fbb9 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java @@ -3520,6 +3520,23 @@ public class StatusBar extends SystemUI implements DemoMode, && mStatusBarKeyguardViewManager.interceptMediaKey(event); } + /** + * While IME is active and a BACK event is detected, check with + * {@link StatusBarKeyguardViewManager#dispatchBackKeyEventPreIme(KeyEvent)} to see if the event + * should be handled before routing to IME, in order to prevent the user having to hit back + * twice to exit bouncer. + */ + public boolean dispatchKeyEventPreIme(KeyEvent event) { + switch (event.getKeyCode()) { + case KeyEvent.KEYCODE_BACK: + if (mState == StatusBarState.KEYGUARD + && mStatusBarKeyguardViewManager.dispatchBackKeyEventPreIme()) { + return onBackPressed(); + } + } + return false; + } + protected boolean shouldUnlockOnMenuPressed() { return mDeviceInteractive && mState != StatusBarState.SHADE && mStatusBarKeyguardViewManager.shouldDismissOnMenuPressed(); diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManager.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManager.java index 055b78a2c0005..b4c687d36e6c4 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManager.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManager.java @@ -955,6 +955,13 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb return mBouncer.interceptMediaKey(event); } + /** + * @return true if the pre IME back event should be handled + */ + public boolean dispatchBackKeyEventPreIme() { + return mBouncer.dispatchBackKeyEventPreIme(); + } + public void readyForKeyguardDone() { mViewMediatorCallback.readyForKeyguardDone(); }