Merge "Revert services assist context in KitKat" into klp-dev
diff --git a/api/current.txt b/api/current.txt
index 3c4555f..9d3dd0f 100644
--- a/api/current.txt
+++ b/api/current.txt
@@ -845,7 +845,6 @@
     field public static final int prompt = 16843131; // 0x101017b
     field public static final int propertyName = 16843489; // 0x10102e1
     field public static final int protectionLevel = 16842761; // 0x1010009
-    field public static final int provideAssistData = 16843758; // 0x10103ee
     field public static final int publicKey = 16843686; // 0x10103a6
     field public static final int queryActionMsg = 16843227; // 0x10101db
     field public static final int queryAfterZeroResults = 16843394; // 0x1010282
@@ -4246,7 +4245,6 @@
     method public void onCreate();
     method public void onDestroy();
     method public void onLowMemory();
-    method public void onProvideAssistData(android.os.Bundle);
     method public void onRebind(android.content.Intent);
     method public deprecated void onStart(android.content.Intent, int);
     method public int onStartCommand(android.content.Intent, int, int);
@@ -6406,7 +6404,6 @@
     field public static final java.lang.String ACTION_USER_INITIALIZE = "android.intent.action.USER_INITIALIZE";
     field public static final java.lang.String ACTION_USER_PRESENT = "android.intent.action.USER_PRESENT";
     field public static final java.lang.String ACTION_VIEW = "android.intent.action.VIEW";
-    field public static final java.lang.String ACTION_VOICE_ASSIST = "android.intent.action.VOICE_ASSIST";
     field public static final java.lang.String ACTION_VOICE_COMMAND = "android.intent.action.VOICE_COMMAND";
     field public static final deprecated java.lang.String ACTION_WALLPAPER_CHANGED = "android.intent.action.WALLPAPER_CHANGED";
     field public static final java.lang.String ACTION_WEB_SEARCH = "android.intent.action.WEB_SEARCH";
@@ -6448,8 +6445,6 @@
     field public static final deprecated java.lang.String EXTRA_ALLOW_REPLACE = "android.intent.extra.ALLOW_REPLACE";
     field public static final java.lang.String EXTRA_ASSIST_CONTEXT = "android.intent.extra.ASSIST_CONTEXT";
     field public static final java.lang.String EXTRA_ASSIST_PACKAGE = "android.intent.extra.ASSIST_PACKAGE";
-    field public static final java.lang.String EXTRA_ASSIST_SERVICES_CONTEXTS = "android.intent.extra.ASSIST_SERVICES_CONTEXTS";
-    field public static final java.lang.String EXTRA_ASSIST_SERVICES_PACKAGES = "android.intent.extra.ASSIST_SERVICES_PACKAGES";
     field public static final java.lang.String EXTRA_BCC = "android.intent.extra.BCC";
     field public static final java.lang.String EXTRA_BUG_REPORT = "android.intent.extra.BUG_REPORT";
     field public static final java.lang.String EXTRA_CC = "android.intent.extra.CC";
@@ -7449,7 +7444,6 @@
     method public void dump(android.util.Printer, java.lang.String);
     field public static final android.os.Parcelable.Creator CREATOR;
     field public static final int FLAG_ISOLATED_PROCESS = 2; // 0x2
-    field public static final int FLAG_PROVIDE_ASSIST_DATA = 4; // 0x4
     field public static final int FLAG_SINGLE_USER = 1073741824; // 0x40000000
     field public static final int FLAG_STOP_WITH_TASK = 1; // 0x1
     field public int flags;
diff --git a/core/java/android/app/ActivityManagerNative.java b/core/java/android/app/ActivityManagerNative.java
index 6b24e6b..370db31 100644
--- a/core/java/android/app/ActivityManagerNative.java
+++ b/core/java/android/app/ActivityManagerNative.java
@@ -1937,8 +1937,7 @@
             data.enforceInterface(IActivityManager.descriptor);
             IBinder token = data.readStrongBinder();
             Bundle extras = data.readBundle();
-            int index = data.readInt();
-            reportAssistContextExtras(token, extras, index);
+            reportAssistContextExtras(token, extras);
             reply.writeNoException();
             return true;
         }
@@ -4492,14 +4491,13 @@
         return res;
     }
 
