Diff between 4c0e55c4df85e304179b76643448002301aae39e and b6df31f1c89149ac2a008421168acf291ba181e8

Changed Files

File Additions Deletions Status
android/bluetooth.c +25 -0 modified

Full Patch

diff --git a/android/bluetooth.c b/android/bluetooth.c
index 6aad9b5..a43eecb 100644
--- a/android/bluetooth.c
+++ b/android/bluetooth.c
@@ -58,6 +58,9 @@
 #define DEVICE_ID_VENDOR	0x1d6b	/* Linux Foundation */
 #define DEVICE_ID_PRODUCT	0x0247	/* BlueZ for Android */
 
+#define ADAPTER_MAJOR_CLASS 0x02 /* Phone */
+#define ADAPTER_MINOR_CLASS 0x03 /* Smartphone */
+
 /* Default to DisplayYesNo */
 #define DEFAULT_IO_CAPABILITY 0x01
 
@@ -1703,6 +1706,26 @@ static void load_devices_info(bt_bluetooth_ready cb)
 	g_key_file_free(key_file);
 }
 
+static void set_adapter_class(void)
+{
+	struct mgmt_cp_set_dev_class cp;
+
+	memset(&cp, 0, sizeof(cp));
+
+	/*
+	 * kernel assign the major and minor numbers straight to dev_class[0]
+	 * and dev_class[1] without considering the proper bit shifting.
+	 */
+	cp.major = ADAPTER_MAJOR_CLASS & 0x1f;
+	cp.minor = ADAPTER_MINOR_CLASS << 2;
+
+	if (mgmt_send(mgmt_if, MGMT_OP_SET_DEV_CLASS, adapter.index,
+					sizeof(cp), &cp, NULL, NULL, NULL) > 0)
+		return;
+
+	error("Failed to set class of device");
+}
+
 static void read_info_complete(uint8_t status, uint16_t length,
 					const void *param, void *user_data)
 {
@@ -1747,6 +1770,8 @@ static void read_info_complete(uint8_t status, uint16_t length,
 	if (g_strcmp0(adapter.name, (const char *) rp->name))
 		set_adapter_name((uint8_t *)adapter.name, strlen(adapter.name));
 
+	set_adapter_class();
+
 	/* Store adapter information */
 	adapter.dev_class = rp->dev_class[0] | (rp->dev_class[1] << 8) |
 						(rp->dev_class[2] << 16);