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,};
}
}
- 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;
_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)));
#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;
}