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

Commit c907a540 authored by Tony Wickham's avatar Tony Wickham Committed by Android (Google) Code Review
Browse files

Merge "Add onKeyEvent, to support KEYCODE_HOME" into main

parents 63181f75 622a882e
Loading
Loading
Loading
Loading
+9 −3
Original line number Diff line number Diff line
@@ -103,9 +103,10 @@ interface ISystemUiProxy {
    oneway void expandNotificationPanel() = 29;

    /**
     * Notifies SystemUI of a back KeyEvent.
     * Notifies SystemUI of KEYCODE_BACK. If the passed KeyEvent is not null, SystemUI may use it to
     * show a predictive back animation, otherwise it will send a ACTION_DOWN followed by ACTION_UP.
     */
    oneway void onBackEvent(in KeyEvent keyEvent) = 44;
    oneway void onBackEvent(in KeyEvent keyEvent, int displayId) = 44;

    /** Sets home rotation enabled. */
    oneway void setHomeRotationEnabled(boolean enabled) = 45;
@@ -183,5 +184,10 @@ interface ISystemUiProxy {
     */
    oneway void notifyRecentsButtonPositionChanged(in Rect position) = 59;

    // Next id = 60
    /**
     * Notifies SystemUI of a KeyEvent of the specified type (e.g. KEYCODE_BACK, KEYCODE_HOME).
     */
    oneway void onKeyEvent(int keycode, int displayId) = 60;

    // Next id = 61
}
+13 −7
Original line number Diff line number Diff line
@@ -19,7 +19,7 @@ package com.android.systemui;
import static android.content.Intent.ACTION_PACKAGE_ADDED;
import static android.content.Intent.EXTRA_CHANGED_COMPONENT_NAME_LIST;
import static android.content.pm.PackageManager.MATCH_SYSTEM_ONLY;
import static android.view.Display.INVALID_DISPLAY;
import static android.view.KeyEvent.KEYCODE_BACK;
import static android.view.MotionEvent.ACTION_CANCEL;
import static android.view.MotionEvent.ACTION_DOWN;
import static android.view.MotionEvent.ACTION_UP;
@@ -343,18 +343,24 @@ public class LauncherProxyService implements CallbackController<LauncherProxyLis
        }

        @Override
        public void onBackEvent(@Nullable KeyEvent keyEvent) throws RemoteException {
            final int displayId = keyEvent == null ? INVALID_DISPLAY : keyEvent.getDisplayId();
        public void onBackEvent(@Nullable KeyEvent keyEvent, int displayId) throws RemoteException {
            if (predictiveBackSwipeEdgeNoneApi() && mBackAnimation != null && keyEvent != null) {
                mBackAnimation.setTriggerBack(!keyEvent.isCanceled());
                mBackAnimation.onBackMotion(/* touchX */ 0, /* touchY */ 0, keyEvent.getAction(),
                        EDGE_NONE, displayId);
            } else {
                verifyCallerAndClearCallingIdentityPostMain("onBackPressed", () -> {
                    sendEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_BACK, displayId);
                    sendEvent(KeyEvent.ACTION_UP, KeyEvent.KEYCODE_BACK, displayId);
                });
                onKeyEvent(KEYCODE_BACK, displayId);
            }
        }

        @Override
        public void onKeyEvent(int keycode, int displayId) {
            verifyCallerAndClearCallingIdentityPostMain(
                    "onKeyEvent " + KeyEvent.keyCodeToString(keycode) + " displayId=" + displayId,
                    () -> {
                        sendEvent(KeyEvent.ACTION_DOWN, keycode, displayId);
                        sendEvent(KeyEvent.ACTION_UP, keycode, displayId);
                    });
        }

        @Override