2 * Copyright (c) 2015 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
17 #ifndef __CAPI_APPLICATION_POLICY_H__
18 #define __CAPI_APPLICATION_POLICY_H__
20 #include <dpm/device-policy-manager.h>
24 * @brief This file provides APIs to control application functionality
32 * @addtogroup CAPI_DPM_APPLICATION_POLICY_MODULE
37 * @brief Enumeration for installation mode
41 DPM_PACKAGE_RESTRICTION_MODE_ALL = 0x0F, /**< All package restriction mode */
42 DPM_PACKAGE_RESTRICTION_MODE_INSTALL = 0x01, /**< Package install restriction */
43 DPM_PACKAGE_RESTRICTION_MODE_UNINSTALL = 0x02, /**< Package uninstall restriction */
44 DPM_PACKAGE_RESTRICTION_MODE_REINSTALL = 0x04, /**< Package reinstall restriction */
45 DPM_PACKAGE_RESTRICTION_MODE_MOVE = 0x08 /**< Package move restriction */
46 } dpm_package_restriction_mode_e;
49 * @brief Restricts installation / uninstallation for all packages.
50 * @details Administrator can use this API to restrict package installation, uninstallation,
51 * reinstallation or move.
53 * @param[in] handle The device policy manager handle
54 * @param[in] mode The installation mode to be set, one of DPM_PACKAGE_INSTALLATION_MODE_ALLOW or
55 * DPM_PACKAGE_INSTALLATION_MODE_DISALLOW
56 * @return #DPM_ERROR_NONE on success, otherwise a negative value
57 * @retval #DPM_ERROR_NONE No error
58 * @retval #DPM_ERROR_TIMEOUT Time out
59 * @retval #DPM_ERROR_ACCESS_DENIED The application does not have
60 * the privilege to call this API
61 * @pre handle must be created by dpm_context_acquire_application_policy()
62 * @see dpm_application_unset_mode_restriction()
63 * @see dpm_application_get_mode_restriction()
65 int dpm_application_set_mode_restriction(device_policy_manager_h handle, int mode);
68 * @brief Allows installation / uninstallation for all packages.
69 * @details If the mode is set to DPM_PACKAGE_INSTALLATION_MODE_DISALLOW,
70 * no application can be installed on the device.
72 * @param[in] handle The device policy manager handle
73 * @param[in] mode The installation mode to be set, one of DPM_PACKAGE_INSTALLATION_MODE_ALLOW or
74 * DPM_PACKAGE_INSTALLATION_MODE_DISALLOW
75 * @return #DPM_ERROR_NONE on success, otherwise a negative value
76 * @retval #DPM_ERROR_NONE No error
77 * @retval #DPM_ERROR_TIMEOUT Time out
78 * @retval #DPM_ERROR_ACCESS_DENIED The application does not have
79 * the privilege to call this API
80 * @pre handle must be created by dpm_context_acquire_application_policy()
81 * @see dpm_application_set_mode_restriction()
82 * @see dpm_application_get_mode_restriction()
84 int dpm_application_unset_mode_restriction(device_policy_manager_h handle, int mode);
87 * @brief Gets the current restriction mode for all packages.
88 * @details The default mode is to allow any package to be installed.
90 * @param[in] handle The device policy manager handle
91 * @param[out] mode Current mode of operation, which is one of the following:
92 * #DPM_PACKAGE_INSTALLATION_MODE_ALLOW Package installation is allowed
93 * #DPM_PACKAGE_INSTALLATION_MODE_DISALLOW Package installation is not allowed
94 * @return #DPM_ERROR_NONE on success, otherwise a negative value
95 * @retval #DPM_ERROR_NONE Successful
96 * @retval #DPM_ERROR_TIMEOUT Time out
97 * @pre handle must be created by dpm_context_acquire_application_policy()
98 * @see dpm_application_set_mode_restriction()
99 * @see dpm_application_unset_mode_restriction()
100 * @see dpm_application_get_mode_restriction()
102 int dpm_application_get_mode_restriction(device_policy_manager_h handle, int *mode);
105 * @brief Adds privilege to blacklist
106 * @details Administrator can use this API to disallow package installation
107 * which requires the privilege.
109 * @param[in] handle The application policy handle
110 * @param[in] type The package type
111 * @param[in] privilehe The privilege name to be blacklisted
112 * @return #DPM_ERROR_NONE on success, otherwise a negative value
113 * @retval #DPM_ERROR_NONE Successful
114 * @retval #DPM_ERROR_TIMEOUT Time out
115 * @retval #DPM_ERROR_ACCESS_DENIED The application does not have
116 * the privilege to call this API
117 * @pre handle must be created by dpm_context_acquire_application_policy()
118 * @see dpm_context_acquire_application_policy()
119 * @see dpm_context_release_application_policy()
120 * @see dpm_application_remove_privilege_from_blacklist()
121 * @see dpm_application_check_privilege_is_blacklisted()
123 int dpm_application_add_privilege_to_blacklist(device_policy_manager_h handle, int type, const char* privilege);
126 * @brief Removes privilege from blacklist
127 * @details Administrator can use this API to remove privilege from blacklist.
129 * @param[in] handle The application policy handle
130 * @param[in] type The package type
131 * @param[in] privilege The privilege name which is removed from blacklist
132 * @return #DPM_ERROR_NONE on success, otherwise a negative value
133 * @retval #DPM_ERROR_NONE Successful
134 * @retval #DPM_ERROR_TIMEOUT Time out
135 * @retval #DPM_ERROR_ACCESS_DENIED The application does not have
136 * the privilege to call this API
137 * @pre handle must be created by dpm_context_acquire_application_policy()
138 * @see dpm_context_acquire_application_policy()
139 * @see dpm_context_release_application_policy()
140 * @see dpm_application_add_privilege_to_blacklist()
141 * @see dpm_application_check_privilege_is_blacklisted()
143 int dpm_application_remove_privilege_from_blacklist(device_policy_manager_h handle, int type, const char* privilege);
146 * @brief Checks whether a privilege is added to blacklist
147 * @details Administrator can use this API to check whether the privilege is blacklisted.
148 * Once privilege is added to blacklist, the package which requires the privilege
149 * is prohibited to install on the device.
151 * @param[in] handle The application policy handle
152 * @param[in] type The package type
153 * @param[in] privilege The privilege name
154 * @param[out] is_blacklisted TRUE if the package installation is disabled, else FALSE
155 * @return #DPM_ERROR_NONE on success, otherwise a negative value
156 * @retval #DPM_ERROR_NONE Successful
157 * @retval #DPM_ERROR_TIMEOUT Time out
158 * @pre handle must be created by dpm_context_acquire_application_policy()
159 * @see dpm_context_acquire_application_policy()
160 * @see dpm_context_release_application_policy()
161 * @see dpm_application_add_privilege_to_blacklist()
162 * @see dpm_application_remove_privilege_from_blacklist()
164 int dpm_application_check_privilege_is_blacklisted(device_policy_manager_h handle, int type, const char* privilege, int *is_blacklisted);
166 int dpm_application_install_package(device_policy_manager_h handle, const char* pkgpath);
167 int dpm_application_uninstall_package(device_policy_manager_h handle, const char* pkgid);
176 #endif //! __CAPI_APPLICATION_POLICY_H__