summaryrefslogtreecommitdiff
path: root/src/components/include/policy/policy_external/policy/policy_manager.h
blob: 22721841aa24577640fa9ced8d470d7e9d10ab21 (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
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
/*
 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_INCLUDE_POLICY_POLICY_EXTERNAL_POLICY_POLICY_MANAGER_H_
#define SRC_COMPONENTS_INCLUDE_POLICY_POLICY_EXTERNAL_POLICY_POLICY_MANAGER_H_

#include <vector>

#include "utils/callable.h"
#include "utils/optional.h"

#include "application_manager/policies/policy_encryption_flag_getter.h"
#include "policy/access_remote.h"
#include "policy/cache_manager_interface.h"
#include "policy/policy_listener.h"
#include "policy/policy_table/types.h"
#include "policy/policy_types.h"
#include "policy/ptu_retry_handler.h"
#include "policy/usage_statistics/statistics_manager.h"

namespace policy {
class PolicySettings;
typedef std::shared_ptr<utils::Callable> StatusNotifier;

class PolicyManager : public usage_statistics::StatisticsManager,
                      public PolicyEncryptionFlagGetterInterface,
                      public PTURetryHandler {
 public:
  /**
   * @brief The NotificationMode enum defines whether application will be
   * notified about changes done (e.g. after consents were changed) or not
   */
  enum NotificationMode { kSilentMode, kNotifyApplicationMode };

  enum PtProcessingResult { kSuccess, kWrongPtReceived, kNewPtRequired };

  virtual ~PolicyManager() {}

  /**
   * @brief set_listener set new policy listener instance
   * @param listener new policy listener
   */
  virtual void set_listener(PolicyListener* listener) = 0;

  /**
   * @brief Inits Policy Table
   * @param file_name path to preloaded PT file
   * @param settings pointer to policy init settings
   * @return true if init is successful
   */
  virtual bool InitPT(const std::string& file_name,
                      const PolicySettings* settings) = 0;

  /**
   * @brief Updates Policy Table from binary message received from
   * mobile device. Saves to Policy Table diff between Policy Table
   * sent in snapshot and received Policy Table.
   * @param file name of file with update policy table
   * @param pt_content PTU as binary string
   * @return result of PT processing
   */
  virtual PtProcessingResult LoadPT(const std::string& file,
                                    const BinaryMessage& pt_content) = 0;

  /**
   * @brief Performs finalizing actions after PT update was processed
   * @param ptu_result result of last PT processing
   */
  virtual void OnPTUFinished(const PtProcessingResult ptu_result) = 0;

  /**
   * @brief Resets Policy Table
   * @param file_name Path to preloaded PT file
   * @return true if successfully
   */
  virtual bool ResetPT(const std::string& file_name) = 0;

  /**
   * @brief Gets last URL for sending PTS to from PT itself
   * @param service_type Service specifies user of URL
   * @return last URL or empty string if endpoint entry is empty
   */
  virtual std::string GetUpdateUrl(int service_type) = 0;

  /**
   * @brief Gets all URLs for sending PTS to from PT itself.
   * @param service_type Service specifies user of URL
   * @return vector of urls
   */
  virtual void GetUpdateUrls(const uint32_t service_type,
                             EndpointUrls& out_end_points) = 0;
  virtual void GetUpdateUrls(const std::string& service_type,
                             EndpointUrls& out_end_points) = 0;

  /**
   * @brief GetLockScreenIcon allows to obtain lock screen icon url;
   * @return url which point to the resource where lock screen icon could be
   *obtained.
   */
  virtual std::string GetLockScreenIconUrl() const = 0;

  /**
   * @brief Get Icon Url used for showing a cloud apps icon before the initial
   *registration
   *
   * @return url which point to the resource where icon could be
   *obtained.
   */
  virtual std::string GetIconUrl(const std::string& policy_app_id) const = 0;

  /**
   * @brief PTU is needed, for this PTS has to be formed and sent.
   */
  virtual void RequestPTUpdate() = 0;

  /**
   * @brief Check if specified RPC for specified application
   * has permission to be executed in specified HMI Level
   * and also its permitted params.
   * @param device_id device identifier
   * @param app_id Id of application provided during registration
   * @param hmi_level Current HMI Level of application
   * @param rpc Name of RPC
   * @param rpc_params List of RPC params
   * @param CheckPermissionResult containing flag if HMI Level is allowed
   * and list of allowed params.
   */
  virtual void CheckPermissions(const PTString& device_id,
                                const PTString& app_id,
                                const PTString& hmi_level,
                                const PTString& rpc,
                                const RPCParams& rpc_params,
                                CheckPermissionResult& result) = 0;

  /**
   * @brief Clear all record of user consents. Used during Factory Reset.
   * @return bool Success of operation
   */
  virtual bool ResetUserConsent() = 0;

  /**
   * @brief Returns current status of policy table for HMI
   * @return Current status of policy table
   */
  virtual std::string GetPolicyTableStatus() const = 0;

  /**
   * @brief Checks is PT exceeded kilometers
   * @param kilometers current kilometers at odometer
   * @return true if exceeded
   */
  virtual void KmsChanged(int kilometers) = 0;

  /**
   * @brief Returns state of the lock screen that could be able to be dismissed
   * while connected to SDL, allowing users the ability to interact with the
   * app.
   * @return bool True if lock screen can be dismissed.
   */
  virtual const boost::optional<bool> LockScreenDismissalEnabledState()
      const = 0;

  /**
   * @brief Returns lock screen warning message. In case when specified language
   * is absent in policy table will be returned message on default language
   * ("en-us"). Otherwise returns uninitialized boost::optional<std::string>
   * @return std::string Lock screen warning message
   */
  virtual const boost::optional<std::string> LockScreenDismissalWarningMessage(
      const std::string& language) const = 0;

  /**
   * @brief Increments counter of ignition cycles
   */
  virtual void IncrementIgnitionCycles() = 0;

  /**
   * @brief Exchange by hmi or mobile request
   * @return Current status of policy table
   */
  virtual std::string ForcePTExchange() = 0;

  /**
   * @brief Stops retry sequence timer and resets retry sequence
   */
  virtual void StopRetrySequence() = 0;

  /**
   * @brief Exchange by user request
   * @return Current status of policy table
   */
  virtual std::string ForcePTExchangeAtUserRequest() = 0;

  /**
   * @brief Resets retry sequence
   * @param reset_type - reset retry count with sending OnStatusUpdate or not
   */
  virtual void ResetRetrySequence(const ResetRetryCountType reset_type) = 0;

  /**
   * @brief Gets timeout to wait before next retry updating PT
   * If timeout is less or equal to zero then the retry sequence is not need.
   * @return timeout in seconds
   */
  virtual int NextRetryTimeout() = 0;

  /**
   * @brief Gets timeout to wait until receive response
   * @return timeout in seconds
   */
  virtual uint32_t TimeoutExchangeMSec() = 0;

  /**
   * @brief List of timeouts in seconds between retries
   *        when attempt to update PT fails
   * @return List of delays between attempts.
   */
  virtual const std::vector<int> RetrySequenceDelaysSeconds() = 0;

  /**
   * @brief Handler of exceeding timeout of exchanging policy table
   */
  virtual void OnExceededTimeout() = 0;

  /**
   * @brief Handler of PTS sending out
   */
  virtual void OnUpdateStarted() = 0;

  /**
   * @brief Gets user consent for mobile device data connection
   * @param device_id Unique device identifier
   * @return status of device consent
   */
  virtual DeviceConsent GetUserConsentForDevice(
      const std::string& device_id) const = 0;

  /**
   * @brief Gets user consent for application
   * @param device_id Device id
   * @param policy_app_id Unique application id
   * @param permissions Array of functional groups permissions
   */
  virtual void GetUserConsentForApp(
      const std::string& device_id,
      const std::string& policy_app_id,
      std::vector<FunctionalGroupPermission>& permissions) = 0;

  /**
   * @brief Set user consent for mobile device data connection
   * @param device_id Unique device identifier
   * @param is_allowed User consent for usage device data connection
   */
  virtual void SetUserConsentForDevice(const std::string& device_id,
                                       const bool is_allowed) = 0;

  /**
   * @brief Update Application Policies as reaction
   * on User allowing/disallowing device this app is running on.
   * @param device_handle device identifier
   * @param app_id Unique application id
   * @param is_device_allowed true if user allowing device otherwise false
   * @return true if operation was successful
   */
  virtual bool ReactOnUserDevConsentForApp(
      const transport_manager::DeviceHandle& device_handle,
      const std::string& app_id,
      const bool is_device_allowed) = 0;

  /**
   * @brief Sets counter value that passed for receiving PT UPdate.
   */
  virtual void PTUpdatedAt(Counters counter, int value) = 0;

  /**
   * @brief Retrieves data from app_policies about app on its registration:
   * @param application_id - id of registered app
   * @param nicknames Synonyms for application
   * @param app_hmi_types Section on HMI where app can appear (Navigation, Phone
   * etc)
   */
  virtual bool GetInitialAppData(const std::string& application_id,
                                 StringArray* nicknames = NULL,
                                 StringArray* app_hmi_types = NULL) = 0;

  /**
   * @brief Add's device to policy table
   * @param device_id        Device mac address
   * @param connection_type  Device connection type
   */
  virtual void AddDevice(const std::string& device_id,
                         const std::string& connection_type) = 0;

  /**
   * @brief Stores device parameters received during application registration
   * to policy table
   * @param device_id Device mac address
   * @param device_info Received device parameters
   */
  virtual void SetDeviceInfo(const std::string& device_id,
                             const DeviceInfo& device_info) = 0;

  /**
   * @brief Set user consent for application functional groups
   * @param permissions User-defined application group pemissions.
   * The permissions is not const reference because it may contains
   * valid data as well as invalid. So we will remove all invalid data
   * from this structure.
   * @param mode notification mode
   */
  virtual void SetUserConsentForApp(const PermissionConsent& permissions,
                                    const NotificationMode mode) = 0;

  /**
   * @brief Get default HMI level for application
   * @param device_id device identifier
   * @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& device_id,
                             const std::string& policy_app_id,
                             std::string* default_hmi) const = 0;

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

  /**
   * @brief Get user friendly messages for given RPC messages and language
   * @param message_codes RPC message codes
   * @param language Language
   * @param active_hmi_language Currently active language
   * @return Array of structs with appropriate message parameters
   */
  virtual std::vector<UserFriendlyMessage> GetUserFriendlyMessages(
      const std::vector<std::string>& message_code,
      const std::string& language,
      const std::string& active_hmi_language) = 0;

  /**
   * @brief Checks if the application is revoked
   * @param app_id application id
   * @return true if application is revoked
   */
  virtual bool IsApplicationRevoked(const std::string& app_id) const = 0;

  /**
   * @brief Get resulting RPCs permissions for application which started on
   * specific device
   * @param device_id Device id
   * @param policy_app_id Unique application id
   * @param permissions Array of functional groups permissions
   */
  virtual void GetPermissionsForApp(
      const std::string& device_id,
      const std::string& policy_app_id,
      std::vector<FunctionalGroupPermission>& permissions) = 0;

  /**
   * @brief Gets specific application permissions changes since last policy
   * table update
   * @param device_id device identifier
   * @param policy_app_id Unique application id
   * @return Permissions changes
   */
  virtual AppPermissions GetAppPermissionsChanges(
      const std::string& device_id, const std::string& policy_app_id) = 0;

  /**
   * @brief Removes specific application permissions changes
   * @param app_id Unique application id
   */
  virtual void RemovePendingPermissionChanges(const std::string& app_id) = 0;

  /**
   * @brief Return device id, which hosts specific application
   * @param device_handle device identifier
   * @param policy_app_id Application id, which is required to update device id
   */
  virtual std::string& GetCurrentDeviceId(
      const transport_manager::DeviceHandle& device_handle,
      const std::string& policy_app_id) const = 0;

  /**
   * @brief Set current system language
   * @param language Language
   */
  virtual void SetSystemLanguage(const std::string& language) = 0;

  /**
   * @brief Set data from GetSystemInfo response to policy table
   * @param ccpu_version CCPU version
   * @param wers_country_code WERS country code
   * @param language System language
   */
  virtual void SetSystemInfo(const std::string& ccpu_version,
                             const std::string& wers_country_code,
                             const std::string& language) = 0;

  /**
   * @brief Send OnPermissionsUpdated for choosen application
   * @param device_id device identifier
   * @param application_id Unique application id
   */
  virtual void SendNotificationOnPermissionsUpdated(
      const std::string& device_id, const std::string& application_id) = 0;

  /**
   * @brief Marks device as upaired
   * @param device_id id device
   */
  virtual void MarkUnpairedDevice(const std::string& device_id) = 0;

  /**
   * @brief Adds, application to the db or update existed one
   * run PTU if policy update is necessary for application.
   * @param device_id device identifier
   * @param application_id Unique application id
   * @param hmi_types application HMI types
   * @return function that will notify update manager about new application
   */
  virtual StatusNotifier AddApplication(
      const std::string& device_id,
      const std::string& application_id,
      const rpc::policy_table_interface_base::AppHmiTypes& hmi_types) = 0;

  /**
   * @brief Removes unpaired device records and related records from DB
   * @return true, if succedeed, otherwise - false
   */
  virtual bool CleanupUnpairedDevices() = 0;

  /**
   * @brief Check if app can keep context.
   * @param app_id Unique application id
   * @return true if app can keep context, otherwise - false
   */
  virtual bool CanAppKeepContext(const std::string& app_id) const = 0;

  /**
   * @brief Check if app can steal focus.
   * @param app_id Unique application id
   * @return true if app can steal focus, otherwise - false
   */
  virtual bool CanAppStealFocus(const std::string& app_id) const = 0;

  /**
   * @brief Runs necessary operations, which is depends on external system
   * state, e.g. getting system-specific parameters which are need to be
   * filled into policy table
   */
  virtual void OnSystemReady() = 0;

  /**
   * @brief Get number of notification by priority
   * @param priority Specified priority
   * @return notification number
   */
  virtual uint32_t GetNotificationsNumber(
      const std::string& priority) const = 0;

  /**
   * @brief Allows to update Vehicle Identification Number in policy table.
   * @param new value for the parameter.
   */
  virtual void SetVINValue(const std::string& value) = 0;

  /**
   * @brief Checks, if application has policy assigned w/o data consent
   * @param policy_app_id Unique application id
   * @return true, if policy assigned w/o data consent, otherwise -false
   */
  virtual bool IsPredataPolicy(const std::string& policy_app_id) const = 0;

  /**
   * @brief Returns heart beat timeout
   * @param app_id application id
   * @return if timeout was set then value in milliseconds greater zero
   * otherwise heart beat for specific application isn't set
   */
  virtual uint32_t HeartBeatTimeout(const std::string& app_id) const = 0;

  /**
   * @brief SaveUpdateStatusRequired allows to save update status.
   * @param is_update_needed true if update needed
   */
  virtual void SaveUpdateStatusRequired(bool is_update_needed) = 0;

  /**
   * @brief Handler on applications search started
   */
  virtual void OnAppsSearchStarted() = 0;

  /**
   * @brief Handler on applications search completed
   * @param trigger_ptu contains true if PTU should be triggered
   */
  virtual void OnAppsSearchCompleted(const bool trigger_ptu) = 0;

  /**
   * @brief OnAppRegisteredOnMobile allows to handle event when application were
   * succesfully registered on mobile device.
   * It will send OnAppPermissionSend notification and will try to start PTU.
   *
   * @param device_id device identifier
   * @param application_id registered application.
   */
  virtual void OnAppRegisteredOnMobile(const std::string& device_id,
                                       const std::string& application_id) = 0;

  virtual void OnDeviceSwitching(const std::string& device_id_from,
                                 const std::string& device_id_to) = 0;

  /**
   * @brief Get state of request types for given application
   * @param policy_app_id Unique application id
   * @return request type state
   */
  virtual RequestType::State GetAppRequestTypesState(
      const std::string& policy_app_id) const = 0;

  /**
   * @brief Get state of request subtypes for given application
   * @param policy_app_id Unique application id
   * @return request subtype state
   */
  virtual RequestSubType::State GetAppRequestSubTypesState(
      const std::string& policy_app_id) const = 0;

  /**
   * @brief Gets request types for application
   * @param device_handle device identifier
   * @param policy_app_id Unique application id
   * @return request types of application
   */
  virtual const std::vector<std::string> GetAppRequestTypes(
      const transport_manager::DeviceHandle& device_handle,
      const std::string policy_app_id) const = 0;

  /**
   * @brief Gets request subtypes for application
   * @param policy_app_id Unique application id
   * @return request subtypes of application
   */
  virtual const std::vector<std::string> GetAppRequestSubTypes(
      const std::string& policy_app_id) const = 0;

  /**
   * @brief Gets vehicle data items
   * @return Structure with vehicle data items
   */
  virtual const std::vector<policy_table::VehicleDataItem> GetVehicleDataItems()
      const = 0;

  /**
   * @brief Gets vehicle data items removed by policies
   * @return Structure with vehicle data items
   */
  virtual std::vector<rpc::policy_table_interface_base::VehicleDataItem>
  GetRemovedVehicleDataItems() const = 0;

  /**
   * @brief Gets copy of current policy table data
   * @return policy_table as json object
   */
  virtual Json::Value GetPolicyTableData() const = 0;

  /**
   * @brief Get a list of enabled cloud applications
   * @param enabled_apps List filled with the policy app id of each enabled
   * cloud application
   */
  virtual void GetEnabledCloudApps(
      std::vector<std::string>& enabled_apps) const = 0;

  /**
   * @brief Get cloud app policy information, all fields that aren't set for a
   * given app will be filled with empty strings
   * @param policy_app_id Unique application id
   * @param enabled Whether or not the app is enabled
   * @param endpoint Filled with the endpoint used to connect to the cloud
   * application
   * @param certificate Filled with the certificate used to for creating a
   * secure connection to the cloud application
   * @param auth_token Filled with the token used for authentication when
   * reconnecting to the cloud app
   * @param cloud_transport_type Filled with the transport type used by the
   * cloud application (ex. "WSS")
   * @param hybrid_app_preference Filled with the hybrid app preference for the
   * cloud application set by the user
   */
  virtual bool GetCloudAppParameters(
      const std::string& policy_app_id,
      bool& enabled,
      std::string& endpoint,
      std::string& certificate,
      std::string& auth_token,
      std::string& cloud_transport_type,
      std::string& hybrid_app_preference) const = 0;

  /**
   * @ brief Initialize new cloud app in the policy table
   * @ param policy_app_id Application ID
   */
  virtual void InitCloudApp(const std::string& policy_app_id) = 0;

  /**
   * @brief Enable or disable a cloud application in the HMI
   * @param enabled Cloud app enabled state
   */
  virtual void SetCloudAppEnabled(const std::string& policy_app_id,
                                  const bool enabled) = 0;

  /**
   * @brief Set an app's auth token
   * @param auth_token Cloud app authentication token
   */
  virtual void SetAppAuthToken(const std::string& policy_app_id,
                               const std::string& auth_token) = 0;

  /**
   * @brief Set a cloud app's transport type
   * @param cloud_transport_type Cloud app transport type
   */
  virtual void SetAppCloudTransportType(
      const std::string& policy_app_id,
      const std::string& cloud_transport_type) = 0;

  /**
   * @brief Set a cloud app's endpoint url
   * @param endpoint URL for websocket connection
   */
  virtual void SetAppEndpoint(const std::string& policy_app_id,
                              const std::string& endpoint) = 0;

  /**
   * @brief Set a cloud app's nicknames
   * @param nicknames Nicknames for cloud app
   */
  virtual void SetAppNicknames(const std::string& policy_app_id,
                               const StringArray& nicknames) = 0;

  /**
   * @brief Set the user preference for how a hybrid (cloud and mobile) app
   * should be used
   * @param hybrid_app_preference Hybrid app user preference
   */
  virtual void SetHybridAppPreference(
      const std::string& policy_app_id,
      const std::string& hybrid_app_preference) = 0;

  /**
   * @brief Get app service parameters from the policy table
   * @param policy_app_id Unique application id
   * @param app_service_parameters Pointer to struct containing all app service
   * information
   */
  virtual void GetAppServiceParameters(
      const std::string& policy_app_id,
      policy_table::AppServiceParameters* app_service_parameters) const = 0;

  /**
   * @brief Check if an app can send unknown rpc requests to an app service
   * provider
   * @param policy_app_id Unique application id
   */
  virtual bool UnknownRPCPassthroughAllowed(
      const std::string& policy_app_id) const = 0;

  /**
   * @brief Gets meta information
   * @return meta information
   */
  virtual const MetaInfo GetMetaInfo() const = 0;

  /**
   * @brief RetrieveCertificate Allows to obtain certificate in order
   * to start secure connection.
   * @return The certificate in PKCS#7 format.
   */
  virtual std::string RetrieveCertificate() const = 0;

  /**
   * @brief HasCertificate check whether policy table has certificate
   * int module_config section.
   * @return true in case certificate exists, false otherwise
   */
  virtual bool HasCertificate() const = 0;

  /**
   * @brief Sets decrypted certificate in policy table
   * @param certificate content of certificate
   */
  virtual void SetDecryptedCertificate(const std::string& certificate) = 0;

  /**
   * @brief Getter for policy settings
   * @return policy settings instance
   */
  virtual const PolicySettings& get_settings() const = 0;

  /**
   * @brief Finds the next URL that must be sent on OnSystemRequest retry
   * @param urls vector of vectors that contain urls for each application
   * @return Pair of policy application id and application url id from the
   * urls vector
   */
  virtual AppIdURL GetNextUpdateUrl(const EndpointUrls& urls) = 0;

  /**
   * @brief Assigns new HMI types for specified application
   * @param device_handle device identifier
   * @param application_id Unique application id
   * @param hmi_types new HMI types list
   */
  virtual void SetDefaultHmiTypes(
      const transport_manager::DeviceHandle& device_handle,
      const std::string& application_id,
      const std::vector<int>& hmi_types) = 0;
  /**
   * @brief Gets HMI types
   * @param application_id ID application
   * @param app_types list to save HMI types
   * @return true if policy has specific policy for this application
   */
  virtual bool GetHMITypes(const std::string& application_id,
                           std::vector<int>* app_types) = 0;

  /**
   * @brief Checks if module for application is present in policy table
   * @param app_id id of application
   * @param module type
   * @return true if module is present, otherwise - false
   */
  virtual bool CheckModule(const PTString& app_id, const PTString& module) = 0;

  /**
   * @brief Send OnPermissionsChange notification to mobile app
   * when it's permissions are changed.
   * @param device_id Device on which app is running
   * @param application_id ID of app whose permissions are changed
   */
  virtual void SendAppPermissionsChanged(const std::string& device_id,
                                         const std::string& application_id) = 0;

  /**
   * @brief Gets all allowed module types
   * @param policy_app_id unique identifier of application
   * @param modules list of allowed module types
   * @return true if application has allowed modules
   */
  virtual bool GetModuleTypes(const std::string& policy_app_id,
                              std::vector<std::string>* modules) const = 0;

  /**
   * @brief Setter for access_remote instance
   * @param access_remote pointer to new access_remote instance
   */
  virtual void set_access_remote(
      std::shared_ptr<AccessRemote> access_remote) = 0;

  /**
   * @brief Checks if there is existing URL in the EndpointUrls vector with
   * index saved in the policy manager and if not, it moves to the next
   * application index
   * @param rs contains the application index and url index from the
   * urls vector that are to be sent on the next OnSystemRequest
   * @param urls vector of vectors that contain urls for each application
   * @return Pair of application index and url index
   */
  virtual AppIdURL RetrySequenceUrl(const struct RetrySequenceURL& rs,
                                    const EndpointUrls& urls) const = 0;

  /**
   * @brief  Checks, if SDL needs to update it's policy table section
             "external_consent_status"
   * @param  ExternalConsent status
   * @return true if such check is needed, false - if not.
   */
  virtual bool IsNeedToUpdateExternalConsentStatus(
      const ExternalConsentStatus& status) const = 0;

  /**
   * @brief Saves customer connectivity settings status
   * @param status ExternalConsent status
   * @return true if succeeded, otherwise - false
   */
  virtual bool SetExternalConsentStatus(
      const ExternalConsentStatus& status) = 0;

  /**
   * @brief Gets customer connectivity settings status
   * @return ExternalConsent status
   */
  virtual ExternalConsentStatus GetExternalConsentStatus() = 0;

  /**
   * @brief Restart PTU timeout if PTU in UPDATING state
   */
  virtual void ResetTimeout() = 0;

 protected:
  /**
   * @brief Checks is PT exceeded IgnitionCycles
   * @return true if exceeded
   */
  virtual bool ExceededIgnitionCycles() = 0;

  /**
   * @brief Checks is PT exceeded days
   * @return true if exceeded
   */
  virtual bool ExceededDays() = 0;

  /**
   * @brief StartPTExchange allows to start PTU. The function will check
   * if one is required and starts the update flow in only case when previous
   * condition is true.
   */
  virtual void StartPTExchange() = 0;
};

}  // namespace policy

extern "C" policy::PolicyManager* CreateManager();
extern "C" void DeleteManager(policy::PolicyManager*);

#endif  // SRC_COMPONENTS_INCLUDE_POLICY_POLICY_EXTERNAL_POLICY_POLICY_MANAGER_H_