Abort transition for invisible background launch

In case there won't be any operation to resume top activity to
invoke transition#setReady.

Bug: 370682768
Bug: 372405077
Flag: EXEMPT bugfix
Test: Start a new task with ActivityOptions#setAvoidMoveToFront.
      There won't be transition timeout.
Change-Id: I703534666727bb6c720cb3e099bc42722dcc6b16
diff --git a/services/core/java/com/android/server/wm/ActivityStarter.java b/services/core/java/com/android/server/wm/ActivityStarter.java
index 5d3ae54..9fda193 100644
--- a/services/core/java/com/android/server/wm/ActivityStarter.java
+++ b/services/core/java/com/android/server/wm/ActivityStarter.java
@@ -1760,6 +1760,13 @@
             startedActivityRootTask.setAlwaysOnTop(true);
         }
 
+        if (isIndependentLaunch && !mDoResume && avoidMoveToFront() && !mTransientLaunch
+                && !started.shouldBeVisible(true /* ignoringKeyguard */)) {
+            Slog.i(TAG, "Abort " + transition + " of invisible launch " + started);
+            transition.abort();
+            return startedActivityRootTask;
+        }
+
         // If there is no state change (e.g. a resumed activity is reparented to top of
         // another display) to trigger a visibility/configuration checking, we have to
         // update the configuration for changing to different display.