summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorInkyun Kil <inkyun.kil@samsung.com>2019-09-20 16:32:51 +0900
committerInkyun Kil <inkyun.kil@samsung.com>2019-09-20 16:32:51 +0900
commit7566487c17fb0867d2c6e758d13d859f6494bf47 (patch)
treea84b5f70809a04f579c6934b3dc57f5970a97b73
parent80dc038c83663d2c98f16ec757089e28de98f2c0 (diff)
downloadalarm-manager-7566487c17fb0867d2c6e758d13d859f6494bf47.tar.gz
alarm-manager-7566487c17fb0867d2c6e758d13d859f6494bf47.tar.bz2
alarm-manager-7566487c17fb0867d2c6e758d13d859f6494bf47.zip
Add logs for invalid parameters
Change-Id: I1a4819fd6ac2ce57b0c7f05f19a4bb37377b49d0 Signed-off-by: Inkyun Kil <inkyun.kil@samsung.com>
-rw-r--r--lib/alarm-lib.c139
1 files changed, 100 insertions, 39 deletions
diff --git a/lib/alarm-lib.c b/lib/alarm-lib.c
index 2d59ea4..fcab652 100644
--- a/lib/alarm-lib.c
+++ b/lib/alarm-lib.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2000 - 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ * Copyright (c) 2000 - 2019 Samsung Electronics Co., Ltd All Rights Reserved
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -512,11 +512,15 @@ EXPORT_API int alarmmgr_init(const char *appid)
int j = 0;
bool is_user = false;
- if (appid == NULL)
+ if (appid == NULL) {
+ LOGE("alarm is null");
return ERR_ALARM_INVALID_PARAM;
+ }
- if (strlen(appid) >= MAX_PKG_NAME_LEN)
+ if (strlen(appid) >= MAX_PKG_NAME_LEN) {
+ LOGE("length of appid is invalid");
return ERR_ALARM_INVALID_PARAM;
+ }
if (b_initialized) {
SECURE_LOGD("alarm was already initialized. app_service_name=%s",
@@ -669,8 +673,10 @@ EXPORT_API alarm_entry_t *alarmmgr_create_alarm(void)
{
alarm_info_t *alarm = (alarm_info_t *)malloc(sizeof(alarm_info_t));
- if (alarm == NULL)
+ if (alarm == NULL) {
+ LOGE("alarm is null");
return NULL;
+ }
alarm->start.year = 0;
alarm->start.month = 0;
@@ -700,8 +706,10 @@ EXPORT_API alarm_entry_t *alarmmgr_create_alarm(void)
EXPORT_API int alarmmgr_free_alarm(alarm_entry_t *alarm)
{
- if (alarm == NULL)
+ if (alarm == NULL) {
+ LOGE("alarm is null");
return ERR_ALARM_INVALID_PARAM;
+ }
free(alarm);
@@ -713,8 +721,10 @@ EXPORT_API int alarmmgr_set_time(alarm_entry_t *alarm, alarm_date_t time)
alarm_info_t *alarm_info;
int error_code;
- if (alarm == NULL)
+ if (alarm == NULL) {
+ LOGE("alarm is null");
return ERR_ALARM_INVALID_PARAM;
+ }
alarm_info = (alarm_info_t *)alarm;
if (!__alarm_validate_date(&time, &error_code)) {
@@ -737,8 +747,10 @@ EXPORT_API int alarmmgr_get_time(const alarm_entry_t *alarm,
{
alarm_info_t *alarm_info = (alarm_info_t *)alarm;
- if (alarm == NULL)
+ if (alarm == NULL) {
+ LOGE("alarm is null");
return ERR_ALARM_INVALID_PARAM;
+ }
if (time != NULL)
memcpy(time, &alarm_info->start, sizeof(alarm_date_t));
@@ -751,8 +763,10 @@ EXPORT_API int alarmmgr_set_repeat_mode(alarm_entry_t *alarm,
{
alarm_info_t *alarm_info = (alarm_info_t *)alarm;
- if (repeat >= ALARM_REPEAT_MODE_MAX)
+ if (repeat >= ALARM_REPEAT_MODE_MAX) {
+ LOGE("repeat value is invalid");
return ERR_ALARM_INVALID_PARAM;
+ }
alarm_info->mode.repeat = repeat;
@@ -771,8 +785,10 @@ EXPORT_API int alarmmgr_get_repeat_mode(const alarm_entry_t *alarm,
{
alarm_info_t *alarm_info = (alarm_info_t *)alarm;
- if (alarm == NULL)
+ if (alarm == NULL) {
+ LOGE("alarm is null");
return ERR_ALARM_INVALID_PARAM;
+ }
if (repeat != NULL)
*repeat = alarm_info->mode.repeat;
@@ -786,8 +802,10 @@ EXPORT_API int alarmmgr_set_type(alarm_entry_t *alarm, int alarm_type)
{
alarm_info_t *alarm_info;
- if (alarm == NULL)
+ if (alarm == NULL) {
+ LOGE("alarm is null");
return ERR_ALARM_INVALID_PARAM;
+ }
alarm_info = (alarm_info_t *)alarm;
alarm_info->alarm_type = alarm_type;
@@ -800,8 +818,10 @@ EXPORT_API int alarmmgr_get_type(const alarm_entry_t *alarm, int *alarm_type)
{
alarm_info_t *alarm_info = (alarm_info_t *)alarm;
- if (alarm == NULL)
+ if (alarm == NULL) {
+ LOGE("alarm is null");
return ERR_ALARM_INVALID_PARAM;
+ }
if (alarm_type != NULL)
*alarm_type = alarm_info->alarm_type;
@@ -839,6 +859,7 @@ EXPORT_API void *alarmmgr_get_alarm_appsvc_info(alarm_id_t alarm_id, int *return
LOGD("[alarm-lib]:alarmmgr_get_alarm_appsvc_info() is called.");
if (alarm_id <= 0) {
+ LOGE("alarm_id is Invalid[%d]", alarm_id);
if (return_code)
*return_code = ERR_ALARM_INVALID_ID;
@@ -858,8 +879,10 @@ EXPORT_API int alarmmgr_get_alarm_noti_info(alarm_id_t alarm_id, notification_h
LOGD("[alarm-lib]:alarmmgr_get_alarm_appsvc_info() is called.");
- if (alarm_id <= 0)
+ if (alarm_id <= 0) {
+ LOGE("alarm_id is Invalid[%d]", alarm_id);
return ERR_ALARM_INVALID_ID;
+ }
*noti = _send_alarm_get_noti_info(alarm_context, alarm_id, &ret);
@@ -939,12 +962,7 @@ EXPORT_API int alarmmgr_add_alarm_appsvc_with_localtime(alarm_entry_t *alarm, vo
appid = appsvc_get_appid(b);
if ((appid == NULL && (alarm_info->alarm_type & ALARM_TYPE_NOLAUNCH)) ||
(appid == NULL && operation && !strcmp(operation, APPSVC_OPERATION_DEFAULT))) {
- LOGE("Invalid parameter\n");
- return ERR_ALARM_INVALID_PARAM;
- }
-
- if (alarm_info == NULL || alarm_id == NULL) {
- LOGE("Invalid parameter\n");
+ LOGE("appid is ivalid");
return ERR_ALARM_INVALID_PARAM;
}
@@ -996,8 +1014,10 @@ EXPORT_API int alarmmgr_add_alarm_with_localtime(alarm_entry_t *alarm,
LOGD("[alarm-lib]:alarm_create() is called\n");
- if (alarm == NULL)
+ if (alarm == NULL) {
+ LOGE("alarm is null");
return ERR_ALARM_INVALID_PARAM;
+ }
alarm_info = (alarm_info_t *) alarm;
if (alarm_info == NULL || alarm_id == NULL) {
@@ -1020,8 +1040,10 @@ EXPORT_API int alarmmgr_add_alarm_with_localtime(alarm_entry_t *alarm,
alarm_info->mode.repeat, alarm_info->mode.u_interval.interval, alarm_info->alarm_type);
/* TODO: This should be changed to > ALARM_REPEAT_MODE_MAX ? */
- if (mode->repeat >= ALARM_REPEAT_MODE_MAX)
+ if (mode->repeat >= ALARM_REPEAT_MODE_MAX) {
+ LOGE("repeat is Invalid");
return ERR_ALARM_INVALID_PARAM;
+ }
if (destination && strlen(destination) >= MAX_PKG_NAME_LEN) {
LOGE("[alarm-lib]: destination name is too long!\n");
@@ -1163,11 +1185,15 @@ EXPORT_API int alarmmgr_add_alarm_appsvc(int alarm_type, time_t trigger_at_time,
return ERR_ALARM_SYSTEM_FAIL;
}
- if (alarm_id == NULL)
+ if (alarm_id == NULL) {
+ LOGE("alarm_id is null");
return ERR_ALARM_INVALID_PARAM;
+ }
- if (trigger_at_time < 0)
+ if (trigger_at_time < 0) {
+ LOGE("trigger_at_time is invalid[%ld]", trigger_at_time);
return ERR_ALARM_INVALID_PARAM;
+ }
_initialize_alarm_info(&alarm_info, alarm_type, trigger_at_time, interval,
false);
@@ -1207,11 +1233,15 @@ EXPORT_API int alarmmgr_add_alarm_noti(int alarm_type, time_t trigger_at_time,
return ERR_ALARM_SYSTEM_FAIL;
}
- if (alarm_id == NULL)
+ if (alarm_id == NULL) {
+ LOGE("alarm_id is null");
return ERR_ALARM_INVALID_PARAM;
+ }
- if (trigger_at_time < 0)
+ if (trigger_at_time < 0) {
+ LOGE("trigger_at_time is invalid[%ld]", trigger_at_time);
return ERR_ALARM_INVALID_PARAM;
+ }
_initialize_alarm_info(&alarm_info, alarm_type, trigger_at_time, interval,
false);
@@ -1246,10 +1276,13 @@ static int _alarmmgr_add_alarm(int alarm_type,
if (ret < 0)
return ret;
- if (alarm_id == NULL)
+ if (alarm_id == NULL) {
+ LOGE("[alarm-lib]: alarm_id is null");
return ERR_ALARM_INVALID_PARAM;
+ }
if (trigger_at_time < 0)
+ LOGE("trigger_at_time is invalid[%ld]", trigger_at_time);
return ERR_ALARM_INVALID_PARAM;
if (destination && strlen(destination) >= MAX_PKG_NAME_LEN) {
@@ -1335,11 +1368,15 @@ static int _alarmmgr_add_alarm_withcb(int alarm_type, time_t trigger_at_time,
LOGD("[alarm-lib]:alarmmgr_add_alarm_withcb() is called");
- if (alarm_id == NULL)
+ if (alarm_id == NULL) {
+ LOGE("alarm_id is null ");
return ERR_ALARM_INVALID_PARAM;
+ }
- if (trigger_at_time < 0)
+ if (trigger_at_time < 0) {
+ LOGE("trigger_at_time is invalid[%ld]", trigger_at_time);
return ERR_ALARM_INVALID_PARAM;
+ }
_initialize_alarm_info(&alarm_info, alarm_type, trigger_at_time, interval,
precision);
@@ -1383,8 +1420,10 @@ EXPORT_API int alarmmgr_remove_alarm(alarm_id_t alarm_id)
LOGD("[alarm-lib]:alarm_delete(%d) is called\n", alarm_id);
- if (alarm_id <= 0)
+ if (alarm_id <= 0) {
+ LOGE("[alarm-lib]:alarm_id is invalid[%d]\n", alarm_id);
return ERR_ALARM_INVALID_ID;
+ }
if (!_send_alarm_delete(alarm_context, alarm_id, &error_code))
return error_code;
@@ -1419,8 +1458,10 @@ EXPORT_API int alarmmgr_enum_alarm_ids(alarm_enum_fn_t fn, void *user_param)
int ret = 0;
GVariantIter *iter = NULL;
- if (fn == NULL)
+ if (fn == NULL) {
+ LOGE("fn is null.");
return ERR_ALARM_INVALID_PARAM;
+ }
ret = __sub_init();
if (ret < 0) {
@@ -1457,8 +1498,10 @@ 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)
+ if (alarm_id < 0 || alarm_info == NULL) {
+ LOGE("[alarm-lib]:alarm_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))
return error_code;
@@ -1471,8 +1514,10 @@ int alarmmgr_get_number_of_ids(int *num_of_ids)
int error_code;
LOGD("[alarm-lib]: alarm_get_number_of_ids() is called.");
- if (num_of_ids == NULL)
+ if (num_of_ids == NULL) {
+ LOGE("[alarm-lib]:num_of_ids.");
return ERR_ALARM_INVALID_PARAM;
+ }
LOGD("call alarm_get_number_of_ids\n");
if (!_send_alarm_get_number_of_ids(alarm_context, num_of_ids, &error_code))
@@ -1492,8 +1537,10 @@ EXPORT_API int alarmmgr_get_next_duetime(alarm_id_t alarm_id, time_t *duetime)
LOGD("[alarm-lib]:alarmmgr_get_next_duetime() is called.");
- if (duetime == NULL)
+ if (duetime == NULL) {
+ LOGE("[alarm-lib]:duetime is null.");
return ERR_ALARM_INVALID_PARAM;
+ }
if (!_send_alarm_get_next_duetime(alarm_context, alarm_id, duetime, &error_code))
return error_code;
@@ -1506,8 +1553,10 @@ EXPORT_API int alarmmgr_get_all_info(char **db_path)
int error_code;
LOGD("[alarm-lib]:alarmmgr_get_all_info() is called.");
- if (db_path == NULL)
+ if (db_path == NULL) {
+ LOGE("[alarm-lib]:db_path is null.");
return ERR_ALARM_INVALID_PARAM;
+ }
if (!_send_alarm_get_all_info(alarm_context, db_path, &error_code))
return error_code;
@@ -1534,8 +1583,10 @@ EXPORT_API int alarmmgr_add_periodic_alarm_withcb(int interval, periodic_method_
if (ret < 0)
return ret;
- if (alarm_id == NULL)
+ if (alarm_id == NULL) {
+ LOGE("[alarm-lib]:alarm_id is null.");
return ERR_ALARM_INVALID_PARAM;
+ }
if (!_send_alarm_create_periodic(alarm_context, interval, 0,
(int)method, alarm_id,
@@ -1565,8 +1616,10 @@ EXPORT_API int alarmmgr_add_reference_periodic_alarm_withcb(int interval,
if (ret < 0)
return ret;
- if (alarm_id == NULL)
+ if (alarm_id == NULL) {
+ LOGE("[alarm-lib]:alarm_id is null.");
return ERR_ALARM_INVALID_PARAM;
+ }
if (!_send_alarm_create_periodic(alarm_context, interval, 1, 0,
alarm_id, &error_code))
@@ -1694,8 +1747,10 @@ EXPORT_API int alarmmgr_set_timezone(char *tzpath_str)
int error_code;
LOGD("[alarm-lib]:alarmmgr_set_timezone() is called.");
- if (tzpath_str == NULL)
+ if (tzpath_str == NULL) {
+ LOGE("[alarm-lib]:tzpath_str is NULL\n");
return ERR_ALARM_INVALID_PARAM;
+ }
if (__sub_init() < 0)
return ERR_ALARM_SYSTEM_FAIL;
@@ -1731,8 +1786,10 @@ EXPORT_API int alarmmgr_get_global(const alarm_id_t alarm_id,
if (__sub_init() < 0)
return ERR_ALARM_SYSTEM_FAIL;
- if (global == NULL)
+ if (global == NULL) {
+ LOGE("[alarm-lib]:global is NULL\n");
return ERR_ALARM_INVALID_PARAM;
+ }
if (!_send_alarm_get_global(alarm_context, alarm_id, global, &error_code))
return error_code;
@@ -1748,12 +1805,16 @@ EXPORT_API int alarmmgr_update_alarm(alarm_id_t alarm_id,
LOGD("[alarm-lib]:alarmmgr_update_alarm() is called\n");
- if (alarm == NULL)
+ if (alarm == NULL) {
+ LOGE("[alarm-lib]:alarm is NULL\n");
return ERR_ALARM_INVALID_PARAM;
+ }
alarm_info = (alarm_info_t *) alarm;
- if (alarm_info == NULL || alarm_id <= 0)
+ if (alarm_info == NULL || alarm_id <= 0) {
+ LOGE("[alarm-lib]:alarm is NULL or invalid alarm_id[%d]\n", alarm_id);
return ERR_ALARM_INVALID_PARAM;
+ }
int error_code;