[OAL/HAL]Add APIs to enable authentication notifications 14/161914/1
authorAtul Rai <a.rai@samsung.com>
Tue, 28 Nov 2017 07:13:19 +0000 (12:43 +0530)
committerAtul Rai <a.rai@samsung.com>
Tue, 28 Nov 2017 07:13:19 +0000 (12:43 +0530)
Change-Id: Id9cfc36d8fb74722c2ed626cf79538d40e5af28d
Signed-off-by: Atul Rai <a.rai@samsung.com>
bt-oal/bluez_hal/src/bt-hal-agent.c
bt-oal/bluez_hal/src/bt-hal-agent.h
bt-oal/bluez_hal/src/bt-hal-bluetooth.c
bt-oal/hardware/bluetooth.h
bt-oal/include/oal-device-mgr.h
bt-oal/oal-device-mgr.c

index 6f034f7..9608e49 100644 (file)
 #define BT_HAL_MAX_EVENT_STR_LENGTH 50
 
 static void *adapter_agent = NULL;
 #define BT_HAL_MAX_EVENT_STR_LENGTH 50
 
 static void *adapter_agent = NULL;
+static gboolean passkey_display_notification = FALSE;
+static gboolean passkey_confirm_notification = FALSE;
+static gboolean passkey_notification = FALSE;
+static gboolean pincode_notification = FALSE;
 
 /* Forward delcaration */
 static void __bt_hal_send_pin_request_event(const gchar *address, const gchar *name,
 
 /* Forward delcaration */
 static void __bt_hal_send_pin_request_event(const gchar *address, const gchar *name,
@@ -210,6 +214,30 @@ void* _bt_hal_get_adapter_agent(void)
        return adapter_agent;
 }
 
        return adapter_agent;
 }
 
