summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorInkyun Kil <inkyun.kil@samsung.com>2018-08-13 09:11:53 +0900
committerInkyun Kil <inkyun.kil@samsung.com>2018-08-13 09:13:19 +0900
commita365dc864dc3c5180de7417659d59864a8ffe583 (patch)
tree9684e1ba78020d64e7640005e35561bf981653ad
parentddbeab2d39a19a62bb3361aff98cad70cd893107 (diff)
downloadalarm-manager-a365dc864dc3c5180de7417659d59864a8ffe583.tar.gz
alarm-manager-a365dc864dc3c5180de7417659d59864a8ffe583.tar.bz2
alarm-manager-a365dc864dc3c5180de7417659d59864a8ffe583.zip
Revert "Change return values"
This reverts commit ad90ebd48ffca109e96f9945d38786784c10033a. Change-Id: If48e5bbb5da44fc78affb671c4bb783d010f788c Signed-off-by: Inkyun Kil <inkyun.kil@samsung.com>
-rw-r--r--alarm-manager.c231
1 files changed, 141 insertions, 90 deletions
diff --git a/alarm-manager.c b/alarm-manager.c
index cd8a071..66e7fd0 100644
--- a/alarm-manager.c
+++ b/alarm-manager.c
@@ -881,89 +881,13 @@ static void __set_caller_info(bundle *b, int pid, uid_t uid,
}
}
-static bool __alarm_add_and_set(__alarm_info_t *alarm_info)
+static bool __alarm_create_appsvc(alarm_info_t *alarm_info, alarm_id_t *alarm_id,
+ long requested_interval, uid_t uid, int pid, char *bundle_data, int *error_code)
{
time_t current_time;
time_t due_time;
struct tm ts_ret;
char due_time_r[100] = { 0 };
-
- time(&current_time);
-
- SECURE_LOGD("[alarm-server]:pid=%d, app_unique_name=%s, \
- app_service_name=%s,dst_service_name=%s, c_due_time=%ld",
- alarm_info->pid, alarm_info->app_unique_name,
- alarm_info->app_service_name,
- alarm_info->dst_service_name,
- alarm_context.c_due_time);
-
- if (alarm_context.c_due_time < current_time) {
- ALARM_MGR_EXCEPTION_PRINT("Caution!! alarm_context.c_due_time \
- (%ld) is less than current time(%ld)", alarm_context.c_due_time, current_time);
- alarm_context.c_due_time = -1;
- }
-
- due_time = _alarm_next_duetime(alarm_info);
-
- if (due_time == 0) {
- ALARM_MGR_EXCEPTION_PRINT("[alarm-server]:Create a new alarm: \
- due_time is 0. [alarm(%d):repeat_type(%d)]",
- alarm_info->alarm_id, alarm_info->alarm_info.mode.repeat);
-
- if (alarm_info->alarm_info.mode.repeat == ALARM_REPEAT_MODE_ONCE)
- return false;
-
- __alarm_add_to_list(alarm_info);
- return true;
- } else if (current_time == due_time) {
- ALARM_MGR_EXCEPTION_PRINT("[alarm-server]:Create alarm: \
- current_time(%ld) is same as due_time(%ld) [alarm(%d):repeat_type(%d)]",
- current_time, due_time, alarm_info->alarm_id, alarm_info->alarm_info.mode.repeat);
-
- if (alarm_info->alarm_info.mode.repeat == ALARM_REPEAT_MODE_ONCE)
- return false;
-
- __alarm_add_to_list(alarm_info);
- return true;
- } else if (difftime(due_time, current_time) < 0) {
- ALARM_MGR_EXCEPTION_PRINT("[alarm-server]: Expired Due Time. \
- [Due time=%ld, Current Time=%ld]!!!Do not add to schedule list. \
- [alarm(%d):repeat_type(%d)]",
- due_time, current_time, alarm_info->alarm_id, alarm_info->alarm_info.mode.repeat);
-
- if (alarm_info->alarm_info.mode.repeat == ALARM_REPEAT_MODE_ONCE)
- return false;
-
- __alarm_add_to_list(alarm_info);
- return true;
- } else {
- localtime_r(&due_time, &ts_ret);
- strftime(due_time_r, 30, "%c", &ts_ret);
- SECURE_LOGD("[alarm-server]:Create a new alarm: alarm(%d) due_time(%s)",
- alarm_info->alarm_id, due_time_r);
-
- __alarm_add_to_list(alarm_info);
- }
-
- ALARM_MGR_LOG_PRINT("[alarm-server]:alarm_context.c_due_time(%ld), due_time(%ld)",
- alarm_context.c_due_time, due_time);
-
- if (alarm_context.c_due_time == -1 || due_time < alarm_context.c_due_time) {
- _clear_scheduled_alarm_list();
- _add_to_scheduled_alarm_list(alarm_info);
- _alarm_set_timer(&alarm_context, alarm_context.timer, due_time);
- alarm_context.c_due_time = due_time;
- __rtc_set();
- } else if (due_time == alarm_context.c_due_time) {
- _add_to_scheduled_alarm_list(alarm_info);
- }
-
- return true;
-}
-
-static bool __alarm_create_appsvc(alarm_info_t *alarm_info, alarm_id_t *alarm_id,
- long requested_interval, uid_t uid, int pid, char *bundle_data, int *error_code)
-{
char app_name[512] = { 0 };
bundle *b;
const char *callee_appid = NULL;
@@ -1043,10 +967,47 @@ static bool __alarm_create_appsvc(alarm_info_t *alarm_info, alarm_id_t *alarm_id
memcpy(&(__alarm_info->alarm_info), alarm_info, sizeof(alarm_info_t));
__alarm_generate_alarm_id(__alarm_info, alarm_id);
- if (__alarm_add_and_set(__alarm_info) == false) {
- *error_code = ERR_ALARM_INVALID_TIME;
- _release_alarm_info_t(__alarm_info);
- return false;
+ time(&current_time);
+
+ if (alarm_context.c_due_time < current_time) {
+ ALARM_MGR_EXCEPTION_PRINT("Caution!! alarm_context.c_due_time "
+ "(%ld) is less than current time(%ld)", alarm_context.c_due_time, current_time);
+ alarm_context.c_due_time = -1;
+ }
+
+ due_time = _alarm_next_duetime(__alarm_info);
+ __alarm_add_to_list(__alarm_info);
+
+ if (due_time == 0) {
+ ALARM_MGR_EXCEPTION_PRINT("[alarm-server]:Create a new alarm: "
+ "due_time is 0, alarm(%d) \n", *alarm_id);
+ return true;
+ } else if (current_time == due_time) {
+ ALARM_MGR_EXCEPTION_PRINT("[alarm-server]:Create alarm: "
+ "current_time(%ld) is same as due_time(%ld)", current_time,
+ due_time);
+ return true;
+ } else if (difftime(due_time, current_time) < 0) {
+ ALARM_MGR_EXCEPTION_PRINT("[alarm-server]: Expired Due Time.[Due time=%ld, Current Time=%ld]!!!Do not add to schedule list\n", due_time, current_time);
+ return true;
+ } else {
+ localtime_r(&due_time, &ts_ret);
+ strftime(due_time_r, 30, "%c", &ts_ret);
+ SECURE_LOGD("[alarm-server]:Create a new alarm: "
+ "alarm(%d) due_time(%s)", *alarm_id,
+ due_time_r);
+ }
+
+ ALARM_MGR_LOG_PRINT("[alarm-server]:alarm_context.c_due_time(%ld), due_time(%ld)", alarm_context.c_due_time, due_time);
+
+ if (alarm_context.c_due_time == -1 || due_time < alarm_context.c_due_time) {
+ _clear_scheduled_alarm_list();
+ _add_to_scheduled_alarm_list(__alarm_info);
+ _alarm_set_timer(&alarm_context, alarm_context.timer, due_time);
+ alarm_context.c_due_time = due_time;
+ __rtc_set();
+ } else if (due_time == alarm_context.c_due_time) {
+ _add_to_scheduled_alarm_list(__alarm_info);
}
return true;
@@ -1058,6 +1019,8 @@ static bool __alarm_create(alarm_info_t *alarm_info, alarm_id_t *alarm_id, uid_t
const char *dst_service_name, const char *dst_service_name_mod,
int *error_code)
{
+ time_t current_time;
+ time_t due_time;
char unique_name[MAX_APP_ID] = { 0 };
char *caller_pkgid = NULL;
pkgmgrinfo_pkginfo_h caller_handle;
@@ -1114,10 +1077,53 @@ static bool __alarm_create(alarm_info_t *alarm_info, alarm_id_t *alarm_id, uid_t
memcpy(&(__alarm_info->alarm_info), alarm_info, sizeof(alarm_info_t));
__alarm_generate_alarm_id(__alarm_info, alarm_id);
- if (__alarm_add_and_set(__alarm_info) == false) {
- *error_code = ERR_ALARM_INVALID_TIME;
- _release_alarm_info_t(__alarm_info);
- return false;
+ time(&current_time);
+
+ SECURE_LOGD("[alarm-server]:pid=%d, app_unique_name=%s, "
+ "app_service_name=%s,dst_service_name=%s, c_due_time=%ld", \
+ pid, __alarm_info->app_unique_name, \
+ __alarm_info->app_service_name, \
+ __alarm_info->dst_service_name, \
+ alarm_context.c_due_time);
+
+ if (alarm_context.c_due_time < current_time) {
+ ALARM_MGR_EXCEPTION_PRINT("Caution!! alarm_context.c_due_time "
+ "(%ld) is less than current time(%ld)", alarm_context.c_due_time, current_time);
+ alarm_context.c_due_time = -1;
+ }
+
+ due_time = _alarm_next_duetime(__alarm_info);
+ __alarm_add_to_list(__alarm_info);
+
+ if (due_time == 0) {
+ ALARM_MGR_EXCEPTION_PRINT("[alarm-server]:Create a new alarm: due_time is 0, alarm(%d).", *alarm_id);
+ return true;
+ } else if (current_time == due_time) {
+ ALARM_MGR_EXCEPTION_PRINT("[alarm-server]:Create alarm: current_time(%ld) is same as due_time(%ld).",
+ current_time, due_time);
+ return true;
+ } else if (difftime(due_time, current_time) < 0) {
+ ALARM_MGR_EXCEPTION_PRINT("[alarm-server]: Expired Due Time.[Due time=%ld, Current Time=%ld]!!!Do not add to schedule list.",
+ due_time, current_time);
+ return true;
+ } else {
+ char due_time_r[100] = { 0 };
+ struct tm ts_ret;
+ localtime_r(&due_time, &ts_ret);
+ strftime(due_time_r, 30, "%c", &ts_ret);
+ SECURE_LOGD("[alarm-server]:Create a new alarm: alarm(%d) due_time(%s)", *alarm_id, due_time_r);
+ }
+
+ ALARM_MGR_LOG_PRINT("[alarm-server]:alarm_context.c_due_time(%ld), due_time(%ld)", alarm_context.c_due_time, due_time);
+
+ if (alarm_context.c_due_time == -1 || due_time < alarm_context.c_due_time) {
+ _clear_scheduled_alarm_list();
+ _add_to_scheduled_alarm_list(__alarm_info);
+ _alarm_set_timer(&alarm_context, alarm_context.timer, due_time);
+ alarm_context.c_due_time = due_time;
+ __rtc_set();
+ } else if (due_time == alarm_context.c_due_time) {
+ _add_to_scheduled_alarm_list(__alarm_info);
}
return true;
@@ -1172,6 +1178,10 @@ end:
static bool __alarm_create_noti(alarm_info_t *alarm_info, alarm_id_t *alarm_id,
long requested_interval, uid_t uid, int pid, char *noti_data, int *error_code)
{
+ time_t current_time;
+ time_t due_time;
+ struct tm ts_ret;
+ char due_time_r[100] = { 0 };
char app_name[512] = { 0 };
char *caller_pkgid = NULL;
pkgmgrinfo_pkginfo_h caller_handle;
@@ -1229,10 +1239,51 @@ static bool __alarm_create_noti(alarm_info_t *alarm_info, alarm_id_t *alarm_id,
memcpy(&(__alarm_info->alarm_info), alarm_info, sizeof(alarm_info_t));
__alarm_generate_alarm_id(__alarm_info, alarm_id);
- if (__alarm_add_and_set(__alarm_info) == false) {
- *error_code = ERR_ALARM_INVALID_TIME;
- _release_alarm_info_t(__alarm_info);
- return false;
+ time(&current_time);
+
+ SECURE_LOGD("[alarm-server]:pid=%d, app_unique_name=%s, "
+ "app_service_name=%s,dst_service_name=%s, c_due_time=%ld", \
+ pid, __alarm_info->app_unique_name, \
+ __alarm_info->app_service_name, \
+ __alarm_info->dst_service_name, \
+ alarm_context.c_due_time);
+
+ if (alarm_context.c_due_time < current_time) {
+ ALARM_MGR_EXCEPTION_PRINT("Caution!! alarm_context.c_due_time "
+ "(%ld) is less than current time(%ld)", alarm_context.c_due_time, current_time);
+ alarm_context.c_due_time = -1;
+ }
+
+ due_time = _alarm_next_duetime(__alarm_info);
+ __alarm_add_to_list(__alarm_info);
+
+ if (due_time == 0) {
+ ALARM_MGR_EXCEPTION_PRINT("[alarm-server]:Create a new alarm: due_time is 0, alarm(%d).", *alarm_id);
+ return true;
+ } else if (current_time == due_time) {
+ ALARM_MGR_EXCEPTION_PRINT("[alarm-server]:Create alarm: current_time(%ld) is same as due_time(%ld).",
+ current_time, due_time);
+ return true;
+ } else if (difftime(due_time, current_time) < 0) {
+ ALARM_MGR_EXCEPTION_PRINT("[alarm-server]: Expired Due Time.[Due time=%ld, Current Time=%ld]!!!Do not add to schedule list.",
+ due_time, current_time);
+ return true;
+ } else {
+ localtime_r(&due_time, &ts_ret);
+ strftime(due_time_r, 30, "%c", &ts_ret);
+ SECURE_LOGD("[alarm-server]:Create a new alarm: alarm(%d) due_time(%s)", *alarm_id, due_time_r);
+ }
+
+ ALARM_MGR_LOG_PRINT("[alarm-server]:alarm_context.c_due_time(%ld), due_time(%ld)", alarm_context.c_due_time, due_time);
+
+ if (alarm_context.c_due_time == -1 || due_time < alarm_context.c_due_time) {
+ _clear_scheduled_alarm_list();
+ _add_to_scheduled_alarm_list(__alarm_info);
+ _alarm_set_timer(&alarm_context, alarm_context.timer, due_time);
+ alarm_context.c_due_time = due_time;
+ __rtc_set();
+ } else if (due_time == alarm_context.c_due_time) {
+ _add_to_scheduled_alarm_list(__alarm_info);
}
return true;