Hand off gesture nav animations to registered remotes.

This is in support of long-lived return animations in the Animation
library. Sometimes we want the home gesture to minimize the
foreground app into a custom view other than the default Launcher
behavior.

For example, ongoing call will minimize to the status bar chip, even if
the app icon is on Home. This is guaranteed to be handled is the
takeover handler is not null, and only happens in this case (which means
a custom animation has been registered and is ready to run).

Bug: 323863002
Bug: 202516970
Flag: com.android.systemui.shared.return_animation_framework_library
Flag: com.android.systemui.shared.return_animation_framework_long_lived
Test: manual and unit test included
Change-Id: Id7cd1f6e92ad3cbe3c259b3f80c753c91472b455
This commit is contained in:
Luca Zuccarini
2024-11-18 14:38:59 +00:00
parent 7241c8c530
commit 33dfe5e7b3
6 changed files with 143 additions and 11 deletions

View File

@@ -17,6 +17,7 @@
package com.android.quickstep;
import static com.android.quickstep.AbsSwipeUpHandler.STATE_HANDLER_INVALIDATED;
import static com.android.wm.shell.shared.ShellSharedConstants.KEY_EXTRA_SHELL_CAN_HAND_OFF_ANIMATION;
import static junit.framework.TestCase.assertFalse;
import static junit.framework.TestCase.assertTrue;
@@ -28,6 +29,7 @@ import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.atLeast;
import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
@@ -40,6 +42,9 @@ import android.graphics.PointF;
import android.graphics.Rect;
import android.os.Bundle;
import android.os.SystemClock;
import android.platform.test.annotations.DisableFlags;
import android.platform.test.annotations.EnableFlags;
import android.platform.test.flag.junit.SetFlagsRule;
import android.view.RemoteAnimationTarget;
import android.view.SurfaceControl;
import android.view.ViewTreeObserver;
@@ -58,6 +63,7 @@ import com.android.quickstep.fallback.window.RecentsWindowManager;
import com.android.quickstep.util.ContextInitListener;
import com.android.quickstep.views.RecentsView;
import com.android.quickstep.views.RecentsViewContainer;
import com.android.systemui.shared.Flags;
import com.android.systemui.shared.system.InputConsumerController;
import org.junit.Before;
@@ -103,14 +109,8 @@ public abstract class AbsSwipeUpHandlerTestCase<
/* startBounds= */ null,
/* taskInfo= */ mRunningTaskInfo,
/* allowEnterPip= */ false);
protected final RecentsAnimationTargets mRecentsAnimationTargets = new RecentsAnimationTargets(
new RemoteAnimationTarget[] {mRemoteAnimationTarget},
new RemoteAnimationTarget[] {mRemoteAnimationTarget},
new RemoteAnimationTarget[] {mRemoteAnimationTarget},
/* homeContentInsets= */ new Rect(),
/* minimizedHomeBounds= */ null,
new Bundle());
protected RecentsAnimationTargets mRecentsAnimationTargets;
protected TaskAnimationManager mTaskAnimationManager;
protected RecentsAnimationDeviceState mRecentsAnimationDeviceState;
@@ -127,6 +127,22 @@ public abstract class AbsSwipeUpHandlerTestCase<
@Rule
public final MockitoRule mMockitoRule = MockitoJUnit.rule();
@Rule
public final SetFlagsRule mSetFlagsRule = new SetFlagsRule();
@Before
public void setUpAnimationTargets() {
Bundle extras = new Bundle();
extras.putBoolean(KEY_EXTRA_SHELL_CAN_HAND_OFF_ANIMATION, true);
mRecentsAnimationTargets = new RecentsAnimationTargets(
new RemoteAnimationTarget[] {mRemoteAnimationTarget},
new RemoteAnimationTarget[] {mRemoteAnimationTarget},
new RemoteAnimationTarget[] {mRemoteAnimationTarget},
/* homeContentInsets= */ new Rect(),
/* minimizedHomeBounds= */ null,
extras);
}
@Before
public void setUpRunningTaskInfo() {
mRunningTaskInfo.baseIntent = new Intent(Intent.ACTION_MAIN)
@@ -237,6 +253,30 @@ public abstract class AbsSwipeUpHandlerTestCase<
});
}
@EnableFlags({Flags.FLAG_RETURN_ANIMATION_FRAMEWORK_LIBRARY,
Flags.FLAG_RETURN_ANIMATION_FRAMEWORK_LONG_LIVED})
@Test
public void testHomeGesture_handsOffAnimation() {
createSwipeUpHandlerForGesture(GestureState.GestureEndTarget.HOME);
runOnMainSync(() -> {
verify(mRecentsAnimationController).handOffAnimation(any(), any());
verifyRecentsAnimationFinishedAndCallCallback();
});
}
@DisableFlags({Flags.FLAG_RETURN_ANIMATION_FRAMEWORK_LIBRARY,
Flags.FLAG_RETURN_ANIMATION_FRAMEWORK_LONG_LIVED})
@Test
public void testHomeGesture_doesNotHandOffAnimation_withFlagsDisabled() {
createSwipeUpHandlerForGesture(GestureState.GestureEndTarget.HOME);
runOnMainSync(() -> {
verify(mRecentsAnimationController, never()).handOffAnimation(any(), any());
verifyRecentsAnimationFinishedAndCallCallback();
});
}
@Test
public void testHomeGesture_invalidatesHandlerAfterParallelAnim() {
ValueAnimator parallelAnim = new ValueAnimator();