diff options
author | Dianne Hackborn <hackbod@google.com> | 2015-06-30 14:38:17 -0700 |
---|---|---|
committer | Dianne Hackborn <hackbod@google.com> | 2015-06-30 16:59:41 -0700 |
commit | 593334ab70a8341c7d24d71a377ab5617e3f4ab7 (patch) | |
tree | 7005af1c583f459a8ce7a02a30f65502258ba015 /tests/VoiceInteraction/src/com/android/test/voiceinteraction/TestInteractionActivity.java | |
parent | 1aaad610dfc7445ec29fd906974677515c3a9f87 (diff) | |
download | frameworks_base-593334ab70a8341c7d24d71a377ab5617e3f4ab7.zip frameworks_base-593334ab70a8341c7d24d71a377ab5617e3f4ab7.tar.gz frameworks_base-593334ab70a8341c7d24d71a377ab5617e3f4ab7.tar.bz2 |
Fix issue #22124996: VI: Command Request not Active
Just forgot to add the request to the active set.
Also eradicate a bunch of old cruft that has been replaced
by the final APIs, and improve voice interaction test to
sit fully on top of the final APIs and have a test for
command request.
Change-Id: Ieff7a6165ebf2a4c5fb80c1ebd020511a2ae63ee
Diffstat (limited to 'tests/VoiceInteraction/src/com/android/test/voiceinteraction/TestInteractionActivity.java')
-rw-r--r-- | tests/VoiceInteraction/src/com/android/test/voiceinteraction/TestInteractionActivity.java | 42 |
1 files changed, 39 insertions, 3 deletions
diff --git a/tests/VoiceInteraction/src/com/android/test/voiceinteraction/TestInteractionActivity.java b/tests/VoiceInteraction/src/com/android/test/voiceinteraction/TestInteractionActivity.java index 943c647..2487e1ca 100644 --- a/tests/VoiceInteraction/src/com/android/test/voiceinteraction/TestInteractionActivity.java +++ b/tests/VoiceInteraction/src/com/android/test/voiceinteraction/TestInteractionActivity.java @@ -33,6 +33,7 @@ public class TestInteractionActivity extends Activity implements View.OnClickLis static final String REQUEST_ABORT = "abort"; static final String REQUEST_COMPLETE = "complete"; + static final String REQUEST_COMMAND = "command"; static final String REQUEST_PICK = "pick"; static final String REQUEST_CONFIRM = "confirm"; @@ -41,6 +42,7 @@ public class TestInteractionActivity extends Activity implements View.OnClickLis TextView mLog; Button mAbortButton; Button mCompleteButton; + Button mCommandButton; Button mPickButton; Button mJumpOutButton; Button mCancelButton; @@ -68,6 +70,8 @@ public class TestInteractionActivity extends Activity implements View.OnClickLis mAbortButton.setOnClickListener(this); mCompleteButton = (Button)findViewById(R.id.complete); mCompleteButton.setOnClickListener(this); + mCommandButton = (Button)findViewById(R.id.command); + mCommandButton.setOnClickListener(this); mPickButton = (Button)findViewById(R.id.pick); mPickButton.setOnClickListener(this); mJumpOutButton = (Button)findViewById(R.id.jump); @@ -117,6 +121,9 @@ public class TestInteractionActivity extends Activity implements View.OnClickLis } else if (v == mCompleteButton) { VoiceInteractor.CompleteVoiceRequest req = new TestCompleteVoice(); mInteractor.submitRequest(req, REQUEST_COMPLETE); + } else if (v == mCommandButton) { + VoiceInteractor.CommandRequest req = new TestCommand("Some arg"); + mInteractor.submitRequest(req, REQUEST_COMMAND); } else if (v == mPickButton) { VoiceInteractor.PickOptionRequest.Option[] options = new VoiceInteractor.PickOptionRequest.Option[5]; @@ -176,6 +183,37 @@ public class TestInteractionActivity extends Activity implements View.OnClickLis } } + static class TestCommand extends VoiceInteractor.CommandRequest { + public TestCommand(String arg) { + super("com.android.test.voiceinteraction.COMMAND", makeBundle(arg)); + } + @Override public void onCancel() { + Log.i(TAG, "Canceled!"); + ((TestInteractionActivity)getActivity()).mLog.append("Canceled command\n"); + } + @Override + public void onCommandResult(boolean finished, Bundle result) { + Log.i(TAG, "Command result: finished=" + finished + " result=" + result); + StringBuilder sb = new StringBuilder(); + if (finished) { + sb.append("Command final result: "); + } else { + sb.append("Command intermediate result: "); + } + if (result != null) { + result.getString("key"); + } + sb.append(result); + sb.append("\n"); + ((TestInteractionActivity)getActivity()).mLog.append(sb.toString()); + } + static Bundle makeBundle(String arg) { + Bundle b = new Bundle(); + b.putString("key", arg); + return b; + } + } + static class TestPickOption extends VoiceInteractor.PickOptionRequest { public TestPickOption(Option[] options) { super(new VoiceInteractor.Prompt("Need to pick something"), options, null); @@ -200,10 +238,8 @@ public class TestInteractionActivity extends Activity implements View.OnClickLis } sb.append(selections[i].getLabel()); } + sb.append("\n"); ((TestInteractionActivity)getActivity()).mLog.append(sb.toString()); - if (finished) { - getActivity().finish(); - } } } } |