OSDN Git Service

android: Initialize IPC with command and notification sockets
authorSzymon Janc <szymon.janc@tieto.com>
Thu, 28 Nov 2013 14:15:21 +0000 (15:15 +0100)
committerLuiz Augusto von Dentz <luiz.von.dentz@intel.com>
Thu, 28 Nov 2013 16:02:26 +0000 (18:02 +0200)
Pass sockets after succesfully connected to HAL. This will allow
to improve IPC helpers API.

android/ipc.c
android/ipc.h
android/main.c

index 25c36fd..028d4ad 100644 (file)
 #include "ipc.h"
 #include "log.h"
 
+static int cmd_sk = -1;
+static int notif_sk = -1;
+
+void ipc_init(int command_sk, int notification_sk)
+{
+       cmd_sk = command_sk;
+       notif_sk = notification_sk;
+}
+
+void ipc_cleanup(void)
+{
+       cmd_sk = -1;
+       notif_sk = -1;
+}
+
 void ipc_send(int sk, uint8_t service_id, uint8_t opcode, uint16_t len,
                                                        void *param, int fd)
 {
index ad4a2d2..5786d2d 100644 (file)
@@ -21,6 +21,9 @@
  *
  */
 
+void ipc_init(int command_sk, int notification_sk);
+void ipc_cleanup(void);
+
 void ipc_send(int sk, uint8_t service_id, uint8_t opcode, uint16_t len,
                                                        void *param, int fd);
 void ipc_send_rsp(int sk, uint8_t service_id, uint8_t opcode, uint8_t status);
index bfd2a87..4e6ad38 100644 (file)
@@ -354,6 +354,9 @@ static gboolean notif_connect_cb(GIOChannel *io, GIOCondition cond,
 
        g_io_add_watch(hal_cmd_io, cond, cmd_watch_cb, NULL);
 
+       ipc_init(g_io_channel_unix_get_fd(hal_cmd_io),
+                               g_io_channel_unix_get_fd(hal_notif_io));
+
        info("Successfully connected to HAL");
 
        return FALSE;
@@ -494,6 +497,8 @@ static void cleanup_hal_connection(void)
                g_io_channel_unref(hal_notif_io);
                hal_notif_io = NULL;
        }
+
+       ipc_cleanup();
 }
 
 static bool set_capabilities(void)