Add api for level of notification on lock screen 92/77192/13 accepted/tizen/common/20160707.171551 accepted/tizen/ivi/20160707.043153 accepted/tizen/mobile/20160707.043233 accepted/tizen/tv/20160707.043043 accepted/tizen/wearable/20160707.043224 submit/tizen/20160707.014055
authorMyungki Lee <mk5004.lee@samsung.com>
Wed, 6 Jul 2016 12:17:26 +0000 (21:17 +0900)
committerMyungki Lee <mk5004.lee@samsung.com>
Wed, 6 Jul 2016 12:17:26 +0000 (21:17 +0900)
- show all content
- hide sensitive content
- don't show notifications

Change-Id: Ib2b86838a8b9018f704561f0bea68e58084cfe32
Signed-off-by: Myungki Lee <mk5004.lee@samsung.com>
include/notification_private.h
include/notification_setting_internal.h
include/notification_setting_service.h
src/notification_db.c
src/notification_ipc.c
src/notification_setting.c
src/notification_setting_service.c
test-app/main.c

index 50c59e95ebaeac0821d02655d0907cefca3c423b..935fdf8180f4381dde56d912d3425a44c36c0e36 100644 (file)
@@ -92,17 +92,6 @@ struct _notification {
        uid_t uid;
 };
 
