Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 4b5b3c6c authored by Philip Quinn's avatar Philip Quinn
Browse files

Don't block the input thread to notify the StatusBar about key events.

Also, give it a ping for volume key events.

Bug: 63183852
Bug: 63909062
Test: runtest systemui

Change-Id: I3e8507ad8fc23cf3078313b500b5012afc84fa07
parent 59aadea8
Loading
Loading
Loading
Loading
+31 −17
Original line number Original line Diff line number Diff line
@@ -816,6 +816,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
    private static final int MSG_BUGREPORT_TV = 22;
    private static final int MSG_BUGREPORT_TV = 22;
    private static final int MSG_ACCESSIBILITY_TV = 23;
    private static final int MSG_ACCESSIBILITY_TV = 23;
    private static final int MSG_DISPATCH_BACK_KEY_TO_AUTOFILL = 24;
    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_STATUS = 0;
    private static final int MSG_REQUEST_TRANSIENT_BARS_ARG_NAVIGATION = 1;
    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:
                case MSG_DISPATCH_BACK_KEY_TO_AUTOFILL:
                    mAutofillManagerInternal.onBackKeyPressed();
                    mAutofillManagerInternal.onBackKeyPressed();
                    break;
                    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.
        // Inform the StatusBar; but do not allow it to consume the event.
        IStatusBarService statusBar = getStatusBarService();
        sendSystemKeyToStatusBarAsync(event.getKeyCode());
        if (statusBar != null) {
            try {
                statusBar.handleSystemKey(event.getKeyCode());
            } catch (RemoteException e) {
                // Oh well.
            }
        }


        // If the power key has still not yet been handled, then detect short
        // If the power key has still not yet been handled, then detect short
        // press, long press, or multi press and decide what to do.
        // press, long press, or multi press and decide what to do.
@@ -5982,6 +5979,8 @@ public class PhoneWindowManager implements WindowManagerPolicy {
                    }
                    }
                }
                }
                if (down) {
                if (down) {
                    sendSystemKeyToStatusBarAsync(event.getKeyCode());

                    TelecomManager telecomManager = getTelecommService();
                    TelecomManager telecomManager = getTelecommService();
                    if (telecomManager != null) {
                    if (telecomManager != null) {
                        if (telecomManager.isRinging()) {
                        if (telecomManager.isRinging()) {
@@ -6019,7 +6018,6 @@ public class PhoneWindowManager implements WindowManagerPolicy {
                                event, AudioManager.USE_DEFAULT_STREAM_TYPE, false);
                                event, AudioManager.USE_DEFAULT_STREAM_TYPE, false);
                        break;
                        break;
                    }
                    }

                }
                }
                if (mUseTvRouting || mHandleVolumeKeysInWM) {
                if (mUseTvRouting || mHandleVolumeKeysInWM) {
                    // Defer special key handlings to
                    // Defer special key handlings to
@@ -6225,17 +6223,33 @@ public class PhoneWindowManager implements WindowManagerPolicy {
            if (!mAccessibilityManager.isEnabled()
            if (!mAccessibilityManager.isEnabled()
                    || !mAccessibilityManager.sendFingerprintGesture(event.getKeyCode())) {
                    || !mAccessibilityManager.sendFingerprintGesture(event.getKeyCode())) {
                if (areSystemNavigationKeysEnabled()) {
                if (areSystemNavigationKeysEnabled()) {
                    IStatusBarService sbar = getStatusBarService();
                    sendSystemKeyToStatusBarAsync(event.getKeyCode());
                    if (sbar != null) {
                }
                        try {
                            sbar.handleSystemKey(event.getKeyCode());
                        } catch (RemoteException e1) {
                            // oops, no statusbar. Ignore event.
            }
            }
        }
        }
    }
    }

    /**
     * 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);
    }
    }


    /**
    /**