OSDN Git Service

android: btattach: get options from properties
authorChih-Wei Huang <cwhuang@linux.org.tw>
Wed, 12 Oct 2016 10:10:09 +0000 (18:10 +0800)
committerChih-Wei Huang <cwhuang@linux.org.tw>
Thu, 1 Jun 2017 03:31:26 +0000 (11:31 +0800)
Since Android 7.0 the services can't accept arguments from cmdline.
To workaround it, let btattach get options from android properties.

android/Android.mk
tools/btattach.c

index 35c387a..1a14ac5 100644 (file)
@@ -679,6 +679,7 @@ LOCAL_CFLAGS := $(BLUEZ_COMMON_CFLAGS)
 
 LOCAL_MODULE_TAGS := optional
 LOCAL_MODULE := btattach
+LOCAL_SHARED_LIBRARIES := libcutils
 
 LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/bluez/configure.ac
 
index 5adbc8d..bc467a3 100644 (file)
 #include "src/shared/tty.h"
 #include "src/shared/hci.h"
 
+#ifdef ANDROID
+#include "cutils/properties.h"
+#endif
+
 static int open_serial(const char *path, unsigned int speed, bool flowctl)
 {
        struct termios ti;
@@ -235,6 +239,20 @@ int main(int argc, char *argv[])
        int exit_status, count = 0, proto_id = HCI_UART_H4;
        unsigned int speed = B115200;
 
+#ifdef ANDROID
+       char pval[PROPERTY_VALUE_MAX];
+       if (property_get("hal.bluetooth.uart", pval, NULL) > 0) {
+               bredr_path = strdup(pval);
+       }
+       if (property_get("hal.bluetooth.uart.proto", pval, NULL) > 0) {
+               proto = strdup(pval);
+       }
+       if (property_get("hal.bluetooth.uart.speed", pval, NULL) > 0) {
+               unsigned int s = tty_get_speed(atoi(pval));
+               if (s > 0) speed = s;
+       }
+#endif
+
        for (;;) {
                int opt;