From d0a159025a06a7400ab3dfca1d754494947092e0 Mon Sep 17 00:00:00 2001 From: Dianne Hackborn Date: Wed, 15 Jul 2015 11:18:09 -0700 Subject: [PATCH] Fix issue #22124996: VI: Command Request not Active This stupid thing wasn't even completely implemented in HandlerCaller! D'oh! Change-Id: I0dac42c208fa0f08a6e20a6cb17b072f51efcaa7 --- .../android/service/voice/VoiceInteractionSession.java | 7 ++++++- core/java/com/android/internal/os/SomeArgs.java | 10 ++++++++++ .../test/voiceinteraction/TestInteractionActivity.java | 8 ++++++++ 3 files changed, 24 insertions(+), 1 deletion(-) diff --git a/core/java/android/service/voice/VoiceInteractionSession.java b/core/java/android/service/voice/VoiceInteractionSession.java index e408b36ea5231..5b87440d72764 100644 --- a/core/java/android/service/voice/VoiceInteractionSession.java +++ b/core/java/android/service/voice/VoiceInteractionSession.java @@ -650,7 +650,7 @@ public class VoiceInteractionSession implements KeyEvent.Callback, ComponentCall class MyCallbacks implements HandlerCaller.Callback, SoftInputWindow.Callback { @Override public void executeMessage(Message msg) { - SomeArgs args; + SomeArgs args = null; switch (msg.what) { case MSG_START_CONFIRMATION: if (DEBUG) Log.d(TAG, "onConfirm: req=" + msg.obj); @@ -676,6 +676,8 @@ public class VoiceInteractionSession implements KeyEvent.Callback, ComponentCall args = (SomeArgs)msg.obj; if (DEBUG) Log.d(TAG, "onGetSupportedCommands: cmds=" + args.arg1); args.arg1 = onGetSupportedCommands((String[]) args.arg1); + args.complete(); + args = null; break; case MSG_CANCEL: if (DEBUG) Log.d(TAG, "onCancel: req=" + ((Request)msg.obj)); @@ -723,6 +725,9 @@ public class VoiceInteractionSession implements KeyEvent.Callback, ComponentCall doHide(); break; } + if (args != null) { + args.recycle(); + } } @Override diff --git a/core/java/com/android/internal/os/SomeArgs.java b/core/java/com/android/internal/os/SomeArgs.java index b0d24fd311e5c..c05e0d8f1256a 100644 --- a/core/java/com/android/internal/os/SomeArgs.java +++ b/core/java/com/android/internal/os/SomeArgs.java @@ -73,6 +73,16 @@ public final class SomeArgs { } } + public void complete() { + synchronized (this) { + if (mWaitState != WAIT_WAITING) { + throw new IllegalStateException("Not waiting"); + } + mWaitState = WAIT_FINISHED; + notifyAll(); + } + } + public void recycle() { if (mInPool) { throw new IllegalStateException("Already recycled."); diff --git a/tests/VoiceInteraction/src/com/android/test/voiceinteraction/TestInteractionActivity.java b/tests/VoiceInteraction/src/com/android/test/voiceinteraction/TestInteractionActivity.java index 2487e1ca94664..b0d6b399eaaac 100644 --- a/tests/VoiceInteraction/src/com/android/test/voiceinteraction/TestInteractionActivity.java +++ b/tests/VoiceInteraction/src/com/android/test/voiceinteraction/TestInteractionActivity.java @@ -103,6 +103,14 @@ public class TestInteractionActivity extends Activity implements View.OnClickLis } }; mInteractor.submitRequest(mCurrentRequest, REQUEST_CONFIRM); + String[] cmds = new String[] { + "com.android.test.voiceinteraction.COMMAND", + "com.example.foo.bar" + }; + boolean sup[] = mInteractor.supportsCommands(cmds); + for (int i=0; i