FM: Add HIDL support on O release

Add fm HIDL support on O release.

CRs-fixed: 2019165
Change-Id: I49b3294cdefbf763e5ad2e8f5776e9fc6393400c
diff --git a/helium/Android.mk b/helium/Android.mk
index 068308b..4008dd6 100644
--- a/helium/Android.mk
+++ b/helium/Android.mk
@@ -5,8 +5,8 @@
 include $(CLEAR_VARS)
 
 LOCAL_SRC_FILES:= \
-	radio_helium_hal.c \
-	radio_helium_hal_cmds.c
+        radio_helium_hal.c \
+        radio_helium_hal_cmds.c
 
 LOCAL_SHARED_LIBRARIES := \
          libfm-hci \
diff --git a/helium/radio_helium_hal.c b/helium/radio_helium_hal.c
index 5d9137e..1109ca3 100644
--- a/helium/radio_helium_hal.c
+++ b/helium/radio_helium_hal.c
@@ -116,9 +116,6 @@
     if (hal->radio->mode == FM_TURNING_OFF) {
         ALOGD("%s:calling fm close\n", LOG_TAG );
         fm_hci_close(hal->private_data);
-        hal->radio->mode = FM_OFF;
-        hal->jni_cb->disabled_cb();
-        hal->jni_cb->thread_evt_cb(1);
     }
 }
 
@@ -823,8 +820,6 @@
 {
    ALOGE("%s:%s: start", LOG_TAG, __func__);
    fm_hci_close(hal->private_data);
-   hal->jni_cb->disabled_cb();
-   hal->jni_cb->thread_evt_cb(1);
 }
 
 static void hci_buff_ert(struct rds_grp_data *rds_buf)
@@ -1034,6 +1029,18 @@
     return 0;
 }
 
+int fm_hci_close_done()
+{
+    ALOGI("fm_hci_close_done");
+    if(hal != NULL){
+        ALOGI("Notifying FM OFF to JNI");
+        hal->radio->mode = FM_OFF;
+        hal->jni_cb->disabled_cb();
+        hal->jni_cb->thread_evt_cb(1);
+    }
+    return 0;
+}
+
 int helium_search_req(int on, int direct)
 {
     int retval = 0;
@@ -1132,7 +1139,8 @@
 
 /* Callback function to be registered with FM-HCI for event notification */
 static struct fm_hci_callbacks_t hal_cb = {
-    process_event
+    process_event,
+    fm_hci_close_done
 };
 
 int hal_init(fm_hal_callbacks_t *cb)
diff --git a/helium/radio_helium_hal_cmds.c b/helium/radio_helium_hal_cmds.c
index b783c53..a8fc305 100644
--- a/helium/radio_helium_hal_cmds.c
+++ b/helium/radio_helium_hal_cmds.c
@@ -41,19 +41,19 @@
 
 static int send_fm_cmd_pkt(uint16_t opcode,  uint32_t len, void *param)
 {
-    int p_len = 4 + len;
+    int p_len = 3 + len;
     int ret = 0;
     ALOGV("Send_fm_cmd_pkt, opcode: %x", opcode);
-//    pthread_mutex_lock(&fm_hal);
+
     struct fm_command_header_t *hdr = (struct fm_command_header_t *) malloc(p_len);
     if (!hdr) {
         ALOGE("%s:hdr allocation failed", LOG_TAG);
         return -FM_HC_STATUS_NOMEM;
     }
 
+    memset(hdr, 0, p_len);
     ALOGV("%s:opcode: %x", LOG_TAG, opcode);
 
-    hdr->pi = RADIO_HCI_COMMAND_PKT;
     hdr->opcode = opcode;
     hdr->len = len;
     if (len)