* Success indicates that the VSC command was sent to controller
*/
int (*read_energy_info)();
+
+ /* Tizen Specific: Send service level Authorization response */
+ int (*authorize_response)(const bt_bdaddr_t *bd_addr, bt_service_id_t service_id,
+ uint8_t authorize, uint8_t save_settings);
} bt_interface_t;
/** TODO: Need to add APIs for Service Discovery, Service authorization and
return BT_STATUS_UNSUPPORTED;
}
+static int authorize_response(const bt_bdaddr_t *bd_addr, bt_service_id_t service_id,
+ uint8_t authorize, uint8_t save_settings)
+{
+ DBG("+");
+ return _bt_hal_device_authorize_response(bd_addr, service_id, authorize, save_settings);
+}
+
static const bt_interface_t bluetooth_if = {
.size = sizeof(bt_interface_t),
.init = init,
.get_connection_state = get_connection_state,
.set_os_callouts = set_os_callouts,
.read_energy_info = read_energy_info,
+ .authorize_response = authorize_response,
};
static const bt_interface_t *get_bluetooth_interface(void)
return result;
}
+int _bt_hal_device_authorize_response(const bt_bdaddr_t *bd_addr, bt_service_id_t service_id,
+ uint8_t authorize, uint8_t save_settings)
+{
+ int reply = GAP_AGENT_ACCEPT;
+ GapAgentPrivate *agent = _bt_hal_get_adapter_agent();
+ DBG("+");
+
+ if (!agent)
+ return BT_STATUS_FAIL;
+
+ if (!authorize)
+ reply = GAP_AGENT_REJECT;
+ else if (authorize && save_settings)
+ reply = GAP_AGENT_ACCEPT_ALWAYS;
+
+ gap_agent_reply_authorize(agent, reply, NULL);
+
+ DBG("-");
+ return BT_STATUS_SUCCESS;
+}
+
static void __bt_hal_device_service_search_cb(GDBusProxy *proxy, GAsyncResult *res,
gpointer user_data)
{
int _bt_hal_dbus_get_remote_device_services(const bt_bdaddr_t *remote_addr);
+int _bt_hal_device_authorize_response(const bt_bdaddr_t *bd_addr, bt_service_id_t service_id,
+ uint8_t authorize, uint8_t save_settings);
+
#ifdef __cplusplus
}
#endif /* __cplusplus */
DBG("-");
return TRUE;
}
+
+gboolean gap_agent_reply_authorize(GapAgentPrivate *agent, const guint accept,
+ GDBusMethodInvocation *context)
+{
+ gboolean ret = TRUE;
+ GapAgentPrivate *priv = agent;
+ DBG("+");
+
+ /* Fix : NULL_RETURNS */
+ if (priv == NULL)
+ return FALSE;
+
+ if (priv->exec_type != GAP_AGENT_EXEC_NO_OPERATION &&
+ priv->reply_context != NULL) {
+ if (accept == GAP_AGENT_ACCEPT) {
+ g_dbus_method_invocation_return_value(priv->reply_context, NULL);
+ } else if (accept == GAP_AGENT_ACCEPT_ALWAYS) {
+ /* TODO: Enable below logic after set authorization API implementation */
+ g_dbus_method_invocation_return_value(priv->reply_context, NULL);
+ } else {
+ switch (accept) {
+ case GAP_AGENT_CANCEL:
+ g_dbus_method_invocation_return_error(priv->reply_context,
+ GAP_AGENT_ERROR, GAP_AGENT_ERROR_CANCEL,
+ "CanceledbyUser");
+ break;
+ case GAP_AGENT_TIMEOUT:
+ case GAP_AGENT_REJECT:
+ default:
+ g_dbus_method_invocation_return_error(priv->reply_context,
+ GAP_AGENT_ERROR, GAP_AGENT_ERROR_REJECT,
+ "Authorization request rejected");
+ break;
+ }
+ }
+
+ if (context)
+ g_dbus_method_invocation_return_value(context, NULL);
+ } else {
+ ERR("No context");
+ if (context)
+ g_dbus_method_invocation_return_error(context,
+ GAP_AGENT_ERROR, GAP_AGENT_ERROR_REJECT,
+ "No context");
+ ret = FALSE;
+ }
+
+ priv->exec_type = GAP_AGENT_EXEC_NO_OPERATION;
+ priv->reply_context = NULL;
+ memset(priv->authorize_addr, 0x00, sizeof(priv->authorize_addr));
+
+ DBG("-");
+ return ret;
+}
gboolean gap_agent_reply_confirmation(GapAgentPrivate *agent, const guint accept,
GDBusMethodInvocation *context);
+gboolean gap_agent_reply_authorize(GapAgentPrivate *agent, const guint accept,
+ GDBusMethodInvocation *context);
#endif //_BT_HAL_GAP_AGENT_H__