From f22e6b03efc694d30e450aac0b293c8cc4dc5fdf Mon Sep 17 00:00:00 2001 From: wilsonshih Date: Fri, 1 Jul 2022 15:28:47 +0800 Subject: Inject back key events if no focus window found. If user applied a back gesture but core cannot find a focus window, inject back key event, so that event can dispatch to client once it gain focus window. And since the gesture was happened, treat it as onBackPressed. And if device is playing recents animation but the focus window is point to live tile, we can also inject back key because Home/Recents activity shall not have the same behavior as normal app. Bug: 237629607 Test: cross test that back gesture can finish recents with legacy/shell transition on Nexus/3rd launcher. Test: test on BackTestApp for both 3btn mode and gesture mode. Test: atest AnrTests BackNavigationLegacyGestureTest Test: atest OnBackInvokedDispatcherTest KeyboardVisibilityControlTest BackInvokedOnWidgetTest BackNavigationTests BackNavigationControllerTests Change-Id: If754e66ea7c1c4ec313c45d17d7f6c10bfc2c465 --- .../wm/shell/back/BackAnimationController.java | 40 ++++++++++++++++++++-- 1 file changed, 38 insertions(+), 2 deletions(-) (limited to 'libs') diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/back/BackAnimationController.java b/libs/WindowManager/Shell/src/com/android/wm/shell/back/BackAnimationController.java index 02211220822a..05fafc54c273 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/back/BackAnimationController.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/back/BackAnimationController.java @@ -30,15 +30,20 @@ import android.database.ContentObserver; import android.graphics.Point; import android.graphics.PointF; import android.hardware.HardwareBuffer; +import android.hardware.input.InputManager; import android.net.Uri; import android.os.Handler; import android.os.IBinder; import android.os.RemoteException; +import android.os.SystemClock; import android.os.SystemProperties; import android.os.UserHandle; import android.provider.Settings.Global; import android.util.Log; import android.view.IWindowFocusObserver; +import android.view.InputDevice; +import android.view.KeyCharacterMap; +import android.view.KeyEvent; import android.view.MotionEvent; import android.view.RemoteAnimationTarget; import android.view.SurfaceControl; @@ -292,6 +297,9 @@ public class BackAnimationController implements RemoteCallable