FM: Drop dependency on libbtconfigstore

Issue: FP4-INT#3
Change-Id: I1d2bb9e50356f342de2d9fa458a626368e890cfc
(cherry picked from commit 8358bd7421cb876aba0b6832f89ed85162927eb6)
diff --git a/jni/Android.bp b/jni/Android.bp
index 1d6e8e0..bf97cbc 100755
--- a/jni/Android.bp
+++ b/jni/Android.bp
@@ -12,12 +12,9 @@
         "libnativehelper",
         "liblog",
         "libcutils",
-        "libbtconfigstore",
     ],
 
     include_dirs: [
-        "vendor/qcom/opensource/commonsys-intf/bluetooth/include",
-        "vendor/qcom/opensource/commonsys/bluetooth_ext/system_bt_ext/btconfigstore",
         "vendor/qcom/opensource/commonsys/fm/helium",
     ],
 
diff --git a/jni/android_hardware_fm.cpp b/jni/android_hardware_fm.cpp
index 76490ee..03e89db 100644
--- a/jni/android_hardware_fm.cpp
+++ b/jni/android_hardware_fm.cpp
@@ -41,7 +41,6 @@
 #include <dlfcn.h>
 #include "android_runtime/Log.h"
 #include "android_runtime/AndroidRuntime.h"
-#include "bt_configstore.h"
 #include <vector>
 #include "radio-helium.h"
 
@@ -157,11 +156,6 @@
 void *lib_handle;
 static int slimbus_flag = 0;
 
-static char soc_name[16];
-bool isSocNameAvailable = false;
-static bt_configstore_interface_t* bt_configstore_intf = NULL;
-static void *bt_configstore_lib_handle = NULL;
-
 static JNIEnv *mCallbackEnv = NULL;
 static jobject mCallbacksObj = NULL;
 static bool mCallbacksObjCreated = false;
@@ -195,8 +189,6 @@
 jmethodID method_enableSoftMuteCallback;
 jmethodID method_FmReceiverJNICtor;
 
-int load_bt_configstore_lib();
-
 static bool checkCallbackThread() {
    JNIEnv* env = AndroidRuntime::getJNIEnv();
    if (mCallbackEnv != env || mCallbackEnv == NULL)
@@ -648,18 +640,6 @@
 };
 /* native interface */
 
-static void get_property(int ptype, char *value)
-{
-    std::vector<vendor_property_t> vPropList;
-    bt_configstore_intf->get_vendor_properties(ptype, vPropList);
-
-    for (auto&& vendorProp : vPropList) {
-        if (vendorProp.type == ptype) {
-            strlcpy(value, vendorProp.value,PROPERTY_VALUE_MAX);
-        }
-    }
-}
-
 /********************************************************************
  * Current JNI
  *******************************************************************/
@@ -905,41 +885,6 @@
     return err;
 }
 
-static jboolean android_hardware_fmradio_FmReceiverJNI_getFmStatsPropNative
- (JNIEnv* env)
-{
-    jboolean ret;
-    char value[PROPERTY_VALUE_MAX] = {'\0'};
-    get_property(FM_STATS_PROP, value);
-    if (!strncasecmp(value, "true", sizeof("true"))) {
-        ret = true;
-    } else {
-        ret = false;
-    }
-
-    return ret;
-}
-
-static jint android_hardware_fmradio_FmReceiverJNI_getFmCoexPropNative
-(JNIEnv * env, jobject thiz, jint fd, jint prop)
-{
-    jint ret;
-    int property = (int)prop;
-    char value[PROPERTY_VALUE_MAX] = {'\0'};
-
-    if (property == FMWAN_RATCONF) {
-        get_property(FM_PROP_WAN_RATCONF, value);
-    } else if (property == FMBTWLAN_LPFENABLER) {
-        get_property(FM_PROP_BTWLAN_LPFENABLER, value);
-    } else {
-        ALOGE("%s: invalid get property prop = %d\n", __func__, property);
-    }
-
-    ret = atoi(value);
-    ALOGI("%d:: ret  = %d",property, ret);
-    return ret;
-}
-
 static jint android_hardware_fmradio_FmReceiverJNI_enableSoftMuteNative
  (JNIEnv * env, jobject thiz, jint fd, jint val)
 {
@@ -950,27 +895,6 @@
     return err;
 }
 
-static jstring android_hardware_fmradio_FmReceiverJNI_getSocNameNative
- (JNIEnv* env)
-{
-    ALOGI("%s, bt_configstore_intf: %p isSocNameAvailable: %d",
-        __FUNCTION__, bt_configstore_intf, isSocNameAvailable);
-
-    if (bt_configstore_intf != NULL && isSocNameAvailable == false) {
-       std::vector<vendor_property_t> vPropList;
-
-       bt_configstore_intf->get_vendor_properties(BT_PROP_SOC_TYPE, vPropList);
-       for (auto&& vendorProp : vPropList) {
-          if (vendorProp.type == BT_PROP_SOC_TYPE) {
-            strlcpy(soc_name, vendorProp.value, sizeof(soc_name));
-            isSocNameAvailable = true;
-            ALOGI("%s:: soc_name = %s",__func__, soc_name);
-          }
-       }
-    }
-    return env->NewStringUTF(soc_name);
-}
-
 static void classInitNative(JNIEnv* env, jclass clazz) {
 
     ALOGI("ClassInit native called \n");
@@ -1092,68 +1016,18 @@
              (void*)android_hardware_fmradio_FmReceiverJNI_enableSlimbusNative},
         { "enableSoftMute", "(II)I",
              (void*)android_hardware_fmradio_FmReceiverJNI_enableSoftMuteNative},
