summaryrefslogtreecommitdiff
path: root/src/components/policy/policy_regular/include/policy/pt_ext_representation.h
blob: f70946d1f5caa222aa6d81207e255e2bf0ab15ca (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
/*
 Copyright (c) 2013, Ford Motor Company
 All rights reserved.

 Redistribution and use in source and binary forms, with or without
 modification, are permitted provided that the following conditions are met:

 Redistributions of source code must retain the above copyright notice, this
 list of conditions and the following disclaimer.

 Redistributions in binary form must reproduce the above copyright notice,
 this list of conditions and the following
 disclaimer in the documentation and/or other materials provided with the
 distribution.

 Neither the name of the Ford Motor Company nor the names of its contributors
 may be used to endorse or promote products derived from this software
 without specific prior written permission.

 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 POSSIBILITY OF SUCH DAMAGE.
 */

#ifndef SRC_COMPONENTS_POLICY_POLICY_REGULAR_INCLUDE_POLICY_PT_EXT_REPRESENTATION_H_
#define SRC_COMPONENTS_POLICY_POLICY_REGULAR_INCLUDE_POLICY_PT_EXT_REPRESENTATION_H_

#include "policy/pt_representation.h"

namespace policy {

enum StatisticsType {
  S_NONE = 0,
  S_IAP_BUFFER_FULL,
  S_SYNC_OUT_OF_MEMORY,
  S_SYNC_REBOOTS,
  S_MINS_HMI_FULL,
  S_MINS_HMI_LIMITED,
  S_MINS_HMI_BACKGROUND,
  S_MINS_HMI_NONE,
  S_RFCOM_LIMIT_REACHED,
  S_USER_SELECTIONS,
  S_REJECTIONS_SYNC_OUT_OF_MEMORY,
  S_REJECTIONS_NICKNAME_MISMATCH,
  S_REJECTIONS_DUPLICATE_NAME,
  S_REJECTED_RPC_CALLS,
  S_RPCS_IN_HMI_NONE,
  S_REMOVALS_MISBEHAVED,
  S_RUN_ATTEMPTS_WHILE_REVOKED
};

enum LanguageType { L_NONE = 0, L_GUI, L_VUI };

class PTExtRepresentation : public virtual PTRepresentation {
 public:
  virtual ~PTExtRepresentation() {}

  /**
   * @brief Is application allowed to send notifications while in
   * Backgound or limited mode.
   * @param app_id Application id
   * @return bool Allowed/disallowed.
   */
  virtual bool CanAppKeepContext(const std::string& app_id) = 0;

  /**
   * @brief Is application allowed to move foreground at will?
   * @param app_id Application id
   * @return bool Allowed/disallowed.
   */
  virtual bool CanAppStealFocus(const std::string& app_id) = 0;

  /**
   * @brief Get default_hmi for given application
   * @param policy_app_id Unique application id
   * @param default_hmi Default HMI level for application or empty, if value was
   * not set
   * @return true, if succedeed, otherwise - false
   */
  virtual bool GetDefaultHMI(const std::string& policy_app_id,
                             std::string* default_hmi) = 0;

  /**
   * @brief Reset user consent for device data and applications permissions
   * @return
   */
  virtual bool ResetUserConsent() = 0;

  /**
   * @brief Reset user consent for device data
   * @return
   */
  virtual bool ResetDeviceConsents() = 0;

  /**
   * @brief Reset user consent for applications permissions
   * @return
   */
  virtual bool ResetAppConsents() = 0;

  /**
   * @brief Get user permissions for device data usage
   * @param device_id Generated or obtained id of device
   * @param consented_groups Groups consented by user
   * @param disallowed_groups Groups not consented by user
   * @return true, if query was successfull, otherwise - false
   */
  virtual bool GetUserPermissionsForDevice(
      const std::string& device_id,
      StringArray* consented_groups = NULL,
      StringArray* disallowed_groups = NULL) = 0;

  /**
   * @brief Gets list of groups permissions from policy table
   * @param device_id Unique device id, which hosts specific application
   * @param policy_app_id Unique application id
   * @param group_types Group list sorted by permission status
   * @return true, if query was successfull, otherwise - false
   */
  virtual bool GetPermissionsForApp(const std::string& device_id,
                                    const std::string& policy_app_id,
                                    FunctionalIdType* group_types) = 0;

  /**
   * @brief Get device groups and preconsented groups from policies section
   * @param groups List of groups to be consented for device usage
   * @param preconsented_groups List of preconsented groups for device usage
   * @return true, if query was successful, otherwise - false
   */
  virtual bool GetDeviceGroupsFromPolicies(
      policy_table::Strings* groups = NULL,
      policy_table::Strings* preconsented_groups = NULL) = 0;

  /**
   * @brief Record information about mobile device in Policy Table.
   * @param device_id Generated or obtained id of device
   * @return bool Success of operation
   */
  virtual bool SetDeviceData(const std::string& device_id,
                             const std::string& hardware = "",
                             const std::string& firmware = "",
                             const std::string& os = "",
                             const std::string& os_version = "",
                             const std::string& carrier = "",
                             const uint32_t number_of_ports = 0,
                             const std::string& connection_type = "") = 0;

  /**
   * @brief Sets user consent for particular mobile device,
   * i.e. to use device for exchanging of Policy Table.
   * @return bool Success of operation
   */
  virtual bool SetUserPermissionsForDevice(
      const std::string& device_id,
      const StringArray& consented_groups = StringArray(),
      const StringArray& disallowed_gropus = StringArray()) = 0;

  /**
   * @brief Update Application Policies as reaction
   * on User allowing/disallowing device this app is running on.
   */
  virtual bool ReactOnUserDevConsentForApp(const std::string& app_id,
                                           bool is_device_allowed) = 0;

  /**
   * @brief Set user consent on functional groups
   * @param permissions User consent on functional group
   * @return true, if operation succedeed, otherwise - false
   */
  virtual bool SetUserPermissionsForApp(
      const PermissionConsent& permissions) = 0;

  /**
   * @brief Counter for statistics information: adds 1 to existing number.
   * @param type Type of statistics (errors, mins in mode etc)
   * @return bool Success of operation
   */
  virtual bool IncreaseStatisticsData(StatisticsType type) = 0;

  /**
   * @brief Records information about what language
   * application tried to register with.
   * @param app_id Id of application
   * @param type - language for UI/VR
   * @param language Language
   * @return bool Success of operation
   */
  virtual bool SetAppRegistrationLanguage(const std::string& app_id,
                                          LanguageType type,
                                          const std::string& language) = 0;

  /**
   * @brief Records information about head unit system to PT
   * @return bool Success of operation
   */
  virtual bool SetMetaInfo(const std::string& ccpu_version,
                           const std::string& wers_country_code,
                           const std::string& language) = 0;

  /**
   * @brief Checks, if specific head unit is present in PT
   * @return boot Suceess, if present, otherwise - false
   */
  virtual bool IsMetaInfoPresent() = 0;

  /**
   * @brief Kms pass since last successfull PT update
   */
  virtual int GetKmFromSuccessfulExchange() = 0;

  /**
   * @brief Days pass since last successfull PT update
   */
  virtual int GetDayFromScsExchange() = 0;

  /**
   * @brief Ignition cycles pass since last successfull PT update
   */
  virtual int GetIgnitionsFromScsExchange() = 0;

  /**
   * @brief Set current system language
   * @param language System language
   * @return true, if succedeed, otherwise - false
   */
  virtual bool SetSystemLanguage(const std::string& language) = 0;

  /**
   * Increments global counter
   * @param type type of counter
   */
  virtual void Increment(const std::string& type) const = 0;

  /**
   * Increments counter of application
   * @param app_id id application
   * @param type type of counter
   */
  virtual void Increment(const std::string& app_id,
                         const std::string& type) const = 0;

  /**
   * Sets value of application information
   * @param app_id id application
   * @param type type of information
   * @param value value of information
   */
  virtual void Set(const std::string& app_id,
                   const std::string& type,
                   const std::string& value) const = 0;

  /**
   * Adds value to stopwatch of application
   * @param app_id id application
   * @param type type of stopwatch
   * @param seconds value for adding in seconds
   */
  virtual void Add(const std::string& app_id,
                   const std::string& type,
                   int seconds) const = 0;

  virtual bool CountUnconsentedGroups(const std::string& policy_app_id,
                                      const std::string& device_id,
                                      int* result) const = 0;

  /**
   * @brief Gets functional group names and user_consent_prompts, if any
   * @param Array to be filled with group ids, names and functional prompts
   * @return true, if succeeded, otherwise - false
   */
  // TODO(AOleynik): Possibly, we can get rid of this method. Check this.
  virtual bool GetFunctionalGroupNames(policy::FunctionalGroupNames& names) = 0;

  /**
       * @brief Set app policy to pre_DataConsented policy
       * @param app_id Policy ID of application to be changed
       * @return true, if succeeded, otherwise - false
       */
  virtual bool SetPredataPolicy(const std::string& app_id) = 0;

  /**
   * @brief Updates application policy to either pre_DataConsented or not
   * @param app_id Policy Id of application to be checked
   * @param is_pre_data True of False to setting app policy to be
   * pre_DataConsented
   * @return true, if succeeded, otherwise - false
   */
  virtual bool SetIsPredata(const std::string& app_id, bool is_pre_data) = 0;

  /**
   * @brief Removes unpaired devices
   * @return true if success
   */
  virtual bool CleanupUnpairedDevices(const DeviceIds& device_ids) const = 0;

  /**
   * Sets flag of unpaired device
   * @param device_id Unique device id
   * @param unpaired True, if unpaired, otherwise - false
   * @return true if success
   */
  virtual bool SetUnpairedDevice(const std::string& device_id,
                                 bool unpaired) const = 0;

  /**
   * Gets list of unpaired devices
   * @param device_ids output list
   * @return true if success
   */
  virtual bool UnpairedDevicesList(DeviceIds* device_ids) const = 0;

  /**
   * @brief Remove application consent for particular group
   * @param policy_app_id Unique application id
   * @param functional_group_name Functional group name, which consents should
   * be removed
   * @return true, in case of success, otherwise - false
   */
  virtual bool RemoveAppConsentForGroup(
      const std::string& policy_app_id,
      const std::string& functional_group_name) const = 0;
  virtual bool SaveExternalConsentStatus(
      const ExternalConsentStatus& status) const = 0;
  virtual ExternalConsentStatus GetExternalConsentStatus() const = 0;
};
}  //  namespace policy

#endif  //  SRC_COMPONENTS_POLICY_POLICY_REGULAR_INCLUDE_POLICY_PT_EXT_REPRESENTATION_H_