* @retval #DEVICE_ERROR_OPERATION_FAILED Operation failed
* @see device_display_change_state_by_reason()
*/
-int device_display_change_state_by_reason(display_state_e type, char *reason, int timeout, dbus_pending_cb cb);
+int device_display_change_state_by_reason(display_state_e type, const char *reason, int timeout, dbus_pending_cb cb);
#ifdef __cplusplus
}
#endif
if (!ret)
return DEVICE_ERROR_NOT_SUPPORTED;
- ret = dbus_method_sync(DEVICED_BUS_NAME,
+ ret = dbus_method_sync_var(DEVICED_BUS_NAME,
DEVICED_PATH_BATTERY, DEVICED_INTERFACE_BATTERY,
- METHOD_GET_PERCENT, NULL, NULL);
+ METHOD_GET_PERCENT, NULL);
/* regard not suppoted as disconnected */
if (ret == -ENOTSUP)
ret = 0;
if (!info)
return DEVICE_ERROR_INVALID_PARAMETER;
- ret = dbus_method_sync_with_reply(DEVICED_BUS_NAME,
+ ret = dbus_method_sync_with_reply_var(DEVICED_BUS_NAME,
DEVICED_PATH_BATTERY, DEVICED_INTERFACE_BATTERY,
- METHOD_GET_INFO, NULL, NULL, &output);
+ METHOD_GET_INFO, NULL, &output);
/* regard not suppoted as disconnected */
if (ret == -ENOTSUP)
ret = 0; //LCOV_EXCL_LINE System Error
/* if it is a first request */
if (display_cnt < 0) {
- ret = dbus_method_sync(DEVICED_BUS_NAME,
+ ret = dbus_method_sync_var(DEVICED_BUS_NAME,
DEVICED_PATH_DISPLAY, DEVICED_INTERFACE_DISPLAY,
- METHOD_GET_DISPLAY_COUNT, NULL, NULL);
+ METHOD_GET_DISPLAY_COUNT, NULL);
if (ret < 0)
return errno_to_device_error(ret);
display_cnt = ret;
int device_display_get_max_brightness(int display_index, int *max_brightness)
{
- char *arr[1];
- char str_val[32];
int ret;
ret = is_display_supported();
if (!display_arr && alloc_display() < 0)
return DEVICE_ERROR_OPERATION_FAILED;
- snprintf(str_val, sizeof(str_val), "%d", DISPLAY_STATE_NORMAL);
- arr[0] = str_val;
if (display_arr[display_index].normal_max < 0) {
- ret = dbus_method_sync(DEVICED_BUS_NAME,
+ ret = dbus_method_sync_var(DEVICED_BUS_NAME,
DEVICED_PATH_DISPLAY, DEVICED_INTERFACE_DISPLAY,
- METHOD_GET_MAX_BRIGHTNESS, "i", arr);
+ METHOD_GET_MAX_BRIGHTNESS, g_variant_new("(i)", (int)DISPLAY_STATE_NORMAL));
if (ret < 0)
return errno_to_device_error(ret);
display_arr[display_index].normal_max = ret;
int device_display_get_brightness(int display_index, int *brightness)
{
- char *arr[1];
- char str_val[32];
int ret;
ret = is_display_supported();
if (display_index < 0 || display_index >= display_cnt)
return DEVICE_ERROR_INVALID_PARAMETER;
- snprintf(str_val, sizeof(str_val), "%d", DISPLAY_STATE_NORMAL);
- arr[0] = str_val;
-
- ret = dbus_method_sync(DEVICED_BUS_NAME,
+ ret = dbus_method_sync_var(DEVICED_BUS_NAME,
DEVICED_PATH_DISPLAY, DEVICED_INTERFACE_DISPLAY,
- METHOD_GET_BRIGHTNESS, "i", arr);
+ METHOD_GET_BRIGHTNESS, g_variant_new("(i)", (int)DISPLAY_STATE_NORMAL));
if (ret < 0)
return errno_to_device_error(ret);
int device_display_set_brightness(int display_index, int brightness)
{
- char *arr[2];
- char str_state[32];
- char str_val[32];
int ret, max;
ret = is_display_supported();
if (brightness < 0 || brightness > display_arr[display_index].normal_max)
return DEVICE_ERROR_INVALID_PARAMETER;
- snprintf(str_state, sizeof(str_state), "%d", DISPLAY_STATE_NORMAL);
- arr[0] = str_state;
-
- snprintf(str_val, sizeof(str_val), "%d", brightness);
- arr[1] = str_val;
-
- ret = dbus_method_sync(DEVICED_BUS_NAME,
+ ret = dbus_method_sync_var(DEVICED_BUS_NAME,
DEVICED_PATH_DISPLAY, DEVICED_INTERFACE_DISPLAY,
- METHOD_SET_BRIGHTNESS, "ii", arr);
+ METHOD_SET_BRIGHTNESS, g_variant_new("(ii)", (int)DISPLAY_STATE_NORMAL, brightness));
if (ret < 0)
return errno_to_device_error(ret);
int device_display_change_state(display_state_e state)
{
- char *str, *arr[1];
+ char *str;
int ret;
static int privilege = -1;
return DEVICE_ERROR_INVALID_PARAMETER;
if (privilege < 0) {
- arr[0] = "privilege check";
-
- ret = dbus_method_sync(DEVICED_BUS_NAME,
+ ret = dbus_method_sync_var(DEVICED_BUS_NAME,
DEVICED_PATH_DISPLAY, DEVICED_INTERFACE_DISPLAY,
- METHOD_CHANGE_STATE, "s", arr);
+ METHOD_CHANGE_STATE, g_variant_new("(s)", "privilege check"));
//LCOV_EXCL_START System Error
if (ret < 0)
return ret;
if (!str)
return DEVICE_ERROR_INVALID_PARAMETER;
- arr[0] = str;
-
- return dbus_method_async_with_reply(DEVICED_BUS_NAME,
+ return dbus_method_async_with_reply_var(DEVICED_BUS_NAME,
DEVICED_PATH_DISPLAY, DEVICED_INTERFACE_DISPLAY,
- METHOD_CHANGE_STATE, "s", arr, change_cb, -1, NULL);
+ METHOD_CHANGE_STATE, g_variant_new("(s)", str), change_cb, -1, NULL);
}
//LCOV_EXCL_START Not used function
int device_display_get_max_brightness_state(int display_index, display_state_e state, int *brightness)
{
- char *arr[1];
- char str_val[32];
int ret;
ret = is_display_supported();
if (!display_arr && alloc_display() < 0)
return DEVICE_ERROR_OPERATION_FAILED;
- if (state == DISPLAY_STATE_NORMAL)
- snprintf(str_val, sizeof(str_val), "%d", DISPLAY_STATE_NORMAL);
- else if (state == DISPLAY_STATE_SCREEN_DIM)
- snprintf(str_val, sizeof(str_val), "%d", DISPLAY_STATE_SCREEN_DIM);
- arr[0] = str_val;
-
- ret = dbus_method_sync(DEVICED_BUS_NAME,
+ ret = dbus_method_sync_var(DEVICED_BUS_NAME,
DEVICED_PATH_DISPLAY, DEVICED_INTERFACE_DISPLAY,
- METHOD_GET_MAX_BRIGHTNESS, "i", arr);
+ METHOD_GET_MAX_BRIGHTNESS, g_variant_new("(i)", (int)state));
if (ret < 0)
return errno_to_device_error(ret);
//LCOV_EXCL_START Not used function
int device_display_get_brightness_state(int display_index, display_state_e state, int *brightness)
{
- char *arr[1];
- char str_val[32];
int ret;
ret = is_display_supported();
if (display_index < 0 || display_index >= display_cnt)
return DEVICE_ERROR_INVALID_PARAMETER;
- if (state == DISPLAY_STATE_NORMAL)
- snprintf(str_val, sizeof(str_val), "%d", DISPLAY_STATE_NORMAL);
- else if (state == DISPLAY_STATE_SCREEN_DIM)
- snprintf(str_val, sizeof(str_val), "%d", DISPLAY_STATE_SCREEN_DIM);
- arr[0] = str_val;
-
- ret = dbus_method_sync(DEVICED_BUS_NAME,
+ ret = dbus_method_sync_var(DEVICED_BUS_NAME,
DEVICED_PATH_DISPLAY, DEVICED_INTERFACE_DISPLAY,
- METHOD_GET_BRIGHTNESS, "i", arr);
+ METHOD_GET_BRIGHTNESS, g_variant_new("(i)", (int)state));
if (ret < 0)
return errno_to_device_error(ret);
//LCOV_EXCL_START Not used function
int device_display_set_brightness_state(int display_index, display_state_e state, int brightness)
{
- char *arr[2];
- char str_state[32];
- char str_val[32];
int ret, max;
ret = is_display_supported();
device_display_get_max_brightness_state(display_index, DISPLAY_STATE_NORMAL, &max);
if (brightness < 0 || brightness > display_arr[display_index].normal_max)
return DEVICE_ERROR_INVALID_PARAMETER;
-
- snprintf(str_val, sizeof(str_val), "%d", DISPLAY_STATE_NORMAL);
- arr[0] = str_val;
- snprintf(str_val, sizeof(str_val), "%d", brightness);
- arr[1] = str_val;
break;
case DISPLAY_STATE_SCREEN_DIM:
if (display_arr[display_index].dim_max < 0)
device_display_get_max_brightness_state(display_index, DISPLAY_STATE_SCREEN_DIM, &max);
if (brightness < 0 || brightness > display_arr[display_index].dim_max)
return DEVICE_ERROR_INVALID_PARAMETER;
-
- snprintf(str_state, sizeof(str_state), "%d", DISPLAY_STATE_SCREEN_DIM);
- arr[0] = str_state;
- snprintf(str_val, sizeof(str_val), "%d", brightness);
- arr[1] = str_val;
break;
-
default:
break;
}
- ret = dbus_method_sync(DEVICED_BUS_NAME,
+ ret = dbus_method_sync_var(DEVICED_BUS_NAME,
DEVICED_PATH_DISPLAY, DEVICED_INTERFACE_DISPLAY,
- METHOD_SET_BRIGHTNESS, "ii", arr);
+ METHOD_SET_BRIGHTNESS, g_variant_new("(ii)", (int)state, brightness));
if (ret < 0)
return errno_to_device_error(ret);
return DEVICE_ERROR_NONE;
}
-int device_display_change_state_by_reason(display_state_e type, char *reason, int timeout, dbus_pending_cb cb)
+int device_display_change_state_by_reason(display_state_e type, const char *reason, int timeout, dbus_pending_cb cb)
{
- char *arr[3];
- char _type[32];
- char _timeout[32];
int ret;
- snprintf(_type, sizeof(_type), "%d", type);
- snprintf(_timeout, sizeof(_timeout), "%d", timeout);
-
- arr[0] = _type;
- arr[1] = reason;
- arr[2] = _timeout;
-
- ret = dbus_method_async_with_reply(DEVICED_BUS_NAME,
+ ret = dbus_method_async_with_reply_var(DEVICED_BUS_NAME,
DEVICED_PATH_DISPLAY, DEVICED_INTERFACE_DISPLAY,
- METHOD_CHANGE_STATE_BY_REASON, "isi", arr, cb, -1, NULL);
+ METHOD_CHANGE_STATE_BY_REASON, g_variant_new("(isi)", (int)type, reason, timeout), cb, -1, NULL);
return errno_to_device_error(ret);
}
return DEVICE_ERROR_NOT_SUPPORTED;
/* request to deviced to get haptic count */
- ret = dbus_method_sync(VIBRATOR_BUS_NAME,
+ ret = dbus_method_sync_var(VIBRATOR_BUS_NAME,
VIBRATOR_PATH_HAPTIC, VIBRATOR_INTERFACE_HAPTIC,
- METHOD_GET_COUNT, NULL, NULL);
+ METHOD_GET_COUNT, NULL);
/**
* there is no haptic method in no vibration model.
* so -ENOTSUP means that haptic count is zero.
void restart_callback(void)
{
dd_list *elem, *elem_next;
- char str_index[32];
- char *arr[1];
struct haptic_handle *temp;
int ret;
DD_LIST_FOREACH_SAFE(handle_list, elem, elem_next, temp) {
- snprintf(str_index, sizeof(str_index), "%d", temp->index);
- arr[0] = str_index;
- ret = dbus_method_sync(VIBRATOR_BUS_NAME,
+ ret = dbus_method_sync_var(VIBRATOR_BUS_NAME,
VIBRATOR_PATH_HAPTIC, VIBRATOR_INTERFACE_HAPTIC,
- METHOD_OPEN_DEVICE, "i", arr);
+ METHOD_OPEN_DEVICE, g_variant_new("(i)", temp->index));
if (ret < 0) {
_E("Failed to open device");
continue;
dd_list *elem, *elem_next;
struct haptic_handle *handle;
struct haptic_handle *temp;
- char str_index[32];
- char *arr[1];
int ret, max;
bool found = false;
if (!ret)
return DEVICE_ERROR_NOT_SUPPORTED;
- snprintf(str_index, sizeof(str_index), "%d", device_index);
- arr[0] = str_index;
-
/* request to deviced to open haptic device */
- ret = dbus_method_sync(VIBRATOR_BUS_NAME,
+ ret = dbus_method_sync_var(VIBRATOR_BUS_NAME,
VIBRATOR_PATH_HAPTIC, VIBRATOR_INTERFACE_HAPTIC,
- METHOD_OPEN_DEVICE, "i", arr);
+ METHOD_OPEN_DEVICE, g_variant_new("(i)", device_index));
if (ret < 0)
return errno_to_device_error(ret); //LCOV_EXCL_LINE System Error
dd_list *elem, *elem_next;
struct haptic_handle *handle = (struct haptic_handle *)device_handle;
struct haptic_handle *temp;
- char str_handle[32];
- char *arr[1];
int ret;
bool found = false;
if (!found)
return DEVICE_ERROR_OPERATION_FAILED;
DD_LIST_REMOVE(handle_list, handle);
- snprintf(str_handle, sizeof(str_handle), "%u", (unsigned int)handle->handle);
- free(handle);
- arr[0] = str_handle;
/* request to deviced to open haptic device */
- ret = dbus_method_sync(VIBRATOR_BUS_NAME,
+ ret = dbus_method_sync_var(VIBRATOR_BUS_NAME,
VIBRATOR_PATH_HAPTIC, VIBRATOR_INTERFACE_HAPTIC,
- METHOD_CLOSE_DEVICE, "u", arr);
+ METHOD_CLOSE_DEVICE, g_variant_new("(u)", (unsigned int)handle->handle));
+
+ free(handle);
+
if (ret < 0)
return errno_to_device_error(ret); //LCOV_EXCL_LINE System Error
dd_list *elem, *elem_next;
struct haptic_handle *handle = (struct haptic_handle *)device_handle;
struct haptic_handle *temp;
- char str_handle[32];
- char str_duration[32];
- char str_feedback[32];
- char str_priority[32];
- char *arr[4];
int ret, priority;
bool found = false;
if (!found)
return DEVICE_ERROR_INVALID_PARAMETER;
- snprintf(str_handle, sizeof(str_handle), "%u", (unsigned int)handle->handle);
- arr[0] = str_handle;
- snprintf(str_duration, sizeof(str_duration), "%d", duration);
- arr[1] = str_duration;
- snprintf(str_feedback, sizeof(str_feedback), "%d", feedback);
- arr[2] = str_feedback;
- snprintf(str_priority, sizeof(str_priority), "%d", priority);
- arr[3] = str_priority;
-
/* request to deviced to vibrate haptic device */
- ret = dbus_method_sync(VIBRATOR_BUS_NAME,
+ ret = dbus_method_sync_var(VIBRATOR_BUS_NAME,
VIBRATOR_PATH_HAPTIC, VIBRATOR_INTERFACE_HAPTIC,
- METHOD_VIBRATE_MONOTONE, "uiii", arr);
+ METHOD_VIBRATE_MONOTONE,
+ g_variant_new("(uiii)", (unsigned int)handle->handle, duration, feedback, priority));
if (ret < 0)
return errno_to_device_error(ret); //LCOV_EXCL_LINE System Error
dd_list *elem, *elem_next;
struct haptic_handle *handle = (struct haptic_handle *)device_handle;
struct haptic_handle *temp;
- char str_handle[32];
- char *arr[1];
int ret;
bool found = false;
return DEVICE_ERROR_INVALID_PARAMETER;
/* TODO : support to stop haptic effect */
- snprintf(str_handle, sizeof(str_handle), "%u", (unsigned int)handle->handle);
- arr[0] = str_handle;
/* request to deviced to open haptic device */
- ret = dbus_method_sync(VIBRATOR_BUS_NAME,
+ ret = dbus_method_sync_var(VIBRATOR_BUS_NAME,
VIBRATOR_PATH_HAPTIC, VIBRATOR_INTERFACE_HAPTIC,
- METHOD_STOP_DEVICE, "u", arr);
+ METHOD_STOP_DEVICE, g_variant_new("(u)", (unsigned int)handle->handle));
if (ret < 0)
return errno_to_device_error(ret); //LCOV_EXCL_LINE System Error
return DEVICE_ERROR_NOT_SUPPORTED;
}
- ret = dbus_method_sync(DEVICED_BUS_NAME, DEVICED_PATH_IR,
+ ret = dbus_method_sync_var(DEVICED_BUS_NAME, DEVICED_PATH_IR,
DEVICED_INTERFACE_IR, METHOD_IS_AVAILABLE,
- NULL, NULL);
+ NULL);
//LCOV_EXCL_START System Error
if (ret == -EACCES || ret == -EPERM)
int device_ir_transmit(int carrier_frequency, int *pattern, int size)
{
- char *arr[1];
- struct dbus_int pattern_list;
- int freq_pattern[size + 1];
int ret;
int i;
bool ir_avail;
+ GVariantBuilder *builder;
ret = device_ir_is_available(&ir_avail);
if (!ir_avail) {
return DEVICE_ERROR_INVALID_PARAMETER;
}
//LCOV_EXCL_STOP
- freq_pattern[0] = carrier_frequency;
- for (i = 1; i <= size; i++)
- freq_pattern[i] = pattern[i-1];
+ builder = g_variant_builder_new(G_VARIANT_TYPE ("ai"));
- pattern_list.list = freq_pattern;
- pattern_list.size = size + 1;
- arr[0] = (char *)&pattern_list;
+ g_variant_builder_add(builder, "i", carrier_frequency);
+ for (i = 0; i < size; ++i)
+ g_variant_builder_add(builder, "i", pattern[i]);
- ret = dbus_method_sync(DEVICED_BUS_NAME, DEVICED_PATH_IR,
+ ret = dbus_method_sync_var(DEVICED_BUS_NAME, DEVICED_PATH_IR,
DEVICED_INTERFACE_IR, METHOD_TRANSMIT,
- "ai", arr);
+ g_variant_new("(ai)", builder));
+ g_variant_builder_unref(builder);
//LCOV_EXCL_START System Error
if (ret == -EACCES || ret == -EPERM)
return DEVICE_ERROR_PERMISSION_DENIED;
if (!max_brightness)
return DEVICE_ERROR_INVALID_PARAMETER;
- ret = dbus_method_sync(DEVICED_BUS_NAME,
+ ret = dbus_method_sync_var(DEVICED_BUS_NAME,
DEVICED_PATH_LED, DEVICED_INTERFACE_LED,
- METHOD_GET_MAX_BRIGHTNESS, NULL, NULL);
+ METHOD_GET_MAX_BRIGHTNESS, NULL);
if (ret < 0)
return errno_to_device_error(ret); //LCOV_EXCL_LINE System Error
if (!brightness)
return DEVICE_ERROR_INVALID_PARAMETER;
- ret = dbus_method_sync(DEVICED_BUS_NAME,
+ ret = dbus_method_sync_var(DEVICED_BUS_NAME,
DEVICED_PATH_LED, DEVICED_INTERFACE_LED,
- METHOD_GET_BRIGHTNESS, NULL, NULL);
+ METHOD_GET_BRIGHTNESS, NULL);
if (ret < 0)
return errno_to_device_error(ret); //LCOV_EXCL_LINE System Error
int device_flash_set_brightness(int brightness)
{
- char *arr[2];
- char buf_val[32];
- char buf_noti[32];
int max, ret;
if (!support_camera_led)
if (brightness < 0 || brightness > max)
return DEVICE_ERROR_INVALID_PARAMETER;
- snprintf(buf_val, sizeof(buf_val), "%d", brightness);
- arr[0] = buf_val;
- snprintf(buf_noti, sizeof(buf_noti), "%d", 0);
- arr[1] = buf_noti;
-
/* if camera API preempt a flash device, it will return -EBUSY error. */
- ret = dbus_method_sync(DEVICED_BUS_NAME,
+ ret = dbus_method_sync_var(DEVICED_BUS_NAME,
DEVICED_PATH_LED, DEVICED_INTERFACE_LED,
- METHOD_SET_BRIGHTNESS, "ii", arr);
+ METHOD_SET_BRIGHTNESS, g_variant_new("(ii)", brightness, 0));
if (ret < 0)
return errno_to_device_error(ret); //LCOV_EXCL_LINE System Error
int device_led_play_custom(int on, int off, unsigned int color, unsigned int flags)
{
- char *arr[4];
- char str_on[32], str_off[32];
- char str_color[32], str_flags[32];
int ret;
if (!support_front_led)
if (on < 0 || off < 0)
return DEVICE_ERROR_INVALID_PARAMETER;
- snprintf(str_on, sizeof(str_on), "%d", on);
- arr[0] = str_on;
- snprintf(str_off, sizeof(str_off), "%d", off);
- arr[1] = str_off;
- snprintf(str_color, sizeof(str_color), "%lu", (long unsigned int)color);
- arr[2] = str_color;
- snprintf(str_flags, sizeof(str_flags), "%lu", (long unsigned int)flags);
- arr[3] = str_flags;
-
- ret = dbus_method_sync(DEVICED_BUS_NAME,
+ ret = dbus_method_sync_var(DEVICED_BUS_NAME,
DEVICED_PATH_LED, DEVICED_INTERFACE_LED,
- METHOD_PLAY_CUSTOM, "iiuu", arr);
+ METHOD_PLAY_CUSTOM, g_variant_new("(iiuu)", on, off, (unsigned int)color, (unsigned int)flags));
//LCOV_EXCL_START System Error
if (ret < 0)
return errno_to_device_error(ret);
if (!support_front_led)
return DEVICE_ERROR_NOT_SUPPORTED;
- ret = dbus_method_sync(DEVICED_BUS_NAME,
+ ret = dbus_method_sync_var(DEVICED_BUS_NAME,
DEVICED_PATH_LED, DEVICED_INTERFACE_LED,
- METHOD_STOP_CUSTOM, NULL, NULL);
+ METHOD_STOP_CUSTOM, NULL);
//LCOV_EXCL_START System Error
if (ret < 0)
return errno_to_device_error(ret);
return DEVICE_ERROR_INVALID_PARAMETER;
if (number_of_devices < 0) {
- ret = dbus_method_sync(DEVICED_BUS_NAME,
+ ret = dbus_method_sync_var(DEVICED_BUS_NAME,
DEVICED_PATH_LED, DEVICED_INTERFACE_LED,
- METHOD_GET_LED_NUMBER, NULL, NULL);
+ METHOD_GET_LED_NUMBER, NULL);
if (ret < 0)
return errno_to_device_error(ret); //LCOV_EXCL_LINE System Error
number_of_devices = ret;
int ret;
pid_t pid;
char *req_id;
- char *param[1];
pid = getpid();
return -ENOMEM;
}
- param[0] = req_id;
- ret = dbus_method_async_with_reply(
+ ret = dbus_method_async_with_reply_var(
DEVICED_BUS_NAME,
DEVICED_PATH_DISPLAY,
DEVICED_INTERFACE_DISPLAY,
"LockTimeoutExpired",
- "s", param,
+ g_variant_new("(s)", req_id),
notice_lock_expired_done,
-1,
NULL);
static int lock_state(display_state_e state, unsigned int flag, int timeout_ms)
{
char *arr[4];
- char str_timeout[32];
int ret;
static int privilege = -1;
else
arr[2] = STR_NULL;
- snprintf(str_timeout, sizeof(str_timeout), "%d", timeout_ms);
- arr[3] = str_timeout;
-
if (privilege < 0) {
arr[0] = "privilege check";
- ret = dbus_method_sync(DEVICED_BUS_NAME,
+ ret = dbus_method_sync_var(DEVICED_BUS_NAME,
DEVICED_PATH_DISPLAY, DEVICED_INTERFACE_DISPLAY,
- METHOD_LOCK_STATE, "sssi", arr);
+ METHOD_LOCK_STATE, g_variant_new("(sssi)", arr[0], arr[1], arr[2], timeout_ms));
//LCOV_EXCL_START System Error
if (ret < 0)
return ret;
if (!arr[0])
return -EINVAL;
- return dbus_method_async_with_reply(DEVICED_BUS_NAME,
+ return dbus_method_async_with_reply_var(DEVICED_BUS_NAME,
DEVICED_PATH_DISPLAY, DEVICED_INTERFACE_DISPLAY,
- METHOD_LOCK_STATE, "sssi", arr, lock_cb, -1, NULL);
+ METHOD_LOCK_STATE, g_variant_new("(sssi)", arr[0], arr[1], arr[2], timeout_ms), lock_cb, -1, NULL);
}
static void unlock_cb(void *data, GVariant *result, GError *err)
if (privilege < 0) {
arr[0] = "privilege check";
- ret = dbus_method_sync(DEVICED_BUS_NAME,
+ ret = dbus_method_sync_var(DEVICED_BUS_NAME,
DEVICED_PATH_DISPLAY, DEVICED_INTERFACE_DISPLAY,
- METHOD_UNLOCK_STATE, "ss", arr);
+ METHOD_UNLOCK_STATE, g_variant_new("(ss)", arr[0], arr[1]));
//LCOV_EXCL_START System Error
if (ret < 0)
return ret;
if (!arr[0])
return -EINVAL;
- return dbus_method_async_with_reply(DEVICED_BUS_NAME,
+ return dbus_method_async_with_reply_var(DEVICED_BUS_NAME,
DEVICED_PATH_DISPLAY, DEVICED_INTERFACE_DISPLAY,
- METHOD_UNLOCK_STATE, "ss", arr, unlock_cb, -1, NULL);
+ METHOD_UNLOCK_STATE, g_variant_new("(ss)", arr[0], arr[1]), unlock_cb, -1, NULL);
}
int device_power_request_lock(power_lock_e type, int timeout_ms)
//LCOV_EXCL_START Not available to test (Reboot during TCT)
int device_power_reboot(const char *reason)
{
- char *arr[2];
- char *method, *sig;
+ const char *method;
+ GVariant *param;
int ret;
if (reason) {
- arr[0] = TYPE_REBOOT;
- arr[1] = (char *)reason;
method = METHOD_POWEROFF_WITH_OPTION;
- sig = "ss";
+ param = g_variant_new("(ss)", TYPE_REBOOT, reason);
} else {
- arr[0] = TYPE_REBOOT;
method = METHOD_POWEROFF;
- sig = "s";
+ param = g_variant_new("(s)", TYPE_REBOOT);
}
- ret = dbus_method_sync(DEVICED_BUS_NAME,
+ ret = dbus_method_sync_var(DEVICED_BUS_NAME,
DEVICED_PATH_POWEROFF,
DEVICED_INTERFACE_POWEROFF,
- method, sig, arr);
+ method, param);
return errno_to_device_error(ret);
}
//LCOV_EXCL_STOP
int device_thermal_get_temperature(device_thermal_e type, int *temp)
{
- char *arr[1];
- char str_val[32];
int ret;
if (type > DEVICE_THERMAL_BATTERY)
if (!ret)
return DEVICE_ERROR_NOT_SUPPORTED;
- snprintf(str_val, sizeof(str_val), "%d", type);
- arr[0] = str_val;
-
- ret = dbus_method_sync(DEVICED_BUS_NAME,
+ ret = dbus_method_sync_var(DEVICED_BUS_NAME,
DEVICED_PATH_TEMPERATURE,
DEVICED_INTERFACE_TEMPERATURE,
- METHOD_GET_TEMPERATURE, "i", arr);
+ METHOD_GET_TEMPERATURE, g_variant_new("(i)", type));
if (ret < 0)
return errno_to_device_error(ret);