Loading services/voiceinteraction/java/com/android/server/soundtrigger/SoundTriggerHelper.java +10 −8 Original line number Diff line number Diff line Loading @@ -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); Loading Loading @@ -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; Loading Loading @@ -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) { Loading Loading @@ -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; } Loading Loading @@ -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; Loading @@ -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() { Loading @@ -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; } Loading tests/SoundTriggerTestApp/res/layout/main.xml +13 −6 Original line number Diff line number Diff line Loading @@ -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" Loading @@ -84,15 +85,21 @@ android:onClick="onRadioButtonClicked"/> </RadioGroup> <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:gravity="left" 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> tests/SoundTriggerTestApp/res/values/strings.xml +1 −1 Original line number Diff line number Diff line Loading @@ -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> tests/SoundTriggerTestApp/src/com/android/test/soundtrigger/TestSoundTriggerActivity.java +15 −0 Original line number Diff line number Diff line Loading @@ -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; Loading @@ -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) { Loading @@ -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); Loading @@ -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() { Loading Loading
services/voiceinteraction/java/com/android/server/soundtrigger/SoundTriggerHelper.java +10 −8 Original line number Diff line number Diff line Loading @@ -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); Loading Loading @@ -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; Loading Loading @@ -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) { Loading Loading @@ -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; } Loading Loading @@ -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; Loading @@ -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() { Loading @@ -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; } Loading
tests/SoundTriggerTestApp/res/layout/main.xml +13 −6 Original line number Diff line number Diff line Loading @@ -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" Loading @@ -84,15 +85,21 @@ android:onClick="onRadioButtonClicked"/> </RadioGroup> <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:gravity="left" 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>
tests/SoundTriggerTestApp/res/values/strings.xml +1 −1 Original line number Diff line number Diff line Loading @@ -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>
tests/SoundTriggerTestApp/src/com/android/test/soundtrigger/TestSoundTriggerActivity.java +15 −0 Original line number Diff line number Diff line Loading @@ -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; Loading @@ -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) { Loading @@ -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); Loading @@ -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() { Loading