summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRockchip2015-02-28 13:48:02 +0800
committerRockchip2015-02-28 13:48:02 +0800
commitdbd4096880391b804da9d85b344afa88bcf34013 (patch)
treeca49a1bac30a0bf9e2b62611aa1d1fd277e67000
parent0e99a4f23e92f2ebc61ed0bca4b33a4f043f030a (diff)
support different wifi bt chip auto compatible
like auto recognize rtl8188eu, ap6210, esp8089 in android
-rwxr-xr-x[-rw-r--r--]jni/com_android_bluetooth_btservice_AdapterService.cpp39
1 files changed, 38 insertions, 1 deletions
diff --git a/jni/com_android_bluetooth_btservice_AdapterService.cpp b/jni/com_android_bluetooth_btservice_AdapterService.cpp
index ea765b5..861a235 100644..100755
--- a/jni/com_android_bluetooth_btservice_AdapterService.cpp
+++ b/jni/com_android_bluetooth_btservice_AdapterService.cpp
@@ -480,6 +480,35 @@ static bt_callbacks_t sBluetoothCallbacks = {
energy_info_recv_callback
};
+#define WIFI_CHIP_TYPE_PATH "/sys/class/rkwifi/chip"
+static int check_wifi_chip_type_string(char *type)
+{
+ int wififd, ret = 0;
+ char buf[64];
+
+ wififd = open(WIFI_CHIP_TYPE_PATH, O_RDONLY);
+ if( wififd < 0 ){
+ ALOGD("Can't open %s, errno = %d", WIFI_CHIP_TYPE_PATH, errno);
+ ret = -1;
+ goto fail_exit;
+ }
+ memset(buf, 0, 64);
+
+ if( 0 == read(wififd, buf, 10) ){
+ ALOGD("read %s failed", WIFI_CHIP_TYPE_PATH);
+ close(wififd);
+ ret = -1;
+ goto fail_exit;
+ }
+ close(wififd);
+
+ strcpy(type, buf);
+ ALOGD("%s: %s", __func__, type);
+
+fail_exit:
+ return ret;
+}
+
// The callback to call when the wake alarm fires.
static alarm_cb sAlarmCallback;
@@ -720,7 +749,15 @@ static void classInitNative(JNIEnv* env, jclass clazz) {
const char *id = (strcmp(value, "1")? BT_STACK_MODULE_ID : BT_STACK_TEST_MODULE_ID);
- err = hw_get_module(id, (hw_module_t const**)&module);
+ char type[64];
+ check_wifi_chip_type_string(type);
+ if (!strncmp(type, "RTL", 3)) {
+ ALOGD("%s, load %s.default.so", __func__, BT_STACK_RTK_MODULE_ID);
+ err = hw_get_module(BT_STACK_RTK_MODULE_ID, (hw_module_t const**)&module);
+ } else {
+ ALOGD("%s, load %s.default.so", __func__, id);
+ err = hw_get_module(id, (hw_module_t const**)&module);
+ }
if (err == 0) {
hw_device_t* abstraction;