Introduce onNewActivityOptions for return activity

When an activity that is already translucent returns to the
previous activity using a scene transition the receiving activity
did not receive its ActivityOptions for its side of the animation.
The new method onNewActivityOptions() delivers those options.

Fixes bug 14869070.

Change-Id: I09b136b3213aae5d3521894e17a7500ac793f3d2
diff --git a/services/core/java/com/android/server/am/ActivityStack.java b/services/core/java/com/android/server/am/ActivityStack.java
index f2922c3..7be7779 100755
--- a/services/core/java/com/android/server/am/ActivityStack.java
+++ b/services/core/java/com/android/server/am/ActivityStack.java
@@ -209,7 +209,7 @@
     // Activity.onTranslucentConversionComplete(false). If a timeout occurs prior to the last
     // background activity being drawn then the same call will be made with a true value.
     ActivityRecord mTranslucentActivityWaiting = null;
-    ArrayList<ActivityRecord> mUndrawnActivitiesBelowTopTranslucent =
+    private ArrayList<ActivityRecord> mUndrawnActivitiesBelowTopTranslucent =
             new ArrayList<ActivityRecord>();
     // Options passed from the caller of the convertToTranslucent to the activity that will
     // appear below it.
@@ -1203,7 +1203,17 @@
                         // else to do here.
                         if (DEBUG_VISBILITY) Slog.v(TAG, "Skipping: already visible at " + r);
                         r.stopFreezingScreenLocked(false);
-
+                        try {
+                            if (mReturningActivityOptions != null) {
+                                if (activityNdx > 0) {
+                                    ActivityRecord under = activities.get(activityNdx - 1);
+                                    under.app.thread.scheduleOnNewActivityOptions(under.appToken,
+                                            mReturningActivityOptions);
+                                }
+                                mReturningActivityOptions = null;
+                            }
+                        } catch(RemoteException e) {
+                        }
                     } else if (onlyThisProcess == null) {
                         // This activity is not currently visible, but is running.
                         // Tell it to become visible.
@@ -1291,6 +1301,12 @@
                 }
             }
         }
+
+        if (mTranslucentActivityWaiting != null &&
+                mUndrawnActivitiesBelowTopTranslucent.isEmpty()) {
+            // Nothing is getting drawn or everything was already visible, don't wait for timeout.
+            notifyActivityDrawnLocked(null);
+        }
     }
 
     void convertToTranslucent(ActivityRecord r, ActivityOptions options) {