Work on issue #6579997: Mariner entrance animation

Add a new variation of ActivityOptions that allows you to
supply custom animation resources and get a callback when the
animation starts.

Use this in SearchPanelView to determine when to start hiding
the search panel instead of having a fixed delay.

Fix some issues in the activity manager where we would cancel
the options in cases where we should actually keep them to give
to the window manager for a transition.  (Basically when the
activity being started is not actually ending up launched, but
just results in a shift in the activity stack.)

Note that this is not quite what the design calls for -- the
entire search UI is waiting and then disappearing when the
animation starts, instead of the ring first disappearing while
waiting for the time to fade out the circle.

Change-Id: Iee9a404ba530908d73cdbd4a9d0d2907ac03428f
diff --git a/services/java/com/android/server/am/ActivityStack.java b/services/java/com/android/server/am/ActivityStack.java
index 5b15e50..6af7a88 100755
--- a/services/java/com/android/server/am/ActivityStack.java
+++ b/services/java/com/android/server/am/ActivityStack.java
@@ -1371,6 +1371,10 @@
      * nothing happened.
      */
     final boolean resumeTopActivityLocked(ActivityRecord prev) {
+        return resumeTopActivityLocked(prev, null);
+    }
+
+    final boolean resumeTopActivityLocked(ActivityRecord prev, Bundle options) {
         // Find the first activity that is not finishing.
         ActivityRecord next = topRunningActivityLocked(null);
 
@@ -1383,6 +1387,7 @@
             // There are no more activities!  Let's just start up the
             // Launcher...
             if (mMainStack) {
+                ActivityOptions.abort(options);
                 return mService.startHomeActivityLocked(0);
             }
         }
@@ -1395,6 +1400,7 @@
             // should be nothing left to do at this point.
             mService.mWindowManager.executeAppTransition();
             mNoAnimActivities.clear();
+            ActivityOptions.abort(options);
             return false;
         }
 
@@ -1409,6 +1415,7 @@
             // should be nothing left to do at this point.
             mService.mWindowManager.executeAppTransition();
             mNoAnimActivities.clear();
+            ActivityOptions.abort(options);
             return false;
         }
         
@@ -1419,6 +1426,8 @@
         next.sleeping = false;
         mWaitingVisibleActivities.remove(next);
 
+        next.updateOptionsLocked(options);
+
         if (DEBUG_SWITCH) Slog.v(TAG, "Resuming " + next);
 
         // If we are currently pausing an activity, then don't do anything
@@ -2666,6 +2675,7 @@
                             movedHome = true;
                             moveHomeToFrontFromLaunchLocked(launchFlags);
                             moveTaskToFrontLocked(taskTop.task, r, options);
+                            options = null;
                         }
                     }
                     // If the caller has requested that the target task be
@@ -2679,9 +2689,10 @@
                         // is the case, so this is it!  And for paranoia, make
                         // sure we have correctly resumed the top activity.
                         if (doResume) {
-                            resumeTopActivityLocked(null);
+                            resumeTopActivityLocked(null, options);
+                        } else {
+                            ActivityOptions.abort(options);
                         }
-                        ActivityOptions.abort(options);
                         return ActivityManager.START_RETURN_INTENT_TO_CALLER;
                     }
                     if ((launchFlags &
@@ -2767,9 +2778,10 @@
                         // don't use that intent!)  And for paranoia, make
                         // sure we have correctly resumed the top activity.
                         if (doResume) {
-                            resumeTopActivityLocked(null);
+                            resumeTopActivityLocked(null, options);
+                        } else {
+                            ActivityOptions.abort(options);
                         }
-                        ActivityOptions.abort(options);
                         return ActivityManager.START_TASK_TO_FRONT;
                     }
                 }