Add reporting of activity movement for search manager.

This adds a new API with the activity manager to find out about movement between
activities.  For my sanity, the old IActivityWatcher is now renamed to
IActivityController, and the new activity movement interface is named
IActivityWatcher.

This changes the search manager itself to use the new API to manage its state.
Note that there are still problems when going back to the search dialog after
it was hidden -- the suggestions window no longer appears until you explicitly
dismiss and re-show it.
diff --git a/core/java/android/app/Activity.java b/core/java/android/app/Activity.java
index 6c2560d..4ac3b9e 100644
--- a/core/java/android/app/Activity.java
+++ b/core/java/android/app/Activity.java
@@ -612,6 +612,7 @@
     // set by the thread after the constructor and before onCreate(Bundle savedInstanceState) is called.
     private Instrumentation mInstrumentation;
     private IBinder mToken;
+    private int mIdent;
     /*package*/ String mEmbeddedID;
     private Application mApplication;
     /*package*/ Intent mIntent;
@@ -789,9 +790,6 @@
     protected void onCreate(Bundle savedInstanceState) {
         mVisibleFromClient = mWindow.getWindowStyle().getBoolean(
                 com.android.internal.R.styleable.Window_windowNoDisplay, true);
-        // uses super.getSystemService() since this.getSystemService() looks at the
-        // mSearchManager field.
-        mSearchManager = (SearchManager) super.getSystemService(Context.SEARCH_SERVICE);
         mCalled = true;
     }
 
@@ -2531,6 +2529,7 @@
      */
     public void startSearch(String initialQuery, boolean selectInitialQuery, 
             Bundle appSearchData, boolean globalSearch) {
+        ensureSearchManager();
         mSearchManager.startSearch(initialQuery, selectInitialQuery, getComponentName(),
                         appSearchData, globalSearch); 
     }
@@ -3241,6 +3240,24 @@
         return getSharedPreferences(getLocalClassName(), mode);
     }
     
+    private void ensureSearchManager() {
+        if (mSearchManager != null) {
+            return;
+        }
+        
+        // uses super.getSystemService() since this.getSystemService() looks at the
+        // mSearchManager field.
+        mSearchManager = (SearchManager) super.getSystemService(Context.SEARCH_SERVICE);
+        int ident = mIdent;
+        if (ident == 0) {
+            if (mParent != null) ident = mParent.mIdent;
+            if (ident == 0) {
+                throw new IllegalArgumentException("no ident");
+            }
+        }
+        mSearchManager.setIdent(ident);
+    }
+    
     @Override
     public Object getSystemService(String name) {
         if (getBaseContext() == null) {
@@ -3251,6 +3268,7 @@
         if (WINDOW_SERVICE.equals(name)) {
             return mWindowManager;
         } else if (SEARCH_SERVICE.equals(name)) {
+            ensureSearchManager();
             return mSearchManager;
         }
         return super.getSystemService(name);
@@ -3450,14 +3468,17 @@
             Application application, Intent intent, ActivityInfo info, CharSequence title, 
             Activity parent, String id, Object lastNonConfigurationInstance,
             Configuration config) {
-        attach(context, aThread, instr, token, application, intent, info, title, parent, id,
+        attach(context, aThread, instr, token, 0, application, intent, info, title, parent, id,
             lastNonConfigurationInstance, null, config);
     }
     
-    final void attach(Context context, ActivityThread aThread, Instrumentation instr, IBinder token,
-        Application application, Intent intent, ActivityInfo info, CharSequence title, 
-        Activity parent, String id, Object lastNonConfigurationInstance,
-        HashMap<String,Object> lastNonConfigurationChildInstances, Configuration config) {
+    final void attach(Context context, ActivityThread aThread,
+            Instrumentation instr, IBinder token, int ident,
+            Application application, Intent intent, ActivityInfo info,
+            CharSequence title, Activity parent, String id,
+            Object lastNonConfigurationInstance,
+            HashMap<String,Object> lastNonConfigurationChildInstances,
+            Configuration config) {
         attachBaseContext(context);
 
         mWindow = PolicyManager.makeNewWindow(this);
@@ -3470,6 +3491,7 @@
         mMainThread = aThread;
         mInstrumentation = instr;
         mToken = token;
+        mIdent = ident;
         mApplication = application;
         mIntent = intent;
         mComponent = intent.getComponent();
@@ -3554,9 +3576,6 @@
 
     final void performPause() {
         onPause();
-
-        // dismiss the search dialog if it is open
-        mSearchManager.stopSearch();
     }
     
     final void performUserLeaving() {