summaryrefslogtreecommitdiffstats
path: root/tests/VoiceInteraction
diff options
context:
space:
mode:
authorDianne Hackborn <hackbod@google.com>2015-03-11 15:16:13 -0700
committerDianne Hackborn <hackbod@google.com>2015-03-12 17:07:51 -0700
commita83ce1dd2ad3a6b71e90ff4845afc1299fe17b9d (patch)
tree2b0f1d1e65920fdbf7e3b7867070ee32776f246e /tests/VoiceInteraction
parentd6ee06a0c86d9d1556bb4b15c9aaea538e415e38 (diff)
downloadframeworks_base-a83ce1dd2ad3a6b71e90ff4845afc1299fe17b9d.zip
frameworks_base-a83ce1dd2ad3a6b71e90ff4845afc1299fe17b9d.tar.gz
frameworks_base-a83ce1dd2ad3a6b71e90ff4845afc1299fe17b9d.tar.bz2
More work on collecting assist data.
Optimize parceling of AssistData (which is now renamed to AssistStructure) by pooling duplicated class name strings. Change text associated with a view node to a CharSequence, so styling information comes along. Include global text attributes -- size, colors, etc. Introduce a new AssistContent structure, which allows us to propagate information about the intent and data the activity is looking at. This further allows us to propagate permission grants, so the assistant can dig in to that data. The default implementation propagates the base intent of an activity, so if for example you bring up the assistant while doing a share the assistant itself has the same information and access that was given to the share activity (so it could for example share it in another way if it wanted to). Did some optimization of loading PersistableBundle from xml, to avoid duplicating hash maps and such. Changed how we dispatch ACTION_ASSIST to no longer include the more detailed AssistStructure (and new AssistContent) data when launching; now the example code that intercepts that needs to be sure to ask for assist data when it starts its session. This is more like it will finally be, and allows us to get to the UI more quickly. Change-Id: I88420a55761bf48d34ce3013e81bd96a0e087637
Diffstat (limited to 'tests/VoiceInteraction')
-rw-r--r--tests/VoiceInteraction/src/com/android/test/voiceinteraction/AssistProxyActivity.java1
-rw-r--r--tests/VoiceInteraction/src/com/android/test/voiceinteraction/AssistVisualizer.java20
-rw-r--r--tests/VoiceInteraction/src/com/android/test/voiceinteraction/MainInteractionService.java7
-rw-r--r--tests/VoiceInteraction/src/com/android/test/voiceinteraction/MainInteractionSession.java29
4 files changed, 30 insertions, 27 deletions
diff --git a/tests/VoiceInteraction/src/com/android/test/voiceinteraction/AssistProxyActivity.java b/tests/VoiceInteraction/src/com/android/test/voiceinteraction/AssistProxyActivity.java
index 6a99351..d0c5e36 100644
--- a/tests/VoiceInteraction/src/com/android/test/voiceinteraction/AssistProxyActivity.java
+++ b/tests/VoiceInteraction/src/com/android/test/voiceinteraction/AssistProxyActivity.java
@@ -28,7 +28,6 @@ public class AssistProxyActivity extends Activity {
finish();
Intent intent = new Intent(this, MainInteractionService.class);
intent.setAction(Intent.ACTION_ASSIST);
- intent.putExtras(getIntent());
startService(intent);
}
}
diff --git a/tests/VoiceInteraction/src/com/android/test/voiceinteraction/AssistVisualizer.java b/tests/VoiceInteraction/src/com/android/test/voiceinteraction/AssistVisualizer.java
index d35bc5c..bae19a6 100644
--- a/tests/VoiceInteraction/src/com/android/test/voiceinteraction/AssistVisualizer.java
+++ b/tests/VoiceInteraction/src/com/android/test/voiceinteraction/AssistVisualizer.java
@@ -17,7 +17,7 @@
package com.android.test.voiceinteraction;
import android.annotation.Nullable;
-import android.app.AssistData;
+import android.app.AssistStructure;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Paint;
@@ -31,7 +31,7 @@ import java.util.ArrayList;
public class AssistVisualizer extends View {
static final String TAG = "AssistVisualizer";
- AssistData mAssistData;
+ AssistStructure mAssistStructure;
final Paint mFramePaint = new Paint();
final ArrayList<Rect> mTextRects = new ArrayList<>();
final int[] mTmpLocation = new int[2];
@@ -44,25 +44,25 @@ public class AssistVisualizer extends View {
mFramePaint.setStrokeWidth(0);
}
- public void setAssistData(AssistData ad) {
- mAssistData = ad;
+ public void setAssistStructure(AssistStructure as) {
+ mAssistStructure = as;
mTextRects.clear();
- final int N = ad.getWindowCount();
+ final int N = as.getWindowCount();
if (N > 0) {
- AssistData.ViewNode window = new AssistData.ViewNode();
+ AssistStructure.ViewNode window = new AssistStructure.ViewNode();
for (int i=0; i<N; i++) {
- ad.getWindowAt(i, window);
+ as.getWindowAt(i, window);
buildTextRects(window, 0, 0);
}
}
}
public void clearAssistData() {
- mAssistData = null;
+ mAssistStructure = null;
mTextRects.clear();
}
- void buildTextRects(AssistData.ViewNode root, int parentLeft, int parentTop) {
+ void buildTextRects(AssistStructure.ViewNode root, int parentLeft, int parentTop) {
if (root.getVisibility() != View.VISIBLE) {
return;
}
@@ -78,7 +78,7 @@ public class AssistVisualizer extends View {
if (N > 0) {
left -= root.getScrollX();
top -= root.getScrollY();
- AssistData.ViewNode child = new AssistData.ViewNode();
+ AssistStructure.ViewNode child = new AssistStructure.ViewNode();
for (int i=0; i<N; i++) {
root.getChildAt(i, child);
buildTextRects(child, left, top);
diff --git a/tests/VoiceInteraction/src/com/android/test/voiceinteraction/MainInteractionService.java b/tests/VoiceInteraction/src/com/android/test/voiceinteraction/MainInteractionService.java
index 2cab3ea..722b0de 100644
--- a/tests/VoiceInteraction/src/com/android/test/voiceinteraction/MainInteractionService.java
+++ b/tests/VoiceInteraction/src/com/android/test/voiceinteraction/MainInteractionService.java
@@ -79,12 +79,7 @@ public class MainInteractionService extends VoiceInteractionService {
Bundle args = new Bundle();
args.putParcelable("intent", new Intent(this, TestInteractionActivity.class));
args.putBundle("assist", intent.getExtras());
- Bundle assistContext = intent.getBundleExtra(Intent.EXTRA_ASSIST_CONTEXT);
- int startFlags = 0;
- if (assistContext == null) {
- startFlags |= START_WITH_ASSIST;
- }
- startSession(args, startFlags);
+ startSession(args, START_WITH_ASSIST);
} else {
Log.w(TAG, "Not starting -- not current voice interaction service");
}
diff --git a/tests/VoiceInteraction/src/com/android/test/voiceinteraction/MainInteractionSession.java b/tests/VoiceInteraction/src/com/android/test/voiceinteraction/MainInteractionSession.java
index 1e30aff..bcfc6f4 100644
--- a/tests/VoiceInteraction/src/com/android/test/voiceinteraction/MainInteractionSession.java
+++ b/tests/VoiceInteraction/src/com/android/test/voiceinteraction/MainInteractionSession.java
@@ -16,7 +16,8 @@
package com.android.test.voiceinteraction;
-import android.app.AssistData;
+import android.app.AssistContent;
+import android.app.AssistStructure;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
@@ -41,7 +42,7 @@ public class MainInteractionSession extends VoiceInteractionSession
Button mCompleteButton;
Button mAbortButton;
- AssistData mAssistData;
+ AssistStructure mAssistStructure;
static final int STATE_IDLE = 0;
static final int STATE_LAUNCHING = 1;
@@ -68,8 +69,9 @@ public class MainInteractionSession extends VoiceInteractionSession
super.onShow(args, showFlags);
mState = STATE_IDLE;
mStartIntent = args.getParcelable("intent");
- Bundle assist = args.getBundle("assist");
- parseAssistData(assist);
+ if (mAssistVisualizer != null) {
+ mAssistVisualizer.clearAssistData();
+ }
updateState();
}
@@ -87,8 +89,8 @@ public class MainInteractionSession extends VoiceInteractionSession
public View onCreateContentView() {
mContentView = getLayoutInflater().inflate(R.layout.voice_interaction_session, null);
mAssistVisualizer = (AssistVisualizer)mContentView.findViewById(R.id.assist_visualizer);
- if (mAssistData != null) {
- mAssistVisualizer.setAssistData(mAssistData);
+ if (mAssistStructure != null) {
+ mAssistVisualizer.setAssistStructure(mAssistStructure);
}
mTopContent = mContentView.findViewById(R.id.top_content);
mBottomContent = mContentView.findViewById(R.id.bottom_content);
@@ -117,10 +119,17 @@ public class MainInteractionSession extends VoiceInteractionSession
if (assistBundle != null) {
Bundle assistContext = assistBundle.getBundle(Intent.EXTRA_ASSIST_CONTEXT);
if (assistContext != null) {
- mAssistData = AssistData.getAssistData(assistContext);
- mAssistData.dump();
- if (mAssistVisualizer != null) {
- mAssistVisualizer.setAssistData(mAssistData);
+ mAssistStructure = AssistStructure.getAssistStructure(assistContext);
+ if (mAssistStructure != null) {
+ mAssistStructure.dump();
+ 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;
}