FM: synchronize mReceiver object

  - synchronize mReceiver object to prevent null object 
    access while fm on/off stablity test.
  - fix is needed in fm on sequence, since we setting 
    mReceiver object to null while disabling.
    in race condition where multiple fm on/off performed
    mReceiver can be null.

Change-Id: I6dd67958b40146ff48ce521e06ecb246e3fd1307
diff --git a/fmapp2/src/com/caf/fmradio/FMRadioService.java b/fmapp2/src/com/caf/fmradio/FMRadioService.java
index 340376e..0ef3a1b 100644
--- a/fmapp2/src/com/caf/fmradio/FMRadioService.java
+++ b/fmapp2/src/com/caf/fmradio/FMRadioService.java
@@ -119,6 +119,7 @@
    private static final String LOGTAG = "FMService";//FMRadio.LOGTAG;
 
    private FmReceiver mReceiver;
+   private final Object mReceiverLock = new Object();
    private BroadcastReceiver mHeadsetReceiver = null;
    private BroadcastReceiver mSdcardUnmountReceiver = null;
    private BroadcastReceiver mMusicCommandListener = null;
@@ -2398,10 +2399,12 @@
       boolean bStatus=false;
 
       // This will disable the FM radio device
-      if (mReceiver != null)
-      {
-         bStatus = mReceiver.disable(this);
-         mReceiver = null;
+      synchronized(mReceiverLock) {
+         if (mReceiver != null)
+         {
+            bStatus = mReceiver.disable(this);
+            mReceiver = null;
+         }
       }
       fmOperationsOff();
       stop();
@@ -3039,10 +3042,12 @@
    public boolean enableStereo(boolean bEnable)
    {
       boolean bCommandSent=false;
-      if (mReceiver != null)
-      {
-         Log.d(LOGTAG, "enableStereo: " + bEnable);
-         bCommandSent = mReceiver.setStereoMode(bEnable);
+      synchronized(mReceiverLock) {
+          if (mReceiver != null)
+          {
+             Log.d(LOGTAG, "enableStereo: " + bEnable);
+             bCommandSent = mReceiver.setStereoMode(bEnable);
+          }
       }
       return bCommandSent;
    }