[Adapt: OAL] Add Device Trust state changed event handlers 57/86057/1
authorAnupam Roy <anupam.r@samsung.com>
Mon, 1 Aug 2016 11:12:42 +0000 (16:42 +0530)
committerAnupam Roy <anupam.r@samsung.com>
Mon, 1 Aug 2016 11:12:42 +0000 (16:42 +0530)
Change-Id: I9773794a9551ca33a642fbd4ce31a5a2a00e96aa
Signed-off-by: Anupam Roy <anupam.r@samsung.com>
bt-oal/include/oal-event.h
bt-oal/oal-adapter-mgr.c
bt-oal/oal-device-mgr.c

index 7a6de30..168f850 100755 (executable)
@@ -63,6 +63,8 @@ extern "C" {
        EVENT(OAL_EVENT_DEVICE_AUTHORIZE_REQUEST)                       /* event_dev_authorize_req_t */\
        EVENT(OAL_EVENT_DEVICE_ACL_CONNECTED)                           /* bt_address_t */\
        EVENT(OAL_EVENT_DEVICE_ACL_DISCONNECTED)                        /* bt_address_t */\
+       EVENT(OAL_EVENT_DEVICE_TRUSTED)                 /* Remote Device is Trusted */\
+       EVENT(OAL_EVENT_DEVICE_UNTRUSTED)                       /* Remote Device is UnTrusted */\
        EVENT(OAL_EVENT_OAL_INITIALISED_SUCCESS)                /* OAL Initialisation event */  \
        EVENT(OAL_EVENT_OAL_INITIALISED_FAILED)                 /* OAL Initialisation event */  \
        EVENT(OAL_EVENT_HID_CONNECTED)                                          /* event_hid_conn_t */\
@@ -134,6 +136,11 @@ typedef struct {
 typedef struct {
        bt_address_t address;
        oal_status_t status;
+} event_dev_trust_t;
+
+typedef struct {
+       bt_address_t address;
+       oal_status_t status;
 } event_dev_conn_status_t;
 
 typedef event_dev_conn_status_t event_dev_bond_failed_t;
index 2a20602..a23c53c 100755 (executable)
@@ -65,6 +65,7 @@ extern void cb_device_pin_request(bt_bdaddr_t *bd_addr, bt_bdname_t *bdname, uin
 extern void cb_device_ssp_request(bt_bdaddr_t *bd_addr, bt_bdname_t *bdname, uint32_t device_class,
                        bt_ssp_variant_t pairing_variant, uint32_t pass_key);
 extern void cb_device_authorize_request(bt_bdaddr_t *remote_bd_addr, bt_service_id_t service_d);
+extern void cb_device_trust_state_changed(bt_bdaddr_t *remote_bd_addr, bt_device_trust_state_t trusted);
 
 static bt_callbacks_t callbacks = {
        sizeof(callbacks),
@@ -82,6 +83,7 @@ static bt_callbacks_t callbacks = {
        NULL, /* le_test_mode_callback*/
        NULL, /* energy_info_callback */
        cb_device_authorize_request,
+       cb_device_trust_state_changed,
 };
 
 oal_status_t adapter_mgr_init(const bt_interface_t * stack_if)
index 5b2ee4c..b1d7116 100755 (executable)
@@ -608,3 +608,20 @@ void cb_device_authorize_request(bt_bdaddr_t *bd_addr, bt_service_id_t service_d
 
        send_event_bda_trace(OAL_EVENT_DEVICE_AUTHORIZE_REQUEST, auth_req, sizeof(event_dev_authorize_req_t), (bt_address_t*)bd_addr);
 }
+
+void cb_device_trust_state_changed(bt_bdaddr_t *bd_addr, bt_device_trust_state_t trusted)
+{
+       oal_event_t event;
+       event_dev_trust_t * trust_val = g_new0(event_dev_trust_t, 1);
+
+       if (trusted == BT_DEVICE_TRUSTED) {
+               BT_INFO("Device is Trusted");
+               event = OAL_EVENT_DEVICE_TRUSTED;
+       } else {
+               BT_INFO("Device is Un Trusted");
+               event = OAL_EVENT_DEVICE_UNTRUSTED;
+       }
+       memcpy(trust_val->address.addr, bd_addr->address, 6);
+       trust_val->status = OAL_STATUS_SUCCESS;
+       send_event_bda_trace(event, trust_val, sizeof(event_dev_trust_t), (bt_address_t*)bd_addr);
+}