Add a new internal function to send raw data 19/303319/1
authorHwankyu Jhun <h.jhun@samsung.com>
Tue, 26 Dec 2023 00:20:31 +0000 (09:20 +0900)
committerHwankyu Jhun <h.jhun@samsung.com>
Tue, 26 Dec 2023 00:20:31 +0000 (09:20 +0900)
The aul_sock_send_raw_data() is added. The aul_launch uses the function
to send a reply to amd.

Change-Id: I176f8ce4d691abce40c766d2525f8fdfad778054
Signed-off-by: Hwankyu Jhun <h.jhun@samsung.com>
include/aul_sock.h
src/aul_launch.c
src/aul_sock.cc

index d0156a9..681c38b 100644 (file)
@@ -148,6 +148,11 @@ int aul_sock_recv_reply_pkt_v2(int fd, app_pkt_t **pkt, bool do_close);
  */
 int aul_sock_create_launchpad_client_without_timeout(const char *pad_type, uid_t uid);
 
+/**
+ * This API is only for Appfw internally.
+ */
+int aul_sock_send_raw_data(int fd, unsigned char *raw_data, size_t length, bool do_close);
+
 #ifdef __cplusplus
 }
 #endif
index f84902b..6d1082c 100644 (file)
@@ -398,14 +398,17 @@ static struct aul_request_s *__create_request(int cmd, int clifd, bundle *b)
 static int __send_result(struct aul_request_s *req, int res)
 {
        int ret;
+       int buf[2];
 
        if (req->cmd != WIDGET_GET_CONTENT && req->clifd >= 0) {
                g_rec_mutex_lock(&__context.mutex);
                if (__find_client_channel(req->clifd) == NULL)
                        _E("Failed to find client channel. fd(%d)", req->clifd);
 
-               aul_sock_send_result_v2(req->clifd, req->req_id, false);
-               ret = aul_sock_send_result_v2(req->clifd, res, false);
+               buf[0] = req->req_id;
+               buf[1] = res;
+               ret = aul_sock_send_raw_data(req->clifd, (unsigned char *)&buf,
+                               sizeof(int) + sizeof(int), false);
                g_rec_mutex_unlock(&__context.mutex);
                if (ret < 0) {
                        _E("Failed to send result. cmd(%s:%d), seq(%d)",
index 3b687ce..f8cc053 100644 (file)
@@ -768,3 +768,20 @@ extern "C" API int aul_sock_recv_reply_pkt_v2(int fd, app_pkt_t** pkt,
 
   return ret;
 }
+
+extern "C" API int aul_sock_send_raw_data(int fd, unsigned char* raw_data,
+    size_t length, bool do_close) {
+  if (fd < 0 || fd >= sysconf(_SC_OPEN_MAX)) {
+    _E("Invalid parameter");
+    return -EINVAL;
+  }
+
+  int ret = send(fd, raw_data, length, MSG_NOSIGNAL);
+  if (ret < 0)
+    _E("send() is failed. fd(%d), errno(%d)", fd, errno);
+
+  if (do_close)
+    close(fd);
+
+  return ret;
+}