From f184c6cbcbc8acd10c94cbf62b6744fea1d76acd Mon Sep 17 00:00:00 2001
From: Venkateshwarlu Domakonda <vdomak@codeaurora.org>
Date: Wed, 30 Sep 2015 16:43:51 +0530
Subject: [PATCH] FM: Fix the issue state machine

As the state is setting to OFF state, next enable is processing
even though cleanup not happend for previous turn OFF.
Handle the disable response then set the state to OFF.

CRs-Fixed: 916321
Change-Id: Ieb8aae20cd859084479c1446f24243ac5f0fbcd0
---
 qcom/fmradio/FmRxEventListner.java | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/qcom/fmradio/FmRxEventListner.java b/qcom/fmradio/FmRxEventListner.java
index 0f73a5c..0ad7c0c 100644
--- a/qcom/fmradio/FmRxEventListner.java
+++ b/qcom/fmradio/FmRxEventListner.java
@@ -213,18 +213,18 @@ class FmRxEventListner {
                             case 18:
                                 Log.d(TAG, "Got RADIO_DISABLED");
                                 if (FmTransceiver.getFMPowerState() == FmTransceiver.subPwrLevel_FMTurning_Off) {
+                                    FmTransceiver.release("/dev/radio0");
+                                    cb.FmRxEvDisableReceiver();
                                     /*Set the state as FMOff */
                                     FmTransceiver.setFMPowerState(FmTransceiver.FMState_Turned_Off);
                                     Log.v(TAG, "RxEvtList: CURRENT-STATE : FMTurningOff ---> NEW-STATE : FMOff");
-                                    FmTransceiver.release("/dev/radio0");
-                                    cb.FmRxEvDisableReceiver();
                                     Thread.currentThread().interrupt();
                                 } else {
-                                    FmTransceiver.setFMPowerState(FmTransceiver.FMState_Turned_Off);
                                     Log.d(TAG, "Unexpected RADIO_DISABLED recvd");
-                                    Log.v(TAG, "RxEvtList: CURRENT-STATE : FMRxOn ---> NEW-STATE : FMOff");
                                     FmTransceiver.release("/dev/radio0");
                                     cb.FmRxEvRadioReset();
+                                    FmTransceiver.setFMPowerState(FmTransceiver.FMState_Turned_Off);
+                                    Log.v(TAG, "RxEvtList: CURRENT-STATE : FMRxOn ---> NEW-STATE : FMOff");
                                     Thread.currentThread().interrupt();
                                 }
                                 break;
-- 
GitLab