From b0268561a45eb18bceac0397f6e7b3f1d1d3a2b6 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Andr=C3=A9=20Vitor?= Date: Fri, 15 Jan 2016 19:28:50 -0300 Subject: [PATCH] android: Update device class info Android-x86 devices are not phone. --- android/bluetooth.c | 43 ++++++++++++++++++++++++++++++++++++++----- 1 file changed, 38 insertions(+), 5 deletions(-) diff --git a/android/bluetooth.c b/android/bluetooth.c index 51a31fec7..e24f4e2ae 100644 --- a/android/bluetooth.c +++ b/android/bluetooth.c @@ -60,9 +60,6 @@ #define DEVICES_FILE ANDROID_STORAGEDIR"/devices" #define CACHE_FILE ANDROID_STORAGEDIR"/cache" -#define ADAPTER_MAJOR_CLASS 0x02 /* Phone */ -#define ADAPTER_MINOR_CLASS 0x03 /* Smartphone */ - /* Default to DisplayYesNo */ #define DEFAULT_IO_CAPABILITY 0x01 @@ -3275,6 +3272,42 @@ static void load_devices_info(bt_bluetooth_ready cb) static void set_adapter_class(void) { struct mgmt_cp_set_dev_class cp; + char *contents; + int type; + uint8_t major_class = 0x01; // Computer + uint8_t minor_class = 0x00; // Uncategorized + + if (g_file_get_contents("/sys/class/dmi/id/chassis_type", + &contents, NULL, NULL)) { + + type = atoi(contents); + + if (type > 0 || type < 0x1D) { + g_free(contents); + + switch (type) { + case 0x3: + case 0x4: + case 0x6: + case 0x7: + minor_class = 0x01; // Desktop + break; + case 0x8: + case 0x9: + case 0xA: + case 0xE: + minor_class = 0x03; // Laptop + break; + case 0xB: + minor_class = 0x04; // Tablet + break; + case 0x11: + case 0x1C: + minor_class = 0x02; // Server + break; + } + } + } memset(&cp, 0, sizeof(cp)); @@ -3282,8 +3315,8 @@ static void set_adapter_class(void) * 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; + cp.major = major_class & 0x1f; + cp.minor = minor_class << 2; if (mgmt_send(mgmt_if, MGMT_OP_SET_DEV_CLASS, adapter.index, sizeof(cp), &cp, NULL, NULL, NULL) > 0) -- 2.11.0