Toggle FM on receiving AVRCP play command
While FM is playing over BT and press the play/pause button from BT
headset, receiving the AVRCP play command from BT headset. On receving AVRCP
play command from BT headset, if FM is already on, we don't turn off the FM and
FM keeps playing.
Toggle the FM to on/off on receving the play command.
Change-Id: Iee34ca9d40929a0f5fd04fcfba0c42f29a0dd388
diff --git a/fmapp2/src/com/caf/fmradio/FMRadioService.java b/fmapp2/src/com/caf/fmradio/FMRadioService.java
index 002224d..762a969 100644
--- a/fmapp2/src/com/caf/fmradio/FMRadioService.java
+++ b/fmapp2/src/com/caf/fmradio/FMRadioService.java
@@ -976,13 +976,28 @@
&& (key_action == KeyEvent.ACTION_DOWN)) {
Log.d(LOGTAG, "SessionCallback: MEDIA_PLAY");
if (isAntennaAvailable() && mServiceInUse) {
- fmOn();
- try {
- if (mCallbacks != null ) {
- mCallbacks.onEnabled();
+ if (isFmOn()){
+ //FM should be off when Headset hook pressed.
+ fmOff();
+ try {
+ /* Notify the UI/Activity, only if the service is "bound"
+ * by an activity and if Callbacks are registered
+ * */
+ if ((mServiceInUse) && (mCallbacks != null) ) {
+ mCallbacks.onDisabled();
+ }
+ } catch (RemoteException e) {
+ e.printStackTrace();
}
- } catch (RemoteException e) {
- e.printStackTrace();
+ } else {
+ fmOn();
+ try {
+ if (mCallbacks != null ) {
+ mCallbacks.onEnabled();
+ }
+ } catch (RemoteException e) {
+ e.printStackTrace();
+ }
}
return true;
}