Promotion of fm.lnx.2.1-00015.

CRs      Change ID                                   Subject
--------------------------------------------------------------------------------------------------------------
1091781   I7bb1ef12f4622f9d94621a9c486a771226aba9f4   Check for TX event before waiting for an event
1091284   Ice666cddd8e734d2d91053c30c42493315292841   Memset structure values to 0 before sending an IOCTL
1090643   Icef5922c3e3972f5e44cd1d3f873f864785e26be   Update FM UI after service bind complete

Change-Id: Ibd8018906c9f07e2655ea2d5080754a7deec59be
CRs-Fixed: 1091781, 1091284, 1090643
diff --git a/fm_hci/fm_hci.c b/fm_hci/fm_hci.c
index a3666af..c48edd5 100644
--- a/fm_hci/fm_hci.c
+++ b/fm_hci/fm_hci.c
@@ -338,7 +338,8 @@
 
     while (lib_running) {
         pthread_mutex_lock(&hci->event_lock);
-        pthread_cond_wait(&hci->event_cond, &hci->event_lock);
+        if (!(ready_events & HC_EVENT_TX))
+            pthread_cond_wait(&hci->event_cond, &hci->event_lock);
         ALOGE("%s: ready_events= %d", __func__, ready_events);
         events = ready_events;
         if (ready_events & HC_EVENT_TX)
diff --git a/fmapp2/src/com/caf/fmradio/FMRadio.java b/fmapp2/src/com/caf/fmradio/FMRadio.java
index 7d357f7..1da839b 100644
--- a/fmapp2/src/com/caf/fmradio/FMRadio.java
+++ b/fmapp2/src/com/caf/fmradio/FMRadio.java
@@ -505,16 +505,25 @@
 
       super.onResume();
 
-      if (!isAntennaAvailable()) {
+      if (mService == null) {
+          Log.d(LOGTAG,"bind callback has not received yet - wait for 100ms");
+          mHandler.postDelayed(UpdateFm, 100);
           return;
       }
-      // TODO: We should return on exception or continue?
-      try {
-          if (mService != null)
-              mService.registerCallbacks(mServiceCallbacks);
-      } catch (RemoteException e) {
-          e.printStackTrace();
-      }
+     mHandler.post(UpdateFm);
+   }
+   Runnable UpdateFm = new Runnable() {
+       public void run() {
+           // TODO: We should return on exception or continue?
+           if (!isAntennaAvailable()) {
+               return;
+           }
+           try {
+               if (mService != null)
+                   mService.registerCallbacks(mServiceCallbacks);
+           } catch (RemoteException e) {
+               e.printStackTrace();
+           }
 
       if (isSleepTimerActive()) {
           Log.d(LOGTAG, "isSleepTimerActive is true");
@@ -559,7 +568,8 @@
       mUpdatePickerValue = true;
       updateStationInfoToUI();
       enableRadioOnOffUI();
-   }
+       }
+   };
    private static class LoadedDataAndState {
       public LoadedDataAndState(){};
       public boolean onOrOff;
diff --git a/jni/FmIoctlsInterface.cpp b/jni/FmIoctlsInterface.cpp
index 046ca1e..640a90f 100644
--- a/jni/FmIoctlsInterface.cpp
+++ b/jni/FmIoctlsInterface.cpp
@@ -111,6 +111,9 @@
     struct v4l2_ext_controls v4l2_ctls;
     char cal_data[CAL_DATA_SIZE] = {0};
 
+    memset(&v4l2_ctls, 0, sizeof(v4l2_ctls));
+    memset(&ext_ctl, 0, sizeof(ext_ctl));
+
     cal_fp = fopen(CALIB_DATA_NAME, "r");
     if(cal_fp != NULL) {
        if(fread(&cal_data[0], 1, CAL_DATA_SIZE, cal_fp)