Call device display lock before attempting to set time 46/215946/1 feature/refactor_v1
authorInkyun Kil <inkyun.kil@samsung.com>
Fri, 18 Oct 2019 01:34:02 +0000 (10:34 +0900)
committerInkyun Kil <inkyun.kil@samsung.com>
Fri, 18 Oct 2019 01:34:02 +0000 (10:34 +0900)
Change-Id: I7f218d3068452715dcd90e3b439ddf74ac9f2991
Signed-off-by: Inkyun Kil <inkyun.kil@samsung.com>
server/alarm-manager-dbus.c
server/alarm-manager-dbus.h
server/alarm-manager-timer.c
server/alarm-manager.c

index b12bd9f..9c16f3d 100644 (file)
@@ -504,14 +504,15 @@ static pid_t __get_caller_pid(const char *name)
        return pid;
 }
 
-int _display_lock_state(char *state, char *flag, unsigned int timeout)
+void _display_lock_state(char *state, char *flag, unsigned int timeout)
 {
        GDBusMessage *msg = NULL;
        GDBusMessage *reply = NULL;
        GVariant *body = NULL;
-       int ret = ALARMMGR_RESULT_SUCCESS;
        int val = -1;
 
+       LOGD("Lock the display not to enter LCD OFF");
+
        msg = g_dbus_message_new_method_call(
                        DEVICED_BUS_NAME,
                        DEVICED_PATH_DISPLAY,
@@ -520,7 +521,7 @@ int _display_lock_state(char *state, char *flag, unsigned int timeout)
        if (!msg) {
                LOGE("g_dbus_message_new_method_call() is failed. (%s:%s-%s)",
                                DEVICED_BUS_NAME, DEVICED_INTERFACE_DISPLAY, DEVICED_LOCK_STATE);
-               return ERR_ALARM_SYSTEM_FAIL;
+               return;
        }
 
        g_dbus_message_set_body(
@@ -534,17 +535,14 @@ int _display_lock_state(char *state, char *flag, unsigned int timeout)
        if (!reply) {
                LOGE("No reply.\
                                g_dbus_connection_send_message_with_reply_sync() is failed.");
-               ret = ERR_ALARM_SYSTEM_FAIL;
        } else {
                body = g_dbus_message_get_body(reply);
                if (!body) {
                        LOGE("g_dbus_message_get_body() is failed.");
-                       ret = ERR_ALARM_SYSTEM_FAIL;
                } else {
                        g_variant_get(body, "(i)", &val);
                        if (val != 0) {
                                LOGE("Failed to lock display");
-                               ret = ERR_ALARM_SYSTEM_FAIL;
                        } else {
                                LOGD("Lock LCD OFF is successfully done");
                        }
@@ -555,18 +553,17 @@ int _display_lock_state(char *state, char *flag, unsigned int timeout)
        g_object_unref(msg);
        if (reply)
                g_object_unref(reply);
-
-       return ret;
 }
 
-int _display_unlock_state(char *state, char *flag)
+void _display_unlock_state(char *state, char *flag)
 {
        GDBusMessage *msg = NULL;
        GDBusMessage *reply = NULL;
        GVariant *body = NULL;
-       int ret = ALARMMGR_RESULT_SUCCESS;
        int val = -1;
 
+       LOGD("Unlock the display from LCD OFF");
+
        msg = g_dbus_message_new_method_call(
                        DEVICED_BUS_NAME,
                        DEVICED_PATH_DISPLAY,
@@ -575,7 +572,7 @@ int _display_unlock_state(char *state, char *flag)
        if (!msg) {
                LOGE("g_dbus_message_new_method_call() is failed. (%s:%s-%s)",
                                DEVICED_BUS_NAME, DEVICED_INTERFACE_DISPLAY, DEVICED_UNLOCK_STATE);
-               return ERR_ALARM_SYSTEM_FAIL;
+               return;
        }
 
        g_dbus_message_set_body(msg, g_variant_new("(ss)", state, flag));
@@ -588,17 +585,14 @@ int _display_unlock_state(char *state, char *flag)
        if (!reply) {
                LOGE("No reply.\
                                g_dbus_connection_send_message_with_reply_sync() is failed.");
-               ret = ERR_ALARM_SYSTEM_FAIL;
        } else {
                body = g_dbus_message_get_body(reply);
                if (!body) {
                        LOGE("g_dbus_message_get_body() is failed.");
-                       ret = ERR_ALARM_SYSTEM_FAIL;
                } else {
                        g_variant_get(body, "(i)", &val);
                        if (val != 0) {
                                LOGE("Failed to unlock display");
-                               ret = ERR_ALARM_SYSTEM_FAIL;
                        } else {
                                LOGD("Unlock LCD OFF is successfully done");
                        }
@@ -609,8 +603,6 @@ int _display_unlock_state(char *state, char *flag)
        g_object_unref(msg);
        if (reply)
                g_object_unref(reply);
-
-       return ret;
 }
 
 static void handle_method_call(GDBusConnection *connection,
@@ -702,17 +694,25 @@ static void handle_method_call(GDBusConnection *connection,
                if (db_path)
                        free(db_path);
        } else if (g_strcmp0(method_name, "alarm_set_rtc_time") == 0) {
+               _display_lock_state(DEVICED_LCD_OFF, DEVICED_STAY_CUR_STATE, 0);
                ret = alarm_manager_alarm_set_rtc_time(parameters);
                g_dbus_method_invocation_return_value(invoc, g_variant_new("(i)", ret));
+               _display_unlock_state(DEVICED_LCD_OFF, DEVICED_SLEEP_MARGIN);
        } else if (g_strcmp0(method_name, "alarm_set_time") == 0) {
+               _display_lock_state(DEVICED_LCD_OFF, DEVICED_STAY_CUR_STATE, 0);
                ret = alarm_manager_alarm_set_time(parameters, pid);
                g_dbus_method_invocation_return_value(invoc, g_variant_new("(i)", ret));
+               _display_unlock_state(DEVICED_LCD_OFF, DEVICED_SLEEP_MARGIN);
        } else if (g_strcmp0(method_name, "alarm_set_time_with_propagation_delay") == 0) {
+               _display_lock_state(DEVICED_LCD_OFF, DEVICED_STAY_CUR_STATE, 0);
                ret = alarm_manager_alarm_set_time_with_propagation_delay(parameters, pid);
                g_dbus_method_invocation_return_value(invoc, g_variant_new("(i)", ret));
+               _display_unlock_state(DEVICED_LCD_OFF, DEVICED_SLEEP_MARGIN);
        } else if (g_strcmp0(method_name, "alarm_set_timezone") == 0) {
+               _display_lock_state(DEVICED_LCD_OFF, DEVICED_STAY_CUR_STATE, 0);
                ret = alarm_manager_alarm_set_timezone(parameters);
                g_dbus_method_invocation_return_value(invoc, g_variant_new("(i)", ret));
+               _display_unlock_state(DEVICED_LCD_OFF, DEVICED_SLEEP_MARGIN);
        } else if (g_strcmp0(method_name, "alarm_set_global") == 0) {
                ret = alarm_manager_alarm_set_global(parameters, uid);
                g_dbus_method_invocation_return_value(invoc, g_variant_new("(i)", ret));
index eb34c17..85f23b8 100644 (file)
@@ -38,8 +38,8 @@ bool _initialize_dbus(void);
 void _alarm_send_noti_to_application_by_dbus(const char *app_service_name,
                alarm_id_t alarm_id, int msec, uid_t uid);
 
-int _display_lock_state(char *state, char *flag, unsigned int timeout);
-int _display_unlock_state(char *state, char *flag);
+void _display_lock_state(char *state, char *flag, unsigned int timeout);
+void _display_unlock_state(char *state, char *flag);
 
 #ifdef __cplusplus
 }
index 4a20307..fd20049 100644 (file)
@@ -53,9 +53,7 @@ static gboolean __alarm_handler_idle(gpointer user_data)
                return false;
        }
 
-       LOGD("Lock the display not to enter LCD OFF");
-       if (_display_lock_state(DEVICED_LCD_OFF, DEVICED_STAY_CUR_STATE, 0) != ALARMMGR_RESULT_SUCCESS)
-               LOGE("_display_lock_state() is failed");
+       _display_lock_state(DEVICED_LCD_OFF, DEVICED_STAY_CUR_STATE, 0);
 
        if (g_dummy_timer_is_set == true) {
                LOGD("dummy alarm timer has expired.");
@@ -79,9 +77,7 @@ static gboolean __alarm_handler_idle(gpointer user_data)
 
        _rtc_set();
 
-       LOGD("Unlock the display from LCD OFF");
-       if (_display_unlock_state(DEVICED_LCD_OFF, DEVICED_SLEEP_MARGIN) != ALARMMGR_RESULT_SUCCESS)
-               LOGE("_display_unlock_state() is failed");
+       _display_unlock_state(DEVICED_LCD_OFF, DEVICED_SLEEP_MARGIN);
 
        return false;
 }
index 6849c0f..4ce7e5f 100755 (executable)
@@ -1873,8 +1873,7 @@ static gboolean __alarm_expired_directly(gpointer user_data)
 
        /* Expire alarms with duetime equal to newtime by force */
        if (alarm_info->due_time == *time_sec) {
-               if (_display_lock_state(DEVICED_LCD_OFF, DEVICED_STAY_CUR_STATE, 0) != ALARMMGR_RESULT_SUCCESS)
-                       LOGE("_display_lock_state() is failed");
+               _display_lock_state(DEVICED_LCD_OFF, DEVICED_STAY_CUR_STATE, 0);
 
                if (g_dummy_timer_is_set == true) {
                        LOGD("dummy alarm timer has expired.");
@@ -1886,8 +1885,7 @@ static gboolean __alarm_expired_directly(gpointer user_data)
                _alarm_schedule();
                _rtc_set();
 
-               if (_display_unlock_state(DEVICED_LCD_OFF, DEVICED_SLEEP_MARGIN) != ALARMMGR_RESULT_SUCCESS)
-                       LOGE("_display_unlock_state() is failed");
+               _display_unlock_state(DEVICED_LCD_OFF, DEVICED_SLEEP_MARGIN);
        }
 
        if (time_sec)