add BT SCO init debugging code to TestVoiceActivity
This commit is contained in:
parent
76c6095c7a
commit
3e852eaf2a
2 changed files with 32 additions and 0 deletions
|
@ -229,6 +229,9 @@ public class TestVoiceActivity extends OsmandActionBarActivity {
|
|||
addButton(ll, "(10.2) GPS signal recovered", builder(p).gpsLocationRecover());
|
||||
addButton(ll, "(10.3) You have been off the route for 1050m", builder(p).offRoute(1050));
|
||||
addButton(ll, "(10.4) You are back on the route", builder(p).backOnRoute());
|
||||
|
||||
addButton(ll, " System checks:", builder(p));
|
||||
addButton(ll, "(11.1) Display BT SCO availability (Phone call audio only)", builder(p).attention(""));
|
||||
ll.forceLayout();
|
||||
}
|
||||
|
||||
|
@ -249,6 +252,9 @@ public class TestVoiceActivity extends OsmandActionBarActivity {
|
|||
@Override
|
||||
public void onClick(View v) {
|
||||
builder.play();
|
||||
if (description.startsWith("(11.1)")) {
|
||||
displayBtScoAvailability();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -263,4 +269,22 @@ public class TestVoiceActivity extends OsmandActionBarActivity {
|
|||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private void displayBtScoAvailability() {
|
||||
if (((OsmandApplication) getApplication()).getSettings().AUDIO_STREAM_GUIDANCE.get() == 0) {
|
||||
String notification;
|
||||
if (AbstractPrologCommandPlayer.btScoAvailable == true) {
|
||||
notification = "BT SCO available: YES";
|
||||
} else {
|
||||
notification = "BT SCO available: NO";
|
||||
}
|
||||
if (AbstractPrologCommandPlayer.btScoInitializes == true) {
|
||||
notification = notification + "\n" + "BT SCO initializes: YES";
|
||||
} else {
|
||||
notification = notification + "\n" + "BT SCO initializes: NO";
|
||||
}
|
||||
notification = notification + "\n" + "BT SCO init delay: " + AbstractPrologCommandPlayer.BT_SCO_DELAY;
|
||||
Toast.makeText(TestVoiceActivity.this, notification, Toast.LENGTH_LONG).show();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -312,18 +312,26 @@ public abstract class AbstractPrologCommandPlayer implements CommandPlayer, Stat
|
|||
|
||||
public static final int BT_SCO_DELAY = 1500;
|
||||
|
||||
// These 2 only needed for status debugging in TestVoiceActivity:
|
||||
public static boolean btScoAvailable = false;
|
||||
public static boolean btScoInitializes = false;
|
||||
|
||||
private boolean startBtSco() {
|
||||
// Hardy, 2016-07-03: Establish a low quality BT SCO (Synchronous Connection-Oriented) link to interrupt e.g. a car stereo FM radio
|
||||
btScoAvailable = false;
|
||||
btScoInitializes = false;
|
||||
try {
|
||||
AudioManager mAudioManager = (AudioManager) ctx.getSystemService(Context.AUDIO_SERVICE);
|
||||
if (mAudioManager == null || !mAudioManager.isBluetoothScoAvailableOffCall()) {
|
||||
return false;
|
||||
}
|
||||
btScoAvailable = true;
|
||||
mAudioManager.setMode(0);
|
||||
mAudioManager.startBluetoothSco();
|
||||
mAudioManager.setBluetoothScoOn(true);
|
||||
mAudioManager.setMode(AudioManager.MODE_IN_COMMUNICATION);
|
||||
btScoStatus = true;
|
||||
btScoInitializes = true;
|
||||
} catch (Exception e) {
|
||||
System.out.println("Exception starting BT SCO " + e.getMessage() );
|
||||
btScoStatus = false;
|
||||
|
|
Loading…
Reference in a new issue