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

Commit b9842f03 authored by Liana Kazanova (xWF)'s avatar Liana Kazanova (xWF) Committed by Android (Google) Code Review
Browse files

Revert "Remove unused injectBackGesture"

This reverts commit ee8d4056.

Reason for revert: DroidMonitor: Potential culprit for http://b/422762465 - verifying through ABTD before revert submission. This is part of the standard investigation process, and does not mean your CL will be reverted.

Bug: 422762465
Bug: 394599430
Change-Id: Ia1530e4f3320f62c4481e28d07bfc5ca59ee41a1
parent ee8d4056
Loading
Loading
Loading
Loading
+22 −0
Original line number Diff line number Diff line
@@ -202,6 +202,7 @@ import android.view.Display;
import android.view.HapticFeedbackConstants;
import android.view.IDisplayFoldListener;
import android.view.InputDevice;
import android.view.KeyCharacterMap;
import android.view.KeyEvent;
import android.view.KeyboardShortcutGroup;
import android.view.MotionEvent;
@@ -3738,6 +3739,27 @@ public class PhoneWindowManager implements WindowManagerPolicy {
        msg.sendToTarget();
    }

    @SuppressLint("MissingPermission")
    private void injectBackGesture(long downtime, int displayId) {
        // Create and inject down event
        KeyEvent downEvent = new KeyEvent(downtime, downtime, KeyEvent.ACTION_DOWN,
                KeyEvent.KEYCODE_BACK, 0 /* repeat */, 0 /* metaState */,
                KeyCharacterMap.VIRTUAL_KEYBOARD, 0 /* scancode */,
                KeyEvent.FLAG_FROM_SYSTEM | KeyEvent.FLAG_VIRTUAL_HARD_KEY,
                InputDevice.SOURCE_KEYBOARD);
        downEvent.setDisplayId(displayId);
        mInputManager.injectInputEvent(downEvent, InputManager.INJECT_INPUT_EVENT_MODE_ASYNC);


        // Create and inject up event
        KeyEvent upEvent = KeyEvent.changeAction(downEvent, KeyEvent.ACTION_UP);
        upEvent.setDisplayId(displayId);
        mInputManager.injectInputEvent(upEvent, InputManager.INJECT_INPUT_EVENT_MODE_ASYNC);

        downEvent.recycle();
        upEvent.recycle();
    }

    private boolean handleHomeShortcuts(IBinder focusedToken, KeyEvent event) {
        // First we always handle the home key here, so applications
        // can never break it, although if keyguard is on, we do let
+33 −0
Original line number Diff line number Diff line
@@ -91,6 +91,8 @@ class BackNavigationController {
    private boolean mShowWallpaper;
    private Runnable mPendingAnimation;
    private final NavigationMonitor mNavigationMonitor = new NavigationMonitor();
    private RemoteCallback mGestureRequest;

    private AnimationHandler mAnimationHandler;

    private final ArrayList<WindowContainer> mTmpOpenApps = new ArrayList<>();
@@ -118,6 +120,37 @@ class BackNavigationController {
        mNavigationMonitor.onEmbeddedWindowGestureTransferred(host);
    }

    void registerBackGestureDelegate(@NonNull RemoteCallback requestObserver) {
        if (!sPredictBackEnable) {
            return;
        }
        synchronized (mWindowManagerService.mGlobalLock) {
            mGestureRequest = requestObserver;
            try {
                requestObserver.getInterface().asBinder().linkToDeath(() -> {
                    synchronized (mWindowManagerService.mGlobalLock) {
                        mGestureRequest = null;
                    }
                }, 0 /* flags */);
            } catch (RemoteException r) {
                Slog.e(TAG, "Failed to link to death");
                mGestureRequest = null;
            }
        }
    }

    boolean requestBackGesture(int displayId) {
        synchronized (mWindowManagerService.mGlobalLock) {
            if (mGestureRequest == null) {
                return false;
            }
            final Bundle result = new Bundle();
            result.putInt(BackNavigationInfo.KEY_DISPLAY_ID, displayId);
            mGestureRequest.sendResult(result);
            return true;
        }
    }

    /**
     * Set up the necessary leashes and build a {@link BackNavigationInfo} instance for an upcoming
     * back gesture animation.