2 Copyright (c) 2013, Ford Motor Company
5 Redistribution and use in source and binary forms, with or without
6 modification, are permitted provided that the following conditions are met:
8 Redistributions of source code must retain the above copyright notice, this
9 list of conditions and the following disclaimer.
11 Redistributions in binary form must reproduce the above copyright notice,
12 this list of conditions and the following
13 disclaimer in the documentation and/or other materials provided with the
16 Neither the name of the Ford Motor Company nor the names of its contributors
17 may be used to endorse or promote products derived from this software
18 without specific prior written permission.
20 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
24 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30 POSSIBILITY OF SUCH DAMAGE.
33 #ifndef SRC_COMPONENTS_POLICY_INCLUDE_POLICY_PT_EXT_REPRESENTATION_H_
34 #define SRC_COMPONENTS_POLICY_INCLUDE_POLICY_PT_EXT_REPRESENTATION_H_
36 #include "policy/pt_representation.h"
47 S_MINS_HMI_BACKGROUND,
49 S_RFCOM_LIMIT_REACHED,
51 S_REJECTIONS_SYNC_OUT_OF_MEMORY,
52 S_REJECTIONS_NICKNAME_MISMATCH,
53 S_REJECTIONS_DUPLICATE_NAME,
56 S_REMOVALS_MISBEHAVED,
57 S_RUN_ATTEMPTS_WHILE_REVOKED
66 class PTExtRepresentation : public virtual PTRepresentation {
68 virtual ~PTExtRepresentation() {
72 * @brief Is application allowed to send notifications while in
73 * Backgound or limited mode.
74 * @param app_id Application id
75 * @return bool Allowed/disallowed.
77 virtual bool CanAppKeepContext(const std::string& app_id) = 0;
80 * @brief Is application allowed to move foreground at will?
81 * @param app_id Application id
82 * @return bool Allowed/disallowed.
84 virtual bool CanAppStealFocus(const std::string& app_id) = 0;
87 * @brief Get default_hmi for given application
88 * @param policy_app_id Unique application id
89 * @param default_hmi Default HMI level for application or empty, if value was
91 * @return true, if succedeed, otherwise - false
93 virtual bool GetDefaultHMI(const std::string& policy_app_id,
94 std::string* default_hmi) = 0;
97 * @brief Get priority for given application
98 * @param policy_app_id Unique application id
99 * @param priority Priority for application or empty, if value was not set
100 * @return true, if succedeed, otherwise - false
102 virtual bool GetPriority(const std::string& policy_app_id,
103 std::string* priority) = 0;
106 * @brief Reset user consent for device data and applications permissions
109 virtual bool ResetUserConsent() = 0;
112 * @brief Reset user consent for device data
115 virtual bool ResetDeviceConsents() = 0;
118 * @brief Reset user consent for applications permissions
121 virtual bool ResetAppConsents() = 0;
124 * @brief Get user permissions for device data usage
125 * @param device_id Generated or obtained id of device
126 * @param consented_groups Groups consented by user
127 * @param disallowed_groups Groups not consented by user
128 * @return true, if query was successfull, otherwise - false
130 virtual bool GetUserPermissionsForDevice(
131 const std::string& device_id, StringArray* consented_groups = NULL,
132 StringArray* disallowed_groups = NULL) = 0;
135 * @brief GetUserPermissionsForApp
137 * @param policy_app_id
141 virtual bool GetUserPermissionsForApp(
142 const std::string& device_id,
143 const std::string& policy_app_id,
144 FunctionalIdType* group_types) = 0;
147 * @brief Get device groups and preconsented groups from policies section
148 * @param groups List of groups to be consented for device usage
149 * @param preconsented_groups List of preconsented groups for device usage
150 * @return true, if query was successful, otherwise - false
152 virtual bool GetDeviceGroupsFromPolicies(
153 policy_table::Strings* groups = NULL,
154 policy_table::Strings* preconsented_groups = NULL) = 0;
157 * @brief Record information about mobile device in Policy Table.
158 * @param device_id Generated or obtained id of device
159 * @return bool Success of operation
161 virtual bool SetDeviceData(const std::string& device_id,
162 const std::string& hardware = "",
163 const std::string& firmware = "",
164 const std::string& os = "",
165 const std::string& os_version = "",
166 const std::string& carrier = "",
167 const uint32_t number_of_ports = 0) = 0;
170 * @brief Sets user consent for particular mobile device,
171 * i.e. to use device for exchanging of Policy Table.
172 * @return bool Success of operation
174 virtual bool SetUserPermissionsForDevice(
175 const std::string& device_id, const StringArray& consented_groups =
177 const StringArray& disallowed_gropus = StringArray()) = 0;
180 * @brief Update Application Policies as reaction
181 * on User allowing/disallowing device this app is running on.
183 virtual bool ReactOnUserDevConsentForApp(
184 const std::string& app_id,
185 bool is_device_allowed) = 0;
188 * @brief Set user consent on functional groups
189 * @param permissions User consent on functional group
190 * @return true, if operation succedeed, otherwise - false
192 virtual bool SetUserPermissionsForApp(
193 const PermissionConsent& permissions) = 0;
196 * @brief Counter for statistics information: adds 1 to existing number.
197 * @param type Type of statistics (errors, mins in mode etc)
198 * @return bool Success of operation
200 virtual bool IncreaseStatisticsData(StatisticsType type) = 0;
203 * @brief Records information about what language
204 * application tried to register with.
205 * @param app_id Id of application
206 * @param type - language for UI/VR
207 * @param language Language
208 * @return bool Success of operation
210 virtual bool SetAppRegistrationLanguage(const std::string& app_id,
212 const std::string& language) = 0;
215 * @brief Records information about head unit system to PT
216 * @return bool Success of operation
218 virtual bool SetMetaInfo(const std::string& ccpu_version,
219 const std::string& wers_country_code,
220 const std::string& language) = 0;
223 * @brief Kms pass since last successfull PT update
225 virtual int GetKmFromSuccessfulExchange() = 0;
228 * @brief Days pass since last successfull PT update
230 virtual int GetDayFromScsExchange() = 0;
233 * @brief Ignition cycles pass since last successfull PT update
235 virtual int GetIgnitionsFromScsExchange() = 0;
238 * @brief Set current system language
239 * @param language System language
240 * @return true, if succedeed, otherwise - false
242 virtual bool SetSystemLanguage(const std::string& language) = 0;
245 * Increments global counter
246 * @param type type of counter
248 virtual void Increment(const std::string& type) const = 0;
251 * Increments counter of application
252 * @param app_id id application
253 * @param type type of counter
255 virtual void Increment(const std::string& app_id,
256 const std::string& type) const = 0;
259 * Sets value of application information
260 * @param app_id id application
261 * @param type type of information
262 * @param value value of information
264 virtual void Set(const std::string& app_id, const std::string& type,
265 const std::string& value) const = 0;
268 * Adds value to stopwatch of application
269 * @param app_id id application
270 * @param type type of stopwatch
271 * @param seconds value for adding in seconds
273 virtual void Add(const std::string& app_id, const std::string& type,
274 int seconds) const = 0;
276 virtual bool CountUnconsentedGroups(const std::string& policy_app_id,
277 const std::string& device_id,
278 int* result) const = 0;
281 * @brief Gets functional group names and user_consent_prompts, if any
282 * @param Array to be filled with group ids, names and functional prompts
283 * @return true, if succeeded, otherwise - false
285 // TODO(AOleynik): Possibly, we can get rid of this method. Check this.
286 virtual bool GetFunctionalGroupNames(policy::FunctionalGroupNames& names) = 0;
289 * @brief Set app policy to pre_DataConsented policy
290 * @param app_id Policy ID of application to be changed
291 * @return true, if succeeded, otherwise - false
293 virtual bool SetPredataPolicy(const std::string& app_id) = 0;
296 * @brief Updates application policy to either pre_DataConsented or not
297 * @param app_id Policy Id of application to be checked
298 * @param is_pre_data True of False to setting app policy to be pre_DataConsented
299 * @return true, if succeeded, otherwise - false
301 virtual bool SetIsPredata(const std::string& app_id, bool is_pre_data) = 0;
304 * @brief Removes unpaired devices
305 * @return true if success
307 virtual bool CleanupUnpairedDevices(const DeviceIds& device_ids) const = 0;
310 * Sets flag of unpaired device
312 * @return true if success
314 virtual bool SetUnpairedDevice(const std::string& device_id) const = 0;
317 * Gets list of unpaired devices
318 * @param device_ids output list
319 * @return true if success
321 virtual bool UnpairedDevicesList(DeviceIds* device_ids) const = 0;
323 } // namespace policy
325 #endif // SRC_COMPONENTS_POLICY_INCLUDE_POLICY_PT_EXT_REPRESENTATION_H_