Skip to content
Snippets Groups Projects
Commit 9c555961 authored by Venkateshwarlu Domakonda's avatar Venkateshwarlu Domakonda
Browse files

FM: Disable speaker option when A2DP connected

As the audio framework not supported to set the speaker option,
disabling the device switch option when A2DP is connected.

Change-Id: I0e3d61aefa400b8df3338af81b1417338880a786
CRs-Fixed: 892109
parent e4813311
Branches
No related tags found
No related merge requests found
......@@ -1858,6 +1858,19 @@ public class FMRadio extends Activity
return(mRtPlusSupported);
}
private boolean isA2DPConnected() {
boolean A2DPConnected = false;
if (mService != null) {
try {
A2DPConnected = mService.isA2DPConnected();
} catch (RemoteException e) {
e.printStackTrace();
}
}
Log.d(LOGTAG, "A2DPConnected: " + A2DPConnected);
return(A2DPConnected);
}
private boolean isSpeakerEnabled() {
boolean speakerEnabled = false;
if (mService != null) {
......@@ -2047,6 +2060,10 @@ public class FMRadio extends Activity
}else{
mSpeakerButton.setImageResource(R.drawable.btn_earphone);
}
if (isA2DPConnected())
mSpeakerButton.setClickable(false);
else
mSpeakerButton.setClickable(true);
}
}
......@@ -2225,6 +2242,16 @@ public class FMRadio extends Activity
updateSearchProgress();
}
private void A2DPConnectionState(boolean state) {
Log.d(LOGTAG, "A2DPConnectionState with:" +state);
if (state) {
Log.d(LOGTAG, "make speaker button disable");
mSpeakerButton.setClickable(false);
} else {
Log.d(LOGTAG, "make speaker button enable");
mSpeakerButton.setClickable(true);
}
}
/** Scan related */
private void initiateSearch(int pty) {
synchronized (this) {
......@@ -3144,6 +3171,10 @@ public class FMRadio extends Activity
Log.d(LOGTAG, "mServiceCallbacks.onSeekNextStation:");
SeekNextStation();
}
public void onA2DPConnectionstateChanged(boolean state){
Log.d(LOGTAG, "mServiceCallbacks.onA2DPConnectionstateChanged :");
A2DPConnectionState(state);
}
};
private void registerFMSettingListner() {
......
......@@ -557,6 +557,12 @@ public class FMRadioService extends Service
boolean bA2dpConnected =
mA2dpDeviceState.isConnected(intent);
Log.d(LOGTAG, "bA2dpConnected:" +bA2dpConnected);
try {
if ((mServiceInUse) && (mCallbacks != null))
mCallbacks.onA2DPConnectionstateChanged(bA2dpConnected);
} catch (RemoteException e) {
e.printStackTrace();
}
if (!bA2dpConnected) {
Log.d(LOGTAG, "A2DP device is dis-connected!");
mA2dpDisconnected = true;
......@@ -1982,6 +1988,11 @@ public class FMRadioService extends Service
{
return(mService.get().isSSRInProgress());
}
public boolean isA2DPConnected()
{
return(mService.get().isA2DPConnected());
}
}
private final IBinder mBinder = new ServiceStub(this);
......@@ -2220,6 +2231,9 @@ public class FMRadioService extends Service
return mIsSSRInProgress;
}
public boolean isA2DPConnected() {
return (mA2dpConnected);
}
/* Returns whether FM hardware is ON.
*
* @return true if FM was tuned, searching. (at the end of
......
......@@ -2716,6 +2716,9 @@ public class FMStats extends Activity {
public void onSeekNextStation() {
Log.d(LOGTAG, "mServiceCallbacks.onSeekNextStation:");
}
public void onA2DPConnectionstateChanged(boolean state){
Log.d(LOGTAG, "mServiceCallbacks.onA2DPConnectionstateChanged :");
}
};
/* Radio Vars */
private Handler mHandler = new Handler();
......
......@@ -74,5 +74,6 @@ interface IFMRadioService
boolean isSleepTimerActive();
boolean isSSRInProgress();
boolean isRtPlusSupported();
boolean isA2DPConnected();
}
......@@ -47,4 +47,5 @@ interface IFMRadioServiceCallbacks
void onExtenRadioTextChanged();
void onRecordingStarted();
void onSeekNextStation();
void onA2DPConnectionstateChanged(boolean state);
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment