Merge "Fix back gesture send to wrong focus window" into tm-dev am: 4bf81d5758
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/17990066 Change-Id: Ic9df3cc1dcfbc6ee3a91d57a113482873b5128e6 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
@@ -246,9 +246,13 @@ public class BackAnimationController implements RemoteCallable<BackAnimationCont
|
|||||||
* {@link BackAnimationController}
|
* {@link BackAnimationController}
|
||||||
*/
|
*/
|
||||||
public void onMotionEvent(MotionEvent event, int action, @BackEvent.SwipeEdge int swipeEdge) {
|
public void onMotionEvent(MotionEvent event, int action, @BackEvent.SwipeEdge int swipeEdge) {
|
||||||
if (action == MotionEvent.ACTION_DOWN) {
|
if (action == MotionEvent.ACTION_MOVE) {
|
||||||
|
if (!mBackGestureStarted) {
|
||||||
|
// Let the animation initialized here to make sure the onPointerDownOutsideFocus
|
||||||
|
// could be happened when ACTION_DOWN, it may change the current focus that we
|
||||||
|
// would access it when startBackNavigation.
|
||||||
initAnimation(event);
|
initAnimation(event);
|
||||||
} else if (action == MotionEvent.ACTION_MOVE) {
|
}
|
||||||
onMove(event, swipeEdge);
|
onMove(event, swipeEdge);
|
||||||
} else if (action == MotionEvent.ACTION_UP || action == MotionEvent.ACTION_CANCEL) {
|
} else if (action == MotionEvent.ACTION_UP || action == MotionEvent.ACTION_CANCEL) {
|
||||||
ProtoLog.d(WM_SHELL_BACK_PREVIEW,
|
ProtoLog.d(WM_SHELL_BACK_PREVIEW,
|
||||||
|
|||||||
@@ -209,12 +209,11 @@ public class BackAnimationControllerTest {
|
|||||||
createNavigationInfo(animationTarget, null, null,
|
createNavigationInfo(animationTarget, null, null,
|
||||||
BackNavigationInfo.TYPE_RETURN_TO_HOME, null);
|
BackNavigationInfo.TYPE_RETURN_TO_HOME, null);
|
||||||
|
|
||||||
// Check that back start is dispatched.
|
|
||||||
doMotionEvent(MotionEvent.ACTION_DOWN, 0);
|
doMotionEvent(MotionEvent.ACTION_DOWN, 0);
|
||||||
verify(mIOnBackInvokedCallback).onBackStarted();
|
|
||||||
|
|
||||||
// Check that back progress is dispatched.
|
// Check that back start and progress is dispatched when first move.
|
||||||
doMotionEvent(MotionEvent.ACTION_MOVE, 100);
|
doMotionEvent(MotionEvent.ACTION_MOVE, 100);
|
||||||
|
verify(mIOnBackInvokedCallback).onBackStarted();
|
||||||
ArgumentCaptor<BackEvent> backEventCaptor = ArgumentCaptor.forClass(BackEvent.class);
|
ArgumentCaptor<BackEvent> backEventCaptor = ArgumentCaptor.forClass(BackEvent.class);
|
||||||
verify(mIOnBackInvokedCallback).onBackProgressed(backEventCaptor.capture());
|
verify(mIOnBackInvokedCallback).onBackProgressed(backEventCaptor.capture());
|
||||||
assertEquals(animationTarget, backEventCaptor.getValue().getDepartingAnimationTarget());
|
assertEquals(animationTarget, backEventCaptor.getValue().getDepartingAnimationTarget());
|
||||||
|
|||||||
@@ -124,8 +124,7 @@ class BackNavigationController {
|
|||||||
LocalServices.getService(WindowManagerInternal.class);
|
LocalServices.getService(WindowManagerInternal.class);
|
||||||
IBinder focusedWindowToken = windowManagerInternal.getFocusedWindowToken();
|
IBinder focusedWindowToken = windowManagerInternal.getFocusedWindowToken();
|
||||||
|
|
||||||
window = wmService.windowForClientLocked(null, focusedWindowToken,
|
window = wmService.getFocusedWindowLocked();
|
||||||
false /* throwOnError */);
|
|
||||||
|
|
||||||
if (window == null) {
|
if (window == null) {
|
||||||
EmbeddedWindowController.EmbeddedWindow embeddedWindow =
|
EmbeddedWindowController.EmbeddedWindow embeddedWindow =
|
||||||
@@ -146,12 +145,6 @@ class BackNavigationController {
|
|||||||
"Focused window found using getFocusedWindowToken");
|
"Focused window found using getFocusedWindowToken");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (window == null) {
|
|
||||||
window = wmService.getFocusedWindowLocked();
|
|
||||||
ProtoLog.d(WM_DEBUG_BACK_PREVIEW,
|
|
||||||
"Focused window found using wmService.getFocusedWindowLocked()");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (window == null) {
|
if (window == null) {
|
||||||
// We don't have any focused window, fallback ont the top currentTask of the focused
|
// We don't have any focused window, fallback ont the top currentTask of the focused
|
||||||
// display.
|
// display.
|
||||||
|
|||||||
@@ -306,6 +306,7 @@ public class BackNavigationControllerTests extends WindowTestsBase {
|
|||||||
if (focus) {
|
if (focus) {
|
||||||
doReturn(window.getWindowInfo().token)
|
doReturn(window.getWindowInfo().token)
|
||||||
.when(mWindowManagerInternal).getFocusedWindowToken();
|
.when(mWindowManagerInternal).getFocusedWindowToken();
|
||||||
|
doReturn(window).when(mWm).getFocusedWindowLocked();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user