+void _bt_hal_enable_gap_auth_notifications(unsigned int type, gboolean enable)
+{
+       INFO("type: %d, enable: %d", type, enable);
+
+       switch (type) {
+       case BT_PASSKEY_CONFIRMATION:
+               /* Note: Currently not used for notification sending, should be used when required */
+               passkey_confirm_notification = enable;
+               break;
+       case BT_PASSKEY_DISPLAY:
+               passkey_display_notification = enable;
+               break;
+       case BT_PASSKEY_ENTRY:
+               /* Note: Currently not used for notification sending, should be used when required */
+               passkey_notification = enable;
+               break;
+       case BT_PINCODE_ENTRY:
+               pincode_notification = enable;
+               break;
+       default:
+               ERR("Unknown type: %d", type);
+       }
+}
+
 static void __bt_hal_send_authorize_request_event(const gchar *address, const char *uuid)
 {
        struct hal_ev_authorize_request ev;
 static void __bt_hal_send_authorize_request_event(const gchar *address, const char *uuid)
 {
        struct hal_ev_authorize_request ev;
@@ -410,14 +438,17 @@ static gboolean __bt_hal_pincode_request(GapAgentPrivate *agent, GDBusProxy *dev
                        headed_plugin_info->headed_plugin->bt_launch_system_popup(
                                        BT_HAL_AGENT_EVENT_KEYBOARD_PASSKEY_REQUEST,
                                        name, auth_info, str_passkey, NULL, _gap_agent_get_path(agent));
                        headed_plugin_info->headed_plugin->bt_launch_system_popup(
                                        BT_HAL_AGENT_EVENT_KEYBOARD_PASSKEY_REQUEST,
                                        name, auth_info, str_passkey, NULL, _gap_agent_get_path(agent));
-               } else if (!__bt_hal_device_is_auto_response(device_class, address, name)) {
+               } else if (__bt_hal_device_is_auto_response(device_class, address, name)) {
+                       DBG("Device is of Type Auto response, send event to HAL");
+                       __bt_hal_send_pin_request_event(address, name, device_class);
+               } else if (pincode_notification) {
+                       DBG("pincode_notification is enabled, send event to HAL");
+                       __bt_hal_send_pin_request_event(address, name, device_class);
+               } else {
                        DBG("Device is not of Auto response class, Show PIN Entry");
                        headed_plugin_info->headed_plugin->bt_launch_system_popup(
                                        BT_HAL_AGENT_EVENT_PIN_REQUEST, name, auth_info,
                                        NULL, NULL, _gap_agent_get_path(agent));
                        DBG("Device is not of Auto response class, Show PIN Entry");
                        headed_plugin_info->headed_plugin->bt_launch_system_popup(
                                        BT_HAL_AGENT_EVENT_PIN_REQUEST, name, auth_info,
                                        NULL, NULL, _gap_agent_get_path(agent));
-               } else {
-                       DBG("Device is of Type Auto response, send event to HAL");
-                       __bt_hal_send_pin_request_event(address, name, device_class);
                }
        } else {
                INFO("Plugin Headed not Enabled");
                }
        } else {
                INFO("Plugin Headed not Enabled");
@@ -518,7 +549,12 @@ static gboolean __bt_hal_display_request(GapAgentPrivate *agent, GDBusProxy *dev
        __bt_hal_get_auth_info(reply, (char *)auth_info);
 
        DBG("KEYBOARD_PASSKEY_REQUEST");
        __bt_hal_get_auth_info(reply, (char *)auth_info);
 
        DBG("KEYBOARD_PASSKEY_REQUEST");
-       if (headed_plugin_info->plugin_headed_enabled) {
+
+       if (passkey_display_notification) {
+               DBG("passkey_display_notification is enabled, send event to HAL");
+               __bt_hal_send_ssp_request_events(address, name, passkey, device_class,
+                               BT_SSP_VARIANT_PASSKEY_NOTIFICATION);
+       } else if (headed_plugin_info->plugin_headed_enabled) {
                INFO("Plugin Headed Enabled");
                headed_plugin_info->headed_plugin->bt_launch_system_popup(BT_HAL_AGENT_EVENT_KEYBOARD_PASSKEY_REQUEST, name,
                                auth_info, str_passkey, NULL, _gap_agent_get_path(agent));
                INFO("Plugin Headed Enabled");
                headed_plugin_info->headed_plugin->bt_launch_system_popup(BT_HAL_AGENT_EVENT_KEYBOARD_PASSKEY_REQUEST, name,
                                auth_info, str_passkey, NULL, _gap_agent_get_path(agent));
index 170eb35..ed1f421 100644 (file)
@@ -64,4 +64,6 @@ void _bt_hal_initialize_adapter_agent(void);
 
 void _bt_hal_destroy_adapter_agent(void);
 
 
 void _bt_hal_destroy_adapter_agent(void);
 
+void _bt_hal_enable_gap_auth_notifications(unsigned int type, gboolean enable);
+
 #endif //__BT_HAL_AGENT__
 #endif //__BT_HAL_AGENT__
index c70ce77..b8197e4 100644 (file)
@@ -43,6 +43,7 @@
 #include <bt-hal-gatt.h>
 #ifdef TIZEN_BT_HAL
 #include <bt-hal-adapter-le.h>
 #include <bt-hal-gatt.h>
 #ifdef TIZEN_BT_HAL
 #include <bt-hal-adapter-le.h>
+#include <bt-hal-agent.h>
 #endif
 
 #define enum_prop_to_hal(prop, hal_prop, type) do { \
 #endif
 
 #define enum_prop_to_hal(prop, hal_prop, type) do { \
@@ -377,6 +378,13 @@ static int enable_rssi_monitoring(bt_bdaddr_t *bd_addr, uint32_t conn_link_type,
        return _bt_hal_device_enable_rssi_monitoring(bd_addr, conn_link_type,
                        low_threshold, in_range_threshold, high_threshold);
 }
        return _bt_hal_device_enable_rssi_monitoring(bd_addr, conn_link_type,
                        low_threshold, in_range_threshold, high_threshold);
 }
+
+static int enable_gap_auth_notifications(uint32_t type, uint8_t enable)
+{
+       DBG("");
+       _bt_hal_enable_gap_auth_notifications(type, ((enable == 0) ? FALSE : TRUE));
+       return BT_STATUS_SUCCESS;
+}
 #endif
 
 static const bt_interface_t bluetooth_if = {
 #endif
 
 static const bt_interface_t bluetooth_if = {
@@ -434,6 +442,7 @@ static const bt_interface_t bluetooth_if = {
        .get_trusted_profile = get_trusted_profile,
        .enable_rssi_monitoring = enable_rssi_monitoring,
        .get_connected_link_rssi_strength = get_connected_link_rssi_strength,
        .get_trusted_profile = get_trusted_profile,
        .enable_rssi_monitoring = enable_rssi_monitoring,
        .get_connected_link_rssi_strength = get_connected_link_rssi_strength,
+       .enable_gap_auth_notifications = enable_gap_auth_notifications,
 #endif
 };
 
 #endif
 };
 
index 1ed02f7..40cd968 100644 (file)
@@ -426,6 +426,14 @@ typedef enum {
        BT_TRUSTED_PROFILE_A2DP,
        BT_TRUSTED_PROFILE_ALL = 0xFFFFFFFF,
 } bt_trusted_profile_t;
        BT_TRUSTED_PROFILE_A2DP,
        BT_TRUSTED_PROFILE_ALL = 0xFFFFFFFF,
 } bt_trusted_profile_t;
+
+/** Bluetooth Bonding Authentication Notifications */
+typedef enum {
+    BT_PASSKEY_CONFIRMATION = 1,
+    BT_PASSKEY_DISPLAY,
+    BT_PASSKEY_ENTRY,
+    BT_PINCODE_ENTRY,
+} bt_gap_auth_variant_t;
 #endif
 
 /** Bluetooth Interface callbacks */
 #endif
 
 /** Bluetooth Interface callbacks */
@@ -804,6 +812,13 @@ typedef struct {
      */
     int (*enable_rssi_monitoring)(bt_bdaddr_t *bd_addr, uint32_t conn_link_type,
                    int low_threshold, int in_range_threshold, int high_threshold);
      */
     int (*enable_rssi_monitoring)(bt_bdaddr_t *bd_addr, uint32_t conn_link_type,
                    int low_threshold, int in_range_threshold, int high_threshold);
+    /*
+     * Enable/Disable GAP authentication notification to application
+     * enable == 0/1 -> Enable/Disable notification sending
+     * type == value from bt_gap_auth_variant_t
+     */
+    int (*enable_gap_auth_notifications)(uint32_t type, uint8_t enable);
+
 #endif
 } bt_interface_t;
 
 #endif
 } bt_interface_t;
 
index 8a3370c..cf493ad 100755 (executable)
@@ -66,6 +66,18 @@ typedef enum {
 } oal_trusted_profile_e;
 
 /**
 } oal_trusted_profile_e;
 
 /**
+ * @brief GAP authentication types
+ *
+ * @see  device_enable_gap_auth_notifications
+ */
+typedef enum {
+       OAL_PASSKEY_CONFIRMATION = 1,
+       OAL_PASSKEY_DISPLAY,
+       OAL_PASSKEY_ENTRY,
+       OAL_PINCODE_ENTRY,
+} oal_gap_auth_type_e;
+
+/**
  * @brief Request remote device attributes
  *
  * @details Attibutes such as name, vidpid, bond state etc are requested. remote_device_t is provided
  * @brief Request remote device attributes
  *
  * @details Attibutes such as name, vidpid, bond state etc are requested. remote_device_t is provided
@@ -397,6 +409,22 @@ oal_status_t device_get_connected_link_rssi_strength(bt_address_t *addr, unsigne
  */
 oal_status_t device_enable_rssi_monitoring(bt_address_t *addr, unsigned int link_type,
                int low_threshold, int in_range_threshold, int high_threshold);
  */
 oal_status_t device_enable_rssi_monitoring(bt_address_t *addr, unsigned int link_type,
                int low_threshold, int in_range_threshold, int high_threshold);
+
+/**
+ * @brief Enable/Disable GAP authentication requests to be received from stack
+ *
+ * @details This API is used to enable/disable GAP authentication requests to be received from stack
+ *
+ * @param[in] type: GAP authentication types oal_gap_auth_type_e
+ * @param[in] enable: TRUE/FALSE
+ *
+ * @return OAL_STATUS_SUCCESS on success, otherwise a non-zero error value.
+ * @retval #OAL_STATUS_SUCCESS Successful
+ *
+ * @pre Adapter must be enabled with adapter_enable() followed by OAL_EVENT_ADAPTER_ENABLED
+ */
+oal_status_t device_enable_gap_auth_notifications(oal_gap_auth_type_e type, gboolean enable);
+
 #ifdef __cplusplus
 }
 #endif /* __cplusplus */
 #ifdef __cplusplus
 }
 #endif /* __cplusplus */
