Setting feedback theme index is required "http://tizen.org/privilege/systemsettings.admin" privilege.
Getting feedback theme is required "http://tizen.org/privilege/internal/default/public".
If application has above privilege, setting/getting theme index is successful.
Change-Id: I5aad3f3138e0fe0d0211832300929d78a4d7d47b
Signed-off-by: Yunhee Seo <yuni.seo@samsung.com>
src/devices.c
src/feedback-config.c
src/feedback.c
- src/check.c)
+ src/check.c
+ src/util/feedback-privilege.c)
SET(HEADERS
include/feedback.h
include/feedback-ids.h
include/feedback-internal.h
include/feedback-ids-internal.h
- include/feedback-ids-product.h)
+ include/feedback-ids-product.h
+ include/util/feedback-privilege.h)
ADD_DEFINITIONS("-DFEEDBACK_SYS_SHARE=\"${TZ_SYS_SHARE}\"")
ADD_DEFINITIONS("-DFEEDBACK_SYS_RO_SHARE=\"${TZ_SYS_RO_SHARE}\"")
INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include)
+INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include/util)
INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/src)
INCLUDE(FindPkgConfig)
capi-media-sound-manager
capi-media-wav-player
libsyscommon
+ cynara-client
+ cynara-session
)
FOREACH(flag ${pkgs_CFLAGS})
* @brief Gets the number of theme supported.
* @details This function gets the number of theme described in the config file.
* @since_tizen 8.0
+ * @remarks For reading count of feedback theme by feedback type, the privilege should be set to, %http://tizen.org/privilege/internal/default/public.
+ * If app doesn't have the privilege, it returns FEEDBACK_ERROR_PERMISSION_DENIED error.
* @param[in] type The feedback type
* @param[out] count_of_theme The number of theme supported
* @return @c 0 on success,
* @retval #FEEDBACK_ERROR_INVALID_PARAMETER Invalid parameter
* @retval #FEEDBACK_ERROR_NOT_SUPPORTED Not supported device
* @retval #FEEDBACK_ERROR_NOT_INITIALIZED Not initialized
+ * @retval #FEEDBACK_ERROR_PERMISSION_DENIED Permission denied
* @pre feedback_initialize()
*/
int feedback_get_count_of_theme_internal(feedback_type_e feedback_type, unsigned int *count_of_theme);
* @brief Gets the current index of theme selected.
* @details This function gets the current index of theme selected.
* @since_tizen 8.0
+ * @remarks For reading feedback theme index, the privilege should be set to, %http://tizen.org/privilege/internal/default/public.
+ * If app doesn't have the privilege, it returns FEEDBACK_ERROR_PERMISSION_DENIED error.
* @param[in] type The feedback type
* @param[out] index_of_theme The current index of theme selected
* @return @c 0 on success,
* @retval #FEEDBACK_ERROR_OPERATION_FAILED Operation not permitted
* @retval #FEEDBACK_ERROR_INVALID_PARAMETER Invalid parameter
* @retval #FEEDBACK_ERROR_NOT_SUPPORTED Not supported device
+ * @retval #FEEDBACK_ERROR_PERMISSION_DENIED Permission denied
*/
int feedback_get_theme_index_internal(feedback_type_e feedback_type, unsigned int *index_of_theme);
* The range of theme index will be 1~N according to conf file.
* Please put the accurate index_of_theme value.
* @since_tizen 8.0
+ * @remarks For setting feedback theme index, the privilege should be set to, %http://tizen.org/privilege/systemsettings.admin.
+ * If app doesn't have the privilege, it returns FEEDBACK_ERROR_PERMISSION_DENIED error.
* @param[in] type The feedback type
* @param[in] index_of_theme The index of theme will be selected
* @return @c 0 on success,
* @retval #FEEDBACK_ERROR_OPERATION_FAILED Operation not permitted
* @retval #FEEDBACK_ERROR_INVALID_PARAMETER Invalid parameter
* @retval #FEEDBACK_ERROR_NOT_SUPPORTED Not supported device
+ * @retval #FEEDBACK_ERROR_PERMISSION_DENIED Permission denied
*/
int feedback_set_theme_index_internal(feedback_type_e feedback_type, unsigned int index_of_theme);
--- /dev/null
+
+/*
+ * libfeedback
+ * Copyright (c) 2023 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __FEEDBACK_PRIVILEGE_H__
+#define __FEEDBACK_PRIVILEGE_H__
+
+#include <stdbool.h>
+
+bool is_privilege_supported(const char *privilege_name);
+
+#endif //__FEEDBACK_PRIVILEGE_H__
\ No newline at end of file
BuildRequires: pkgconfig(libtzplatform-config)
BuildRequires: pkgconfig(capi-system-info)
BuildRequires: pkgconfig(libsyscommon)
+BuildRequires: pkgconfig(cynara-client)
+BuildRequires: pkgconfig(cynara-session)
%if 0%{?gcov:1}
BuildRequires: lcov
#include <limits.h>
#include <libsyscommon/libgdbus.h>
+#include "util/feedback-privilege.h"
#include "feedback.h"
#include "feedback-internal.h"
#include "profiles.h"
static guint signal_id = 0;
#define SIGNAL_VIBRATOR_INITIATED "InitiateVibrator"
+#define PRIVILEGE_FEEDBACK_SET_THEME "http://tizen.org/privilege/systemsettings.admin"
+#define PRIVILEGE_FEEDBACK_GET_THEME "http://tizen.org/privilege/internal/default/public"
//LCOV_EXCL_START Not called Callback
static void restart_callback(GDBusConnection *conn,
const struct device_ops *dev = NULL;
int ret = 0;
+ if (!is_privilege_supported(PRIVILEGE_FEEDBACK_GET_THEME))
+ return FEEDBACK_ERROR_PERMISSION_DENIED;
+
pthread_mutex_lock(&fmutex);
if (!init_cnt) {
_E("Not initialized"); //LCOV_EXCL_LINE
const struct device_ops *dev = NULL;
int ret = 0;
+ if (!is_privilege_supported(PRIVILEGE_FEEDBACK_GET_THEME))
+ return FEEDBACK_ERROR_PERMISSION_DENIED;
+
if (feedback_type <= FEEDBACK_TYPE_NONE || feedback_type >= profile->max_type || !index_of_theme) {
_E("Invalid parameter : type(%d)", feedback_type);
return FEEDBACK_ERROR_INVALID_PARAMETER;
const struct device_ops *dev = NULL;
int ret = 0;
+ if (!is_privilege_supported(PRIVILEGE_FEEDBACK_SET_THEME))
+ return FEEDBACK_ERROR_PERMISSION_DENIED;
+
if (feedback_type <= FEEDBACK_TYPE_NONE || feedback_type >= profile->max_type) {
_E("Invalid parameter : type(%d)", feedback_type);
return FEEDBACK_ERROR_INVALID_PARAMETER;
--- /dev/null
+/*
+ * libfeedback
+ * Copyright (c) 2023 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <unistd.h>
+#include <glib.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+#include <cynara-client.h>
+#include <cynara-session.h>
+
+#include "util/feedback-privilege.h"
+#include "log.h"
+
+#define BUFF_MAX 255
+
+extern char *program_invocation_name;
+
+bool is_privilege_supported(const char *privilege_name)
+{
+ cynara *cynara = NULL;
+ FILE *fp = NULL;
+ char uid[16];
+ char *session = NULL;
+ char smack_label[BUFF_MAX] = {0, };
+ int ret;
+
+ if (cynara_initialize(&cynara, NULL) != CYNARA_API_SUCCESS) {
+ _E("failed to initialize cynara");
+ return false;
+ }
+
+ fp = fopen("/proc/self/attr/current", "r");
+ if (fp != NULL) {
+ int ch = 0;
+ int idx = 0;
+ while (EOF != (ch = fgetc(fp))) {
+ smack_label[idx] = ch;
+ idx++;
+ }
+ fclose(fp);
+ }
+
+ pid_t pid = getpid();
+ session = cynara_session_from_pid(pid);
+ snprintf(uid, 16, "%d", getuid());
+ uid[15] = '\0';
+
+ ret = cynara_check(cynara, smack_label, session, uid, privilege_name);
+ if (session)
+ free(session);
+ if (cynara)
+ cynara_finish(cynara);
+ if (ret != CYNARA_API_ACCESS_ALLOWED) {
+ _E("'%s' privilege is not supported on %s",
+ privilege_name, program_invocation_name);
+ return false;
+ }
+
+ return true;
+}