diff options
author | jeonghoon.lim <jeonghoon.lim@lge.com> | 2012-07-03 11:52:18 -0700 |
---|---|---|
committer | Brian Muramatsu <btmura@google.com> | 2012-07-16 17:42:25 -0700 |
commit | 3a293d2850d4530054cdcc78a4a747d6c4f0fff1 (patch) | |
tree | 2fdc586d2e14b27221379f862ccc4469b0a4ead8 | |
parent | f893f324710cde1cc5e0f551832692610ee4513c (diff) | |
download | bluetooth-3a293d2850d4530054cdcc78a4a747d6c4f0fff1.tar.gz |
bluetooth: bring up
refactoring the code for other bluetooth module which don't use rfkill and hciattach service
Change-Id: Ide420540b398bcc63e19bb7ab0cc0d3f94d5987a
-rw-r--r-- | bluedroid/Android.mk | 5 | ||||
-rw-r--r-- | bluedroid/bluetooth.c | 31 |
2 files changed, 33 insertions, 3 deletions
diff --git a/bluedroid/Android.mk b/bluedroid/Android.mk index 17df49b..c0ccd4f 100644 --- a/bluedroid/Android.mk +++ b/bluedroid/Android.mk @@ -6,6 +6,11 @@ LOCAL_PATH:= $(call my-dir) include $(CLEAR_VARS) +ifeq ($(BOARD_BLUETOOTH_DOES_NOT_USE_RFKILL),true) + LOCAL_CFLAGS := $(LOCAL_CFLAGS) -DBLUETOOTH_DOES_NOT_USE_RFKILL + LOCAL_CFLAGS := $(LOCAL_CFLAGS) -DBLUETOOTH_HCIATTACH_USING_PROPERTY +endif + LOCAL_SRC_FILES := \ bluetooth.c diff --git a/bluedroid/bluetooth.c b/bluedroid/bluetooth.c index ee104c9..b265fef 100644 --- a/bluedroid/bluetooth.c +++ b/bluedroid/bluetooth.c @@ -45,7 +45,7 @@ static int rfkill_id = -1; static char *rfkill_state_path = NULL; - +#ifndef BLUETOOTH_DOES_NOT_USE_RFKILL static int init_rfkill() { char path[64]; char buf[16]; @@ -136,6 +136,7 @@ out: if (fd >= 0) close(fd); return ret; } +#endif static inline int create_hci_sock() { int sk = socket(AF_BLUETOOTH, SOCK_RAW, BTPROTO_HCI); @@ -153,12 +154,22 @@ int bt_enable() { int hci_sock = -1; int attempt; +#ifndef BLUETOOTH_DOES_NOT_USE_RFKILL if (set_bluetooth_power(1) < 0) goto out; +#endif +#ifndef BLUETOOTH_HCIATTACH_USING_PROPERTY ALOGI("Starting hciattach daemon"); - if (property_set("ctl.start", "hciattach") < 0) { + if (property_set("ctl.start", "hciattach") < 0) +#else + ALOGI("Enable hci tranport"); + if (property_set("bluetooth.hciattach", "true") < 0) +#endif + { ALOGE("Failed to start hciattach"); +#ifndef BLUETOOTH_DOES_NOT_USE_RFKILL set_bluetooth_power(0); +#endif goto out; } @@ -187,14 +198,18 @@ int bt_enable() { if (property_set("ctl.stop", "hciattach") < 0) { ALOGE("Error stopping hciattach"); } +#ifndef BLUETOOTH_DOES_NOT_USE_RFKILL set_bluetooth_power(0); +#endif goto out; } ALOGI("Starting bluetoothd deamon"); if (property_set("ctl.start", "bluetoothd") < 0) { ALOGE("Failed to start bluetoothd"); +#ifndef BLUETOOTH_DOES_NOT_USE_RFKILL set_bluetooth_power(0); +#endif goto out; } @@ -222,15 +237,23 @@ int bt_disable() { if (hci_sock < 0) goto out; ioctl(hci_sock, HCIDEVDOWN, HCI_DEV_ID); +#ifndef BLUETOOTH_HCIATTACH_USING_PROPERTY ALOGI("Stopping hciattach deamon"); - if (property_set("ctl.stop", "hciattach") < 0) { + if (property_set("ctl.stop", "hciattach") < 0) +#else + ALOGI("Disable hci tranport"); + if (property_set("bluetooth.hciattach", "false") < 0) +#endif + { ALOGE("Error stopping hciattach"); goto out; } +#ifndef BLUETOOTH_DOES_NOT_USE_RFKILL if (set_bluetooth_power(0) < 0) { goto out; } +#endif ret = 0; out: @@ -246,9 +269,11 @@ int bt_is_enabled() { struct hci_dev_info dev_info; +#ifndef BLUETOOTH_DOES_NOT_USE_RFKILL // Check power first ret = check_bluetooth_power(); if (ret == -1 || ret == 0) goto out; +#endif ret = -1; |