2 * Copyright (c) 2018 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.
21 #include "dpl/test/test_runner.h"
22 #include "privilege_manager.h"
24 namespace PrivilegeManager {
26 void setPrivacyPrivileges(const uid_t uid, const std::string &pkgId,
27 const std::string &tizenVersion, const std::vector<std::string> &privileges,
28 const privilege_manager_package_type_e &type)
30 GList *list = nullptr;
32 for (const std::string &privilege : privileges) {
33 gchar *str = g_strdup(privilege.c_str());
35 g_list_free_full(list, g_free);
36 throw std::bad_alloc();
39 GList *listNew = g_list_append(list, str);
40 if (listNew == nullptr) {
41 g_list_free_full(list, g_free);
42 throw std::bad_alloc();
48 int ret = privilege_package_info_set_privacy_privilege(uid, pkgId.c_str(),
49 type, tizenVersion.empty() ? "4.0" : tizenVersion.c_str(), list);
50 g_list_free_full(list, g_free);
52 RUNNER_ASSERT_MSG(ret == PRVMGR_ERR_NONE,
53 "privilege_package_info_set_privacy_privilege failed: " << ret);
56 void unsetPrivacyPrivileges(const uid_t uid, const std::string &pkgId)
58 int ret = privilege_package_info_unset_package_privilege_info(
61 RUNNER_ASSERT_MSG(ret == PRVMGR_ERR_NONE,
62 "privilege_package_info_unset_privacy_privilege failed: " << ret);
65 } // namespace PrivilegeManager