Route audio to connected A2DP headset on turn on
If BT is connected after FM app launch and then FM is turned off and then
turned on, audio gets routed to wired headset. Check if A2DP device is
connected every time FM is turned on. Also set the UI icon to correct
image.
CRs-Fixed: 996689
Change-Id: I7314075f1652a1b99b906b674a98dfc12179e9cf
diff --git a/fmapp2/src/com/caf/fmradio/FMRadio.java b/fmapp2/src/com/caf/fmradio/FMRadio.java
index fb5ca1a..34b3d23 100644
--- a/fmapp2/src/com/caf/fmradio/FMRadio.java
+++ b/fmapp2/src/com/caf/fmradio/FMRadio.java
@@ -2250,7 +2250,7 @@
}
private void A2DPConnectionState(boolean state) {
- Log.d(LOGTAG, "A2DPConnectionState with:" +state);
+ Log.d(LOGTAG, "A2DPConnectionState with: " + state);
if (state) {
Log.d(LOGTAG, "A2DP connected, set button to speaker");
mSpeakerButton.setImageResource(R.drawable.btn_speaker);
diff --git a/fmapp2/src/com/caf/fmradio/FMRadioService.java b/fmapp2/src/com/caf/fmradio/FMRadioService.java
index 7dcc261..86f2b63 100644
--- a/fmapp2/src/com/caf/fmradio/FMRadioService.java
+++ b/fmapp2/src/com/caf/fmradio/FMRadioService.java
@@ -1059,7 +1059,12 @@
Log.d(LOGTAG, "Audio source set it as headset");
AudioSystem.setForceUse(AudioSystem.FOR_MEDIA, AudioSystem.FORCE_NONE);
}
+ } else {
+ Log.d(LOGTAG, "A2DP is connected, set audio source to A2DP HS");
+ AudioSystem.setForceUse(AudioSystem.FOR_MEDIA, AudioSystem.FORCE_SPEAKER);
+ mSpeakerPhoneOn = true;
}
+
mPlaybackInProgress = true;
configureAudioDataPath(true);
try {