Merge "More API changes." into mnc-dev
diff --git a/Android.mk b/Android.mk
index d6dac53..4d8a37c 100644
--- a/Android.mk
+++ b/Android.mk
@@ -555,8 +555,6 @@
 	frameworks/base/core/java/android/service/chooser/ChooserTarget.aidl \
 	frameworks/base/core/java/android/speech/tts/Voice.aidl \
 	frameworks/base/core/java/android/app/usage/UsageEvents.aidl \
-	frameworks/base/core/java/android/app/AssistStructure.aidl \
-	frameworks/base/core/java/android/app/AssistContent.aidl \
 	frameworks/base/core/java/android/app/Notification.aidl \
 	frameworks/base/core/java/android/app/NotificationManager.aidl \
 	frameworks/base/core/java/android/app/WallpaperInfo.aidl \
@@ -566,6 +564,8 @@
 	frameworks/base/core/java/android/app/AlarmManager.aidl \
 	frameworks/base/core/java/android/app/SearchableInfo.aidl \
 	frameworks/base/core/java/android/app/VoiceInteractor.aidl \
+	frameworks/base/core/java/android/app/assist/AssistContent.aidl \
+	frameworks/base/core/java/android/app/assist/AssistStructure.aidl \
 	frameworks/base/core/java/android/app/job/JobParameters.aidl \
 	frameworks/base/core/java/android/app/job/JobInfo.aidl \
 	frameworks/base/core/java/android/appwidget/AppWidgetProviderInfo.aidl \
diff --git a/api/current.txt b/api/current.txt
index 481e651..c9a8efb 100644
--- a/api/current.txt
+++ b/api/current.txt
@@ -3445,7 +3445,7 @@
     method public void onPrepareNavigateUpTaskStack(android.app.TaskStackBuilder);
     method public boolean onPrepareOptionsMenu(android.view.Menu);
     method public boolean onPreparePanel(int, android.view.View, android.view.Menu);
-    method public void onProvideAssistContent(android.app.AssistContent);
+    method public void onProvideAssistContent(android.app.assist.AssistContent);
     method public void onProvideAssistData(android.os.Bundle);
     method public void onRequestPermissionsResult(int, java.lang.String[], int[]);
     method protected void onRestart();
@@ -3996,26 +3996,19 @@
     field public java.lang.String serviceDetails;
   }
 
