libfmjni: Resolve property isolation issues
* Set system instead of vendor properties for FM init
on devices that don't use firmware download.
* Shut the radio down properly while we are at it.
Change-Id: I8f77a4f822ec8c609fe3526d7e96ea19d46cb1f8
diff --git a/FM_Const.h b/FM_Const.h
index 8cad9bf..82d0174 100644
--- a/FM_Const.h
+++ b/FM_Const.h
@@ -117,7 +117,11 @@
//STRING LITERALS
const char *const FM_MODE_PROP = "vendor.hw.fm.mode";
const char *const FM_VERSION_PROP = "vendor.hw.fm.version";
+#ifndef QCOM_NO_FM_FIRMWARE
const char *const FM_INIT_PROP = "vendor.hw.fm.init";
+#else
+const char *const FM_INIT_PROP = "hw.fm.init";
+#endif
const char *const FM_INTERNAL_ANTENNA_PROP = "vendor.hw.fm.internal_antenna";
const char *const SCRIPT_START_PROP = "ctl.start";
const char *const SCRIPT_STOP_PROP = "ctl.stop";
diff --git a/FmIoctlsInterface.cpp b/FmIoctlsInterface.cpp
index 62058dd..aa36359 100644
--- a/FmIoctlsInterface.cpp
+++ b/FmIoctlsInterface.cpp
@@ -42,15 +42,14 @@
int FmIoctlsInterface :: start_fm_patch_dl
(
- UINT fd
+ UINT fd __unused
)
{
int ret;
+#ifndef QCOM_NO_FM_FIRMWARE
int init_success = 0;
char versionStr[MAX_VER_STR_LEN] = {'\0'};
-#ifndef QCOM_NO_FM_FIRMWARE
char prop_value[PROPERTY_VALUE_MAX] = {'\0'};
-#endif
struct v4l2_capability cap;
ALOGI("%s: start_fm_patch_dl = %d\n", __func__, fd);
@@ -73,7 +72,6 @@
ALOGD("set FM_INIT_PROP done");
if(ret != PROP_SET_SUCC)
return FM_FAILURE;
-#ifndef QCOM_NO_FM_FIRMWARE
ret = property_set(SCRIPT_START_PROP, SOC_PATCH_DL_SCRPT);
if(ret != PROP_SET_SUCC)
return FM_FAILURE;
@@ -86,13 +84,6 @@
usleep(INIT_WAIT_TIMEOUT);
}
}
-#else
- ret = property_set(FM_INIT_PROP, "1");
- usleep(INIT_WAIT_TIMEOUT);
- if(ret != PROP_SET_SUCC)
- return FM_FAILURE;
- init_success = 1;
-#endif
if(!init_success) {
property_set(SCRIPT_STOP_PROP, SOC_PATCH_DL_SCRPT);
return FM_FAILURE;
@@ -103,6 +94,14 @@
}else {
return FM_FAILURE;
}
+#else
+ ret = property_set(FM_INIT_PROP, "1");
+ usleep(INIT_WAIT_TIMEOUT);
+ if (ret != PROP_SET_SUCC)
+ return FM_FAILURE;
+ else
+ return FM_SUCCESS;
+#endif
}
int FmIoctlsInterface :: close_fm_patch_dl
@@ -110,9 +109,9 @@
void
)
{
-#ifndef QCOM_NO_FM_FIRMWARE
int ret;
+#ifndef QCOM_NO_FM_FIRMWARE
ret = property_set(SCRIPT_STOP_PROP, SOC_PATCH_DL_SCRPT);
if(ret != PROP_SET_SUCC) {
return FM_FAILURE;
@@ -120,7 +119,11 @@
return FM_SUCCESS;
}
#else
- return FM_SUCCESS;
+ ret = property_set(FM_INIT_PROP, "0");
+ if (ret != PROP_SET_SUCC)
+ return FM_FAILURE;
+ else
+ return FM_SUCCESS;
#endif
}
diff --git a/FmRadioController.cpp b/FmRadioController.cpp
index 44a3d57..9946cce 100644
--- a/FmRadioController.cpp
+++ b/FmRadioController.cpp
@@ -267,6 +267,12 @@
close_fd:
event_listener_canceled = true;
pthread_join(event_listener_thread, NULL);
+ if (strcmp(value, "rome") != 0) {
+ ret = FmIoctlsInterface::close_fm_patch_dl();
+ if (ret != FM_SUCCESS) {
+ ALOGE("FM patch downloader close failed: %d\n", ret);
+ }
+ }
close(fd_driver);
fd_driver = -1;
set_fm_state(FM_OFF);
@@ -278,6 +284,9 @@
int FmRadioController ::Pwr_Down()
{
int ret = 0;
+ char value[PROPERTY_VALUE_MAX] = {'\0'};
+
+ property_get("vendor.bluetooth.soc", value, NULL);
if((cur_fm_state != FM_OFF)) {
Stop_Scan_Seek();
@@ -290,6 +299,12 @@
event_listener_canceled = true;
pthread_join(event_listener_thread, NULL);
}
+ if (strcmp(value, "rome") != 0) {
+ ret = FmIoctlsInterface::close_fm_patch_dl();
+ if (ret != FM_SUCCESS) {
+ ALOGE("FM patch downloader close failed: %d\n", ret);
+ }
+ }
ALOGD("%s, [ret=%d]\n", __func__, ret);
return ret;
}