Update alarm-manager source from tizen_2.4 19/53619/1 accepted/tizen/mobile/20151210.082842 accepted/tizen/tv/20151210.082858 accepted/tizen/wearable/20151210.082908 submit/tizen/20151210.025005
authorHwankyu Jhun <h.jhun@samsung.com>
Mon, 7 Dec 2015 08:34:45 +0000 (17:34 +0900)
committerJiwoong Im <jiwoong.im@samsung.com>
Tue, 8 Dec 2015 05:32:07 +0000 (14:32 +0900)
- Add dbus activation feature
- Revert settime api ti do not user compensating latency
- Expire alarms forcibly when real duetime is same to current time
- Fix prevent issue

Change-Id: I09c51cb395cbe340c646ea24bd75882761b080ab
Signed-off-by: Jiwoong Im <jiwoong.im@samsung.com>
CMakeLists.txt
alarm-manager.c
org.tizen.alarm.manager.service.in [new file with mode: 0644]
packaging/alarm-manager.spec
packaging/alarm-server.service
src/alarm-lib-stub.c
src/alarm-lib.c

index e00fb97..7e5447b 100644 (file)
@@ -54,3 +54,6 @@ IF(_APPFW_FEATURE_ALARM_MANAGER_MODULE_LOG)
        INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/alarmmgr_log_dump.sh DESTINATION ${SYSCONF_INSTALL_DIR}/dump.d/module.d/)
 ENDIF(_APPFW_FEATURE_ALARM_MANAGER_MODULE_LOG)
 INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/alarm-service.conf DESTINATION ${SYSCONF_INSTALL_DIR}/dbus-1/system.d/)
+
+CONFIGURE_FILE(org.tizen.alarm.manager.service.in org.tizen.alarm.manager.service @ONLY)
+INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/org.tizen.alarm.manager.service DESTINATION ${SHARE_INSTALL_PREFIX}/dbus-1/system-services/)
index 954f0df..783ed25 100644 (file)
@@ -1120,7 +1120,7 @@ static bool __can_skip_expired_cb(alarm_id_t alarm_id)
                        int dur = entry->requested_interval;
                        int from, to;
 
-                       if (!(alarm->alarm_type & ALARM_TYPE_PERIOD) || entry->method == CUT_OFF)
+                       if (dur == 0 || !(alarm->alarm_type & ALARM_TYPE_PERIOD) || entry->method == CUT_OFF)
                                return false;
 
                        ts_tm.tm_hour = alarm->start.hour;
@@ -1572,6 +1572,8 @@ static gboolean __alarm_handler_idle(gpointer user_data)
 {
        GPollFD *gpollfd = (GPollFD *) user_data;
        uint64_t exp;
+       time_t current_time;
+
        if (gpollfd == NULL) {
                ALARM_MGR_EXCEPTION_PRINT("gpollfd is NULL");
                return false;
@@ -1597,6 +1599,17 @@ static gboolean __alarm_handler_idle(gpointer user_data)
 
        _alarm_schedule();
 
+       /*
+        * Previous alarm can be expired late as tolerance of RTC.
+        * In this case, Expire alarms forcibly if real duetime is same to current time.
+        */
+       time(&current_time);
+       if (alarm_context.c_due_time == current_time) {
+               ALARM_MGR_LOG_PRINT("Expire alarms forcibly when duetime is same to current time(%d).", current_time)
+               __alarm_expired();
+               _alarm_schedule();
+       }
+
        __rtc_set();
 
        ALARM_MGR_LOG_PRINT("Unlock the display from LCD OFF");
@@ -1871,7 +1884,8 @@ int __display_lock_state(char *state, char *flag, unsigned int timeout)
 
        g_dbus_connection_flush_sync(alarm_context.connection, NULL, NULL);
        g_object_unref(msg);
-       g_object_unref(reply);
+       if (reply)
+               g_object_unref(reply);
 
        return ret;
 }
@@ -1914,7 +1928,8 @@ int __display_unlock_state(char *state, char *flag)
 
        g_dbus_connection_flush_sync(alarm_context.connection, NULL, NULL);
        g_object_unref(msg);
-       g_object_unref(reply);
+       if (reply)
+               g_object_unref(reply);
 
        return ret;
 }
@@ -3133,6 +3148,10 @@ static void __initialize_timer()
        src = g_source_new(&funcs, sizeof(GSource));
 
        gpollfd = (GPollFD *) g_malloc(sizeof(GPollFD));