-  public class AssistContent implements android.os.Parcelable {
+  public deprecated class AssistContent {
     ctor public AssistContent();
-    method public int describeContents();
     method public android.content.ClipData getClipData();
-    method public android.content.Intent getIntent();
     method public android.net.Uri getWebUri();
     method public void setClipData(android.content.ClipData);
     method public void setIntent(android.content.Intent);
     method public void setWebUri(android.net.Uri);
-    method public void writeToParcel(android.os.Parcel, int);
-    field public static final android.os.Parcelable.Creator<android.app.AssistContent> CREATOR;
   }
 
-  public final class AssistStructure implements android.os.Parcelable {
-    method public int describeContents();
+  public deprecated class AssistStructure {
+    ctor public AssistStructure();
     method public android.content.ComponentName getActivityComponent();
-    method public android.app.AssistStructure.WindowNode getWindowNodeAt(int);
     method public int getWindowNodeCount();
-    method public void writeToParcel(android.os.Parcel, int);
-    field public static final android.os.Parcelable.Creator<android.app.AssistStructure> CREATOR;
   }
 
   public static class AssistStructure.ViewNode {
@@ -5900,6 +5893,26 @@
 
 }
 
+package android.app.assist {
+
+  public final class AssistContent extends android.app.AssistContent implements android.os.Parcelable {
+    ctor public AssistContent(android.os.Parcel);
+    method public int describeContents();
+    method public android.content.Intent getIntent();
+    method public void writeToParcel(android.os.Parcel, int);
+    field public static final android.os.Parcelable.Creator<android.app.assist.AssistContent> CREATOR;
+  }
+
+  public final class AssistStructure extends android.app.AssistStructure implements android.os.Parcelable {
+    ctor public AssistStructure();
+    method public int describeContents();
+    method public android.app.AssistStructure.WindowNode getWindowNodeAt(int);
+    method public void writeToParcel(android.os.Parcel, int);
+    field public static final android.os.Parcelable.Creator<android.app.assist.AssistStructure> CREATOR;
+  }
+
+}
+
 package android.app.backup {
 
   public abstract class BackupAgent extends android.content.ContextWrapper {
@@ -28935,7 +28948,7 @@
     method public android.view.View onCreateContentView();
     method public void onDestroy();
     method public boolean[] onGetSupportedCommands(java.lang.String[]);
-    method public void onHandleAssist(android.os.Bundle, android.app.AssistStructure, android.app.AssistContent);
+    method public void onHandleAssist(android.os.Bundle, android.app.assist.AssistStructure, android.app.assist.AssistContent);
     method public void onHide();
     method public boolean onKeyDown(int, android.view.KeyEvent);
     method public boolean onKeyLongPress(int, android.view.KeyEvent);
diff --git a/api/system-current.txt b/api/system-current.txt
index 32af01c..2f26891 100644
--- a/api/system-current.txt
+++ b/api/system-current.txt
@@ -3531,7 +3531,7 @@
     method public void onPrepareNavigateUpTaskStack(android.app.TaskStackBuilder);
     method public boolean onPrepareOptionsMenu(android.view.Menu);
     method public boolean onPreparePanel(int, android.view.View, android.view.Menu);
-    method public void onProvideAssistContent(android.app.AssistContent);
+    method public void onProvideAssistContent(android.app.assist.AssistContent);
     method public void onProvideAssistData(android.os.Bundle);
     method public void onRequestPermissionsResult(int, java.lang.String[], int[]);
     method protected void onRestart();
@@ -4092,26 +4092,19 @@
     field public java.lang.String serviceDetails;
   }
 
-  public class AssistContent implements android.os.Parcelable {
+  public deprecated class AssistContent {
     ctor public AssistContent();
-    method public int describeContents();
     method public android.content.ClipData getClipData();
-    method public android.content.Intent getIntent();
     method public android.net.Uri getWebUri();
     method public void setClipData(android.content.ClipData);
     method public void setIntent(android.content.Intent);
     method public void setWebUri(android.net.Uri);
-    method public void writeToParcel(android.os.Parcel, int);
-    field public static final android.os.Parcelable.Creator<android.app.AssistContent> CREATOR;
   }
 
-  public final class AssistStructure implements android.os.Parcelable {
-    method public int describeContents();
+  public deprecated class AssistStructure {
+    ctor public AssistStructure();
     method public android.content.ComponentName getActivityComponent();
-    method public android.app.AssistStructure.WindowNode getWindowNodeAt(int);
     method public int getWindowNodeCount();
-    method public void writeToParcel(android.os.Parcel, int);
-    field public static final android.os.Parcelable.Creator<android.app.AssistStructure> CREATOR;
   }
 
   public static class AssistStructure.ViewNode {
@@ -6015,6 +6008,26 @@
 
 }
 
+package android.app.assist {
+
+  public final class AssistContent extends android.app.AssistContent implements android.os.Parcelable {
+    ctor public AssistContent(android.os.Parcel);
+    method public int describeContents();
+    method public android.content.Intent getIntent();
+    method public void writeToParcel(android.os.Parcel, int);
+    field public static final android.os.Parcelable.Creator<android.app.assist.AssistContent> CREATOR;
+  }
+
+  public final class AssistStructure extends android.app.AssistStructure implements android.os.Parcelable {
+    ctor public AssistStructure();
+    method public int describeContents();
+    method public android.app.AssistStructure.WindowNode getWindowNodeAt(int);
+    method public void writeToParcel(android.os.Parcel, int);
+    field public static final android.os.Parcelable.Creator<android.app.assist.AssistStructure> CREATOR;
+  }
+
+}
+
 package android.app.backup {
 
   public abstract class BackupAgent extends android.content.ContextWrapper {
@@ -31068,7 +31081,7 @@
     method public android.view.View onCreateContentView();
     method public void onDestroy();
     method public boolean[] onGetSupportedCommands(java.lang.String[]);
-    method public void onHandleAssist(android.os.Bundle, android.app.AssistStructure, android.app.AssistContent);
+    method public void onHandleAssist(android.os.Bundle, android.app.assist.AssistStructure, android.app.assist.AssistContent);
     method public void onHide();
     method public boolean onKeyDown(int, android.view.KeyEvent);
     method public boolean onKeyLongPress(int, android.view.KeyEvent);
diff --git a/core/java/android/app/Activity.java b/core/java/android/app/Activity.java
index 073fefc..90567c7 100644
--- a/core/java/android/app/Activity.java
+++ b/core/java/android/app/Activity.java
@@ -38,6 +38,7 @@
 
 import android.annotation.SystemApi;
 import android.app.admin.DevicePolicyManager;
+import android.app.assist.AssistContent;
 import android.content.ComponentCallbacks2;
 import android.content.ComponentName;
 import android.content.ContentResolver;
diff --git a/core/java/android/app/ActivityManagerNative.java b/core/java/android/app/ActivityManagerNative.java
index e4def1e..b6cec60 100644
--- a/core/java/android/app/ActivityManagerNative.java
+++ b/core/java/android/app/ActivityManagerNative.java
@@ -17,6 +17,8 @@
 package android.app;
 
 import android.app.ActivityManager.StackInfo;
+import android.app.assist.AssistContent;
+import android.app.assist.AssistStructure;
 import android.content.ComponentName;
 import android.content.IIntentReceiver;
 import android.content.IIntentSender;
diff --git a/core/java/android/app/ActivityThread.java b/core/java/android/app/ActivityThread.java
index 2a98b6c..3224d41 100644
--- a/core/java/android/app/ActivityThread.java
+++ b/core/java/android/app/ActivityThread.java
@@ -16,6 +16,8 @@
 
 package android.app;
 
+import android.app.assist.AssistContent;
+import android.app.assist.AssistStructure;
 import android.app.backup.BackupAgent;
 import android.content.BroadcastReceiver;
 import android.content.ComponentCallbacks2;
diff --git a/core/java/android/app/AssistContent.java b/core/java/android/app/AssistContent.java
index f271af1..4cb89a8 100644
--- a/core/java/android/app/AssistContent.java
+++ b/core/java/android/app/AssistContent.java
@@ -26,9 +26,11 @@
 /**
  * Holds information about the content an application is viewing, to hand to an
  * assistant at the user's request.  This is filled in by
- * {@link Activity#onProvideAssistContent Activity.onProvideAssistContent}.
+ * {@link android.app.Activity#onProvideAssistContent Activity.onProvideAssistContent}.
+ * @deprecated use {@link android.app.assist.AssistContent}.
  */
-public class AssistContent implements Parcelable {
+@Deprecated
+public class AssistContent {
     private Intent mIntent;
     private ClipData mClipData;
     private Uri mUri;
@@ -36,16 +38,16 @@
     /**
      * @hide
      * Key name this data structure is stored in the Bundle generated by
-     * {@link Activity#onProvideAssistData}.
+     * {@link android.app.Activity#onProvideAssistData}.
      */
     public static final String ASSIST_KEY = "android:assist_content";
 
     /**
      * @hide
      * Retrieve the framework-generated AssistContent that is stored within
-     * the Bundle filled in by {@link Activity#onProvideAssistContent}.
+     * the Bundle filled in by {@link android.app.Activity#onProvideAssistContent}.
      */
-    public static AssistContent getAssistContent(Bundle assistBundle) {
+    public static android.app.assist.AssistContent getAssistContent(Bundle assistBundle) {
         return assistBundle.getParcelable(ASSIST_KEY);
     }
 
@@ -71,6 +73,7 @@
 
     /**
      * Return the current {@link #setIntent}, which you can modify in-place.
+     * @hide
      */
     public Intent getIntent() {
         return mIntent;
@@ -116,7 +119,8 @@
         return mUri;
     }
 
-    AssistContent(Parcel in) {
+    /** @hide */
+    public AssistContent(Parcel in) {
         if (in.readInt() != 0) {
             mIntent = Intent.CREATOR.createFromParcel(in);
         }
@@ -128,13 +132,8 @@
         }
     }
 
-    @Override
-    public int describeContents() {
-        return 0;
-    }
-
-    @Override
-    public void writeToParcel(Parcel dest, int flags) {
+    /** @hide */
+    public void writeToParcelInternal(Parcel dest, int flags) {
         if (mIntent != null) {
             dest.writeInt(1);
             mIntent.writeToParcel(dest, flags);
@@ -154,15 +153,4 @@
             dest.writeInt(0);
         }
     }
-
-    public static final Parcelable.Creator<AssistContent> CREATOR
-            = new Parcelable.Creator<AssistContent>() {
-        public AssistContent createFromParcel(Parcel in) {
-            return new AssistContent(in);
-        }
-
-        public AssistContent[] newArray(int size) {
-            return new AssistContent[size];
-        }
-    };
 }
diff --git a/core/java/android/app/AssistStructure.java b/core/java/android/app/AssistStructure.java
index ca47a5e..ef7fde4 100644
--- a/core/java/android/app/AssistStructure.java
+++ b/core/java/android/app/AssistStructure.java
@@ -17,9 +17,7 @@
 package android.app;
 
 import android.content.ComponentName;
-import android.graphics.Paint;
 import android.graphics.Rect;
-import android.graphics.Typeface;
 import android.os.Binder;
 import android.os.Bundle;
 import android.os.IBinder;
@@ -29,7 +27,6 @@
 import android.os.PooledStringWriter;
 import android.os.RemoteException;
 import android.os.SystemClock;
-import android.text.TextPaint;
 import android.text.TextUtils;
 import android.util.Log;
 import android.view.View;
@@ -42,19 +39,22 @@
 
 /**
  * Assist data automatically created by the platform's implementation
- * of {@link Activity#onProvideAssistData}.
+ * of {@link android.app.Activity#onProvideAssistData}.
+ * @deprecated use {@link android.app.assist.AssistStructure}.
  */
-final public class AssistStructure implements Parcelable {
+@Deprecated
+public class AssistStructure {
     static final String TAG = "AssistStructure";
 
     /**
      * @hide
      * Key name this data structure is stored in the Bundle generated by
-     * {@link Activity#onProvideAssistData}.
+     * {@link android.app.Activity#onProvideAssistData}.
      */
     public static final String ASSIST_KEY = "android:assist_structure";
 
-    boolean mHaveData;
+    /** @hide */
+    public boolean mHaveData;
 
     ComponentName mActivityComponent;
 
@@ -62,15 +62,18 @@
 
     final ArrayList<ViewNodeBuilder> mPendingAsyncChildren = new ArrayList<>();
 
-    SendChannel mSendChannel;
-    IBinder mReceiveChannel;
+    /** @hide */
+    public SendChannel mSendChannel;
+    /** @hide */
+    public IBinder mReceiveChannel;
 
     Rect mTmpRect = new Rect();
 
     static final int TRANSACTION_XFER = Binder.FIRST_CALL_TRANSACTION+1;
     static final String DESCRIPTOR = "android.app.AssistStructure";
 
-    final class SendChannel extends Binder {
+    /** @hide */
+    public final class SendChannel extends Binder {
         @Override protected boolean onTransact(int code, Parcel data, Parcel reply, int flags)
                 throws RemoteException {
             if (code == TRANSACTION_XFER) {
@@ -702,7 +705,8 @@
         }
     }
 
-    AssistStructure(Activity activity) {
+    /** @hide */
+    public AssistStructure(Activity activity) {
         mHaveData = true;
         mActivityComponent = activity.getComponentName();
         ArrayList<ViewRootImpl> views = WindowManagerGlobal.getInstance().getRootViews(
@@ -713,12 +717,13 @@
         }
     }
 
-    AssistStructure() {
+    public AssistStructure() {
         mHaveData = true;
         mActivityComponent = null;
     }
 
-    AssistStructure(Parcel in) {
+    /** @hide */
+    public AssistStructure(Parcel in) {
         mReceiveChannel = in.readStrongBinder();
     }
 
@@ -792,7 +797,7 @@
      * Retrieve the framework-generated AssistStructure that is stored within
      * the Bundle filled in by {@link Activity#onProvideAssistData}.
      */
-    public static AssistStructure getAssistStructure(Bundle assistBundle) {
+    public static android.app.assist.AssistStructure getAssistStructure(Bundle assistBundle) {
         return assistBundle.getParcelable(ASSIST_KEY);
     }
 
@@ -812,16 +817,13 @@
     /**
      * Return one of the windows in the assist data.
      * @param index Which window to retrieve, may be 0 to {@link #getWindowNodeCount()}-1.
+     * @hide
      */
     public WindowNode getWindowNodeAt(int index) {
         ensureData();
         return mWindowNodes.get(index);
     }
 
-    public int describeContents() {
-        return 0;
-    }
-
     /** @hide */
     public void ensureData() {
         if (mHaveData) {
@@ -880,29 +882,4 @@
         }
         //dump();
     }
-
-    public void writeToParcel(Parcel out, int flags) {
-        if (mHaveData) {
-            // This object holds its data.  We want to write a send channel that the
-            // other side can use to retrieve that data.
-            if (mSendChannel == null) {
-                mSendChannel = new SendChannel();
-            }
-            out.writeStrongBinder(mSendChannel);
-        } else {
-            // This object doesn't hold its data, so just propagate along its receive channel.
-            out.writeStrongBinder(mReceiveChannel);
-        }
-    }
-
-    public static final Parcelable.Creator<AssistStructure> CREATOR
-            = new Parcelable.Creator<AssistStructure>() {
-        public AssistStructure createFromParcel(Parcel in) {
-            return new AssistStructure(in);
-        }
-
-        public AssistStructure[] newArray(int size) {
-            return new AssistStructure[size];
-        }
-    };
 }
diff --git a/core/java/android/app/IActivityManager.java b/core/java/android/app/IActivityManager.java
index 0a425ae..249cdb2 100644
--- a/core/java/android/app/IActivityManager.java
+++ b/core/java/android/app/IActivityManager.java
@@ -19,6 +19,8 @@
 import android.app.ActivityManager.RunningTaskInfo;
 import android.app.ActivityManager.RunningServiceInfo;
 import android.app.ActivityManager.StackInfo;
+import android.app.assist.AssistContent;
+import android.app.assist.AssistStructure;
 import android.content.ComponentName;
 import android.content.ContentProviderNative;
 import android.content.IContentProvider;
diff --git a/core/java/android/app/AssistContent.aidl b/core/java/android/app/assist/AssistContent.aidl
similarity index 95%
rename from core/java/android/app/AssistContent.aidl
rename to core/java/android/app/assist/AssistContent.aidl
index a6321bf..24379bb 100644
--- a/core/java/android/app/AssistContent.aidl
+++ b/core/java/android/app/assist/AssistContent.aidl
@@ -14,6 +14,6 @@
  * limitations under the License.
  */
 
-package android.app;
+package android.app.assist;
 
 parcelable AssistContent;
diff --git a/core/java/android/app/assist/AssistContent.java b/core/java/android/app/assist/AssistContent.java
new file mode 100644
index 0000000..c7e7330
--- /dev/null
+++ b/core/java/android/app/assist/AssistContent.java
@@ -0,0 +1,44 @@
+package android.app.assist;
+
+import android.content.Intent;
+import android.os.Parcel;
+import android.os.Parcelable;
+
+/**
+ * New home for AssistContent.
+ */
+public final class AssistContent extends android.app.AssistContent implements Parcelable {
+
+    /** @hide */
+    public AssistContent() {
+    }
+
+    public AssistContent(Parcel in) {
+        super(in);
+    }
+
+    public Intent getIntent() {
+        return super.getIntent();
+    }
+
+    @Override
+    public int describeContents() {
+        return 0;
+    }
+
+    @Override
+    public void writeToParcel(Parcel dest, int flags) {
+        writeToParcelInternal(dest, flags);
+    }
+
+    public static final Parcelable.Creator<AssistContent> CREATOR
+            = new Parcelable.Creator<AssistContent>() {
+        public AssistContent createFromParcel(Parcel in) {
+            return new AssistContent(in);
+        }
+
+        public AssistContent[] newArray(int size) {
+            return new AssistContent[size];
+        }
+    };
+}
diff --git a/core/java/android/app/AssistStructure.aidl b/core/java/android/app/assist/AssistStructure.aidl
similarity index 95%
rename from core/java/android/app/AssistStructure.aidl
rename to core/java/android/app/assist/AssistStructure.aidl
index 07fb2453..ae0a34c 100644
--- a/core/java/android/app/AssistStructure.aidl
+++ b/core/java/android/app/assist/AssistStructure.aidl
@@ -14,6 +14,6 @@
  * limitations under the License.
  */
 
-package android.app;
+package android.app.assist;
 
 parcelable AssistStructure;
diff --git a/core/java/android/app/assist/AssistStructure.java b/core/java/android/app/assist/AssistStructure.java
new file mode 100644
index 0000000..1677e95
--- /dev/null
+++ b/core/java/android/app/assist/AssistStructure.java
@@ -0,0 +1,56 @@
+package android.app.assist;
+
+import android.app.Activity;
+import android.os.Parcel;
+import android.os.Parcelable;
+
+/**
+ * New home for AssistStructure.
+ */
+public final class AssistStructure extends android.app.AssistStructure implements Parcelable {
+
+    public AssistStructure() {
+    }
+
+    /** @hide */
+    public AssistStructure(Activity activity) {
+        super(activity);
+    }
+
+    AssistStructure(Parcel in) {
+        super(in);
+    }
+
+    public WindowNode getWindowNodeAt(int index) {
+        return super.getWindowNodeAt(index);
+    }
+
+    public int describeContents() {
+        return 0;
+    }
+
+    public void writeToParcel(Parcel out, int flags) {
+        if (mHaveData) {
+            // This object holds its data.  We want to write a send channel that the
+            // other side can use to retrieve that data.
+            if (mSendChannel == null) {
+                mSendChannel = new SendChannel();
+            }
+            out.writeStrongBinder(mSendChannel);
+        } else {
+            // This object doesn't hold its data, so just propagate along its receive channel.
+            out.writeStrongBinder(mReceiveChannel);
+        }
+    }
+
+    public static final Parcelable.Creator<AssistStructure> CREATOR
+            = new Parcelable.Creator<AssistStructure>() {
+        public AssistStructure createFromParcel(Parcel in) {
+            return new AssistStructure(in);
+        }
+
+        public AssistStructure[] newArray(int size) {
+            return new AssistStructure[size];
+        }
+    };
+}
diff --git a/core/java/android/service/voice/IVoiceInteractionSession.aidl b/core/java/android/service/voice/IVoiceInteractionSession.aidl
index 894edac..8fe84e1 100644
--- a/core/java/android/service/voice/IVoiceInteractionSession.aidl
+++ b/core/java/android/service/voice/IVoiceInteractionSession.aidl
@@ -16,8 +16,8 @@
 
 package android.service.voice;
 
-import android.app.AssistContent;
-import android.app.AssistStructure;
+import android.app.assist.AssistContent;
+import android.app.assist.AssistStructure;
 import android.content.Intent;
 import android.graphics.Bitmap;
 import android.os.Bundle;
diff --git a/core/java/android/service/voice/VoiceInteractionSession.java b/core/java/android/service/voice/VoiceInteractionSession.java
index 48ad5a8..33fef62 100644
--- a/core/java/android/service/voice/VoiceInteractionSession.java
+++ b/core/java/android/service/voice/VoiceInteractionSession.java
@@ -16,11 +16,11 @@
 
 package android.service.voice;
 
-import android.app.AssistContent;
-import android.app.AssistStructure;
 import android.app.Dialog;
 import android.app.Instrumentation;
 import android.app.VoiceInteractor;
+import android.app.assist.AssistContent;
+import android.app.assist.AssistStructure;
 import android.content.ComponentCallbacks2;
 import android.content.Context;
 import android.content.Intent;
@@ -386,7 +386,7 @@
         }
 
         /**
-         * ASk the app to cancel this current request.
+         * ASk the app to cancelLocked this current request.
          */
         public void cancel() {
             try {
@@ -878,14 +878,34 @@
         show(null, 0);
     }
 
-    public void show(Bundle args, int showFlags) {
+    /**
+     * Show the UI for this session.  This asks the system to go through the process of showing
+     * your UI, which will eventually culminate in {@link #onShow}.  This is similar to calling
+     * {@link VoiceInteractionService#showSession VoiceInteractionService.showSession}.
+     * @param args Arbitrary arguments that will be propagated {@link #onShow}.
+     * @param flags Indicates additional optional behavior that should be performed.  May
+     * be {@link VoiceInteractionSession#SHOW_WITH_ASSIST VoiceInteractionSession.SHOW_WITH_ASSIST}
+     * to request that the system generate and deliver assist data on the current foreground
+     * app as part of showing the session UI.
+     */
+    public void show(Bundle args, int flags) {
+        if (mToken == null) {
+            throw new IllegalStateException("Can't call before onCreate()");
+        }
         try {
-            mSystemService.showSessionFromSession(mToken, null, 0);
+            mSystemService.showSessionFromSession(mToken, args, flags);
         } catch (RemoteException e) {
         }
     }
 
+    /**
+     * Hide the session's UI, if currently shown.  Call this when you are done with your
+     * user interaction.
+     */
     public void hide() {
+        if (mToken == null) {
+            throw new IllegalStateException("Can't call before onCreate()");
+        }
         try {
             mSystemService.hideSessionFromSession(mToken);
         } catch (RemoteException e) {
@@ -964,6 +984,9 @@
      * {@link #startVoiceActivity}.</p>
      */
     public void setKeepAwake(boolean keepAwake) {
+        if (mToken == null) {
+            throw new IllegalStateException("Can't call before onCreate()");
+        }
         try {
             mSystemService.setKeepAwake(mToken, keepAwake);
         } catch (RemoteException e) {
@@ -985,7 +1008,9 @@
     }
 
     /**
-     * Finish the session.
+     * Finish the session.  This completely destroys the session -- the next time it is shown,
+     * an entirely new one will be created.  You do not normally call this function; instead,
+     * use {@link #hide} and allow the system to destroy your session if it needs its RAM.
      */
     public void finish() {
         if (mToken == null) {
@@ -1114,7 +1139,7 @@
      * Called when the user presses the back button while focus is in the session UI.  Note
      * that this will only happen if the session UI has requested input focus in its window;
      * otherwise, the back key will go to whatever window has focus and do whatever behavior
-     * it normally has there.
+     * it normally has there.  The default implementation simply calls {@link #hide}.
      */
     public void onBackPressed() {
         hide();
@@ -1123,7 +1148,7 @@
     /**
      * Sessions automatically watch for requests that all system UI be closed (such as when
      * the user presses HOME), which will appear here.  The default implementation always
-     * calls {@link #finish}.
+     * calls {@link #hide}.
      */
     public void onCloseSystemDialogs() {
         hide();
@@ -1287,7 +1312,7 @@
     }
 
     /**
-     * Called when the {@link android.app.VoiceInteractor} has asked to cancel a {@link Request}
+     * Called when the {@link android.app.VoiceInteractor} has asked to cancelLocked a {@link Request}
      * that was previously delivered to {@link #onRequestConfirmation},
      * {@link #onRequestPickOption}, {@link #onRequestCompleteVoice}, {@link #onRequestAbortVoice},
      * or {@link #onRequestCommand}.
diff --git a/core/java/android/view/ViewStructure.java b/core/java/android/view/ViewStructure.java
index 886547a..e525474 100644
--- a/core/java/android/view/ViewStructure.java
+++ b/core/java/android/view/ViewStructure.java
@@ -18,7 +18,6 @@
 
 import android.graphics.Rect;
 import android.os.Bundle;
-import android.text.TextPaint;
 
 /**
  * Container for storing additional per-view data generated by {@link View#onProvideStructure
diff --git a/services/core/java/com/android/server/am/ActivityManagerService.java b/services/core/java/com/android/server/am/ActivityManagerService.java
index 81b8457..64e30e5 100644
--- a/services/core/java/com/android/server/am/ActivityManagerService.java
+++ b/services/core/java/com/android/server/am/ActivityManagerService.java
@@ -39,13 +39,13 @@
 import android.Manifest;
 import android.app.AppOpsManager;
 import android.app.ApplicationThreadNative;
-import android.app.AssistContent;
-import android.app.AssistStructure;
 import android.app.IActivityContainer;
 import android.app.IActivityContainerCallback;
 import android.app.IAppTask;
 import android.app.ITaskStackListener;
 import android.app.ProfilerInfo;
+import android.app.assist.AssistContent;
+import android.app.assist.AssistStructure;
 import android.app.usage.UsageEvents;
 import android.app.usage.UsageStatsManagerInternal;
 import android.appwidget.AppWidgetManager;
diff --git a/services/voiceinteraction/java/com/android/server/voiceinteraction/VoiceInteractionManagerServiceImpl.java b/services/voiceinteraction/java/com/android/server/voiceinteraction/VoiceInteractionManagerServiceImpl.java
index 6de887b..d8569bc 100644
--- a/services/voiceinteraction/java/com/android/server/voiceinteraction/VoiceInteractionManagerServiceImpl.java
+++ b/services/voiceinteraction/java/com/android/server/voiceinteraction/VoiceInteractionManagerServiceImpl.java
@@ -201,7 +201,7 @@
             Slog.w(TAG, "finish does not match active session");
             return;
         }
-        mActiveSession.cancel();
+        mActiveSession.cancelLocked();
         mActiveSession = null;
     }
 
@@ -251,7 +251,7 @@
         // If there is an active session, cancel it to allow it to clean up its window and other
         // state.
         if (mActiveSession != null) {
-            mActiveSession.cancel();
+            mActiveSession.cancelLocked();
             mActiveSession = null;
         }
         try {
diff --git a/services/voiceinteraction/java/com/android/server/voiceinteraction/VoiceInteractionSessionConnection.java b/services/voiceinteraction/java/com/android/server/voiceinteraction/VoiceInteractionSessionConnection.java
index b4629f2..0b430ca0 100644
--- a/services/voiceinteraction/java/com/android/server/voiceinteraction/VoiceInteractionSessionConnection.java
+++ b/services/voiceinteraction/java/com/android/server/voiceinteraction/VoiceInteractionSessionConnection.java
@@ -19,9 +19,9 @@
 import android.app.ActivityManager;
 import android.app.ActivityManagerNative;
 import android.app.AppOpsManager;
-import android.app.AssistContent;
-import android.app.AssistStructure;
 import android.app.IActivityManager;
+import android.app.assist.AssistContent;
+import android.app.assist.AssistStructure;
 import android.content.ClipData;
 import android.content.ComponentName;
 import android.content.ContentProvider;
@@ -376,6 +376,40 @@
         return false;
     }
 
+    public void cancelLocked() {
+        hideLocked();
+        mCanceled = true;
+        if (mBound) {
+            if (mSession != null) {
+                try {
+                    mSession.destroy();
+                } catch (RemoteException e) {
+                    Slog.w(TAG, "Voice interation session already dead");
+                }
+            }
+            if (mSession != null) {
+                try {
+                    mAm.finishVoiceTask(mSession);
+                } catch (RemoteException e) {
+                }
+            }
+            mContext.unbindService(this);
+            try {
+                mIWindowManager.removeWindowToken(mToken);
+            } catch (RemoteException e) {
+                Slog.w(TAG, "Failed removing window token", e);
+            }
+            mBound = false;
+            mService = null;
+            mSession = null;
+            mInteractor = null;
+        }
+        if (mFullyBound) {
+            mContext.unbindService(mFullConnection);
+            mFullyBound = false;
+        }
+    }
+
     public boolean deliverNewSessionLocked(IVoiceInteractionSession session,
             IVoiceInteractor interactor) {
         mSession = session;
@@ -432,39 +466,6 @@
         mService = null;
     }
 
-    public void cancel() {
-        mCanceled = true;
-        if (mBound) {
-            if (mSession != null) {
-                try {
-                    mSession.destroy();
-                } catch (RemoteException e) {
-                    Slog.w(TAG, "Voice interation session already dead");
-                }
-            }
-            if (mSession != null) {
-                try {
-                    mAm.finishVoiceTask(mSession);
-                } catch (RemoteException e) {
-                }
-            }
-            mContext.unbindService(this);
-            try {
-                mIWindowManager.removeWindowToken(mToken);
-            } catch (RemoteException e) {
-                Slog.w(TAG, "Failed removing window token", e);
-            }
-            mBound = false;
-            mService = null;
-            mSession = null;
-            mInteractor = null;
-        }
-        if (mFullyBound) {
-            mContext.unbindService(mFullConnection);
-            mFullyBound = false;
-        }
-    }
-
     private boolean isStructureEnabled() {
         return Settings.Secure.getIntForUser(mContext.getContentResolver(),
                 Settings.Secure.ASSIST_STRUCTURE_ENABLED, 1, mUser) != 0;
diff --git a/tests/VoiceInteraction/src/com/android/test/voiceinteraction/MainInteractionSession.java b/tests/VoiceInteraction/src/com/android/test/voiceinteraction/MainInteractionSession.java
index f66a9ce..dae1ac3 100644
--- a/tests/VoiceInteraction/src/com/android/test/voiceinteraction/MainInteractionSession.java
+++ b/tests/VoiceInteraction/src/com/android/test/voiceinteraction/MainInteractionSession.java
@@ -17,9 +17,9 @@
 package com.android.test.voiceinteraction;
 
 import android.app.ActivityManager;
+import android.app.VoiceInteractor;
 import android.app.AssistContent;
 import android.app.AssistStructure;
-import android.app.VoiceInteractor;
 import android.content.Context;
 import android.content.Intent;
 import android.graphics.Bitmap;
@@ -71,7 +71,7 @@
     public void onCreate(Bundle args, int startFlags) {
         super.onCreate(args, startFlags);
         ActivityManager am = getContext().getSystemService(ActivityManager.class);
-        am.setWatchHeapLimit(40*1024*1024);
+        am.setWatchHeapLimit(40 * 1024 * 1024);
     }
 
     @Override
@@ -118,6 +118,30 @@
         return mContentView;
     }
 
+    public void onHandleAssist(Bundle assistBundle) {
+        if (assistBundle != null) {
+            Bundle assistContext = assistBundle.getBundle(Intent.EXTRA_ASSIST_CONTEXT);
+            if (assistContext != null) {
+                mAssistStructure = AssistStructure.getAssistStructure(assistContext);
+                if (mAssistStructure != null) {
+                    if (mAssistVisualizer != null) {
+                        mAssistVisualizer.setAssistStructure(mAssistStructure);
+                    }
+                }
+                AssistContent content = AssistContent.getAssistContent(assistContext);
+                if (content != null) {
+                    Log.i(TAG, "Assist intent: " + content.getIntent());
+                    Log.i(TAG, "Assist clipdata: " + content.getClipData());
+                }
+                return;
+            }
+        }
+        if (mAssistVisualizer != null) {
+            mAssistVisualizer.clearAssistData();
+        }
+    }
+
+    /*
     @Override
     public void onHandleAssist(Bundle data, AssistStructure structure, AssistContent content) {
         mAssistStructure = structure;
@@ -131,6 +155,7 @@
             Log.i(TAG, "Assist clipdata: " + content.getClipData());
         }
     }
+    */
 
     @Override
     public void onHandleScreenshot(Bitmap screenshot) {