summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/alarm-internal.h16
-rw-r--r--lib/alarm-lib-dbus.c146
-rw-r--r--lib/alarm-lib.c298
-rw-r--r--packaging/alarm-manager.spec2
-rw-r--r--server/alarm-manager-db.c82
-rw-r--r--server/alarm-manager-dbus.c18
-rw-r--r--server/alarm-manager-schedule.c42
-rw-r--r--server/alarm-manager-util.c4
-rw-r--r--server/alarm-manager.c439
-rw-r--r--[-rwxr-xr-x]unittest/alarm_manager_unittest.cpp2
10 files changed, 541 insertions, 508 deletions
diff --git a/include/alarm-internal.h b/include/alarm-internal.h
index b479faf..faaf2ad 100644
--- a/include/alarm-internal.h
+++ b/include/alarm-internal.h
@@ -65,20 +65,22 @@ enum async_param_type {
#define ALARM_TYPE_WITHCB 0x40000000 /**< withcb */
#define ALARM_TYPE_PERIOD 0x10000000 /**< periodic */
-bool _send_alarm_create(alarm_context_t context, alarm_info_t *alarm,
+#define base_info_t alarm_info_t
+
+bool _send_alarm_create(alarm_context_t context, base_info_t *base,
alarm_id_t *id, const char *dst_service_name, const char *dst_service_name_mod, int *error_code);
-bool _send_alarm_create_appsvc(alarm_context_t context, alarm_info_t *alarm_info,
+bool _send_alarm_create_appsvc(alarm_context_t context, base_info_t *base_info,
alarm_id_t *alarm_id, bundle *b, int *error_code);
-bool _send_alarm_create_noti(alarm_context_t context, alarm_info_t *alarm_info,
+bool _send_alarm_create_noti(alarm_context_t context, base_info_t *base_info,
alarm_id_t *alarm_id, notification_h noti, int *error_code);
bool _send_alarm_update(alarm_context_t context, alarm_id_t alarm_id,
- alarm_info_t *alarm_info, int update_flag, int *error_code);
+ base_info_t *base_info, int update_flag, int *error_code);
bool _send_alarm_delete(alarm_context_t context, alarm_id_t alarm_id, int *error_code);
bool _send_alarm_delete_all(alarm_context_t context, int *error_code);
bool _send_alarm_get_list_of_ids(alarm_context_t context, int maxnum_of_ids,
GVariantIter **iter, int *num_of_ids, int *error_code);
bool _send_alarm_get_number_of_ids(alarm_context_t context, int *num_of_ids, int *error_code);
-bool _send_alarm_get_info(alarm_context_t context, alarm_id_t alarm_id, alarm_info_t *alarm_info, int *error_code);
+bool _send_alarm_get_info(alarm_context_t context, alarm_id_t alarm_id, base_info_t *base_info, int *error_code);
bool _send_alarm_get_next_duetime(alarm_context_t context, alarm_id_t alarm_id, time_t* duetime, int *error_code);
bool _send_alarm_get_all_info(alarm_context_t context, char ** db_path, int *error_code);
bool _send_alarm_reset(alarm_context_t context, int *error_code);
@@ -115,7 +117,7 @@ typedef struct {
char *bundle;
char *noti;
- alarm_info_t alarm_info;
+ base_info_t base_info;
periodic_method_e method;
long requested_interval;
@@ -185,7 +187,7 @@ int alarm_manager_alarm_get_number_of_ids(uid_t uid, pid_t pid, int *num_of_ids)
int alarm_manager_alarm_get_list_of_ids(GVariant *parameters, uid_t uid, pid_t pid, GVariant **alarm_array, int *num_of_alarm);
int alarm_manager_alarm_get_appsvc_info(GVariant *parameters, uid_t uid, gchar **b_data);
int alarm_manager_alarm_get_noti_info(GVariant *parameters, uid_t uid, gchar **noti_data);
-int alarm_manager_alarm_get_info(GVariant *parameters, uid_t uid, alarm_info_t *alarm_info);
+int alarm_manager_alarm_get_info(GVariant *parameters, uid_t uid, base_info_t *base_info);
int alarm_manager_alarm_get_next_duetime(GVariant *parameters, uid_t uid, time_t *duetime);
int alarm_manager_alarm_get_all_info(uid_t uid, char **db_path);
int alarm_manager_alarm_set_rtc_time(GVariant *parameters);
diff --git a/lib/alarm-lib-dbus.c b/lib/alarm-lib-dbus.c
index 6c763a2..a23da20 100644
--- a/lib/alarm-lib-dbus.c
+++ b/lib/alarm-lib-dbus.c
@@ -48,7 +48,7 @@ static int __dbus_call_sync(GDBusProxy *proxy, const gchar *method_name,
return error_code;
}
-bool _send_alarm_create_noti(alarm_context_t context, alarm_info_t *alarm_info,
+bool _send_alarm_create_noti(alarm_context_t context, base_info_t *base_info,
alarm_id_t *alarm_id, notification_h noti, int *error_code)
{
int return_code = -1;
@@ -78,20 +78,20 @@ bool _send_alarm_create_noti(alarm_context_t context, alarm_info_t *alarm_info,
noti_data = g_base64_encode((guchar *)data, datalen);
param = g_variant_new("(iiiiiiiiiixiixs)",
- alarm_info->start.year,
- alarm_info->start.month,
- alarm_info->start.day,
- alarm_info->start.hour,
- alarm_info->start.min,
- alarm_info->start.sec,
- alarm_info->end.year,
- alarm_info->end.month,
- alarm_info->end.day,
- alarm_info->mode.u_interval.day_of_week,
- (gint64)alarm_info->mode.u_interval.interval,
- alarm_info->mode.repeat,
- alarm_info->alarm_type,
- (gint64)alarm_info->reserved_info,
+ base_info->start.year,
+ base_info->start.month,
+ base_info->start.day,
+ base_info->start.hour,
+ base_info->start.min,
+ base_info->start.sec,
+ base_info->end.year,
+ base_info->end.month,
+ base_info->end.day,
+ base_info->mode.u_interval.day_of_week,
+ (gint64)base_info->mode.u_interval.interval,
+ base_info->mode.repeat,
+ base_info->alarm_type,
+ (gint64)base_info->reserved_info,
(char *)noti_data);
if (noti_data)
@@ -125,7 +125,7 @@ bool _send_alarm_create_noti(alarm_context_t context, alarm_info_t *alarm_info,
return true;
}
-bool _send_alarm_create_appsvc(alarm_context_t context, alarm_info_t *alarm_info,
+bool _send_alarm_create_appsvc(alarm_context_t context, base_info_t *base_info,
alarm_id_t *alarm_id, bundle *b, int *error_code)
{
int return_code = -1;
@@ -142,20 +142,20 @@ bool _send_alarm_create_appsvc(alarm_context_t context, alarm_info_t *alarm_info
}
param = g_variant_new("(iiiiiiiiiixiixs)",
- alarm_info->start.year,
- alarm_info->start.month,
- alarm_info->start.day,
- alarm_info->start.hour,
- alarm_info->start.min,
- alarm_info->start.sec,
- alarm_info->end.year,
- alarm_info->end.month,
- alarm_info->end.day,
- alarm_info->mode.u_interval.day_of_week,
- (gint64)alarm_info->mode.u_interval.interval,
- alarm_info->mode.repeat,
- alarm_info->alarm_type,
- (gint64)alarm_info->reserved_info,
+ base_info->start.year,
+ base_info->start.month,
+ base_info->start.day,
+ base_info->start.hour,
+ base_info->start.min,
+ base_info->start.sec,
+ base_info->end.year,
+ base_info->end.month,
+ base_info->end.day,
+ base_info->mode.u_interval.day_of_week,
+ (gint64)base_info->mode.u_interval.interval,
+ base_info->mode.repeat,
+ base_info->alarm_type,
+ (gint64)base_info->reserved_info,
(char *)b_data);
if (b_data)
@@ -186,7 +186,7 @@ bool _send_alarm_create_appsvc(alarm_context_t context, alarm_info_t *alarm_info
return true;
}
-bool _send_alarm_create(alarm_context_t context, alarm_info_t *alarm_info,
+bool _send_alarm_create(alarm_context_t context, base_info_t *base_info,
alarm_id_t *alarm_id, const char *dst_service_name, const char *dst_service_name_mod,
int *error_code)
{
@@ -207,20 +207,20 @@ bool _send_alarm_create(alarm_context_t context, alarm_info_t *alarm_info,
param = g_variant_new("(ssiiiiiiiiiiiiixss)",
context.app_service_name,
context.app_service_name_mod,
- alarm_info->start.year,
- alarm_info->start.month,
- alarm_info->start.day,
- alarm_info->start.hour,
- alarm_info->start.min,
- alarm_info->start.sec,
- alarm_info->msec,
- alarm_info->end.year,
- alarm_info->end.month,
- alarm_info->end.day,
- alarm_info->mode.u_interval.day_of_week,
- alarm_info->mode.repeat,
- alarm_info->alarm_type,
- (gint64)alarm_info->reserved_info,
+ base_info->start.year,
+ base_info->start.month,
+ base_info->start.day,
+ base_info->start.hour,
+ base_info->start.min,
+ base_info->start.sec,
+ base_info->msec,
+ base_info->end.year,
+ base_info->end.month,
+ base_info->end.day,
+ base_info->mode.u_interval.day_of_week,
+ base_info->mode.repeat,
+ base_info->alarm_type,
+ (gint64)base_info->reserved_info,
dst_service_name, dst_service_name_mod);
return_code = __dbus_call_sync(context.proxy, "alarm_create",
@@ -553,7 +553,7 @@ bool _send_alarm_get_number_of_ids(alarm_context_t context, int *num_of_ids,
}
bool _send_alarm_get_info(alarm_context_t context, alarm_id_t alarm_id,
- alarm_info_t *alarm_info, int *error_code)
+ base_info_t *base_info, int *error_code)
{
int return_code = -1;
GVariant *param = NULL;
@@ -570,21 +570,21 @@ bool _send_alarm_get_info(alarm_context_t context, alarm_id_t alarm_id,
}
g_variant_get(reply, "(iiiiiiiiiiiixi)",
- &alarm_info->start.year,
- &alarm_info->start.month,
- &alarm_info->start.day,
- &alarm_info->start.hour,
- &alarm_info->start.min,
- &alarm_info->start.sec,
- &alarm_info->end.year,
- &alarm_info->end.month,
- &alarm_info->end.day,
- &alarm_info->mode.u_interval.day_of_week,
- &alarm_info->mode.repeat,
- &alarm_info->alarm_type,
+ &base_info->start.year,
+ &base_info->start.month,
+ &base_info->start.day,
+ &base_info->start.hour,
+ &base_info->start.min,
+ &base_info->start.sec,
+ &base_info->end.year,
+ &base_info->end.month,
+ &base_info->end.day,
+ &base_info->mode.u_interval.day_of_week,
+ &base_info->mode.repeat,
+ &base_info->alarm_type,
&tmp_reserved_info,
&return_code);
- alarm_info->reserved_info = (time_t)tmp_reserved_info;
+ base_info->reserved_info = (time_t)tmp_reserved_info;
LOGD("alarm_get_info() dbus sync success. return_code[%d].",
return_code);
@@ -939,7 +939,7 @@ bool _send_alarm_get_global(alarm_context_t context, const alarm_id_t alarm_id,
}
bool _send_alarm_update(alarm_context_t context, alarm_id_t alarm_id,
- alarm_info_t *alarm_info, int update_flag, int *error_code)
+ base_info_t *base_info, int update_flag, int *error_code)
{
int return_code = -1;
GVariant *param = NULL;
@@ -947,19 +947,19 @@ bool _send_alarm_update(alarm_context_t context, alarm_id_t alarm_id,
param = g_variant_new("(iiiiiiiiiixiixi)",
alarm_id,
- alarm_info->start.year,
- alarm_info->start.month,
- alarm_info->start.day,
- alarm_info->start.hour,
- alarm_info->start.min,
- alarm_info->start.sec,
- alarm_info->end.year,
- alarm_info->end.month,
- alarm_info->end.day,
- (gint64)alarm_info->mode.u_interval.interval,
- alarm_info->mode.repeat,
- alarm_info->alarm_type,
- (gint64)alarm_info->reserved_info,
+ base_info->start.year,
+ base_info->start.month,
+ base_info->start.day,
+ base_info->start.hour,
+ base_info->start.min,
+ base_info->start.sec,
+ base_info->end.year,
+ base_info->end.month,
+ base_info->end.day,
+ (gint64)base_info->mode.u_interval.interval,
+ base_info->mode.repeat,
+ base_info->alarm_type,
+ (gint64)base_info->reserved_info,
update_flag);
return_code = __dbus_call_sync(context.proxy, "alarm_update",
diff --git a/lib/alarm-lib.c b/lib/alarm-lib.c
index 1f53853..fbc18da 100644
--- a/lib/alarm-lib.c
+++ b/lib/alarm-lib.c
@@ -95,7 +95,7 @@ static const GDBusInterfaceVTable interface_vtable = {
NULL
};
-void _initialize_alarm_info(alarm_info_t *alarm_info, int alarm_type,
+void _initialize_alarm_info(base_info_t *base_info, int alarm_type,
time_t trigger_at_time, time_t interval, bool precision)
{
struct timespec current_time;
@@ -103,10 +103,10 @@ void _initialize_alarm_info(alarm_info_t *alarm_info, int alarm_type,
clock_gettime(CLOCK_REALTIME, &current_time);
- memset(alarm_info, 0, sizeof(alarm_info_t));
+ memset(base_info, 0, sizeof(base_info_t));
- alarm_info->mode.repeat = ALARM_REPEAT_MODE_ONCE;
- alarm_info->alarm_type = alarm_type;
+ base_info->mode.repeat = ALARM_REPEAT_MODE_ONCE;
+ base_info->alarm_type = alarm_type;
if (current_time.tv_nsec > (BILLION / 2)) {
/* When the nanosecond part of the current_time is bigger than 500ms,
@@ -115,40 +115,40 @@ void _initialize_alarm_info(alarm_info_t *alarm_info, int alarm_type,
} else {
current_time.tv_sec += trigger_at_time;
}
- alarm_info->reserved_info = current_time.tv_sec;
+ base_info->reserved_info = current_time.tv_sec;
tzset(); /* Processes the TZ environment variable, and Set timezone, daylight, and tzname. */
localtime_r(&current_time.tv_sec, &duetime_tm);
- alarm_info->start.year = duetime_tm.tm_year + 1900;
- alarm_info->start.month = duetime_tm.tm_mon + 1;
- alarm_info->start.day = duetime_tm.tm_mday;
+ base_info->start.year = duetime_tm.tm_year + 1900;
+ base_info->start.month = duetime_tm.tm_mon + 1;
+ base_info->start.day = duetime_tm.tm_mday;
- alarm_info->end.year = 0;
- alarm_info->end.month = 0;
- alarm_info->end.day = 0;
+ base_info->end.year = 0;
+ base_info->end.month = 0;
+ base_info->end.day = 0;
- alarm_info->start.hour = duetime_tm.tm_hour;
- alarm_info->start.min = duetime_tm.tm_min;
- alarm_info->start.sec = duetime_tm.tm_sec;
+ base_info->start.hour = duetime_tm.tm_hour;
+ base_info->start.min = duetime_tm.tm_min;
+ base_info->start.sec = duetime_tm.tm_sec;
if (interval <= 0) {
- alarm_info->mode.repeat = ALARM_REPEAT_MODE_ONCE;
- alarm_info->mode.u_interval.interval = 0;
+ base_info->mode.repeat = ALARM_REPEAT_MODE_ONCE;
+ base_info->mode.u_interval.interval = 0;
} else {
- alarm_info->mode.repeat = ALARM_REPEAT_MODE_REPEAT;
- alarm_info->mode.u_interval.interval = interval;
+ base_info->mode.repeat = ALARM_REPEAT_MODE_REPEAT;
+ base_info->mode.u_interval.interval = interval;
}
- alarm_info->msec = precision ? (int)current_time.tv_nsec / MILLION : 0;
+ base_info->msec = precision ? (int)current_time.tv_nsec / MILLION : 0;
LOGD("trigger_at_time(%ld), start(%d-%d-%d, %02d:%02d:%02d),\
repeat(%d), interval(%ld), type(%d)",
- trigger_at_time, alarm_info->start.day, alarm_info->start.month,
- alarm_info->start.year, alarm_info->start.hour,
- alarm_info->start.min, alarm_info->start.sec,
- alarm_info->mode.repeat, alarm_info->mode.u_interval.interval,
- alarm_info->alarm_type);
+ trigger_at_time, base_info->start.day, base_info->start.month,
+ base_info->start.year, base_info->start.hour,
+ base_info->start.min, base_info->start.sec,
+ base_info->mode.repeat, base_info->mode.u_interval.interval,
+ base_info->alarm_type);
}
static void __add_resultcb(alarm_id_t alarm_id, alarm_cb_t cb_func, void *data)
@@ -329,21 +329,21 @@ static bool __alarm_validate_time(alarm_date_t *date, int *error_code)
return true;
}
-static int __check_validation(alarm_info_t *alarm_info, const char *function)
+static int __check_validation(base_info_t *base_info, const char *function)
{
int error_code;
- if (!__alarm_validate_date(&alarm_info->start, &error_code)) {
+ if (!__alarm_validate_date(&base_info->start, &error_code)) {
LOGE("%s : start date error\n", function);
return error_code;
}
- if (!__alarm_validate_time(&alarm_info->start, &error_code)) {
+ if (!__alarm_validate_time(&base_info->start, &error_code)) {
LOGE("%s : start time error\n", function);
return error_code;
}
- if (!__alarm_validate_date(&alarm_info->end, &error_code)) {
+ if (!__alarm_validate_date(&base_info->end, &error_code)) {
LOGE("%s : end date error\n", function);
return error_code;
}
@@ -484,7 +484,7 @@ static int __compare_api_version(int *result, uid_t uid)
return ret;
}
-static void __adjust_current_milliseconds(alarm_info_t *alarm_info)
+static void __adjust_current_milliseconds(base_info_t *base_info)
{
struct timespec current_time;
struct tm start_tm;
@@ -495,12 +495,12 @@ static void __adjust_current_milliseconds(alarm_info_t *alarm_info)
/* When the nanosecond part of the current_time is bigger than 500ms,
* the duetime increases by extra 1sec. */
- start_tm.tm_year = alarm_info->start.year - 1900;
- start_tm.tm_mon = alarm_info->start.month - 1;
- start_tm.tm_mday = alarm_info->start.day;
- start_tm.tm_hour = alarm_info->start.hour;
- start_tm.tm_min = alarm_info->start.min;
- start_tm.tm_sec = alarm_info->start.sec;
+ start_tm.tm_year = base_info->start.year - 1900;
+ start_tm.tm_mon = base_info->start.month - 1;
+ start_tm.tm_mday = base_info->start.day;
+ start_tm.tm_hour = base_info->start.hour;
+ start_tm.tm_min = base_info->start.min;
+ start_tm.tm_sec = base_info->start.sec;
start_tm.tm_isdst = -1;
start = timegm(&start_tm);
@@ -509,16 +509,16 @@ static void __adjust_current_milliseconds(alarm_info_t *alarm_info)
start += 1;
localtime_r(&start, &start_tm);
- alarm_info->start.year = start_tm.tm_year + 1900;
- alarm_info->start.month = start_tm.tm_mon + 1;
- alarm_info->start.day = start_tm.tm_mday;
- alarm_info->start.hour = start_tm.tm_hour;
- alarm_info->start.min = start_tm.tm_min;
- alarm_info->start.sec = start_tm.tm_sec;
+ base_info->start.year = start_tm.tm_year + 1900;
+ base_info->start.month = start_tm.tm_mon + 1;
+ base_info->start.day = start_tm.tm_mday;
+ base_info->start.hour = start_tm.tm_hour;
+ base_info->start.min = start_tm.tm_min;
+ base_info->start.sec = start_tm.tm_sec;
LOGW("adjusted start(%d-%d-%d, %02d:%02d:%02d),",
- alarm_info->start.day, alarm_info->start.month, alarm_info->start.year,
- alarm_info->start.hour, alarm_info->start.min, alarm_info->start.sec);
+ base_info->start.day, base_info->start.month, base_info->start.year,
+ base_info->start.hour, base_info->start.min, base_info->start.sec);
}
}
}
@@ -706,37 +706,37 @@ EXPORT_API int alarmmgr_set_cb(alarm_cb_t handler, void *user_param)
EXPORT_API alarm_entry_t *alarmmgr_create_alarm(void)
{
- alarm_info_t *alarm = (alarm_info_t *)malloc(sizeof(alarm_info_t));
+ base_info_t *base_info = (base_info_t *)malloc(sizeof(base_info_t));
- if (alarm == NULL) {
+ if (base_info == NULL) {
LOGE("alarm is null");
return NULL;
}
- alarm->start.year = 0;
- alarm->start.month = 0;
- alarm->start.day = 0;
- alarm->start.hour = 0;
- alarm->start.min = 0;
- alarm->start.sec = 0;
+ base_info->start.year = 0;
+ base_info->start.month = 0;
+ base_info->start.day = 0;
+ base_info->start.hour = 0;
+ base_info->start.min = 0;
+ base_info->start.sec = 0;
- alarm->msec = 0;
+ base_info->msec = 0;
- alarm->end.year = 0;
- alarm->end.month = 0;
- alarm->end.day = 0;
- alarm->end.hour = 0;
- alarm->end.min = 0;
- alarm->end.sec = 0;
+ base_info->end.year = 0;
+ base_info->end.month = 0;
+ base_info->end.day = 0;
+ base_info->end.hour = 0;
+ base_info->end.min = 0;
+ base_info->end.sec = 0;
- alarm->mode.repeat = ALARM_REPEAT_MODE_ONCE;
- alarm->mode.u_interval.interval = 0;
+ base_info->mode.repeat = ALARM_REPEAT_MODE_ONCE;
+ base_info->mode.u_interval.interval = 0;
- alarm->alarm_type = ALARM_TYPE_DEFAULT;
+ base_info->alarm_type = ALARM_TYPE_DEFAULT;
- alarm->reserved_info = 0;
+ base_info->reserved_info = 0;
- return (alarm_entry_t *) alarm;
+ return (alarm_entry_t *) base_info;
}
EXPORT_API int alarmmgr_free_alarm(alarm_entry_t *alarm)
@@ -753,7 +753,7 @@ EXPORT_API int alarmmgr_free_alarm(alarm_entry_t *alarm)
EXPORT_API int alarmmgr_set_time(alarm_entry_t *alarm, alarm_date_t time)
{
- alarm_info_t *alarm_info;
+ base_info_t *base_info;
int error_code;
if (alarm == NULL) {
@@ -761,7 +761,7 @@ EXPORT_API int alarmmgr_set_time(alarm_entry_t *alarm, alarm_date_t time)
return ERR_ALARM_INVALID_PARAM;
}
- alarm_info = (alarm_info_t *)alarm;
+ base_info = (base_info_t *)alarm;
if (!__alarm_validate_date(&time, &error_code)) {
LOGE("start date error\n");
return error_code;
@@ -772,7 +772,7 @@ EXPORT_API int alarmmgr_set_time(alarm_entry_t *alarm, alarm_date_t time)
return error_code;
}
- memcpy(&alarm_info->start, &time, sizeof(alarm_date_t));
+ memcpy(&base_info->start, &time, sizeof(alarm_date_t));
return ALARMMGR_RESULT_SUCCESS;
}
@@ -780,7 +780,7 @@ EXPORT_API int alarmmgr_set_time(alarm_entry_t *alarm, alarm_date_t time)
EXPORT_API int alarmmgr_get_time(const alarm_entry_t *alarm,
alarm_date_t *time)
{
- alarm_info_t *alarm_info = (alarm_info_t *)alarm;
+ base_info_t *base_info = (base_info_t *)alarm;
if (alarm == NULL) {
LOGE("alarm is null");
@@ -788,7 +788,7 @@ EXPORT_API int alarmmgr_get_time(const alarm_entry_t *alarm,
}
if (time != NULL)
- memcpy(time, &alarm_info->start, sizeof(alarm_date_t));
+ memcpy(time, &base_info->start, sizeof(alarm_date_t));
return ALARMMGR_RESULT_SUCCESS;
}
@@ -796,20 +796,20 @@ EXPORT_API int alarmmgr_get_time(const alarm_entry_t *alarm,
EXPORT_API int alarmmgr_set_repeat_mode(alarm_entry_t *alarm,
alarm_repeat_mode_t repeat, int interval)
{
- alarm_info_t *alarm_info = (alarm_info_t *)alarm;
+ base_info_t *base_info = (base_info_t *)alarm;
if (repeat >= ALARM_REPEAT_MODE_MAX) {
LOGE("repeat value is invalid");
return ERR_ALARM_INVALID_PARAM;
}
- alarm_info->mode.repeat = repeat;
+ base_info->mode.repeat = repeat;
if (repeat == ALARM_REPEAT_MODE_REPEAT
|| repeat == ALARM_REPEAT_MODE_WEEKLY) {
if (interval <= 0)
return ERR_ALARM_INVALID_PARAM;
- alarm_info->mode.u_interval.interval = interval;
+ base_info->mode.u_interval.interval = interval;
}
return ALARMMGR_RESULT_SUCCESS;
@@ -818,7 +818,7 @@ EXPORT_API int alarmmgr_set_repeat_mode(alarm_entry_t *alarm,
EXPORT_API int alarmmgr_get_repeat_mode(const alarm_entry_t *alarm,
alarm_repeat_mode_t *repeat, int *interval)
{
- alarm_info_t *alarm_info = (alarm_info_t *)alarm;
+ base_info_t *base_info = (base_info_t *)alarm;
if (alarm == NULL) {
LOGE("alarm is null");
@@ -826,32 +826,32 @@ EXPORT_API int alarmmgr_get_repeat_mode(const alarm_entry_t *alarm,
}
if (repeat != NULL)
- *repeat = alarm_info->mode.repeat;
+ *repeat = base_info->mode.repeat;
if (interval != NULL)
- *interval = alarm_info->mode.u_interval.interval;
+ *interval = base_info->mode.u_interval.interval;
return ALARMMGR_RESULT_SUCCESS;
}
EXPORT_API int alarmmgr_set_type(alarm_entry_t *alarm, int alarm_type)
{
- alarm_info_t *alarm_info;
+ base_info_t *base_info;
if (alarm == NULL) {
LOGE("alarm is null");
return ERR_ALARM_INVALID_PARAM;
}
- alarm_info = (alarm_info_t *)alarm;
- alarm_info->alarm_type = alarm_type;
- alarm_info->alarm_type &= (~ALARM_TYPE_RELATIVE);
+ base_info = (base_info_t *)alarm;
+ base_info->alarm_type = alarm_type;
+ base_info->alarm_type &= (~ALARM_TYPE_RELATIVE);
return ALARMMGR_RESULT_SUCCESS;
}
EXPORT_API int alarmmgr_get_type(const alarm_entry_t *alarm, int *alarm_type)
{
- alarm_info_t *alarm_info = (alarm_info_t *)alarm;
+ base_info_t *base_info = (base_info_t *)alarm;
if (alarm == NULL) {
LOGE("alarm is null");
@@ -859,7 +859,7 @@ EXPORT_API int alarmmgr_get_type(const alarm_entry_t *alarm, int *alarm_type)
}
if (alarm_type != NULL)
- *alarm_type = alarm_info->alarm_type;
+ *alarm_type = base_info->alarm_type;
return ALARMMGR_RESULT_SUCCESS;
}
@@ -962,7 +962,7 @@ EXPORT_API int alarmmgr_set_rtc_time(alarm_date_t *time)
EXPORT_API int alarmmgr_add_alarm_appsvc_with_localtime(alarm_entry_t *alarm, void *bundle_data, alarm_id_t *alarm_id)
{
- alarm_info_t *alarm_info = NULL;
+ base_info_t *base_info = NULL;
alarm_mode_t *mode;
const char *operation = NULL;
int error_code = 0;
@@ -971,13 +971,13 @@ EXPORT_API int alarmmgr_add_alarm_appsvc_with_localtime(alarm_entry_t *alarm, vo
LOGD("[alarm-lib]:alarm_create() is called\n");
- alarm_info = (alarm_info_t *)alarm;
- if (alarm_info == NULL || alarm_id == NULL) {
+ base_info = (base_info_t *)alarm;
+ if (base_info == NULL || alarm_id == NULL) {
LOGE("Invalid parameter\n");
return ERR_ALARM_INVALID_PARAM;
}
- __adjust_current_milliseconds(alarm_info);
+ __adjust_current_milliseconds(base_info);
b = (bundle *)bundle_data;
if (b == NULL) {
@@ -996,30 +996,30 @@ EXPORT_API int alarmmgr_add_alarm_appsvc_with_localtime(alarm_entry_t *alarm, vo
appid = appsvc_get_appid(b);
if (appid == NULL) {
- if ((alarm_info->alarm_type & ALARM_TYPE_NOLAUNCH) ||
+ if ((base_info->alarm_type & ALARM_TYPE_NOLAUNCH) ||
(operation && !strcmp(operation, APPSVC_OPERATION_DEFAULT))) {
LOGE("appid is invalid");
return ERR_ALARM_INVALID_PARAM;
}
}
- mode = &alarm_info->mode;
+ mode = &base_info->mode;
LOGW("start(%d-%d-%d, %02d:%02d:%02d), end(%d-%d-%d), repeat(%d), interval(%ld), type(%d)",
- alarm_info->start.day, alarm_info->start.month, alarm_info->start.year,
- alarm_info->start.hour, alarm_info->start.min, alarm_info->start.sec,
- alarm_info->end.year, alarm_info->end.month, alarm_info->end.day,
- alarm_info->mode.repeat, alarm_info->mode.u_interval.interval, alarm_info->alarm_type);
+ base_info->start.day, base_info->start.month, base_info->start.year,
+ base_info->start.hour, base_info->start.min, base_info->start.sec,
+ base_info->end.year, base_info->end.month, base_info->end.day,
+ base_info->mode.repeat, base_info->mode.u_interval.interval, base_info->alarm_type);
/* TODO: This should be changed to > ALARM_REPEAT_MODE_MAX ? */
if (mode->repeat >= ALARM_REPEAT_MODE_MAX)
return ERR_ALARM_INVALID_PARAM;
- error_code = __check_validation(alarm_info, __FUNCTION__);
+ error_code = __check_validation(base_info, __FUNCTION__);
if (error_code != ALARMMGR_RESULT_SUCCESS)
return error_code;
- if (!_send_alarm_create_appsvc(alarm_context, alarm_info, alarm_id, b, &error_code))
+ if (!_send_alarm_create_appsvc(alarm_context, base_info, alarm_id, b, &error_code))
return error_code;
return ALARMMGR_RESULT_SUCCESS;
@@ -1031,7 +1031,7 @@ EXPORT_API int alarmmgr_add_alarm_with_localtime(alarm_entry_t *alarm,
{
char dst_service_name[MAX_SERVICE_NAME_LEN] = { 0 };
char dst_service_name_mod[MAX_SERVICE_NAME_LEN] = { 0 };
- alarm_info_t *alarm_info = NULL;
+ base_info_t *base_info = NULL;
alarm_mode_t *mode;
int ret;
int error_code;
@@ -1045,25 +1045,25 @@ EXPORT_API int alarmmgr_add_alarm_with_localtime(alarm_entry_t *alarm,
return ERR_ALARM_INVALID_PARAM;
}
- alarm_info = (alarm_info_t *) alarm;
- if (alarm_info == NULL || alarm_id == NULL) {
+ base_info = (base_info_t *) alarm;
+ if (base_info == NULL || alarm_id == NULL) {
LOGE("Invalid parameter bundle\n");
return ERR_ALARM_INVALID_PARAM;
}
- __adjust_current_milliseconds(alarm_info);
+ __adjust_current_milliseconds(base_info);
- mode = &alarm_info->mode;
+ mode = &base_info->mode;
ret = __sub_init();
if (ret < 0)
return ret;
LOGD("start(%d-%d-%d, %02d:%02d:%02d), end(%d-%d-%d), repeat(%d), interval(%ld), type(%d)",
- alarm_info->start.day, alarm_info->start.month, alarm_info->start.year,
- alarm_info->start.hour, alarm_info->start.min, alarm_info->start.sec,
- alarm_info->end.year, alarm_info->end.month, alarm_info->end.day,
- alarm_info->mode.repeat, alarm_info->mode.u_interval.interval, alarm_info->alarm_type);
+ base_info->start.day, base_info->start.month, base_info->start.year,
+ base_info->start.hour, base_info->start.min, base_info->start.sec,
+ base_info->end.year, base_info->end.month, base_info->end.day,
+ base_info->mode.repeat, base_info->mode.u_interval.interval, base_info->alarm_type);
/* TODO: This should be changed to > ALARM_REPEAT_MODE_MAX ? */
if (mode->repeat >= ALARM_REPEAT_MODE_MAX) {
@@ -1076,7 +1076,7 @@ EXPORT_API int alarmmgr_add_alarm_with_localtime(alarm_entry_t *alarm,
return ERR_ALARM_INVALID_PARAM;
}
- error_code = __check_validation(alarm_info, __FUNCTION__);
+ error_code = __check_validation(base_info, __FUNCTION__);
if (error_code != ALARMMGR_RESULT_SUCCESS)
return error_code;
@@ -1095,10 +1095,10 @@ EXPORT_API int alarmmgr_add_alarm_with_localtime(alarm_entry_t *alarm,
j++;
}
- if (!_send_alarm_create(alarm_context, alarm_info, alarm_id, dst_service_name, dst_service_name_mod, &error_code))
+ if (!_send_alarm_create(alarm_context, base_info, alarm_id, dst_service_name, dst_service_name_mod, &error_code))
return error_code;
} else {
- if (!_send_alarm_create(alarm_context, alarm_info, alarm_id, "null", "null", &error_code))
+ if (!_send_alarm_create(alarm_context, base_info, alarm_id, "null", "null", &error_code))
return error_code;
}
@@ -1107,40 +1107,40 @@ EXPORT_API int alarmmgr_add_alarm_with_localtime(alarm_entry_t *alarm,
EXPORT_API int alarmmgr_add_alarm_noti_with_localtime(alarm_entry_t *alarm, notification_h noti, alarm_id_t *alarm_id)
{
- alarm_info_t *alarm_info = NULL;
+ base_info_t *base_info = NULL;
int error_code = 0;
- alarm_info = (alarm_info_t *)alarm;
+ base_info = (base_info_t *)alarm;
alarm_mode_t *mode;
- if (alarm_info == NULL || alarm_id == NULL) {
+ if (base_info == NULL || alarm_id == NULL) {
LOGE("Invalid parameter\n");
return ERR_ALARM_INVALID_PARAM;
}
- __adjust_current_milliseconds(alarm_info);
+ __adjust_current_milliseconds(base_info);
if (__alarmmgr_init_appsvc() < 0) {
LOGE("Unable to initialize dbus!!!\n");
return ERR_ALARM_SYSTEM_FAIL;
}
- mode = &alarm_info->mode;
+ mode = &base_info->mode;
LOGW("start(%d-%d-%d, %02d:%02d:%02d), end(%d-%d-%d), repeat(%d), interval(%ld), type(%d)",
- alarm_info->start.day, alarm_info->start.month, alarm_info->start.year,
- alarm_info->start.hour, alarm_info->start.min, alarm_info->start.sec,
- alarm_info->end.year, alarm_info->end.month, alarm_info->end.day,
- alarm_info->mode.repeat, alarm_info->mode.u_interval.interval, alarm_info->alarm_type);
+ base_info->start.day, base_info->start.month, base_info->start.year,
+ base_info->start.hour, base_info->start.min, base_info->start.sec,
+ base_info->end.year, base_info->end.month, base_info->end.day,
+ base_info->mode.repeat, base_info->mode.u_interval.interval, base_info->alarm_type);
/* TODO: This should be changed to > ALARM_REPEAT_MODE_MAX ? */
if (mode->repeat >= ALARM_REPEAT_MODE_MAX)
return ERR_ALARM_INVALID_PARAM;
- error_code = __check_validation(alarm_info, __FUNCTION__);
+ error_code = __check_validation(base_info, __FUNCTION__);
if (error_code != ALARMMGR_RESULT_SUCCESS)
return error_code;
- if (!_send_alarm_create_noti(alarm_context, alarm_info, alarm_id, noti, &error_code))
+ if (!_send_alarm_create_noti(alarm_context, base_info, alarm_id, noti, &error_code))
return error_code;
return ALARMMGR_RESULT_SUCCESS;
@@ -1153,7 +1153,7 @@ EXPORT_API int alarmmgr_add_alarm_appsvc(int alarm_type, time_t trigger_at_time,
int error_code = 0;
int result = 0;
int modified_alarm_type = 0;
- alarm_info_t alarm_info;
+ base_info_t base_info;
const char *operation = NULL;
const char *appid = NULL;
bundle *b;
@@ -1202,16 +1202,16 @@ EXPORT_API int alarmmgr_add_alarm_appsvc(int alarm_type, time_t trigger_at_time,
modified_alarm_type ^= ALARM_TYPE_INEXACT;
}
- _initialize_alarm_info(&alarm_info, modified_alarm_type | ALARM_TYPE_RELATIVE,
+ _initialize_alarm_info(&base_info, modified_alarm_type | ALARM_TYPE_RELATIVE,
trigger_at_time, interval, false);
- if ((alarm_info.alarm_type & ALARM_TYPE_INEXACT) &&
- alarm_info.mode.u_interval.interval < MIN_INEXACT_INTERVAL) {
- alarm_info.mode.u_interval.interval = MIN_INEXACT_INTERVAL;
- alarm_info.mode.repeat = ALARM_REPEAT_MODE_REPEAT;
+ if ((base_info.alarm_type & ALARM_TYPE_INEXACT) &&
+ base_info.mode.u_interval.interval < MIN_INEXACT_INTERVAL) {
+ base_info.mode.u_interval.interval = MIN_INEXACT_INTERVAL;
+ base_info.mode.repeat = ALARM_REPEAT_MODE_REPEAT;
}
- if (!_send_alarm_create_appsvc(alarm_context, &alarm_info, alarm_id, b, &error_code))
+ if (!_send_alarm_create_appsvc(alarm_context, &base_info, alarm_id, b, &error_code))
return error_code;
@@ -1225,7 +1225,7 @@ EXPORT_API int alarmmgr_add_alarm_noti(int alarm_type, time_t trigger_at_time,
alarm_id_t *alarm_id)
{
int error_code = 0;
- alarm_info_t alarm_info;
+ base_info_t base_info;
if (__alarmmgr_init_appsvc() < 0) {
LOGE("Unable to initialize dbus!!!\n");
@@ -1242,16 +1242,16 @@ EXPORT_API int alarmmgr_add_alarm_noti(int alarm_type, time_t trigger_at_time,
return ERR_ALARM_INVALID_PARAM;
}
- _initialize_alarm_info(&alarm_info, alarm_type | ALARM_TYPE_RELATIVE,
+ _initialize_alarm_info(&base_info, alarm_type | ALARM_TYPE_RELATIVE,
trigger_at_time, interval, false);
- if ((alarm_info.alarm_type & ALARM_TYPE_INEXACT) &&
- alarm_info.mode.u_interval.interval < MIN_INEXACT_INTERVAL) {
- alarm_info.mode.u_interval.interval = MIN_INEXACT_INTERVAL;
- alarm_info.mode.repeat = ALARM_REPEAT_MODE_REPEAT;
+ if ((base_info.alarm_type & ALARM_TYPE_INEXACT) &&
+ base_info.mode.u_interval.interval < MIN_INEXACT_INTERVAL) {
+ base_info.mode.u_interval.interval = MIN_INEXACT_INTERVAL;
+ base_info.mode.repeat = ALARM_REPEAT_MODE_REPEAT;
}
- if (!_send_alarm_create_noti(alarm_context, &alarm_info, alarm_id, noti, &error_code))
+ if (!_send_alarm_create_noti(alarm_context, &base_info, alarm_id, noti, &error_code))
return error_code;
return ALARMMGR_RESULT_SUCCESS;
@@ -1267,7 +1267,7 @@ static int _alarmmgr_add_alarm(int alarm_type,
int i = 0;
int j = 0;
int error_code;
- alarm_info_t alarm_info;
+ base_info_t base_info;
int ret;
ret = __sub_init();
@@ -1289,7 +1289,7 @@ static int _alarmmgr_add_alarm(int alarm_type,
return ERR_ALARM_INVALID_PARAM;
}
- _initialize_alarm_info(&alarm_info, alarm_type | ALARM_TYPE_RELATIVE,
+ _initialize_alarm_info(&base_info, alarm_type | ALARM_TYPE_RELATIVE,
trigger_at_time, interval, precision);
if (destination != NULL) {
@@ -1310,13 +1310,13 @@ static int _alarmmgr_add_alarm(int alarm_type,
j++;
}
- if (!_send_alarm_create(alarm_context, &alarm_info,
+ if (!_send_alarm_create(alarm_context, &base_info,
alarm_id, dst_service_name,
dst_service_name_mod,
&error_code))
return error_code;
} else {
- if (!_send_alarm_create(alarm_context, &alarm_info, alarm_id,
+ if (!_send_alarm_create(alarm_context, &base_info, alarm_id,
"null", "null", &error_code))
return error_code;
}
@@ -1346,7 +1346,7 @@ static int _alarmmgr_add_alarm_withcb(int alarm_type, time_t trigger_at_time,
alarm_id_t *alarm_id, bool precision)
{
int error_code = 0;
- alarm_info_t alarm_info;
+ base_info_t base_info;
int ret = 0;
__check_appid();
@@ -1366,11 +1366,11 @@ static int _alarmmgr_add_alarm_withcb(int alarm_type, time_t trigger_at_time,
return ERR_ALARM_INVALID_PARAM;
}
- _initialize_alarm_info(&alarm_info,
+ _initialize_alarm_info(&base_info,
alarm_type | ALARM_TYPE_RELATIVE | ALARM_TYPE_WITHCB,
trigger_at_time, interval, precision);
- if (!_send_alarm_create(alarm_context, &alarm_info, alarm_id, "null", "null", &error_code))
+ if (!_send_alarm_create(alarm_context, &base_info, alarm_id, "null", "null", &error_code))
return error_code;
__add_resultcb(*alarm_id, handler, user_param);
@@ -1473,7 +1473,7 @@ EXPORT_API int alarmmgr_enum_alarm_ids(alarm_enum_fn_t fn, void *user_param)
EXPORT_API int alarmmgr_get_info(alarm_id_t alarm_id, alarm_entry_t *alarm)
{
int error_code;
- alarm_info_t *alarm_info = (alarm_info_t *) alarm;
+ base_info_t *base_info = (base_info_t *) alarm;
int ret;
ret = __sub_init();
@@ -1482,12 +1482,12 @@ EXPORT_API int alarmmgr_get_info(alarm_id_t alarm_id, alarm_entry_t *alarm)
LOGD("[alarm-lib]:alarm_get_info() is called\n");
- if (alarm_id < 0 || alarm_info == NULL) {
- LOGE("[alarm-lib]:alarm_info is null or alar_id is invalid[%d].", alarm_id);
+ if (alarm_id < 0 || base_info == NULL) {
+ LOGE("[alarm-lib]:base_info is null or alar_id is invalid[%d].", alarm_id);
return ERR_ALARM_INVALID_PARAM;
}
- if (!_send_alarm_get_info(alarm_context, alarm_id, alarm_info, &error_code))
+ if (!_send_alarm_get_info(alarm_context, alarm_id, base_info, &error_code))
return error_code;
return ALARMMGR_RESULT_SUCCESS;
@@ -1770,7 +1770,7 @@ EXPORT_API int alarmmgr_get_global(const alarm_id_t alarm_id,
EXPORT_API int alarmmgr_update_alarm(alarm_id_t alarm_id,
alarm_entry_t *alarm, int update_flag)
{
- alarm_info_t *alarm_info;
+ base_info_t *base_info;
int ret;
LOGD("[alarm-lib]:alarmmgr_update_alarm() is called\n");
@@ -1780,8 +1780,8 @@ EXPORT_API int alarmmgr_update_alarm(alarm_id_t alarm_id,
return ERR_ALARM_INVALID_PARAM;
}
- alarm_info = (alarm_info_t *) alarm;
- if (alarm_info == NULL || alarm_id <= 0) {
+ base_info = (base_info_t *) alarm;
+ if (base_info == NULL || alarm_id <= 0) {
LOGE("[alarm-lib]:alarm is NULL or invalid alarm_id[%d]\n", alarm_id);
return ERR_ALARM_INVALID_PARAM;
}
@@ -1793,18 +1793,18 @@ EXPORT_API int alarmmgr_update_alarm(alarm_id_t alarm_id,
return ret;
LOGD("start(%d-%d-%d, %02d:%02d:%02d), end(%d-%d-%d), repeat(%d), interval(%ld), type(%d)",
- alarm_info->start.day, alarm_info->start.month, alarm_info->start.year,
- alarm_info->start.hour, alarm_info->start.min, alarm_info->start.sec,
- alarm_info->end.year, alarm_info->end.month, alarm_info->end.day,
- alarm_info->mode.repeat, alarm_info->mode.u_interval.interval, alarm_info->alarm_type);
+ base_info->start.day, base_info->start.month, base_info->start.year,
+ base_info->start.hour, base_info->start.min, base_info->start.sec,
+ base_info->end.year, base_info->end.month, base_info->end.day,
+ base_info->mode.repeat, base_info->mode.u_interval.interval, base_info->alarm_type);
if (update_flag == ALARM_UPDATE_FLAG_TIME) {
- error_code = __check_validation(alarm_info, __FUNCTION__);
+ error_code = __check_validation(base_info, __FUNCTION__);
if (error_code != ALARMMGR_RESULT_SUCCESS)
return error_code;
}
- if (!_send_alarm_update(alarm_context, alarm_id, alarm_info, update_flag, &error_code))
+ if (!_send_alarm_update(alarm_context, alarm_id, base_info, update_flag, &error_code))
return error_code;
return ALARMMGR_RESULT_SUCCESS;
diff --git a/packaging/alarm-manager.spec b/packaging/alarm-manager.spec
index 611b862..5412983 100644
--- a/packaging/alarm-manager.spec
+++ b/packaging/alarm-manager.spec
@@ -1,6 +1,6 @@
Name: alarm-manager
Summary: Alarm library
-Version: 0.10.4
+Version: 0.10.7
Release: 1
Group: System/Libraries
License: Apache-2.0
diff --git a/server/alarm-manager-db.c b/server/alarm-manager-db.c
index 0fdd4bf..1b63b77 100644
--- a/server/alarm-manager-db.c
+++ b/server/alarm-manager-db.c
@@ -209,10 +209,10 @@ static int __db_busyhandler(void *pData, int count)
bool _save_alarms(__alarm_info_t *__alarm_info)
{
char *error_message = NULL;
- alarm_info_t *alarm_info =
- (alarm_info_t *) &(__alarm_info->alarm_info);
- alarm_date_t *start = &alarm_info->start;
- alarm_mode_t *mode = &alarm_info->mode;
+ base_info_t *base_info =
+ (base_info_t *) &(__alarm_info->base_info);
+ alarm_date_t *start = &base_info->start;
+ alarm_mode_t *mode = &base_info->mode;
char *query = sqlite3_mprintf("insert into alarmmgr( alarm_id, start,\
end, uid, global, is_disabled, caller_pkgid, callee_pkgid, app_unique_name,\
@@ -240,14 +240,19 @@ bool _save_alarms(__alarm_info_t *__alarm_info)
start->hour,
start->min,
start->sec,
- alarm_info->msec,
+ base_info->msec,
mode->u_interval.day_of_week,
mode->repeat,
- alarm_info->alarm_type,
- (gint64)alarm_info->reserved_info,
+ base_info->alarm_type,
+ (gint64)base_info->reserved_info,
CHECK_NULL_STRING(__alarm_info->dst_service_name),
CHECK_NULL_STRING(__alarm_info->dst_service_name_mod));
+ if (!query) {
+ LOGE("Failed to alloc query");
+ return false;
+ }
+
if (SQLITE_OK != sqlite3_exec(alarmmgr_db, query, NULL, NULL, &error_message)) {
SECURE_LOGE("sqlite3_exec() is failed. query = %s, error message = %s", query, error_message);
sqlite3_free(error_message);
@@ -262,10 +267,10 @@ bool _save_alarms(__alarm_info_t *__alarm_info)
bool _update_alarms(__alarm_info_t *__alarm_info)
{
char *error_message = NULL;
- alarm_info_t *alarm_info =
- (alarm_info_t *) &(__alarm_info->alarm_info);
- alarm_date_t *start = &alarm_info->start;
- alarm_mode_t *mode = &alarm_info->mode;
+ base_info_t *base_info =
+ (base_info_t *) &(__alarm_info->base_info);
+ alarm_date_t *start = &base_info->start;
+ alarm_mode_t *mode = &base_info->mode;
char *query = sqlite3_mprintf("update alarmmgr set start=%lld, end=%lld,\
uid=%d, global=%d, is_disabled=0, caller_pkgid=%Q, callee_pkgid=%Q, app_unique_name=%Q, app_service_name=%Q, app_service_name_mod=%Q,\
@@ -291,15 +296,20 @@ bool _update_alarms(__alarm_info_t *__alarm_info)
start->hour,
start->min,
start->sec,
- alarm_info->msec,
+ base_info->msec,
mode->u_interval.day_of_week,
mode->repeat,
- alarm_info->alarm_type,
- (gint64)alarm_info->reserved_info,
+ base_info->alarm_type,
+ (gint64)base_info->reserved_info,
CHECK_NULL_STRING(__alarm_info->dst_service_name),
CHECK_NULL_STRING(__alarm_info->dst_service_name_mod),
__alarm_info->alarm_id);
+ if (!query) {
+ LOGE("Failed to alloc query");
+ return false;
+ }
+
if (SQLITE_OK != sqlite3_exec(alarmmgr_db, query, NULL, NULL, &error_message)) {
SECURE_LOGE("sqlite3_exec() is failed. query = %s, error message = %s", query, error_message);
sqlite3_free(error_message);
@@ -316,6 +326,11 @@ bool _delete_alarms(alarm_id_t alarm_id)
char *error_message = NULL;
char *query = sqlite3_mprintf("delete from alarmmgr where alarm_id=%d", alarm_id);
+ if (!query) {
+ LOGE("Failed to alloc query");
+ return false;
+ }
+
if (SQLITE_OK != sqlite3_exec(alarmmgr_db, query, NULL, NULL, &error_message)) {
SECURE_LOGE("sqlite3_exec() is failed. query = %s, error message = %s", query, error_message);
sqlite3_free(error_message);
@@ -335,7 +350,7 @@ void _load_alarms_from_db()
const char *null_str = "null";
sqlite3_stmt *stmt = NULL;
const char *tail = NULL;
- alarm_info_t *alarm_info = NULL;
+ base_info_t *base_info = NULL;
__alarm_info_t *__alarm_info = NULL;
alarm_date_t *start = NULL;
alarm_mode_t *mode = NULL;
@@ -365,9 +380,9 @@ void _load_alarms_from_db()
LOGE("Memory allocation failed.");
goto done;
}
- alarm_info = (alarm_info_t *) &(__alarm_info->alarm_info);
- start = &alarm_info->start;
- mode = &alarm_info->mode;
+ base_info = (base_info_t *) &(__alarm_info->base_info);
+ start = &base_info->start;
+ mode = &base_info->mode;
__alarm_info->alarm_id = sqlite3_column_int(stmt, col_idx++);
start_64 = sqlite3_column_int64(stmt, col_idx++);
@@ -402,12 +417,12 @@ void _load_alarms_from_db()
start->hour = sqlite3_column_int(stmt, col_idx++);
start->min = sqlite3_column_int(stmt, col_idx++);
start->sec = sqlite3_column_int(stmt, col_idx++);
- alarm_info->msec = sqlite3_column_int(stmt, col_idx++);
+ base_info->msec = sqlite3_column_int(stmt, col_idx++);
mode->u_interval.day_of_week = sqlite3_column_int(stmt, col_idx++);
mode->repeat = (alarm_repeat_mode_t)sqlite3_column_int(stmt, col_idx++);
- alarm_info->alarm_type = sqlite3_column_int(stmt, col_idx++);
+ base_info->alarm_type = sqlite3_column_int(stmt, col_idx++);
reserved_info_64 = sqlite3_column_int64(stmt, col_idx++);
- alarm_info->reserved_info = (time_t)reserved_info_64;
+ base_info->reserved_info = (time_t)reserved_info_64;
strncpy(dst_service_name, (const char *)sqlite3_column_text(stmt, col_idx++),
MAX_SERVICE_NAME_LEN - 1);
strncpy(dst_service_name_mod, (const char *)sqlite3_column_text(stmt, col_idx++),
@@ -518,8 +533,8 @@ int _get_db_path_for_all_info(uid_t uid, char** db_path)
SECURE_LOGD("#%d alarm id[%d] app_name[%s] duetime[%ld]",
index, entry->alarm_id, entry->app_unique_name, entry->start);
- alarm_info_t *alarm_info = (alarm_info_t *) &(entry->alarm_info);
- alarm_mode_t *mode = &alarm_info->mode;
+ base_info_t *base_info = (base_info_t *) &(entry->base_info);
+ alarm_mode_t *mode = &base_info->mode;
char *query = sqlite3_mprintf("insert into alarmmgr_tool( alarm_id, duetime_epoch, duetime, start_epoch,\
end_epoch, global, caller_pkgid, callee_pkgid, app_unique_name, app_service_name, dst_service_name, day_of_week, repeat, alarm_type)\
@@ -537,7 +552,12 @@ int _get_db_path_for_all_info(uid_t uid, char** db_path)
CHECK_NULL_STRING(entry->dst_service_name),
mode->u_interval.day_of_week,
mode->repeat,
- entry->alarm_info.alarm_type);
+ entry->base_info.alarm_type);
+
+ if (!query) {
+ LOGE("Failed to alloc query");
+ return ERR_ALARM_SYSTEM_FAIL;
+ }
if (sqlite3_exec(alarmmgr_tool_db, query, NULL, NULL, &error_message) != SQLITE_OK) {
SECURE_LOGE("sqlite3_exec() is failed. error message = %s", error_message);
@@ -565,8 +585,8 @@ gboolean _update_relative_alarms(gpointer user_data)
for (iter = alarm_context.alarms; iter != NULL; iter = g_slist_next(iter)) {
entry = (__alarm_info_t *)iter->data;
- alarm_info_t *alarm_info = &(entry->alarm_info);
- if (alarm_info->alarm_type & ALARM_TYPE_RELATIVE)
+ base_info_t *base_info = &(entry->base_info);
+ if (base_info->alarm_type & ALARM_TYPE_RELATIVE)
_update_alarms(entry);
}
@@ -586,6 +606,11 @@ bool _alarm_set_global_to_db(__alarm_info_t *alarm_info, bool global)
char *query = sqlite3_mprintf("update alarmmgr set global=%d where alarm_id=%d",
alarm_info->global, alarm_info->alarm_id);
+ if (!query) {
+ LOGE("Failed to alloc query");
+ return false;
+ }
+
if (SQLITE_OK != sqlite3_exec(alarmmgr_db, query, NULL, NULL, &error_message)) {
SECURE_LOGE("sqlite3_exec() is failed. query = %s, error message = %s", query, error_message);
sqlite3_free(query);
@@ -604,6 +629,11 @@ void _update_db_for_disabled_alarm(alarm_id_t alarm_id, bool disabled)
LOGW("Update (%d) is_disabled to (%d)", alarm_id, disabled);
char *query = sqlite3_mprintf("update alarmmgr set is_disabled=%d where alarm_id=%d", disabled, alarm_id);
+ if (!query) {
+ LOGE("Failed to alloc query");
+ return;
+ }
+
if (SQLITE_OK != sqlite3_exec(alarmmgr_db, query, NULL, NULL, &error_message)) {
SECURE_LOGE("Failed to update the DB table. error message = %s", error_message);
sqlite3_free(error_message);
diff --git a/server/alarm-manager-dbus.c b/server/alarm-manager-dbus.c
index 927ae04..66a1bb5 100644
--- a/server/alarm-manager-dbus.c
+++ b/server/alarm-manager-dbus.c
@@ -682,19 +682,19 @@ static void handle_method_call(GDBusConnection *connection,
if (noti_data)
free(noti_data);
} else if (g_strcmp0(method_name, "alarm_get_info") == 0) {
- alarm_info_t alarm_info = { 0, };
+ base_info_t base_info = { 0, };
- ret = alarm_manager_alarm_get_info(parameters, uid, &alarm_info);
+ ret = alarm_manager_alarm_get_info(parameters, uid, &base_info);
g_dbus_method_invocation_return_value(
invoc, g_variant_new("(iiiiiiiiiiiixi)",
- alarm_info.start.year, alarm_info.start.month,
- alarm_info.start.day, alarm_info.start.hour,
- alarm_info.start.min, alarm_info.start.sec,
- alarm_info.end.year, alarm_info.end.month,
- alarm_info.end.day, alarm_info.mode.u_interval.day_of_week,
- alarm_info.mode.repeat, alarm_info.alarm_type,
- (gint64)alarm_info.reserved_info, ret));
+ base_info.start.year, base_info.start.month,
+ base_info.start.day, base_info.start.hour,
+ base_info.start.min, base_info.start.sec,
+ base_info.end.year, base_info.end.month,
+ base_info.end.day, base_info.mode.u_interval.day_of_week,
+ base_info.mode.repeat, base_info.alarm_type,
+ (gint64)base_info.reserved_info, ret));
} else if (g_strcmp0(method_name, "alarm_get_next_duetime") == 0) {
time_t duetime;
ret = alarm_manager_alarm_get_next_duetime(parameters, uid, &duetime);
diff --git a/server/alarm-manager-schedule.c b/server/alarm-manager-schedule.c
index 68b9180..a4ded97 100644
--- a/server/alarm-manager-schedule.c
+++ b/server/alarm-manager-schedule.c
@@ -98,14 +98,14 @@ static time_t __alarm_next_duetime_once(__alarm_info_t *__alarm_info)
struct tm tmp_tm;
int current_dst = 0;
- if ((__alarm_info->alarm_info.alarm_type & ALARM_TYPE_RELATIVE) && __alarm_info->start != 0) {
+ if ((__alarm_info->base_info.alarm_type & ALARM_TYPE_RELATIVE) && __alarm_info->start != 0) {
LOGE("Final due_time = %ld, %s",
__alarm_info->start, ctime(&__alarm_info->start));
return __alarm_info->start;
}
- alarm_info_t *alarm_info = &__alarm_info->alarm_info;
- alarm_date_t *start = &alarm_info->start;
+ base_info_t *base_info = &__alarm_info->base_info;
+ alarm_date_t *start = &base_info->start;
tzset();
time(&current_time);
@@ -163,8 +163,8 @@ static time_t __alarm_next_duetime_repeat(__alarm_info_t *__alarm_info)
time_t current_time = 0;
struct tm duetime_tm;
- alarm_info_t *alarm_info = &__alarm_info->alarm_info;
- alarm_date_t *start = &alarm_info->start;
+ base_info_t *base_info = &__alarm_info->base_info;
+ alarm_date_t *start = &base_info->start;
time(&current_time);
@@ -177,26 +177,26 @@ static time_t __alarm_next_duetime_repeat(__alarm_info_t *__alarm_info)
duetime_tm.tm_mday = start->day;
duetime_tm.tm_isdst = -1;
- if (alarm_info->alarm_type & ALARM_TYPE_PERIOD &&
- alarm_info->mode.u_interval.interval > 0) {
+ if (base_info->alarm_type & ALARM_TYPE_PERIOD &&
+ base_info->mode.u_interval.interval > 0) {
/* For minimize 'while loop'
* Duetime should be "periodic_standard_time + (interval * x) >= current" */
time_t periodic_standard_time = _get_periodic_alarm_standard_time();
time_t temp;
- temp = (current_time - periodic_standard_time) / alarm_info->mode.u_interval.interval;
- due_time = periodic_standard_time + (temp * alarm_info->mode.u_interval.interval);
+ temp = (current_time - periodic_standard_time) / base_info->mode.u_interval.interval;
+ due_time = periodic_standard_time + (temp * base_info->mode.u_interval.interval);
} else {
due_time = mktime(&duetime_tm);
}
while (__alarm_info->start > due_time || current_time > due_time || ((!is_time_changed) && (current_time == due_time))) {
- if (due_time + alarm_info->mode.u_interval.interval < due_time) {
+ if (due_time + base_info->mode.u_interval.interval < due_time) {
LOGD("time_t OVERFLOW!! duetime = %ld", due_time);
due_time = -1;
break;
}
- due_time += alarm_info->mode.u_interval.interval;
+ due_time += base_info->mode.u_interval.interval;
}
localtime_r(&due_time, &duetime_tm);
@@ -217,8 +217,8 @@ static time_t __alarm_next_duetime_annually(__alarm_info_t *__alarm_info)
time_t current_time = 0;
struct tm duetime_tm;
- alarm_info_t *alarm_info = &__alarm_info->alarm_info;
- alarm_date_t *start = &alarm_info->start;
+ base_info_t *base_info = &__alarm_info->base_info;
+ alarm_date_t *start = &base_info->start;
time(&current_time);
localtime_r(&current_time, &duetime_tm);
@@ -252,8 +252,8 @@ static time_t __alarm_next_duetime_monthly(__alarm_info_t *__alarm_info)
time_t current_time = 0;
struct tm duetime_tm;
- alarm_info_t *alarm_info = &__alarm_info->alarm_info;
- alarm_date_t *start = &alarm_info->start;
+ base_info_t *base_info = &__alarm_info->base_info;
+ alarm_date_t *start = &base_info->start;
time(&current_time);
localtime_r(&current_time, &duetime_tm);
@@ -298,9 +298,9 @@ static time_t __alarm_next_duetime_weekly(__alarm_info_t *__alarm_info)
struct tm before_tm;
struct tm after_tm;
- alarm_info_t *alarm_info = &__alarm_info->alarm_info;
- alarm_date_t *start = &alarm_info->start;
- alarm_mode_t *mode = &alarm_info->mode;
+ base_info_t *base_info = &__alarm_info->base_info;
+ alarm_date_t *start = &base_info->start;
+ alarm_mode_t *mode = &base_info->mode;
tzset();
time(&current_time);
@@ -402,8 +402,8 @@ void _alarm_set_next_duetime(__alarm_info_t *__alarm_info)
struct tm tm, *cur_tm = NULL;
struct tm *due_tm = NULL;
- alarm_info_t *alarm_info = &__alarm_info->alarm_info;
- alarm_mode_t *mode = &alarm_info->mode;
+ base_info_t *base_info = &__alarm_info->base_info;
+ alarm_mode_t *mode = &base_info->mode;
time(&current_time);
cur_tm = localtime_r(&current_time, &tm);
@@ -490,7 +490,7 @@ static bool __find_next_alarm_to_be_scheduled(time_t *min_due_time)
LOGW("The alarm(%d) is removed [unique_name : %s, dst : %s",
entry->alarm_id, entry->app_unique_name, dst);
- if (!(entry->alarm_info.alarm_type & ALARM_TYPE_VOLATILE))
+ if (!(entry->base_info.alarm_type & ALARM_TYPE_VOLATILE))
_delete_alarms(entry->alarm_id);
_save_alarm_info_log("AUTO_DELETE", entry);
diff --git a/server/alarm-manager-util.c b/server/alarm-manager-util.c
index 9515a52..b4698e9 100644
--- a/server/alarm-manager-util.c
+++ b/server/alarm-manager-util.c
@@ -516,8 +516,8 @@ void _save_alarm_info_log(const char *tag, __alarm_info_t *info)
"interval:%ld, duetime: %ld %s",
info->alarm_id, info->uid, info->app_unique_name, info->callee_pkgid,
info->dst_service_name, info->dst_service_name_mod,
- info->alarm_info.alarm_type, info->alarm_info.mode.repeat,
- info->alarm_info.mode.u_interval.interval, info->due_time, due_time_str);
+ info->base_info.alarm_type, info->base_info.mode.repeat,
+ info->base_info.mode.u_interval.interval, info->due_time, due_time_str);
_save_module_log(tag, log_message);
#endif /* _APPFW_FEATURE_ALARM_MANAGER_MODULE_LOG */
diff --git a/server/alarm-manager.c b/server/alarm-manager.c
index e0434ef..0824bca 100644
--- a/server/alarm-manager.c
+++ b/server/alarm-manager.c
@@ -102,23 +102,23 @@ static long __get_proper_interval(long interval, int alarm_type);
static void __alarm_add_to_list(__alarm_info_t *__alarm_info);
static void __alarm_generate_alarm_id(__alarm_info_t *__alarm_info, alarm_id_t *alarm_id);
static __alarm_info_t *__alarm_update_in_list(uid_t uid, alarm_id_t alarm_id,
- alarm_info_t *alarm_info, int update_flag, int *error_code);
+ base_info_t *base_info, int update_flag, int *error_code);
static bool __alarm_remove_from_list(uid_t uid, alarm_id_t alarm_id,
int *error_code);
-static void __alarm_set_start_and_end_time(alarm_info_t *alarm_info,
+static void __alarm_set_start_and_end_time(base_info_t *base_info,
__alarm_info_t *__alarm_info);
static void __alarm_update_due_time_of_all_items_in_list(time_t new_time,double diff_time);
-static bool __alarm_create(alarm_info_t *alarm_info, alarm_id_t *alarm_id, uid_t uid,
+static bool __alarm_create(base_info_t *base_info, alarm_id_t *alarm_id, uid_t uid,
int pid, periodic_method_e method, long requested_interval, int is_ref,
char *app_service_name, char *app_service_name_mod,
const char *dst_service_name, const char *dst_service_name_mod,
int *error_code);
-static bool __alarm_create_appsvc(alarm_info_t *alarm_info, alarm_id_t *alarm_id,
+static bool __alarm_create_appsvc(base_info_t *base_info, alarm_id_t *alarm_id,
long requested_interval, uid_t uid, int pid, char *bundle_data, int *error_code);
static bool __alarm_delete(uid_t uid, alarm_id_t alarm_id, int *error_code);
static bool __alarm_update(uid_t uid, alarm_id_t alarm_id,
- alarm_info_t *alarm_info, int update_flag, int *error_code);
+ base_info_t *base_info, int update_flag, int *error_code);
static void __on_system_time_external_changed(keynode_t *node, void *data);
static void __initialize_alarm_list();
static void __initialize_scheduled_alarm_list();
@@ -371,7 +371,7 @@ static void __alarm_generate_alarm_id(__alarm_info_t *__alarm_info, alarm_id_t *
static void __alarm_add_to_list(__alarm_info_t *__alarm_info)
{
- alarm_info_t *alarm_info = &__alarm_info->alarm_info;
+ base_info_t *base_info = &__alarm_info->base_info;
__alarm_info_t *entry = NULL;
GSList *iter = NULL;
@@ -386,7 +386,7 @@ static void __alarm_add_to_list(__alarm_info_t *__alarm_info)
LOGD("[alarm-server]: alarm_id(%d).", entry->alarm_id);
}
- if (!(alarm_info->alarm_type & ALARM_TYPE_VOLATILE)) {
+ if (!(base_info->alarm_type & ALARM_TYPE_VOLATILE)) {
if (!_save_alarms(__alarm_info))
LOGE("Saving alarm_id(%d) in DB is failed.", __alarm_info->alarm_id);
}
@@ -422,12 +422,12 @@ static bool __check_bundle_for_update(const gchar *b_data, uid_t uid)
}
static __alarm_info_t *__alarm_update_in_list(uid_t uid, alarm_id_t alarm_id,
- alarm_info_t *alarm_info, int update_flag, int *error_code)
+ base_info_t *base_info, int update_flag, int *error_code)
{
bool found = false;
GSList *iter = NULL;
__alarm_info_t *entry = NULL;
- alarm_info_t *_alarm_info = NULL;
+ base_info_t *found_base_info = NULL;
time_t current_time;
for (iter = alarm_context.alarms; iter != NULL;
@@ -436,7 +436,7 @@ static __alarm_info_t *__alarm_update_in_list(uid_t uid, alarm_id_t alarm_id,
if (entry->uid == uid &&
entry->alarm_id == alarm_id) {
found = true;
- _alarm_info = &entry->alarm_info;
+ found_base_info = &entry->base_info;
if (update_flag == ALARM_UPDATE_FLAG_TIME ||
ALARM_UPDATE_FLAG_WEEK) {
@@ -448,32 +448,32 @@ static __alarm_info_t *__alarm_update_in_list(uid_t uid, alarm_id_t alarm_id,
}
if (update_flag == ALARM_UPDATE_FLAG_TIME) {
- __alarm_set_start_and_end_time(alarm_info, entry);
- memcpy(_alarm_info, alarm_info, sizeof(alarm_info_t));
+ __alarm_set_start_and_end_time(base_info, entry);
+ memcpy(found_base_info, base_info, sizeof(base_info_t));
- if (_alarm_info->mode.repeat == ALARM_REPEAT_MODE_ONCE) {
+ if (found_base_info->mode.repeat == ALARM_REPEAT_MODE_ONCE) {
time(&current_time);
- _alarm_info->reserved_info = current_time;
+ found_base_info->reserved_info = current_time;
}
} else if (update_flag == ALARM_UPDATE_FLAG_PERIOD) {
- _alarm_info->alarm_type |= ALARM_TYPE_INEXACT;
- _alarm_info->alarm_type |= ALARM_TYPE_PERIOD;
- _alarm_info->mode.repeat = ALARM_REPEAT_MODE_REPEAT;
- _alarm_info->mode.u_interval.interval =
- __get_proper_interval(alarm_info->mode.u_interval.interval,
- _alarm_info->alarm_type);
+ found_base_info->alarm_type |= ALARM_TYPE_INEXACT;
+ found_base_info->alarm_type |= ALARM_TYPE_PERIOD;
+ found_base_info->mode.repeat = ALARM_REPEAT_MODE_REPEAT;
+ found_base_info->mode.u_interval.interval =
+ __get_proper_interval(base_info->mode.u_interval.interval,
+ found_base_info->alarm_type);
} else if (update_flag == ALARM_UPDATE_FLAG_WEEK) {
- _alarm_info->alarm_type &= ~ALARM_TYPE_INEXACT;
- _alarm_info->mode = alarm_info->mode;
+ found_base_info->alarm_type &= ~ALARM_TYPE_INEXACT;
+ found_base_info->mode = base_info->mode;
} else if (update_flag == ALARM_UPDATE_FLAG_CLEAR_PERIOD) {
- if (_alarm_info->mode.repeat == ALARM_REPEAT_MODE_REPEAT) {
- _alarm_info->mode.repeat = ALARM_REPEAT_MODE_ONCE;
- _alarm_info->mode.u_interval.interval = 0;
+ if (found_base_info->mode.repeat == ALARM_REPEAT_MODE_REPEAT) {
+ found_base_info->mode.repeat = ALARM_REPEAT_MODE_ONCE;
+ found_base_info->mode.u_interval.interval = 0;
}
} else if (update_flag == ALARM_UPDATE_FLAG_CLEAR_WEEK_FLAG) {
- if (_alarm_info->mode.repeat == ALARM_REPEAT_MODE_WEEKLY) {
- _alarm_info->mode.repeat = ALARM_REPEAT_MODE_ONCE;
- _alarm_info->mode.u_interval.interval = 0;
+ if (found_base_info->mode.repeat == ALARM_REPEAT_MODE_WEEKLY) {
+ found_base_info->mode.repeat = ALARM_REPEAT_MODE_ONCE;
+ found_base_info->mode.u_interval.interval = 0;
}
}
break;
@@ -486,7 +486,7 @@ static __alarm_info_t *__alarm_update_in_list(uid_t uid, alarm_id_t alarm_id,
return NULL;
}
- if (!(alarm_info->alarm_type & ALARM_TYPE_VOLATILE)) {
+ if (!(base_info->alarm_type & ALARM_TYPE_VOLATILE)) {
if (!_update_alarms(entry))
LOGE("Updating alarm_id(%d) in DB is failed.", alarm_id);
}
@@ -499,7 +499,7 @@ static bool __alarm_remove_from_list(uid_t uid, alarm_id_t alarm_id,
{
bool found = false;
- alarm_info_t *alarm_info = NULL;
+ base_info_t *base_info = NULL;
GSList *iter = NULL;
__alarm_info_t *entry = NULL;
@@ -510,11 +510,11 @@ static bool __alarm_remove_from_list(uid_t uid, alarm_id_t alarm_id,
for (iter = alarm_context.alarms; iter != NULL; iter = g_slist_next(iter)) {
entry = (__alarm_info_t *)iter->data;
if (entry->uid == uid && entry->alarm_id == alarm_id) {
- alarm_info = &entry->alarm_info;
+ base_info = &entry->base_info;
LOGD("[alarm-server]:Remove alarm id(%d)", entry->alarm_id);
- if (!(alarm_info->alarm_type & ALARM_TYPE_VOLATILE)) {
+ if (!(base_info->alarm_type & ALARM_TYPE_VOLATILE)) {
if (!_delete_alarms(alarm_id))
break;
}
@@ -537,17 +537,17 @@ static bool __alarm_remove_from_list(uid_t uid, alarm_id_t alarm_id,
return true;
}
-static void __alarm_set_start_and_end_time(alarm_info_t *alarm_info,
+static void __alarm_set_start_and_end_time(base_info_t *base_info,
__alarm_info_t *__alarm_info)
{
- alarm_date_t *start = &alarm_info->start;
- alarm_date_t *end = &alarm_info->end;
+ alarm_date_t *start = &base_info->start;
+ alarm_date_t *end = &base_info->end;
struct tm alarm_tm = { 0, };
if (start->year != 0) {
- if ((alarm_info->alarm_type & ALARM_TYPE_RELATIVE) && alarm_info->reserved_info != 0) {
- __alarm_info->start = alarm_info->reserved_info;
+ if ((base_info->alarm_type & ALARM_TYPE_RELATIVE) && base_info->reserved_info != 0) {
+ __alarm_info->start = base_info->reserved_info;
} else {
alarm_tm.tm_year = start->year - 1900;
alarm_tm.tm_mon = start->month - 1;
@@ -597,38 +597,38 @@ static void __alarm_update_due_time_of_all_items_in_list(time_t new_time, double
tzset();
for (iter = alarm_context.alarms; iter != NULL; iter = g_slist_next(iter)) {
entry = (__alarm_info_t *)iter->data;
- alarm_info_t *alarm_info = &(entry->alarm_info);
- if (alarm_info->alarm_type & ALARM_TYPE_RELATIVE) {
+ base_info_t *base_info = &(entry->base_info);
+ if (base_info->alarm_type & ALARM_TYPE_RELATIVE) {
/* case of RTC reset */
- if (entry->alarm_info.mode.repeat == ALARM_REPEAT_MODE_ONCE) {
+ if (entry->base_info.mode.repeat == ALARM_REPEAT_MODE_ONCE) {
if ((entry->due_time + diff_time - new_time) >
- (entry->due_time - entry->alarm_info.reserved_info)) {
+ (entry->due_time - entry->base_info.reserved_info)) {
LOGE("[ RTC reset]: new time %s %ld, diff %f, id %d duetime %s %ld %ld",
ctime(&new_time), new_time, diff_time, entry->alarm_id,
ctime(&entry->due_time), entry->due_time,
- entry->alarm_info.reserved_info);
+ entry->base_info.reserved_info);
continue;
}
entry->due_time += diff_time;
- entry->alarm_info.reserved_info = new_time;
+ entry->base_info.reserved_info = new_time;
} else {
entry->due_time += diff_time;
is_rtc_reset = false;
- if ((entry->due_time - new_time) > alarm_info->mode.u_interval.interval) {
+ if ((entry->due_time - new_time) > base_info->mode.u_interval.interval) {
is_rtc_reset = true;
entry->due_time = new_time +
- ((entry->due_time - new_time) % alarm_info->mode.u_interval.interval);
+ ((entry->due_time - new_time) % base_info->mode.u_interval.interval);
LOGE("[ RTC reset]: new time %s %ld, diff %f, id %d duetime %s %ld %ld",
ctime(&new_time), new_time, diff_time, entry->alarm_id,
ctime(&entry->due_time), entry->due_time,
- alarm_info->mode.u_interval.interval);
+ base_info->mode.u_interval.interval);
}
}
- alarm_date_t *start = &alarm_info->start; /**< start time of the alarm */
- alarm_date_t *end = &alarm_info->end; /**< end time of the alarm */
+ alarm_date_t *start = &base_info->start; /**< start time of the alarm */
+ alarm_date_t *end = &base_info->end; /**< end time of the alarm */
p_time = localtime_r(&entry->due_time, &due_time_result);
if (p_time != NULL) {
@@ -682,7 +682,7 @@ static void __alarm_update_due_time_of_all_items_in_list(time_t new_time, double
LOGW("The alarm(%d) is removed [unique_name : %s, dst : %s",
entry->alarm_id, entry->app_unique_name, dst);
- if (!(entry->alarm_info.alarm_type & ALARM_TYPE_VOLATILE))
+ if (!(entry->base_info.alarm_type & ALARM_TYPE_VOLATILE))
_delete_alarms(entry->alarm_id);
_save_alarm_info_log("AUTO_DELETE", entry);
@@ -741,8 +741,8 @@ static bool __alarm_add_and_set(__alarm_info_t *alarm_info, pid_t pid)
alarm_info->dst_service_name,
alarm_context.c_due_time);
- if (alarm_info->alarm_info.mode.repeat == ALARM_REPEAT_MODE_ONCE)
- alarm_info->alarm_info.reserved_info = current_time;
+ if (alarm_info->base_info.mode.repeat == ALARM_REPEAT_MODE_ONCE)
+ alarm_info->base_info.reserved_info = current_time;
if (alarm_context.c_due_time < current_time) {
LOGW("Caution!! alarm_context.c_due_time (%ld) is less than current time(%ld)",
@@ -754,16 +754,16 @@ static bool __alarm_add_and_set(__alarm_info_t *alarm_info, pid_t pid)
if (alarm_info->due_time == 0) {
LOGW("[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);
+ alarm_info->alarm_id, alarm_info->base_info.mode.repeat);
- if (alarm_info->alarm_info.mode.repeat == ALARM_REPEAT_MODE_ONCE)
+ if (alarm_info->base_info.mode.repeat == ALARM_REPEAT_MODE_ONCE)
return false;
__alarm_add_to_list(alarm_info);
return true;
} else if (current_time == alarm_info->due_time) {
LOGW("[alarm-server]:Create alarm: current_time(%ld) is same as due_time(%ld) [alarm(%d):repeat_type(%d)]",
- current_time, alarm_info->due_time, alarm_info->alarm_id, alarm_info->alarm_info.mode.repeat);
+ current_time, alarm_info->due_time, alarm_info->alarm_id, alarm_info->base_info.mode.repeat);
__alarm_add_to_list(alarm_info);
_clear_scheduled_alarm_list();
@@ -785,9 +785,9 @@ static bool __alarm_add_and_set(__alarm_info_t *alarm_info, pid_t pid)
LOGW("[alarm-server]: Expired Due Time. \
[Due time=%ld, Current Time=%ld]!!!Do not add to schedule list. \
[alarm(%d):repeat_type(%d)]",
- alarm_info->due_time, current_time, alarm_info->alarm_id, alarm_info->alarm_info.mode.repeat);
+ alarm_info->due_time, current_time, alarm_info->alarm_id, alarm_info->base_info.mode.repeat);
- if (alarm_info->alarm_info.mode.repeat == ALARM_REPEAT_MODE_ONCE)
+ if (alarm_info->base_info.mode.repeat == ALARM_REPEAT_MODE_ONCE)
return false;
__alarm_add_to_list(alarm_info);
@@ -817,7 +817,7 @@ static bool __alarm_add_and_set(__alarm_info_t *alarm_info, pid_t pid)
return true;
}
-static bool __alarm_create_appsvc(alarm_info_t *alarm_info, alarm_id_t *alarm_id,
+static bool __alarm_create_appsvc(base_info_t *base_info, alarm_id_t *alarm_id,
long requested_interval, uid_t uid, int pid, char *bundle_data, int *error_code)
{
char app_name[MAX_APP_ID_LEN] = { 0 };
@@ -877,8 +877,8 @@ static bool __alarm_create_appsvc(alarm_info_t *alarm_info, alarm_id_t *alarm_id
b_data = NULL;
}
- __alarm_set_start_and_end_time(alarm_info, __alarm_info);
- memcpy(&(__alarm_info->alarm_info), alarm_info, sizeof(alarm_info_t));
+ __alarm_set_start_and_end_time(base_info, __alarm_info);
+ memcpy(&(__alarm_info->base_info), base_info, sizeof(base_info_t));
__alarm_generate_alarm_id(__alarm_info, alarm_id);
if (__alarm_add_and_set(__alarm_info, pid) == false) {
@@ -892,7 +892,7 @@ static bool __alarm_create_appsvc(alarm_info_t *alarm_info, alarm_id_t *alarm_id
return true;
}
-static bool __alarm_create(alarm_info_t *alarm_info, alarm_id_t *alarm_id, uid_t uid,
+static bool __alarm_create(base_info_t *base_info, alarm_id_t *alarm_id, uid_t uid,
int pid, periodic_method_e method, long requested_interval, int is_ref,
char *app_service_name, char *app_service_name_mod,
const char *dst_service_name, const char *dst_service_name_mod,
@@ -941,8 +941,8 @@ static bool __alarm_create(alarm_info_t *alarm_info, alarm_id_t *alarm_id, uid_t
if (dst_service_name_mod)
__alarm_info->dst_service_name_mod = strdup(dst_service_name_mod);
- __alarm_set_start_and_end_time(alarm_info, __alarm_info);
- memcpy(&(__alarm_info->alarm_info), alarm_info, sizeof(alarm_info_t));
+ __alarm_set_start_and_end_time(base_info, __alarm_info);
+ memcpy(&(__alarm_info->base_info), base_info, sizeof(base_info_t));
__alarm_generate_alarm_id(__alarm_info, alarm_id);
if (__alarm_add_and_set(__alarm_info, pid) == false) {
@@ -1002,7 +1002,7 @@ end:
return new_noti_data;
}
-static bool __alarm_create_noti(alarm_info_t *alarm_info, alarm_id_t *alarm_id,
+static bool __alarm_create_noti(base_info_t *base_info, alarm_id_t *alarm_id,
long requested_interval, uid_t uid, int pid, char *noti_data, int *error_code)
{
char app_name[MAX_APP_ID_LEN] = { 0 };
@@ -1050,8 +1050,8 @@ static bool __alarm_create_noti(alarm_info_t *alarm_info, alarm_id_t *alarm_id,
__alarm_info->noti = strdup(noti_data);
}
- __alarm_set_start_and_end_time(alarm_info, __alarm_info);
- memcpy(&(__alarm_info->alarm_info), alarm_info, sizeof(alarm_info_t));
+ __alarm_set_start_and_end_time(base_info, __alarm_info);
+ memcpy(&(__alarm_info->base_info), base_info, sizeof(base_info_t));
__alarm_generate_alarm_id(__alarm_info, alarm_id);
if (__alarm_add_and_set(__alarm_info, pid) == false) {
@@ -1066,7 +1066,7 @@ static bool __alarm_create_noti(alarm_info_t *alarm_info, alarm_id_t *alarm_id,
}
static bool __alarm_update(uid_t uid, alarm_id_t alarm_id,
- alarm_info_t *alarm_info, int update_flag, int *error_code)
+ base_info_t *base_info, int update_flag, int *error_code)
{
time_t current_time;
char due_time_r[100] = { 0 };
@@ -1082,7 +1082,7 @@ static bool __alarm_update(uid_t uid, alarm_id_t alarm_id,
alarm_context.c_due_time = -1;
}
- __alarm_info = __alarm_update_in_list(uid, alarm_id, alarm_info,
+ __alarm_info = __alarm_update_in_list(uid, alarm_id, base_info,
update_flag, error_code);
if (!__alarm_info) {
LOGE("[alarm-server]: requested alarm_id "
@@ -1090,8 +1090,8 @@ static bool __alarm_update(uid_t uid, alarm_id_t alarm_id,
return false;
}
- if (__alarm_info->alarm_info.mode.repeat == ALARM_REPEAT_MODE_ONCE)
- __alarm_info->alarm_info.reserved_info = current_time;
+ if (__alarm_info->base_info.mode.repeat == ALARM_REPEAT_MODE_ONCE)
+ __alarm_info->base_info.reserved_info = current_time;
_alarm_set_next_duetime(__alarm_info);
@@ -1183,27 +1183,27 @@ bool _can_skip_expired_cb(alarm_id_t alarm_id)
{
GSList *gs_iter = NULL;
__alarm_info_t *entry = NULL;
- alarm_info_t *alarm = NULL;
+ base_info_t *base_info = NULL;
for (gs_iter = alarm_context.alarms; gs_iter != NULL; gs_iter = g_slist_next(gs_iter)) {
entry = (__alarm_info_t *)gs_iter->data;
if (entry->alarm_id == alarm_id) {
- alarm = &(entry->alarm_info);
+ base_info = &(entry->base_info);
time_t ts = 0;
struct tm ts_tm;
int dur = entry->requested_interval;
int from, to;
- if (dur == 0 || !(alarm->alarm_type & ALARM_TYPE_PERIOD) || entry->method == CUT_OFF)
+ if (dur == 0 || !(base_info->alarm_type & ALARM_TYPE_PERIOD) || entry->method == CUT_OFF)
return false;
- ts_tm.tm_hour = alarm->start.hour;
- ts_tm.tm_min = alarm->start.min;
- ts_tm.tm_sec = alarm->start.sec;
+ ts_tm.tm_hour = base_info->start.hour;
+ ts_tm.tm_min = base_info->start.min;
+ ts_tm.tm_sec = base_info->start.sec;
- ts_tm.tm_year = alarm->start.year - 1900;
- ts_tm.tm_mon = alarm->start.month - 1;
- ts_tm.tm_mday = alarm->start.day;
+ ts_tm.tm_year = base_info->start.year - 1900;
+ ts_tm.tm_mon = base_info->start.month - 1;
+ ts_tm.tm_mday = base_info->start.day;
ts_tm.tm_isdst = -1;
ts = mktime(&ts_tm);
@@ -1211,7 +1211,7 @@ bool _can_skip_expired_cb(alarm_id_t alarm_id)
from = (ts / dur) * dur;
to = from + dur;
- if (ts >= from && ts < to && from > ts - alarm->mode.u_interval.interval)
+ if (ts >= from && ts < to && from > ts - base_info->mode.u_interval.interval)
return false;
return true;
@@ -1380,9 +1380,9 @@ static void __expire_app_control(__alarm_info_t *alarm_info)
} else {
/* since 2.4 */
appid = (char *)appsvc_get_appid(b);
- if ((alarm_info->alarm_info.alarm_type & ALARM_TYPE_NOLAUNCH) && !aul_app_is_running(appid)) {
+ if ((alarm_info->base_info.alarm_type & ALARM_TYPE_NOLAUNCH) && !aul_app_is_running(appid)) {
LOGE("This alarm is ignored\n");
- } else if (!(alarm_info->alarm_info.alarm_type & ALARM_TYPE_INEXACT) ||
+ } else if (!(alarm_info->base_info.alarm_type & ALARM_TYPE_INEXACT) ||
!_can_skip_expired_cb(alarm_info->alarm_id)) {
if (alarm_info->global) {
if (__find_login_user(&target_uid) < 0) {
@@ -1479,7 +1479,7 @@ static int __expire_dbus_activation(__alarm_info_t *alarm_info)
LOGD("before alarm_send_noti_to_application");
_alarm_send_noti_to_application_by_dbus(destination_app_service_name,
- alarm_info->alarm_id, alarm_info->alarm_info.msec, alarm_info->uid); /* dbus auto activation */
+ alarm_info->alarm_id, alarm_info->base_info.msec, alarm_info->uid); /* dbus auto activation */
LOGD("after _alarm_send_noti_to_application_by_dbus");
} else {
/* Case #3-2. The process was killed && App type
@@ -1487,7 +1487,7 @@ static int __expire_dbus_activation(__alarm_info_t *alarm_info)
__expired_alarm_t *expire_info;
char alarm_id_str[32] = { 0, };
- if (alarm_info->alarm_info.alarm_type & ALARM_TYPE_WITHCB) {
+ if (alarm_info->base_info.alarm_type & ALARM_TYPE_WITHCB) {
__alarm_remove_from_list(alarm_info->uid, alarm_info->alarm_id, NULL);
LOGW("[alarm-server]:This alarm_type is WITHCB");
return -2;
@@ -1525,7 +1525,7 @@ static int __expire_dbus_activation(__alarm_info_t *alarm_info)
} else {
/* Case #3-3. The process was killed && non-app type(daemon)
* Expiration noti is sent by DBus. it makes the process alive. (dbus auto activation) */
- if (alarm_info->alarm_info.alarm_type & ALARM_TYPE_WITHCB) {
+ if (alarm_info->base_info.alarm_type & ALARM_TYPE_WITHCB) {
char *cmdline = _get_cmdline_from_pid(alarm_info->pid);
if (!cmdline || strcmp(cmdline, alarm_info->app_unique_name) != 0) {
__alarm_remove_from_list(alarm_info->uid, alarm_info->alarm_id, NULL);
@@ -1539,7 +1539,7 @@ static int __expire_dbus_activation(__alarm_info_t *alarm_info)
LOGD("before alarm_send_noti_to_application for daemon");
_alarm_send_noti_to_application_by_dbus(destination_app_service_name,
- alarm_info->alarm_id, alarm_info->alarm_info.msec, alarm_info->uid); /* dbus auto activation */
+ alarm_info->alarm_id, alarm_info->base_info.msec, alarm_info->uid); /* dbus auto activation */
LOGD("after _alarm_send_noti_to_application_by_dbus for daemon");
}
@@ -1602,7 +1602,7 @@ void _alarm_expired()
if (using_rtc)
DO_AFTER_ALARM_EXPIRE(__alarm_info->pid, __alarm_info->app_unique_name);
- if (__alarm_info->alarm_info.mode.repeat == ALARM_REPEAT_MODE_ONCE) {
+ if (__alarm_info->base_info.mode.repeat == ALARM_REPEAT_MODE_ONCE) {
__alarm_remove_from_list(__alarm_info->uid, __alarm_info->alarm_id, NULL);
} else {
_alarm_set_next_duetime(__alarm_info);
@@ -1694,7 +1694,7 @@ static int __on_app_enable_cb(uid_t target_uid, int req_id,
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))
+ if (!(entry->base_info.alarm_type & ALARM_TYPE_VOLATILE))
_update_db_for_disabled_alarm(entry->alarm_id, false);
is_restored = true;
}
@@ -1728,7 +1728,7 @@ static int __on_app_disable_cb(uid_t target_uid, int req_id,
gs_iter = g_slist_next(gs_iter);
if (strncmp(appid, entry->app_unique_name, strlen(appid)) == 0) {
- if (!(entry->alarm_info.alarm_type & ALARM_TYPE_VOLATILE))
+ if (!(entry->base_info.alarm_type & ALARM_TYPE_VOLATILE))
_update_db_for_disabled_alarm(entry->alarm_id, true);
g_disabled_alarm_list = g_slist_append(g_disabled_alarm_list, entry);
alarm_context.alarms = g_slist_remove(alarm_context.alarms, entry);
@@ -1777,7 +1777,7 @@ static int __on_app_installed(uid_t target_uid, int req_id, const char *pkg_type
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))
+ if (!(entry->base_info.alarm_type & ALARM_TYPE_VOLATILE))
_update_db_for_disabled_alarm(entry->alarm_id, false);
is_restored = true;
}
@@ -1799,7 +1799,7 @@ static int __on_app_uninstalled(uid_t target_uid, int req_id, const char *pkg_ty
{
GSList *gs_iter = NULL;
__alarm_info_t *entry = NULL;
- alarm_info_t *alarm_info = NULL;
+ base_info_t *base_info = NULL;
bool is_deleted = false;
int is_power_saving_mode = 0;
@@ -1824,8 +1824,8 @@ static int __on_app_uninstalled(uid_t target_uid, int req_id, const char *pkg_ty
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)) {
+ base_info = &entry->base_info;
+ if (!(base_info->alarm_type & ALARM_TYPE_VOLATILE)) {
if (is_power_saving_mode == 1)
_update_db_for_disabled_alarm(entry->alarm_id, true);
else
@@ -1864,10 +1864,10 @@ static long __get_proper_interval(long interval, int alarm_type)
for (gs_iter = alarm_context.alarms; gs_iter != NULL; gs_iter = g_slist_next(gs_iter)) {
entry = (__alarm_info_t *)gs_iter->data;
- if (entry->alarm_info.alarm_type & ALARM_TYPE_PERIOD) {
- if (entry->alarm_info.mode.u_interval.interval <= interval &&
- entry->alarm_info.mode.u_interval.interval > maxInterval)
- maxInterval = entry->alarm_info.mode.u_interval.interval;
+ if (entry->base_info.alarm_type & ALARM_TYPE_PERIOD) {
+ if (entry->base_info.mode.u_interval.interval <= interval &&
+ entry->base_info.mode.u_interval.interval > maxInterval)
+ maxInterval = entry->base_info.mode.u_interval.interval;
}
}
@@ -2068,9 +2068,9 @@ int alarm_manager_alarm_set_time(GVariant* parameters, pid_t pid)
clock_gettime(CLOCK_REALTIME, &cur_time);
accrue_nsec += (cur_time.tv_nsec / MILLION); /* Accrue the nanosecond to compensate the time */
- if (accrue_nsec > (BILLION / 2)) { /* Over 500ms */
+ if (accrue_nsec > 500) { /* Over 500ms */
diff_time = difftime(new_time, cur_time.tv_sec) - 1;
- accrue_nsec -= BILLION;
+ accrue_nsec -= 1000;
} else {
diff_time = difftime(new_time, cur_time.tv_sec);
}
@@ -2245,7 +2245,7 @@ done:
int alarm_manager_alarm_create_appsvc(GVariant *parameters, uid_t uid, pid_t pid, int *alarm_id)
{
- alarm_info_t alarm_info;
+ base_info_t base_info;
int return_code = ALARMMGR_RESULT_SUCCESS;
int _alarm_id = 0;
char log_tag[ALARMMGR_LOG_TAG_SIZE] = {0,};
@@ -2298,32 +2298,32 @@ int alarm_manager_alarm_create_appsvc(GVariant *parameters, uid_t uid, pid_t pid
bundle_free(b);
}
- alarm_info.start.year = start_year;
- alarm_info.start.month = start_month;
- alarm_info.start.day = start_day;
- alarm_info.start.hour = start_hour;
- alarm_info.start.min = start_min;
- alarm_info.start.sec = start_sec;
+ base_info.start.year = start_year;
+ base_info.start.month = start_month;
+ base_info.start.day = start_day;
+ base_info.start.hour = start_hour;
+ base_info.start.min = start_min;
+ base_info.start.sec = start_sec;
- alarm_info.end.year = end_year;
- alarm_info.end.month = end_month;
- alarm_info.end.day = end_day;
+ base_info.end.year = end_year;
+ base_info.end.month = end_month;
+ base_info.end.day = end_day;
- alarm_info.mode.u_interval.day_of_week = mode_day_of_week;
- alarm_info.mode.repeat = (alarm_repeat_mode_t)mode_repeat;
+ base_info.mode.u_interval.day_of_week = mode_day_of_week;
+ base_info.mode.repeat = (alarm_repeat_mode_t)mode_repeat;
- alarm_info.alarm_type = alarm_type;
- alarm_info.reserved_info = reserved_info;
+ base_info.alarm_type = alarm_type;
+ base_info.reserved_info = reserved_info;
- if ((alarm_info.alarm_type & ALARM_TYPE_INEXACT)) {
- alarm_info.alarm_type |= ALARM_TYPE_PERIOD;
- alarm_info.mode.u_interval.interval =
- __get_proper_interval(mode_interval, alarm_info.alarm_type);
+ if ((base_info.alarm_type & ALARM_TYPE_INEXACT)) {
+ base_info.alarm_type |= ALARM_TYPE_PERIOD;
+ base_info.mode.u_interval.interval =
+ __get_proper_interval(mode_interval, base_info.alarm_type);
} else if (mode_interval <= 0) {
- alarm_info.mode.u_interval.interval = 0;
+ base_info.mode.u_interval.interval = 0;
}
- if (!__alarm_create_appsvc(&alarm_info, &_alarm_id, mode_interval, uid, pid, bundle_data, &return_code)) {
+ if (!__alarm_create_appsvc(&base_info, &_alarm_id, mode_interval, uid, pid, bundle_data, &return_code)) {
LOGE("Unable to create alarm! return_code[%d]", return_code);
strncpy(log_tag, "FAIL: CREATE SVC", sizeof(log_tag) - 1);
snprintf(log_message, sizeof(log_message),
@@ -2342,7 +2342,7 @@ int alarm_manager_alarm_create_appsvc(GVariant *parameters, uid_t uid, pid_t pid
int alarm_manager_alarm_create_noti(GVariant *parameters, uid_t uid, pid_t pid,
int *alarm_id)
{
- alarm_info_t alarm_info;
+ base_info_t base_info;
int return_code = ALARMMGR_RESULT_SUCCESS;
int _alarm_id = 0;
char log_tag[ALARMMGR_LOG_TAG_SIZE] = {0,};
@@ -2364,32 +2364,32 @@ int alarm_manager_alarm_create_noti(GVariant *parameters, uid_t uid, pid_t pid,
mode_interval = (time_t)tmp_mode_interval;
reserved_info = (time_t)tmp_reserved_info;
- alarm_info.start.year = start_year;
- alarm_info.start.month = start_month;
- alarm_info.start.day = start_day;
- alarm_info.start.hour = start_hour;
- alarm_info.start.min = start_min;
- alarm_info.start.sec = start_sec;
+ base_info.start.year = start_year;
+ base_info.start.month = start_month;
+ base_info.start.day = start_day;
+ base_info.start.hour = start_hour;
+ base_info.start.min = start_min;
+ base_info.start.sec = start_sec;
- alarm_info.end.year = end_year;
- alarm_info.end.month = end_month;
- alarm_info.end.day = end_day;
+ base_info.end.year = end_year;
+ base_info.end.month = end_month;
+ base_info.end.day = end_day;
- alarm_info.mode.u_interval.day_of_week = mode_day_of_week;
- alarm_info.mode.repeat = (alarm_repeat_mode_t)mode_repeat;
+ base_info.mode.u_interval.day_of_week = mode_day_of_week;
+ base_info.mode.repeat = (alarm_repeat_mode_t)mode_repeat;
- alarm_info.alarm_type = alarm_type;
- alarm_info.reserved_info = reserved_info;
+ base_info.alarm_type = alarm_type;
+ base_info.reserved_info = reserved_info;
- if ((alarm_info.alarm_type & ALARM_TYPE_INEXACT)) {
- alarm_info.alarm_type |= ALARM_TYPE_PERIOD;
- alarm_info.mode.u_interval.interval =
- __get_proper_interval(mode_interval, alarm_info.alarm_type);
+ if ((base_info.alarm_type & ALARM_TYPE_INEXACT)) {
+ base_info.alarm_type |= ALARM_TYPE_PERIOD;
+ base_info.mode.u_interval.interval =
+ __get_proper_interval(mode_interval, base_info.alarm_type);
} else if (mode_interval <= 0) {
- alarm_info.mode.u_interval.interval = 0;
+ base_info.mode.u_interval.interval = 0;
}
- if (!__alarm_create_noti(&alarm_info, &_alarm_id, mode_interval, uid, pid, noti_data, &return_code)) {
+ if (!__alarm_create_noti(&base_info, &_alarm_id, mode_interval, uid, pid, noti_data, &return_code)) {
LOGE("Unable to create alarm! return_code[%d]", return_code);
strncpy(log_tag, "FAIL: CREATE NOTI", sizeof(log_tag) - 1);
snprintf(log_message, sizeof(log_message), "alarmID: %d, uid: %d, pid: %d, duetime: %d-%d-%d %02d:%02d:%02d",
@@ -2406,7 +2406,7 @@ int alarm_manager_alarm_create_noti(GVariant *parameters, uid_t uid, pid_t pid,
int alarm_manager_alarm_create(GVariant *parameters, uid_t uid, pid_t pid, int *alarm_id)
{
- alarm_info_t alarm_info;
+ base_info_t base_info;
int return_code = ALARMMGR_RESULT_SUCCESS;
int _alarm_id = 0;
char log_tag[ALARMMGR_LOG_TAG_SIZE] = {0,};
@@ -2435,31 +2435,31 @@ int alarm_manager_alarm_create(GVariant *parameters, uid_t uid, pid_t pid, int *
reserved_info = (time_t)tmp_reserved_info;
- alarm_info.start.year = start_year;
- alarm_info.start.month = start_month;
- alarm_info.start.day = start_day;
- alarm_info.start.hour = start_hour;
- alarm_info.start.min = start_min;
- alarm_info.start.sec = start_sec;
+ base_info.start.year = start_year;
+ base_info.start.month = start_month;
+ base_info.start.day = start_day;
+ base_info.start.hour = start_hour;
+ base_info.start.min = start_min;
+ base_info.start.sec = start_sec;
- alarm_info.msec = msec;
+ base_info.msec = msec;
- alarm_info.end.year = end_year;
- alarm_info.end.month = end_month;
- alarm_info.end.day = end_day;
+ base_info.end.year = end_year;
+ base_info.end.month = end_month;
+ base_info.end.day = end_day;
- alarm_info.mode.u_interval.day_of_week = mode_day_of_week;
- alarm_info.mode.repeat = (alarm_repeat_mode_t)mode_repeat;
+ base_info.mode.u_interval.day_of_week = mode_day_of_week;
+ base_info.mode.repeat = (alarm_repeat_mode_t)mode_repeat;
- alarm_info.alarm_type = alarm_type;
- alarm_info.reserved_info = reserved_info;
+ base_info.alarm_type = alarm_type;
+ base_info.reserved_info = reserved_info;
if (strcmp(reserved_service_name, "null") == 0)
_reserved_service_name = NULL;
if (strcmp(reserved_service_name_mod, "null") == 0)
_reserved_service_name_mod = NULL;
- if (!__alarm_create(&alarm_info, &_alarm_id, uid, pid, QUANTUMIZE, 0, 0, app_service_name, app_service_name_mod,
+ if (!__alarm_create(&base_info, &_alarm_id, uid, pid, QUANTUMIZE, 0, 0, app_service_name, app_service_name_mod,
_reserved_service_name, _reserved_service_name_mod, &return_code)) {
LOGE("Unable to create alarm! return_code[%d]", return_code);
strncpy(log_tag, "FAIL: CREATE", sizeof(log_tag) - 1);
@@ -2488,7 +2488,7 @@ time_t _get_periodic_alarm_standard_time(void)
int alarm_manager_alarm_create_periodic(GVariant *parameters, uid_t uid,
pid_t pid, int *alarm_id)
{
- alarm_info_t alarm_info;
+ base_info_t base_info;
int return_code = ALARMMGR_RESULT_SUCCESS;
int _alarm_id = 0;
char log_tag[ALARMMGR_LOG_TAG_SIZE] = {0,};
@@ -2506,46 +2506,46 @@ int alarm_manager_alarm_create_periodic(GVariant *parameters, uid_t uid,
time_t standard_time = _get_periodic_alarm_standard_time();
localtime_r(&standard_time, &standard_tm);
- alarm_info.reserved_info = standard_time;
+ base_info.reserved_info = standard_time;
- alarm_info.start.year = standard_tm.tm_year + 1900;
- alarm_info.start.month = standard_tm.tm_mon + 1;
- alarm_info.start.day = standard_tm.tm_mday;
- alarm_info.start.hour = standard_tm.tm_hour;
- alarm_info.start.min = standard_tm.tm_min;
- alarm_info.start.sec = standard_tm.tm_sec;
+ base_info.start.year = standard_tm.tm_year + 1900;
+ base_info.start.month = standard_tm.tm_mon + 1;
+ base_info.start.day = standard_tm.tm_mday;
+ base_info.start.hour = standard_tm.tm_hour;
+ base_info.start.min = standard_tm.tm_min;
+ base_info.start.sec = standard_tm.tm_sec;
- alarm_info.msec = 0;
+ base_info.msec = 0;
- alarm_info.end.year = 0;
- alarm_info.end.month = 0;
- alarm_info.end.day = 0;
+ base_info.end.year = 0;
+ base_info.end.month = 0;
+ base_info.end.day = 0;
- alarm_info.alarm_type = ALARM_TYPE_VOLATILE;
- alarm_info.alarm_type |= ALARM_TYPE_RELATIVE;
- alarm_info.alarm_type |= ALARM_TYPE_WITHCB;
- alarm_info.alarm_type |= ALARM_TYPE_PERIOD;
+ base_info.alarm_type = ALARM_TYPE_VOLATILE;
+ base_info.alarm_type |= ALARM_TYPE_RELATIVE;
+ base_info.alarm_type |= ALARM_TYPE_WITHCB;
+ base_info.alarm_type |= ALARM_TYPE_PERIOD;
if (interval <= 0) {
- alarm_info.mode.repeat = ALARM_REPEAT_MODE_ONCE;
- alarm_info.mode.u_interval.interval = 0;
+ base_info.mode.repeat = ALARM_REPEAT_MODE_ONCE;
+ base_info.mode.u_interval.interval = 0;
} else {
- alarm_info.mode.repeat = ALARM_REPEAT_MODE_REPEAT;
+ base_info.mode.repeat = ALARM_REPEAT_MODE_REPEAT;
if (is_ref)
- alarm_info.mode.u_interval.interval = interval * 60;
+ base_info.mode.u_interval.interval = interval * 60;
else
- alarm_info.mode.u_interval.interval = __get_proper_interval(interval * 60, alarm_info.alarm_type);
+ base_info.mode.u_interval.interval = __get_proper_interval(interval * 60, base_info.alarm_type);
}
- if (!__alarm_create(&alarm_info, &_alarm_id, uid, pid, (periodic_method_e)method, interval * 60, is_ref,
+ if (!__alarm_create(&base_info, &_alarm_id, uid, pid, (periodic_method_e)method, interval * 60, is_ref,
app_service_name, app_service_name_mod,
NULL, NULL, &return_code)) {
LOGE("Unable to create alarm! return_code[%d]", return_code);
strncpy(log_tag, "FAIL: CREAT PERIOD", sizeof(log_tag) - 1);
snprintf(log_message, sizeof(log_message), "alarmID: %d, uid: %d, pid: %d, duetime: %d-%d-%d %02d:%02d:%02d",
- _alarm_id, uid, pid, alarm_info.start.year, alarm_info.start.month,
- alarm_info.start.day, alarm_info.start.hour,
- alarm_info.start.min, alarm_info.start.sec);
+ _alarm_id, uid, pid, base_info.start.year, base_info.start.month,
+ base_info.start.day, base_info.start.hour,
+ base_info.start.min, base_info.start.sec);
_save_module_log(log_tag, log_message);
return_code = ERR_ALARM_SYSTEM_FAIL;
} else {
@@ -2588,7 +2588,7 @@ int alarm_manager_alarm_delete_all(GVariant *parameters, uid_t uid, pid_t pid)
{
GSList *gs_iter = NULL;
char app_name[MAX_APP_ID_LEN] = { 0 };
- alarm_info_t *alarm_info = NULL;
+ base_info_t *base_info = NULL;
__alarm_info_t *entry = NULL;
bool is_deleted = false;
char log_message[ALARMMGR_LOG_MESSAGE_SIZE] = {0,};
@@ -2610,8 +2610,8 @@ int alarm_manager_alarm_delete_all(GVariant *parameters, uid_t uid, pid_t pid)
if (_remove_from_scheduled_alarm_list(uid, entry->alarm_id))
is_deleted = true;
- alarm_info = &entry->alarm_info;
- if (!(alarm_info->alarm_type & ALARM_TYPE_VOLATILE)) {
+ base_info = &entry->base_info;
+ if (!(base_info->alarm_type & ALARM_TYPE_VOLATILE)) {
if (!_delete_alarms(entry->alarm_id))
SECURE_LOGE("_delete_alarms() is failed. pid[%d], alarm_id[%d]", pid, entry->alarm_id);
}
@@ -2643,7 +2643,7 @@ int alarm_manager_alarm_delete_all(GVariant *parameters, uid_t uid, pid_t pid)
int alarm_manager_alarm_update(GVariant *parameters, uid_t uid, pid_t pid)
{
int return_code = ALARMMGR_RESULT_SUCCESS;
- alarm_info_t alarm_info;
+ base_info_t base_info;
char log_tag[ALARMMGR_LOG_TAG_SIZE] = {0,};
char log_message[ALARMMGR_LOG_MESSAGE_SIZE] = {0,};
int alarm_id;
@@ -2666,24 +2666,24 @@ int alarm_manager_alarm_update(GVariant *parameters, uid_t uid, pid_t pid)
if (return_code != ALARMMGR_RESULT_SUCCESS)
return return_code;
- alarm_info.start.year = start_year;
- alarm_info.start.month = start_month;
- alarm_info.start.day = start_day;
- alarm_info.start.hour = start_hour;
- alarm_info.start.min = start_min;
- alarm_info.start.sec = start_sec;
+ base_info.start.year = start_year;
+ base_info.start.month = start_month;
+ base_info.start.day = start_day;
+ base_info.start.hour = start_hour;
+ base_info.start.min = start_min;
+ base_info.start.sec = start_sec;
- alarm_info.end.year = end_year;
- alarm_info.end.month = end_month;
- alarm_info.end.day = end_day;
+ base_info.end.year = end_year;
+ base_info.end.month = end_month;
+ base_info.end.day = end_day;
- alarm_info.mode.u_interval.interval = mode_interval;
- alarm_info.mode.repeat = (alarm_repeat_mode_t)mode_repeat;
+ base_info.mode.u_interval.interval = mode_interval;
+ base_info.mode.repeat = (alarm_repeat_mode_t)mode_repeat;
- alarm_info.alarm_type = alarm_type;
- alarm_info.reserved_info = reserved_info;
+ base_info.alarm_type = alarm_type;
+ base_info.reserved_info = reserved_info;
- if (!__alarm_update(uid, alarm_id, &alarm_info,
+ if (!__alarm_update(uid, alarm_id, &base_info,
update_flag, &return_code)) {
LOGE("Unable to update the alarm! alarm_id[%d], return_code[%d]", alarm_id, return_code);
strncpy(log_tag, "FAIL: UPDATE", sizeof(log_tag) - 1);
@@ -2837,11 +2837,11 @@ int alarm_manager_alarm_get_noti_info(GVariant *parameters, uid_t uid, gchar **n
return return_code;
}
-int alarm_manager_alarm_get_info(GVariant *parameters, uid_t uid, alarm_info_t *alarm_info)
+int alarm_manager_alarm_get_info(GVariant *parameters, uid_t uid, base_info_t *base_info)
{
GSList *gs_iter = NULL;
__alarm_info_t *entry = NULL;
- alarm_info_t *_alarm_info = NULL;
+ base_info_t *found_base_info = NULL;
int alarm_id;
g_variant_get(parameters, "(i)", &alarm_id);
@@ -2850,30 +2850,30 @@ int alarm_manager_alarm_get_info(GVariant *parameters, uid_t uid, alarm_info_t *
for (gs_iter = alarm_context.alarms; gs_iter != NULL; gs_iter = g_slist_next(gs_iter)) {
entry = (__alarm_info_t*)gs_iter->data;
if (entry->uid == uid && entry->alarm_id == alarm_id) {
- _alarm_info = &(entry->alarm_info);
+ found_base_info = &(entry->base_info);
break;
}
}
- if (_alarm_info == NULL) {
+ if (found_base_info == NULL) {
LOGE("The alarm(%d) is not found.", alarm_id);
return ERR_ALARM_INVALID_ID;
} else {
LOGD("The alarm(%d) is found.", alarm_id);
- alarm_info->start.year = _alarm_info->start.year;
- alarm_info->start.month = _alarm_info->start.month;
- alarm_info->start.day = _alarm_info->start.day;
- alarm_info->start.hour = _alarm_info->start.hour;
- alarm_info->start.min = _alarm_info->start.min;
- alarm_info->start.sec = _alarm_info->start.sec;
- alarm_info->end.year = _alarm_info->end.year;
- alarm_info->end.month = _alarm_info->end.month;
- alarm_info->end.day = _alarm_info->end.day;
- alarm_info->mode.u_interval.day_of_week =
- _alarm_info->mode.u_interval.day_of_week;
- alarm_info->mode.repeat = _alarm_info->mode.repeat;
- alarm_info->alarm_type = _alarm_info->alarm_type;
- alarm_info->reserved_info = _alarm_info->reserved_info;
+ base_info->start.year = found_base_info->start.year;
+ base_info->start.month = found_base_info->start.month;
+ base_info->start.day = found_base_info->start.day;
+ base_info->start.hour = found_base_info->start.hour;
+ base_info->start.min = found_base_info->start.min;
+ base_info->start.sec = found_base_info->start.sec;
+ base_info->end.year = found_base_info->end.year;
+ base_info->end.month = found_base_info->end.month;
+ base_info->end.day = found_base_info->end.day;
+ base_info->mode.u_interval.day_of_week =
+ found_base_info->mode.u_interval.day_of_week;
+ base_info->mode.repeat = found_base_info->mode.repeat;
+ base_info->alarm_type = found_base_info->alarm_type;
+ base_info->reserved_info = found_base_info->reserved_info;
}
return ALARMMGR_RESULT_SUCCESS;
@@ -2918,7 +2918,7 @@ int alarm_manager_alarm_set_global(GVariant *parameters, uid_t uid)
{
GSList *gs_iter = NULL;
__alarm_info_t *entry = NULL;
- alarm_info_t *alarm_info = NULL;
+ base_info_t *base_info = NULL;
int retval = 0;
int return_code = ALARMMGR_RESULT_SUCCESS;
char *callee_pkgid;
@@ -2931,12 +2931,12 @@ int alarm_manager_alarm_set_global(GVariant *parameters, uid_t uid)
for (gs_iter = alarm_context.alarms; gs_iter != NULL; gs_iter = g_slist_next(gs_iter)) {
entry = (__alarm_info_t*)gs_iter->data;
if (entry->uid == uid && entry->alarm_id == alarm_id) {
- alarm_info = &(entry->alarm_info);
+ base_info = &(entry->base_info);
break;
}
}
- if (alarm_info == NULL) {
+ if (base_info == NULL) {
LOGE("The alarm(%d) is not found.", alarm_id);
return ERR_ALARM_INVALID_ID;
} else {
@@ -3155,7 +3155,8 @@ void _alarm_initialize()
if (using_rtc) {
if (RTC_INIT() != 0) {
LOGE("rtc init failed");
- exit(1);
+ _save_module_log("FAIL: RTC_INIT", "alarm_manager won't use RTC");
+ using_rtc = false;
}
if (PS_MODE_INIT() != 0) {
diff --git a/unittest/alarm_manager_unittest.cpp b/unittest/alarm_manager_unittest.cpp
index 62d3607..e59c190 100755..100644
--- a/unittest/alarm_manager_unittest.cpp
+++ b/unittest/alarm_manager_unittest.cpp
@@ -312,7 +312,7 @@ TEST_F(AlarmServerTest, alarm_manager_alarm_get_noti_info_n)
TEST_F(AlarmServerTest, alarm_manager_alarm_get_info_n)
{
int ret;
- alarm_info_t info;
+ base_info_t info;
GVariant *param = NULL;
param = g_variant_new("(i)", 10);