-    public void reportAssistContextExtras(IBinder token, Bundle extras, int index)
+    public void reportAssistContextExtras(IBinder token, Bundle extras)
             throws RemoteException {
         Parcel data = Parcel.obtain();
         Parcel reply = Parcel.obtain();
         data.writeInterfaceToken(IActivityManager.descriptor);
         data.writeStrongBinder(token);
         data.writeBundle(extras);
-        data.writeInt(index);
         mRemote.transact(REPORT_ASSIST_CONTEXT_EXTRAS_TRANSACTION, data, reply, 0);
         reply.readException();
         data.recycle();
diff --git a/core/java/android/app/ActivityThread.java b/core/java/android/app/ActivityThread.java
index 018fbe0..209514a 100644
--- a/core/java/android/app/ActivityThread.java
+++ b/core/java/android/app/ActivityThread.java
@@ -528,7 +528,6 @@
         IBinder activityToken;
         IBinder requestToken;
         int requestType;
-        int index;
     }
 
     private native void dumpGraphicsInfo(FileDescriptor fd);
@@ -1194,12 +1193,11 @@
 
         @Override
         public void requestAssistContextExtras(IBinder activityToken, IBinder requestToken,
-                int requestType, int index) {
+                int requestType) {
             RequestAssistContextExtras cmd = new RequestAssistContextExtras();
             cmd.activityToken = activityToken;
             cmd.requestToken = requestToken;
             cmd.requestType = requestType;
-            cmd.index = index;
             queueOrSendMessage(H.REQUEST_ASSIST_CONTEXT_EXTRAS, cmd);
         }
 
@@ -2278,18 +2276,13 @@
         if (r != null) {
             r.activity.getApplication().dispatchOnProvideAssistData(r.activity, data);
             r.activity.onProvideAssistData(data);
-        } else {
-            Service service = mServices.get(cmd.activityToken);
-            if (service != null) {
-                service.onProvideAssistData(data);
-            }
         }
         if (data.isEmpty()) {
             data = null;
         }
         IActivityManager mgr = ActivityManagerNative.getDefault();
         try {
-            mgr.reportAssistContextExtras(cmd.requestToken, data, cmd.index);
+            mgr.reportAssistContextExtras(cmd.requestToken, data);
         } catch (RemoteException e) {
         }
     }
diff --git a/core/java/android/app/ApplicationThreadNative.java b/core/java/android/app/ApplicationThreadNative.java
index c0080be..a4e80e5 100644
--- a/core/java/android/app/ApplicationThreadNative.java
+++ b/core/java/android/app/ApplicationThreadNative.java
@@ -606,8 +606,7 @@
             IBinder activityToken = data.readStrongBinder();
             IBinder requestToken = data.readStrongBinder();
             int requestType = data.readInt();
-            int index = data.readInt();
-            requestAssistContextExtras(activityToken, requestToken, requestType, index);
+            requestAssistContextExtras(activityToken, requestToken, requestType);
             reply.writeNoException();
             return true;
         }
