To support hal-api IPC transport, tidl-generated code has been added.
By generating proxy/stub code in pair, it provides a way to communicate
between server and client in a predefined manner.
These are newly added files.
- include/hal_device_bezel_ipc_1.tidl
: Define types and interfaces. Based on the tidl file, proxy and
stub code are generated.
- src/generated/hal_device_bezel_proxy_1.h
- src/generated/hal_device_bezel_proxy_1.c
: By using this code, client can be implemented. And it talks to
sever that has been implemented by the stub code below.
- src/generated/hal_device_bezel_stub_1.h
- src/generated/hal_device_bezel_stub_1.c
: By using this code. server can be implemented. And it can
handle request from a client that has been implemented by the
above proxy code.
Change-Id: Ie63d504c77db21a7499a39518085656fe75008f9
Signed-off-by: Youngjae Cho <y0.cho@samsung.com>
--- /dev/null
+protocol 2
+
+struct enums {
+ enum state {
+ TURNOFF = 0, /**< bezel state Turnoff */
+ TURNON, /**< bezel state Turnon */
+ }
+
+ enum vib_state {
+ NONE = 0, /**< bezel vibration state None */
+ LIGHT, /**< bezel vibration state Light */
+ MEDIUM, /**< bezel vibration state Medium */
+ STRONG, /**< bezel vibration state Strong */
+ }
+}
+
+interface device_bezel {
+ int get_state(out enums.state state); /**< Get hardware bezel state */
+ int set_state(enums.state state); /**< Set hardware bezel state */
+ int get_sw_state(out enums.state state); /**< Get software bezel state */
+ int set_sw_state(enums.state state); /**< Set software bezel state */
+ int get_vib_state(out enums.vib_state state); /**< Get bezel vibration state */
+ int set_vib_state(enums.vib_state state); /**< Set bezel vibration state */
+}
tidlc -s -l C -i ./include/hal_device_led_ipc_1.tidl -o ./src/generated/hal_device_led_stub_1 -n
tidlc -p -l C -i ./include/hal_device_battery_ipc_1.tidl -o ./src/generated/hal_device_battery_proxy_1 -n
tidlc -s -l C -i ./include/hal_device_battery_ipc_1.tidl -o ./src/generated/hal_device_battery_stub_1 -n
+tidlc -p -l C -i ./include/hal_device_bezel_ipc_1.tidl -o ./src/generated/hal_device_bezel_proxy_1 -n
+tidlc -s -l C -i ./include/hal_device_bezel_ipc_1.tidl -o ./src/generated/hal_device_bezel_stub_1 -n
%build
cp %{SOURCE1} .
--- /dev/null
+
+/*
+ * Generated by tidlc 2.6.1.
+ */
+
+#ifndef _GNU_SOURCE
+#define _GNU_SOURCE
+#endif
+
+#pragma GCC diagnostic ignored "-Warray-bounds"
+#pragma GCC diagnostic ignored "-Wunused-function"
+
+#include <pthread.h>
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <libgen.h>
+#include <glib.h>
+#include <dlog.h>
+#include <rpc-port.h>
+#include <rpc-port-parcel.h>
+#include <unistd.h>
+#include <dlfcn.h>
+#include <app_common.h>
+#include "./src/generated/hal_device_bezel_proxy_1.h"
+
+
+#undef LOG_TAG
+#define LOG_TAG "RPC_PORT_PROXY"
+
+#undef _E
+#define _E(fmt, ...) dlog_print(DLOG_ERROR, LOG_TAG, "%s: %s(%d) > "fmt, basename(__FILE__), __FUNCTION__, __LINE__, ##__VA_ARGS__)
+
+#undef _W
+#define _W(fmt, ...) dlog_print(DLOG_WARN, LOG_TAG, "%s: %s(%d) > "fmt, basename(__FILE__), __FUNCTION__, __LINE__, ##__VA_ARGS__)
+
+#undef _I
+#define _I(fmt, ...) dlog_print(DLOG_INFO, LOG_TAG, "%s: %s(%d) > "fmt, basename(__FILE__), __FUNCTION__, __LINE__, ##__VA_ARGS__)
+
+#undef _D
+#define _D(fmt, ...) dlog_print(DLOG_DEBUG, LOG_TAG, "%s: %s(%d) > "fmt, basename(__FILE__), __FUNCTION__, __LINE__, ##__VA_ARGS__)
+
+#ifndef TIDL_VERSION
+#define TIDL_VERSION "2.6.1"
+#endif
+
+#ifndef nullptr
+#define nullptr NULL
+#endif
+
+#ifndef ARRAY_SIZE
+#define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0]))
+#endif
+
+#ifndef STRING_GET
+#define STRING_GET(x) ((x) ? x : "")
+#endif
+
+#ifndef EXPORT_API
+#define EXPORT_API extern "C" __attribute__ ((visibility("default")))
+#endif
+
+
+
+typedef int (*rpc_port_parcel_reserve_t)(rpc_port_parcel_h h, unsigned int size);
+typedef int (*rpc_port_parcel_create_from_parcel_t)(rpc_port_parcel_h* h,
+ rpc_port_parcel_h origin_parcel,
+ unsigned int start_pos,
+ unsigned int size);
+typedef int (*rpc_port_parcel_set_data_size_t)(rpc_port_parcel_h h, unsigned int size);
+typedef int (*rpc_port_parcel_get_data_size_t)(rpc_port_parcel_h h, unsigned int* size);
+typedef int (*rpc_port_parcel_pin_t)(rpc_port_parcel_h h);
+typedef int (*rpc_port_parcel_get_reader_t)(rpc_port_parcel_h h, unsigned int* reader_pos);
+typedef int (*rpc_port_parcel_set_reader_t)(rpc_port_parcel_h h, unsigned int reader_pos);
+typedef int (*rpc_port_parcel_write_fd_t)(rpc_port_parcel_h h, int fd);
+typedef int (*rpc_port_parcel_read_fd_t)(rpc_port_parcel_h h, int* fd);
+typedef int (*rpc_port_parcel_clone_t)(rpc_port_parcel_h* h, rpc_port_parcel_h origin);
+
+static rpc_port_parcel_reserve_t rpc_port_parcel_reserve;
+static rpc_port_parcel_create_from_parcel_t rpc_port_parcel_create_from_parcel;
+static rpc_port_parcel_set_data_size_t rpc_port_parcel_set_data_size;
+static rpc_port_parcel_get_data_size_t rpc_port_parcel_get_data_size;
+static rpc_port_parcel_pin_t rpc_port_parcel_pin;
+static rpc_port_parcel_get_reader_t rpc_port_parcel_get_reader;
+static rpc_port_parcel_set_reader_t rpc_port_parcel_set_reader;
+static rpc_port_parcel_write_fd_t rpc_port_parcel_write_fd;
+static rpc_port_parcel_read_fd_t rpc_port_parcel_read_fd;
+static rpc_port_parcel_clone_t rpc_port_parcel_clone;
+
+static bool rpc_port_internal_loaded;
+
+static void rpc_port_internal_init(void)
+{
+ const char *symbol = "rpc_port_parcel_reserve";
+
+ if (rpc_port_internal_loaded)
+ return;
+
+ rpc_port_parcel_reserve = dlsym(RTLD_DEFAULT, symbol);
+ if (rpc_port_parcel_reserve == nullptr) {
+ _E("Failed to find symbol(%s). Please check rpc-port version", symbol);
+ return;
+ }
+
+ symbol = "rpc_port_parcel_create_from_parcel";
+ rpc_port_parcel_create_from_parcel = dlsym(RTLD_DEFAULT, symbol);
+ if (rpc_port_parcel_create_from_parcel == nullptr) {
+ _E("Failed to find symbol(%s). Please check rpc-port version", symbol);
+ return;
+ }
+
+ symbol = "rpc_port_parcel_set_data_size";
+ rpc_port_parcel_set_data_size = dlsym(RTLD_DEFAULT, symbol);
+ if (rpc_port_parcel_set_data_size == nullptr) {
+ _E("Failed to find symbol(%s). Please check rpc-port version", symbol);
+ return;
+ }
+
+ symbol = "rpc_port_parcel_get_data_size";
+ rpc_port_parcel_get_data_size = dlsym(RTLD_DEFAULT, symbol);
+ if (rpc_port_parcel_get_data_size == nullptr) {
+ _E("Failed to find symbol(%s). Please check rpc-port version", symbol);
+ return;
+ }
+
+ symbol = "rpc_port_parcel_pin";
+ rpc_port_parcel_pin = dlsym(RTLD_DEFAULT, symbol);
+ if (rpc_port_parcel_pin == nullptr) {
+ _E("Failed to find symbol(%s). Please check rpc-port version", symbol);
+ return;
+ }
+
+ symbol = "rpc_port_parcel_get_reader";
+ rpc_port_parcel_get_reader = dlsym(RTLD_DEFAULT, symbol);
+ if (rpc_port_parcel_get_reader == nullptr) {
+ _E("Failed to find symbol(%s). Please check rpc-port version", symbol);
+ return;
+ }
+
+ symbol = "rpc_port_parcel_set_reader";
+ rpc_port_parcel_set_reader = dlsym(RTLD_DEFAULT, symbol);
+ if (rpc_port_parcel_set_reader == nullptr) {
+ _E("Failed to find symbol(%s). Please check rpc-port version", symbol);
+ return;
+ }
+
+ symbol = "rpc_port_parcel_write_fd";
+ rpc_port_parcel_write_fd = dlsym(RTLD_DEFAULT, symbol);
+ if (rpc_port_parcel_write_fd == nullptr) {
+ _E("Failed to find symbol(%s). Please check rpc-port version", symbol);
+ return;
+ }
+
+ symbol = "rpc_port_parcel_read_fd";
+ rpc_port_parcel_read_fd = dlsym(RTLD_DEFAULT, symbol);
+ if (rpc_port_parcel_read_fd == nullptr) {
+ _E("Failed to find symbol(%s). Please check rpc-port version", symbol);
+ return;
+ }
+
+ symbol = "rpc_port_parcel_clone";
+ rpc_port_parcel_clone = dlsym(RTLD_DEFAULT, symbol);
+ if (rpc_port_parcel_clone == nullptr) {
+ _E("Failed to find symbol(%s). Please check rpc-port version", symbol);
+ return;
+ }
+
+ rpc_port_internal_loaded = true;
+}
+
+
+
+typedef void (*rpc_port_unit_write_func)(rpc_port_parcel_h parcel, void* data);
+
+typedef struct rpc_port_unit_s {
+ rpc_port_parcelable_t parcelable;
+ int name;
+ int type;
+ rpc_port_parcel_h parcel;
+ rpc_port_unit_write_func write_cb;
+ void *data;
+} rpc_port_unit_t;
+
+typedef rpc_port_unit_t *rpc_port_unit_h;
+
+typedef struct rpc_port_unit_map_s {
+ rpc_port_parcelable_t parcelable;
+ GHashTable *table;
+} rpc_port_unit_map_t;
+
+typedef rpc_port_unit_map_t *rpc_port_unit_map_h;
+
+
+typedef int (*rpc_port_stub_lem_connect_func)(void *context, const char *appid, const char *instance, bool sync);
+typedef void (*rpc_port_stub_lem_disconnect_func)(void *context, const char *appid, const char *instance);
+typedef int (*rpc_port_stub_lem_send_func)(void *context, const char *appid, const char *instance, rpc_port_parcel_h h);
+
+typedef void (*rpc_port_proxy_lem_connected_cb)(void *context);
+typedef void (*rpc_port_proxy_lem_disconnected_cb)(void* context);
+typedef void (*rpc_port_proxy_lem_received_cb)(void* context, rpc_port_parcel_h);
+
+typedef struct {
+ rpc_port_proxy_lem_connected_cb connected;
+ rpc_port_proxy_lem_disconnected_cb disconnected;
+ rpc_port_proxy_lem_received_cb received;
+} rpc_port_proxy_lem_event_s;
+
+typedef struct {
+ void *context;
+ rpc_port_proxy_lem_event_s callback;
+ char *port_name;
+ char *instance;
+ rpc_port_stub_lem_connect_func connect_func;
+ rpc_port_stub_lem_disconnect_func disconnect_func;
+ rpc_port_stub_lem_send_func send_func;
+ bool connected;
+ bool connecting;
+ bool loaded;
+ GQueue *result_queue;
+ GQueue *request_queue;
+ GRecMutex mutex;
+ GMainContext *thread_context;
+} rpc_port_proxy_lem_s;
+
+typedef rpc_port_proxy_lem_s *rpc_port_proxy_lem_h;
+
+typedef struct rpc_port_delegate_s {
+ rpc_port_parcelable_t parcelable;
+ int id;
+ int seq_id;
+ bool once;
+} rpc_port_delegate_t;
+
+typedef rpc_port_delegate_t *rpc_port_delegate_h;
+
+
+typedef void (*rpc_port_proxy_delegate_cb)(GList **delegates, rpc_port_unit_map_h map, rpc_port_delegate_h delegate);
+
+
+typedef struct rpc_port_proxy_hal_device_bezel_proxy_1_enums_s {
+ rpc_port_parcelable_t parcelable;
+} rpc_port_proxy_hal_device_bezel_proxy_1_enums_t;
+
+
+typedef struct rpc_port_proxy_hal_device_bezel_proxy_1_remote_exception_s {
+ rpc_port_parcelable_t parcelable;
+ int cause;
+ char *message;
+} rpc_port_proxy_hal_device_bezel_proxy_1_remote_exception_t;
+
+static rpc_port_proxy_hal_device_bezel_proxy_1_remote_exception_h __rpc_port_proxy_hal_device_bezel_proxy_1_remote_exception;
+
+int rpc_port_proxy_hal_device_bezel_proxy_1_remote_exception_create(rpc_port_proxy_hal_device_bezel_proxy_1_remote_exception_h *h);
+
+
+
+typedef struct rpc_port_proxy_hal_device_bezel_proxy_1_device_bezel_s {
+ char *stub_appid;
+ rpc_port_proxy_h proxy;
+ rpc_port_h port;
+ rpc_port_h callback_port;
+ rpc_port_proxy_hal_device_bezel_proxy_1_device_bezel_callback_s callback;
+ void *user_data;
+ GList *delegates;
+ GRecMutex mutex;
+ rpc_port_proxy_lem_h lem;
+} rpc_port_proxy_hal_device_bezel_proxy_1_device_bezel_t;
+
+rpc_port_proxy_hal_device_bezel_proxy_1_device_bezel_h __rpc_port_proxy_hal_device_bezel_proxy_1_device_bezel_handle;
+
+
+
+static void __rpc_port_unit_to(rpc_port_parcel_h parcel, void *user_data)
+{
+ rpc_port_unit_h unit = user_data;
+ size_t size = 0;
+ unsigned int size_pos = 0;
+ unsigned int cur_pos = 0;
+ int ret;
+
+ ret = rpc_port_parcel_write_int32(parcel, unit->name);
+ if (ret != RPC_PORT_ERROR_NONE) {
+ set_last_result(ret);
+ return;
+ }
+
+ ret = rpc_port_parcel_write_int32(parcel, unit->type);
+ if (ret != RPC_PORT_ERROR_NONE) {
+ set_last_result(ret);
+ return;
+ }
+
+ ret = rpc_port_parcel_get_data_size(parcel, &size_pos);
+ if (ret != RPC_PORT_ERROR_NONE) {
+ set_last_result(ret);
+ return;
+ }
+
+ ret = rpc_port_parcel_reserve(parcel, sizeof(unsigned int));
+ if (ret != RPC_PORT_ERROR_NONE) {
+ set_last_result(ret);
+ return;
+ }
+
+ if (unit->write_cb)
+ unit->write_cb(parcel, unit);
+
+ ret = rpc_port_parcel_get_data_size(parcel, &cur_pos);
+ if (ret != RPC_PORT_ERROR_NONE) {
+ set_last_result(ret);
+ return;
+ }
+
+ size = cur_pos - size_pos - sizeof(unsigned int);
+ ret = rpc_port_parcel_set_data_size(parcel, size_pos);
+ if (ret != RPC_PORT_ERROR_NONE) {
+ set_last_result(ret);
+ return;
+ }
+
+ ret = rpc_port_parcel_write_int32(parcel, size);
+ if (ret != RPC_PORT_ERROR_NONE) {
+ set_last_result(ret);
+ return;
+ }
+
+ ret = rpc_port_parcel_set_data_size(parcel, cur_pos);
+
+ set_last_result(ret);
+}
+
+static void __rpc_port_unit_from(rpc_port_parcel_h parcel, void *user_data)
+{
+ rpc_port_unit_h unit = user_data;
+ int size = 0;
+ unsigned int start_pos = 0;
+ int ret;
+ rpc_port_parcel_h sub_parcel = NULL;
+
+ rpc_port_parcel_read_int32(parcel, &unit->name);
+ rpc_port_parcel_read_int32(parcel, &unit->type);
+ rpc_port_parcel_read_array_count(parcel, &size);
+ if (size == 0) return;
+
+ ret = rpc_port_parcel_get_reader(parcel, &start_pos);
+ if (ret != RPC_PORT_ERROR_NONE) {
+ set_last_result(ret);
+ return;
+ }
+
+ ret = rpc_port_parcel_create_from_parcel(&sub_parcel, parcel, start_pos,
+ size);
+ if (ret != RPC_PORT_ERROR_NONE) {
+ set_last_result(ret);
+ return;
+ }
+
+ ret = rpc_port_parcel_reserve(sub_parcel, size);
+ if (ret != RPC_PORT_ERROR_NONE) {
+ rpc_port_parcel_destroy(sub_parcel);
+ set_last_result(ret);
+ return;
+ }
+
+ ret = rpc_port_parcel_set_reader(parcel, start_pos + size);
+ if (ret != RPC_PORT_ERROR_NONE) {
+ rpc_port_parcel_destroy(sub_parcel);
+ set_last_result(ret);
+ return;
+ }
+
+ unit->parcel = sub_parcel;
+ set_last_result(RPC_PORT_ERROR_NONE);
+}
+
+static void rpc_port_unit_destroy(gpointer user_data)
+{
+ rpc_port_unit_h unit = user_data;
+
+ if (unit == nullptr)
+ return;
+
+ if (unit->parcel)
+ rpc_port_parcel_destroy(unit->parcel);
+
+ free(unit);
+}
+
+static rpc_port_unit_h rpc_port_unit_create(int name, int type)
+{
+ rpc_port_unit_h unit;
+
+ unit = calloc(1, sizeof(rpc_port_unit_t));
+ if (unit == nullptr) {
+ _E("calloc() is failed");
+ return nullptr;
+ }
+
+ unit->name = name;
+ unit->type = type;
+ unit->parcelable.to = __rpc_port_unit_to;
+ unit->parcelable.from = __rpc_port_unit_from;
+ unit->write_cb = nullptr;
+
+ return unit;
+}
+
+static void __rpc_port_unit_map_to(rpc_port_parcel_h parcel, void *user_data)
+{
+ rpc_port_unit_map_h unit_map = user_data;
+ rpc_port_unit_h unit;
+ GHashTableIter iter;
+ gpointer key;
+ gpointer value;
+
+ rpc_port_parcel_write_array_count(parcel, g_hash_table_size(unit_map->table) & INT_MAX);
+ g_hash_table_iter_init(&iter, unit_map->table);
+ while (g_hash_table_iter_next(&iter, &key, &value)) {
+ unit = (rpc_port_unit_h)value;
+ rpc_port_parcel_write(parcel, &unit->parcelable, unit);
+ if (get_last_result() != RPC_PORT_ERROR_NONE)
+ break;
+ }
+}
+
+static void __rpc_port_unit_map_from(rpc_port_parcel_h parcel, void *user_data)
+{
+ rpc_port_unit_map_h unit_map = user_data;
+ rpc_port_unit_h unit;
+ int size = 0;
+ int i;
+
+ rpc_port_parcel_read_array_count(parcel, &size);
+ rpc_port_parcel_pin(parcel);
+ for (i = 0; i < size; ++i) {
+ unit = rpc_port_unit_create(0, 0);
+ if (unit == nullptr) {
+ set_last_result(RPC_PORT_ERROR_OUT_OF_MEMORY);
+ break;
+ }
+
+ rpc_port_parcel_read(parcel, &unit->parcelable, unit);
+ if (get_last_result() != RPC_PORT_ERROR_NONE) {
+ rpc_port_unit_destroy(unit);
+ break;
+ }
+
+ g_hash_table_insert(unit_map->table, GINT_TO_POINTER(unit->name), unit);
+ }
+}
+
+static void rpc_port_unit_map_destroy(rpc_port_unit_map_h handle)
+{
+ if (handle == nullptr)
+ return;
+
+ if (handle->table)
+ g_hash_table_destroy(handle->table);
+
+ free(handle);
+}
+
+static rpc_port_unit_map_h rpc_port_unit_map_create(void)
+{
+ rpc_port_unit_map_h unit_map;
+
+ unit_map = calloc(1, sizeof(rpc_port_unit_map_t));
+ if (unit_map == nullptr) {
+ _E("calloc() is failed");
+ return nullptr;
+ }
+
+ unit_map->table = g_hash_table_new_full(g_direct_hash, g_direct_equal, nullptr, rpc_port_unit_destroy);
+ if (unit_map->table == nullptr) {
+ _E("g_hash_table_new_full() is failed");
+ rpc_port_unit_map_destroy(unit_map);
+ return nullptr;
+ }
+
+ unit_map->parcelable.to = __rpc_port_unit_map_to;
+ unit_map->parcelable.from = __rpc_port_unit_map_from;
+
+ return unit_map;
+}
+
+static int rpc_port_unit_map_clear(rpc_port_unit_map_h map)
+{
+ if (map == nullptr) {
+ _E("Invalid parameter");
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
+ }
+
+ g_hash_table_remove_all(map->table);
+
+ return RPC_PORT_ERROR_NONE;
+}
+
+static void rpc_port_unit_map_write_remote_exception_write_cb(rpc_port_parcel_h parcel, void* data)
+{
+ rpc_port_unit_h unit = data;
+ rpc_port_proxy_hal_device_bezel_proxy_1_remote_exception_h handle = unit->data;
+
+ rpc_port_parcel_write(parcel, &handle->parcelable, handle);
+}
+
+static int rpc_port_unit_map_write_remote_exception(rpc_port_unit_map_h unit_map,
+ int name, rpc_port_proxy_hal_device_bezel_proxy_1_remote_exception_h value)
+{
+ rpc_port_unit_h unit;
+
+ if (unit_map == nullptr)
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
+
+ unit = rpc_port_unit_create(name, -1223777386 /*remote_exception*/);
+ if (unit == nullptr)
+ return RPC_PORT_ERROR_OUT_OF_MEMORY;
+
+ unit->data = value;
+ unit->write_cb = rpc_port_unit_map_write_remote_exception_write_cb;
+ g_hash_table_insert(unit_map->table, GINT_TO_POINTER(unit->name), unit);
+
+ return RPC_PORT_ERROR_NONE;
+}
+
+static void rpc_port_unit_map_read_remote_exception(rpc_port_unit_map_h unit_map,
+ int name, rpc_port_proxy_hal_device_bezel_proxy_1_remote_exception_h *value)
+{
+ rpc_port_unit_h unit;
+ rpc_port_proxy_hal_device_bezel_proxy_1_remote_exception_t *handle;
+ int ret;
+
+ if (value == nullptr) {
+ _E("Invalid parameter");
+ return;
+ }
+
+ if (unit_map == nullptr) {
+ _E("Invalid parameter");
+ return;
+ }
+
+ unit = g_hash_table_lookup(unit_map->table, GINT_TO_POINTER(name));
+ if (unit == nullptr) {
+ return;
+ }
+
+ if (unit->type != -1223777386 /*remote_exception*/) {
+ _E("type(%d) is not remote_exception", unit->type);
+ return;
+ }
+
+ ret = rpc_port_proxy_hal_device_bezel_proxy_1_remote_exception_create((rpc_port_proxy_hal_device_bezel_proxy_1_remote_exception_h *)&handle);
+ if (ret != RPC_PORT_ERROR_NONE) {
+ *value = nullptr;
+ return;
+ }
+
+ rpc_port_parcel_read(unit->parcel, &handle->parcelable, handle);
+ *value = handle;
+}
+
+static void rpc_port_unit_map_read_int(rpc_port_unit_map_h unit_map,
+ int name, int *value)
+{
+ rpc_port_unit_h unit;
+
+ if (value == nullptr) {
+ _E("Invalid parameter");
+ return;
+ }
+
+ if (unit_map == nullptr) {
+ *value = 0;
+ _E("Invalid parameter");
+ return;
+ }
+
+ unit = g_hash_table_lookup(unit_map->table, GINT_TO_POINTER(name));
+ if (unit == nullptr) {
+ _E("g_hash_table_lookup() is failed. name: %d", name);
+ *value = 0;
+ return;
+ }
+
+ if (unit->type != 104431 /*int*/) {
+ _E("type(%d) is not int", unit->type);
+ *value = 0;
+ return;
+ }
+
+ rpc_port_parcel_burst_read(unit->parcel, (unsigned char*)value, sizeof(*value));
+}
+
+static void rpc_port_unit_map_write_int_write_cb(rpc_port_parcel_h parcel, void* data)
+{
+ rpc_port_unit_h unit = data;
+ int *handle = unit->data;
+
+ rpc_port_parcel_burst_write(parcel, (const unsigned char*)handle, sizeof(*handle));
+}
+
+static int rpc_port_unit_map_write_int(rpc_port_unit_map_h unit_map,
+ int name, int *value)
+{
+ rpc_port_unit_h unit;
+
+ if (unit_map == nullptr)
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
+
+ unit = rpc_port_unit_create(name, 104431 /*int*/);
+ if (unit == nullptr)
+ return RPC_PORT_ERROR_OUT_OF_MEMORY;
+
+ unit->data = value;
+ unit->write_cb = rpc_port_unit_map_write_int_write_cb;
+
+ g_hash_table_insert(unit_map->table, GINT_TO_POINTER(unit->name), unit);
+
+ return RPC_PORT_ERROR_NONE;
+}
+
+
+static const char *__get_appid(void)
+{
+ static char *appid;
+
+ if (getuid() < 5000)
+ return appid;
+
+ if (appid == nullptr) {
+ app_get_id(&appid);
+ if (appid == nullptr)
+ _E("Failed to get appid");
+ }
+
+ return appid;
+}
+
+static void rpc_port_proxy_lem_destroy(rpc_port_proxy_lem_h handle)
+{
+ if (handle == nullptr)
+ return;
+
+ if (g_rec_mutex_trylock(&(handle->mutex)))
+ g_rec_mutex_unlock(&handle->mutex);
+
+ g_rec_mutex_clear(&handle->mutex);
+
+ if (handle->request_queue)
+ g_queue_free_full(handle->request_queue, (GDestroyNotify)rpc_port_parcel_destroy);
+
+ if (handle->result_queue)
+ g_queue_free_full(handle->result_queue, (GDestroyNotify)rpc_port_parcel_destroy);
+
+ if (handle->instance)
+ free(handle->instance);
+
+ if (handle->port_name)
+ free(handle->port_name);
+
+ if (handle->thread_context)
+ g_main_context_unref(handle->thread_context);
+
+ free(handle);
+}
+
+static rpc_port_proxy_lem_h rpc_port_proxy_lem_create(void *context, const char *port_name, rpc_port_proxy_lem_event_s* callback)
+{
+ static gint seq;
+ rpc_port_proxy_lem_h handle;
+ char buf[512] = { 0, };
+
+ if (context == nullptr || port_name == nullptr || callback == nullptr) {
+ _E("Invalid parameter");
+ return nullptr;
+ }
+
+ handle = calloc(1, sizeof(rpc_port_proxy_lem_s));
+ if (handle == nullptr) {
+ _E("Out of memory");
+ return nullptr;
+ }
+
+ g_rec_mutex_init(&handle->mutex);
+ handle->context = context;
+ handle->callback = *callback;
+ handle->port_name = strdup(port_name);
+ if (handle->port_name == nullptr) {
+ _E("Failed to duplicate port name(%s)", port_name);
+ rpc_port_proxy_lem_destroy(handle);
+ return nullptr;
+ }
+
+ g_atomic_int_inc(&seq);
+ snprintf(buf, sizeof(buf), "%s::%d", __get_appid(), g_atomic_int_get(&seq));
+ handle->instance = strdup(buf);
+ if (handle->instance == nullptr) {
+ _E("Failed to duplicate instance(%s)", buf);
+ rpc_port_proxy_lem_destroy(handle);
+ return nullptr;
+ }
+
+ handle->result_queue = g_queue_new();
+ if (handle->result_queue == nullptr) {
+ _E("g_queue_new() is failed");
+ rpc_port_proxy_lem_destroy(handle);
+ return nullptr;
+ }
+
+ handle->request_queue = g_queue_new();
+ if (handle->request_queue == nullptr) {
+ _E("g_queue_new() is failed");
+ rpc_port_proxy_lem_destroy(handle);
+ return nullptr;
+ }
+
+ handle->thread_context = g_main_context_ref_thread_default();
+
+ return handle;
+}
+
+static void rpc_port_proxy_lem_result_queue_push(rpc_port_proxy_lem_h handle, rpc_port_parcel_h parcel)
+{
+ if (handle == nullptr || parcel == nullptr)
+ return;
+
+ g_rec_mutex_lock(&handle->mutex);
+ g_queue_push_tail(handle->result_queue, parcel);
+ g_rec_mutex_unlock(&handle->mutex);
+}
+
+static rpc_port_parcel_h rpc_port_proxy_lem_result_queue_pop(rpc_port_proxy_lem_h handle)
+{
+ rpc_port_parcel_h parcel;
+
+ if (handle == nullptr)
+ return nullptr;
+
+ g_rec_mutex_lock(&handle->mutex);
+ parcel = (rpc_port_parcel_h)g_queue_pop_head(handle->result_queue);
+ g_rec_mutex_unlock(&handle->mutex);
+
+ return parcel;
+}
+
+static bool rpc_port_proxy_lem_result_queue_empty(rpc_port_proxy_lem_h handle)
+{
+ bool empty;
+
+ if (handle == nullptr)
+ return true;
+
+ g_rec_mutex_lock(&handle->mutex);
+ empty = g_queue_is_empty(handle->result_queue);
+ g_rec_mutex_unlock(&handle->mutex);
+ return empty;
+}
+
+static void rpc_port_proxy_lem_request_queue_push(rpc_port_proxy_lem_h handle, rpc_port_parcel_h parcel)
+{
+ if (handle == nullptr || parcel == nullptr)
+ return;
+
+ g_rec_mutex_lock(&handle->mutex);
+ g_queue_push_tail(handle->request_queue, parcel);
+ g_rec_mutex_unlock(&handle->mutex);
+}
+
+static rpc_port_parcel_h rpc_port_proxy_lem_request_queue_pop(rpc_port_proxy_lem_h handle)
+{
+ rpc_port_parcel_h parcel;
+
+ if (handle == nullptr)
+ return nullptr;
+
+ g_rec_mutex_lock(&handle->mutex);
+ parcel = (rpc_port_parcel_h)g_queue_pop_head(handle->request_queue);
+ g_rec_mutex_unlock(&handle->mutex);
+
+ return parcel;
+}
+
+static int rpc_port_proxy_lem_connect(rpc_port_proxy_lem_h handle, bool sync)
+{
+ int ret = RPC_PORT_ERROR_NONE;
+
+ if (handle == nullptr)
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
+
+ g_rec_mutex_lock(&handle->mutex);
+ if (handle->connecting) {
+ _E("Already connecting");
+ g_rec_mutex_unlock(&handle->mutex);
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
+ }
+
+ if (handle->connected) {
+ _E("Already connected");
+ g_rec_mutex_unlock(&handle->mutex);
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
+ }
+
+ if (handle->connect_func)
+ ret = handle->connect_func(handle, __get_appid(), handle->instance, sync);
+
+ handle->connecting = true;
+ g_rec_mutex_unlock(&handle->mutex);
+ return ret;
+}
+
+static void rpc_port_proxy_lem_disconnect(rpc_port_proxy_lem_h handle)
+{
+ if (handle == nullptr)
+ return;
+
+ g_rec_mutex_lock(&handle->mutex);
+ handle->connecting = false;
+ if (handle->disconnect_func)
+ handle->disconnect_func(handle, __get_appid(), handle->instance);
+
+ g_rec_mutex_unlock(&handle->mutex);
+}
+
+static int rpc_port_proxy_lem_send(rpc_port_proxy_lem_h handle, rpc_port_parcel_h request, rpc_port_parcel_h* result)
+{
+ int ret;
+ int count = 0;
+
+ if (handle == nullptr || request == nullptr) {
+ _E("Invalid parameter");
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
+ }
+
+ if (handle->send_func) {
+ ret = handle->send_func(handle, __get_appid(), handle->instance, request);
+ if (result != nullptr) {
+ while (rpc_port_proxy_lem_result_queue_empty(handle) && count++ < 100)
+ usleep(100 * 1000);
+
+ if (rpc_port_proxy_lem_result_queue_empty(handle)) {
+ _E("Failed to get result from server");
+ return RPC_PORT_ERROR_IO_ERROR;
+ }
+
+ *result = rpc_port_proxy_lem_result_queue_pop(handle);
+ }
+
+ return ret;
+ }
+
+ return RPC_PORT_ERROR_NONE;
+}
+
+static bool rpc_port_proxy_lem_is_connected(rpc_port_proxy_lem_h handle)
+{
+ bool ret;
+
+ if (handle == nullptr)
+ return false;
+
+ g_rec_mutex_lock(&handle->mutex);
+ ret = handle->connected;
+ g_rec_mutex_unlock(&handle->mutex);
+
+ return ret;
+}
+
+static bool rpc_port_proxy_lem_load_symbols(rpc_port_proxy_lem_h handle)
+{
+ char symbol[1024];
+
+ if (handle == nullptr)
+ return false;
+
+ if (handle->loaded)
+ return true;
+
+ if (handle->connect_func == nullptr) {
+ snprintf(symbol, sizeof(symbol), "rpc_port_stub_hal_device_bezel_ipc_1_lem_%s_connect", handle->port_name);
+ handle->connect_func = (rpc_port_stub_lem_connect_func)dlsym(RTLD_DEFAULT, symbol);
+ if (handle->connect_func == nullptr) {
+ _E("Failed to find symbol(%s)", symbol);
+ return false;
+ }
+ }
+
+ if (handle->disconnect_func == nullptr) {
+ snprintf(symbol, sizeof(symbol), "rpc_port_stub_hal_device_bezel_ipc_1_lem_%s_disconnect", handle->port_name);
+ handle->disconnect_func = (rpc_port_stub_lem_disconnect_func)dlsym(RTLD_DEFAULT, symbol);
+ if (handle->disconnect_func == nullptr) {
+ _E("Failed to find symbol(%s)", symbol);
+ return false;
+ }
+ }
+
+ if (handle->send_func == nullptr) {
+ snprintf(symbol, sizeof(symbol), "rpc_port_stub_hal_device_bezel_ipc_1_lem_%s_send", handle->port_name);
+ handle->send_func = (rpc_port_stub_lem_send_func)dlsym(RTLD_DEFAULT, symbol);
+ if (handle->send_func == nullptr) {
+ _E("Failed to find symbol(%s)", symbol);
+ return false;
+ }
+ }
+
+ handle->loaded = true;
+ return true;
+}
+
+static gboolean rpc_port_proxy_lem_on_connected(gpointer user_data)
+{
+ rpc_port_proxy_lem_h handle = user_data;
+
+ if (handle == nullptr)
+ return G_SOURCE_REMOVE;
+
+ g_rec_mutex_lock(&handle->mutex);
+ handle->connecting = false;
+ handle->connected = true;
+ if (handle->callback.connected)
+ handle->callback.connected(handle->context);
+
+ g_rec_mutex_unlock(&handle->mutex);
+ return G_SOURCE_REMOVE;
+}
+
+static gboolean rpc_port_proxy_lem_on_disconnected(gpointer user_data)
+{
+ rpc_port_proxy_lem_h handle = user_data;
+
+ if (handle == nullptr)
+ return G_SOURCE_REMOVE;
+
+ g_rec_mutex_lock(&handle->mutex);
+ handle->connecting = false;
+ handle->connected = false;
+ if (handle->callback.disconnected)
+ handle->callback.disconnected(handle->context);
+
+ g_rec_mutex_unlock(&handle->mutex);
+ return G_SOURCE_REMOVE;
+}
+
+static gboolean rpc_port_proxy_lem_on_received(gpointer user_data)
+{
+ rpc_port_proxy_lem_h handle = user_data;
+ rpc_port_parcel_h request;
+
+ if (handle == nullptr)
+ return G_SOURCE_REMOVE;
+
+ request = rpc_port_proxy_lem_request_queue_pop(handle);
+ if (handle->callback.received)
+ handle->callback.received(handle->context, request);
+
+ rpc_port_parcel_destroy(request);
+ return G_SOURCE_REMOVE;
+}
+
+
+
+
+
+
+static void __rpc_port_proxy_hal_device_bezel_proxy_1_enums_to(rpc_port_parcel_h parcel, void *data)
+{
+ rpc_port_proxy_hal_device_bezel_proxy_1_enums_t *handle = data;
+
+ if (parcel == nullptr || handle == nullptr) {
+ _E("Invalid parameter");
+ set_last_result(RPC_PORT_ERROR_INVALID_PARAMETER);
+ return;
+ }
+
+ set_last_result(RPC_PORT_ERROR_NONE);
+}
+
+static void __rpc_port_proxy_hal_device_bezel_proxy_1_enums_from(rpc_port_parcel_h parcel, void *data)
+{
+ rpc_port_proxy_hal_device_bezel_proxy_1_enums_t *handle = data;
+
+ if (parcel == nullptr || handle == nullptr) {
+ _E("Invalid parameter");
+ set_last_result(RPC_PORT_ERROR_INVALID_PARAMETER);
+ return;
+ }
+
+ set_last_result(RPC_PORT_ERROR_NONE);
+}
+
+int rpc_port_proxy_hal_device_bezel_proxy_1_enums_create(rpc_port_proxy_hal_device_bezel_proxy_1_enums_h *h)
+{
+ rpc_port_proxy_hal_device_bezel_proxy_1_enums_t *handle;
+
+ if (h == nullptr) {
+ _E("Invalid parameter");
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
+ }
+
+ handle = calloc(1, sizeof(rpc_port_proxy_hal_device_bezel_proxy_1_enums_t));
+ if (handle == nullptr) {
+ _E("Out of memory");
+ return RPC_PORT_ERROR_OUT_OF_MEMORY;
+ }
+
+ handle->parcelable.to = __rpc_port_proxy_hal_device_bezel_proxy_1_enums_to;
+ handle->parcelable.from = __rpc_port_proxy_hal_device_bezel_proxy_1_enums_from;
+
+ *h = handle;
+
+ return RPC_PORT_ERROR_NONE;
+}
+
+int rpc_port_proxy_hal_device_bezel_proxy_1_enums_destroy(rpc_port_proxy_hal_device_bezel_proxy_1_enums_h h)
+{
+ rpc_port_proxy_hal_device_bezel_proxy_1_enums_t *handle = h;
+
+ if (handle == nullptr) {
+ _E("Invalid parameter");
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
+ }
+
+ free(handle);
+
+ return RPC_PORT_ERROR_NONE;
+}
+
+int rpc_port_proxy_hal_device_bezel_proxy_1_enums_clone(rpc_port_proxy_hal_device_bezel_proxy_1_enums_h h, rpc_port_proxy_hal_device_bezel_proxy_1_enums_h *clone)
+{
+ rpc_port_proxy_hal_device_bezel_proxy_1_enums_h handle;
+ rpc_port_parcel_h parcel;
+ int ret;
+
+ if (h == nullptr || clone == nullptr) {
+ _E("Invalid parameter");
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
+ }
+
+ ret = rpc_port_proxy_hal_device_bezel_proxy_1_enums_create(&handle);
+ if (ret != RPC_PORT_ERROR_NONE) {
+ _E("Failed to create handle. error(%d)", ret);
+ return ret;
+ }
+
+ ret = rpc_port_parcel_create(&parcel);
+ if (ret != RPC_PORT_ERROR_NONE) {
+ _E("Failed to create parcel handle. error(%d)", ret);
+ rpc_port_proxy_hal_device_bezel_proxy_1_enums_destroy(handle);
+ return ret;
+ }
+
+ rpc_port_parcel_write(parcel, &h->parcelable, h);
+ rpc_port_parcel_read(parcel, &handle->parcelable, handle);
+ ret = get_last_result();
+ rpc_port_parcel_destroy(parcel);
+
+ if (ret != RPC_PORT_ERROR_NONE) {
+ _E("Failed to read data. error(%d)", ret);
+ rpc_port_proxy_hal_device_bezel_proxy_1_enums_destroy(handle);
+ return ret;
+ }
+
+ *clone = handle;
+
+ return RPC_PORT_ERROR_NONE;
+}
+
+
+static void __rpc_port_proxy_hal_device_bezel_proxy_1_remote_exception_to(rpc_port_parcel_h parcel, void *user_data)
+{
+ rpc_port_proxy_hal_device_bezel_proxy_1_remote_exception_h h = user_data;
+
+ rpc_port_parcel_write_int32(parcel, h->cause);
+ rpc_port_parcel_write_string(parcel, h->message);
+
+ set_last_result(RPC_PORT_ERROR_NONE);
+}
+
+static void __rpc_port_proxy_hal_device_bezel_proxy_1_remote_exception_from(rpc_port_parcel_h parcel, void *user_data)
+{
+ rpc_port_proxy_hal_device_bezel_proxy_1_remote_exception_h h = user_data;
+
+ rpc_port_parcel_read_int32(parcel, &h->cause);
+ rpc_port_parcel_read_string(parcel, &h->message);
+
+ set_last_result(RPC_PORT_ERROR_NONE);
+}
+
+int rpc_port_proxy_hal_device_bezel_proxy_1_remote_exception_create(rpc_port_proxy_hal_device_bezel_proxy_1_remote_exception_h *h)
+{
+ rpc_port_proxy_hal_device_bezel_proxy_1_remote_exception_h exception;
+
+ if (h == nullptr) {
+ _E("Invalid parameter");
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
+ }
+
+ exception = calloc(1, sizeof(rpc_port_proxy_hal_device_bezel_proxy_1_remote_exception_t));
+ if (exception == nullptr) {
+ _E("calloc() is failed");
+ return RPC_PORT_ERROR_OUT_OF_MEMORY;
+ }
+
+ exception->parcelable.to = __rpc_port_proxy_hal_device_bezel_proxy_1_remote_exception_to;
+ exception->parcelable.from = __rpc_port_proxy_hal_device_bezel_proxy_1_remote_exception_from;
+
+ *h = exception;
+
+ return RPC_PORT_ERROR_NONE;
+}
+
+int rpc_port_proxy_hal_device_bezel_proxy_1_remote_exception_set_cause(rpc_port_proxy_hal_device_bezel_proxy_1_remote_exception_h h, int cause)
+{
+ if (h == nullptr) {
+ _E("Invalid parameter");
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
+ }
+
+ h->cause = cause;
+
+ return RPC_PORT_ERROR_NONE;
+}
+
+int rpc_port_proxy_hal_device_bezel_proxy_1_remote_exception_set_message(rpc_port_proxy_hal_device_bezel_proxy_1_remote_exception_h h, const char *message)
+{
+ if (h == nullptr || message == nullptr) {
+ _E("Invalid parameter");
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
+ }
+
+ if (h->message)
+ free(h->message);
+
+ h->message = strdup(message);
+ if (h->message == nullptr) {
+ _E("strdup() is failed");
+ return RPC_PORT_ERROR_OUT_OF_MEMORY;
+ }
+
+ return RPC_PORT_ERROR_NONE;
+}
+
+int rpc_port_proxy_hal_device_bezel_proxy_1_remote_exception_get_cause(rpc_port_proxy_hal_device_bezel_proxy_1_remote_exception_h h, int *cause)
+{
+ if (h == nullptr || cause == nullptr) {
+ _E("Invalid parameter");
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
+ }
+
+ *cause = h->cause;
+
+ return RPC_PORT_ERROR_NONE;
+}
+
+int rpc_port_proxy_hal_device_bezel_proxy_1_remote_exception_get_message(rpc_port_proxy_hal_device_bezel_proxy_1_remote_exception_h h, char **message)
+{
+ if (h == nullptr || message == nullptr) {
+ _E("Invalid parameter");
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
+ }
+
+ *message = strdup(h->message);
+ if (*message == nullptr) {
+ _E("strdup() is failed");
+ return RPC_PORT_ERROR_OUT_OF_MEMORY;
+ }
+
+ return RPC_PORT_ERROR_NONE;
+}
+
+int rpc_port_proxy_hal_device_bezel_proxy_1_remote_exception_destroy(rpc_port_proxy_hal_device_bezel_proxy_1_remote_exception_h h)
+{
+ if (h == nullptr) {
+ _E("Invalid parameter");
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
+ }
+
+ if (h->message)
+ free(h->message);
+
+ free(h);
+
+ return RPC_PORT_ERROR_NONE;
+}
+
+int rpc_port_proxy_hal_device_bezel_proxy_1_get_remote_exception(rpc_port_proxy_hal_device_bezel_proxy_1_remote_exception_h *h)
+{
+ rpc_port_proxy_hal_device_bezel_proxy_1_remote_exception_h handle;
+ int ret;
+
+ if (h == nullptr) {
+ _E("Invalid parameter");
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
+ }
+
+ if (__rpc_port_proxy_hal_device_bezel_proxy_1_remote_exception == nullptr) {
+ _W("There is no exceptions");
+ *h = nullptr;
+ return RPC_PORT_ERROR_NONE;
+ }
+
+ ret = rpc_port_proxy_hal_device_bezel_proxy_1_remote_exception_create(&handle);
+ if (ret != RPC_PORT_ERROR_NONE) {
+ _E("Failed to create remote exception");
+ return RPC_PORT_ERROR_OUT_OF_MEMORY;
+ }
+
+ handle->cause = __rpc_port_proxy_hal_device_bezel_proxy_1_remote_exception->cause;
+ handle->message = __rpc_port_proxy_hal_device_bezel_proxy_1_remote_exception->message ?
+ strdup(__rpc_port_proxy_hal_device_bezel_proxy_1_remote_exception->message) : nullptr;
+ *h = handle;
+
+ return RPC_PORT_ERROR_NONE;
+}
+
+
+
+
+
+
+
+typedef enum {
+ RPC_PORT_PROXY_HAL_DEVICE_BEZEL_PROXY_1_DEVICE_BEZEL_METHOD_RESULT_,
+ RPC_PORT_PROXY_HAL_DEVICE_BEZEL_PROXY_1_DEVICE_BEZEL_METHOD_CALLBACK_,
+ RPC_PORT_PROXY_HAL_DEVICE_BEZEL_PROXY_1_DEVICE_BEZEL_METHOD_GET_STATE,
+ RPC_PORT_PROXY_HAL_DEVICE_BEZEL_PROXY_1_DEVICE_BEZEL_METHOD_SET_STATE,
+ RPC_PORT_PROXY_HAL_DEVICE_BEZEL_PROXY_1_DEVICE_BEZEL_METHOD_GET_SW_STATE,
+ RPC_PORT_PROXY_HAL_DEVICE_BEZEL_PROXY_1_DEVICE_BEZEL_METHOD_SET_SW_STATE,
+ RPC_PORT_PROXY_HAL_DEVICE_BEZEL_PROXY_1_DEVICE_BEZEL_METHOD_GET_VIB_STATE,
+ RPC_PORT_PROXY_HAL_DEVICE_BEZEL_PROXY_1_DEVICE_BEZEL_METHOD_SET_VIB_STATE,
+} rpc_port_proxy_hal_device_bezel_proxy_1_device_bezel_method_e;
+
+
+
+static void __rpc_port_proxy_hal_device_bezel_proxy_1_device_bezel_consume_command(rpc_port_h port, int seq_num, rpc_port_unit_map_h *unit_map)
+{
+ rpc_port_parcel_h parcel;
+ rpc_port_parcel_header_h header;
+ rpc_port_unit_map_h map;
+ int recv_seq_num = -1;
+ int cmd = -1;
+ int ret;
+
+ map = rpc_port_unit_map_create();
+ if (map == nullptr) {
+ _E("Failed to create unit map");
+ return;
+ }
+
+ do {
+ ret = rpc_port_parcel_create_from_port(&parcel, port);
+ if (ret != RPC_PORT_ERROR_NONE) {
+ _E("Failed to create parcel from port. error(%d)", ret);
+ break;
+ }
+
+ rpc_port_parcel_get_header(parcel, &header);
+ rpc_port_parcel_header_get_seq_num(header, &recv_seq_num);
+ if (recv_seq_num != seq_num) {
+ _W("%d : %d", recv_seq_num, seq_num);
+ rpc_port_parcel_destroy(parcel);
+ continue;
+ }
+
+ rpc_port_parcel_read(parcel, &map->parcelable, map);
+ rpc_port_parcel_destroy(parcel);
+
+ rpc_port_unit_map_read_int(map, 1355467489 /*[METHOD]*/, &cmd);
+ if (cmd == RPC_PORT_PROXY_HAL_DEVICE_BEZEL_PROXY_1_DEVICE_BEZEL_METHOD_RESULT_) {
+ if (__rpc_port_proxy_hal_device_bezel_proxy_1_remote_exception != nullptr)
+ rpc_port_proxy_hal_device_bezel_proxy_1_remote_exception_destroy(__rpc_port_proxy_hal_device_bezel_proxy_1_remote_exception);
+
+ __rpc_port_proxy_hal_device_bezel_proxy_1_remote_exception = nullptr;
+ rpc_port_unit_map_read_remote_exception(map, -1571313492 /*[REMOTE_EXCEPTION]*/, &__rpc_port_proxy_hal_device_bezel_proxy_1_remote_exception);
+
+ *unit_map = map;
+ return;
+ }
+
+ rpc_port_unit_map_clear(map);
+ } while (true);
+
+ rpc_port_unit_map_destroy(map);
+ *unit_map = nullptr;
+}
+
+static void __rpc_port_proxy_hal_device_bezel_proxy_1_device_bezel_connected(const char *endpoint, const char *port_name, rpc_port_h port, void *data)
+{
+ rpc_port_proxy_hal_device_bezel_proxy_1_device_bezel_h h = data;
+
+ _I("endpoint(%s), port_name(%s)", endpoint, port_name);
+ h->port = port;
+ rpc_port_proxy_get_port(h->proxy, RPC_PORT_PORT_CALLBACK, &h->callback_port);
+ h->callback.connected(h, h->user_data);
+}
+
+static void __rpc_port_proxy_hal_device_bezel_proxy_1_device_bezel_disconnected(const char *endpoint, const char *port_name, void *data)
+{
+ rpc_port_proxy_hal_device_bezel_proxy_1_device_bezel_h h = data;
+
+ _W("endpoint(%s), port_name(%s)", endpoint, port_name);
+ h->port = nullptr;
+ h->callback.disconnected(h, h->user_data);
+}
+
+static void __rpc_port_proxy_hal_device_bezel_proxy_1_device_bezel_rejected(const char *endpoint, const char *port_name, void *data)
+{
+ rpc_port_proxy_hal_device_bezel_proxy_1_device_bezel_h h = data;
+
+ _W("endpoint(%s), port_name(%s)", endpoint, port_name);
+ h->port = nullptr;
+ h->callback.rejected(h, h->user_data);
+}
+
+static void __rpc_port_proxy_hal_device_bezel_proxy_1_device_bezel_lem_connected(void *context)
+{
+ rpc_port_proxy_hal_device_bezel_proxy_1_device_bezel_t *handle = context;
+
+ handle->callback.connected(handle, handle->user_data);
+}
+
+static void __rpc_port_proxy_hal_device_bezel_proxy_1_device_bezel_lem_disconnected(void *context)
+{
+ rpc_port_proxy_hal_device_bezel_proxy_1_device_bezel_t *handle = context;
+
+ handle->callback.disconnected(handle, handle->user_data);
+}
+
+int rpc_port_proxy_hal_device_bezel_proxy_1_device_bezel_create(const char *stub_appid, rpc_port_proxy_hal_device_bezel_proxy_1_device_bezel_callback_s *callback, void *user_data, rpc_port_proxy_hal_device_bezel_proxy_1_device_bezel_h *h)
+{
+ rpc_port_proxy_hal_device_bezel_proxy_1_device_bezel_t *handle;
+ int ret;
+ rpc_port_proxy_lem_event_s lem_callback = { 0, };
+ const char *appid = __get_appid();
+
+ rpc_port_internal_init();
+
+ if (stub_appid == nullptr || callback == nullptr || h == nullptr) {
+ _E("Invalid parameter");
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
+ }
+
+ if (callback->connected == nullptr || callback->disconnected == nullptr || callback->rejected == nullptr) {
+ _E("Invalid parameter");
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
+ }
+
+ handle = calloc(1, sizeof(rpc_port_proxy_hal_device_bezel_proxy_1_device_bezel_t));
+ if (handle == nullptr) {
+ _E("Out of memory");
+ return RPC_PORT_ERROR_OUT_OF_MEMORY;
+ }
+
+ g_rec_mutex_init(&handle->mutex);
+
+ handle->stub_appid = strdup(stub_appid);
+ if (handle->stub_appid == nullptr) {
+ _E("Failed to duplicate stub appid");
+ rpc_port_proxy_hal_device_bezel_proxy_1_device_bezel_destroy(handle);
+ return RPC_PORT_ERROR_OUT_OF_MEMORY;
+ }
+
+ ret = rpc_port_proxy_create(&handle->proxy);
+ if (ret != RPC_PORT_ERROR_NONE) {
+ _E("Failed to create proxy handle. error(%d)", ret);
+ rpc_port_proxy_hal_device_bezel_proxy_1_device_bezel_destroy(handle);
+ return ret;
+ }
+
+ handle->callback = *callback;
+ handle->user_data = user_data;
+
+ ret = rpc_port_proxy_add_connected_event_cb(handle->proxy, __rpc_port_proxy_hal_device_bezel_proxy_1_device_bezel_connected, handle);
+ if (ret != RPC_PORT_ERROR_NONE) {
+ _E("Failed to add connected event cb. error(%d)", ret);
+ rpc_port_proxy_hal_device_bezel_proxy_1_device_bezel_destroy(handle);
+ return ret;
+ }
+
+ ret = rpc_port_proxy_add_disconnected_event_cb(handle->proxy, __rpc_port_proxy_hal_device_bezel_proxy_1_device_bezel_disconnected, handle);
+ if (ret != RPC_PORT_ERROR_NONE) {
+ _E("Failed to add disconnected event cb. error(%d)", ret);
+ rpc_port_proxy_hal_device_bezel_proxy_1_device_bezel_destroy(handle);
+ return ret;
+ }
+
+ ret = rpc_port_proxy_add_rejected_event_cb(handle->proxy, __rpc_port_proxy_hal_device_bezel_proxy_1_device_bezel_rejected, handle);
+ if (ret != RPC_PORT_ERROR_NONE) {
+ _E("Failed to add rejected event cb. error(%d)", ret);
+ rpc_port_proxy_hal_device_bezel_proxy_1_device_bezel_destroy(handle);
+ return ret;
+ }
+
+ lem_callback.connected = __rpc_port_proxy_hal_device_bezel_proxy_1_device_bezel_lem_connected;
+ lem_callback.disconnected = __rpc_port_proxy_hal_device_bezel_proxy_1_device_bezel_lem_disconnected;
+
+ if (appid != nullptr && !strcmp(appid, stub_appid)) {
+ handle->lem = rpc_port_proxy_lem_create(handle, "device_bezel", &lem_callback);
+ if (handle->lem == nullptr) {
+ _E("Failed to create lem");
+ rpc_port_proxy_hal_device_bezel_proxy_1_device_bezel_destroy(handle);
+ return RPC_PORT_ERROR_OUT_OF_MEMORY;
+ }
+
+ rpc_port_proxy_lem_load_symbols(handle->lem);
+ }
+ *h = handle;
+
+ return RPC_PORT_ERROR_NONE;
+}
+
+int rpc_port_proxy_hal_device_bezel_proxy_1_device_bezel_destroy(rpc_port_proxy_hal_device_bezel_proxy_1_device_bezel_h h)
+{
+ if (h == nullptr) {
+ _E("Invalid parameter");
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
+ }
+
+ g_rec_mutex_lock(&h->mutex);
+ g_rec_mutex_unlock(&h->mutex);
+ g_rec_mutex_clear(&h->mutex);
+
+ if (h->delegates)
+ g_list_free_full(h->delegates, free);
+
+ if (h->proxy)
+ rpc_port_proxy_destroy(h->proxy);
+
+ if (h->stub_appid)
+ free(h->stub_appid);
+
+ if (h->lem) {
+ rpc_port_proxy_lem_disconnect(h->lem);
+ rpc_port_proxy_lem_destroy(h->lem);
+ }
+
+ free(h);
+
+ return RPC_PORT_ERROR_NONE;
+}
+
+int rpc_port_proxy_hal_device_bezel_proxy_1_device_bezel_connect(rpc_port_proxy_hal_device_bezel_proxy_1_device_bezel_h h)
+{
+ int ret;
+
+ if (h == nullptr || h->proxy == nullptr) {
+ _E("Invalid parameter");
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
+ }
+
+ if (h->lem != nullptr && rpc_port_proxy_lem_load_symbols(h->lem))
+ ret = rpc_port_proxy_lem_connect(h->lem, false);
+ else
+ ret = rpc_port_proxy_connect(h->proxy, h->stub_appid, "device_bezel");
+
+ if (ret != RPC_PORT_ERROR_NONE) {
+ _E("Failed to connect to stub. error(%d)", ret);
+ return ret;
+ }
+
+ return RPC_PORT_ERROR_NONE;
+}
+
+int rpc_port_proxy_hal_device_bezel_proxy_1_device_bezel_connect_sync(rpc_port_proxy_hal_device_bezel_proxy_1_device_bezel_h h)
+{
+ int ret;
+
+ if (h == nullptr || h->proxy == nullptr) {
+ _E("Invalid parameter");
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
+ }
+
+ if (h->lem != nullptr && rpc_port_proxy_lem_load_symbols(h->lem))
+ ret = rpc_port_proxy_lem_connect(h->lem, true);
+ else
+ ret = rpc_port_proxy_connect_sync(h->proxy, h->stub_appid, "device_bezel");
+
+ if (ret != RPC_PORT_ERROR_NONE) {
+ _E("Failed to connect to stub. error(%d)", ret);
+ return ret;
+ }
+
+ return RPC_PORT_ERROR_NONE;
+}
+
+int rpc_port_proxy_hal_device_bezel_proxy_1_device_bezel_disconnect(rpc_port_proxy_hal_device_bezel_proxy_1_device_bezel_h h)
+{
+ int ret;
+
+ if (h == nullptr ) {
+ _E("Invalid parameter");
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
+ }
+
+ if (h->proxy == nullptr) {
+ _E("Invalid parameter");
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
+ }
+
+ if (h->lem != nullptr && rpc_port_proxy_lem_is_connected(h->lem))
+ {
+ rpc_port_proxy_lem_disconnect(h->lem);
+ return RPC_PORT_ERROR_NONE;
+ }
+
+ ret = rpc_port_disconnect(h->port);
+ if (ret != RPC_PORT_ERROR_NONE) {
+ _E("Failed to disconnect from stub. error(%d)", ret);
+ return ret;
+ }
+
+ return RPC_PORT_ERROR_NONE;
+}
+
+
+int rpc_port_proxy_hal_device_bezel_proxy_1_device_bezel_invoke_get_state(rpc_port_proxy_hal_device_bezel_proxy_1_device_bezel_h h, rpc_port_proxy_hal_device_bezel_proxy_1_enums_state_e *state)
+{
+ rpc_port_parcel_h parcel_;
+ rpc_port_parcel_header_h header_;
+ rpc_port_unit_map_h map_;
+ int seq_num_ = -1;
+ int res_;
+ int method_ = RPC_PORT_PROXY_HAL_DEVICE_BEZEL_PROXY_1_DEVICE_BEZEL_METHOD_GET_STATE;
+ int ret_ = -1;
+ rpc_port_proxy_hal_device_bezel_proxy_1_enums_state_e new_state;
+
+ if (h == nullptr) {
+ _E("Invalid parameter");
+ set_last_result(RPC_PORT_ERROR_INVALID_PARAMETER);
+ return ret_;
+ }
+
+ if (h->port == nullptr && !rpc_port_proxy_lem_is_connected(h->lem)) {
+ _E("Not connected");
+ set_last_result(RPC_PORT_ERROR_INVALID_PARAMETER);
+ return ret_;
+ }
+
+ res_ = rpc_port_parcel_create(&parcel_);
+ if (res_ != RPC_PORT_ERROR_NONE) {
+ _E("Failed to create parcel handle. error(%d)", res_);
+ set_last_result(res_);
+ return ret_;
+ }
+
+ rpc_port_parcel_get_header(parcel_, &header_);
+ rpc_port_parcel_header_set_tag(header_, TIDL_VERSION);
+ rpc_port_parcel_header_get_seq_num(header_, &seq_num_);
+
+ map_ = rpc_port_unit_map_create();
+ if (map_ == nullptr) {
+ _E("Failed to create unit map");
+ rpc_port_parcel_destroy(parcel_);
+ set_last_result(RPC_PORT_ERROR_OUT_OF_MEMORY);
+ return ret_;
+ }
+
+ rpc_port_unit_map_write_int(map_, 1355467489 /*[METHOD]*/, &method_);
+
+ rpc_port_parcel_write(parcel_, &map_->parcelable, map_);
+ rpc_port_unit_map_destroy(map_);
+
+ g_rec_mutex_lock(&h->mutex);
+ rpc_port_parcel_h result_parcel_ = nullptr;
+ if (rpc_port_proxy_lem_is_connected(h->lem))
+ res_ = rpc_port_proxy_lem_send(h->lem, parcel_, &result_parcel_);
+ else
+ res_ = rpc_port_parcel_send(parcel_, h->port);
+
+ rpc_port_parcel_destroy(parcel_);
+ if (res_ != RPC_PORT_ERROR_NONE) {
+ _E("Failed to send parcel. error(%d)", res_);
+ set_last_result(res_);
+ g_rec_mutex_unlock(&h->mutex);
+ return ret_;
+ }
+
+ do {
+ map_ = nullptr;
+ if (rpc_port_proxy_lem_is_connected(h->lem)) {
+ map_ = rpc_port_unit_map_create();
+ rpc_port_parcel_read(result_parcel_, &map_->parcelable, map_);
+ rpc_port_parcel_destroy(result_parcel_);
+ } else {
+ __rpc_port_proxy_hal_device_bezel_proxy_1_device_bezel_consume_command(h->port, seq_num_, &map_);
+ }
+
+ if (map_ == nullptr) {
+ _E("Invalid protocol");
+ res_ = RPC_PORT_ERROR_IO_ERROR;
+ break;
+ }
+
+ rpc_port_unit_map_read_int(map_, 109757585 /*state*/, (int *)&new_state);
+
+ *state = new_state;
+
+ rpc_port_unit_map_read_int(map_, 1497479973 /*[RESULT]*/, &ret_);
+
+ rpc_port_unit_map_destroy(map_);
+ } while (0);
+ g_rec_mutex_unlock(&h->mutex);
+ set_last_result(res_);
+
+ return ret_;
+}
+
+
+int rpc_port_proxy_hal_device_bezel_proxy_1_device_bezel_invoke_set_state(rpc_port_proxy_hal_device_bezel_proxy_1_device_bezel_h h, rpc_port_proxy_hal_device_bezel_proxy_1_enums_state_e state)
+{
+ rpc_port_parcel_h parcel_;
+ rpc_port_parcel_header_h header_;
+ rpc_port_unit_map_h map_;
+ int seq_num_ = -1;
+ int res_;
+ int method_ = RPC_PORT_PROXY_HAL_DEVICE_BEZEL_PROXY_1_DEVICE_BEZEL_METHOD_SET_STATE;
+ int ret_ = -1;
+
+ if (h == nullptr) {
+ _E("Invalid parameter");
+ set_last_result(RPC_PORT_ERROR_INVALID_PARAMETER);
+ return ret_;
+ }
+
+ if (h->port == nullptr && !rpc_port_proxy_lem_is_connected(h->lem)) {
+ _E("Not connected");
+ set_last_result(RPC_PORT_ERROR_INVALID_PARAMETER);
+ return ret_;
+ }
+
+ res_ = rpc_port_parcel_create(&parcel_);
+ if (res_ != RPC_PORT_ERROR_NONE) {
+ _E("Failed to create parcel handle. error(%d)", res_);
+ set_last_result(res_);
+ return ret_;
+ }
+
+ rpc_port_parcel_get_header(parcel_, &header_);
+ rpc_port_parcel_header_set_tag(header_, TIDL_VERSION);
+ rpc_port_parcel_header_get_seq_num(header_, &seq_num_);
+
+ map_ = rpc_port_unit_map_create();
+ if (map_ == nullptr) {
+ _E("Failed to create unit map");
+ rpc_port_parcel_destroy(parcel_);
+ set_last_result(RPC_PORT_ERROR_OUT_OF_MEMORY);
+ return ret_;
+ }
+
+ rpc_port_unit_map_write_int(map_, 1355467489 /*[METHOD]*/, &method_);
+ rpc_port_unit_map_write_int(map_, 109757585 /*state*/, (int*)&state);
+
+ rpc_port_parcel_write(parcel_, &map_->parcelable, map_);
+ rpc_port_unit_map_destroy(map_);
+
+ g_rec_mutex_lock(&h->mutex);
+ rpc_port_parcel_h result_parcel_ = nullptr;
+ if (rpc_port_proxy_lem_is_connected(h->lem))
+ res_ = rpc_port_proxy_lem_send(h->lem, parcel_, &result_parcel_);
+ else
+ res_ = rpc_port_parcel_send(parcel_, h->port);
+
+ rpc_port_parcel_destroy(parcel_);
+ if (res_ != RPC_PORT_ERROR_NONE) {
+ _E("Failed to send parcel. error(%d)", res_);
+ set_last_result(res_);
+ g_rec_mutex_unlock(&h->mutex);
+ return ret_;
+ }
+
+ do {
+ map_ = nullptr;
+ if (rpc_port_proxy_lem_is_connected(h->lem)) {
+ map_ = rpc_port_unit_map_create();
+ rpc_port_parcel_read(result_parcel_, &map_->parcelable, map_);
+ rpc_port_parcel_destroy(result_parcel_);
+ } else {
+ __rpc_port_proxy_hal_device_bezel_proxy_1_device_bezel_consume_command(h->port, seq_num_, &map_);
+ }
+
+ if (map_ == nullptr) {
+ _E("Invalid protocol");
+ res_ = RPC_PORT_ERROR_IO_ERROR;
+ break;
+ }
+
+ rpc_port_unit_map_read_int(map_, 1497479973 /*[RESULT]*/, &ret_);
+
+ rpc_port_unit_map_destroy(map_);
+ } while (0);
+ g_rec_mutex_unlock(&h->mutex);
+ set_last_result(res_);
+
+ return ret_;
+}
+
+
+int rpc_port_proxy_hal_device_bezel_proxy_1_device_bezel_invoke_get_sw_state(rpc_port_proxy_hal_device_bezel_proxy_1_device_bezel_h h, rpc_port_proxy_hal_device_bezel_proxy_1_enums_state_e *state)
+{
+ rpc_port_parcel_h parcel_;
+ rpc_port_parcel_header_h header_;
+ rpc_port_unit_map_h map_;
+ int seq_num_ = -1;
+ int res_;
+ int method_ = RPC_PORT_PROXY_HAL_DEVICE_BEZEL_PROXY_1_DEVICE_BEZEL_METHOD_GET_SW_STATE;
+ int ret_ = -1;
+ rpc_port_proxy_hal_device_bezel_proxy_1_enums_state_e new_state;
+
+ if (h == nullptr) {
+ _E("Invalid parameter");
+ set_last_result(RPC_PORT_ERROR_INVALID_PARAMETER);
+ return ret_;
+ }
+
+ if (h->port == nullptr && !rpc_port_proxy_lem_is_connected(h->lem)) {
+ _E("Not connected");
+ set_last_result(RPC_PORT_ERROR_INVALID_PARAMETER);
+ return ret_;
+ }
+
+ res_ = rpc_port_parcel_create(&parcel_);
+ if (res_ != RPC_PORT_ERROR_NONE) {
+ _E("Failed to create parcel handle. error(%d)", res_);
+ set_last_result(res_);
+ return ret_;
+ }
+
+ rpc_port_parcel_get_header(parcel_, &header_);
+ rpc_port_parcel_header_set_tag(header_, TIDL_VERSION);
+ rpc_port_parcel_header_get_seq_num(header_, &seq_num_);
+
+ map_ = rpc_port_unit_map_create();
+ if (map_ == nullptr) {
+ _E("Failed to create unit map");
+ rpc_port_parcel_destroy(parcel_);
+ set_last_result(RPC_PORT_ERROR_OUT_OF_MEMORY);
+ return ret_;
+ }
+
+ rpc_port_unit_map_write_int(map_, 1355467489 /*[METHOD]*/, &method_);
+
+ rpc_port_parcel_write(parcel_, &map_->parcelable, map_);
+ rpc_port_unit_map_destroy(map_);
+
+ g_rec_mutex_lock(&h->mutex);
+ rpc_port_parcel_h result_parcel_ = nullptr;
+ if (rpc_port_proxy_lem_is_connected(h->lem))
+ res_ = rpc_port_proxy_lem_send(h->lem, parcel_, &result_parcel_);
+ else
+ res_ = rpc_port_parcel_send(parcel_, h->port);
+
+ rpc_port_parcel_destroy(parcel_);
+ if (res_ != RPC_PORT_ERROR_NONE) {
+ _E("Failed to send parcel. error(%d)", res_);
+ set_last_result(res_);
+ g_rec_mutex_unlock(&h->mutex);
+ return ret_;
+ }
+
+ do {
+ map_ = nullptr;
+ if (rpc_port_proxy_lem_is_connected(h->lem)) {
+ map_ = rpc_port_unit_map_create();
+ rpc_port_parcel_read(result_parcel_, &map_->parcelable, map_);
+ rpc_port_parcel_destroy(result_parcel_);
+ } else {
+ __rpc_port_proxy_hal_device_bezel_proxy_1_device_bezel_consume_command(h->port, seq_num_, &map_);
+ }
+
+ if (map_ == nullptr) {
+ _E("Invalid protocol");
+ res_ = RPC_PORT_ERROR_IO_ERROR;
+ break;
+ }
+
+ rpc_port_unit_map_read_int(map_, 109757585 /*state*/, (int *)&new_state);
+
+ *state = new_state;
+
+ rpc_port_unit_map_read_int(map_, 1497479973 /*[RESULT]*/, &ret_);
+
+ rpc_port_unit_map_destroy(map_);
+ } while (0);
+ g_rec_mutex_unlock(&h->mutex);
+ set_last_result(res_);
+
+ return ret_;
+}
+
+
+int rpc_port_proxy_hal_device_bezel_proxy_1_device_bezel_invoke_set_sw_state(rpc_port_proxy_hal_device_bezel_proxy_1_device_bezel_h h, rpc_port_proxy_hal_device_bezel_proxy_1_enums_state_e state)
+{
+ rpc_port_parcel_h parcel_;
+ rpc_port_parcel_header_h header_;
+ rpc_port_unit_map_h map_;
+ int seq_num_ = -1;
+ int res_;
+ int method_ = RPC_PORT_PROXY_HAL_DEVICE_BEZEL_PROXY_1_DEVICE_BEZEL_METHOD_SET_SW_STATE;
+ int ret_ = -1;
+
+ if (h == nullptr) {
+ _E("Invalid parameter");
+ set_last_result(RPC_PORT_ERROR_INVALID_PARAMETER);
+ return ret_;
+ }
+
+ if (h->port == nullptr && !rpc_port_proxy_lem_is_connected(h->lem)) {
+ _E("Not connected");
+ set_last_result(RPC_PORT_ERROR_INVALID_PARAMETER);
+ return ret_;
+ }
+
+ res_ = rpc_port_parcel_create(&parcel_);
+ if (res_ != RPC_PORT_ERROR_NONE) {
+ _E("Failed to create parcel handle. error(%d)", res_);
+ set_last_result(res_);
+ return ret_;
+ }
+
+ rpc_port_parcel_get_header(parcel_, &header_);
+ rpc_port_parcel_header_set_tag(header_, TIDL_VERSION);
+ rpc_port_parcel_header_get_seq_num(header_, &seq_num_);
+
+ map_ = rpc_port_unit_map_create();
+ if (map_ == nullptr) {
+ _E("Failed to create unit map");
+ rpc_port_parcel_destroy(parcel_);
+ set_last_result(RPC_PORT_ERROR_OUT_OF_MEMORY);
+ return ret_;
+ }
+
+ rpc_port_unit_map_write_int(map_, 1355467489 /*[METHOD]*/, &method_);
+ rpc_port_unit_map_write_int(map_, 109757585 /*state*/, (int*)&state);
+
+ rpc_port_parcel_write(parcel_, &map_->parcelable, map_);
+ rpc_port_unit_map_destroy(map_);
+
+ g_rec_mutex_lock(&h->mutex);
+ rpc_port_parcel_h result_parcel_ = nullptr;
+ if (rpc_port_proxy_lem_is_connected(h->lem))
+ res_ = rpc_port_proxy_lem_send(h->lem, parcel_, &result_parcel_);
+ else
+ res_ = rpc_port_parcel_send(parcel_, h->port);
+
+ rpc_port_parcel_destroy(parcel_);
+ if (res_ != RPC_PORT_ERROR_NONE) {
+ _E("Failed to send parcel. error(%d)", res_);
+ set_last_result(res_);
+ g_rec_mutex_unlock(&h->mutex);
+ return ret_;
+ }
+
+ do {
+ map_ = nullptr;
+ if (rpc_port_proxy_lem_is_connected(h->lem)) {
+ map_ = rpc_port_unit_map_create();
+ rpc_port_parcel_read(result_parcel_, &map_->parcelable, map_);
+ rpc_port_parcel_destroy(result_parcel_);
+ } else {
+ __rpc_port_proxy_hal_device_bezel_proxy_1_device_bezel_consume_command(h->port, seq_num_, &map_);
+ }
+
+ if (map_ == nullptr) {
+ _E("Invalid protocol");
+ res_ = RPC_PORT_ERROR_IO_ERROR;
+ break;
+ }
+
+ rpc_port_unit_map_read_int(map_, 1497479973 /*[RESULT]*/, &ret_);
+
+ rpc_port_unit_map_destroy(map_);
+ } while (0);
+ g_rec_mutex_unlock(&h->mutex);
+ set_last_result(res_);
+
+ return ret_;
+}
+
+
+int rpc_port_proxy_hal_device_bezel_proxy_1_device_bezel_invoke_get_vib_state(rpc_port_proxy_hal_device_bezel_proxy_1_device_bezel_h h, rpc_port_proxy_hal_device_bezel_proxy_1_enums_vib_state_e *state)
+{
+ rpc_port_parcel_h parcel_;
+ rpc_port_parcel_header_h header_;
+ rpc_port_unit_map_h map_;
+ int seq_num_ = -1;
+ int res_;
+ int method_ = RPC_PORT_PROXY_HAL_DEVICE_BEZEL_PROXY_1_DEVICE_BEZEL_METHOD_GET_VIB_STATE;
+ int ret_ = -1;
+ rpc_port_proxy_hal_device_bezel_proxy_1_enums_vib_state_e new_state;
+
+ if (h == nullptr) {
+ _E("Invalid parameter");
+ set_last_result(RPC_PORT_ERROR_INVALID_PARAMETER);
+ return ret_;
+ }
+
+ if (h->port == nullptr && !rpc_port_proxy_lem_is_connected(h->lem)) {
+ _E("Not connected");
+ set_last_result(RPC_PORT_ERROR_INVALID_PARAMETER);
+ return ret_;
+ }
+
+ res_ = rpc_port_parcel_create(&parcel_);
+ if (res_ != RPC_PORT_ERROR_NONE) {
+ _E("Failed to create parcel handle. error(%d)", res_);
+ set_last_result(res_);
+ return ret_;
+ }
+
+ rpc_port_parcel_get_header(parcel_, &header_);
+ rpc_port_parcel_header_set_tag(header_, TIDL_VERSION);
+ rpc_port_parcel_header_get_seq_num(header_, &seq_num_);
+
+ map_ = rpc_port_unit_map_create();
+ if (map_ == nullptr) {
+ _E("Failed to create unit map");
+ rpc_port_parcel_destroy(parcel_);
+ set_last_result(RPC_PORT_ERROR_OUT_OF_MEMORY);
+ return ret_;
+ }
+
+ rpc_port_unit_map_write_int(map_, 1355467489 /*[METHOD]*/, &method_);
+
+ rpc_port_parcel_write(parcel_, &map_->parcelable, map_);
+ rpc_port_unit_map_destroy(map_);
+
+ g_rec_mutex_lock(&h->mutex);
+ rpc_port_parcel_h result_parcel_ = nullptr;
+ if (rpc_port_proxy_lem_is_connected(h->lem))
+ res_ = rpc_port_proxy_lem_send(h->lem, parcel_, &result_parcel_);
+ else
+ res_ = rpc_port_parcel_send(parcel_, h->port);
+
+ rpc_port_parcel_destroy(parcel_);
+ if (res_ != RPC_PORT_ERROR_NONE) {
+ _E("Failed to send parcel. error(%d)", res_);
+ set_last_result(res_);
+ g_rec_mutex_unlock(&h->mutex);
+ return ret_;
+ }
+
+ do {
+ map_ = nullptr;
+ if (rpc_port_proxy_lem_is_connected(h->lem)) {
+ map_ = rpc_port_unit_map_create();
+ rpc_port_parcel_read(result_parcel_, &map_->parcelable, map_);
+ rpc_port_parcel_destroy(result_parcel_);
+ } else {
+ __rpc_port_proxy_hal_device_bezel_proxy_1_device_bezel_consume_command(h->port, seq_num_, &map_);
+ }
+
+ if (map_ == nullptr) {
+ _E("Invalid protocol");
+ res_ = RPC_PORT_ERROR_IO_ERROR;
+ break;
+ }
+
+ rpc_port_unit_map_read_int(map_, 109757585 /*state*/, (int *)&new_state);
+
+ *state = new_state;
+
+ rpc_port_unit_map_read_int(map_, 1497479973 /*[RESULT]*/, &ret_);
+
+ rpc_port_unit_map_destroy(map_);
+ } while (0);
+ g_rec_mutex_unlock(&h->mutex);
+ set_last_result(res_);
+
+ return ret_;
+}
+
+
+int rpc_port_proxy_hal_device_bezel_proxy_1_device_bezel_invoke_set_vib_state(rpc_port_proxy_hal_device_bezel_proxy_1_device_bezel_h h, rpc_port_proxy_hal_device_bezel_proxy_1_enums_vib_state_e state)
+{
+ rpc_port_parcel_h parcel_;
+ rpc_port_parcel_header_h header_;
+ rpc_port_unit_map_h map_;
+ int seq_num_ = -1;
+ int res_;
+ int method_ = RPC_PORT_PROXY_HAL_DEVICE_BEZEL_PROXY_1_DEVICE_BEZEL_METHOD_SET_VIB_STATE;
+ int ret_ = -1;
+
+ if (h == nullptr) {
+ _E("Invalid parameter");
+ set_last_result(RPC_PORT_ERROR_INVALID_PARAMETER);
+ return ret_;
+ }
+
+ if (h->port == nullptr && !rpc_port_proxy_lem_is_connected(h->lem)) {
+ _E("Not connected");
+ set_last_result(RPC_PORT_ERROR_INVALID_PARAMETER);
+ return ret_;
+ }
+
+ res_ = rpc_port_parcel_create(&parcel_);
+ if (res_ != RPC_PORT_ERROR_NONE) {
+ _E("Failed to create parcel handle. error(%d)", res_);
+ set_last_result(res_);
+ return ret_;
+ }
+
+ rpc_port_parcel_get_header(parcel_, &header_);
+ rpc_port_parcel_header_set_tag(header_, TIDL_VERSION);
+ rpc_port_parcel_header_get_seq_num(header_, &seq_num_);
+
+ map_ = rpc_port_unit_map_create();
+ if (map_ == nullptr) {
+ _E("Failed to create unit map");
+ rpc_port_parcel_destroy(parcel_);
+ set_last_result(RPC_PORT_ERROR_OUT_OF_MEMORY);
+ return ret_;
+ }
+
+ rpc_port_unit_map_write_int(map_, 1355467489 /*[METHOD]*/, &method_);
+ rpc_port_unit_map_write_int(map_, 109757585 /*state*/, (int*)&state);
+
+ rpc_port_parcel_write(parcel_, &map_->parcelable, map_);
+ rpc_port_unit_map_destroy(map_);
+
+ g_rec_mutex_lock(&h->mutex);
+ rpc_port_parcel_h result_parcel_ = nullptr;
+ if (rpc_port_proxy_lem_is_connected(h->lem))
+ res_ = rpc_port_proxy_lem_send(h->lem, parcel_, &result_parcel_);
+ else
+ res_ = rpc_port_parcel_send(parcel_, h->port);
+
+ rpc_port_parcel_destroy(parcel_);
+ if (res_ != RPC_PORT_ERROR_NONE) {
+ _E("Failed to send parcel. error(%d)", res_);
+ set_last_result(res_);
+ g_rec_mutex_unlock(&h->mutex);
+ return ret_;
+ }
+
+ do {
+ map_ = nullptr;
+ if (rpc_port_proxy_lem_is_connected(h->lem)) {
+ map_ = rpc_port_unit_map_create();
+ rpc_port_parcel_read(result_parcel_, &map_->parcelable, map_);
+ rpc_port_parcel_destroy(result_parcel_);
+ } else {
+ __rpc_port_proxy_hal_device_bezel_proxy_1_device_bezel_consume_command(h->port, seq_num_, &map_);
+ }
+
+ if (map_ == nullptr) {
+ _E("Invalid protocol");
+ res_ = RPC_PORT_ERROR_IO_ERROR;
+ break;
+ }
+
+ rpc_port_unit_map_read_int(map_, 1497479973 /*[RESULT]*/, &ret_);
+
+ rpc_port_unit_map_destroy(map_);
+ } while (0);
+ g_rec_mutex_unlock(&h->mutex);
+ set_last_result(res_);
+
+ return ret_;
+}
+
+
+EXPORT_API int rpc_port_proxy_hal_device_bezel_ipc_1_lem_device_bezel_connect(void *h, bool sync)
+{
+ rpc_port_proxy_lem_h handle = h;
+ GSource* source;
+
+ if (h == nullptr) {
+ _E("Invalid parameter");
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
+ }
+
+ if (sync) {
+ rpc_port_proxy_lem_on_connected(h);
+ return RPC_PORT_ERROR_NONE;
+ }
+
+ source = g_idle_source_new();
+ if (source == nullptr) {
+ _E("Failed to create idle source");
+ return RPC_PORT_ERROR_OUT_OF_MEMORY;
+ }
+
+ g_source_set_callback(source, (GSourceFunc)rpc_port_proxy_lem_on_connected, h, nullptr);
+ g_source_attach(source, handle->thread_context);
+ g_source_unref(source);
+ return RPC_PORT_ERROR_NONE;
+}
+
+EXPORT_API int rpc_port_proxy_hal_device_bezel_ipc_1_lem_device_bezel_disconnect(void* h)
+{
+ rpc_port_proxy_lem_h handle = h;
+ GSource* source;
+
+ if (h == nullptr) {
+ _E("Invalid parameter");
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
+ }
+
+ source = g_idle_source_new();
+ if (source == nullptr) {
+ _E("Failed to create idle source");
+ return RPC_PORT_ERROR_OUT_OF_MEMORY;
+ }
+
+ g_source_set_callback(source, (GSourceFunc)rpc_port_proxy_lem_on_disconnected, h, nullptr);
+ g_source_attach(source, handle->thread_context);
+ g_source_unref(source);
+ return RPC_PORT_ERROR_NONE;
+}
+
+EXPORT_API int rpc_port_proxy_hal_device_bezel_ipc_1_lem_device_bezel_invoke_callback(void* h, rpc_port_parcel_h parcel)
+{
+ rpc_port_proxy_lem_h handle = h;
+ rpc_port_parcel_h cloned_parcel;
+ GSource* source;
+
+ if (h == nullptr || parcel == nullptr) {
+ _E("Invalid parameter");
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
+ }
+
+ rpc_port_parcel_clone(&cloned_parcel, parcel);
+ rpc_port_proxy_lem_request_queue_push(handle, cloned_parcel);
+
+ source = g_idle_source_new();
+ if (source == nullptr) {
+ _E("Failed to create idle source");
+ return RPC_PORT_ERROR_OUT_OF_MEMORY;
+ }
+
+ g_source_set_callback(source, (GSourceFunc)rpc_port_proxy_lem_on_received, handle, nullptr);
+ g_source_attach(source, handle->thread_context);
+ g_source_unref(source);
+ return RPC_PORT_ERROR_NONE;
+}
+
+EXPORT_API int rpc_port_proxy_hal_device_bezel_ipc_1_lem_device_bezel_send_result(void* h, rpc_port_parcel_h parcel)
+{
+ rpc_port_proxy_lem_h handle = h;
+ rpc_port_parcel_h cloned_parcel;
+
+ if (h == nullptr || parcel == nullptr) {
+ _E("Invalid parameter");
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
+ }
+
+ rpc_port_parcel_clone(&cloned_parcel, parcel);
+ rpc_port_proxy_lem_result_queue_push(handle, cloned_parcel);
+ return RPC_PORT_ERROR_NONE;
+}
+
--- /dev/null
+/*
+ * Generated by tidlc 2.6.1.
+ */
+
+#pragma once
+
+#include <stdbool.h>
+#include <bundle.h>
+#include <rpc-port.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * @brief The rpc_port_proxy_hal_device_bezel_proxy_1_enums_state enum.
+ */
+typedef enum {
+ RPC_PORT_PROXY_HAL_DEVICE_BEZEL_PROXY_1_STATE_ENUMS_TURNOFF = 0,
+ RPC_PORT_PROXY_HAL_DEVICE_BEZEL_PROXY_1_STATE_ENUMS_TURNON,
+} rpc_port_proxy_hal_device_bezel_proxy_1_enums_state_e;
+
+/**
+ * @brief The rpc_port_proxy_hal_device_bezel_proxy_1_enums_vib_state enum.
+ */
+typedef enum {
+ RPC_PORT_PROXY_HAL_DEVICE_BEZEL_PROXY_1_VIB_STATE_ENUMS_NONE = 0,
+ RPC_PORT_PROXY_HAL_DEVICE_BEZEL_PROXY_1_VIB_STATE_ENUMS_LIGHT,
+ RPC_PORT_PROXY_HAL_DEVICE_BEZEL_PROXY_1_VIB_STATE_ENUMS_MEDIUM,
+ RPC_PORT_PROXY_HAL_DEVICE_BEZEL_PROXY_1_VIB_STATE_ENUMS_STRONG,
+} rpc_port_proxy_hal_device_bezel_proxy_1_enums_vib_state_e;
+
+/**
+ * @brief The rpc_port_proxy_hal_device_bezel_proxy_1_enums handle.
+ */
+typedef struct rpc_port_proxy_hal_device_bezel_proxy_1_enums_s *rpc_port_proxy_hal_device_bezel_proxy_1_enums_h;
+
+/**
+ * @breif The rpc_port_proxy_hal_device_bezel_proxy_1 remote exception handle.
+ */
+typedef struct rpc_port_proxy_hal_device_bezel_proxy_1_remote_exception_s *rpc_port_proxy_hal_device_bezel_proxy_1_remote_exception_h;
+
+/**
+ * @brief The rpc_port_proxy_hal_device_bezel_proxy_1_device_bezel handle.
+ */
+typedef struct rpc_port_proxy_hal_device_bezel_proxy_1_device_bezel_s *rpc_port_proxy_hal_device_bezel_proxy_1_device_bezel_h;
+
+/**
+ * @brief Creates a rpc_port_proxy_hal_device_bezel_proxy_1_enums handle.
+ *
+ * @remarks The @a h handle should be released using the rpc_port_proxy_hal_device_bezel_proxy_1_enums_destroy()
+ * if it's no longer needed.
+ * @param[out] h The rpc_port_proxy_hal_device_bezel_proxy_1_enums handle that is newly created
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #RPC_PORT_ERROR_NONE Successful
+ * @retval #RPC_PORT_ERROR_INVALID_PARAMTER Invaid parameter
+ * @retval #RPC_PORT_ERROR_OUT_OF_MEMORY Out of memory
+ * @see rpc_port_proxy_hal_device_bezel_proxy_1_enums_destroy()
+ */
+int rpc_port_proxy_hal_device_bezel_proxy_1_enums_create(rpc_port_proxy_hal_device_bezel_proxy_1_enums_h *h);
+
+/**
+ * @brief Destroys the rpc_port_proxy_hal_device_bezel_proxy_1_enums handle.
+ *
+ * @param[in] h The rpc_port_proxy_hal_device_bezel_proxy_1_enums handle
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #RPC_PORT_ERROR_NONE Successful
+ * @retval #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #RPC_PORT_ERROR_OUT_OF_MEMORY Out of memory
+ * @see rpc_port_proxy_hal_device_bezel_proxy_1_enums_create()
+ */
+int rpc_port_proxy_hal_device_bezel_proxy_1_enums_destroy(rpc_port_proxy_hal_device_bezel_proxy_1_enums_h h);
+
+/**
+ * @brief Creates and returns a copy of the given rpc_port_proxy_hal_device_bezel_proxy_1_enums handle.
+ *
+ * @remarks A new created rpc_port_proxy_hal_device_bezel_proxy_1_enums should be released using
+ * the rpc_port_proxy_hal_device_bezel_proxy_1_enums_destroy() if it's no longer needed.
+ * @param[in] h The rpc_port_proxy_hal_device_bezel_proxy_1_enums handle
+ * @param[out] clone If successful, a new created rpc_port_proxy_hal_device_bezel_proxy_1_enums handle will be returned
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #RPC_PORT_ERROR_NONE Successful
+ * @retval #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #RPC_PORT_ERROR_OUT_OF_MEMORY Out of memory
+ * @see rpc_port_proxy_hal_device_bezel_proxy_1_enums_destroy()
+ */
+int rpc_port_proxy_hal_device_bezel_proxy_1_enums_clone(rpc_port_proxy_hal_device_bezel_proxy_1_enums_h h, rpc_port_proxy_hal_device_bezel_proxy_1_enums_h *clone);
+
+/**
+ * @brief Creates the rpc_port_proxy_hal_device_bezel_proxy_1 remote exception handle.
+ *
+ * @remarks The @c h handle should be released if it's no longer needed.
+ * @param[out] h The rpc_port_proxy_hal_device_bezel_proxy_1 remote exception handle.
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #RPC_PORT_ERROR_NONE Successful
+ * @retval #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #RPC_PORT_ERROR_OUT_OF_MEMORY Out of memory
+* @see rpc_port_proxy_hal_device_bezel_proxy_1_remote_exception_destroy()
+ */
+int rpc_port_proxy_hal_device_bezel_proxy_1_remote_exception_create(rpc_port_proxy_hal_device_bezel_proxy_1_remote_exception_h *h);
+
+/**
+ * @brief Sets the cause of the exception.
+ *
+ * @param[in] h The rpc_port_proxy_hal_device_bezel_proxy_1 remote exception handle
+ * @param[in] cause The cause of the exception
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #RPC_PORT_ERROR_NONE Successful
+ * @retval #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter
+ */
+int rpc_port_proxy_hal_device_bezel_proxy_1_remote_exception_set_cause(rpc_port_proxy_hal_device_bezel_proxy_1_remote_exception_h h, int cause);
+
+/**
+ * @brief Sets the detail message of the exception.
+ *
+ * @param[in] h The rpc_port_proxy_hal_device_bezel_proxy_1 remote exception handle
+ * @param[in] message The detail message of the exception
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #RPC_PORT_ERROR_NONE Successful
+ * @retval #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #RPC_PORT_ERROR_OUT_OF_MEMORY Out of memory
+ */
+int rpc_port_proxy_hal_device_bezel_proxy_1_remote_exception_set_message(rpc_port_proxy_hal_device_bezel_proxy_1_remote_exception_h h, const char *message);
+
+/**
+ * @brief Gets the cause of the exception.
+ * @param[in] h The rpc_port_proxy_hal_device_bezel_proxy_1 remote exception handle.
+ * @param[out] cause The cause
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #RPC_PORT_ERROR_NONE Successful
+ * @retval #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter
+ */
+int rpc_port_proxy_hal_device_bezel_proxy_1_remote_exception_get_cause(rpc_port_proxy_hal_device_bezel_proxy_1_remote_exception_h h, int *cause);
+
+/**
+ * @brief Gets the detail message of the exception.
+ * @remarks The @c message should be released if it's no longer needed.
+ * @param[in] h The rpc_port_proxy_hal_device_bezel_proxy_1 remote exception handle.
+ * @param[out] message The detail message
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #RPC_PORT_ERROR_NONE Successful
+ * @retval #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #RPC_PORT_ERROR_OUT_OF_MEMORY Out of memory
+ */
+int rpc_port_proxy_hal_device_bezel_proxy_1_remote_exception_get_message(rpc_port_proxy_hal_device_bezel_proxy_1_remote_exception_h, char **message);
+
+/**
+ * @brief Destroys the remote exception handle.
+ * @param[in] h The rpc_port_proxy_hal_device_bezel_proxy_1 remote exception handle
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #RPC_PORT_ERROR_NONE Successful
+ * @retval #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter
+ */
+int rpc_port_proxy_hal_device_bezel_proxy_1_remote_exception_destroy(rpc_port_proxy_hal_device_bezel_proxy_1_remote_exception_h h);
+
+/**
+ * @brief Gets the remote exception handle.
+ * @details If the return value is nullptr, there is no exceptions.
+ * @remarks The handle should be released using rpc_port_proxy_hal_device_bezel_proxy_1_remote_exception_destroy(), if it's no longer needed.
+ * @param[out] h The rpc_port_proxy_hal_device_bezel_proxy_1 remote exception handle.
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #RPC_PORT_ERROR_NONE Successful
+ * @retval #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #RPC_PORT_ERROR_OUT_OF_MEMORY Out of memory
+ * @see rpc_port_proxy_hal_device_bezel_proxy_1_remote_exception_destroy();
+ */
+int rpc_port_proxy_hal_device_bezel_proxy_1_get_remote_exception(rpc_port_proxy_hal_device_bezel_proxy_1_remote_exception_h *h);
+
+/**
+ * @brief Called when the proxy is connected.
+ * @details The callback function is called when the proxy is connected to the stub.
+ *
+ * @param[in] h The rpc_port_proxy_hal_device_bezel_proxy_1_device_bezel handle
+ * @param[in] user_data The user data passed from the registeration function
+ * @see #rpc_port_proxy_hal_device_bezel_proxy_1_device_bezel_callback_s
+ */
+typedef void (*rpc_port_proxy_hal_device_bezel_proxy_1_device_bezel_connected_cb)(rpc_port_proxy_hal_device_bezel_proxy_1_device_bezel_h h, void *user_data);
+
+/**
+ * @brief Called when the proxy is disconnected.
+ * @details The callback function is called when the proxy is disconnected from the stub.
+ *
+ * @param[in] h The rpc_port_proxy_hal_device_bezel_proxy_1_device_bezel handle
+ * @param[in] user_data The user data passed from the registeration function
+ * @see #rpc_port_proxy_hal_device_bezel_proxy_1_device_bezel_callback_s
+ */
+typedef void (*rpc_port_proxy_hal_device_bezel_proxy_1_device_bezel_disconnected_cb)(rpc_port_proxy_hal_device_bezel_proxy_1_device_bezel_h h, void *user_data);
+
+/**
+ * @brief Called when the proxy is rejected.
+ * @details The callback function is called when the proxy is rejected to connect to the stub.
+ *
+ * @param[in] h The rpc_port_proxy_hal_device_bezel_proxy_1_device_bezel handle
+ * @param[in] user_data The user data passed from the registeration function
+ * @see #rpc_port_proxy_hal_device_bezel_proxy_1_device_bezel_callback_s
+ */
+typedef void (*rpc_port_proxy_hal_device_bezel_proxy_1_device_bezel_rejected_cb)(rpc_port_proxy_hal_device_bezel_proxy_1_device_bezel_h h, void *user_data);
+
+/**
+ * @brief The structure type containing the set of callback functions for handling proxy events.
+ * @details It is one of the input parameters of the rpc_port_proxy_hal_device_bezel_proxy_1_device_bezel_create() function.
+ *
+ * @see rpc_port_proxy_hal_device_bezel_proxy_1_device_bezel_connected_cb
+ * @see rpc_port_proxy_hal_device_bezel_proxy_1_device_bezel_disconnected_cb
+ * @see rpc_port_proxy_hal_device_bezel_proxy_1_device_bezel_rejected_cb
+ */
+typedef struct {
+ rpc_port_proxy_hal_device_bezel_proxy_1_device_bezel_connected_cb connected; /**< This callback function is called when the proxy is connected to the stub. */
+ rpc_port_proxy_hal_device_bezel_proxy_1_device_bezel_disconnected_cb disconnected; /**< This callback function is called when the proxy is disconnected from the stub. */
+ rpc_port_proxy_hal_device_bezel_proxy_1_device_bezel_rejected_cb rejected; /**< This callback function is called when the proxy is rejected to connect to the stub. */
+} rpc_port_proxy_hal_device_bezel_proxy_1_device_bezel_callback_s;
+
+/**
+ * @brief Creates a rpc_port_proxy_hal_device_bezel_proxy_1_device_bezel handle.
+ * @remarks The @a h handle should be released using
+ * the rpc_port_proxy_hal_device_bezel_proxy_1_device_bezel_destroy() if it's no longer needed.
+ *
+ * @param[in] stub_appid The application ID of the stub
+ * @param[in] callback The set of callback functions to handle proxy events
+ * @param[in] user_data The user data to be passed to the callback function
+ * @param[out] h The rpc_port_proxy_hal_device_bezel_proxy_1_device_bezel handle
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #RPC_PORT_ERROR_NONE Successful
+ * @retval #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #RPC_PORT_ERROR_OUT_OF_MEMORY Out of memory
+ * @see rpc_port_proxy_hal_device_bezel_proxy_1_device_bezel_destroy()
+ * @see #rpc_port_proxy_hal_device_bezel_proxy_1_device_bezel_callback_s
+ */
+int rpc_port_proxy_hal_device_bezel_proxy_1_device_bezel_create(const char *stub_appid, rpc_port_proxy_hal_device_bezel_proxy_1_device_bezel_callback_s *callback, void *user_data, rpc_port_proxy_hal_device_bezel_proxy_1_device_bezel_h *h);
+
+/**
+ * @brief Destroys the rpc_port_proxy_hal_device_bezel_proxy_1_device_bezel handle.
+ *
+ * @param[in] h The rpc_port_proxy_hal_device_bezel_proxy_1_device_bezel handle
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #RPC_PORT_ERROR_NONE Successful
+ * @retval #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @see rpc_port_proxy_hal_device_bezel_proxy_1_device_bezel_create()
+ */
+int rpc_port_proxy_hal_device_bezel_proxy_1_device_bezel_destroy(rpc_port_proxy_hal_device_bezel_proxy_1_device_bezel_h h);
+
+/**
+ * @brief Connects to the stub.
+ *
+ * @param[in] h The rpc_port_proxy_hal_device_bezel_proxy_1_device_bezel handle
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #RPC_PORT_ERROR_NONE Successful
+ * @retval #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #RPC_PORT_ERROR_IO_ERROR I/O error
+ * @retval #RPC_PORT_ERROR_PERMISSION_DENIED Permission denied
+ */
+int rpc_port_proxy_hal_device_bezel_proxy_1_device_bezel_connect(rpc_port_proxy_hal_device_bezel_proxy_1_device_bezel_h h);
+
+/**
+ * @brief Connects to the stub synchronously.
+ *
+ * @param[in] h The rpc_port_proxy_hal_device_bezel_proxy_1_device_bezel handle
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #RPC_PORT_ERROR_NONE Successful
+ * @retval #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #RPC_PORT_ERROR_IO_ERROR I/O error
+ * @retval #RPC_PORT_ERROR_PERMISSION_DENIED Permission denied
+ */
+int rpc_port_proxy_hal_device_bezel_proxy_1_device_bezel_connect_sync(rpc_port_proxy_hal_device_bezel_proxy_1_device_bezel_h h);
+
+/**
+ * @brief Disconnects from the stub.
+ *
+ * @param[in] h The rpc_port_proxy_hal_device_bezel_proxy_1_device_bezel handle
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #RPC_PORT_ERROR_NONE Successful
+ * @retval #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter
+ */
+int rpc_port_proxy_hal_device_bezel_proxy_1_device_bezel_disconnect(rpc_port_proxy_hal_device_bezel_proxy_1_device_bezel_h h);
+
+/**
+ * @brief Calls the get_state() method.
+ * @details The return value and args are decided by the interface declaration.
+ * You can get the result using get_last_result().
+ * Before returning the function, the function sets the result using set_last_result().
+ * @remarks The specific error code can be obtained using the get_last_result() function. Error codes are described in Exception section.
+ * @param[in] h The rpc_port_proxy_hal_device_bezel_proxy_1_device_bezel handle
+ * @param[in] ...
+ * @exception #RPC_PORT_ERROR_NONE Successful
+ * @exception #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @exception #RPC_PORT_ERROR_OUT_OF_MEMORY Out of memory
+ * @exception #RPC_PORT_ERROR_IO_ERROR I/O error
+ */
+int rpc_port_proxy_hal_device_bezel_proxy_1_device_bezel_invoke_get_state(rpc_port_proxy_hal_device_bezel_proxy_1_device_bezel_h h, rpc_port_proxy_hal_device_bezel_proxy_1_enums_state_e *state);
+
+/**
+ * @brief Calls the set_state() method.
+ * @details The return value and args are decided by the interface declaration.
+ * You can get the result using get_last_result().
+ * Before returning the function, the function sets the result using set_last_result().
+ * @remarks The specific error code can be obtained using the get_last_result() function. Error codes are described in Exception section.
+ * @param[in] h The rpc_port_proxy_hal_device_bezel_proxy_1_device_bezel handle
+ * @param[in] ...
+ * @exception #RPC_PORT_ERROR_NONE Successful
+ * @exception #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @exception #RPC_PORT_ERROR_OUT_OF_MEMORY Out of memory
+ * @exception #RPC_PORT_ERROR_IO_ERROR I/O error
+ */
+int rpc_port_proxy_hal_device_bezel_proxy_1_device_bezel_invoke_set_state(rpc_port_proxy_hal_device_bezel_proxy_1_device_bezel_h h, rpc_port_proxy_hal_device_bezel_proxy_1_enums_state_e state);
+
+/**
+ * @brief Calls the get_sw_state() method.
+ * @details The return value and args are decided by the interface declaration.
+ * You can get the result using get_last_result().
+ * Before returning the function, the function sets the result using set_last_result().
+ * @remarks The specific error code can be obtained using the get_last_result() function. Error codes are described in Exception section.
+ * @param[in] h The rpc_port_proxy_hal_device_bezel_proxy_1_device_bezel handle
+ * @param[in] ...
+ * @exception #RPC_PORT_ERROR_NONE Successful
+ * @exception #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @exception #RPC_PORT_ERROR_OUT_OF_MEMORY Out of memory
+ * @exception #RPC_PORT_ERROR_IO_ERROR I/O error
+ */
+int rpc_port_proxy_hal_device_bezel_proxy_1_device_bezel_invoke_get_sw_state(rpc_port_proxy_hal_device_bezel_proxy_1_device_bezel_h h, rpc_port_proxy_hal_device_bezel_proxy_1_enums_state_e *state);
+
+/**
+ * @brief Calls the set_sw_state() method.
+ * @details The return value and args are decided by the interface declaration.
+ * You can get the result using get_last_result().
+ * Before returning the function, the function sets the result using set_last_result().
+ * @remarks The specific error code can be obtained using the get_last_result() function. Error codes are described in Exception section.
+ * @param[in] h The rpc_port_proxy_hal_device_bezel_proxy_1_device_bezel handle
+ * @param[in] ...
+ * @exception #RPC_PORT_ERROR_NONE Successful
+ * @exception #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @exception #RPC_PORT_ERROR_OUT_OF_MEMORY Out of memory
+ * @exception #RPC_PORT_ERROR_IO_ERROR I/O error
+ */
+int rpc_port_proxy_hal_device_bezel_proxy_1_device_bezel_invoke_set_sw_state(rpc_port_proxy_hal_device_bezel_proxy_1_device_bezel_h h, rpc_port_proxy_hal_device_bezel_proxy_1_enums_state_e state);
+
+/**
+ * @brief Calls the get_vib_state() method.
+ * @details The return value and args are decided by the interface declaration.
+ * You can get the result using get_last_result().
+ * Before returning the function, the function sets the result using set_last_result().
+ * @remarks The specific error code can be obtained using the get_last_result() function. Error codes are described in Exception section.
+ * @param[in] h The rpc_port_proxy_hal_device_bezel_proxy_1_device_bezel handle
+ * @param[in] ...
+ * @exception #RPC_PORT_ERROR_NONE Successful
+ * @exception #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @exception #RPC_PORT_ERROR_OUT_OF_MEMORY Out of memory
+ * @exception #RPC_PORT_ERROR_IO_ERROR I/O error
+ */
+int rpc_port_proxy_hal_device_bezel_proxy_1_device_bezel_invoke_get_vib_state(rpc_port_proxy_hal_device_bezel_proxy_1_device_bezel_h h, rpc_port_proxy_hal_device_bezel_proxy_1_enums_vib_state_e *state);
+
+/**
+ * @brief Calls the set_vib_state() method.
+ * @details The return value and args are decided by the interface declaration.
+ * You can get the result using get_last_result().
+ * Before returning the function, the function sets the result using set_last_result().
+ * @remarks The specific error code can be obtained using the get_last_result() function. Error codes are described in Exception section.
+ * @param[in] h The rpc_port_proxy_hal_device_bezel_proxy_1_device_bezel handle
+ * @param[in] ...
+ * @exception #RPC_PORT_ERROR_NONE Successful
+ * @exception #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @exception #RPC_PORT_ERROR_OUT_OF_MEMORY Out of memory
+ * @exception #RPC_PORT_ERROR_IO_ERROR I/O error
+ */
+int rpc_port_proxy_hal_device_bezel_proxy_1_device_bezel_invoke_set_vib_state(rpc_port_proxy_hal_device_bezel_proxy_1_device_bezel_h h, rpc_port_proxy_hal_device_bezel_proxy_1_enums_vib_state_e state);
+
+#ifdef __cplusplus
+}
+#endif
--- /dev/null
+
+/*
+ * Generated by tidlc 2.6.1.
+ */
+
+#ifndef _GNU_SOURCE
+#define _GNU_SOURCE
+#endif
+
+#pragma GCC diagnostic ignored "-Warray-bounds"
+#pragma GCC diagnostic ignored "-Wunused-function"
+
+#include <pthread.h>
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <libgen.h>
+#include <glib.h>
+#include <dlog.h>
+#include <rpc-port.h>
+#include <rpc-port-parcel.h>
+#include <app_manager.h>
+#include <package_manager.h>
+#include <unistd.h>
+#include <dlfcn.h>
+#include <app_common.h>
+
+#include "./src/generated/hal_device_bezel_stub_1.h"
+
+#undef LOG_TAG
+#define LOG_TAG "RPC_PORT_STUB"
+
+#undef _E
+#define _E(fmt, ...) dlog_print(DLOG_ERROR, LOG_TAG, "%s: %s(%d) > "fmt, basename(__FILE__), __FUNCTION__, __LINE__, ##__VA_ARGS__)
+
+#undef _W
+#define _W(fmt, ...) dlog_print(DLOG_WARN, LOG_TAG, "%s: %s(%d) > "fmt, basename(__FILE__), __FUNCTION__, __LINE__, ##__VA_ARGS__)
+
+#undef _I
+#define _I(fmt, ...) dlog_print(DLOG_INFO, LOG_TAG, "%s: %s(%d) > "fmt, basename(__FILE__), __FUNCTION__, __LINE__, ##__VA_ARGS__)
+
+#undef _D
+#define _D(fmt, ...) dlog_print(DLOG_DEBUG, LOG_TAG, "%s: %s(%d) > "fmt, basename(__FILE__), __FUNCTION__, __LINE__, ##__VA_ARGS__)
+
+#ifndef TIDL_VERSION
+#define TIDL_VERSION "2.6.1"
+#endif
+
+#ifndef nullptr
+#define nullptr NULL
+#endif
+
+#ifndef ARRAY_SIZE
+#define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0]))
+#endif
+
+#ifndef STRING_GET
+#define STRING_GET(x) ((x) ? x : "")
+#endif
+
+#ifndef EXPORT_API
+#define EXPORT_API extern "C" __attribute__ ((visibility("default")))
+#endif
+
+typedef int (*rpc_port_parcel_reserve_t)(rpc_port_parcel_h h, unsigned int size);
+typedef int (*rpc_port_parcel_create_from_parcel_t)(rpc_port_parcel_h* h,
+ rpc_port_parcel_h origin_parcel,
+ unsigned int start_pos,
+ unsigned int size);
+typedef int (*rpc_port_parcel_set_data_size_t)(rpc_port_parcel_h h, unsigned int size);
+typedef int (*rpc_port_parcel_get_data_size_t)(rpc_port_parcel_h h, unsigned int* size);
+typedef int (*rpc_port_parcel_pin_t)(rpc_port_parcel_h h);
+typedef int (*rpc_port_parcel_get_reader_t)(rpc_port_parcel_h h, unsigned int* reader_pos);
+typedef int (*rpc_port_parcel_set_reader_t)(rpc_port_parcel_h h, unsigned int reader_pos);
+typedef int (*rpc_port_parcel_write_fd_t)(rpc_port_parcel_h h, int fd);
+typedef int (*rpc_port_parcel_read_fd_t)(rpc_port_parcel_h h, int* fd);
+typedef int (*rpc_port_parcel_clone_t)(rpc_port_parcel_h* h, rpc_port_parcel_h origin);
+
+static rpc_port_parcel_reserve_t rpc_port_parcel_reserve;
+static rpc_port_parcel_create_from_parcel_t rpc_port_parcel_create_from_parcel;
+static rpc_port_parcel_set_data_size_t rpc_port_parcel_set_data_size;
+static rpc_port_parcel_get_data_size_t rpc_port_parcel_get_data_size;
+static rpc_port_parcel_pin_t rpc_port_parcel_pin;
+static rpc_port_parcel_get_reader_t rpc_port_parcel_get_reader;
+static rpc_port_parcel_set_reader_t rpc_port_parcel_set_reader;
+static rpc_port_parcel_write_fd_t rpc_port_parcel_write_fd;
+static rpc_port_parcel_read_fd_t rpc_port_parcel_read_fd;
+static rpc_port_parcel_clone_t rpc_port_parcel_clone;
+
+static bool rpc_port_internal_loaded;
+
+static void rpc_port_internal_init(void)
+{
+ const char *symbol = "rpc_port_parcel_reserve";
+
+ if (rpc_port_internal_loaded)
+ return;
+
+ rpc_port_parcel_reserve = dlsym(RTLD_DEFAULT, symbol);
+ if (rpc_port_parcel_reserve == nullptr) {
+ _E("Failed to find symbol(%s). Please check rpc-port version", symbol);
+ return;
+ }
+
+ symbol = "rpc_port_parcel_create_from_parcel";
+ rpc_port_parcel_create_from_parcel = dlsym(RTLD_DEFAULT, symbol);
+ if (rpc_port_parcel_create_from_parcel == nullptr) {
+ _E("Failed to find symbol(%s). Please check rpc-port version", symbol);
+ return;
+ }
+
+ symbol = "rpc_port_parcel_set_data_size";
+ rpc_port_parcel_set_data_size = dlsym(RTLD_DEFAULT, symbol);
+ if (rpc_port_parcel_set_data_size == nullptr) {
+ _E("Failed to find symbol(%s). Please check rpc-port version", symbol);
+ return;
+ }
+
+ symbol = "rpc_port_parcel_get_data_size";
+ rpc_port_parcel_get_data_size = dlsym(RTLD_DEFAULT, symbol);
+ if (rpc_port_parcel_get_data_size == nullptr) {
+ _E("Failed to find symbol(%s). Please check rpc-port version", symbol);
+ return;
+ }
+
+ symbol = "rpc_port_parcel_pin";
+ rpc_port_parcel_pin = dlsym(RTLD_DEFAULT, symbol);
+ if (rpc_port_parcel_pin == nullptr) {
+ _E("Failed to find symbol(%s). Please check rpc-port version", symbol);
+ return;
+ }
+
+ symbol = "rpc_port_parcel_get_reader";
+ rpc_port_parcel_get_reader = dlsym(RTLD_DEFAULT, symbol);
+ if (rpc_port_parcel_get_reader == nullptr) {
+ _E("Failed to find symbol(%s). Please check rpc-port version", symbol);
+ return;
+ }
+
+ symbol = "rpc_port_parcel_set_reader";
+ rpc_port_parcel_set_reader = dlsym(RTLD_DEFAULT, symbol);
+ if (rpc_port_parcel_set_reader == nullptr) {
+ _E("Failed to find symbol(%s). Please check rpc-port version", symbol);
+ return;
+ }
+
+ symbol = "rpc_port_parcel_write_fd";
+ rpc_port_parcel_write_fd = dlsym(RTLD_DEFAULT, symbol);
+ if (rpc_port_parcel_write_fd == nullptr) {
+ _E("Failed to find symbol(%s). Please check rpc-port version", symbol);
+ return;
+ }
+
+ symbol = "rpc_port_parcel_read_fd";
+ rpc_port_parcel_read_fd = dlsym(RTLD_DEFAULT, symbol);
+ if (rpc_port_parcel_read_fd == nullptr) {
+ _E("Failed to find symbol(%s). Please check rpc-port version", symbol);
+ return;
+ }
+
+ symbol = "rpc_port_parcel_clone";
+ rpc_port_parcel_clone = dlsym(RTLD_DEFAULT, symbol);
+ if (rpc_port_parcel_clone == nullptr) {
+ _E("Failed to find symbol(%s). Please check rpc-port version", symbol);
+ return;
+ }
+
+ rpc_port_internal_loaded = true;
+}
+
+typedef enum {
+ RPC_PORT_STUB_HAL_DEVICE_BEZEL_STUB_1_DEVICE_BEZEL_METHOD_RESULT_,
+ RPC_PORT_STUB_HAL_DEVICE_BEZEL_STUB_1_DEVICE_BEZEL_METHOD_CALLBACK_,
+ RPC_PORT_STUB_HAL_DEVICE_BEZEL_STUB_1_DEVICE_BEZEL_METHOD_GET_STATE,
+ RPC_PORT_STUB_HAL_DEVICE_BEZEL_STUB_1_DEVICE_BEZEL_METHOD_SET_STATE,
+ RPC_PORT_STUB_HAL_DEVICE_BEZEL_STUB_1_DEVICE_BEZEL_METHOD_GET_SW_STATE,
+ RPC_PORT_STUB_HAL_DEVICE_BEZEL_STUB_1_DEVICE_BEZEL_METHOD_SET_SW_STATE,
+ RPC_PORT_STUB_HAL_DEVICE_BEZEL_STUB_1_DEVICE_BEZEL_METHOD_GET_VIB_STATE,
+ RPC_PORT_STUB_HAL_DEVICE_BEZEL_STUB_1_DEVICE_BEZEL_METHOD_SET_VIB_STATE,
+} rpc_port_stub_hal_device_bezel_stub_1_device_bezel_method_e;
+
+typedef void (*rpc_port_unit_write_func)(rpc_port_parcel_h parcel, void* data);
+
+typedef struct rpc_port_unit_s {
+ rpc_port_parcelable_t parcelable;
+ int name;
+ int type;
+ rpc_port_parcel_h parcel;
+ rpc_port_unit_write_func write_cb;
+ void *data;
+} rpc_port_unit_t;
+
+typedef rpc_port_unit_t *rpc_port_unit_h;
+
+typedef struct rpc_port_unit_map_s {
+ rpc_port_parcelable_t parcelable;
+ GHashTable *table;
+} rpc_port_unit_map_t;
+
+typedef rpc_port_unit_map_t *rpc_port_unit_map_h;
+
+typedef int (*rpc_port_proxy_lem_connect_func)(void *context, bool sync);
+typedef int (*rpc_port_proxy_lem_disconnect_func)(void *context);
+typedef int (*rpc_port_proxy_lem_send_result_func)(void *context, rpc_port_parcel_h parcel);
+typedef int (*rpc_port_proxy_lem_invoke_callback_func)(void *context, rpc_port_parcel_h parcel);
+
+typedef void (*rpc_port_stub_lem_connected_cb)(void *context, const char *sender, const char *instance, bool sync);
+typedef void (*rpc_port_stub_lem_disconnected_cb)(void *context, const char *sender, const char *instance);
+typedef void (*rpc_port_stub_lem_received_cb)(void *context, const char *sender, const char *instance, rpc_port_parcel_h parcel);
+
+typedef struct {
+ rpc_port_stub_lem_connected_cb connected;
+ rpc_port_stub_lem_disconnected_cb disconnected;
+ rpc_port_stub_lem_received_cb received;
+} rpc_port_stub_lem_event_s;
+
+typedef struct {
+ void *context;
+ char *sender;
+ char *instance;
+ bool sync;
+ rpc_port_parcel_h parcel;
+} rpc_port_stub_lem_data_s;
+
+typedef rpc_port_stub_lem_data_s *rpc_port_stub_lem_data_h;
+
+typedef struct {
+ char *port_name;
+ rpc_port_stub_lem_event_s callback;
+ bool listening;
+ bool loaded;
+ rpc_port_proxy_lem_connect_func connect_func;
+ rpc_port_proxy_lem_disconnect_func disconnect_func;
+ rpc_port_proxy_lem_send_result_func send_result_func;
+ rpc_port_proxy_lem_invoke_callback_func invoke_callback_func;
+ GQueue *connected_queue;
+ GQueue *disconnected_queue;
+ GQueue *received_queue;
+ GRecMutex mutex;
+ GMainContext *context;
+} rpc_port_stub_lem_s;
+
+typedef rpc_port_stub_lem_s *rpc_port_stub_lem_h;
+static char *__stub_appid;
+
+static rpc_port_stub_lem_h __device_bezel_context;
+
+typedef int (*rpc_port_stub_method_handler)(rpc_port_h port, rpc_port_parcel_h parcel, rpc_port_unit_map_h map, void *data);
+
+typedef struct rpc_port_delegate_s {
+ rpc_port_parcelable_t parcelable;
+ rpc_port_h port;
+ int id;
+ int seq_id;
+ bool once;
+ bool valid;
+ char *lem_instance;
+} rpc_port_delegate_t;
+
+typedef rpc_port_delegate_t *rpc_port_delegate_h;
+
+typedef struct rpc_port_stub_hal_device_bezel_stub_1_enums_s {
+ rpc_port_parcelable_t parcelable;
+} rpc_port_stub_hal_device_bezel_stub_1_enums_t;
+
+typedef struct rpc_port_stub_hal_device_bezel_stub_1_remote_exception_s {
+ rpc_port_parcelable_t parcelable;
+ int cause;
+ char *message;
+} rpc_port_stub_hal_device_bezel_stub_1_remote_exception_t;
+
+static rpc_port_stub_hal_device_bezel_stub_1_remote_exception_h __rpc_port_stub_hal_device_bezel_stub_1_remote_exception;
+
+int rpc_port_stub_hal_device_bezel_stub_1_remote_exception_create(rpc_port_stub_hal_device_bezel_stub_1_remote_exception_h *h);
+
+typedef struct rpc_port_stub_hal_device_bezel_stub_1_device_bezel_context_s {
+ char *sender;
+ char *instance;
+ rpc_port_h port;
+ rpc_port_h callback_port;
+ void *tag;
+ rpc_port_stub_hal_device_bezel_stub_1_device_bezel_callback_s callback;
+ void *user_data;
+ app_info_h app_info;
+ GHashTable *privileges;
+ void *lem_context;
+#ifdef TIDL_THREAD_ENABLE
+ GThread *thread;
+ GQueue *queue;
+ GMutex mutex;
+ GCond cond;
+ bool done;
+#endif /* TIDL_THREAD_ENABLE */
+} rpc_port_stub_hal_device_bezel_stub_1_device_bezel_context_t;
+
+typedef int (*rpc_port_stub_hal_device_bezel_stub_1_device_bezel_privilege_checker)(rpc_port_stub_hal_device_bezel_stub_1_device_bezel_context_h h, bool *sync);
+
+typedef struct rpc_port_stub_hal_device_bezel_stub_1_device_bezel_s {
+ rpc_port_stub_h stub;
+ rpc_port_stub_hal_device_bezel_stub_1_device_bezel_callback_s callback;
+ void *user_data;
+ GList* contexts;
+ GList* callback_ports;
+ GRecMutex mutex;
+} rpc_port_stub_hal_device_bezel_stub_1_device_bezel_t;
+
+static rpc_port_stub_hal_device_bezel_stub_1_device_bezel_t __device_bezel;
+
+static void rpc_port_stub_lem_data_destroy(rpc_port_stub_lem_data_h data)
+{
+ if (data == nullptr)
+ return;
+
+ if (data->sender)
+ free(data->sender);
+
+ if (data->instance)
+ free(data->instance);
+
+ if (data->parcel)
+ rpc_port_parcel_destroy(data->parcel);
+
+ free(data);
+}
+
+static rpc_port_stub_lem_data_h rpc_port_stub_lem_data_create(void *context, const char *sender, const char *instance, bool sync)
+{
+ rpc_port_stub_lem_data_h data;
+
+ if (context == nullptr || instance == nullptr) {
+ _E("Invalid parameter");
+ return nullptr;
+ }
+
+ data = calloc(1, sizeof(rpc_port_stub_lem_data_s));
+ if (data == nullptr) {
+ _E("Out of memory");
+ return nullptr;
+ }
+
+ data->sender = strdup(sender ? sender : "");
+ if (data->sender == nullptr) {
+ _E("strdup() is failed");
+ rpc_port_stub_lem_data_destroy(data);
+ return nullptr;
+ }
+
+ data->instance = strdup(instance);
+ if (data->instance == nullptr) {
+ _E("strdup() is failed");
+ rpc_port_stub_lem_data_destroy(data);
+ return nullptr;
+ }
+
+ data->context = context;
+ data->sync = sync;
+ return data;
+}
+
+static rpc_port_stub_lem_data_h rpc_port_stub_lem_data_create_with_parcel(void *context, const char *sender, const char *instance, rpc_port_parcel_h parcel)
+{
+ rpc_port_stub_lem_data_h data;
+
+ if (context == nullptr || instance == nullptr || parcel == nullptr) {
+ _E("Invalid parameter");
+ return nullptr;
+ }
+
+ data = calloc(1, sizeof(rpc_port_stub_lem_data_s));
+ if (data == nullptr) {
+ _E("Out of memory");
+ return nullptr;
+ }
+
+ data->sender = strdup(sender ? sender : "");
+ if (data->sender == nullptr) {
+ _E("strdup() is failed");
+ rpc_port_stub_lem_data_destroy(data);
+ return nullptr;
+ }
+
+ data->instance = strdup(instance);
+ if (data->instance == nullptr) {
+ _E("strdup() is failed");
+ rpc_port_stub_lem_data_destroy(data);
+ return nullptr;
+ }
+
+ rpc_port_parcel_clone(&data->parcel, parcel);
+ if (data->parcel == nullptr) {
+ _E("Failed to clone parcel");
+ rpc_port_stub_lem_data_destroy(data);
+ return nullptr;
+ }
+
+ data->context = context;
+ return data;
+}
+
+static bool rpc_port_stub_lem_load_symbols(rpc_port_stub_lem_h handle)
+{
+ char symbol[1024];
+
+ if (handle == nullptr) {
+ _E("Invalid parameter");
+ return false;
+ }
+
+ if (handle->loaded)
+ return true;
+
+ snprintf(symbol, sizeof(symbol), "rpc_port_proxy_hal_device_bezel_ipc_1_lem_%s_connect", handle->port_name);
+ handle->connect_func = (rpc_port_proxy_lem_connect_func)dlsym(RTLD_DEFAULT, symbol);
+ if (handle->connect_func == nullptr) {
+ _E("Failed to find symbol");
+ return false;
+ }
+
+ snprintf(symbol, sizeof(symbol), "rpc_port_proxy_hal_device_bezel_ipc_1_lem_%s_disconnect", handle->port_name);
+ handle->disconnect_func = (rpc_port_proxy_lem_disconnect_func)dlsym(RTLD_DEFAULT, symbol);
+ if (handle->disconnect_func == nullptr) {
+ _E("Failed to find symbol");
+ return false;
+ }
+
+ snprintf(symbol, sizeof(symbol), "rpc_port_proxy_hal_device_bezel_ipc_1_lem_%s_send_result", handle->port_name);
+ handle->send_result_func = (rpc_port_proxy_lem_send_result_func)dlsym(RTLD_DEFAULT, symbol);
+ if (handle->send_result_func == nullptr) {
+ _E("Failed to find symbol");
+ return false;
+ }
+
+ snprintf(symbol, sizeof(symbol), "rpc_port_proxy_hal_device_bezel_ipc_1_lem_%s_invoke_callback", handle->port_name);
+ handle->invoke_callback_func = (rpc_port_proxy_lem_invoke_callback_func)dlsym(RTLD_DEFAULT, symbol);
+ if (handle->invoke_callback_func == nullptr) {
+ _E("Failed to find symbol");
+ return false;
+ }
+
+ handle->loaded = true;
+ return true;
+}
+
+static void rpc_port_stub_lem_destroy(rpc_port_stub_lem_h handle)
+{
+ if (handle == nullptr)
+ return;
+
+ if (g_rec_mutex_trylock(&handle->mutex))
+ g_rec_mutex_unlock(&handle->mutex);
+
+ g_rec_mutex_clear(&handle->mutex);
+
+ if (handle->connected_queue)
+ g_queue_free_full(handle->connected_queue, (GDestroyNotify)rpc_port_stub_lem_data_destroy);
+
+ if (handle->disconnected_queue)
+ g_queue_free_full(handle->disconnected_queue, (GDestroyNotify)rpc_port_stub_lem_data_destroy);
+
+ if (handle->received_queue)
+ g_queue_free_full(handle->received_queue, (GDestroyNotify)rpc_port_stub_lem_data_destroy);
+
+ if (handle->port_name)
+ free(handle->port_name);
+
+ if (handle->context)
+ g_main_context_unref(handle->context);
+
+ free(handle);
+}
+
+static rpc_port_stub_lem_h rpc_port_stub_lem_create(const char *port_name, rpc_port_stub_lem_event_s* callback)
+{
+ rpc_port_stub_lem_h handle;
+
+ if (port_name == nullptr || callback == nullptr) {
+ _E("Invalid parameter");
+ return nullptr;
+ }
+
+ handle = (rpc_port_stub_lem_h)calloc(1, sizeof(rpc_port_stub_lem_s));
+ if (handle == nullptr) {
+ _E("Out of memory");
+ return nullptr;
+ }
+
+ g_rec_mutex_init(&handle->mutex);
+ handle->port_name = strdup(port_name);
+ if (handle->port_name == nullptr) {
+ _E("strdup() is failed");
+ rpc_port_stub_lem_destroy(handle);
+ return nullptr;
+ }
+
+ handle->connected_queue = g_queue_new();
+ if (handle->connected_queue == nullptr) {
+ _E("g_queue_new() is failed");
+ rpc_port_stub_lem_destroy(handle);
+ return nullptr;
+ }
+
+ handle->disconnected_queue = g_queue_new();
+ if (handle->disconnected_queue == nullptr) {
+ _E("g_queue_new() is failed");
+ rpc_port_stub_lem_destroy(handle);
+ return nullptr;
+ }
+
+ handle->received_queue = g_queue_new();
+ if (handle->received_queue == nullptr) {
+ _E("g_queue_new() is failed");
+ rpc_port_stub_lem_destroy(handle);
+ return nullptr;
+ }
+
+ handle->context = g_main_context_ref_thread_default();
+ handle->callback = *callback;
+ rpc_port_stub_lem_load_symbols(handle);
+
+ return handle;
+}
+
+static void rpc_port_stub_lem_connect(rpc_port_stub_lem_h handle, void *context, bool sync)
+{
+ if (handle == nullptr || context == nullptr)
+ return;
+
+ if (handle->connect_func)
+ handle->connect_func(context, sync);
+}
+
+static void rpc_port_stub_lem_disconnect(rpc_port_stub_lem_h handle, void *context)
+{
+ if (handle == nullptr || context == nullptr)
+ return;
+
+ if (handle->disconnect_func)
+ handle->disconnect_func(context);
+}
+
+static void rpc_port_stub_lem_send_result(rpc_port_stub_lem_h handle, void *context, rpc_port_parcel_h parcel)
+{
+ if (handle == nullptr || context == nullptr || parcel == nullptr)
+ return;
+
+ if (handle->send_result_func)
+ handle->send_result_func(context, parcel);
+}
+
+static void rpc_port_stub_lem_set_listening(rpc_port_stub_lem_h handle, bool listening)
+{
+ if (handle == nullptr)
+ return;
+
+ g_rec_mutex_lock(&handle->mutex);
+ handle->listening = listening;
+ g_rec_mutex_unlock(&handle->mutex);
+}
+
+static bool rpc_port_stub_lem_is_listening(rpc_port_stub_lem_h handle)
+{
+ bool ret;
+
+ if (handle == nullptr)
+ return false;
+
+ g_rec_mutex_lock(&handle->mutex);
+ ret = handle->listening;
+ g_rec_mutex_unlock(&handle->mutex);
+ return ret;
+}
+
+static void rpc_port_stub_lem_connected_data_push(rpc_port_stub_lem_h handle, rpc_port_stub_lem_data_h data)
+{
+ if (handle == nullptr || data == nullptr)
+ return;
+
+ g_rec_mutex_lock(&handle->mutex);
+ g_queue_push_tail(handle->connected_queue, data);
+ g_rec_mutex_unlock(&handle->mutex);
+}
+
+static rpc_port_stub_lem_data_h rpc_port_stub_lem_connected_data_pop(rpc_port_stub_lem_h handle)
+{
+ rpc_port_stub_lem_data_h data;
+
+ if (handle == nullptr)
+ return nullptr;
+
+ g_rec_mutex_lock(&handle->mutex);
+ data = (rpc_port_stub_lem_data_h)g_queue_pop_head(handle->connected_queue);
+ g_rec_mutex_unlock(&handle->mutex);
+
+ return data;
+}
+
+static void rpc_port_stub_lem_disconnected_data_push(rpc_port_stub_lem_h handle, rpc_port_stub_lem_data_h data)
+{
+ if (handle == nullptr || data == nullptr)
+ return;
+
+ g_rec_mutex_lock(&handle->mutex);
+ g_queue_push_tail(handle->disconnected_queue, data);
+ g_rec_mutex_unlock(&handle->mutex);
+}
+
+static rpc_port_stub_lem_data_h rpc_port_stub_lem_disconnected_data_pop(rpc_port_stub_lem_h handle)
+{
+ rpc_port_stub_lem_data_h data;
+
+ if (handle == nullptr)
+ return nullptr;
+
+ g_rec_mutex_lock(&handle->mutex);
+ data = (rpc_port_stub_lem_data_h)g_queue_pop_head(handle->disconnected_queue);
+ g_rec_mutex_unlock(&handle->mutex);
+
+ return data;
+}
+
+static void rpc_port_stub_lem_received_data_push(rpc_port_stub_lem_h handle, rpc_port_stub_lem_data_h data)
+{
+ if (handle == nullptr || data == nullptr)
+ return;
+
+ g_rec_mutex_lock(&handle->mutex);
+ g_queue_push_tail(handle->received_queue, data);
+ g_rec_mutex_unlock(&handle->mutex);
+}
+
+static rpc_port_stub_lem_data_h rpc_port_stub_lem_received_data_pop(rpc_port_stub_lem_h handle)
+{
+ rpc_port_stub_lem_data_h data;
+
+ if (handle == nullptr)
+ return nullptr;
+
+ g_rec_mutex_lock(&handle->mutex);
+ data = (rpc_port_stub_lem_data_h)g_queue_pop_head(handle->received_queue);
+ g_rec_mutex_unlock(&handle->mutex);
+
+ return data;
+}
+
+static gboolean rpc_port_stub_lem_on_connected(gpointer user_data)
+{
+ rpc_port_stub_lem_h handle = (rpc_port_stub_lem_h)user_data;
+ rpc_port_stub_lem_data_h data;
+
+ g_rec_mutex_lock(&handle->mutex);
+ data = rpc_port_stub_lem_connected_data_pop(handle);
+ if (handle->callback.connected)
+ handle->callback.connected(data->context, data->sender, data->instance, data->sync);
+
+ rpc_port_stub_lem_data_destroy(data);
+ g_rec_mutex_unlock(&handle->mutex);
+ return G_SOURCE_REMOVE;
+}
+
+static gboolean rpc_port_stub_lem_on_disconnected(gpointer user_data)
+{
+ rpc_port_stub_lem_h handle = (rpc_port_stub_lem_h)user_data;
+ rpc_port_stub_lem_data_h data;
+
+ g_rec_mutex_lock(&handle->mutex);
+ data = rpc_port_stub_lem_disconnected_data_pop(handle);
+ if (handle->callback.disconnected)
+ handle->callback.disconnected(data->context, data->sender, data->instance);
+
+ rpc_port_stub_lem_data_destroy(data);
+ g_rec_mutex_unlock(&handle->mutex);
+ return G_SOURCE_REMOVE;
+}
+
+static gboolean rpc_port_stub_lem_on_received(gpointer user_data)
+{
+ rpc_port_stub_lem_h handle = (rpc_port_stub_lem_h)user_data;
+ rpc_port_stub_lem_data_h data;
+
+ g_rec_mutex_lock(&handle->mutex);
+ data = rpc_port_stub_lem_received_data_pop(handle);
+ if (handle->callback.received)
+ handle->callback.received(data->context, data->sender, data->instance, data->parcel);
+
+ rpc_port_stub_lem_data_destroy(data);
+ g_rec_mutex_unlock(&handle->mutex);
+ return G_SOURCE_REMOVE;
+}
+
+static void __rpc_port_unit_to(rpc_port_parcel_h parcel, void *user_data)
+{
+ rpc_port_unit_h unit = user_data;
+ size_t size = 0;
+ unsigned int size_pos = 0;
+ unsigned int cur_pos = 0;
+ int ret;
+
+ ret = rpc_port_parcel_write_int32(parcel, unit->name);
+ if (ret != RPC_PORT_ERROR_NONE) {
+ set_last_result(ret);
+ return;
+ }
+
+ ret = rpc_port_parcel_write_int32(parcel, unit->type);
+ if (ret != RPC_PORT_ERROR_NONE) {
+ set_last_result(ret);
+ return;
+ }
+
+ ret = rpc_port_parcel_get_data_size(parcel, &size_pos);
+ if (ret != RPC_PORT_ERROR_NONE) {
+ set_last_result(ret);
+ return;
+ }
+
+ ret = rpc_port_parcel_reserve(parcel, sizeof(unsigned int));
+ if (ret != RPC_PORT_ERROR_NONE) {
+ set_last_result(ret);
+ return;
+ }
+
+ if (unit->write_cb)
+ unit->write_cb(parcel, unit);
+
+ ret = rpc_port_parcel_get_data_size(parcel, &cur_pos);
+ if (ret != RPC_PORT_ERROR_NONE) {
+ set_last_result(ret);
+ return;
+ }
+
+ size = cur_pos - size_pos - sizeof(unsigned int);
+ ret = rpc_port_parcel_set_data_size(parcel, size_pos);
+ if (ret != RPC_PORT_ERROR_NONE) {
+ set_last_result(ret);
+ return;
+ }
+
+ ret = rpc_port_parcel_write_int32(parcel, size);
+ if (ret != RPC_PORT_ERROR_NONE) {
+ set_last_result(ret);
+ return;
+ }
+
+ ret = rpc_port_parcel_set_data_size(parcel, cur_pos);
+
+ set_last_result(ret);
+}
+
+static void __rpc_port_unit_from(rpc_port_parcel_h parcel, void *user_data)
+{
+ rpc_port_unit_h unit = user_data;
+ int size = 0;
+ unsigned int start_pos = 0;
+ int ret;
+ rpc_port_parcel_h sub_parcel = NULL;
+
+ rpc_port_parcel_read_int32(parcel, &unit->name);
+ rpc_port_parcel_read_int32(parcel, &unit->type);
+ rpc_port_parcel_read_array_count(parcel, &size);
+ if (size == 0) return;
+
+ ret = rpc_port_parcel_get_reader(parcel, &start_pos);
+ if (ret != RPC_PORT_ERROR_NONE) {
+ set_last_result(ret);
+ return;
+ }
+
+ ret = rpc_port_parcel_create_from_parcel(&sub_parcel, parcel, start_pos,
+ size);
+ if (ret != RPC_PORT_ERROR_NONE) {
+ set_last_result(ret);
+ return;
+ }
+
+ ret = rpc_port_parcel_reserve(sub_parcel, size);
+ if (ret != RPC_PORT_ERROR_NONE) {
+ rpc_port_parcel_destroy(sub_parcel);
+ set_last_result(ret);
+ return;
+ }
+
+ ret = rpc_port_parcel_set_reader(parcel, start_pos + size);
+ if (ret != RPC_PORT_ERROR_NONE) {
+ rpc_port_parcel_destroy(sub_parcel);
+ set_last_result(ret);
+ return;
+ }
+
+ unit->parcel = sub_parcel;
+ set_last_result(RPC_PORT_ERROR_NONE);
+}
+
+static void rpc_port_unit_destroy(gpointer user_data)
+{
+ rpc_port_unit_h unit = user_data;
+
+ if (unit == nullptr)
+ return;
+
+ if (unit->parcel)
+ rpc_port_parcel_destroy(unit->parcel);
+
+ free(unit);
+}
+
+static rpc_port_unit_h rpc_port_unit_create(int name, int type)
+{
+ rpc_port_unit_h unit;
+
+ unit = calloc(1, sizeof(rpc_port_unit_t));
+ if (unit == nullptr) {
+ _E("calloc() is failed");
+ return nullptr;
+ }
+
+ unit->name = name;
+ unit->type = type;
+ unit->parcelable.to = __rpc_port_unit_to;
+ unit->parcelable.from = __rpc_port_unit_from;
+ unit->write_cb = nullptr;
+
+ return unit;
+}
+
+static void __rpc_port_unit_map_to(rpc_port_parcel_h parcel, void *user_data)
+{
+ rpc_port_unit_map_h unit_map = user_data;
+ rpc_port_unit_h unit;
+ GHashTableIter iter;
+ gpointer key;
+ gpointer value;
+
+ rpc_port_parcel_write_array_count(parcel, g_hash_table_size(unit_map->table) & INT_MAX);
+ g_hash_table_iter_init(&iter, unit_map->table);
+ while (g_hash_table_iter_next(&iter, &key, &value)) {
+ unit = (rpc_port_unit_h)value;
+ rpc_port_parcel_write(parcel, &unit->parcelable, unit);
+ if (get_last_result() != RPC_PORT_ERROR_NONE)
+ break;
+ }
+}
+
+static void __rpc_port_unit_map_from(rpc_port_parcel_h parcel, void *user_data)
+{
+ rpc_port_unit_map_h unit_map = user_data;
+ rpc_port_unit_h unit;
+ int size = 0;
+ int i;
+
+ rpc_port_parcel_read_array_count(parcel, &size);
+ rpc_port_parcel_pin(parcel);
+ for (i = 0; i < size; ++i) {
+ unit = rpc_port_unit_create(0, 0);
+ if (unit == nullptr) {
+ set_last_result(RPC_PORT_ERROR_OUT_OF_MEMORY);
+ break;
+ }
+
+ rpc_port_parcel_read(parcel, &unit->parcelable, unit);
+ if (get_last_result() != RPC_PORT_ERROR_NONE) {
+ rpc_port_unit_destroy(unit);
+ break;
+ }
+
+ g_hash_table_insert(unit_map->table, GINT_TO_POINTER(unit->name), unit);
+ }
+}
+
+static void rpc_port_unit_map_destroy(rpc_port_unit_map_h handle)
+{
+ if (handle == nullptr)
+ return;
+
+ if (handle->table)
+ g_hash_table_destroy(handle->table);
+
+ free(handle);
+}
+
+static rpc_port_unit_map_h rpc_port_unit_map_create(void)
+{
+ rpc_port_unit_map_h unit_map;
+
+ unit_map = calloc(1, sizeof(rpc_port_unit_map_t));
+ if (unit_map == nullptr) {
+ _E("calloc() is failed");
+ return nullptr;
+ }
+
+ unit_map->table = g_hash_table_new_full(g_direct_hash, g_direct_equal, nullptr, rpc_port_unit_destroy);
+ if (unit_map->table == nullptr) {
+ _E("g_hash_table_new_full() is failed");
+ rpc_port_unit_map_destroy(unit_map);
+ return nullptr;
+ }
+
+ unit_map->parcelable.to = __rpc_port_unit_map_to;
+ unit_map->parcelable.from = __rpc_port_unit_map_from;
+
+ return unit_map;
+}
+
+static void rpc_port_unit_map_read_remote_exception(rpc_port_unit_map_h unit_map,
+ int name, rpc_port_stub_hal_device_bezel_stub_1_remote_exception_h *value)
+{
+ rpc_port_unit_h unit;
+ rpc_port_stub_hal_device_bezel_stub_1_remote_exception_t *handle;
+ int ret;
+
+ if (value == nullptr) {
+ _E("Invalid parameter");
+ return;
+ }
+
+ if (unit_map == nullptr) {
+ _E("Invalid parameter");
+ return;
+ }
+
+ unit = g_hash_table_lookup(unit_map->table, GINT_TO_POINTER(name));
+ if (unit == nullptr) {
+ return;
+ }
+
+ if (unit->type != -1223777386 /*remote_exception*/) {
+ _E("type(%d) is not remote_exception", unit->type);
+ return;
+ }
+
+ ret = rpc_port_stub_hal_device_bezel_stub_1_remote_exception_create((rpc_port_stub_hal_device_bezel_stub_1_remote_exception_h *)&handle);
+ if (ret != RPC_PORT_ERROR_NONE) {
+ *value = nullptr;
+ return;
+ }
+
+ rpc_port_parcel_read(unit->parcel, &handle->parcelable, handle);
+ *value = handle;
+}
+
+static void rpc_port_unit_map_write_remote_exception_write_cb(rpc_port_parcel_h parcel, void* data)
+{
+ rpc_port_unit_h unit = data;
+ rpc_port_stub_hal_device_bezel_stub_1_remote_exception_h handle = unit->data;
+
+ rpc_port_parcel_write(parcel, &handle->parcelable, handle);
+}
+
+static int rpc_port_unit_map_write_remote_exception(rpc_port_unit_map_h unit_map,
+ int name, rpc_port_stub_hal_device_bezel_stub_1_remote_exception_h value)
+{
+ rpc_port_unit_h unit;
+
+ if (unit_map == nullptr)
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
+
+ unit = rpc_port_unit_create(name, -1223777386 /*remote_exception*/);
+ if (unit == nullptr)
+ return RPC_PORT_ERROR_OUT_OF_MEMORY;
+
+ unit->data = value;
+ unit->write_cb = rpc_port_unit_map_write_remote_exception_write_cb;
+ g_hash_table_insert(unit_map->table, GINT_TO_POINTER(unit->name), unit);
+
+ return RPC_PORT_ERROR_NONE;
+}
+
+static void rpc_port_unit_map_write_int_write_cb(rpc_port_parcel_h parcel, void* data)
+{
+ rpc_port_unit_h unit = data;
+ int *handle = unit->data;
+
+ rpc_port_parcel_burst_write(parcel, (const unsigned char*)handle, sizeof(*handle));
+}
+
+static int rpc_port_unit_map_write_int(rpc_port_unit_map_h unit_map,
+ int name, int *value)
+{
+ rpc_port_unit_h unit;
+
+ if (unit_map == nullptr)
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
+
+ unit = rpc_port_unit_create(name, 104431 /*int*/);
+ if (unit == nullptr)
+ return RPC_PORT_ERROR_OUT_OF_MEMORY;
+
+ unit->data = value;
+ unit->write_cb = rpc_port_unit_map_write_int_write_cb;
+
+ g_hash_table_insert(unit_map->table, GINT_TO_POINTER(unit->name), unit);
+
+ return RPC_PORT_ERROR_NONE;
+}
+
+static void rpc_port_unit_map_read_int(rpc_port_unit_map_h unit_map,
+ int name, int *value)
+{
+ rpc_port_unit_h unit;
+
+ if (value == nullptr) {
+ _E("Invalid parameter");
+ return;
+ }
+
+ if (unit_map == nullptr) {
+ *value = 0;
+ _E("Invalid parameter");
+ return;
+ }
+
+ unit = g_hash_table_lookup(unit_map->table, GINT_TO_POINTER(name));
+ if (unit == nullptr) {
+ _E("g_hash_table_lookup() is failed. name: %d", name);
+ *value = 0;
+ return;
+ }
+
+ if (unit->type != 104431 /*int*/) {
+ _E("type(%d) is not int", unit->type);
+ *value = 0;
+ return;
+ }
+
+ rpc_port_parcel_burst_read(unit->parcel, (unsigned char*)value, sizeof(*value));
+}
+
+static void __rpc_port_stub_hal_device_bezel_stub_1_enums_to(rpc_port_parcel_h parcel, void *data)
+{
+ rpc_port_stub_hal_device_bezel_stub_1_enums_t *handle = data;
+
+ if (parcel == nullptr || handle == nullptr) {
+ _E("Invalid parameter");
+ set_last_result(RPC_PORT_ERROR_INVALID_PARAMETER);
+ return;
+ }
+
+ set_last_result(RPC_PORT_ERROR_NONE);
+}
+
+static void __rpc_port_stub_hal_device_bezel_stub_1_enums_from(rpc_port_parcel_h parcel, void *data)
+{
+ rpc_port_stub_hal_device_bezel_stub_1_enums_t *handle = data;
+
+ if (parcel == nullptr || handle == nullptr) {
+ _E("Invalid parameter");
+ set_last_result(RPC_PORT_ERROR_INVALID_PARAMETER);
+ return;
+ }
+
+ set_last_result(RPC_PORT_ERROR_NONE);
+}
+
+int rpc_port_stub_hal_device_bezel_stub_1_enums_create(rpc_port_stub_hal_device_bezel_stub_1_enums_h *h)
+{
+ rpc_port_stub_hal_device_bezel_stub_1_enums_t *handle;
+
+ if (h == nullptr) {
+ _E("Invalid parameter");
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
+ }
+
+ handle = calloc(1, sizeof(rpc_port_stub_hal_device_bezel_stub_1_enums_t));
+ if (handle == nullptr) {
+ _E("Out of memory");
+ return RPC_PORT_ERROR_OUT_OF_MEMORY;
+ }
+
+ handle->parcelable.to = __rpc_port_stub_hal_device_bezel_stub_1_enums_to;
+ handle->parcelable.from = __rpc_port_stub_hal_device_bezel_stub_1_enums_from;
+
+ *h = handle;
+
+ return RPC_PORT_ERROR_NONE;
+}
+
+int rpc_port_stub_hal_device_bezel_stub_1_enums_destroy(rpc_port_stub_hal_device_bezel_stub_1_enums_h h)
+{
+ rpc_port_stub_hal_device_bezel_stub_1_enums_t *handle = h;
+
+ if (handle == nullptr) {
+ _E("Invalid parameter");
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
+ }
+
+ free(handle);
+
+ return RPC_PORT_ERROR_NONE;
+}
+
+int rpc_port_stub_hal_device_bezel_stub_1_enums_clone(rpc_port_stub_hal_device_bezel_stub_1_enums_h h, rpc_port_stub_hal_device_bezel_stub_1_enums_h *clone)
+{
+ rpc_port_stub_hal_device_bezel_stub_1_enums_h handle;
+ rpc_port_parcel_h parcel;
+ int ret;
+
+ if (h == nullptr || clone == nullptr) {
+ _E("Invalid parameter");
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
+ }
+
+ ret = rpc_port_stub_hal_device_bezel_stub_1_enums_create(&handle);
+ if (ret != RPC_PORT_ERROR_NONE) {
+ _E("Failed to create handle. error(%d)", ret);
+ return ret;
+ }
+
+ ret = rpc_port_parcel_create(&parcel);
+ if (ret != RPC_PORT_ERROR_NONE) {
+ _E("Failed to create parcel handle. error(%d)", ret);
+ rpc_port_stub_hal_device_bezel_stub_1_enums_destroy(handle);
+ return ret;
+ }
+
+ rpc_port_parcel_write(parcel, &h->parcelable, h);
+ rpc_port_parcel_read(parcel, &handle->parcelable, handle);
+ ret = get_last_result();
+ rpc_port_parcel_destroy(parcel);
+
+ if (ret != RPC_PORT_ERROR_NONE) {
+ _E("Failed to read data. error(%d)", ret);
+ rpc_port_stub_hal_device_bezel_stub_1_enums_destroy(handle);
+ return ret;
+ }
+
+ *clone = handle;
+
+ return RPC_PORT_ERROR_NONE;
+}
+
+static void __rpc_port_stub_hal_device_bezel_stub_1_remote_exception_to(rpc_port_parcel_h parcel, void *user_data)
+{
+ rpc_port_stub_hal_device_bezel_stub_1_remote_exception_h h = user_data;
+
+ rpc_port_parcel_write_int32(parcel, h->cause);
+ rpc_port_parcel_write_string(parcel, h->message);
+
+ set_last_result(RPC_PORT_ERROR_NONE);
+}
+
+static void __rpc_port_stub_hal_device_bezel_stub_1_remote_exception_from(rpc_port_parcel_h parcel, void *user_data)
+{
+ rpc_port_stub_hal_device_bezel_stub_1_remote_exception_h h = user_data;
+
+ rpc_port_parcel_read_int32(parcel, &h->cause);
+ rpc_port_parcel_read_string(parcel, &h->message);
+
+ set_last_result(RPC_PORT_ERROR_NONE);
+}
+
+int rpc_port_stub_hal_device_bezel_stub_1_remote_exception_create(rpc_port_stub_hal_device_bezel_stub_1_remote_exception_h *h)
+{
+ rpc_port_stub_hal_device_bezel_stub_1_remote_exception_h exception;
+
+ if (h == nullptr) {
+ _E("Invalid parameter");
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
+ }
+
+ exception = calloc(1, sizeof(rpc_port_stub_hal_device_bezel_stub_1_remote_exception_t));
+ if (exception == nullptr) {
+ _E("calloc() is failed");
+ return RPC_PORT_ERROR_OUT_OF_MEMORY;
+ }
+
+ exception->parcelable.to = __rpc_port_stub_hal_device_bezel_stub_1_remote_exception_to;
+ exception->parcelable.from = __rpc_port_stub_hal_device_bezel_stub_1_remote_exception_from;
+
+ *h = exception;
+
+ return RPC_PORT_ERROR_NONE;
+}
+
+int rpc_port_stub_hal_device_bezel_stub_1_remote_exception_set_cause(rpc_port_stub_hal_device_bezel_stub_1_remote_exception_h h, int cause)
+{
+ if (h == nullptr) {
+ _E("Invalid parameter");
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
+ }
+
+ h->cause = cause;
+
+ return RPC_PORT_ERROR_NONE;
+}
+
+int rpc_port_stub_hal_device_bezel_stub_1_remote_exception_set_message(rpc_port_stub_hal_device_bezel_stub_1_remote_exception_h h, const char *message)
+{
+ if (h == nullptr || message == nullptr) {
+ _E("Invalid parameter");
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
+ }
+
+ if (h->message)
+ free(h->message);
+
+ h->message = strdup(message);
+ if (h->message == nullptr) {
+ _E("strdup() is failed");
+ return RPC_PORT_ERROR_OUT_OF_MEMORY;
+ }
+
+ return RPC_PORT_ERROR_NONE;
+}
+
+int rpc_port_stub_hal_device_bezel_stub_1_remote_exception_get_cause(rpc_port_stub_hal_device_bezel_stub_1_remote_exception_h h, int *cause)
+{
+ if (h == nullptr || cause == nullptr) {
+ _E("Invalid parameter");
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
+ }
+
+ *cause = h->cause;
+
+ return RPC_PORT_ERROR_NONE;
+}
+
+int rpc_port_stub_hal_device_bezel_stub_1_remote_exception_get_message(rpc_port_stub_hal_device_bezel_stub_1_remote_exception_h h, char **message)
+{
+ if (h == nullptr || message == nullptr) {
+ _E("Invalid parameter");
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
+ }
+
+ *message = strdup(h->message);
+ if (*message == nullptr) {
+ _E("strdup() is failed");
+ return RPC_PORT_ERROR_OUT_OF_MEMORY;
+ }
+
+ return RPC_PORT_ERROR_NONE;
+}
+
+int rpc_port_stub_hal_device_bezel_stub_1_remote_exception_destroy(rpc_port_stub_hal_device_bezel_stub_1_remote_exception_h h)
+{
+ if (h == nullptr) {
+ _E("Invalid parameter");
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
+ }
+
+ if (h->message)
+ free(h->message);
+
+ free(h);
+
+ return RPC_PORT_ERROR_NONE;
+}
+
+int rpc_port_stub_hal_device_bezel_stub_1_remote_exception_throw(rpc_port_stub_hal_device_bezel_stub_1_remote_exception_h h)
+{
+ rpc_port_stub_hal_device_bezel_stub_1_remote_exception_h handle;
+ int ret;
+
+ if (h == nullptr) {
+ _E("Invalid parameter");
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
+ }
+
+ ret = rpc_port_stub_hal_device_bezel_stub_1_remote_exception_create(&handle);
+ if (ret != RPC_PORT_ERROR_NONE) {
+ _E("Failed to create remote exception");
+ return RPC_PORT_ERROR_OUT_OF_MEMORY;
+ }
+
+ if (__rpc_port_stub_hal_device_bezel_stub_1_remote_exception != nullptr) {
+ rpc_port_stub_hal_device_bezel_stub_1_remote_exception_destroy(__rpc_port_stub_hal_device_bezel_stub_1_remote_exception);
+ __rpc_port_stub_hal_device_bezel_stub_1_remote_exception = nullptr;
+ }
+
+ handle->cause = h->cause;
+ handle->message = h->message ? strdup(h->message) : nullptr;
+ __rpc_port_stub_hal_device_bezel_stub_1_remote_exception = handle;
+
+ return ret;
+}
+
+static int __rpc_port_stub_hal_device_bezel_stub_1_device_bezel_method_get_state_privilege_checker(rpc_port_stub_hal_device_bezel_stub_1_device_bezel_context_h h, bool *sync)
+{
+ return RPC_PORT_ERROR_NONE;
+}
+
+static int __rpc_port_stub_hal_device_bezel_stub_1_device_bezel_method_get_state_handler(rpc_port_h port, rpc_port_parcel_h parcel, rpc_port_unit_map_h map, void *user_data)
+{
+ rpc_port_stub_hal_device_bezel_stub_1_device_bezel_context_h context_ = user_data;
+ rpc_port_parcel_header_h header_;
+ int seq_num_ = -1;
+ rpc_port_h callback_port_;
+ int ret_ = RPC_PORT_ERROR_NONE;
+
+ rpc_port_stub_hal_device_bezel_stub_1_enums_state_e state;
+ rpc_port_parcel_h parcel_;
+ rpc_port_unit_map_h map_;
+ int res_ = -1;
+
+ if (context_->lem_context == nullptr) {
+ ret_ = rpc_port_stub_get_port(__device_bezel.stub, RPC_PORT_PORT_CALLBACK, context_->instance, &callback_port_);
+ if (ret_ != RPC_PORT_ERROR_NONE) {
+ _E("Failed to get callback port. error(%d)", ret_);
+ goto out;
+ }
+ }
+
+ rpc_port_parcel_get_header(parcel, &header_);
+ rpc_port_parcel_header_get_seq_num(header_, &seq_num_);
+
+ if (__rpc_port_stub_hal_device_bezel_stub_1_remote_exception != nullptr) {
+ rpc_port_stub_hal_device_bezel_stub_1_remote_exception_destroy(__rpc_port_stub_hal_device_bezel_stub_1_remote_exception);
+ __rpc_port_stub_hal_device_bezel_stub_1_remote_exception = nullptr;
+ }
+
+ if (context_->callback.get_state)
+ res_ = context_->callback.get_state(context_, &state, context_->user_data);
+
+ int method_ = RPC_PORT_STUB_HAL_DEVICE_BEZEL_STUB_1_DEVICE_BEZEL_METHOD_RESULT_;
+ ret_ = rpc_port_parcel_create(&parcel_);
+ if (ret_ != RPC_PORT_ERROR_NONE) {
+ _E("Failed to create parcel handle. error(%d)", ret_);
+ goto out;
+ }
+
+ rpc_port_parcel_get_header(parcel_, &header_);
+ rpc_port_parcel_header_set_tag(header_, TIDL_VERSION);
+ rpc_port_parcel_header_set_seq_num(header_, seq_num_);
+
+ map_ = rpc_port_unit_map_create();
+ if (map_ == nullptr) {
+ _E("Failed to create unit map");
+ rpc_port_parcel_destroy(parcel_);
+ ret_ = RPC_PORT_ERROR_OUT_OF_MEMORY;
+ goto out;
+ }
+
+ rpc_port_unit_map_write_int(map_, 1355467489 /*[METHOD]*/, &method_);
+
+ rpc_port_unit_map_write_int(map_, 109757585 /*state*/, (int*)&state);
+
+ rpc_port_unit_map_write_int(map_, 1497479973 /*[RESULT]*/, &res_);
+
+ if (__rpc_port_stub_hal_device_bezel_stub_1_remote_exception != nullptr)
+ rpc_port_unit_map_write_remote_exception(map_, -1571313492 /*[REMOTE_EXCEPTION]*/, __rpc_port_stub_hal_device_bezel_stub_1_remote_exception);
+
+ rpc_port_parcel_write(parcel_, &map_->parcelable, map_);
+ rpc_port_unit_map_destroy(map_);
+
+ if (context_->lem_context)
+ rpc_port_stub_lem_send_result(__device_bezel_context, context_->lem_context, parcel_);
+ else
+ ret_ = rpc_port_parcel_send(parcel_, port);
+
+ rpc_port_parcel_destroy(parcel_);
+
+out:
+
+ return ret_;
+}
+
+static int __rpc_port_stub_hal_device_bezel_stub_1_device_bezel_method_set_state_privilege_checker(rpc_port_stub_hal_device_bezel_stub_1_device_bezel_context_h h, bool *sync)
+{
+ return RPC_PORT_ERROR_NONE;
+}
+
+static int __rpc_port_stub_hal_device_bezel_stub_1_device_bezel_method_set_state_handler(rpc_port_h port, rpc_port_parcel_h parcel, rpc_port_unit_map_h map, void *user_data)
+{
+ rpc_port_stub_hal_device_bezel_stub_1_device_bezel_context_h context_ = user_data;
+ rpc_port_parcel_header_h header_;
+ int seq_num_ = -1;
+ rpc_port_h callback_port_;
+ int ret_ = RPC_PORT_ERROR_NONE;
+
+ rpc_port_stub_hal_device_bezel_stub_1_enums_state_e state;
+ rpc_port_parcel_h parcel_;
+ rpc_port_unit_map_h map_;
+ int res_ = -1;
+
+ if (context_->lem_context == nullptr) {
+ ret_ = rpc_port_stub_get_port(__device_bezel.stub, RPC_PORT_PORT_CALLBACK, context_->instance, &callback_port_);
+ if (ret_ != RPC_PORT_ERROR_NONE) {
+ _E("Failed to get callback port. error(%d)", ret_);
+ goto out;
+ }
+ }
+
+ rpc_port_parcel_get_header(parcel, &header_);
+ rpc_port_parcel_header_get_seq_num(header_, &seq_num_);
+
+ rpc_port_unit_map_read_int(map, 109757585 /*state*/, (int *)&state);
+
+ if (__rpc_port_stub_hal_device_bezel_stub_1_remote_exception != nullptr) {
+ rpc_port_stub_hal_device_bezel_stub_1_remote_exception_destroy(__rpc_port_stub_hal_device_bezel_stub_1_remote_exception);
+ __rpc_port_stub_hal_device_bezel_stub_1_remote_exception = nullptr;
+ }
+
+ if (context_->callback.set_state)
+ res_ = context_->callback.set_state(context_, state, context_->user_data);
+
+ int method_ = RPC_PORT_STUB_HAL_DEVICE_BEZEL_STUB_1_DEVICE_BEZEL_METHOD_RESULT_;
+ ret_ = rpc_port_parcel_create(&parcel_);
+ if (ret_ != RPC_PORT_ERROR_NONE) {
+ _E("Failed to create parcel handle. error(%d)", ret_);
+ goto out;
+ }
+
+ rpc_port_parcel_get_header(parcel_, &header_);
+ rpc_port_parcel_header_set_tag(header_, TIDL_VERSION);
+ rpc_port_parcel_header_set_seq_num(header_, seq_num_);
+
+ map_ = rpc_port_unit_map_create();
+ if (map_ == nullptr) {
+ _E("Failed to create unit map");
+ rpc_port_parcel_destroy(parcel_);
+ ret_ = RPC_PORT_ERROR_OUT_OF_MEMORY;
+ goto out;
+ }
+
+ rpc_port_unit_map_write_int(map_, 1355467489 /*[METHOD]*/, &method_);
+
+ rpc_port_unit_map_write_int(map_, 1497479973 /*[RESULT]*/, &res_);
+
+ if (__rpc_port_stub_hal_device_bezel_stub_1_remote_exception != nullptr)
+ rpc_port_unit_map_write_remote_exception(map_, -1571313492 /*[REMOTE_EXCEPTION]*/, __rpc_port_stub_hal_device_bezel_stub_1_remote_exception);
+
+ rpc_port_parcel_write(parcel_, &map_->parcelable, map_);
+ rpc_port_unit_map_destroy(map_);
+
+ if (context_->lem_context)
+ rpc_port_stub_lem_send_result(__device_bezel_context, context_->lem_context, parcel_);
+ else
+ ret_ = rpc_port_parcel_send(parcel_, port);
+
+ rpc_port_parcel_destroy(parcel_);
+
+out:
+
+ return ret_;
+}
+
+static int __rpc_port_stub_hal_device_bezel_stub_1_device_bezel_method_get_sw_state_privilege_checker(rpc_port_stub_hal_device_bezel_stub_1_device_bezel_context_h h, bool *sync)
+{
+ return RPC_PORT_ERROR_NONE;
+}
+
+static int __rpc_port_stub_hal_device_bezel_stub_1_device_bezel_method_get_sw_state_handler(rpc_port_h port, rpc_port_parcel_h parcel, rpc_port_unit_map_h map, void *user_data)
+{
+ rpc_port_stub_hal_device_bezel_stub_1_device_bezel_context_h context_ = user_data;
+ rpc_port_parcel_header_h header_;
+ int seq_num_ = -1;
+ rpc_port_h callback_port_;
+ int ret_ = RPC_PORT_ERROR_NONE;
+
+ rpc_port_stub_hal_device_bezel_stub_1_enums_state_e state;
+ rpc_port_parcel_h parcel_;
+ rpc_port_unit_map_h map_;
+ int res_ = -1;
+
+ if (context_->lem_context == nullptr) {
+ ret_ = rpc_port_stub_get_port(__device_bezel.stub, RPC_PORT_PORT_CALLBACK, context_->instance, &callback_port_);
+ if (ret_ != RPC_PORT_ERROR_NONE) {
+ _E("Failed to get callback port. error(%d)", ret_);
+ goto out;
+ }
+ }
+
+ rpc_port_parcel_get_header(parcel, &header_);
+ rpc_port_parcel_header_get_seq_num(header_, &seq_num_);
+
+ if (__rpc_port_stub_hal_device_bezel_stub_1_remote_exception != nullptr) {
+ rpc_port_stub_hal_device_bezel_stub_1_remote_exception_destroy(__rpc_port_stub_hal_device_bezel_stub_1_remote_exception);
+ __rpc_port_stub_hal_device_bezel_stub_1_remote_exception = nullptr;
+ }
+
+ if (context_->callback.get_sw_state)
+ res_ = context_->callback.get_sw_state(context_, &state, context_->user_data);
+
+ int method_ = RPC_PORT_STUB_HAL_DEVICE_BEZEL_STUB_1_DEVICE_BEZEL_METHOD_RESULT_;
+ ret_ = rpc_port_parcel_create(&parcel_);
+ if (ret_ != RPC_PORT_ERROR_NONE) {
+ _E("Failed to create parcel handle. error(%d)", ret_);
+ goto out;
+ }
+
+ rpc_port_parcel_get_header(parcel_, &header_);
+ rpc_port_parcel_header_set_tag(header_, TIDL_VERSION);
+ rpc_port_parcel_header_set_seq_num(header_, seq_num_);
+
+ map_ = rpc_port_unit_map_create();
+ if (map_ == nullptr) {
+ _E("Failed to create unit map");
+ rpc_port_parcel_destroy(parcel_);
+ ret_ = RPC_PORT_ERROR_OUT_OF_MEMORY;
+ goto out;
+ }
+
+ rpc_port_unit_map_write_int(map_, 1355467489 /*[METHOD]*/, &method_);
+
+ rpc_port_unit_map_write_int(map_, 109757585 /*state*/, (int*)&state);
+
+ rpc_port_unit_map_write_int(map_, 1497479973 /*[RESULT]*/, &res_);
+
+ if (__rpc_port_stub_hal_device_bezel_stub_1_remote_exception != nullptr)
+ rpc_port_unit_map_write_remote_exception(map_, -1571313492 /*[REMOTE_EXCEPTION]*/, __rpc_port_stub_hal_device_bezel_stub_1_remote_exception);
+
+ rpc_port_parcel_write(parcel_, &map_->parcelable, map_);
+ rpc_port_unit_map_destroy(map_);
+
+ if (context_->lem_context)
+ rpc_port_stub_lem_send_result(__device_bezel_context, context_->lem_context, parcel_);
+ else
+ ret_ = rpc_port_parcel_send(parcel_, port);
+
+ rpc_port_parcel_destroy(parcel_);
+
+out:
+
+ return ret_;
+}
+
+static int __rpc_port_stub_hal_device_bezel_stub_1_device_bezel_method_set_sw_state_privilege_checker(rpc_port_stub_hal_device_bezel_stub_1_device_bezel_context_h h, bool *sync)
+{
+ return RPC_PORT_ERROR_NONE;
+}
+
+static int __rpc_port_stub_hal_device_bezel_stub_1_device_bezel_method_set_sw_state_handler(rpc_port_h port, rpc_port_parcel_h parcel, rpc_port_unit_map_h map, void *user_data)
+{
+ rpc_port_stub_hal_device_bezel_stub_1_device_bezel_context_h context_ = user_data;
+ rpc_port_parcel_header_h header_;
+ int seq_num_ = -1;
+ rpc_port_h callback_port_;
+ int ret_ = RPC_PORT_ERROR_NONE;
+
+ rpc_port_stub_hal_device_bezel_stub_1_enums_state_e state;
+ rpc_port_parcel_h parcel_;
+ rpc_port_unit_map_h map_;
+ int res_ = -1;
+
+ if (context_->lem_context == nullptr) {
+ ret_ = rpc_port_stub_get_port(__device_bezel.stub, RPC_PORT_PORT_CALLBACK, context_->instance, &callback_port_);
+ if (ret_ != RPC_PORT_ERROR_NONE) {
+ _E("Failed to get callback port. error(%d)", ret_);
+ goto out;
+ }
+ }
+
+ rpc_port_parcel_get_header(parcel, &header_);
+ rpc_port_parcel_header_get_seq_num(header_, &seq_num_);
+
+ rpc_port_unit_map_read_int(map, 109757585 /*state*/, (int *)&state);
+
+ if (__rpc_port_stub_hal_device_bezel_stub_1_remote_exception != nullptr) {
+ rpc_port_stub_hal_device_bezel_stub_1_remote_exception_destroy(__rpc_port_stub_hal_device_bezel_stub_1_remote_exception);
+ __rpc_port_stub_hal_device_bezel_stub_1_remote_exception = nullptr;
+ }
+
+ if (context_->callback.set_sw_state)
+ res_ = context_->callback.set_sw_state(context_, state, context_->user_data);
+
+ int method_ = RPC_PORT_STUB_HAL_DEVICE_BEZEL_STUB_1_DEVICE_BEZEL_METHOD_RESULT_;
+ ret_ = rpc_port_parcel_create(&parcel_);
+ if (ret_ != RPC_PORT_ERROR_NONE) {
+ _E("Failed to create parcel handle. error(%d)", ret_);
+ goto out;
+ }
+
+ rpc_port_parcel_get_header(parcel_, &header_);
+ rpc_port_parcel_header_set_tag(header_, TIDL_VERSION);
+ rpc_port_parcel_header_set_seq_num(header_, seq_num_);
+
+ map_ = rpc_port_unit_map_create();
+ if (map_ == nullptr) {
+ _E("Failed to create unit map");
+ rpc_port_parcel_destroy(parcel_);
+ ret_ = RPC_PORT_ERROR_OUT_OF_MEMORY;
+ goto out;
+ }
+
+ rpc_port_unit_map_write_int(map_, 1355467489 /*[METHOD]*/, &method_);
+
+ rpc_port_unit_map_write_int(map_, 1497479973 /*[RESULT]*/, &res_);
+
+ if (__rpc_port_stub_hal_device_bezel_stub_1_remote_exception != nullptr)
+ rpc_port_unit_map_write_remote_exception(map_, -1571313492 /*[REMOTE_EXCEPTION]*/, __rpc_port_stub_hal_device_bezel_stub_1_remote_exception);
+
+ rpc_port_parcel_write(parcel_, &map_->parcelable, map_);
+ rpc_port_unit_map_destroy(map_);
+
+ if (context_->lem_context)
+ rpc_port_stub_lem_send_result(__device_bezel_context, context_->lem_context, parcel_);
+ else
+ ret_ = rpc_port_parcel_send(parcel_, port);
+
+ rpc_port_parcel_destroy(parcel_);
+
+out:
+
+ return ret_;
+}
+
+static int __rpc_port_stub_hal_device_bezel_stub_1_device_bezel_method_get_vib_state_privilege_checker(rpc_port_stub_hal_device_bezel_stub_1_device_bezel_context_h h, bool *sync)
+{
+ return RPC_PORT_ERROR_NONE;
+}
+
+static int __rpc_port_stub_hal_device_bezel_stub_1_device_bezel_method_get_vib_state_handler(rpc_port_h port, rpc_port_parcel_h parcel, rpc_port_unit_map_h map, void *user_data)
+{
+ rpc_port_stub_hal_device_bezel_stub_1_device_bezel_context_h context_ = user_data;
+ rpc_port_parcel_header_h header_;
+ int seq_num_ = -1;
+ rpc_port_h callback_port_;
+ int ret_ = RPC_PORT_ERROR_NONE;
+
+ rpc_port_stub_hal_device_bezel_stub_1_enums_vib_state_e state;
+ rpc_port_parcel_h parcel_;
+ rpc_port_unit_map_h map_;
+ int res_ = -1;
+
+ if (context_->lem_context == nullptr) {
+ ret_ = rpc_port_stub_get_port(__device_bezel.stub, RPC_PORT_PORT_CALLBACK, context_->instance, &callback_port_);
+ if (ret_ != RPC_PORT_ERROR_NONE) {
+ _E("Failed to get callback port. error(%d)", ret_);
+ goto out;
+ }
+ }
+
+ rpc_port_parcel_get_header(parcel, &header_);
+ rpc_port_parcel_header_get_seq_num(header_, &seq_num_);
+
+ if (__rpc_port_stub_hal_device_bezel_stub_1_remote_exception != nullptr) {
+ rpc_port_stub_hal_device_bezel_stub_1_remote_exception_destroy(__rpc_port_stub_hal_device_bezel_stub_1_remote_exception);
+ __rpc_port_stub_hal_device_bezel_stub_1_remote_exception = nullptr;
+ }
+
+ if (context_->callback.get_vib_state)
+ res_ = context_->callback.get_vib_state(context_, &state, context_->user_data);
+
+ int method_ = RPC_PORT_STUB_HAL_DEVICE_BEZEL_STUB_1_DEVICE_BEZEL_METHOD_RESULT_;
+ ret_ = rpc_port_parcel_create(&parcel_);
+ if (ret_ != RPC_PORT_ERROR_NONE) {
+ _E("Failed to create parcel handle. error(%d)", ret_);
+ goto out;
+ }
+
+ rpc_port_parcel_get_header(parcel_, &header_);
+ rpc_port_parcel_header_set_tag(header_, TIDL_VERSION);
+ rpc_port_parcel_header_set_seq_num(header_, seq_num_);
+
+ map_ = rpc_port_unit_map_create();
+ if (map_ == nullptr) {
+ _E("Failed to create unit map");
+ rpc_port_parcel_destroy(parcel_);
+ ret_ = RPC_PORT_ERROR_OUT_OF_MEMORY;
+ goto out;
+ }
+
+ rpc_port_unit_map_write_int(map_, 1355467489 /*[METHOD]*/, &method_);
+
+ rpc_port_unit_map_write_int(map_, 109757585 /*state*/, (int*)&state);
+
+ rpc_port_unit_map_write_int(map_, 1497479973 /*[RESULT]*/, &res_);
+
+ if (__rpc_port_stub_hal_device_bezel_stub_1_remote_exception != nullptr)
+ rpc_port_unit_map_write_remote_exception(map_, -1571313492 /*[REMOTE_EXCEPTION]*/, __rpc_port_stub_hal_device_bezel_stub_1_remote_exception);
+
+ rpc_port_parcel_write(parcel_, &map_->parcelable, map_);
+ rpc_port_unit_map_destroy(map_);
+
+ if (context_->lem_context)
+ rpc_port_stub_lem_send_result(__device_bezel_context, context_->lem_context, parcel_);
+ else
+ ret_ = rpc_port_parcel_send(parcel_, port);
+
+ rpc_port_parcel_destroy(parcel_);
+
+out:
+
+ return ret_;
+}
+
+static int __rpc_port_stub_hal_device_bezel_stub_1_device_bezel_method_set_vib_state_privilege_checker(rpc_port_stub_hal_device_bezel_stub_1_device_bezel_context_h h, bool *sync)
+{
+ return RPC_PORT_ERROR_NONE;
+}
+
+static int __rpc_port_stub_hal_device_bezel_stub_1_device_bezel_method_set_vib_state_handler(rpc_port_h port, rpc_port_parcel_h parcel, rpc_port_unit_map_h map, void *user_data)
+{
+ rpc_port_stub_hal_device_bezel_stub_1_device_bezel_context_h context_ = user_data;
+ rpc_port_parcel_header_h header_;
+ int seq_num_ = -1;
+ rpc_port_h callback_port_;
+ int ret_ = RPC_PORT_ERROR_NONE;
+
+ rpc_port_stub_hal_device_bezel_stub_1_enums_vib_state_e state;
+ rpc_port_parcel_h parcel_;
+ rpc_port_unit_map_h map_;
+ int res_ = -1;
+
+ if (context_->lem_context == nullptr) {
+ ret_ = rpc_port_stub_get_port(__device_bezel.stub, RPC_PORT_PORT_CALLBACK, context_->instance, &callback_port_);
+ if (ret_ != RPC_PORT_ERROR_NONE) {
+ _E("Failed to get callback port. error(%d)", ret_);
+ goto out;
+ }
+ }
+
+ rpc_port_parcel_get_header(parcel, &header_);
+ rpc_port_parcel_header_get_seq_num(header_, &seq_num_);
+
+ rpc_port_unit_map_read_int(map, 109757585 /*state*/, (int *)&state);
+
+ if (__rpc_port_stub_hal_device_bezel_stub_1_remote_exception != nullptr) {
+ rpc_port_stub_hal_device_bezel_stub_1_remote_exception_destroy(__rpc_port_stub_hal_device_bezel_stub_1_remote_exception);
+ __rpc_port_stub_hal_device_bezel_stub_1_remote_exception = nullptr;
+ }
+
+ if (context_->callback.set_vib_state)
+ res_ = context_->callback.set_vib_state(context_, state, context_->user_data);
+
+ int method_ = RPC_PORT_STUB_HAL_DEVICE_BEZEL_STUB_1_DEVICE_BEZEL_METHOD_RESULT_;
+ ret_ = rpc_port_parcel_create(&parcel_);
+ if (ret_ != RPC_PORT_ERROR_NONE) {
+ _E("Failed to create parcel handle. error(%d)", ret_);
+ goto out;
+ }
+
+ rpc_port_parcel_get_header(parcel_, &header_);
+ rpc_port_parcel_header_set_tag(header_, TIDL_VERSION);
+ rpc_port_parcel_header_set_seq_num(header_, seq_num_);
+
+ map_ = rpc_port_unit_map_create();
+ if (map_ == nullptr) {
+ _E("Failed to create unit map");
+ rpc_port_parcel_destroy(parcel_);
+ ret_ = RPC_PORT_ERROR_OUT_OF_MEMORY;
+ goto out;
+ }
+
+ rpc_port_unit_map_write_int(map_, 1355467489 /*[METHOD]*/, &method_);
+
+ rpc_port_unit_map_write_int(map_, 1497479973 /*[RESULT]*/, &res_);
+
+ if (__rpc_port_stub_hal_device_bezel_stub_1_remote_exception != nullptr)
+ rpc_port_unit_map_write_remote_exception(map_, -1571313492 /*[REMOTE_EXCEPTION]*/, __rpc_port_stub_hal_device_bezel_stub_1_remote_exception);
+
+ rpc_port_parcel_write(parcel_, &map_->parcelable, map_);
+ rpc_port_unit_map_destroy(map_);
+
+ if (context_->lem_context)
+ rpc_port_stub_lem_send_result(__device_bezel_context, context_->lem_context, parcel_);
+ else
+ ret_ = rpc_port_parcel_send(parcel_, port);
+
+ rpc_port_parcel_destroy(parcel_);
+
+out:
+
+ return ret_;
+}
+
+static rpc_port_stub_hal_device_bezel_stub_1_device_bezel_privilege_checker __device_bezel_privilege_checkers[] = {
+ [RPC_PORT_STUB_HAL_DEVICE_BEZEL_STUB_1_DEVICE_BEZEL_METHOD_GET_STATE] = __rpc_port_stub_hal_device_bezel_stub_1_device_bezel_method_get_state_privilege_checker,
+ [RPC_PORT_STUB_HAL_DEVICE_BEZEL_STUB_1_DEVICE_BEZEL_METHOD_SET_STATE] = __rpc_port_stub_hal_device_bezel_stub_1_device_bezel_method_set_state_privilege_checker,
+ [RPC_PORT_STUB_HAL_DEVICE_BEZEL_STUB_1_DEVICE_BEZEL_METHOD_GET_SW_STATE] = __rpc_port_stub_hal_device_bezel_stub_1_device_bezel_method_get_sw_state_privilege_checker,
+ [RPC_PORT_STUB_HAL_DEVICE_BEZEL_STUB_1_DEVICE_BEZEL_METHOD_SET_SW_STATE] = __rpc_port_stub_hal_device_bezel_stub_1_device_bezel_method_set_sw_state_privilege_checker,
+ [RPC_PORT_STUB_HAL_DEVICE_BEZEL_STUB_1_DEVICE_BEZEL_METHOD_GET_VIB_STATE] = __rpc_port_stub_hal_device_bezel_stub_1_device_bezel_method_get_vib_state_privilege_checker,
+ [RPC_PORT_STUB_HAL_DEVICE_BEZEL_STUB_1_DEVICE_BEZEL_METHOD_SET_VIB_STATE] = __rpc_port_stub_hal_device_bezel_stub_1_device_bezel_method_set_vib_state_privilege_checker,
+};
+
+static rpc_port_stub_method_handler __device_bezel_method_table[] = {
+ [RPC_PORT_STUB_HAL_DEVICE_BEZEL_STUB_1_DEVICE_BEZEL_METHOD_GET_STATE] = __rpc_port_stub_hal_device_bezel_stub_1_device_bezel_method_get_state_handler,
+ [RPC_PORT_STUB_HAL_DEVICE_BEZEL_STUB_1_DEVICE_BEZEL_METHOD_SET_STATE] = __rpc_port_stub_hal_device_bezel_stub_1_device_bezel_method_set_state_handler,
+ [RPC_PORT_STUB_HAL_DEVICE_BEZEL_STUB_1_DEVICE_BEZEL_METHOD_GET_SW_STATE] = __rpc_port_stub_hal_device_bezel_stub_1_device_bezel_method_get_sw_state_handler,
+ [RPC_PORT_STUB_HAL_DEVICE_BEZEL_STUB_1_DEVICE_BEZEL_METHOD_SET_SW_STATE] = __rpc_port_stub_hal_device_bezel_stub_1_device_bezel_method_set_sw_state_handler,
+ [RPC_PORT_STUB_HAL_DEVICE_BEZEL_STUB_1_DEVICE_BEZEL_METHOD_GET_VIB_STATE] = __rpc_port_stub_hal_device_bezel_stub_1_device_bezel_method_get_vib_state_handler,
+ [RPC_PORT_STUB_HAL_DEVICE_BEZEL_STUB_1_DEVICE_BEZEL_METHOD_SET_VIB_STATE] = __rpc_port_stub_hal_device_bezel_stub_1_device_bezel_method_set_vib_state_handler,
+};
+
+static void __rpc_port_stub_hal_device_bezel_stub_1_device_bezel_throw_remote_exception(rpc_port_h port, rpc_port_parcel_h parcel, int cause, const char *message)
+{
+ rpc_port_stub_hal_device_bezel_stub_1_remote_exception_h remote_exception = nullptr;
+ rpc_port_parcel_h result_parcel = nullptr;
+ rpc_port_parcel_header_h header = nullptr;
+ rpc_port_unit_map_h map;
+ int seq_num = 0;
+ int method = RPC_PORT_STUB_HAL_DEVICE_BEZEL_STUB_1_DEVICE_BEZEL_METHOD_RESULT_;
+
+ map = rpc_port_unit_map_create();
+ if (map == nullptr) {
+ _E("Failed to create unit map");
+ return;
+ }
+
+ rpc_port_unit_map_write_int(map, 1355467489 /*[METHOD]*/, &method);
+
+ rpc_port_stub_hal_device_bezel_stub_1_remote_exception_create(&remote_exception);
+ rpc_port_stub_hal_device_bezel_stub_1_remote_exception_set_cause(remote_exception, cause);
+ rpc_port_stub_hal_device_bezel_stub_1_remote_exception_set_message(remote_exception, message);
+ rpc_port_unit_map_write_remote_exception(map, -1571313492 /*[REMOTE_EXCEPTION]*/, remote_exception);
+ rpc_port_stub_hal_device_bezel_stub_1_remote_exception_destroy(remote_exception);
+
+ if (rpc_port_parcel_create(&result_parcel) != RPC_PORT_ERROR_NONE) {
+ _E("Failed to create parcel handle");
+ rpc_port_unit_map_destroy(map);
+ return;
+ }
+
+ rpc_port_parcel_get_header(parcel, &header);
+ rpc_port_parcel_header_get_seq_num(header, &seq_num);
+
+ header = nullptr;
+ rpc_port_parcel_get_header(result_parcel, &header);
+ rpc_port_parcel_header_set_tag(header, TIDL_VERSION);
+ rpc_port_parcel_header_set_seq_num(header, seq_num);
+
+ rpc_port_parcel_write(result_parcel, &map->parcelable, map);
+ rpc_port_unit_map_destroy(map);
+
+ if (rpc_port_parcel_send(result_parcel, port) != RPC_PORT_ERROR_NONE)
+ _E("Failed to send result");
+
+ rpc_port_parcel_destroy(result_parcel);
+}
+
+static int __rpc_port_stub_hal_device_bezel_stub_1_device_bezel_context_handle_request(rpc_port_stub_hal_device_bezel_stub_1_device_bezel_context_h h, rpc_port_parcel_h parcel)
+{
+ int cmd = -1;
+ rpc_port_unit_map_h map;
+ bool sync = false;
+ int ret;
+
+ map = rpc_port_unit_map_create();
+ if (map == nullptr) {
+ _E("Failed to create unit map");
+ return RPC_PORT_ERROR_OUT_OF_MEMORY;
+ }
+
+ rpc_port_parcel_read(parcel, &map->parcelable, map);
+
+ rpc_port_unit_map_read_int(map, 1355467489 /*[METHOD]*/, &cmd);
+
+ if (cmd > 1 && cmd < ARRAY_SIZE(__device_bezel_method_table)) {
+ if (h->lem_context == nullptr && h->app_info && __device_bezel_privilege_checkers[cmd]) {
+ ret = __device_bezel_privilege_checkers[cmd](h, &sync);
+ if (ret != RPC_PORT_ERROR_NONE) {
+ rpc_port_unit_map_destroy(map);
+ if (sync)
+ __rpc_port_stub_hal_device_bezel_stub_1_device_bezel_throw_remote_exception(h->port, parcel, ret, "Permission denied");
+
+ return ret;
+ }
+ }
+
+ if (__device_bezel_method_table[cmd])
+ ret = __device_bezel_method_table[cmd](h->port, parcel, map, h);
+
+ rpc_port_unit_map_destroy(map);
+ return ret;
+ }
+
+ rpc_port_unit_map_destroy(map);
+ _W("Invalid protocol. cmd(%d)", cmd);
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
+}
+
+#ifdef TIDL_THREAD_ENABLE
+static int __rpc_port_stub_hal_device_bezel_stub_1_device_bezel_context_push(rpc_port_stub_hal_device_bezel_stub_1_device_bezel_context_h h, rpc_port_parcel_h parcel)
+{
+ g_mutex_lock(&h->mutex);
+ g_queue_push_tail(h->queue, parcel);
+ g_cond_signal(&h->cond);
+ g_mutex_unlock(&h->mutex);
+
+ return 0;
+}
+
+static rpc_port_parcel_h __rpc_port_stub_hal_device_bezel_stub_1_device_bezel_context_wait_and_pop(rpc_port_stub_hal_device_bezel_stub_1_device_bezel_context_h h)
+{
+ rpc_port_parcel_h parcel;
+
+ g_mutex_lock(&h->mutex);
+ while (g_queue_is_empty(h->queue) && !h->done)
+ g_cond_wait(&h->cond, &h->mutex);
+
+ parcel = g_queue_pop_head(h->queue);
+ g_mutex_unlock(&h->mutex);
+
+ return parcel;
+}
+
+static gpointer __rpc_port_stub_hal_device_bezel_stub_1_device_bezel_context_thread_cb(gpointer user_data)
+{
+ rpc_port_stub_hal_device_bezel_stub_1_device_bezel_context_h h = user_data;
+ rpc_port_parcel_h parcel;
+
+ _W("START");
+ while (!h->done) {
+ parcel = __rpc_port_stub_hal_device_bezel_stub_1_device_bezel_context_wait_and_pop(h);
+ if (parcel) {
+ __rpc_port_stub_hal_device_bezel_stub_1_device_bezel_context_handle_request(h, parcel);
+ rpc_port_parcel_destroy(parcel);
+ }
+ }
+ _W("END");
+
+ return nullptr;
+}
+#endif /* TIDL_THREAD_ENABLE */
+
+static void __rpc_port_stub_hal_device_bezel_stub_1_device_bezel_context_destroy(gpointer data)
+{
+ rpc_port_stub_hal_device_bezel_stub_1_device_bezel_context_h h = data;
+#ifdef TIDL_THREAD_ENABLE
+ rpc_port_parcel_h parcel;
+#endif /* TIDL_THREAD_ENABLE */
+
+ if (h == nullptr)
+ return;
+
+#ifdef TIDL_THREAD_ENABLE
+ g_mutex_lock(&h->mutex);
+ h->done = true;
+ g_cond_signal(&h->cond);
+ g_mutex_unlock(&h->mutex);
+
+ if (h->thread) {
+ g_thread_join(h->thread);
+ g_thread_unref(h->thread);
+ }
+
+ g_mutex_clear(&h->mutex);
+ g_cond_clear(&h->cond);
+
+ if (h->queue) {
+ while (!g_queue_is_empty(h->queue)) {
+ parcel = g_queue_pop_head(h->queue);
+ rpc_port_parcel_destroy(parcel);
+ }
+
+ g_queue_free(h->queue);
+ }
+#endif /* TIDL_THREAD_ENABLE */
+
+ if (h->app_info)
+ app_info_destroy(h->app_info);
+
+ if (h->privileges)
+ g_hash_table_destroy(h->privileges);
+
+ if (h->instance)
+ free(h->instance);
+
+ if (h->sender)
+ free(h->sender);
+
+ free(h);
+}
+
+static bool __rpc_port_stub_hal_device_bezel_stub_1_device_bezel_context_privilege_info_cb(const char *privilege_name, void *user_data)
+{
+ rpc_port_stub_hal_device_bezel_stub_1_device_bezel_context_h h = user_data;
+ char *privilege;
+
+ privilege = strdup(privilege_name);
+ if (privilege == nullptr) {
+ _E("strdup() is failed. privilege: %s", privilege_name);
+ return false;
+ }
+
+ _D("appid: %s, privilege: %s", h->sender, privilege);
+ g_hash_table_insert(h->privileges, privilege, privilege);
+
+ return true;
+}
+
+static int __rpc_port_stub_hal_device_bezel_stub_1_device_bezel_context_load_privileges(rpc_port_stub_hal_device_bezel_stub_1_device_bezel_context_h h)
+{
+ package_info_h package_info;
+ app_info_h app_info;
+ char *package = nullptr;
+ int ret;
+
+ ret = app_info_create(h->sender, &app_info);
+ if (ret != APP_MANAGER_ERROR_NONE) {
+ if (ret == APP_MANAGER_ERROR_NO_SUCH_APP) {
+ _W("%s is not an application", h->sender);
+ return 0;
+ }
+
+ return ret;
+ }
+
+ h->app_info = app_info;
+ ret = app_info_get_package(app_info, &package);
+ if (ret != APP_MANAGER_ERROR_NONE) {
+ _E("Failed to get package. error(%d)", ret);
+ return ret;
+ }
+
+ ret = package_info_create(package, &package_info);
+ free(package);
+ if (ret != PACKAGE_MANAGER_ERROR_NONE) {
+ _E("Failed to create package info. error(%d)", ret);
+ return ret;
+ }
+
+ ret = package_info_foreach_privilege_info(package_info, __rpc_port_stub_hal_device_bezel_stub_1_device_bezel_context_privilege_info_cb, h);
+ package_info_destroy(package_info);
+
+ return ret;
+}
+
+static rpc_port_stub_hal_device_bezel_stub_1_device_bezel_context_h __rpc_port_stub_hal_device_bezel_stub_1_device_bezel_context_create(const char *sender, const char *instance, rpc_port_h callback_port, void *lem_context)
+{
+ rpc_port_stub_hal_device_bezel_stub_1_device_bezel_context_t *handle;
+
+ if (sender == nullptr || instance == nullptr) {
+ _E("Invalid parameter");
+ return nullptr;
+ }
+
+ if (lem_context == nullptr && callback_port == nullptr) {
+ _E("Invalid parameter");
+ return nullptr;
+ }
+
+ handle = calloc(1, sizeof(rpc_port_stub_hal_device_bezel_stub_1_device_bezel_context_t));
+ if (handle == nullptr) {
+ _E("Out of memory");
+ return nullptr;
+ }
+
+ handle->sender = strdup(sender);
+ if (handle->sender == nullptr) {
+ _E("Failed to duplicate sender");
+ __rpc_port_stub_hal_device_bezel_stub_1_device_bezel_context_destroy(handle);
+ return nullptr;
+ }
+
+ handle->instance = strdup(instance);
+ if (handle->instance == nullptr) {
+ _E("Failed to duplicate instance");
+ __rpc_port_stub_hal_device_bezel_stub_1_device_bezel_context_destroy(handle);
+ return nullptr;
+ }
+
+ handle->privileges = g_hash_table_new_full(g_str_hash, g_str_equal, free, nullptr);
+ if (handle->privileges == nullptr) {
+ _E("Failed to create hash table for privileges");
+ __rpc_port_stub_hal_device_bezel_stub_1_device_bezel_context_destroy(handle);
+ return nullptr;
+ }
+
+ if (__rpc_port_stub_hal_device_bezel_stub_1_device_bezel_context_load_privileges(handle) != 0) {
+ __rpc_port_stub_hal_device_bezel_stub_1_device_bezel_context_destroy(handle);
+ return nullptr;
+ }
+
+#ifdef TIDL_THREAD_ENABLE
+ g_mutex_init(&handle->mutex);
+ g_cond_init(&handle->cond);
+
+ handle->queue = g_queue_new();
+ if (handle->queue == nullptr) {
+ _E("Failed to create queue");
+ __rpc_port_stub_hal_device_bezel_stub_1_device_bezel_context_destroy(handle);
+ return nullptr;
+ }
+
+ handle->thread = g_thread_new(instance, __rpc_port_stub_hal_device_bezel_stub_1_device_bezel_context_thread_cb, handle);
+ if (handle->thread == nullptr) {
+ _E("Failed to create thread");
+ __rpc_port_stub_hal_device_bezel_stub_1_device_bezel_context_destroy(handle);
+ return nullptr;
+ }
+#endif /* TIDL_THREAD_ENABLE */
+
+ handle->lem_context = lem_context;
+ handle->callback_port = callback_port;
+ handle->callback = __device_bezel.callback;
+ handle->user_data = __device_bezel.user_data;
+
+ return handle;
+}
+
+static rpc_port_stub_hal_device_bezel_stub_1_device_bezel_context_h __rpc_port_stub_hal_device_bezel_stub_1_device_bezel_find_context(const char *instance)
+{
+ rpc_port_stub_hal_device_bezel_stub_1_device_bezel_context_h context;
+ GList *iter;
+
+ g_rec_mutex_lock(&__device_bezel.mutex);
+ iter = __device_bezel.contexts;
+ while (iter) {
+ context = iter->data;
+ if (!strcmp(context->instance, instance)) {
+ g_rec_mutex_unlock(&__device_bezel.mutex);
+ return context;
+ }
+
+ iter = g_list_next(iter);
+ }
+ g_rec_mutex_unlock(&__device_bezel.mutex);
+
+ return nullptr;
+}
+
+static void __rpc_port_stub_hal_device_bezel_stub_1_device_bezel_add_context(rpc_port_stub_hal_device_bezel_stub_1_device_bezel_context_h context)
+{
+ g_rec_mutex_lock(&__device_bezel.mutex);
+ __device_bezel.contexts = g_list_append(__device_bezel.contexts, context);
+ g_rec_mutex_unlock(&__device_bezel.mutex);
+}
+
+static void __rpc_port_stub_hal_device_bezel_stub_1_device_bezel_remove_context(rpc_port_stub_hal_device_bezel_stub_1_device_bezel_context_h context)
+{
+ g_rec_mutex_lock(&__device_bezel.mutex);
+ __device_bezel.contexts = g_list_remove(__device_bezel.contexts, context);
+ g_rec_mutex_unlock(&__device_bezel.mutex);
+}
+
+static void __rpc_port_stub_hal_device_bezel_stub_1_device_bezel_clear_context(gpointer data)
+{
+ rpc_port_stub_hal_device_bezel_stub_1_device_bezel_context_h context = data;
+
+ if (context->lem_context) {
+ _W("[LEM] disconnect %s:device_bezel", __stub_appid);
+ rpc_port_stub_lem_disconnect(__device_bezel_context, context->lem_context);
+ __rpc_port_stub_hal_device_bezel_stub_1_device_bezel_remove_context(context);
+ }
+ __rpc_port_stub_hal_device_bezel_stub_1_device_bezel_context_destroy(context);
+}
+
+int rpc_port_stub_hal_device_bezel_stub_1_device_bezel_context_set_tag(rpc_port_stub_hal_device_bezel_stub_1_device_bezel_context_h context, void *tag)
+{
+ if (context == nullptr) {
+ _E("Invalid parameter");
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
+ }
+
+ context->tag = tag;
+
+ return RPC_PORT_ERROR_NONE;
+}
+
+int rpc_port_stub_hal_device_bezel_stub_1_device_bezel_context_get_tag(rpc_port_stub_hal_device_bezel_stub_1_device_bezel_context_h context, void **tag)
+{
+ if (context == nullptr || tag == nullptr) {
+ _E("Invalid parameter");
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
+ }
+
+ *tag = context->tag;
+
+ return RPC_PORT_ERROR_NONE;
+}
+
+int rpc_port_stub_hal_device_bezel_stub_1_device_bezel_context_get_sender(rpc_port_stub_hal_device_bezel_stub_1_device_bezel_context_h context, char **sender)
+{
+ char *value;
+
+ if (context == nullptr || sender == nullptr) {
+ _E("Invalid parameter");
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
+ }
+
+ value = strdup(context->sender);
+ if (value == nullptr) {
+ _E("Failed to duplicate sender");
+ return RPC_PORT_ERROR_OUT_OF_MEMORY;
+ }
+
+ *sender = value;
+
+ return RPC_PORT_ERROR_NONE;
+}
+
+int rpc_port_stub_hal_device_bezel_stub_1_device_bezel_context_get_instance(rpc_port_stub_hal_device_bezel_stub_1_device_bezel_context_h context, char **instance)
+{
+ char *value;
+
+ if (context == nullptr || instance == nullptr) {
+ _E("Invalid parameter");
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
+ }
+
+ value = strdup(context->instance);
+ if (value == nullptr) {
+ _E("Failed to duplicate instance");
+ return RPC_PORT_ERROR_OUT_OF_MEMORY;
+ }
+
+ *instance = value;
+
+ return RPC_PORT_ERROR_NONE;
+}
+
+int rpc_port_stub_hal_device_bezel_stub_1_device_bezel_context_disconnect(rpc_port_stub_hal_device_bezel_stub_1_device_bezel_context_h context)
+{
+ int ret = RPC_PORT_ERROR_NONE;
+
+ if (context == nullptr) {
+ _E("Invalid parameter");
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
+ }
+
+ g_rec_mutex_lock(&__device_bezel.mutex);
+
+ if (context->lem_context) {
+ _W("[LEM] disconnect %s:device_bezel", __stub_appid);
+ rpc_port_stub_lem_disconnect(__device_bezel_context, context->lem_context);
+ __rpc_port_stub_hal_device_bezel_stub_1_device_bezel_remove_context(context);
+ __rpc_port_stub_hal_device_bezel_stub_1_device_bezel_context_destroy(context);
+ } else {
+ ret = rpc_port_disconnect(context->callback_port);
+ if (ret != RPC_PORT_ERROR_NONE)
+ _E("Failed to disconnect. error(%d)", ret);
+ }
+ g_rec_mutex_unlock(&__device_bezel.mutex);
+
+ return ret;
+}
+
+static void __rpc_port_stub_hal_device_bezel_stub_1_device_bezel_add_callback_port(rpc_port_h callback_port)
+{
+ g_rec_mutex_lock(&__device_bezel.mutex);
+ __device_bezel.callback_ports = g_list_append(__device_bezel.callback_ports, callback_port);
+ g_rec_mutex_unlock(&__device_bezel.mutex);
+}
+
+static void __rpc_port_stub_hal_device_bezel_stub_1_device_bezel_remove_callback_port(rpc_port_h callback_port)
+{
+ g_rec_mutex_lock(&__device_bezel.mutex);
+ __device_bezel.callback_ports = g_list_remove(__device_bezel.callback_ports, callback_port);
+ g_rec_mutex_unlock(&__device_bezel.mutex);
+}
+
+static void __rpc_port_stub_hal_device_bezel_stub_1_device_bezel_connected_event_cb(const char *sender, const char *instance, void *user_data)
+{
+ rpc_port_stub_hal_device_bezel_stub_1_device_bezel_context_h context;
+ rpc_port_h callback_port = nullptr;
+ int ret;
+
+ _W("sender(%s), instance(%s)", sender, instance);
+ ret = rpc_port_stub_get_port(__device_bezel.stub, RPC_PORT_PORT_CALLBACK, instance, &callback_port);
+ if (ret != RPC_PORT_ERROR_NONE) {
+ _E("Failed to get callback port. error(%d)", ret);
+ return;
+ }
+
+ context = __rpc_port_stub_hal_device_bezel_stub_1_device_bezel_context_create(sender, instance, callback_port, nullptr);
+ if (context == nullptr)
+ return;
+
+ __rpc_port_stub_hal_device_bezel_stub_1_device_bezel_add_context(context);
+ __rpc_port_stub_hal_device_bezel_stub_1_device_bezel_add_callback_port(context->callback_port);
+ context->callback.create(context, context->user_data);
+}
+
+static void __rpc_port_stub_hal_device_bezel_stub_1_device_bezel_disconnected_event_cb(const char *sender, const char *instance, void *user_data)
+{
+ rpc_port_stub_hal_device_bezel_stub_1_device_bezel_context_h context;
+
+ _W("sender(%s), instance(%s)", sender, instance);
+ context = __rpc_port_stub_hal_device_bezel_stub_1_device_bezel_find_context(instance);
+ if (context == nullptr)
+ return;
+
+ __rpc_port_stub_hal_device_bezel_stub_1_device_bezel_remove_callback_port(context->callback_port);
+ context->callback.terminate(context, context->user_data);
+ __rpc_port_stub_hal_device_bezel_stub_1_device_bezel_remove_context(context);
+ __rpc_port_stub_hal_device_bezel_stub_1_device_bezel_context_destroy(context);
+}
+
+static int __rpc_port_stub_hal_device_bezel_stub_1_device_bezel_received_event_cb(const char *sender, const char *instance, rpc_port_h port, void *user_data)
+{
+ rpc_port_stub_hal_device_bezel_stub_1_device_bezel_context_h context;
+ rpc_port_parcel_h parcel;
+ int ret;
+
+ _W("sender(%s), instance(%s)", sender, instance);
+ context = __rpc_port_stub_hal_device_bezel_stub_1_device_bezel_find_context(instance);
+ if (context == nullptr) {
+ _E("Failed to find context. instance(%s)", instance);
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
+ }
+
+ context->port = port;
+ ret = rpc_port_parcel_create_from_port(&parcel, port);
+ if (ret != RPC_PORT_ERROR_NONE) {
+ _E("Failed to create parcel handle from port. error(%d)", ret);
+ return ret;
+ }
+
+#ifdef TIDL_THREAD_ENABLE
+ ret = __rpc_port_stub_hal_device_bezel_stub_1_device_bezel_context_push(context, parcel);
+#else
+ ret = __rpc_port_stub_hal_device_bezel_stub_1_device_bezel_context_handle_request(context, parcel);
+ rpc_port_parcel_destroy(parcel);
+#endif /* TIDL_THREAD_ENABLE */
+
+ return ret;
+}
+
+static int __rpc_port_stub_hal_device_bezel_stub_1_device_bezel_set_access_control(void)
+{
+ int ret = RPC_PORT_ERROR_NONE;
+
+ return ret;
+}
+
+static void __rpc_port_stub_device_bezel_lem_connected_cb(void *lem_context, const char *sender, const char* instance, bool sync)
+{
+ rpc_port_stub_hal_device_bezel_stub_1_device_bezel_context_h context;
+
+ _W("[LEM] sender(%s), instance(%s)", sender, instance);
+ context = __rpc_port_stub_hal_device_bezel_stub_1_device_bezel_context_create(sender, instance, nullptr, lem_context);
+ if (context == nullptr)
+ return;
+
+ __rpc_port_stub_hal_device_bezel_stub_1_device_bezel_add_context(context);
+ context->callback.create(context, context->user_data);
+
+ rpc_port_stub_lem_connect(__device_bezel_context, lem_context, sync);
+}
+
+static void __rpc_port_stub_device_bezel_lem_disconnected_cb(void *lem_context, const char *sender, const char *instance)
+{
+ rpc_port_stub_hal_device_bezel_stub_1_device_bezel_context_h context;
+
+ _W("[LEM] sender(%s), instance(%s)", sender, instance);
+ context = __rpc_port_stub_hal_device_bezel_stub_1_device_bezel_find_context(instance);
+ if (context == nullptr)
+ return;
+
+ __rpc_port_stub_hal_device_bezel_stub_1_device_bezel_remove_callback_port(context->callback_port);
+ context->callback.terminate(context, context->user_data);
+ __rpc_port_stub_hal_device_bezel_stub_1_device_bezel_remove_context(context);
+ __rpc_port_stub_hal_device_bezel_stub_1_device_bezel_context_destroy(context);
+
+ rpc_port_stub_lem_disconnect(__device_bezel_context, lem_context);
+}
+
+static void __rpc_port_stub_device_bezel_lem_received_cb(void *lem_context, const char *sender, const char *instance, rpc_port_parcel_h parcel)
+{
+ rpc_port_stub_hal_device_bezel_stub_1_device_bezel_context_h context;
+
+ _W("[LEM] sender(%s), instance(%s)", sender, instance);
+ context = __rpc_port_stub_hal_device_bezel_stub_1_device_bezel_find_context(instance);
+ if (context == nullptr) {
+ _E("Failed to find context. instance(%s)", instance);
+ return;
+ }
+
+ __rpc_port_stub_hal_device_bezel_stub_1_device_bezel_context_handle_request(context, parcel);
+}
+
+int rpc_port_stub_hal_device_bezel_stub_1_device_bezel_register(rpc_port_stub_hal_device_bezel_stub_1_device_bezel_callback_s *callback, void *user_data)
+{
+ rpc_port_stub_lem_event_s lem_callback = { 0, };
+ int ret;
+
+ if (callback == nullptr || callback->create == nullptr || callback->terminate == nullptr) {
+ _E("Invalid parameter");
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
+ }
+
+ if (__stub_appid == nullptr)
+ app_get_id(&__stub_appid);
+
+ if (__device_bezel.stub) {
+ _E("Already exists");
+ return RPC_PORT_ERROR_NONE;
+ }
+
+ rpc_port_internal_init();
+
+ g_rec_mutex_init(&__device_bezel.mutex);
+ __device_bezel.callback = *callback;
+ __device_bezel.user_data = user_data;
+
+ ret = rpc_port_stub_create(&__device_bezel.stub, "device_bezel");
+ if (ret != RPC_PORT_ERROR_NONE) {
+ _E("Failed to create stub handle. error(%d)", ret);
+ g_rec_mutex_clear(&__device_bezel.mutex);
+ return ret;
+ }
+
+ ret = rpc_port_stub_add_received_event_cb(__device_bezel.stub, __rpc_port_stub_hal_device_bezel_stub_1_device_bezel_received_event_cb, &__device_bezel);
+ if (ret != RPC_PORT_ERROR_NONE) {
+ _E("Failed to add received event callback");
+ rpc_port_stub_hal_device_bezel_stub_1_device_bezel_unregister();
+ return ret;
+ }
+
+ ret = rpc_port_stub_add_connected_event_cb(__device_bezel.stub, __rpc_port_stub_hal_device_bezel_stub_1_device_bezel_connected_event_cb, &__device_bezel);
+ if (ret != RPC_PORT_ERROR_NONE) {
+ _E("Failed to add connected event callback");
+ rpc_port_stub_hal_device_bezel_stub_1_device_bezel_unregister();
+ return ret;
+ }
+
+ ret = rpc_port_stub_add_disconnected_event_cb(__device_bezel.stub, __rpc_port_stub_hal_device_bezel_stub_1_device_bezel_disconnected_event_cb, &__device_bezel);
+ if (ret != RPC_PORT_ERROR_NONE) {
+ _E("Failed to add disconnected event callback");
+ rpc_port_stub_hal_device_bezel_stub_1_device_bezel_unregister();
+ return ret;
+ }
+
+ ret = __rpc_port_stub_hal_device_bezel_stub_1_device_bezel_set_access_control();
+ if (ret != RPC_PORT_ERROR_NONE) {
+ _E("Failed to add privileges");
+ rpc_port_stub_hal_device_bezel_stub_1_device_bezel_unregister();
+ return ret;
+ }
+
+ ret = rpc_port_stub_listen(__device_bezel.stub);
+ if (ret != RPC_PORT_ERROR_NONE) {
+ _E("Failed to listen events. error(%d)", ret);
+ rpc_port_stub_hal_device_bezel_stub_1_device_bezel_unregister();
+ return ret;
+ }
+
+ lem_callback.connected = __rpc_port_stub_device_bezel_lem_connected_cb;
+ lem_callback.disconnected = __rpc_port_stub_device_bezel_lem_disconnected_cb;
+ lem_callback.received = __rpc_port_stub_device_bezel_lem_received_cb;
+
+ __device_bezel_context = rpc_port_stub_lem_create("device_bezel", &lem_callback);
+ if (__device_bezel_context == nullptr) {
+ _E("Failed to create lem context");
+ rpc_port_stub_hal_device_bezel_stub_1_device_bezel_unregister();
+ return RPC_PORT_ERROR_OUT_OF_MEMORY;
+ }
+
+ rpc_port_stub_lem_set_listening(__device_bezel_context, true);
+
+ return RPC_PORT_ERROR_NONE;
+}
+
+int rpc_port_stub_hal_device_bezel_stub_1_device_bezel_unregister(void)
+{
+ if (__device_bezel.stub == nullptr)
+ return RPC_PORT_ERROR_NONE;
+
+ g_rec_mutex_lock(&__device_bezel.mutex);
+ g_rec_mutex_unlock(&__device_bezel.mutex);
+ g_rec_mutex_clear(&__device_bezel.mutex);
+
+ rpc_port_stub_lem_set_listening(__device_bezel_context, false);
+
+ if (__device_bezel.contexts) {
+ g_list_free_full(__device_bezel.contexts, __rpc_port_stub_hal_device_bezel_stub_1_device_bezel_clear_context);
+ __device_bezel.contexts = nullptr;
+ }
+
+ if (__device_bezel.stub) {
+ rpc_port_stub_destroy(__device_bezel.stub);
+ __device_bezel.stub = nullptr;
+ }
+
+ if (__device_bezel_context) {
+ rpc_port_stub_lem_destroy(__device_bezel_context);
+ __device_bezel_context = nullptr;
+ }
+
+ return RPC_PORT_ERROR_NONE;
+}
+
+int rpc_port_stub_hal_device_bezel_stub_1_device_bezel_foreach_context(rpc_port_stub_hal_device_bezel_stub_1_device_bezel_context_cb callback, void *user_data)
+{
+ rpc_port_stub_hal_device_bezel_stub_1_device_bezel_context_h context;
+ GList *iter;
+
+ if (callback == nullptr) {
+ _E("Invalid parameter");
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
+ }
+
+ g_rec_mutex_lock(&__device_bezel.mutex);
+ iter = __device_bezel.contexts;
+ while (iter) {
+ context = iter->data;
+ if (!callback(context, user_data))
+ break;
+
+ iter = g_list_next(iter);
+ }
+ g_rec_mutex_unlock(&__device_bezel.mutex);
+
+ return RPC_PORT_ERROR_NONE;
+}
+
+int rpc_port_stub_hal_device_bezel_stub_1_device_bezel_get_client_number(unsigned int *client_number)
+{
+ if (client_number == nullptr) {
+ _E("Invalid parameter");
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
+ }
+
+ if (__device_bezel.stub == nullptr) {
+ _E("Invalid context");
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
+ }
+
+ g_rec_mutex_lock(&__device_bezel.mutex);
+ *client_number = g_list_length(__device_bezel.contexts);
+ g_rec_mutex_unlock(&__device_bezel.mutex);
+
+ return RPC_PORT_ERROR_NONE;
+}
+
+EXPORT_API int rpc_port_stub_hal_device_bezel_ipc_1_lem_device_bezel_connect(void *context, const char *sender, const char *instance, bool sync)
+{
+ rpc_port_stub_lem_h handle = __device_bezel_context;
+ rpc_port_stub_lem_data_h data;
+ GSource *source;
+
+ if (!rpc_port_stub_lem_is_listening(handle)) {
+ _E("Server is not ready");
+ return RPC_PORT_ERROR_IO_ERROR;
+ }
+
+ if (gettid() == getpid()) {
+ if (handle->callback.connected)
+ handle->callback.connected(context, sender, instance, sync);
+
+ return RPC_PORT_ERROR_NONE;
+ }
+
+ data = rpc_port_stub_lem_data_create(context, sender, instance, sync);
+ if (data == nullptr) {
+ _E("Ouf of memory");
+ return RPC_PORT_ERROR_OUT_OF_MEMORY;
+ }
+
+ rpc_port_stub_lem_connected_data_push(handle, data);
+ source = g_idle_source_new();
+ if (source == nullptr) {
+ _E("Failed to create idle source");
+ return RPC_PORT_ERROR_OUT_OF_MEMORY;
+ }
+
+ g_source_set_callback(source, (GSourceFunc)rpc_port_stub_lem_on_connected, handle, nullptr);
+ g_source_attach(source, handle->context);
+ g_source_unref(source);
+ return RPC_PORT_ERROR_NONE;
+}
+
+EXPORT_API int rpc_port_stub_hal_device_bezel_ipc_1_lem_device_bezel_disconnect(void *context, const char *sender, const char *instance)
+{
+ rpc_port_stub_lem_h handle = __device_bezel_context;
+ rpc_port_stub_lem_data_h data;
+ GSource *source;
+
+ if (!rpc_port_stub_lem_is_listening(handle)) {
+ _E("Server is not ready");
+ return RPC_PORT_ERROR_IO_ERROR;
+ }
+
+ if (gettid() == getpid()) {
+ if (handle->callback.disconnected)
+ handle->callback.disconnected(context, sender, instance);
+
+ return RPC_PORT_ERROR_NONE;
+ }
+
+ data = rpc_port_stub_lem_data_create(context, sender, instance, false);
+ if (data == nullptr) {
+ _E("Ouf of memory");
+ return RPC_PORT_ERROR_OUT_OF_MEMORY;
+ }
+
+ rpc_port_stub_lem_disconnected_data_push(handle, data);
+ source = g_idle_source_new();
+ if (source == nullptr) {
+ _E("Failed to create idle source");
+ return RPC_PORT_ERROR_OUT_OF_MEMORY;
+ }
+
+ g_source_set_callback(source, (GSourceFunc)rpc_port_stub_lem_on_disconnected, handle, nullptr);
+ g_source_attach(source, handle->context);
+ g_source_unref(source);
+ return RPC_PORT_ERROR_NONE;
+}
+
+EXPORT_API int rpc_port_stub_hal_device_bezel_ipc_1_lem_device_bezel_send(void *context, const char* sender, const char *instance, rpc_port_parcel_h parcel)
+{
+ rpc_port_stub_lem_h handle = __device_bezel_context;
+ rpc_port_stub_lem_data_h data;
+ GSource *source;
+ rpc_port_parcel_h cloned_parcel;
+
+ if (!rpc_port_stub_lem_is_listening(handle)) {
+ _E("Server is not ready");
+ return RPC_PORT_ERROR_IO_ERROR;
+ }
+
+ if (gettid() == getpid()) {
+ if (handle->callback.received) {
+ rpc_port_parcel_clone(&cloned_parcel, parcel);
+ handle->callback.received(context, sender, instance, cloned_parcel);
+ rpc_port_parcel_destroy(cloned_parcel);
+ }
+
+ return RPC_PORT_ERROR_NONE;
+ }
+
+ data = rpc_port_stub_lem_data_create_with_parcel(context, sender, instance, parcel);
+ if (data == nullptr) {
+ _E("Ouf of memory");
+ return RPC_PORT_ERROR_OUT_OF_MEMORY;
+ }
+
+ rpc_port_stub_lem_received_data_push(handle, data);
+ source = g_idle_source_new();
+ if (source == nullptr) {
+ _E("Failed to create idle source");
+ return RPC_PORT_ERROR_OUT_OF_MEMORY;
+ }
+
+ g_source_set_callback(source, (GSourceFunc)rpc_port_stub_lem_on_received, handle, nullptr);
+ g_source_attach(source, handle->context);
+ g_source_unref(source);
+ return RPC_PORT_ERROR_NONE;
+}
+
--- /dev/null
+/*
+ * Generated by tidlc 2.6.1.
+ */
+
+#pragma once
+
+#include <stdbool.h>
+#include <bundle.h>
+#include <rpc-port.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * @brief The rpc_port_stub_hal_device_bezel_stub_1_enums_state enum.
+ */
+typedef enum {
+ RPC_PORT_STUB_HAL_DEVICE_BEZEL_STUB_1_STATE_ENUMS_TURNOFF = 0,
+ RPC_PORT_STUB_HAL_DEVICE_BEZEL_STUB_1_STATE_ENUMS_TURNON,
+} rpc_port_stub_hal_device_bezel_stub_1_enums_state_e;
+
+/**
+ * @brief The rpc_port_stub_hal_device_bezel_stub_1_enums_vib_state enum.
+ */
+typedef enum {
+ RPC_PORT_STUB_HAL_DEVICE_BEZEL_STUB_1_VIB_STATE_ENUMS_NONE = 0,
+ RPC_PORT_STUB_HAL_DEVICE_BEZEL_STUB_1_VIB_STATE_ENUMS_LIGHT,
+ RPC_PORT_STUB_HAL_DEVICE_BEZEL_STUB_1_VIB_STATE_ENUMS_MEDIUM,
+ RPC_PORT_STUB_HAL_DEVICE_BEZEL_STUB_1_VIB_STATE_ENUMS_STRONG,
+} rpc_port_stub_hal_device_bezel_stub_1_enums_vib_state_e;
+
+/**
+ * @brief The rpc_port_stub_hal_device_bezel_stub_1_enums handle.
+ */
+typedef struct rpc_port_stub_hal_device_bezel_stub_1_enums_s *rpc_port_stub_hal_device_bezel_stub_1_enums_h;
+
+/**
+ * @breif The rpc_port_stub_hal_device_bezel_stub_1 remote exception handle.
+ */
+typedef struct rpc_port_stub_hal_device_bezel_stub_1_remote_exception_s *rpc_port_stub_hal_device_bezel_stub_1_remote_exception_h;
+
+/**
+ * @brief The rpc_port_stub_hal_device_bezel_stub_1_device_bezel_context handle.
+ */
+typedef struct rpc_port_stub_hal_device_bezel_stub_1_device_bezel_context_s *rpc_port_stub_hal_device_bezel_stub_1_device_bezel_context_h;
+
+/**
+ * @brief Creates a rpc_port_stub_hal_device_bezel_stub_1_enums handle.
+ *
+ * @remarks The @a h handle should be released using the rpc_port_stub_hal_device_bezel_stub_1_enums_destroy()
+ * if it's no longer needed.
+ * @param[out] h The rpc_port_stub_hal_device_bezel_stub_1_enums handle that is newly created
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #RPC_PORT_ERROR_NONE Successful
+ * @retval #RPC_PORT_ERROR_INVALID_PARAMTER Invaid parameter
+ * @retval #RPC_PORT_ERROR_OUT_OF_MEMORY Out of memory
+ * @see rpc_port_stub_hal_device_bezel_stub_1_enums_destroy()
+ */
+int rpc_port_stub_hal_device_bezel_stub_1_enums_create(rpc_port_stub_hal_device_bezel_stub_1_enums_h *h);
+
+/**
+ * @brief Destroys the rpc_port_stub_hal_device_bezel_stub_1_enums handle.
+ *
+ * @param[in] h The rpc_port_stub_hal_device_bezel_stub_1_enums handle
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #RPC_PORT_ERROR_NONE Successful
+ * @retval #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #RPC_PORT_ERROR_OUT_OF_MEMORY Out of memory
+ * @see rpc_port_stub_hal_device_bezel_stub_1_enums_create()
+ */
+int rpc_port_stub_hal_device_bezel_stub_1_enums_destroy(rpc_port_stub_hal_device_bezel_stub_1_enums_h h);
+
+/**
+ * @brief Creates and returns a copy of the given rpc_port_stub_hal_device_bezel_stub_1_enums handle.
+ *
+ * @remarks A new created rpc_port_stub_hal_device_bezel_stub_1_enums should be released using
+ * the rpc_port_stub_hal_device_bezel_stub_1_enums_destroy() if it's no longer needed.
+ * @param[in] h The rpc_port_stub_hal_device_bezel_stub_1_enums handle
+ * @param[out] clone If successful, a new created rpc_port_stub_hal_device_bezel_stub_1_enums handle will be returned
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #RPC_PORT_ERROR_NONE Successful
+ * @retval #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #RPC_PORT_ERROR_OUT_OF_MEMORY Out of memory
+ * @see rpc_port_stub_hal_device_bezel_stub_1_enums_destroy()
+ */
+int rpc_port_stub_hal_device_bezel_stub_1_enums_clone(rpc_port_stub_hal_device_bezel_stub_1_enums_h h, rpc_port_stub_hal_device_bezel_stub_1_enums_h *clone);
+
+/**
+ * @brief Creates the rpc_port_stub_hal_device_bezel_stub_1 remote exception handle.
+ *
+ * @remarks The @c h handle should be released if it's no longer needed.
+ * @param[out] h The rpc_port_stub_hal_device_bezel_stub_1 remote exception handle.
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #RPC_PORT_ERROR_NONE Successful
+ * @retval #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #RPC_PORT_ERROR_OUT_OF_MEMORY Out of memory
+* @see rpc_port_stub_hal_device_bezel_stub_1_remote_exception_destroy()
+ */
+int rpc_port_stub_hal_device_bezel_stub_1_remote_exception_create(rpc_port_stub_hal_device_bezel_stub_1_remote_exception_h *h);
+
+/**
+ * @brief Sets the cause of the exception.
+ *
+ * @param[in] h The rpc_port_stub_hal_device_bezel_stub_1 remote exception handle
+ * @param[in] cause The cause of the exception
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #RPC_PORT_ERROR_NONE Successful
+ * @retval #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter
+ */
+int rpc_port_stub_hal_device_bezel_stub_1_remote_exception_set_cause(rpc_port_stub_hal_device_bezel_stub_1_remote_exception_h h, int cause);
+
+/**
+ * @brief Sets the detail message of the exception.
+ *
+ * @param[in] h The rpc_port_stub_hal_device_bezel_stub_1 remote exception handle
+ * @param[in] message The detail message of the exception
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #RPC_PORT_ERROR_NONE Successful
+ * @retval #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #RPC_PORT_ERROR_OUT_OF_MEMORY Out of memory
+ */
+int rpc_port_stub_hal_device_bezel_stub_1_remote_exception_set_message(rpc_port_stub_hal_device_bezel_stub_1_remote_exception_h h, const char *message);
+
+/**
+ * @brief Gets the cause of the exception.
+ * @param[in] h The rpc_port_stub_hal_device_bezel_stub_1 remote exception handle.
+ * @param[out] cause The cause
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #RPC_PORT_ERROR_NONE Successful
+ * @retval #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter
+ */
+int rpc_port_stub_hal_device_bezel_stub_1_remote_exception_get_cause(rpc_port_stub_hal_device_bezel_stub_1_remote_exception_h h, int *cause);
+
+/**
+ * @brief Gets the detail message of the exception.
+ * @remarks The @c message should be released if it's no longer needed.
+ * @param[in] h The rpc_port_stub_hal_device_bezel_stub_1 remote exception handle.
+ * @param[out] message The detail message
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #RPC_PORT_ERROR_NONE Successful
+ * @retval #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #RPC_PORT_ERROR_OUT_OF_MEMORY Out of memory
+ */
+int rpc_port_stub_hal_device_bezel_stub_1_remote_exception_get_message(rpc_port_stub_hal_device_bezel_stub_1_remote_exception_h, char **message);
+
+/**
+ * @brief Destroys the remote exception handle.
+ * @param[in] h The rpc_port_stub_hal_device_bezel_stub_1 remote exception handle
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #RPC_PORT_ERROR_NONE Successful
+ * @retval #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter
+ */
+int rpc_port_stub_hal_device_bezel_stub_1_remote_exception_destroy(rpc_port_stub_hal_device_bezel_stub_1_remote_exception_h h);
+
+/**
+ * @brief Throws the exception to the client.
+ * @details This function throws the exception to the client in the callback function.
+ * While calling the registered callback function related the method call, this function should be called
+ * if you want to send the remote exception to the client.
+ * If this function is called outside of the registered callback function, it's meaningless.
+ * The callback function is not returned by calling this function.
+ *
+ * @param[in] h The rpc_port_stub_hal_device_bezel_stub_1 remote exception handle
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #RPC_PORT_ERROR_NONE Successful
+ * @retval #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #RPC_PORT_ERROR_OUT_OF_MEMORY Out of memory
+ * @see rpc_port_stub_hal_device_bezel_stub_1_remote_exception_create()
+ * @see rpc_port_stub_hal_device_bezel_stub_1_remote_exception_destroy()
+ */
+int rpc_port_stub_hal_device_bezel_stub_1_remote_exception_throw(rpc_port_stub_hal_device_bezel_stub_1_remote_exception_h h);
+
+/**
+ * @brief Called when the proxy is connected.
+ * @details The callback function is called when the proxy is connected to the stub.
+ *
+ * @param[in] context The context handle
+ * @param[in] user_data The user data passed from the registration function
+ * @see #rpc_port_stub_hal_device_bezel_stub_1_device_bezel_callback_s
+ */
+typedef void (*rpc_port_stub_hal_device_bezel_stub_1_device_bezel_create_cb)(rpc_port_stub_hal_device_bezel_stub_1_device_bezel_context_h context, void *user_data);
+
+/**
+ * @brief Called when the proxy is disconnected.
+ * @details The callback function is called when the proxy is disconnected from the stub.
+ *
+ * @param[in] context The context handle
+ * @param[in] user_data The user data passed from the registration function
+ * @see #rpc_port_stub_hal_device_bezel_stub_1_device_bezel_callback_s
+ */
+typedef void (*rpc_port_stub_hal_device_bezel_stub_1_device_bezel_terminate_cb)(rpc_port_stub_hal_device_bezel_stub_1_device_bezel_context_h context, void *user_data);
+
+/**
+ * @brief Called to get the proxy context once for each connected proxy.
+ *
+ * @param[in] context The context handle
+ * @param[in] user_data The user data passed from the registration function
+ * @return @c true to continue with the next iteration of the loop,
+ * otherwise @c false to break out of the loop
+ * @pre rpc_port_stub_hal_device_bezel_stub_1_device_bezel_foreach_context() will invoke this callback.
+ * @see rpc_port_stub_hal_device_bezel_stub_1_device_bezel_foreach_context()
+ */
+typedef bool (*rpc_port_stub_hal_device_bezel_stub_1_device_bezel_context_cb)(rpc_port_stub_hal_device_bezel_stub_1_device_bezel_context_h context, void *user_data);
+
+/**
+ * @brief Called when the request of the proxy is delivered.
+ *
+ * @param[in] context The context handle
+ * @param[in] user_data The user data passed from the registration function
+ * @see #rpc_port_stub_hal_device_bezel_stub_1_device_bezel_callback_s;
+ */
+typedef int (*rpc_port_stub_hal_device_bezel_stub_1_device_bezel_get_state_cb)(rpc_port_stub_hal_device_bezel_stub_1_device_bezel_context_h context, rpc_port_stub_hal_device_bezel_stub_1_enums_state_e *state, void *user_data);
+
+/**
+ * @brief Called when the request of the proxy is delivered.
+ *
+ * @param[in] context The context handle
+ * @param[in] user_data The user data passed from the registration function
+ * @see #rpc_port_stub_hal_device_bezel_stub_1_device_bezel_callback_s;
+ */
+typedef int (*rpc_port_stub_hal_device_bezel_stub_1_device_bezel_set_state_cb)(rpc_port_stub_hal_device_bezel_stub_1_device_bezel_context_h context, rpc_port_stub_hal_device_bezel_stub_1_enums_state_e state, void *user_data);
+
+/**
+ * @brief Called when the request of the proxy is delivered.
+ *
+ * @param[in] context The context handle
+ * @param[in] user_data The user data passed from the registration function
+ * @see #rpc_port_stub_hal_device_bezel_stub_1_device_bezel_callback_s;
+ */
+typedef int (*rpc_port_stub_hal_device_bezel_stub_1_device_bezel_get_sw_state_cb)(rpc_port_stub_hal_device_bezel_stub_1_device_bezel_context_h context, rpc_port_stub_hal_device_bezel_stub_1_enums_state_e *state, void *user_data);
+
+/**
+ * @brief Called when the request of the proxy is delivered.
+ *
+ * @param[in] context The context handle
+ * @param[in] user_data The user data passed from the registration function
+ * @see #rpc_port_stub_hal_device_bezel_stub_1_device_bezel_callback_s;
+ */
+typedef int (*rpc_port_stub_hal_device_bezel_stub_1_device_bezel_set_sw_state_cb)(rpc_port_stub_hal_device_bezel_stub_1_device_bezel_context_h context, rpc_port_stub_hal_device_bezel_stub_1_enums_state_e state, void *user_data);
+
+/**
+ * @brief Called when the request of the proxy is delivered.
+ *
+ * @param[in] context The context handle
+ * @param[in] user_data The user data passed from the registration function
+ * @see #rpc_port_stub_hal_device_bezel_stub_1_device_bezel_callback_s;
+ */
+typedef int (*rpc_port_stub_hal_device_bezel_stub_1_device_bezel_get_vib_state_cb)(rpc_port_stub_hal_device_bezel_stub_1_device_bezel_context_h context, rpc_port_stub_hal_device_bezel_stub_1_enums_vib_state_e *state, void *user_data);
+
+/**
+ * @brief Called when the request of the proxy is delivered.
+ *
+ * @param[in] context The context handle
+ * @param[in] user_data The user data passed from the registration function
+ * @see #rpc_port_stub_hal_device_bezel_stub_1_device_bezel_callback_s;
+ */
+typedef int (*rpc_port_stub_hal_device_bezel_stub_1_device_bezel_set_vib_state_cb)(rpc_port_stub_hal_device_bezel_stub_1_device_bezel_context_h context, rpc_port_stub_hal_device_bezel_stub_1_enums_vib_state_e state, void *user_data);
+
+/**
+ * @brief Sets the tag to the context handle.
+ *
+ * @param[in] context The context handle
+ * @param[in] tag The tag
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #RPC_PORT_ERROR_NONE Successful
+ * @retval #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @see rpc_port_stub_hal_device_bezel_stub_1_device_bezel_context_get_tag()
+ */
+int rpc_port_stub_hal_device_bezel_stub_1_device_bezel_context_set_tag(rpc_port_stub_hal_device_bezel_stub_1_device_bezel_context_h context, void *tag);
+
+/**
+ * @brief Gets the tag from the context handle.
+ *
+ * @param[in] context The context handle
+ * @param[out] tag The tag
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #RPC_PORT_ERROR_NONE Successful
+ * @retval #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @see rpc_port_stub_hal_device_bezel_stub_1_device_bezel_context_set_tag()
+ */
+int rpc_port_stub_hal_device_bezel_stub_1_device_bezel_context_get_tag(rpc_port_stub_hal_device_bezel_stub_1_device_bezel_context_h context, void **tag);
+
+/**
+ * @brief Gets the sender ID from the context handle.
+ * @details The @a sender should be released using free().
+ *
+ * @param[in] context The context handle
+ * @param[out] sender The sender ID of the context handle
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #RPC_PORT_ERROR_NONE Successful
+ * @retval #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #RPC_PORT_ERROR_OUT_OF_MEMORY Out of memory
+ */
+int rpc_port_stub_hal_device_bezel_stub_1_device_bezel_context_get_sender(rpc_port_stub_hal_device_bezel_stub_1_device_bezel_context_h context, char **sender);
+
+/**
+ * @brief Gets the instance ID from the context handle.
+ * @details The @a instance should be released using free().
+ *
+ * @param[in] context The context handle
+ * @param[out] instance The instance ID of the context handle
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #RPC_PORT_ERROR_NONE Successful
+ * @retval #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #RPC_PORT_ERROR_OUT_OF_MEMORY Out of memory
+ */
+int rpc_port_stub_hal_device_bezel_stub_1_device_bezel_context_get_instance(rpc_port_stub_hal_device_bezel_stub_1_device_bezel_context_h context, char **instance);
+
+/**
+ * @brief Disconnects from the proxy.
+ *
+ * @param[in] context The context handle
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #RPC_PORT_ERROR_NONE Successful
+ * @retval #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter
+ */
+int rpc_port_stub_hal_device_bezel_stub_1_device_bezel_context_disconnect(rpc_port_stub_hal_device_bezel_stub_1_device_bezel_context_h context);
+
+/**
+ * @brief The structure type containing the set of callback functions for handling stub events.
+ * @details It is one of the input parameters of the rpc_port_stub_hal_device_bezel_stub_1_device_bezel_register() function.
+ *
+ * @see rpc_port_stub_hal_device_bezel_stub_1_device_bezel_create_cb
+ * @see rpc_port_stub_hal_device_bezel_stub_1_device_bezel_terminate_cb
+ */
+typedef struct {
+ rpc_port_stub_hal_device_bezel_stub_1_device_bezel_create_cb create; /**< This callback function is invoked when the proxy is connected. */
+ rpc_port_stub_hal_device_bezel_stub_1_device_bezel_terminate_cb terminate; /**< This callback function is invoked when the proxy is disconnected. */
+
+ rpc_port_stub_hal_device_bezel_stub_1_device_bezel_get_state_cb get_state; /**< This callback function is invoked when the get_state request is delivered. */
+
+ rpc_port_stub_hal_device_bezel_stub_1_device_bezel_set_state_cb set_state; /**< This callback function is invoked when the set_state request is delivered. */
+
+ rpc_port_stub_hal_device_bezel_stub_1_device_bezel_get_sw_state_cb get_sw_state; /**< This callback function is invoked when the get_sw_state request is delivered. */
+
+ rpc_port_stub_hal_device_bezel_stub_1_device_bezel_set_sw_state_cb set_sw_state; /**< This callback function is invoked when the set_sw_state request is delivered. */
+
+ rpc_port_stub_hal_device_bezel_stub_1_device_bezel_get_vib_state_cb get_vib_state; /**< This callback function is invoked when the get_vib_state request is delivered. */
+
+ rpc_port_stub_hal_device_bezel_stub_1_device_bezel_set_vib_state_cb set_vib_state; /**< This callback function is invoked when the set_vib_state request is delivered. */
+} rpc_port_stub_hal_device_bezel_stub_1_device_bezel_callback_s;
+
+/**
+ * @brief Registers the set of the callback functions and the port.
+ * @details This function registers the set of the callback functions to handle stub events.
+ * And, the rpc_port_stub_listen() is called internally to handle events.
+ *
+ * @param[in] callback The set of callback functions to handle stub events
+ * @param[in] user_data The user data to be passed to the callback function
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #RPC_PORT_ERROR_NONE Successful
+ * @retval #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #RPC_PORT_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #RPC_PORT_ERROR_IO_ERROR I/O error
+ * @retval #RPC_PORT_ERROR_PERMISSION_DENIED Permission denied
+ * @see rpc_port_stub_hal_device_bezel_stub_1_device_bezel_unregister()
+ * @see #rpc_port_stub_hal_device_bezel_stub_1_device_bezel_callback_s
+ */
+int rpc_port_stub_hal_device_bezel_stub_1_device_bezel_register(rpc_port_stub_hal_device_bezel_stub_1_device_bezel_callback_s *callback, void *user_data);
+
+/**
+ * @brief Unregisters the registered port.
+ */
+int rpc_port_stub_hal_device_bezel_stub_1_device_bezel_unregister(void);
+
+/**
+ * @brief Retrieves the connected context handles.
+ *
+ * @param[in] callback The callback function
+ * @param[in] user_data The user data to be passed to the callback function
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #RPC_PORT_ERROR_NONE Successful
+ * @retval #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @see rpc_port_stub_hal_device_bezel_stub_1_device_bezel_context_cb()
+ */
+int rpc_port_stub_hal_device_bezel_stub_1_device_bezel_foreach_context(rpc_port_stub_hal_device_bezel_stub_1_device_bezel_context_cb callback, void *user_data);
+
+/**
+ * @brief Gets the number of connected clients.
+ *
+ * @param[out] client_number The client number
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #RPC_PORT_ERROR_NONE Successful
+ * @retval #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter
+ */
+int rpc_port_stub_hal_device_bezel_stub_1_device_bezel_get_client_number(unsigned int *client_number);
+
+#ifdef __cplusplus
+}
+#endif