DO NOT MERGE Split BackEvent into an internal BackMotionEvent and public BackEvent. am: 2c2265c345
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/20841116 Change-Id: Ia489d2b096b35f7210dad25d74853ee06ad013be Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
@@ -18,10 +18,8 @@ package android.window;
|
||||
|
||||
import android.annotation.IntDef;
|
||||
import android.annotation.NonNull;
|
||||
import android.annotation.Nullable;
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
import android.view.RemoteAnimationTarget;
|
||||
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
@@ -52,8 +50,6 @@ public class BackEvent implements Parcelable {
|
||||
|
||||
@SwipeEdge
|
||||
private final int mSwipeEdge;
|
||||
@Nullable
|
||||
private final RemoteAnimationTarget mDepartingAnimationTarget;
|
||||
|
||||
/**
|
||||
* Creates a new {@link BackEvent} instance.
|
||||
@@ -62,16 +58,12 @@ public class BackEvent implements Parcelable {
|
||||
* @param touchY Absolute Y location of the touch point of this event.
|
||||
* @param progress Value between 0 and 1 on how far along the back gesture is.
|
||||
* @param swipeEdge Indicates which edge the swipe starts from.
|
||||
* @param departingAnimationTarget The remote animation target of the departing application
|
||||
* window.
|
||||
*/
|
||||
public BackEvent(float touchX, float touchY, float progress, @SwipeEdge int swipeEdge,
|
||||
@Nullable RemoteAnimationTarget departingAnimationTarget) {
|
||||
public BackEvent(float touchX, float touchY, float progress, @SwipeEdge int swipeEdge) {
|
||||
mTouchX = touchX;
|
||||
mTouchY = touchY;
|
||||
mProgress = progress;
|
||||
mSwipeEdge = swipeEdge;
|
||||
mDepartingAnimationTarget = departingAnimationTarget;
|
||||
}
|
||||
|
||||
private BackEvent(@NonNull Parcel in) {
|
||||
@@ -79,7 +71,6 @@ public class BackEvent implements Parcelable {
|
||||
mTouchY = in.readFloat();
|
||||
mProgress = in.readFloat();
|
||||
mSwipeEdge = in.readInt();
|
||||
mDepartingAnimationTarget = in.readTypedObject(RemoteAnimationTarget.CREATOR);
|
||||
}
|
||||
|
||||
public static final Creator<BackEvent> CREATOR = new Creator<BackEvent>() {
|
||||
@@ -105,7 +96,6 @@ public class BackEvent implements Parcelable {
|
||||
dest.writeFloat(mTouchY);
|
||||
dest.writeFloat(mProgress);
|
||||
dest.writeInt(mSwipeEdge);
|
||||
dest.writeTypedObject(mDepartingAnimationTarget, flags);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -136,16 +126,6 @@ public class BackEvent implements Parcelable {
|
||||
return mSwipeEdge;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the {@link RemoteAnimationTarget} of the top departing application window,
|
||||
* or {@code null} if the top window should not be moved for the current type of back
|
||||
* destination.
|
||||
*/
|
||||
@Nullable
|
||||
public RemoteAnimationTarget getDepartingAnimationTarget() {
|
||||
return mDepartingAnimationTarget;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "BackEvent{"
|
||||
@@ -153,7 +133,6 @@ public class BackEvent implements Parcelable {
|
||||
+ ", mTouchY=" + mTouchY
|
||||
+ ", mProgress=" + mProgress
|
||||
+ ", mSwipeEdge" + mSwipeEdge
|
||||
+ ", mDepartingAnimationTarget" + mDepartingAnimationTarget
|
||||
+ "}";
|
||||
}
|
||||
}
|
||||
|
||||
22
core/java/android/window/BackMotionEvent.aidl
Normal file
22
core/java/android/window/BackMotionEvent.aidl
Normal file
@@ -0,0 +1,22 @@
|
||||
/*
|
||||
* Copyright (C) 2022 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package android.window;
|
||||
|
||||
/**
|
||||
* @hide
|
||||
*/
|
||||
parcelable BackMotionEvent;
|
||||
150
core/java/android/window/BackMotionEvent.java
Normal file
150
core/java/android/window/BackMotionEvent.java
Normal file
@@ -0,0 +1,150 @@
|
||||
/*
|
||||
* Copyright (C) 2022 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package android.window;
|
||||
|
||||
import android.annotation.FloatRange;
|
||||
import android.annotation.NonNull;
|
||||
import android.annotation.Nullable;
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
import android.view.RemoteAnimationTarget;
|
||||
|
||||
/**
|
||||
* Object used to report back gesture progress. Holds information about a {@link BackEvent} plus
|
||||
* any {@link RemoteAnimationTarget} the gesture manipulates.
|
||||
*
|
||||
* @see BackEvent
|
||||
* @hide
|
||||
*/
|
||||
public final class BackMotionEvent implements Parcelable {
|
||||
private final float mTouchX;
|
||||
private final float mTouchY;
|
||||
private final float mProgress;
|
||||
|
||||
@BackEvent.SwipeEdge
|
||||
private final int mSwipeEdge;
|
||||
@Nullable
|
||||
private final RemoteAnimationTarget mDepartingAnimationTarget;
|
||||
|
||||
/**
|
||||
* Creates a new {@link BackMotionEvent} instance.
|
||||
*
|
||||
* @param touchX Absolute X location of the touch point of this event.
|
||||
* @param touchY Absolute Y location of the touch point of this event.
|
||||
* @param progress Value between 0 and 1 on how far along the back gesture is.
|
||||
* @param swipeEdge Indicates which edge the swipe starts from.
|
||||
* @param departingAnimationTarget The remote animation target of the departing
|
||||
* application window.
|
||||
*/
|
||||
public BackMotionEvent(float touchX, float touchY, float progress,
|
||||
@BackEvent.SwipeEdge int swipeEdge,
|
||||
@Nullable RemoteAnimationTarget departingAnimationTarget) {
|
||||
mTouchX = touchX;
|
||||
mTouchY = touchY;
|
||||
mProgress = progress;
|
||||
mSwipeEdge = swipeEdge;
|
||||
mDepartingAnimationTarget = departingAnimationTarget;
|
||||
}
|
||||
|
||||
private BackMotionEvent(@NonNull Parcel in) {
|
||||
mTouchX = in.readFloat();
|
||||
mTouchY = in.readFloat();
|
||||
mProgress = in.readFloat();
|
||||
mSwipeEdge = in.readInt();
|
||||
mDepartingAnimationTarget = in.readTypedObject(RemoteAnimationTarget.CREATOR);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public static final Creator<BackMotionEvent> CREATOR = new Creator<BackMotionEvent>() {
|
||||
@Override
|
||||
public BackMotionEvent createFromParcel(Parcel in) {
|
||||
return new BackMotionEvent(in);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BackMotionEvent[] newArray(int size) {
|
||||
return new BackMotionEvent[size];
|
||||
}
|
||||
};
|
||||
|
||||
@Override
|
||||
public int describeContents() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToParcel(@NonNull Parcel dest, int flags) {
|
||||
dest.writeFloat(mTouchX);
|
||||
dest.writeFloat(mTouchY);
|
||||
dest.writeFloat(mProgress);
|
||||
dest.writeInt(mSwipeEdge);
|
||||
dest.writeTypedObject(mDepartingAnimationTarget, flags);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the progress of a {@link BackEvent}.
|
||||
*
|
||||
* @see BackEvent#getProgress()
|
||||
*/
|
||||
@FloatRange(from = 0, to = 1)
|
||||
public float getProgress() {
|
||||
return mProgress;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the absolute X location of the touch point.
|
||||
*/
|
||||
public float getTouchX() {
|
||||
return mTouchX;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the absolute Y location of the touch point.
|
||||
*/
|
||||
public float getTouchY() {
|
||||
return mTouchY;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the screen edge that the swipe starts from.
|
||||
*/
|
||||
@BackEvent.SwipeEdge
|
||||
public int getSwipeEdge() {
|
||||
return mSwipeEdge;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the {@link RemoteAnimationTarget} of the top departing application window,
|
||||
* or {@code null} if the top window should not be moved for the current type of back
|
||||
* destination.
|
||||
*/
|
||||
@Nullable
|
||||
public RemoteAnimationTarget getDepartingAnimationTarget() {
|
||||
return mDepartingAnimationTarget;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "BackMotionEvent{"
|
||||
+ "mTouchX=" + mTouchX
|
||||
+ ", mTouchY=" + mTouchY
|
||||
+ ", mProgress=" + mProgress
|
||||
+ ", mSwipeEdge" + mSwipeEdge
|
||||
+ ", mDepartingAnimationTarget" + mDepartingAnimationTarget
|
||||
+ "}";
|
||||
}
|
||||
}
|
||||
@@ -40,7 +40,7 @@ public class BackProgressAnimator {
|
||||
private final SpringAnimation mSpring;
|
||||
private ProgressCallback mCallback;
|
||||
private float mProgress = 0;
|
||||
private BackEvent mLastBackEvent;
|
||||
private BackMotionEvent mLastBackEvent;
|
||||
private boolean mStarted = false;
|
||||
|
||||
private void setProgress(float progress) {
|
||||
@@ -82,9 +82,9 @@ public class BackProgressAnimator {
|
||||
/**
|
||||
* Sets a new target position for the back progress.
|
||||
*
|
||||
* @param event the {@link BackEvent} containing the latest target progress.
|
||||
* @param event the {@link BackMotionEvent} containing the latest target progress.
|
||||
*/
|
||||
public void onBackProgressed(BackEvent event) {
|
||||
public void onBackProgressed(BackMotionEvent event) {
|
||||
if (!mStarted) {
|
||||
return;
|
||||
}
|
||||
@@ -95,11 +95,11 @@ public class BackProgressAnimator {
|
||||
/**
|
||||
* Starts the back progress animation.
|
||||
*
|
||||
* @param event the {@link BackEvent} that started the gesture.
|
||||
* @param event the {@link BackMotionEvent} that started the gesture.
|
||||
* @param callback the back callback to invoke for the gesture. It will receive back progress
|
||||
* dispatches as the progress animation updates.
|
||||
*/
|
||||
public void onBackStarted(BackEvent event, ProgressCallback callback) {
|
||||
public void onBackStarted(BackMotionEvent event, ProgressCallback callback) {
|
||||
reset();
|
||||
mLastBackEvent = event;
|
||||
mCallback = callback;
|
||||
@@ -129,8 +129,7 @@ public class BackProgressAnimator {
|
||||
}
|
||||
mCallback.onProgressUpdate(
|
||||
new BackEvent(mLastBackEvent.getTouchX(), mLastBackEvent.getTouchY(),
|
||||
progress / SCALE_FACTOR, mLastBackEvent.getSwipeEdge(),
|
||||
mLastBackEvent.getDepartingAnimationTarget()));
|
||||
progress / SCALE_FACTOR, mLastBackEvent.getSwipeEdge()));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
|
||||
package android.window;
|
||||
|
||||
import android.window.BackEvent;
|
||||
import android.window.BackMotionEvent;
|
||||
|
||||
/**
|
||||
* Interface that wraps a {@link OnBackInvokedCallback} object, to be stored in window manager
|
||||
@@ -30,18 +30,19 @@ oneway interface IOnBackInvokedCallback {
|
||||
* Called when a back gesture has been started, or back button has been pressed down.
|
||||
* Wraps {@link OnBackInvokedCallback#onBackStarted(BackEvent)}.
|
||||
*
|
||||
* @param backEvent The {@link BackEvent} containing information about the touch or button press.
|
||||
* @param backMotionEvent The {@link BackMotionEvent} containing information about the touch
|
||||
* or button press.
|
||||
*/
|
||||
void onBackStarted(in BackEvent backEvent);
|
||||
void onBackStarted(in BackMotionEvent backMotionEvent);
|
||||
|
||||
/**
|
||||
* Called on back gesture progress.
|
||||
* Wraps {@link OnBackInvokedCallback#onBackProgressed(BackEvent)}.
|
||||
*
|
||||
* @param backEvent The {@link BackEvent} containing information about the latest touch point
|
||||
* and the progress that the back animation should seek to.
|
||||
* @param backMotionEvent The {@link BackMotionEvent} containing information about the latest
|
||||
* touch point and the progress that the back animation should seek to.
|
||||
*/
|
||||
void onBackProgressed(in BackEvent backEvent);
|
||||
void onBackProgressed(in BackMotionEvent backMotionEvent);
|
||||
|
||||
/**
|
||||
* Called when a back gesture or back button press has been cancelled.
|
||||
|
||||
@@ -229,19 +229,21 @@ public class WindowOnBackInvokedDispatcher implements OnBackInvokedDispatcher {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBackStarted(BackEvent backEvent) {
|
||||
public void onBackStarted(BackMotionEvent backEvent) {
|
||||
Handler.getMain().post(() -> {
|
||||
final OnBackAnimationCallback callback = getBackAnimationCallback();
|
||||
if (callback != null) {
|
||||
mProgressAnimator.onBackStarted(backEvent, event ->
|
||||
callback.onBackProgressed(event));
|
||||
callback.onBackStarted(backEvent);
|
||||
callback.onBackStarted(new BackEvent(
|
||||
backEvent.getTouchX(), backEvent.getTouchY(),
|
||||
backEvent.getProgress(), backEvent.getSwipeEdge()));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBackProgressed(BackEvent backEvent) {
|
||||
public void onBackProgressed(BackMotionEvent backEvent) {
|
||||
Handler.getMain().post(() -> {
|
||||
final OnBackAnimationCallback callback = getBackAnimationCallback();
|
||||
if (callback != null) {
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
package android.window;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.isNull;
|
||||
import static org.mockito.Mockito.reset;
|
||||
import static org.mockito.Mockito.times;
|
||||
@@ -60,8 +61,8 @@ public class WindowOnBackInvokedDispatcherTest {
|
||||
private OnBackAnimationCallback mCallback1;
|
||||
@Mock
|
||||
private OnBackAnimationCallback mCallback2;
|
||||
@Mock
|
||||
private BackEvent mBackEvent;
|
||||
private final BackMotionEvent mBackEvent = new BackMotionEvent(
|
||||
0, 0, 0, BackEvent.EDGE_LEFT, null);
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
@@ -89,12 +90,12 @@ public class WindowOnBackInvokedDispatcherTest {
|
||||
captor.capture());
|
||||
captor.getAllValues().get(0).getCallback().onBackStarted(mBackEvent);
|
||||
waitForIdle();
|
||||
verify(mCallback1).onBackStarted(mBackEvent);
|
||||
verify(mCallback1).onBackStarted(any(BackEvent.class));
|
||||
verifyZeroInteractions(mCallback2);
|
||||
|
||||
captor.getAllValues().get(1).getCallback().onBackStarted(mBackEvent);
|
||||
waitForIdle();
|
||||
verify(mCallback2).onBackStarted(mBackEvent);
|
||||
verify(mCallback2).onBackStarted(any(BackEvent.class));
|
||||
verifyNoMoreInteractions(mCallback1);
|
||||
}
|
||||
|
||||
@@ -114,7 +115,7 @@ public class WindowOnBackInvokedDispatcherTest {
|
||||
assertEquals(captor.getValue().getPriority(), OnBackInvokedDispatcher.PRIORITY_OVERLAY);
|
||||
captor.getValue().getCallback().onBackStarted(mBackEvent);
|
||||
waitForIdle();
|
||||
verify(mCallback1).onBackStarted(mBackEvent);
|
||||
verify(mCallback1).onBackStarted(any(BackEvent.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -152,6 +153,6 @@ public class WindowOnBackInvokedDispatcherTest {
|
||||
verify(mWindowSession).setOnBackInvokedCallbackInfo(Mockito.eq(mWindow), captor.capture());
|
||||
captor.getValue().getCallback().onBackStarted(mBackEvent);
|
||||
waitForIdle();
|
||||
verify(mCallback2).onBackStarted(mBackEvent);
|
||||
verify(mCallback2).onBackStarted(any(BackEvent.class));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -51,6 +51,7 @@ import android.view.RemoteAnimationTarget;
|
||||
import android.view.SurfaceControl;
|
||||
import android.window.BackAnimationAdaptor;
|
||||
import android.window.BackEvent;
|
||||
import android.window.BackMotionEvent;
|
||||
import android.window.BackNavigationInfo;
|
||||
import android.window.IBackAnimationRunner;
|
||||
import android.window.IBackNaviAnimationController;
|
||||
@@ -173,11 +174,11 @@ public class BackAnimationController implements RemoteCallable<BackAnimationCont
|
||||
boolean consumed = false;
|
||||
if (mWaitingAnimation && mOnBackCallback != null) {
|
||||
if (mTriggerBack) {
|
||||
final BackEvent backFinish = mTouchTracker.createProgressEvent(1);
|
||||
final BackMotionEvent backFinish = mTouchTracker.createProgressEvent(1);
|
||||
dispatchOnBackProgressed(mBackToLauncherCallback, backFinish);
|
||||
dispatchOnBackInvoked(mOnBackCallback);
|
||||
} else {
|
||||
final BackEvent backFinish = mTouchTracker.createProgressEvent(0);
|
||||
final BackMotionEvent backFinish = mTouchTracker.createProgressEvent(0);
|
||||
dispatchOnBackProgressed(mBackToLauncherCallback, backFinish);
|
||||
dispatchOnBackCancelled(mOnBackCallback);
|
||||
}
|
||||
@@ -480,7 +481,7 @@ public class BackAnimationController implements RemoteCallable<BackAnimationCont
|
||||
if (!mBackGestureStarted || mBackNavigationInfo == null) {
|
||||
return;
|
||||
}
|
||||
final BackEvent backEvent = mTouchTracker.createProgressEvent();
|
||||
final BackMotionEvent backEvent = mTouchTracker.createProgressEvent();
|
||||
if (USE_TRANSITION && mBackAnimationController != null && mAnimationTarget != null) {
|
||||
dispatchOnBackProgressed(mBackToLauncherCallback, backEvent);
|
||||
} else if (mEnableAnimations.get()) {
|
||||
@@ -573,7 +574,7 @@ public class BackAnimationController implements RemoteCallable<BackAnimationCont
|
||||
}
|
||||
|
||||
private void dispatchOnBackStarted(IOnBackInvokedCallback callback,
|
||||
BackEvent backEvent) {
|
||||
BackMotionEvent backEvent) {
|
||||
if (callback == null) {
|
||||
return;
|
||||
}
|
||||
@@ -611,7 +612,7 @@ public class BackAnimationController implements RemoteCallable<BackAnimationCont
|
||||
}
|
||||
|
||||
private void dispatchOnBackProgressed(IOnBackInvokedCallback callback,
|
||||
BackEvent backEvent) {
|
||||
BackMotionEvent backEvent) {
|
||||
if (callback == null) {
|
||||
return;
|
||||
}
|
||||
@@ -730,7 +731,7 @@ public class BackAnimationController implements RemoteCallable<BackAnimationCont
|
||||
}
|
||||
dispatchOnBackStarted(mBackToLauncherCallback,
|
||||
mTouchTracker.createStartEvent(mAnimationTarget));
|
||||
final BackEvent backInit = mTouchTracker.createProgressEvent();
|
||||
final BackMotionEvent backInit = mTouchTracker.createProgressEvent();
|
||||
if (!mCachingBackDispatcher.consume()) {
|
||||
dispatchOnBackProgressed(mBackToLauncherCallback, backInit);
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@ package com.android.wm.shell.back;
|
||||
import android.os.SystemProperties;
|
||||
import android.view.RemoteAnimationTarget;
|
||||
import android.window.BackEvent;
|
||||
import android.window.BackMotionEvent;
|
||||
|
||||
/**
|
||||
* Helper class to record the touch location for gesture and generate back events.
|
||||
@@ -82,11 +83,11 @@ class TouchTracker {
|
||||
mSwipeEdge = BackEvent.EDGE_LEFT;
|
||||
}
|
||||
|
||||
BackEvent createStartEvent(RemoteAnimationTarget target) {
|
||||
return new BackEvent(mInitTouchX, mInitTouchY, 0, mSwipeEdge, target);
|
||||
BackMotionEvent createStartEvent(RemoteAnimationTarget target) {
|
||||
return new BackMotionEvent(mInitTouchX, mInitTouchY, 0, mSwipeEdge, target);
|
||||
}
|
||||
|
||||
BackEvent createProgressEvent() {
|
||||
BackMotionEvent createProgressEvent() {
|
||||
float progressThreshold = PROGRESS_THRESHOLD >= 0
|
||||
? PROGRESS_THRESHOLD : mProgressThreshold;
|
||||
progressThreshold = progressThreshold == 0 ? 1 : progressThreshold;
|
||||
@@ -109,8 +110,8 @@ class TouchTracker {
|
||||
return createProgressEvent(progress);
|
||||
}
|
||||
|
||||
BackEvent createProgressEvent(float progress) {
|
||||
return new BackEvent(mLatestTouchX, mLatestTouchY, progress, mSwipeEdge, null);
|
||||
BackMotionEvent createProgressEvent(float progress) {
|
||||
return new BackMotionEvent(mLatestTouchX, mLatestTouchY, progress, mSwipeEdge, null);
|
||||
}
|
||||
|
||||
public void setProgressThreshold(float progressThreshold) {
|
||||
|
||||
@@ -53,6 +53,7 @@ import android.view.MotionEvent;
|
||||
import android.view.RemoteAnimationTarget;
|
||||
import android.view.SurfaceControl;
|
||||
import android.window.BackEvent;
|
||||
import android.window.BackMotionEvent;
|
||||
import android.window.BackNavigationInfo;
|
||||
import android.window.IBackNaviAnimationController;
|
||||
import android.window.IOnBackInvokedCallback;
|
||||
@@ -246,10 +247,11 @@ public class BackAnimationControllerTest extends ShellTestCase {
|
||||
// Check that back start and progress is dispatched when first move.
|
||||
doMotionEvent(MotionEvent.ACTION_MOVE, 100);
|
||||
simulateRemoteAnimationStart(BackNavigationInfo.TYPE_RETURN_TO_HOME, animationTarget);
|
||||
ArgumentCaptor<BackEvent> backEventCaptor = ArgumentCaptor.forClass(BackEvent.class);
|
||||
ArgumentCaptor<BackMotionEvent> backEventCaptor =
|
||||
ArgumentCaptor.forClass(BackMotionEvent.class);
|
||||
verify(mIOnBackInvokedCallback).onBackStarted(backEventCaptor.capture());
|
||||
assertEquals(animationTarget, backEventCaptor.getValue().getDepartingAnimationTarget());
|
||||
verify(mIOnBackInvokedCallback, atLeastOnce()).onBackProgressed(any(BackEvent.class));
|
||||
verify(mIOnBackInvokedCallback, atLeastOnce()).onBackProgressed(any(BackMotionEvent.class));
|
||||
|
||||
// Check that back invocation is dispatched.
|
||||
mController.setTriggerBack(true); // Fake trigger back
|
||||
@@ -271,17 +273,18 @@ public class BackAnimationControllerTest extends ShellTestCase {
|
||||
|
||||
RemoteAnimationTarget animationTarget = createAnimationTarget();
|
||||
IOnBackInvokedCallback appCallback = mock(IOnBackInvokedCallback.class);
|
||||
ArgumentCaptor<BackEvent> backEventCaptor = ArgumentCaptor.forClass(BackEvent.class);
|
||||
ArgumentCaptor<BackMotionEvent> backEventCaptor =
|
||||
ArgumentCaptor.forClass(BackMotionEvent.class);
|
||||
createNavigationInfo(animationTarget, null, null,
|
||||
BackNavigationInfo.TYPE_RETURN_TO_HOME, appCallback, false);
|
||||
|
||||
triggerBackGesture();
|
||||
|
||||
verify(appCallback, never()).onBackStarted(any(BackEvent.class));
|
||||
verify(appCallback, never()).onBackStarted(any(BackMotionEvent.class));
|
||||
verify(appCallback, never()).onBackProgressed(backEventCaptor.capture());
|
||||
verify(appCallback, times(1)).onBackInvoked();
|
||||
|
||||
verify(mIOnBackInvokedCallback, never()).onBackStarted(any(BackEvent.class));
|
||||
verify(mIOnBackInvokedCallback, never()).onBackStarted(any(BackMotionEvent.class));
|
||||
verify(mIOnBackInvokedCallback, never()).onBackProgressed(backEventCaptor.capture());
|
||||
verify(mIOnBackInvokedCallback, never()).onBackInvoked();
|
||||
}
|
||||
@@ -314,7 +317,7 @@ public class BackAnimationControllerTest extends ShellTestCase {
|
||||
doMotionEvent(MotionEvent.ACTION_DOWN, 0);
|
||||
doMotionEvent(MotionEvent.ACTION_MOVE, 100);
|
||||
simulateRemoteAnimationStart(BackNavigationInfo.TYPE_RETURN_TO_HOME, animationTarget);
|
||||
verify(mIOnBackInvokedCallback).onBackStarted(any(BackEvent.class));
|
||||
verify(mIOnBackInvokedCallback).onBackStarted(any(BackMotionEvent.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -333,7 +336,7 @@ public class BackAnimationControllerTest extends ShellTestCase {
|
||||
doMotionEvent(MotionEvent.ACTION_DOWN, 0);
|
||||
doMotionEvent(MotionEvent.ACTION_MOVE, 100);
|
||||
simulateRemoteAnimationStart(BackNavigationInfo.TYPE_RETURN_TO_HOME, animationTarget);
|
||||
verify(mIOnBackInvokedCallback).onBackStarted(any(BackEvent.class));
|
||||
verify(mIOnBackInvokedCallback).onBackStarted(any(BackMotionEvent.class));
|
||||
}
|
||||
|
||||
|
||||
@@ -349,7 +352,7 @@ public class BackAnimationControllerTest extends ShellTestCase {
|
||||
// Check that back start and progress is dispatched when first move.
|
||||
doMotionEvent(MotionEvent.ACTION_MOVE, 100);
|
||||
simulateRemoteAnimationStart(BackNavigationInfo.TYPE_RETURN_TO_HOME, animationTarget);
|
||||
verify(mIOnBackInvokedCallback).onBackStarted(any(BackEvent.class));
|
||||
verify(mIOnBackInvokedCallback).onBackStarted(any(BackMotionEvent.class));
|
||||
|
||||
// Check that back invocation is dispatched.
|
||||
mController.setTriggerBack(true); // Fake trigger back
|
||||
|
||||
@@ -19,6 +19,7 @@ package com.android.wm.shell.back;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import android.window.BackEvent;
|
||||
import android.window.BackMotionEvent;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
@@ -38,7 +39,7 @@ public class TouchTrackerTest {
|
||||
@Test
|
||||
public void generatesProgress_onStart() {
|
||||
mTouchTracker.setGestureStartLocation(INITIAL_X_LEFT_EDGE, 0, BackEvent.EDGE_LEFT);
|
||||
BackEvent event = mTouchTracker.createStartEvent(null);
|
||||
BackMotionEvent event = mTouchTracker.createStartEvent(null);
|
||||
assertEquals(event.getProgress(), 0f, 0f);
|
||||
}
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ import android.hardware.HardwareBuffer;
|
||||
import android.os.RemoteException;
|
||||
import android.platform.test.annotations.Presubmit;
|
||||
import android.view.WindowManager;
|
||||
import android.window.BackEvent;
|
||||
import android.window.BackMotionEvent;
|
||||
import android.window.BackNavigationInfo;
|
||||
import android.window.IOnBackInvokedCallback;
|
||||
import android.window.OnBackInvokedCallback;
|
||||
@@ -242,11 +242,11 @@ public class BackNavigationControllerTests extends WindowTestsBase {
|
||||
private IOnBackInvokedCallback createOnBackInvokedCallback() {
|
||||
return new IOnBackInvokedCallback.Stub() {
|
||||
@Override
|
||||
public void onBackStarted(BackEvent backEvent) {
|
||||
public void onBackStarted(BackMotionEvent backEvent) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBackProgressed(BackEvent backEvent) {
|
||||
public void onBackProgressed(BackMotionEvent backEvent) {
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user