+       if (gpollfd == NULL) {
+               ALARM_MGR_EXCEPTION_PRINT("Out of memory\n");
+               exit(1);
+       }
        gpollfd->events = POLLIN;
        gpollfd->fd = fd;
 
diff --git a/org.tizen.alarm.manager.service.in b/org.tizen.alarm.manager.service.in
new file mode 100644 (file)
index 0000000..a474264
--- /dev/null
@@ -0,0 +1,5 @@
+[D-BUS Service]
+Name=org.tizen.alarm.manager
+Exec=/bin/false
+SystemdService=alarm-server.service
+User=root
index 41b12b3..e30c9c6 100644 (file)
@@ -109,6 +109,7 @@ chown system:system /var/log/alarmmgr.log
 %attr(0755,root,root) %{_bindir}/alarm-server
 %attr(0644,root,root) %{_unitdir}/alarm-server.service
 %{_unitdir}/multi-user.target.wants/alarm-server.service
+%attr(0644,root,root) %{_datadir}/dbus-1/system-services/org.tizen.alarm.manager.service
 %license LICENSE
 %config %{_sysconfdir}/dbus-1/system.d/alarm-service.conf
 %if 0%{?appfw_feature_alarm_manager_module_log}
index 49bb577..7d9a6cd 100644 (file)
@@ -3,6 +3,8 @@ Description=Alarm server
 After=system-server.service
 
 [Service]
+BusName=org.tizen.alarm.manager
+Type=dbus
 ExecStart=/usr/bin/alarm-server
 TimeoutStopSec=3s
 Restart=always
index 81eb4b9..9e0949d 100644 (file)
@@ -555,6 +555,36 @@ bool _send_alarm_get_all_info(alarm_context_t context, char ** db_path, int *err
        return true;
 }
 
+bool _send_alarm_set_time(alarm_context_t context, int new_time, int *error_code)
+{
+       GError *error = NULL;
+       int return_code = 0;
+
+       if (!alarm_manager_call_alarm_set_time_sync((AlarmManager *)context.proxy, new_time, &return_code, NULL, &error)) {
+               /*g_dbus_proxy_call_sync error */
+               /*error_code should be set */
+               ALARM_MGR_EXCEPTION_PRINT("alarm_manager_call_alarm_set_time_sync() failed by dbus. return_code[%d]", return_code);
+               if (error) {
+                       ALARM_MGR_EXCEPTION_PRINT("dbus error message: %s", error->message);
+                       g_error_free(error);
+               }
+               if (error_code) {
+                       *error_code = ERR_ALARM_SYSTEM_FAIL;
+               }
+               return false;
+       }
+
+       if (return_code != ALARMMGR_RESULT_SUCCESS) {
+               if (error_code) {
+                       *error_code = return_code;
+               }
+               return false;
+       }
+
+       return true;
+}
+
+
 bool _send_alarm_set_time_with_propagation_delay(alarm_context_t context, unsigned int new_sec, unsigned int new_nsec, unsigned int req_sec, unsigned int req_nsec, int *error_code)
 {
        GError *error = NULL;
index b829fcf..c8b7058 100644 (file)
@@ -1189,7 +1189,6 @@ EXPORT_API int alarmmgr_remove_alarm(alarm_id_t alarm_id)
        int error_code;
        int ret;
        alarm_cb_info_t *info;
-       alarm_info_t alarm;
 
        ret = __sub_init();
        if (ret < 0)
@@ -1530,16 +1529,14 @@ EXPORT_API int alarmmgr_add_reference_periodic_alarm_withcb(int interval,
 EXPORT_API int alarmmgr_set_systime(int new_time)
 {
        int error_code;
-       struct timespec req_time = {0,};
        ALARM_MGR_LOG_PRINT("[alarm-lib]:alarmmgr_set_systime(%d) is called.", new_time);
 
        if (__sub_init() < 0) {
                return ERR_ALARM_SYSTEM_FAIL;
        }
 
-       clock_gettime(CLOCK_REALTIME, &req_time);
-       if (!_send_alarm_set_time_with_propagation_delay(alarm_context, new_time, 0, req_time.tv_sec, req_time.tv_nsec, &error_code)) {
-               ALARM_MGR_EXCEPTION_PRINT("Failed to set time with propagation delay. error: %d", error_code);
+       if (!_send_alarm_set_time(alarm_context, new_time, &error_code)) {
+               ALARM_MGR_EXCEPTION_PRINT("Failed to set time. error: %d", error_code);
                return error_code;
        }