summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDianne Hackborn <hackbod@google.com>2015-06-02 10:52:59 -0700
committerDianne Hackborn <hackbod@google.com>2015-06-02 16:56:41 -0700
commit69c6adc96eecfde74ceb83cf9177428dc08b6067 (patch)
tree1c9fb3e63573cf0133ad3680d3cc8a048b0874c0
parent133b107d28649ef5a984be0acc06f53e49853b22 (diff)
downloadframeworks_base-69c6adc96eecfde74ceb83cf9177428dc08b6067.zip
frameworks_base-69c6adc96eecfde74ceb83cf9177428dc08b6067.tar.gz
frameworks_base-69c6adc96eecfde74ceb83cf9177428dc08b6067.tar.bz2
More API changes.
Start moving Assist* stuff to android.app.assist. Clean up some more of the VoiceInteractionSession APIs. Clearly document that finish() is not the same as hide(), always call hide() instead, and fix the finish() path to also always do a hide to make sure everything is cleaned up correctly. Change-Id: I962d4069fcb34fe89547a95d395ae1b9fa3b4148
-rw-r--r--Android.mk4
-rw-r--r--api/current.txt37
-rw-r--r--api/system-current.txt37
-rw-r--r--core/java/android/app/Activity.java1
-rw-r--r--core/java/android/app/ActivityManagerNative.java2
-rw-r--r--core/java/android/app/ActivityThread.java2
-rw-r--r--core/java/android/app/AssistContent.java36
-rw-r--r--core/java/android/app/AssistStructure.java63
-rw-r--r--core/java/android/app/IActivityManager.java2
-rw-r--r--core/java/android/app/assist/AssistContent.aidl (renamed from core/java/android/app/AssistContent.aidl)2
-rw-r--r--core/java/android/app/assist/AssistContent.java44
-rw-r--r--core/java/android/app/assist/AssistStructure.aidl (renamed from core/java/android/app/AssistStructure.aidl)2
-rw-r--r--core/java/android/app/assist/AssistStructure.java56
-rw-r--r--core/java/android/service/voice/IVoiceInteractionSession.aidl4
-rw-r--r--core/java/android/service/voice/VoiceInteractionSession.java43
-rw-r--r--core/java/android/view/ViewStructure.java1
-rw-r--r--services/core/java/com/android/server/am/ActivityManagerService.java4
-rw-r--r--services/voiceinteraction/java/com/android/server/voiceinteraction/VoiceInteractionManagerServiceImpl.java4
-rw-r--r--services/voiceinteraction/java/com/android/server/voiceinteraction/VoiceInteractionSessionConnection.java71
-rw-r--r--tests/VoiceInteraction/src/com/android/test/voiceinteraction/MainInteractionSession.java29
20 files changed, 296 insertions, 148 deletions
diff --git a/Android.mk b/Android.mk
index d6dac53..4d8a37c 100644
--- a/Android.mk
+++ b/Android.mk
@@ -555,8 +555,6 @@ aidl_files := \
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 @@ aidl_files := \
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 28c344e..54d6138 100644
--- a/api/current.txt
+++ b/api/current.txt
@@ -3444,7 +3444,7 @@ package android.app {
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();
@@ -3994,26 +3994,19 @@ package android.app {
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 {
@@ -5896,6 +5889,26 @@ package android.app.admin {
}
+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 {
@@ -28908,7 +28921,7 @@ package android.service.voice {
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 5218595..661e64a 100644
--- a/api/system-current.txt
+++ b/api/system-current.txt
@@ -3529,7 +3529,7 @@ package android.app {
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();
@@ -4089,26 +4089,19 @@ package android.app {
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 {
@@ -6010,6 +6003,26 @@ package android.app.admin {
}
+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 {
@@ -31034,7 +31047,7 @@ package android.service.voice {
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 49f5099..87de498 100644
--- a/core/java/android/app/Activity.java
+++ b/core/java/android/app/Activity.java
@@ -38,6 +38,7 @@ import com.android.internal.app.ToolbarActionBar;
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 @@ import android.os.Parcelable;
/**
* 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 @@ public class AssistContent implements Parcelable {
/**
* @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 @@ public class AssistContent implements Parcelable {
/**
* Return the current {@link #setIntent}, which you can modify in-place.
+ * @hide
*/
public Intent getIntent() {
return mIntent;
@@ -116,7 +119,8 @@ public class AssistContent implements Parcelable {
return mUri;
}
- AssistContent(Parcel in) {
+ /** @hide */
+ public AssistContent(Parcel in) {
if (in.readInt() != 0) {
mIntent = Intent.CREATOR.createFromParcel(in);
}
@@ -128,13 +132,8 @@ public class AssistContent implements Parcelable {
}
}
- @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 @@ public class AssistContent implements Parcelable {
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.PooledStringReader;
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 @@ import java.util.ArrayList;
/**
* 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 public class AssistStructure implements Parcelable {
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 @@ final public class AssistStructure implements Parcelable {
}
}
- AssistStructure(Activity activity) {
+ /** @hide */
+ public AssistStructure(Activity activity) {
mHaveData = true;
mActivityComponent = activity.getComponentName();
ArrayList<ViewRootImpl> views = WindowManagerGlobal.getInstance().getRootViews(
@@ -713,12 +717,13 @@ final public class AssistStructure implements Parcelable {
}
}
- AssistStructure() {
+ public AssistStructure() {
mHaveData = true;
mActivityComponent = null;
}
- AssistStructure(Parcel in) {
+ /** @hide */
+ public AssistStructure(Parcel in) {
mReceiveChannel = in.readStrongBinder();
}
@@ -792,7 +797,7 @@ final public class AssistStructure implements Parcelable {
* 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 @@ final public class AssistStructure implements Parcelable {
/**
* 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 @@ final public class AssistStructure implements Parcelable {
}
//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 @@ package android.app;
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
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
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 @@ public class VoiceInteractionSession implements KeyEvent.Callback, ComponentCall
}
/**
- * ASk the app to cancel this current request.
+ * ASk the app to cancelLocked this current request.
*/
public void cancel() {
try {
@@ -878,14 +878,34 @@ public class VoiceInteractionSession implements KeyEvent.Callback, ComponentCall
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 @@ public class VoiceInteractionSession implements KeyEvent.Callback, ComponentCall
* {@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 @@ public class VoiceInteractionSession implements KeyEvent.Callback, ComponentCall
}
/**
- * 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 @@ public class VoiceInteractionSession implements KeyEvent.Callback, ComponentCall
* 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 @@ public class VoiceInteractionSession implements KeyEvent.Callback, ComponentCall
/**
* 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 @@ public class VoiceInteractionSession implements KeyEvent.Callback, ComponentCall
}
/**
- * 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 @@ package android.view;
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 static org.xmlpull.v1.XmlPullParser.START_TAG;
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 @@ class VoiceInteractionManagerServiceImpl implements VoiceInteractionSessionConne
Slog.w(TAG, "finish does not match active session");
return;
}
- mActiveSession.cancel();
+ mActiveSession.cancelLocked();
mActiveSession = null;
}
@@ -251,7 +251,7 @@ class VoiceInteractionManagerServiceImpl implements VoiceInteractionSessionConne
// 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..0b430ca 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 @@ package com.android.server.voiceinteraction;
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 @@ final class VoiceInteractionSessionConnection implements ServiceConnection {
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 @@ final class VoiceInteractionSessionConnection implements ServiceConnection {
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 class MainInteractionSession extends VoiceInteractionSession
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 @@ public class MainInteractionSession extends VoiceInteractionSession
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 @@ public class MainInteractionSession extends VoiceInteractionSession
Log.i(TAG, "Assist clipdata: " + content.getClipData());
}
}
+ */
@Override
public void onHandleScreenshot(Bitmap screenshot) {