GATT: Handle prepare_authorize parameter in WriteValue DBUS API 05/252405/2
authorAyush Garg <ayush.garg@samsung.com>
Wed, 27 Jan 2021 14:15:59 +0000 (19:45 +0530)
committerAyush Garg <ayush.garg@samsung.com>
Wed, 27 Jan 2021 14:41:47 +0000 (14:41 +0000)
In GATT Server role, prepare_authorize parameter will be set
when bluez wants authorization permission from the application when
ATT_PREPARE_WRITE_REQUEST PDU receive for the first time in case
of long write.

This is an initial patchset to parse prepare_authorize parameter from
bluez and avoid crash. Subsequent patches will be added to handle
authorization completely.

This patchset should be merged with the following bluez's patchset
in order to match API and avoid crash:
bluez Change-Id: I93bc46151ebbe695c74b224c3a3579c6e5d0de14

Change-Id: Ic4397ae86760177e08ccd283e80d4526bd32e0c4
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
bt-oal/bluez_hal/src/bt-hal-gatt-server.c

index 2f093c3..a028010 100644 (file)
@@ -262,6 +262,7 @@ static const gchar characteristics_introspection_xml[] =
 "               <arg type='u' name='id' direction='in'/>"
 "               <arg type='q' name='offset' direction='in'/>"
 "               <arg type='b' name='response_needed' direction='in'/>"
+"               <arg type='b' name='prep_authorize' direction='in'/>"
 "               <arg type='ay' name='value' direction='in'/>"
 "        </method>"
 "       <method name ='AcquireWrite'>"
@@ -320,6 +321,7 @@ static const gchar descriptor_introspection_xml[] =
 "               <arg type='u' name='id' direction='in'/>"
 "               <arg type='q' name='offset' direction='in'/>"
 "               <arg type='b' name='response_needed' direction='in'/>"
+"               <arg type='b' name='prep_authorize' direction='in'/>"
 "               <arg type='ay' name='value' direction='in'/>"
 "        </method>"
 "  </interface>"
@@ -1116,6 +1118,7 @@ static void __bt_gatt_desc_method_call(GDBusConnection *connection,
                guint req_id = 0;
                guint16 offset = 0;
                gboolean response_needed = FALSE;
+               gboolean prep_authorize = FALSE;
                struct hal_ev_gatt_server_write_req ev;
                int desc_hdl = -1;
                int len;
@@ -1130,10 +1133,13 @@ static void __bt_gatt_desc_method_call(GDBusConnection *connection,
                DBG("Application path = %s", object_path);
                DBG("Sender = %s", sender);
 
-               g_variant_get(parameters, "(&suqb@ay)",
-                               &addr, &req_id, &offset, &response_needed, &var);
+               g_variant_get(parameters, "(&suqbb@ay)",
+                               &addr, &req_id, &offset, &response_needed, &prep_authorize, &var);
                DBG("Request id = %u, Offset = %u", req_id, offset);
 
+               if (prep_authorize)
+                       DBG("prep_authorize = true");
+
                /* Check if device is already in connected list */
                conn_info = __bt_find_remote_gatt_client_info(addr);
 
@@ -1261,6 +1267,7 @@ static void __bt_gatt_char_method_call(GDBusConnection *connection,
                guint req_id = 0;
                guint16 offset = 0;
                gboolean response_needed = FALSE;
+               gboolean prep_authorize = FALSE;
                struct hal_ev_gatt_server_write_req ev;
                int char_hdl = -1;
                int len;
@@ -1273,10 +1280,13 @@ static void __bt_gatt_char_method_call(GDBusConnection *connection,
 
                DBG("WriteValue : Application path %s, sender %s", object_path, sender);
 
-               g_variant_get(parameters, "(&suqb@ay)",
-                               &addr, &req_id, &offset, &response_needed, &var);
+               g_variant_get(parameters, "(&suqbb@ay)",
+                               &addr, &req_id, &offset, &response_needed, &prep_authorize, &var);
                DBG("Request id = %u, Offset = %u", req_id, offset);
 
+               if (prep_authorize)
+                       DBG("prep_authorize = true");
+
                svc_info = __bt_gatt_find_gatt_service_from_char(object_path, &char_hdl);
 
                /* Check if device is already in connected list */