2 * Copyright (c) 2020 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
22 #include <app_manager.h>
23 #include <package_manager.h>
25 #include "sst_vconf.h"
27 bool sst_misc_file_exists(const char *path)
29 if (0 != access(path, R_OK)) {
30 ERR("access(%s) Fail(%d)", path, errno);
36 int sst_misc_get_wifi_QS_noti(sst_interface *iface, bool *value)
39 if (vconf_get_int(iface->vconf_key, &vconf_value)) {
40 ERR("vconf_get_int(%s) Fail", iface->vconf_key);
41 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
45 result = (vconf_value == VCONFKEY_WIFI_QS_ENABLE) ? true : false;
48 return SYSTEM_SETTINGS_ERROR_NONE;
51 //It is related with Advertisements
52 #define DEFAULT_ADS_ID "00000000-0000-0000-0000-000000000000"
53 int sst_misc_get_ads_id(sst_interface *iface, char **value)
56 const char *key = VCONFKEY_SETAPPL_AD_ID_OPT_OUT;
57 if (vconf_get_int(key, &result)) {
58 ERR("vconf_get_int(%s) Fail", key);
59 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
63 *value = strdup(DEFAULT_ADS_ID);
64 return SYSTEM_SETTINGS_ERROR_NONE;
67 char *vconf_value = NULL;
68 if (sst_vconf_get_str_ally(iface->vconf_key, &vconf_value)) {
69 ERR("sst_vconf_get_str_ally(%s) Fail", iface->vconf_key);
70 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
74 return SYSTEM_SETTINGS_ERROR_NONE;
77 int sst_misc_set_ads_id(sst_interface *iface, const char *value)
79 if (vconf_set_str(iface->vconf_key, value)) {
80 ERR("vconf_set_str(%s) Fail", iface->vconf_key);
81 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
84 return SYSTEM_SETTINGS_ERROR_NONE;
87 int sst_misc_get_uds_state(sst_interface *iface, int *value)
92 if (vconf_get_int(iface->vconf_key, &int_val))
93 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
95 if (int_val == SYSTEM_SETTINGS_UDS_ON) {
96 const char *vconf_key = VCONFKEY_SETAPPL_UDSM_PKGID_LIST;
97 int ret = sst_vconf_get_str_ally(vconf_key, &str_val);
98 if (SYSTEM_SETTINGS_ERROR_NONE != ret) {
99 ERR("sst_vconf_get_str_ally(%s) Fail(%d)", vconf_key, ret);
103 if (SST_EQUAL != strcmp(str_val, "NONE")) {
105 char *package_id = NULL;
106 pid_t pid = getpid();
108 int ret = app_manager_get_app_id(pid, &app_id);
109 if (ret != APP_MANAGER_ERROR_NONE) {
110 SECURE_ERR("app_manager_get_app_id(%d) Fail(%d)", pid, ret);
112 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
115 ret = package_manager_get_package_id_by_app_id(app_id, &package_id);
116 if (PACKAGE_MANAGER_ERROR_NONE != ret) {
117 SECURE_ERR("package_manager_get_package_id_by_app_id(%s) Fail(%d)", app_id, ret);
120 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
124 if (package_id && strstr(str_val, package_id))
125 int_val = SYSTEM_SETTINGS_UDS_ON_WHITELISTED;
133 return SYSTEM_SETTINGS_ERROR_NONE;