Skip anim background tests in freeform displays.

These tests rely on custom animations to launch another activity in a
different task. That would result in a different window in freeform mode
and by its nature the custom animation will be ignored.

Bug: 112404375
Test: Tests skip in freeform displays; still passes on walleye.
Change-Id: I029c06fd28a5600816e603b615f75caae93b1d00
diff --git a/tests/framework/base/activitymanager/src/android/server/am/AnimationBackgroundTests.java b/tests/framework/base/activitymanager/src/android/server/am/AnimationBackgroundTests.java
index 563ce91..8022c87 100644
--- a/tests/framework/base/activitymanager/src/android/server/am/AnimationBackgroundTests.java
+++ b/tests/framework/base/activitymanager/src/android/server/am/AnimationBackgroundTests.java
@@ -16,6 +16,7 @@
 
 package android.server.am;
 
+import static android.app.WindowConfiguration.WINDOWING_MODE_FREEFORM;
 import static android.app.WindowConfiguration.WINDOWING_MODE_FULLSCREEN;
 import static android.server.am.Components.ANIMATION_TEST_ACTIVITY;
 import static android.server.am.Components.LAUNCHING_ACTIVITY;
@@ -23,6 +24,10 @@
 
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertTrue;
+import static org.junit.Assume.assumeFalse;
+
+import android.content.ComponentName;
+import android.server.am.WindowManagerState.Display;
 
 import org.junit.Test;
 
@@ -40,11 +45,16 @@
                 .setWaitForLaunched(false)
                 .execute();
 
+        // Make sure we're testing an activity that runs on fullscreen display. This animation API
+        // doesn't make much sense in freeform displays.
+        assumeActivityNotInFreeformDisplay(ANIMATION_TEST_ACTIVITY);
+
         // Make sure we are in the middle of the animation.
         mAmWmState.waitForWithWmState(state -> state
                 .getStandardStackByWindowingMode(WINDOWING_MODE_FULLSCREEN)
                         .isWindowAnimationBackgroundSurfaceShowing(),
                 "***Waiting for animation background showing");
+
         assertTrue("window animation background needs to be showing", mAmWmState.getWmState()
                 .getStandardStackByWindowingMode(WINDOWING_MODE_FULLSCREEN)
                 .isWindowAnimationBackgroundSurfaceShowing());
@@ -56,8 +66,21 @@
         getLaunchActivityBuilder().setTargetActivity(ANIMATION_TEST_ACTIVITY).execute();
         mAmWmState.computeState(ANIMATION_TEST_ACTIVITY);
         mAmWmState.waitForAppTransitionIdle();
+
+        // Make sure we're testing an activity that runs on fullscreen display. This animation API
+        // doesn't make much sense in freeform displays.
+        assumeActivityNotInFreeformDisplay(ANIMATION_TEST_ACTIVITY);
+
         assertFalse("window animation background needs to be gone", mAmWmState.getWmState()
                 .getStandardStackByWindowingMode(WINDOWING_MODE_FULLSCREEN)
                 .isWindowAnimationBackgroundSurfaceShowing());
     }
+
+    private void assumeActivityNotInFreeformDisplay(ComponentName activity) throws Exception {
+        mAmWmState.waitForValidState(activity);
+        final int displayId = mAmWmState.getAmState().getDisplayByActivity(activity);
+        final Display display = mAmWmState.getWmState().getDisplay(displayId);
+        assumeFalse("Animation test activity is in freeform display. It may not run "
+                + "cross-task animations.", display.getWindowingMode() == WINDOWING_MODE_FREEFORM);
+    }
 }