FM: Do not stop FMRadioService if FM is still on
Fix the issue: After pressing back-key or rotating DUT, FM will stop.
Change-Id: If9c3b5001963e837dde699a844a6406acd892126
Signed-off-by: juncao <juncao@codeaurora.org>
CRs-Fixed: 956792
diff --git a/fmapp2/src/com/caf/fmradio/FMRadio.java b/fmapp2/src/com/caf/fmradio/FMRadio.java
index ff48847..c364885 100644
--- a/fmapp2/src/com/caf/fmradio/FMRadio.java
+++ b/fmapp2/src/com/caf/fmradio/FMRadio.java
@@ -2976,14 +2976,21 @@
public void unbindFromService(Context context) {
ServiceBinder sb = (ServiceBinder) sConnectionMap.remove(context);
+ boolean isFmOn = isFmOn();
Log.e(LOGTAG, "unbindFromService: Context");
if (sb == null) {
Log.e(LOGTAG, "Trying to unbind for unknown Context");
return;
}
context.unbindService(sb);
- Log.e(LOGTAG, "stop FM radio service");
- context.stopService(new Intent(context, FMRadioService.class));
+
+ if (isFmOn) {
+ Log.d(LOGTAG, "FM is still on");
+ } else {
+ 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