[Adapt] Implement SSP & Legacy Pairing API's in bt-service 64/78764/2
authorAnupam Roy <anupam.r@samsung.com>
Wed, 6 Jul 2016 19:51:33 +0000 (15:51 -0400)
committerPyun DoHyun <dh79.pyun@samsung.com>
Thu, 7 Jul 2016 01:48:37 +0000 (18:48 -0700)
Note: As Syspopup support is by default disabled,
Confirmation request should be replied from BT CAPI
in order to establish bonding with Remote device
(Device with I/O capabilities - e.g Mobile Phone)

Change-Id: If0783c862cef4ba706ff141ebd67656c993a2e2a
Signed-off-by: Anupam Roy <anupam.r@samsung.com>
bt-oal/include/oal-device-mgr.h
bt-oal/oal-device-mgr.c
bt-service-adaptation/services/bt-request-handler.c
bt-service-adaptation/services/device/bt-service-core-device.c
bt-service-adaptation/services/include/bt-service-core-device.h

index 8ec2dc9..193a631 100755 (executable)
@@ -132,7 +132,7 @@ oal_status_t device_destroy_bond(bt_address_t * addr);
  *
  * @see  OAL_EVENT_DEVICE_PIN_REQUEST
  */
-oal_status_t device_accept_pin_request(bt_address_t * addr, char * pin);
+oal_status_t device_accept_pin_request(bt_address_t * addr, const char * pin);
 
 /**
  * @brief Reject PIN request as part of Bonding procedure
index ae6a32e..01322bb 100755 (executable)
@@ -128,7 +128,7 @@ oal_status_t device_destroy_bond(bt_address_t * addr)
        return OAL_STATUS_SUCCESS;
 }
 
-oal_status_t device_accept_pin_request(bt_address_t * addr, char * pin)
+oal_status_t device_accept_pin_request(bt_address_t * addr, const char * pin)
 {
        int res;
        bdstr_t bdstr;
index 661f2dd..6776f73 100644 (file)
@@ -569,6 +569,22 @@ int __bt_bluez_request(int function_name,
                       }
                       break;
        }
+       case BT_PASSKEY_REPLY: {
+                      const char *passkey = NULL;
+                      gboolean authentication_reply = FALSE;
+                      passkey = g_variant_get_data(in_param1);
+                      __bt_service_get_parameters(in_param2,
+                                      &authentication_reply, sizeof(gboolean));
+                      result = _bt_passkey_reply(passkey, authentication_reply);
+                      break;
+       }
+       case BT_PASSKEY_CONFIRMATION_REPLY: {
+                   gboolean confirmation_reply = FALSE;
+                   __bt_service_get_parameters(in_param1,
+                                   &confirmation_reply, sizeof(gboolean));
+                   result = _bt_passkey_confirmation_reply(confirmation_reply);
+                   break;
+       }
        default:
                BT_INFO("UnSupported function [%d]", function_name);
                result = BLUETOOTH_ERROR_NOT_SUPPORT;
@@ -711,6 +727,8 @@ gboolean __bt_service_check_privilege(int function_name,
        case BT_BOND_DEVICE:
        case BT_CANCEL_BONDING:
        case BT_UNBOND_DEVICE:
+       case BT_PASSKEY_CONFIRMATION_REPLY:
+        case BT_PASSKEY_REPLY:
        case BT_SET_ALIAS:
        case BT_SET_AUTHORIZATION:
        case BT_UNSET_AUTHORIZATION:
index 43b733a..e7451aa 100644 (file)
@@ -643,7 +643,7 @@ done:
        BT_DBG("-");
 }
 
-
+/* SSP Pairing event handler */
 static void __bt_device_ssp_passkey_entry_callback(remote_device_t* dev_info)
 {
        GVariant *param;
@@ -1140,6 +1140,65 @@ fail:
        return result;
 }
 
+int _bt_passkey_reply(const char *passkey, gboolean cnfm_reply)
+{
+       bluetooth_device_address_t device_address;
+       int ret = OAL_STATUS_SUCCESS;
+       BT_INFO("reply: %d", cnfm_reply);
+
+       retv_if(trigger_pairing_info == NULL, BLUETOOTH_ERROR_INTERNAL);
+       retv_if(trigger_pairing_info->addr == NULL, BLUETOOTH_ERROR_INTERNAL);
+
+       _bt_convert_addr_string_to_type(device_address.addr, trigger_pairing_info->addr);
+
+       if (trigger_pairing_info->is_ssp) {
+               if (cnfm_reply)
+                       ret = device_accept_passkey_entry((bt_address_t *)&device_address, atoi(passkey));
+               else
+                       ret = device_reject_passkey_entry((bt_address_t *)&device_address);
+               trigger_pairing_info->is_ssp = FALSE;
+       } else {
+               if (cnfm_reply)
+                       ret = device_accept_pin_request((bt_address_t *)&device_address, passkey);
+               else
+                       ret = device_reject_pin_request((bt_address_t *)&device_address);
+       }
+
+       __bt_free_pairing_info(&trigger_pairing_info);
+
+       if (ret != OAL_STATUS_SUCCESS) {
+               BT_ERR("_bt_device_handle_passkey_reply: err [%d]", ret);
+               return BLUETOOTH_ERROR_INTERNAL;
+       }
+
+       BT_INFO("-");
+       return BLUETOOTH_ERROR_NONE;
+}
+
+int _bt_passkey_confirmation_reply(gboolean cnfm_reply)
+{
+       BT_INFO("BT_PASSKEY_CONFIRMATION_REPLY");
+       bluetooth_device_address_t device_address;
+       int ret = OAL_STATUS_SUCCESS;
+       BT_INFO("reply: %d", cnfm_reply);
+
+       retv_if(trigger_pairing_info == NULL, BLUETOOTH_ERROR_INTERNAL);
+       retv_if(trigger_pairing_info->addr == NULL, BLUETOOTH_ERROR_INTERNAL);
+
+       _bt_convert_addr_string_to_type(device_address.addr, trigger_pairing_info->addr);
+
+       ret = device_reply_passkey_confirmation((bt_address_t *)&device_address, cnfm_reply);
+
+       __bt_free_pairing_info(&trigger_pairing_info);
+       if (ret != OAL_STATUS_SUCCESS) {
+               BT_ERR("_bt_device_handle_passkey_confirmation_reply: err [%d]", ret);
+               return BLUETOOTH_ERROR_INTERNAL;
+       }
+
+       BT_INFO("-");
+       return BLUETOOTH_ERROR_NONE;
+}
+
 gboolean _bt_device_is_pairing(void)
 {
         return (trigger_pairing_info) ? TRUE : FALSE;
index 2cc360b..47138be 100755 (executable)
@@ -48,6 +48,11 @@ gboolean _bt_is_bonding_device_address(const char *address);
 
 void _bt_set_autopair_status_in_bonding_info(gboolean is_autopair);
 
+int _bt_passkey_reply(const char *passkey, gboolean authentication_reply);
+
+int _bt_passkey_confirmation_reply(gboolean confirmation_reply);
+
+
 #ifdef __cplusplus
 }
 #endif /* __cplusplus */