#include <unistd.h>
#include <errno.h>
#include <linux/rtc.h>
-#include <sys/ioctl.h>
#include <fcntl.h>
+#include <dlfcn.h>
#include <tzplatform_config.h>
#include <aul.h>
#define _APPFW_FEATURE_WAKEUP_USING_RTC (_get_profile() != PROFILE_TV)
+#define PATH_LIB_ALARMMGR_PLUGIN "/usr/lib/libalarm-server-plugin.so"
-static const char default_rtc[] = "/dev/rtc";
-static int gfd = -1;
+static void *plugin_handle;
+static int (*RTC_INIT)(void);
+static int (*CLEAR_WAKEUP_RTC)(void);
+static int (*SET_WAKEUP_RTC)(time_t due_time);
+static int (*SET_WAKEUP_RTC_WITH_DATETIME)(struct tm *tm);
+static int (*SET_SYSTIME_RTC)(time_t new_time);
+static void (*DO_AFTER_TIMEZONE_SET)(void);
+static void (*DO_AFTER_ALARM_CREATE)(int pid, const char *unique_name);
+static void (*DO_AFTER_ALARM_EXPIRE)(int pid, const char *unique_name);
+static int (*PS_MODE_INIT)(void);
+static int (*GET_POWER_SAVING_MODE)(void);
__alarm_server_context_t alarm_context;
void _rtc_set()
{
if (_APPFW_FEATURE_WAKEUP_USING_RTC) {
- const char *rtc = default_rtc;
- struct tm due_tm;
char log_message[ALARMMGR_LOG_MESSAGE_SIZE] = {0,};
#ifdef _SIMUL /* RTC does not work in simulator. */
LOGE("because it is simulator's mode, we don't set RTC.");
return;
#endif
- if (gfd < 0) {
- gfd = open(rtc, O_RDWR);
- if (gfd < 0) {
- LOGE("RTC open failed.");
- return;
- }
- }
-
/* Read the RTC time/date */
int retval = 0;
char buf[1024];
LOGD("alarm_context.c_due_time is %d.", (int)alarm_context.c_due_time);
if (alarm_context.c_due_time != -1) {
- struct rtc_wkalrm rtc_wkalarm = { 0, };
- rtc_wkalarm.enabled = 0;
- rtc_wkalarm.time.tm_year = 1900;
- rtc_wkalarm.time.tm_mon = 0;
- rtc_wkalarm.time.tm_mday = 1;
- rtc_wkalarm.time.tm_hour = 0;
- rtc_wkalarm.time.tm_min = 0;
- rtc_wkalarm.time.tm_sec = 0;
-
- retval = ioctl(gfd, RTC_WKALM_SET, &rtc_wkalarm);
+ retval = CLEAR_WAKEUP_RTC();
if (retval == -1) {
if (errno == ENOTTY)
LOGE("Alarm IRQs is not supported.");
}
LOGD("[alarm-server]RTC_WKALM_SET disabled ioctl is successfully done.");
- time_t due_time = alarm_context.c_due_time;
- gmtime_r(&due_time, &due_tm);
-
- LOGD("Setted RTC Alarm date/time is %d-%d-%d, %02d:%02d:%02d (UTC).",
- due_tm.tm_mday, due_tm.tm_mon + 1, due_tm.tm_year + 1900,
- due_tm.tm_hour, due_tm.tm_min, due_tm.tm_sec);
-
- rtc_wkalarm.enabled = 1;
- rtc_wkalarm.time.tm_year = due_tm.tm_year;
- rtc_wkalarm.time.tm_mon = due_tm.tm_mon;
- rtc_wkalarm.time.tm_mday = due_tm.tm_mday;
- rtc_wkalarm.time.tm_hour = due_tm.tm_hour;
- rtc_wkalarm.time.tm_min = due_tm.tm_min;
- rtc_wkalarm.time.tm_sec = due_tm.tm_sec;
- retval = ioctl(gfd, RTC_WKALM_SET, &rtc_wkalarm);
+ retval = SET_WAKEUP_RTC(alarm_context.c_due_time);
if (retval == -1) {
if (errno == ENOTTY)
LOGE("Alarm IRQs is not supported.");
{
int ret = 0;
struct timeval tv;
- struct tm tm, *gmtime_res;
-
tv.tv_sec = _time;
tv.tv_usec = 0;
- gmtime_res = gmtime_r(&(tv.tv_sec), &tm);
- if (!gmtime_res) {
- LOGE("gmtime_r is failed. [%d]", errno);
- return false;
- }
-
ret = settimeofday(&tv, NULL);
if (ret < 0) {
LOGE("settimeofday is failed.[%d]", errno);
}
if (_APPFW_FEATURE_WAKEUP_USING_RTC) {
- const char *rtc0 = default_rtc;
- struct rtc_time _rtc_time;
char buf[1024];
char log_tag[ALARMMGR_LOG_TAG_SIZE] = {0,};
char log_message[ALARMMGR_LOG_MESSAGE_SIZE] = {0,};
_time, timebuf);
}
- if (gfd < 0) {
- gfd = open(rtc0, O_RDWR);
- if (gfd < 0) {
- LOGE("Opening the /dev/rtc is failed.");
- return false;
- }
- }
-
- memset(&_rtc_time, 0, sizeof(_rtc_time));
- _rtc_time.tm_sec = tm.tm_sec;
- _rtc_time.tm_min = tm.tm_min;
- _rtc_time.tm_hour = tm.tm_hour;
- _rtc_time.tm_mday = tm.tm_mday;
- _rtc_time.tm_mon = tm.tm_mon;
- _rtc_time.tm_year = tm.tm_year;
- _rtc_time.tm_wday = tm.tm_wday;
- _rtc_time.tm_yday = tm.tm_yday;
- _rtc_time.tm_isdst = tm.tm_isdst;
-
- ret = ioctl(gfd, RTC_SET_TIME, &_rtc_time);
+ ret = SET_SYSTIME_RTC(_time);
if (ret == -1) {
LOGE("ALARM_SET_RTC ioctl is failed. errno = %s", strerror_r(errno, buf, sizeof(buf)));
strncpy(log_tag, "FAIL: SET RTC", sizeof(log_tag) - 1);
if (!_save_alarms(__alarm_info))
LOGE("Saving alarm_id(%d) in DB is failed.", __alarm_info->alarm_id);
}
+
+ DO_AFTER_ALARM_CREATE(__alarm_info->pid, __alarm_info->app_unique_name);
}
static bool __check_bundle_for_update(const gchar *b_data, uid_t uid)
_save_alarm_info_log("EXPIRED", __alarm_info);
+ DO_AFTER_ALARM_EXPIRE(__alarm_info->pid, __alarm_info->app_unique_name);
+
if (__alarm_info->alarm_info.mode.repeat == ALARM_REPEAT_MODE_ONCE) {
__alarm_remove_from_list(__alarm_info->uid, __alarm_info->alarm_id, NULL);
} else {
return 0;
}
+static int __on_app_installed(uid_t target_uid, int req_id, const char *pkg_type,
+ const char *pkgid, const char *key, const char *val,
+ const void *pmsg, void *user_data)
+{
+ GSList *gs_iter = NULL;
+ __alarm_info_t *entry = NULL;
+ bool is_restored = false;
+
+ if (GET_POWER_SAVING_MODE() == -1)
+ return ALARMMGR_RESULT_SUCCESS;
+
+ if ((key && strncmp(key, "end", 3) != 0) || (val && strncmp(val, "ok", 2) != 0))
+ return ALARMMGR_RESULT_SUCCESS;
+
+ if (g_slist_length(g_disabled_alarm_list) == 0)
+ return ALARMMGR_RESULT_SUCCESS;
+
+ for (gs_iter = g_disabled_alarm_list; gs_iter != NULL; ) {
+ entry = gs_iter->data;
+
+ const char *caller_pkgid = entry->caller_pkgid;
+ const char *callee_pkgid = entry->callee_pkgid;
+
+ gs_iter = g_slist_next(gs_iter);
+ if ((caller_pkgid && strncmp(pkgid, caller_pkgid, strlen(pkgid)) == 0) ||
+ (callee_pkgid && strncmp(pkgid, callee_pkgid, strlen(pkgid)) == 0)) {
+ _alarm_set_next_duetime(entry);
+ alarm_context.alarms = g_slist_append(alarm_context.alarms, entry);
+ g_disabled_alarm_list = g_slist_remove(g_disabled_alarm_list, entry);
+
+ if (!(entry->alarm_info.alarm_type & ALARM_TYPE_VOLATILE))
+ _update_db_for_disabled_alarm(entry->alarm_id, false);
+ is_restored = true;
+ }
+ }
+
+ if (is_restored) {
+ _alarm_disable_timer(alarm_context);
+ _clear_scheduled_alarm_list();
+ _alarm_schedule();
+ _rtc_set();
+ }
+
+ return ALARMMGR_RESULT_SUCCESS;
+}
+
static int __on_app_uninstalled(uid_t target_uid, int req_id, const char *pkg_type,
const char *pkgid, const char *key, const char *val,
const void *pmsg, void *user_data)
__alarm_info_t *entry = NULL;
alarm_info_t *alarm_info = NULL;
bool is_deleted = false;
+ int is_power_saving_mode;
SECURE_LOGD("pkg_type(%s), pkgid(%s), key(%s), value(%s)", pkg_type, pkgid, key, val);
- if (strncmp(key, "end", 3) == 0 && strncmp(val, "ok", 2) == 0) {
- for (gs_iter = alarm_context.alarms; gs_iter != NULL;) {
- entry = (__alarm_info_t *)gs_iter->data;
+ if ((key && strncmp(key, "end", 3) != 0) || (val && strncmp(val, "ok", 2) != 0))
+ return ALARMMGR_RESULT_SUCCESS;
- const char *caller_pkgid = entry->caller_pkgid;
- const char *callee_pkgid = entry->callee_pkgid;
- int pid = _get_pid_from_appid(entry->app_unique_name, entry->uid);
+ is_power_saving_mode = GET_POWER_SAVING_MODE();
- gs_iter = g_slist_next(gs_iter);
- if ((caller_pkgid && strncmp(pkgid, caller_pkgid, strlen(pkgid)) == 0) ||
- (callee_pkgid && strncmp(pkgid, callee_pkgid, strlen(pkgid)) == 0)) {
- if (_remove_from_scheduled_alarm_list(entry->uid, entry->alarm_id))
- is_deleted = true;
-
- alarm_info = &entry->alarm_info;
- if (!(alarm_info->alarm_type & ALARM_TYPE_VOLATILE)) {
- if (!_delete_alarms(entry->alarm_id))
- SECURE_LOGE("_delete_alarms() is failed. pkgid[%s], alarm_id[%d]", pkgid, entry->alarm_id);
- }
+ for (gs_iter = alarm_context.alarms; gs_iter != NULL;) {
+ entry = (__alarm_info_t *)gs_iter->data;
+
+ const char *caller_pkgid = entry->caller_pkgid;
+ const char *callee_pkgid = entry->callee_pkgid;
+ int pid = _get_pid_from_appid(entry->app_unique_name, entry->uid);
+ gs_iter = g_slist_next(gs_iter);
+ if ((caller_pkgid && strncmp(pkgid, caller_pkgid, strlen(pkgid)) == 0) ||
+ (callee_pkgid && strncmp(pkgid, callee_pkgid, strlen(pkgid)) == 0)) {
+ if (_remove_from_scheduled_alarm_list(entry->uid, entry->alarm_id))
+ is_deleted = true;
+
+ alarm_info = &entry->alarm_info;
+ if (!(alarm_info->alarm_type & ALARM_TYPE_VOLATILE)) {
+ if (is_power_saving_mode == 1)
+ _update_db_for_disabled_alarm(entry->alarm_id, true);
+ else
+ _delete_alarms(entry->alarm_id);
+ }
+
+ if (is_power_saving_mode == 1) {
+ LOGD("Save pkgid[%s] alarm_id[%d] duetime[%ld]", pkgid, entry->alarm_id, entry->due_time);
+ g_disabled_alarm_list = g_slist_append(g_disabled_alarm_list, entry);
+ alarm_context.alarms = g_slist_remove(alarm_context.alarms, entry);
+ } else {
if (g_hash_table_remove(caller_appid_cache_table, GINT_TO_POINTER(pid)) == true)
LOGD("Remove cachd data of pid[%d]", pid);
- SECURE_LOGD("Remove pkgid[%s], alarm_id[%d]", pkgid, entry->alarm_id);
+ LOGD("Remove pkgid[%s], alarm_id[%d]", pkgid, entry->alarm_id);
alarm_context.alarms = g_slist_remove(alarm_context.alarms, entry);
_release_alarm_info_t(entry);
-
}
}
+ }
- if (is_deleted && (g_slist_length(g_scheduled_alarm_list) == 0)) {
- _alarm_disable_timer();
- _alarm_schedule();
- _rtc_set();
- }
+ if (is_deleted && (g_slist_length(g_scheduled_alarm_list) == 0)) {
+ _alarm_disable_timer();
+ _alarm_schedule();
+ _rtc_set();
}
return ALARMMGR_RESULT_SUCCESS;
int alarm_manager_alarm_set_rtc_time(GVariant *parameters)
{
if (_APPFW_FEATURE_WAKEUP_USING_RTC) {
- const char *rtc = default_rtc;
- struct rtc_wkalrm rtc_wkalarm;
int retval = 0;
struct tm tm, *alarm_tm = NULL;
char log_tag[ALARMMGR_LOG_TAG_SIZE] = {0,};
alarm_tm->tm_min = min;
alarm_tm->tm_sec = sec;
- /*convert to calendar time representation*/
- time_t rtc_time = mktime(alarm_tm);
-
- if (gfd < 0) {
- gfd = open(rtc, O_RDWR);
- if (gfd < 0) {
- LOGE("RTC open failed.");
- return ERR_ALARM_SYSTEM_FAIL;
- }
- }
-
- rtc_wkalarm.enabled = 1;
- rtc_wkalarm.time.tm_year = year;
- rtc_wkalarm.time.tm_mon = mon;
- rtc_wkalarm.time.tm_mday = day;
- rtc_wkalarm.time.tm_hour = hour;
- rtc_wkalarm.time.tm_min = min;
- rtc_wkalarm.time.tm_sec = sec;
-
- retval = ioctl(gfd, RTC_WKALM_SET, &rtc_wkalarm);
+ retval = SET_WAKEUP_RTC_WITH_DATETIME(alarm_tm);
if (retval == -1) {
if (errno == ENOTTY)
LOGE("Alarm IRQs is not supported.");
strncpy(log_tag, "SET RTC", sizeof(log_tag) - 1);
}
+ /*convert to calendar time representation*/
+ time_t rtc_time = mktime(alarm_tm);
+
snprintf(log_message, sizeof(log_message), "wakeup rtc time: %ld, %s", rtc_time, ctime(&rtc_time));
_save_module_log(log_tag, log_message);
return return_code;
}
tzset();
+ DO_AFTER_TIMEZONE_SET();
/* Rescheduling alarms */
_alarm_disable_timer();
/* If the caller or callee app is uninstalled, all registered alarms will be canceled. */
pkgmgr_client *pc = pkgmgr_client_new(PC_LISTENING);
+
+ pkgmgr_client_set_status_type(pc, PKGMGR_CLIENT_STATUS_INSTALL);
+ pkgmgr_client_listen_status(pc, __on_app_installed, NULL);
+
pkgmgr_client_set_status_type(pc, PKGMGR_CLIENT_STATUS_UNINSTALL);
pkgmgr_client_listen_status(pc, __on_app_uninstalled, NULL);
pkgmgr_client_listen_app_status(pc, __on_app_disable_cb, NULL);
}
+static int __load_module(const char *path)
+{
+ plugin_handle = dlopen(path, RTLD_LAZY | RTLD_GLOBAL);
+ if (!plugin_handle) {
+ LOGE("Failed to load - %s", dlerror());
+ return -1;
+ }
+
+ if (_APPFW_FEATURE_WAKEUP_USING_RTC) {
+ RTC_INIT = dlsym(plugin_handle, "RTC_INIT");
+ if (!RTC_INIT) {
+ LOGE("Failed to find PLUGIN_INIT");
+ goto out;
+ }
+
+ CLEAR_WAKEUP_RTC = dlsym(plugin_handle, "CLEAR_WAKEUP_RTC");
+ if (!CLEAR_WAKEUP_RTC) {
+ LOGE("Failed to find CLEAR_WAKEUP_RTC");
+ goto out;
+ }
+
+ SET_WAKEUP_RTC = dlsym(plugin_handle, "SET_WAKEUP_RTC");
+ if (!SET_WAKEUP_RTC) {
+ LOGE("Failed to find SET_WAKEUP_RTC");
+ goto out;
+ }
+
+ SET_WAKEUP_RTC_WITH_DATETIME = dlsym(plugin_handle,
+ "SET_WAKEUP_RTC_WITH_DATETIME");
+ if (!SET_WAKEUP_RTC_WITH_DATETIME) {
+ LOGE("Failed to find SET_WAKEUP_RTC_WITH_DATETIME");
+ goto out;
+ }
+
+ SET_SYSTIME_RTC = dlsym(plugin_handle, "SET_SYSTIME_RTC");
+ if (!SET_SYSTIME_RTC) {
+ LOGE("Failed to find SET_SYSTIME_RTC");
+ goto out;
+ }
+ }
+
+ DO_AFTER_TIMEZONE_SET = dlsym(plugin_handle, "DO_AFTER_TIMEZONE_SET");
+ if (!DO_AFTER_TIMEZONE_SET) {
+ LOGE("Failed to find DO_AFTER_TIMEZONE_SET");
+ goto out;
+ }
+
+ DO_AFTER_ALARM_CREATE = dlsym(plugin_handle, "DO_AFTER_ALARM_CREATE");
+ if (!DO_AFTER_ALARM_CREATE) {
+ LOGE("Failed to find DO_AFTER_ALARM_CREATE");
+ goto out;
+ }
+
+ DO_AFTER_ALARM_EXPIRE = dlsym(plugin_handle, "DO_AFTER_ALARM_EXPIRE");
+ if (!DO_AFTER_ALARM_EXPIRE) {
+ LOGE("Failed to find DO_AFTER_ALARM_EXPIRE");
+ goto out;
+ }
+
+ PS_MODE_INIT = dlsym(plugin_handle, "PS_MODE_INIT");
+ if (!PS_MODE_INIT) {
+ LOGE("Failed to init PS_MODE_INIT");
+ goto out;
+ }
+
+ GET_POWER_SAVING_MODE = dlsym(plugin_handle, "GET_POWER_SAVING_MODE");
+ if (!GET_POWER_SAVING_MODE) {
+ LOGE("Failed to find IS_POWER_SAVING_MODE");
+ goto out;
+ }
+
+ return 0;
+
+out:
+ if (plugin_handle)
+ dlclose(plugin_handle);
+
+ return -1;
+}
+
void _alarm_initialize()
{
#if !(GLIB_CHECK_VERSION(2, 36, 0))
alarm_context.timer = _initialize_timer();
if (alarm_context.timer == -1) {
LOGE("because _initialize_timer failed, "
- "alarm-server cannot be runned.\n");
+ "alarm-server cannot be runned.\n");
exit(1);
}
/* because dbus's initialize
* failed, we cannot continue any more. */
LOGE("because _initialize_dbus failed, "
- "alarm-server cannot be runned.\n");
+ "alarm-server cannot be runned.\n");
exit(1);
}
__initialize_scheduled_alarm_list();
if (_initialize_db() == false) {
LOGE("_initialize_db failed, "
- "alarm cannot be stored to database.\n");
+ "alarm cannot be stored to database.\n");
+ }
+
+ if (__load_module(PATH_LIB_ALARMMGR_PLUGIN) != 0) {
+ LOGE("_load_module failed");
+ exit(1);
+ }
+
+ if (_APPFW_FEATURE_WAKEUP_USING_RTC) {
+ if (RTC_INIT() != 0) {
+ LOGE("rtc init failed");
+ exit(1);
+ }
}
+
+ if (PS_MODE_INIT() != 0) {
+ LOGE("power saving mode init failed");
+ exit(1);
+ }
+
__initialize_alarm_list();
__initialize_noti();
caller_appid_cache_table = g_hash_table_new_full(g_direct_hash,
g_direct_equal, NULL, __free_cached_value);
}
+
+ if (_APPFW_FEATURE_WAKEUP_USING_RTC) {
+ tzset();
+ DO_AFTER_TIMEZONE_SET();
+ }
}
void _release_alarm_info_t(__alarm_info_t *entry)
free(entry->app_service_name_mod);
if (entry->dst_service_name)
free(entry->dst_service_name);
-
if (entry->dst_service_name_mod)
free(entry->dst_service_name_mod);
if (entry->bundle)
--- /dev/null
+/*
+ * Copyright (c) 2020 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <stdbool.h>
+#include <fcntl.h>
+#include <time.h>
+#include <errno.h>
+#include <dlog.h>
+#include <sys/ioctl.h>
+#include <sys/stat.h>
+#include <linux/rtc.h>
+
+#include "plugin.h"
+
+static const char default_rtc[] = "/dev/rtc";
+int gfd = -1;
+int is_psm = -1;
+
+EXPORT int CLEAR_WAKEUP_RTC(void)
+{
+ struct rtc_wkalrm rtc_wkalarm;
+
+ rtc_wkalarm.enabled = 0;
+ rtc_wkalarm.time.tm_year = 1900;
+ rtc_wkalarm.time.tm_mon = 0;
+ rtc_wkalarm.time.tm_mday = 1;
+ rtc_wkalarm.time.tm_hour = 0;
+ rtc_wkalarm.time.tm_min = 0;
+ rtc_wkalarm.time.tm_sec = 0;
+
+ return ioctl(gfd, RTC_WKALM_SET, &rtc_wkalarm);
+}
+
+EXPORT int SET_WAKEUP_RTC(time_t due_time)
+{
+ struct rtc_wkalrm rtc_wkalarm;
+ struct tm due_tm;
+
+ gmtime_r(&due_time, &due_tm);
+ LOGD("Setted RTC Alarm date/time is %d-%d-%d, %02d:%02d:%02d (UTC).",
+ due_tm.tm_mday, due_tm.tm_mon + 1, due_tm.tm_year + 1900,
+ due_tm.tm_hour, due_tm.tm_min, due_tm.tm_sec);
+
+ rtc_wkalarm.enabled = 1;
+ rtc_wkalarm.time.tm_year = due_tm.tm_year;
+ rtc_wkalarm.time.tm_mon = due_tm.tm_mon;
+ rtc_wkalarm.time.tm_mday = due_tm.tm_mday;
+ rtc_wkalarm.time.tm_hour = due_tm.tm_hour;
+ rtc_wkalarm.time.tm_min = due_tm.tm_min;
+ rtc_wkalarm.time.tm_sec = due_tm.tm_sec;
+
+ return ioctl(gfd, RTC_WKALM_SET, &rtc_wkalarm);
+}
+
+EXPORT int SET_WAKEUP_RTC_WITH_DATETIME(struct tm *tm)
+{
+ struct rtc_wkalrm rtc_wkalarm;
+
+ rtc_wkalarm.enabled = 1;
+ rtc_wkalarm.time.tm_year = tm->tm_year;
+ rtc_wkalarm.time.tm_mon = tm->tm_mon;
+ rtc_wkalarm.time.tm_mday = tm->tm_mday;
+ rtc_wkalarm.time.tm_hour = tm->tm_hour;
+ rtc_wkalarm.time.tm_min = tm->tm_min;
+ rtc_wkalarm.time.tm_sec = tm->tm_sec;
+
+ return ioctl(gfd, RTC_WKALM_SET, &rtc_wkalarm);
+}
+
+EXPORT int SET_SYSTIME_RTC(time_t new_time)
+{
+ struct tm tm, *gmtime_res;
+ struct rtc_time _rtc_time;
+
+ gmtime_res = gmtime_r(&(new_time), &tm);
+ if (!gmtime_res) {
+ LOGE("gmtime_r is failed. [%d]", errno);
+ return -1;
+ }
+
+ _rtc_time.tm_sec = tm.tm_sec;
+ _rtc_time.tm_min = tm.tm_min;
+ _rtc_time.tm_hour = tm.tm_hour;
+ _rtc_time.tm_mday = tm.tm_mday;
+ _rtc_time.tm_mon = tm.tm_mon;
+ _rtc_time.tm_year = tm.tm_year;
+ _rtc_time.tm_wday = tm.tm_wday;
+ _rtc_time.tm_yday = tm.tm_yday;
+ _rtc_time.tm_isdst = tm.tm_isdst;
+
+ return ioctl(gfd, RTC_SET_TIME, &_rtc_time);
+}
+
+EXPORT void DO_AFTER_TIMEZONE_SET(void)
+{
+ return;
+}
+
+EXPORT void DO_AFTER_ALARM_CREATE(int pid, const char *unique_name)
+{
+ return;
+}
+
+EXPORT void DO_AFTER_ALARM_EXPIRE(int pid, const char *unique_name)
+{
+ return;
+}
+
+EXPORT int GET_POWER_SAVING_MODE(void)
+{
+ return is_psm;
+}
+
+EXPORT int RTC_INIT(void)
+{
+ const char *rtc = default_rtc;
+
+ if (gfd < 0) {
+ gfd = open(rtc, O_RDWR);
+ if (gfd < 0) {
+ LOGE("RTC open failed.");
+ return -1;
+ }
+ }
+
+ return 0;
+}
+
+EXPORT int PS_MODE_INIT(void)
+{
+ return 0;
+}