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_battery_ipc_1.tidl
: Define types and interfaces. Based on the tidl file, proxy and
stub code are generated.
- src/generated/hal_device_battery_proxy_1.h
- src/generated/hal_device_battery_proxy_1.c
: By using this code, one can implement client to talk to server
that has been implemented by the stub code below.
- src/generated/hal_device_battery_stub_1.h
- src/generated/hal_device_battery_stub_1.c
: By using this code, server can be implemented. And it can
handle request from a clinet that has been implemented by the
above proxy code.
Change-Id: I256b4e04c047ea8dc15df244914d1fc89a35a4bc
Signed-off-by: Youngjae Cho <y0.cho@samsung.com>
--- /dev/null
+protocol 2
+
+struct enums {
+ enum power_source_type {
+ POWER_SOURCE_NONE = 0, /**< power source type None */
+ POWER_SOURCE_AC, /**< power source type Ac */
+ POWER_SOURCE_USB, /**< power source type Usb */
+ POWER_SOURCE_WIRELESS, /**< power source type Wireless */
+ }
+}
+
+struct battery_info {
+ string name; /**< The name of the battery */
+ string status; /**< The current state of the battery */
+ string health; /**< The overall condition of the battery */
+ enums.power_source_type power_source; /**< The source of power being supplied */
+
+ int online; /**< This indicates whether the device is currently
+ receiving power from an external source. */
+ int present; /**< This indicates whether there is a battery inside the system physically,
+ with 1 indicating it is connected and 0 otherwise. */
+ int capacity; /**< The remaining capacity of the battery */
+
+ int current_now; /**< The amount of current being consumed by the device at the moment */
+ int current_average; /**< The average amount of current consumed by the device over time */
+ int voltage_now; /**< The current voltage level of the battery */
+ int voltage_average; /**< The average voltage level of the battery over time */
+ int temperature; /**< The current temperature of the battery */
+}
+
+interface device_battery {
+ void updated_cb(battery_info info) delegate;
+ int register_changed_event(updated_cb cb);
+ void unregister_changed_event(updated_cb cb) async;
+ int get_current_state(out battery_info info);
+}
tidlc -s -l C -i ./include/hal_device_display_ipc_1.tidl -o ./src/generated/hal_device_display_stub_1 -n
tidlc -p -l C -i ./include/hal_device_led_ipc_1.tidl -o ./src/generated/hal_device_led_proxy_1 -n
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
%build
cp %{SOURCE1} .
--- /dev/null
+
+/*
+ * Generated by tidlc 2.6.0.
+ */
+
+#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_battery_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.0"
+#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;
+
+static rpc_port_delegate_h rpc_port_delegate_create();
+
+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_battery_proxy_1_enums_s {
+ rpc_port_parcelable_t parcelable;
+} rpc_port_proxy_hal_device_battery_proxy_1_enums_t;
+
+typedef struct rpc_port_proxy_hal_device_battery_proxy_1_battery_info_s {
+ rpc_port_parcelable_t parcelable;
+ char *name;
+ char *status;
+ char *health;
+ rpc_port_proxy_hal_device_battery_proxy_1_enums_power_source_type_e power_source;
+ int online;
+ int present;
+ int capacity;
+ int current_now;
+ int current_average;
+ int voltage_now;
+ int voltage_average;
+ int temperature;
+} rpc_port_proxy_hal_device_battery_proxy_1_battery_info_t;
+
+
+typedef struct rpc_port_proxy_hal_device_battery_proxy_1_remote_exception_s {
+ rpc_port_parcelable_t parcelable;
+ int cause;
+ char *message;
+} rpc_port_proxy_hal_device_battery_proxy_1_remote_exception_t;
+
+static rpc_port_proxy_hal_device_battery_proxy_1_remote_exception_h __rpc_port_proxy_hal_device_battery_proxy_1_remote_exception;
+
+int rpc_port_proxy_hal_device_battery_proxy_1_remote_exception_create(rpc_port_proxy_hal_device_battery_proxy_1_remote_exception_h *h);
+
+
+
+typedef struct rpc_port_proxy_hal_device_battery_proxy_1_device_battery_updated_cb_s {
+ rpc_port_parcelable_t parcelable;
+ int id;
+ int seq_id;
+ bool once;
+ rpc_port_proxy_hal_device_battery_proxy_1_device_battery_updated_cb_cb callback;
+ void *user_data;
+} rpc_port_proxy_hal_device_battery_proxy_1_device_battery_updated_cb_t;
+
+typedef struct rpc_port_proxy_hal_device_battery_proxy_1_device_battery_s {
+ char *stub_appid;
+ rpc_port_proxy_h proxy;
+ rpc_port_h port;
+ rpc_port_h callback_port;
+ rpc_port_proxy_hal_device_battery_proxy_1_device_battery_callback_s callback;
+ void *user_data;
+ GList *delegates;
+ GRecMutex mutex;
+ rpc_port_proxy_lem_h lem;
+} rpc_port_proxy_hal_device_battery_proxy_1_device_battery_t;
+
+rpc_port_proxy_hal_device_battery_proxy_1_device_battery_h __rpc_port_proxy_hal_device_battery_proxy_1_device_battery_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_read_device_battery_updated_cb(rpc_port_unit_map_h unit_map,
+ int name, rpc_port_proxy_hal_device_battery_proxy_1_device_battery_updated_cb_h *value)
+{
+ rpc_port_unit_h unit;
+ rpc_port_proxy_hal_device_battery_proxy_1_device_battery_updated_cb_t *handle;
+ int ret;
+
+ if (value == nullptr) {
+ _E("Invalid parameter");
+ return;
+ }
+
+ ret = rpc_port_proxy_hal_device_battery_proxy_1_device_battery_updated_cb_create((rpc_port_proxy_hal_device_battery_proxy_1_device_battery_updated_cb_h *)&handle);
+ if (ret != RPC_PORT_ERROR_NONE) {
+ *value = nullptr;
+ return;
+ }
+
+ *value = handle;
+ if (unit_map == nullptr) {
+ _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);
+ return;
+ }
+
+ if (unit->type != -432452514 /*device_battery_updated_cb*/) {
+ _E("type(%d) is not device_battery_updated_cb", unit->type);
+ return;
+ }
+
+ rpc_port_parcel_read(unit->parcel, &handle->parcelable, handle);
+}
+
+static void rpc_port_unit_map_write_device_battery_updated_cb_write_cb(rpc_port_parcel_h parcel, void* data)
+{
+ rpc_port_unit_h unit = data;
+ rpc_port_proxy_hal_device_battery_proxy_1_device_battery_updated_cb_h handle = unit->data;
+
+ rpc_port_parcel_write(parcel, &handle->parcelable, handle);
+}
+
+static int rpc_port_unit_map_write_device_battery_updated_cb(rpc_port_unit_map_h unit_map,
+ int name, rpc_port_proxy_hal_device_battery_proxy_1_device_battery_updated_cb_h value)
+{
+ rpc_port_unit_h unit;
+
+ if (unit_map == nullptr)
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
+
+ unit = rpc_port_unit_create(name, -432452514 /*device_battery_updated_cb*/);
+ if (unit == nullptr)
+ return RPC_PORT_ERROR_OUT_OF_MEMORY;
+
+ unit->data = value;
+ unit->write_cb = rpc_port_unit_map_write_device_battery_updated_cb_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_delegate(rpc_port_unit_map_h unit_map,
+ int name, rpc_port_delegate_h *value)
+{
+ rpc_port_unit_h unit;
+ rpc_port_delegate_h delegate;
+
+ if (value == nullptr) {
+ _E("Invalid parameter");
+ return;
+ }
+
+ delegate = rpc_port_delegate_create();
+ *value = delegate;
+
+ if (delegate == nullptr)
+ return;
+
+ if (unit_map == nullptr) {
+ _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);
+ return;
+ }
+
+ if (unit->type != 819322245 /*delegate*/) {
+ _E("type(%d) is not delegate", unit->type);
+ return;
+ }
+
+ rpc_port_parcel_read(unit->parcel, &delegate->parcelable, delegate);
+}
+
+static void rpc_port_unit_map_write_delegate_write_cb(rpc_port_parcel_h parcel, void* data)
+{
+ rpc_port_unit_h unit = data;
+ rpc_port_delegate_h handle = unit->data;
+
+ rpc_port_parcel_write(parcel, &handle->parcelable, handle);
+}
+
+static int rpc_port_unit_map_write_delegate(rpc_port_unit_map_h unit_map,
+ int name, rpc_port_delegate_h value)
+{
+ rpc_port_unit_h unit;
+
+ if (unit_map == nullptr || value == nullptr)
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
+
+ unit = rpc_port_unit_create(name, 819322245 /*delegate*/);
+ if (unit == nullptr)
+ return RPC_PORT_ERROR_OUT_OF_MEMORY;
+
+ unit->data = value;
+ unit->write_cb = rpc_port_unit_map_write_delegate_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_battery_info(rpc_port_unit_map_h unit_map,
+ int name, rpc_port_proxy_hal_device_battery_proxy_1_battery_info_h *value)
+{
+ rpc_port_unit_h unit;
+ rpc_port_proxy_hal_device_battery_proxy_1_battery_info_t *handle;
+ int ret;
+
+ if (value == nullptr) {
+ _E("Invalid parameter");
+ return;
+ }
+
+ ret = rpc_port_proxy_hal_device_battery_proxy_1_battery_info_create((rpc_port_proxy_hal_device_battery_proxy_1_battery_info_h *)&handle);
+ if (ret != RPC_PORT_ERROR_NONE) {
+ *value = nullptr;
+ return;
+ }
+
+ *value = handle;
+ if (unit_map == nullptr) {
+ _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);
+ return;
+ }
+
+ if (unit->type != -1690947680 /*battery_info*/) {
+ _E("type(%d) is not battery_info", unit->type);
+ return;
+ }
+
+ rpc_port_parcel_read(unit->parcel, &handle->parcelable, 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_proxy_hal_device_battery_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_battery_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_battery_proxy_1_remote_exception_h *value)
+{
+ rpc_port_unit_h unit;
+ rpc_port_proxy_hal_device_battery_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_battery_proxy_1_remote_exception_create((rpc_port_proxy_hal_device_battery_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_battery_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_battery_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_battery_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_delegate_to(rpc_port_parcel_h parcel, void *user_data)
+{
+ rpc_port_delegate_h delegate = user_data;
+
+ rpc_port_parcel_write_int32(parcel, delegate->id);
+ rpc_port_parcel_write_int32(parcel, delegate->seq_id);
+ rpc_port_parcel_write_bool(parcel, delegate->once);
+
+ set_last_result(RPC_PORT_ERROR_NONE);
+}
+
+static void __rpc_port_delegate_from(rpc_port_parcel_h parcel, void *user_data)
+{
+ rpc_port_delegate_h delegate = user_data;
+
+ rpc_port_parcel_read_int32(parcel, &delegate->id);
+ rpc_port_parcel_read_int32(parcel, &delegate->seq_id);
+ rpc_port_parcel_read_bool(parcel, &delegate->once);
+
+ set_last_result(RPC_PORT_ERROR_NONE);
+}
+
+static void rpc_port_delegate_destroy(rpc_port_delegate_h handle)
+{
+ if (handle == nullptr)
+ return;
+
+ free(handle);
+}
+
+static rpc_port_delegate_h rpc_port_delegate_create()
+{
+ rpc_port_delegate_h delegate;
+
+ delegate = calloc(1, sizeof(rpc_port_delegate_t));
+ if (delegate == nullptr) {
+ _E("malloc() is failed");
+ return nullptr;
+ }
+
+ delegate->parcelable.to = __rpc_port_delegate_to;
+ delegate->parcelable.from = __rpc_port_delegate_from;
+
+ return delegate;
+}
+
+
+
+static void __rpc_port_proxy_hal_device_battery_proxy_1_enums_to(rpc_port_parcel_h parcel, void *data)
+{
+ rpc_port_proxy_hal_device_battery_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_battery_proxy_1_enums_from(rpc_port_parcel_h parcel, void *data)
+{
+ rpc_port_proxy_hal_device_battery_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_battery_proxy_1_enums_create(rpc_port_proxy_hal_device_battery_proxy_1_enums_h *h)
+{
+ rpc_port_proxy_hal_device_battery_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_battery_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_battery_proxy_1_enums_to;
+ handle->parcelable.from = __rpc_port_proxy_hal_device_battery_proxy_1_enums_from;
+
+ *h = handle;
+
+ return RPC_PORT_ERROR_NONE;
+}
+
+int rpc_port_proxy_hal_device_battery_proxy_1_enums_destroy(rpc_port_proxy_hal_device_battery_proxy_1_enums_h h)
+{
+ rpc_port_proxy_hal_device_battery_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_battery_proxy_1_enums_clone(rpc_port_proxy_hal_device_battery_proxy_1_enums_h h, rpc_port_proxy_hal_device_battery_proxy_1_enums_h *clone)
+{
+ rpc_port_proxy_hal_device_battery_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_battery_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_battery_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_battery_proxy_1_enums_destroy(handle);
+ return ret;
+ }
+
+ *clone = handle;
+
+ return RPC_PORT_ERROR_NONE;
+}
+
+static void __rpc_port_proxy_hal_device_battery_proxy_1_battery_info_to(rpc_port_parcel_h parcel, void *data)
+{
+ rpc_port_proxy_hal_device_battery_proxy_1_battery_info_t *handle = data;
+
+ if (parcel == nullptr || handle == nullptr) {
+ _E("Invalid parameter");
+ set_last_result(RPC_PORT_ERROR_INVALID_PARAMETER);
+ return;
+ }
+
+ rpc_port_parcel_write_string(parcel, handle->name);
+ rpc_port_parcel_write_string(parcel, handle->status);
+ rpc_port_parcel_write_string(parcel, handle->health);
+ rpc_port_parcel_burst_write(parcel, (const unsigned char*)(&handle->power_source), sizeof(handle->power_source));
+ rpc_port_parcel_burst_write(parcel, (const unsigned char*)(&handle->online), sizeof(handle->online));
+ rpc_port_parcel_burst_write(parcel, (const unsigned char*)(&handle->present), sizeof(handle->present));
+ rpc_port_parcel_burst_write(parcel, (const unsigned char*)(&handle->capacity), sizeof(handle->capacity));
+ rpc_port_parcel_burst_write(parcel, (const unsigned char*)(&handle->current_now), sizeof(handle->current_now));
+ rpc_port_parcel_burst_write(parcel, (const unsigned char*)(&handle->current_average), sizeof(handle->current_average));
+ rpc_port_parcel_burst_write(parcel, (const unsigned char*)(&handle->voltage_now), sizeof(handle->voltage_now));
+ rpc_port_parcel_burst_write(parcel, (const unsigned char*)(&handle->voltage_average), sizeof(handle->voltage_average));
+ rpc_port_parcel_burst_write(parcel, (const unsigned char*)(&handle->temperature), sizeof(handle->temperature));
+
+ set_last_result(RPC_PORT_ERROR_NONE);
+}
+
+static void __rpc_port_proxy_hal_device_battery_proxy_1_battery_info_from(rpc_port_parcel_h parcel, void *data)
+{
+ rpc_port_proxy_hal_device_battery_proxy_1_battery_info_t *handle = data;
+
+ if (parcel == nullptr || handle == nullptr) {
+ _E("Invalid parameter");
+ set_last_result(RPC_PORT_ERROR_INVALID_PARAMETER);
+ return;
+ }
+
+ rpc_port_parcel_read_string(parcel, &handle->name);
+ rpc_port_parcel_read_string(parcel, &handle->status);
+ rpc_port_parcel_read_string(parcel, &handle->health);
+ rpc_port_parcel_burst_read(parcel, (unsigned char*)(&handle->power_source), sizeof(handle->power_source));
+ rpc_port_parcel_burst_read(parcel, (unsigned char*)(&handle->online), sizeof(handle->online));
+ rpc_port_parcel_burst_read(parcel, (unsigned char*)(&handle->present), sizeof(handle->present));
+ rpc_port_parcel_burst_read(parcel, (unsigned char*)(&handle->capacity), sizeof(handle->capacity));
+ rpc_port_parcel_burst_read(parcel, (unsigned char*)(&handle->current_now), sizeof(handle->current_now));
+ rpc_port_parcel_burst_read(parcel, (unsigned char*)(&handle->current_average), sizeof(handle->current_average));
+ rpc_port_parcel_burst_read(parcel, (unsigned char*)(&handle->voltage_now), sizeof(handle->voltage_now));
+ rpc_port_parcel_burst_read(parcel, (unsigned char*)(&handle->voltage_average), sizeof(handle->voltage_average));
+ rpc_port_parcel_burst_read(parcel, (unsigned char*)(&handle->temperature), sizeof(handle->temperature));
+
+ set_last_result(RPC_PORT_ERROR_NONE);
+}
+
+int rpc_port_proxy_hal_device_battery_proxy_1_battery_info_create(rpc_port_proxy_hal_device_battery_proxy_1_battery_info_h *h)
+{
+ rpc_port_proxy_hal_device_battery_proxy_1_battery_info_t *handle;
+
+ if (h == nullptr) {
+ _E("Invalid parameter");
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
+ }
+
+ handle = calloc(1, sizeof(rpc_port_proxy_hal_device_battery_proxy_1_battery_info_t));
+ if (handle == nullptr) {
+ _E("Out of memory");
+ return RPC_PORT_ERROR_OUT_OF_MEMORY;
+ }
+
+ handle->parcelable.to = __rpc_port_proxy_hal_device_battery_proxy_1_battery_info_to;
+ handle->parcelable.from = __rpc_port_proxy_hal_device_battery_proxy_1_battery_info_from;
+
+ *h = handle;
+
+ return RPC_PORT_ERROR_NONE;
+}
+
+int rpc_port_proxy_hal_device_battery_proxy_1_battery_info_destroy(rpc_port_proxy_hal_device_battery_proxy_1_battery_info_h h)
+{
+ rpc_port_proxy_hal_device_battery_proxy_1_battery_info_t *handle = h;
+
+ if (handle == nullptr) {
+ _E("Invalid parameter");
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
+ }
+
+ if (handle->name)
+ free(handle->name);
+ if (handle->status)
+ free(handle->status);
+ if (handle->health)
+ free(handle->health);
+
+ free(handle);
+
+ return RPC_PORT_ERROR_NONE;
+}
+
+int rpc_port_proxy_hal_device_battery_proxy_1_battery_info_clone(rpc_port_proxy_hal_device_battery_proxy_1_battery_info_h h, rpc_port_proxy_hal_device_battery_proxy_1_battery_info_h *clone)
+{
+ rpc_port_proxy_hal_device_battery_proxy_1_battery_info_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_battery_proxy_1_battery_info_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_battery_proxy_1_battery_info_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_battery_proxy_1_battery_info_destroy(handle);
+ return ret;
+ }
+
+ *clone = handle;
+
+ return RPC_PORT_ERROR_NONE;
+}
+int rpc_port_proxy_hal_device_battery_proxy_1_battery_info_set_name(rpc_port_proxy_hal_device_battery_proxy_1_battery_info_h handle, const char *value)
+{
+ char *new_value;
+
+ if (handle == nullptr || value == nullptr) {
+ _E("Invalid parameter");
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
+ }
+
+ new_value = strdup(value);
+ if (new_value == nullptr) {
+ _E("Failed to duplicate value");
+ return RPC_PORT_ERROR_OUT_OF_MEMORY;
+ }
+
+ if (handle->name)
+ free(handle->name);
+
+ handle->name = new_value;
+
+ return RPC_PORT_ERROR_NONE;
+}
+
+int rpc_port_proxy_hal_device_battery_proxy_1_battery_info_get_name(rpc_port_proxy_hal_device_battery_proxy_1_battery_info_h handle, char **value)
+{
+ char *new_value;
+ if (handle == nullptr || value == nullptr) {
+ _E("Invalid parameter");
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
+ }
+
+ if (handle->name == nullptr) {
+ _E("name is nullptr");
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
+ }
+
+ new_value = strdup(handle->name);
+ if (new_value == nullptr) {
+ _E("Failed to duplicate value");
+ return RPC_PORT_ERROR_OUT_OF_MEMORY;
+ }
+
+ *value = new_value;
+
+ return RPC_PORT_ERROR_NONE;
+}
+
+int rpc_port_proxy_hal_device_battery_proxy_1_battery_info_set_status(rpc_port_proxy_hal_device_battery_proxy_1_battery_info_h handle, const char *value)
+{
+ char *new_value;
+
+ if (handle == nullptr || value == nullptr) {
+ _E("Invalid parameter");
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
+ }
+
+ new_value = strdup(value);
+ if (new_value == nullptr) {
+ _E("Failed to duplicate value");
+ return RPC_PORT_ERROR_OUT_OF_MEMORY;
+ }
+
+ if (handle->status)
+ free(handle->status);
+
+ handle->status = new_value;
+
+ return RPC_PORT_ERROR_NONE;
+}
+
+int rpc_port_proxy_hal_device_battery_proxy_1_battery_info_get_status(rpc_port_proxy_hal_device_battery_proxy_1_battery_info_h handle, char **value)
+{
+ char *new_value;
+ if (handle == nullptr || value == nullptr) {
+ _E("Invalid parameter");
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
+ }
+
+ if (handle->status == nullptr) {
+ _E("status is nullptr");
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
+ }
+
+ new_value = strdup(handle->status);
+ if (new_value == nullptr) {
+ _E("Failed to duplicate value");
+ return RPC_PORT_ERROR_OUT_OF_MEMORY;
+ }
+
+ *value = new_value;
+
+ return RPC_PORT_ERROR_NONE;
+}
+
+int rpc_port_proxy_hal_device_battery_proxy_1_battery_info_set_health(rpc_port_proxy_hal_device_battery_proxy_1_battery_info_h handle, const char *value)
+{
+ char *new_value;
+
+ if (handle == nullptr || value == nullptr) {
+ _E("Invalid parameter");
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
+ }
+
+ new_value = strdup(value);
+ if (new_value == nullptr) {
+ _E("Failed to duplicate value");
+ return RPC_PORT_ERROR_OUT_OF_MEMORY;
+ }
+
+ if (handle->health)
+ free(handle->health);
+
+ handle->health = new_value;
+
+ return RPC_PORT_ERROR_NONE;
+}
+
+int rpc_port_proxy_hal_device_battery_proxy_1_battery_info_get_health(rpc_port_proxy_hal_device_battery_proxy_1_battery_info_h handle, char **value)
+{
+ char *new_value;
+ if (handle == nullptr || value == nullptr) {
+ _E("Invalid parameter");
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
+ }
+
+ if (handle->health == nullptr) {
+ _E("health is nullptr");
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
+ }
+
+ new_value = strdup(handle->health);
+ if (new_value == nullptr) {
+ _E("Failed to duplicate value");
+ return RPC_PORT_ERROR_OUT_OF_MEMORY;
+ }
+
+ *value = new_value;
+
+ return RPC_PORT_ERROR_NONE;
+}
+
+int rpc_port_proxy_hal_device_battery_proxy_1_battery_info_set_power_source(rpc_port_proxy_hal_device_battery_proxy_1_battery_info_h handle, rpc_port_proxy_hal_device_battery_proxy_1_enums_power_source_type_e value)
+{
+ if (handle == nullptr) {
+ _E("Invalid parameter");
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
+ }
+
+ handle->power_source = value;
+
+ return RPC_PORT_ERROR_NONE;
+}
+
+int rpc_port_proxy_hal_device_battery_proxy_1_battery_info_get_power_source(rpc_port_proxy_hal_device_battery_proxy_1_battery_info_h handle, rpc_port_proxy_hal_device_battery_proxy_1_enums_power_source_type_e *value)
+{
+ if (handle == nullptr || value == nullptr) {
+ _E("Invalid parameter");
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
+ }
+
+ *value = handle->power_source;
+
+ return RPC_PORT_ERROR_NONE;
+}
+
+int rpc_port_proxy_hal_device_battery_proxy_1_battery_info_set_online(rpc_port_proxy_hal_device_battery_proxy_1_battery_info_h handle, int value)
+{
+ if (handle == nullptr) {
+ _E("Invalid parameter");
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
+ }
+
+ handle->online = value;
+
+ return RPC_PORT_ERROR_NONE;
+}
+
+int rpc_port_proxy_hal_device_battery_proxy_1_battery_info_get_online(rpc_port_proxy_hal_device_battery_proxy_1_battery_info_h handle, int *value)
+{
+ if (handle == nullptr || value == nullptr) {
+ _E("Invalid parameter");
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
+ }
+
+ *value = handle->online;
+
+ return RPC_PORT_ERROR_NONE;
+}
+
+int rpc_port_proxy_hal_device_battery_proxy_1_battery_info_set_present(rpc_port_proxy_hal_device_battery_proxy_1_battery_info_h handle, int value)
+{
+ if (handle == nullptr) {
+ _E("Invalid parameter");
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
+ }
+
+ handle->present = value;
+
+ return RPC_PORT_ERROR_NONE;
+}
+
+int rpc_port_proxy_hal_device_battery_proxy_1_battery_info_get_present(rpc_port_proxy_hal_device_battery_proxy_1_battery_info_h handle, int *value)
+{
+ if (handle == nullptr || value == nullptr) {
+ _E("Invalid parameter");
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
+ }
+
+ *value = handle->present;
+
+ return RPC_PORT_ERROR_NONE;
+}
+
+int rpc_port_proxy_hal_device_battery_proxy_1_battery_info_set_capacity(rpc_port_proxy_hal_device_battery_proxy_1_battery_info_h handle, int value)
+{
+ if (handle == nullptr) {
+ _E("Invalid parameter");
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
+ }
+
+ handle->capacity = value;
+
+ return RPC_PORT_ERROR_NONE;
+}
+
+int rpc_port_proxy_hal_device_battery_proxy_1_battery_info_get_capacity(rpc_port_proxy_hal_device_battery_proxy_1_battery_info_h handle, int *value)
+{
+ if (handle == nullptr || value == nullptr) {
+ _E("Invalid parameter");
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
+ }
+
+ *value = handle->capacity;
+
+ return RPC_PORT_ERROR_NONE;
+}
+
+int rpc_port_proxy_hal_device_battery_proxy_1_battery_info_set_current_now(rpc_port_proxy_hal_device_battery_proxy_1_battery_info_h handle, int value)
+{
+ if (handle == nullptr) {
+ _E("Invalid parameter");
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
+ }
+
+ handle->current_now = value;
+
+ return RPC_PORT_ERROR_NONE;
+}
+
+int rpc_port_proxy_hal_device_battery_proxy_1_battery_info_get_current_now(rpc_port_proxy_hal_device_battery_proxy_1_battery_info_h handle, int *value)
+{
+ if (handle == nullptr || value == nullptr) {
+ _E("Invalid parameter");
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
+ }
+
+ *value = handle->current_now;
+
+ return RPC_PORT_ERROR_NONE;
+}
+
+int rpc_port_proxy_hal_device_battery_proxy_1_battery_info_set_current_average(rpc_port_proxy_hal_device_battery_proxy_1_battery_info_h handle, int value)
+{
+ if (handle == nullptr) {
+ _E("Invalid parameter");
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
+ }
+
+ handle->current_average = value;
+
+ return RPC_PORT_ERROR_NONE;
+}
+
+int rpc_port_proxy_hal_device_battery_proxy_1_battery_info_get_current_average(rpc_port_proxy_hal_device_battery_proxy_1_battery_info_h handle, int *value)
+{
+ if (handle == nullptr || value == nullptr) {
+ _E("Invalid parameter");
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
+ }
+
+ *value = handle->current_average;
+
+ return RPC_PORT_ERROR_NONE;
+}
+
+int rpc_port_proxy_hal_device_battery_proxy_1_battery_info_set_voltage_now(rpc_port_proxy_hal_device_battery_proxy_1_battery_info_h handle, int value)
+{
+ if (handle == nullptr) {
+ _E("Invalid parameter");
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
+ }
+
+ handle->voltage_now = value;
+
+ return RPC_PORT_ERROR_NONE;
+}
+
+int rpc_port_proxy_hal_device_battery_proxy_1_battery_info_get_voltage_now(rpc_port_proxy_hal_device_battery_proxy_1_battery_info_h handle, int *value)
+{
+ if (handle == nullptr || value == nullptr) {
+ _E("Invalid parameter");
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
+ }
+
+ *value = handle->voltage_now;
+
+ return RPC_PORT_ERROR_NONE;
+}
+
+int rpc_port_proxy_hal_device_battery_proxy_1_battery_info_set_voltage_average(rpc_port_proxy_hal_device_battery_proxy_1_battery_info_h handle, int value)
+{
+ if (handle == nullptr) {
+ _E("Invalid parameter");
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
+ }
+
+ handle->voltage_average = value;
+
+ return RPC_PORT_ERROR_NONE;
+}
+
+int rpc_port_proxy_hal_device_battery_proxy_1_battery_info_get_voltage_average(rpc_port_proxy_hal_device_battery_proxy_1_battery_info_h handle, int *value)
+{
+ if (handle == nullptr || value == nullptr) {
+ _E("Invalid parameter");
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
+ }
+
+ *value = handle->voltage_average;
+
+ return RPC_PORT_ERROR_NONE;
+}
+
+int rpc_port_proxy_hal_device_battery_proxy_1_battery_info_set_temperature(rpc_port_proxy_hal_device_battery_proxy_1_battery_info_h handle, int value)
+{
+ if (handle == nullptr) {
+ _E("Invalid parameter");
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
+ }
+
+ handle->temperature = value;
+
+ return RPC_PORT_ERROR_NONE;
+}
+
+int rpc_port_proxy_hal_device_battery_proxy_1_battery_info_get_temperature(rpc_port_proxy_hal_device_battery_proxy_1_battery_info_h handle, int *value)
+{
+ if (handle == nullptr || value == nullptr) {
+ _E("Invalid parameter");
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
+ }
+
+ *value = handle->temperature;
+
+ return RPC_PORT_ERROR_NONE;
+}
+
+
+static void __rpc_port_proxy_hal_device_battery_proxy_1_remote_exception_to(rpc_port_parcel_h parcel, void *user_data)
+{
+ rpc_port_proxy_hal_device_battery_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_battery_proxy_1_remote_exception_from(rpc_port_parcel_h parcel, void *user_data)
+{
+ rpc_port_proxy_hal_device_battery_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_battery_proxy_1_remote_exception_create(rpc_port_proxy_hal_device_battery_proxy_1_remote_exception_h *h)
+{
+ rpc_port_proxy_hal_device_battery_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_battery_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_battery_proxy_1_remote_exception_to;
+ exception->parcelable.from = __rpc_port_proxy_hal_device_battery_proxy_1_remote_exception_from;
+
+ *h = exception;
+
+ return RPC_PORT_ERROR_NONE;
+}
+
+int rpc_port_proxy_hal_device_battery_proxy_1_remote_exception_set_cause(rpc_port_proxy_hal_device_battery_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_battery_proxy_1_remote_exception_set_message(rpc_port_proxy_hal_device_battery_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_battery_proxy_1_remote_exception_get_cause(rpc_port_proxy_hal_device_battery_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_battery_proxy_1_remote_exception_get_message(rpc_port_proxy_hal_device_battery_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_battery_proxy_1_remote_exception_destroy(rpc_port_proxy_hal_device_battery_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_battery_proxy_1_get_remote_exception(rpc_port_proxy_hal_device_battery_proxy_1_remote_exception_h *h)
+{
+ rpc_port_proxy_hal_device_battery_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_battery_proxy_1_remote_exception == nullptr) {
+ _W("There is no exceptions");
+ *h = nullptr;
+ return RPC_PORT_ERROR_NONE;
+ }
+
+ ret = rpc_port_proxy_hal_device_battery_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_battery_proxy_1_remote_exception->cause;
+ handle->message = __rpc_port_proxy_hal_device_battery_proxy_1_remote_exception->message ?
+ strdup(__rpc_port_proxy_hal_device_battery_proxy_1_remote_exception->message) : nullptr;
+ *h = handle;
+
+ return RPC_PORT_ERROR_NONE;
+}
+
+
+
+typedef enum {
+ RPC_PORT_PROXY_HAL_DEVICE_BATTERY_PROXY_1_DEVICE_BATTERY_DELEGATE_UPDATED_CB = 1,
+} rpc_port_proxy_hal_device_battery_proxy_1_device_battery_delegate_e;
+
+static void __rpc_port_proxy_hal_device_battery_proxy_1_device_battery_updated_cb_to(rpc_port_parcel_h parcel, void *data)
+{
+ rpc_port_proxy_hal_device_battery_proxy_1_device_battery_updated_cb_h h = data;
+
+ if (parcel == nullptr || h == nullptr) {
+ _E("Invalid parameter");
+ set_last_result(RPC_PORT_ERROR_INVALID_PARAMETER);
+ return;
+ }
+
+ rpc_port_parcel_write_int32(parcel, h->id);
+ rpc_port_parcel_write_int32(parcel, h->seq_id);
+ rpc_port_parcel_write_bool(parcel, h->once);
+
+ _I("id(%d), seq_id(%d), once(%s)", h->id, h->seq_id, h->once ? "true" : "false");
+ set_last_result(RPC_PORT_ERROR_NONE);
+}
+
+static void __rpc_port_proxy_hal_device_battery_proxy_1_device_battery_updated_cb_from(rpc_port_parcel_h parcel, void *data)
+{
+ rpc_port_proxy_hal_device_battery_proxy_1_device_battery_updated_cb_h h = data;
+
+ if (parcel == nullptr || h == nullptr) {
+ _E("Invalid parameter");
+ set_last_result(RPC_PORT_ERROR_INVALID_PARAMETER);
+ return;
+ }
+
+ rpc_port_parcel_read_int32(parcel, &h->id);
+ rpc_port_parcel_read_int32(parcel, &h->seq_id);
+ rpc_port_parcel_read_bool(parcel, &h->once);
+
+ _I("id(%d), seq_id(%d), once(%s)", h->id, h->seq_id, h->once ? "true" : "false");
+ set_last_result(RPC_PORT_ERROR_NONE);
+}
+
+int rpc_port_proxy_hal_device_battery_proxy_1_device_battery_updated_cb_create(rpc_port_proxy_hal_device_battery_proxy_1_device_battery_updated_cb_h *h)
+{
+ rpc_port_proxy_hal_device_battery_proxy_1_device_battery_updated_cb_t *handle;
+ static int seq_num;
+
+ if (h == nullptr) {
+ _E("Invalid parameter");
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
+ }
+
+ handle = calloc(1, sizeof(rpc_port_proxy_hal_device_battery_proxy_1_device_battery_updated_cb_t));
+ if (handle == nullptr) {
+ _E("Out of memory");
+ return RPC_PORT_ERROR_OUT_OF_MEMORY;
+ }
+
+ handle->parcelable.to = __rpc_port_proxy_hal_device_battery_proxy_1_device_battery_updated_cb_to;
+ handle->parcelable.from = __rpc_port_proxy_hal_device_battery_proxy_1_device_battery_updated_cb_from;
+ handle->id = RPC_PORT_PROXY_HAL_DEVICE_BATTERY_PROXY_1_DEVICE_BATTERY_DELEGATE_UPDATED_CB;
+ handle->seq_id = g_atomic_int_add(&seq_num, 1) + 1;
+ _I("id(%d), seq_id(%d)", handle->id, handle->seq_id);
+
+ *h = handle;
+
+ return RPC_PORT_ERROR_NONE;
+}
+
+int rpc_port_proxy_hal_device_battery_proxy_1_device_battery_updated_cb_destroy(rpc_port_proxy_hal_device_battery_proxy_1_device_battery_updated_cb_h h)
+{
+ if (h == nullptr) {
+ _E("Invalid parameter");
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
+ }
+
+ _W("id(%d), seq_id(%d), once(%s)", h->id, h->seq_id, h->once ? "true" : "false");
+
+ free(h);
+
+ return RPC_PORT_ERROR_NONE;
+}
+
+int rpc_port_proxy_hal_device_battery_proxy_1_device_battery_updated_cb_clone(rpc_port_proxy_hal_device_battery_proxy_1_device_battery_updated_cb_h h, rpc_port_proxy_hal_device_battery_proxy_1_device_battery_updated_cb_h *clone)
+{
+ rpc_port_proxy_hal_device_battery_proxy_1_device_battery_updated_cb_h handle;
+ int ret;
+
+ if (h == nullptr || clone == nullptr) {
+ _E("Invalid parameter");
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
+ }
+
+ ret = rpc_port_proxy_hal_device_battery_proxy_1_device_battery_updated_cb_create(&handle);
+ if (ret != RPC_PORT_ERROR_NONE) {
+ _E("Failed to create handle. error(%d)", ret);
+ return ret;
+ }
+
+ handle->id = h->id;
+ handle->seq_id = h->seq_id;
+ handle->once = h->once;
+ handle->callback = h->callback;
+ handle->user_data = h->user_data;
+
+ *clone = handle;
+ return RPC_PORT_ERROR_NONE;
+}
+
+int rpc_port_proxy_hal_device_battery_proxy_1_device_battery_updated_cb_set_callback(rpc_port_proxy_hal_device_battery_proxy_1_device_battery_updated_cb_h h, rpc_port_proxy_hal_device_battery_proxy_1_device_battery_updated_cb_cb callback, void *user_data)
+{
+ if (h == nullptr || callback == nullptr) {
+ _E("Invalid parameter");
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
+ }
+
+ h->callback = callback;
+ h->user_data = user_data;
+
+ return RPC_PORT_ERROR_NONE;
+}
+
+int rpc_port_proxy_hal_device_battery_proxy_1_device_battery_updated_cb_set_once(rpc_port_proxy_hal_device_battery_proxy_1_device_battery_updated_cb_h h, bool once)
+{
+ if (h == nullptr) {
+ _E("Invalid parameter");
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
+ }
+
+ h->once = once;
+
+ return RPC_PORT_ERROR_NONE;
+}
+
+int rpc_port_proxy_hal_device_battery_proxy_1_device_battery_updated_cb_get_id(rpc_port_proxy_hal_device_battery_proxy_1_device_battery_updated_cb_h h, int *id)
+{
+ if (h == nullptr || id == nullptr) {
+ _E("Invalid parameter");
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
+ }
+
+ *id = h->id;
+
+ return RPC_PORT_ERROR_NONE;
+}
+
+int rpc_port_proxy_hal_device_battery_proxy_1_device_battery_updated_cb_get_seq_id(rpc_port_proxy_hal_device_battery_proxy_1_device_battery_updated_cb_h h, int *seq_id)
+{
+ if (h == nullptr || seq_id == nullptr) {
+ _E("Invalid parameter");
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
+ }
+
+ *seq_id = h->seq_id;
+
+ return RPC_PORT_ERROR_NONE;
+}
+
+int rpc_port_proxy_hal_device_battery_proxy_1_device_battery_updated_cb_is_once(rpc_port_proxy_hal_device_battery_proxy_1_device_battery_updated_cb_h h, bool *once)
+{
+ if (h == nullptr || once == nullptr) {
+ _E("Invalid parameter");
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
+ }
+
+ *once = h->once;
+
+ return RPC_PORT_ERROR_NONE;
+}
+
+int rpc_port_proxy_hal_device_battery_proxy_1_device_battery_updated_cb_get_tag(rpc_port_proxy_hal_device_battery_proxy_1_device_battery_updated_cb_h h, char **tag)
+{
+ char *new_tag;
+ char buf[128];
+
+ if (h == nullptr || tag == nullptr) {
+ _E("Invalid parameter");
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
+ }
+
+ snprintf(buf, sizeof(buf), "%d::%d", h->id, h->seq_id);
+ new_tag = strdup(buf);
+ if (new_tag == nullptr) {
+ _E("Out of memory");
+ return RPC_PORT_ERROR_OUT_OF_MEMORY;
+ }
+
+ *tag = new_tag;
+
+ return RPC_PORT_ERROR_NONE;
+}
+
+int rpc_port_proxy_hal_device_battery_proxy_1_device_battery_updated_cb_dispose(rpc_port_proxy_hal_device_battery_proxy_1_device_battery_h proxy, rpc_port_proxy_hal_device_battery_proxy_1_device_battery_updated_cb_h h)
+{
+ GList *found;
+
+ if (proxy == nullptr || h == nullptr) {
+ _E("Invalid parameter");
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
+ }
+
+ g_rec_mutex_lock(&proxy->mutex);
+ found = g_list_find(proxy->delegates, h);
+ if (found == nullptr) {
+ _E("Invalid parameter");
+ g_rec_mutex_unlock(&proxy->mutex);
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
+ }
+
+ proxy->delegates = g_list_remove_link(proxy->delegates, found);
+ rpc_port_proxy_hal_device_battery_proxy_1_device_battery_updated_cb_destroy(h);
+ g_list_free(found);
+ g_rec_mutex_unlock(&proxy->mutex);
+
+ return RPC_PORT_ERROR_NONE;
+}
+
+static void __rpc_port_proxy_hal_device_battery_proxy_1_device_battery_updated_cb_delegate_handler(GList **delegates, rpc_port_unit_map_h map, rpc_port_delegate_h delegate)
+{
+ rpc_port_proxy_hal_device_battery_proxy_1_device_battery_updated_cb_h handle;
+ GList *iter;
+ bool once;
+
+ rpc_port_proxy_hal_device_battery_proxy_1_battery_info_h info = nullptr;
+
+ rpc_port_unit_map_read_battery_info(map, 3237038 /*info*/, &info);
+
+ iter = *delegates;
+ while (iter) {
+ handle = iter->data;
+ iter = g_list_next(iter);
+ if (handle->id == delegate->id && handle->seq_id == delegate->seq_id) {
+ once = handle->once;
+ _W("Invoke id(%d), seq_id(%d)", handle->id, handle->seq_id);
+ if (handle->callback)
+ handle->callback(handle->user_data, info);
+ else
+ _W("The callback function is nullptr");
+
+ if (once) {
+ *delegates = g_list_remove(*delegates, handle);
+ rpc_port_proxy_hal_device_battery_proxy_1_device_battery_updated_cb_destroy(handle);
+ }
+
+ break;
+ }
+ }
+
+ if (info)
+ rpc_port_proxy_hal_device_battery_proxy_1_battery_info_destroy(info);
+
+ return;
+}
+
+
+
+static rpc_port_proxy_delegate_cb __rpc_port_proxy_hal_device_battery_proxy_1_device_battery_delegate_table[] = {
+ [RPC_PORT_PROXY_HAL_DEVICE_BATTERY_PROXY_1_DEVICE_BATTERY_DELEGATE_UPDATED_CB] = __rpc_port_proxy_hal_device_battery_proxy_1_device_battery_updated_cb_delegate_handler,
+};
+
+
+typedef enum {
+ RPC_PORT_PROXY_HAL_DEVICE_BATTERY_PROXY_1_DEVICE_BATTERY_METHOD_RESULT_,
+ RPC_PORT_PROXY_HAL_DEVICE_BATTERY_PROXY_1_DEVICE_BATTERY_METHOD_CALLBACK_,
+ RPC_PORT_PROXY_HAL_DEVICE_BATTERY_PROXY_1_DEVICE_BATTERY_METHOD_REGISTER_CHANGED_EVENT,
+ RPC_PORT_PROXY_HAL_DEVICE_BATTERY_PROXY_1_DEVICE_BATTERY_METHOD_UNREGISTER_CHANGED_EVENT,
+ RPC_PORT_PROXY_HAL_DEVICE_BATTERY_PROXY_1_DEVICE_BATTERY_METHOD_GET_CURRENT_STATE,
+} rpc_port_proxy_hal_device_battery_proxy_1_device_battery_method_e;
+
+
+static void __rpc_port_proxy_hal_device_battery_proxy_1_device_battery_process_received_event(GList **delegates, rpc_port_unit_map_h map)
+{
+ rpc_port_delegate_h delegate;
+
+ rpc_port_unit_map_read_delegate(map, 819322245 /*delegate*/, &delegate);
+
+ _W("id(%d), seq_id(%d)", delegate->id, delegate->seq_id);
+
+ if (delegate->id > 0 && delegate->id < ARRAY_SIZE(__rpc_port_proxy_hal_device_battery_proxy_1_device_battery_delegate_table)) {
+ if (__rpc_port_proxy_hal_device_battery_proxy_1_device_battery_delegate_table[delegate->id])
+ __rpc_port_proxy_hal_device_battery_proxy_1_device_battery_delegate_table[delegate->id](delegates, map, delegate);
+ } else {
+ _W("Unknown ID(%d)", delegate->id);
+ }
+
+ rpc_port_delegate_destroy(delegate);
+}
+
+static void __rpc_port_proxy_hal_device_battery_proxy_1_device_battery_lem_received(void *context, rpc_port_parcel_h parcel)
+{
+ rpc_port_proxy_hal_device_battery_proxy_1_device_battery_t *h = context;
+ rpc_port_unit_map_h map;
+ int cmd = -1;
+
+ map = rpc_port_unit_map_create();
+ if (map == nullptr) {
+ _E("Failed to create unit map");
+ return;
+ }
+
+ rpc_port_parcel_read(parcel, &map->parcelable, map);
+
+ rpc_port_unit_map_read_int(map, 1355467489 /*[METHOD]*/, &cmd);
+ if (cmd != RPC_PORT_PROXY_HAL_DEVICE_BATTERY_PROXY_1_DEVICE_BATTERY_METHOD_CALLBACK_) {
+ _E("Invalid protocol");
+ rpc_port_unit_map_destroy(map);
+ return;
+ }
+
+ __rpc_port_proxy_hal_device_battery_proxy_1_device_battery_process_received_event(&h->delegates, map);
+ rpc_port_unit_map_destroy(map);
+}
+
+static void __rpc_port_proxy_hal_device_battery_proxy_1_device_battery_received(const char *endpoint, const char *port_name, void *data)
+{
+ rpc_port_proxy_hal_device_battery_proxy_1_device_battery_h h = data;
+ rpc_port_parcel_h parcel;
+ rpc_port_unit_map_h map;
+ int cmd = -1;
+ int ret;
+
+ _W("endpoint(%s), port_name(%s)", endpoint, port_name);
+ ret = rpc_port_parcel_create_from_port(&parcel, h->callback_port);
+ if (ret != RPC_PORT_ERROR_NONE) {
+ _E("Failed to create parcel handle from port. error(%d)", ret);
+ return;
+ }
+
+ map = rpc_port_unit_map_create();
+ if (map == nullptr) {
+ _E("Failed to create unit map");
+ rpc_port_parcel_destroy(parcel);
+ return;
+ }
+
+ 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_BATTERY_PROXY_1_DEVICE_BATTERY_METHOD_CALLBACK_) {
+ _E("Invalid protocol");
+ rpc_port_unit_map_destroy(map);
+ return;
+ }
+
+ g_rec_mutex_lock(&h->mutex);
+ __rpc_port_proxy_hal_device_battery_proxy_1_device_battery_process_received_event(&h->delegates, map);
+ g_rec_mutex_unlock(&h->mutex);
+ rpc_port_unit_map_destroy(map);
+}
+
+
+static void __rpc_port_proxy_hal_device_battery_proxy_1_device_battery_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_BATTERY_PROXY_1_DEVICE_BATTERY_METHOD_RESULT_) {
+ if (__rpc_port_proxy_hal_device_battery_proxy_1_remote_exception != nullptr)
+ rpc_port_proxy_hal_device_battery_proxy_1_remote_exception_destroy(__rpc_port_proxy_hal_device_battery_proxy_1_remote_exception);
+
+ __rpc_port_proxy_hal_device_battery_proxy_1_remote_exception = nullptr;
+ rpc_port_unit_map_read_remote_exception(map, -1571313492 /*[REMOTE_EXCEPTION]*/, &__rpc_port_proxy_hal_device_battery_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_battery_proxy_1_device_battery_connected(const char *endpoint, const char *port_name, rpc_port_h port, void *data)
+{
+ rpc_port_proxy_hal_device_battery_proxy_1_device_battery_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_battery_proxy_1_device_battery_disconnected(const char *endpoint, const char *port_name, void *data)
+{
+ rpc_port_proxy_hal_device_battery_proxy_1_device_battery_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_battery_proxy_1_device_battery_rejected(const char *endpoint, const char *port_name, void *data)
+{
+ rpc_port_proxy_hal_device_battery_proxy_1_device_battery_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_battery_proxy_1_device_battery_lem_connected(void *context)
+{
+ rpc_port_proxy_hal_device_battery_proxy_1_device_battery_t *handle = context;
+
+ handle->callback.connected(handle, handle->user_data);
+}
+
+static void __rpc_port_proxy_hal_device_battery_proxy_1_device_battery_lem_disconnected(void *context)
+{
+ rpc_port_proxy_hal_device_battery_proxy_1_device_battery_t *handle = context;
+
+ handle->callback.disconnected(handle, handle->user_data);
+}
+
+int rpc_port_proxy_hal_device_battery_proxy_1_device_battery_create(const char *stub_appid, rpc_port_proxy_hal_device_battery_proxy_1_device_battery_callback_s *callback, void *user_data, rpc_port_proxy_hal_device_battery_proxy_1_device_battery_h *h)
+{
+ rpc_port_proxy_hal_device_battery_proxy_1_device_battery_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_battery_proxy_1_device_battery_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_battery_proxy_1_device_battery_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_battery_proxy_1_device_battery_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_battery_proxy_1_device_battery_connected, handle);
+ if (ret != RPC_PORT_ERROR_NONE) {
+ _E("Failed to add connected event cb. error(%d)", ret);
+ rpc_port_proxy_hal_device_battery_proxy_1_device_battery_destroy(handle);
+ return ret;
+ }
+
+ ret = rpc_port_proxy_add_disconnected_event_cb(handle->proxy, __rpc_port_proxy_hal_device_battery_proxy_1_device_battery_disconnected, handle);
+ if (ret != RPC_PORT_ERROR_NONE) {
+ _E("Failed to add disconnected event cb. error(%d)", ret);
+ rpc_port_proxy_hal_device_battery_proxy_1_device_battery_destroy(handle);
+ return ret;
+ }
+
+ ret = rpc_port_proxy_add_rejected_event_cb(handle->proxy, __rpc_port_proxy_hal_device_battery_proxy_1_device_battery_rejected, handle);
+ if (ret != RPC_PORT_ERROR_NONE) {
+ _E("Failed to add rejected event cb. error(%d)", ret);
+ rpc_port_proxy_hal_device_battery_proxy_1_device_battery_destroy(handle);
+ return ret;
+ }
+
+ ret = rpc_port_proxy_add_received_event_cb(handle->proxy, __rpc_port_proxy_hal_device_battery_proxy_1_device_battery_received, handle);
+ if (ret != RPC_PORT_ERROR_NONE) {
+ _E("Failed to add received event cb. error(%d)", ret);
+ rpc_port_proxy_hal_device_battery_proxy_1_device_battery_destroy(handle);
+ return ret;
+ }
+
+ lem_callback.received = __rpc_port_proxy_hal_device_battery_proxy_1_device_battery_lem_received;
+
+ lem_callback.connected = __rpc_port_proxy_hal_device_battery_proxy_1_device_battery_lem_connected;
+ lem_callback.disconnected = __rpc_port_proxy_hal_device_battery_proxy_1_device_battery_lem_disconnected;
+
+ if (appid != nullptr && !strcmp(appid, stub_appid)) {
+ handle->lem = rpc_port_proxy_lem_create(handle, "device_battery", &lem_callback);
+ if (handle->lem == nullptr) {
+ _E("Failed to create lem");
+ rpc_port_proxy_hal_device_battery_proxy_1_device_battery_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_battery_proxy_1_device_battery_destroy(rpc_port_proxy_hal_device_battery_proxy_1_device_battery_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_battery_proxy_1_device_battery_connect(rpc_port_proxy_hal_device_battery_proxy_1_device_battery_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_battery");
+
+ 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_battery_proxy_1_device_battery_connect_sync(rpc_port_proxy_hal_device_battery_proxy_1_device_battery_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_battery");
+
+ 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_battery_proxy_1_device_battery_disconnect(rpc_port_proxy_hal_device_battery_proxy_1_device_battery_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_battery_proxy_1_device_battery_invoke_register_changed_event(rpc_port_proxy_hal_device_battery_proxy_1_device_battery_h h, rpc_port_proxy_hal_device_battery_proxy_1_device_battery_updated_cb_h cb)
+{
+ 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_BATTERY_PROXY_1_DEVICE_BATTERY_METHOD_REGISTER_CHANGED_EVENT;
+ int ret_ = -1;
+
+ if (h == nullptr || cb == 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_delegate(map_, 3167 /*cb*/, (rpc_port_delegate_h)cb);
+
+ h->delegates = g_list_append(h->delegates, cb);
+
+ 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_battery_proxy_1_device_battery_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_;
+}
+
+
+void rpc_port_proxy_hal_device_battery_proxy_1_device_battery_invoke_unregister_changed_event(rpc_port_proxy_hal_device_battery_proxy_1_device_battery_h h, rpc_port_proxy_hal_device_battery_proxy_1_device_battery_updated_cb_h cb)
+{
+ 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_BATTERY_PROXY_1_DEVICE_BATTERY_METHOD_UNREGISTER_CHANGED_EVENT;
+
+ if (h == nullptr || cb == nullptr) {
+ _E("Invalid parameter");
+ set_last_result(RPC_PORT_ERROR_INVALID_PARAMETER);
+ return;
+ }
+
+ if (h->port == nullptr && !rpc_port_proxy_lem_is_connected(h->lem)) {
+ _E("Not connected");
+ set_last_result(RPC_PORT_ERROR_INVALID_PARAMETER);
+ return;
+ }
+
+ 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;
+ }
+
+ 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;
+ }
+
+ rpc_port_unit_map_write_int(map_, 1355467489 /*[METHOD]*/, &method_);
+ rpc_port_unit_map_write_delegate(map_, 3167 /*cb*/, (rpc_port_delegate_h)cb);
+
+ h->delegates = g_list_append(h->delegates, cb);
+
+ rpc_port_parcel_write(parcel_, &map_->parcelable, map_);
+ rpc_port_unit_map_destroy(map_);
+
+ g_rec_mutex_lock(&h->mutex);
+ if (rpc_port_proxy_lem_is_connected(h->lem))
+ res_ = rpc_port_proxy_lem_send(h->lem, parcel_, nullptr);
+ 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_);
+
+ g_rec_mutex_unlock(&h->mutex);
+ set_last_result(res_);
+}
+
+
+int rpc_port_proxy_hal_device_battery_proxy_1_device_battery_invoke_get_current_state(rpc_port_proxy_hal_device_battery_proxy_1_device_battery_h h, rpc_port_proxy_hal_device_battery_proxy_1_battery_info_h *info)
+{
+ 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_BATTERY_PROXY_1_DEVICE_BATTERY_METHOD_GET_CURRENT_STATE;
+ int ret_ = -1;
+ rpc_port_proxy_hal_device_battery_proxy_1_battery_info_h new_info;
+
+ if (h == nullptr || info == 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_battery_proxy_1_device_battery_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_battery_info(map_, 3237038 /*info*/, &new_info);
+
+ *info = new_info;
+
+ 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_battery_ipc_1_lem_device_battery_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_battery_ipc_1_lem_device_battery_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_battery_ipc_1_lem_device_battery_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_battery_ipc_1_lem_device_battery_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.0.
+ */
+
+#pragma once
+
+#include <stdbool.h>
+#include <bundle.h>
+#include <rpc-port.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * @brief The rpc_port_proxy_hal_device_battery_proxy_1_enums_power_source_type enum.
+ */
+typedef enum {
+ RPC_PORT_PROXY_HAL_DEVICE_BATTERY_PROXY_1_POWER_SOURCE_TYPE_ENUMS_POWER_SOURCE_NONE = 0,
+ RPC_PORT_PROXY_HAL_DEVICE_BATTERY_PROXY_1_POWER_SOURCE_TYPE_ENUMS_POWER_SOURCE_AC,
+ RPC_PORT_PROXY_HAL_DEVICE_BATTERY_PROXY_1_POWER_SOURCE_TYPE_ENUMS_POWER_SOURCE_USB,
+ RPC_PORT_PROXY_HAL_DEVICE_BATTERY_PROXY_1_POWER_SOURCE_TYPE_ENUMS_POWER_SOURCE_WIRELESS,
+} rpc_port_proxy_hal_device_battery_proxy_1_enums_power_source_type_e;
+
+/**
+ * @brief The rpc_port_proxy_hal_device_battery_proxy_1_enums handle.
+ */
+typedef struct rpc_port_proxy_hal_device_battery_proxy_1_enums_s *rpc_port_proxy_hal_device_battery_proxy_1_enums_h;
+
+/**
+ * @brief The rpc_port_proxy_hal_device_battery_proxy_1_battery_info handle.
+ */
+typedef struct rpc_port_proxy_hal_device_battery_proxy_1_battery_info_s *rpc_port_proxy_hal_device_battery_proxy_1_battery_info_h;
+
+/**
+ * @breif The rpc_port_proxy_hal_device_battery_proxy_1 remote exception handle.
+ */
+typedef struct rpc_port_proxy_hal_device_battery_proxy_1_remote_exception_s *rpc_port_proxy_hal_device_battery_proxy_1_remote_exception_h;
+
+/**
+ * @brief The rpc_port_proxy_hal_device_battery_proxy_1_device_battery handle.
+ */
+typedef struct rpc_port_proxy_hal_device_battery_proxy_1_device_battery_s *rpc_port_proxy_hal_device_battery_proxy_1_device_battery_h;
+
+/**
+ * @brief The rpc_port_proxy_hal_device_battery_proxy_1_device_battery_updated_cb handle.
+ */
+typedef struct rpc_port_proxy_hal_device_battery_proxy_1_device_battery_updated_cb_s *rpc_port_proxy_hal_device_battery_proxy_1_device_battery_updated_cb_h;
+
+/**
+ * @brief Creates a rpc_port_proxy_hal_device_battery_proxy_1_enums handle.
+ *
+ * @remarks The @a h handle should be released using the rpc_port_proxy_hal_device_battery_proxy_1_enums_destroy()
+ * if it's no longer needed.
+ * @param[out] h The rpc_port_proxy_hal_device_battery_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_battery_proxy_1_enums_destroy()
+ */
+int rpc_port_proxy_hal_device_battery_proxy_1_enums_create(rpc_port_proxy_hal_device_battery_proxy_1_enums_h *h);
+
+/**
+ * @brief Destroys the rpc_port_proxy_hal_device_battery_proxy_1_enums handle.
+ *
+ * @param[in] h The rpc_port_proxy_hal_device_battery_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_battery_proxy_1_enums_create()
+ */
+int rpc_port_proxy_hal_device_battery_proxy_1_enums_destroy(rpc_port_proxy_hal_device_battery_proxy_1_enums_h h);
+
+/**
+ * @brief Creates and returns a copy of the given rpc_port_proxy_hal_device_battery_proxy_1_enums handle.
+ *
+ * @remarks A new created rpc_port_proxy_hal_device_battery_proxy_1_enums should be released using
+ * the rpc_port_proxy_hal_device_battery_proxy_1_enums_destroy() if it's no longer needed.
+ * @param[in] h The rpc_port_proxy_hal_device_battery_proxy_1_enums handle
+ * @param[out] clone If successful, a new created rpc_port_proxy_hal_device_battery_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_battery_proxy_1_enums_destroy()
+ */
+int rpc_port_proxy_hal_device_battery_proxy_1_enums_clone(rpc_port_proxy_hal_device_battery_proxy_1_enums_h h, rpc_port_proxy_hal_device_battery_proxy_1_enums_h *clone);
+
+/**
+ * @brief Creates a rpc_port_proxy_hal_device_battery_proxy_1_battery_info handle.
+ *
+ * @remarks The @a h handle should be released using the rpc_port_proxy_hal_device_battery_proxy_1_battery_info_destroy()
+ * if it's no longer needed.
+ * @param[out] h The rpc_port_proxy_hal_device_battery_proxy_1_battery_info 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_battery_proxy_1_battery_info_destroy()
+ */
+int rpc_port_proxy_hal_device_battery_proxy_1_battery_info_create(rpc_port_proxy_hal_device_battery_proxy_1_battery_info_h *h);
+
+/**
+ * @brief Destroys the rpc_port_proxy_hal_device_battery_proxy_1_battery_info handle.
+ *
+ * @param[in] h The rpc_port_proxy_hal_device_battery_proxy_1_battery_info 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_battery_proxy_1_battery_info_create()
+ */
+int rpc_port_proxy_hal_device_battery_proxy_1_battery_info_destroy(rpc_port_proxy_hal_device_battery_proxy_1_battery_info_h h);
+
+/**
+ * @brief Creates and returns a copy of the given rpc_port_proxy_hal_device_battery_proxy_1_battery_info handle.
+ *
+ * @remarks A new created rpc_port_proxy_hal_device_battery_proxy_1_battery_info should be released using
+ * the rpc_port_proxy_hal_device_battery_proxy_1_battery_info_destroy() if it's no longer needed.
+ * @param[in] h The rpc_port_proxy_hal_device_battery_proxy_1_battery_info handle
+ * @param[out] clone If successful, a new created rpc_port_proxy_hal_device_battery_proxy_1_battery_info 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_battery_proxy_1_battery_info_destroy()
+ */
+int rpc_port_proxy_hal_device_battery_proxy_1_battery_info_clone(rpc_port_proxy_hal_device_battery_proxy_1_battery_info_h h, rpc_port_proxy_hal_device_battery_proxy_1_battery_info_h *clone);
+
+/**
+ * @brief Sets the name to the rpc_port_proxy_hal_device_battery_proxy_1_battery_info handle.
+ *
+ * @remarks The name is internally copied and stored.
+ * You should release it if it's allocated when it's no longer needed.
+ * @param[in] h The rpc_port_proxy_hal_device_battery_proxy_1_battery_info handle
+ * @param[in] value The name
+ * @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_battery_proxy_1_battery_info_get_name()
+ */
+int rpc_port_proxy_hal_device_battery_proxy_1_battery_info_set_name(rpc_port_proxy_hal_device_battery_proxy_1_battery_info_h h, const char *value);
+
+/**
+ * @brief Gets the name from the rpc_port_proxy_hal_device_battery_proxy_1_battery_info handle.
+ *
+ * @remarks A new created value should be released if it's allocated when it's no longer needed.
+ * @param[in] h The rpc_port_proxy_hal_device_battery_proxy_1_battery_info handle
+ * @param[out] value The name
+ * @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_battery_proxy_1_battery_info_set_name
+ */
+int rpc_port_proxy_hal_device_battery_proxy_1_battery_info_get_name(rpc_port_proxy_hal_device_battery_proxy_1_battery_info_h h, char **value);
+
+/**
+ * @brief Sets the status to the rpc_port_proxy_hal_device_battery_proxy_1_battery_info handle.
+ *
+ * @remarks The status is internally copied and stored.
+ * You should release it if it's allocated when it's no longer needed.
+ * @param[in] h The rpc_port_proxy_hal_device_battery_proxy_1_battery_info handle
+ * @param[in] value The status
+ * @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_battery_proxy_1_battery_info_get_status()
+ */
+int rpc_port_proxy_hal_device_battery_proxy_1_battery_info_set_status(rpc_port_proxy_hal_device_battery_proxy_1_battery_info_h h, const char *value);
+
+/**
+ * @brief Gets the status from the rpc_port_proxy_hal_device_battery_proxy_1_battery_info handle.
+ *
+ * @remarks A new created value should be released if it's allocated when it's no longer needed.
+ * @param[in] h The rpc_port_proxy_hal_device_battery_proxy_1_battery_info handle
+ * @param[out] value The status
+ * @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_battery_proxy_1_battery_info_set_status
+ */
+int rpc_port_proxy_hal_device_battery_proxy_1_battery_info_get_status(rpc_port_proxy_hal_device_battery_proxy_1_battery_info_h h, char **value);
+
+/**
+ * @brief Sets the health to the rpc_port_proxy_hal_device_battery_proxy_1_battery_info handle.
+ *
+ * @remarks The health is internally copied and stored.
+ * You should release it if it's allocated when it's no longer needed.
+ * @param[in] h The rpc_port_proxy_hal_device_battery_proxy_1_battery_info handle
+ * @param[in] value The health
+ * @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_battery_proxy_1_battery_info_get_health()
+ */
+int rpc_port_proxy_hal_device_battery_proxy_1_battery_info_set_health(rpc_port_proxy_hal_device_battery_proxy_1_battery_info_h h, const char *value);
+
+/**
+ * @brief Gets the health from the rpc_port_proxy_hal_device_battery_proxy_1_battery_info handle.
+ *
+ * @remarks A new created value should be released if it's allocated when it's no longer needed.
+ * @param[in] h The rpc_port_proxy_hal_device_battery_proxy_1_battery_info handle
+ * @param[out] value The health
+ * @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_battery_proxy_1_battery_info_set_health
+ */
+int rpc_port_proxy_hal_device_battery_proxy_1_battery_info_get_health(rpc_port_proxy_hal_device_battery_proxy_1_battery_info_h h, char **value);
+
+/**
+ * @brief Sets the power_source to the rpc_port_proxy_hal_device_battery_proxy_1_battery_info handle.
+ *
+ * @remarks The power_source is internally copied and stored.
+ * You should release it if it's allocated when it's no longer needed.
+ * @param[in] h The rpc_port_proxy_hal_device_battery_proxy_1_battery_info handle
+ * @param[in] value The power_source
+ * @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_battery_proxy_1_battery_info_get_power_source()
+ */
+int rpc_port_proxy_hal_device_battery_proxy_1_battery_info_set_power_source(rpc_port_proxy_hal_device_battery_proxy_1_battery_info_h h, rpc_port_proxy_hal_device_battery_proxy_1_enums_power_source_type_e value);
+
+/**
+ * @brief Gets the power_source from the rpc_port_proxy_hal_device_battery_proxy_1_battery_info handle.
+ *
+ * @remarks A new created value should be released if it's allocated when it's no longer needed.
+ * @param[in] h The rpc_port_proxy_hal_device_battery_proxy_1_battery_info handle
+ * @param[out] value The power_source
+ * @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_battery_proxy_1_battery_info_set_power_source
+ */
+int rpc_port_proxy_hal_device_battery_proxy_1_battery_info_get_power_source(rpc_port_proxy_hal_device_battery_proxy_1_battery_info_h h, rpc_port_proxy_hal_device_battery_proxy_1_enums_power_source_type_e *value);
+
+/**
+ * @brief Sets the online to the rpc_port_proxy_hal_device_battery_proxy_1_battery_info handle.
+ *
+ * @remarks The online is internally copied and stored.
+ * You should release it if it's allocated when it's no longer needed.
+ * @param[in] h The rpc_port_proxy_hal_device_battery_proxy_1_battery_info handle
+ * @param[in] value The online
+ * @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_battery_proxy_1_battery_info_get_online()
+ */
+int rpc_port_proxy_hal_device_battery_proxy_1_battery_info_set_online(rpc_port_proxy_hal_device_battery_proxy_1_battery_info_h h, int value);
+
+/**
+ * @brief Gets the online from the rpc_port_proxy_hal_device_battery_proxy_1_battery_info handle.
+ *
+ * @remarks A new created value should be released if it's allocated when it's no longer needed.
+ * @param[in] h The rpc_port_proxy_hal_device_battery_proxy_1_battery_info handle
+ * @param[out] value The online
+ * @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_battery_proxy_1_battery_info_set_online
+ */
+int rpc_port_proxy_hal_device_battery_proxy_1_battery_info_get_online(rpc_port_proxy_hal_device_battery_proxy_1_battery_info_h h, int *value);
+
+/**
+ * @brief Sets the present to the rpc_port_proxy_hal_device_battery_proxy_1_battery_info handle.
+ *
+ * @remarks The present is internally copied and stored.
+ * You should release it if it's allocated when it's no longer needed.
+ * @param[in] h The rpc_port_proxy_hal_device_battery_proxy_1_battery_info handle
+ * @param[in] value The present
+ * @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_battery_proxy_1_battery_info_get_present()
+ */
+int rpc_port_proxy_hal_device_battery_proxy_1_battery_info_set_present(rpc_port_proxy_hal_device_battery_proxy_1_battery_info_h h, int value);
+
+/**
+ * @brief Gets the present from the rpc_port_proxy_hal_device_battery_proxy_1_battery_info handle.
+ *
+ * @remarks A new created value should be released if it's allocated when it's no longer needed.
+ * @param[in] h The rpc_port_proxy_hal_device_battery_proxy_1_battery_info handle
+ * @param[out] value The present
+ * @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_battery_proxy_1_battery_info_set_present
+ */
+int rpc_port_proxy_hal_device_battery_proxy_1_battery_info_get_present(rpc_port_proxy_hal_device_battery_proxy_1_battery_info_h h, int *value);
+
+/**
+ * @brief Sets the capacity to the rpc_port_proxy_hal_device_battery_proxy_1_battery_info handle.
+ *
+ * @remarks The capacity is internally copied and stored.
+ * You should release it if it's allocated when it's no longer needed.
+ * @param[in] h The rpc_port_proxy_hal_device_battery_proxy_1_battery_info handle
+ * @param[in] value The capacity
+ * @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_battery_proxy_1_battery_info_get_capacity()
+ */
+int rpc_port_proxy_hal_device_battery_proxy_1_battery_info_set_capacity(rpc_port_proxy_hal_device_battery_proxy_1_battery_info_h h, int value);
+
+/**
+ * @brief Gets the capacity from the rpc_port_proxy_hal_device_battery_proxy_1_battery_info handle.
+ *
+ * @remarks A new created value should be released if it's allocated when it's no longer needed.
+ * @param[in] h The rpc_port_proxy_hal_device_battery_proxy_1_battery_info handle
+ * @param[out] value The capacity
+ * @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_battery_proxy_1_battery_info_set_capacity
+ */
+int rpc_port_proxy_hal_device_battery_proxy_1_battery_info_get_capacity(rpc_port_proxy_hal_device_battery_proxy_1_battery_info_h h, int *value);
+
+/**
+ * @brief Sets the current_now to the rpc_port_proxy_hal_device_battery_proxy_1_battery_info handle.
+ *
+ * @remarks The current_now is internally copied and stored.
+ * You should release it if it's allocated when it's no longer needed.
+ * @param[in] h The rpc_port_proxy_hal_device_battery_proxy_1_battery_info handle
+ * @param[in] value The current_now
+ * @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_battery_proxy_1_battery_info_get_current_now()
+ */
+int rpc_port_proxy_hal_device_battery_proxy_1_battery_info_set_current_now(rpc_port_proxy_hal_device_battery_proxy_1_battery_info_h h, int value);
+
+/**
+ * @brief Gets the current_now from the rpc_port_proxy_hal_device_battery_proxy_1_battery_info handle.
+ *
+ * @remarks A new created value should be released if it's allocated when it's no longer needed.
+ * @param[in] h The rpc_port_proxy_hal_device_battery_proxy_1_battery_info handle
+ * @param[out] value The current_now
+ * @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_battery_proxy_1_battery_info_set_current_now
+ */
+int rpc_port_proxy_hal_device_battery_proxy_1_battery_info_get_current_now(rpc_port_proxy_hal_device_battery_proxy_1_battery_info_h h, int *value);
+
+/**
+ * @brief Sets the current_average to the rpc_port_proxy_hal_device_battery_proxy_1_battery_info handle.
+ *
+ * @remarks The current_average is internally copied and stored.
+ * You should release it if it's allocated when it's no longer needed.
+ * @param[in] h The rpc_port_proxy_hal_device_battery_proxy_1_battery_info handle
+ * @param[in] value The current_average
+ * @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_battery_proxy_1_battery_info_get_current_average()
+ */
+int rpc_port_proxy_hal_device_battery_proxy_1_battery_info_set_current_average(rpc_port_proxy_hal_device_battery_proxy_1_battery_info_h h, int value);
+
+/**
+ * @brief Gets the current_average from the rpc_port_proxy_hal_device_battery_proxy_1_battery_info handle.
+ *
+ * @remarks A new created value should be released if it's allocated when it's no longer needed.
+ * @param[in] h The rpc_port_proxy_hal_device_battery_proxy_1_battery_info handle
+ * @param[out] value The current_average
+ * @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_battery_proxy_1_battery_info_set_current_average
+ */
+int rpc_port_proxy_hal_device_battery_proxy_1_battery_info_get_current_average(rpc_port_proxy_hal_device_battery_proxy_1_battery_info_h h, int *value);
+
+/**
+ * @brief Sets the voltage_now to the rpc_port_proxy_hal_device_battery_proxy_1_battery_info handle.
+ *
+ * @remarks The voltage_now is internally copied and stored.
+ * You should release it if it's allocated when it's no longer needed.
+ * @param[in] h The rpc_port_proxy_hal_device_battery_proxy_1_battery_info handle
+ * @param[in] value The voltage_now
+ * @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_battery_proxy_1_battery_info_get_voltage_now()
+ */
+int rpc_port_proxy_hal_device_battery_proxy_1_battery_info_set_voltage_now(rpc_port_proxy_hal_device_battery_proxy_1_battery_info_h h, int value);
+
+/**
+ * @brief Gets the voltage_now from the rpc_port_proxy_hal_device_battery_proxy_1_battery_info handle.
+ *
+ * @remarks A new created value should be released if it's allocated when it's no longer needed.
+ * @param[in] h The rpc_port_proxy_hal_device_battery_proxy_1_battery_info handle
+ * @param[out] value The voltage_now
+ * @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_battery_proxy_1_battery_info_set_voltage_now
+ */
+int rpc_port_proxy_hal_device_battery_proxy_1_battery_info_get_voltage_now(rpc_port_proxy_hal_device_battery_proxy_1_battery_info_h h, int *value);
+
+/**
+ * @brief Sets the voltage_average to the rpc_port_proxy_hal_device_battery_proxy_1_battery_info handle.
+ *
+ * @remarks The voltage_average is internally copied and stored.
+ * You should release it if it's allocated when it's no longer needed.
+ * @param[in] h The rpc_port_proxy_hal_device_battery_proxy_1_battery_info handle
+ * @param[in] value The voltage_average
+ * @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_battery_proxy_1_battery_info_get_voltage_average()
+ */
+int rpc_port_proxy_hal_device_battery_proxy_1_battery_info_set_voltage_average(rpc_port_proxy_hal_device_battery_proxy_1_battery_info_h h, int value);
+
+/**
+ * @brief Gets the voltage_average from the rpc_port_proxy_hal_device_battery_proxy_1_battery_info handle.
+ *
+ * @remarks A new created value should be released if it's allocated when it's no longer needed.
+ * @param[in] h The rpc_port_proxy_hal_device_battery_proxy_1_battery_info handle
+ * @param[out] value The voltage_average
+ * @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_battery_proxy_1_battery_info_set_voltage_average
+ */
+int rpc_port_proxy_hal_device_battery_proxy_1_battery_info_get_voltage_average(rpc_port_proxy_hal_device_battery_proxy_1_battery_info_h h, int *value);
+
+/**
+ * @brief Sets the temperature to the rpc_port_proxy_hal_device_battery_proxy_1_battery_info handle.
+ *
+ * @remarks The temperature is internally copied and stored.
+ * You should release it if it's allocated when it's no longer needed.
+ * @param[in] h The rpc_port_proxy_hal_device_battery_proxy_1_battery_info handle
+ * @param[in] value The temperature
+ * @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_battery_proxy_1_battery_info_get_temperature()
+ */
+int rpc_port_proxy_hal_device_battery_proxy_1_battery_info_set_temperature(rpc_port_proxy_hal_device_battery_proxy_1_battery_info_h h, int value);
+
+/**
+ * @brief Gets the temperature from the rpc_port_proxy_hal_device_battery_proxy_1_battery_info handle.
+ *
+ * @remarks A new created value should be released if it's allocated when it's no longer needed.
+ * @param[in] h The rpc_port_proxy_hal_device_battery_proxy_1_battery_info handle
+ * @param[out] value The temperature
+ * @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_battery_proxy_1_battery_info_set_temperature
+ */
+int rpc_port_proxy_hal_device_battery_proxy_1_battery_info_get_temperature(rpc_port_proxy_hal_device_battery_proxy_1_battery_info_h h, int *value);
+
+/**
+ * @brief Creates the rpc_port_proxy_hal_device_battery_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_battery_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_battery_proxy_1_remote_exception_destroy()
+ */
+int rpc_port_proxy_hal_device_battery_proxy_1_remote_exception_create(rpc_port_proxy_hal_device_battery_proxy_1_remote_exception_h *h);
+
+/**
+ * @brief Sets the cause of the exception.
+ *
+ * @param[in] h The rpc_port_proxy_hal_device_battery_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_battery_proxy_1_remote_exception_set_cause(rpc_port_proxy_hal_device_battery_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_battery_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_battery_proxy_1_remote_exception_set_message(rpc_port_proxy_hal_device_battery_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_battery_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_battery_proxy_1_remote_exception_get_cause(rpc_port_proxy_hal_device_battery_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_battery_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_battery_proxy_1_remote_exception_get_message(rpc_port_proxy_hal_device_battery_proxy_1_remote_exception_h, char **message);
+
+/**
+ * @brief Destroys the remote exception handle.
+ * @param[in] h The rpc_port_proxy_hal_device_battery_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_battery_proxy_1_remote_exception_destroy(rpc_port_proxy_hal_device_battery_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_battery_proxy_1_remote_exception_destroy(), if it's no longer needed.
+ * @param[out] h The rpc_port_proxy_hal_device_battery_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_battery_proxy_1_remote_exception_destroy();
+ */
+int rpc_port_proxy_hal_device_battery_proxy_1_get_remote_exception(rpc_port_proxy_hal_device_battery_proxy_1_remote_exception_h *h);
+
+/**
+ * @brief Called when the event is received.
+ *
+ * @param[in] user_data The user data passed from the callback registration function
+ * @param[in] ...
+ *
+ * @see rpc_port_proxy_hal_device_battery_proxy_1_device_battery_updated_cb_create()
+ */
+typedef void (*rpc_port_proxy_hal_device_battery_proxy_1_device_battery_updated_cb_cb)(void *user_data, rpc_port_proxy_hal_device_battery_proxy_1_battery_info_h info);
+
+/**
+ * @brief Creates a rpc_port_proxy_hal_device_battery_proxy_1_device_battery_updated_cb handle.
+ *
+ * @param[out] h The rpc_port_proxy_hal_device_battery_proxy_1_device_battery_updated_cb 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 memorya
+ * @see rpc_port_proxy_hal_device_battery_proxy_1_device_battery_updated_cb_destroy()
+ * @see rpc_port_proxy_hal_device_battery_proxy_1_device_battery_updated_cb_dispose()
+ * @see rpc_port_proxy_hal_device_battery_proxy_1_device_battery_updated_cb_set_callback()
+ * @see rpc_port_proxy_hal_device_battery_proxy_1_device_battery_updated_cb_set_once()
+ */
+int rpc_port_proxy_hal_device_battery_proxy_1_device_battery_updated_cb_create(rpc_port_proxy_hal_device_battery_proxy_1_device_battery_updated_cb_h *h);
+
+/**
+ * @brief Destroys the rpc_port_proxy_hal_device_battery_proxy_1_device_battery_updated_cb handle.
+ *
+ * @param[in] h The rpc_port_proxy_hal_device_battery_proxy_1_device_battery_updated_cb 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_battery_proxy_1_device_battery_updated_cb_create()
+ */
+int rpc_port_proxy_hal_device_battery_proxy_1_device_battery_updated_cb_destroy(rpc_port_proxy_hal_device_battery_proxy_1_device_battery_updated_cb_h h);
+
+/**
+ * @brief Creates and returns a copy of the given rpc_port_proxy_hal_device_battery_proxy_1_device_battery_updated_cb handle.
+ *
+ * @remarks A new created rpc_port_proxy_hal_device_battery_proxy_1_device_battery_updated_cb should be released using
+ * the rpc_port_proxy_hal_device_battery_proxy_1_device_battery_updated_cb_destroy() if it's no longer needed.
+ * @param[in] h The rpc_port_proxy_hal_device_battery_proxy_1_device_battery_updated_cb handle
+ * @param[out] clone If successful, a new created rpc_port_proxy_hal_device_battery_proxy_1_device_battery_updated_cb 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_battery_proxy_1_device_battery_updated_cb_destroy()
+ */
+int rpc_port_proxy_hal_device_battery_proxy_1_device_battery_updated_cb_clone(rpc_port_proxy_hal_device_battery_proxy_1_device_battery_updated_cb_h h, rpc_port_proxy_hal_device_battery_proxy_1_device_battery_updated_cb_h *clone);
+
+/**
+ * @brief Sets the callback function to the rpc_port_proxy_hal_device_battery_proxy_1_device_battery_updated_cb handle.
+ *
+ * @param[in] h The rpc_port_proxy_hal_device_battery_proxy_1_device_battery_updated_cb handle
+ * @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
+ */
+int rpc_port_proxy_hal_device_battery_proxy_1_device_battery_updated_cb_set_callback(rpc_port_proxy_hal_device_battery_proxy_1_device_battery_updated_cb_h h, rpc_port_proxy_hal_device_battery_proxy_1_device_battery_updated_cb_cb callback, void *user_data);
+
+/**
+ * @brief Set the once flag to the rpc_port_proxy_hal_device_battery_proxy_1_device_battery_updated_cb handle.
+ * @details If the once flag is 'true', the delegate handle will be deleted after invocation.
+ * If the @a h handle is not used using the method, the handle should be released using
+ * the rpc_port_proxy_hal_device_battery_proxy_1_device_battery_updated_cb_destroy() when it's no longer needed.
+ * If you don't want the delegate callback function to be called after it's used using the method,
+ * you should release the handle using the rpc_port_proxy_hal_device_battery_proxy_1_device_battery_updated_cb_dispose().
+ *
+ * @param[in] h The rpc_port_proxy_hal_device_battery_proxy_1_device_battery_updated_cb handle
+ * @param[in] once The flag if it's true, the delegate will be deleted after invocation
+ * @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_battery_proxy_1_device_battery_updated_cb_set_once(rpc_port_proxy_hal_device_battery_proxy_1_device_battery_updated_cb_h h, bool once);
+
+/**
+ * @brief Gets the ID of the rpc_port_proxy_hal_device_battery_proxy_1_device_battery_updated_cb handle.
+ *
+ * @param[in] h The rpc_port_proxy_hal_device_battery_proxy_1_device_battery_updated_cb handle
+ * @param[out] id The ID
+ * @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_battery_proxy_1_device_battery_updated_cb_get_id(rpc_port_proxy_hal_device_battery_proxy_1_device_battery_updated_cb_h h, int *id);
+
+/**
+ * @brief Gets the sequence ID of the rpc_port_proxy_hal_device_battery_proxy_1_device_battery_updated_cb handle.
+ *
+ * @param[in] h The rpc_port_proxy_hal_device_battery_proxy_1_device_battery_updated_cb handle
+ * @param[out] seq_id The Sequence ID
+ * @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_battery_proxy_1_device_battery_updated_cb_get_seq_id(rpc_port_proxy_hal_device_battery_proxy_1_device_battery_updated_cb_h h, int *seq_id);
+
+/**
+ * @brief Checks whether the delegate is for one-time or not.
+ *
+ * @param[in] h The rpc_port_proxy_hal_device_battery_proxy_1_device_battery_updated_cb handle
+ * @param[out] once The flag, it's true, the handle is for one-time
+ * @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_battery_proxy_1_device_battery_updated_cb_is_once(rpc_port_proxy_hal_device_battery_proxy_1_device_battery_updated_cb_h h, bool *once);
+
+/**
+ * @brief Gets the tag from the rpc_port_proxy_hal_device_battery_proxy_1_device_battery_updated_cb handle.
+ *
+ * @remarks The @a tag should be released using free().
+ * @param[in] h The rpc_port_proxy_hal_device_battery_proxy_1_device_battery_updated_cb 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
+ * @retval #RPC_PORT_ERROR_OUT_OF_MEMORY Out of memory
+ */
+int rpc_port_proxy_hal_device_battery_proxy_1_device_battery_updated_cb_get_tag(rpc_port_proxy_hal_device_battery_proxy_1_device_battery_updated_cb_h h, char **tag);
+
+/**
+ * @brief Disposes the rpc_port_proxy_hal_device_battery_proxy_1_device_battery_updated_cb handle from the rpc_port_proxy_hal_device_battery_proxy_1_device_battery handle.
+ *
+ * @param[in] proxy The rpc_port_proxy_hal_device_battery_proxy_1_device_battery handle
+ * @param[in] h The rpc_port_proxy_hal_device_battery_proxy_1_device_battery_updated_cb 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_battery_proxy_1_device_battery_updated_cb_create()
+ */
+int rpc_port_proxy_hal_device_battery_proxy_1_device_battery_updated_cb_dispose(rpc_port_proxy_hal_device_battery_proxy_1_device_battery_h proxy, rpc_port_proxy_hal_device_battery_proxy_1_device_battery_updated_cb_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_battery_proxy_1_device_battery handle
+ * @param[in] user_data The user data passed from the registeration function
+ * @see #rpc_port_proxy_hal_device_battery_proxy_1_device_battery_callback_s
+ */
+typedef void (*rpc_port_proxy_hal_device_battery_proxy_1_device_battery_connected_cb)(rpc_port_proxy_hal_device_battery_proxy_1_device_battery_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_battery_proxy_1_device_battery handle
+ * @param[in] user_data The user data passed from the registeration function
+ * @see #rpc_port_proxy_hal_device_battery_proxy_1_device_battery_callback_s
+ */
+typedef void (*rpc_port_proxy_hal_device_battery_proxy_1_device_battery_disconnected_cb)(rpc_port_proxy_hal_device_battery_proxy_1_device_battery_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_battery_proxy_1_device_battery handle
+ * @param[in] user_data The user data passed from the registeration function
+ * @see #rpc_port_proxy_hal_device_battery_proxy_1_device_battery_callback_s
+ */
+typedef void (*rpc_port_proxy_hal_device_battery_proxy_1_device_battery_rejected_cb)(rpc_port_proxy_hal_device_battery_proxy_1_device_battery_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_battery_proxy_1_device_battery_create() function.
+ *
+ * @see rpc_port_proxy_hal_device_battery_proxy_1_device_battery_connected_cb
+ * @see rpc_port_proxy_hal_device_battery_proxy_1_device_battery_disconnected_cb
+ * @see rpc_port_proxy_hal_device_battery_proxy_1_device_battery_rejected_cb
+ */
+typedef struct {
+ rpc_port_proxy_hal_device_battery_proxy_1_device_battery_connected_cb connected; /**< This callback function is called when the proxy is connected to the stub. */
+ rpc_port_proxy_hal_device_battery_proxy_1_device_battery_disconnected_cb disconnected; /**< This callback function is called when the proxy is disconnected from the stub. */
+ rpc_port_proxy_hal_device_battery_proxy_1_device_battery_rejected_cb rejected; /**< This callback function is called when the proxy is rejected to connect to the stub. */
+} rpc_port_proxy_hal_device_battery_proxy_1_device_battery_callback_s;
+
+/**
+ * @brief Creates a rpc_port_proxy_hal_device_battery_proxy_1_device_battery handle.
+ * @remarks The @a h handle should be released using
+ * the rpc_port_proxy_hal_device_battery_proxy_1_device_battery_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_battery_proxy_1_device_battery 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_battery_proxy_1_device_battery_destroy()
+ * @see #rpc_port_proxy_hal_device_battery_proxy_1_device_battery_callback_s
+ */
+int rpc_port_proxy_hal_device_battery_proxy_1_device_battery_create(const char *stub_appid, rpc_port_proxy_hal_device_battery_proxy_1_device_battery_callback_s *callback, void *user_data, rpc_port_proxy_hal_device_battery_proxy_1_device_battery_h *h);
+
+/**
+ * @brief Destroys the rpc_port_proxy_hal_device_battery_proxy_1_device_battery handle.
+ *
+ * @param[in] h The rpc_port_proxy_hal_device_battery_proxy_1_device_battery 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_battery_proxy_1_device_battery_create()
+ */
+int rpc_port_proxy_hal_device_battery_proxy_1_device_battery_destroy(rpc_port_proxy_hal_device_battery_proxy_1_device_battery_h h);
+
+/**
+ * @brief Connects to the stub.
+ *
+ * @param[in] h The rpc_port_proxy_hal_device_battery_proxy_1_device_battery 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_battery_proxy_1_device_battery_connect(rpc_port_proxy_hal_device_battery_proxy_1_device_battery_h h);
+
+/**
+ * @brief Connects to the stub synchronously.
+ *
+ * @param[in] h The rpc_port_proxy_hal_device_battery_proxy_1_device_battery 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_battery_proxy_1_device_battery_connect_sync(rpc_port_proxy_hal_device_battery_proxy_1_device_battery_h h);
+
+/**
+ * @brief Disconnects from the stub.
+ *
+ * @param[in] h The rpc_port_proxy_hal_device_battery_proxy_1_device_battery 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_battery_proxy_1_device_battery_disconnect(rpc_port_proxy_hal_device_battery_proxy_1_device_battery_h h);
+
+/**
+ * @brief Calls the register_changed_event() 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_battery_proxy_1_device_battery 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_battery_proxy_1_device_battery_invoke_register_changed_event(rpc_port_proxy_hal_device_battery_proxy_1_device_battery_h h, rpc_port_proxy_hal_device_battery_proxy_1_device_battery_updated_cb_h cb);
+
+/**
+ * @brief Calls the unregister_changed_event() 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_battery_proxy_1_device_battery 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
+ */
+void rpc_port_proxy_hal_device_battery_proxy_1_device_battery_invoke_unregister_changed_event(rpc_port_proxy_hal_device_battery_proxy_1_device_battery_h h, rpc_port_proxy_hal_device_battery_proxy_1_device_battery_updated_cb_h cb);
+
+/**
+ * @brief Calls the get_current_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_battery_proxy_1_device_battery 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_battery_proxy_1_device_battery_invoke_get_current_state(rpc_port_proxy_hal_device_battery_proxy_1_device_battery_h h, rpc_port_proxy_hal_device_battery_proxy_1_battery_info_h *info);
+
+#ifdef __cplusplus
+}
+#endif
--- /dev/null
+
+/*
+ * Generated by tidlc 2.6.0.
+ */
+
+#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_battery_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.0"
+#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_BATTERY_STUB_1_DEVICE_BATTERY_METHOD_RESULT_,
+ RPC_PORT_STUB_HAL_DEVICE_BATTERY_STUB_1_DEVICE_BATTERY_METHOD_CALLBACK_,
+ RPC_PORT_STUB_HAL_DEVICE_BATTERY_STUB_1_DEVICE_BATTERY_METHOD_REGISTER_CHANGED_EVENT,
+ RPC_PORT_STUB_HAL_DEVICE_BATTERY_STUB_1_DEVICE_BATTERY_METHOD_UNREGISTER_CHANGED_EVENT,
+ RPC_PORT_STUB_HAL_DEVICE_BATTERY_STUB_1_DEVICE_BATTERY_METHOD_GET_CURRENT_STATE,
+} rpc_port_stub_hal_device_battery_stub_1_device_battery_method_e;
+
+typedef enum {
+ RPC_PORT_STUB_HAL_DEVICE_BATTERY_STUB_1_DEVICE_BATTERY_DELEGATE_UPDATED_CB = 1,
+} rpc_port_stub_hal_device_battery_stub_1_device_battery_delegate_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_battery_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;
+
+static rpc_port_delegate_h rpc_port_delegate_create();
+
+typedef struct rpc_port_stub_hal_device_battery_stub_1_enums_s {
+ rpc_port_parcelable_t parcelable;
+} rpc_port_stub_hal_device_battery_stub_1_enums_t;
+
+typedef struct rpc_port_stub_hal_device_battery_stub_1_battery_info_s {
+ rpc_port_parcelable_t parcelable;
+ char *name;
+ char *status;
+ char *health;
+ rpc_port_stub_hal_device_battery_stub_1_enums_power_source_type_e power_source;
+ int online;
+ int present;
+ int capacity;
+ int current_now;
+ int current_average;
+ int voltage_now;
+ int voltage_average;
+ int temperature;
+} rpc_port_stub_hal_device_battery_stub_1_battery_info_t;
+
+typedef struct rpc_port_stub_hal_device_battery_stub_1_remote_exception_s {
+ rpc_port_parcelable_t parcelable;
+ int cause;
+ char *message;
+} rpc_port_stub_hal_device_battery_stub_1_remote_exception_t;
+
+static rpc_port_stub_hal_device_battery_stub_1_remote_exception_h __rpc_port_stub_hal_device_battery_stub_1_remote_exception;
+
+int rpc_port_stub_hal_device_battery_stub_1_remote_exception_create(rpc_port_stub_hal_device_battery_stub_1_remote_exception_h *h);
+
+typedef struct rpc_port_stub_hal_device_battery_stub_1_device_battery_updated_cb_s {
+ rpc_port_parcelable_t parcelable;
+ rpc_port_h port;
+ int id;
+ int seq_id;
+ bool once;
+ bool valid;
+ char *lem_instance;
+} rpc_port_stub_hal_device_battery_stub_1_device_battery_updated_cb_t;
+
+static bool __rpc_port_stub_hal_device_battery_stub_1_device_battery_exist_callback_port(rpc_port_h callback_port);
+static rpc_port_stub_hal_device_battery_stub_1_device_battery_context_h __rpc_port_stub_hal_device_battery_stub_1_device_battery_find_context(const char *instance);
+
+typedef struct rpc_port_stub_hal_device_battery_stub_1_device_battery_context_s {
+ char *sender;
+ char *instance;
+ rpc_port_h port;
+ rpc_port_h callback_port;
+ void *tag;
+ rpc_port_stub_hal_device_battery_stub_1_device_battery_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_battery_stub_1_device_battery_context_t;
+
+typedef int (*rpc_port_stub_hal_device_battery_stub_1_device_battery_privilege_checker)(rpc_port_stub_hal_device_battery_stub_1_device_battery_context_h h, bool *sync);
+
+typedef struct rpc_port_stub_hal_device_battery_stub_1_device_battery_s {
+ rpc_port_stub_h stub;
+ rpc_port_stub_hal_device_battery_stub_1_device_battery_callback_s callback;
+ void *user_data;
+ GList* contexts;
+ GList* callback_ports;
+ GRecMutex mutex;
+} rpc_port_stub_hal_device_battery_stub_1_device_battery_t;
+
+static rpc_port_stub_hal_device_battery_stub_1_device_battery_t __device_battery;
+
+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_battery_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_battery_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_battery_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_battery_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_invoke_callback(rpc_port_stub_lem_h handle, void *context, rpc_port_parcel_h parcel)
+{
+ if (handle == nullptr || context == nullptr || parcel == nullptr)
+ return;
+
+ if (handle->invoke_callback_func)
+ handle->invoke_callback_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_write_device_battery_updated_cb_write_cb(rpc_port_parcel_h parcel, void* data)
+{
+ rpc_port_unit_h unit = data;
+ rpc_port_stub_hal_device_battery_stub_1_device_battery_updated_cb_h handle = unit->data;
+
+ rpc_port_parcel_write(parcel, &handle->parcelable, handle);
+}
+
+static int rpc_port_unit_map_write_device_battery_updated_cb(rpc_port_unit_map_h unit_map,
+ int name, rpc_port_stub_hal_device_battery_stub_1_device_battery_updated_cb_h value)
+{
+ rpc_port_unit_h unit;
+
+ if (unit_map == nullptr)
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
+
+ unit = rpc_port_unit_create(name, -432452514 /*device_battery_updated_cb*/);
+ if (unit == nullptr)
+ return RPC_PORT_ERROR_OUT_OF_MEMORY;
+
+ unit->data = value;
+ unit->write_cb = rpc_port_unit_map_write_device_battery_updated_cb_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_device_battery_updated_cb(rpc_port_unit_map_h unit_map,
+ int name, rpc_port_stub_hal_device_battery_stub_1_device_battery_updated_cb_h *value)
+{
+ rpc_port_unit_h unit;
+ rpc_port_stub_hal_device_battery_stub_1_device_battery_updated_cb_t *handle;
+ int ret;
+
+ if (value == nullptr) {
+ _E("Invalid parameter");
+ return;
+ }
+
+ ret = rpc_port_stub_hal_device_battery_stub_1_device_battery_updated_cb_create((rpc_port_stub_hal_device_battery_stub_1_device_battery_updated_cb_h *)&handle);
+ if (ret != RPC_PORT_ERROR_NONE) {
+ *value = nullptr;
+ return;
+ }
+
+ *value = handle;
+ if (unit_map == nullptr) {
+ _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);
+ return;
+ }
+
+ if (unit->type != -432452514 /*device_battery_updated_cb*/) {
+ _E("type(%d) is not device_battery_updated_cb", unit->type);
+ return;
+ }
+
+ rpc_port_parcel_read(unit->parcel, &handle->parcelable, handle);
+}
+
+static void rpc_port_unit_map_write_delegate_write_cb(rpc_port_parcel_h parcel, void* data)
+{
+ rpc_port_unit_h unit = data;
+ rpc_port_delegate_h handle = unit->data;
+
+ rpc_port_parcel_write(parcel, &handle->parcelable, handle);
+}
+
+static int rpc_port_unit_map_write_delegate(rpc_port_unit_map_h unit_map,
+ int name, rpc_port_delegate_h value)
+{
+ rpc_port_unit_h unit;
+
+ if (unit_map == nullptr || value == nullptr)
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
+
+ unit = rpc_port_unit_create(name, 819322245 /*delegate*/);
+ if (unit == nullptr)
+ return RPC_PORT_ERROR_OUT_OF_MEMORY;
+
+ unit->data = value;
+ unit->write_cb = rpc_port_unit_map_write_delegate_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_delegate(rpc_port_unit_map_h unit_map,
+ int name, rpc_port_delegate_h *value)
+{
+ rpc_port_unit_h unit;
+ rpc_port_delegate_h delegate;
+
+ if (value == nullptr) {
+ _E("Invalid parameter");
+ return;
+ }
+
+ delegate = rpc_port_delegate_create();
+ *value = delegate;
+
+ if (delegate == nullptr)
+ return;
+
+ if (unit_map == nullptr) {
+ _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);
+ return;
+ }
+
+ if (unit->type != 819322245 /*delegate*/) {
+ _E("type(%d) is not delegate", unit->type);
+ return;
+ }
+
+ rpc_port_parcel_read(unit->parcel, &delegate->parcelable, delegate);
+}
+
+static void rpc_port_unit_map_write_battery_info_write_cb(rpc_port_parcel_h parcel, void* data)
+{
+ rpc_port_unit_h unit = data;
+ rpc_port_stub_hal_device_battery_stub_1_battery_info_h handle = unit->data;
+
+ rpc_port_parcel_write(parcel, &handle->parcelable, handle);
+}
+
+static int rpc_port_unit_map_write_battery_info(rpc_port_unit_map_h unit_map,
+ int name, rpc_port_stub_hal_device_battery_stub_1_battery_info_h value)
+{
+ rpc_port_unit_h unit;
+
+ if (unit_map == nullptr)
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
+
+ unit = rpc_port_unit_create(name, -1690947680 /*battery_info*/);
+ if (unit == nullptr)
+ return RPC_PORT_ERROR_OUT_OF_MEMORY;
+
+ unit->data = value;
+ unit->write_cb = rpc_port_unit_map_write_battery_info_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_stub_hal_device_battery_stub_1_remote_exception_h *value)
+{
+ rpc_port_unit_h unit;
+ rpc_port_stub_hal_device_battery_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_battery_stub_1_remote_exception_create((rpc_port_stub_hal_device_battery_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_battery_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_battery_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_delegate_to(rpc_port_parcel_h parcel, void *user_data)
+{
+ rpc_port_delegate_h delegate = user_data;
+
+ rpc_port_parcel_write_int32(parcel, delegate->id);
+ rpc_port_parcel_write_int32(parcel, delegate->seq_id);
+ rpc_port_parcel_write_bool(parcel, delegate->once);
+
+ set_last_result(RPC_PORT_ERROR_NONE);
+}
+
+static void __rpc_port_delegate_from(rpc_port_parcel_h parcel, void *user_data)
+{
+ rpc_port_delegate_h delegate = user_data;
+
+ rpc_port_parcel_read_int32(parcel, &delegate->id);
+ rpc_port_parcel_read_int32(parcel, &delegate->seq_id);
+ rpc_port_parcel_read_bool(parcel, &delegate->once);
+
+ set_last_result(RPC_PORT_ERROR_NONE);
+}
+
+static rpc_port_delegate_h rpc_port_delegate_create()
+{
+ rpc_port_delegate_h delegate;
+
+ delegate = calloc(1, sizeof(rpc_port_delegate_t));
+ if (delegate == nullptr) {
+ _E("malloc() is failed");
+ return nullptr;
+ }
+
+ delegate->parcelable.to = __rpc_port_delegate_to;
+ delegate->parcelable.from = __rpc_port_delegate_from;
+
+ return delegate;
+}
+
+static void __rpc_port_stub_hal_device_battery_stub_1_enums_to(rpc_port_parcel_h parcel, void *data)
+{
+ rpc_port_stub_hal_device_battery_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_battery_stub_1_enums_from(rpc_port_parcel_h parcel, void *data)
+{
+ rpc_port_stub_hal_device_battery_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_battery_stub_1_enums_create(rpc_port_stub_hal_device_battery_stub_1_enums_h *h)
+{
+ rpc_port_stub_hal_device_battery_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_battery_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_battery_stub_1_enums_to;
+ handle->parcelable.from = __rpc_port_stub_hal_device_battery_stub_1_enums_from;
+
+ *h = handle;
+
+ return RPC_PORT_ERROR_NONE;
+}
+
+int rpc_port_stub_hal_device_battery_stub_1_enums_destroy(rpc_port_stub_hal_device_battery_stub_1_enums_h h)
+{
+ rpc_port_stub_hal_device_battery_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_battery_stub_1_enums_clone(rpc_port_stub_hal_device_battery_stub_1_enums_h h, rpc_port_stub_hal_device_battery_stub_1_enums_h *clone)
+{
+ rpc_port_stub_hal_device_battery_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_battery_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_battery_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_battery_stub_1_enums_destroy(handle);
+ return ret;
+ }
+
+ *clone = handle;
+
+ return RPC_PORT_ERROR_NONE;
+}
+
+static void __rpc_port_stub_hal_device_battery_stub_1_battery_info_to(rpc_port_parcel_h parcel, void *data)
+{
+ rpc_port_stub_hal_device_battery_stub_1_battery_info_t *handle = data;
+
+ if (parcel == nullptr || handle == nullptr) {
+ _E("Invalid parameter");
+ set_last_result(RPC_PORT_ERROR_INVALID_PARAMETER);
+ return;
+ }
+
+ rpc_port_parcel_write_string(parcel, handle->name);
+ rpc_port_parcel_write_string(parcel, handle->status);
+ rpc_port_parcel_write_string(parcel, handle->health);
+ rpc_port_parcel_burst_write(parcel, (const unsigned char*)(&handle->power_source), sizeof(handle->power_source));
+ rpc_port_parcel_burst_write(parcel, (const unsigned char*)(&handle->online), sizeof(handle->online));
+ rpc_port_parcel_burst_write(parcel, (const unsigned char*)(&handle->present), sizeof(handle->present));
+ rpc_port_parcel_burst_write(parcel, (const unsigned char*)(&handle->capacity), sizeof(handle->capacity));
+ rpc_port_parcel_burst_write(parcel, (const unsigned char*)(&handle->current_now), sizeof(handle->current_now));
+ rpc_port_parcel_burst_write(parcel, (const unsigned char*)(&handle->current_average), sizeof(handle->current_average));
+ rpc_port_parcel_burst_write(parcel, (const unsigned char*)(&handle->voltage_now), sizeof(handle->voltage_now));
+ rpc_port_parcel_burst_write(parcel, (const unsigned char*)(&handle->voltage_average), sizeof(handle->voltage_average));
+ rpc_port_parcel_burst_write(parcel, (const unsigned char*)(&handle->temperature), sizeof(handle->temperature));
+
+ set_last_result(RPC_PORT_ERROR_NONE);
+}
+
+static void __rpc_port_stub_hal_device_battery_stub_1_battery_info_from(rpc_port_parcel_h parcel, void *data)
+{
+ rpc_port_stub_hal_device_battery_stub_1_battery_info_t *handle = data;
+
+ if (parcel == nullptr || handle == nullptr) {
+ _E("Invalid parameter");
+ set_last_result(RPC_PORT_ERROR_INVALID_PARAMETER);
+ return;
+ }
+
+ rpc_port_parcel_read_string(parcel, &handle->name);
+ rpc_port_parcel_read_string(parcel, &handle->status);
+ rpc_port_parcel_read_string(parcel, &handle->health);
+ rpc_port_parcel_burst_read(parcel, (unsigned char*)(&handle->power_source), sizeof(handle->power_source));
+ rpc_port_parcel_burst_read(parcel, (unsigned char*)(&handle->online), sizeof(handle->online));
+ rpc_port_parcel_burst_read(parcel, (unsigned char*)(&handle->present), sizeof(handle->present));
+ rpc_port_parcel_burst_read(parcel, (unsigned char*)(&handle->capacity), sizeof(handle->capacity));
+ rpc_port_parcel_burst_read(parcel, (unsigned char*)(&handle->current_now), sizeof(handle->current_now));
+ rpc_port_parcel_burst_read(parcel, (unsigned char*)(&handle->current_average), sizeof(handle->current_average));
+ rpc_port_parcel_burst_read(parcel, (unsigned char*)(&handle->voltage_now), sizeof(handle->voltage_now));
+ rpc_port_parcel_burst_read(parcel, (unsigned char*)(&handle->voltage_average), sizeof(handle->voltage_average));
+ rpc_port_parcel_burst_read(parcel, (unsigned char*)(&handle->temperature), sizeof(handle->temperature));
+
+ set_last_result(RPC_PORT_ERROR_NONE);
+}
+
+int rpc_port_stub_hal_device_battery_stub_1_battery_info_create(rpc_port_stub_hal_device_battery_stub_1_battery_info_h *h)
+{
+ rpc_port_stub_hal_device_battery_stub_1_battery_info_t *handle;
+
+ if (h == nullptr) {
+ _E("Invalid parameter");
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
+ }
+
+ handle = calloc(1, sizeof(rpc_port_stub_hal_device_battery_stub_1_battery_info_t));
+ if (handle == nullptr) {
+ _E("Out of memory");
+ return RPC_PORT_ERROR_OUT_OF_MEMORY;
+ }
+
+ handle->parcelable.to = __rpc_port_stub_hal_device_battery_stub_1_battery_info_to;
+ handle->parcelable.from = __rpc_port_stub_hal_device_battery_stub_1_battery_info_from;
+
+ *h = handle;
+
+ return RPC_PORT_ERROR_NONE;
+}
+
+int rpc_port_stub_hal_device_battery_stub_1_battery_info_destroy(rpc_port_stub_hal_device_battery_stub_1_battery_info_h h)
+{
+ rpc_port_stub_hal_device_battery_stub_1_battery_info_t *handle = h;
+
+ if (handle == nullptr) {
+ _E("Invalid parameter");
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
+ }
+
+ if (handle->name)
+ free(handle->name);
+ if (handle->status)
+ free(handle->status);
+ if (handle->health)
+ free(handle->health);
+
+ free(handle);
+
+ return RPC_PORT_ERROR_NONE;
+}
+
+int rpc_port_stub_hal_device_battery_stub_1_battery_info_clone(rpc_port_stub_hal_device_battery_stub_1_battery_info_h h, rpc_port_stub_hal_device_battery_stub_1_battery_info_h *clone)
+{
+ rpc_port_stub_hal_device_battery_stub_1_battery_info_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_battery_stub_1_battery_info_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_battery_stub_1_battery_info_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_battery_stub_1_battery_info_destroy(handle);
+ return ret;
+ }
+
+ *clone = handle;
+
+ return RPC_PORT_ERROR_NONE;
+}
+int rpc_port_stub_hal_device_battery_stub_1_battery_info_set_name(rpc_port_stub_hal_device_battery_stub_1_battery_info_h handle, const char *value)
+{
+ char *new_value;
+
+ if (handle == nullptr || value == nullptr) {
+ _E("Invalid parameter");
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
+ }
+
+ new_value = strdup(value);
+ if (new_value == nullptr) {
+ _E("Failed to duplicate value");
+ return RPC_PORT_ERROR_OUT_OF_MEMORY;
+ }
+
+ if (handle->name)
+ free(handle->name);
+
+ handle->name = new_value;
+
+ return RPC_PORT_ERROR_NONE;
+}
+
+int rpc_port_stub_hal_device_battery_stub_1_battery_info_get_name(rpc_port_stub_hal_device_battery_stub_1_battery_info_h handle, char **value)
+{
+ char *new_value;
+ if (handle == nullptr || value == nullptr) {
+ _E("Invalid parameter");
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
+ }
+
+ if (handle->name == nullptr) {
+ _E("name is nullptr");
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
+ }
+
+ new_value = strdup(handle->name);
+ if (new_value == nullptr) {
+ _E("Failed to duplicate value");
+ return RPC_PORT_ERROR_OUT_OF_MEMORY;
+ }
+
+ *value = new_value;
+
+ return RPC_PORT_ERROR_NONE;
+}
+
+int rpc_port_stub_hal_device_battery_stub_1_battery_info_set_status(rpc_port_stub_hal_device_battery_stub_1_battery_info_h handle, const char *value)
+{
+ char *new_value;
+
+ if (handle == nullptr || value == nullptr) {
+ _E("Invalid parameter");
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
+ }
+
+ new_value = strdup(value);
+ if (new_value == nullptr) {
+ _E("Failed to duplicate value");
+ return RPC_PORT_ERROR_OUT_OF_MEMORY;
+ }
+
+ if (handle->status)
+ free(handle->status);
+
+ handle->status = new_value;
+
+ return RPC_PORT_ERROR_NONE;
+}
+
+int rpc_port_stub_hal_device_battery_stub_1_battery_info_get_status(rpc_port_stub_hal_device_battery_stub_1_battery_info_h handle, char **value)
+{
+ char *new_value;
+ if (handle == nullptr || value == nullptr) {
+ _E("Invalid parameter");
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
+ }
+
+ if (handle->status == nullptr) {
+ _E("status is nullptr");
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
+ }
+
+ new_value = strdup(handle->status);
+ if (new_value == nullptr) {
+ _E("Failed to duplicate value");
+ return RPC_PORT_ERROR_OUT_OF_MEMORY;
+ }
+
+ *value = new_value;
+
+ return RPC_PORT_ERROR_NONE;
+}
+
+int rpc_port_stub_hal_device_battery_stub_1_battery_info_set_health(rpc_port_stub_hal_device_battery_stub_1_battery_info_h handle, const char *value)
+{
+ char *new_value;
+
+ if (handle == nullptr || value == nullptr) {
+ _E("Invalid parameter");
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
+ }
+
+ new_value = strdup(value);
+ if (new_value == nullptr) {
+ _E("Failed to duplicate value");
+ return RPC_PORT_ERROR_OUT_OF_MEMORY;
+ }
+
+ if (handle->health)
+ free(handle->health);
+
+ handle->health = new_value;
+
+ return RPC_PORT_ERROR_NONE;
+}
+
+int rpc_port_stub_hal_device_battery_stub_1_battery_info_get_health(rpc_port_stub_hal_device_battery_stub_1_battery_info_h handle, char **value)
+{
+ char *new_value;
+ if (handle == nullptr || value == nullptr) {
+ _E("Invalid parameter");
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
+ }
+
+ if (handle->health == nullptr) {
+ _E("health is nullptr");
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
+ }
+
+ new_value = strdup(handle->health);
+ if (new_value == nullptr) {
+ _E("Failed to duplicate value");
+ return RPC_PORT_ERROR_OUT_OF_MEMORY;
+ }
+
+ *value = new_value;
+
+ return RPC_PORT_ERROR_NONE;
+}
+
+int rpc_port_stub_hal_device_battery_stub_1_battery_info_set_power_source(rpc_port_stub_hal_device_battery_stub_1_battery_info_h handle, rpc_port_stub_hal_device_battery_stub_1_enums_power_source_type_e value)
+{
+ if (handle == nullptr) {
+ _E("Invalid parameter");
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
+ }
+
+ handle->power_source = value;
+
+ return RPC_PORT_ERROR_NONE;
+}
+
+int rpc_port_stub_hal_device_battery_stub_1_battery_info_get_power_source(rpc_port_stub_hal_device_battery_stub_1_battery_info_h handle, rpc_port_stub_hal_device_battery_stub_1_enums_power_source_type_e *value)
+{
+ if (handle == nullptr || value == nullptr) {
+ _E("Invalid parameter");
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
+ }
+
+ *value = handle->power_source;
+
+ return RPC_PORT_ERROR_NONE;
+}
+
+int rpc_port_stub_hal_device_battery_stub_1_battery_info_set_online(rpc_port_stub_hal_device_battery_stub_1_battery_info_h handle, int value)
+{
+ if (handle == nullptr) {
+ _E("Invalid parameter");
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
+ }
+
+ handle->online = value;
+
+ return RPC_PORT_ERROR_NONE;
+}
+
+int rpc_port_stub_hal_device_battery_stub_1_battery_info_get_online(rpc_port_stub_hal_device_battery_stub_1_battery_info_h handle, int *value)
+{
+ if (handle == nullptr || value == nullptr) {
+ _E("Invalid parameter");
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
+ }
+
+ *value = handle->online;
+
+ return RPC_PORT_ERROR_NONE;
+}
+
+int rpc_port_stub_hal_device_battery_stub_1_battery_info_set_present(rpc_port_stub_hal_device_battery_stub_1_battery_info_h handle, int value)
+{
+ if (handle == nullptr) {
+ _E("Invalid parameter");
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
+ }
+
+ handle->present = value;
+
+ return RPC_PORT_ERROR_NONE;
+}
+
+int rpc_port_stub_hal_device_battery_stub_1_battery_info_get_present(rpc_port_stub_hal_device_battery_stub_1_battery_info_h handle, int *value)
+{
+ if (handle == nullptr || value == nullptr) {
+ _E("Invalid parameter");
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
+ }
+
+ *value = handle->present;
+
+ return RPC_PORT_ERROR_NONE;
+}
+
+int rpc_port_stub_hal_device_battery_stub_1_battery_info_set_capacity(rpc_port_stub_hal_device_battery_stub_1_battery_info_h handle, int value)
+{
+ if (handle == nullptr) {
+ _E("Invalid parameter");
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
+ }
+
+ handle->capacity = value;
+
+ return RPC_PORT_ERROR_NONE;
+}
+
+int rpc_port_stub_hal_device_battery_stub_1_battery_info_get_capacity(rpc_port_stub_hal_device_battery_stub_1_battery_info_h handle, int *value)
+{
+ if (handle == nullptr || value == nullptr) {
+ _E("Invalid parameter");
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
+ }
+
+ *value = handle->capacity;
+
+ return RPC_PORT_ERROR_NONE;
+}
+
+int rpc_port_stub_hal_device_battery_stub_1_battery_info_set_current_now(rpc_port_stub_hal_device_battery_stub_1_battery_info_h handle, int value)
+{
+ if (handle == nullptr) {
+ _E("Invalid parameter");
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
+ }
+
+ handle->current_now = value;
+
+ return RPC_PORT_ERROR_NONE;
+}
+
+int rpc_port_stub_hal_device_battery_stub_1_battery_info_get_current_now(rpc_port_stub_hal_device_battery_stub_1_battery_info_h handle, int *value)
+{
+ if (handle == nullptr || value == nullptr) {
+ _E("Invalid parameter");
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
+ }
+
+ *value = handle->current_now;
+
+ return RPC_PORT_ERROR_NONE;
+}
+
+int rpc_port_stub_hal_device_battery_stub_1_battery_info_set_current_average(rpc_port_stub_hal_device_battery_stub_1_battery_info_h handle, int value)
+{
+ if (handle == nullptr) {
+ _E("Invalid parameter");
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
+ }
+
+ handle->current_average = value;
+
+ return RPC_PORT_ERROR_NONE;
+}
+
+int rpc_port_stub_hal_device_battery_stub_1_battery_info_get_current_average(rpc_port_stub_hal_device_battery_stub_1_battery_info_h handle, int *value)
+{
+ if (handle == nullptr || value == nullptr) {
+ _E("Invalid parameter");
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
+ }
+
+ *value = handle->current_average;
+
+ return RPC_PORT_ERROR_NONE;
+}
+
+int rpc_port_stub_hal_device_battery_stub_1_battery_info_set_voltage_now(rpc_port_stub_hal_device_battery_stub_1_battery_info_h handle, int value)
+{
+ if (handle == nullptr) {
+ _E("Invalid parameter");
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
+ }
+
+ handle->voltage_now = value;
+
+ return RPC_PORT_ERROR_NONE;
+}
+
+int rpc_port_stub_hal_device_battery_stub_1_battery_info_get_voltage_now(rpc_port_stub_hal_device_battery_stub_1_battery_info_h handle, int *value)
+{
+ if (handle == nullptr || value == nullptr) {
+ _E("Invalid parameter");
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
+ }
+
+ *value = handle->voltage_now;
+
+ return RPC_PORT_ERROR_NONE;
+}
+
+int rpc_port_stub_hal_device_battery_stub_1_battery_info_set_voltage_average(rpc_port_stub_hal_device_battery_stub_1_battery_info_h handle, int value)
+{
+ if (handle == nullptr) {
+ _E("Invalid parameter");
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
+ }
+
+ handle->voltage_average = value;
+
+ return RPC_PORT_ERROR_NONE;
+}
+
+int rpc_port_stub_hal_device_battery_stub_1_battery_info_get_voltage_average(rpc_port_stub_hal_device_battery_stub_1_battery_info_h handle, int *value)
+{
+ if (handle == nullptr || value == nullptr) {
+ _E("Invalid parameter");
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
+ }
+
+ *value = handle->voltage_average;
+
+ return RPC_PORT_ERROR_NONE;
+}
+
+int rpc_port_stub_hal_device_battery_stub_1_battery_info_set_temperature(rpc_port_stub_hal_device_battery_stub_1_battery_info_h handle, int value)
+{
+ if (handle == nullptr) {
+ _E("Invalid parameter");
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
+ }
+
+ handle->temperature = value;
+
+ return RPC_PORT_ERROR_NONE;
+}
+
+int rpc_port_stub_hal_device_battery_stub_1_battery_info_get_temperature(rpc_port_stub_hal_device_battery_stub_1_battery_info_h handle, int *value)
+{
+ if (handle == nullptr || value == nullptr) {
+ _E("Invalid parameter");
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
+ }
+
+ *value = handle->temperature;
+
+ return RPC_PORT_ERROR_NONE;
+}
+
+static void __rpc_port_stub_hal_device_battery_stub_1_remote_exception_to(rpc_port_parcel_h parcel, void *user_data)
+{
+ rpc_port_stub_hal_device_battery_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_battery_stub_1_remote_exception_from(rpc_port_parcel_h parcel, void *user_data)
+{
+ rpc_port_stub_hal_device_battery_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_battery_stub_1_remote_exception_create(rpc_port_stub_hal_device_battery_stub_1_remote_exception_h *h)
+{
+ rpc_port_stub_hal_device_battery_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_battery_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_battery_stub_1_remote_exception_to;
+ exception->parcelable.from = __rpc_port_stub_hal_device_battery_stub_1_remote_exception_from;
+
+ *h = exception;
+
+ return RPC_PORT_ERROR_NONE;
+}
+
+int rpc_port_stub_hal_device_battery_stub_1_remote_exception_set_cause(rpc_port_stub_hal_device_battery_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_battery_stub_1_remote_exception_set_message(rpc_port_stub_hal_device_battery_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_battery_stub_1_remote_exception_get_cause(rpc_port_stub_hal_device_battery_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_battery_stub_1_remote_exception_get_message(rpc_port_stub_hal_device_battery_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_battery_stub_1_remote_exception_destroy(rpc_port_stub_hal_device_battery_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_battery_stub_1_remote_exception_throw(rpc_port_stub_hal_device_battery_stub_1_remote_exception_h h)
+{
+ rpc_port_stub_hal_device_battery_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_battery_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_battery_stub_1_remote_exception != nullptr) {
+ rpc_port_stub_hal_device_battery_stub_1_remote_exception_destroy(__rpc_port_stub_hal_device_battery_stub_1_remote_exception);
+ __rpc_port_stub_hal_device_battery_stub_1_remote_exception = nullptr;
+ }
+
+ handle->cause = h->cause;
+ handle->message = h->message ? strdup(h->message) : nullptr;
+ __rpc_port_stub_hal_device_battery_stub_1_remote_exception = handle;
+
+ return ret;
+}
+
+static void __rpc_port_stub_hal_device_battery_stub_1_device_battery_updated_cb_to(rpc_port_parcel_h parcel, void *user_data)
+{
+ rpc_port_stub_hal_device_battery_stub_1_device_battery_updated_cb_h h = user_data;
+
+ if (parcel == nullptr || h == nullptr) {
+ _E("Invalid parameter");
+ set_last_result(RPC_PORT_ERROR_INVALID_PARAMETER);
+ return;
+ }
+
+ rpc_port_parcel_write_int32(parcel, h->id);
+ rpc_port_parcel_write_int32(parcel, h->seq_id);
+ rpc_port_parcel_write_bool(parcel, h->once);
+
+ _I("id(%d), seq_id(%d), once(%s)", h->id, h->seq_id, h->once ? "true" : "false");
+ set_last_result(RPC_PORT_ERROR_NONE);
+}
+
+static void __rpc_port_stub_hal_device_battery_stub_1_device_battery_updated_cb_from(rpc_port_parcel_h parcel, void *user_data)
+{
+ rpc_port_stub_hal_device_battery_stub_1_device_battery_updated_cb_h h = user_data;
+
+ if (parcel == nullptr || h == nullptr) {
+ _E("Invalid parameter");
+ set_last_result(RPC_PORT_ERROR_INVALID_PARAMETER);
+ return;
+ }
+
+ rpc_port_parcel_read_int32(parcel, &h->id);
+ rpc_port_parcel_read_int32(parcel, &h->seq_id);
+ rpc_port_parcel_read_bool(parcel, &h->once);
+
+ _I("id(%d), seq_id(%d), once(%s)", h->id, h->seq_id, h->once ? "true" : "false");
+ set_last_result(RPC_PORT_ERROR_NONE);
+}
+
+int rpc_port_stub_hal_device_battery_stub_1_device_battery_updated_cb_create(rpc_port_stub_hal_device_battery_stub_1_device_battery_updated_cb_h *h)
+{
+ rpc_port_stub_hal_device_battery_stub_1_device_battery_updated_cb_t *handle;
+ static int seq_num;
+
+ if (h == nullptr) {
+ _E("Invalid parameter");
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
+ }
+
+ handle = calloc(1, sizeof(rpc_port_stub_hal_device_battery_stub_1_device_battery_updated_cb_t));
+ if (handle == nullptr) {
+ _E("Out of memory");
+ return RPC_PORT_ERROR_OUT_OF_MEMORY;
+ }
+
+ handle->parcelable.to = __rpc_port_stub_hal_device_battery_stub_1_device_battery_updated_cb_to;
+ handle->parcelable.from = __rpc_port_stub_hal_device_battery_stub_1_device_battery_updated_cb_from;
+ handle->id = RPC_PORT_STUB_HAL_DEVICE_BATTERY_STUB_1_DEVICE_BATTERY_DELEGATE_UPDATED_CB;
+ handle->seq_id = g_atomic_int_add(&seq_num, 1) + 1;
+ handle->once = false;
+ handle->valid = true;
+ _I("id(%d), seq_id(%d)", handle->id, handle->seq_id);
+
+ *h = handle;
+
+ return RPC_PORT_ERROR_NONE;
+}
+
+int rpc_port_stub_hal_device_battery_stub_1_device_battery_updated_cb_destroy(rpc_port_stub_hal_device_battery_stub_1_device_battery_updated_cb_h h)
+{
+ if (h == nullptr) {
+ _E("Invalid parameter");
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
+ }
+
+ _W("id(%d), seq_id(%d), once(%s)", h->id, h->seq_id, h->once ? "true" : "false");
+
+ if (h->lem_instance)
+ free(h->lem_instance);
+
+ free(h);
+
+ return RPC_PORT_ERROR_NONE;
+}
+
+int rpc_port_stub_hal_device_battery_stub_1_device_battery_updated_cb_clone(rpc_port_stub_hal_device_battery_stub_1_device_battery_updated_cb_h h, rpc_port_stub_hal_device_battery_stub_1_device_battery_updated_cb_h *clone)
+{
+ rpc_port_stub_hal_device_battery_stub_1_device_battery_updated_cb_h handle;
+ int ret;
+
+ if (h == nullptr || clone == nullptr) {
+ _E("Invalid parameter");
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
+ }
+
+ ret = rpc_port_stub_hal_device_battery_stub_1_device_battery_updated_cb_create(&handle);
+ if (ret != RPC_PORT_ERROR_NONE) {
+ _E("Failed to create handle. error(%d)", ret);
+ return ret;
+ }
+
+ handle->port = h->port;
+ handle->id = h->id;
+ handle->seq_id = h->seq_id;
+ handle->once = h->once;
+ handle->valid = h->valid;
+ handle->lem_instance = h->lem_instance ? strdup(h->lem_instance) : nullptr;
+
+ *clone = handle;
+ return RPC_PORT_ERROR_NONE;
+}
+
+int rpc_port_stub_hal_device_battery_stub_1_device_battery_updated_cb_get_id(rpc_port_stub_hal_device_battery_stub_1_device_battery_updated_cb_h h, int *id)
+{
+ if (h == nullptr || id == nullptr) {
+ _E("Invalid parameter");
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
+ }
+
+ *id = h->id;
+
+ return RPC_PORT_ERROR_NONE;
+}
+
+int rpc_port_stub_hal_device_battery_stub_1_device_battery_updated_cb_get_seq_id(rpc_port_stub_hal_device_battery_stub_1_device_battery_updated_cb_h h, int *seq_id)
+{
+ if (h == nullptr || seq_id == nullptr) {
+ _E("Invalid parameter");
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
+ }
+
+ *seq_id = h->seq_id;
+
+ return RPC_PORT_ERROR_NONE;
+}
+
+int rpc_port_stub_hal_device_battery_stub_1_device_battery_updated_cb_is_once(rpc_port_stub_hal_device_battery_stub_1_device_battery_updated_cb_h h, bool *once)
+{
+ if (h == nullptr || once == nullptr) {
+ _E("Invalid parameter");
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
+ }
+
+ *once = h->once;
+
+ return RPC_PORT_ERROR_NONE;
+}
+
+int rpc_port_stub_hal_device_battery_stub_1_device_battery_updated_cb_get_tag(rpc_port_stub_hal_device_battery_stub_1_device_battery_updated_cb_h h, char **tag)
+{
+ char *value;
+ char buf[128];
+
+ if (h == nullptr || tag == nullptr) {
+ _E("Invalid parameter");
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
+ }
+
+ snprintf(buf, sizeof(buf), "%d::%d", h->id, h->seq_id);
+ value = strdup(buf);
+ if (value == nullptr) {
+ _E("Out of memory");
+ return RPC_PORT_ERROR_OUT_OF_MEMORY;
+ }
+
+ *tag = value;
+
+ return RPC_PORT_ERROR_NONE;
+}
+
+int rpc_port_stub_hal_device_battery_stub_1_device_battery_updated_cb_set_port(rpc_port_stub_hal_device_battery_stub_1_device_battery_updated_cb_h h, rpc_port_h port)
+{
+ if (h == nullptr || port == nullptr) {
+ _E("Invalid parameter");
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
+ }
+
+ h->port = port;
+
+ return RPC_PORT_ERROR_NONE;
+}
+
+static int rpc_port_stub_hal_device_battery_stub_1_device_battery_updated_cb_set_lem_instance(rpc_port_stub_hal_device_battery_stub_1_device_battery_updated_cb_h h, const char *lem_instance)
+{
+ if (h == nullptr || lem_instance == nullptr) {
+ _E("Invalid parameter");
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
+ }
+
+ if (h->lem_instance)
+ free(h->lem_instance);
+
+ h->lem_instance = strdup(lem_instance);
+ if (h->lem_instance == nullptr) {
+ _E("strdup() is failed");
+ return RPC_PORT_ERROR_OUT_OF_MEMORY;
+ }
+
+ return RPC_PORT_ERROR_NONE;
+}
+
+int rpc_port_stub_hal_device_battery_stub_1_device_battery_updated_cb_invoke(rpc_port_stub_hal_device_battery_stub_1_device_battery_updated_cb_h h, rpc_port_stub_hal_device_battery_stub_1_battery_info_h info)
+{
+ rpc_port_parcel_h parcel_;
+ int ret_;
+ rpc_port_unit_map_h map_;
+ rpc_port_stub_hal_device_battery_stub_1_device_battery_context_h context = nullptr;
+ int method_ = RPC_PORT_STUB_HAL_DEVICE_BATTERY_STUB_1_DEVICE_BATTERY_METHOD_CALLBACK_;
+
+ if (h == nullptr || info == nullptr) {
+ _E("Invalid parameter");
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
+ }
+
+ if (h->lem_instance) {
+ context = __rpc_port_stub_hal_device_battery_stub_1_device_battery_find_context(h->lem_instance);
+ if (context == nullptr) {
+ _E("Not connected");
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
+ }
+ } else {
+ if (h->port == nullptr) {
+ _E("Invalid parameter");
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
+ }
+
+ if (!__rpc_port_stub_hal_device_battery_stub_1_device_battery_exist_callback_port(h->port)) {
+ _E("Not connected");
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
+ }
+ }
+
+ if (h->once && !h->valid) {
+ _E("The delegate handle is already used");
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
+ }
+
+ ret_ = rpc_port_parcel_create(&parcel_);
+ if (ret_ != RPC_PORT_ERROR_NONE) {
+ _E("Failed to create parcel handle. error(%d)", ret_);
+ return ret_;
+ }
+
+ 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_delegate(map_, 819322245 /*delegate*/, (rpc_port_delegate_h)h);
+ rpc_port_unit_map_write_battery_info(map_, 3237038 /*info*/, info);
+
+ rpc_port_parcel_write(parcel_, &map_->parcelable, map_);
+
+ if (context && context->lem_context) {
+ rpc_port_stub_lem_invoke_callback(__device_battery_context, context->lem_context, parcel_);
+ ret_ = RPC_PORT_ERROR_NONE;
+ } else {
+ ret_ = rpc_port_parcel_send(parcel_, h->port);
+ }
+
+ rpc_port_unit_map_destroy(map_);
+ rpc_port_parcel_destroy(parcel_);
+ h->valid = false;
+
+ return ret_;
+}
+
+static int __rpc_port_stub_hal_device_battery_stub_1_device_battery_method_register_changed_event_privilege_checker(rpc_port_stub_hal_device_battery_stub_1_device_battery_context_h h, bool *sync)
+{
+ return RPC_PORT_ERROR_NONE;
+}
+
+static int __rpc_port_stub_hal_device_battery_stub_1_device_battery_method_register_changed_event_handler(rpc_port_h port, rpc_port_parcel_h parcel, rpc_port_unit_map_h map, void *user_data)
+{
+ rpc_port_stub_hal_device_battery_stub_1_device_battery_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_battery_stub_1_device_battery_updated_cb_h cb = nullptr;
+ 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_battery.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_delegate(map, 3167 /*cb*/, (rpc_port_delegate_h *)&cb);
+
+ if (context_->lem_context)
+ rpc_port_stub_hal_device_battery_stub_1_device_battery_updated_cb_set_lem_instance(cb, context_->instance);
+ else
+ rpc_port_stub_hal_device_battery_stub_1_device_battery_updated_cb_set_port(cb, callback_port_);
+
+ if (__rpc_port_stub_hal_device_battery_stub_1_remote_exception != nullptr) {
+ rpc_port_stub_hal_device_battery_stub_1_remote_exception_destroy(__rpc_port_stub_hal_device_battery_stub_1_remote_exception);
+ __rpc_port_stub_hal_device_battery_stub_1_remote_exception = nullptr;
+ }
+
+ if (context_->callback.register_changed_event)
+ res_ = context_->callback.register_changed_event(context_, cb, context_->user_data);
+
+ int method_ = RPC_PORT_STUB_HAL_DEVICE_BATTERY_STUB_1_DEVICE_BATTERY_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_battery_stub_1_remote_exception != nullptr)
+ rpc_port_unit_map_write_remote_exception(map_, -1571313492 /*[REMOTE_EXCEPTION]*/, __rpc_port_stub_hal_device_battery_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_battery_context, context_->lem_context, parcel_);
+ else
+ ret_ = rpc_port_parcel_send(parcel_, port);
+
+ rpc_port_parcel_destroy(parcel_);
+
+out:
+ if (cb)
+ rpc_port_stub_hal_device_battery_stub_1_device_battery_updated_cb_destroy(cb);
+
+ return ret_;
+}
+
+static int __rpc_port_stub_hal_device_battery_stub_1_device_battery_method_unregister_changed_event_privilege_checker(rpc_port_stub_hal_device_battery_stub_1_device_battery_context_h h, bool *sync)
+{
+ return RPC_PORT_ERROR_NONE;
+}
+
+static int __rpc_port_stub_hal_device_battery_stub_1_device_battery_method_unregister_changed_event_handler(rpc_port_h port, rpc_port_parcel_h parcel, rpc_port_unit_map_h map, void *user_data)
+{
+ rpc_port_stub_hal_device_battery_stub_1_device_battery_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_battery_stub_1_device_battery_updated_cb_h cb = nullptr;
+
+ if (context_->lem_context == nullptr) {
+ ret_ = rpc_port_stub_get_port(__device_battery.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_delegate(map, 3167 /*cb*/, (rpc_port_delegate_h *)&cb);
+
+ if (context_->lem_context)
+ rpc_port_stub_hal_device_battery_stub_1_device_battery_updated_cb_set_lem_instance(cb, context_->instance);
+ else
+ rpc_port_stub_hal_device_battery_stub_1_device_battery_updated_cb_set_port(cb, callback_port_);
+
+ if (__rpc_port_stub_hal_device_battery_stub_1_remote_exception != nullptr) {
+ rpc_port_stub_hal_device_battery_stub_1_remote_exception_destroy(__rpc_port_stub_hal_device_battery_stub_1_remote_exception);
+ __rpc_port_stub_hal_device_battery_stub_1_remote_exception = nullptr;
+ }
+
+ if (context_->callback.unregister_changed_event)
+ context_->callback.unregister_changed_event(context_, cb, context_->user_data);
+
+out:
+ if (cb)
+ rpc_port_stub_hal_device_battery_stub_1_device_battery_updated_cb_destroy(cb);
+
+ return ret_;
+}
+
+static int __rpc_port_stub_hal_device_battery_stub_1_device_battery_method_get_current_state_privilege_checker(rpc_port_stub_hal_device_battery_stub_1_device_battery_context_h h, bool *sync)
+{
+ return RPC_PORT_ERROR_NONE;
+}
+
+static int __rpc_port_stub_hal_device_battery_stub_1_device_battery_method_get_current_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_battery_stub_1_device_battery_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_battery_stub_1_battery_info_h info = nullptr;
+ 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_battery.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_battery_stub_1_remote_exception != nullptr) {
+ rpc_port_stub_hal_device_battery_stub_1_remote_exception_destroy(__rpc_port_stub_hal_device_battery_stub_1_remote_exception);
+ __rpc_port_stub_hal_device_battery_stub_1_remote_exception = nullptr;
+ }
+
+ if (context_->callback.get_current_state)
+ res_ = context_->callback.get_current_state(context_, &info, context_->user_data);
+
+ int method_ = RPC_PORT_STUB_HAL_DEVICE_BATTERY_STUB_1_DEVICE_BATTERY_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_battery_info(map_, 3237038 /*info*/, info);
+
+ rpc_port_unit_map_write_int(map_, 1497479973 /*[RESULT]*/, &res_);
+
+ if (__rpc_port_stub_hal_device_battery_stub_1_remote_exception != nullptr)
+ rpc_port_unit_map_write_remote_exception(map_, -1571313492 /*[REMOTE_EXCEPTION]*/, __rpc_port_stub_hal_device_battery_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_battery_context, context_->lem_context, parcel_);
+ else
+ ret_ = rpc_port_parcel_send(parcel_, port);
+
+ rpc_port_parcel_destroy(parcel_);
+
+out:
+ if (info)
+ rpc_port_stub_hal_device_battery_stub_1_battery_info_destroy(info);
+
+ return ret_;
+}
+
+static rpc_port_stub_hal_device_battery_stub_1_device_battery_privilege_checker __device_battery_privilege_checkers[] = {
+ [RPC_PORT_STUB_HAL_DEVICE_BATTERY_STUB_1_DEVICE_BATTERY_METHOD_REGISTER_CHANGED_EVENT] = __rpc_port_stub_hal_device_battery_stub_1_device_battery_method_register_changed_event_privilege_checker,
+ [RPC_PORT_STUB_HAL_DEVICE_BATTERY_STUB_1_DEVICE_BATTERY_METHOD_UNREGISTER_CHANGED_EVENT] = __rpc_port_stub_hal_device_battery_stub_1_device_battery_method_unregister_changed_event_privilege_checker,
+ [RPC_PORT_STUB_HAL_DEVICE_BATTERY_STUB_1_DEVICE_BATTERY_METHOD_GET_CURRENT_STATE] = __rpc_port_stub_hal_device_battery_stub_1_device_battery_method_get_current_state_privilege_checker,
+};
+
+static rpc_port_stub_method_handler __device_battery_method_table[] = {
+ [RPC_PORT_STUB_HAL_DEVICE_BATTERY_STUB_1_DEVICE_BATTERY_METHOD_REGISTER_CHANGED_EVENT] = __rpc_port_stub_hal_device_battery_stub_1_device_battery_method_register_changed_event_handler,
+ [RPC_PORT_STUB_HAL_DEVICE_BATTERY_STUB_1_DEVICE_BATTERY_METHOD_UNREGISTER_CHANGED_EVENT] = __rpc_port_stub_hal_device_battery_stub_1_device_battery_method_unregister_changed_event_handler,
+ [RPC_PORT_STUB_HAL_DEVICE_BATTERY_STUB_1_DEVICE_BATTERY_METHOD_GET_CURRENT_STATE] = __rpc_port_stub_hal_device_battery_stub_1_device_battery_method_get_current_state_handler,
+};
+
+static void __rpc_port_stub_hal_device_battery_stub_1_device_battery_throw_remote_exception(rpc_port_h port, rpc_port_parcel_h parcel, int cause, const char *message)
+{
+ rpc_port_stub_hal_device_battery_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_BATTERY_STUB_1_DEVICE_BATTERY_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_battery_stub_1_remote_exception_create(&remote_exception);
+ rpc_port_stub_hal_device_battery_stub_1_remote_exception_set_cause(remote_exception, cause);
+ rpc_port_stub_hal_device_battery_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_battery_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_battery_stub_1_device_battery_context_handle_request(rpc_port_stub_hal_device_battery_stub_1_device_battery_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_battery_method_table)) {
+ if (h->lem_context == nullptr && h->app_info && __device_battery_privilege_checkers[cmd]) {
+ ret = __device_battery_privilege_checkers[cmd](h, &sync);
+ if (ret != RPC_PORT_ERROR_NONE) {
+ rpc_port_unit_map_destroy(map);
+ if (sync)
+ __rpc_port_stub_hal_device_battery_stub_1_device_battery_throw_remote_exception(h->port, parcel, ret, "Permission denied");
+
+ return ret;
+ }
+ }
+
+ if (__device_battery_method_table[cmd])
+ ret = __device_battery_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_battery_stub_1_device_battery_context_push(rpc_port_stub_hal_device_battery_stub_1_device_battery_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_battery_stub_1_device_battery_context_wait_and_pop(rpc_port_stub_hal_device_battery_stub_1_device_battery_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_battery_stub_1_device_battery_context_thread_cb(gpointer user_data)
+{
+ rpc_port_stub_hal_device_battery_stub_1_device_battery_context_h h = user_data;
+ rpc_port_parcel_h parcel;
+
+ _W("START");
+ while (!h->done) {
+ parcel = __rpc_port_stub_hal_device_battery_stub_1_device_battery_context_wait_and_pop(h);
+ if (parcel) {
+ __rpc_port_stub_hal_device_battery_stub_1_device_battery_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_battery_stub_1_device_battery_context_destroy(gpointer data)
+{
+ rpc_port_stub_hal_device_battery_stub_1_device_battery_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_battery_stub_1_device_battery_context_privilege_info_cb(const char *privilege_name, void *user_data)
+{
+ rpc_port_stub_hal_device_battery_stub_1_device_battery_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_battery_stub_1_device_battery_context_load_privileges(rpc_port_stub_hal_device_battery_stub_1_device_battery_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_battery_stub_1_device_battery_context_privilege_info_cb, h);
+ package_info_destroy(package_info);
+
+ return ret;
+}
+
+static rpc_port_stub_hal_device_battery_stub_1_device_battery_context_h __rpc_port_stub_hal_device_battery_stub_1_device_battery_context_create(const char *sender, const char *instance, rpc_port_h callback_port, void *lem_context)
+{
+ rpc_port_stub_hal_device_battery_stub_1_device_battery_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_battery_stub_1_device_battery_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_battery_stub_1_device_battery_context_destroy(handle);
+ return nullptr;
+ }
+
+ handle->instance = strdup(instance);
+ if (handle->instance == nullptr) {
+ _E("Failed to duplicate instance");
+ __rpc_port_stub_hal_device_battery_stub_1_device_battery_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_battery_stub_1_device_battery_context_destroy(handle);
+ return nullptr;
+ }
+
+ if (__rpc_port_stub_hal_device_battery_stub_1_device_battery_context_load_privileges(handle) != 0) {
+ __rpc_port_stub_hal_device_battery_stub_1_device_battery_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_battery_stub_1_device_battery_context_destroy(handle);
+ return nullptr;
+ }
+
+ handle->thread = g_thread_new(instance, __rpc_port_stub_hal_device_battery_stub_1_device_battery_context_thread_cb, handle);
+ if (handle->thread == nullptr) {
+ _E("Failed to create thread");
+ __rpc_port_stub_hal_device_battery_stub_1_device_battery_context_destroy(handle);
+ return nullptr;
+ }
+#endif /* TIDL_THREAD_ENABLE */
+
+ handle->lem_context = lem_context;
+ handle->callback_port = callback_port;
+ handle->callback = __device_battery.callback;
+ handle->user_data = __device_battery.user_data;
+
+ return handle;
+}
+
+static rpc_port_stub_hal_device_battery_stub_1_device_battery_context_h __rpc_port_stub_hal_device_battery_stub_1_device_battery_find_context(const char *instance)
+{
+ rpc_port_stub_hal_device_battery_stub_1_device_battery_context_h context;
+ GList *iter;
+
+ g_rec_mutex_lock(&__device_battery.mutex);
+ iter = __device_battery.contexts;
+ while (iter) {
+ context = iter->data;
+ if (!strcmp(context->instance, instance)) {
+ g_rec_mutex_unlock(&__device_battery.mutex);
+ return context;
+ }
+
+ iter = g_list_next(iter);
+ }
+ g_rec_mutex_unlock(&__device_battery.mutex);
+
+ return nullptr;
+}
+
+static void __rpc_port_stub_hal_device_battery_stub_1_device_battery_add_context(rpc_port_stub_hal_device_battery_stub_1_device_battery_context_h context)
+{
+ g_rec_mutex_lock(&__device_battery.mutex);
+ __device_battery.contexts = g_list_append(__device_battery.contexts, context);
+ g_rec_mutex_unlock(&__device_battery.mutex);
+}
+
+static void __rpc_port_stub_hal_device_battery_stub_1_device_battery_remove_context(rpc_port_stub_hal_device_battery_stub_1_device_battery_context_h context)
+{
+ g_rec_mutex_lock(&__device_battery.mutex);
+ __device_battery.contexts = g_list_remove(__device_battery.contexts, context);
+ g_rec_mutex_unlock(&__device_battery.mutex);
+}
+
+static void __rpc_port_stub_hal_device_battery_stub_1_device_battery_clear_context(gpointer data)
+{
+ rpc_port_stub_hal_device_battery_stub_1_device_battery_context_h context = data;
+
+ if (context->lem_context) {
+ _W("[LEM] disconnect %s:device_battery", __stub_appid);
+ rpc_port_stub_lem_disconnect(__device_battery_context, context->lem_context);
+ __rpc_port_stub_hal_device_battery_stub_1_device_battery_remove_context(context);
+ }
+ __rpc_port_stub_hal_device_battery_stub_1_device_battery_context_destroy(context);
+}
+
+int rpc_port_stub_hal_device_battery_stub_1_device_battery_context_set_tag(rpc_port_stub_hal_device_battery_stub_1_device_battery_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_battery_stub_1_device_battery_context_get_tag(rpc_port_stub_hal_device_battery_stub_1_device_battery_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_battery_stub_1_device_battery_context_get_sender(rpc_port_stub_hal_device_battery_stub_1_device_battery_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_battery_stub_1_device_battery_context_get_instance(rpc_port_stub_hal_device_battery_stub_1_device_battery_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_battery_stub_1_device_battery_context_disconnect(rpc_port_stub_hal_device_battery_stub_1_device_battery_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_battery.mutex);
+
+ if (context->lem_context) {
+ _W("[LEM] disconnect %s:device_battery", __stub_appid);
+ rpc_port_stub_lem_disconnect(__device_battery_context, context->lem_context);
+ __rpc_port_stub_hal_device_battery_stub_1_device_battery_remove_context(context);
+ __rpc_port_stub_hal_device_battery_stub_1_device_battery_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_battery.mutex);
+
+ return ret;
+}
+
+static bool __rpc_port_stub_hal_device_battery_stub_1_device_battery_exist_callback_port(rpc_port_h callback_port)
+{
+ rpc_port_h port;
+ GList *iter;
+
+ g_rec_mutex_lock(&__device_battery.mutex);
+ iter = __device_battery.callback_ports;
+ while (iter) {
+ port = iter->data;
+ if (port == callback_port) {
+ g_rec_mutex_unlock(&__device_battery.mutex);
+ return true;
+ }
+
+ iter = g_list_next(iter);
+ }
+ g_rec_mutex_unlock(&__device_battery.mutex);
+
+ return false;
+}
+
+static void __rpc_port_stub_hal_device_battery_stub_1_device_battery_add_callback_port(rpc_port_h callback_port)
+{
+ g_rec_mutex_lock(&__device_battery.mutex);
+ __device_battery.callback_ports = g_list_append(__device_battery.callback_ports, callback_port);
+ g_rec_mutex_unlock(&__device_battery.mutex);
+}
+
+static void __rpc_port_stub_hal_device_battery_stub_1_device_battery_remove_callback_port(rpc_port_h callback_port)
+{
+ g_rec_mutex_lock(&__device_battery.mutex);
+ __device_battery.callback_ports = g_list_remove(__device_battery.callback_ports, callback_port);
+ g_rec_mutex_unlock(&__device_battery.mutex);
+}
+
+static void __rpc_port_stub_hal_device_battery_stub_1_device_battery_connected_event_cb(const char *sender, const char *instance, void *user_data)
+{
+ rpc_port_stub_hal_device_battery_stub_1_device_battery_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_battery.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_battery_stub_1_device_battery_context_create(sender, instance, callback_port, nullptr);
+ if (context == nullptr)
+ return;
+
+ __rpc_port_stub_hal_device_battery_stub_1_device_battery_add_context(context);
+ __rpc_port_stub_hal_device_battery_stub_1_device_battery_add_callback_port(context->callback_port);
+ context->callback.create(context, context->user_data);
+}
+
+static void __rpc_port_stub_hal_device_battery_stub_1_device_battery_disconnected_event_cb(const char *sender, const char *instance, void *user_data)
+{
+ rpc_port_stub_hal_device_battery_stub_1_device_battery_context_h context;
+
+ _W("sender(%s), instance(%s)", sender, instance);
+ context = __rpc_port_stub_hal_device_battery_stub_1_device_battery_find_context(instance);
+ if (context == nullptr)
+ return;
+
+ __rpc_port_stub_hal_device_battery_stub_1_device_battery_remove_callback_port(context->callback_port);
+ context->callback.terminate(context, context->user_data);
+ __rpc_port_stub_hal_device_battery_stub_1_device_battery_remove_context(context);
+ __rpc_port_stub_hal_device_battery_stub_1_device_battery_context_destroy(context);
+}
+
+static int __rpc_port_stub_hal_device_battery_stub_1_device_battery_received_event_cb(const char *sender, const char *instance, rpc_port_h port, void *user_data)
+{
+ rpc_port_stub_hal_device_battery_stub_1_device_battery_context_h context;
+ rpc_port_parcel_h parcel;
+ int ret;
+
+ _W("sender(%s), instance(%s)", sender, instance);
+ context = __rpc_port_stub_hal_device_battery_stub_1_device_battery_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_battery_stub_1_device_battery_context_push(context, parcel);
+#else
+ ret = __rpc_port_stub_hal_device_battery_stub_1_device_battery_context_handle_request(context, parcel);
+ rpc_port_parcel_destroy(parcel);
+#endif /* TIDL_THREAD_ENABLE */
+
+ return ret;
+}
+
+static int __rpc_port_stub_hal_device_battery_stub_1_device_battery_set_access_control(void)
+{
+ int ret = RPC_PORT_ERROR_NONE;
+
+ return ret;
+}
+
+static void __rpc_port_stub_device_battery_lem_connected_cb(void *lem_context, const char *sender, const char* instance, bool sync)
+{
+ rpc_port_stub_hal_device_battery_stub_1_device_battery_context_h context;
+
+ _W("[LEM] sender(%s), instance(%s)", sender, instance);
+ context = __rpc_port_stub_hal_device_battery_stub_1_device_battery_context_create(sender, instance, nullptr, lem_context);
+ if (context == nullptr)
+ return;
+
+ __rpc_port_stub_hal_device_battery_stub_1_device_battery_add_context(context);
+ context->callback.create(context, context->user_data);
+
+ rpc_port_stub_lem_connect(__device_battery_context, lem_context, sync);
+}
+
+static void __rpc_port_stub_device_battery_lem_disconnected_cb(void *lem_context, const char *sender, const char *instance)
+{
+ rpc_port_stub_hal_device_battery_stub_1_device_battery_context_h context;
+
+ _W("[LEM] sender(%s), instance(%s)", sender, instance);
+ context = __rpc_port_stub_hal_device_battery_stub_1_device_battery_find_context(instance);
+ if (context == nullptr)
+ return;
+
+ __rpc_port_stub_hal_device_battery_stub_1_device_battery_remove_callback_port(context->callback_port);
+ context->callback.terminate(context, context->user_data);
+ __rpc_port_stub_hal_device_battery_stub_1_device_battery_remove_context(context);
+ __rpc_port_stub_hal_device_battery_stub_1_device_battery_context_destroy(context);
+
+ rpc_port_stub_lem_disconnect(__device_battery_context, lem_context);
+}
+
+static void __rpc_port_stub_device_battery_lem_received_cb(void *lem_context, const char *sender, const char *instance, rpc_port_parcel_h parcel)
+{
+ rpc_port_stub_hal_device_battery_stub_1_device_battery_context_h context;
+
+ _W("[LEM] sender(%s), instance(%s)", sender, instance);
+ context = __rpc_port_stub_hal_device_battery_stub_1_device_battery_find_context(instance);
+ if (context == nullptr) {
+ _E("Failed to find context. instance(%s)", instance);
+ return;
+ }
+
+ __rpc_port_stub_hal_device_battery_stub_1_device_battery_context_handle_request(context, parcel);
+}
+
+int rpc_port_stub_hal_device_battery_stub_1_device_battery_register(rpc_port_stub_hal_device_battery_stub_1_device_battery_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_battery.stub) {
+ _E("Already exists");
+ return RPC_PORT_ERROR_NONE;
+ }
+
+ rpc_port_internal_init();
+
+ g_rec_mutex_init(&__device_battery.mutex);
+ __device_battery.callback = *callback;
+ __device_battery.user_data = user_data;
+
+ ret = rpc_port_stub_create(&__device_battery.stub, "device_battery");
+ if (ret != RPC_PORT_ERROR_NONE) {
+ _E("Failed to create stub handle. error(%d)", ret);
+ g_rec_mutex_clear(&__device_battery.mutex);
+ return ret;
+ }
+
+ ret = rpc_port_stub_add_received_event_cb(__device_battery.stub, __rpc_port_stub_hal_device_battery_stub_1_device_battery_received_event_cb, &__device_battery);
+ if (ret != RPC_PORT_ERROR_NONE) {
+ _E("Failed to add received event callback");
+ rpc_port_stub_hal_device_battery_stub_1_device_battery_unregister();
+ return ret;
+ }
+
+ ret = rpc_port_stub_add_connected_event_cb(__device_battery.stub, __rpc_port_stub_hal_device_battery_stub_1_device_battery_connected_event_cb, &__device_battery);
+ if (ret != RPC_PORT_ERROR_NONE) {
+ _E("Failed to add connected event callback");
+ rpc_port_stub_hal_device_battery_stub_1_device_battery_unregister();
+ return ret;
+ }
+
+ ret = rpc_port_stub_add_disconnected_event_cb(__device_battery.stub, __rpc_port_stub_hal_device_battery_stub_1_device_battery_disconnected_event_cb, &__device_battery);
+ if (ret != RPC_PORT_ERROR_NONE) {
+ _E("Failed to add disconnected event callback");
+ rpc_port_stub_hal_device_battery_stub_1_device_battery_unregister();
+ return ret;
+ }
+
+ ret = __rpc_port_stub_hal_device_battery_stub_1_device_battery_set_access_control();
+ if (ret != RPC_PORT_ERROR_NONE) {
+ _E("Failed to add privileges");
+ rpc_port_stub_hal_device_battery_stub_1_device_battery_unregister();
+ return ret;
+ }
+
+ ret = rpc_port_stub_listen(__device_battery.stub);
+ if (ret != RPC_PORT_ERROR_NONE) {
+ _E("Failed to listen events. error(%d)", ret);
+ rpc_port_stub_hal_device_battery_stub_1_device_battery_unregister();
+ return ret;
+ }
+
+ lem_callback.connected = __rpc_port_stub_device_battery_lem_connected_cb;
+ lem_callback.disconnected = __rpc_port_stub_device_battery_lem_disconnected_cb;
+ lem_callback.received = __rpc_port_stub_device_battery_lem_received_cb;
+
+ __device_battery_context = rpc_port_stub_lem_create("device_battery", &lem_callback);
+ if (__device_battery_context == nullptr) {
+ _E("Failed to create lem context");
+ rpc_port_stub_hal_device_battery_stub_1_device_battery_unregister();
+ return RPC_PORT_ERROR_OUT_OF_MEMORY;
+ }
+
+ rpc_port_stub_lem_set_listening(__device_battery_context, true);
+
+ return RPC_PORT_ERROR_NONE;
+}
+
+int rpc_port_stub_hal_device_battery_stub_1_device_battery_unregister(void)
+{
+ if (__device_battery.stub == nullptr)
+ return RPC_PORT_ERROR_NONE;
+
+ g_rec_mutex_lock(&__device_battery.mutex);
+ g_rec_mutex_unlock(&__device_battery.mutex);
+ g_rec_mutex_clear(&__device_battery.mutex);
+
+ rpc_port_stub_lem_set_listening(__device_battery_context, false);
+
+ if (__device_battery.contexts) {
+ g_list_free_full(__device_battery.contexts, __rpc_port_stub_hal_device_battery_stub_1_device_battery_clear_context);
+ __device_battery.contexts = nullptr;
+ }
+
+ if (__device_battery.stub) {
+ rpc_port_stub_destroy(__device_battery.stub);
+ __device_battery.stub = nullptr;
+ }
+
+ if (__device_battery_context) {
+ rpc_port_stub_lem_destroy(__device_battery_context);
+ __device_battery_context = nullptr;
+ }
+
+ return RPC_PORT_ERROR_NONE;
+}
+
+int rpc_port_stub_hal_device_battery_stub_1_device_battery_foreach_context(rpc_port_stub_hal_device_battery_stub_1_device_battery_context_cb callback, void *user_data)
+{
+ rpc_port_stub_hal_device_battery_stub_1_device_battery_context_h context;
+ GList *iter;
+
+ if (callback == nullptr) {
+ _E("Invalid parameter");
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
+ }
+
+ g_rec_mutex_lock(&__device_battery.mutex);
+ iter = __device_battery.contexts;
+ while (iter) {
+ context = iter->data;
+ if (!callback(context, user_data))
+ break;
+
+ iter = g_list_next(iter);
+ }
+ g_rec_mutex_unlock(&__device_battery.mutex);
+
+ return RPC_PORT_ERROR_NONE;
+}
+
+int rpc_port_stub_hal_device_battery_stub_1_device_battery_get_client_number(unsigned int *client_number)
+{
+ if (client_number == nullptr) {
+ _E("Invalid parameter");
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
+ }
+
+ if (__device_battery.stub == nullptr) {
+ _E("Invalid context");
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
+ }
+
+ g_rec_mutex_lock(&__device_battery.mutex);
+ *client_number = g_list_length(__device_battery.contexts);
+ g_rec_mutex_unlock(&__device_battery.mutex);
+
+ return RPC_PORT_ERROR_NONE;
+}
+
+EXPORT_API int rpc_port_stub_hal_device_battery_ipc_1_lem_device_battery_connect(void *context, const char *sender, const char *instance, bool sync)
+{
+ rpc_port_stub_lem_h handle = __device_battery_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_battery_ipc_1_lem_device_battery_disconnect(void *context, const char *sender, const char *instance)
+{
+ rpc_port_stub_lem_h handle = __device_battery_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_battery_ipc_1_lem_device_battery_send(void *context, const char* sender, const char *instance, rpc_port_parcel_h parcel)
+{
+ rpc_port_stub_lem_h handle = __device_battery_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.0.
+ */
+
+#pragma once
+
+#include <stdbool.h>
+#include <bundle.h>
+#include <rpc-port.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * @brief The rpc_port_stub_hal_device_battery_stub_1_enums_power_source_type enum.
+ */
+typedef enum {
+ RPC_PORT_STUB_HAL_DEVICE_BATTERY_STUB_1_POWER_SOURCE_TYPE_ENUMS_POWER_SOURCE_NONE = 0,
+ RPC_PORT_STUB_HAL_DEVICE_BATTERY_STUB_1_POWER_SOURCE_TYPE_ENUMS_POWER_SOURCE_AC,
+ RPC_PORT_STUB_HAL_DEVICE_BATTERY_STUB_1_POWER_SOURCE_TYPE_ENUMS_POWER_SOURCE_USB,
+ RPC_PORT_STUB_HAL_DEVICE_BATTERY_STUB_1_POWER_SOURCE_TYPE_ENUMS_POWER_SOURCE_WIRELESS,
+} rpc_port_stub_hal_device_battery_stub_1_enums_power_source_type_e;
+
+/**
+ * @brief The rpc_port_stub_hal_device_battery_stub_1_enums handle.
+ */
+typedef struct rpc_port_stub_hal_device_battery_stub_1_enums_s *rpc_port_stub_hal_device_battery_stub_1_enums_h;
+
+/**
+ * @brief The rpc_port_stub_hal_device_battery_stub_1_battery_info handle.
+ */
+typedef struct rpc_port_stub_hal_device_battery_stub_1_battery_info_s *rpc_port_stub_hal_device_battery_stub_1_battery_info_h;
+
+/**
+ * @breif The rpc_port_stub_hal_device_battery_stub_1 remote exception handle.
+ */
+typedef struct rpc_port_stub_hal_device_battery_stub_1_remote_exception_s *rpc_port_stub_hal_device_battery_stub_1_remote_exception_h;
+
+/**
+ * @brief The rpc_port_stub_hal_device_battery_stub_1_device_battery_context handle.
+ */
+typedef struct rpc_port_stub_hal_device_battery_stub_1_device_battery_context_s *rpc_port_stub_hal_device_battery_stub_1_device_battery_context_h;
+
+/**
+ * @brief The rpc_port_stub_hal_device_battery_stub_1_device_battery_updated_cb handle.
+ */
+typedef struct rpc_port_stub_hal_device_battery_stub_1_device_battery_updated_cb_s *rpc_port_stub_hal_device_battery_stub_1_device_battery_updated_cb_h;
+
+/**
+ * @brief Creates a rpc_port_stub_hal_device_battery_stub_1_enums handle.
+ *
+ * @remarks The @a h handle should be released using the rpc_port_stub_hal_device_battery_stub_1_enums_destroy()
+ * if it's no longer needed.
+ * @param[out] h The rpc_port_stub_hal_device_battery_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_battery_stub_1_enums_destroy()
+ */
+int rpc_port_stub_hal_device_battery_stub_1_enums_create(rpc_port_stub_hal_device_battery_stub_1_enums_h *h);
+
+/**
+ * @brief Destroys the rpc_port_stub_hal_device_battery_stub_1_enums handle.
+ *
+ * @param[in] h The rpc_port_stub_hal_device_battery_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_battery_stub_1_enums_create()
+ */
+int rpc_port_stub_hal_device_battery_stub_1_enums_destroy(rpc_port_stub_hal_device_battery_stub_1_enums_h h);
+
+/**
+ * @brief Creates and returns a copy of the given rpc_port_stub_hal_device_battery_stub_1_enums handle.
+ *
+ * @remarks A new created rpc_port_stub_hal_device_battery_stub_1_enums should be released using
+ * the rpc_port_stub_hal_device_battery_stub_1_enums_destroy() if it's no longer needed.
+ * @param[in] h The rpc_port_stub_hal_device_battery_stub_1_enums handle
+ * @param[out] clone If successful, a new created rpc_port_stub_hal_device_battery_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_battery_stub_1_enums_destroy()
+ */
+int rpc_port_stub_hal_device_battery_stub_1_enums_clone(rpc_port_stub_hal_device_battery_stub_1_enums_h h, rpc_port_stub_hal_device_battery_stub_1_enums_h *clone);
+
+/**
+ * @brief Creates a rpc_port_stub_hal_device_battery_stub_1_battery_info handle.
+ *
+ * @remarks The @a h handle should be released using the rpc_port_stub_hal_device_battery_stub_1_battery_info_destroy()
+ * if it's no longer needed.
+ * @param[out] h The rpc_port_stub_hal_device_battery_stub_1_battery_info 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_battery_stub_1_battery_info_destroy()
+ */
+int rpc_port_stub_hal_device_battery_stub_1_battery_info_create(rpc_port_stub_hal_device_battery_stub_1_battery_info_h *h);
+
+/**
+ * @brief Destroys the rpc_port_stub_hal_device_battery_stub_1_battery_info handle.
+ *
+ * @param[in] h The rpc_port_stub_hal_device_battery_stub_1_battery_info 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_battery_stub_1_battery_info_create()
+ */
+int rpc_port_stub_hal_device_battery_stub_1_battery_info_destroy(rpc_port_stub_hal_device_battery_stub_1_battery_info_h h);
+
+/**
+ * @brief Creates and returns a copy of the given rpc_port_stub_hal_device_battery_stub_1_battery_info handle.
+ *
+ * @remarks A new created rpc_port_stub_hal_device_battery_stub_1_battery_info should be released using
+ * the rpc_port_stub_hal_device_battery_stub_1_battery_info_destroy() if it's no longer needed.
+ * @param[in] h The rpc_port_stub_hal_device_battery_stub_1_battery_info handle
+ * @param[out] clone If successful, a new created rpc_port_stub_hal_device_battery_stub_1_battery_info 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_battery_stub_1_battery_info_destroy()
+ */
+int rpc_port_stub_hal_device_battery_stub_1_battery_info_clone(rpc_port_stub_hal_device_battery_stub_1_battery_info_h h, rpc_port_stub_hal_device_battery_stub_1_battery_info_h *clone);
+
+/**
+ * @brief Sets the name to the rpc_port_stub_hal_device_battery_stub_1_battery_info handle.
+ *
+ * @remarks The name is internally copied and stored.
+ * You should release it if it's allocated when it's no longer needed.
+ * @param[in] h The rpc_port_stub_hal_device_battery_stub_1_battery_info handle
+ * @param[in] value The name
+ * @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_battery_stub_1_battery_info_get_name()
+ */
+int rpc_port_stub_hal_device_battery_stub_1_battery_info_set_name(rpc_port_stub_hal_device_battery_stub_1_battery_info_h h, const char *value);
+
+/**
+ * @brief Gets the name from the rpc_port_stub_hal_device_battery_stub_1_battery_info handle.
+ *
+ * @remarks A new created value should be released if it's allocated when it's no longer needed.
+ * @param[in] h The rpc_port_stub_hal_device_battery_stub_1_battery_info handle
+ * @param[out] value The name
+ * @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_battery_stub_1_battery_info_set_name
+ */
+int rpc_port_stub_hal_device_battery_stub_1_battery_info_get_name(rpc_port_stub_hal_device_battery_stub_1_battery_info_h h, char **value);
+
+/**
+ * @brief Sets the status to the rpc_port_stub_hal_device_battery_stub_1_battery_info handle.
+ *
+ * @remarks The status is internally copied and stored.
+ * You should release it if it's allocated when it's no longer needed.
+ * @param[in] h The rpc_port_stub_hal_device_battery_stub_1_battery_info handle
+ * @param[in] value The status
+ * @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_battery_stub_1_battery_info_get_status()
+ */
+int rpc_port_stub_hal_device_battery_stub_1_battery_info_set_status(rpc_port_stub_hal_device_battery_stub_1_battery_info_h h, const char *value);
+
+/**
+ * @brief Gets the status from the rpc_port_stub_hal_device_battery_stub_1_battery_info handle.
+ *
+ * @remarks A new created value should be released if it's allocated when it's no longer needed.
+ * @param[in] h The rpc_port_stub_hal_device_battery_stub_1_battery_info handle
+ * @param[out] value The status
+ * @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_battery_stub_1_battery_info_set_status
+ */
+int rpc_port_stub_hal_device_battery_stub_1_battery_info_get_status(rpc_port_stub_hal_device_battery_stub_1_battery_info_h h, char **value);
+
+/**
+ * @brief Sets the health to the rpc_port_stub_hal_device_battery_stub_1_battery_info handle.
+ *
+ * @remarks The health is internally copied and stored.
+ * You should release it if it's allocated when it's no longer needed.
+ * @param[in] h The rpc_port_stub_hal_device_battery_stub_1_battery_info handle
+ * @param[in] value The health
+ * @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_battery_stub_1_battery_info_get_health()
+ */
+int rpc_port_stub_hal_device_battery_stub_1_battery_info_set_health(rpc_port_stub_hal_device_battery_stub_1_battery_info_h h, const char *value);
+
+/**
+ * @brief Gets the health from the rpc_port_stub_hal_device_battery_stub_1_battery_info handle.
+ *
+ * @remarks A new created value should be released if it's allocated when it's no longer needed.
+ * @param[in] h The rpc_port_stub_hal_device_battery_stub_1_battery_info handle
+ * @param[out] value The health
+ * @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_battery_stub_1_battery_info_set_health
+ */
+int rpc_port_stub_hal_device_battery_stub_1_battery_info_get_health(rpc_port_stub_hal_device_battery_stub_1_battery_info_h h, char **value);
+
+/**
+ * @brief Sets the power_source to the rpc_port_stub_hal_device_battery_stub_1_battery_info handle.
+ *
+ * @remarks The power_source is internally copied and stored.
+ * You should release it if it's allocated when it's no longer needed.
+ * @param[in] h The rpc_port_stub_hal_device_battery_stub_1_battery_info handle
+ * @param[in] value The power_source
+ * @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_battery_stub_1_battery_info_get_power_source()
+ */
+int rpc_port_stub_hal_device_battery_stub_1_battery_info_set_power_source(rpc_port_stub_hal_device_battery_stub_1_battery_info_h h, rpc_port_stub_hal_device_battery_stub_1_enums_power_source_type_e value);
+
+/**
+ * @brief Gets the power_source from the rpc_port_stub_hal_device_battery_stub_1_battery_info handle.
+ *
+ * @remarks A new created value should be released if it's allocated when it's no longer needed.
+ * @param[in] h The rpc_port_stub_hal_device_battery_stub_1_battery_info handle
+ * @param[out] value The power_source
+ * @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_battery_stub_1_battery_info_set_power_source
+ */
+int rpc_port_stub_hal_device_battery_stub_1_battery_info_get_power_source(rpc_port_stub_hal_device_battery_stub_1_battery_info_h h, rpc_port_stub_hal_device_battery_stub_1_enums_power_source_type_e *value);
+
+/**
+ * @brief Sets the online to the rpc_port_stub_hal_device_battery_stub_1_battery_info handle.
+ *
+ * @remarks The online is internally copied and stored.
+ * You should release it if it's allocated when it's no longer needed.
+ * @param[in] h The rpc_port_stub_hal_device_battery_stub_1_battery_info handle
+ * @param[in] value The online
+ * @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_battery_stub_1_battery_info_get_online()
+ */
+int rpc_port_stub_hal_device_battery_stub_1_battery_info_set_online(rpc_port_stub_hal_device_battery_stub_1_battery_info_h h, int value);
+
+/**
+ * @brief Gets the online from the rpc_port_stub_hal_device_battery_stub_1_battery_info handle.
+ *
+ * @remarks A new created value should be released if it's allocated when it's no longer needed.
+ * @param[in] h The rpc_port_stub_hal_device_battery_stub_1_battery_info handle
+ * @param[out] value The online
+ * @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_battery_stub_1_battery_info_set_online
+ */
+int rpc_port_stub_hal_device_battery_stub_1_battery_info_get_online(rpc_port_stub_hal_device_battery_stub_1_battery_info_h h, int *value);
+
+/**
+ * @brief Sets the present to the rpc_port_stub_hal_device_battery_stub_1_battery_info handle.
+ *
+ * @remarks The present is internally copied and stored.
+ * You should release it if it's allocated when it's no longer needed.
+ * @param[in] h The rpc_port_stub_hal_device_battery_stub_1_battery_info handle
+ * @param[in] value The present
+ * @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_battery_stub_1_battery_info_get_present()
+ */
+int rpc_port_stub_hal_device_battery_stub_1_battery_info_set_present(rpc_port_stub_hal_device_battery_stub_1_battery_info_h h, int value);
+
+/**
+ * @brief Gets the present from the rpc_port_stub_hal_device_battery_stub_1_battery_info handle.
+ *
+ * @remarks A new created value should be released if it's allocated when it's no longer needed.
+ * @param[in] h The rpc_port_stub_hal_device_battery_stub_1_battery_info handle
+ * @param[out] value The present
+ * @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_battery_stub_1_battery_info_set_present
+ */
+int rpc_port_stub_hal_device_battery_stub_1_battery_info_get_present(rpc_port_stub_hal_device_battery_stub_1_battery_info_h h, int *value);
+
+/**
+ * @brief Sets the capacity to the rpc_port_stub_hal_device_battery_stub_1_battery_info handle.
+ *
+ * @remarks The capacity is internally copied and stored.
+ * You should release it if it's allocated when it's no longer needed.
+ * @param[in] h The rpc_port_stub_hal_device_battery_stub_1_battery_info handle
+ * @param[in] value The capacity
+ * @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_battery_stub_1_battery_info_get_capacity()
+ */
+int rpc_port_stub_hal_device_battery_stub_1_battery_info_set_capacity(rpc_port_stub_hal_device_battery_stub_1_battery_info_h h, int value);
+
+/**
+ * @brief Gets the capacity from the rpc_port_stub_hal_device_battery_stub_1_battery_info handle.
+ *
+ * @remarks A new created value should be released if it's allocated when it's no longer needed.
+ * @param[in] h The rpc_port_stub_hal_device_battery_stub_1_battery_info handle
+ * @param[out] value The capacity
+ * @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_battery_stub_1_battery_info_set_capacity
+ */
+int rpc_port_stub_hal_device_battery_stub_1_battery_info_get_capacity(rpc_port_stub_hal_device_battery_stub_1_battery_info_h h, int *value);
+
+/**
+ * @brief Sets the current_now to the rpc_port_stub_hal_device_battery_stub_1_battery_info handle.
+ *
+ * @remarks The current_now is internally copied and stored.
+ * You should release it if it's allocated when it's no longer needed.
+ * @param[in] h The rpc_port_stub_hal_device_battery_stub_1_battery_info handle
+ * @param[in] value The current_now
+ * @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_battery_stub_1_battery_info_get_current_now()
+ */
+int rpc_port_stub_hal_device_battery_stub_1_battery_info_set_current_now(rpc_port_stub_hal_device_battery_stub_1_battery_info_h h, int value);
+
+/**
+ * @brief Gets the current_now from the rpc_port_stub_hal_device_battery_stub_1_battery_info handle.
+ *
+ * @remarks A new created value should be released if it's allocated when it's no longer needed.
+ * @param[in] h The rpc_port_stub_hal_device_battery_stub_1_battery_info handle
+ * @param[out] value The current_now
+ * @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_battery_stub_1_battery_info_set_current_now
+ */
+int rpc_port_stub_hal_device_battery_stub_1_battery_info_get_current_now(rpc_port_stub_hal_device_battery_stub_1_battery_info_h h, int *value);
+
+/**
+ * @brief Sets the current_average to the rpc_port_stub_hal_device_battery_stub_1_battery_info handle.
+ *
+ * @remarks The current_average is internally copied and stored.
+ * You should release it if it's allocated when it's no longer needed.
+ * @param[in] h The rpc_port_stub_hal_device_battery_stub_1_battery_info handle
+ * @param[in] value The current_average
+ * @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_battery_stub_1_battery_info_get_current_average()
+ */
+int rpc_port_stub_hal_device_battery_stub_1_battery_info_set_current_average(rpc_port_stub_hal_device_battery_stub_1_battery_info_h h, int value);
+
+/**
+ * @brief Gets the current_average from the rpc_port_stub_hal_device_battery_stub_1_battery_info handle.
+ *
+ * @remarks A new created value should be released if it's allocated when it's no longer needed.
+ * @param[in] h The rpc_port_stub_hal_device_battery_stub_1_battery_info handle
+ * @param[out] value The current_average
+ * @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_battery_stub_1_battery_info_set_current_average
+ */
+int rpc_port_stub_hal_device_battery_stub_1_battery_info_get_current_average(rpc_port_stub_hal_device_battery_stub_1_battery_info_h h, int *value);
+
+/**
+ * @brief Sets the voltage_now to the rpc_port_stub_hal_device_battery_stub_1_battery_info handle.
+ *
+ * @remarks The voltage_now is internally copied and stored.
+ * You should release it if it's allocated when it's no longer needed.
+ * @param[in] h The rpc_port_stub_hal_device_battery_stub_1_battery_info handle
+ * @param[in] value The voltage_now
+ * @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_battery_stub_1_battery_info_get_voltage_now()
+ */
+int rpc_port_stub_hal_device_battery_stub_1_battery_info_set_voltage_now(rpc_port_stub_hal_device_battery_stub_1_battery_info_h h, int value);
+
+/**
+ * @brief Gets the voltage_now from the rpc_port_stub_hal_device_battery_stub_1_battery_info handle.
+ *
+ * @remarks A new created value should be released if it's allocated when it's no longer needed.
+ * @param[in] h The rpc_port_stub_hal_device_battery_stub_1_battery_info handle
+ * @param[out] value The voltage_now
+ * @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_battery_stub_1_battery_info_set_voltage_now
+ */
+int rpc_port_stub_hal_device_battery_stub_1_battery_info_get_voltage_now(rpc_port_stub_hal_device_battery_stub_1_battery_info_h h, int *value);
+
+/**
+ * @brief Sets the voltage_average to the rpc_port_stub_hal_device_battery_stub_1_battery_info handle.
+ *
+ * @remarks The voltage_average is internally copied and stored.
+ * You should release it if it's allocated when it's no longer needed.
+ * @param[in] h The rpc_port_stub_hal_device_battery_stub_1_battery_info handle
+ * @param[in] value The voltage_average
+ * @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_battery_stub_1_battery_info_get_voltage_average()
+ */
+int rpc_port_stub_hal_device_battery_stub_1_battery_info_set_voltage_average(rpc_port_stub_hal_device_battery_stub_1_battery_info_h h, int value);
+
+/**
+ * @brief Gets the voltage_average from the rpc_port_stub_hal_device_battery_stub_1_battery_info handle.
+ *
+ * @remarks A new created value should be released if it's allocated when it's no longer needed.
+ * @param[in] h The rpc_port_stub_hal_device_battery_stub_1_battery_info handle
+ * @param[out] value The voltage_average
+ * @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_battery_stub_1_battery_info_set_voltage_average
+ */
+int rpc_port_stub_hal_device_battery_stub_1_battery_info_get_voltage_average(rpc_port_stub_hal_device_battery_stub_1_battery_info_h h, int *value);
+
+/**
+ * @brief Sets the temperature to the rpc_port_stub_hal_device_battery_stub_1_battery_info handle.
+ *
+ * @remarks The temperature is internally copied and stored.
+ * You should release it if it's allocated when it's no longer needed.
+ * @param[in] h The rpc_port_stub_hal_device_battery_stub_1_battery_info handle
+ * @param[in] value The temperature
+ * @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_battery_stub_1_battery_info_get_temperature()
+ */
+int rpc_port_stub_hal_device_battery_stub_1_battery_info_set_temperature(rpc_port_stub_hal_device_battery_stub_1_battery_info_h h, int value);
+
+/**
+ * @brief Gets the temperature from the rpc_port_stub_hal_device_battery_stub_1_battery_info handle.
+ *
+ * @remarks A new created value should be released if it's allocated when it's no longer needed.
+ * @param[in] h The rpc_port_stub_hal_device_battery_stub_1_battery_info handle
+ * @param[out] value The temperature
+ * @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_battery_stub_1_battery_info_set_temperature
+ */
+int rpc_port_stub_hal_device_battery_stub_1_battery_info_get_temperature(rpc_port_stub_hal_device_battery_stub_1_battery_info_h h, int *value);
+
+/**
+ * @brief Creates the rpc_port_stub_hal_device_battery_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_battery_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_battery_stub_1_remote_exception_destroy()
+ */
+int rpc_port_stub_hal_device_battery_stub_1_remote_exception_create(rpc_port_stub_hal_device_battery_stub_1_remote_exception_h *h);
+
+/**
+ * @brief Sets the cause of the exception.
+ *
+ * @param[in] h The rpc_port_stub_hal_device_battery_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_battery_stub_1_remote_exception_set_cause(rpc_port_stub_hal_device_battery_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_battery_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_battery_stub_1_remote_exception_set_message(rpc_port_stub_hal_device_battery_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_battery_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_battery_stub_1_remote_exception_get_cause(rpc_port_stub_hal_device_battery_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_battery_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_battery_stub_1_remote_exception_get_message(rpc_port_stub_hal_device_battery_stub_1_remote_exception_h, char **message);
+
+/**
+ * @brief Destroys the remote exception handle.
+ * @param[in] h The rpc_port_stub_hal_device_battery_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_battery_stub_1_remote_exception_destroy(rpc_port_stub_hal_device_battery_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_battery_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_battery_stub_1_remote_exception_create()
+ * @see rpc_port_stub_hal_device_battery_stub_1_remote_exception_destroy()
+ */
+int rpc_port_stub_hal_device_battery_stub_1_remote_exception_throw(rpc_port_stub_hal_device_battery_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_battery_stub_1_device_battery_callback_s
+ */
+typedef void (*rpc_port_stub_hal_device_battery_stub_1_device_battery_create_cb)(rpc_port_stub_hal_device_battery_stub_1_device_battery_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_battery_stub_1_device_battery_callback_s
+ */
+typedef void (*rpc_port_stub_hal_device_battery_stub_1_device_battery_terminate_cb)(rpc_port_stub_hal_device_battery_stub_1_device_battery_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_battery_stub_1_device_battery_foreach_context() will invoke this callback.
+ * @see rpc_port_stub_hal_device_battery_stub_1_device_battery_foreach_context()
+ */
+typedef bool (*rpc_port_stub_hal_device_battery_stub_1_device_battery_context_cb)(rpc_port_stub_hal_device_battery_stub_1_device_battery_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_battery_stub_1_device_battery_callback_s;
+ */
+typedef int (*rpc_port_stub_hal_device_battery_stub_1_device_battery_register_changed_event_cb)(rpc_port_stub_hal_device_battery_stub_1_device_battery_context_h context, rpc_port_stub_hal_device_battery_stub_1_device_battery_updated_cb_h cb, 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_battery_stub_1_device_battery_callback_s;
+ */
+typedef void (*rpc_port_stub_hal_device_battery_stub_1_device_battery_unregister_changed_event_cb)(rpc_port_stub_hal_device_battery_stub_1_device_battery_context_h context, rpc_port_stub_hal_device_battery_stub_1_device_battery_updated_cb_h cb, 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_battery_stub_1_device_battery_callback_s;
+ */
+typedef int (*rpc_port_stub_hal_device_battery_stub_1_device_battery_get_current_state_cb)(rpc_port_stub_hal_device_battery_stub_1_device_battery_context_h context, rpc_port_stub_hal_device_battery_stub_1_battery_info_h *info, 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_battery_stub_1_device_battery_context_get_tag()
+ */
+int rpc_port_stub_hal_device_battery_stub_1_device_battery_context_set_tag(rpc_port_stub_hal_device_battery_stub_1_device_battery_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_battery_stub_1_device_battery_context_set_tag()
+ */
+int rpc_port_stub_hal_device_battery_stub_1_device_battery_context_get_tag(rpc_port_stub_hal_device_battery_stub_1_device_battery_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_battery_stub_1_device_battery_context_get_sender(rpc_port_stub_hal_device_battery_stub_1_device_battery_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_battery_stub_1_device_battery_context_get_instance(rpc_port_stub_hal_device_battery_stub_1_device_battery_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_battery_stub_1_device_battery_context_disconnect(rpc_port_stub_hal_device_battery_stub_1_device_battery_context_h context);
+
+/**
+ * @brief Creates a rpc_port_stub_hal_device_battery_stub_1_device_battery_updated_cb handle.
+ *
+ * @param[out] h The rpc_port_stub_hal_device_battery_stub_1_device_battery_updated_cb 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_battery_stub_1_device_battery_updated_cb_destroy()
+ */
+int rpc_port_stub_hal_device_battery_stub_1_device_battery_updated_cb_create(rpc_port_stub_hal_device_battery_stub_1_device_battery_updated_cb_h *h);
+
+/**
+ * @brief Destroys the rpc_port_stub_hal_device_battery_stub_1_device_battery_updated_cb handle.
+ *
+ * @param[in] h The rpc_port_stub_hal_device_battery_stub_1_device_battery_updated_cb 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_stub_hal_device_battery_stub_1_device_battery_updated_cb_clone()
+ */
+int rpc_port_stub_hal_device_battery_stub_1_device_battery_updated_cb_destroy(rpc_port_stub_hal_device_battery_stub_1_device_battery_updated_cb_h h);
+
+/**
+ * @brief Creates and returns a copy of the given rpc_port_stub_hal_device_battery_stub_1_device_battery_updated_cb handle.
+ *
+ * @remarks A new created rpc_port_stub_hal_device_battery_stub_1_device_battery_updated_cb should be released using
+ * the rpc_port_stub_hal_device_battery_stub_1_device_battery_updated_cb_destroy() if it's no longer needed.
+ * @param[in] h The rpc_port_stub_hal_device_battery_stub_1_device_battery_updated_cb handle
+ * @param[out] clone If successful, a new created rpc_port_stub_hal_device_battery_stub_1_device_battery_updated_cb 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_battery_stub_1_device_battery_updated_cb_destroy()
+ */
+int rpc_port_stub_hal_device_battery_stub_1_device_battery_updated_cb_clone(rpc_port_stub_hal_device_battery_stub_1_device_battery_updated_cb_h h, rpc_port_stub_hal_device_battery_stub_1_device_battery_updated_cb_h *clone);
+
+/**
+ * @brief Gets the ID of the rpc_port_stub_hal_device_battery_stub_1_device_battery_updated_cb handle.
+ *
+ * @param[in] h The rpc_port_stub_hal_device_battery_stub_1_device_battery_updated_cb handle
+ * @param[out] id The ID
+ * @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_battery_stub_1_device_battery_updated_cb_get_id(rpc_port_stub_hal_device_battery_stub_1_device_battery_updated_cb_h h, int *id);
+
+/**
+ * @brief Gets the sequence ID of the rpc_port_stub_hal_device_battery_stub_1_device_battery_updated_cb handle.
+ *
+ * @param[in] h The rpc_port_stub_hal_device_battery_stub_1_device_battery_updated_cb handle
+ * @param[out] seq_id The Sequence ID
+ * @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_battery_stub_1_device_battery_updated_cb_get_seq_id(rpc_port_stub_hal_device_battery_stub_1_device_battery_updated_cb_h h, int *seq_id);
+
+/**
+ * @brief Checks whether the delegate is for one-time or not.
+ *
+ * @param[in] h The rpc_port_stub_hal_device_battery_stub_1_device_battery_updated_cb handle
+ * @param[out] once The flag, it's true, the handle is for one-time
+ * @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_battery_stub_1_device_battery_updated_cb_is_once(rpc_port_stub_hal_device_battery_stub_1_device_battery_updated_cb_h h, bool *once);
+
+/**
+ * @brief Gets the tag from the rpc_port_stub_hal_device_battery_stub_1_device_battery_updated_cb handle.
+ *
+ * @remarks The @a tag should be released using free().
+ * @param[in] h The rpc_port_stub_hal_device_battery_stub_1_device_battery_updated_cb 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
+ * @retval #RPC_PORT_ERROR_OUT_OF_MEMORY Out of memory
+ */
+int rpc_port_stub_hal_device_battery_stub_1_device_battery_updated_cb_get_tag(rpc_port_stub_hal_device_battery_stub_1_device_battery_updated_cb_h h, char **tag);
+
+/**
+ * @brief Invokes the callback function of the rpc_port_stub_hal_device_battery_stub_1_device_battery_updated_cb handle.
+ *
+ * @param[in] h The rpc_port_stub_hal_device_battery_stub_1_device_battery_updated_cb handle
+ * @param[in] ...
+ * @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
+ */
+int rpc_port_stub_hal_device_battery_stub_1_device_battery_updated_cb_invoke(rpc_port_stub_hal_device_battery_stub_1_device_battery_updated_cb_h h, rpc_port_stub_hal_device_battery_stub_1_battery_info_h info);
+
+/**
+ * @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_battery_stub_1_device_battery_register() function.
+ *
+ * @see rpc_port_stub_hal_device_battery_stub_1_device_battery_create_cb
+ * @see rpc_port_stub_hal_device_battery_stub_1_device_battery_terminate_cb
+ */
+typedef struct {
+ rpc_port_stub_hal_device_battery_stub_1_device_battery_create_cb create; /**< This callback function is invoked when the proxy is connected. */
+ rpc_port_stub_hal_device_battery_stub_1_device_battery_terminate_cb terminate; /**< This callback function is invoked when the proxy is disconnected. */
+
+ rpc_port_stub_hal_device_battery_stub_1_device_battery_register_changed_event_cb register_changed_event; /**< This callback function is invoked when the register_changed_event request is delivered. */
+
+ rpc_port_stub_hal_device_battery_stub_1_device_battery_unregister_changed_event_cb unregister_changed_event; /**< This callback function is invoked when the unregister_changed_event request is delivered. */
+
+ rpc_port_stub_hal_device_battery_stub_1_device_battery_get_current_state_cb get_current_state; /**< This callback function is invoked when the get_current_state request is delivered. */
+} rpc_port_stub_hal_device_battery_stub_1_device_battery_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_battery_stub_1_device_battery_unregister()
+ * @see #rpc_port_stub_hal_device_battery_stub_1_device_battery_callback_s
+ */
+int rpc_port_stub_hal_device_battery_stub_1_device_battery_register(rpc_port_stub_hal_device_battery_stub_1_device_battery_callback_s *callback, void *user_data);
+
+/**
+ * @brief Unregisters the registered port.
+ */
+int rpc_port_stub_hal_device_battery_stub_1_device_battery_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_battery_stub_1_device_battery_context_cb()
+ */
+int rpc_port_stub_hal_device_battery_stub_1_device_battery_foreach_context(rpc_port_stub_hal_device_battery_stub_1_device_battery_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_battery_stub_1_device_battery_get_client_number(unsigned int *client_number);
+
+#ifdef __cplusplus
+}
+#endif