static bool is_db_corrupted = false;
+/* LCOV_EXCL_START */
static int __check_integrity_cb(void *pid, int argc, char **argv, char **notUsed)
{
char *check_str = "ok";
INFO("db integrity result : %s" , argv[0]);
return 0;
}
+/* LCOV_EXCL_STOP */
+/* LCOV_EXCL_START */
static int __recover_corrupted_db(sqlite3 *db)
{
int ret = NOTIFICATION_ERROR_NONE;
return ret;
}
+/* LCOV_EXCL_STOP */
+/* LCOV_EXCL_START */
EXPORT_API int notification_db_init()
{
int ret = NOTIFICATION_ERROR_NONE;
sql_ret = sqlite3_open_v2(DBPATH, &db,
SQLITE_OPEN_CREATE | SQLITE_OPEN_READWRITE, NULL);
if (sql_ret != SQLITE_OK) {
- /* LCOV_EXCL_START */
ERR("Failed to open db[%d]", ret);
ret = NOTIFICATION_ERROR_FROM_DB;
goto out;
- /* LCOV_EXCL_STOP */
}
sql_ret = sqlite3_exec(db, CREATE_NOTIFICATION_TABLE, NULL, NULL, &errmsg);
if (sql_ret != SQLITE_OK) {
- /* LCOV_EXCL_START */
ERR("Failed to exec sqlite[%d][%s]", ret, errmsg);
ret = NOTIFICATION_ERROR_FROM_DB;
goto out;
- /* LCOV_EXCL_STOP */
}
sql_ret = sqlite3_exec(db, "PRAGMA integrity_check",
return ret;
}
+/* LCOV_EXCL_STOP */
sqlite3 *notification_db_open()
{
#define _E(fmt, arg...) fprintf(stderr, "[NOTIFICATION_INIT][E][%s,%d] "fmt"\n", \
__FUNCTION__, __LINE__, ##arg);
+/* LCOV_EXCL_START */
static int _is_authorized()
{
/* pkg_init db should be called by as root privilege. */
else
return 0;
}
+/* LCOV_EXCL_STOP */
+/* LCOV_EXCL_START */
int main(int argc, char *argv[])
{
int ret;
return ret;
}
+/* LCOV_EXCL_STOP */
g_variant_unref(coupled_body);
g_variant_unref(body);
if (ret != NOTIFICATION_ERROR_NONE) {
+ /* LCOV_EXCL_START */
ERR("Failed to make notification handle from gvariant");
notification_free(noti);
return;
+ /* LCOV_EXCL_STOP */
}
notification_call_event_handler_cb(noti, event_type);
fd_list = g_unix_fd_list_new();
g_unix_fd_list_append(fd_list, fd, &g_err);
if (g_err != NULL) {
+ /* LCOV_EXCL_START */
ERR("g_unix_fd_list_append [%s]", g_err->message);
g_object_unref(fd_list);
g_error_free(g_err);
return NOTIFICATION_ERROR_IO_ERROR;
+ /* LCOV_EXCL_STOP */
}
msg = __get_new_msg(body, cmd);
errno = 0;
nb = write(fd, buffer, left);
if (nb == -1) {
+ /* LCOV_EXCL_START */
if (errno == EINTR || errno == EAGAIN || errno == EWOULDBLOCK) {
ERR("continue..");
retry_cnt++;
}
ERR("error fd [%d] errno [%d]", fd, errno);
return NOTIFICATION_ERROR_IO_ERROR;
+ /* LCOV_EXCL_STOP */
}
left -= nb;
ret = notification_ipc_socket_write(fd, (char *)&string_len, sizeof(string_len));
if (ret != NOTIFICATION_ERROR_NONE) {
+ /* LCOV_EXCL_START */
ERR("write string_len fail");
return ret;
+ /* LCOV_EXCL_STOP */
}
if (string_len > 0) {
ret = notification_ipc_socket_write(fd, buffer, string_len);
if (ret != NOTIFICATION_ERROR_NONE) {
+ /* LCOV_EXCL_START */
ERR("write string fail");
return ret;
+ /* LCOV_EXCL_STOP */
}
}
db = notification_db_open();
if (db == NULL) {
+ /* LCOV_EXCL_START */
ret = get_last_result();
ERR("Failed to open db [%d]", ret);
return ret;
+ /* LCOV_EXCL_STOP */
}
if (type != NOTIFICATION_TYPE_NONE)
NOTIFICATION_DB_TABLE, uid);
if (sql_buf == NULL) {
+ /* LCOV_EXCL_START */
ret = NOTIFICATION_ERROR_FROM_DB;
ERR("OOM - sqlite3_mprintf");
goto out;
+ /* LCOV_EXCL_STOP */
}
sql_ret = sqlite3_prepare_v2(db, sql_buf, -1, &stmt, NULL);
if (sql_ret != SQLITE_OK) {
+ /* LCOV_EXCL_START */
ret = NOTIFICATION_ERROR_FROM_DB;
ERR("SQLITE3 Error - sqlite3_prepare_v2 [%d][%s]",
sql_ret, sqlite3_errmsg(db));
goto out;
+ /* LCOV_EXCL_STOP */
}
sql_ret = sqlite3_step(stmt);
return ret;
}
+/* LCOV_EXCL_START */
EXPORT_API void notification_noti_init_data(void)
{
int ret;
sqlite3_free(query);
notification_db_close(&db);
}
+/* LCOV_EXCL_STOP */
EXPORT_API int notification_noti_check_limit(notification_h noti, uid_t uid, GList **list)
{
}
if (setting->package_name == NULL) {
+ /* LCOV_EXCL_START */
ERR("setting->package_name is null");
return NOTIFICATION_ERROR_NOT_EXIST_ID;
+ /* LCOV_EXCL_STOP */
}
*value = SAFE_STRDUP(setting->package_name);
}
if (setting->app_id == NULL) {
+ /* LCOV_EXCL_START */
ERR("setting->app_id is null");
return NOTIFICATION_ERROR_NOT_EXIST_ID;
+ /* LCOV_EXCL_STOP */
}
*app_id = SAFE_STRDUP(setting->app_id);
return err;
}
+/* LCOV_EXCL_START */
EXPORT_API int notification_setting_refresh_setting_table(uid_t uid)
{
int err = NOTIFICATION_ERROR_NONE;
pkgmgr_ret = pkgmgrinfo_appinfo_filter_create(&filter);
if (pkgmgr_ret != PMINFO_R_OK) {
- /* LCOV_EXCL_START */
ERR("Failed to create appinfo_filter[%d]", pkgmgr_ret);
err = NOTIFICATION_ERROR_FROM_DB;
goto out;
- /* LCOV_EXCL_STOP */
}
pkgmgr_ret = pkgmgrinfo_appinfo_filter_add_string(filter,
PMINFO_APPINFO_PROP_PRIVILEGE, NOTIFICATION_PRIVILEGE);
if (pkgmgr_ret != PMINFO_R_OK) {
- /* LCOV_EXCL_START */
ERR("Failed to add string to appinfo_filter[%d]", pkgmgr_ret);
err = NOTIFICATION_ERROR_FROM_DB;
goto out;
- /* LCOV_EXCL_STOP */
}
info.db = db;
pkgmgr_ret = pkgmgrinfo_appinfo_usr_filter_foreach_appinfo(filter,
_foreach_app_info_callback, &info, uid);
if (pkgmgr_ret != PMINFO_R_OK) {
- /* LCOV_EXCL_START */
ERR("Failed to foreach appinfo[%d]", pkgmgr_ret);
err = NOTIFICATION_ERROR_FROM_DB;
goto out;
- /* LCOV_EXCL_STOP */
}
out:
return err;
}
+/* LCOV_EXCL_STOP */
EXPORT_API int notification_setting_insert_package_for_uid(const char *package_name, uid_t uid)
{
return NOTIFICATION_ERROR_INVALID_PARAMETER;
if (notification_ipc_monitor_init(uid) != NOTIFICATION_ERROR_NONE) {
+ /* LCOV_EXCL_START */
ERR("Failed to init monitor");
return NOTIFICATION_ERROR_IO_ERROR;
+ /* LCOV_EXCL_STOP */
}
if (_noti_dnd_cb_hash == NULL)
return notification_unregister_system_setting_dnd_changed_cb_for_uid(callback, getuid());
}
+/* LCOV_EXCL_START */
static bool _is_uid_in_system_setting_table(sqlite3 *db, uid_t uid)
{
sqlite3_stmt *stmt = NULL;
query = sqlite3_mprintf("SELECT uid FROM %s WHERE uid = %d",
NOTIFICATION_SYSTEM_SETTING_DB_TABLE, uid);
if (query == NULL) {
- /* LCOV_EXCL_START */
ERR("Failed to alloc query");
return NOTIFICATION_ERROR_OUT_OF_MEMORY;
- /* LCOV_EXCL_STOP */
}
sql_ret = sqlite3_prepare_v2(db, query, -1, &stmt, NULL);
if (sql_ret != SQLITE_OK) {
- /* LCOV_EXCL_START */
ERR("sqlite3_prepare_v2 failed [%d][%s]", sql_ret,
sqlite3_errmsg(db));
err = false;
goto out;
- /* LCOV_EXCL_STOP */
}
sql_ret = sqlite3_step(stmt);
return err;
}
+/* LCOV_EXCL_STOP */
+/* LCOV_EXCL_START */
EXPORT_API int notification_system_setting_init_system_setting_table(uid_t uid)
{
sqlite3 *db = NULL;
db = notification_db_open();
if (db == NULL)
- return get_last_result(); /* LCOV_EXCL_LINE */
+ return get_last_result();
if (_is_uid_in_system_setting_table(db, uid) == true) {
INFO("Setting table is already initialized.");
NOTIFICATION_SYSTEM_SETTING_DB_TABLE,
uid);
if (query_system_setting == NULL) {
- /* LCOV_EXCL_START */
ERR("fail to alloc query");
ret = NOTIFICATION_ERROR_OUT_OF_MEMORY;
goto out;
- /* LCOV_EXCL_STOP */
}
ret = notification_db_exec(db, query_system_setting, NULL);
NOTIFICATION_DND_ALLOW_EXCEPTION,
uid);
if (query_dnd_allow_exception == NULL) {
- /* LCOV_EXCL_START */
ERR("Failed to alloc query");
ret = NOTIFICATION_ERROR_OUT_OF_MEMORY;
goto out;
- /* LCOV_EXCL_STOP */
}
ret = notification_db_exec(db, query_dnd_allow_exception, NULL);
return ret;
}
+/* LCOV_EXCL_STOP */
NOTIFICATION_SYSTEM_SETTING_DB_TABLE, uid);
if (query == NULL) {
/* LCOV_EXCL_START */
- ERR("Failed to alloc query"); /* LCOV_EXCL_LINE */
+ ERR("Failed to alloc query");
ret = NOTIFICATION_ERROR_OUT_OF_MEMORY;
goto out;
/* LCOV_EXCL_STOP */
sql_ret = sqlite3_get_table(db, query, &query_result, &row_count, &column_count, NULL);
if (sql_ret != SQLITE_OK && sql_ret != -1) {
/* LCOV_EXCL_START */
- ERR("Failed to get db table [%d][%s]", sql_ret, query); /* LCOV_EXCL_LINE */
+ ERR("Failed to get db table [%d][%s]", sql_ret, query);
ret = NOTIFICATION_ERROR_FROM_DB;
goto out;
/* LCOV_EXCL_STOP */
result_system_setting = (struct notification_system_setting *)malloc(sizeof(struct notification_system_setting));
if (result_system_setting == NULL) {
/* LCOV_EXCL_START */
- ERR("Failed to alloc memory"); /* LCOV_EXCL_LINE */
+ ERR("Failed to alloc memory");
ret = NOTIFICATION_ERROR_OUT_OF_MEMORY;
goto out;
/* LCOV_EXCL_STOP */
/* no system setting record. allow everyting */
if (!row_count) {
- DBG("No setting found"); /* LCOV_EXCL_LINE */
+ /* LCOV_EXCL_START */
+ DBG("No setting found");
result_system_setting->do_not_disturb = 0;
result_system_setting->visibility_class = 0;
result_system_setting->dnd_schedule_enabled = 0;
result_system_setting->dnd_end_min = 0;
result_system_setting->lock_screen_content_level = 0;
result_system_setting->dnd_allow_exceptions = NULL;
+ /* LCOV_EXCL_STOP */
} else {
/* LCOV_EXCL_START */
col_index = column_count;
NOTIFICATION_SYSTEM_SETTING_DB_TABLE,
do_not_disturb, uid);
if (query == NULL) {
- /* LCOV_EXCL_START */
- ERR("Failed to alloc query"); /* LCOV_EXCL_LINE */
+ ERR("Failed to alloc query");
ret = NOTIFICATION_ERROR_OUT_OF_MEMORY;
goto out;
- /* LCOV_EXCL_STOP */
}
ret = notification_db_exec(db, query, NULL);
}
/* LCOV_EXCL_STOP */
+/* LCOV_EXCL_START */
EXPORT_API
int notification_system_setting_get_dnd_schedule_enabled_uid(uid_t **uids, int *count)
{
"WHERE dnd_schedule_enabled = 1",
NOTIFICATION_SYSTEM_SETTING_DB_TABLE);
if (query == NULL) {
- /* LCOV_EXCL_START */
ret = NOTIFICATION_ERROR_OUT_OF_MEMORY;
goto out;
- /* LCOV_EXCL_STOP */
}
ret = sqlite3_get_table(db, query, &query_result, &row_count, &column_count, NULL);
if (ret != SQLITE_OK && ret != -1) {
- /* LCOV_EXCL_START */
- ERR("Failed to get DB table [%d][%s]", ret, query); /* LCOV_EXCL_LINE */
+ ERR("Failed to get DB table [%d][%s]", ret, query);
ret = NOTIFICATION_ERROR_FROM_DB;
goto out;
- /* LCOV_EXCL_STOP */
}
if (row_count == 0) {
}
if (!(result_uids = (uid_t *)malloc(sizeof(int) * row_count))) {
- /* LCOV_EXCL_START */
ERR("Failed to alloc memory");
ret = NOTIFICATION_ERROR_OUT_OF_MEMORY;
goto out;
- /* LCOV_EXCL_STOP */
}
column_index = column_count;
return ret;
}
+/* LCOV_EXCL_STOP */
EXPORT_API
int notification_get_dnd_and_allow_to_notify(const char *app_id,
#include <notification_debug.h>
#include <notification_viewer.h>
+/* LCOV_EXCL_START */
EXPORT_API int notification_get_default_viewer(const char *path, char **default_viewer)
{
char *viewer = NULL;
return -1;
}
- /* LCOV_EXCL_START */
dict = iniparser_load(path);
if (!dict) {
ERR("can't load file");
iniparser_freedict(dict);
return 0;
- /* LCOV_EXCL_STOP */
}
+/* LCOV_EXCL_STOP */
/* LCOV_EXCL_START */
EXPORT_API int notification_launch_default_viewer(const char *default_viewer,