From 0134fd8139611964cb8f58198c7b7a923d62161d Mon Sep 17 00:00:00 2001 From: Barnaby James Date: Sat, 9 Aug 2014 14:10:14 -0700 Subject: [PATCH] Make Test Voice Interactor support new requirements. Add settings activity and stub RecognizerService to voice interactor test. Change-Id: I3c3dda7d2c30eac5e0b889c0c7305dc8f4dfbcb9 --- tests/VoiceInteraction/AndroidManifest.xml | 18 ++++++ .../VoiceInteraction/res/layout/settings.xml | 20 +++++++ .../res/xml/interaction_service.xml | 4 +- .../res/xml/recognition_service.xml | 21 +++++++ .../MainRecognitionService.java | 56 +++++++++++++++++++ .../voiceinteraction/SettingsActivity.java | 31 ++++++++++ 6 files changed, 149 insertions(+), 1 deletion(-) create mode 100644 tests/VoiceInteraction/res/layout/settings.xml create mode 100644 tests/VoiceInteraction/res/xml/recognition_service.xml create mode 100644 tests/VoiceInteraction/src/com/android/test/voiceinteraction/MainRecognitionService.java create mode 100644 tests/VoiceInteraction/src/com/android/test/voiceinteraction/SettingsActivity.java diff --git a/tests/VoiceInteraction/AndroidManifest.xml b/tests/VoiceInteraction/AndroidManifest.xml index c328b3ce1fe9c..06d31a4e2061b 100644 --- a/tests/VoiceInteraction/AndroidManifest.xml +++ b/tests/VoiceInteraction/AndroidManifest.xml @@ -12,7 +12,17 @@ + + + + + + + + + + + + + diff --git a/tests/VoiceInteraction/res/layout/settings.xml b/tests/VoiceInteraction/res/layout/settings.xml new file mode 100644 index 0000000000000..e123449a59bea --- /dev/null +++ b/tests/VoiceInteraction/res/layout/settings.xml @@ -0,0 +1,20 @@ + + + diff --git a/tests/VoiceInteraction/res/xml/interaction_service.xml b/tests/VoiceInteraction/res/xml/interaction_service.xml index 45bd994da55d3..ce5669cab1ea7 100644 --- a/tests/VoiceInteraction/res/xml/interaction_service.xml +++ b/tests/VoiceInteraction/res/xml/interaction_service.xml @@ -18,4 +18,6 @@ --> + android:sessionService="com.android.test.voiceinteraction.MainInteractionSessionService" + android:recognitionService="com.android.test.voiceinteraction.MainRecognitionService" + android:settingsActivity="com.android.test.voiceinteraction.SettingsActivity" /> diff --git a/tests/VoiceInteraction/res/xml/recognition_service.xml b/tests/VoiceInteraction/res/xml/recognition_service.xml new file mode 100644 index 0000000000000..b720fc4efb3f3 --- /dev/null +++ b/tests/VoiceInteraction/res/xml/recognition_service.xml @@ -0,0 +1,21 @@ + + + + diff --git a/tests/VoiceInteraction/src/com/android/test/voiceinteraction/MainRecognitionService.java b/tests/VoiceInteraction/src/com/android/test/voiceinteraction/MainRecognitionService.java new file mode 100644 index 0000000000000..c716e7a42cfdf --- /dev/null +++ b/tests/VoiceInteraction/src/com/android/test/voiceinteraction/MainRecognitionService.java @@ -0,0 +1,56 @@ +/* + * Copyright (C) 2014 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.test.voiceinteraction; + +import android.content.Intent; +import android.speech.RecognitionService; +import android.util.Log; + +/** + * Stub recognition service needed to be a complete voice interactor. + */ +public class MainRecognitionService extends RecognitionService { + + private static final String TAG = "MainRecognitionService"; + + @Override + public void onCreate() { + super.onCreate(); + Log.i(TAG, "onCreate"); + } + + @Override + protected void onStartListening(Intent recognizerIntent, Callback listener) { + Log.d(TAG, "onStartListening"); + } + + @Override + protected void onCancel(Callback listener) { + Log.d(TAG, "onCancel"); + } + + @Override + protected void onStopListening(Callback listener) { + Log.d(TAG, "onStopListening"); + } + + @Override + public void onDestroy() { + super.onDestroy(); + Log.d(TAG, "onDestroy"); + } +} diff --git a/tests/VoiceInteraction/src/com/android/test/voiceinteraction/SettingsActivity.java b/tests/VoiceInteraction/src/com/android/test/voiceinteraction/SettingsActivity.java new file mode 100644 index 0000000000000..8b346ff3f52de --- /dev/null +++ b/tests/VoiceInteraction/src/com/android/test/voiceinteraction/SettingsActivity.java @@ -0,0 +1,31 @@ +/* + * Copyright (C) 2014 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.test.voiceinteraction; + +import android.app.Activity; +import android.os.Bundle; + +/** + * Stub activity to test out settings selection for voice interactor. + */ +public class SettingsActivity extends Activity { + @Override + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.settings); + } +}