Do not stop FM Radio Service during unbind using stopSelf.
During Unbind, do not kill FM Radio service. The service might restart
again and it will end up getting Media Button events starving other
eligible applications. Use explicit stopService call in FM Radio. This
calls Destroy callback resulting in proper clean up of FM Radio Service.
CRs-Fixed: 932236
Change-Id: Idf3d768e66bd4bafc7d1ef40aefa15982454889c
diff --git a/fmapp2/src/com/caf/fmradio/FMRadio.java b/fmapp2/src/com/caf/fmradio/FMRadio.java
index 20270e3..45b68bc 100644
--- a/fmapp2/src/com/caf/fmradio/FMRadio.java
+++ b/fmapp2/src/com/caf/fmradio/FMRadio.java
@@ -2999,6 +2999,8 @@
return;
}
context.unbindService(sb);
+ 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,
// so don't hang on to the ServiceConnection
diff --git a/fmapp2/src/com/caf/fmradio/FMRadioService.java b/fmapp2/src/com/caf/fmradio/FMRadioService.java
index 56d9aa6..b9adc42 100644
--- a/fmapp2/src/com/caf/fmradio/FMRadioService.java
+++ b/fmapp2/src/com/caf/fmradio/FMRadioService.java
@@ -941,13 +941,6 @@
/* Application/UI is not attached, so go into lower power mode */
unregisterCallbacks();
setLowPowerMode(true);
- if (isFmOn())
- {
- // something is currently playing, or will be playing once
- // an in-progress call ends, so don't stop the service now.
- return true;
- }
- stopSelf(mServiceStartId);
return true;
}