diff --git a/android/main.c b/android/main.c
index 4417e3b..7dafb29 100644
--- a/android/main.c
+++ b/android/main.c
static volatile sig_atomic_t __terminated = 0;
+static bool services[HAL_SERVICE_ID_MAX + 1] = {false};
+
+static void service_register(void *buf, uint16_t len)
+{
+ struct hal_msg_cmd_register_module *m = buf;
+
+ if (m->service_id > HAL_SERVICE_ID_MAX || services[m->service_id]) {
+ ipc_send_error(hal_cmd_io, HAL_SERVICE_ID_CORE, 0x01);
+ return;
+ }
+
+ services[m->service_id] = true;
+
+ ipc_send(hal_cmd_io, HAL_SERVICE_ID_CORE, HAL_MSG_OP_REGISTER_MODULE, 0,
+ NULL, -1);
+
+ info("Service ID=%u registered", m->service_id);
+}
+
+static void service_unregister(void *buf, uint16_t len)
+{
+ struct hal_msg_cmd_unregister_module *m = buf;
+
+ if (m->service_id > HAL_SERVICE_ID_MAX || !services[m->service_id]) {
+ ipc_send_error(hal_cmd_io, HAL_SERVICE_ID_CORE, 0x01);
+ return;
+ }
+
+ services[m->service_id] = false;
+
+ ipc_send(hal_cmd_io, HAL_SERVICE_ID_CORE, HAL_MSG_OP_UNREGISTER_MODULE,
+ 0, NULL, -1);
+
+ info("Service ID=%u unregistered", m->service_id);
+}
+
+static void handle_service_core(uint8_t opcode, void *buf, uint16_t len)
+{
+ switch (opcode) {
+ case HAL_MSG_OP_REGISTER_MODULE:
+ service_register(buf, len);
+ break;
+ case HAL_MSG_OP_UNREGISTER_MODULE:
+ service_unregister(buf, len);
+ break;
+ default:
+ ipc_send_error(hal_cmd_io, HAL_SERVICE_ID_CORE, 0x01);
+ break;
+ }
+}
+
static gboolean cmd_watch_cb(GIOChannel *io, GIOCondition cond,
gpointer user_data)
{
}
switch (msg->service_id) {
+ case HAL_SERVICE_ID_CORE:
+ handle_service_core(msg->opcode, buf + sizeof(*msg), msg->len);
+ break;
default:
ipc_send_error(hal_cmd_io, msg->service_id, 0x01);
break;