-        {"getSocNameNative", "()Ljava/lang/String;",
-             (void*) android_hardware_fmradio_FmReceiverJNI_getSocNameNative},
-        {"getFmStatsPropNative", "()Z",
-             (void*) android_hardware_fmradio_FmReceiverJNI_getFmStatsPropNative},
-        { "getFmCoexPropNative", "(II)I",
-            (void*)android_hardware_fmradio_FmReceiverJNI_getFmCoexPropNative},
 };
 
 int register_android_hardware_fm_fmradio(JNIEnv* env)
 {
-        ALOGI("%s, bt_configstore_intf", __FUNCTION__, bt_configstore_intf);
-        if (bt_configstore_intf == NULL) {
-          load_bt_configstore_lib();
-        }
-
         return jniRegisterNativeMethods(env, "qcom/fmradio/FmReceiverJNI", gMethods, NELEM(gMethods));
 }
 
 int deregister_android_hardware_fm_fmradio(JNIEnv* env)
 {
-        if (bt_configstore_lib_handle) {
-            dlclose(bt_configstore_lib_handle);
-            bt_configstore_lib_handle = NULL;
-            bt_configstore_intf = NULL;
-        }
         return 0;
 }
 
-int load_bt_configstore_lib() {
-    const char* sym = BT_CONFIG_STORE_INTERFACE_STRING;
-
-    bt_configstore_lib_handle = dlopen("libbtconfigstore.so", RTLD_NOW);
-    if (!bt_configstore_lib_handle) {
-        const char* err_str = dlerror();
-        ALOGE("%s:: failed to load Bt Config store library, error= %s",
-            __func__, (err_str) ? err_str : "error unknown");
-        goto error;
-    }
-
-    // Get the address of the bt_configstore_interface_t.
-    bt_configstore_intf = (bt_configstore_interface_t*)dlsym(bt_configstore_lib_handle, sym);
-    if (!bt_configstore_intf) {
-        ALOGE("%s:: failed to load symbol from bt config store library = %s",
-            __func__, sym);
-        goto error;
-    }
-
-    // Success.
-    ALOGI("%s::  loaded HAL: bt_configstore_interface_t = %p , bt_configstore_lib_handle= %p",
-        __func__, bt_configstore_intf, bt_configstore_lib_handle);
-    return 0;
-
-  error:
-    if (bt_configstore_lib_handle) {
-      dlclose(bt_configstore_lib_handle);
-      bt_configstore_lib_handle = NULL;
-      bt_configstore_intf = NULL;
-    }
-
-    return -EINVAL;
-}
-
 } // end namespace
 
 jint JNI_OnLoad(JavaVM *jvm, void *reserved)
diff --git a/qcom/fmradio/FmReceiver.java b/qcom/fmradio/FmReceiver.java
index 48e4d11..814e7a3 100644
--- a/qcom/fmradio/FmReceiver.java
+++ b/qcom/fmradio/FmReceiver.java
@@ -359,7 +359,7 @@
    }
 
    public static boolean isRomeChip() {
-       String chip = FmReceiverJNI.getSocNameNative();
+       String chip = getSocName();
        if (chip.equals("rome"))
            return true;
        else
@@ -2898,15 +2898,22 @@
        mControl.enableSoftMute(sFd, enable);
    }
 
-   public String getSocName() {
-     return FmReceiverJNI.getSocNameNative();
+   public static String getSocName() {
+       return SystemProperties.get("vendor.bluetooth.soc");
    }
 
    public boolean getFmStatsProp() {
-     return FmReceiverJNI.getFmStatsPropNative();
+       return SystemProperties.getBoolean("persist.fm.stats", false);
    }
 
    public int getFmWanWlanCoexProp(int property) {
-     return FmReceiverJNI.getFmCoexPropNative(sFd, property);
+       switch (property) {
+           case WAN_RATCONF:
+               return SystemProperties.getInt("persist.fm_wan.ratconf", 0);
+           case BTWLAN_LPFENABLER:
+               return SystemProperties.getInt("persist.btwlan.lpfenabler", 0);
+           default:
+              return 0;
+       }
    }
 }
diff --git a/qcom/fmradio/FmReceiverJNI.java b/qcom/fmradio/FmReceiverJNI.java
index 298ed07..a1f82f2 100644
--- a/qcom/fmradio/FmReceiverJNI.java
+++ b/qcom/fmradio/FmReceiverJNI.java
@@ -470,7 +470,4 @@
     static native int setSpurDataNative(int fd, short  buff[], int len);
     static native int enableSlimbus(int fd, int val);
     static native int enableSoftMute(int fd, int val);
-    static native String getSocNameNative();
-    static native boolean getFmStatsPropNative();
-    static native int getFmCoexPropNative(int fd, int property);
 }