@@ -1243,13 +1242,12 @@
 
     @Override
     public void requestAssistContextExtras(IBinder activityToken, IBinder requestToken,
-            int requestType, int index) throws RemoteException {
+            int requestType) throws RemoteException {
         Parcel data = Parcel.obtain();
         data.writeInterfaceToken(IApplicationThread.descriptor);
         data.writeStrongBinder(activityToken);
         data.writeStrongBinder(requestToken);
         data.writeInt(requestType);
-        data.writeInt(index);
         mRemote.transact(REQUEST_ASSIST_CONTEXT_EXTRAS_TRANSACTION, data, null,
                 IBinder.FLAG_ONEWAY);
         data.recycle();
diff --git a/core/java/android/app/IActivityManager.java b/core/java/android/app/IActivityManager.java
index e362afb..b2ae298 100644
--- a/core/java/android/app/IActivityManager.java
+++ b/core/java/android/app/IActivityManager.java
@@ -389,8 +389,7 @@
 
     public Bundle getAssistContextExtras(int requestType) throws RemoteException;
 
-    public void reportAssistContextExtras(IBinder token, Bundle extras, int index)
-            throws RemoteException;
+    public void reportAssistContextExtras(IBinder token, Bundle extras) throws RemoteException;
 
     public void killUid(int uid, String reason) throws RemoteException;
 
diff --git a/core/java/android/app/IApplicationThread.java b/core/java/android/app/IApplicationThread.java
index 01a0a91..058b975 100644
--- a/core/java/android/app/IApplicationThread.java
+++ b/core/java/android/app/IApplicationThread.java
@@ -133,8 +133,8 @@
     void dumpGfxInfo(FileDescriptor fd, String[] args) throws RemoteException;
     void dumpDbInfo(FileDescriptor fd, String[] args) throws RemoteException;
     void unstableProviderDied(IBinder provider) throws RemoteException;
-    void requestAssistContextExtras(IBinder activityToken, IBinder requestToken, int requestType,
-            int index) throws RemoteException;
+    void requestAssistContextExtras(IBinder activityToken, IBinder requestToken, int requestType)
+            throws RemoteException;
     void scheduleTranslucentConversionComplete(IBinder token, boolean timeout)
             throws RemoteException;
     void setProcessState(int state) throws RemoteException;
diff --git a/core/java/android/app/Service.java b/core/java/android/app/Service.java
index 1254bac..3967740 100644
--- a/core/java/android/app/Service.java
+++ b/core/java/android/app/Service.java
@@ -23,7 +23,6 @@
 import android.content.Context;
 import android.content.res.Configuration;
 import android.os.Build;
-import android.os.Bundle;
 import android.os.RemoteException;
 import android.os.IBinder;
 import android.util.Log;
@@ -308,18 +307,6 @@
     }
 
     /**
-     * This is called on foreground services when the user is requesting an assist, to build a
-     * full {@link Intent#ACTION_ASSIST} Intent with all of the context of the current
-     * running foreground services.  You can override this method to place into the bundle
-     * anything you would like to appear as an item in the
-     * {@link Intent#EXTRA_ASSIST_SERVICES_CONTEXTS} part of the assist Intent.
-     * This method will not be called if this service is not in the foreground.
-     * The default implementation does nothing.
-     */
-    public void onProvideAssistData(Bundle data) {
-    }
-
-    /**
      * @deprecated Implement {@link #onStartCommand(Intent, int, int)} instead.
      */
     @Deprecated
diff --git a/core/java/android/content/Intent.java b/core/java/android/content/Intent.java
index 2f2aae4..7925123 100644
--- a/core/java/android/content/Intent.java
+++ b/core/java/android/content/Intent.java
@@ -1153,9 +1153,8 @@
     /**
      * Activity Action: Perform assist action.
      * <p>
-     * Input: {@link #EXTRA_ASSIST_PACKAGE}, {@link #EXTRA_ASSIST_CONTEXT},
-     * {@link #EXTRA_ASSIST_SERVICES_PACKAGES}, and {@link #EXTRA_ASSIST_SERVICES_CONTEXTS} can
-     * provide additional optional contextual information about where the user was when they
+     * Input: {@link #EXTRA_ASSIST_PACKAGE}, {@link #EXTRA_ASSIST_CONTEXT}, can provide
+     * additional optional contextual information about where the user was when they
      * requested the assist.
      * Output: nothing.
      */
