Handle the pin code request in case of peripheral 02/220802/2
authorDoHyun Pyun <dh79.pyun@samsung.com>
Mon, 23 Dec 2019 10:13:51 +0000 (19:13 +0900)
committerDoHyun Pyun <dh79.pyun@samsung.com>
Mon, 23 Dec 2019 10:17:11 +0000 (19:17 +0900)
Change-Id: I002e92e7882f245d25b75ae9e64668d2ee5e19b6
Signed-off-by: DoHyun Pyun <dh79.pyun@samsung.com>
bt-oal/bluez_hal/src/bt-hal-adapter-dbus-handler.c
bt-oal/bluez_hal/src/bt-hal-adapter-dbus-handler.h
bt-oal/bluez_hal/src/bt-hal-agent.c

index e46afbb..f14ca79 100644 (file)
@@ -926,6 +926,50 @@ int _bt_hal_dbus_get_discovery_timeout(void)
        return BT_STATUS_SUCCESS;
 }
 
+int _bt_hal_dbus_get_adapter_class(unsigned int *adapter_class)
+{
+       GDBusProxy *proxy;
+       GVariant *result;
+       GVariant *temp;
+       GError *error = NULL;
+       DBG("+");
+
+       proxy = _bt_hal_get_adapter_properties_proxy();
+       if (!proxy) {
+               DBG("Adapter Properties proxy get failed!!!");
+               return BT_STATUS_FAIL;
+       }
+
+       result = g_dbus_proxy_call_sync(proxy,
+                       "Get",
+                       g_variant_new("(ss)", BT_HAL_ADAPTER_INTERFACE,
+                               "Class"),
+                       G_DBUS_CALL_FLAGS_NONE,
+                       -1,
+                       NULL,
+                       &error);
+
+       if (!result) {
+               if (error != NULL) {
+                       ERR("Failed to get class (Error: %s)", error->message);
+                       g_clear_error(&error);
+               } else
+                       ERR("Failed to get class");
+               return BT_STATUS_FAIL;
+       }
+
+
+       g_variant_get(result, "(v)", &temp);
+       *adapter_class = g_variant_get_uint32(temp);
+       DBG("Class value: [0x%06x]", *adapter_class);
+
+       g_variant_unref(result);
+       g_variant_unref(temp);
+
+       DBG("-");
+       return BT_STATUS_SUCCESS;
+}
+
 /* Get Discoverable Mode API and callback */
 static gboolean __bt_adapter_scan_mode_cb(gpointer user_data)
 {
index ee7ac3f..d5657c1 100644 (file)
@@ -66,6 +66,8 @@ int _bt_hal_dbus_get_adapter_properties(void);
 
 int _bt_hal_dbus_set_adapter_property(const bt_property_t *property);
 
+int _bt_hal_dbus_get_adapter_class(unsigned int *adapter_class);
+
 int _bt_hal_enable_core(void);
 
 #ifdef __cplusplus
index d84c596..09f395e 100644 (file)
@@ -1101,6 +1101,7 @@ static gboolean __bt_hal_device_is_auto_response(uint32_t dev_class,
 {
        gboolean is_headset = FALSE;
        gboolean is_mouse = FALSE;
+       unsigned int adapter_class = 0;
        char lap_address[BT_HAL_LOWER_ADDRESS_LENGTH];
 
        DBG("bt_agent_is_headset_class, %d +", dev_class);
@@ -1108,6 +1109,14 @@ static gboolean __bt_hal_device_is_auto_response(uint32_t dev_class,
        if (address == NULL)
                return FALSE;
 
+       _bt_hal_dbus_get_adapter_class(&adapter_class);
+
+       if (((adapter_class & 0x1f00) >> 8) == 0x05)
+       {
+               DBG("Adapter is Peripheral, do not response automatically");
+               return FALSE;
+       }
+
        switch ((dev_class & 0x1f00) >> 8) {
        case 0x04:
                switch ((dev_class & 0xfc) >> 2) {