Immediately deliver new intent to paused activities.

ag/1437028 tried to fix this problem, but limited intent
delivery to only paused activities in a minimized docked stack
to reduce the effect of the change since we are late in the
release cycle. However, it didn't completely solve the problem
for example when the ChooserActivity comes up in the fullscreen
stack un-minimizing the docked stack and then the user selects
the app in the docked stack from ChooserActivity.
We now immediately deliver intents to paused activities as they
are currently visible to the user and we want the user to see
the visual effects caused by the intent delivery now.

Bug: 31371093
Change-Id: I94f9717da66daa512071bb96e62b2f9811691a78
diff --git a/services/core/java/com/android/server/am/ActivityRecord.java b/services/core/java/com/android/server/am/ActivityRecord.java
index 5895633..3f69712 100755
--- a/services/core/java/com/android/server/am/ActivityRecord.java
+++ b/services/core/java/com/android/server/am/ActivityRecord.java
@@ -954,22 +954,18 @@
                 stack != null && stack.topRunningActivityLocked() == this;
         final boolean isTopActivityWhileSleeping =
                 service.isSleepingLocked() && isTopActivityInStack;
-        final boolean isTopActivityInMinimizedDockedStack = isTopActivityInStack
-                && stack.mStackId == DOCKED_STACK_ID && mStackSupervisor.mIsDockMinimized
-                && state == ActivityState.PAUSED;
 
         // We want to immediately deliver the intent to the activity if:
-        // - It is the resumed activity.
+        // - It is currently resumed or paused. i.e. it is currently visible to the user and we want
+        //   the user to see the visual effects caused by the intent delivery now.
         // - The device is sleeping and it is the top activity behind the lock screen (b/6700897).
-        // - It is the top activity in a minimized docked stack. In this case the activity will be
-        //   temporarily resumed then paused again on the client side.
-        if ((state == ActivityState.RESUMED || isTopActivityWhileSleeping
-                || isTopActivityInMinimizedDockedStack) && app != null && app.thread != null) {
+        if ((state == ActivityState.RESUMED || state == ActivityState.PAUSED
+                || isTopActivityWhileSleeping) && app != null && app.thread != null) {
             try {
                 ArrayList<ReferrerIntent> ar = new ArrayList<>(1);
                 ar.add(rintent);
                 app.thread.scheduleNewIntent(
-                        ar, appToken, isTopActivityInMinimizedDockedStack /* andPause */);
+                        ar, appToken, state == ActivityState.PAUSED /* andPause */);
                 unsent = false;
             } catch (RemoteException e) {
                 Slog.w(TAG, "Exception thrown sending new intent to " + this, e);