@@ -1165,52 +1164,31 @@
     /**
      * Activity Action: Perform voice assist action.
      * <p>
-     * Input: {@link #EXTRA_ASSIST_PACKAGE}, {@link #EXTRA_ASSIST_CONTEXT},
-     * {@link #EXTRA_ASSIST_SERVICES_PACKAGES}, and {@link #EXTRA_ASSIST_SERVICES_CONTEXTS} can
-     * provide additional optional contextual information about where the user was when they
+     * Input: {@link #EXTRA_ASSIST_PACKAGE}, {@link #EXTRA_ASSIST_CONTEXT}, can provide
+     * additional optional contextual information about where the user was when they
      * requested the voice assist.
      * Output: nothing.
+     * @hide
      */
     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
     public static final String ACTION_VOICE_ASSIST = "android.intent.action.VOICE_ASSIST";
 
     /**
-     * An optional field on {@link #ACTION_ASSIST} and {@link #ACTION_VOICE_ASSIST}
-     * containing the name of the current foreground application package at the time
-     * the assist was invoked.
+     * An optional field on {@link #ACTION_ASSIST} containing the name of the current foreground
+     * application package at the time the assist was invoked.
      */
     public static final String EXTRA_ASSIST_PACKAGE
             = "android.intent.extra.ASSIST_PACKAGE";
 
     /**
-     * An optional field on {@link #ACTION_ASSIST} and {@link #ACTION_VOICE_ASSIST}
-     * containing additional contextual information supplied by the current
-     * foreground app at the time of the assist request.  This is a {@link Bundle} of
-     * additional data.
+     * An optional field on {@link #ACTION_ASSIST} and containing additional contextual
+     * information supplied by the current foreground app at the time of the assist request.
+     * This is a {@link Bundle} of additional data.
      */
     public static final String EXTRA_ASSIST_CONTEXT
             = "android.intent.extra.ASSIST_CONTEXT";
 
     /**
-     * An optional field on {@link #ACTION_ASSIST} and {@link #ACTION_VOICE_ASSIST}
-     * containing the application package names of foreground services at the time
-     * of the assist request.  This is an array of {@link String}s, with one entry
-     * per service.
-     */
-    public static final String EXTRA_ASSIST_SERVICES_PACKAGES
-            = "android.intent.extra.ASSIST_SERVICES_PACKAGES";
-
-    /**
-     * An optional field on {@link #ACTION_ASSIST} and {@link #ACTION_VOICE_ASSIST}
-     * containing additional contextual information supplied by the current
-     * foreground services at the time of the assist request.  This is an array
-     * of {@link Bundle}s of additional data, with one {@link Bundle} per service.
-     */
-    public static final String EXTRA_ASSIST_SERVICES_CONTEXTS
-            = "android.intent.extra.ASSIST_SERVICES_CONTEXTS";
-
-
-    /**
      * Activity Action: List all available applications
      * <p>Input: Nothing.
      * <p>Output: nothing.
diff --git a/core/java/android/content/pm/PackageParser.java b/core/java/android/content/pm/PackageParser.java
index 6760f49..4494e69 100644
--- a/core/java/android/content/pm/PackageParser.java
+++ b/core/java/android/content/pm/PackageParser.java
@@ -3015,11 +3015,6 @@
 
         s.info.flags = 0;
         if (sa.getBoolean(
-                com.android.internal.R.styleable.AndroidManifestService_provideAssistData,
-                false)) {
-            s.info.flags |= ServiceInfo.FLAG_PROVIDE_ASSIST_DATA;
-        }
-        if (sa.getBoolean(
                 com.android.internal.R.styleable.AndroidManifestService_stopWithTask,
                 false)) {
             s.info.flags |= ServiceInfo.FLAG_STOP_WITH_TASK;
diff --git a/core/java/android/content/pm/ServiceInfo.java b/core/java/android/content/pm/ServiceInfo.java
index 3dc8717..796c2a4 100644
--- a/core/java/android/content/pm/ServiceInfo.java
+++ b/core/java/android/content/pm/ServiceInfo.java
@@ -49,14 +49,6 @@
     public static final int FLAG_ISOLATED_PROCESS = 0x0002;
 
     /**
-     * Bit in {@link #flags}: If set,
-     * {@link android.app.Service#onProvideAssistData(android.os.Bundle)} will
-     * be called on the service when it is running in the foreground. Set from
-     * the {@link android.R.attr#provideAssistData} attribute.
-     */
-    public static final int FLAG_PROVIDE_ASSIST_DATA = 0x0004;
-
-    /**
      * Bit in {@link #flags}: If set, a single instance of the service will
      * run for all users on the device.  Set from the
      * {@link android.R.attr#singleUser} attribute.
diff --git a/core/res/res/values/attrs_manifest.xml b/core/res/res/values/attrs_manifest.xml
index 05ca120..d2ada7a 100644
--- a/core/res/res/values/attrs_manifest.xml
+++ b/core/res/res/values/attrs_manifest.xml
@@ -1379,9 +1379,6 @@
              component specific values). -->
         <attr name="enabled" />
         <attr name="exported" />
-        <!-- If set to true, onProvideAssistData will be called on this service when this service
-             is running in the foreground. -->
-        <attr name="provideAssistData" format="boolean" />
         <!-- If set to true, this service with be automatically stopped
              when the user remove a task rooted in an activity owned by
              the application.  The default is false. -->
diff --git a/core/res/res/values/public.xml b/core/res/res/values/public.xml
index 1b4a083..cd1402c 100644
--- a/core/res/res/values/public.xml
+++ b/core/res/res/values/public.xml
@@ -2077,6 +2077,5 @@
   <public type="attr" name="supportsSwitchingToNextInputMethod" />
   <public type="attr" name="requireDeviceUnlock" />
   <public type="attr" name="apduServiceBanner" />
-  <public type="attr" name="provideAssistData" />
 
 </resources>
diff --git a/core/res/res/values/strings.xml b/core/res/res/values/strings.xml
index 68acd8c..41be951 100644
--- a/core/res/res/values/strings.xml
+++ b/core/res/res/values/strings.xml
@@ -831,7 +831,7 @@
     <string name="permlab_getTopActivityInfo">get current app info</string>
     <!-- Description of an application permission, listed so the user can choose whether they want to allow the application to do this. -->
     <string name="permdesc_getTopActivityInfo">Allows the holder to retrieve private information
-        about the current application and services in the foreground of the screen.</string>
+        about the current application in the foreground of the screen.</string>
 
     <!-- Title of an application permission, listed so the user can choose whether they want to allow the application to do this. -->
     <string name="permlab_runSetActivityWatcher">monitor and control all app launching</string>
diff --git a/services/java/com/android/server/am/ActivityManagerService.java b/services/java/com/android/server/am/ActivityManagerService.java
index 13eb169..96b7030 100644
--- a/services/java/com/android/server/am/ActivityManagerService.java
+++ b/services/java/com/android/server/am/ActivityManagerService.java
@@ -187,7 +187,6 @@
 import java.lang.ref.WeakReference;
 import java.util.ArrayList;
 import java.util.Arrays;
-import java.util.Collection;
 import java.util.Collections;
 import java.util.Comparator;
 import java.util.HashMap;
@@ -314,10 +313,6 @@
     // to respond with the result.
     static final int PENDING_ASSIST_EXTRAS_TIMEOUT = 500;
 
-    // Index for assist context bundle pertaining to the top activity. Non-negative indices
-    // correspond to assist context bundles from foreground services.
-    static final int TOP_ACTIVITY_ASSIST_EXTRAS_INDEX = -1;
-
     static final int MY_PID = Process.myPid();
 
     static final String[] EMPTY_STRING_ARRAY = new String[0];
@@ -394,30 +389,16 @@
 
     public class PendingAssistExtras extends Binder implements Runnable {
         public final ActivityRecord activity;
-        public final List<ServiceRecord> services;
-        public int numPending;
-        public int numRespondedServices = 0;
-        public Bundle activityExtras = null;
-        public Bundle[] servicesExtras;
-        public PendingAssistExtras(ActivityRecord _activity, List<ServiceRecord> _services) {
+        public boolean haveResult = false;
+        public Bundle result = null;
+        public PendingAssistExtras(ActivityRecord _activity) {
             activity = _activity;
-            services = _services;
-            numPending = services.size() + 1;
         }
         @Override
         public void run() {
-            if (activityExtras == null) {
-                Slog.w(TAG, "getAssistContextExtras failed: timeout retrieving from activtity "
-                        + activity);
-            }
-            for (int i = 0; i < services.size(); i++) {
-                if (servicesExtras[i] == null) {
-                    Slog.w(TAG, "getAssistContextExtras failed: timeout retrieving from service "
-                            + i + " " + services.get(i));
-                }
-            }
+            Slog.w(TAG, "getAssistContextExtras failed: timeout retrieving from " + activity);
             synchronized (this) {
-                numPending = 0;
+                haveResult = true;
                 notifyAll();
             }
         }
@@ -8049,81 +8030,41 @@
                 "getAssistContextExtras()");
         PendingAssistExtras pae;
         Bundle extras = new Bundle();
-        List<ServiceRecord> foregroundServices;
         synchronized (this) {
-            Collection<ServiceRecord> allServices = mServices.mServiceMap.getAllServices(
-                    Binder.getCallingUid());
-            foregroundServices = new ArrayList<ServiceRecord>();
-            for (ServiceRecord record : allServices) {
-                if ((record.serviceInfo.flags & ServiceInfo.FLAG_PROVIDE_ASSIST_DATA) > 0 &&
-                        record.isForeground) {
-                    if (record.app == null || record.app.thread == null) {
-                        Slog.w(TAG, "getAssistContextExtras error: no process for " + record);
-                        continue;
-                    }
-                    if (record.app.pid == Binder.getCallingPid()) {
-                        Slog.w(TAG, "getAssistContextExtras error: request process same as " +
-                                record);
-                        continue;
-                    }
-                    foregroundServices.add(record);
-                }
-            }
-
             ActivityRecord activity = getFocusedStack().mResumedActivity;
-            boolean validActivity = true;
             if (activity == null) {
-                Slog.w(TAG, "getAssistContextExtras error: no resumed activity");
-                validActivity = false;
-            } else if (activity.app == null || activity.app.thread == null) {
-                Slog.w(TAG, "getAssistContextExtras error: no process for " + activity);
-                validActivity = false;
-            } else if (activity.app.pid == Binder.getCallingPid()) {
-                Slog.w(TAG, "getAssistContextExtras error: request process same as " + activity);
-                validActivity = false;
+                Slog.w(TAG, "getAssistContextExtras failed: no resumed activity");
+                return null;
             }
-
-            pae = new PendingAssistExtras(activity, foregroundServices);
+            extras.putString(Intent.EXTRA_ASSIST_PACKAGE, activity.packageName);
+            if (activity.app == null || activity.app.thread == null) {
+                Slog.w(TAG, "getAssistContextExtras failed: no process for " + activity);
+                return extras;
+            }
+            if (activity.app.pid == Binder.getCallingPid()) {
+                Slog.w(TAG, "getAssistContextExtras failed: request process same as " + activity);
+                return extras;
+            }
+            pae = new PendingAssistExtras(activity);
             try {
-                if (validActivity) {
-                    activity.app.thread.requestAssistContextExtras(activity.appToken, pae,
-                            requestType, -1);
-                }
-                for (int i = 0; i < foregroundServices.size(); i++) {
-                    ServiceRecord record = foregroundServices.get(i);
-                    record.app.thread.requestAssistContextExtras(record, pae, requestType, i);
-                }
+                activity.app.thread.requestAssistContextExtras(activity.appToken, pae,
+                        requestType);
                 mPendingAssistExtras.add(pae);
                 mHandler.postDelayed(pae, PENDING_ASSIST_EXTRAS_TIMEOUT);
             } catch (RemoteException e) {
-                Slog.w(TAG, "getAssistContextExtras failed: crash fetching extras.", e);
+                Slog.w(TAG, "getAssistContextExtras failed: crash calling " + activity);
+                return extras;
             }
         }
         synchronized (pae) {
-            while (pae.numPending > 0) {
+            while (!pae.haveResult) {
                 try {
                     pae.wait();
                 } catch (InterruptedException e) {
                 }
             }
-            if (pae.activityExtras != null) {
-                extras.putBundle(Intent.EXTRA_ASSIST_CONTEXT, pae.activityExtras);
-                extras.putString(Intent.EXTRA_ASSIST_PACKAGE, pae.activity.packageName);
-            }
-            if (pae.numRespondedServices > 0) {
-                Bundle[] servicesExtras = new Bundle[pae.numRespondedServices];
-                String[] servicesPackages = new String[pae.numRespondedServices];
-                int extrasIndex = 0;
-                for (int i = 0; i < foregroundServices.size(); i++) {
-                    if (pae.servicesExtras[i] != null) {
-                        servicesExtras[extrasIndex] = pae.servicesExtras[i];
-                        ServiceRecord record = foregroundServices.get(i);
-                        servicesPackages[extrasIndex] = record.packageName;
-                        extrasIndex++;
-                    }
-                }
-                extras.putParcelableArray(Intent.EXTRA_ASSIST_SERVICES_CONTEXTS, servicesExtras);
-                extras.putStringArray(Intent.EXTRA_ASSIST_SERVICES_PACKAGES, servicesPackages);
+            if (pae.result != null) {
+                extras.putBundle(Intent.EXTRA_ASSIST_CONTEXT, pae.result);
             }
         }
         synchronized (this) {
@@ -8133,19 +8074,12 @@
         return extras;
     }
 
-    public void reportAssistContextExtras(IBinder token, Bundle extras, int index) {
+    public void reportAssistContextExtras(IBinder token, Bundle extras) {
         PendingAssistExtras pae = (PendingAssistExtras)token;
         synchronized (pae) {
-            if (index == TOP_ACTIVITY_ASSIST_EXTRAS_INDEX) {
-                pae.activityExtras = extras;
-            } else {
-                pae.servicesExtras[index] = extras;
-                pae.numRespondedServices++;
-            }
-            pae.numPending--;
-            if (pae.numPending == 0) {
-                pae.notifyAll();
-            }
+            pae.result = extras;
+            pae.haveResult = true;
+            pae.notifyAll();
         }
     }