summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--services/voiceinteraction/java/com/android/server/soundtrigger/SoundTriggerHelper.java18
-rw-r--r--tests/SoundTriggerTestApp/res/layout/main.xml19
-rw-r--r--tests/SoundTriggerTestApp/res/values/strings.xml2
-rw-r--r--tests/SoundTriggerTestApp/src/com/android/test/soundtrigger/TestSoundTriggerActivity.java15
4 files changed, 39 insertions, 15 deletions
diff --git a/services/voiceinteraction/java/com/android/server/soundtrigger/SoundTriggerHelper.java b/services/voiceinteraction/java/com/android/server/soundtrigger/SoundTriggerHelper.java
index cde47bd0666a..b4c4bf8b5ef3 100644
--- a/services/voiceinteraction/java/com/android/server/soundtrigger/SoundTriggerHelper.java
+++ b/services/voiceinteraction/java/com/android/server/soundtrigger/SoundTriggerHelper.java
@@ -198,6 +198,7 @@ public class SoundTriggerHelper implements SoundTrigger.StatusListener {
return STATUS_ERROR;
}
modelData.setHandle(handle[0]);
+ modelData.setLoaded();
}
modelData.setCallback(callback);
modelData.setRecognitionConfig(recognitionConfig);
@@ -346,7 +347,7 @@ public class SoundTriggerHelper implements SoundTrigger.StatusListener {
return STATUS_ERROR;
}
- if (currentCallback == null || !modelData.modelStarted()) {
+ if (currentCallback == null || !modelData.isModelStarted()) {
// startRecognition hasn't been called or it failed.
Slog.w(TAG, "Attempting stopRecognition without a successful startRecognition");
return STATUS_ERROR;
@@ -451,7 +452,7 @@ public class SoundTriggerHelper implements SoundTrigger.StatusListener {
// Stop all generic recognition models.
for (ModelData model : mGenericModelDataMap.values()) {
- if (model.modelStarted()) {
+ if (model.isModelStarted()) {
int status = stopGenericRecognitionLocked(model,
false /* do not notify for synchronous calls */);
if (status != STATUS_OK) {
@@ -970,7 +971,7 @@ public class SoundTriggerHelper implements SoundTrigger.StatusListener {
}
for (UUID modelId : mGenericModelDataMap.keySet()) {
ModelData modelData = mGenericModelDataMap.get(modelId);
- if (modelData.modelStarted()) {
+ if (modelData.isModelStarted()) {
mRecognitionRunning = true;
return mRecognitionRunning;
}
@@ -1001,7 +1002,6 @@ public class SoundTriggerHelper implements SoundTrigger.StatusListener {
// to SoundModel.TYPE_UNKNOWN;
private int mModelType = SoundModel.TYPE_UNKNOWN;
private IRecognitionStatusCallback mCallback = null;
- private SoundModel mSoundModel = null;
private RecognitionConfig mRecognitionConfig = null;
@@ -1026,8 +1026,7 @@ public class SoundTriggerHelper implements SoundTrigger.StatusListener {
}
synchronized boolean isModelLoaded() {
- return (mModelState == MODEL_LOADED || mModelState == MODEL_STARTED) &&
- mSoundModel != null;
+ return (mModelState == MODEL_LOADED || mModelState == MODEL_STARTED);
}
synchronized void setStarted() {
@@ -1038,13 +1037,16 @@ public class SoundTriggerHelper implements SoundTrigger.StatusListener {
mModelState = MODEL_LOADED;
}
- synchronized boolean modelStarted() {
+ synchronized void setLoaded() {
+ mModelState = MODEL_LOADED;
+ }
+
+ synchronized boolean isModelStarted() {
return mModelState == MODEL_STARTED;
}
synchronized void clearState() {
mModelState = MODEL_NOTLOADED;
- mSoundModel = null;
mModelHandle = INVALID_VALUE;
}
diff --git a/tests/SoundTriggerTestApp/res/layout/main.xml b/tests/SoundTriggerTestApp/res/layout/main.xml
index 5ecc7705cd75..702be49aac7b 100644
--- a/tests/SoundTriggerTestApp/res/layout/main.xml
+++ b/tests/SoundTriggerTestApp/res/layout/main.xml
@@ -66,6 +66,7 @@
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:padding="20dp"
+ android:checkedButton="@+id/model_one"
android:orientation="vertical">
<RadioButton android:id="@+id/model_one"
android:layout_width="wrap_content"
@@ -84,15 +85,21 @@
android:onClick="onRadioButtonClicked"/>
</RadioGroup>
- <TextView
- android:id="@+id/console"
- android:gravity="left"
+<ScrollView
+ android:id="@+id/scroller_id"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:scrollbars="vertical"
+ android:fillViewport="true">
+
+ <TextView
+ android:id="@+id/console"
android:paddingTop="20pt"
android:layout_height="fill_parent"
- android:layout_width="match_parent"
- android:maxLines="40"
+ android:layout_width="fill_parent"
android:textSize="14dp"
- android:scrollbars = "vertical"
+ android:layout_weight="1.0"
android:text="@string/none">
</TextView>
+</ScrollView>
</LinearLayout>
diff --git a/tests/SoundTriggerTestApp/res/values/strings.xml b/tests/SoundTriggerTestApp/res/values/strings.xml
index 5f0fb1daf3e9..b4ca71b8286e 100644
--- a/tests/SoundTriggerTestApp/res/values/strings.xml
+++ b/tests/SoundTriggerTestApp/res/values/strings.xml
@@ -24,5 +24,5 @@
<string name="model_one">Model One</string>
<string name="model_two">Model Two</string>
<string name="model_three">Model Three</string>
- <string name="none">Debug messages appear here:</string>
+ <string name="none">Debug messages appear here:\n</string>
</resources>
diff --git a/tests/SoundTriggerTestApp/src/com/android/test/soundtrigger/TestSoundTriggerActivity.java b/tests/SoundTriggerTestApp/src/com/android/test/soundtrigger/TestSoundTriggerActivity.java
index 96a69661a7aa..3149783506de 100644
--- a/tests/SoundTriggerTestApp/src/com/android/test/soundtrigger/TestSoundTriggerActivity.java
+++ b/tests/SoundTriggerTestApp/src/com/android/test/soundtrigger/TestSoundTriggerActivity.java
@@ -32,6 +32,7 @@ import android.os.UserManager;
import android.util.Log;
import android.view.View;
import android.widget.RadioButton;
+import android.widget.ScrollView;
import android.widget.TextView;
import android.widget.Toast;
@@ -52,6 +53,7 @@ public class TestSoundTriggerActivity extends Activity {
private TextView mDebugView = null;
private int mSelectedModelId = 1;
+ private ScrollView mScrollView = null;
@Override
protected void onCreate(Bundle savedInstanceState) {
@@ -59,6 +61,7 @@ public class TestSoundTriggerActivity extends Activity {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
mDebugView = (TextView) findViewById(R.id.console);
+ mScrollView = (ScrollView) findViewById(R.id.scroller_id);
mDebugView.setText(mDebugView.getText(), TextView.BufferType.EDITABLE);
mDebugView.setMovementMethod(new ScrollingMovementMethod());
mSoundTriggerUtil = new SoundTriggerUtil(this);
@@ -68,6 +71,18 @@ public class TestSoundTriggerActivity extends Activity {
private void postMessage(String msg) {
Log.i(TAG, "Posted: " + msg);
((Editable) mDebugView.getText()).append(msg + "\n");
+ if ((mDebugView.getMeasuredHeight() - mScrollView.getScrollY()) <=
+ (mScrollView.getHeight() + mDebugView.getLineHeight())) {
+ scrollToBottom();
+ }
+ }
+
+ private void scrollToBottom() {
+ mScrollView.post(new Runnable() {
+ public void run() {
+ mScrollView.smoothScrollTo(0, mDebugView.getBottom());
+ }
+ });
}
private UUID getSelectedUuid() {