diff options
author | Jiwoong Im <jiwoong.im@samsung.com> | 2016-09-28 17:32:48 +0900 |
---|---|---|
committer | Jiwoong Im <jiwoong.im@samsung.com> | 2016-09-28 17:36:50 +0900 |
commit | 66804408240f1c312d1af9d4b9d05dce6c5231ef (patch) | |
tree | 8dc091fb3e91be5c41b658c4c2f871d02f2d115a | |
parent | 9a2dedc1f34c25b691fffe73223a1105c2024d10 (diff) | |
download | alarm-manager-66804408240f1c312d1af9d4b9d05dce6c5231ef.tar.gz alarm-manager-66804408240f1c312d1af9d4b9d05dce6c5231ef.tar.bz2 alarm-manager-66804408240f1c312d1af9d4b9d05dce6c5231ef.zip |
fix system time setting in tv profilesubmit/tizen/20160928.084653accepted/tizen/common/20160928.164447
Change-Id: I5ad368f964f33cc46bfc7cc86306db38a8a7a813
Signed-off-by: Jiwoong Im <jiwoong.im@samsung.com>
-rw-r--r-- | alarm-manager.c | 29 |
1 files changed, 14 insertions, 15 deletions
diff --git a/alarm-manager.c b/alarm-manager.c index 891ae34..8258c8d 100644 --- a/alarm-manager.c +++ b/alarm-manager.c @@ -266,13 +266,13 @@ static void __rtc_set() int __set_time(time_t _time) { + int ret = 0; + struct timeval tv; + struct tm tm, *gmtime_res; #ifdef _APPFW_FEATURE_WAKEUP_USING_RTC /* Using /dev/alarm, this function changes both OS time and RTC. */ - int ret = 0; const char *rtc0 = default_rtc; struct rtc_time _rtc_time; - struct timeval tv; - struct tm tm, *gmtime_res; #ifdef _APPFW_FEATURE_ALARM_MANAGER_MODULE_LOG char log_tag[ALARMMGR_LOG_TAG_SIZE] = {0,}; char log_message[ALARMMGR_LOG_MESSAGE_SIZE] = {0,}; @@ -288,13 +288,6 @@ int __set_time(time_t _time) } } - tv.tv_sec = _time; - tv.tv_usec = 0; - - gmtime_res = gmtime_r(&(tv.tv_sec), &tm); - if (!gmtime_res) - ALARM_MGR_EXCEPTION_PRINT("gmtime_r is failed. [%d]", errno); - memset(&_rtc_time, 0, sizeof(_rtc_time)); _rtc_time.tm_sec = tm.tm_sec; _rtc_time.tm_min = tm.tm_min; @@ -306,11 +299,6 @@ int __set_time(time_t _time) _rtc_time.tm_yday = tm.tm_yday; _rtc_time.tm_isdst = tm.tm_isdst; - - ret = settimeofday(&tv, NULL); - if (ret < 0) - ALARM_MGR_EXCEPTION_PRINT("settimeofday is failed.[%d]", errno); - ret = ioctl(gfd, RTC_SET_TIME, &_rtc_time); if (ret == -1) { ALARM_MGR_EXCEPTION_PRINT("ALARM_SET_RTC ioctl is failed. errno = %s", strerror_r(errno, buf, sizeof(buf))); @@ -334,6 +322,17 @@ int __set_time(time_t _time) #else ALARM_MGR_LOG_PRINT("[alarm-server] RTC does not work."); #endif /* _APPFW_FEATURE_WAKEUP_USING_RTC */ + tv.tv_sec = _time; + tv.tv_usec = 0; + + gmtime_res = gmtime_r(&(tv.tv_sec), &tm); + if (!gmtime_res) + ALARM_MGR_EXCEPTION_PRINT("gmtime_r is failed. [%d]", errno); + + ret = settimeofday(&tv, NULL); + if (ret < 0) + ALARM_MGR_EXCEPTION_PRINT("settimeofday is failed.[%d]", errno); + return 1; } |