Bluedroid 4.2 battle

Материал из Toshiba AC100 wiki
Перейти к навигации Перейти к поиску
Версия для печати больше не поддерживается и может содержать ошибки обработки. Обновите закладки браузера и используйте вместо этого функцию печати браузера по умолчанию.

Make 4.2+ Android Bluedroid work with USB HCI

  • Current status
  • Now Android Bluedroid have USB Hci support, thanks to intel, here cm patches:

http://review.cyanogenmod.org/#/c/45535/ http://review.cyanogenmod.org/#/c/45536/ http://review.cyanogenmod.org/#/c/45537/ http://review.cyanogenmod.org/#/c/45538/

    • Bluedroid fail to identify our usb device as bt device
      • Fixed
        • Disable all kernel bluetooth drivers or remove modules on system start (bluetooth.ko & btusb.ko)
        • Compile bluedroid without rfkill support, as without btusb module no rfkill created for usb bt device
# Bluetooth
BOARD_HAVE_BLUETOOTH                    := true
BLUETOOTH_HCI_USE_USB                   := true
BOARD_HAVE_BLUETOOTH_BCM                := true
BOARD_BLUETOOTH_BDROID_BUILDCFG_INCLUDE_DIR := device/toshiba/paz00-common/bluetooth
BOARD_BLUETOOTH_DOES_NOT_USE_RFKILL     := true

' Add system property to disable rfkill for bt_upio, do ween this?

#disable rfkill for upio
ro.rfkilldisabled=1

' Set correct permissions (bluetooth:bluetooth) on devices on /dev/uhid' and /dev/bus/usb/001/004 in ueventd.rc

# for bluetooth nodes
#/dev/uhid                      0660    bluetooth bluetooth

# bt device
/dev/bus/usb/001/004            0660    bluetooth bluetooth

* Bt turns on, can scan devices, pair and even data transfer happen in log, but it seems no uinput device created


Add debug to LibUsb (the one cm-10.1 use)

diff --git a/config.h b/config.h
index e251d64..29aba07 100644
--- a/config.h
+++ b/config.h
@@ -4,7 +4,7 @@
 #define API_EXPORTED __attribute__((visibility("default")))
 
 /* Debug message logging */
-/* #undef ENABLE_DEBUG_LOGGING */
+#define ENABLE_DEBUG_LOGGING 1
 
 /* Message logging */
 #define ENABLE_LOGGING 1
diff --git a/libusb/Android.mk b/libusb/Android.mk
index c437a87..9e0c1c7 100644
--- a/libusb/Android.mk
+++ b/libusb/Android.mk
@@ -14,7 +14,8 @@ LOCAL_C_INCLUDES += \
  external/libusb/libusb/ \
  external/libusb/libusb/os
 
-LOCAL_CFLAGS := -D_SHARED_LIBRARY_
+LOCAL_CFLAGS := -D_SHARED_LIBRARY_ 
+LOCAL_SHARED_LIBRARIES := liblog
 LOCAL_MODULE_TAGS:= optional
 LOCAL_MODULE:= libusb
 include $(BUILD_SHARED_LIBRARY)
diff --git a/libusb/core.c b/libusb/core.c
index 7e4fd24..e22c6ad 100644
--- a/libusb/core.c
+++ b/libusb/core.c
@@ -29,6 +29,10 @@
 #include <sys/types.h>
 #include <unistd.h>
 
+#if defined(__ANDROID__)
+#include <android/log.h>
+#endif
+
 #include "libusb.h"
 #include "libusbi.h"
 
@@ -1538,7 +1542,12 @@ void usbi_log(struct libusb_context *ctx, enum usbi_log_level level,
 {
        va_list args;
        FILE *stream = stdout;
+#if defined(__ANDROID__)
+       int prio;
+#else
        const char *prefix;
+#endif
+
 
 #ifndef ENABLE_DEBUG_LOGGING
        USBI_GET_CONTEXT(ctx);
@@ -1550,6 +1559,29 @@ void usbi_log(struct libusb_context *ctx, enum usbi_log_level level,
                return;
 #endif
 
+#if defined(__ANDROID__)
+       switch (level) {
+               case LOG_LEVEL_INFO:
+                       prio = ANDROID_LOG_INFO;
+                       break;
+               case LOG_LEVEL_WARNING:
+                       prio = ANDROID_LOG_WARN;
+                       break;
+               case LOG_LEVEL_ERROR:
+                       prio = ANDROID_LOG_ERROR;
+                       break;
+               case LOG_LEVEL_DEBUG:
+                       prio = ANDROID_LOG_DEBUG;
+                       break;
+               default:
+                       prio = ANDROID_LOG_UNKNOWN;
+                       break;
+       }
+
+       va_start (args, format);
+       __android_log_vprint(prio, "LibUsb", format, args);
+       va_end (args);
+#else
        switch (level) {
        case LOG_LEVEL_INFO:
                prefix = "info";
@@ -1579,5 +1611,6 @@ void usbi_log(struct libusb_context *ctx, enum usbi_log_level level,
        va_end (args);
 
        fprintf(stream, "\n");
+#endif
 }


Find the reason of ev.u.create.bus mystic

Everybody lucky with BUS_BLUETOOTH but why? Maybe they have some extra patch or config option?

./kernel/toshiba/ac100/samples/uhid/uhid-example.c:124: ev.u.create.bus = BUS_USB;
./external/bluetooth/bluedroid/btif/co/bta_hh_co.c:423:    ev.u.create.bus = BUS_BLUETOOTH;