Diff between a0edc4f8b749bcb266f4af7257325e6bfd718da7 and bd3f985532ba2a6152c403db2ec7e599676e3cc5

Changed Files

File Additions Deletions Status
android/bluetooth.c +31 -0 modified
android/bluetooth.h +2 -0 modified

Full Patch

diff --git a/android/bluetooth.c b/android/bluetooth.c
index aaba585..a4a77c8 100644
--- a/android/bluetooth.c
+++ b/android/bluetooth.c
@@ -1496,6 +1496,37 @@ bool bt_kernel_conn_control(void)
 	return kernel_conn_control;
 }
 
+bool bt_auto_connect_add(const bdaddr_t *addr)
+{
+	struct mgmt_cp_add_device cp;
+	struct device *dev;
+
+	if (!kernel_conn_control)
+		return false;
+
+	dev = find_device(addr);
+	if (!dev)
+		return false;
+
+	if (dev->bdaddr_type == BDADDR_BREDR) {
+		DBG("auto-connection feature is not available for BR/EDR");
+		return false;
+	}
+
+	memset(&cp, 0, sizeof(cp));
+	bacpy(&cp.addr.bdaddr, addr);
+	cp.addr.type = dev->bdaddr_type;
+	cp.action = 0x02;
+
+	if (mgmt_send(mgmt_if, MGMT_OP_ADD_DEVICE, adapter.index, sizeof(cp),
+						&cp, NULL, NULL, NULL) > 0)
+		return true;
+
+	error("Failed to add device");
+
+	return false;
+}
+
 static bool rssi_above_threshold(int old, int new)
 {
 	/* only 8 dBm or more */
diff --git a/android/bluetooth.h b/android/bluetooth.h
index adad6c4..4a7063d 100644
--- a/android/bluetooth.h
+++ b/android/bluetooth.h
@@ -81,3 +81,5 @@ uint16_t bt_get_gatt_ccc(const bdaddr_t *addr);
 const bdaddr_t *bt_get_id_addr(const bdaddr_t *addr, uint8_t *type);
 
 bool bt_kernel_conn_control(void);
+
+bool bt_auto_connect_add(const bdaddr_t *addr);