FM: stop fm radio service when fm activity is destroyed
Stop fm radio service when fm activity is destroyed.
CRs-Fixed: 2620277
Change-Id: I9251fbb5a6a0ad5322e689add7974e926dd1ce04
diff --git a/fmapp2/src/com/caf/fmradio/FMRadio.java b/fmapp2/src/com/caf/fmradio/FMRadio.java
index 5940f4b..4ee3494 100644
--- a/fmapp2/src/com/caf/fmradio/FMRadio.java
+++ b/fmapp2/src/com/caf/fmradio/FMRadio.java
@@ -2944,12 +2944,8 @@
}
context.unbindService(sb);
- if (isFmOn) {
- Log.d(LOGTAG, "FM is still on");
- } else {
- Log.e(LOGTAG, "stop FM radio service");
- context.stopService(new Intent(context, FMRadioService.class));
- }
+ Log.e(LOGTAG, "stop FM radio service");
+ context.stopService(new Intent(context, FMRadioService.class));
if (sConnectionMap.isEmpty()) {
// presumably there is nobody interested in the service at this point,
diff --git a/fmapp2/src/com/caf/fmradio/FMRadioService.java b/fmapp2/src/com/caf/fmradio/FMRadioService.java
index 2618a0c..7dacbee 100644
--- a/fmapp2/src/com/caf/fmradio/FMRadioService.java
+++ b/fmapp2/src/com/caf/fmradio/FMRadioService.java
@@ -279,8 +279,6 @@
mA2dpDeviceSupportInHal = valueStr.contains("=true");
Log.d(LOGTAG, " is A2DP device Supported In HAL"+mA2dpDeviceSupportInHal);
- getA2dpStatusAtStart();
-
mGainFocusReq = requestAudioFocus();
AudioManager mAudioManager =
(AudioManager) getSystemService(Context.AUDIO_SERVICE);
@@ -299,7 +297,9 @@
Log.d(LOGTAG, "onDestroy");
if (isFmOn())
{
- Log.e(LOGTAG, "Service being destroyed while still playing.");
+ Log.e(LOGTAG, "FMRadio Service being destroyed");
+ /* Since the service is closing, disable the receiver */
+ fmOff();
}
// make sure there aren't any other messages coming
@@ -359,9 +359,6 @@
unregisterReceiver(mRegisterUserSwitched);
mRegisterUserSwitched = null;
}
- /* Since the service is closing, disable the receiver */
- if (isFmOn())
- fmOff();
TelephonyManager tmgr = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
tmgr.listen(mPhoneStateListener, 0);