Merge "Fix minor bugs:" into nyc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
28af5fcdc9
@@ -198,6 +198,7 @@ public class SoundTriggerHelper implements SoundTrigger.StatusListener {
|
|||||||
return STATUS_ERROR;
|
return STATUS_ERROR;
|
||||||
}
|
}
|
||||||
modelData.setHandle(handle[0]);
|
modelData.setHandle(handle[0]);
|
||||||
|
modelData.setLoaded();
|
||||||
}
|
}
|
||||||
modelData.setCallback(callback);
|
modelData.setCallback(callback);
|
||||||
modelData.setRecognitionConfig(recognitionConfig);
|
modelData.setRecognitionConfig(recognitionConfig);
|
||||||
@@ -346,7 +347,7 @@ public class SoundTriggerHelper implements SoundTrigger.StatusListener {
|
|||||||
return STATUS_ERROR;
|
return STATUS_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (currentCallback == null || !modelData.modelStarted()) {
|
if (currentCallback == null || !modelData.isModelStarted()) {
|
||||||
// startRecognition hasn't been called or it failed.
|
// startRecognition hasn't been called or it failed.
|
||||||
Slog.w(TAG, "Attempting stopRecognition without a successful startRecognition");
|
Slog.w(TAG, "Attempting stopRecognition without a successful startRecognition");
|
||||||
return STATUS_ERROR;
|
return STATUS_ERROR;
|
||||||
@@ -451,7 +452,7 @@ public class SoundTriggerHelper implements SoundTrigger.StatusListener {
|
|||||||
|
|
||||||
// Stop all generic recognition models.
|
// Stop all generic recognition models.
|
||||||
for (ModelData model : mGenericModelDataMap.values()) {
|
for (ModelData model : mGenericModelDataMap.values()) {
|
||||||
if (model.modelStarted()) {
|
if (model.isModelStarted()) {
|
||||||
int status = stopGenericRecognitionLocked(model,
|
int status = stopGenericRecognitionLocked(model,
|
||||||
false /* do not notify for synchronous calls */);
|
false /* do not notify for synchronous calls */);
|
||||||
if (status != STATUS_OK) {
|
if (status != STATUS_OK) {
|
||||||
@@ -970,7 +971,7 @@ public class SoundTriggerHelper implements SoundTrigger.StatusListener {
|
|||||||
}
|
}
|
||||||
for (UUID modelId : mGenericModelDataMap.keySet()) {
|
for (UUID modelId : mGenericModelDataMap.keySet()) {
|
||||||
ModelData modelData = mGenericModelDataMap.get(modelId);
|
ModelData modelData = mGenericModelDataMap.get(modelId);
|
||||||
if (modelData.modelStarted()) {
|
if (modelData.isModelStarted()) {
|
||||||
mRecognitionRunning = true;
|
mRecognitionRunning = true;
|
||||||
return mRecognitionRunning;
|
return mRecognitionRunning;
|
||||||
}
|
}
|
||||||
@@ -1001,7 +1002,6 @@ public class SoundTriggerHelper implements SoundTrigger.StatusListener {
|
|||||||
// to SoundModel.TYPE_UNKNOWN;
|
// to SoundModel.TYPE_UNKNOWN;
|
||||||
private int mModelType = SoundModel.TYPE_UNKNOWN;
|
private int mModelType = SoundModel.TYPE_UNKNOWN;
|
||||||
private IRecognitionStatusCallback mCallback = null;
|
private IRecognitionStatusCallback mCallback = null;
|
||||||
private SoundModel mSoundModel = null;
|
|
||||||
private RecognitionConfig mRecognitionConfig = null;
|
private RecognitionConfig mRecognitionConfig = null;
|
||||||
|
|
||||||
|
|
||||||
@@ -1026,8 +1026,7 @@ public class SoundTriggerHelper implements SoundTrigger.StatusListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
synchronized boolean isModelLoaded() {
|
synchronized boolean isModelLoaded() {
|
||||||
return (mModelState == MODEL_LOADED || mModelState == MODEL_STARTED) &&
|
return (mModelState == MODEL_LOADED || mModelState == MODEL_STARTED);
|
||||||
mSoundModel != null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
synchronized void setStarted() {
|
synchronized void setStarted() {
|
||||||
@@ -1038,13 +1037,16 @@ public class SoundTriggerHelper implements SoundTrigger.StatusListener {
|
|||||||
mModelState = MODEL_LOADED;
|
mModelState = MODEL_LOADED;
|
||||||
}
|
}
|
||||||
|
|
||||||
synchronized boolean modelStarted() {
|
synchronized void setLoaded() {
|
||||||
|
mModelState = MODEL_LOADED;
|
||||||
|
}
|
||||||
|
|
||||||
|
synchronized boolean isModelStarted() {
|
||||||
return mModelState == MODEL_STARTED;
|
return mModelState == MODEL_STARTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
synchronized void clearState() {
|
synchronized void clearState() {
|
||||||
mModelState = MODEL_NOTLOADED;
|
mModelState = MODEL_NOTLOADED;
|
||||||
mSoundModel = null;
|
|
||||||
mModelHandle = INVALID_VALUE;
|
mModelHandle = INVALID_VALUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -66,6 +66,7 @@
|
|||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:padding="20dp"
|
android:padding="20dp"
|
||||||
|
android:checkedButton="@+id/model_one"
|
||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
<RadioButton android:id="@+id/model_one"
|
<RadioButton android:id="@+id/model_one"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
@@ -84,15 +85,21 @@
|
|||||||
android:onClick="onRadioButtonClicked"/>
|
android:onClick="onRadioButtonClicked"/>
|
||||||
</RadioGroup>
|
</RadioGroup>
|
||||||
|
|
||||||
<TextView
|
<ScrollView
|
||||||
android:id="@+id/console"
|
android:id="@+id/scroller_id"
|
||||||
android:gravity="left"
|
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:paddingTop="20pt"
|
||||||
android:layout_height="fill_parent"
|
android:layout_height="fill_parent"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="fill_parent"
|
||||||
android:maxLines="40"
|
|
||||||
android:textSize="14dp"
|
android:textSize="14dp"
|
||||||
android:scrollbars = "vertical"
|
android:layout_weight="1.0"
|
||||||
android:text="@string/none">
|
android:text="@string/none">
|
||||||
</TextView>
|
</TextView>
|
||||||
|
</ScrollView>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|||||||
@@ -24,5 +24,5 @@
|
|||||||
<string name="model_one">Model One</string>
|
<string name="model_one">Model One</string>
|
||||||
<string name="model_two">Model Two</string>
|
<string name="model_two">Model Two</string>
|
||||||
<string name="model_three">Model Three</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>
|
</resources>
|
||||||
|
|||||||
@@ -32,6 +32,7 @@ import android.os.UserManager;
|
|||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.RadioButton;
|
import android.widget.RadioButton;
|
||||||
|
import android.widget.ScrollView;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
@@ -52,6 +53,7 @@ public class TestSoundTriggerActivity extends Activity {
|
|||||||
|
|
||||||
private TextView mDebugView = null;
|
private TextView mDebugView = null;
|
||||||
private int mSelectedModelId = 1;
|
private int mSelectedModelId = 1;
|
||||||
|
private ScrollView mScrollView = null;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
@@ -59,6 +61,7 @@ public class TestSoundTriggerActivity extends Activity {
|
|||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setContentView(R.layout.main);
|
setContentView(R.layout.main);
|
||||||
mDebugView = (TextView) findViewById(R.id.console);
|
mDebugView = (TextView) findViewById(R.id.console);
|
||||||
|
mScrollView = (ScrollView) findViewById(R.id.scroller_id);
|
||||||
mDebugView.setText(mDebugView.getText(), TextView.BufferType.EDITABLE);
|
mDebugView.setText(mDebugView.getText(), TextView.BufferType.EDITABLE);
|
||||||
mDebugView.setMovementMethod(new ScrollingMovementMethod());
|
mDebugView.setMovementMethod(new ScrollingMovementMethod());
|
||||||
mSoundTriggerUtil = new SoundTriggerUtil(this);
|
mSoundTriggerUtil = new SoundTriggerUtil(this);
|
||||||
@@ -68,6 +71,18 @@ public class TestSoundTriggerActivity extends Activity {
|
|||||||
private void postMessage(String msg) {
|
private void postMessage(String msg) {
|
||||||
Log.i(TAG, "Posted: " + msg);
|
Log.i(TAG, "Posted: " + msg);
|
||||||
((Editable) mDebugView.getText()).append(msg + "\n");
|
((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() {
|
private UUID getSelectedUuid() {
|
||||||
|
|||||||
Reference in New Issue
Block a user