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

Commit 34cd5b0e authored by Vaibhav Devmurari's avatar Vaibhav Devmurari
Browse files

Handle back shortcuts in native and remove home shortcut handling

Home: This is fully handled by System and can be handled in
PhoneWindowManager like all the other shortcuts.
Note: We are knowingly removing Meta+Enter for home which is the
old shortcut and is replaced by Meta+H.

Back: This event need to be sent to application for handling. Since,
meta based shortcuts or KeyEvents are not sent to application, we
need to pre-convert Meta+` and Meta+arrow_left to KEYCODE_BACK before
sending to App.

Test: atest ShortcutDispatchTest
Bug: 270242945
Bug: 270241579
Change-Id: I7dc17891920f7a5d61b4b3172533610a6dd4d65e
parent d0998529
Loading
Loading
Loading
Loading
+8 −6
Original line number Diff line number Diff line
@@ -4036,18 +4036,20 @@ void InputDispatcher::notifyConfigurationChanged(const NotifyConfigurationChange

/**
 * If one of the meta shortcuts is detected, process them here:
 *     Meta + Backspace -> generate BACK
 *     Meta + Enter -> generate HOME
 * This will potentially overwrite keyCode and metaState.
 *     Meta + Backspace; Meta + Grave; Meta + Left arrow -> generate BACK
 * Most System shortcuts are handled in PhoneWindowManager.java except 'Back' shortcuts. Unlike
 * Back, other shortcuts DO NOT need to be sent to applications and are fully handled by the system.
 * But for Back key and Back shortcuts, we need to send KEYCODE_BACK to applications which can
 * potentially handle the back key presses.
 * Note: We don't send any Meta based KeyEvents to applications, so we need to convert to a KeyEvent
 * where meta modifier is off before sending. Currently only use case is 'Back'.
 */
void InputDispatcher::accelerateMetaShortcuts(const int32_t deviceId, const int32_t action,
                                              int32_t& keyCode, int32_t& metaState) {
    if (metaState & AMETA_META_ON && action == AKEY_EVENT_ACTION_DOWN) {
        int32_t newKeyCode = AKEYCODE_UNKNOWN;
        if (keyCode == AKEYCODE_DEL) {
        if (keyCode == AKEYCODE_DEL || keyCode == AKEYCODE_GRAVE || keyCode == AKEYCODE_DPAD_LEFT) {
            newKeyCode = AKEYCODE_BACK;
        } else if (keyCode == AKEYCODE_ENTER) {
            newKeyCode = AKEYCODE_HOME;
        }
        if (newKeyCode != AKEYCODE_UNKNOWN) {
            std::scoped_lock _l(mLock);