From: Yunhee Seo Date: Thu, 21 Dec 2023 07:13:39 +0000 (+0900) Subject: display: Change device_display_change_state() from async to sync X-Git-Tag: accepted/tizen/unified/20240122.175407^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F32%2F304232%2F1;p=platform%2Fcore%2Fapi%2Fdevice.git display: Change device_display_change_state() from async to sync device_display_change_state() made the state change request asynchronous, so it was not possible to know whether the request execution succeeded or not. Due to the difficulty in checking whether requests were fulfilled properly, the request method is changed as synchronous way. Change-Id: Id4f957989248fb2c627459367fa575aa306a8d58 Signed-off-by: Yunhee Seo --- diff --git a/src/display.c b/src/display.c index d964953..4c2c0d3 100644 --- a/src/display.c +++ b/src/display.c @@ -252,27 +252,14 @@ static char *get_state_str(display_state_e state) return NULL; } -static void change_cb(GVariant *result, void *data, GError *err) -{ - int val; - - if (!result) { -//LCOV_EXCL_START System Error - _E("no message : %s", err->message); - return; -//LCOV_EXCL_STOP - } - - g_variant_get(result, "(i)", &val); - _D("%s-%s : %d", DEVICED_INTERFACE_DISPLAY, METHOD_CHANGE_STATE, val); -} - int device_display_change_state(display_state_e state) { char *str; int ret; + int val; static int privilege = -1; static long num_calls = 0; + GVariant *reply = NULL; ret = is_feature_display_state_supported(); if (!ret) @@ -306,13 +293,21 @@ int device_display_change_state(display_state_e state) if (!str) return DEVICE_ERROR_INVALID_PARAMETER; - ret = gdbus_call_async_with_reply(DEVICED_BUS_NAME, + ret = gdbus_call_sync_with_reply(DEVICED_BUS_NAME, DEVICED_PATH_DISPLAY, DEVICED_INTERFACE_DISPLAY, - METHOD_CHANGE_STATE, g_variant_new("(s)", str), change_cb, -1, NULL); + METHOD_CHANGE_STATE, g_variant_new("(s)", str), &reply); if (ret < 0) ret = errno_to_device_error(ret); //LCOV_EXCL_LINE System Error + if (reply) { + g_variant_get(reply, "(i)", &val); + _D("%s-%s : %d", DEVICED_INTERFACE_DISPLAY, METHOD_CHANGE_STATE, val); + + if (val < 0) + return errno_to_device_error(val); + } + return ret; }