summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorseungha.son <seungha.son@samsung.com>2016-08-29 15:35:14 +0900
committerSon seungha <seungha.son@samsung.com>2016-08-30 23:09:16 -0700
commitae69c98b06bb37d125e5f66801f0478a5f8f4683 (patch)
treea5bad170224bb998fa3518528e50321c4a1b9c43 /src
parent6aa070a4cf4b6e20a78ac9b4b981a86592d6c1fe (diff)
downloadnotification-ae69c98b06bb37d125e5f66801f0478a5f8f4683.tar.gz
notification-ae69c98b06bb37d125e5f66801f0478a5f8f4683.tar.bz2
notification-ae69c98b06bb37d125e5f66801f0478a5f8f4683.zip
- Pop-up notification : Active notification from the app is not allowed when 'Pop-up notification' is off. - Notification on lock screen : Notifications from the app show/hide contests or hide the notification on the lock screen. Signed-off-by: seungha.son <seungha.son@samsung.com> Change-Id: I00b72be2e993d33d4d18455d5df743a956ba8ceb
Diffstat (limited to 'src')
-rwxr-xr-xsrc/notification_db.c2
-rwxr-xr-xsrc/notification_ipc.c20
-rwxr-xr-xsrc/notification_noti.c40
-rwxr-xr-xsrc/notification_setting.c44
-rw-r--r--src/notification_setting_service.c29
5 files changed, 120 insertions, 15 deletions
diff --git a/src/notification_db.c b/src/notification_db.c
index 9dbd342..156ad78 100755
--- a/src/notification_db.c
+++ b/src/notification_db.c
@@ -124,6 +124,8 @@ create table if not exists noti_list ( \
allow_to_notify INTEGER DEFAULT 1, \
do_not_disturb_except INTEGER DEFAULT 0, \
visibility_class INTEGER DEFAULT 0, \
+ pop_up_notification INTEGER DEFAULT 1, \
+ lock_screen_content_level INTEGER DEFAULT 0, \
UNIQUE (uid, package_name) \
); \
CREATE TABLE IF NOT EXISTS notification_system_setting ( \
diff --git a/src/notification_ipc.c b/src/notification_ipc.c
index be7b43c..940ce70 100755
--- a/src/notification_ipc.c
+++ b/src/notification_ipc.c
@@ -1275,11 +1275,13 @@ int notification_ipc_update_setting(notification_setting_h setting, uid_t uid)
return result;
}
- body = g_variant_new("(siiii)",
+ body = g_variant_new("(siiiiii)",
setting->package_name,
(int)(setting->allow_to_notify),
(int)(setting->do_not_disturb_except),
(int)(setting->visibility_class),
+ (int)(setting->pop_up_notification),
+ (int)(setting->lock_screen_content_level),
uid);
result = _send_sync_noti(body, &reply, "update_noti_setting");
@@ -1915,11 +1917,13 @@ EXPORT_API GVariant *notification_ipc_make_gvariant_from_setting(struct notifica
{
GVariant *body = NULL;
- body = g_variant_new("(siii)",
+ body = g_variant_new("(siiiii)",
noti_setting->package_name,
noti_setting->allow_to_notify,
noti_setting->do_not_disturb_except,
- noti_setting->visibility_class);
+ noti_setting->visibility_class,
+ noti_setting->pop_up_notification,
+ noti_setting->lock_screen_content_level);
return body;
}
@@ -1932,17 +1936,21 @@ EXPORT_API int notification_ipc_make_setting_from_gvariant(struct notification_s
int allow_to_notify;
int do_not_disturb_except;
int visibility_class;
+ int pop_up_notification;
+ int lock_screen_content_level;
if (noti_setting == NULL || variant == NULL) {
NOTIFICATION_ERR("invalid data");
return NOTIFICATION_ERROR_INVALID_PARAMETER;
}
g_variant_get(variant,
- "(&siii)",
+ "(&siiiii)",
&pkgname,
&allow_to_notify,
&do_not_disturb_except,
- &visibility_class);
+ &visibility_class,
+ &pop_up_notification,
+ &lock_screen_content_level);
NOTIFICATION_DBG("setting from variant %s !!", pkgname);
@@ -1950,6 +1958,8 @@ EXPORT_API int notification_ipc_make_setting_from_gvariant(struct notification_s
noti_setting->allow_to_notify = allow_to_notify;
noti_setting->do_not_disturb_except = do_not_disturb_except;
noti_setting->visibility_class = visibility_class;
+ noti_setting->pop_up_notification = pop_up_notification;
+ noti_setting->lock_screen_content_level = lock_screen_content_level;
NOTIFICATION_DBG("setting from variant %s, %s",
noti_setting->package_name, pkgname);
diff --git a/src/notification_noti.c b/src/notification_noti.c
index 114b893..31ea558 100755
--- a/src/notification_noti.c
+++ b/src/notification_noti.c
@@ -849,6 +849,37 @@ out:
return err;
}
+static bool _is_pop_up_notification(const char *caller_package_name, uid_t uid)
+{
+ int err;
+ char *package_id = NULL;
+ bool ret = true;
+ notification_setting_h setting = NULL;
+
+ err = noti_setting_service_get_setting_by_package_name(caller_package_name, &setting, uid);
+ if (err != NOTIFICATION_ERROR_NONE) {
+ NOTIFICATION_ERR("noti_setting_service_get_setting_by_package_name failed [%d]", err);
+ goto out;
+ }
+
+ err = notification_setting_get_pop_up_notification(setting, &ret);
+ if (err != NOTIFICATION_ERROR_NONE) {
+ NOTIFICATION_ERR("notification_setting_get_pop_up_notification failed");
+ goto out;
+ }
+
+ if (ret != true)
+ NOTIFICATION_DBG("[%s] is not allowed Pop-up notification", caller_package_name);
+
+out:
+ if (package_id)
+ free(package_id);
+ if (setting)
+ notification_setting_free_notification(setting);
+
+ return ret;
+}
+
EXPORT_API int notification_noti_insert(notification_h noti)
{
int ret = 0;
@@ -871,6 +902,10 @@ EXPORT_API int notification_noti_insert(notification_h noti)
if (_handle_do_not_disturb_option(noti) != NOTIFICATION_ERROR_NONE)
NOTIFICATION_WARN("_handle_do_not_disturb_option failed");
+ if (_is_pop_up_notification((const char *)noti->caller_pkgname, noti->uid) == false) {
+ noti->display_applist = (noti->display_applist & (~NOTIFICATION_DISPLAY_APP_ACTIVE));
+ NOTIFICATION_DBG("notification display applist - pkgname [%s], applist [%d]", noti->caller_pkgname, noti->display_applist);
+ }
db = notification_db_open(DBPATH);
if (!db)
@@ -1147,6 +1182,11 @@ EXPORT_API int notification_noti_update(notification_h noti)
if (_handle_do_not_disturb_option(noti) != NOTIFICATION_ERROR_NONE)
NOTIFICATION_WARN("_handle_do_not_disturb_option failed");
+ if (_is_pop_up_notification((const char *)noti->caller_pkgname, noti->uid) == false) {
+ noti->display_applist = (noti->display_applist & (~NOTIFICATION_DISPLAY_APP_ACTIVE));
+ NOTIFICATION_DBG("notification display applist - pkgname [%s], applist [%d]", noti->caller_pkgname, noti->display_applist);
+ }
+
/* Check private ID is exist */
ret = _notification_noti_check_priv_id(noti, db);
if (ret != NOTIFICATION_ERROR_ALREADY_EXIST_ID) {
diff --git a/src/notification_setting.c b/src/notification_setting.c
index f085a63..0be8062 100755
--- a/src/notification_setting.c
+++ b/src/notification_setting.c
@@ -205,6 +205,50 @@ EXPORT_API int notification_setting_set_visibility_class(notification_setting_h
return NOTIFICATION_ERROR_NONE;
}
+EXPORT_API int notification_setting_get_pop_up_notification(notification_setting_h setting, bool *value)
+{
+ if (setting == NULL || value == NULL) {
+ NOTIFICATION_ERR("Invalid parameter");
+ return NOTIFICATION_ERROR_INVALID_PARAMETER;
+ }
+
+ *value = setting->pop_up_notification;
+ return NOTIFICATION_ERROR_NONE;
+}
+
+EXPORT_API int notification_setting_set_pop_up_notification(notification_setting_h setting, bool value)
+{
+ if (setting == NULL) {
+ NOTIFICATION_ERR("Invalid parameter");
+ return NOTIFICATION_ERROR_INVALID_PARAMETER;
+ }
+
+ setting->pop_up_notification = value;
+ return NOTIFICATION_ERROR_NONE;
+}
+
+EXPORT_API int notification_setting_get_lock_screen_content(notification_setting_h setting, lock_screen_content_level_e *level)
+{
+ if (setting == NULL || level == NULL) {
+ NOTIFICATION_ERR("Invalid parameter");
+ return NOTIFICATION_ERROR_INVALID_PARAMETER;
+ }
+
+ *level = setting->lock_screen_content_level;
+ return NOTIFICATION_ERROR_NONE;
+}
+
+EXPORT_API int notification_setting_set_lock_screen_content(notification_setting_h setting, lock_screen_content_level_e level)
+{
+ if (setting == NULL) {
+ NOTIFICATION_ERR("Invalid parameter");
+ return NOTIFICATION_ERROR_INVALID_PARAMETER;
+ }
+
+ setting->lock_screen_content_level = level;
+ return NOTIFICATION_ERROR_NONE;
+}
+
EXPORT_API int notification_setting_update_setting_for_uid(notification_setting_h setting, uid_t uid)
{
if (setting == NULL) {
diff --git a/src/notification_setting_service.c b/src/notification_setting_service.c
index 9202ce5..768250a 100644
--- a/src/notification_setting_service.c
+++ b/src/notification_setting_service.c
@@ -116,9 +116,9 @@ int noti_setting_service_get_setting_by_package_name(const char *package_name, n
goto out;
}
- sql_query = sqlite3_mprintf("SELECT package_name, allow_to_notify, do_not_disturb_except, visibility_class "
- "FROM %s "
- "WHERE package_name = %Q AND uid = %d", NOTIFICATION_SETTING_DB_TABLE, package_name, uid);
+ sql_query = sqlite3_mprintf("SELECT package_name, allow_to_notify, do_not_disturb_except, visibility_class, "
+ "pop_up_notification, lock_screen_content_level FROM %s "
+ "WHERE package_name = %Q AND uid = %d", NOTIFICATION_SETTING_DB_TABLE, package_name, uid);
if (!sql_query) {
NOTIFICATION_ERR("fail to alloc query"); /* LCOV_EXCL_LINE */
@@ -156,6 +156,8 @@ int noti_setting_service_get_setting_by_package_name(const char *package_name, n
_get_table_field_data_int(query_result, (int *)&(result_setting_array[i].allow_to_notify), col_index++);
_get_table_field_data_int(query_result, (int *)&(result_setting_array[i].do_not_disturb_except), col_index++);
_get_table_field_data_int(query_result, &(result_setting_array[i].visibility_class), col_index++);
+ _get_table_field_data_int(query_result, (int *)&(result_setting_array[i].pop_up_notification), col_index++);
+ _get_table_field_data_int(query_result, (int *)&(result_setting_array[i].lock_screen_content_level), col_index++);
*setting = result_setting_array;
@@ -203,9 +205,9 @@ int noti_setting_get_setting_array(notification_setting_h *setting_array, int *c
goto out;
}
- sql_query = sqlite3_mprintf("SELECT package_name, allow_to_notify, do_not_disturb_except, visibility_class "
- "FROM %s WHERE uid = %d "
- "ORDER BY package_name", NOTIFICATION_SETTING_DB_TABLE, uid);
+ sql_query = sqlite3_mprintf("SELECT package_name, allow_to_notify, do_not_disturb_except, visibility_class, "
+ "pop_up_notification, lock_screen_content_level FROM %s WHERE uid = %d "
+ "ORDER BY package_name", NOTIFICATION_SETTING_DB_TABLE, uid);
if (!sql_query) {
NOTIFICATION_ERR("fail to alloc query"); /* LCOV_EXCL_LINE */
@@ -241,6 +243,8 @@ int noti_setting_get_setting_array(notification_setting_h *setting_array, int *c
_get_table_field_data_int(query_result, (int *)&(result_setting_array[i].allow_to_notify), col_index++);
_get_table_field_data_int(query_result, (int *)&(result_setting_array[i].do_not_disturb_except), col_index++);
_get_table_field_data_int(query_result, &(result_setting_array[i].visibility_class), col_index++);
+ _get_table_field_data_int(query_result, (int *)&(result_setting_array[i].pop_up_notification), col_index++);
+ _get_table_field_data_int(query_result, (int *)&(result_setting_array[i].lock_screen_content_level), col_index++);
}
*setting_array = result_setting_array;
@@ -248,7 +252,7 @@ int noti_setting_get_setting_array(notification_setting_h *setting_array, int *c
out:
if (query_result)
- sqlite3_free_table(query_result);
+ sqlite3_free_table(query_result);
if (sql_query)
sqlite3_free(sql_query);
@@ -362,7 +366,10 @@ out:
}
EXPORT_API
-int notification_setting_db_update(const char *package_name, int allow_to_notify, int do_not_disturb_except, int visibility_class, uid_t uid)
+int notification_setting_db_update(const char *package_name, int allow_to_notify,
+ int do_not_disturb_except, int visibility_class,
+ int pop_up_notification, int lock_screen_content_level,
+ uid_t uid)
{
int err = NOTIFICATION_ERROR_NONE;
sqlite3 *db = NULL;
@@ -378,9 +385,11 @@ int notification_setting_db_update(const char *package_name, int allow_to_notify
return NOTIFICATION_ERROR_FROM_DB;
}
- sqlbuf = sqlite3_mprintf("UPDATE %s SET allow_to_notify = %d, do_not_disturb_except = %d, visibility_class = %d " \
+ sqlbuf = sqlite3_mprintf("UPDATE %s SET allow_to_notify = %d, do_not_disturb_except = %d, visibility_class = %d, " \
+ "pop_up_notification = %d, lock_screen_content_level = %d " \
"WHERE package_name = %Q AND uid = %d",
- NOTIFICATION_SETTING_DB_TABLE, allow_to_notify, do_not_disturb_except, visibility_class, package_name, uid);
+ NOTIFICATION_SETTING_DB_TABLE, allow_to_notify, do_not_disturb_except, visibility_class,
+ pop_up_notification, lock_screen_content_level, package_name, uid);
if (!sqlbuf) {
NOTIFICATION_ERR("fail to alloc query");
err = NOTIFICATION_ERROR_OUT_OF_MEMORY;