summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHwankyu Jhun <h.jhun@samsung.com>2015-12-07 17:34:45 +0900
committerJiwoong Im <jiwoong.im@samsung.com>2015-12-08 14:32:07 +0900
commitaecbea763fc4c9bbaf48faacd0014b1ad378fdc8 (patch)
tree2b1b02f2546dc0a5e49f911c38cc8c451b0f486a
parentbb5484a3a939f06edb4bb5478cc234aa995af52b (diff)
downloadalarm-manager-aecbea763fc4c9bbaf48faacd0014b1ad378fdc8.tar.gz
alarm-manager-aecbea763fc4c9bbaf48faacd0014b1ad378fdc8.tar.bz2
alarm-manager-aecbea763fc4c9bbaf48faacd0014b1ad378fdc8.zip
- 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>
-rw-r--r--CMakeLists.txt3
-rw-r--r--alarm-manager.c25
-rw-r--r--org.tizen.alarm.manager.service.in5
-rw-r--r--packaging/alarm-manager.spec1
-rw-r--r--packaging/alarm-server.service2
-rw-r--r--src/alarm-lib-stub.c30
-rw-r--r--src/alarm-lib.c7
7 files changed, 65 insertions, 8 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index e00fb97..7e5447b 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -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/)
diff --git a/alarm-manager.c b/alarm-manager.c
index 954f0df..783ed25 100644
--- a/alarm-manager.c
+++ b/alarm-manager.c
@@ -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
index 0000000..a474264
--- /dev/null
+++ b/org.tizen.alarm.manager.service.in
@@ -0,0 +1,5 @@
+[D-BUS Service]
+Name=org.tizen.alarm.manager
+Exec=/bin/false
+SystemdService=alarm-server.service
+User=root
diff --git a/packaging/alarm-manager.spec b/packaging/alarm-manager.spec
index 41b12b3..e30c9c6 100644
--- a/packaging/alarm-manager.spec
+++ b/packaging/alarm-manager.spec
@@ -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}
diff --git a/packaging/alarm-server.service b/packaging/alarm-server.service
index 49bb577..7d9a6cd 100644
--- a/packaging/alarm-server.service
+++ b/packaging/alarm-server.service
@@ -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
diff --git a/src/alarm-lib-stub.c b/src/alarm-lib-stub.c
index 81eb4b9..9e0949d 100644
--- a/src/alarm-lib-stub.c
+++ b/src/alarm-lib-stub.c
@@ -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;
diff --git a/src/alarm-lib.c b/src/alarm-lib.c
index b829fcf..c8b7058 100644
--- a/src/alarm-lib.c
+++ b/src/alarm-lib.c
@@ -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;
}