diff options
| author | 2017-07-26 02:44:56 +0000 | |
|---|---|---|
| committer | 2017-07-26 02:44:56 +0000 | |
| commit | 6ccaea570dcedada57d0c2bcda1f969bf1adf866 (patch) | |
| tree | 5e511e35a8995e79308b1036f22f6486d4d4154a | |
| parent | 9e7262732c33be3b62f03cebd3ca287166364cd1 (diff) | |
| parent | 4b5b3c6ccc5c22377d2b3a2514c895f9a7bde85a (diff) | |
Don't block the input thread to notify the StatusBar about key events.
am: 4b5b3c6ccc
Change-Id: Ie5e9f5a71b49c7eca1d646d72680998aef39f69c
| -rw-r--r-- | services/core/java/com/android/server/policy/PhoneWindowManager.java | 48 |
1 files changed, 31 insertions, 17 deletions
diff --git a/services/core/java/com/android/server/policy/PhoneWindowManager.java b/services/core/java/com/android/server/policy/PhoneWindowManager.java index e89ab1de7b65..e3cf459774e9 100644 --- a/services/core/java/com/android/server/policy/PhoneWindowManager.java +++ b/services/core/java/com/android/server/policy/PhoneWindowManager.java @@ -816,6 +816,7 @@ public class PhoneWindowManager implements WindowManagerPolicy { private static final int MSG_BUGREPORT_TV = 22; private static final int MSG_ACCESSIBILITY_TV = 23; private static final int MSG_DISPATCH_BACK_KEY_TO_AUTOFILL = 24; + private static final int MSG_SYSTEM_KEY_PRESS = 25; private static final int MSG_REQUEST_TRANSIENT_BARS_ARG_STATUS = 0; private static final int MSG_REQUEST_TRANSIENT_BARS_ARG_NAVIGATION = 1; @@ -905,6 +906,9 @@ public class PhoneWindowManager implements WindowManagerPolicy { case MSG_DISPATCH_BACK_KEY_TO_AUTOFILL: mAutofillManagerInternal.onBackKeyPressed(); break; + case MSG_SYSTEM_KEY_PRESS: + sendSystemKeyToStatusBar(msg.arg1); + break; } } } @@ -1276,14 +1280,7 @@ public class PhoneWindowManager implements WindowManagerPolicy { } // Inform the StatusBar; but do not allow it to consume the event. - IStatusBarService statusBar = getStatusBarService(); - if (statusBar != null) { - try { - statusBar.handleSystemKey(event.getKeyCode()); - } catch (RemoteException e) { - // Oh well. - } - } + sendSystemKeyToStatusBarAsync(event.getKeyCode()); // If the power key has still not yet been handled, then detect short // press, long press, or multi press and decide what to do. @@ -5982,6 +5979,8 @@ public class PhoneWindowManager implements WindowManagerPolicy { } } if (down) { + sendSystemKeyToStatusBarAsync(event.getKeyCode()); + TelecomManager telecomManager = getTelecommService(); if (telecomManager != null) { if (telecomManager.isRinging()) { @@ -6019,7 +6018,6 @@ public class PhoneWindowManager implements WindowManagerPolicy { event, AudioManager.USE_DEFAULT_STREAM_TYPE, false); break; } - } if (mUseTvRouting || mHandleVolumeKeysInWM) { // Defer special key handlings to @@ -6225,20 +6223,36 @@ public class PhoneWindowManager implements WindowManagerPolicy { if (!mAccessibilityManager.isEnabled() || !mAccessibilityManager.sendFingerprintGesture(event.getKeyCode())) { if (areSystemNavigationKeysEnabled()) { - IStatusBarService sbar = getStatusBarService(); - if (sbar != null) { - try { - sbar.handleSystemKey(event.getKeyCode()); - } catch (RemoteException e1) { - // oops, no statusbar. Ignore event. - } - } + sendSystemKeyToStatusBarAsync(event.getKeyCode()); } } } } /** + * Notify the StatusBar that a system key was pressed. + */ + private void sendSystemKeyToStatusBar(int keyCode) { + IStatusBarService statusBar = getStatusBarService(); + if (statusBar != null) { + try { + statusBar.handleSystemKey(keyCode); + } catch (RemoteException e) { + // Oh well. + } + } + } + + /** + * Notify the StatusBar that a system key was pressed without blocking the current thread. + */ + private void sendSystemKeyToStatusBarAsync(int keyCode) { + Message message = mHandler.obtainMessage(MSG_SYSTEM_KEY_PRESS, keyCode, 0); + message.setAsynchronous(true); + mHandler.sendMessage(message); + } + + /** * Returns true if the key can have global actions attached to it. * We reserve all power management keys for the system since they require * very careful handling. |