[Adapt] Add OAL API & bt-service request handler for 'Set Trust' 32/81732/1
authorAnupam Roy <anupam.r@samsung.com>
Mon, 25 Jul 2016 14:32:59 +0000 (20:02 +0530)
committerAnupam Roy <anupam.r@samsung.com>
Thu, 28 Jul 2016 06:02:50 +0000 (11:32 +0530)
Change-Id: If5135f45f3eb2af04d663f36adcd1c7d4a5cb039
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 549f30e..ec3ccb5 100755 (executable)
@@ -249,6 +249,21 @@ oal_status_t device_reply_ssp_consent(bt_address_t * addr, int accept);
  */
 oal_status_t device_reply_auth_request(bt_address_t * addr, oal_service_t service_type, int accept, int always);
 
+/**
+ * @brief Set a device as authorized or unauthorized
+ *
+ * @details authorize = TRUE: all connections from this device will be auto accepted without any auth-event
+ *                 authorize = FALSE: all connections from this device will result in auth request event
+ *
+ * @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
+ *
+ * @see  OAL_EVENT_DEVICE_AUTHORIZE_REQUEST
+ */
+oal_status_t device_set_authorized(bt_address_t * addr, int authorize);
+
 #ifdef __cplusplus
 }
 #endif /* __cplusplus */
index 910c7f3..5b2ee4c 100755 (executable)
@@ -327,6 +327,27 @@ oal_status_t device_reply_auth_request(bt_address_t * addr, oal_service_t servic
        return OAL_STATUS_SUCCESS;
 }
 
+oal_status_t device_set_authorized(bt_address_t * addr, int authorize)
+{
+       int res;
+       bdstr_t bdstr;
+
+       CHECK_OAL_INITIALIZED();
+
+       OAL_CHECK_PARAMETER(addr, return);
+
+       API_TRACE("[%s] %d", bdt_bd2str(addr, &bdstr), authorize);
+
+       res = blued_api->set_authorization((bt_bdaddr_t *)addr, authorize);
+       if (res != BT_STATUS_SUCCESS) {
+               BT_ERR("set_authorization error: [%s]", status2string(res));
+               BT_ERR("%d", authorize);
+               return convert_to_oal_status(res);
+       }
+
+       return OAL_STATUS_SUCCESS;
+}
+
 void cb_device_properties(bt_status_t status, bt_bdaddr_t *bd_addr,
                int num_properties, bt_property_t *properties)
 {
index 3881c0f..6ed74a6 100644 (file)
@@ -617,6 +617,16 @@ int __bt_bluez_request(int function_name,
                result = _bt_passkey_confirmation_reply(confirmation_reply);
                break;
        }
+       case BT_SET_AUTHORIZATION: {
+               bluetooth_device_address_t address = { {0} };
+               gboolean authorize;
+                __bt_service_get_parameters(in_param1,
+                               &address, sizeof(bluetooth_device_address_t));
+                __bt_service_get_parameters(in_param2,
+                               &authorize, sizeof(gboolean));
+               result = _bt_set_authorization(&address, authorize);
+               break;
+       }
        case BT_HID_CONNECT: {
                bluetooth_device_address_t address = { {0} };
 
index 64372b3..a2cbe86 100644 (file)
@@ -1525,3 +1525,21 @@ int _bt_cancel_search_device(void)
        return BLUETOOTH_ERROR_NONE;
        BT_DBG("-");
 }
+
+int _bt_set_authorization(bluetooth_device_address_t *device_address,
+                                      gboolean authorize)
+{
+       int ret = OAL_STATUS_SUCCESS;
+       BT_DBG("+");
+
+       BT_CHECK_PARAMETER(device_address, return);
+       BT_INFO("Device to be Trusted? [%d]", authorize);
+
+       ret = device_set_authorized((bt_address_t*)device_address, authorize);
+       if (ret != OAL_STATUS_SUCCESS) {
+               BT_ERR("device_set_authorized: %d", ret);
+               return BLUETOOTH_ERROR_INTERNAL;
+       }
+
+       return BLUETOOTH_ERROR_NONE;
+}
index d42b845..9534599 100755 (executable)
@@ -58,7 +58,8 @@ int _bt_passkey_reply(const char *passkey, gboolean authentication_reply);
 
 int _bt_passkey_confirmation_reply(gboolean confirmation_reply);
 
-
+int _bt_set_authorization(bluetooth_device_address_t *device_address,
+                               gboolean authorize);
 #ifdef __cplusplus
 }
 #endif /* __cplusplus */