index 0f4e19c..b738711 100755 (executable)
@@ -524,6 +524,29 @@ oal_status_t device_get_connected_link_rssi_strength(bt_address_t *addr, unsigne
 #endif
 }
 
 #endif
 }
 
+oal_status_t device_enable_gap_auth_notifications(oal_gap_auth_type_e type, gboolean enable)
+{
+       int res;
+
+       CHECK_OAL_INITIALIZED();
+
+       API_TRACE("type: [%d], enable: %d", type, enable);
+
+#ifdef TIZEN_BT_HAL
+       res = blued_api->enable_gap_auth_notifications(type, (enable ? 1 : 0));
+       if (res != BT_STATUS_SUCCESS) {
+               BT_ERR("enable_gap_auth_notifications error: [%s]", status2string(res));
+               return convert_to_oal_status(res);
+       }
+
+       return OAL_STATUS_SUCCESS;
+#else
+       BT_ERR("Not supported");
+       res = OAL_STATUS_NOT_SUPPORT;
+       return res;
+#endif
+}
+
 void cb_device_properties(bt_status_t status, bt_bdaddr_t *bd_addr,
                int num_properties, bt_property_t *properties)
 {
 void cb_device_properties(bt_status_t status, bt_bdaddr_t *bd_addr,
                int num_properties, bt_property_t *properties)
 {