-struct notification_system_setting {
-       bool do_not_disturb;
-       int  visibility_class;
-       bool dnd_schedule_enabled;
-       int dnd_schedule_day;
-       int dnd_start_hour;
-       int dnd_start_min;
-       int dnd_end_hour;
-       int dnd_end_min;
-};
-
 typedef enum notification_data_type {
        NOTIFICATION_DATA_TYPE_NOTI_TYPE = 1,
        NOTIFICATION_DATA_TYPE_LAYOUT,
index 9c84a3023fa9961f596e7769e7dd9eed3574e6b4..c22019bae4e6116153a0319faef14c44710e38e7 100644 (file)
@@ -40,6 +40,16 @@ typedef enum {
        DND_SCHEDULE_WEEK_FLAG_SATURDAY = 0x40,         /**< Saturday */
 } dnd_schedule_week_flag_e;
 
+/**
+* @brief Enumeration for lock screen content.
+* @since_tizen 3.0
+*/
+typedef enum lock_screen_content_level {
+       SHOW_ALL_CONTENT = 0,
+       HIDE_SENSITIVE_CONTENT,
+       DO_NOT_SHOW_NOTIFICATIONS,
+} lock_screen_content_level_e;
+
 /* Application setting */
 struct notification_setting {
        char *package_name;
@@ -48,6 +58,18 @@ struct notification_setting {
        int   visibility_class;
 };
 
+struct notification_system_setting {
+       bool do_not_disturb;
+       int visibility_class;
+       bool dnd_schedule_enabled;
+       int dnd_schedule_day;
+       int dnd_start_hour;
+       int dnd_start_min;
+       int dnd_end_hour;
+       int dnd_end_min;
+       lock_screen_content_level_e lock_screen_content_level;
+};
+
 int notification_setting_get_setting_array(notification_setting_h *setting_array, int *count);
 int notification_setting_get_setting_array_for_uid(notification_setting_h *setting_array, int *count, uid_t uid);
 
@@ -97,6 +119,9 @@ int notification_system_setting_dnd_schedule_set_start_time(notification_system_
 int notification_system_setting_dnd_schedule_get_end_time(notification_system_setting_h system_setting, int *hour, int *min);
 int notification_system_setting_dnd_schedule_set_end_time(notification_system_setting_h system_setting, int hour, int min);
 
+int notification_system_setting_set_lock_screen_content(notification_system_setting_h system_setting, lock_screen_content_level_e level);
+int notification_system_setting_get_lock_screen_content(notification_system_setting_h system_setting, lock_screen_content_level_e *level);
+
 /* OLD IMPLEMENTATION */
 int notification_setting_property_set(const char *pkgname, const char *property, const char *value) NOTIFICATION_DEPRECATED_API;
 int notification_setting_property_get(const char *pkgname, const char *property, char **value) NOTIFICATION_DEPRECATED_API;
index 7dabc5b5e6648d42c3b1caa950b6767d55178fea..b9483daf34f706e1222abe22e5baff05a8dbc5f7 100644 (file)
@@ -32,7 +32,8 @@ int notification_setting_db_update(const char *package_name, int allow_to_notify
 int notification_setting_db_update_system_setting(int do_not_disturb, int visibility_class,
                                        int dnd_schedule_enabled, int dnd_schedule_day,
                                        int dnd_start_hour, int dnd_start_min,
-                                       int dnd_end_hour, int dnd_end_min, uid_t uid);
+                                       int dnd_end_hour, int dnd_end_min,
+                                       int lock_screen_content_level, uid_t uid);
 int notification_setting_db_update_do_not_disturb(int do_not_disturb, uid_t uid);
 
 int noti_setting_service_get_setting_by_package_name(const char *package_name, notification_setting_h *setting, uid_t uid);
index cf9059597b3012cf3b8e57359c4b34dc00fd7e40..0a0e4d7e9336c0308a971a210de2e8b43a454542 100755 (executable)
@@ -136,6 +136,7 @@ create      table if not exists noti_list ( \
                        dnd_start_min INTEGER DEFAULT 0, \
                        dnd_end_hour INTEGER DEFAULT 0, \
                        dnd_end_min INTEGER DEFAULT 0, \
+                       lock_screen_content_level INTEGER DEFAULT 0, \
                        UNIQUE (uid) \
                );"
 
index a7588975881b8df780cbeb3be4d18b6ce86564ca..1afb44e440ed198f72c5c984fab47a444468f073 100755 (executable)
@@ -1293,7 +1293,7 @@ int notification_ipc_update_system_setting(notification_system_setting_h system_
                return result;
        }
 
-       body = g_variant_new("(iiiiiiiii)",
+       body = g_variant_new("(iiiiiiiiii)",
                        (int)(system_setting->do_not_disturb),
                        (int)(system_setting->visibility_class),
                        (int)(system_setting->dnd_schedule_enabled),
@@ -1302,6 +1302,7 @@ int notification_ipc_update_system_setting(notification_system_setting_h system_
                        (int)(system_setting->dnd_start_min),
                        (int)(system_setting->dnd_end_hour),
                        (int)(system_setting->dnd_end_min),
+                       (int)(system_setting->lock_screen_content_level),
                        uid);
 
        result = _send_sync_noti(body, &reply, "update_noti_sys_setting");
@@ -1693,7 +1694,7 @@ EXPORT_API int notification_ipc_make_noti_from_gvariant(notification_h noti,
 EXPORT_API GVariant *notification_ipc_make_gvariant_from_system_setting(struct notification_system_setting *noti_setting)
 {
        GVariant *body = NULL;
-       body = g_variant_new("(iiiiiiii)",
+       body = g_variant_new("(iiiiiiiii)",
                        noti_setting->do_not_disturb,
                        noti_setting->visibility_class,
                        noti_setting->dnd_schedule_enabled,
@@ -1701,7 +1702,8 @@ EXPORT_API GVariant *notification_ipc_make_gvariant_from_system_setting(struct n
                        noti_setting->dnd_start_hour,
                        noti_setting->dnd_start_min,
                        noti_setting->dnd_end_hour,
-                       noti_setting->dnd_end_min);
+                       noti_setting->dnd_end_min,
+                       noti_setting->lock_screen_content_level);
        return body;
 }
 
@@ -1716,6 +1718,7 @@ EXPORT_API int notification_ipc_make_system_setting_from_gvariant(struct notific
        int dnd_start_min;
        int dnd_end_hour;
        int dnd_end_min;
+       int lock_screen_content_level;
 
        if (noti_setting == NULL) {
                NOTIFICATION_ERR("invalid data");
@@ -1723,7 +1726,7 @@ EXPORT_API int notification_ipc_make_system_setting_from_gvariant(struct notific
        }
 
        g_variant_get(variant,
-                       "(iiiiiiii)",
+                       "(iiiiiiiii)",
                        &do_not_disturb,
                        &visibility_class,
                        &dnd_schedule_enabled,
@@ -1731,12 +1734,13 @@ EXPORT_API int notification_ipc_make_system_setting_from_gvariant(struct notific
                        &dnd_start_hour,
                        &dnd_start_min,
                        &dnd_end_hour,
-                       &dnd_end_min);
+                       &dnd_end_min,
+                       &lock_screen_content_level);
 
-       NOTIFICATION_DBG("system setting  #### %d, %d, %d, %d, [%d:%d] [%d:%d]",
-                       do_not_disturb, visibility_class,
-                       dnd_schedule_enabled, dnd_schedule_day,
-                       dnd_start_hour, dnd_start_min, dnd_end_hour, dnd_end_min);
+       NOTIFICATION_DBG("system setting  #### %d, %d, %d, %d, [%d:%d] [%d:%d], %d",
+                       do_not_disturb, visibility_class, dnd_schedule_enabled,
+                       dnd_schedule_day, dnd_start_hour, dnd_start_min,
+                       dnd_end_hour, dnd_end_min, lock_screen_content_level);
 
        noti_setting->do_not_disturb = do_not_disturb;
        noti_setting->visibility_class = visibility_class;
@@ -1746,11 +1750,7 @@ EXPORT_API int notification_ipc_make_system_setting_from_gvariant(struct notific
        noti_setting->dnd_start_min = dnd_start_min;
        noti_setting->dnd_end_hour = dnd_end_hour;
        noti_setting->dnd_end_min = dnd_end_min;
-
-       NOTIFICATION_DBG("system setting2  #### %d, %d, %d",
-                       noti_setting->do_not_disturb,
-                       noti_setting->visibility_class,
-                       noti_setting->dnd_schedule_enabled);
+       noti_setting->lock_screen_content_level = lock_screen_content_level;
 
        return NOTIFICATION_ERROR_NONE;
 }
index e2e290b8723433b50f3a3d34156d9e04e5b374bc..fbe2cdcc2f51bfe0fae7a9e451aab4846091f384 100755 (executable)
@@ -806,3 +806,35 @@ EXPORT_API int notification_system_setting_dnd_schedule_set_end_time(notificatio
 out:
        return err;
 }
+
+EXPORT_API int notification_system_setting_get_lock_screen_content(notification_system_setting_h system_setting, lock_screen_content_level_e *level)
+{
+       int err = NOTIFICATION_ERROR_NONE;
+
+       if (system_setting == NULL || level == NULL) {
+               NOTIFICATION_ERR("Invalid parameter\n");
+               err = NOTIFICATION_ERROR_INVALID_PARAMETER;
+               goto out;
+       }
+
+       *level = system_setting->lock_screen_content_level;
+
+out:
+       return err;
+}
+
+EXPORT_API int notification_system_setting_set_lock_screen_content(notification_system_setting_h system_setting, lock_screen_content_level_e level)
+{
+       int err = NOTIFICATION_ERROR_NONE;
+
+       if (system_setting == NULL) {
+               NOTIFICATION_ERR("Invalid parameter\n");
+               err = NOTIFICATION_ERROR_INVALID_PARAMETER;
+               goto out;
+       }
+
+       system_setting->lock_screen_content_level = level;
+
+out:
+       return err;
+}
index 1817ddabd1c81889fe5ad513d32e4770d040f7be..e5a3a32ff7d204e98b01473d0874d76a3bf53ec9 100644 (file)
@@ -308,7 +308,8 @@ int noti_system_setting_load_system_setting(notification_system_setting_h *syste
 
        sql_query = sqlite3_mprintf("SELECT do_not_disturb, visibility_class, "
                        "dnd_schedule_enabled, dnd_schedule_day, "
-                       "dnd_start_hour, dnd_start_min, dnd_end_hour, dnd_end_min "
+                       "dnd_start_hour, dnd_start_min, dnd_end_hour, dnd_end_min, "
+                       "lock_screen_content_level "
                        "FROM %s WHERE uid = %d", NOTIFICATION_SYSTEM_SETTING_DB_TABLE, uid);
 
        if (!sql_query) {
@@ -343,6 +344,7 @@ int noti_system_setting_load_system_setting(notification_system_setting_h *syste
                result_system_setting->dnd_start_min = 0;
                result_system_setting->dnd_end_hour = 0;
                result_system_setting->dnd_end_min = 0;
+               result_system_setting->lock_screen_content_level = 0;
        } else {
                /* LCOV_EXCL_START */
                col_index = column_count;
@@ -354,6 +356,7 @@ int noti_system_setting_load_system_setting(notification_system_setting_h *syste
                _get_table_field_data_int(query_result, &(result_system_setting->dnd_start_min), col_index++);
                _get_table_field_data_int(query_result, &(result_system_setting->dnd_end_hour), col_index++);
                _get_table_field_data_int(query_result, &(result_system_setting->dnd_end_min), col_index++);
+               _get_table_field_data_int(query_result, &(result_system_setting->lock_screen_content_level), col_index++);
                /* LCOV_EXCL_STOP */
        }
 
@@ -417,7 +420,8 @@ EXPORT_API
 int notification_setting_db_update_system_setting(int do_not_disturb, int visibility_class,
                int dnd_schedule_enabled, int dnd_schedule_day,
                int dnd_start_hour, int dnd_start_min,
-               int dnd_end_hour, int dnd_end_min, uid_t uid)
+               int dnd_end_hour, int dnd_end_min,
+               int lock_screen_content_level, uid_t uid)
 {
        int err = NOTIFICATION_ERROR_NONE;
        int sqlret;
@@ -435,7 +439,7 @@ int notification_setting_db_update_system_setting(int do_not_disturb, int visibi
 
        sqlite3_exec(db, "BEGIN immediate;", NULL, NULL, NULL);
 
-       sqlret = sqlite3_prepare_v2(db, "INSERT OR REPLACE INTO notification_system_setting (uid, do_not_disturb, visibility_class, dnd_schedule_enabled, dnd_schedule_day, dnd_start_hour, dnd_start_min, dnd_end_hour, dnd_end_min) VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?) ", -1, &db_statement, NULL);
+       sqlret = sqlite3_prepare_v2(db, "INSERT OR REPLACE INTO notification_system_setting (uid, do_not_disturb, visibility_class, dnd_schedule_enabled, dnd_schedule_day, dnd_start_hour, dnd_start_min, dnd_end_hour, dnd_end_min, lock_screen_content_level) VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?) ", -1, &db_statement, NULL);
 
        if (sqlret != SQLITE_OK) {
                NOTIFICATION_ERR("sqlite3_prepare_v2 failed [%d][%s]", sqlret, sqlite3_errmsg(db));
@@ -452,6 +456,7 @@ int notification_setting_db_update_system_setting(int do_not_disturb, int visibi
        sqlite3_bind_int(db_statement, field_index++, dnd_start_min);
        sqlite3_bind_int(db_statement, field_index++, dnd_end_hour);
        sqlite3_bind_int(db_statement, field_index++, dnd_end_min);
+       sqlite3_bind_int(db_statement, field_index++, lock_screen_content_level);
 
        sqlret = sqlite3_step(db_statement);
        if (sqlret != SQLITE_OK && sqlret != SQLITE_DONE) {
index 3f6e04d4840ebc59e192dd276d88fda7fbf37a99..b0457bdc3df574efc3225eda6cc1cea3b60a3f95 100755 (executable)
@@ -722,6 +722,8 @@ static int testapp_test_update_system_setting()
        int err = NOTIFICATION_ERROR_NONE;
        bool do_not_disturb;
        int visibility_class;
+       bool dnd_schedule_enabled;
+       lock_screen_content_level_e lock_screen_content_level = SHOW_ALL_CONTENT;
        notification_system_setting_h system_setting = NULL;
 
        err = notification_system_setting_load_system_setting(&system_setting);
@@ -741,6 +743,15 @@ static int testapp_test_update_system_setting()
        visibility_class = !visibility_class;
        notification_system_setting_set_visibility_class(system_setting, visibility_class);
 
+       notification_system_setting_dnd_schedule_get_enabled(system_setting, &dnd_schedule_enabled);
+       testapp_print("dnd_schedule_enabled [%d]\n", dnd_schedule_enabled);
+       dnd_schedule_enabled = !dnd_schedule_enabled;
+       notification_system_setting_dnd_schedule_set_enabled(system_setting, dnd_schedule_enabled);
+
+       notification_system_setting_get_lock_screen_content(system_setting, &lock_screen_content_level);
+       testapp_print("lock_screen_content_level [%d]\n", lock_screen_content_level);
+       lock_screen_content_level = !lock_screen_content_level;
+       notification_system_setting_set_lock_screen_content(system_setting, lock_screen_content_level);
        err = notification_system_setting_update_system_setting(system_setting);
 
        if (err != NOTIFICATION_ERROR_NONE || system_setting == NULL) {