summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAGaliuzov <AGaliuzov@luxoft.com>2016-05-18 10:52:44 -0700
committerAGaliuzov <AGaliuzov@luxoft.com>2016-05-18 10:52:44 -0700
commitbcf8405bbcb80823ac8bda564115695826ca99c4 (patch)
tree709781da072873410bb3bac2c0e230f691357735
parent2b17b5546d4d94665a37697d73f10adfb14b6dd3 (diff)
parent9e78a620a5aa43650036dd8230a8de26624c0242 (diff)
downloadsdl_core-bcf8405bbcb80823ac8bda564115695826ca99c4.tar.gz
Merge pull request #544 from dev-gh/hotfix/Partial_proprietary_policy_support4.0.12
Stabilization of partial proprietary policy support on master
-rw-r--r--src/components/application_manager/include/application_manager/application_manager.h56
-rw-r--r--src/components/application_manager/include/application_manager/application_manager_impl.h2424
-rw-r--r--src/components/application_manager/include/application_manager/policies/policy_handler.h229
-rw-r--r--src/components/application_manager/include/application_manager/state_controller.h696
-rw-r--r--src/components/application_manager/src/application_manager_impl.cc1667
-rw-r--r--src/components/application_manager/src/commands/mobile/register_app_interface_request.cc458
-rw-r--r--src/components/application_manager/src/commands/mobile/register_app_interface_response.cc48
-rw-r--r--src/components/application_manager/src/policies/policy_handler.cc725
-rw-r--r--src/components/application_manager/src/state_controller.cc365
-rw-r--r--src/components/policy/src/policy/include/policy/policy_listener.h57
-rw-r--r--src/components/policy/src/policy/include/policy/policy_manager.h799
-rw-r--r--src/components/policy/src/policy/include/policy/policy_manager_impl.h540
-rw-r--r--src/components/policy/src/policy/policy_table/table_struct/types.cc787
-rw-r--r--src/components/policy/src/policy/policy_table/table_struct/types.h594
-rw-r--r--src/components/policy/src/policy/src/cache_manager.cc485
-rw-r--r--src/components/policy/src/policy/src/policy_manager_impl.cc394
-rw-r--r--src/components/policy/src/policy/src/sql_pt_queries.cc991
-rw-r--r--src/components/policy/src/policy/src/sql_pt_representation.cc319
-rw-r--r--src/components/policy/test/include/mock_policy_listener.h58
-rw-r--r--src/components/policy/test/policy_manager_impl_test.cc166
20 files changed, 5916 insertions, 5942 deletions
diff --git a/src/components/application_manager/include/application_manager/application_manager.h b/src/components/application_manager/include/application_manager/application_manager.h
index c5a0402687..b535b5b63d 100644
--- a/src/components/application_manager/include/application_manager/application_manager.h
+++ b/src/components/application_manager/include/application_manager/application_manager.h
@@ -33,15 +33,17 @@
#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_APPLICATION_MANAGER_H_
#define SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_APPLICATION_MANAGER_H_
+#include "application_manager/application.h"
+
// Other compomnents class declaration
namespace hmi_message_handler {
- class HMIMessageHandler;
+class HMIMessageHandler;
}
namespace protocol_handler {
- class ProtocolHandler;
+class ProtocolHandler;
}
namespace connection_handler {
- class ConnectionHandler;
+class ConnectionHandler;
}
namespace application_manager {
@@ -49,30 +51,36 @@ namespace application_manager {
class Application;
class ApplicationManager {
- public:
- virtual ~ApplicationManager() {
- }
+public:
+ virtual ~ApplicationManager() {}
+
+ /**
+ * Inits application manager
+ */
+ virtual bool Init() = 0;
- /**
- * Inits application manager
- */
- virtual bool Init() = 0;
+ /**
+ * @brief Stop work.
+ *
+ * @return TRUE on success otherwise FALSE.
+ **/
+ virtual bool Stop() = 0;
- /**
- * @brief Stop work.
- *
- * @return TRUE on success otherwise FALSE.
- **/
- virtual bool Stop() = 0;
+ virtual void
+ set_hmi_message_handler(hmi_message_handler::HMIMessageHandler *handler) = 0;
+ virtual void
+ set_protocol_handler(protocol_handler::ProtocolHandler *handler) = 0;
+ virtual void
+ set_connection_handler(connection_handler::ConnectionHandler *handler) = 0;
- virtual void set_hmi_message_handler(
- hmi_message_handler::HMIMessageHandler* handler) = 0;
- virtual void set_protocol_handler(
- protocol_handler::ProtocolHandler* handler) = 0;
- virtual void set_connection_handler(
- connection_handler::ConnectionHandler* handler) = 0;
+ /**
+ * @brief Sets default HMI level and configure application after its
+ * registration
+ * @param app Application
+ */
+ virtual void OnApplicationRegistered(ApplicationSharedPtr app) = 0;
};
-} // namespace application_manager
+} // namespace application_manager
-#endif // SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_APPLICATION_MANAGER_H_
+#endif // SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_APPLICATION_MANAGER_H_
diff --git a/src/components/application_manager/include/application_manager/application_manager_impl.h b/src/components/application_manager/include/application_manager/application_manager_impl.h
index dd9cd33fa3..a5b9833954 100644
--- a/src/components/application_manager/include/application_manager/application_manager_impl.h
+++ b/src/components/application_manager/include/application_manager/application_manager_impl.h
@@ -68,7 +68,7 @@
#include "interfaces/v4_protocol_v1_2_no_extra_schema.h"
#ifdef TIME_TESTER
#include "time_metric_observer.h"
-#endif // TIME_TESTER
+#endif // TIME_TESTER
#include "utils/macro.h"
#include "utils/shared_ptr.h"
@@ -99,10 +99,7 @@ using namespace timer;
class ApplicationManagerImpl;
-enum VRTTSSessionChanging {
- kVRSessionChanging = 0,
- kTTSSessionChanging
-};
+enum VRTTSSessionChanging { kVRSessionChanging = 0, kTTSSessionChanging };
struct CommandParametersPermissions;
@@ -113,1305 +110,1296 @@ using namespace threads;
* These dummy classes are here to locally impose strong typing on different
* kinds of messages
* Currently there is no type difference between incoming and outgoing messages
- * And due to ApplicationManagerImpl works as message router it has to distinguish
+ * And due to ApplicationManagerImpl works as message router it has to
+ * distinguish
* messages passed from it's different connection points
* TODO(ik): replace these with globally defined message types
* when we have them.
*/
-struct MessageFromMobile: public utils::SharedPtr<Message> {
- explicit MessageFromMobile(const utils::SharedPtr<Message>& message)
- : utils::SharedPtr<Message>(message) {
- }
+struct MessageFromMobile : public utils::SharedPtr<Message> {
+ explicit MessageFromMobile(const utils::SharedPtr<Message> &message)
+ : utils::SharedPtr<Message>(message) {}
// PrioritizedQueue requres this method to decide which priority to assign
- size_t PriorityOrder() const {
- return (*this)->Priority().OrderingValue();
- }
+ size_t PriorityOrder() const { return (*this)->Priority().OrderingValue(); }
};
-struct MessageToMobile: public utils::SharedPtr<Message> {
- explicit MessageToMobile(const utils::SharedPtr<Message>& message,
+struct MessageToMobile : public utils::SharedPtr<Message> {
+ explicit MessageToMobile(const utils::SharedPtr<Message> &message,
bool final_message)
- : utils::SharedPtr<Message>(message),
- is_final(final_message) {
- }
+ : utils::SharedPtr<Message>(message), is_final(final_message) {}
// PrioritizedQueue requres this method to decide which priority to assign
- size_t PriorityOrder() const {
- return (*this)->Priority().OrderingValue();
- }
+ size_t PriorityOrder() const { return (*this)->Priority().OrderingValue(); }
// Signals if connection to mobile must be closed after sending this message
bool is_final;
};
-struct MessageFromHmi: public utils::SharedPtr<Message> {
- explicit MessageFromHmi(const utils::SharedPtr<Message>& message)
- : utils::SharedPtr<Message>(message) {
- }
+struct MessageFromHmi : public utils::SharedPtr<Message> {
+ explicit MessageFromHmi(const utils::SharedPtr<Message> &message)
+ : utils::SharedPtr<Message>(message) {}
// PrioritizedQueue requres this method to decide which priority to assign
- size_t PriorityOrder() const {
- return (*this)->Priority().OrderingValue();
- }
+ size_t PriorityOrder() const { return (*this)->Priority().OrderingValue(); }
};
-struct MessageToHmi: public utils::SharedPtr<Message> {
- explicit MessageToHmi(const utils::SharedPtr<Message>& message)
- : utils::SharedPtr<Message>(message) {
- }
+struct MessageToHmi : public utils::SharedPtr<Message> {
+ explicit MessageToHmi(const utils::SharedPtr<Message> &message)
+ : utils::SharedPtr<Message>(message) {}
// PrioritizedQueue requres this method to decide which priority to assign
- size_t PriorityOrder() const {
- return (*this)->Priority().OrderingValue();
- }
+ size_t PriorityOrder() const { return (*this)->Priority().OrderingValue(); }
};
// Short type names for prioritized message queues
-typedef threads::MessageLoopThread<utils::PrioritizedQueue<MessageFromMobile> > FromMobileQueue;
-typedef threads::MessageLoopThread<utils::PrioritizedQueue<MessageToMobile> > ToMobileQueue;
-typedef threads::MessageLoopThread<utils::PrioritizedQueue<MessageFromHmi> > FromHmiQueue;
-typedef threads::MessageLoopThread<utils::PrioritizedQueue<MessageToHmi> > ToHmiQueue;
+typedef threads::MessageLoopThread<utils::PrioritizedQueue<MessageFromMobile>>
+ FromMobileQueue;
+typedef threads::MessageLoopThread<utils::PrioritizedQueue<MessageToMobile>>
+ ToMobileQueue;
+typedef threads::MessageLoopThread<utils::PrioritizedQueue<MessageFromHmi>>
+ FromHmiQueue;
+typedef threads::MessageLoopThread<utils::PrioritizedQueue<MessageToHmi>>
+ ToHmiQueue;
// AudioPassThru
-typedef struct {
-std::vector<uint8_t> binary_data;
-int32_t session_key;
+typedef struct {
+ std::vector<uint8_t> binary_data;
+ int32_t session_key;
} AudioData;
-typedef std::queue<AudioData> RawAudioDataQueue;
-typedef threads::MessageLoopThread<RawAudioDataQueue> AudioPassThruQueue;
+typedef std::queue<AudioData> RawAudioDataQueue;
+typedef threads::MessageLoopThread<RawAudioDataQueue> AudioPassThruQueue;
}
typedef std::vector<std::string> RPCParams;
-class ApplicationManagerImpl : public ApplicationManager,
- public hmi_message_handler::HMIMessageObserver,
- public protocol_handler::ProtocolObserver,
- public connection_handler::ConnectionHandlerObserver,
- public policy::PolicyHandlerObserver,
- public impl::FromMobileQueue::Handler, public impl::ToMobileQueue::Handler,
- public impl::FromHmiQueue::Handler, public impl::ToHmiQueue::Handler,
- public impl::AudioPassThruQueue::Handler,
- public utils::Singleton<ApplicationManagerImpl> {
-
- friend class ResumeCtrl;
- friend class CommandImpl;
-
- public:
- ~ApplicationManagerImpl();
-
- /**
- * Inits application manager
- */
- virtual bool Init();
-
- /**
- * @brief Stop work.
- *
- * @return TRUE on success otherwise FALSE.
- **/
- virtual bool Stop();
-
- /////////////////////////////////////////////////////
-
- ApplicationSharedPtr application(uint32_t app_id) const;
- ApplicationSharedPtr application_by_policy_id(
- const std::string& policy_app_id) const;
- ApplicationSharedPtr active_application() const;
- std::vector<ApplicationSharedPtr> applications_by_button(uint32_t button);
- std::vector<ApplicationSharedPtr> applications_by_ivi(uint32_t vehicle_info);
- std::vector<ApplicationSharedPtr> applications_with_navi();
-
- /**
- * @brief Returns media application with LIMITED HMI Level if exist.
- *
- * @return Shared pointer to application if application does not
- * exist returns empty shared pointer.
- */
- ApplicationSharedPtr get_limited_media_application() const;
-
- /**
- * @brief Returns navigation application with LIMITED HMI Level if exist.
- *
- * @return Shared pointer to application if application does not
- * exist returns empty shared pointer
- */
- ApplicationSharedPtr get_limited_navi_application() const;
-
- /**
- * @brief Returns voice communication application with LIMITED HMI Level if exist.
- *
- * @return Shared pointer to application if application does not
- * exist returns empty shared pointer
- */
- ApplicationSharedPtr get_limited_voice_application() const;
-
- /**
- * @brief Checks if application with the same HMI type
- * (media, voice communication or navi) exists
- * in HMI_FULL or HMI_LIMITED level.
- *
- * @param app Pointer to application to compare with
- *
- * @return true if exist otherwise false
- */
- bool IsAppTypeExistsInFullOrLimited(ApplicationSharedPtr app) const;
-
- /**
- * @brief Notifies all components interested in Vehicle Data update
- * i.e. new value of odometer etc and returns list of applications
- * subscribed for event.
- * @param vehicle_info Enum value of type of vehicle data
- * @param new value (for integer values currently) of vehicle data
- */
- std::vector<ApplicationSharedPtr> IviInfoUpdated(
- VehicleDataType vehicle_info, int value);
-
- /////////////////////////////////////////////////////
-
- HMICapabilities& hmi_capabilities();
-
- /**
- * @brief ProcessQueryApp executes logic related to QUERY_APP system request.
- *
- * @param sm_object smart object wich is actually parsed json obtained within
- * system request.
- * @param connection_key connection key for app, which sent system request
- */
- void ProcessQueryApp(const smart_objects::SmartObject& sm_object,
- const uint32_t connection_key);
+class ApplicationManagerImpl
+ : public ApplicationManager,
+ public hmi_message_handler::HMIMessageObserver,
+ public protocol_handler::ProtocolObserver,
+ public connection_handler::ConnectionHandlerObserver,
+ public policy::PolicyHandlerObserver,
+ public impl::FromMobileQueue::Handler,
+ public impl::ToMobileQueue::Handler,
+ public impl::FromHmiQueue::Handler,
+ public impl::ToHmiQueue::Handler,
+ public impl::AudioPassThruQueue::Handler,
+ public utils::Singleton<ApplicationManagerImpl> {
+
+ friend class ResumeCtrl;
+ friend class CommandImpl;
+
+public:
+ ~ApplicationManagerImpl();
+
+ /**
+ * Inits application manager
+ */
+ virtual bool Init();
+
+ /**
+ * @brief Stop work.
+ *
+ * @return TRUE on success otherwise FALSE.
+ **/
+ virtual bool Stop();
+
+ /////////////////////////////////////////////////////
+
+ ApplicationSharedPtr application(uint32_t app_id) const;
+ ApplicationSharedPtr
+ application_by_policy_id(const std::string &policy_app_id) const;
+ ApplicationSharedPtr active_application() const;
+ std::vector<ApplicationSharedPtr> applications_by_button(uint32_t button);
+ std::vector<ApplicationSharedPtr> applications_by_ivi(uint32_t vehicle_info);
+ std::vector<ApplicationSharedPtr> applications_with_navi();
+
+ /**
+ * @brief Returns media application with LIMITED HMI Level if exist.
+ *
+ * @return Shared pointer to application if application does not
+ * exist returns empty shared pointer.
+ */
+ ApplicationSharedPtr get_limited_media_application() const;
+
+ /**
+ * @brief Returns navigation application with LIMITED HMI Level if exist.
+ *
+ * @return Shared pointer to application if application does not
+ * exist returns empty shared pointer
+ */
+ ApplicationSharedPtr get_limited_navi_application() const;
+
+ /**
+ * @brief Returns voice communication application with LIMITED HMI Level if
+ *exist.
+ *
+ * @return Shared pointer to application if application does not
+ * exist returns empty shared pointer
+ */
+ ApplicationSharedPtr get_limited_voice_application() const;
+
+ /**
+ * @brief Checks if application with the same HMI type
+ * (media, voice communication or navi) exists
+ * in HMI_FULL or HMI_LIMITED level.
+ *
+ * @param app Pointer to application to compare with
+ *
+ * @return true if exist otherwise false
+ */
+ bool IsAppTypeExistsInFullOrLimited(ApplicationSharedPtr app) const;
+
+ /**
+ * @brief Notifies all components interested in Vehicle Data update
+ * i.e. new value of odometer etc and returns list of applications
+ * subscribed for event.
+ * @param vehicle_info Enum value of type of vehicle data
+ * @param new value (for integer values currently) of vehicle data
+ */
+ std::vector<ApplicationSharedPtr> IviInfoUpdated(VehicleDataType vehicle_info,
+ int value);
+
+ void OnApplicationRegistered(ApplicationSharedPtr app) OVERRIDE;
+
+ /////////////////////////////////////////////////////
+
+ HMICapabilities &hmi_capabilities();
+
+ /**
+ * @brief ProcessQueryApp executes logic related to QUERY_APP system request.
+ *
+ * @param sm_object smart object wich is actually parsed json obtained within
+ * system request.
+ * @param connection_key connection key for app, which sent system request
+ */
+ void ProcessQueryApp(const smart_objects::SmartObject &sm_object,
+ const uint32_t connection_key);
#ifdef TIME_TESTER
- /**
- * @brief Setup observer for time metric.
- *
- * @param observer - pointer to observer
- */
- void SetTimeMetricObserver(AMMetricObserver* observer);
-#endif // TIME_TESTER
-
- ApplicationSharedPtr RegisterApplication(
- const utils::SharedPtr<smart_objects::SmartObject>& request_for_registration);
- /*
- * @brief Closes application by id
- *
- * @param app_id Application id
- * @param reason reason of unregistering application
- * @param is_resuming describes - is this unregister
- * is normal or need to be resumed\
- * @param is_unexpected_disconnect
- * Indicates if connection was unexpectedly lost(TM layer, HB)
- */
- void UnregisterApplication(const uint32_t& app_id,
- mobile_apis::Result::eType reason,
- bool is_resuming = false,
- bool is_unexpected_disconnect = false);
-
- /**
- * @brief Handle sequence for unauthorized application
- * @param app_id Application id
- */
- void OnAppUnauthorized(const uint32_t& app_id);
-
- /*
- * @brief Sets unregister reason for closing all registered applications
- * duringHU switching off
- *
- * @param reason Describes the reason for HU switching off
- */
- void SetUnregisterAllApplicationsReason(
+ /**
+ * @brief Setup observer for time metric.
+ *
+ * @param observer - pointer to observer
+ */
+ void SetTimeMetricObserver(AMMetricObserver *observer);
+#endif // TIME_TESTER
+
+ ApplicationSharedPtr
+ RegisterApplication(const utils::SharedPtr<smart_objects::SmartObject> &
+ request_for_registration);
+ /*
+ * @brief Closes application by id
+ *
+ * @param app_id Application id
+ * @param reason reason of unregistering application
+ * @param is_resuming describes - is this unregister
+ * is normal or need to be resumed\
+ * @param is_unexpected_disconnect
+ * Indicates if connection was unexpectedly lost(TM layer, HB)
+ */
+ void UnregisterApplication(const uint32_t &app_id,
+ mobile_apis::Result::eType reason,
+ bool is_resuming = false,
+ bool is_unexpected_disconnect = false);
+
+ /**
+ * @brief Handle sequence for unauthorized application
+ * @param app_id Application id
+ */
+ void OnAppUnauthorized(const uint32_t &app_id);
+
+ /*
+ * @brief Sets unregister reason for closing all registered applications
+ * duringHU switching off
+ *
+ * @param reason Describes the reason for HU switching off
+ */
+ void SetUnregisterAllApplicationsReason(
mobile_api::AppInterfaceUnregisteredReason::eType reason);
- /*
- * @brief Called on Master_reset or Factory_defaults
- * when User chooses to reset HU.
- * Resets Policy Table if applicable.
- */
- void HeadUnitReset(
- mobile_api::AppInterfaceUnregisteredReason::eType reason);
-
- /*
- * @brief Closes all registered applications
- */
- void UnregisterAllApplications();
-
- bool RemoveAppDataFromHMI(ApplicationSharedPtr app);
- bool LoadAppDataToHMI(ApplicationSharedPtr app);
- bool ActivateApplication(ApplicationSharedPtr app);
-
- /**
- * @brief Put application in FULL HMI Level if possible,
- * otherwise put applicatuion other HMI level.
- * do not send any notifications to mobile
- * @param app, application, that need to be puted in FULL
- * @return seted HMI Level
- */
- mobile_api::HMILevel::eType IsHmiLevelFullAllowed(ApplicationSharedPtr app);
-
- void ConnectToDevice(const std::string& device_mac);
- void OnHMIStartedCooperation();
-
- /*
- * @brief Returns unique correlation ID for HMI request
- *
- * @return Unique correlation ID
- */
- uint32_t GetNextHMICorrelationID();
-
- /* @brief Starts audio passthru process
- *
- * @return true on success, false if passthru is already in process
- */
- bool begin_audio_pass_thru();
-
- /*
- * @brief Finishes already started audio passthru process
- *
- * @return true on success, false if passthru is not active
- */
- bool end_audio_pass_thru();
-
- /*
- * @brief Retrieves driver distraction state
- *
- * @return Current state of the distraction state
- */
- inline bool driver_distraction() const;
-
- /*
- * @brief Sets state for driver distraction
- *
- * @param state New state to be set
- */
- void set_driver_distraction(bool is_distracting);
-
- /*
- * @brief Retrieves if VR session has started
- *
- * @return Current VR session state (started, stopped)
- */
- inline bool vr_session_started() const;
-
- /*
- * @brief Sets VR session state
- *
- * @param state Current HMI VR session state
- */
- void set_vr_session_started(const bool& state);
-
- /*
- * @brief Retrieves SDL access to all mobile apps
- *
- * @return Currently active state of the access
- */
- inline bool all_apps_allowed() const;
-
- /*
- * @brief Sets SDL access to all mobile apps
- *
- * @param allowed SDL access to all mobile apps
- */
- void set_all_apps_allowed(const bool& allowed);
-
- /**
- * @brief CreateRegularState create regular HMI state for application
- * @param app_id
- * @param hmi_level of returned state
- * @param audio_state of returned state
- * @param system_context of returned state
- * @return new regular HMI state
- */
- HmiStatePtr CreateRegularState(
- uint32_t app_id, mobile_apis::HMILevel::eType hmi_level,
- mobile_apis::AudioStreamingState::eType audio_state,
- mobile_apis::SystemContext::eType system_context) const;
-
- /**
- * @brief SetState set regular audio state
- * @param app_id applicatio id
- * @param audio_state aaudio streaming state
- */
- void SetState(uint32_t app_id,
- mobile_apis::AudioStreamingState::eType audio_state) {
- ApplicationSharedPtr app = application(app_id);
- if (!app) {
- LOG4CXX_ERROR(logger_, "Application with appID="<<app_id<<" does not exist");
- return;
- }
- state_ctrl_.SetRegularState(app, audio_state);
+ /*
+ * @brief Called on Master_reset or Factory_defaults
+ * when User chooses to reset HU.
+ * Resets Policy Table if applicable.
+ */
+ void HeadUnitReset(mobile_api::AppInterfaceUnregisteredReason::eType reason);
+
+ /*
+ * @brief Closes all registered applications
+ */
+ void UnregisterAllApplications();
+
+ bool RemoveAppDataFromHMI(ApplicationSharedPtr app);
+ bool LoadAppDataToHMI(ApplicationSharedPtr app);
+ bool ActivateApplication(ApplicationSharedPtr app);
+
+ /**
+ * @brief Put application in FULL HMI Level if possible,
+ * otherwise put applicatuion other HMI level.
+ * do not send any notifications to mobile
+ * @param app, application, that need to be puted in FULL
+ * @return seted HMI Level
+ */
+ mobile_api::HMILevel::eType IsHmiLevelFullAllowed(ApplicationSharedPtr app);
+
+ void ConnectToDevice(const std::string &device_mac);
+ void OnHMIStartedCooperation();
+
+ /*
+ * @brief Returns unique correlation ID for HMI request
+ *
+ * @return Unique correlation ID
+ */
+ uint32_t GetNextHMICorrelationID();
+
+ /* @brief Starts audio passthru process
+ *
+ * @return true on success, false if passthru is already in process
+ */
+ bool begin_audio_pass_thru();
+
+ /*
+ * @brief Finishes already started audio passthru process
+ *
+ * @return true on success, false if passthru is not active
+ */
+ bool end_audio_pass_thru();
+
+ /*
+ * @brief Retrieves driver distraction state
+ *
+ * @return Current state of the distraction state
+ */
+ inline bool driver_distraction() const;
+
+ /*
+ * @brief Sets state for driver distraction
+ *
+ * @param state New state to be set
+ */
+ void set_driver_distraction(bool is_distracting);
+
+ /*
+ * @brief Retrieves if VR session has started
+ *
+ * @return Current VR session state (started, stopped)
+ */
+ inline bool vr_session_started() const;
+
+ /*
+ * @brief Sets VR session state
+ *
+ * @param state Current HMI VR session state
+ */
+ void set_vr_session_started(const bool &state);
+
+ /*
+ * @brief Retrieves SDL access to all mobile apps
+ *
+ * @return Currently active state of the access
+ */
+ inline bool all_apps_allowed() const;
+
+ /*
+ * @brief Sets SDL access to all mobile apps
+ *
+ * @param allowed SDL access to all mobile apps
+ */
+ void set_all_apps_allowed(const bool &allowed);
+
+ /**
+ * @brief CreateRegularState create regular HMI state for application
+ * @param app_id
+ * @param hmi_level of returned state
+ * @param audio_state of returned state
+ * @param system_context of returned state
+ * @return new regular HMI state
+ */
+ HmiStatePtr
+ CreateRegularState(uint32_t app_id, mobile_apis::HMILevel::eType hmi_level,
+ mobile_apis::AudioStreamingState::eType audio_state,
+ mobile_apis::SystemContext::eType system_context) const;
+
+ /**
+ * @brief SetState set regular audio state
+ * @param app_id applicatio id
+ * @param audio_state aaudio streaming state
+ */
+ void SetState(uint32_t app_id,
+ mobile_apis::AudioStreamingState::eType audio_state) {
+ ApplicationSharedPtr app = application(app_id);
+ if (!app) {
+ LOG4CXX_ERROR(logger_, "Application with appID=" << app_id
+ << " does not exist");
+ return;
}
+ state_ctrl_.SetRegularState(app, audio_state);
+ }
- /**
- * @brief SetState setup regular hmi state, tha will appear if no
- * specific events are active
- * @param app appication to setup regular State
- * @param state state of new regular state
- */
- template <bool SendActivateApp>
- void SetState(uint32_t app_id,
- HmiStatePtr new_state) {
- ApplicationSharedPtr app = application(app_id);
- if (!app) {
- LOG4CXX_ERROR(logger_, "Application with appID="<<app_id<<" does not exist");
- return;
- }
- state_ctrl_.SetRegularState<SendActivateApp>(app, new_state);
+ /**
+ * @brief SetState setup regular hmi state, tha will appear if no
+ * specific events are active
+ * @param app appication to setup regular State
+ * @param state state of new regular state
+ */
+ template <bool SendActivateApp>
+ void SetState(uint32_t app_id, HmiStatePtr new_state) {
+ ApplicationSharedPtr app = application(app_id);
+ if (!app) {
+ LOG4CXX_ERROR(logger_, "Application with appID=" << app_id
+ << " does not exist");
+ return;
}
+ state_ctrl_.SetRegularState<SendActivateApp>(app, new_state);
+ }
- /**
- * @brief SetState Change regular audio state
- * @param app appication to setup regular State
- * @param audio_state of new regular state
- */
- template <bool SendActivateApp>
- void SetState(uint32_t app_id,
- mobile_apis::HMILevel::eType hmi_level){
- ApplicationSharedPtr app = application(app_id);
- if (!app) {
- LOG4CXX_ERROR(logger_, "Application with appID="<<app_id<<" does not exist");
- return;
- }
- state_ctrl_.SetRegularState<SendActivateApp>(app, hmi_level);
+ /**
+ * @brief SetState Change regular audio state
+ * @param app appication to setup regular State
+ * @param audio_state of new regular state
+ */
+ template <bool SendActivateApp>
+ void SetState(uint32_t app_id, mobile_apis::HMILevel::eType hmi_level) {
+ ApplicationSharedPtr app = application(app_id);
+ if (!app) {
+ LOG4CXX_ERROR(logger_, "Application with appID=" << app_id
+ << " does not exist");
+ return;
}
+ state_ctrl_.SetRegularState<SendActivateApp>(app, hmi_level);
+ }
- /**
- * @brief SetState Change regular hmi level and audio state
- * @param app appication to setup regular State
- * @param hmi_level of new regular state
- * @param audio_state of new regular state
- * @param SendActivateApp: if true, ActivateAppRequest will be sent on HMI
- */
- template <bool SendActivateApp>
- void SetState(uint32_t app_id,
- mobile_apis::HMILevel::eType hmi_level,
- mobile_apis::AudioStreamingState::eType audio_state){
- ApplicationSharedPtr app = application(app_id);
- if (!app) {
- LOG4CXX_ERROR(logger_, "Application with appID="<<app_id<<" does not exist");
- return;
- }
- state_ctrl_.SetRegularState<SendActivateApp>(app, hmi_level, audio_state);
+ /**
+ * @brief SetState Change regular hmi level and audio state
+ * @param app appication to setup regular State
+ * @param hmi_level of new regular state
+ * @param audio_state of new regular state
+ * @param SendActivateApp: if true, ActivateAppRequest will be sent on HMI
+ */
+ template <bool SendActivateApp>
+ void SetState(uint32_t app_id, mobile_apis::HMILevel::eType hmi_level,
+ mobile_apis::AudioStreamingState::eType audio_state) {
+ ApplicationSharedPtr app = application(app_id);
+ if (!app) {
+ LOG4CXX_ERROR(logger_, "Application with appID=" << app_id
+ << " does not exist");
+ return;
}
+ state_ctrl_.SetRegularState<SendActivateApp>(app, hmi_level, audio_state);
+ }
- /**
- * @brief SetState Change regular hmi level and audio state
- * @param app appication to setup regular State
- * @param hmi_level of new regular state
- * @param audio_state of new regular state
- * @param SendActivateApp: if true, ActivateAppRequest will be sent on HMI
- */
- template <bool SendActivateApp>
- void SetState(uint32_t app_id, mobile_apis::HMILevel::eType hmi_level,
- mobile_apis::AudioStreamingState::eType audio_state,
- mobile_apis::SystemContext::eType system_context) {
- ApplicationSharedPtr app = application(app_id);
- if (!app) {
- LOG4CXX_ERROR(logger_, "Application with appID="<<app_id<<" does not exist");
- return;
- }
- state_ctrl_.SetRegularState<SendActivateApp>(app, hmi_level,
- audio_state, system_context);
+ /**
+ * @brief SetState Change regular hmi level and audio state
+ * @param app appication to setup regular State
+ * @param hmi_level of new regular state
+ * @param audio_state of new regular state
+ * @param SendActivateApp: if true, ActivateAppRequest will be sent on HMI
+ */
+ template <bool SendActivateApp>
+ void SetState(uint32_t app_id, mobile_apis::HMILevel::eType hmi_level,
+ mobile_apis::AudioStreamingState::eType audio_state,
+ mobile_apis::SystemContext::eType system_context) {
+ ApplicationSharedPtr app = application(app_id);
+ if (!app) {
+ LOG4CXX_ERROR(logger_, "Application with appID=" << app_id
+ << " does not exist");
+ return;
}
+ state_ctrl_.SetRegularState<SendActivateApp>(app, hmi_level, audio_state,
+ system_context);
+ }
- /**
- * @brief SetState Change regular system context
- * @param app appication to setup regular State
- * @param system_context of new regular state
- */
- void SetState(uint32_t app_id,
- mobile_apis::SystemContext::eType system_context) {
- ApplicationSharedPtr app = application(app_id);
- if (!app) {
- LOG4CXX_ERROR(logger_, "Application with appID="<<app_id<<" does not exist");
- return;
- }
- state_ctrl_.SetRegularState(app, system_context);
+ /**
+ * @brief SetState Change regular system context
+ * @param app appication to setup regular State
+ * @param system_context of new regular state
+ */
+ void SetState(uint32_t app_id,
+ mobile_apis::SystemContext::eType system_context) {
+ ApplicationSharedPtr app = application(app_id);
+ if (!app) {
+ LOG4CXX_ERROR(logger_, "Application with appID=" << app_id
+ << " does not exist");
+ return;
}
+ state_ctrl_.SetRegularState(app, system_context);
+ }
- /**
- * @brief Notification from PolicyHandler about PTU.
- * Compares AppHMIType between saved in app and received from PTU. If they are different method sends:
- * UI_ChangeRegistration with list new AppHMIType;
- * ActivateApp with HMI level BACKGROUND;
- * OnHMIStatus notification;
- * for app with HMI level FULL or LIMITED.
- * method sends:
- * UI_ChangeRegistration with list new AppHMIType
- * for app with HMI level BACKGROUND.
- */
- virtual void OnUpdateHMIAppType(std::map<std::string, std::vector<std::string> > app_hmi_types);
-
- /*
- * @brief Starts audio pass thru thread
- *
- * @param session_key Session key of connection for Mobile side
- * @param correlation_id Correlation id for response for Mobile side
- * @param max_duration Max duration of audio recording in milliseconds
- * @param sampling_rate Value for rate(8, 16, 22, 44 kHz)
- * @param bits_per_sample The quality the audio is recorded.
- * @param audio_type Type of audio data
- */
- void StartAudioPassThruThread(int32_t session_key, int32_t correlation_id,
- int32_t max_duration, int32_t sampling_rate,
- int32_t bits_per_sample, int32_t audio_type);
-
- /*
- * @brief Terminates audio pass thru thread
- * @param application_key Id of application for which
- * audio pass thru should be stopped
- */
- void StopAudioPassThru(int32_t application_key);
-
- /*
- * @brief Creates AudioPassThru data chunk and inserts it
- * to audio_pass_thru_messages_
- *
- * @param session_key Id of application for which
- * audio pass thru should be sent
- *
- * @param binary_data AudioPassThru data chunk
- */
- void SendAudioPassThroughNotification(uint32_t session_key,
- std::vector<uint8_t>& binary_data);
-
- std::string GetDeviceName(connection_handler::DeviceHandle handle);
-
- /*
- * @brief Converts connection string transport type representation
- * to HMI Common_TransportType
- *
- * @param transport_type String representing connection type
- *
- * @return Corresponding HMI TransporType value
- */
- hmi_apis::Common_TransportType::eType GetDeviceTransportType(
- const std::string& transport_type);
-
- /////////////////////////////////////////////////////
-
- void set_hmi_message_handler(hmi_message_handler::HMIMessageHandler* handler);
- void set_connection_handler(connection_handler::ConnectionHandler* handler);
- void set_protocol_handler(protocol_handler::ProtocolHandler* handler);
-
- ///////////////////////////////////////////////////////
-
- void StartDevicesDiscovery();
-
- // Put message to the queue to be sent to mobile.
- // if |final_message| parameter is set connection to mobile will be closed
- // after processing this message
- void SendMessageToMobile(const commands::MessageSharedPtr message,
- bool final_message = false);
-
- /**
- * @brief TerminateRequest forces termination of request
- * @param connection_key - application id of request
- * @param corr_id correlation id of request
- */
- void TerminateRequest(uint32_t connection_key, uint32_t corr_id);
-
- bool ManageMobileCommand(
- const commands::MessageSharedPtr message,
- commands::Command::CommandOrigin origin =
- commands::Command::ORIGIN_SDL);
- void SendMessageToHMI(const commands::MessageSharedPtr message);
- bool ManageHMICommand(const commands::MessageSharedPtr message);
-
- /////////////////////////////////////////////////////////
- // Overriden ProtocolObserver method
- virtual void OnMessageReceived(
- const ::protocol_handler::RawMessagePtr message) OVERRIDE;
- virtual void OnMobileMessageSent(
- const ::protocol_handler::RawMessagePtr message) OVERRIDE;
-
- // Overriden HMIMessageObserver method
- void OnMessageReceived(hmi_message_handler::MessageSharedPointer message) OVERRIDE;
- void OnErrorSending(hmi_message_handler::MessageSharedPointer message) OVERRIDE;
-
- // Overriden ConnectionHandlerObserver method
- void OnDeviceListUpdated(const connection_handler::DeviceMap& device_list) OVERRIDE;
- //TODO (EZamakhov): fix all indentations in this file
- void OnFindNewApplicationsRequest() OVERRIDE;
- void RemoveDevice(const connection_handler::DeviceHandle& device_handle) OVERRIDE;
- bool OnServiceStartedCallback(
- const connection_handler::DeviceHandle& device_handle,
- const int32_t& session_key, const protocol_handler::ServiceType& type) OVERRIDE;
- void OnServiceEndedCallback(
- const int32_t& session_key,
- const protocol_handler::ServiceType& type,
- const connection_handler::CloseSessionReason& close_reason) OVERRIDE;
-
- /**
- * @ Add notification to collection
- *
- * @param ptr Reference to shared pointer that point on hmi notification
- */
- void addNotification(const CommandSharedPtr ptr);
-
- /**
- * @ Add notification to collection
- *
- * @param ptr Reference to shared pointer that point on hmi notification
- */
- void removeNotification(const commands::Command* notification);
-
- /**
- * @ Updates request timeout
- *
- * @param connection_key Connection key of application
- * @param mobile_correlation_id Correlation ID of the mobile request
- * @param new_timeout_value New timeout in milliseconds to be set
- */
- void updateRequestTimeout(uint32_t connection_key,
- uint32_t mobile_correlation_id,
- uint32_t new_timeout_value);
-
- /*
- * @brief Retrieves application id associated whith correlation id
- *
- * @param correlation_id Correlation ID of the HMI request
- *
- * @return application id associated whith correlation id
- */
- const uint32_t application_id(const int32_t correlation_id);
-
- /*
- * @brief Sets application id correlation id
- *
- * @param correlation_id Correlation ID of the HMI request
- * @param app_id Application ID
- */
- void set_application_id(const int32_t correlation_id, const uint32_t app_id);
-
- /**
- * @brief AddPolicyObserver allows to subscribe needed component to events
- * from policy.
- *
- * @param listener the component to subscribe.
- */
- void AddPolicyObserver(PolicyHandlerObserver* listener);
-
- /**
- * @brief RemovePolicyObserver allows to remove observer from collection.
- *
- * @param listener observer to remove.
- */
- void RemovePolicyObserver(PolicyHandlerObserver* listener);
-
- /**
- * @brief Checks HMI level and returns true if streaming is allowed
- * @param app_id Application id
- * @param service_type Service type to check
- * @return True if streaming is allowed, false in other case
- */
- bool HMILevelAllowsStreaming(
- uint32_t app_id, protocol_handler::ServiceType service_type) const;
-
- /**
- * @brief Checks if application can stream (streaming service is started and
- * streaming is enabled in application)
- * @param app_id Application id
- * @param service_type Service type to check
- * @return True if streaming is allowed, false in other case
- */
- bool CanAppStream(
- uint32_t app_id, protocol_handler::ServiceType service_type) const;
-
- /**
- * @brief Ends opened navi services (audio/video) for application
- * @param app_id Application id
- */
- void EndNaviServices(uint32_t app_id);
-
- /**
- * @brief ForbidStreaming forbid the stream over the certain application.
- * @param app_id the application's id which should stop streaming.
- */
- void ForbidStreaming(uint32_t app_id);
-
- /**
- * @brief Callback calls when application starts/stops data streaming
- * @param app_id Streaming application id
- * @param service_type Streaming service type
- * @param state Shows if streaming started or stopped
- */
- void OnAppStreaming(
- uint32_t app_id, protocol_handler::ServiceType service_type, bool state);
-
- /**
- * @brief OnHMILevelChanged the callback that allows SDL to react when
- * application's HMILeval has been changed.
- *
- * @param app_id application identifier for which HMILevel has been chaned.
- *
- * @param from previous HMILevel.
- * @param to current HMILevel.
- */
- void OnHMILevelChanged(uint32_t app_id,
- mobile_apis::HMILevel::eType from,
- mobile_apis::HMILevel::eType to);
-
- mobile_api::HMILevel::eType GetDefaultHmiLevel(
- ApplicationSharedPtr application) const;
-
- /**
- * Getter for resume_controller
- * @return Resume Controller
- */
- ResumeCtrl& resume_controller() {
- return resume_ctrl_;
+ /**
+ * @brief Notification from PolicyHandler about PTU.
+ * Compares AppHMIType between saved in app and received from PTU. If they are
+ * different method sends:
+ * UI_ChangeRegistration with list new AppHMIType;
+ * ActivateApp with HMI level BACKGROUND;
+ * OnHMIStatus notification;
+ * for app with HMI level FULL or LIMITED.
+ * method sends:
+ * UI_ChangeRegistration with list new AppHMIType
+ * for app with HMI level BACKGROUND.
+ */
+ virtual void OnUpdateHMIAppType(
+ std::map<std::string, std::vector<std::string>> app_hmi_types);
+
+ /*
+ * @brief Starts audio pass thru thread
+ *
+ * @param session_key Session key of connection for Mobile side
+ * @param correlation_id Correlation id for response for Mobile side
+ * @param max_duration Max duration of audio recording in milliseconds
+ * @param sampling_rate Value for rate(8, 16, 22, 44 kHz)
+ * @param bits_per_sample The quality the audio is recorded.
+ * @param audio_type Type of audio data
+ */
+ void StartAudioPassThruThread(int32_t session_key, int32_t correlation_id,
+ int32_t max_duration, int32_t sampling_rate,
+ int32_t bits_per_sample, int32_t audio_type);
+
+ /*
+ * @brief Terminates audio pass thru thread
+ * @param application_key Id of application for which
+ * audio pass thru should be stopped
+ */
+ void StopAudioPassThru(int32_t application_key);
+
+ /*
+ * @brief Creates AudioPassThru data chunk and inserts it
+ * to audio_pass_thru_messages_
+ *
+ * @param session_key Id of application for which
+ * audio pass thru should be sent
+ *
+ * @param binary_data AudioPassThru data chunk
+ */
+ void SendAudioPassThroughNotification(uint32_t session_key,
+ std::vector<uint8_t> &binary_data);
+
+ std::string GetDeviceName(connection_handler::DeviceHandle handle);
+
+ /*
+ * @brief Converts connection string transport type representation
+ * to HMI Common_TransportType
+ *
+ * @param transport_type String representing connection type
+ *
+ * @return Corresponding HMI TransporType value
+ */
+ hmi_apis::Common_TransportType::eType
+ GetDeviceTransportType(const std::string &transport_type);
+
+ /////////////////////////////////////////////////////
+
+ void set_hmi_message_handler(hmi_message_handler::HMIMessageHandler *handler);
+ void set_connection_handler(connection_handler::ConnectionHandler *handler);
+ void set_protocol_handler(protocol_handler::ProtocolHandler *handler);
+
+ ///////////////////////////////////////////////////////
+
+ void StartDevicesDiscovery();
+
+ // Put message to the queue to be sent to mobile.
+ // if |final_message| parameter is set connection to mobile will be closed
+ // after processing this message
+ void SendMessageToMobile(const commands::MessageSharedPtr message,
+ bool final_message = false);
+
+ /**
+ * @brief TerminateRequest forces termination of request
+ * @param connection_key - application id of request
+ * @param corr_id correlation id of request
+ */
+ void TerminateRequest(uint32_t connection_key, uint32_t corr_id);
+
+ bool ManageMobileCommand(
+ const commands::MessageSharedPtr message,
+ commands::Command::CommandOrigin origin = commands::Command::ORIGIN_SDL);
+ void SendMessageToHMI(const commands::MessageSharedPtr message);
+ bool ManageHMICommand(const commands::MessageSharedPtr message);
+
+ /////////////////////////////////////////////////////////
+ // Overriden ProtocolObserver method
+ virtual void
+ OnMessageReceived(const ::protocol_handler::RawMessagePtr message) OVERRIDE;
+ virtual void
+ OnMobileMessageSent(const ::protocol_handler::RawMessagePtr message) OVERRIDE;
+
+ // Overriden HMIMessageObserver method
+ void
+ OnMessageReceived(hmi_message_handler::MessageSharedPointer message) OVERRIDE;
+ void
+ OnErrorSending(hmi_message_handler::MessageSharedPointer message) OVERRIDE;
+
+ // Overriden ConnectionHandlerObserver method
+ void OnDeviceListUpdated(
+ const connection_handler::DeviceMap &device_list) OVERRIDE;
+ // TODO (EZamakhov): fix all indentations in this file
+ void OnFindNewApplicationsRequest() OVERRIDE;
+ void
+ RemoveDevice(const connection_handler::DeviceHandle &device_handle) OVERRIDE;
+ bool OnServiceStartedCallback(
+ const connection_handler::DeviceHandle &device_handle,
+ const int32_t &session_key,
+ const protocol_handler::ServiceType &type) OVERRIDE;
+ void OnServiceEndedCallback(
+ const int32_t &session_key, const protocol_handler::ServiceType &type,
+ const connection_handler::CloseSessionReason &close_reason) OVERRIDE;
+
+ /**
+ * @ Add notification to collection
+ *
+ * @param ptr Reference to shared pointer that point on hmi notification
+ */
+ void addNotification(const CommandSharedPtr ptr);
+
+ /**
+ * @ Add notification to collection
+ *
+ * @param ptr Reference to shared pointer that point on hmi notification
+ */
+ void removeNotification(const commands::Command *notification);
+
+ /**
+ * @ Updates request timeout
+ *
+ * @param connection_key Connection key of application
+ * @param mobile_correlation_id Correlation ID of the mobile request
+ * @param new_timeout_value New timeout in milliseconds to be set
+ */
+ void updateRequestTimeout(uint32_t connection_key,
+ uint32_t mobile_correlation_id,
+ uint32_t new_timeout_value);
+
+ /*
+ * @brief Retrieves application id associated whith correlation id
+ *
+ * @param correlation_id Correlation ID of the HMI request
+ *
+ * @return application id associated whith correlation id
+ */
+ const uint32_t application_id(const int32_t correlation_id);
+
+ /*
+ * @brief Sets application id correlation id
+ *
+ * @param correlation_id Correlation ID of the HMI request
+ * @param app_id Application ID
+ */
+ void set_application_id(const int32_t correlation_id, const uint32_t app_id);
+
+ /**
+ * @brief AddPolicyObserver allows to subscribe needed component to events
+ * from policy.
+ *
+ * @param listener the component to subscribe.
+ */
+ void AddPolicyObserver(PolicyHandlerObserver *listener);
+
+ /**
+ * @brief RemovePolicyObserver allows to remove observer from collection.
+ *
+ * @param listener observer to remove.
+ */
+ void RemovePolicyObserver(PolicyHandlerObserver *listener);
+
+ /**
+ * @brief Checks HMI level and returns true if streaming is allowed
+ * @param app_id Application id
+ * @param service_type Service type to check
+ * @return True if streaming is allowed, false in other case
+ */
+ bool
+ HMILevelAllowsStreaming(uint32_t app_id,
+ protocol_handler::ServiceType service_type) const;
+
+ /**
+ * @brief Checks if application can stream (streaming service is started and
+ * streaming is enabled in application)
+ * @param app_id Application id
+ * @param service_type Service type to check
+ * @return True if streaming is allowed, false in other case
+ */
+ bool CanAppStream(uint32_t app_id,
+ protocol_handler::ServiceType service_type) const;
+
+ /**
+ * @brief Ends opened navi services (audio/video) for application
+ * @param app_id Application id
+ */
+ void EndNaviServices(uint32_t app_id);
+
+ /**
+ * @brief ForbidStreaming forbid the stream over the certain application.
+ * @param app_id the application's id which should stop streaming.
+ */
+ void ForbidStreaming(uint32_t app_id);
+
+ /**
+ * @brief Callback calls when application starts/stops data streaming
+ * @param app_id Streaming application id
+ * @param service_type Streaming service type
+ * @param state Shows if streaming started or stopped
+ */
+ void OnAppStreaming(uint32_t app_id,
+ protocol_handler::ServiceType service_type, bool state);
+
+ /**
+ * @brief OnHMILevelChanged the callback that allows SDL to react when
+ * application's HMILeval has been changed.
+ *
+ * @param app_id application identifier for which HMILevel has been chaned.
+ *
+ * @param from previous HMILevel.
+ * @param to current HMILevel.
+ */
+ void OnHMILevelChanged(uint32_t app_id, mobile_apis::HMILevel::eType from,
+ mobile_apis::HMILevel::eType to);
+
+ mobile_api::HMILevel::eType
+ GetDefaultHmiLevel(ApplicationSharedPtr application) const;
+
+ /**
+ * Getter for resume_controller
+ * @return Resume Controller
+ */
+ ResumeCtrl &resume_controller() { return resume_ctrl_; }
+
+ /**
+ * Generate grammar ID
+ *
+ * @return New grammar ID
+ */
+ uint32_t GenerateGrammarID();
+
+ /**
+ * Generate new HMI application ID
+ *
+ * @return New HMI application ID
+ */
+ uint32_t GenerateNewHMIAppID();
+
+ /**
+ * @brief Parse smartObject and replace mobile app Id by HMI app ID
+ *
+ * @param message Smartobject to be parsed
+ */
+ void ReplaceMobileByHMIAppId(smart_objects::SmartObject &message);
+
+ /**
+ * @brief Parse smartObject and replace HMI app ID by mobile app Id
+ *
+ * @param message Smartobject to be parsed
+ */
+ void ReplaceHMIByMobileAppId(smart_objects::SmartObject &message);
+
+ /*
+ * @brief Save binary data to specified directory
+ *
+ * @param binary data
+ * @param path for saving data
+ * @param file_name File name
+ * @param offset for saving data to existing file with offset.
+ * If offset is 0 - create new file ( overrite existing )
+ *
+ *
+ * @return SUCCESS if file was saved, other code otherwise
+ */
+ mobile_apis::Result::eType SaveBinary(const std::vector<uint8_t> &binary_data,
+ const std::string &file_path,
+ const std::string &file_name,
+ const int64_t offset);
+
+ /**
+ * @brief Get available app space
+ * @param name of the app folder(make + mobile app id)
+ * @return free app space.
+ */
+ uint32_t GetAvailableSpaceForApp(const std::string &folder_name);
+
+ /*
+ * @brief returns true if HMI is cooperating
+ */
+ bool IsHMICooperating() const;
+
+ /**
+ * @brief Method used to send default app tts globalProperties
+ * in case they were not provided from mobile side after defined time
+ */
+ void OnTimerSendTTSGlobalProperties();
+
+ /**
+ * @brief method adds application
+ * to tts_global_properties_app_list_
+ * @param app_id contains application which will
+ * send TTS global properties after timeout
+ */
+ void AddAppToTTSGlobalPropertiesList(const uint32_t app_id);
+
+ /**
+ * @brief method removes application
+ * from tts_global_properties_app_list_
+ * @param app_id contains application which will
+ * send TTS global properties after timeout
+ */
+ void RemoveAppFromTTSGlobalPropertiesList(const uint32_t app_id);
+
+ /**
+ * @brief method adds application in FULL and LIMITED state
+ * to on_phone_call_app_list_.
+ * Also OnHMIStateNotification with BACKGROUND state sent for these apps
+ */
+ void CreatePhoneCallAppList();
+
+ /**
+ * @brief method removes application from on_phone_call_app_list_.
+ *
+ * Also OnHMIStateNotification with previous HMI state sent for these apps
+ */
+ void ResetPhoneCallAppList();
+
+ /**
+ * Function used only by HMI request/response/notification base classes
+ * to change HMI app id to Mobile app id and vice versa.
+ * Dot use it inside Core
+ */
+ ApplicationSharedPtr application_by_hmi_app(uint32_t hmi_app_id) const;
+
+ // TODO(AOleynik): Temporary added, to fix build. Should be reworked.
+ connection_handler::ConnectionHandler *connection_handler();
+
+ /**
+ * @brief Checks, if given RPC is allowed at current HMI level for specific
+ * application in policy table
+ * @param policy_app_id Application id
+ * @param hmi_level Current HMI level of application
+ * @param function_id FunctionID of RPC
+ * @param params_permissions Permissions for RPC parameters (e.g.
+ * SubscribeVehicleData) defined in policy table
+ * @return SUCCESS, if allowed, otherwise result code of check
+ */
+ mobile_apis::Result::eType CheckPolicyPermissions(
+ const std::string &policy_app_id, mobile_apis::HMILevel::eType hmi_level,
+ mobile_apis::FunctionID::eType function_id, const RPCParams &rpc_params,
+ CommandParametersPermissions *params_permissions = NULL);
+ /*
+ * @brief Function Should be called when Low Voltage is occured
+ */
+ void OnLowVoltage();
+
+ /*
+ * @brief Function Should be called when WakeUp occures after Low Voltage
+ */
+ void OnWakeUp();
+
+ struct ApplicationsAppIdSorter {
+ bool operator()(const ApplicationSharedPtr lhs,
+ const ApplicationSharedPtr rhs) {
+ return lhs->app_id() < rhs->app_id();
}
+ };
- /**
- * Generate grammar ID
- *
- * @return New grammar ID
- */
- uint32_t GenerateGrammarID();
-
- /**
- * Generate new HMI application ID
- *
- * @return New HMI application ID
- */
- uint32_t GenerateNewHMIAppID();
-
- /**
- * @brief Parse smartObject and replace mobile app Id by HMI app ID
- *
- * @param message Smartobject to be parsed
- */
- void ReplaceMobileByHMIAppId(
- smart_objects::SmartObject& message);
+ struct ApplicationsMobileAppIdSorter {
+ bool operator()(const ApplicationSharedPtr lhs,
+ const ApplicationSharedPtr rhs) {
- /**
- * @brief Parse smartObject and replace HMI app ID by mobile app Id
- *
- * @param message Smartobject to be parsed
- */
- void ReplaceHMIByMobileAppId(
- smart_objects::SmartObject& message);
-
- /*
- * @brief Save binary data to specified directory
- *
- * @param binary data
- * @param path for saving data
- * @param file_name File name
- * @param offset for saving data to existing file with offset.
- * If offset is 0 - create new file ( overrite existing )
- *
- *
- * @return SUCCESS if file was saved, other code otherwise
- */
- mobile_apis::Result::eType SaveBinary(
- const std::vector<uint8_t>& binary_data,
- const std::string& file_path,
- const std::string& file_name,
- const int64_t offset);
-
- /**
- * @brief Get available app space
- * @param name of the app folder(make + mobile app id)
- * @return free app space.
- */
- uint32_t GetAvailableSpaceForApp(const std::string& folder_name);
+ if (lhs->mobile_app_id() == rhs->mobile_app_id()) {
+ return lhs->device() < rhs->device();
+ }
+ return lhs->mobile_app_id() < rhs->mobile_app_id();
+ }
+ };
- /*
- * @brief returns true if HMI is cooperating
- */
- bool IsHMICooperating() const;
+ // typedef for Applications list
+ typedef std::set<ApplicationSharedPtr, ApplicationsAppIdSorter> ApplictionSet;
- /**
- * @brief Method used to send default app tts globalProperties
- * in case they were not provided from mobile side after defined time
- */
- void OnTimerSendTTSGlobalProperties();
+ typedef std::multiset<ApplicationSharedPtr, ApplicationsMobileAppIdSorter>
+ AppsWaitRegistrationSet;
- /**
- * @brief method adds application
- * to tts_global_properties_app_list_
- * @param app_id contains application which will
- * send TTS global properties after timeout
- */
- void AddAppToTTSGlobalPropertiesList(const uint32_t app_id);
+ // typedef for Applications list iterator
+ typedef ApplictionSet::iterator ApplictionSetIt;
- /**
- * @brief method removes application
- * from tts_global_properties_app_list_
- * @param app_id contains application which will
- * send TTS global properties after timeout
- */
- void RemoveAppFromTTSGlobalPropertiesList(const uint32_t app_id);
+ // typedef for Applications list const iterator
+ typedef ApplictionSet::const_iterator ApplictionSetConstIt;
- /**
- * @brief method adds application in FULL and LIMITED state
- * to on_phone_call_app_list_.
- * Also OnHMIStateNotification with BACKGROUND state sent for these apps
- */
- void CreatePhoneCallAppList();
+ DataAccessor<AppsWaitRegistrationSet> apps_waiting_for_registration() const;
+ ApplicationConstSharedPtr waiting_app(const uint32_t hmi_id) const;
+ /**
+ * Class for thread-safe access to applications list
+ */
+ class ApplicationListAccessor : public DataAccessor<ApplictionSet> {
+ public:
/**
- * @brief method removes application from on_phone_call_app_list_.
- *
- * Also OnHMIStateNotification with previous HMI state sent for these apps
+ * @brief ApplicationListAccessor class constructor
*/
- void ResetPhoneCallAppList();
+ ApplicationListAccessor()
+ : DataAccessor<ApplictionSet>(
+ ApplicationManagerImpl::instance()->applications_,
+ ApplicationManagerImpl::instance()->applications_list_lock_) {}
- /**
- * Function used only by HMI request/response/notification base classes
- * to change HMI app id to Mobile app id and vice versa.
- * Dot use it inside Core
- */
- ApplicationSharedPtr application_by_hmi_app(uint32_t hmi_app_id) const;
-
- // TODO(AOleynik): Temporary added, to fix build. Should be reworked.
- connection_handler::ConnectionHandler* connection_handler();
+ ~ApplicationListAccessor();
/**
- * @brief Checks, if given RPC is allowed at current HMI level for specific
- * application in policy table
- * @param policy_app_id Application id
- * @param hmi_level Current HMI level of application
- * @param function_id FunctionID of RPC
- * @param params_permissions Permissions for RPC parameters (e.g.
- * SubscribeVehicleData) defined in policy table
- * @return SUCCESS, if allowed, otherwise result code of check
- */
- mobile_apis::Result::eType CheckPolicyPermissions(
- const std::string& policy_app_id,
- mobile_apis::HMILevel::eType hmi_level,
- mobile_apis::FunctionID::eType function_id,
- const RPCParams& rpc_params,
- CommandParametersPermissions* params_permissions = NULL);
- /*
- * @brief Function Should be called when Low Voltage is occured
+ * @brief thread-safe getter for applications
+ * @return applications list
*/
- void OnLowVoltage();
+ const ApplictionSet &applications() const { return GetData(); }
- /*
- * @brief Function Should be called when WakeUp occures after Low Voltage
- */
- void OnWakeUp();
-
- struct ApplicationsAppIdSorter {
- bool operator() (const ApplicationSharedPtr lhs,
- const ApplicationSharedPtr rhs) {
- return lhs->app_id() < rhs->app_id();
- }
- };
+ ApplictionSetConstIt begin() { return applications().begin(); }
- struct ApplicationsMobileAppIdSorter {
- bool operator() (const ApplicationSharedPtr lhs,
- const ApplicationSharedPtr rhs) {
+ ApplictionSetConstIt end() { return applications().end(); }
- if (lhs->mobile_app_id() == rhs->mobile_app_id()) {
- return lhs->device() < rhs->device();
- }
- return lhs->mobile_app_id() < rhs->mobile_app_id();
- }
- };
-
- // typedef for Applications list
- typedef std::set<ApplicationSharedPtr,
- ApplicationsAppIdSorter> ApplictionSet;
-
- typedef std::multiset<ApplicationSharedPtr,
- ApplicationsMobileAppIdSorter> AppsWaitRegistrationSet;
-
- // typedef for Applications list iterator
- typedef ApplictionSet::iterator ApplictionSetIt;
-
- // typedef for Applications list const iterator
- typedef ApplictionSet::const_iterator ApplictionSetConstIt;
-
- DataAccessor<AppsWaitRegistrationSet> apps_waiting_for_registration() const;
- ApplicationConstSharedPtr waiting_app(const uint32_t hmi_id) const;
-
- /**
- * Class for thread-safe access to applications list
- */
- class ApplicationListAccessor: public DataAccessor<ApplictionSet> {
- public:
-
- /**
- * @brief ApplicationListAccessor class constructor
- */
- ApplicationListAccessor() :
- DataAccessor<ApplictionSet>(ApplicationManagerImpl::instance()->applications_,
- ApplicationManagerImpl::instance()->applications_list_lock_) {
- }
-
- ~ApplicationListAccessor();
-
- /**
- * @brief thread-safe getter for applications
- * @return applications list
- */
- const ApplictionSet& applications() const {
- return GetData();
- }
-
- ApplictionSetConstIt begin() {
- return applications().begin();
- }
-
- ApplictionSetConstIt end() {
- return applications().end();
- }
-
- template<class UnaryPredicate>
- ApplicationSharedPtr Find(UnaryPredicate finder) {
- ApplicationSharedPtr result;
- ApplictionSetConstIt it = std::find_if(begin(), end(), finder);
- if (it != end()) {
- result = *it;
- }
- return result;
+ template <class UnaryPredicate>
+ ApplicationSharedPtr Find(UnaryPredicate finder) {
+ ApplicationSharedPtr result;
+ ApplictionSetConstIt it = std::find_if(begin(), end(), finder);
+ if (it != end()) {
+ result = *it;
}
+ return result;
+ }
- template<class UnaryPredicate>
- std::vector<ApplicationSharedPtr> FindAll(UnaryPredicate finder) {
- std::vector<ApplicationSharedPtr> result;
- ApplictionSetConstIt it = std::find_if(begin(), end(), finder);
- while (it != end()) {
- result.push_back(*it);
- it = std::find_if(++it, end(), finder);
- }
- return result;
+ template <class UnaryPredicate>
+ std::vector<ApplicationSharedPtr> FindAll(UnaryPredicate finder) {
+ std::vector<ApplicationSharedPtr> result;
+ ApplictionSetConstIt it = std::find_if(begin(), end(), finder);
+ while (it != end()) {
+ result.push_back(*it);
+ it = std::find_if(++it, end(), finder);
}
+ return result;
+ }
- void Erase(ApplicationSharedPtr app_to_remove) {
- ApplicationManagerImpl::instance()->applications_.erase(app_to_remove);
- }
+ void Erase(ApplicationSharedPtr app_to_remove) {
+ ApplicationManagerImpl::instance()->applications_.erase(app_to_remove);
+ }
- void Insert(ApplicationSharedPtr app_to_insert) {
- ApplicationManagerImpl::instance()->applications_.insert(app_to_insert);
- }
+ void Insert(ApplicationSharedPtr app_to_insert) {
+ ApplicationManagerImpl::instance()->applications_.insert(app_to_insert);
+ }
- bool Empty() {
- return ApplicationManagerImpl::instance()->applications_.empty();
- }
+ bool Empty() {
+ return ApplicationManagerImpl::instance()->applications_.empty();
+ }
- private:
- DISALLOW_COPY_AND_ASSIGN(ApplicationListAccessor);
- };
+ private:
+ DISALLOW_COPY_AND_ASSIGN(ApplicationListAccessor);
+ };
- friend class ApplicationListAccessor;
+ friend class ApplicationListAccessor;
- struct AppIdPredicate {
- uint32_t app_id_;
- AppIdPredicate(uint32_t app_id): app_id_(app_id) {}
- bool operator () (const ApplicationSharedPtr app) const {
- return app ? app_id_ == app->app_id() : false;
- }
- };
+ struct AppIdPredicate {
+ uint32_t app_id_;
+ AppIdPredicate(uint32_t app_id) : app_id_(app_id) {}
+ bool operator()(const ApplicationSharedPtr app) const {
+ return app ? app_id_ == app->app_id() : false;
+ }
+ };
- struct HmiAppIdPredicate {
- uint32_t hmi_app_id_;
- HmiAppIdPredicate(uint32_t hmi_app_id): hmi_app_id_(hmi_app_id) {}
- bool operator () (const ApplicationSharedPtr app) const {
- return app ? hmi_app_id_ == app->hmi_app_id() : false;
- }
- };
-
- struct MobileAppIdPredicate {
- std::string policy_app_id_;
- MobileAppIdPredicate(const std::string& policy_app_id):
- policy_app_id_(policy_app_id) {}
- bool operator () (const ApplicationSharedPtr app) const {
- return app ? policy_app_id_ == app->mobile_app_id() : false;
- }
- };
+ struct HmiAppIdPredicate {
+ uint32_t hmi_app_id_;
+ HmiAppIdPredicate(uint32_t hmi_app_id) : hmi_app_id_(hmi_app_id) {}
+ bool operator()(const ApplicationSharedPtr app) const {
+ return app ? hmi_app_id_ == app->hmi_app_id() : false;
+ }
+ };
+
+ struct MobileAppIdPredicate {
+ std::string policy_app_id_;
+ MobileAppIdPredicate(const std::string &policy_app_id)
+ : policy_app_id_(policy_app_id) {}
+ bool operator()(const ApplicationSharedPtr app) const {
+ return app ? policy_app_id_ == app->mobile_app_id() : false;
+ }
+ };
- struct SubscribedToButtonPredicate {
- mobile_apis::ButtonName::eType button_;
- SubscribedToButtonPredicate(mobile_apis::ButtonName::eType button)
+ struct SubscribedToButtonPredicate {
+ mobile_apis::ButtonName::eType button_;
+ SubscribedToButtonPredicate(mobile_apis::ButtonName::eType button)
: button_(button) {}
- bool operator () (const ApplicationSharedPtr app) const {
- return app ? app->IsSubscribedToButton(button_) : false;
- }
- };
-
- struct AppV4DevicePredicate {
- connection_handler::DeviceHandle handle_;
- AppV4DevicePredicate(const connection_handler::DeviceHandle handle):
- handle_(handle) {}
- bool operator () (const ApplicationSharedPtr app) const {
- return app ? handle_ == app->device() &&
- ProtocolVersion::kV4 == app->protocol_version() : false;
- }
- };
-
- struct DevicePredicate {
- connection_handler::DeviceHandle handle_;
- DevicePredicate(const connection_handler::DeviceHandle handle):
- handle_(handle) {}
- bool operator () (const ApplicationSharedPtr app) const {
- return handle_ == app->device() ? true : false;
- }
- };
+ bool operator()(const ApplicationSharedPtr app) const {
+ return app ? app->IsSubscribedToButton(button_) : false;
+ }
+ };
+
+ struct AppV4DevicePredicate {
+ connection_handler::DeviceHandle handle_;
+ AppV4DevicePredicate(const connection_handler::DeviceHandle handle)
+ : handle_(handle) {}
+ bool operator()(const ApplicationSharedPtr app) const {
+ return app
+ ? handle_ == app->device() &&
+ ProtocolVersion::kV4 == app->protocol_version()
+ : false;
+ }
+ };
+
+ struct DevicePredicate {
+ connection_handler::DeviceHandle handle_;
+ DevicePredicate(const connection_handler::DeviceHandle handle)
+ : handle_(handle) {}
+ bool operator()(const ApplicationSharedPtr app) const {
+ return handle_ == app->device() ? true : false;
+ }
+ };
- struct SubscribedToIVIPredicate {
- int32_t vehicle_info_;
- SubscribedToIVIPredicate(int32_t vehicle_info)
+ struct SubscribedToIVIPredicate {
+ int32_t vehicle_info_;
+ SubscribedToIVIPredicate(int32_t vehicle_info)
: vehicle_info_(vehicle_info) {}
- bool operator () (const ApplicationSharedPtr app) const {
- return app ? app->IsSubscribedToIVI(vehicle_info_) : false;
- }
- };
-
- /**
- * @brief Sends UpdateAppList notification to HMI
- */
- void SendUpdateAppList();
-
- /**
- * @brief Marks applications received through QueryApps as should be
- * greyed out on HMI
- * @param is_greyed_out, true, if should be greyed out, otherwise - false
- * @param handle, device handle
- */
- void MarkAppsGreyOut(const connection_handler::DeviceHandle handle,
- bool is_greyed_out);
-
- /**
- * @brief Checks, if apps list had been queried already from certain device
- * @param handle, Device handle
- * @return true, if list had been queried already, otherwise - false
- */
- bool IsAppsQueriedFrom(const connection_handler::DeviceHandle handle) const;
-
- bool IsStopping() const {
- return is_stopping_;
+ bool operator()(const ApplicationSharedPtr app) const {
+ return app ? app->IsSubscribedToIVI(vehicle_info_) : false;
}
-
- private:
- /**
- * @brief PullLanguagesInfo allows to pull information about languages.
- *
- * @param app_data entry to parse
- *
- * @param ttsName tts name that should be filled.
- * @param vrSynonym vr synonymus that should be filled.
- */
- void PullLanguagesInfo(const smart_objects::SmartObject& app_data,
- smart_objects::SmartObject& ttsName,
- smart_objects::SmartObject& vrSynonym);
-
- ApplicationManagerImpl();
-
- /**
- * @brief Method transforms string to AppHMIType
- * @param str contains string AppHMIType
- * @return enum AppHMIType
- */
- mobile_apis::AppHMIType::eType StringToAppHMIType(std::string str);
-
- /**
- * @brief Method compares arrays of app HMI type
- * @param from_policy contains app HMI type from policy
- * @param from_application contains app HMI type from application
- * @return return TRUE if arrays of appHMIType equal, otherwise return FALSE
- */
- bool CompareAppHMIType (const smart_objects::SmartObject& from_policy,
- const smart_objects::SmartObject& from_application);
-
- hmi_apis::HMI_API& hmi_so_factory();
- mobile_apis::MOBILE_API& mobile_so_factory();
-
- bool ConvertMessageToSO(const Message& message,
- smart_objects::SmartObject& output);
- bool ConvertSOtoMessage(const smart_objects::SmartObject& message,
- Message& output);
- utils::SharedPtr<Message> ConvertRawMsgToMessage(
- const ::protocol_handler::RawMessagePtr message);
-
- void ProcessMessageFromMobile(const utils::SharedPtr<Message> message);
- void ProcessMessageFromHMI(const utils::SharedPtr<Message> message);
-
- // threads::MessageLoopThread<*>::Handler implementations
- /*
- * @brief Handles for threads pumping different types
- * of messages. Beware, each is called on different thread!
- */
- // CALLED ON messages_from_mobile_ thread!
- virtual void Handle(const impl::MessageFromMobile message) OVERRIDE;
-
- // CALLED ON messages_to_mobile_ thread!
- virtual void Handle(const impl::MessageToMobile message) OVERRIDE;
-
- // CALLED ON messages_from_hmi_ thread!
- virtual void Handle(const impl::MessageFromHmi message) OVERRIDE;
-
- // CALLED ON messages_to_hmi_ thread!
- virtual void Handle(const impl::MessageToHmi message) OVERRIDE;
-
- // CALLED ON audio_pass_thru_messages_ thread!
- virtual void Handle(const impl::AudioData message) OVERRIDE;
-
- template<typename ApplicationList>
- void PrepareApplicationListSO(ApplicationList app_list,
- smart_objects::SmartObject& applications) {
- CREATE_LOGGERPTR_LOCAL(logger_, "ApplicatinManagerImpl");
-
- smart_objects::SmartArray* app_array = applications.asArray();
- uint32_t app_count = NULL == app_array ? 0 : app_array->size();
- typename ApplicationList::const_iterator it;
- for (it = app_list.begin(); it != app_list.end(); ++it) {
- if (!it->valid()) {
- LOG4CXX_ERROR(logger_, "Application not found ");
- continue;
- }
-
- smart_objects::SmartObject hmi_application(smart_objects::SmartType_Map);;
- if (MessageHelper::CreateHMIApplicationStruct(*it, hmi_application)) {
- applications[app_count++] = hmi_application;
- } else {
- LOG4CXX_DEBUG(logger_, "Can't CreateHMIApplicationStruct ");
- }
+ };
+
+ /**
+ * @brief Sends UpdateAppList notification to HMI
+ */
+ void SendUpdateAppList();
+
+ /**
+ * @brief Marks applications received through QueryApps as should be
+ * greyed out on HMI
+ * @param is_greyed_out, true, if should be greyed out, otherwise - false
+ * @param handle, device handle
+ */
+ void MarkAppsGreyOut(const connection_handler::DeviceHandle handle,
+ bool is_greyed_out);
+
+ /**
+ * @brief Checks, if apps list had been queried already from certain device
+ * @param handle, Device handle
+ * @return true, if list had been queried already, otherwise - false
+ */
+ bool IsAppsQueriedFrom(const connection_handler::DeviceHandle handle) const;
+
+ bool IsStopping() const { return is_stopping_; }
+
+private:
+ /**
+ * @brief PullLanguagesInfo allows to pull information about languages.
+ *
+ * @param app_data entry to parse
+ *
+ * @param ttsName tts name that should be filled.
+ * @param vrSynonym vr synonymus that should be filled.
+ */
+ void PullLanguagesInfo(const smart_objects::SmartObject &app_data,
+ smart_objects::SmartObject &ttsName,
+ smart_objects::SmartObject &vrSynonym);
+
+ ApplicationManagerImpl();
+
+ /**
+ * @brief Method transforms string to AppHMIType
+ * @param str contains string AppHMIType
+ * @return enum AppHMIType
+ */
+ mobile_apis::AppHMIType::eType StringToAppHMIType(std::string str);
+
+ /**
+ * @brief Method compares arrays of app HMI type
+ * @param from_policy contains app HMI type from policy
+ * @param from_application contains app HMI type from application
+ * @return return TRUE if arrays of appHMIType equal, otherwise return FALSE
+ */
+ bool CompareAppHMIType(const smart_objects::SmartObject &from_policy,
+ const smart_objects::SmartObject &from_application);
+
+ hmi_apis::HMI_API &hmi_so_factory();
+ mobile_apis::MOBILE_API &mobile_so_factory();
+
+ bool ConvertMessageToSO(const Message &message,
+ smart_objects::SmartObject &output);
+ bool ConvertSOtoMessage(const smart_objects::SmartObject &message,
+ Message &output);
+ utils::SharedPtr<Message>
+ ConvertRawMsgToMessage(const ::protocol_handler::RawMessagePtr message);
+
+ void ProcessMessageFromMobile(const utils::SharedPtr<Message> message);
+ void ProcessMessageFromHMI(const utils::SharedPtr<Message> message);
+
+ // threads::MessageLoopThread<*>::Handler implementations
+ /*
+ * @brief Handles for threads pumping different types
+ * of messages. Beware, each is called on different thread!
+ */
+ // CALLED ON messages_from_mobile_ thread!
+ virtual void Handle(const impl::MessageFromMobile message) OVERRIDE;
+
+ // CALLED ON messages_to_mobile_ thread!
+ virtual void Handle(const impl::MessageToMobile message) OVERRIDE;
+
+ // CALLED ON messages_from_hmi_ thread!
+ virtual void Handle(const impl::MessageFromHmi message) OVERRIDE;
+
+ // CALLED ON messages_to_hmi_ thread!
+ virtual void Handle(const impl::MessageToHmi message) OVERRIDE;
+
+ // CALLED ON audio_pass_thru_messages_ thread!
+ virtual void Handle(const impl::AudioData message) OVERRIDE;
+
+ template <typename ApplicationList>
+ void PrepareApplicationListSO(ApplicationList app_list,
+ smart_objects::SmartObject &applications) {
+ CREATE_LOGGERPTR_LOCAL(logger_, "ApplicatinManagerImpl");
+
+ smart_objects::SmartArray *app_array = applications.asArray();
+ uint32_t app_count = NULL == app_array ? 0 : app_array->size();
+ typename ApplicationList::const_iterator it;
+ for (it = app_list.begin(); it != app_list.end(); ++it) {
+ if (!it->valid()) {
+ LOG4CXX_ERROR(logger_, "Application not found ");
+ continue;
}
- if (0 == app_count) {
- LOG4CXX_WARN(logger_, "Empty applications list");
+ smart_objects::SmartObject hmi_application(smart_objects::SmartType_Map);
+ ;
+ if (MessageHelper::CreateHMIApplicationStruct(*it, hmi_application)) {
+ applications[app_count++] = hmi_application;
+ } else {
+ LOG4CXX_DEBUG(logger_, "Can't CreateHMIApplicationStruct ");
}
}
- void OnApplicationListUpdateTimer();
-
- /**
- * @brief CreateApplications creates aplpication adds it to application list
- * and prepare data for sending AppIcon request.
- *
- * @param obj_array applications array.
- *
- * @param connection_key connection key of app, which provided app list to
- * be created
- */
- void CreateApplications(smart_objects::SmartArray& obj_array,
- const uint32_t connection_key);
-
- /*
- * @brief Function is called on IGN_OFF, Master_reset or Factory_defaults
- * to notify HMI that SDL is shutting down.
- */
- void SendOnSDLClose();
-
- /*
- * @brief returns true if low voltage state is active
- */
- bool IsLowVoltage();
-
- private:
- /*
- * NaviServiceStatusMap shows which navi service (audio/video) is opened
- * for specified application. Two bool values in std::pair mean:
- * 1st value - is video service opened or not
- * 2nd value - is audio service opened or not
- */
- typedef std::map<uint32_t, std::pair<bool, bool> > NaviServiceStatusMap;
-
- typedef SharedPtr<TimerThread<ApplicationManagerImpl> > ApplicationManagerTimerPtr;
-
- /**
- * @brief Removes suspended and stopped timers from timer pool
- */
- void ClearTimerPool();
-
- /**
- * @brief CloseNaviApp allows to unregister application in case the EndServiceEndedAck
- * didn't come for at least one of services(audio or video)
- */
- void CloseNaviApp();
-
- /**
- * @brief Suspends streaming ability of application in case application's HMI level
- * has been changed to not allowed for streaming
- */
- void EndNaviStreaming();
-
- /**
- * @brief Starts specified navi service for application
- * @param app_id Application to proceed
- * @param service_type Type of service to start
- * @return True on success, false on fail
- */
- bool StartNaviService(
- uint32_t app_id, protocol_handler::ServiceType service_type);
-
- /**
- * @brief Stops specified navi service for application
- * @param app_id Application to proceed
- * @param service_type Type of service to stop
- */
- void StopNaviService(
- uint32_t app_id, protocol_handler::ServiceType service_type);
-
- /**
- * @brief Allows streaming for application if it was disallowed by
- * DisallowStreaming()
- * @param app_id Application to proceed
- */
- void AllowStreaming(uint32_t app_id);
-
- /**
- * @brief Disallows streaming for application, but doesn't close
- * opened services. Streaming ability could be restored by AllowStreaming();
- * @param app_id Application to proceed
- */
- void DisallowStreaming(uint32_t app_id);
-
- /**
- * @brief Function returns supported SDL Protocol Version
- * @return protocol version depends on parameters from smartDeviceLink.ini.
- */
- ProtocolVersion SupportedSDLVersion() const;
-
- /**
- * @brief Types of directories used by Application Manager
- */
- enum DirectoryType {
- TYPE_STORAGE,
- TYPE_SYSTEM,
- TYPE_ICONS
- };
-
- typedef std::map<DirectoryType, std::string> DirectoryTypeMap;
- DirectoryTypeMap dir_type_to_string_map_;
-
- /**
- * @brief Converts directory type to string
- * @param type Directory type
- * @return Stringified type
- */
- const std::string DirectoryTypeToString(DirectoryType type) const;
-
- /**
- * @brief Creates directory path, if necessary
- * @param path Directory path
- * @param type Directory type
- * @return true, if succedeed, otherwise - false
- */
- bool InitDirectory(const std::string& path, DirectoryType type) const;
-
- /**
- * @brief Checks, whether r/w permissions are present for particular path
- * @param path Directory path
- * @param type Directory type
- * @return true, if allowed, otherwise - false
- */
- bool IsReadWriteAllowed(const std::string& path, DirectoryType type) const;
-
- /**
- * @brief Removes apps, waiting for registration related to
- * certain device handle
- * @param handle, Device handle
- */
- void RemoveAppsWaitingForRegistration(
- const connection_handler::DeviceHandle handle);
-
- /**
- * @brief Clears TTS global properties list of apps
- */
- void ClearTTSGlobalPropertiesList();
-
- private:
- /**
- * @brief List of applications
- */
- ApplictionSet applications_;
- AppsWaitRegistrationSet apps_to_register_;
-
- // Lock for applications list
- mutable sync_primitives::Lock applications_list_lock_;
- mutable sync_primitives::Lock apps_to_register_list_lock_;
-
- /**
- * @brief Map of correlation id and associated application id.
- */
- std::map<const int32_t, const uint32_t> appID_list_;
-
- /**
- * @brief Map contains applications which
- * will send TTS global properties to HMI after timeout
- */
- std::map<uint32_t, TimevalStruct> tts_global_properties_app_list_;
-
- bool audio_pass_thru_active_;
- sync_primitives::Lock audio_pass_thru_lock_;
- sync_primitives::Lock tts_global_properties_app_list_lock_;
- bool is_distracting_driver_;
- bool is_vr_session_strated_;
- bool hmi_cooperating_;
- bool is_all_apps_allowed_;
- media_manager::MediaManager* media_manager_;
-
- hmi_message_handler::HMIMessageHandler* hmi_handler_;
- connection_handler::ConnectionHandler* connection_handler_;
- protocol_handler::ProtocolHandler* protocol_handler_;
- request_controller::RequestController request_ctrl_;
-
- hmi_apis::HMI_API* hmi_so_factory_;
- mobile_apis::MOBILE_API* mobile_so_factory_;
-
- static uint32_t corelation_id_;
- static const uint32_t max_corelation_id_;
-
-
- // Construct message threads when everything is already created
-
- // Thread that pumps messages coming from mobile side.
- impl::FromMobileQueue messages_from_mobile_;
- // Thread that pumps messages being passed to mobile side.
- impl::ToMobileQueue messages_to_mobile_;
- // Thread that pumps messages coming from HMI.
- impl::FromHmiQueue messages_from_hmi_;
- // Thread that pumps messages being passed to HMI.
- impl::ToHmiQueue messages_to_hmi_;
- // Thread that pumps messages audio pass thru to mobile.
- impl::AudioPassThruQueue audio_pass_thru_messages_;
-
-
- HMICapabilities hmi_capabilities_;
- // The reason of HU shutdown
- mobile_api::AppInterfaceUnregisteredReason::eType unregister_reason_;
-
- /**
- * @brief Resume controler is responcible for save and load information
- * about persistent application data on disk, and save session ID for resuming
- * application in case INGITION_OFF or MASTER_RESSET
- */
- ResumeCtrl resume_ctrl_;
-
- NaviServiceStatusMap navi_service_status_;
- std::deque<uint32_t> navi_app_to_stop_;
- std::deque<uint32_t> navi_app_to_end_stream_;
- uint32_t navi_close_app_timeout_;
- uint32_t navi_end_stream_timeout_;
-
- std::vector<ApplicationManagerTimerPtr> timer_pool_;
- sync_primitives::Lock timer_pool_lock_;
- sync_primitives::Lock stopping_flag_lock_;
+ if (0 == app_count) {
+ LOG4CXX_WARN(logger_, "Empty applications list");
+ }
+ }
- StateController state_ctrl_;
+ void OnApplicationListUpdateTimer();
+
+ /**
+ * @brief CreateApplications creates aplpication adds it to application list
+ * and prepare data for sending AppIcon request.
+ *
+ * @param obj_array applications array.
+ *
+ * @param connection_key connection key of app, which provided app list to
+ * be created
+ */
+ void CreateApplications(smart_objects::SmartArray &obj_array,
+ const uint32_t connection_key);
+
+ /*
+ * @brief Function is called on IGN_OFF, Master_reset or Factory_defaults
+ * to notify HMI that SDL is shutting down.
+ */
+ void SendOnSDLClose();
+
+ /*
+ * @brief returns true if low voltage state is active
+ */
+ bool IsLowVoltage();
+
+private:
+ /*
+ * NaviServiceStatusMap shows which navi service (audio/video) is opened
+ * for specified application. Two bool values in std::pair mean:
+ * 1st value - is video service opened or not
+ * 2nd value - is audio service opened or not
+ */
+ typedef std::map<uint32_t, std::pair<bool, bool>> NaviServiceStatusMap;
+
+ typedef SharedPtr<TimerThread<ApplicationManagerImpl>>
+ ApplicationManagerTimerPtr;
+
+ /**
+ * @brief Removes suspended and stopped timers from timer pool
+ */
+ void ClearTimerPool();
+
+ /**
+ * @brief CloseNaviApp allows to unregister application in case the
+ * EndServiceEndedAck
+ * didn't come for at least one of services(audio or video)
+ */
+ void CloseNaviApp();
+
+ /**
+ * @brief Suspends streaming ability of application in case application's HMI
+ * level
+ * has been changed to not allowed for streaming
+ */
+ void EndNaviStreaming();
+
+ /**
+ * @brief Starts specified navi service for application
+ * @param app_id Application to proceed
+ * @param service_type Type of service to start
+ * @return True on success, false on fail
+ */
+ bool StartNaviService(uint32_t app_id,
+ protocol_handler::ServiceType service_type);
+
+ /**
+ * @brief Stops specified navi service for application
+ * @param app_id Application to proceed
+ * @param service_type Type of service to stop
+ */
+ void StopNaviService(uint32_t app_id,
+ protocol_handler::ServiceType service_type);
+
+ /**
+ * @brief Allows streaming for application if it was disallowed by
+ * DisallowStreaming()
+ * @param app_id Application to proceed
+ */
+ void AllowStreaming(uint32_t app_id);
+
+ /**
+ * @brief Disallows streaming for application, but doesn't close
+ * opened services. Streaming ability could be restored by AllowStreaming();
+ * @param app_id Application to proceed
+ */
+ void DisallowStreaming(uint32_t app_id);
+
+ /**
+ * @brief Function returns supported SDL Protocol Version
+ * @return protocol version depends on parameters from smartDeviceLink.ini.
+ */
+ ProtocolVersion SupportedSDLVersion() const;
+
+ /**
+ * @brief Types of directories used by Application Manager
+ */
+ enum DirectoryType { TYPE_STORAGE, TYPE_SYSTEM, TYPE_ICONS };
+
+ typedef std::map<DirectoryType, std::string> DirectoryTypeMap;
+ DirectoryTypeMap dir_type_to_string_map_;
+
+ /**
+ * @brief Converts directory type to string
+ * @param type Directory type
+ * @return Stringified type
+ */
+ const std::string DirectoryTypeToString(DirectoryType type) const;
+
+ /**
+ * @brief Creates directory path, if necessary
+ * @param path Directory path
+ * @param type Directory type
+ * @return true, if succedeed, otherwise - false
+ */
+ bool InitDirectory(const std::string &path, DirectoryType type) const;
+
+ /**
+ * @brief Checks, whether r/w permissions are present for particular path
+ * @param path Directory path
+ * @param type Directory type
+ * @return true, if allowed, otherwise - false
+ */
+ bool IsReadWriteAllowed(const std::string &path, DirectoryType type) const;
+
+ /**
+ * @brief Removes apps, waiting for registration related to
+ * certain device handle
+ * @param handle, Device handle
+ */
+ void RemoveAppsWaitingForRegistration(
+ const connection_handler::DeviceHandle handle);
+
+ /**
+ * @brief Clears TTS global properties list of apps
+ */
+ void ClearTTSGlobalPropertiesList();
+
+private:
+ /**
+ * @brief List of applications
+ */
+ ApplictionSet applications_;
+ AppsWaitRegistrationSet apps_to_register_;
+
+ // Lock for applications list
+ mutable sync_primitives::Lock applications_list_lock_;
+ mutable sync_primitives::Lock apps_to_register_list_lock_;
+
+ /**
+ * @brief Map of correlation id and associated application id.
+ */
+ std::map<const int32_t, const uint32_t> appID_list_;
+
+ /**
+ * @brief Map contains applications which
+ * will send TTS global properties to HMI after timeout
+ */
+ std::map<uint32_t, TimevalStruct> tts_global_properties_app_list_;
+
+ bool audio_pass_thru_active_;
+ sync_primitives::Lock audio_pass_thru_lock_;
+ sync_primitives::Lock tts_global_properties_app_list_lock_;
+ bool is_distracting_driver_;
+ bool is_vr_session_strated_;
+ bool hmi_cooperating_;
+ bool is_all_apps_allowed_;
+ media_manager::MediaManager *media_manager_;
+
+ hmi_message_handler::HMIMessageHandler *hmi_handler_;
+ connection_handler::ConnectionHandler *connection_handler_;
+ protocol_handler::ProtocolHandler *protocol_handler_;
+ request_controller::RequestController request_ctrl_;
+
+ hmi_apis::HMI_API *hmi_so_factory_;
+ mobile_apis::MOBILE_API *mobile_so_factory_;
+
+ static uint32_t corelation_id_;
+ static const uint32_t max_corelation_id_;
+
+ // Construct message threads when everything is already created
+
+ // Thread that pumps messages coming from mobile side.
+ impl::FromMobileQueue messages_from_mobile_;
+ // Thread that pumps messages being passed to mobile side.
+ impl::ToMobileQueue messages_to_mobile_;
+ // Thread that pumps messages coming from HMI.
+ impl::FromHmiQueue messages_from_hmi_;
+ // Thread that pumps messages being passed to HMI.
+ impl::ToHmiQueue messages_to_hmi_;
+ // Thread that pumps messages audio pass thru to mobile.
+ impl::AudioPassThruQueue audio_pass_thru_messages_;
+
+ HMICapabilities hmi_capabilities_;
+ // The reason of HU shutdown
+ mobile_api::AppInterfaceUnregisteredReason::eType unregister_reason_;
+
+ /**
+ * @brief Resume controler is responcible for save and load information
+ * about persistent application data on disk, and save session ID for resuming
+ * application in case INGITION_OFF or MASTER_RESSET
+ */
+ ResumeCtrl resume_ctrl_;
+
+ NaviServiceStatusMap navi_service_status_;
+ std::deque<uint32_t> navi_app_to_stop_;
+ std::deque<uint32_t> navi_app_to_end_stream_;
+ uint32_t navi_close_app_timeout_;
+ uint32_t navi_end_stream_timeout_;
+
+ std::vector<ApplicationManagerTimerPtr> timer_pool_;
+ sync_primitives::Lock timer_pool_lock_;
+ sync_primitives::Lock stopping_flag_lock_;
+
+ StateController state_ctrl_;
#ifdef TIME_TESTER
- AMMetricObserver* metric_observer_;
-#endif // TIME_TESTER
-
- class ApplicationListUpdateTimer : public timer::TimerThread<ApplicationManagerImpl> {
- public:
- ApplicationListUpdateTimer(ApplicationManagerImpl* callee) :
- timer::TimerThread<ApplicationManagerImpl>("AM ListUpdater",
- callee, &ApplicationManagerImpl::OnApplicationListUpdateTimer) {
- }
- };
- typedef utils::SharedPtr<ApplicationListUpdateTimer> ApplicationListUpdateTimerSptr;
- ApplicationListUpdateTimerSptr application_list_update_timer_;
+ AMMetricObserver *metric_observer_;
+#endif // TIME_TESTER
+
+ class ApplicationListUpdateTimer
+ : public timer::TimerThread<ApplicationManagerImpl> {
+ public:
+ ApplicationListUpdateTimer(ApplicationManagerImpl *callee)
+ : timer::TimerThread<ApplicationManagerImpl>(
+ "AM ListUpdater", callee,
+ &ApplicationManagerImpl::OnApplicationListUpdateTimer) {}
+ };
+ typedef utils::SharedPtr<ApplicationListUpdateTimer>
+ ApplicationListUpdateTimerSptr;
+ ApplicationListUpdateTimerSptr application_list_update_timer_;
- timer::TimerThread<ApplicationManagerImpl> tts_global_properties_timer_;
+ timer::TimerThread<ApplicationManagerImpl> tts_global_properties_timer_;
- bool is_low_voltage_;
- volatile bool is_stopping_;
+ bool is_low_voltage_;
+ volatile bool is_stopping_;
- DISALLOW_COPY_AND_ASSIGN(ApplicationManagerImpl);
+ DISALLOW_COPY_AND_ASSIGN(ApplicationManagerImpl);
- FRIEND_BASE_SINGLETON_CLASS(ApplicationManagerImpl);
+ FRIEND_BASE_SINGLETON_CLASS(ApplicationManagerImpl);
};
bool ApplicationManagerImpl::vr_session_started() const {
@@ -1425,6 +1413,6 @@ bool ApplicationManagerImpl::driver_distraction() const {
inline bool ApplicationManagerImpl::all_apps_allowed() const {
return is_all_apps_allowed_;
}
-} // namespace application_manager
+} // namespace application_manager
-#endif // SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_H_
+#endif // SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_H_
diff --git a/src/components/application_manager/include/application_manager/policies/policy_handler.h b/src/components/application_manager/include/application_manager/policies/policy_handler.h
index ac63e95d1a..1fb7d68d25 100644
--- a/src/components/application_manager/include/application_manager/policies/policy_handler.h
+++ b/src/components/application_manager/include/application_manager/policies/policy_handler.h
@@ -1,5 +1,5 @@
/*
- Copyright (c) 2013, Ford Motor Company
+ Copyright (c) 2016, Ford Motor Company
All rights reserved.
Redistribution and use in source and binary forms, with or without
@@ -37,6 +37,7 @@
#include <map>
#include <set>
#include <vector>
+#include <cstdint>
#include "policy/policy_manager.h"
#include "application_manager/policies/policy_event_observer.h"
#include "application_manager/policies/delegates/statistics_delegate.h"
@@ -59,56 +60,55 @@ namespace policy {
typedef std::vector<uint32_t> AppIds;
typedef std::vector<uint32_t> DeviceHandles;
-class PolicyHandler :
- public utils::Singleton<PolicyHandler, utils::deleters::Deleter<PolicyHandler> >,
- public PolicyListener,
- public threads::AsyncRunner {
- public:
+class PolicyHandler
+ : public utils::Singleton<PolicyHandler,
+ utils::deleters::Deleter<PolicyHandler>>,
+ public PolicyListener,
+ public threads::AsyncRunner {
+public:
virtual ~PolicyHandler();
bool LoadPolicyLibrary();
bool PolicyEnabled();
bool InitPolicyTable();
bool ResetPolicyTable();
bool ClearUserConsent();
- bool SendMessageToSDK(const BinaryMessage& pt_string, const std::string& url);
- bool ReceiveMessageFromSDK(const std::string& file,
- const BinaryMessage& pt_string);
+ bool SendMessageToSDK(const BinaryMessage &pt_string, const std::string &url);
+ bool ReceiveMessageFromSDK(const std::string &file,
+ const BinaryMessage &pt_string);
bool UnloadPolicyLibrary();
- virtual void OnPermissionsUpdated(const std::string& policy_app_id,
- const Permissions& permissions,
- const HMILevel& default_hmi);
-
- virtual void OnPermissionsUpdated(const std::string& policy_app_id,
- const Permissions& permissions);
-
- virtual void OnSnapshotCreated(const BinaryMessage& pt_string);
-
- bool GetPriority(const std::string& policy_app_id, std::string* priority);
- void CheckPermissions(const PTString& app_id,
- const PTString& hmi_level,
- const PTString& rpc,
- const RPCParams& rpc_params,
- CheckPermissionResult& result);
-
- uint32_t GetNotificationsNumber(const std::string& priority);
- DeviceConsent GetUserConsentForDevice(const std::string& device_id);
- bool GetDefaultHmi(const std::string& policy_app_id,
- std::string* default_hmi);
- bool GetInitialAppData(const std::string& application_id,
- StringArray* nicknames = NULL,
- StringArray* app_hmi_types = NULL);
- void GetServiceUrls(const std::string& service_type,
- EndpointUrls& end_points);
+ virtual void OnPermissionsUpdated(const std::string &policy_app_id,
+ const Permissions &permissions,
+ const HMILevel &default_hmi);
+
+ virtual void OnPermissionsUpdated(const std::string &policy_app_id,
+ const Permissions &permissions);
+
+ void OnSnapshotCreated(const BinaryMessage &pt_string) OVERRIDE;
+
+ bool GetPriority(const std::string &policy_app_id, std::string *priority);
+ void CheckPermissions(const PTString &app_id, const PTString &hmi_level,
+ const PTString &rpc, const RPCParams &rpc_params,
+ CheckPermissionResult &result);
+
+ uint32_t GetNotificationsNumber(const std::string &priority);
+ DeviceConsent GetUserConsentForDevice(const std::string &device_id);
+ bool GetDefaultHmi(const std::string &policy_app_id,
+ std::string *default_hmi);
+ bool GetInitialAppData(const std::string &application_id,
+ StringArray *nicknames = NULL,
+ StringArray *app_hmi_types = NULL);
+ void GetServiceUrls(const std::string &service_type,
+ EndpointUrls &end_points);
std::string GetLockScreenIconUrl() const;
void ResetRetrySequence();
- int NextRetryTimeout();
+ uint32_t NextRetryTimeout();
int TimeoutExchange();
void OnExceededTimeout();
void OnSystemReady();
void PTUpdatedAt(int kilometers, int days_after_epoch);
- void add_listener(PolicyHandlerObserver* listener);
- void remove_listener(PolicyHandlerObserver* listener);
+ void add_listener(PolicyHandlerObserver *listener);
+ void remove_listener(PolicyHandlerObserver *listener);
utils::SharedPtr<usage_statistics::StatisticsManager> GetStatisticManager();
@@ -121,7 +121,7 @@ class PolicyHandler :
* @return true if specified system action is enabled, false otherwise.
*/
bool CheckSystemAction(mobile_apis::SystemAction::eType system_action,
- const std::string& policy_app_id);
+ const std::string &policy_app_id);
/**
* Lets client to notify PolicyHandler that more kilometers expired
@@ -148,7 +148,7 @@ class PolicyHandler :
*/
void OnIgnitionCycleOver();
- void OnPendingPermissionChange(const std::string& policy_app_id);
+ void OnPendingPermissionChange(const std::string &policy_app_id);
/**
* Initializes PT exchange at user request
@@ -161,7 +161,7 @@ class PolicyHandler :
* @param device_id Device mac address
* @param device_info Device params
*/
- void SetDeviceInfo(std::string& device_id, const DeviceInfo& device_info);
+ void SetDeviceInfo(std::string &device_id, const DeviceInfo &device_info);
/**
* @brief Store user-changed permissions consent to DB
@@ -179,8 +179,8 @@ class PolicyHandler :
* @param language Language
* @param correlation_id correlation id of request
*/
- void OnGetUserFriendlyMessage(const std::vector<std::string>& message_codes,
- const std::string& language,
+ void OnGetUserFriendlyMessage(const std::vector<std::string> &message_codes,
+ const std::string &language,
uint32_t correlation_id);
/**
@@ -203,20 +203,20 @@ class PolicyHandler :
* @brief Send notification to HMI with changed policy update status
* @param status Current policy update state
*/
- void OnUpdateStatusChanged(const std::string& status);
+ void OnUpdateStatusChanged(const std::string &status);
/**
* @brief Update currently used device id in policies manager for given
* application
* @param policy_app_id Application id
*/
- std::string OnCurrentDeviceIdUpdateRequired(const std::string& policy_app_id);
+ std::string OnCurrentDeviceIdUpdateRequired(const std::string &policy_app_id);
/**
* @brief Set parameters from OnSystemInfoChanged to policy table
* @param language System language
*/
- void OnSystemInfoChanged(const std::string& language);
+ void OnSystemInfoChanged(const std::string &language);
/**
* @brief Save data from GetSystemInfo request to policy table
@@ -224,14 +224,14 @@ class PolicyHandler :
* @param wers_country_code WERS country code
* @param language System language
*/
- void OnGetSystemInfo(const std::string& ccpu_version,
- const std::string& wers_country_code,
- const std::string& language);
+ void OnGetSystemInfo(const std::string &ccpu_version,
+ const std::string &wers_country_code,
+ const std::string &language);
/**
* @brief Send request to HMI to get update on system parameters
*/
- virtual void OnSystemInfoUpdateRequired();
+ void OnSystemInfoUpdateRequired() OVERRIDE;
/**
* @brief Sends GetVehicleData request in case when Vechicle info is ready.
@@ -242,13 +242,13 @@ class PolicyHandler :
* @brief Allows to update vechicle data info.
* @param SmartObject which contains all needed information.
*/
- virtual void OnVehicleDataUpdated(const smart_objects::SmartObject& message);
+ virtual void OnVehicleDataUpdated(const smart_objects::SmartObject &message);
/**
* Removes device
* @param device_id id of device
*/
- void RemoveDevice(const std::string& device_id);
+ void RemoveDevice(const std::string &device_id);
/**
* Adds statistics info
@@ -268,34 +268,35 @@ class PolicyHandler :
*/
uint32_t GetAppIdForSending();
- std::string GetAppName(const std::string& policy_app_id);
+ std::string GetAppName(const std::string &policy_app_id);
- virtual void OnUpdateHMIAppType(std::map<std::string, StringArray> app_hmi_types);
+ void
+ OnUpdateHMIAppType(std::map<std::string, StringArray> app_hmi_types) OVERRIDE;
- virtual void OnCertificateUpdated(const std::string& certificate_data);
+ void OnCertificateUpdated(const std::string &certificate_data) OVERRIDE;
- virtual bool CanUpdate();
+ bool CanUpdate() OVERRIDE;
- virtual void OnDeviceConsentChanged(const std::string& device_id,
- bool is_allowed);
+ void OnDeviceConsentChanged(const std::string &device_id,
+ bool is_allowed) OVERRIDE;
virtual void OnPTExchangeNeeded();
- virtual void GetAvailableApps(std::queue<std::string>& apps);
+ void GetAvailableApps(std::queue<std::string> &apps) OVERRIDE;
/**
* @brief Allows to add new or update existed application during
* registration process
* @param application_id The policy aplication id.
*/
- void AddApplication(const std::string& application_id);
+ void AddApplication(const std::string &application_id);
/**
* Checks whether application is revoked
* @param app_id id application
* @return true if application is revoked
*/
- bool IsApplicationRevoked(const std::string& app_id);
+ bool IsApplicationRevoked(const std::string &app_id);
/**
* @brief Notifies policy manager, that PTS was sent out
@@ -308,7 +309,7 @@ class PolicyHandler :
* @return if timeout was set then value in seconds greater zero
* otherwise heart beat for specific application isn't set
*/
- uint16_t HeartBeatTimeout(const std::string& app_id) const;
+ uint16_t HeartBeatTimeout(const std::string &app_id) const;
/**
* @brief Returns URL for querying list of remote apps
@@ -326,12 +327,21 @@ class PolicyHandler :
void OnAppsSearchCompleted();
/**
+ * @brief OnAppRegisteredOnMobile alows to handle event when application were
+ * succesfully registered on mobile device.
+ * It will send OnAppPermissionSend notification and will try to start PTU.
+ *
+ * @param application_id registered application.
+ */
+ void OnAppRegisteredOnMobile(const std::string &application_id);
+
+ /**
* @brief Checks if certain request type is allowed for application
* @param policy_app_id Unique applicaion id
* @param type Request type
* @return true, if allowed, otherwise - false
*/
- bool IsRequestTypeAllowed(const std::string& policy_app_id,
+ bool IsRequestTypeAllowed(const std::string &policy_app_id,
mobile_apis::RequestType::eType type) const;
/**
@@ -339,46 +349,45 @@ class PolicyHandler :
* @param policy_app_id Unique application id
* @return request types
*/
- const std::vector<std::string> GetAppRequestTypes(
- const std::string& policy_app_id) const;
+ const std::vector<std::string>
+ GetAppRequestTypes(const std::string &policy_app_id) const;
-//TODO(AKutsan) REMOVE THIS UGLY HOTFIX
+ // TODO(AKutsan) REMOVE THIS UGLY HOTFIX
virtual void Increment(usage_statistics::GlobalCounterId type);
- virtual void Increment(const std::string& app_id,
+ virtual void Increment(const std::string &app_id,
usage_statistics::AppCounterId type);
- virtual void Set(const std::string& app_id,
- usage_statistics::AppInfoId type,
- const std::string& value);
- virtual void Add(const std::string& app_id,
+ virtual void Set(const std::string &app_id, usage_statistics::AppInfoId type,
+ const std::string &value);
+ virtual void Add(const std::string &app_id,
usage_statistics::AppStopwatchId type,
int32_t timespan_seconds);
protected:
-
/**
* Starts next retry exchange policy table
*/
void StartNextRetry();
- private:
-
+private:
/**
* Checks system action of application for permission of keep context
* @param system_action system action (see mobile api)
* @param policy_app_id unique application id
- * @return false if system_action is KEEP_CONTEXT and it isn't allowed by policy
+ * @return false if system_action is KEEP_CONTEXT and it isn't allowed by
+ * policy
* otherwise true
*/
- bool CheckKeepContext(const std::string& policy_app_id);
+ bool CheckKeepContext(const std::string &policy_app_id);
/**
* Checks system action of application for permission of steal focus
* @param system_action system action (see mobile api)
* @param policy_app_id unique application id
- * @return false if system_action is STEAL_FOCUS and it isn't allowed by policy
+ * @return false if system_action is STEAL_FOCUS and it isn't allowed by
+ * policy
* otherwise true
*/
- bool CheckStealFocus(const std::string& policy_app_id);
+ bool CheckStealFocus(const std::string &policy_app_id);
/**
* @brief OnAppPermissionConsentInternal reacts on permission changing
@@ -388,49 +397,47 @@ protected:
* @param permissions new permissions.
*/
void OnAppPermissionConsentInternal(const uint32_t connection_key,
- PermissionConsent& permissions);
+ PermissionConsent &permissions);
+
private:
- class StatisticManagerImpl: public usage_statistics::StatisticsManager {
- //TODO(AKutsan) REMOVE THIS UGLY HOTFIX
- virtual void Increment(usage_statistics::GlobalCounterId type) {
+ class StatisticManagerImpl : public usage_statistics::StatisticsManager {
+ // TODO(AKutsan) REMOVE THIS UGLY HOTFIX
+ virtual void Increment(usage_statistics::GlobalCounterId type) {
- PolicyHandler::instance()->AsyncRun(new StatisticsDelegate(type));
- }
+ PolicyHandler::instance()->AsyncRun(new StatisticsDelegate(type));
+ }
- virtual void Increment(const std::string& app_id,
- usage_statistics::AppCounterId type) {
+ virtual void Increment(const std::string &app_id,
+ usage_statistics::AppCounterId type) {
- PolicyHandler::instance()->AsyncRun(new StatisticsDelegate(app_id,
- type));
- }
+ PolicyHandler::instance()->AsyncRun(new StatisticsDelegate(app_id, type));
+ }
- virtual void Set(const std::string& app_id,
- usage_statistics::AppInfoId type,
- const std::string& value) {
+ virtual void Set(const std::string &app_id,
+ usage_statistics::AppInfoId type,
+ const std::string &value) {
- PolicyHandler::instance()->AsyncRun(new StatisticsDelegate(app_id,
- type,
- value));
- }
+ PolicyHandler::instance()->AsyncRun(
+ new StatisticsDelegate(app_id, type, value));
+ }
- virtual void Add(const std::string& app_id,
- usage_statistics::AppStopwatchId type,
- int32_t timespan_seconds) {
+ virtual void Add(const std::string &app_id,
+ usage_statistics::AppStopwatchId type,
+ int32_t timespan_seconds) {
- PolicyHandler::instance()->AsyncRun(new StatisticsDelegate(
- app_id, type, timespan_seconds));
- }
+ PolicyHandler::instance()->AsyncRun(
+ new StatisticsDelegate(app_id, type, timespan_seconds));
+ }
};
- //TODO(AKutsan) REMOVE THIS UGLY HOTFIX
-
+ // TODO(AKutsan) REMOVE THIS UGLY HOTFIX
PolicyHandler();
- bool SaveSnapshot(const BinaryMessage& pt_string, std::string& snap_path);
- static PolicyHandler* instance_;
+ bool SaveSnapshot(const BinaryMessage &pt_string, std::string &snap_path);
+ static PolicyHandler *instance_;
static const std::string kLibrary;
mutable sync_primitives::RWLock policy_manager_lock_;
utils::SharedPtr<PolicyManager> policy_manager_;
- void* dl_handle_;
+ void *dl_handle_;
AppIds last_used_app_ids_;
utils::SharedPtr<PolicyEventObserver> event_observer_;
uint32_t last_activated_app_id_;
@@ -442,7 +449,7 @@ private:
inline bool CreateManager();
- typedef std::list <PolicyHandlerObserver*> HandlersCollection;
+ typedef std::list<PolicyHandlerObserver *> HandlersCollection;
HandlersCollection listeners_;
sync_primitives::Lock listeners_lock_;
@@ -460,11 +467,11 @@ private:
friend class AppPermissionDelegate;
DISALLOW_COPY_AND_ASSIGN(PolicyHandler);
- FRIEND_BASE_SINGLETON_CLASS_WITH_DELETER(PolicyHandler,
- utils::deleters::Deleter<PolicyHandler>);
+ FRIEND_BASE_SINGLETON_CLASS_WITH_DELETER(
+ PolicyHandler, utils::deleters::Deleter<PolicyHandler>);
FRIEND_DELETER_DESTRUCTOR(PolicyHandler);
};
-} // namespace policy
+} // namespace policy
-#endif // SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_POLICY_HANDLER_H_
+#endif // SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_POLICY_HANDLER_H_
diff --git a/src/components/application_manager/include/application_manager/state_controller.h b/src/components/application_manager/include/application_manager/state_controller.h
index fc10597a6a..a09d11f18e 100644
--- a/src/components/application_manager/include/application_manager/state_controller.h
+++ b/src/components/application_manager/include/application_manager/state_controller.h
@@ -45,364 +45,364 @@
namespace application_manager {
class ApplicationManagerImpl;
class StateController : public event_engine::EventObserver {
- public:
-
- StateController();
-
- /**
- * @brief SetRegularState setup regular hmi state, tha will appear if no
- * specific events are active
- * @param app appication to setup regular State
- * @param state state of new regular state
- */
- template <bool SendActivateApp>
- void SetRegularState(ApplicationSharedPtr app,
- HmiStatePtr state) {
- if (!app) {
- return;
- }
- DCHECK_OR_RETURN_VOID(state);
- DCHECK_OR_RETURN_VOID(state->state_id() == HmiState::STATE_ID_REGULAR);
-
- if (SendActivateApp) {
- uint32_t corr_id = MessageHelper::SendActivateAppToHMI(app->app_id());
- subscribe_on_event(hmi_apis::FunctionID::BasicCommunication_ActivateApp,
- corr_id);
- waiting_for_activate[app->app_id()] = state;
- } else {
- ApplyRegularState(app, state);
- }
+public:
+ StateController();
+
+ /**
+ * @brief SetRegularState setup regular hmi state, tha will appear if no
+ * specific events are active
+ * @param app appication to setup regular State
+ * @param state state of new regular state
+ */
+ template <bool SendActivateApp>
+ void SetRegularState(ApplicationSharedPtr app, HmiStatePtr state) {
+ if (!app) {
+ return;
}
-
- /**
- * @brief SetRegularState Change regular audio state
- * @param app appication to setup regular State
- * @param audio_state of new regular state
- */
- void SetRegularState(ApplicationSharedPtr app,
- const mobile_apis::AudioStreamingState::eType audio_state);
-
- /**
- * @brief SetRegularState Change regular hmi level and audio state
- * @param app appication to setup regular State
- * @param hmi_level of new regular state
- * @param audio_state of new regular state
- * @param SendActivateApp: if true, ActivateAppRequest will be sent on HMI */
- template <bool SendActivateApp>
- void SetRegularState(ApplicationSharedPtr app,
- const mobile_apis::HMILevel::eType hmi_level,
- const mobile_apis::AudioStreamingState::eType audio_state) {
- if (!app) {
- return;
- }
- HmiStatePtr prev_regular = app->RegularHmiState();
- DCHECK_OR_RETURN_VOID(prev_regular);
- HmiStatePtr hmi_state = CreateHmiState(app->app_id(),
- HmiState::StateID::STATE_ID_REGULAR);
- DCHECK_OR_RETURN_VOID(hmi_state);
- hmi_state->set_hmi_level(hmi_level);
- hmi_state->set_audio_streaming_state(audio_state);
- hmi_state->set_system_context(prev_regular->system_context());
- SetRegularState<SendActivateApp>(app, hmi_state);
+ DCHECK_OR_RETURN_VOID(state);
+ DCHECK_OR_RETURN_VOID(state->state_id() == HmiState::STATE_ID_REGULAR);
+
+ if (SendActivateApp) {
+ uint32_t corr_id = MessageHelper::SendActivateAppToHMI(app->app_id());
+ subscribe_on_event(hmi_apis::FunctionID::BasicCommunication_ActivateApp,
+ corr_id);
+ waiting_for_activate[app->app_id()] = state;
+ } else {
+ ApplyRegularState(app, state);
}
-
-
- /**
- * @brief SetRegularState Change regular hmi level
- * @param app appication to setup regular State
- * @param hmi_level of new regular state
- * @param SendActivateApp: if true, ActivateAppRequest will be sent on HMI */
- template <bool SendActivateApp>
- void SetRegularState(ApplicationSharedPtr app,
- const mobile_apis::HMILevel::eType hmi_level) {
- if (!app) {
- return;
- }
- HmiStatePtr prev_regular = app->RegularHmiState();
- DCHECK_OR_RETURN_VOID(prev_regular);
- HmiStatePtr hmi_state = CreateHmiState(app->app_id(),
- HmiState::StateID::STATE_ID_REGULAR);
- DCHECK_OR_RETURN_VOID(hmi_state);
- hmi_state->set_hmi_level(hmi_level);
- hmi_state->set_audio_streaming_state(prev_regular->audio_streaming_state());
- hmi_state->set_system_context(prev_regular->system_context());
- SetRegularState<SendActivateApp>(app, hmi_state);
+ }
+
+ /**
+ * @brief SetRegularState Change regular audio state
+ * @param app appication to setup regular State
+ * @param audio_state of new regular state
+ */
+ void
+ SetRegularState(ApplicationSharedPtr app,
+ const mobile_apis::AudioStreamingState::eType audio_state);
+
+ /**
+ * @brief SetRegularState Change regular hmi level and audio state
+ * @param app appication to setup regular State
+ * @param hmi_level of new regular state
+ * @param audio_state of new regular state
+ * @param SendActivateApp: if true, ActivateAppRequest will be sent on HMI */
+ template <bool SendActivateApp>
+ void
+ SetRegularState(ApplicationSharedPtr app,
+ const mobile_apis::HMILevel::eType hmi_level,
+ const mobile_apis::AudioStreamingState::eType audio_state) {
+ if (!app) {
+ return;
}
-
- /**
- * @brief SetRegularState Change regular hmi level, audio state and system context
- * @param app appication to setup regular State
- * @param hmi_level of new regular state
- * @param audio_state of new regular state
- * @param system_context of new regular state
- * @param SendActivateApp: if true, ActivateAppRequest will be sent on HMI */
- template <bool SendActivateApp>
- void SetRegularState(ApplicationSharedPtr app,
- const mobile_apis::HMILevel::eType hmi_level,
- const mobile_apis::AudioStreamingState::eType audio_state,
- const mobile_apis::SystemContext::eType system_context) {
- if (!app) {
- return;
- }
-
- HmiStatePtr hmi_state = CreateHmiState(app->app_id(),
- HmiState::StateID::STATE_ID_REGULAR);
- DCHECK_OR_RETURN_VOID(hmi_state);
- hmi_state->set_hmi_level(hmi_level);
- hmi_state->set_audio_streaming_state(audio_state);
- hmi_state->set_system_context(system_context);
- SetRegularState<SendActivateApp>(app, hmi_state);
+ HmiStatePtr prev_regular = app->RegularHmiState();
+ DCHECK_OR_RETURN_VOID(prev_regular);
+ HmiStatePtr hmi_state =
+ CreateHmiState(app->app_id(), HmiState::StateID::STATE_ID_REGULAR);
+ DCHECK_OR_RETURN_VOID(hmi_state);
+ hmi_state->set_hmi_level(hmi_level);
+ hmi_state->set_audio_streaming_state(audio_state);
+ hmi_state->set_system_context(prev_regular->system_context());
+ SetRegularState<SendActivateApp>(app, hmi_state);
+ }
+
+ /**
+ * @brief SetRegularState Change regular hmi level
+ * @param app appication to setup regular State
+ * @param hmi_level of new regular state
+ * @param SendActivateApp: if true, ActivateAppRequest will be sent on HMI */
+ template <bool SendActivateApp>
+ void SetRegularState(ApplicationSharedPtr app,
+ const mobile_apis::HMILevel::eType hmi_level) {
+ if (!app) {
+ return;
}
-
- /**
- * @brief SetRegularState Change regular system context
- * @param app appication to setup regular State
- * @param system_context of new regular state
- */
- void SetRegularState(ApplicationSharedPtr app,
- const mobile_apis::SystemContext::eType system_context) {
- if (!app) {
- return;
- }
- HmiStatePtr prev_regular = app->RegularHmiState();
- DCHECK_OR_RETURN_VOID(prev_regular);
- HmiStatePtr hmi_state = CreateHmiState(app->app_id(),
- HmiState::StateID::STATE_ID_REGULAR);
- DCHECK_OR_RETURN_VOID(hmi_state);
- hmi_state->set_hmi_level(prev_regular->hmi_level());
- hmi_state->set_audio_streaming_state(prev_regular->audio_streaming_state());
- hmi_state->set_system_context(system_context);
- SetRegularState<false>(app, hmi_state);
+ HmiStatePtr prev_regular = app->RegularHmiState();
+ DCHECK_OR_RETURN_VOID(prev_regular);
+ HmiStatePtr hmi_state =
+ CreateHmiState(app->app_id(), HmiState::StateID::STATE_ID_REGULAR);
+ DCHECK_OR_RETURN_VOID(hmi_state);
+ hmi_state->set_hmi_level(hmi_level);
+ hmi_state->set_audio_streaming_state(prev_regular->audio_streaming_state());
+ hmi_state->set_system_context(prev_regular->system_context());
+ SetRegularState<SendActivateApp>(app, hmi_state);
+ }
+
+ /**
+ * @brief SetRegularState Change regular hmi level, audio state and system
+ * context
+ * @param app appication to setup regular State
+ * @param hmi_level of new regular state
+ * @param audio_state of new regular state
+ * @param system_context of new regular state
+ * @param SendActivateApp: if true, ActivateAppRequest will be sent on HMI */
+ template <bool SendActivateApp>
+ void
+ SetRegularState(ApplicationSharedPtr app,
+ const mobile_apis::HMILevel::eType hmi_level,
+ const mobile_apis::AudioStreamingState::eType audio_state,
+ const mobile_apis::SystemContext::eType system_context) {
+ if (!app) {
+ return;
}
- // EventObserver interface
- void on_event(const event_engine::Event& event);
-
- /**
- * @brief OnStateChanged send HMIStatusNotification if neded
- * @param app application
- * @param old_state state before change
- * @param new_state state after change
- */
- void OnStateChanged(ApplicationSharedPtr app, HmiStatePtr old_state,
- HmiStatePtr new_state);
- /**
- * @brief state_context getter for state_context
- * @return
- */
- const StateContext& state_context() const {
- return state_context_;
+ HmiStatePtr hmi_state =
+ CreateHmiState(app->app_id(), HmiState::StateID::STATE_ID_REGULAR);
+ DCHECK_OR_RETURN_VOID(hmi_state);
+ hmi_state->set_hmi_level(hmi_level);
+ hmi_state->set_audio_streaming_state(audio_state);
+ hmi_state->set_system_context(system_context);
+ SetRegularState<SendActivateApp>(app, hmi_state);
+ }
+
+ /**
+ * @brief SetRegularState Change regular system context
+ * @param app appication to setup regular State
+ * @param system_context of new regular state
+ */
+ void SetRegularState(ApplicationSharedPtr app,
+ const mobile_apis::SystemContext::eType system_context) {
+ if (!app) {
+ return;
}
-
- /**
- * @brief ApplyStatesForApp apply active HMI states for new App without s
- * ending any OnHMIStatus
- * @param app application to apply states
- */
- void ApplyStatesForApp(ApplicationSharedPtr app);
-
- /**
- * @brief OnNaviStreamingStarted process Navi streaming started
- */
- void OnNaviStreamingStarted();
-
- /**
- * @brief OnNaviStreamingStopped process Navi streaming stopped
- */
- void OnNaviStreamingStopped();
-
- private:
- /**
- * Execute Unary punction for each application
- */
- template < typename UnaryFunction,
- typename ContextAcessor = ApplicationManagerImpl >
- void ForEachApplication(UnaryFunction func) {
- using namespace utils;
- typename ContextAcessor::ApplicationListAccessor accessor;
- typedef typename ContextAcessor::ApplictionSetConstIt Iter;
- for (Iter it = accessor.begin(); it != accessor.end(); ++it) {
- if (it->valid()) {
- ApplicationConstSharedPtr const_app = *it;
- func(ContextAcessor::instance()->application(const_app->app_id()));
- }
+ HmiStatePtr prev_regular = app->RegularHmiState();
+ DCHECK_OR_RETURN_VOID(prev_regular);
+ HmiStatePtr hmi_state =
+ CreateHmiState(app->app_id(), HmiState::StateID::STATE_ID_REGULAR);
+ DCHECK_OR_RETURN_VOID(hmi_state);
+ hmi_state->set_hmi_level(prev_regular->hmi_level());
+ hmi_state->set_audio_streaming_state(prev_regular->audio_streaming_state());
+ hmi_state->set_system_context(system_context);
+ SetRegularState<false>(app, hmi_state);
+ }
+
+ // EventObserver interface
+ void on_event(const event_engine::Event &event);
+
+ /**
+ * @brief Sets default application state and apply currently active HMI states
+ * on application registration
+ * @param app application to apply states
+ * @param default_level default HMI level
+ */
+ virtual void
+ OnApplicationRegistered(ApplicationSharedPtr app,
+ const mobile_apis::HMILevel::eType default_level);
+
+ /**
+ * @brief OnStateChanged send HMIStatusNotification if neded
+ * @param app application
+ * @param old_state state before change
+ * @param new_state state after change
+ */
+ void OnStateChanged(ApplicationSharedPtr app, HmiStatePtr old_state,
+ HmiStatePtr new_state);
+ /**
+ * @brief state_context getter for state_context
+ * @return
+ */
+ const StateContext &state_context() const { return state_context_; }
+
+ /**
+ * @brief OnNaviStreamingStarted process Navi streaming started
+ */
+ void OnNaviStreamingStarted();
+
+ /**
+ * @brief OnNaviStreamingStopped process Navi streaming stopped
+ */
+ void OnNaviStreamingStopped();
+
+private:
+ /**
+ * Execute Unary punction for each application
+ */
+ template <typename UnaryFunction,
+ typename ContextAcessor = ApplicationManagerImpl>
+ void ForEachApplication(UnaryFunction func) {
+ using namespace utils;
+ typename ContextAcessor::ApplicationListAccessor accessor;
+ typedef typename ContextAcessor::ApplictionSetConstIt Iter;
+ for (Iter it = accessor.begin(); it != accessor.end(); ++it) {
+ if (it->valid()) {
+ ApplicationConstSharedPtr const_app = *it;
+ func(ContextAcessor::instance()->application(const_app->app_id()));
}
}
-
- /**
- * @brief The HmiLevelConflictResolver struct
- * Move other application to HmiStates if applied moved to FULL or LIMITED
- */
- struct HmiLevelConflictResolver {
- ApplicationSharedPtr applied_;
- HmiStatePtr state_;
- StateController* state_ctrl_;
- HmiLevelConflictResolver(ApplicationSharedPtr app,
- HmiStatePtr state,
- StateController* state_ctrl):
- applied_(app), state_(state) {}
- void operator()(ApplicationSharedPtr to_resolve);
- };
-
- /**
- * Function to add new temporary HmiState for application
- */
- template <HmiState::StateID ID>
- void HMIStateStarted(ApplicationSharedPtr app) {
- DCHECK_OR_RETURN_VOID(app);
- HmiStatePtr old_hmi_state = app->CurrentHmiState();
- HmiStatePtr new_hmi_state = CreateHmiState(app->app_id(), ID);
- DCHECK_OR_RETURN_VOID(new_hmi_state);
- DCHECK_OR_RETURN_VOID(new_hmi_state->state_id() != HmiState::STATE_ID_REGULAR);
- new_hmi_state->set_parent(old_hmi_state);
- app->AddHMIState(new_hmi_state);
- OnStateChanged(app, old_hmi_state, new_hmi_state);
- }
-
- /**
- * @brief TempStateStarted add HMI State ID in StateController collection
- * @param ID state identifier
- */
- void TempStateStarted(HmiState::StateID ID);
-
- /**
- * @brief TempStateStopped remove HMI State ID from StateController collection
- * @param ID state identifier
- */
- void TempStateStopped(HmiState::StateID ID);
-
-
- /**
- * Function to remove temporary HmiState for application
- */
- template <HmiState::StateID ID>
- void HMIStateStopped(ApplicationSharedPtr app) {
- DCHECK_OR_RETURN_VOID(app);
- HmiStatePtr cur = app->CurrentHmiState();
- HmiStatePtr old_hmi_state = CreateHmiState(app->app_id(),
- HmiState::StateID::STATE_ID_REGULAR);
- DCHECK_OR_RETURN_VOID(old_hmi_state);
- old_hmi_state->set_hmi_level(cur->hmi_level());
- old_hmi_state->set_audio_streaming_state(cur->audio_streaming_state());
- old_hmi_state->set_system_context(cur->system_context());
- app->RemoveHMIState(ID);
- HmiStatePtr new_hmi_state = app->CurrentHmiState();
- OnStateChanged(app, old_hmi_state, new_hmi_state);
- }
-
- /**
- * @brief ApplyRegularState setup regular hmi state, that will appear if no
- * specific events are active, without sending ActivateApp
- * @param app appication to setup default State
- * @param state state of new defailt state
- */
- void ApplyRegularState(ApplicationSharedPtr app,
- HmiStatePtr state);
-
- /**
- * @brief SetupRegularHmiState set regular HMI State without
- * resolwing conflicts and ActivateApp request
- * @param app application
- * @param state hmi_state to setup
- */
- void SetupRegularHmiState(ApplicationSharedPtr app,
- HmiStatePtr state);
-
- /**
- * @brief IsSameAppType checkis if apps has same types
- * @param app1
- * @param app2
- * @return true if aps have same types, otherwise return false
- */
- bool IsSameAppType(ApplicationConstSharedPtr app1,
- ApplicationConstSharedPtr app2);
-
- /**
- * @brief SetupRegularHmiState set regular HMI State without
- * resolwing conflicts and ActivateApp request
- * @param app application
- * @param hmi_level of new regular state
- * @param audio_state of new regular state
- * @param system_context of new regular state
- */
- void SetupRegularHmiState(ApplicationSharedPtr app,
- const mobile_apis::HMILevel::eType hmi_level,
- const mobile_apis::AudioStreamingState::eType audio_state,
- const mobile_apis::SystemContext::eType system_context);
-
- /**
- * @brief SetupRegularHmiState set regular HMI State without
- * resolwing conflicts and ActivateApp request
- * @param app application
- * @param hmi_level of new regular state
- * @param audio_state of new regular state
- */
- void SetupRegularHmiState(ApplicationSharedPtr app,
- const mobile_apis::HMILevel::eType hmi_level,
- const mobile_apis::AudioStreamingState::eType audio_state);
-
- /**
- * @brief OnActivateAppResponse calback for activate app response
- * @param message Smart Object
- */
- void OnActivateAppResponse(const smart_objects::SmartObject& message);
-
- /**
- * @brief OnPhoneCallStarted process Phone Call Started event
- */
- void OnPhoneCallStarted();
-
- /**
- * @brief OnPhoneCallEnded process Phone Call Ended event
- */
- void OnPhoneCallEnded();
-
-
- /**
- * @brief OnSafetyModeEnabled process Safety Mode Enable event
- */
- void OnSafetyModeEnabled();
-
- /**
- * @brief OnSafetyModeDisabled process Safety Mode Disable event
- */
- void OnSafetyModeDisabled();
-
- /**
- * @brief OnVRStarted process VR session started
- */
- void OnVRStarted();
-
- /**
- * @brief OnVREnded process VR session ended
- */
- void OnVREnded();
- /**
- * @brief OnTTSStarted process TTS session started
- */
- void OnTTSStarted();
-
- /**
- * @brief OnTTSEnded process TTS session ended
- */
- void OnTTSStopped();
-
- /**
- * @brief CreateHmiState creates Hmi state according to state_id
- * @param app_id application ID
- * @param state_id state id
- * @return
- */
- HmiStatePtr CreateHmiState(uint32_t app_id, HmiState::StateID state_id);
-
- typedef std::list<HmiState::StateID> StateIDList;
- StateIDList active_states_;
- sync_primitives::Lock active_states_lock_;
- std::map<uint32_t, HmiStatePtr> waiting_for_activate;
- StateContext state_context_;
+ }
+
+ /**
+ * @brief The HmiLevelConflictResolver struct
+ * Move other application to HmiStates if applied moved to FULL or LIMITED
+ */
+ struct HmiLevelConflictResolver {
+ ApplicationSharedPtr applied_;
+ HmiStatePtr state_;
+ StateController *state_ctrl_;
+ HmiLevelConflictResolver(ApplicationSharedPtr app, HmiStatePtr state,
+ StateController *state_ctrl)
+ : applied_(app), state_(state) {}
+ void operator()(ApplicationSharedPtr to_resolve);
+ };
+
+ /**
+ * Function to add new temporary HmiState for application
+ */
+ template <HmiState::StateID ID>
+ void HMIStateStarted(ApplicationSharedPtr app) {
+ DCHECK_OR_RETURN_VOID(app);
+ HmiStatePtr old_hmi_state = app->CurrentHmiState();
+ HmiStatePtr new_hmi_state = CreateHmiState(app->app_id(), ID);
+ DCHECK_OR_RETURN_VOID(new_hmi_state);
+ DCHECK_OR_RETURN_VOID(new_hmi_state->state_id() !=
+ HmiState::STATE_ID_REGULAR);
+ new_hmi_state->set_parent(old_hmi_state);
+ app->AddHMIState(new_hmi_state);
+ OnStateChanged(app, old_hmi_state, new_hmi_state);
+ }
+
+ /**
+ * @brief TempStateStarted add HMI State ID in StateController collection
+ * @param ID state identifier
+ */
+ void TempStateStarted(HmiState::StateID ID);
+
+ /**
+ * @brief TempStateStopped remove HMI State ID from StateController collection
+ * @param ID state identifier
+ */
+ void TempStateStopped(HmiState::StateID ID);
+
+ /**
+ * Function to remove temporary HmiState for application
+ */
+ template <HmiState::StateID ID>
+ void HMIStateStopped(ApplicationSharedPtr app) {
+ DCHECK_OR_RETURN_VOID(app);
+ HmiStatePtr cur = app->CurrentHmiState();
+ HmiStatePtr old_hmi_state =
+ CreateHmiState(app->app_id(), HmiState::StateID::STATE_ID_REGULAR);
+ DCHECK_OR_RETURN_VOID(old_hmi_state);
+ old_hmi_state->set_hmi_level(cur->hmi_level());
+ old_hmi_state->set_audio_streaming_state(cur->audio_streaming_state());
+ old_hmi_state->set_system_context(cur->system_context());
+ app->RemoveHMIState(ID);
+ HmiStatePtr new_hmi_state = app->CurrentHmiState();
+ OnStateChanged(app, old_hmi_state, new_hmi_state);
+ }
+
+ /**
+ * @brief ApplyRegularState setup regular hmi state, that will appear if no
+ * specific events are active, without sending ActivateApp
+ * @param app appication to setup default State
+ * @param state state of new defailt state
+ */
+ void ApplyRegularState(ApplicationSharedPtr app, HmiStatePtr state);
+
+ /**
+ * @brief SetupRegularHmiState set regular HMI State without
+ * resolwing conflicts and ActivateApp request
+ * @param app application
+ * @param state hmi_state to setup
+ */
+ void SetupRegularHmiState(ApplicationSharedPtr app, HmiStatePtr state);
+
+ /**
+ * @brief IsSameAppType checkis if apps has same types
+ * @param app1
+ * @param app2
+ * @return true if aps have same types, otherwise return false
+ */
+ bool IsSameAppType(ApplicationConstSharedPtr app1,
+ ApplicationConstSharedPtr app2);
+
+ /**
+ * @brief SetupRegularHmiState set regular HMI State without
+ * resolwing conflicts and ActivateApp request
+ * @param app application
+ * @param hmi_level of new regular state
+ * @param audio_state of new regular state
+ * @param system_context of new regular state
+ */
+ void SetupRegularHmiState(
+ ApplicationSharedPtr app, const mobile_apis::HMILevel::eType hmi_level,
+ const mobile_apis::AudioStreamingState::eType audio_state,
+ const mobile_apis::SystemContext::eType system_context);
+
+ /**
+ * @brief SetupRegularHmiState set regular HMI State without
+ * resolwing conflicts and ActivateApp request
+ * @param app application
+ * @param hmi_level of new regular state
+ * @param audio_state of new regular state
+ */
+ void SetupRegularHmiState(
+ ApplicationSharedPtr app, const mobile_apis::HMILevel::eType hmi_level,
+ const mobile_apis::AudioStreamingState::eType audio_state);
+
+ /**
+ * @brief OnActivateAppResponse calback for activate app response
+ * @param message Smart Object
+ */
+ void OnActivateAppResponse(const smart_objects::SmartObject &message);
+
+ /**
+ * @brief OnPhoneCallStarted process Phone Call Started event
+ */
+ void OnPhoneCallStarted();
+
+ /**
+ * @brief OnPhoneCallEnded process Phone Call Ended event
+ */
+ void OnPhoneCallEnded();
+
+ /**
+ * @brief OnSafetyModeEnabled process Safety Mode Enable event
+ */
+ void OnSafetyModeEnabled();
+
+ /**
+ * @brief OnSafetyModeDisabled process Safety Mode Disable event
+ */
+ void OnSafetyModeDisabled();
+
+ /**
+ * @brief OnVRStarted process VR session started
+ */
+ void OnVRStarted();
+
+ /**
+ * @brief OnVREnded process VR session ended
+ */
+ void OnVREnded();
+ /**
+ * @brief OnTTSStarted process TTS session started
+ */
+ void OnTTSStarted();
+
+ /**
+ * @brief OnTTSEnded process TTS session ended
+ */
+ void OnTTSStopped();
+
+ /**
+ * @brief CreateHmiState creates Hmi state according to state_id
+ * @param app_id application ID
+ * @param state_id state id
+ * @return
+ */
+ HmiStatePtr CreateHmiState(uint32_t app_id, HmiState::StateID state_id);
+
+ mobile_apis::AudioStreamingState::eType
+ CalcAudioState(ApplicationSharedPtr app,
+ const mobile_apis::HMILevel::eType hmi_level) const;
+
+ typedef std::list<HmiState::StateID> StateIDList;
+ StateIDList active_states_;
+ sync_primitives::Lock active_states_lock_;
+ std::map<uint32_t, HmiStatePtr> waiting_for_activate;
+ StateContext state_context_;
};
-
}
#endif // SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_STATE_CONTROLLER_H_
-
diff --git a/src/components/application_manager/src/application_manager_impl.cc b/src/components/application_manager/src/application_manager_impl.cc
index d5f9f49e71..2aba14ec30 100644
--- a/src/components/application_manager/src/application_manager_impl.cc
+++ b/src/components/application_manager/src/application_manager_impl.cc
@@ -30,7 +30,7 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-#include <stdlib.h> // for rand()
+#include <stdlib.h> // for rand()
#include <climits>
#include <string>
@@ -61,9 +61,9 @@
#include <time.h>
namespace {
- int get_rand_from_range(uint32_t from = 0, int to = RAND_MAX) {
- return std::rand() % to + from;
- }
+int get_rand_from_range(uint32_t from = 0, int to = RAND_MAX) {
+ return std::rand() % to + from;
+}
}
namespace application_manager {
@@ -79,55 +79,47 @@ namespace jhs = NsSmartDeviceLink::NsJSONHandler::strings;
using namespace NsSmartDeviceLink::NsSmartObjects;
ApplicationManagerImpl::ApplicationManagerImpl()
- : applications_list_lock_(true),
- audio_pass_thru_active_(false),
- is_distracting_driver_(false),
- is_vr_session_strated_(false),
- hmi_cooperating_(false),
- is_all_apps_allowed_(true),
- media_manager_(NULL),
- hmi_handler_(NULL),
- connection_handler_(NULL),
- protocol_handler_(NULL),
- request_ctrl_(),
- hmi_so_factory_(NULL),
- mobile_so_factory_(NULL),
- messages_from_mobile_("AM FromMobile", this),
- messages_to_mobile_("AM ToMobile", this),
- messages_from_hmi_("AM FromHMI", this),
- messages_to_hmi_("AM ToHMI", this),
- audio_pass_thru_messages_("AudioPassThru", this),
- hmi_capabilities_(this),
- unregister_reason_(mobile_api::AppInterfaceUnregisteredReason::INVALID_ENUM),
- resume_ctrl_(this),
- navi_close_app_timeout_(profile::Profile::instance()->stop_streaming_timeout()),
- navi_end_stream_timeout_(profile::Profile::instance()->stop_streaming_timeout()),
- stopping_flag_lock_(true),
+ : applications_list_lock_(true), audio_pass_thru_active_(false),
+ is_distracting_driver_(false), is_vr_session_strated_(false),
+ hmi_cooperating_(false), is_all_apps_allowed_(true), media_manager_(NULL),
+ hmi_handler_(NULL), connection_handler_(NULL), protocol_handler_(NULL),
+ request_ctrl_(), hmi_so_factory_(NULL), mobile_so_factory_(NULL),
+ messages_from_mobile_("AM FromMobile", this),
+ messages_to_mobile_("AM ToMobile", this),
+ messages_from_hmi_("AM FromHMI", this),
+ messages_to_hmi_("AM ToHMI", this),
+ audio_pass_thru_messages_("AudioPassThru", this), hmi_capabilities_(this),
+ unregister_reason_(
+ mobile_api::AppInterfaceUnregisteredReason::INVALID_ENUM),
+ resume_ctrl_(this),
+ navi_close_app_timeout_(
+ profile::Profile::instance()->stop_streaming_timeout()),
+ navi_end_stream_timeout_(
+ profile::Profile::instance()->stop_streaming_timeout()),
+ stopping_flag_lock_(true),
#ifdef TIME_TESTER
- metric_observer_(NULL),
-#endif // TIME_TESTER
- application_list_update_timer_(new ApplicationListUpdateTimer(this)),
- tts_global_properties_timer_("TTSGLPRTimer",
- this,
- &ApplicationManagerImpl::OnTimerSendTTSGlobalProperties,
- true),
- is_low_voltage_(false),
- is_stopping_(false) {
-
- std::srand(std::time(0));
- AddPolicyObserver(this);
-
- dir_type_to_string_map_ = {
- {TYPE_STORAGE, "Storage"},
- {TYPE_SYSTEM, "System"},
- {TYPE_ICONS, "Icons"}
- };
+ metric_observer_(NULL),
+#endif // TIME_TESTER
+ application_list_update_timer_(new ApplicationListUpdateTimer(this)),
+ tts_global_properties_timer_(
+ "TTSGLPRTimer", this,
+ &ApplicationManagerImpl::OnTimerSendTTSGlobalProperties, true),
+ is_low_voltage_(false), is_stopping_(false) {
- sync_primitives::AutoLock lock(timer_pool_lock_);
- ApplicationManagerTimerPtr clearTimerPoolTimer(new TimerThread<ApplicationManagerImpl>(
- "ClearTimerPoolTimer", this, &ApplicationManagerImpl::ClearTimerPool, true));
- clearTimerPoolTimer->start(10);
- timer_pool_.push_back(clearTimerPoolTimer);
+ std::srand(std::time(0));
+ AddPolicyObserver(this);
+
+ dir_type_to_string_map_ = {{TYPE_STORAGE, "Storage"},
+ {TYPE_SYSTEM, "System"},
+ {TYPE_ICONS, "Icons"}};
+
+ sync_primitives::AutoLock lock(timer_pool_lock_);
+ ApplicationManagerTimerPtr clearTimerPoolTimer(
+ new TimerThread<ApplicationManagerImpl>(
+ "ClearTimerPoolTimer", this, &ApplicationManagerImpl::ClearTimerPool,
+ true));
+ clearTimerPoolTimer->start(10);
+ timer_pool_.push_back(clearTimerPoolTimer);
}
ApplicationManagerImpl::~ApplicationManagerImpl() {
@@ -138,11 +130,11 @@ ApplicationManagerImpl::~ApplicationManagerImpl() {
media_manager_ = NULL;
hmi_handler_ = NULL;
connection_handler_ = NULL;
- if(hmi_so_factory_) {
+ if (hmi_so_factory_) {
delete hmi_so_factory_;
hmi_so_factory_ = NULL;
}
- if(mobile_so_factory_) {
+ if (mobile_so_factory_) {
delete mobile_so_factory_;
mobile_so_factory_ = NULL;
}
@@ -181,7 +173,8 @@ bool ApplicationManagerImpl::Stop() {
return true;
}
-ApplicationSharedPtr ApplicationManagerImpl::application(uint32_t app_id) const {
+ApplicationSharedPtr
+ApplicationManagerImpl::application(uint32_t app_id) const {
AppIdPredicate finder(app_id);
ApplicationListAccessor accessor;
ApplicationSharedPtr app = accessor.Find(finder);
@@ -189,8 +182,8 @@ ApplicationSharedPtr ApplicationManagerImpl::application(uint32_t app_id) const
return app;
}
-ApplicationSharedPtr ApplicationManagerImpl::application_by_hmi_app(
- uint32_t hmi_app_id) const {
+ApplicationSharedPtr
+ApplicationManagerImpl::application_by_hmi_app(uint32_t hmi_app_id) const {
HmiAppIdPredicate finder(hmi_app_id);
ApplicationListAccessor accessor;
ApplicationSharedPtr app = accessor.Find(finder);
@@ -199,15 +192,16 @@ ApplicationSharedPtr ApplicationManagerImpl::application_by_hmi_app(
}
ApplicationSharedPtr ApplicationManagerImpl::application_by_policy_id(
- const std::string& policy_app_id) const {
+ const std::string &policy_app_id) const {
MobileAppIdPredicate finder(policy_app_id);
ApplicationListAccessor accessor;
ApplicationSharedPtr app = accessor.Find(finder);
- LOG4CXX_DEBUG(logger_, " policy_app_id << " << policy_app_id << "Found = " << app);
+ LOG4CXX_DEBUG(logger_, " policy_app_id << " << policy_app_id
+ << "Found = " << app);
return app;
}
-bool ActiveAppPredicate (const ApplicationSharedPtr app) {
+bool ActiveAppPredicate(const ApplicationSharedPtr app) {
return app ? app->IsFullscreen() : false;
}
@@ -219,9 +213,8 @@ ApplicationSharedPtr ApplicationManagerImpl::active_application() const {
return app;
}
-bool LimitedAppPredicate (const ApplicationSharedPtr app) {
- return app ? app->hmi_level() == mobile_api::HMILevel::HMI_LIMITED :
- false;
+bool LimitedAppPredicate(const ApplicationSharedPtr app) {
+ return app ? app->hmi_level() == mobile_api::HMILevel::HMI_LIMITED : false;
}
ApplicationSharedPtr
@@ -232,10 +225,10 @@ ApplicationManagerImpl::get_limited_media_application() const {
return app;
}
-bool LimitedNaviAppPredicate (const ApplicationSharedPtr app) {
+bool LimitedNaviAppPredicate(const ApplicationSharedPtr app) {
return app ? (app->is_navi() &&
- app->hmi_level() == mobile_api::HMILevel::HMI_LIMITED) :
- false;
+ app->hmi_level() == mobile_api::HMILevel::HMI_LIMITED)
+ : false;
}
ApplicationSharedPtr
@@ -246,10 +239,10 @@ ApplicationManagerImpl::get_limited_navi_application() const {
return app;
}
-bool LimitedVoiceAppPredicate (const ApplicationSharedPtr app) {
+bool LimitedVoiceAppPredicate(const ApplicationSharedPtr app) {
return app ? (app->is_voice_communication_supported() &&
- app->hmi_level() == mobile_api::HMILevel::HMI_LIMITED) :
- false;
+ app->hmi_level() == mobile_api::HMILevel::HMI_LIMITED)
+ : false;
}
ApplicationSharedPtr
@@ -260,47 +253,56 @@ ApplicationManagerImpl::get_limited_voice_application() const {
return app;
}
-bool NaviAppPredicate (const ApplicationSharedPtr app) {
+bool NaviAppPredicate(const ApplicationSharedPtr app) {
return app ? app->is_navi() : false;
}
-std::vector<ApplicationSharedPtr> ApplicationManagerImpl::applications_with_navi() {
+std::vector<ApplicationSharedPtr>
+ApplicationManagerImpl::applications_with_navi() {
ApplicationListAccessor accessor;
std::vector<ApplicationSharedPtr> apps = accessor.FindAll(NaviAppPredicate);
LOG4CXX_DEBUG(logger_, " Found count: " << apps.size());
return apps;
}
-std::vector<ApplicationSharedPtr> ApplicationManagerImpl::applications_by_button(
- uint32_t button) {
+std::vector<ApplicationSharedPtr>
+ApplicationManagerImpl::applications_by_button(uint32_t button) {
SubscribedToButtonPredicate finder(
- static_cast<mobile_apis::ButtonName::eType>(button));
+ static_cast<mobile_apis::ButtonName::eType>(button));
ApplicationListAccessor accessor;
std::vector<ApplicationSharedPtr> apps = accessor.FindAll(finder);
LOG4CXX_DEBUG(logger_, " Found count: " << apps.size());
return apps;
}
-std::vector<ApplicationSharedPtr> ApplicationManagerImpl::IviInfoUpdated(
- VehicleDataType vehicle_info, int value) {
+std::vector<ApplicationSharedPtr>
+ApplicationManagerImpl::IviInfoUpdated(VehicleDataType vehicle_info,
+ int value) {
// Notify Policy Manager if available about info it's interested in,
// i.e. odometer etc
switch (vehicle_info) {
- case ODOMETER:
- policy::PolicyHandler::instance()->KmsChanged(value);
- break;
- default:
- break;
+ case ODOMETER:
+ policy::PolicyHandler::instance()->KmsChanged(value);
+ break;
+ default:
+ break;
}
- SubscribedToIVIPredicate finder(
- static_cast<int32_t>(vehicle_info));
+ SubscribedToIVIPredicate finder(static_cast<int32_t>(vehicle_info));
ApplicationListAccessor accessor;
std::vector<ApplicationSharedPtr> apps = accessor.FindAll(finder);
- LOG4CXX_DEBUG(logger_, " vehicle_info << " << vehicle_info << "Found count: " << apps.size());
+ LOG4CXX_DEBUG(logger_, " vehicle_info << " << vehicle_info
+ << "Found count: " << apps.size());
return apps;
}
+void ApplicationManagerImpl::OnApplicationRegistered(ApplicationSharedPtr app) {
+ DCHECK_OR_RETURN_VOID(app);
+ sync_primitives::AutoLock lock(applications_list_lock_);
+ const mobile_apis::HMILevel::eType default_level = GetDefaultHmiLevel(app);
+ state_ctrl_.OnApplicationRegistered(app, default_level);
+}
+
bool ApplicationManagerImpl::IsAppTypeExistsInFullOrLimited(
ApplicationSharedPtr app) const {
bool voice_state = app->is_voice_communication_supported();
@@ -310,7 +312,8 @@ bool ApplicationManagerImpl::IsAppTypeExistsInFullOrLimited(
// Check app in FULL level
if (active_app.valid()) {
// If checking app hmi level FULL, we return false
- // because we couldn't have two applications with same HMIType in FULL and LIMITED HMI level
+ // because we couldn't have two applications with same HMIType in FULL and
+ // LIMITED HMI level
if (active_app->app_id() == app->app_id()) {
return false;
}
@@ -353,28 +356,28 @@ bool ApplicationManagerImpl::IsAppTypeExistsInFullOrLimited(
return false;
}
-
ApplicationSharedPtr ApplicationManagerImpl::RegisterApplication(
- const utils::SharedPtr<smart_objects::SmartObject>&
- request_for_registration) {
+ const utils::SharedPtr<smart_objects::SmartObject> &
+ request_for_registration) {
LOG4CXX_DEBUG(logger_, "Restarting application list update timer");
policy::PolicyHandler::instance()->OnAppsSearchStarted();
- uint32_t timeout = profile::Profile::instance()->application_list_update_timeout();
+ uint32_t timeout =
+ profile::Profile::instance()->application_list_update_timeout();
application_list_update_timer_->start(timeout);
- smart_objects::SmartObject& message = *request_for_registration;
+ smart_objects::SmartObject &message = *request_for_registration;
uint32_t connection_key =
- message[strings::params][strings::connection_key].asInt();
+ message[strings::params][strings::connection_key].asInt();
if (false == is_all_apps_allowed_) {
LOG4CXX_INFO(logger_,
"RegisterApplication: access to app's disabled by user");
utils::SharedPtr<smart_objects::SmartObject> response(
- MessageHelper::CreateNegativeResponse(
- connection_key, mobile_apis::FunctionID::RegisterAppInterfaceID,
- message[strings::params][strings::correlation_id].asUInt(),
- mobile_apis::Result::DISALLOWED));
+ MessageHelper::CreateNegativeResponse(
+ connection_key, mobile_apis::FunctionID::RegisterAppInterfaceID,
+ message[strings::params][strings::correlation_id].asUInt(),
+ mobile_apis::Result::DISALLOWED));
ManageMobileCommand(response);
return ApplicationSharedPtr();
}
@@ -386,49 +389,48 @@ ApplicationSharedPtr ApplicationManagerImpl::RegisterApplication(
uint32_t device_id = 0;
if (connection_handler_) {
- connection_handler::ConnectionHandlerImpl* con_handler_impl =
- static_cast<connection_handler::ConnectionHandlerImpl*>(
- connection_handler_);
+ connection_handler::ConnectionHandlerImpl *con_handler_impl =
+ static_cast<connection_handler::ConnectionHandlerImpl *>(
+ connection_handler_);
- if (con_handler_impl->GetDataOnSessionKey(connection_key, &app_id,
- &sessions_list, &device_id)
- == -1) {
+ if (con_handler_impl->GetDataOnSessionKey(
+ connection_key, &app_id, &sessions_list, &device_id) == -1) {
LOG4CXX_ERROR(logger_,
"Failed to create application: no connection info.");
utils::SharedPtr<smart_objects::SmartObject> response(
- MessageHelper::CreateNegativeResponse(
- connection_key, mobile_apis::FunctionID::RegisterAppInterfaceID,
- message[strings::params][strings::correlation_id].asUInt(),
- mobile_apis::Result::GENERIC_ERROR));
+ MessageHelper::CreateNegativeResponse(
+ connection_key, mobile_apis::FunctionID::RegisterAppInterfaceID,
+ message[strings::params][strings::correlation_id].asUInt(),
+ mobile_apis::Result::GENERIC_ERROR));
ManageMobileCommand(response);
return ApplicationSharedPtr();
}
}
- smart_objects::SmartObject& params = message[strings::msg_params];
+ smart_objects::SmartObject &params = message[strings::msg_params];
- const std::string& mobile_app_id = params[strings::app_id].asString();
- const std::string& app_name =
- message[strings::msg_params][strings::app_name].asString();
+ const std::string &mobile_app_id = params[strings::app_id].asString();
+ const std::string &app_name =
+ message[strings::msg_params][strings::app_name].asString();
- LOG4CXX_DEBUG(logger_, "App with connection key: " << connection_key
- << " registered from handle: " << device_id);
+ LOG4CXX_DEBUG(logger_, "App with connection key: "
+ << connection_key
+ << " registered from handle: " << device_id);
- ApplicationSharedPtr application(
- new ApplicationImpl(app_id,
- mobile_app_id, app_name,
- policy::PolicyHandler::instance()->GetStatisticManager()));
+ ApplicationSharedPtr application(new ApplicationImpl(
+ app_id, mobile_app_id, app_name,
+ policy::PolicyHandler::instance()->GetStatisticManager()));
if (!application) {
usage_statistics::AppCounter count_of_rejections_sync_out_of_memory(
- policy::PolicyHandler::instance()->GetStatisticManager(), mobile_app_id,
- usage_statistics::REJECTIONS_SYNC_OUT_OF_MEMORY);
+ policy::PolicyHandler::instance()->GetStatisticManager(), mobile_app_id,
+ usage_statistics::REJECTIONS_SYNC_OUT_OF_MEMORY);
++count_of_rejections_sync_out_of_memory;
utils::SharedPtr<smart_objects::SmartObject> response(
- MessageHelper::CreateNegativeResponse(
- connection_key, mobile_apis::FunctionID::RegisterAppInterfaceID,
- message[strings::params][strings::correlation_id].asUInt(),
- mobile_apis::Result::OUT_OF_MEMORY));
+ MessageHelper::CreateNegativeResponse(
+ connection_key, mobile_apis::FunctionID::RegisterAppInterfaceID,
+ message[strings::params][strings::correlation_id].asUInt(),
+ mobile_apis::Result::OUT_OF_MEMORY));
ManageMobileCommand(response);
return ApplicationSharedPtr();
}
@@ -436,28 +438,26 @@ ApplicationSharedPtr ApplicationManagerImpl::RegisterApplication(
application->set_device(device_id);
application->set_grammar_id(GenerateGrammarID());
mobile_api::Language::eType launguage_desired =
- static_cast<mobile_api::Language::eType>(params[strings::language_desired]
- .asInt());
+ static_cast<mobile_api::Language::eType>(
+ params[strings::language_desired].asInt());
application->set_language(launguage_desired);
application->usage_report().RecordAppRegistrationVuiLanguage(
- launguage_desired);
+ launguage_desired);
mobile_api::Language::eType hmi_display_language_desired =
- static_cast<mobile_api::Language::eType>(params[strings::hmi_display_language_desired]
- .asInt());
+ static_cast<mobile_api::Language::eType>(
+ params[strings::hmi_display_language_desired].asInt());
application->set_ui_language(hmi_display_language_desired);
application->usage_report().RecordAppRegistrationGuiLanguage(
- hmi_display_language_desired);
+ hmi_display_language_desired);
Version version;
- int32_t min_version =
- message[strings::msg_params][strings::sync_msg_version]
- [strings::minor_version].asInt();
+ int32_t min_version = message[strings::msg_params][strings::sync_msg_version]
+ [strings::minor_version].asInt();
version.min_supported_api_version = static_cast<APIVersion>(min_version);
- int32_t max_version =
- message[strings::msg_params][strings::sync_msg_version]
- [strings::major_version].asInt();
+ int32_t max_version = message[strings::msg_params][strings::sync_msg_version]
+ [strings::major_version].asInt();
version.max_supported_api_version = static_cast<APIVersion>(max_version);
application->set_version(version);
@@ -471,7 +471,7 @@ ApplicationSharedPtr ApplicationManagerImpl::RegisterApplication(
connection_key, static_cast<uint8_t>(protocol_version));
}
if (protocol_version >= ProtocolVersion::kV3 &&
- profile::Profile::instance()->heart_beat_timeout() > 0) {
+ profile::Profile::instance()->heart_beat_timeout() > 0) {
connection_handler_->StartSessionHeartBeat(connection_key);
}
}
@@ -487,17 +487,21 @@ ApplicationSharedPtr ApplicationManagerImpl::RegisterApplication(
if (!application->hmi_app_id()) {
const bool is_saved = resume_ctrl_.IsApplicationSaved(mobile_app_id);
- application->set_hmi_application_id(is_saved ?
- resume_ctrl_.GetHMIApplicationID(mobile_app_id) : GenerateNewHMIAppID());
+ application->set_hmi_application_id(
+ is_saved ? resume_ctrl_.GetHMIApplicationID(mobile_app_id)
+ : GenerateNewHMIAppID());
}
- ApplicationListAccessor app_list_accesor;
+ // Add application to registered app list and set appropriate mark.
+ // Lock has to be released before adding app to policy DB to avoid possible
+ // deadlock with simultaneous PTU processing
+ applications_list_lock_.Acquire();
application->MarkRegistered();
- state_ctrl_.ApplyStatesForApp(application);
- app_list_accesor.Insert(application);
+ applications_.insert(application);
+ applications_list_lock_.Release();
policy::PolicyHandler::instance()->AddApplication(
- application->mobile_app_id());
+ application->mobile_app_id());
return application;
}
@@ -515,18 +519,17 @@ bool ApplicationManagerImpl::ActivateApplication(ApplicationSharedPtr app) {
LOG4CXX_AUTO_TRACE(logger_);
DCHECK_OR_RETURN(app, false);
-
HMILevel::eType hmi_level = HMILevel::HMI_FULL;
AudioStreamingState::eType audio_state;
- app->IsAudioApplication() ? audio_state = AudioStreamingState::AUDIBLE :
- audio_state = AudioStreamingState::NOT_AUDIBLE;
- state_ctrl_.ApplyStatesForApp(app);
+ app->IsAudioApplication() ? audio_state = AudioStreamingState::AUDIBLE
+ : audio_state = AudioStreamingState::NOT_AUDIBLE;
+
state_ctrl_.SetRegularState<false>(app, hmi_level, audio_state);
return true;
}
-mobile_api::HMILevel::eType ApplicationManagerImpl::IsHmiLevelFullAllowed(
- ApplicationSharedPtr app) {
+mobile_api::HMILevel::eType
+ApplicationManagerImpl::IsHmiLevelFullAllowed(ApplicationSharedPtr app) {
LOG4CXX_AUTO_TRACE(logger_);
if (!app) {
LOG4CXX_ERROR(logger_, "Application pointer invalid");
@@ -546,14 +549,16 @@ mobile_api::HMILevel::eType ApplicationManagerImpl::IsHmiLevelFullAllowed(
} else if (is_active_app_exist && (!is_audio_app)) {
result = GetDefaultHmiLevel(app);
}
- LOG4CXX_ERROR(logger_, "is_audio_app : " << is_audio_app
- << "; does_audio_app_with_same_type_exist : " << does_audio_app_with_same_type_exist
- << "; is_active_app_exist : " << is_active_app_exist
- << "; result : " << result);
+ LOG4CXX_ERROR(logger_, "is_audio_app : "
+ << is_audio_app
+ << "; does_audio_app_with_same_type_exist : "
+ << does_audio_app_with_same_type_exist
+ << "; is_active_app_exist : "
+ << is_active_app_exist << "; result : " << result);
return result;
}
-void ApplicationManagerImpl::ConnectToDevice(const std::string& device_mac) {
+void ApplicationManagerImpl::ConnectToDevice(const std::string &device_mac) {
// TODO(VS): Call function from ConnectionHandler
if (!connection_handler_) {
LOG4CXX_WARN(logger_, "Connection handler is not set.");
@@ -561,9 +566,9 @@ void ApplicationManagerImpl::ConnectToDevice(const std::string& device_mac) {
}
connection_handler::DeviceHandle handle;
- if (!connection_handler_->GetDeviceID(device_mac, &handle) ) {
+ if (!connection_handler_->GetDeviceID(device_mac, &handle)) {
LOG4CXX_ERROR(logger_, "Attempt to connect to invalid device with mac:"
- << device_mac );
+ << device_mac);
return;
}
connection_handler_->ConnectToDevice(handle);
@@ -644,18 +649,18 @@ void ApplicationManagerImpl::set_driver_distraction(bool is_distracting) {
is_distracting_driver_ = is_distracting;
}
-void ApplicationManagerImpl::set_vr_session_started(const bool& state) {
+void ApplicationManagerImpl::set_vr_session_started(const bool &state) {
is_vr_session_strated_ = state;
}
-void ApplicationManagerImpl::set_all_apps_allowed(const bool& allowed) {
+void ApplicationManagerImpl::set_all_apps_allowed(const bool &allowed) {
is_all_apps_allowed_ = allowed;
}
-HmiStatePtr ApplicationManagerImpl::CreateRegularState(uint32_t app_id,
- mobile_apis::HMILevel::eType hmi_level,
- mobile_apis::AudioStreamingState::eType audio_state,
- mobile_apis::SystemContext::eType system_context) const{
+HmiStatePtr ApplicationManagerImpl::CreateRegularState(
+ uint32_t app_id, mobile_apis::HMILevel::eType hmi_level,
+ mobile_apis::AudioStreamingState::eType audio_state,
+ mobile_apis::SystemContext::eType system_context) const {
HmiStatePtr state(new HmiState(app_id, state_ctrl_.state_context()));
state->set_hmi_level(hmi_level);
state->set_audio_streaming_state(audio_state);
@@ -663,26 +668,24 @@ HmiStatePtr ApplicationManagerImpl::CreateRegularState(uint32_t app_id,
return state;
}
-void ApplicationManagerImpl::StartAudioPassThruThread(int32_t session_key,
- int32_t correlation_id, int32_t max_duration, int32_t sampling_rate,
- int32_t bits_per_sample, int32_t audio_type) {
+void ApplicationManagerImpl::StartAudioPassThruThread(
+ int32_t session_key, int32_t correlation_id, int32_t max_duration,
+ int32_t sampling_rate, int32_t bits_per_sample, int32_t audio_type) {
LOG4CXX_INFO(logger_, "START MICROPHONE RECORDER");
if (NULL != media_manager_) {
media_manager_->StartMicrophoneRecording(
- session_key,
- profile::Profile::instance()->recording_file_name(),
- max_duration);
+ session_key, profile::Profile::instance()->recording_file_name(),
+ max_duration);
}
}
void ApplicationManagerImpl::SendAudioPassThroughNotification(
- uint32_t session_key,
- std::vector<uint8_t>& binary_data) {
+ uint32_t session_key, std::vector<uint8_t> &binary_data) {
LOG4CXX_AUTO_TRACE(logger_);
if (!audio_pass_thru_active_) {
LOG4CXX_ERROR(logger_, "Trying to send PassThroughNotification"
- " when PassThrough is not active");
+ " when PassThrough is not active");
return;
}
@@ -700,16 +703,15 @@ void ApplicationManagerImpl::StopAudioPassThru(int32_t application_key) {
}
}
-std::string ApplicationManagerImpl::GetDeviceName(
- connection_handler::DeviceHandle handle) {
+std::string
+ApplicationManagerImpl::GetDeviceName(connection_handler::DeviceHandle handle) {
DCHECK(connection_handler_ != 0);
std::string device_name = "";
- connection_handler::ConnectionHandlerImpl* con_handler_impl =
- static_cast<connection_handler::ConnectionHandlerImpl*>(
- connection_handler_);
- if (con_handler_impl->GetDataOnDeviceID(handle, &device_name,
- NULL) == -1) {
+ connection_handler::ConnectionHandlerImpl *con_handler_impl =
+ static_cast<connection_handler::ConnectionHandlerImpl *>(
+ connection_handler_);
+ if (con_handler_impl->GetDataOnDeviceID(handle, &device_name, NULL) == -1) {
LOG4CXX_ERROR(logger_, "Failed to extract device name for id " << handle);
} else {
LOG4CXX_INFO(logger_, "\t\t\t\t\tDevice name is " << device_name);
@@ -718,8 +720,9 @@ std::string ApplicationManagerImpl::GetDeviceName(
return device_name;
}
-hmi_apis::Common_TransportType::eType ApplicationManagerImpl::GetDeviceTransportType(
- const std::string& transport_type) {
+hmi_apis::Common_TransportType::eType
+ApplicationManagerImpl::GetDeviceTransportType(
+ const std::string &transport_type) {
hmi_apis::Common_TransportType::eType result =
hmi_apis::Common_TransportType::INVALID_ENUM;
@@ -737,7 +740,7 @@ hmi_apis::Common_TransportType::eType ApplicationManagerImpl::GetDeviceTransport
}
void ApplicationManagerImpl::OnMessageReceived(
- const ::protocol_handler::RawMessagePtr message) {
+ const ::protocol_handler::RawMessagePtr message) {
LOG4CXX_AUTO_TRACE(logger_);
if (!message) {
@@ -750,17 +753,17 @@ void ApplicationManagerImpl::OnMessageReceived(
if (outgoing_message) {
messages_from_mobile_.PostMessage(
- impl::MessageFromMobile(outgoing_message));
+ impl::MessageFromMobile(outgoing_message));
}
}
void ApplicationManagerImpl::OnMobileMessageSent(
- const ::protocol_handler::RawMessagePtr message) {
+ const ::protocol_handler::RawMessagePtr message) {
LOG4CXX_AUTO_TRACE(logger_);
}
void ApplicationManagerImpl::OnMessageReceived(
- hmi_message_handler::MessageSharedPointer message) {
+ hmi_message_handler::MessageSharedPointer message) {
LOG4CXX_AUTO_TRACE(logger_);
if (!message) {
@@ -772,9 +775,8 @@ void ApplicationManagerImpl::OnMessageReceived(
messages_from_hmi_.PostMessage(impl::MessageFromHmi(message));
}
-
-ApplicationConstSharedPtr ApplicationManagerImpl::waiting_app(
- const uint32_t hmi_id) const {
+ApplicationConstSharedPtr
+ApplicationManagerImpl::waiting_app(const uint32_t hmi_id) const {
AppsWaitRegistrationSet app_list = apps_waiting_for_registration().GetData();
AppsWaitRegistrationSet::const_iterator it_end = app_list.end();
@@ -791,8 +793,8 @@ ApplicationConstSharedPtr ApplicationManagerImpl::waiting_app(
DataAccessor<ApplicationManagerImpl::AppsWaitRegistrationSet>
ApplicationManagerImpl::apps_waiting_for_registration() const {
return DataAccessor<AppsWaitRegistrationSet>(
- ApplicationManagerImpl::instance()->apps_to_register_,
- ApplicationManagerImpl::instance()->apps_to_register_list_lock_);
+ ApplicationManagerImpl::instance()->apps_to_register_,
+ ApplicationManagerImpl::instance()->apps_to_register_list_lock_);
}
bool ApplicationManagerImpl::IsAppsQueriedFrom(
@@ -809,8 +811,7 @@ bool ApplicationManagerImpl::IsAppsQueriedFrom(
}
void application_manager::ApplicationManagerImpl::MarkAppsGreyOut(
- const connection_handler::DeviceHandle handle,
- bool is_greyed_out) {
+ const connection_handler::DeviceHandle handle, bool is_greyed_out) {
sync_primitives::AutoLock lock(apps_to_register_list_lock_);
AppsWaitRegistrationSet::iterator it = apps_to_register_.begin();
AppsWaitRegistrationSet::const_iterator it_end = apps_to_register_.end();
@@ -821,28 +822,27 @@ void application_manager::ApplicationManagerImpl::MarkAppsGreyOut(
}
}
-
void ApplicationManagerImpl::OnErrorSending(
- hmi_message_handler::MessageSharedPointer message) {
+ hmi_message_handler::MessageSharedPointer message) {
return;
}
void ApplicationManagerImpl::OnDeviceListUpdated(
- const connection_handler::DeviceMap& device_list) {
+ const connection_handler::DeviceMap &device_list) {
LOG4CXX_AUTO_TRACE(logger_);
- smart_objects::SmartObjectSPtr msg_params = MessageHelper::CreateDeviceListSO(
- device_list);
+ smart_objects::SmartObjectSPtr msg_params =
+ MessageHelper::CreateDeviceListSO(device_list);
if (!msg_params) {
LOG4CXX_WARN(logger_, "Failed to create sub-smart object.");
return;
}
smart_objects::SmartObjectSPtr update_list = new smart_objects::SmartObject;
- smart_objects::SmartObject& so_to_send = *update_list;
+ smart_objects::SmartObject &so_to_send = *update_list;
so_to_send[jhs::S_PARAMS][jhs::S_FUNCTION_ID] =
- hmi_apis::FunctionID::BasicCommunication_UpdateDeviceList;
+ hmi_apis::FunctionID::BasicCommunication_UpdateDeviceList;
so_to_send[jhs::S_PARAMS][jhs::S_MESSAGE_TYPE] =
- hmi_apis::messageType::request;
+ hmi_apis::messageType::request;
so_to_send[jhs::S_PARAMS][jhs::S_PROTOCOL_VERSION] = 3;
so_to_send[jhs::S_PARAMS][jhs::S_PROTOCOL_TYPE] = 1;
so_to_send[jhs::S_PARAMS][jhs::S_CORRELATION_ID] = GetNextHMICorrelationID();
@@ -853,7 +853,8 @@ void ApplicationManagerImpl::OnDeviceListUpdated(
void ApplicationManagerImpl::OnFindNewApplicationsRequest() {
connection_handler_->ConnectToAllDevices();
LOG4CXX_DEBUG(logger_, "Starting application list update timer");
- uint32_t timeout = profile::Profile::instance()->application_list_update_timeout();
+ uint32_t timeout =
+ profile::Profile::instance()->application_list_update_timeout();
application_list_update_timer_->start(timeout);
policy::PolicyHandler::instance()->OnAppsSearchStarted();
}
@@ -865,11 +866,13 @@ void ApplicationManagerImpl::SendUpdateAppList() {
using namespace hmi_apis;
SmartObjectSPtr request = MessageHelper::CreateModuleInfoSO(
- FunctionID::BasicCommunication_UpdateAppList);
+ FunctionID::BasicCommunication_UpdateAppList);
- (*request)[strings::msg_params][strings::applications] = SmartObject(SmartType_Array);
+ (*request)[strings::msg_params][strings::applications] =
+ SmartObject(SmartType_Array);
- SmartObject& applications = (*request)[strings::msg_params][strings::applications];
+ SmartObject &applications =
+ (*request)[strings::msg_params][strings::applications];
PrepareApplicationListSO(applications_, applications);
PrepareApplicationListSO(apps_to_register_, applications);
@@ -878,7 +881,7 @@ void ApplicationManagerImpl::SendUpdateAppList() {
}
void ApplicationManagerImpl::RemoveDevice(
- const connection_handler::DeviceHandle& device_handle) {
+ const connection_handler::DeviceHandle &device_handle) {
LOG4CXX_INFO(logger_, "device_handle " << device_handle);
}
@@ -891,8 +894,8 @@ mobile_apis::HMILevel::eType ApplicationManagerImpl::GetDefaultHmiLevel(
if (policy::PolicyHandler::instance()->PolicyEnabled()) {
const std::string policy_app_id = application->mobile_app_id();
std::string default_hmi_string = "";
- if (policy::PolicyHandler::instance()->GetDefaultHmi(
- policy_app_id, &default_hmi_string)) {
+ if (policy::PolicyHandler::instance()->GetDefaultHmi(policy_app_id,
+ &default_hmi_string)) {
if ("BACKGROUND" == default_hmi_string) {
default_hmi = HMILevel::HMI_BACKGROUND;
} else if ("FULL" == default_hmi_string) {
@@ -902,19 +905,18 @@ mobile_apis::HMILevel::eType ApplicationManagerImpl::GetDefaultHmiLevel(
} else if ("NONE" == default_hmi_string) {
default_hmi = HMILevel::HMI_NONE;
} else {
- LOG4CXX_ERROR(logger_, "Unable to convert " + default_hmi_string + " to HMILevel");
+ LOG4CXX_ERROR(logger_, "Unable to convert " + default_hmi_string +
+ " to HMILevel");
}
} else {
LOG4CXX_ERROR(logger_, "Unable to get default hmi_level for "
- << policy_app_id);
+ << policy_app_id);
}
}
return default_hmi;
}
-uint32_t ApplicationManagerImpl::GenerateGrammarID() {
- return rand();
-}
+uint32_t ApplicationManagerImpl::GenerateGrammarID() { return rand(); }
uint32_t ApplicationManagerImpl::GenerateNewHMIAppID() {
LOG4CXX_TRACE(logger_, "ENTER");
@@ -932,76 +934,74 @@ uint32_t ApplicationManagerImpl::GenerateNewHMIAppID() {
}
void ApplicationManagerImpl::ReplaceMobileByHMIAppId(
- smart_objects::SmartObject& message) {
+ smart_objects::SmartObject &message) {
MessageHelper::PrintSmartObject(message);
if (message.keyExists(strings::app_id)) {
ApplicationSharedPtr application =
ApplicationManagerImpl::instance()->application(
- message[strings::app_id].asUInt());
+ message[strings::app_id].asUInt());
if (application.valid()) {
- LOG4CXX_INFO(logger_, "ReplaceMobileByHMIAppId from " << message[strings::app_id].asInt()
- << " to " << application->hmi_app_id());
+ LOG4CXX_INFO(logger_, "ReplaceMobileByHMIAppId from "
+ << message[strings::app_id].asInt() << " to "
+ << application->hmi_app_id());
message[strings::app_id] = application->hmi_app_id();
}
} else {
switch (message.getType()) {
- case smart_objects::SmartType::SmartType_Array: {
- smart_objects::SmartArray* message_array = message.asArray();
- smart_objects::SmartArray::iterator it = message_array->begin();
- for(; it != message_array->end(); ++it) {
- ReplaceMobileByHMIAppId(*it);
- }
- break;
- }
- case smart_objects::SmartType::SmartType_Map: {
- std::set<std::string> keys = message.enumerate();
- std::set<std::string>::const_iterator key = keys.begin();
- for (; key != keys.end(); ++key) {
- std::string k = *key;
- ReplaceMobileByHMIAppId(message[*key]);
- }
- break;
+ case smart_objects::SmartType::SmartType_Array: {
+ smart_objects::SmartArray *message_array = message.asArray();
+ smart_objects::SmartArray::iterator it = message_array->begin();
+ for (; it != message_array->end(); ++it) {
+ ReplaceMobileByHMIAppId(*it);
}
- default: {
- break;
+ break;
+ }
+ case smart_objects::SmartType::SmartType_Map: {
+ std::set<std::string> keys = message.enumerate();
+ std::set<std::string>::const_iterator key = keys.begin();
+ for (; key != keys.end(); ++key) {
+ std::string k = *key;
+ ReplaceMobileByHMIAppId(message[*key]);
}
+ break;
+ }
+ default: { break; }
}
}
}
void ApplicationManagerImpl::ReplaceHMIByMobileAppId(
- smart_objects::SmartObject& message) {
+ smart_objects::SmartObject &message) {
if (message.keyExists(strings::app_id)) {
ApplicationSharedPtr application =
- ApplicationManagerImpl::instance()->application_by_hmi_app(
- message[strings::app_id].asUInt());
+ ApplicationManagerImpl::instance()->application_by_hmi_app(
+ message[strings::app_id].asUInt());
if (application.valid()) {
- LOG4CXX_INFO(logger_, "ReplaceHMIByMobileAppId from " << message[strings::app_id].asInt()
- << " to " << application->app_id());
+ LOG4CXX_INFO(logger_, "ReplaceHMIByMobileAppId from "
+ << message[strings::app_id].asInt() << " to "
+ << application->app_id());
message[strings::app_id] = application->app_id();
}
} else {
switch (message.getType()) {
- case smart_objects::SmartType::SmartType_Array: {
- smart_objects::SmartArray* message_array = message.asArray();
- smart_objects::SmartArray::iterator it = message_array->begin();
- for(; it != message_array->end(); ++it) {
- ReplaceHMIByMobileAppId(*it);
- }
- break;
+ case smart_objects::SmartType::SmartType_Array: {
+ smart_objects::SmartArray *message_array = message.asArray();
+ smart_objects::SmartArray::iterator it = message_array->begin();
+ for (; it != message_array->end(); ++it) {
+ ReplaceHMIByMobileAppId(*it);
}
- case smart_objects::SmartType::SmartType_Map: {
- std::set<std::string> keys = message.enumerate();
- std::set<std::string>::const_iterator key = keys.begin();
- for (; key != keys.end(); ++key) {
- ReplaceHMIByMobileAppId(message[*key]);
- }
- break;
- }
- default: {
- break;
+ break;
+ }
+ case smart_objects::SmartType::SmartType_Map: {
+ std::set<std::string> keys = message.enumerate();
+ std::set<std::string>::const_iterator key = keys.begin();
+ for (; key != keys.end(); ++key) {
+ ReplaceHMIByMobileAppId(message[*key]);
}
+ break;
+ }
+ default: { break; }
}
}
}
@@ -1012,12 +1012,12 @@ bool ApplicationManagerImpl::StartNaviService(
LOG4CXX_AUTO_TRACE(logger_);
if (HMILevelAllowsStreaming(app_id, service_type)) {
- NaviServiceStatusMap::iterator it =
- navi_service_status_.find(app_id);
+ NaviServiceStatusMap::iterator it = navi_service_status_.find(app_id);
if (navi_service_status_.end() == it) {
std::pair<NaviServiceStatusMap::iterator, bool> res =
- navi_service_status_.insert(std::pair<uint32_t, std::pair<bool, bool> >(
- app_id, std::make_pair(false, false)));
+ navi_service_status_.insert(
+ std::pair<uint32_t, std::pair<bool, bool>>(
+ app_id, std::make_pair(false, false)));
if (!res.second) {
return false;
}
@@ -1026,8 +1026,8 @@ bool ApplicationManagerImpl::StartNaviService(
// Fill NaviServices map. Set true to first value of pair if
// we've started video service or to second value if we've
// started audio service
- service_type == ServiceType::kMobileNav ? it->second.first =
- true : it->second.second = true;
+ service_type == ServiceType::kMobileNav ? it->second.first = true
+ : it->second.second = true;
application(app_id)->StartStreaming(service_type);
return true;
@@ -1040,17 +1040,15 @@ void ApplicationManagerImpl::StopNaviService(
using namespace protocol_handler;
LOG4CXX_AUTO_TRACE(logger_);
- NaviServiceStatusMap::iterator it =
- navi_service_status_.find(app_id);
+ NaviServiceStatusMap::iterator it = navi_service_status_.find(app_id);
if (navi_service_status_.end() == it) {
- LOG4CXX_WARN(logger_, "No Information about navi service "
- << service_type);
+ LOG4CXX_WARN(logger_, "No Information about navi service " << service_type);
} else {
// Fill NaviServices map. Set false to first value of pair if
// we've stopped video service or to second value if we've
// stopped audio service
- service_type == ServiceType::kMobileNav ? it->second.first =
- false : it->second.second = false;
+ service_type == ServiceType::kMobileNav ? it->second.first = false
+ : it->second.second = false;
}
ApplicationSharedPtr app = application(app_id);
@@ -1062,28 +1060,27 @@ void ApplicationManagerImpl::StopNaviService(
}
bool ApplicationManagerImpl::OnServiceStartedCallback(
- const connection_handler::DeviceHandle& device_handle,
- const int32_t& session_key,
- const protocol_handler::ServiceType& type) {
+ const connection_handler::DeviceHandle &device_handle,
+ const int32_t &session_key, const protocol_handler::ServiceType &type) {
using namespace helpers;
using namespace protocol_handler;
- LOG4CXX_DEBUG(logger_,
- "OnServiceStartedCallback " << type
- << " in session 0x" << std::hex << session_key);
+ LOG4CXX_DEBUG(logger_, "OnServiceStartedCallback " << type << " in session 0x"
+ << std::hex
+ << session_key);
if (type == kRpc) {
LOG4CXX_INFO(logger_, "RPC service is about to be started.");
return true;
}
ApplicationSharedPtr app = application(session_key);
if (!app) {
- LOG4CXX_DEBUG(logger_, "The application with id:" << session_key <<
- " doesn't exists.");
+ LOG4CXX_DEBUG(logger_, "The application with id:" << session_key
+ << " doesn't exists.");
return false;
}
- if (Compare<ServiceType, EQ, ONE>(type,
- ServiceType::kMobileNav, ServiceType::kAudio)) {
+ if (Compare<ServiceType, EQ, ONE>(type, ServiceType::kMobileNav,
+ ServiceType::kAudio)) {
if (app->is_navi()) {
return StartNaviService(session_key, type);
}
@@ -1092,9 +1089,8 @@ bool ApplicationManagerImpl::OnServiceStartedCallback(
}
void ApplicationManagerImpl::OnServiceEndedCallback(
- const int32_t& session_key,
- const protocol_handler::ServiceType& type,
- const connection_handler::CloseSessionReason& close_reason) {
+ const int32_t &session_key, const protocol_handler::ServiceType &type,
+ const connection_handler::CloseSessionReason &close_reason) {
using namespace helpers;
using namespace protocol_handler;
using namespace mobile_apis;
@@ -1102,8 +1098,8 @@ void ApplicationManagerImpl::OnServiceEndedCallback(
using namespace mobile_apis;
LOG4CXX_DEBUG(logger_, "OnServiceEndedCallback for service "
- << type << " with reason " << close_reason
- << " in session 0x" << std::hex << session_key);
+ << type << " with reason " << close_reason
+ << " in session 0x" << std::hex << session_key);
if (type == kRpc) {
LOG4CXX_INFO(logger_, "Remove application.");
@@ -1118,67 +1114,68 @@ void ApplicationManagerImpl::OnServiceEndedCallback(
bool is_resuming;
bool is_unexpected_disconnect;
switch (close_reason) {
- case CloseSessionReason::kFlood: {
- reason = Result::TOO_MANY_PENDING_REQUESTS;
- is_resuming = true;
- is_unexpected_disconnect = false;
+ case CloseSessionReason::kFlood: {
+ reason = Result::TOO_MANY_PENDING_REQUESTS;
+ is_resuming = true;
+ is_unexpected_disconnect = false;
- MessageHelper::SendOnAppInterfaceUnregisteredNotificationToMobile(
- session_key, AppInterfaceUnregisteredReason::TOO_MANY_REQUESTS);
- break;
- }
- case CloseSessionReason::kMalformed: {
- reason = Result::INVALID_ENUM;
- is_resuming = true;
- is_unexpected_disconnect = false;
- break;
- }
- case CloseSessionReason::kUnauthorizedApp: {
- reason = Result::INVALID_ENUM;
- is_resuming = true;
- is_unexpected_disconnect = false;
- break;
- }
- default: {
- reason = Result::INVALID_ENUM;
- is_resuming = true;
- is_unexpected_disconnect = true;
- break;
- }
+ MessageHelper::SendOnAppInterfaceUnregisteredNotificationToMobile(
+ session_key, AppInterfaceUnregisteredReason::TOO_MANY_REQUESTS);
+ break;
+ }
+ case CloseSessionReason::kMalformed: {
+ reason = Result::INVALID_ENUM;
+ is_resuming = true;
+ is_unexpected_disconnect = false;
+ break;
+ }
+ case CloseSessionReason::kUnauthorizedApp: {
+ reason = Result::INVALID_ENUM;
+ is_resuming = true;
+ is_unexpected_disconnect = false;
+ break;
}
- UnregisterApplication(
- session_key, reason, is_resuming, is_unexpected_disconnect);
+ default: {
+ reason = Result::INVALID_ENUM;
+ is_resuming = true;
+ is_unexpected_disconnect = true;
+ break;
+ }
+ }
+ UnregisterApplication(session_key, reason, is_resuming,
+ is_unexpected_disconnect);
return;
}
- if (Compare<ServiceType, EQ, ONE>(type,
- ServiceType::kMobileNav, ServiceType::kAudio)) {
+ if (Compare<ServiceType, EQ, ONE>(type, ServiceType::kMobileNav,
+ ServiceType::kAudio)) {
StopNaviService(session_key, type);
}
}
void ApplicationManagerImpl::set_hmi_message_handler(
- hmi_message_handler::HMIMessageHandler* handler) {
+ hmi_message_handler::HMIMessageHandler *handler) {
hmi_handler_ = handler;
}
void ApplicationManagerImpl::set_connection_handler(
- connection_handler::ConnectionHandler* handler) {
+ connection_handler::ConnectionHandler *handler) {
connection_handler_ = handler;
}
-connection_handler::ConnectionHandler* ApplicationManagerImpl::connection_handler() {
+connection_handler::ConnectionHandler *
+ApplicationManagerImpl::connection_handler() {
return connection_handler_;
}
void ApplicationManagerImpl::set_protocol_handler(
- protocol_handler::ProtocolHandler* handler) {
+ protocol_handler::ProtocolHandler *handler) {
protocol_handler_ = handler;
}
void ApplicationManagerImpl::StartDevicesDiscovery() {
- connection_handler::ConnectionHandlerImpl::instance()->
- StartDevicesDiscovery();
+ connection_handler::ConnectionHandlerImpl::instance()
+ ->StartDevicesDiscovery();
}
void ApplicationManagerImpl::SendMessageToMobile(
@@ -1197,23 +1194,22 @@ void ApplicationManagerImpl::SendMessageToMobile(
}
ApplicationSharedPtr app = application(
- (*message)[strings::params][strings::connection_key].asUInt());
+ (*message)[strings::params][strings::connection_key].asUInt());
if (!app) {
- LOG4CXX_ERROR_EXT(logger_,
- "No application associated with connection key");
+ LOG4CXX_ERROR_EXT(logger_, "No application associated with connection key");
if ((*message)[strings::msg_params].keyExists(strings::result_code) &&
((*message)[strings::msg_params][strings::result_code] ==
NsSmartDeviceLinkRPC::V1::Result::UNSUPPORTED_VERSION)) {
(*message)[strings::params][strings::protocol_version] =
- ProtocolVersion::kV1;
+ ProtocolVersion::kV1;
} else {
(*message)[strings::params][strings::protocol_version] =
- SupportedSDLVersion();
+ SupportedSDLVersion();
}
} else {
(*message)[strings::params][strings::protocol_version] =
- app->protocol_version();
+ app->protocol_version();
}
mobile_so_factory().attachSchema(*message, false);
@@ -1221,27 +1217,27 @@ void ApplicationManagerImpl::SendMessageToMobile(
<< message->isValid());
// Messages to mobile are not yet prioritized so use default priority value
- utils::SharedPtr<Message> message_to_send(new Message(
- protocol_handler::MessagePriority::kDefault));
+ utils::SharedPtr<Message> message_to_send(
+ new Message(protocol_handler::MessagePriority::kDefault));
if (!ConvertSOtoMessage((*message), (*message_to_send))) {
LOG4CXX_WARN(logger_, "Can't send msg to Mobile: failed to create string");
return;
}
- smart_objects::SmartObject& msg_to_mobile = *message;
+ smart_objects::SmartObject &msg_to_mobile = *message;
// If correlation_id is not present, it is from-HMI message which should be
// checked against policy permissions
if (msg_to_mobile[strings::params].keyExists(strings::correlation_id)) {
request_ctrl_.OnMobileResponse(
- msg_to_mobile[strings::params][strings::correlation_id].asInt(),
- msg_to_mobile[strings::params][strings::connection_key].asInt());
+ msg_to_mobile[strings::params][strings::correlation_id].asInt(),
+ msg_to_mobile[strings::params][strings::connection_key].asInt());
} else if (app) {
mobile_apis::FunctionID::eType function_id =
static_cast<mobile_apis::FunctionID::eType>(
- (*message)[strings::params][strings::function_id].asUInt());
+ (*message)[strings::params][strings::function_id].asUInt());
RPCParams params;
- const smart_objects::SmartObject& s_map = (*message)[strings::msg_params];
+ const smart_objects::SmartObject &s_map = (*message)[strings::msg_params];
if (smart_objects::SmartType_Map == s_map.getType()) {
smart_objects::SmartMap::iterator iter = s_map.map_begin();
smart_objects::SmartMap::iterator iter_end = s_map.map_end();
@@ -1253,21 +1249,21 @@ void ApplicationManagerImpl::SendMessageToMobile(
}
}
}
- const mobile_apis::Result::eType check_result =
- CheckPolicyPermissions( app->mobile_app_id(),
- app->hmi_level(), function_id, params);
+ const mobile_apis::Result::eType check_result = CheckPolicyPermissions(
+ app->mobile_app_id(), app->hmi_level(), function_id, params);
if (mobile_apis::Result::SUCCESS != check_result) {
const std::string string_functionID =
MessageHelper::StringifiedFunctionID(function_id);
LOG4CXX_WARN(logger_, "Function \"" << string_functionID << "\" (#"
- << function_id << ") not allowed by policy");
+ << function_id
+ << ") not allowed by policy");
return;
}
if (function_id == mobile_apis::FunctionID::OnSystemRequestID) {
mobile_apis::RequestType::eType request_type =
static_cast<mobile_apis::RequestType::eType>(
- (*message)[strings::msg_params][strings::request_type].asUInt());
+ (*message)[strings::msg_params][strings::request_type].asUInt());
if (mobile_apis::RequestType::PROPRIETARY == request_type ||
mobile_apis::RequestType::HTTP == request_type) {
policy::PolicyHandler::instance()->OnUpdateRequestSentToMobile();
@@ -1276,13 +1272,15 @@ void ApplicationManagerImpl::SendMessageToMobile(
}
if (message_to_send->binary_data()) {
- LOG4CXX_DEBUG(logger_, "Binary data size: " << message_to_send->binary_data()->size());
+ LOG4CXX_DEBUG(logger_, "Binary data size: "
+ << message_to_send->binary_data()->size());
}
- messages_to_mobile_.PostMessage(impl::MessageToMobile(message_to_send,
- final_message));
+ messages_to_mobile_.PostMessage(
+ impl::MessageToMobile(message_to_send, final_message));
}
-void ApplicationManagerImpl::TerminateRequest(uint32_t connection_key, uint32_t corr_id) {
+void ApplicationManagerImpl::TerminateRequest(uint32_t connection_key,
+ uint32_t corr_id) {
request_ctrl_.terminateRequest(corr_id, connection_key, true);
}
@@ -1306,31 +1304,33 @@ bool ApplicationManagerImpl::ManageMobileCommand(
LOG4CXX_INFO(logger_, "Trying to create message in mobile factory.");
utils::SharedPtr<commands::Command> command(
- MobileCommandFactory::CreateCommand(message, origin));
+ MobileCommandFactory::CreateCommand(message, origin));
if (!command) {
- LOG4CXX_WARN(logger_, "RET Failed to create mobile command from smart object");
+ LOG4CXX_WARN(logger_,
+ "RET Failed to create mobile command from smart object");
return false;
}
mobile_apis::FunctionID::eType function_id =
- static_cast<mobile_apis::FunctionID::eType>(
- (*message)[strings::params][strings::function_id].asInt());
+ static_cast<mobile_apis::FunctionID::eType>(
+ (*message)[strings::params][strings::function_id].asInt());
// Notifications from HMI have no such parameter
uint32_t correlation_id =
- (*message)[strings::params].keyExists(strings::correlation_id)
- ? (*message)[strings::params][strings::correlation_id].asUInt()
- : 0;
+ (*message)[strings::params].keyExists(strings::correlation_id)
+ ? (*message)[strings::params][strings::correlation_id].asUInt()
+ : 0;
uint32_t connection_key =
- (*message)[strings::params][strings::connection_key].asUInt();
+ (*message)[strings::params][strings::connection_key].asUInt();
int32_t protocol_type =
- (*message)[strings::params][strings::protocol_type].asUInt();
+ (*message)[strings::params][strings::protocol_type].asUInt();
ApplicationSharedPtr app;
- int32_t message_type = (*message)[strings::params][strings::message_type].asInt();
+ int32_t message_type =
+ (*message)[strings::params][strings::message_type].asInt();
if (((mobile_apis::FunctionID::RegisterAppInterfaceID != function_id) &&
(protocol_type == commands::CommandImpl::mobile_protocol_type_)) &&
@@ -1339,10 +1339,10 @@ bool ApplicationManagerImpl::ManageMobileCommand(
if (!app) {
LOG4CXX_ERROR_EXT(logger_, "RET APPLICATION_NOT_REGISTERED");
smart_objects::SmartObjectSPtr response =
- MessageHelper::CreateNegativeResponse(connection_key,
- static_cast<int32_t>(function_id),
- correlation_id,
- static_cast<int32_t>(mobile_apis::Result::APPLICATION_NOT_REGISTERED));
+ MessageHelper::CreateNegativeResponse(
+ connection_key, static_cast<int32_t>(function_id), correlation_id,
+ static_cast<int32_t>(
+ mobile_apis::Result::APPLICATION_NOT_REGISTERED));
SendMessageToMobile(response);
return false;
@@ -1352,16 +1352,14 @@ bool ApplicationManagerImpl::ManageMobileCommand(
mobile_so_factory().attachSchema(*message, false);
}
- if (message_type ==
- mobile_apis::messageType::response) {
+ if (message_type == mobile_apis::messageType::response) {
if (command->Init()) {
command->Run();
command->CleanUp();
}
return true;
}
- if (message_type ==
- mobile_apis::messageType::notification) {
+ if (message_type == mobile_apis::messageType::notification) {
request_ctrl_.addNotification(command);
if (command->Init()) {
command->Run();
@@ -1373,11 +1371,11 @@ bool ApplicationManagerImpl::ManageMobileCommand(
return true;
}
- if (message_type ==
- mobile_apis::messageType::request) {
+ if (message_type == mobile_apis::messageType::request) {
// commands will be launched from requesr_ctrl
- mobile_apis::HMILevel::eType app_hmi_level = mobile_apis::HMILevel::INVALID_ENUM;
+ mobile_apis::HMILevel::eType app_hmi_level =
+ mobile_apis::HMILevel::INVALID_ENUM;
if (app) {
app_hmi_level = app->hmi_level();
}
@@ -1385,56 +1383,55 @@ bool ApplicationManagerImpl::ManageMobileCommand(
// commands will be launched from request_ctrl
const request_controller::RequestController::TResult result =
- request_ctrl_.addMobileRequest(command, app_hmi_level);
+ request_ctrl_.addMobileRequest(command, app_hmi_level);
if (result == request_controller::RequestController::SUCCESS) {
LOG4CXX_INFO(logger_, "Perform request");
- } else if (result ==
- request_controller::RequestController::
- TOO_MANY_PENDING_REQUESTS) {
- LOG4CXX_ERROR_EXT(logger_, "RET Unable top perform request: " <<
- "TOO_MANY_PENDING_REQUESTS");
+ } else if (result == request_controller::RequestController::
+ TOO_MANY_PENDING_REQUESTS) {
+ LOG4CXX_ERROR_EXT(logger_, "RET Unable top perform request: "
+ << "TOO_MANY_PENDING_REQUESTS");
smart_objects::SmartObjectSPtr response =
- MessageHelper::CreateNegativeResponse(connection_key,
- static_cast<int32_t>(function_id),
- correlation_id,
- static_cast<int32_t>(mobile_apis::Result::TOO_MANY_PENDING_REQUESTS));
+ MessageHelper::CreateNegativeResponse(
+ connection_key, static_cast<int32_t>(function_id), correlation_id,
+ static_cast<int32_t>(
+ mobile_apis::Result::TOO_MANY_PENDING_REQUESTS));
SendMessageToMobile(response);
return false;
} else if (result ==
request_controller::RequestController::TOO_MANY_REQUESTS) {
- LOG4CXX_ERROR_EXT(logger_, "RET Unable to perform request: " <<
- "TOO_MANY_REQUESTS");
+ LOG4CXX_ERROR_EXT(logger_, "RET Unable to perform request: "
+ << "TOO_MANY_REQUESTS");
MessageHelper::SendOnAppInterfaceUnregisteredNotificationToMobile(
- connection_key,
- mobile_api::AppInterfaceUnregisteredReason::TOO_MANY_REQUESTS);
+ connection_key,
+ mobile_api::AppInterfaceUnregisteredReason::TOO_MANY_REQUESTS);
UnregisterApplication(connection_key,
mobile_apis::Result::TOO_MANY_PENDING_REQUESTS,
false);
return false;
- } else if (result ==
- request_controller::RequestController::
- NONE_HMI_LEVEL_MANY_REQUESTS) {
- LOG4CXX_ERROR_EXT(logger_, "RET Unable to perform request: " <<
- "REQUEST_WHILE_IN_NONE_HMI_LEVEL");
+ } else if (result == request_controller::RequestController::
+ NONE_HMI_LEVEL_MANY_REQUESTS) {
+ LOG4CXX_ERROR_EXT(logger_, "RET Unable to perform request: "
+ << "REQUEST_WHILE_IN_NONE_HMI_LEVEL");
MessageHelper::SendOnAppInterfaceUnregisteredNotificationToMobile(
- connection_key, mobile_api::AppInterfaceUnregisteredReason::
- REQUEST_WHILE_IN_NONE_HMI_LEVEL);
+ connection_key, mobile_api::AppInterfaceUnregisteredReason::
+ REQUEST_WHILE_IN_NONE_HMI_LEVEL);
ApplicationSharedPtr app_ptr = application(connection_key);
- if(app_ptr) {
+ if (app_ptr) {
app_ptr->usage_report().RecordRemovalsForBadBehavior();
}
UnregisterApplication(connection_key, mobile_apis::Result::INVALID_ENUM,
false);
return false;
} else {
- LOG4CXX_ERROR_EXT(logger_, "RET Unable to perform request: Unknown case");
+ LOG4CXX_ERROR_EXT(logger_,
+ "RET Unable to perform request: Unknown case");
return false;
}
return true;
@@ -1461,7 +1458,7 @@ void ApplicationManagerImpl::SendMessageToHMI(
// SmartObject |message| has no way to declare priority for now
utils::SharedPtr<Message> message_to_send(
- new Message(protocol_handler::MessagePriority::kDefault));
+ new Message(protocol_handler::MessagePriority::kDefault));
if (!message_to_send) {
LOG4CXX_ERROR(logger_, "Null pointer");
return;
@@ -1479,7 +1476,7 @@ void ApplicationManagerImpl::SendMessageToHMI(
"Cannot send message to HMI: failed to create string");
return;
}
-#endif // HMI_DBUS_API
+#endif // HMI_DBUS_API
messages_to_hmi_.PostMessage(impl::MessageToHmi(message_to_send));
}
@@ -1516,12 +1513,12 @@ bool ApplicationManagerImpl::ManageHMICommand(
request_ctrl_.addHMIRequest(command);
}
command->Run();
- if (kResponse == message_type) {
- int32_t correlation_id =
+ if (kResponse == message_type) {
+ int32_t correlation_id =
(*(message.get()))[strings::params][strings::correlation_id].asInt();
- request_ctrl_.OnHMIResponse(correlation_id);
- }
- return true;
+ request_ctrl_.OnHMIResponse(correlation_id);
+ }
+ return true;
}
return false;
}
@@ -1552,8 +1549,9 @@ bool ApplicationManagerImpl::Init() {
IsReadWriteAllowed(app_icons_folder, TYPE_ICONS);
if (policy::PolicyHandler::instance()->PolicyEnabled()) {
- if(!policy::PolicyHandler::instance()->LoadPolicyLibrary()) {
- LOG4CXX_ERROR(logger_, "Policy library is not loaded. Check LD_LIBRARY_PATH");
+ if (!policy::PolicyHandler::instance()->LoadPolicyLibrary()) {
+ LOG4CXX_ERROR(logger_,
+ "Policy library is not loaded. Check LD_LIBRARY_PATH");
return false;
}
LOG4CXX_INFO(logger_, "Policy library is loaded, now initing PT");
@@ -1562,147 +1560,144 @@ bool ApplicationManagerImpl::Init() {
return false;
}
} else {
- LOG4CXX_WARN(logger_, "System is configured to work without policy functionality.");
+ LOG4CXX_WARN(logger_,
+ "System is configured to work without policy functionality.");
}
media_manager_ = media_manager::MediaManagerImpl::instance();
return true;
}
bool ApplicationManagerImpl::ConvertMessageToSO(
- const Message& message, smart_objects::SmartObject& output) {
- LOG4CXX_INFO(
- logger_,
- "\t\t\tMessage to convert: protocol " << message.protocol_version()
- << "; json " << message.json_message());
+ const Message &message, smart_objects::SmartObject &output) {
+ LOG4CXX_INFO(logger_, "\t\t\tMessage to convert: protocol "
+ << message.protocol_version() << "; json "
+ << message.json_message());
switch (message.protocol_version()) {
- case ProtocolVersion::kV4:
- case ProtocolVersion::kV3:
- case ProtocolVersion::kV2: {
- const bool conversion_result =
- formatters::CFormatterJsonSDLRPCv2::fromString(
- message.json_message(), output, message.function_id(),
- message.type(), message.correlation_id());
- if (!conversion_result
- || !mobile_so_factory().attachSchema(output, true)
- || ((output.validate() != smart_objects::Errors::OK))) {
- LOG4CXX_WARN(logger_, "Failed to parse string to smart object :"
- << message.json_message());
+ case ProtocolVersion::kV4:
+ case ProtocolVersion::kV3:
+ case ProtocolVersion::kV2: {
+ const bool conversion_result =
+ formatters::CFormatterJsonSDLRPCv2::fromString(
+ message.json_message(), output, message.function_id(),
+ message.type(), message.correlation_id());
+ if (!conversion_result || !mobile_so_factory().attachSchema(output, true) ||
+ ((output.validate() != smart_objects::Errors::OK))) {
+ LOG4CXX_WARN(logger_, "Failed to parse string to smart object :"
+ << message.json_message());
+ utils::SharedPtr<smart_objects::SmartObject> response(
+ MessageHelper::CreateNegativeResponse(
+ message.connection_key(), message.function_id(),
+ message.correlation_id(), mobile_apis::Result::INVALID_DATA));
+ ManageMobileCommand(response, commands::Command::ORIGIN_SDL);
+ return false;
+ }
+ LOG4CXX_INFO(logger_,
+ "Convertion result for sdl object is true"
+ << " function_id "
+ << output[jhs::S_PARAMS][jhs::S_FUNCTION_ID].asInt());
+ output[strings::params][strings::connection_key] = message.connection_key();
+ output[strings::params][strings::protocol_version] =
+ message.protocol_version();
+ if (message.binary_data()) {
+ if (message.payload_size() < message.data_size()) {
+ LOG4CXX_ERROR(
+ logger_, "Incomplete binary"
+ << " binary size should be " << message.data_size()
+ << " payload data size is " << message.payload_size());
utils::SharedPtr<smart_objects::SmartObject> response(
MessageHelper::CreateNegativeResponse(
message.connection_key(), message.function_id(),
message.correlation_id(), mobile_apis::Result::INVALID_DATA));
- ManageMobileCommand(response, commands::Command::ORIGIN_SDL);
+ ManageMobileCommand(response);
return false;
}
- LOG4CXX_INFO(
- logger_,
- "Convertion result for sdl object is true" << " function_id "
- << output[jhs::S_PARAMS][jhs::S_FUNCTION_ID].asInt());
- output[strings::params][strings::connection_key] =
- message.connection_key();
- output[strings::params][strings::protocol_version] =
- message.protocol_version();
- if (message.binary_data()) {
- if (message.payload_size() < message.data_size()) {
- LOG4CXX_ERROR(logger_, "Incomplete binary" <<
- " binary size should be " << message.data_size() <<
- " payload data size is " << message.payload_size());
- utils::SharedPtr<smart_objects::SmartObject> response(
- MessageHelper::CreateNegativeResponse(
- message.connection_key(), message.function_id(),
- message.correlation_id(), mobile_apis::Result::INVALID_DATA));
- ManageMobileCommand(response);
- return false;
- }
- output[strings::params][strings::binary_data] =
- *(message.binary_data());
- }
- break;
+ output[strings::params][strings::binary_data] = *(message.binary_data());
}
- case ProtocolVersion::kHMI: {
+ break;
+ }
+ case ProtocolVersion::kHMI: {
#ifdef ENABLE_LOG
- int32_t result =
+ int32_t result =
#endif
- formatters::FormatterJsonRpc::FromString<
- hmi_apis::FunctionID::eType, hmi_apis::messageType::eType>(
- message.json_message(), output);
- LOG4CXX_INFO(logger_,
- "Convertion result: "
- << result << " function id "
- << output[jhs::S_PARAMS][jhs::S_FUNCTION_ID].asInt());
- if (!hmi_so_factory().attachSchema(output, false)) {
- LOG4CXX_WARN(logger_, "Failed to attach schema to object.");
+ formatters::FormatterJsonRpc::FromString<hmi_apis::FunctionID::eType,
+ hmi_apis::messageType::eType>(
+ message.json_message(), output);
+ LOG4CXX_INFO(logger_,
+ "Convertion result: "
+ << result << " function id "
+ << output[jhs::S_PARAMS][jhs::S_FUNCTION_ID].asInt());
+ if (!hmi_so_factory().attachSchema(output, false)) {
+ LOG4CXX_WARN(logger_, "Failed to attach schema to object.");
+ return false;
+ }
+ if (output.validate() != smart_objects::Errors::OK) {
+ LOG4CXX_ERROR(logger_, "Incorrect parameter from HMI");
+
+ if (application_manager::MessageType::kNotification ==
+ output[strings::params][strings::message_type].asInt()) {
+ LOG4CXX_ERROR(logger_, "Ignore wrong HMI notification");
return false;
}
- if (output.validate() != smart_objects::Errors::OK) {
- LOG4CXX_ERROR(logger_, "Incorrect parameter from HMI");
-
- if (application_manager::MessageType::kNotification ==
- output[strings::params][strings::message_type].asInt()) {
- LOG4CXX_ERROR(logger_, "Ignore wrong HMI notification");
- return false;
- }
- if (application_manager::MessageType::kRequest ==
- output[strings::params][strings::message_type].asInt()) {
- LOG4CXX_ERROR(logger_, "Ignore wrong HMI request");
- return false;
- }
+ if (application_manager::MessageType::kRequest ==
+ output[strings::params][strings::message_type].asInt()) {
+ LOG4CXX_ERROR(logger_, "Ignore wrong HMI request");
+ return false;
+ }
- output.erase(strings::msg_params);
- output[strings::params][hmi_response::code] =
+ output.erase(strings::msg_params);
+ output[strings::params][hmi_response::code] =
hmi_apis::Common_Result::INVALID_DATA;
- output[strings::msg_params][strings::info] =
+ output[strings::msg_params][strings::info] =
std::string("Received invalid data on HMI response");
- }
- break;
}
- case ProtocolVersion::kV1: {
- static NsSmartDeviceLinkRPC::V1::v4_protocol_v1_2_no_extra v1_shema;
+ break;
+ }
+ case ProtocolVersion::kV1: {
+ static NsSmartDeviceLinkRPC::V1::v4_protocol_v1_2_no_extra v1_shema;
- if (message.function_id() == 0 || message.type() == kUnknownType) {
- LOG4CXX_ERROR(logger_, "Message received: UNSUPPORTED_VERSION");
+ if (message.function_id() == 0 || message.type() == kUnknownType) {
+ LOG4CXX_ERROR(logger_, "Message received: UNSUPPORTED_VERSION");
- int32_t conversation_result =
- formatters::CFormatterJsonSDLRPCv1::fromString <
- NsSmartDeviceLinkRPC::V1::FunctionID::eType,
- NsSmartDeviceLinkRPC::V1::messageType::eType > (
- message.json_message(), output);
+ int32_t conversation_result =
+ formatters::CFormatterJsonSDLRPCv1::fromString<
+ NsSmartDeviceLinkRPC::V1::FunctionID::eType,
+ NsSmartDeviceLinkRPC::V1::messageType::eType>(
+ message.json_message(), output);
- if (formatters::CFormatterJsonSDLRPCv1::kSuccess
- == conversation_result) {
+ if (formatters::CFormatterJsonSDLRPCv1::kSuccess == conversation_result) {
- smart_objects::SmartObject params = smart_objects::SmartObject(smart_objects::SmartType::SmartType_Map);
+ smart_objects::SmartObject params =
+ smart_objects::SmartObject(smart_objects::SmartType::SmartType_Map);
- output[strings::params][strings::message_type] =
+ output[strings::params][strings::message_type] =
NsSmartDeviceLinkRPC::V1::messageType::response;
- output[strings::params][strings::connection_key] = message.connection_key();
+ output[strings::params][strings::connection_key] =
+ message.connection_key();
- output[strings::msg_params] =
+ output[strings::msg_params] =
smart_objects::SmartObject(smart_objects::SmartType::SmartType_Map);
- output[strings::msg_params][strings::success] = false;
- output[strings::msg_params][strings::result_code] =
+ output[strings::msg_params][strings::success] = false;
+ output[strings::msg_params][strings::result_code] =
NsSmartDeviceLinkRPC::V1::Result::UNSUPPORTED_VERSION;
- smart_objects::SmartObjectSPtr msg_to_send =
- new smart_objects::SmartObject(output);
- v1_shema.attachSchema(*msg_to_send, false);
- SendMessageToMobile(msg_to_send);
- return false;
- }
+ smart_objects::SmartObjectSPtr msg_to_send =
+ new smart_objects::SmartObject(output);
+ v1_shema.attachSchema(*msg_to_send, false);
+ SendMessageToMobile(msg_to_send);
+ return false;
}
-
- break;
}
- default:
- // TODO(PV):
- // removed NOTREACHED() because some app can still have vesion 1.
- LOG4CXX_WARN(
- logger_,
- "Application used unsupported protocol :" << message.protocol_version()
- << ".");
- return false;
+
+ break;
+ }
+ default:
+ // TODO(PV):
+ // removed NOTREACHED() because some app can still have vesion 1.
+ LOG4CXX_WARN(logger_, "Application used unsupported protocol :"
+ << message.protocol_version() << ".");
+ return false;
}
LOG4CXX_INFO(logger_, "Successfully parsed message into smart object");
@@ -1710,88 +1705,93 @@ bool ApplicationManagerImpl::ConvertMessageToSO(
}
bool ApplicationManagerImpl::ConvertSOtoMessage(
- const smart_objects::SmartObject& message, Message& output) {
+ const smart_objects::SmartObject &message, Message &output) {
LOG4CXX_INFO(logger_, "Message to convert");
- if (smart_objects::SmartType_Null == message.getType()
- || smart_objects::SmartType_Invalid == message.getType()) {
+ if (smart_objects::SmartType_Null == message.getType() ||
+ smart_objects::SmartType_Invalid == message.getType()) {
LOG4CXX_WARN(logger_, "Invalid smart object received.");
return false;
}
- LOG4CXX_INFO(
- logger_,
- "Message with protocol: "
- << message.getElement(jhs::S_PARAMS).getElement(jhs::S_PROTOCOL_TYPE)
- .asInt());
+ LOG4CXX_INFO(logger_, "Message with protocol: "
+ << message.getElement(jhs::S_PARAMS)
+ .getElement(jhs::S_PROTOCOL_TYPE)
+ .asInt());
std::string output_string;
- switch (message.getElement(jhs::S_PARAMS).getElement(jhs::S_PROTOCOL_TYPE)
- .asInt()) {
- case 0: {
- if (message.getElement(jhs::S_PARAMS).getElement(jhs::S_PROTOCOL_VERSION).asInt() == 1) {
- if (!formatters::CFormatterJsonSDLRPCv1::toString(message,
- output_string)) {
- LOG4CXX_WARN(logger_, "Failed to serialize smart object");
- return false;
- }
- output.set_protocol_version(application_manager::kV1);
- } else {
- if (!formatters::CFormatterJsonSDLRPCv2::toString(message,
- output_string)) {
- LOG4CXX_WARN(logger_, "Failed to serialize smart object");
- return false;
- }
- output.set_protocol_version(
- static_cast<ProtocolVersion>(
- message.getElement(jhs::S_PARAMS).getElement(
- jhs::S_PROTOCOL_VERSION).asUInt()));
+ switch (message.getElement(jhs::S_PARAMS)
+ .getElement(jhs::S_PROTOCOL_TYPE)
+ .asInt()) {
+ case 0: {
+ if (message.getElement(jhs::S_PARAMS)
+ .getElement(jhs::S_PROTOCOL_VERSION)
+ .asInt() == 1) {
+ if (!formatters::CFormatterJsonSDLRPCv1::toString(message,
+ output_string)) {
+ LOG4CXX_WARN(logger_, "Failed to serialize smart object");
+ return false;
}
-
- break;
- }
- case 1: {
- if (!formatters::FormatterJsonRpc::ToString(message, output_string)) {
+ output.set_protocol_version(application_manager::kV1);
+ } else {
+ if (!formatters::CFormatterJsonSDLRPCv2::toString(message,
+ output_string)) {
LOG4CXX_WARN(logger_, "Failed to serialize smart object");
return false;
}
- output.set_protocol_version(application_manager::kHMI);
- break;
+ output.set_protocol_version(
+ static_cast<ProtocolVersion>(message.getElement(jhs::S_PARAMS)
+ .getElement(jhs::S_PROTOCOL_VERSION)
+ .asUInt()));
}
- default:
- NOTREACHED();
+
+ break;
+ }
+ case 1: {
+ if (!formatters::FormatterJsonRpc::ToString(message, output_string)) {
+ LOG4CXX_WARN(logger_, "Failed to serialize smart object");
return false;
+ }
+ output.set_protocol_version(application_manager::kHMI);
+ break;
+ }
+ default:
+ NOTREACHED();
+ return false;
}
LOG4CXX_INFO(logger_, "Convertion result: " << output_string);
- output.set_connection_key(
- message.getElement(jhs::S_PARAMS).getElement(strings::connection_key)
- .asInt());
+ output.set_connection_key(message.getElement(jhs::S_PARAMS)
+ .getElement(strings::connection_key)
+ .asInt());
output.set_function_id(
- message.getElement(jhs::S_PARAMS).getElement(jhs::S_FUNCTION_ID).asInt());
+ message.getElement(jhs::S_PARAMS).getElement(jhs::S_FUNCTION_ID).asInt());
- output.set_correlation_id(
- message.getElement(jhs::S_PARAMS).getElement(jhs::S_CORRELATION_ID)
- .asInt());
+ output.set_correlation_id(message.getElement(jhs::S_PARAMS)
+ .getElement(jhs::S_CORRELATION_ID)
+ .asInt());
output.set_message_type(
- static_cast<MessageType>(message.getElement(jhs::S_PARAMS).getElement(
- jhs::S_MESSAGE_TYPE).asInt()));
+ static_cast<MessageType>(message.getElement(jhs::S_PARAMS)
+ .getElement(jhs::S_MESSAGE_TYPE)
+ .asInt()));
// Currently formatter creates JSON = 3 bytes for empty SmartObject.
// workaround for notification. JSON must be empty
- if (mobile_apis::FunctionID::OnAudioPassThruID
- != message.getElement(jhs::S_PARAMS).getElement(strings::function_id)
- .asInt()) {
+ if (mobile_apis::FunctionID::OnAudioPassThruID !=
+ message.getElement(jhs::S_PARAMS)
+ .getElement(strings::function_id)
+ .asInt()) {
output.set_json_message(output_string);
}
if (message.getElement(jhs::S_PARAMS).keyExists(strings::binary_data)) {
- application_manager::BinaryData* binaryData =
- new application_manager::BinaryData(
- message.getElement(jhs::S_PARAMS).getElement(strings::binary_data)
- .asBinary());
+ application_manager::BinaryData *binaryData =
+ new application_manager::BinaryData(
+ message.getElement(jhs::S_PARAMS)
+ .getElement(strings::binary_data)
+ .asBinary());
if (NULL == binaryData) {
LOG4CXX_ERROR(logger_, "Null pointer");
@@ -1805,21 +1805,21 @@ bool ApplicationManagerImpl::ConvertSOtoMessage(
}
utils::SharedPtr<Message> ApplicationManagerImpl::ConvertRawMsgToMessage(
- const ::protocol_handler::RawMessagePtr message) {
+ const ::protocol_handler::RawMessagePtr message) {
DCHECK(message);
utils::SharedPtr<Message> outgoing_message;
LOG4CXX_INFO(logger_, "Service type." << message->service_type());
- if (message->service_type() != protocol_handler::kRpc
- &&
+ if (message->service_type() != protocol_handler::kRpc &&
message->service_type() != protocol_handler::kBulk) {
// skip this message, not under handling of ApplicationManager
LOG4CXX_TRACE(logger_, "Skipping message; not the under AM handling.");
return outgoing_message;
}
- Message* convertion_result = MobileMessageHandler::HandleIncomingMessageProtocol(message);
+ Message *convertion_result =
+ MobileMessageHandler::HandleIncomingMessageProtocol(message);
if (convertion_result) {
outgoing_message = convertion_result;
@@ -1830,12 +1830,13 @@ utils::SharedPtr<Message> ApplicationManagerImpl::ConvertRawMsgToMessage(
}
void ApplicationManagerImpl::ProcessMessageFromMobile(
- const utils::SharedPtr<Message> message) {
+ const utils::SharedPtr<Message> message) {
LOG4CXX_INFO(logger_, "ApplicationManagerImpl::ProcessMessageFromMobile()");
#ifdef TIME_TESTER
- AMMetricObserver::MessageMetricSharedPtr metric(new AMMetricObserver::MessageMetric());
+ AMMetricObserver::MessageMetricSharedPtr metric(
+ new AMMetricObserver::MessageMetric());
metric->begin = date_time::DateTime::getCurrentTime();
-#endif // TIME_TESTER
+#endif // TIME_TESTER
smart_objects::SmartObjectSPtr so_from_mobile(new smart_objects::SmartObject);
if (!so_from_mobile) {
@@ -1849,10 +1850,9 @@ void ApplicationManagerImpl::ProcessMessageFromMobile(
}
#ifdef TIME_TESTER
metric->message = so_from_mobile;
-#endif // TIME_TESTER
+#endif // TIME_TESTER
- if (!ManageMobileCommand(so_from_mobile,
- commands::Command::ORIGIN_MOBILE)) {
+ if (!ManageMobileCommand(so_from_mobile, commands::Command::ORIGIN_MOBILE)) {
LOG4CXX_ERROR(logger_, "Received command didn't run successfully");
}
#ifdef TIME_TESTER
@@ -1860,11 +1860,11 @@ void ApplicationManagerImpl::ProcessMessageFromMobile(
if (metric_observer_) {
metric_observer_->OnMessage(metric);
}
-#endif // TIME_TESTER
+#endif // TIME_TESTER
}
void ApplicationManagerImpl::ProcessMessageFromHMI(
- const utils::SharedPtr<Message> message) {
+ const utils::SharedPtr<Message> message) {
LOG4CXX_INFO(logger_, "ApplicationManagerImpl::ProcessMessageFromHMI()");
smart_objects::SmartObjectSPtr smart_object(new smart_objects::SmartObject);
@@ -1880,7 +1880,7 @@ void ApplicationManagerImpl::ProcessMessageFromHMI(
LOG4CXX_ERROR(logger_, "Cannot create smart object from message");
return;
}
-#endif // HMI_DBUS_API
+#endif // HMI_DBUS_API
LOG4CXX_INFO(logger_, "Converted message, trying to create hmi command");
if (!ManageHMICommand(smart_object)) {
@@ -1888,7 +1888,7 @@ void ApplicationManagerImpl::ProcessMessageFromHMI(
}
}
-hmi_apis::HMI_API& ApplicationManagerImpl::hmi_so_factory() {
+hmi_apis::HMI_API &ApplicationManagerImpl::hmi_so_factory() {
if (!hmi_so_factory_) {
hmi_so_factory_ = new hmi_apis::HMI_API;
if (!hmi_so_factory_) {
@@ -1899,7 +1899,7 @@ hmi_apis::HMI_API& ApplicationManagerImpl::hmi_so_factory() {
return *hmi_so_factory_;
}
-mobile_apis::MOBILE_API& ApplicationManagerImpl::mobile_so_factory() {
+mobile_apis::MOBILE_API &ApplicationManagerImpl::mobile_so_factory() {
if (!mobile_so_factory_) {
mobile_so_factory_ = new mobile_apis::MOBILE_API;
if (!mobile_so_factory_) {
@@ -1910,19 +1910,20 @@ mobile_apis::MOBILE_API& ApplicationManagerImpl::mobile_so_factory() {
return *mobile_so_factory_;
}
-HMICapabilities& ApplicationManagerImpl::hmi_capabilities() {
+HMICapabilities &ApplicationManagerImpl::hmi_capabilities() {
return hmi_capabilities_;
}
-void ApplicationManagerImpl::PullLanguagesInfo(const SmartObject& app_data,
- SmartObject& ttsName,
- SmartObject& vrSynonym) {
+void ApplicationManagerImpl::PullLanguagesInfo(const SmartObject &app_data,
+ SmartObject &ttsName,
+ SmartObject &vrSynonym) {
LOG4CXX_AUTO_TRACE(logger_);
if (app_data.keyExists(json::languages)) {
- const HMICapabilities& hmi_cap = hmi_capabilities();
- std::string vr(MessageHelper::CommonLanguageToString(hmi_cap.active_vr_language()));
- const SmartObject& arr = app_data[json::languages];
+ const HMICapabilities &hmi_cap = hmi_capabilities();
+ std::string vr(
+ MessageHelper::CommonLanguageToString(hmi_cap.active_vr_language()));
+ const SmartObject &arr = app_data[json::languages];
std::transform(vr.begin(), vr.end(), vr.begin(), ::toupper);
@@ -1932,9 +1933,13 @@ void ApplicationManagerImpl::PullLanguagesInfo(const SmartObject& app_data,
const size_t size = arr.length();
for (size_t idx = 0; idx < size; ++idx) {
if (arr[idx].keyExists(vr)) {
- specific_idx = idx; break;
- } else if (arr[idx].keyExists(json::default_)) { default_idx = idx; }
- else { LOG4CXX_DEBUG(logger_, "Unknown key was specified."); }
+ specific_idx = idx;
+ break;
+ } else if (arr[idx].keyExists(json::default_)) {
+ default_idx = idx;
+ } else {
+ LOG4CXX_DEBUG(logger_, "Unknown key was specified.");
+ }
}
const ssize_t regular_id = specific_idx != -1 ? specific_idx : default_idx;
@@ -1948,7 +1953,7 @@ void ApplicationManagerImpl::PullLanguagesInfo(const SmartObject& app_data,
}
}
-void ApplicationManagerImpl::CreateApplications(SmartArray& obj_array,
+void ApplicationManagerImpl::CreateApplications(SmartArray &obj_array,
const uint32_t connection_key) {
LOG4CXX_AUTO_TRACE(logger_);
using namespace policy;
@@ -1956,7 +1961,7 @@ void ApplicationManagerImpl::CreateApplications(SmartArray& obj_array,
const std::size_t arr_size(obj_array.size());
for (std::size_t idx = 0; idx < arr_size; ++idx) {
- const SmartObject& app_data = obj_array[idx];
+ const SmartObject &app_data = obj_array[idx];
if (!(app_data.keyExists(json::name) && app_data.keyExists(json::appId))) {
LOG4CXX_DEBUG(logger_, "The entry in query apps json is not valid");
@@ -1965,11 +1970,11 @@ void ApplicationManagerImpl::CreateApplications(SmartArray& obj_array,
const std::string mobile_app_id(app_data[json::appId].asString());
ApplicationSharedPtr registered_app =
- ApplicationManagerImpl::instance()->
- application_by_policy_id(mobile_app_id);
+ ApplicationManagerImpl::instance()->application_by_policy_id(
+ mobile_app_id);
if (registered_app) {
- LOG4CXX_DEBUG(logger_, "Application with the same id: " << mobile_app_id
- << " is registered already.");
+ LOG4CXX_DEBUG(logger_, "Application with the same id: "
+ << mobile_app_id << " is registered already.");
continue;
}
@@ -1986,8 +1991,7 @@ void ApplicationManagerImpl::CreateApplications(SmartArray& obj_array,
url_scheme = app_data[os_type][json::urlScheme].asString();
} else if (app_data.keyExists(json::android)) {
os_type = json::android;
- package_name =
- app_data[os_type][json::packageName].asString();
+ package_name = app_data[os_type][json::packageName].asString();
}
PullLanguagesInfo(app_data[os_type], ttsName, vrSynonym);
@@ -2000,30 +2004,32 @@ void ApplicationManagerImpl::CreateApplications(SmartArray& obj_array,
vrSynonym[0] = appName;
}
- const uint32_t hmi_app_id = resume_ctrl_.IsApplicationSaved(mobile_app_id)?
- resume_ctrl_.GetHMIApplicationID(mobile_app_id) : GenerateNewHMIAppID();
+ const uint32_t hmi_app_id =
+ resume_ctrl_.IsApplicationSaved(mobile_app_id)
+ ? resume_ctrl_.GetHMIApplicationID(mobile_app_id)
+ : GenerateNewHMIAppID();
const std::string app_icon_dir(Profile::instance()->app_icons_folder());
const std::string full_icon_path(app_icon_dir + "/" + mobile_app_id);
uint32_t device_id = 0;
- connection_handler::ConnectionHandlerImpl* con_handler_impl =
- static_cast<connection_handler::ConnectionHandlerImpl*>(
- connection_handler_);
+ connection_handler::ConnectionHandlerImpl *con_handler_impl =
+ static_cast<connection_handler::ConnectionHandlerImpl *>(
+ connection_handler_);
- if (-1 == con_handler_impl->GetDataOnSessionKey(
- connection_key, NULL, NULL, &device_id)) {
+ if (-1 ==
+ con_handler_impl->GetDataOnSessionKey(connection_key, NULL, NULL,
+ &device_id)) {
LOG4CXX_ERROR(logger_,
"Failed to create application: no connection info.");
continue;
}
- // AppId = 0 because this is query_app(provided by hmi for download, but not yet registered)
+ // AppId = 0 because this is query_app(provided by hmi for download, but not
+ // yet registered)
ApplicationSharedPtr app(
- new ApplicationImpl(0,
- mobile_app_id,
- appName,
- PolicyHandler::instance()->GetStatisticManager()));
+ new ApplicationImpl(0, mobile_app_id, appName,
+ PolicyHandler::instance()->GetStatisticManager()));
DCHECK_OR_RETURN_VOID(app);
app->SetShemaUrl(url_scheme);
app->SetPackageName(package_name);
@@ -2035,16 +2041,16 @@ void ApplicationManagerImpl::CreateApplications(SmartArray& obj_array,
app->set_tts_name(ttsName);
sync_primitives::AutoLock lock(apps_to_register_list_lock_);
- LOG4CXX_DEBUG(logger_, "apps_to_register_ size before: "
- << apps_to_register_.size());
+ LOG4CXX_DEBUG(
+ logger_, "apps_to_register_ size before: " << apps_to_register_.size());
apps_to_register_.insert(app);
- LOG4CXX_DEBUG(logger_, "apps_to_register_ size after: "
- << apps_to_register_.size());
+ LOG4CXX_DEBUG(logger_,
+ "apps_to_register_ size after: " << apps_to_register_.size());
}
}
void ApplicationManagerImpl::ProcessQueryApp(
- const smart_objects::SmartObject& sm_object,
+ const smart_objects::SmartObject &sm_object,
const uint32_t connection_key) {
LOG4CXX_AUTO_TRACE(logger_);
using namespace policy;
@@ -2054,7 +2060,7 @@ void ApplicationManagerImpl::ProcessQueryApp(
return;
}
- SmartArray* obj_array = sm_object[json::response].asArray();
+ SmartArray *obj_array = sm_object[json::response].asArray();
if (NULL != obj_array) {
CreateApplications(*obj_array, connection_key);
SendUpdateAppList();
@@ -2071,32 +2077,33 @@ void ApplicationManagerImpl::ProcessQueryApp(
}
#ifdef TIME_TESTER
-void ApplicationManagerImpl::SetTimeMetricObserver(AMMetricObserver* observer) {
+void ApplicationManagerImpl::SetTimeMetricObserver(AMMetricObserver *observer) {
metric_observer_ = observer;
}
-#endif // TIME_TESTER
+#endif // TIME_TESTER
void ApplicationManagerImpl::addNotification(const CommandSharedPtr ptr) {
request_ctrl_.addNotification(ptr);
}
-void ApplicationManagerImpl::removeNotification(const commands::Command* notification) {
+void ApplicationManagerImpl::removeNotification(
+ const commands::Command *notification) {
request_ctrl_.removeNotification(notification);
}
-void ApplicationManagerImpl::updateRequestTimeout(uint32_t connection_key,
- uint32_t mobile_correlation_id,
+void ApplicationManagerImpl::updateRequestTimeout(
+ uint32_t connection_key, uint32_t mobile_correlation_id,
uint32_t new_timeout_value) {
LOG4CXX_AUTO_TRACE(logger_);
request_ctrl_.updateRequestTimeout(connection_key, mobile_correlation_id,
new_timeout_value);
}
-const uint32_t ApplicationManagerImpl::application_id
-(const int32_t correlation_id) {
+const uint32_t
+ApplicationManagerImpl::application_id(const int32_t correlation_id) {
// ykazakov: there is no erase for const iterator for QNX
std::map<const int32_t, const uint32_t>::iterator it =
- appID_list_.find(correlation_id);
+ appID_list_.find(correlation_id);
if (appID_list_.end() != it) {
const uint32_t app_id = it->second;
appID_list_.erase(it);
@@ -2107,21 +2114,23 @@ const uint32_t ApplicationManagerImpl::application_id
}
void ApplicationManagerImpl::set_application_id(const int32_t correlation_id,
- const uint32_t app_id) {
- appID_list_.insert(std::pair<const int32_t, const uint32_t>
- (correlation_id, app_id));
+ const uint32_t app_id) {
+ appID_list_.insert(
+ std::pair<const int32_t, const uint32_t>(correlation_id, app_id));
}
-void ApplicationManagerImpl::AddPolicyObserver( policy::PolicyHandlerObserver* listener) {
+void ApplicationManagerImpl::AddPolicyObserver(
+ policy::PolicyHandlerObserver *listener) {
policy::PolicyHandler::instance()->add_listener(listener);
}
-void ApplicationManagerImpl::RemovePolicyObserver(policy::PolicyHandlerObserver* listener) {
+void ApplicationManagerImpl::RemovePolicyObserver(
+ policy::PolicyHandlerObserver *listener) {
policy::PolicyHandler::instance()->remove_listener(listener);
}
void ApplicationManagerImpl::SetUnregisterAllApplicationsReason(
- mobile_api::AppInterfaceUnregisteredReason::eType reason) {
+ mobile_api::AppInterfaceUnregisteredReason::eType reason) {
LOG4CXX_TRACE(logger_, "reason = " << reason);
unregister_reason_ = reason;
}
@@ -2132,38 +2141,37 @@ void ApplicationManagerImpl::HeadUnitReset(
is_stopping_ = true;
stopping_flag_lock_.Release();
switch (reason) {
- case mobile_api::AppInterfaceUnregisteredReason::MASTER_RESET: {
- UnregisterAllApplications();
- policy::PolicyHandler::instance()->ResetPolicyTable();
- policy::PolicyHandler::instance()->UnloadPolicyLibrary();
+ case mobile_api::AppInterfaceUnregisteredReason::MASTER_RESET: {
+ UnregisterAllApplications();
+ policy::PolicyHandler::instance()->ResetPolicyTable();
+ policy::PolicyHandler::instance()->UnloadPolicyLibrary();
- resume_controller().StopSavePersistentDataTimer();
- file_system::remove_directory_content(profile::Profile::instance()->app_storage_folder());
- break;
- }
- case mobile_api::AppInterfaceUnregisteredReason::FACTORY_DEFAULTS: {
- policy::PolicyHandler::instance()->ClearUserConsent();
- break;
- }
- default: {
- LOG4CXX_ERROR(logger_, "Bad AppInterfaceUnregisteredReason");
- return;
- }
+ resume_controller().StopSavePersistentDataTimer();
+ file_system::remove_directory_content(
+ profile::Profile::instance()->app_storage_folder());
+ break;
+ }
+ case mobile_api::AppInterfaceUnregisteredReason::FACTORY_DEFAULTS: {
+ policy::PolicyHandler::instance()->ClearUserConsent();
+ break;
+ }
+ default: {
+ LOG4CXX_ERROR(logger_, "Bad AppInterfaceUnregisteredReason");
+ return;
+ }
}
}
-
void ApplicationManagerImpl::SendOnSDLClose() {
LOG4CXX_AUTO_TRACE(logger_);
// must be sent to PASA HMI on shutdown synchronously
- smart_objects::SmartObjectSPtr msg = new smart_objects::SmartObject(
- smart_objects::SmartType_Map);
+ smart_objects::SmartObjectSPtr msg =
+ new smart_objects::SmartObject(smart_objects::SmartType_Map);
(*msg)[strings::params][strings::function_id] =
- hmi_apis::FunctionID::BasicCommunication_OnSDLClose;
- (*msg)[strings::params][strings::message_type] =
- MessageType::kNotification;
+ hmi_apis::FunctionID::BasicCommunication_OnSDLClose;
+ (*msg)[strings::params][strings::message_type] = MessageType::kNotification;
(*msg)[strings::params][strings::protocol_type] =
commands::CommandImpl::hmi_protocol_type_;
(*msg)[strings::params][strings::protocol_version] =
@@ -2177,12 +2185,11 @@ void ApplicationManagerImpl::SendOnSDLClose() {
// SmartObject |message| has no way to declare priority for now
utils::SharedPtr<Message> message_to_send(
- new Message(protocol_handler::MessagePriority::kDefault));
+ new Message(protocol_handler::MessagePriority::kDefault));
hmi_so_factory().attachSchema(*msg, false);
- LOG4CXX_DEBUG(logger_,
- "Attached schema to message, result if valid: " << msg->isValid());
-
+ LOG4CXX_DEBUG(logger_, "Attached schema to message, result if valid: "
+ << msg->isValid());
#ifdef HMI_DBUS_API
message_to_send->set_smart_object(*msg);
@@ -2192,7 +2199,7 @@ void ApplicationManagerImpl::SendOnSDLClose() {
"Cannot send message to HMI: failed to create string");
return;
}
-#endif // HMI_DBUS_API
+#endif // HMI_DBUS_API
if (!hmi_handler_) {
LOG4CXX_WARN(logger_, "No HMI Handler set");
@@ -2202,7 +2209,6 @@ void ApplicationManagerImpl::SendOnSDLClose() {
hmi_handler_->SendMessageToHMI(message_to_send);
}
-
void ApplicationManagerImpl::UnregisterAllApplications() {
LOG4CXX_DEBUG(logger_, "Unregister reason " << unregister_reason_);
@@ -2214,37 +2220,36 @@ void ApplicationManagerImpl::UnregisterAllApplications() {
is_ignition_off =
Compare<eType, EQ, ONE>(unregister_reason_, IGNITION_OFF, INVALID_ENUM);
- bool is_unexpected_disconnect =
- Compare<eType, NEQ, ALL>(unregister_reason_,
- IGNITION_OFF, MASTER_RESET, FACTORY_DEFAULTS);
+ bool is_unexpected_disconnect = Compare<eType, NEQ, ALL>(
+ unregister_reason_, IGNITION_OFF, MASTER_RESET, FACTORY_DEFAULTS);
ClearTTSGlobalPropertiesList();
- { // A local scope to limit accessor's lifetime and release app list lock.
- ApplicationListAccessor accessor;
- ApplictionSetConstIt it = accessor.begin();
- while (it != accessor.end()) {
- ApplicationSharedPtr app_to_remove = *it;
+ { // A local scope to limit accessor's lifetime and release app list lock.
+ ApplicationListAccessor accessor;
+ ApplictionSetConstIt it = accessor.begin();
+ while (it != accessor.end()) {
+ ApplicationSharedPtr app_to_remove = *it;
#ifdef CUSTOMER_PASA
- if (!is_ignition_off) {
+ if (!is_ignition_off) {
#endif // CUSTOMER_PASA
- MessageHelper::SendOnAppInterfaceUnregisteredNotificationToMobile(
+ MessageHelper::SendOnAppInterfaceUnregisteredNotificationToMobile(
app_to_remove->app_id(), unregister_reason_);
#ifdef CUSTOMER_PASA
- }
+ }
#endif // CUSTOMER_PASA
- UnregisterApplication(app_to_remove->app_id(),
- mobile_apis::Result::INVALID_ENUM, is_ignition_off,
- is_unexpected_disconnect);
- connection_handler_->CloseSession(app_to_remove->app_id(),
- connection_handler::kCommon);
- it = accessor.begin();
- }
+ UnregisterApplication(app_to_remove->app_id(),
+ mobile_apis::Result::INVALID_ENUM, is_ignition_off,
+ is_unexpected_disconnect);
+ connection_handler_->CloseSession(app_to_remove->app_id(),
+ connection_handler::kCommon);
+ it = accessor.begin();
+ }
}
- if (is_ignition_off) { // Move this block before unregistering apps?
+ if (is_ignition_off) { // Move this block before unregistering apps?
resume_controller().Suspend();
}
request_ctrl_.terminateAllHMIRequests();
@@ -2254,16 +2259,14 @@ void ApplicationManagerImpl::RemoveAppsWaitingForRegistration(
const connection_handler::DeviceHandle handle) {
DevicePredicate device_finder(handle);
apps_to_register_list_lock_.Acquire();
- AppsWaitRegistrationSet::iterator it_app =
- std::find_if(apps_to_register_.begin(), apps_to_register_.end(),
- device_finder);
+ AppsWaitRegistrationSet::iterator it_app = std::find_if(
+ apps_to_register_.begin(), apps_to_register_.end(), device_finder);
- while (apps_to_register_.end()!= it_app) {
+ while (apps_to_register_.end() != it_app) {
LOG4CXX_DEBUG(logger_, "Waiting app: " << (*it_app)->name()
- << " is removed.");
+ << " is removed.");
apps_to_register_.erase(it_app);
- it_app = std::find_if(apps_to_register_.begin(),
- apps_to_register_.end(),
+ it_app = std::find_if(apps_to_register_.begin(), apps_to_register_.end(),
device_finder);
}
@@ -2271,39 +2274,43 @@ void ApplicationManagerImpl::RemoveAppsWaitingForRegistration(
}
void ApplicationManagerImpl::UnregisterApplication(
- const uint32_t& app_id, mobile_apis::Result::eType reason,
- bool is_resuming, bool is_unexpected_disconnect) {
- LOG4CXX_INFO(logger_, "app_id = " << app_id
- << "; reason = " << reason
- << "; is_resuming = " << is_resuming
- << "; is_unexpected_disconnect = " << is_unexpected_disconnect);
-
- NaviServiceStatusMap::iterator it =
- navi_service_status_.find(app_id);
+ const uint32_t &app_id, mobile_apis::Result::eType reason, bool is_resuming,
+ bool is_unexpected_disconnect) {
+ LOG4CXX_INFO(logger_, "app_id = " << app_id << "; reason = " << reason
+ << "; is_resuming = " << is_resuming
+ << "; is_unexpected_disconnect = "
+ << is_unexpected_disconnect);
+
+ NaviServiceStatusMap::iterator it = navi_service_status_.find(app_id);
if (navi_service_status_.end() != it) {
navi_service_status_.erase(it);
}
- //remove appID from tts_global_properties_app_list_
+ // remove appID from tts_global_properties_app_list_
RemoveAppFromTTSGlobalPropertiesList(app_id);
switch (reason) {
- case mobile_apis::Result::SUCCESS:break;
- case mobile_apis::Result::DISALLOWED: break;
- case mobile_apis::Result::USER_DISALLOWED:break;
- case mobile_apis::Result::INVALID_CERT: break;
- case mobile_apis::Result::EXPIRED_CERT: break;
- case mobile_apis::Result::TOO_MANY_PENDING_REQUESTS: {
- ApplicationSharedPtr app_ptr = application(app_id);
- if(app_ptr) {
- app_ptr->usage_report().RecordRemovalsForBadBehavior();
- }
- break;
- }
- default: {
- LOG4CXX_ERROR(logger_, "Unknown unregister reason " << reason);
- break;
+ case mobile_apis::Result::SUCCESS:
+ break;
+ case mobile_apis::Result::DISALLOWED:
+ break;
+ case mobile_apis::Result::USER_DISALLOWED:
+ break;
+ case mobile_apis::Result::INVALID_CERT:
+ break;
+ case mobile_apis::Result::EXPIRED_CERT:
+ break;
+ case mobile_apis::Result::TOO_MANY_PENDING_REQUESTS: {
+ ApplicationSharedPtr app_ptr = application(app_id);
+ if (app_ptr) {
+ app_ptr->usage_report().RecordRemovalsForBadBehavior();
}
+ break;
+ }
+ default: {
+ LOG4CXX_ERROR(logger_, "Unknown unregister reason " << reason);
+ break;
+ }
}
ApplicationSharedPtr app_to_remove;
@@ -2327,8 +2334,8 @@ void ApplicationManagerImpl::UnregisterApplication(
AppV4DevicePredicate finder(handle);
ApplicationSharedPtr app = accessor.Find(finder);
if (!app) {
- LOG4CXX_DEBUG(logger_, "There is no more SDL4 apps with device handle: "
- << handle);
+ LOG4CXX_DEBUG(
+ logger_, "There is no more SDL4 apps with device handle: " << handle);
RemoveAppsWaitingForRegistration(handle);
SendUpdateAppList();
@@ -2336,7 +2343,7 @@ void ApplicationManagerImpl::UnregisterApplication(
}
if (is_resuming) {
- resume_ctrl_.SaveApplication(app_to_remove);
+ resume_ctrl_.SaveApplication(app_to_remove);
} else {
resume_ctrl_.RemoveApplicationFromSaved(app_to_remove->mobile_app_id());
}
@@ -2354,8 +2361,9 @@ void ApplicationManagerImpl::UnregisterApplication(
return;
}
-void ApplicationManagerImpl::OnAppUnauthorized(const uint32_t& app_id) {
- connection_handler_->CloseSession(app_id, connection_handler::kUnauthorizedApp);
+void ApplicationManagerImpl::OnAppUnauthorized(const uint32_t &app_id) {
+ connection_handler_->CloseSession(app_id,
+ connection_handler::kUnauthorizedApp);
}
void ApplicationManagerImpl::Handle(const impl::MessageFromMobile message) {
@@ -2382,7 +2390,7 @@ void ApplicationManagerImpl::Handle(const impl::MessageToMobile message) {
}
utils::SharedPtr<protocol_handler::RawMessage> rawMessage =
- MobileMessageHandler::HandleOutgoingMessageProtocol(message);
+ MobileMessageHandler::HandleOutgoingMessageProtocol(message);
if (!rawMessage) {
LOG4CXX_ERROR(logger_, "Failed to create raw message.");
@@ -2392,7 +2400,8 @@ void ApplicationManagerImpl::Handle(const impl::MessageToMobile message) {
bool is_final = message.is_final;
bool close_session = false;
if (is_final) {
- if (1 < connection_handler_->GetConnectionSessionsCount(message->connection_key())) {
+ if (1 < connection_handler_->GetConnectionSessionsCount(
+ message->connection_key())) {
is_final = false;
close_session = true;
}
@@ -2431,7 +2440,8 @@ void ApplicationManagerImpl::Handle(const impl::MessageToHmi message) {
void ApplicationManagerImpl::Handle(const impl::AudioData message) {
LOG4CXX_INFO(logger_, "Send AudioPassThru notification");
- smart_objects::SmartObjectSPtr on_audio_pass = new smart_objects::SmartObject();
+ smart_objects::SmartObjectSPtr on_audio_pass =
+ new smart_objects::SmartObject();
if (!on_audio_pass) {
LOG4CXX_ERROR_EXT(logger_, "OnAudioPassThru NULL pointer");
@@ -2453,23 +2463,20 @@ void ApplicationManagerImpl::Handle(const impl::AudioData message) {
(*on_audio_pass)[strings::params][strings::binary_data] =
smart_objects::SmartObject(message.binary_data);
- LOG4CXX_INFO_EXT(logger_, "After fill binary data");
+ LOG4CXX_INFO_EXT(logger_, "After fill binary data");
- LOG4CXX_INFO_EXT(logger_, "Send data");
- CommandSharedPtr command (
- MobileCommandFactory::CreateCommand(on_audio_pass,
- commands::Command::ORIGIN_SDL));
- command->Init();
- command->Run();
- command->CleanUp();
+ LOG4CXX_INFO_EXT(logger_, "Send data");
+ CommandSharedPtr command(MobileCommandFactory::CreateCommand(
+ on_audio_pass, commands::Command::ORIGIN_SDL));
+ command->Init();
+ command->Run();
+ command->CleanUp();
}
mobile_apis::Result::eType ApplicationManagerImpl::CheckPolicyPermissions(
- const std::string& policy_app_id,
- mobile_apis::HMILevel::eType hmi_level,
- mobile_apis::FunctionID::eType function_id,
- const RPCParams& rpc_params,
- CommandParametersPermissions* params_permissions) {
+ const std::string &policy_app_id, mobile_apis::HMILevel::eType hmi_level,
+ mobile_apis::FunctionID::eType function_id, const RPCParams &rpc_params,
+ CommandParametersPermissions *params_permissions) {
LOG4CXX_INFO(logger_, "CheckPolicyPermissions");
// TODO(AOleynik): Remove check of policy_enable, when this flag will be
// unused in config file
@@ -2481,27 +2488,22 @@ mobile_apis::Result::eType ApplicationManagerImpl::CheckPolicyPermissions(
MessageHelper::StringifiedFunctionID(function_id);
const std::string stringified_hmi_level =
MessageHelper::StringifiedHMILevel(hmi_level);
- LOG4CXX_INFO(
- logger_,
- "Checking permissions for " << policy_app_id <<
- " in " << stringified_hmi_level <<
- " rpc " << stringified_functionID);
- policy::CheckPermissionResult result;
- policy::PolicyHandler::instance()->CheckPermissions(
- policy_app_id,
- stringified_hmi_level,
- stringified_functionID,
- rpc_params,
- result);
+ LOG4CXX_INFO(logger_, "Checking permissions for "
+ << policy_app_id << " in " << stringified_hmi_level
+ << " rpc " << stringified_functionID);
+ policy::CheckPermissionResult result;
+ policy::PolicyHandler::instance()->CheckPermissions(
+ policy_app_id, stringified_hmi_level, stringified_functionID, rpc_params,
+ result);
if (NULL != params_permissions) {
- params_permissions->allowed_params = result.list_of_allowed_params;
- params_permissions->disallowed_params = result.list_of_disallowed_params;
- params_permissions->undefined_params = result.list_of_undefined_params;
+ params_permissions->allowed_params = result.list_of_allowed_params;
+ params_permissions->disallowed_params = result.list_of_disallowed_params;
+ params_permissions->undefined_params = result.list_of_undefined_params;
}
- if (hmi_level == mobile_apis::HMILevel::HMI_NONE
- && function_id != mobile_apis::FunctionID::UnregisterAppInterfaceID) {
+ if (hmi_level == mobile_apis::HMILevel::HMI_NONE &&
+ function_id != mobile_apis::FunctionID::UnregisterAppInterfaceID) {
ApplicationSharedPtr app = application_by_policy_id(policy_app_id);
if (!app) {
LOG4CXX_ERROR(logger_, "No application for policy id " << policy_app_id);
@@ -2512,12 +2514,12 @@ mobile_apis::Result::eType ApplicationManagerImpl::CheckPolicyPermissions(
}
}
- const std::string log_msg = "Application: "+ policy_app_id+
- ", RPC: "+stringified_functionID+
- ", HMI status: "+stringified_hmi_level;
+ const std::string log_msg = "Application: " + policy_app_id + ", RPC: " +
+ stringified_functionID + ", HMI status: " +
+ stringified_hmi_level;
if (result.hmi_level_permitted != policy::kRpcAllowed) {
- LOG4CXX_WARN(logger_, "Request is blocked by policies. " << log_msg );
+ LOG4CXX_WARN(logger_, "Request is blocked by policies. " << log_msg);
ApplicationSharedPtr app = application_by_policy_id(policy_app_id);
if (!app) {
@@ -2527,23 +2529,22 @@ mobile_apis::Result::eType ApplicationManagerImpl::CheckPolicyPermissions(
app->usage_report().RecordPolicyRejectedRpcCall();
switch (result.hmi_level_permitted) {
- case policy::kRpcDisallowed:
- return mobile_apis::Result::DISALLOWED;
- case policy::kRpcUserDisallowed:
- return mobile_apis::Result::USER_DISALLOWED;
- default:
- return mobile_apis::Result::INVALID_ENUM;
+ case policy::kRpcDisallowed:
+ return mobile_apis::Result::DISALLOWED;
+ case policy::kRpcUserDisallowed:
+ return mobile_apis::Result::USER_DISALLOWED;
+ default:
+ return mobile_apis::Result::INVALID_ENUM;
}
}
- LOG4CXX_INFO(logger_, "Request is allowed by policies. "+log_msg);
+ LOG4CXX_INFO(logger_, "Request is allowed by policies. " + log_msg);
return mobile_api::Result::SUCCESS;
}
-
-void ApplicationManagerImpl::OnLowVoltage() {
- LOG4CXX_AUTO_TRACE(logger_);
- is_low_voltage_ = true;
- request_ctrl_.OnLowVoltage();
+void ApplicationManagerImpl::OnLowVoltage() {
+ LOG4CXX_AUTO_TRACE(logger_);
+ is_low_voltage_ = true;
+ request_ctrl_.OnLowVoltage();
}
bool ApplicationManagerImpl::IsLowVoltage() {
@@ -2562,8 +2563,7 @@ bool ApplicationManagerImpl::HMILevelAllowsStreaming(
LOG4CXX_WARN(logger_, "An application is not registered.");
return false;
}
- return Compare<eType, EQ, ONE>(
- app->hmi_level(), HMI_FULL, HMI_LIMITED);
+ return Compare<eType, EQ, ONE>(app->hmi_level(), HMI_FULL, HMI_LIMITED);
}
bool ApplicationManagerImpl::CanAppStream(
@@ -2601,14 +2601,14 @@ void ApplicationManagerImpl::ForbidStreaming(uint32_t app_id) {
}
if (navi_app_to_stop_.end() != std::find(navi_app_to_stop_.begin(),
- navi_app_to_stop_.end(), app_id) ||
- navi_app_to_end_stream_.end() != std::find(navi_app_to_end_stream_.begin(),
- navi_app_to_end_stream_.end(), app_id)) {
+ navi_app_to_stop_.end(), app_id) ||
+ navi_app_to_end_stream_.end() !=
+ std::find(navi_app_to_end_stream_.begin(),
+ navi_app_to_end_stream_.end(), app_id)) {
return;
}
- NaviServiceStatusMap::iterator it =
- navi_service_status_.find(app_id);
+ NaviServiceStatusMap::iterator it = navi_service_status_.find(app_id);
if (navi_service_status_.end() == it ||
(!it->second.first && !it->second.second)) {
MessageHelper::SendOnAppInterfaceUnregisteredNotificationToMobile(
@@ -2650,8 +2650,7 @@ void ApplicationManagerImpl::EndNaviServices(uint32_t app_id) {
return;
}
- NaviServiceStatusMap::iterator it =
- navi_service_status_.find(app_id);
+ NaviServiceStatusMap::iterator it = navi_service_status_.find(app_id);
if (navi_service_status_.end() == it) {
return;
}
@@ -2671,8 +2670,9 @@ void ApplicationManagerImpl::EndNaviServices(uint32_t app_id) {
}
navi_app_to_stop_.push_back(app_id);
- ApplicationManagerTimerPtr closeTimer(new TimerThread<ApplicationManagerImpl>(
- "CloseAppTimer", this, &ApplicationManagerImpl::CloseNaviApp));
+ ApplicationManagerTimerPtr closeTimer(
+ new TimerThread<ApplicationManagerImpl>(
+ "CloseAppTimer", this, &ApplicationManagerImpl::CloseNaviApp));
closeTimer->start(navi_close_app_timeout_);
sync_primitives::AutoLock lock(timer_pool_lock_);
@@ -2680,9 +2680,9 @@ void ApplicationManagerImpl::EndNaviServices(uint32_t app_id) {
}
}
-void ApplicationManagerImpl::OnHMILevelChanged(uint32_t app_id,
- mobile_apis::HMILevel::eType from,
- mobile_apis::HMILevel::eType to) {
+void ApplicationManagerImpl::OnHMILevelChanged(
+ uint32_t app_id, mobile_apis::HMILevel::eType from,
+ mobile_apis::HMILevel::eType to) {
using namespace mobile_apis::HMILevel;
using namespace helpers;
@@ -2704,16 +2704,17 @@ void ApplicationManagerImpl::OnHMILevelChanged(uint32_t app_id,
if (from == HMI_FULL || from == HMI_LIMITED) {
navi_app_to_end_stream_.push_back(app_id);
- ApplicationManagerTimerPtr endStreamTimer(new TimerThread<ApplicationManagerImpl>(
- "EndStreamTimer", this, &ApplicationManagerImpl::EndNaviStreaming));
+ ApplicationManagerTimerPtr endStreamTimer(
+ new TimerThread<ApplicationManagerImpl>(
+ "EndStreamTimer", this,
+ &ApplicationManagerImpl::EndNaviStreaming));
endStreamTimer->start(navi_end_stream_timeout_);
sync_primitives::AutoLock lock(timer_pool_lock_);
timer_pool_.push_back(endStreamTimer);
}
} else if (to == HMI_NONE) {
- if (from == HMI_FULL || from == HMI_LIMITED ||
- from == HMI_BACKGROUND) {
+ if (from == HMI_FULL || from == HMI_LIMITED || from == HMI_BACKGROUND) {
EndNaviServices(app_id);
}
}
@@ -2745,8 +2746,7 @@ void ApplicationManagerImpl::CloseNaviApp() {
uint32_t app_id = navi_app_to_stop_.front();
navi_app_to_stop_.pop_front();
- NaviServiceStatusMap::iterator it =
- navi_service_status_.find(app_id);
+ NaviServiceStatusMap::iterator it = navi_service_status_.find(app_id);
if (navi_service_status_.end() != it) {
if (it->second.first || it->second.second) {
MessageHelper::SendOnAppInterfaceUnregisteredNotificationToMobile(
@@ -2764,8 +2764,8 @@ void ApplicationManagerImpl::EndNaviStreaming() {
uint32_t app_id = navi_app_to_end_stream_.front();
navi_app_to_end_stream_.pop_front();
- if (navi_app_to_stop_.end() == std::find(navi_app_to_stop_.begin(),
- navi_app_to_stop_.end(), app_id)) {
+ if (navi_app_to_stop_.end() ==
+ std::find(navi_app_to_stop_.begin(), navi_app_to_stop_.end(), app_id)) {
DisallowStreaming(app_id);
}
}
@@ -2780,8 +2780,7 @@ void ApplicationManagerImpl::DisallowStreaming(uint32_t app_id) {
return;
}
- NaviServiceStatusMap::iterator it =
- navi_service_status_.find(app_id);
+ NaviServiceStatusMap::iterator it = navi_service_status_.find(app_id);
if (navi_service_status_.end() != it) {
if (it->second.first) {
app->set_video_streaming_allowed(false);
@@ -2802,8 +2801,7 @@ void ApplicationManagerImpl::AllowStreaming(uint32_t app_id) {
return;
}
- NaviServiceStatusMap::iterator it =
- navi_service_status_.find(app_id);
+ NaviServiceStatusMap::iterator it = navi_service_status_.find(app_id);
if (navi_service_status_.end() != it) {
if (it->second.first) {
app->set_video_streaming_allowed(true);
@@ -2815,17 +2813,16 @@ void ApplicationManagerImpl::AllowStreaming(uint32_t app_id) {
}
void ApplicationManagerImpl::OnWakeUp() {
- LOG4CXX_AUTO_TRACE(logger_);
- is_low_voltage_ = false;
- request_ctrl_.OnWakeUp();
+ LOG4CXX_AUTO_TRACE(logger_);
+ is_low_voltage_ = false;
+ request_ctrl_.OnWakeUp();
}
mobile_apis::Result::eType ApplicationManagerImpl::SaveBinary(
- const std::vector<uint8_t>& binary_data, const std::string& file_path,
- const std::string& file_name, const int64_t offset) {
- LOG4CXX_INFO(logger_,
- "SaveBinaryWithOffset binary_size = " << binary_data.size()
- << " offset = " << offset);
+ const std::vector<uint8_t> &binary_data, const std::string &file_path,
+ const std::string &file_name, const int64_t offset) {
+ LOG4CXX_INFO(logger_, "SaveBinaryWithOffset binary_size = "
+ << binary_data.size() << " offset = " << offset);
if (binary_data.size() > file_system::GetAvailableDiskSpace(file_path)) {
LOG4CXX_ERROR(logger_, "Out of free disc space.");
@@ -2834,19 +2831,19 @@ mobile_apis::Result::eType ApplicationManagerImpl::SaveBinary(
const std::string full_file_path = file_path + "/" + file_name;
int64_t file_size = file_system::FileSize(full_file_path);
- std::ofstream* file_stream;
+ std::ofstream *file_stream;
if (offset != 0) {
if (file_size != offset) {
LOG4CXX_INFO(logger_,
"ApplicationManagerImpl::SaveBinaryWithOffset offset"
- << " does'n match existing file size");
+ << " does'n match existing file size");
return mobile_apis::Result::INVALID_DATA;
}
file_stream = file_system::Open(full_file_path, std::ios_base::app);
} else {
LOG4CXX_INFO(
- logger_,
- "ApplicationManagerImpl::SaveBinaryWithOffset offset is 0, rewrite");
+ logger_,
+ "ApplicationManagerImpl::SaveBinaryWithOffset offset is 0, rewrite");
// if offset == 0: rewrite file
file_stream = file_system::Open(full_file_path, std::ios_base::out);
}
@@ -2863,10 +2860,10 @@ mobile_apis::Result::eType ApplicationManagerImpl::SaveBinary(
}
uint32_t ApplicationManagerImpl::GetAvailableSpaceForApp(
- const std::string& folder_name) {
+ const std::string &folder_name) {
const uint32_t app_quota = profile::Profile::instance()->app_dir_quota();
std::string app_storage_path =
- profile::Profile::instance()->app_storage_folder();
+ profile::Profile::instance()->app_storage_folder();
app_storage_path += "/";
app_storage_path += folder_name;
@@ -2879,7 +2876,7 @@ uint32_t ApplicationManagerImpl::GetAvailableSpaceForApp(
uint32_t current_app_quota = app_quota - size_of_directory;
uint32_t available_disk_space =
- file_system::GetAvailableDiskSpace(app_storage_path);
+ file_system::GetAvailableDiskSpace(app_storage_path);
if (current_app_quota > available_disk_space) {
return available_disk_space;
@@ -2920,7 +2917,8 @@ void ApplicationManagerImpl::OnTimerSendTTSGlobalProperties() {
}
if (!app_list.empty()) {
for (uint32_t i = 0; i < app_list.size(); ++i) {
- LOG4CXX_INFO(logger_, "Send TTS GlobalProperties to HMI with default helpPrompt");
+ LOG4CXX_INFO(logger_,
+ "Send TTS GlobalProperties to HMI with default helpPrompt");
MessageHelper::SendTTSGlobalProperties(application(app_list[i]), true);
RemoveAppFromTTSGlobalPropertiesList(app_list[i]);
}
@@ -2930,7 +2928,8 @@ void ApplicationManagerImpl::OnTimerSendTTSGlobalProperties() {
void ApplicationManagerImpl::AddAppToTTSGlobalPropertiesList(
const uint32_t app_id) {
LOG4CXX_AUTO_TRACE(logger_);
- uint16_t timeout = profile::Profile::instance()->tts_global_properties_timeout();
+ uint16_t timeout =
+ profile::Profile::instance()->tts_global_properties_timeout();
TimevalStruct current_time = date_time::DateTime::getCurrentTime();
current_time.tv_sec += timeout;
// please avoid AutoLock usage to avoid deadlock
@@ -2939,7 +2938,7 @@ void ApplicationManagerImpl::AddAppToTTSGlobalPropertiesList(
tts_global_properties_app_list_.find(app_id)) {
tts_global_properties_app_list_[app_id] = current_time;
}
- //if add first item need to start timer on one second
+ // if add first item need to start timer on one second
if (1 == tts_global_properties_app_list_.size()) {
LOG4CXX_INFO(logger_, "Start tts_global_properties_timer_");
tts_global_properties_app_list_lock_.Release();
@@ -2969,7 +2968,8 @@ void ApplicationManagerImpl::RemoveAppFromTTSGlobalPropertiesList(
tts_global_properties_app_list_lock_.Release();
}
-mobile_apis::AppHMIType::eType ApplicationManagerImpl::StringToAppHMIType(std::string str) {
+mobile_apis::AppHMIType::eType
+ApplicationManagerImpl::StringToAppHMIType(std::string str) {
LOG4CXX_AUTO_TRACE(logger_);
if ("DEFAULT" == str) {
return mobile_apis::AppHMIType::DEFAULT;
@@ -2996,21 +2996,22 @@ mobile_apis::AppHMIType::eType ApplicationManagerImpl::StringToAppHMIType(std::s
}
}
-bool ApplicationManagerImpl::CompareAppHMIType (const smart_objects::SmartObject& from_policy,
- const smart_objects::SmartObject& from_application) {
+bool ApplicationManagerImpl::CompareAppHMIType(
+ const smart_objects::SmartObject &from_policy,
+ const smart_objects::SmartObject &from_application) {
LOG4CXX_AUTO_TRACE(logger_);
bool equal = false;
uint32_t lenght_policy_app_types = from_policy.length();
uint32_t lenght_application_app_types = from_application.length();
- for(uint32_t i = 0; i < lenght_application_app_types; ++i) {
- for(uint32_t k = 0; k < lenght_policy_app_types; ++k) {
+ for (uint32_t i = 0; i < lenght_application_app_types; ++i) {
+ for (uint32_t k = 0; k < lenght_policy_app_types; ++k) {
if (from_application[i] == from_policy[k]) {
equal = true;
break;
}
}
- if(!equal) {
+ if (!equal) {
return false;
}
equal = false;
@@ -3019,43 +3020,46 @@ bool ApplicationManagerImpl::CompareAppHMIType (const smart_objects::SmartObject
}
void ApplicationManagerImpl::OnUpdateHMIAppType(
- std::map<std::string, std::vector<std::string> > app_hmi_types) {
+ std::map<std::string, std::vector<std::string>> app_hmi_types) {
LOG4CXX_AUTO_TRACE(logger_);
- std::map<std::string, std::vector<std::string> >::iterator it_app_hmi_types_from_policy;
+ std::map<std::string, std::vector<std::string>>::iterator
+ it_app_hmi_types_from_policy;
std::vector<std::string> hmi_types_from_policy;
- smart_objects::SmartObject transform_app_hmi_types(smart_objects::SmartType_Array);
+ smart_objects::SmartObject transform_app_hmi_types(
+ smart_objects::SmartType_Array);
bool flag_diffirence_app_hmi_type = false;
ApplicationListAccessor accessor;
- for (ApplictionSetIt it = accessor.begin();
- it != accessor.end(); ++it) {
+ for (ApplictionSetIt it = accessor.begin(); it != accessor.end(); ++it) {
- it_app_hmi_types_from_policy =
- app_hmi_types.find(((*it)->mobile_app_id()));
+ it_app_hmi_types_from_policy = app_hmi_types.find(((*it)->mobile_app_id()));
if (it_app_hmi_types_from_policy != app_hmi_types.end() &&
((it_app_hmi_types_from_policy->second).size())) {
flag_diffirence_app_hmi_type = false;
hmi_types_from_policy = (it_app_hmi_types_from_policy->second);
- if(transform_app_hmi_types.length()) {
+ if (transform_app_hmi_types.length()) {
transform_app_hmi_types =
smart_objects::SmartObject(smart_objects::SmartType_Array);
}
- for(uint32_t i = 0; i < hmi_types_from_policy.size(); ++i) {
- transform_app_hmi_types[i] = StringToAppHMIType(hmi_types_from_policy[i]);
+ for (uint32_t i = 0; i < hmi_types_from_policy.size(); ++i) {
+ transform_app_hmi_types[i] =
+ StringToAppHMIType(hmi_types_from_policy[i]);
}
ApplicationConstSharedPtr app = *it;
- const smart_objects::SmartObject* save_application_hmi_type = app->app_types();
+ const smart_objects::SmartObject *save_application_hmi_type =
+ app->app_types();
if (save_application_hmi_type == NULL ||
- ((*save_application_hmi_type).length() != transform_app_hmi_types.length())) {
+ ((*save_application_hmi_type).length() !=
+ transform_app_hmi_types.length())) {
flag_diffirence_app_hmi_type = true;
} else {
- flag_diffirence_app_hmi_type = !(CompareAppHMIType(transform_app_hmi_types,
- *save_application_hmi_type));
+ flag_diffirence_app_hmi_type = !(CompareAppHMIType(
+ transform_app_hmi_types, *save_application_hmi_type));
}
if (flag_diffirence_app_hmi_type) {
@@ -3065,12 +3069,11 @@ void ApplicationManagerImpl::OnUpdateHMIAppType(
MessageHelper::SendUIChangeRegistrationRequestToHMI(*it);
} else if (((*it)->hmi_level() == mobile_api::HMILevel::HMI_FULL) ||
- ((*it)->hmi_level() == mobile_api::HMILevel::HMI_LIMITED)) {
+ ((*it)->hmi_level() == mobile_api::HMILevel::HMI_LIMITED)) {
MessageHelper::SendUIChangeRegistrationRequestToHMI(*it);
- ApplicationManagerImpl::instance()->SetState<true>((*it)->app_id(),
- mobile_apis::HMILevel::HMI_BACKGROUND
- );
+ ApplicationManagerImpl::instance()->SetState<true>(
+ (*it)->app_id(), mobile_apis::HMILevel::HMI_BACKGROUND);
}
}
}
@@ -3079,20 +3082,22 @@ void ApplicationManagerImpl::OnUpdateHMIAppType(
ProtocolVersion ApplicationManagerImpl::SupportedSDLVersion() const {
LOG4CXX_AUTO_TRACE(logger_);
- bool heart_beat_support =
- profile::Profile::instance()->heart_beat_timeout();
+ bool heart_beat_support = profile::Profile::instance()->heart_beat_timeout();
bool sdl4_support = profile::Profile::instance()->enable_protocol_4();
if (sdl4_support) {
- LOG4CXX_DEBUG(logger_, "SDL Supported protocol version "<<ProtocolVersion::kV4);
+ LOG4CXX_DEBUG(logger_, "SDL Supported protocol version "
+ << ProtocolVersion::kV4);
return ProtocolVersion::kV4;
}
if (heart_beat_support) {
- LOG4CXX_DEBUG(logger_, "SDL Supported protocol version "<<ProtocolVersion::kV3);
+ LOG4CXX_DEBUG(logger_, "SDL Supported protocol version "
+ << ProtocolVersion::kV3);
return ProtocolVersion::kV3;
}
- LOG4CXX_DEBUG(logger_, "SDL Supported protocol version "<<ProtocolVersion::kV2);
+ LOG4CXX_DEBUG(logger_, "SDL Supported protocol version "
+ << ProtocolVersion::kV2);
return ProtocolVersion::kV2;
}
@@ -3106,37 +3111,36 @@ const std::string ApplicationManagerImpl::DirectoryTypeToString(
}
bool ApplicationManagerImpl::InitDirectory(
- const std::string& path,
- ApplicationManagerImpl::DirectoryType type) const {
+ const std::string &path, ApplicationManagerImpl::DirectoryType type) const {
const std::string directory_type = DirectoryTypeToString(type);
if (!file_system::DirectoryExists(path)) {
LOG4CXX_WARN(logger_, directory_type << " directory doesn't exist.");
// if storage directory doesn't exist try to create it
if (!file_system::CreateDirectoryRecursively(path)) {
LOG4CXX_ERROR(logger_, "Unable to create " << directory_type
- << " directory " << path);
+ << " directory " << path);
return false;
}
- LOG4CXX_DEBUG(logger_, directory_type << " directory has been created: "
- << path);
+ LOG4CXX_DEBUG(logger_, directory_type
+ << " directory has been created: " << path);
}
return true;
}
-bool ApplicationManagerImpl::IsReadWriteAllowed(
- const std::string& path,
- DirectoryType type) const {
+bool ApplicationManagerImpl::IsReadWriteAllowed(const std::string &path,
+ DirectoryType type) const {
const std::string directory_type = DirectoryTypeToString(type);
if (!(file_system::IsWritingAllowed(path) &&
file_system::IsReadingAllowed(path))) {
- LOG4CXX_ERROR(logger_, directory_type
- << " directory doesn't have read/write permissions.");
+ LOG4CXX_ERROR(logger_,
+ directory_type
+ << " directory doesn't have read/write permissions.");
return false;
}
LOG4CXX_DEBUG(logger_, directory_type
- << " directory has read/write permissions.");
+ << " directory has read/write permissions.");
return true;
}
@@ -3147,7 +3151,6 @@ void ApplicationManagerImpl::ClearTTSGlobalPropertiesList() {
tts_global_properties_app_list_.clear();
}
-ApplicationManagerImpl::ApplicationListAccessor::~ApplicationListAccessor() {
-}
+ApplicationManagerImpl::ApplicationListAccessor::~ApplicationListAccessor() {}
-} // namespace application_manager
+} // namespace application_manager
diff --git a/src/components/application_manager/src/commands/mobile/register_app_interface_request.cc b/src/components/application_manager/src/commands/mobile/register_app_interface_request.cc
index a3fe1422cf..6a724bfacf 100644
--- a/src/components/application_manager/src/commands/mobile/register_app_interface_request.cc
+++ b/src/components/application_manager/src/commands/mobile/register_app_interface_request.cc
@@ -46,7 +46,7 @@
namespace {
-mobile_apis::AppHMIType::eType StringToAppHMIType(const std::string& str) {
+mobile_apis::AppHMIType::eType StringToAppHMIType(const std::string &str) {
if ("DEFAULT" == str) {
return mobile_apis::AppHMIType::DEFAULT;
} else if ("COMMUNICATION" == str) {
@@ -73,60 +73,54 @@ mobile_apis::AppHMIType::eType StringToAppHMIType(const std::string& str) {
}
struct AppHMITypeInserter {
- AppHMITypeInserter(smart_objects::SmartObject& so_array)
- : index_(0),
- so_array_(so_array) {
- }
+ AppHMITypeInserter(smart_objects::SmartObject &so_array)
+ : index_(0), so_array_(so_array) {}
- bool operator()(const std::string& app_hmi_type) {
- so_array_[index_] = StringToAppHMIType(app_hmi_type);
- ++index_;
- return true;
- }
+ bool operator()(const std::string &app_hmi_type) {
+ so_array_[index_] = StringToAppHMIType(app_hmi_type);
+ ++index_;
+ return true;
+ }
- private:
- uint32_t index_;
- smart_objects::SmartObject& so_array_;
+private:
+ uint32_t index_;
+ smart_objects::SmartObject &so_array_;
};
struct CheckMissedTypes {
- CheckMissedTypes(const policy::StringArray& policy_app_types,
- std::string& log)
- : policy_app_types_(policy_app_types),
- log_(log) {
- }
-
- bool operator()(const smart_objects::SmartArray::value_type& value) {
- std::string app_type_str = value.asString();
- policy::StringArray::const_iterator it = policy_app_types_.begin();
- policy::StringArray::const_iterator it_end = policy_app_types_.end();
- for (; it != it_end; ++it) {
- if (app_type_str == *it) {
- return true;
- }
+ CheckMissedTypes(const policy::StringArray &policy_app_types,
+ std::string &log)
+ : policy_app_types_(policy_app_types), log_(log) {}
+
+ bool operator()(const smart_objects::SmartArray::value_type &value) {
+ std::string app_type_str = value.asString();
+ policy::StringArray::const_iterator it = policy_app_types_.begin();
+ policy::StringArray::const_iterator it_end = policy_app_types_.end();
+ for (; it != it_end; ++it) {
+ if (app_type_str == *it) {
+ return true;
}
+ }
- log_ += app_type_str;
- log_ += ",";
+ log_ += app_type_str;
+ log_ += ",";
- return true;
- }
+ return true;
+ }
- private:
- const policy::StringArray& policy_app_types_;
- std::string& log_;
+private:
+ const policy::StringArray &policy_app_types_;
+ std::string &log_;
};
struct IsSameNickname {
- IsSameNickname(const std::string& app_id):
- app_id_(app_id) {
- }
+ IsSameNickname(const std::string &app_id) : app_id_(app_id) {}
bool operator()(const policy::StringArray::value_type nickname) const {
return !strcasecmp(app_id_.c_str(), nickname.c_str());
}
private:
- const std::string& app_id_;
+ const std::string &app_id_;
};
}
@@ -135,13 +129,11 @@ namespace application_manager {
namespace commands {
RegisterAppInterfaceRequest::RegisterAppInterfaceRequest(
- const MessageSharedPtr& message)
- : CommandRequestImpl(message),
- result_checking_app_hmi_type_(mobile_apis::Result::INVALID_ENUM) {
-}
+ const MessageSharedPtr &message)
+ : CommandRequestImpl(message),
+ result_checking_app_hmi_type_(mobile_apis::Result::INVALID_ENUM) {}
-RegisterAppInterfaceRequest::~RegisterAppInterfaceRequest() {
-}
+RegisterAppInterfaceRequest::~RegisterAppInterfaceRequest() {}
bool RegisterAppInterfaceRequest::Init() {
LOG4CXX_AUTO_TRACE(logger_);
@@ -149,10 +141,12 @@ bool RegisterAppInterfaceRequest::Init() {
}
void RegisterAppInterfaceRequest::Run() {
- LOG4CXX_INFO(logger_, "RegisterAppInterfaceRequest::Run " << connection_key());
+ LOG4CXX_INFO(logger_, "RegisterAppInterfaceRequest::Run "
+ << connection_key());
// Fix problem with SDL and HMI HTML. This problem is not actual for HMI PASA.
- // Flag conditional compilation specific to customer is used in order to exclude hit code
+ // Flag conditional compilation specific to customer is used in order to
+ // exclude hit code
// to RTC
// FIXME(EZamakhov): on shutdown - get freez
@@ -161,12 +155,12 @@ void RegisterAppInterfaceRequest::Run() {
!ApplicationManagerImpl::instance()->IsStopping() &&
!ApplicationManagerImpl::instance()->IsHMICooperating()) {
LOG4CXX_DEBUG(logger_, "Waiting for the HMI... conn_key="
- << connection_key() << ", correlation_id=" << correlation_id()
- << ", default_timeout=" << default_timeout()
- << ", thread=" << pthread_self());
- ApplicationManagerImpl::instance()->updateRequestTimeout(connection_key(),
- correlation_id(),
- default_timeout());
+ << connection_key()
+ << ", correlation_id=" << correlation_id()
+ << ", default_timeout=" << default_timeout()
+ << ", thread=" << pthread_self());
+ ApplicationManagerImpl::instance()->updateRequestTimeout(
+ connection_key(), correlation_id(), default_timeout());
sleep(1);
// TODO(DK): timer_->StartWait(1);
}
@@ -179,11 +173,11 @@ void RegisterAppInterfaceRequest::Run() {
return;
}
- const std::string mobile_app_id = (*message_)[strings::msg_params][strings::app_id]
- .asString();
+ const std::string mobile_app_id =
+ (*message_)[strings::msg_params][strings::app_id].asString();
ApplicationSharedPtr application =
- ApplicationManagerImpl::instance()->application(connection_key());
+ ApplicationManagerImpl::instance()->application(connection_key());
if (application) {
SendResponse(false, mobile_apis::Result::APPLICATION_REGISTERED_ALREADY);
@@ -196,8 +190,8 @@ void RegisterAppInterfaceRequest::Run() {
}
mobile_apis::Result::eType policy_result = CheckWithPolicyData();
- if (mobile_apis::Result::SUCCESS != policy_result
- && mobile_apis::Result::WARNINGS != policy_result) {
+ if (mobile_apis::Result::SUCCESS != policy_result &&
+ mobile_apis::Result::WARNINGS != policy_result) {
SendResponse(false, policy_result);
return;
}
@@ -208,8 +202,8 @@ void RegisterAppInterfaceRequest::Run() {
LOG4CXX_ERROR_EXT(logger_, "Coincidence check failed.");
if (mobile_apis::Result::DUPLICATE_NAME == coincidence_result) {
usage_statistics::AppCounter count_of_rejections_duplicate_name(
- policy::PolicyHandler::instance()->GetStatisticManager(), mobile_app_id,
- usage_statistics::REJECTIONS_DUPLICATE_NAME);
+ policy::PolicyHandler::instance()->GetStatisticManager(),
+ mobile_app_id, usage_statistics::REJECTIONS_DUPLICATE_NAME);
++count_of_rejections_duplicate_name;
}
SendResponse(false, coincidence_result);
@@ -218,24 +212,24 @@ void RegisterAppInterfaceRequest::Run() {
if (IsWhiteSpaceExist()) {
LOG4CXX_INFO(logger_,
- "Incoming register app interface has contains \t\n \\t \\n");
+ "Incoming register app interface has contains \t\n \\t \\n");
SendResponse(false, mobile_apis::Result::INVALID_DATA);
return;
}
- const smart_objects::SmartObject& msg_params =
- (*message_)[strings::msg_params];
+ const smart_objects::SmartObject &msg_params =
+ (*message_)[strings::msg_params];
ApplicationSharedPtr app =
- ApplicationManagerImpl::instance()->RegisterApplication(message_);
+ ApplicationManagerImpl::instance()->RegisterApplication(message_);
if (!app) {
- LOG4CXX_ERROR_EXT(logger_, "Application " <<
- msg_params[strings::app_name].asString() <<
- " hasn't been registered!");
+ LOG4CXX_ERROR_EXT(logger_, "Application "
+ << msg_params[strings::app_name].asString()
+ << " hasn't been registered!");
} else {
app->set_is_media_application(
- msg_params[strings::is_media_application].asBool());
+ msg_params[strings::is_media_application].asBool());
if (msg_params.keyExists(strings::vr_synonyms)) {
app->set_vr_synonyms(msg_params[strings::vr_synonyms]);
@@ -243,7 +237,7 @@ void RegisterAppInterfaceRequest::Run() {
if (msg_params.keyExists(strings::ngn_media_screen_app_name)) {
app->set_ngn_media_screen_name(
- msg_params[strings::ngn_media_screen_app_name]);
+ msg_params[strings::ngn_media_screen_app_name]);
}
if (msg_params.keyExists(strings::tts_name)) {
@@ -254,8 +248,8 @@ void RegisterAppInterfaceRequest::Run() {
app->set_app_types(msg_params[strings::app_hmi_type]);
// check app type
- const smart_objects::SmartObject& app_type =
- msg_params.getElement(strings::app_hmi_type);
+ const smart_objects::SmartObject &app_type =
+ msg_params.getElement(strings::app_hmi_type);
for (size_t i = 0; i < app_type.length(); ++i) {
if (mobile_apis::AppHMIType::NAVIGATION ==
@@ -265,7 +259,7 @@ void RegisterAppInterfaceRequest::Run() {
}
if (mobile_apis::AppHMIType::COMMUNICATION ==
static_cast<mobile_apis::AppHMIType::eType>(
- app_type.getElement(i).asUInt())) {
+ app_type.getElement(i).asUInt())) {
app->set_voice_communication_supported(true);
}
}
@@ -274,7 +268,8 @@ void RegisterAppInterfaceRequest::Run() {
const connection_handler::DeviceHandle handle = app->device();
// Add device to policy table and set device info, if any
std::string device_mac_address =
- application_manager::MessageHelper::GetDeviceMacAddressForHandle(handle);
+ application_manager::MessageHelper::GetDeviceMacAddressForHandle(
+ handle);
policy::DeviceParams dev_params;
application_manager::MessageHelper::GetDeviceInfoForHandle(handle,
&dev_params);
@@ -285,7 +280,7 @@ void RegisterAppInterfaceRequest::Run() {
}
policy::PolicyHandler::instance()->SetDeviceInfo(device_mac_address,
- device_info);
+ device_info);
SendRegisterAppInterfaceResponseToMobile();
@@ -295,164 +290,160 @@ void RegisterAppInterfaceRequest::Run() {
}
void RegisterAppInterfaceRequest::SendRegisterAppInterfaceResponseToMobile(
- mobile_apis::Result::eType result) {
+ mobile_apis::Result::eType result) {
smart_objects::SmartObject response_params(smart_objects::SmartType_Map);
- ApplicationManagerImpl* app_manager = ApplicationManagerImpl::instance();
- const HMICapabilities& hmi_capabilities = app_manager->hmi_capabilities();
+ ApplicationManagerImpl *app_manager = ApplicationManagerImpl::instance();
+ const HMICapabilities &hmi_capabilities = app_manager->hmi_capabilities();
const uint32_t key = connection_key();
ApplicationSharedPtr application =
- ApplicationManagerImpl::instance()->application(key);
+ ApplicationManagerImpl::instance()->application(key);
if (!application) {
- LOG4CXX_ERROR(logger_, "There is no application for such connection key" <<
- key);
+ LOG4CXX_ERROR(logger_, "There is no application for such connection key"
+ << key);
return;
}
response_params[strings::sync_msg_version][strings::major_version] =
- APIVersion::kAPIV3;
+ APIVersion::kAPIV3;
response_params[strings::sync_msg_version][strings::minor_version] =
- APIVersion::kAPIV0;
+ APIVersion::kAPIV0;
response_params[strings::language] = hmi_capabilities.active_vr_language();
response_params[strings::hmi_display_language] =
- hmi_capabilities.active_ui_language();
+ hmi_capabilities.active_ui_language();
- const smart_objects::SmartObject& msg_params =
- (*message_)[strings::msg_params];
+ const smart_objects::SmartObject &msg_params =
+ (*message_)[strings::msg_params];
if (msg_params[strings::language_desired].asInt() !=
- hmi_capabilities.active_vr_language() ||
+ hmi_capabilities.active_vr_language() ||
msg_params[strings::hmi_display_language_desired].asInt() !=
- hmi_capabilities.active_ui_language()) {
+ hmi_capabilities.active_ui_language()) {
- LOG4CXX_WARN_EXT(
- logger_,
- "Wrong language on registering application " << application->name());
+ LOG4CXX_WARN_EXT(logger_, "Wrong language on registering application "
+ << application->name());
LOG4CXX_ERROR_EXT(
- logger_,
- "vr "
- << msg_params[strings::language_desired].asInt()
- << " - "
- << hmi_capabilities.active_vr_language()
- << "ui "
- << msg_params[strings::hmi_display_language_desired].asInt()
- << " - "
- << hmi_capabilities.active_ui_language());
+ logger_,
+ "vr " << msg_params[strings::language_desired].asInt() << " - "
+ << hmi_capabilities.active_vr_language() << "ui "
+ << msg_params[strings::hmi_display_language_desired].asInt()
+ << " - " << hmi_capabilities.active_ui_language());
result = mobile_apis::Result::WRONG_LANGUAGE;
}
if (hmi_capabilities.display_capabilities()) {
response_params[hmi_response::display_capabilities] =
- smart_objects::SmartObject(smart_objects::SmartType_Map);
+ smart_objects::SmartObject(smart_objects::SmartType_Map);
- smart_objects::SmartObject& display_caps =
- response_params[hmi_response::display_capabilities];
+ smart_objects::SmartObject &display_caps =
+ response_params[hmi_response::display_capabilities];
display_caps[hmi_response::display_type] =
- hmi_capabilities.display_capabilities()->getElement(
- hmi_response::display_type);
+ hmi_capabilities.display_capabilities()->getElement(
+ hmi_response::display_type);
display_caps[hmi_response::text_fields] =
- hmi_capabilities.display_capabilities()->getElement(
- hmi_response::text_fields);
+ hmi_capabilities.display_capabilities()->getElement(
+ hmi_response::text_fields);
display_caps[hmi_response::image_fields] =
- hmi_capabilities.display_capabilities()->getElement(
- hmi_response::image_fields);
+ hmi_capabilities.display_capabilities()->getElement(
+ hmi_response::image_fields);
display_caps[hmi_response::media_clock_formats] =
- hmi_capabilities.display_capabilities()->getElement(
- hmi_response::media_clock_formats);
+ hmi_capabilities.display_capabilities()->getElement(
+ hmi_response::media_clock_formats);
display_caps[hmi_response::templates_available] =
- hmi_capabilities.display_capabilities()->getElement(
- hmi_response::templates_available);
+ hmi_capabilities.display_capabilities()->getElement(
+ hmi_response::templates_available);
display_caps[hmi_response::screen_params] =
- hmi_capabilities.display_capabilities()->getElement(
- hmi_response::screen_params);
+ hmi_capabilities.display_capabilities()->getElement(
+ hmi_response::screen_params);
display_caps[hmi_response::num_custom_presets_available] =
- hmi_capabilities.display_capabilities()->getElement(
- hmi_response::num_custom_presets_available);
+ hmi_capabilities.display_capabilities()->getElement(
+ hmi_response::num_custom_presets_available);
- if (hmi_capabilities.display_capabilities()->getElement(
- hmi_response::image_capabilities).length() > 0) {
+ if (hmi_capabilities.display_capabilities()
+ ->getElement(hmi_response::image_capabilities)
+ .length() > 0) {
display_caps[hmi_response::graphic_supported] = true;
} else {
display_caps[hmi_response::graphic_supported] = false;
}
display_caps[hmi_response::templates_available] =
- hmi_capabilities.display_capabilities()->getElement(
- hmi_response::templates_available);
+ hmi_capabilities.display_capabilities()->getElement(
+ hmi_response::templates_available);
display_caps[hmi_response::screen_params] =
- hmi_capabilities.display_capabilities()->getElement(
- hmi_response::screen_params);
+ hmi_capabilities.display_capabilities()->getElement(
+ hmi_response::screen_params);
display_caps[hmi_response::num_custom_presets_available] =
- hmi_capabilities.display_capabilities()->getElement(
- hmi_response::num_custom_presets_available);
+ hmi_capabilities.display_capabilities()->getElement(
+ hmi_response::num_custom_presets_available);
}
if (hmi_capabilities.button_capabilities()) {
response_params[hmi_response::button_capabilities] =
- *hmi_capabilities.button_capabilities();
+ *hmi_capabilities.button_capabilities();
}
if (hmi_capabilities.soft_button_capabilities()) {
response_params[hmi_response::soft_button_capabilities] =
- *hmi_capabilities.soft_button_capabilities();
+ *hmi_capabilities.soft_button_capabilities();
}
if (hmi_capabilities.preset_bank_capabilities()) {
response_params[hmi_response::preset_bank_capabilities] =
- *hmi_capabilities.preset_bank_capabilities();
+ *hmi_capabilities.preset_bank_capabilities();
}
if (hmi_capabilities.hmi_zone_capabilities()) {
if (smart_objects::SmartType_Array ==
hmi_capabilities.hmi_zone_capabilities()->getType()) {
// hmi_capabilities json contains array and HMI response object
response_params[hmi_response::hmi_zone_capabilities] =
- *hmi_capabilities.hmi_zone_capabilities();
+ *hmi_capabilities.hmi_zone_capabilities();
} else {
response_params[hmi_response::hmi_zone_capabilities][0] =
- *hmi_capabilities.hmi_zone_capabilities();
+ *hmi_capabilities.hmi_zone_capabilities();
}
}
if (hmi_capabilities.speech_capabilities()) {
response_params[strings::speech_capabilities] =
- *hmi_capabilities.speech_capabilities();
+ *hmi_capabilities.speech_capabilities();
}
if (hmi_capabilities.vr_capabilities()) {
response_params[strings::vr_capabilities] =
- *hmi_capabilities.vr_capabilities();
+ *hmi_capabilities.vr_capabilities();
}
if (hmi_capabilities.audio_pass_thru_capabilities()) {
if (smart_objects::SmartType_Array ==
hmi_capabilities.audio_pass_thru_capabilities()->getType()) {
// hmi_capabilities json contains array and HMI response object
response_params[strings::audio_pass_thru_capabilities] =
- *hmi_capabilities.audio_pass_thru_capabilities();
+ *hmi_capabilities.audio_pass_thru_capabilities();
} else {
response_params[strings::audio_pass_thru_capabilities][0] =
- *hmi_capabilities.audio_pass_thru_capabilities();
+ *hmi_capabilities.audio_pass_thru_capabilities();
}
}
if (hmi_capabilities.vehicle_type()) {
response_params[hmi_response::vehicle_type] =
- *hmi_capabilities.vehicle_type();
+ *hmi_capabilities.vehicle_type();
}
if (hmi_capabilities.prerecorded_speech()) {
response_params[strings::prerecorded_speech] =
- *(hmi_capabilities.prerecorded_speech());
+ *(hmi_capabilities.prerecorded_speech());
}
- const std::vector<uint32_t>& diag_modes =
- profile::Profile::instance()->supported_diag_modes();
+ const std::vector<uint32_t> &diag_modes =
+ profile::Profile::instance()->supported_diag_modes();
if (!diag_modes.empty()) {
std::vector<uint32_t>::const_iterator it = diag_modes.begin();
uint32_t index = 0;
@@ -473,11 +464,12 @@ void RegisterAppInterfaceRequest::SendRegisterAppInterfaceResponseToMobile(
response_params[strings::system_software_version] =
hmi_capabilities.ccpu_version();
- ResumeCtrl& resumer = ApplicationManagerImpl::instance()->resume_controller();
+ ResumeCtrl &resumer = ApplicationManagerImpl::instance()->resume_controller();
std::string hash_id = "";
std::string add_info("");
- bool resumption = (*message_)[strings::msg_params].keyExists(strings::hash_id);
+ bool resumption =
+ (*message_)[strings::msg_params].keyExists(strings::hash_id);
bool need_restore_vr = resumption;
if (resumption) {
hash_id = (*message_)[strings::msg_params][strings::hash_id].asString();
@@ -506,26 +498,15 @@ void RegisterAppInterfaceRequest::SendRegisterAppInterfaceResponseToMobile(
resumption = resumer.IsApplicationSaved(application->mobile_app_id());
}
-
- MessageHelper::SendOnAppRegisteredNotificationToHMI(*(application.get()),
- resumption,
- need_restore_vr);
+ MessageHelper::SendOnAppRegisteredNotificationToHMI(
+ *(application.get()), resumption, need_restore_vr);
SendResponse(true, result, add_info.c_str(), &response_params);
- // when application's hmilevel is not defined, we should set
- // default and try to perform resumption
- // fix for APPLINK-12311
- if (mobile_apis::HMILevel::INVALID_ENUM == application->CurrentHmiState()->hmi_level()) {
- // Default HMI level should be set before any permissions validation, since it
- // relies on HMI level.
- resumer.SetupDefaultHMILevel(application);
-
- if (result != mobile_apis::Result::RESUME_FAILED) {
- resumer.StartResumption(application, hash_id);
- } else {
- resumer.StartResumptionOnlyHMILevel(application);
- }
+ if (result != mobile_apis::Result::RESUME_FAILED) {
+ resumer.StartResumption(application, hash_id);
+ } else {
+ resumer.StartResumptionOnlyHMILevel(application);
}
// By default app subscribed to CUSTOM_BUTTON
@@ -534,29 +515,27 @@ void RegisterAppInterfaceRequest::SendRegisterAppInterfaceResponseToMobile(
MessageHelper::SendChangeRegistrationRequestToHMI(application);
}
-mobile_apis::Result::eType
-RegisterAppInterfaceRequest::CheckCoincidence() {
+mobile_apis::Result::eType RegisterAppInterfaceRequest::CheckCoincidence() {
LOG4CXX_AUTO_TRACE(logger_);
- const smart_objects::SmartObject& msg_params =
- (*message_)[strings::msg_params];
+ const smart_objects::SmartObject &msg_params =
+ (*message_)[strings::msg_params];
ApplicationManagerImpl::ApplicationListAccessor accessor;
- ApplicationManagerImpl::ApplictionSetConstIt it =
- accessor.begin();
+ ApplicationManagerImpl::ApplictionSetConstIt it = accessor.begin();
const std::string app_name = msg_params[strings::app_name].asString();
for (; accessor.end() != it; ++it) {
// name check
- const std::string& cur_name = (*it)->name();
+ const std::string &cur_name = (*it)->name();
if (!strcasecmp(app_name.c_str(), cur_name.c_str())) {
LOG4CXX_ERROR(logger_, "Application name is known already.");
return mobile_apis::Result::DUPLICATE_NAME;
}
- const smart_objects::SmartObject* vr = (*it)->vr_synonyms();
- const std::vector<smart_objects::SmartObject>* curr_vr = NULL;
+ const smart_objects::SmartObject *vr = (*it)->vr_synonyms();
+ const std::vector<smart_objects::SmartObject> *curr_vr = NULL;
if (NULL != vr) {
curr_vr = vr->asArray();
CoincidencePredicateVR v(app_name);
@@ -569,7 +548,7 @@ RegisterAppInterfaceRequest::CheckCoincidence() {
// vr check
if (msg_params.keyExists(strings::vr_synonyms)) {
- const std::vector<smart_objects::SmartObject>* new_vr =
+ const std::vector<smart_objects::SmartObject> *new_vr =
msg_params[strings::vr_synonyms].asArray();
CoincidencePredicateVR v(cur_name);
@@ -577,12 +556,12 @@ RegisterAppInterfaceRequest::CheckCoincidence() {
LOG4CXX_ERROR(logger_, "vr_synonyms duplicated with app_name .");
return mobile_apis::Result::DUPLICATE_NAME;
}
- } // end vr check
+ } // end vr check
- } // application for end
+ } // application for end
return mobile_apis::Result::SUCCESS;
-} // method end
+} // method end
mobile_apis::Result::eType RegisterAppInterfaceRequest::CheckWithPolicyData() {
LOG4CXX_INFO(logger_, "CheckWithPolicyData");
@@ -593,13 +572,14 @@ mobile_apis::Result::eType RegisterAppInterfaceRequest::CheckWithPolicyData() {
return mobile_apis::Result::WARNINGS;
}
- smart_objects::SmartObject& message = *message_;
+ smart_objects::SmartObject &message = *message_;
policy::StringArray app_nicknames;
policy::StringArray app_hmi_types;
- std::string mobile_app_id = message[strings::msg_params][strings::app_id].asString();
+ std::string mobile_app_id =
+ message[strings::msg_params][strings::app_id].asString();
const bool init_result = policy::PolicyHandler::instance()->GetInitialAppData(
- mobile_app_id, &app_nicknames, &app_hmi_types);
+ mobile_app_id, &app_nicknames, &app_hmi_types);
if (!init_result) {
LOG4CXX_ERROR(logger_, "Error during initial application data check.");
@@ -608,16 +588,17 @@ mobile_apis::Result::eType RegisterAppInterfaceRequest::CheckWithPolicyData() {
if (!app_nicknames.empty()) {
IsSameNickname compare(
- message[strings::msg_params][strings::app_name].asString());
- policy::StringArray::const_iterator it = std::find_if(
- app_nicknames.begin(), app_nicknames.end(), compare);
+ message[strings::msg_params][strings::app_name].asString());
+ policy::StringArray::const_iterator it =
+ std::find_if(app_nicknames.begin(), app_nicknames.end(), compare);
if (app_nicknames.end() == it) {
LOG4CXX_WARN(logger_,
"Application name was not found in nicknames list.");
- //App should be unregistered, if its name is not present in nicknames list
+ // App should be unregistered, if its name is not present in nicknames
+ // list
usage_statistics::AppCounter count_of_rejections_nickname_mismatch(
- policy::PolicyHandler::instance()->GetStatisticManager(), mobile_app_id,
- usage_statistics::REJECTIONS_NICKNAME_MISMATCH);
+ policy::PolicyHandler::instance()->GetStatisticManager(),
+ mobile_app_id, usage_statistics::REJECTIONS_NICKNAME_MISMATCH);
++count_of_rejections_nickname_mismatch;
return mobile_apis::Result::DISALLOWED;
}
@@ -631,23 +612,24 @@ mobile_apis::Result::eType RegisterAppInterfaceRequest::CheckWithPolicyData() {
// If AppHMITypes are partially same, the system should allow those listed
// in the policy table and send warning info on missed values
smart_objects::SmartArray app_types =
- *(message[strings::msg_params][strings::app_hmi_type].asArray());
+ *(message[strings::msg_params][strings::app_hmi_type].asArray());
std::string log;
CheckMissedTypes checker(app_hmi_types, log);
std::for_each(app_types.begin(), app_types.end(), checker);
if (!log.empty()) {
response_info_ = "Following AppHMITypes are not present in policy "
- "table:" + log;
+ "table:" +
+ log;
result_checking_app_hmi_type_ = mobile_apis::Result::WARNINGS;
}
}
// Replace AppHMITypes in request with values allowed by policy table
message[strings::msg_params][strings::app_hmi_type] =
- smart_objects::SmartObject(smart_objects::SmartType_Array);
+ smart_objects::SmartObject(smart_objects::SmartType_Array);
- smart_objects::SmartObject& app_hmi_type =
- message[strings::msg_params][strings::app_hmi_type];
+ smart_objects::SmartObject &app_hmi_type =
+ message[strings::msg_params][strings::app_hmi_type];
AppHMITypeInserter inserter(app_hmi_type);
std::for_each(app_hmi_types.begin(), app_hmi_types.end(), inserter);
@@ -657,7 +639,7 @@ mobile_apis::Result::eType RegisterAppInterfaceRequest::CheckWithPolicyData() {
}
void RegisterAppInterfaceRequest::FillDeviceInfo(
- policy::DeviceInfo* device_info) {
+ policy::DeviceInfo *device_info) {
const std::string hardware = "hardware";
const std::string firmware_rev = "firmwareRev";
const std::string os = "os";
@@ -665,17 +647,19 @@ void RegisterAppInterfaceRequest::FillDeviceInfo(
const std::string carrier = "carrier";
const std::string max_number_rfcom_ports = "maxNumberRFCOMMPorts";
- const smart_objects::SmartObject& msg_params =
- (*message_)[strings::msg_params];
+ const smart_objects::SmartObject &msg_params =
+ (*message_)[strings::msg_params];
- const smart_objects::SmartObject& device_info_so =
- msg_params[strings::device_info];
+ const smart_objects::SmartObject &device_info_so =
+ msg_params[strings::device_info];
if (device_info_so.keyExists(hardware)) {
- device_info->hardware = msg_params[strings::device_info][hardware].asString();
+ device_info->hardware =
+ msg_params[strings::device_info][hardware].asString();
}
if (device_info_so.keyExists(firmware_rev)) {
- device_info->firmware_rev = msg_params[strings::device_info][firmware_rev].asString();
+ device_info->firmware_rev =
+ msg_params[strings::device_info][firmware_rev].asString();
}
if (device_info_so.keyExists(os)) {
device_info->os = device_info_so[os].asString();
@@ -688,26 +672,27 @@ void RegisterAppInterfaceRequest::FillDeviceInfo(
}
if (device_info_so.keyExists(max_number_rfcom_ports)) {
device_info->max_number_rfcom_ports =
- device_info_so[max_number_rfcom_ports].asInt();
+ device_info_so[max_number_rfcom_ports].asInt();
}
}
bool RegisterAppInterfaceRequest::IsApplicationWithSameAppIdRegistered() {
LOG4CXX_INFO(logger_, "RegisterAppInterfaceRequest::"
- "IsApplicationWithSameAppIdRegistered");
+ "IsApplicationWithSameAppIdRegistered");
- const std::string mobile_app_id = (*message_)[strings::msg_params]
- [strings::app_id].asString();
+ const std::string mobile_app_id =
+ (*message_)[strings::msg_params][strings::app_id].asString();
ApplicationManagerImpl::ApplicationListAccessor accessor;
- const ApplicationManagerImpl::ApplictionSet applications = accessor.applications();
+ const ApplicationManagerImpl::ApplictionSet applications =
+ accessor.applications();
- ApplicationManagerImpl::ApplictionSetConstIt it = applications.begin();
- ApplicationManagerImpl::ApplictionSetConstIt it_end = applications.end();
+ ApplicationManagerImpl::ApplictionSetConstIt it = applications.begin();
+ ApplicationManagerImpl::ApplictionSetConstIt it_end = applications.end();
for (; it != it_end; ++it) {
- if (!strcasecmp(mobile_app_id.c_str(),(*it)->mobile_app_id().c_str())) {
+ if (!strcasecmp(mobile_app_id.c_str(), (*it)->mobile_app_id().c_str())) {
return true;
}
}
@@ -717,7 +702,7 @@ bool RegisterAppInterfaceRequest::IsApplicationWithSameAppIdRegistered() {
bool RegisterAppInterfaceRequest::IsWhiteSpaceExist() {
LOG4CXX_AUTO_TRACE(logger_);
- const char* str = NULL;
+ const char *str = NULL;
str = (*message_)[strings::msg_params][strings::app_name].asCharArray();
if (!CheckSyntax(str)) {
@@ -725,9 +710,8 @@ bool RegisterAppInterfaceRequest::IsWhiteSpaceExist() {
return true;
}
-
if ((*message_)[strings::msg_params].keyExists(strings::tts_name)) {
- const smart_objects::SmartArray* tn_array =
+ const smart_objects::SmartArray *tn_array =
(*message_)[strings::msg_params][strings::tts_name].asArray();
smart_objects::SmartArray::const_iterator it_tn = tn_array->begin();
@@ -742,10 +726,10 @@ bool RegisterAppInterfaceRequest::IsWhiteSpaceExist() {
}
}
- if ((*message_)[strings::msg_params].
- keyExists(strings::ngn_media_screen_app_name)) {
- str = (*message_)[strings::msg_params]
- [strings::ngn_media_screen_app_name].asCharArray();
+ if ((*message_)[strings::msg_params].keyExists(
+ strings::ngn_media_screen_app_name)) {
+ str = (*message_)[strings::msg_params][strings::ngn_media_screen_app_name]
+ .asCharArray();
if (strlen(str) && !CheckSyntax(str)) {
LOG4CXX_ERROR(logger_,
"Invalid ngn_media_screen_app_name syntax check failed");
@@ -754,7 +738,7 @@ bool RegisterAppInterfaceRequest::IsWhiteSpaceExist() {
}
if ((*message_)[strings::msg_params].keyExists(strings::vr_synonyms)) {
- const smart_objects::SmartArray* vs_array =
+ const smart_objects::SmartArray *vs_array =
(*message_)[strings::msg_params][strings::vr_synonyms].asArray();
smart_objects::SmartArray::const_iterator it_vs = vs_array->begin();
@@ -779,10 +763,10 @@ bool RegisterAppInterfaceRequest::IsWhiteSpaceExist() {
if ((*message_)[strings::msg_params].keyExists(strings::device_info)) {
- if ((*message_)[strings::msg_params][strings::device_info].
- keyExists(strings::hardware)) {
- str = (*message_)[strings::msg_params]
- [strings::device_info][strings::hardware].asCharArray();
+ if ((*message_)[strings::msg_params][strings::device_info].keyExists(
+ strings::hardware)) {
+ str = (*message_)[strings::msg_params][strings::device_info]
+ [strings::hardware].asCharArray();
if (strlen(str) && !CheckSyntax(str)) {
LOG4CXX_ERROR(logger_,
"Invalid device_info hardware syntax check failed");
@@ -790,10 +774,10 @@ bool RegisterAppInterfaceRequest::IsWhiteSpaceExist() {
}
}
- if ((*message_)[strings::msg_params][strings::device_info].
- keyExists(strings::firmware_rev)) {
- str = (*message_)[strings::msg_params]
- [strings::device_info][strings::firmware_rev].asCharArray();
+ if ((*message_)[strings::msg_params][strings::device_info].keyExists(
+ strings::firmware_rev)) {
+ str = (*message_)[strings::msg_params][strings::device_info]
+ [strings::firmware_rev].asCharArray();
if (strlen(str) && !CheckSyntax(str)) {
LOG4CXX_ERROR(logger_,
"Invalid device_info firmware_rev syntax check failed");
@@ -801,21 +785,20 @@ bool RegisterAppInterfaceRequest::IsWhiteSpaceExist() {
}
}
- if ((*message_)[strings::msg_params][strings::device_info].
- keyExists(strings::os)) {
- str = (*message_)[strings::msg_params]
- [strings::device_info][strings::os].asCharArray();
+ if ((*message_)[strings::msg_params][strings::device_info].keyExists(
+ strings::os)) {
+ str = (*message_)[strings::msg_params][strings::device_info][strings::os]
+ .asCharArray();
if (strlen(str) && !CheckSyntax(str)) {
- LOG4CXX_ERROR(logger_,
- "Invalid device_info os syntax check failed");
+ LOG4CXX_ERROR(logger_, "Invalid device_info os syntax check failed");
return true;
}
}
- if ((*message_)[strings::msg_params][strings::device_info].
- keyExists(strings::os_version)) {
- str = (*message_)[strings::msg_params]
- [strings::device_info][strings::os_version].asCharArray();
+ if ((*message_)[strings::msg_params][strings::device_info].keyExists(
+ strings::os_version)) {
+ str = (*message_)[strings::msg_params][strings::device_info]
+ [strings::os_version].asCharArray();
if (strlen(str) && !CheckSyntax(str)) {
LOG4CXX_ERROR(logger_,
"Invalid device_info os_version syntax check failed");
@@ -823,17 +806,16 @@ bool RegisterAppInterfaceRequest::IsWhiteSpaceExist() {
}
}
- if ((*message_)[strings::msg_params][strings::device_info].
- keyExists(strings::carrier)) {
- str = (*message_)[strings::msg_params]
- [strings::device_info][strings::carrier].asCharArray();
+ if ((*message_)[strings::msg_params][strings::device_info].keyExists(
+ strings::carrier)) {
+ str = (*message_)[strings::msg_params][strings::device_info]
+ [strings::carrier].asCharArray();
if (strlen(str) && !CheckSyntax(str)) {
LOG4CXX_ERROR(logger_,
"Invalid device_info carrier syntax check failed");
return true;
}
}
-
}
if ((*message_)[strings::msg_params].keyExists(strings::app_id)) {
@@ -847,15 +829,14 @@ bool RegisterAppInterfaceRequest::IsWhiteSpaceExist() {
}
void RegisterAppInterfaceRequest::CheckResponseVehicleTypeParam(
- smart_objects::SmartObject& vehicle_type,
- const std::string& param,
- const std::string& backup_value) {
+ smart_objects::SmartObject &vehicle_type, const std::string &param,
+ const std::string &backup_value) {
using namespace hmi_response;
- if (!vehicle_type.keyExists(param) ||
- vehicle_type[param].empty()) {
+ if (!vehicle_type.keyExists(param) || vehicle_type[param].empty()) {
if (!backup_value.empty()) {
- LOG4CXX_DEBUG(logger_, param << " is missing."
- "Will be replaced with policy table value.");
+ LOG4CXX_DEBUG(logger_,
+ param << " is missing."
+ "Will be replaced with policy table value.");
vehicle_type[param] = backup_value;
} else {
vehicle_type.erase(param);
@@ -871,10 +852,9 @@ void RegisterAppInterfaceRequest::SendSubscribeCustomButtonNotification() {
msg_params[strings::app_id] = connection_key();
msg_params[strings::name] = Common_ButtonName::CUSTOM_BUTTON;
msg_params[strings::is_suscribed] = true;
- CreateHMINotification(FunctionID::Buttons_OnButtonSubscription,
- msg_params);
+ CreateHMINotification(FunctionID::Buttons_OnButtonSubscription, msg_params);
}
-} // namespace commands
+} // namespace commands
-} // namespace application_manager
+} // namespace application_manager
diff --git a/src/components/application_manager/src/commands/mobile/register_app_interface_response.cc b/src/components/application_manager/src/commands/mobile/register_app_interface_response.cc
index b318795859..b910881273 100644
--- a/src/components/application_manager/src/commands/mobile/register_app_interface_response.cc
+++ b/src/components/application_manager/src/commands/mobile/register_app_interface_response.cc
@@ -47,11 +47,13 @@ void RegisterAppInterfaceResponse::Run() {
mobile_apis::Result::eType result_code = mobile_apis::Result::INVALID_ENUM;
bool success = (*message_)[strings::msg_params][strings::success].asBool();
bool last_message = !success;
- // Do not close connection in case of APPLICATION_NOT_REGISTERED despite it is an error
- if (!success && (*message_)[strings::msg_params].keyExists(strings::result_code)) {
+ // Do not close connection in case of APPLICATION_NOT_REGISTERED despite it is
+ // an error
+ if (!success &&
+ (*message_)[strings::msg_params].keyExists(strings::result_code)) {
result_code = static_cast<mobile_apis::Result::eType>(
(*message_)[strings::msg_params][strings::result_code].asInt());
- if (result_code == mobile_apis::Result::APPLICATION_REGISTERED_ALREADY) {
+ if (result_code == mobile_apis::Result::APPLICATION_REGISTERED_ALREADY) {
last_message = false;
}
}
@@ -60,32 +62,44 @@ void RegisterAppInterfaceResponse::Run() {
// Add registered application to the policy db right after response sent to
// mobile to be able to check all other API according to app permissions
- application_manager::ApplicationConstSharedPtr app =
- application_manager::ApplicationManagerImpl::instance()->
- application(connection_key());
- if (app.valid()) {
- policy::PolicyHandler *policy_handler = policy::PolicyHandler::instance();
- std::string mobile_app_id = app->mobile_app_id();
- policy_handler->AddApplication(mobile_app_id);
- SetHeartBeatTimeout(connection_key(), mobile_app_id);
+ application_manager::ApplicationSharedPtr application =
+ application_manager::ApplicationManagerImpl::instance()->application(
+ connection_key());
+
+ if (!application) {
+ LOG4CXX_ERROR(logger_, "Application with connection key "
+ << connection_key() << " is not registered.");
+ return;
}
+
+ SetHeartBeatTimeout(connection_key(), application->mobile_app_id());
+
+ // Default HMI level should be set before any permissions validation, since it
+ // relies on HMI level.
+ ApplicationManagerImpl::instance()->OnApplicationRegistered(application);
+
+ // Sends OnPermissionChange notification to mobile right after RAI response
+ // and HMI level set-up
+ policy::PolicyHandler::instance()->OnAppRegisteredOnMobile(
+ application->mobile_app_id());
}
void RegisterAppInterfaceResponse::SetHeartBeatTimeout(
- uint32_t connection_key, const std::string& mobile_app_id) {
+ uint32_t connection_key, const std::string &mobile_app_id) {
LOG4CXX_AUTO_TRACE(logger_);
policy::PolicyHandler *policy_handler = policy::PolicyHandler::instance();
if (policy_handler->PolicyEnabled()) {
const int32_t timeout = policy_handler->HeartBeatTimeout(mobile_app_id) /
- date_time::DateTime::MILLISECONDS_IN_SECOND;
+ date_time::DateTime::MILLISECONDS_IN_SECOND;
if (timeout > 0) {
- application_manager::ApplicationManagerImpl::instance()->
- connection_handler()->SetHeartBeatTimeout(connection_key, timeout);
+ application_manager::ApplicationManagerImpl::instance()
+ ->connection_handler()
+ ->SetHeartBeatTimeout(connection_key, timeout);
}
} else {
LOG4CXX_INFO(logger_, "Policy is turn off");
}
}
-} // namespace commands
-} // namespace application_manager
+} // namespace commands
+} // namespace application_manager
diff --git a/src/components/application_manager/src/policies/policy_handler.cc b/src/components/application_manager/src/policies/policy_handler.cc
index 148c8bfbb0..8732a122c5 100644
--- a/src/components/application_manager/src/policies/policy_handler.cc
+++ b/src/components/application_manager/src/policies/policy_handler.cc
@@ -1,5 +1,5 @@
/*
- Copyright (c) 2014, Ford Motor Company
+ Copyright (c) 2016, Ford Motor Company
All rights reserved.
Redistribution and use in source and binary forms, with or without
@@ -62,28 +62,27 @@ namespace {
using namespace mobile_apis;
typedef std::map<RequestType::eType, std::string> RequestTypeMap;
RequestTypeMap TypeToString = {
- {RequestType::INVALID_ENUM, "INVALID_ENUM"},
- {RequestType::HTTP, "HTTP"},
- {RequestType::FILE_RESUME, "FILE_RESUME"},
- {RequestType::AUTH_REQUEST, "AUTH_REQUEST"},
- {RequestType::AUTH_CHALLENGE, "AUTH_CHALLENGE"},
- {RequestType::AUTH_ACK, "AUTH_ACK"},
- {RequestType::PROPRIETARY, "PROPRIETARY"},
- {RequestType::QUERY_APPS, "QUERY_APPS"},
- {RequestType::LAUNCH_APP, "LAUNCH_APP"},
- {RequestType::LOCK_SCREEN_ICON_URL, "LOCK_SCREEN_ICON_URL"},
- {RequestType::TRAFFIC_MESSAGE_CHANNEL, "TRAFFIC_MESSAGE_CHANNEL"},
- {RequestType::DRIVER_PROFILE, "DRIVER_PROFILE"},
- {RequestType::VOICE_SEARCH, "VOICE_SEARCH"},
- {RequestType::NAVIGATION, "NAVIGATION"},
- {RequestType::PHONE,"PHONE"},
- {RequestType::CLIMATE, "CLIMATE"},
- {RequestType::SETTINGS, "SETTINGS"},
- {RequestType::VEHICLE_DIAGNOSTICS, "VEHICLE_DIAGNOSTICS"},
- {RequestType::EMERGENCY, "EMERGENCY"},
- {RequestType::MEDIA, "MEDIA"},
- {RequestType::FOTA, "FOTA"}
-};
+ {RequestType::INVALID_ENUM, "INVALID_ENUM"},
+ {RequestType::HTTP, "HTTP"},
+ {RequestType::FILE_RESUME, "FILE_RESUME"},
+ {RequestType::AUTH_REQUEST, "AUTH_REQUEST"},
+ {RequestType::AUTH_CHALLENGE, "AUTH_CHALLENGE"},
+ {RequestType::AUTH_ACK, "AUTH_ACK"},
+ {RequestType::PROPRIETARY, "PROPRIETARY"},
+ {RequestType::QUERY_APPS, "QUERY_APPS"},
+ {RequestType::LAUNCH_APP, "LAUNCH_APP"},
+ {RequestType::LOCK_SCREEN_ICON_URL, "LOCK_SCREEN_ICON_URL"},
+ {RequestType::TRAFFIC_MESSAGE_CHANNEL, "TRAFFIC_MESSAGE_CHANNEL"},
+ {RequestType::DRIVER_PROFILE, "DRIVER_PROFILE"},
+ {RequestType::VOICE_SEARCH, "VOICE_SEARCH"},
+ {RequestType::NAVIGATION, "NAVIGATION"},
+ {RequestType::PHONE, "PHONE"},
+ {RequestType::CLIMATE, "CLIMATE"},
+ {RequestType::SETTINGS, "SETTINGS"},
+ {RequestType::VEHICLE_DIAGNOSTICS, "VEHICLE_DIAGNOSTICS"},
+ {RequestType::EMERGENCY, "EMERGENCY"},
+ {RequestType::MEDIA, "MEDIA"},
+ {RequestType::FOTA, "FOTA"}};
const std::string RequestTypeToString(RequestType::eType type) {
RequestTypeMap::const_iterator it = TypeToString.find(type);
@@ -93,28 +92,29 @@ const std::string RequestTypeToString(RequestType::eType type) {
return "";
}
}
-#define POLICY_LIB_CHECK(return_value) {\
- sync_primitives::AutoReadLock lock(policy_manager_lock_); \
- if (!policy_manager_) {\
- LOG4CXX_DEBUG(logger_, "The shared library of policy is not loaded");\
- return return_value;\
- }\
-}
+#define POLICY_LIB_CHECK(return_value) \
+ { \
+ sync_primitives::AutoReadLock lock(policy_manager_lock_); \
+ if (!policy_manager_) { \
+ LOG4CXX_DEBUG(logger_, "The shared library of policy is not loaded"); \
+ return return_value; \
+ } \
+ }
-#define POLICY_LIB_CHECK_VOID() {\
- sync_primitives::AutoReadLock lock(policy_manager_lock_); \
- if (!policy_manager_) {\
- LOG4CXX_DEBUG(logger_, "The shared library of policy is not loaded");\
- return;\
- }\
-}
+#define POLICY_LIB_CHECK_VOID() \
+ { \
+ sync_primitives::AutoReadLock lock(policy_manager_lock_); \
+ if (!policy_manager_) { \
+ LOG4CXX_DEBUG(logger_, "The shared library of policy is not loaded"); \
+ return; \
+ } \
+ }
CREATE_LOGGERPTR_GLOBAL(logger_, "PolicyHandler")
-
struct ApplicationListHmiLevelSorter {
- bool operator() (const application_manager::ApplicationSharedPtr& lhs,
- const application_manager::ApplicationSharedPtr& rhs) {
+ bool operator()(const application_manager::ApplicationSharedPtr &lhs,
+ const application_manager::ApplicationSharedPtr &rhs) {
if (lhs && rhs) {
mobile_apis::HMILevel::eType lhs_hmi_level = lhs->hmi_level();
mobile_apis::HMILevel::eType rhs_hmi_level = rhs->hmi_level();
@@ -128,103 +128,99 @@ struct ApplicationListHmiLevelSorter {
}
};
-typedef std::set<application_manager::ApplicationSharedPtr, ApplicationListHmiLevelSorter>
-HmiLevelOrderedApplicationList;
+typedef std::set<application_manager::ApplicationSharedPtr,
+ ApplicationListHmiLevelSorter> HmiLevelOrderedApplicationList;
struct DeactivateApplication {
- explicit DeactivateApplication(
- const connection_handler::DeviceHandle& device_id)
+ explicit DeactivateApplication(
+ const connection_handler::DeviceHandle &device_id)
: device_id_(device_id) {}
- void operator()(const ApplicationSharedPtr& app) {
- if (device_id_ == app->device()) {
- ApplicationManagerImpl::instance()->SetState<true>(app->app_id(),
- mobile_apis::HMILevel::HMI_NONE,
- mobile_apis::AudioStreamingState::NOT_AUDIBLE);
- }
+ void operator()(const ApplicationSharedPtr &app) {
+ if (device_id_ == app->device()) {
+ ApplicationManagerImpl::instance()->SetState<true>(
+ app->app_id(), mobile_apis::HMILevel::HMI_NONE,
+ mobile_apis::AudioStreamingState::NOT_AUDIBLE);
}
+ }
- private:
- connection_handler::DeviceHandle device_id_;
+private:
+ connection_handler::DeviceHandle device_id_;
};
struct SDLAlowedNotification {
- SDLAlowedNotification(const connection_handler::DeviceHandle& device_id,
- PolicyManager* policy_manager)
- : device_id_(device_id),
- policy_manager_(policy_manager){}
+ SDLAlowedNotification(const connection_handler::DeviceHandle &device_id,
+ PolicyManager *policy_manager)
+ : device_id_(device_id), policy_manager_(policy_manager) {}
- void operator()(const ApplicationSharedPtr& app) {
+ void operator()(const ApplicationSharedPtr &app) {
if (!policy_manager_) {
return;
}
if (device_id_ == app->device()) {
- std::string hmi_level;
- mobile_apis::HMILevel::eType default_mobile_hmi;
- policy_manager_->GetDefaultHmi(app->mobile_app_id(), &hmi_level);
- if ("BACKGROUND" == hmi_level) {
- default_mobile_hmi = mobile_apis::HMILevel::HMI_BACKGROUND;
- } else if ("FULL" == hmi_level) {
- default_mobile_hmi = mobile_apis::HMILevel::HMI_FULL;
- } else if ("LIMITED" == hmi_level) {
- default_mobile_hmi = mobile_apis::HMILevel::HMI_LIMITED;
- } else if ("NONE" == hmi_level) {
- default_mobile_hmi = mobile_apis::HMILevel::HMI_NONE;
- } else {
- return ;
- }
- ApplicationManagerImpl::instance()->SetState<true>(app->app_id(),
- default_mobile_hmi
- );
+ std::string hmi_level;
+ mobile_apis::HMILevel::eType default_mobile_hmi;
+ policy_manager_->GetDefaultHmi(app->mobile_app_id(), &hmi_level);
+ if ("BACKGROUND" == hmi_level) {
+ default_mobile_hmi = mobile_apis::HMILevel::HMI_BACKGROUND;
+ } else if ("FULL" == hmi_level) {
+ default_mobile_hmi = mobile_apis::HMILevel::HMI_FULL;
+ } else if ("LIMITED" == hmi_level) {
+ default_mobile_hmi = mobile_apis::HMILevel::HMI_LIMITED;
+ } else if ("NONE" == hmi_level) {
+ default_mobile_hmi = mobile_apis::HMILevel::HMI_NONE;
+ } else {
+ return;
}
+ ApplicationManagerImpl::instance()->SetState<true>(app->app_id(),
+ default_mobile_hmi);
}
- private:
- connection_handler::DeviceHandle device_id_;
- PolicyManager* policy_manager_;
+ }
+
+private:
+ connection_handler::DeviceHandle device_id_;
+ PolicyManager *policy_manager_;
};
struct LinkAppToDevice {
explicit LinkAppToDevice(
- std::map<std::string, std::string>& app_to_device_link)
- : app_to_device_link_(app_to_device_link) {
+ std::map<std::string, std::string> &app_to_device_link)
+ : app_to_device_link_(app_to_device_link) {
app_to_device_link_.clear();
}
- void operator()(const ApplicationSharedPtr& app) {
+ void operator()(const ApplicationSharedPtr &app) {
if (!app.valid()) {
LOG4CXX_WARN(logger_, "Invalid pointer to application was passed."
- "Skip current application.");
+ "Skip current application.");
return;
}
DeviceParams device_params;
- MessageHelper::GetDeviceInfoForApp(
- app->app_id(),
- &device_params);
+ MessageHelper::GetDeviceInfoForApp(app->app_id(), &device_params);
const std::string app_id = app->mobile_app_id();
if (device_params.device_mac_address.empty()) {
LOG4CXX_WARN(logger_, "Couldn't find device, which hosts application "
- << app_id);
+ << app_id);
return;
}
app_to_device_link_[app_id] = device_params.device_mac_address;
}
private:
- std::map<std::string, std::string>& app_to_device_link_;
+ std::map<std::string, std::string> &app_to_device_link_;
};
struct PermissionsConsolidator {
void Consolidate(
- const std::vector<policy::FunctionalGroupPermission>& permissions) {
+ const std::vector<policy::FunctionalGroupPermission> &permissions) {
std::vector<policy::FunctionalGroupPermission>::const_iterator it =
permissions.begin();
std::vector<policy::FunctionalGroupPermission>::const_iterator it_end =
permissions.end();
- for (;it != it_end; ++it) {
+ for (; it != it_end; ++it) {
std::vector<policy::FunctionalGroupPermission>::iterator it_consolidated =
std::find(consolidated_permissions_.begin(),
- consolidated_permissions_.end(),
- *it);
+ consolidated_permissions_.end(), *it);
// If found, consolidate states
if (consolidated_permissions_.end() != it_consolidated) {
@@ -243,7 +239,7 @@ struct PermissionsConsolidator {
}
}
- const std::vector<policy::FunctionalGroupPermission>&
+ const std::vector<policy::FunctionalGroupPermission> &
GetConsolidatedPermissions() const {
return consolidated_permissions_;
}
@@ -252,38 +248,33 @@ private:
std::vector<policy::FunctionalGroupPermission> consolidated_permissions_;
};
-PolicyHandler* PolicyHandler::instance_ = NULL;
+PolicyHandler *PolicyHandler::instance_ = NULL;
const std::string PolicyHandler::kLibrary = "libPolicy.so";
PolicyHandler::PolicyHandler()
- : AsyncRunner("PolicyHandler async runner thread"),
- dl_handle_(0),
- last_activated_app_id_(0),
- app_to_device_link_lock_(true),
- statistic_manager_impl_(new StatisticManagerImpl()) {
-}
-
-PolicyHandler::~PolicyHandler() {
+ : AsyncRunner("PolicyHandler async runner thread"), dl_handle_(0),
+ last_activated_app_id_(0), app_to_device_link_lock_(true),
+ statistic_manager_impl_(new StatisticManagerImpl()) {}
-}
+PolicyHandler::~PolicyHandler() {}
bool PolicyHandler::LoadPolicyLibrary() {
LOG4CXX_AUTO_TRACE(logger_);
sync_primitives::AutoWriteLock lock(policy_manager_lock_);
if (!PolicyEnabled()) {
LOG4CXX_WARN(logger_, "System is configured to work without policy "
- "functionality.");
+ "functionality.");
policy_manager_ = NULL;
return NULL;
}
dl_handle_ = dlopen(kLibrary.c_str(), RTLD_LAZY);
- char* error_string = dlerror();
+ char *error_string = dlerror();
if (error_string == NULL) {
if (CreateManager()) {
policy_manager_->set_listener(this);
- event_observer_= new PolicyEventObserver(this);
+ event_observer_ = new PolicyEventObserver(this);
}
} else {
LOG4CXX_ERROR(logger_, error_string);
@@ -297,9 +288,10 @@ bool PolicyHandler::PolicyEnabled() {
}
bool PolicyHandler::CreateManager() {
- typedef PolicyManager* (*CreateManager)();
- CreateManager create_manager = reinterpret_cast<CreateManager>(dlsym(dl_handle_, "CreateManager"));
- char* error_string = dlerror();
+ typedef PolicyManager *(*CreateManager)();
+ CreateManager create_manager =
+ reinterpret_cast<CreateManager>(dlsym(dl_handle_, "CreateManager"));
+ char *error_string = dlerror();
if (error_string == NULL) {
policy_manager_ = create_manager();
} else {
@@ -314,9 +306,9 @@ bool PolicyHandler::InitPolicyTable() {
// Subscribing to notification for system readiness to be able to get system
// info necessary for policy table
event_observer_->subscribe_on_event(
- hmi_apis::FunctionID::BasicCommunication_OnReady);
+ hmi_apis::FunctionID::BasicCommunication_OnReady);
std::string preloaded_file =
- profile::Profile::instance()->preloaded_pt_file();
+ profile::Profile::instance()->preloaded_pt_file();
if (file_system::FileExists(preloaded_file)) {
return policy_manager_->InitPT(preloaded_file);
}
@@ -328,7 +320,7 @@ bool PolicyHandler::ResetPolicyTable() {
LOG4CXX_TRACE(logger_, "Reset policy table.");
POLICY_LIB_CHECK(false);
std::string preloaded_file =
- profile::Profile::instance()->preloaded_pt_file();
+ profile::Profile::instance()->preloaded_pt_file();
if (file_system::FileExists(preloaded_file)) {
return policy_manager_->ResetPT(preloaded_file);
}
@@ -355,7 +347,8 @@ uint32_t PolicyHandler::GetAppIdForSending() {
const uint32_t app_id = (*first)->app_id();
MessageHelper::GetDeviceInfoForApp(app_id, &device_param);
if (kDeviceAllowed ==
- policy_manager_->GetUserConsentForDevice(device_param.device_mac_address)) {
+ policy_manager_->GetUserConsentForDevice(
+ device_param.device_mac_address)) {
return app_id;
}
}
@@ -364,44 +357,39 @@ uint32_t PolicyHandler::GetAppIdForSending() {
return 0;
}
-void PolicyHandler::OnAppPermissionConsent(const uint32_t connection_key,
- const PermissionConsent& permissions) {
+void PolicyHandler::OnAppPermissionConsent(
+ const uint32_t connection_key, const PermissionConsent &permissions) {
LOG4CXX_AUTO_TRACE(logger_);
AsyncRun(new AppPermissionDelegate(connection_key, permissions));
}
-void PolicyHandler::OnDeviceConsentChanged(const std::string& device_id,
+void PolicyHandler::OnDeviceConsentChanged(const std::string &device_id,
bool is_allowed) {
POLICY_LIB_CHECK_VOID();
connection_handler::DeviceHandle device_handle;
- ApplicationManagerImpl::instance()->connection_handler()
- ->GetDeviceID(device_id, &device_handle);
+ ApplicationManagerImpl::instance()->connection_handler()->GetDeviceID(
+ device_id, &device_handle);
// In case of changed consent for device, related applications will be
// limited to pre_DataConsent permissions, if device disallowed, or switch
// back to their own permissions, if device allowed again, and must be
// notified about these changes
ApplicationManagerImpl::ApplicationListAccessor accessor;
- ApplicationManagerImpl::ApplictionSetConstIt it_app_list =
- accessor.begin();
- ApplicationManagerImpl::ApplictionSetConstIt it_app_list_end =
- accessor.end();
+ ApplicationManagerImpl::ApplictionSetConstIt it_app_list = accessor.begin();
+ ApplicationManagerImpl::ApplictionSetConstIt it_app_list_end = accessor.end();
for (; it_app_list != it_app_list_end; ++it_app_list) {
if (device_handle == (*it_app_list).get()->device()) {
- const std::string policy_app_id =
- (*it_app_list)->mobile_app_id();
+ const std::string policy_app_id = (*it_app_list)->mobile_app_id();
// If app has predata policy, which is assigned without device consent or
// with negative data consent, there no necessity to change smth and send
// notification for such app in case of device consent is not allowed
- if (policy_manager_->IsPredataPolicy(policy_app_id) &&
- !is_allowed) {
+ if (policy_manager_->IsPredataPolicy(policy_app_id) && !is_allowed) {
continue;
}
- policy_manager_->ReactOnUserDevConsentForApp(policy_app_id,
- is_allowed);
+ policy_manager_->ReactOnUserDevConsentForApp(policy_app_id, is_allowed);
policy_manager_->SendNotificationOnPermissionsUpdated(policy_app_id);
}
@@ -413,25 +401,26 @@ void PolicyHandler::OnPTExchangeNeeded() {
policy_manager_->ForcePTExchange();
}
-void PolicyHandler::GetAvailableApps(std::queue<std::string>& apps) {
+void PolicyHandler::GetAvailableApps(std::queue<std::string> &apps) {
LOG4CXX_INFO(logger_, "GetAvailable apps");
ApplicationManagerImpl::ApplicationListAccessor accessor;
- const ApplicationManagerImpl::ApplictionSet app_list = accessor.applications();
+ const ApplicationManagerImpl::ApplictionSet app_list =
+ accessor.applications();
ApplicationManagerImpl::ApplictionSetConstIt iter = app_list.begin();
- for (;app_list.end() != iter; ++iter) {
+ for (; app_list.end() != iter; ++iter) {
LOG4CXX_INFO(logger_, "one more app");
apps.push((*iter)->mobile_app_id());
}
}
-void PolicyHandler::AddApplication(const std::string& application_id) {
+void PolicyHandler::AddApplication(const std::string &application_id) {
POLICY_LIB_CHECK_VOID();
policy_manager_->AddApplication(application_id);
}
-void PolicyHandler::SetDeviceInfo(std::string& device_id,
- const DeviceInfo& device_info) {
+void PolicyHandler::SetDeviceInfo(std::string &device_id,
+ const DeviceInfo &device_info) {
LOG4CXX_AUTO_TRACE(logger_);
POLICY_LIB_CHECK_VOID();
policy_manager_->SetDeviceInfo(device_id, device_info);
@@ -443,15 +432,12 @@ void PolicyHandler::OnAppPermissionConsentInternal(
POLICY_LIB_CHECK_VOID();
if (connection_key) {
ApplicationSharedPtr app =
- ApplicationManagerImpl::instance()
- ->application(connection_key);
+ ApplicationManagerImpl::instance()->application(connection_key);
if (app.valid()) {
permissions.policy_app_id = app->mobile_app_id();
policy::DeviceParams device_params;
- MessageHelper::GetDeviceInfoForHandle(
- app->device(),
- &device_params);
+ MessageHelper::GetDeviceInfoForHandle(app->device(), &device_params);
permissions.device_id = device_params.device_mac_address;
}
@@ -466,7 +452,7 @@ void PolicyHandler::OnAppPermissionConsentInternal(
sync_primitives::AutoLock lock(app_to_device_link_lock_);
if (!app_to_device_link_.size()) {
LOG4CXX_WARN(logger_, "There are no applications previously stored for "
- "setting common permissions.");
+ "setting common permissions.");
return;
}
@@ -474,27 +460,24 @@ void PolicyHandler::OnAppPermissionConsentInternal(
app_to_device_link_.begin();
std::map<std::string, std::string>::const_iterator it_end =
app_to_device_link_.end();
- for (;it != it_end; ++it) {
+ for (; it != it_end; ++it) {
ApplicationSharedPtr app =
- ApplicationManagerImpl::instance()->
- application_by_policy_id(it->first);
+ ApplicationManagerImpl::instance()->application_by_policy_id(it->first);
// If list of apps sent to HMI for user consents is not the same as current,
// permissions should be set only for coincident to registered apps
if (!app.valid()) {
LOG4CXX_WARN(logger_, "Invalid pointer to application was passed."
- "Permissions setting skipped.");
+ "Permissions setting skipped.");
continue;
}
policy::DeviceParams device_params;
- MessageHelper::GetDeviceInfoForHandle(
- app->device(),
- &device_params);
+ MessageHelper::GetDeviceInfoForHandle(app->device(), &device_params);
if (device_params.device_mac_address != it->second) {
LOG4CXX_WARN(logger_, "Device_id of application is changed."
- "Permissions setting skipped.");
+ "Permissions setting skipped.");
continue;
}
@@ -505,19 +488,18 @@ void PolicyHandler::OnAppPermissionConsentInternal(
}
void PolicyHandler::OnGetUserFriendlyMessage(
- const std::vector<std::string>& message_codes, const std::string& language,
- uint32_t correlation_id) {
+ const std::vector<std::string> &message_codes, const std::string &language,
+ uint32_t correlation_id) {
LOG4CXX_AUTO_TRACE(logger_);
POLICY_LIB_CHECK_VOID();
- std::vector<UserFriendlyMessage> result = policy_manager_
- ->GetUserFriendlyMessages(message_codes, language);
+ std::vector<UserFriendlyMessage> result =
+ policy_manager_->GetUserFriendlyMessages(message_codes, language);
// Send response to HMI with gathered data
- MessageHelper::SendGetUserFriendlyMessageResponse(
- result, correlation_id);
+ MessageHelper::SendGetUserFriendlyMessageResponse(result, correlation_id);
}
void PolicyHandler::OnGetListOfPermissions(const uint32_t connection_key,
- const uint32_t correlation_id) {
+ const uint32_t correlation_id) {
LOG4CXX_AUTO_TRACE(logger_);
POLICY_LIB_CHECK_VOID();
// If no specific app was passed, get permissions for all currently registered
@@ -526,10 +508,8 @@ void PolicyHandler::OnGetListOfPermissions(const uint32_t connection_key,
sync_primitives::AutoLock lock(app_to_device_link_lock_);
LinkAppToDevice linker(app_to_device_link_);
ApplicationManagerImpl::ApplicationListAccessor accessor;
- ApplicationManagerImpl::ApplictionSetConstIt it_app
- = accessor.begin();
- ApplicationManagerImpl::ApplictionSetConstIt it_app_end
- = accessor.end();
+ ApplicationManagerImpl::ApplictionSetConstIt it_app = accessor.begin();
+ ApplicationManagerImpl::ApplictionSetConstIt it_app_end = accessor.end();
// Add all currently registered applications
std::for_each(it_app, it_app_end, linker);
@@ -538,32 +518,32 @@ void PolicyHandler::OnGetListOfPermissions(const uint32_t connection_key,
std::vector<policy::FunctionalGroupPermission> group_permissions;
std::map<std::string, std::string>::const_iterator it =
app_to_device_link_.begin();
- for (;it != app_to_device_link_.end(); ++it) {
+ for (; it != app_to_device_link_.end(); ++it) {
policy_manager_->GetUserConsentForApp(it->second, it->first,
group_permissions);
consolidator.Consolidate(group_permissions);
}
MessageHelper::SendGetListOfPermissionsResponse(
- consolidator.GetConsolidatedPermissions(), correlation_id);
+ consolidator.GetConsolidatedPermissions(), correlation_id);
return;
}
// Single app only
ApplicationSharedPtr app =
- ApplicationManagerImpl::instance()->application(
- connection_key);
+ ApplicationManagerImpl::instance()->application(connection_key);
if (!app.valid()) {
- LOG4CXX_WARN(logger_, "Connection key '" << connection_key << "' "
- "not found within registered applications.");
+ LOG4CXX_WARN(logger_, "Connection key '"
+ << connection_key
+ << "' "
+ "not found within registered applications.");
return;
}
DeviceParams device_params;
- MessageHelper::GetDeviceInfoForApp(connection_key,
- &device_params);
+ MessageHelper::GetDeviceInfoForApp(connection_key, &device_params);
std::vector<FunctionalGroupPermission> group_permissions;
if (device_params.device_mac_address.empty()) {
LOG4CXX_WARN(logger_, "Couldn't find device, which hosts application.");
@@ -574,8 +554,8 @@ void PolicyHandler::OnGetListOfPermissions(const uint32_t connection_key,
app->mobile_app_id(),
group_permissions);
- MessageHelper::SendGetListOfPermissionsResponse(
- group_permissions, correlation_id);
+ MessageHelper::SendGetListOfPermissionsResponse(group_permissions,
+ correlation_id);
}
}
@@ -583,41 +563,42 @@ void PolicyHandler::OnGetStatusUpdate(const uint32_t correlation_id) {
LOG4CXX_AUTO_TRACE(logger_);
POLICY_LIB_CHECK_VOID();
MessageHelper::SendGetStatusUpdateResponse(
- policy_manager_->GetPolicyTableStatus(), correlation_id);
+ policy_manager_->GetPolicyTableStatus(), correlation_id);
}
-void PolicyHandler::OnUpdateStatusChanged(const std::string& status) {
+void PolicyHandler::OnUpdateStatusChanged(const std::string &status) {
LOG4CXX_AUTO_TRACE(logger_);
MessageHelper::SendOnStatusUpdate(status);
}
std::string PolicyHandler::OnCurrentDeviceIdUpdateRequired(
- const std::string& policy_app_id) {
+ const std::string &policy_app_id) {
LOG4CXX_AUTO_TRACE(logger_);
ApplicationSharedPtr app =
- ApplicationManagerImpl::instance()
- ->application_by_policy_id(policy_app_id);
+ ApplicationManagerImpl::instance()->application_by_policy_id(
+ policy_app_id);
if (!app.valid()) {
- LOG4CXX_WARN(logger_, "Application with id '" << policy_app_id << "' "
- "not found within registered applications.");
+ LOG4CXX_WARN(logger_, "Application with id '"
+ << policy_app_id
+ << "' "
+ "not found within registered applications.");
return "";
}
DeviceParams device_param;
- MessageHelper::GetDeviceInfoForApp(app->app_id(),
- &device_param);
+ MessageHelper::GetDeviceInfoForApp(app->app_id(), &device_param);
return device_param.device_mac_address;
}
-void PolicyHandler::OnSystemInfoChanged(const std::string& language) {
+void PolicyHandler::OnSystemInfoChanged(const std::string &language) {
LOG4CXX_AUTO_TRACE(logger_);
POLICY_LIB_CHECK_VOID();
policy_manager_->SetSystemLanguage(language);
}
-void PolicyHandler::OnGetSystemInfo(const std::string& ccpu_version,
- const std::string& wers_country_code,
- const std::string& language) {
+void PolicyHandler::OnGetSystemInfo(const std::string &ccpu_version,
+ const std::string &wers_country_code,
+ const std::string &language) {
LOG4CXX_AUTO_TRACE(logger_);
POLICY_LIB_CHECK_VOID();
policy_manager_->SetSystemInfo(ccpu_version, wers_country_code, language);
@@ -636,41 +617,39 @@ void PolicyHandler::OnVIIsReady() {
std::vector<std::string> params;
params.push_back(strings::vin);
- MessageHelper::CreateGetVehicleDataRequest(
- correlation_id, params);
-
+ MessageHelper::CreateGetVehicleDataRequest(correlation_id, params);
}
void PolicyHandler::OnVehicleDataUpdated(
- const smart_objects::SmartObject& message) {
+ const smart_objects::SmartObject &message) {
POLICY_LIB_CHECK_VOID();
}
void PolicyHandler::OnPendingPermissionChange(
- const std::string& policy_app_id) {
+ const std::string &policy_app_id) {
LOG4CXX_DEBUG(logger_, "PolicyHandler::OnPendingPermissionChange for "
- << policy_app_id);
+ << policy_app_id);
POLICY_LIB_CHECK_VOID();
ApplicationSharedPtr app =
- ApplicationManagerImpl::instance()
- ->application_by_policy_id(policy_app_id);
+ ApplicationManagerImpl::instance()->application_by_policy_id(
+ policy_app_id);
if (!app.valid()) {
- LOG4CXX_WARN(logger_,
- "No app found for " << policy_app_id << " policy app id.");
+ LOG4CXX_WARN(logger_, "No app found for " << policy_app_id
+ << " policy app id.");
return;
}
- AppPermissions permissions = policy_manager_->GetAppPermissionsChanges(
- policy_app_id);
+ AppPermissions permissions =
+ policy_manager_->GetAppPermissionsChanges(policy_app_id);
const uint32_t app_id = app->app_id();
if (permissions.appRevoked) {
application_manager::MessageHelper::SendOnAppPermissionsChangedNotification(
- app_id, permissions);
- ApplicationManagerImpl::instance()->SetState<true>(app->app_id(),
- mobile_apis::HMILevel::HMI_NONE,
- mobile_apis::AudioStreamingState::NOT_AUDIBLE);
+ app_id, permissions);
+ ApplicationManagerImpl::instance()->SetState<true>(
+ app->app_id(), mobile_apis::HMILevel::HMI_NONE,
+ mobile_apis::AudioStreamingState::NOT_AUDIBLE);
policy_manager_->RemovePendingPermissionChanges(policy_app_id);
return;
}
@@ -681,8 +660,8 @@ void PolicyHandler::OnPendingPermissionChange(
case mobile_apis::HMILevel::eType::HMI_FULL:
case mobile_apis::HMILevel::eType::HMI_LIMITED: {
if (permissions.appPermissionsConsentNeeded) {
- MessageHelper::
- SendOnAppPermissionsChangedNotification(app->app_id(), permissions);
+ MessageHelper::SendOnAppPermissionsChangedNotification(app->app_id(),
+ permissions);
policy_manager_->RemovePendingPermissionChanges(policy_app_id);
// "Break" statement has to be here to continue processing in case of
@@ -692,8 +671,8 @@ void PolicyHandler::OnPendingPermissionChange(
}
case mobile_apis::HMILevel::eType::HMI_BACKGROUND: {
if (permissions.isAppPermissionsRevoked) {
- MessageHelper::
- SendOnAppPermissionsChangedNotification(app->app_id(), permissions);
+ MessageHelper::SendOnAppPermissionsChangedNotification(app->app_id(),
+ permissions);
policy_manager_->RemovePendingPermissionChanges(policy_app_id);
}
@@ -706,61 +685,61 @@ void PolicyHandler::OnPendingPermissionChange(
if (permissions.appUnauthorized) {
if (mobile_apis::HMILevel::HMI_FULL == app_hmi_level ||
mobile_apis::HMILevel::HMI_LIMITED == app_hmi_level) {
- MessageHelper::
- SendOnAppPermissionsChangedNotification(app->app_id(), permissions);
+ MessageHelper::SendOnAppPermissionsChangedNotification(app->app_id(),
+ permissions);
}
- MessageHelper::
- SendOnAppInterfaceUnregisteredNotificationToMobile(
- app->app_id(),
- mobile_api::AppInterfaceUnregisteredReason::APP_UNAUTHORIZED);
+ MessageHelper::SendOnAppInterfaceUnregisteredNotificationToMobile(
+ app->app_id(),
+ mobile_api::AppInterfaceUnregisteredReason::APP_UNAUTHORIZED);
ApplicationManagerImpl::instance()->OnAppUnauthorized(app->app_id());
policy_manager_->RemovePendingPermissionChanges(policy_app_id);
}
if (permissions.requestTypeChanged) {
- MessageHelper::
- SendOnAppPermissionsChangedNotification(app->app_id(), permissions);
+ MessageHelper::SendOnAppPermissionsChangedNotification(app->app_id(),
+ permissions);
policy_manager_->RemovePendingPermissionChanges(policy_app_id);
}
}
-bool PolicyHandler::SendMessageToSDK(const BinaryMessage& pt_string,
- const std::string& url) {
+bool PolicyHandler::SendMessageToSDK(const BinaryMessage &pt_string,
+ const std::string &url) {
LOG4CXX_AUTO_TRACE(logger_);
POLICY_LIB_CHECK(false);
-
uint32_t app_id = GetAppIdForSending();
ApplicationSharedPtr app =
- ApplicationManagerImpl::instance()->application(app_id);
+ ApplicationManagerImpl::instance()->application(app_id);
if (!app.valid()) {
LOG4CXX_WARN(logger_, "There is no registered application with "
- "connection key '" << app_id << "'");
+ "connection key '"
+ << app_id << "'");
return false;
}
- const std::string& mobile_app_id = app->mobile_app_id();
+ const std::string &mobile_app_id = app->mobile_app_id();
if (mobile_app_id.empty()) {
- LOG4CXX_WARN(logger_, "Application with connection key '" << app_id << "'"
- " has no application id.");
+ LOG4CXX_WARN(logger_, "Application with connection key '"
+ << app_id << "'"
+ " has no application id.");
return false;
}
LOG4CXX_DEBUG(logger_, "Update url is " << url << " for application "
- << ApplicationManagerImpl::instance()
- ->application(app_id)->name());
+ << ApplicationManagerImpl::instance()
+ ->application(app_id)
+ ->name());
- MessageHelper::SendPolicySnapshotNotification(
- app_id, pt_string, url, 0);
+ MessageHelper::SendPolicySnapshotNotification(app_id, pt_string, url, 0);
return true;
}
-bool PolicyHandler::ReceiveMessageFromSDK(const std::string& file,
- const BinaryMessage& pt_string) {
+bool PolicyHandler::ReceiveMessageFromSDK(const std::string &file,
+ const BinaryMessage &pt_string) {
POLICY_LIB_CHECK(false);
bool ret = policy_manager_->LoadPT(file, pt_string);
@@ -769,21 +748,20 @@ bool PolicyHandler::ReceiveMessageFromSDK(const std::string& file,
LOG4CXX_INFO(logger_, "PTU was successful.");
policy_manager_->CleanupUnpairedDevices();
int32_t correlation_id =
- ApplicationManagerImpl::instance()
- ->GetNextHMICorrelationID();
+ ApplicationManagerImpl::instance()->GetNextHMICorrelationID();
event_observer_->subscribe_on_event(
#ifdef HMI_DBUS_API
- hmi_apis::FunctionID::VehicleInfo_GetOdometer, correlation_id
+ hmi_apis::FunctionID::VehicleInfo_GetOdometer, correlation_id
#else
- hmi_apis::FunctionID::VehicleInfo_GetVehicleData, correlation_id
+ hmi_apis::FunctionID::VehicleInfo_GetVehicleData, correlation_id
#endif
- );
+ );
std::vector<std::string> vehicle_data_args;
vehicle_data_args.push_back(strings::odometer);
- MessageHelper::CreateGetVehicleDataRequest(
- correlation_id, vehicle_data_args);
- } else {
+ MessageHelper::CreateGetVehicleDataRequest(correlation_id,
+ vehicle_data_args);
+ } else {
LOG4CXX_WARN(logger_, "Exchange wasn't successful, trying another one.");
OnPTExchangeNeeded();
}
@@ -808,7 +786,7 @@ bool PolicyHandler::UnloadPolicyLibrary() {
}
void PolicyHandler::OnAllowSDLFunctionalityNotification(bool is_allowed,
- uint32_t device_id) {
+ uint32_t device_id) {
LOG4CXX_AUTO_TRACE(logger_);
POLICY_LIB_CHECK_VOID();
// Device ids, need to be changed
@@ -817,12 +795,13 @@ void PolicyHandler::OnAllowSDLFunctionalityNotification(bool is_allowed,
// Common devices consents change
if (!device_specific) {
ApplicationManagerImpl::ApplicationListAccessor accessor;
- const ApplicationManagerImpl::ApplictionSet app_list = accessor.applications();
+ const ApplicationManagerImpl::ApplictionSet app_list =
+ accessor.applications();
ApplicationManagerImpl::ApplictionSetConstIt it_app_list = app_list.begin();
ApplicationManagerImpl::ApplictionSetConstIt it_app_end = app_list.end();
- for (;it_app_list != it_app_end; ++it_app_list) {
+ for (; it_app_list != it_app_end; ++it_app_list) {
if (!(*it_app_list).valid()) {
continue;
}
@@ -834,28 +813,26 @@ void PolicyHandler::OnAllowSDLFunctionalityNotification(bool is_allowed,
std::set<uint32_t>::const_iterator it_ids = device_ids.begin();
std::set<uint32_t>::const_iterator it_ids_end = device_ids.end();
- for (;it_ids != it_ids_end; ++it_ids) {
+ for (; it_ids != it_ids_end; ++it_ids) {
const uint32_t device_id = *it_ids;
DeviceParams device_params;
- MessageHelper::GetDeviceInfoForHandle(device_id,
- &device_params);
+ MessageHelper::GetDeviceInfoForHandle(device_id, &device_params);
device_params.device_handle = device_id;
if (kDefaultDeviceMacAddress == device_params.device_mac_address) {
LOG4CXX_WARN(logger_, "Device with handle " << device_id
- << " wasn't found.");
+ << " wasn't found.");
return;
}
policy_manager_->SetUserConsentForDevice(device_params.device_mac_address,
- is_allowed);
-
+ is_allowed);
}
// Case, when specific device was changed
if (device_id) {
- DeviceHandles::iterator it = std::find(pending_device_handles_.begin(),
- pending_device_handles_.end(),
- device_id);
+ DeviceHandles::iterator it =
+ std::find(pending_device_handles_.begin(),
+ pending_device_handles_.end(), device_id);
// If consent done from HMI menu
if (it == pending_device_handles_.end()) {
return;
@@ -863,7 +840,6 @@ void PolicyHandler::OnAllowSDLFunctionalityNotification(bool is_allowed,
pending_device_handles_.erase(it);
}
-
}
void PolicyHandler::OnIgnitionCycleOver() {
@@ -877,8 +853,7 @@ void PolicyHandler::OnActivateApp(uint32_t connection_key,
LOG4CXX_AUTO_TRACE(logger_);
ApplicationSharedPtr app =
- ApplicationManagerImpl::instance()->application(
- connection_key);
+ ApplicationManagerImpl::instance()->application(connection_key);
if (!app.valid()) {
LOG4CXX_WARN(logger_, "Activated App failed: no app found.");
return;
@@ -894,8 +869,7 @@ void PolicyHandler::OnActivateApp(uint32_t connection_key,
permissions.isSDLAllowed = true;
}
} else {
- permissions = policy_manager_->GetAppPermissionsChanges(
- policy_app_id);
+ permissions = policy_manager_->GetAppPermissionsChanges(policy_app_id);
permissions.isSDLAllowed = true;
policy_manager_->RemovePendingPermissionChanges(policy_app_id);
@@ -903,10 +877,10 @@ void PolicyHandler::OnActivateApp(uint32_t connection_key,
// If application is revoked it should not be activated
// In this case we need to activate application
if (false == permissions.appRevoked && true == permissions.isSDLAllowed) {
- LOG4CXX_INFO(logger_, "Application will be activated");
- if (ApplicationManagerImpl::instance()->ActivateApplication(app)) {
- last_activated_app_id_ = 0;
- }
+ LOG4CXX_INFO(logger_, "Application will be activated");
+ if (ApplicationManagerImpl::instance()->ActivateApplication(app)) {
+ last_activated_app_id_ = 0;
+ }
} else {
LOG4CXX_INFO(logger_, "Application should not be activated");
}
@@ -915,7 +889,8 @@ void PolicyHandler::OnActivateApp(uint32_t connection_key,
}
void PolicyHandler::KmsChanged(int kilometers) {
- LOG4CXX_DEBUG(logger_, "PolicyHandler::KmsChanged " << kilometers << " kilometers");
+ LOG4CXX_DEBUG(logger_, "PolicyHandler::KmsChanged " << kilometers
+ << " kilometers");
POLICY_LIB_CHECK_VOID();
policy_manager_->KmsChanged(kilometers);
}
@@ -924,23 +899,21 @@ void PolicyHandler::PTExchangeAtUserRequest(uint32_t correlation_id) {
LOG4CXX_TRACE(logger_, "PT exchange at user request");
POLICY_LIB_CHECK_VOID();
std::string update_status = policy_manager_->ForcePTExchange();
- MessageHelper::SendUpdateSDLResponse(update_status,
- correlation_id);
+ MessageHelper::SendUpdateSDLResponse(update_status, correlation_id);
}
-void PolicyHandler::OnPermissionsUpdated(const std::string& policy_app_id,
- const Permissions& permissions,
- const HMILevel& default_hmi) {
+void PolicyHandler::OnPermissionsUpdated(const std::string &policy_app_id,
+ const Permissions &permissions,
+ const HMILevel &default_hmi) {
LOG4CXX_AUTO_TRACE(logger_);
OnPermissionsUpdated(policy_app_id, permissions);
ApplicationSharedPtr app =
- ApplicationManagerImpl::instance()
- ->application_by_policy_id(policy_app_id);
+ ApplicationManagerImpl::instance()->application_by_policy_id(
+ policy_app_id);
if (!app.valid()) {
- LOG4CXX_WARN(
- logger_,
- "Connection_key not found for application_id:" << policy_app_id);
+ LOG4CXX_WARN(logger_, "Connection_key not found for application_id:"
+ << policy_app_id);
return;
}
@@ -948,11 +921,11 @@ void PolicyHandler::OnPermissionsUpdated(const std::string& policy_app_id,
// level to default
mobile_apis::HMILevel::eType current_hmi_level = app->hmi_level();
mobile_apis::HMILevel::eType hmi_level =
- MessageHelper::StringToHMILevel(default_hmi);
+ MessageHelper::StringToHMILevel(default_hmi);
if (mobile_apis::HMILevel::INVALID_ENUM == hmi_level) {
- LOG4CXX_WARN(logger_, "Couldn't convert default hmi level "
- << default_hmi << " to enum.");
+ LOG4CXX_WARN(logger_, "Couldn't convert default hmi level " << default_hmi
+ << " to enum.");
return;
}
if (current_hmi_level == hmi_level) {
@@ -960,50 +933,50 @@ void PolicyHandler::OnPermissionsUpdated(const std::string& policy_app_id,
return;
}
switch (current_hmi_level) {
- case mobile_apis::HMILevel::HMI_NONE: {
- LOG4CXX_INFO(logger_, "Changing hmi level of application "
- << policy_app_id
- << " to default hmi level " << default_hmi);
- ApplicationManagerImpl::instance()->SetState<true>(app->app_id(),
- mobile_apis::HMILevel::HMI_FULL
- );
- break;
- }
- default:
- LOG4CXX_WARN(logger_, "Application " << policy_app_id << " is running."
- "HMI level won't be changed.");
- break;
+ case mobile_apis::HMILevel::HMI_NONE: {
+ LOG4CXX_INFO(logger_, "Changing hmi level of application "
+ << policy_app_id << " to default hmi level "
+ << default_hmi);
+ ApplicationManagerImpl::instance()->SetState<true>(
+ app->app_id(), mobile_apis::HMILevel::HMI_FULL);
+ break;
+ }
+ default:
+ LOG4CXX_WARN(logger_, "Application " << policy_app_id
+ << " is running."
+ "HMI level won't be changed.");
+ break;
}
}
-void PolicyHandler::OnPermissionsUpdated(const std::string& policy_app_id,
- const Permissions& permissions) {
+void PolicyHandler::OnPermissionsUpdated(const std::string &policy_app_id,
+ const Permissions &permissions) {
LOG4CXX_AUTO_TRACE(logger_);
ApplicationSharedPtr app =
- ApplicationManagerImpl::instance()
- ->application_by_policy_id(policy_app_id);
+ ApplicationManagerImpl::instance()->application_by_policy_id(
+ policy_app_id);
if (!app.valid()) {
- LOG4CXX_WARN(
- logger_,
- "Connection_key not found for application_id:" << policy_app_id);
+ LOG4CXX_WARN(logger_, "Connection_key not found for application_id:"
+ << policy_app_id);
return;
}
- MessageHelper::SendOnPermissionsChangeNotification(
- app->app_id(), permissions);
+ MessageHelper::SendOnPermissionsChangeNotification(app->app_id(),
+ permissions);
- LOG4CXX_DEBUG(
- logger_,
- "Notification sent for application_id:" << policy_app_id
- << " and connection_key " << app->app_id());
+ LOG4CXX_DEBUG(logger_, "Notification sent for application_id:"
+ << policy_app_id << " and connection_key "
+ << app->app_id());
}
-bool PolicyHandler::SaveSnapshot(const BinaryMessage& pt_string,
- std::string& snap_path) {
+bool PolicyHandler::SaveSnapshot(const BinaryMessage &pt_string,
+ std::string &snap_path) {
using namespace profile;
- const std::string& policy_snapshot_file_name = Profile::instance()->policies_snapshot_file_name();
- const std::string& system_files_path = Profile::instance()->system_files_path();
+ const std::string &policy_snapshot_file_name =
+ Profile::instance()->policies_snapshot_file_name();
+ const std::string &system_files_path =
+ Profile::instance()->system_files_path();
snap_path = system_files_path + '/' + policy_snapshot_file_name;
bool result = false;
@@ -1018,7 +991,7 @@ bool PolicyHandler::SaveSnapshot(const BinaryMessage& pt_string,
return result;
}
-void PolicyHandler::OnSnapshotCreated(const BinaryMessage& pt_string) {
+void PolicyHandler::OnSnapshotCreated(const BinaryMessage &pt_string) {
LOG4CXX_AUTO_TRACE(logger_);
POLICY_LIB_CHECK_VOID();
#ifdef EXTENDED_POLICY
@@ -1028,8 +1001,7 @@ void PolicyHandler::OnSnapshotCreated(const BinaryMessage& pt_string) {
return;
}
MessageHelper::SendPolicyUpdate(
- policy_snapshot_full_path,
- policy_manager_->TimeoutExchange(),
+ policy_snapshot_full_path, policy_manager_->TimeoutExchange(),
policy_manager_->RetrySequenceDelaysSeconds());
#else
EndpointUrls urls;
@@ -1038,46 +1010,48 @@ void PolicyHandler::OnSnapshotCreated(const BinaryMessage& pt_string) {
#endif
}
-bool PolicyHandler::GetPriority(const std::string& policy_app_id,
- std::string* priority) {
+bool PolicyHandler::GetPriority(const std::string &policy_app_id,
+ std::string *priority) {
POLICY_LIB_CHECK(false);
return policy_manager_->GetPriority(policy_app_id, priority);
}
-void PolicyHandler::CheckPermissions(const PTString& app_id,
- const PTString& hmi_level,
- const PTString& rpc,
- const RPCParams& rpc_params,
- CheckPermissionResult& result) {
+void PolicyHandler::CheckPermissions(const PTString &app_id,
+ const PTString &hmi_level,
+ const PTString &rpc,
+ const RPCParams &rpc_params,
+ CheckPermissionResult &result) {
POLICY_LIB_CHECK_VOID();
policy_manager_->CheckPermissions(app_id, hmi_level, rpc, rpc_params, result);
}
-uint32_t PolicyHandler::GetNotificationsNumber(const std::string& priority) {
+uint32_t PolicyHandler::GetNotificationsNumber(const std::string &priority) {
POLICY_LIB_CHECK(0);
- return policy_manager_->GetNotificationsNumber(priority);
+ return policy_manager_->GetNotificationsNumber(priority);
}
-DeviceConsent PolicyHandler::GetUserConsentForDevice(
- const std::string& device_id) {
+DeviceConsent
+PolicyHandler::GetUserConsentForDevice(const std::string &device_id) {
POLICY_LIB_CHECK(kDeviceDisallowed);
return policy_manager_->GetUserConsentForDevice(device_id);
}
-bool PolicyHandler::GetDefaultHmi(const std::string& policy_app_id,
- std::string* default_hmi) {
+bool PolicyHandler::GetDefaultHmi(const std::string &policy_app_id,
+ std::string *default_hmi) {
POLICY_LIB_CHECK(false);
return policy_manager_->GetDefaultHmi(policy_app_id, default_hmi);
}
-bool PolicyHandler::GetInitialAppData(const std::string& application_id,
- StringArray* nicknames,
- StringArray* app_hmi_types) {
+bool PolicyHandler::GetInitialAppData(const std::string &application_id,
+ StringArray *nicknames,
+ StringArray *app_hmi_types) {
POLICY_LIB_CHECK(false);
- return policy_manager_->GetInitialAppData(application_id, nicknames, app_hmi_types);
+ return policy_manager_->GetInitialAppData(application_id, nicknames,
+ app_hmi_types);
}
-void PolicyHandler::GetServiceUrls(const std::string& service_type, EndpointUrls& end_points) {
+void PolicyHandler::GetServiceUrls(const std::string &service_type,
+ EndpointUrls &end_points) {
POLICY_LIB_CHECK_VOID();
policy_manager_->GetServiceUrls(service_type, end_points);
}
@@ -1092,7 +1066,7 @@ void PolicyHandler::ResetRetrySequence() {
policy_manager_->ResetRetrySequence();
}
-int PolicyHandler::NextRetryTimeout() {
+uint32_t PolicyHandler::NextRetryTimeout() {
POLICY_LIB_CHECK(0);
return policy_manager_->NextRetryTimeout();
}
@@ -1117,12 +1091,12 @@ void PolicyHandler::PTUpdatedAt(int kilometers, int days_after_epoch) {
policy_manager_->PTUpdatedAt(kilometers, days_after_epoch);
}
-void PolicyHandler::add_listener(PolicyHandlerObserver* listener) {
+void PolicyHandler::add_listener(PolicyHandlerObserver *listener) {
sync_primitives::AutoLock lock(listeners_lock_);
listeners_.push_back(listener);
}
-void PolicyHandler::remove_listener(PolicyHandlerObserver* listener) {
+void PolicyHandler::remove_listener(PolicyHandlerObserver *listener) {
sync_primitives::AutoLock lock(listeners_lock_);
listeners_.remove(listener);
}
@@ -1135,54 +1109,50 @@ PolicyHandler::GetStatisticManager() {
void PolicyHandler::AddStatisticsInfo(int type) {
POLICY_LIB_CHECK_VOID();
switch (static_cast<hmi_apis::Common_StatisticsType::eType>(type)) {
- case hmi_apis::Common_StatisticsType::iAPP_BUFFER_FULL: {
- usage_statistics::GlobalCounter count_of_iap_buffer_full(
+ case hmi_apis::Common_StatisticsType::iAPP_BUFFER_FULL: {
+ usage_statistics::GlobalCounter count_of_iap_buffer_full(
GetStatisticManager(), usage_statistics::IAP_BUFFER_FULL);
- ++count_of_iap_buffer_full;
- break;
- }
- default: {
- LOG4CXX_WARN(logger_, "Type of statistics is unknown");
- }
+ ++count_of_iap_buffer_full;
+ break;
+ }
+ default: { LOG4CXX_WARN(logger_, "Type of statistics is unknown"); }
}
}
void PolicyHandler::OnSystemError(int code) {
POLICY_LIB_CHECK_VOID();
switch (static_cast<hmi_apis::Common_SystemError::eType>(code)) {
- case hmi_apis::Common_SystemError::SYNC_REBOOTED: {
- usage_statistics::GlobalCounter count_of_sync_reboots(
+ case hmi_apis::Common_SystemError::SYNC_REBOOTED: {
+ usage_statistics::GlobalCounter count_of_sync_reboots(
GetStatisticManager(), usage_statistics::SYNC_REBOOTS);
- ++count_of_sync_reboots;
- break;
- }
- case hmi_apis::Common_SystemError::SYNC_OUT_OF_MEMMORY: {
- usage_statistics::GlobalCounter count_sync_out_of_memory(
+ ++count_of_sync_reboots;
+ break;
+ }
+ case hmi_apis::Common_SystemError::SYNC_OUT_OF_MEMMORY: {
+ usage_statistics::GlobalCounter count_sync_out_of_memory(
GetStatisticManager(), usage_statistics::SYNC_OUT_OF_MEMORY);
- ++count_sync_out_of_memory;
- break;
- }
- default: {
- LOG4CXX_WARN(logger_, "System error is unknown");
- }
+ ++count_sync_out_of_memory;
+ break;
+ }
+ default: { LOG4CXX_WARN(logger_, "System error is unknown"); }
}
}
-std::string PolicyHandler::GetAppName(const std::string& policy_app_id) {
+std::string PolicyHandler::GetAppName(const std::string &policy_app_id) {
ApplicationSharedPtr app =
- ApplicationManagerImpl::instance()
- ->application_by_policy_id(policy_app_id);
+ ApplicationManagerImpl::instance()->application_by_policy_id(
+ policy_app_id);
if (!app.valid()) {
- LOG4CXX_WARN(
- logger_,
- "Connection_key not found for application_id:" << policy_app_id);
+ LOG4CXX_WARN(logger_, "Connection_key not found for application_id:"
+ << policy_app_id);
return "";
}
- return app->name();
+ return app->name();
}
-void PolicyHandler::OnUpdateHMIAppType(std::map<std::string, StringArray> app_hmi_types) {
+void PolicyHandler::OnUpdateHMIAppType(
+ std::map<std::string, StringArray> app_hmi_types) {
LOG4CXX_AUTO_TRACE(logger_);
sync_primitives::AutoLock lock(listeners_lock_);
HandlersCollection::const_iterator it = listeners_.begin();
@@ -1191,7 +1161,7 @@ void PolicyHandler::OnUpdateHMIAppType(std::map<std::string, StringArray> app_hm
}
}
-void PolicyHandler::OnCertificateUpdated(const std::string& certificate_data) {
+void PolicyHandler::OnCertificateUpdated(const std::string &certificate_data) {
LOG4CXX_AUTO_TRACE(logger_);
sync_primitives::AutoLock lock(listeners_lock_);
HandlersCollection::const_iterator it = listeners_.begin();
@@ -1200,19 +1170,16 @@ void PolicyHandler::OnCertificateUpdated(const std::string& certificate_data) {
}
}
-bool PolicyHandler::CanUpdate() {
- return 0 != GetAppIdForSending();
-}
+bool PolicyHandler::CanUpdate() { return 0 != GetAppIdForSending(); }
-void PolicyHandler::RemoveDevice(const std::string& device_id) {
+void PolicyHandler::RemoveDevice(const std::string &device_id) {
LOG4CXX_AUTO_TRACE(logger_);
POLICY_LIB_CHECK_VOID();
policy_manager_->MarkUnpairedDevice(device_id);
-
}
-bool PolicyHandler::IsApplicationRevoked(const std::string& app_id) {
+bool PolicyHandler::IsApplicationRevoked(const std::string &app_id) {
LOG4CXX_TRACE(logger_, "PolicyHandler::IsApplicationRevoked");
POLICY_LIB_CHECK(false);
@@ -1225,36 +1192,36 @@ void PolicyHandler::OnUpdateRequestSentToMobile() {
policy_manager_->OnUpdateStarted();
}
-bool PolicyHandler::CheckKeepContext(const std::string& policy_app_id) {
+bool PolicyHandler::CheckKeepContext(const std::string &policy_app_id) {
POLICY_LIB_CHECK(false);
return policy_manager_->CanAppKeepContext(policy_app_id);
}
-bool PolicyHandler::CheckStealFocus(const std::string& policy_app_id) {
+bool PolicyHandler::CheckStealFocus(const std::string &policy_app_id) {
POLICY_LIB_CHECK(false);
return policy_manager_->CanAppStealFocus(policy_app_id);
}
bool PolicyHandler::CheckSystemAction(
mobile_apis::SystemAction::eType system_action,
- const std::string& policy_app_id) {
+ const std::string &policy_app_id) {
using namespace mobile_apis;
LOG4CXX_AUTO_TRACE(logger_);
switch (system_action) {
- case SystemAction::STEAL_FOCUS:
- return CheckStealFocus(policy_app_id);
- case SystemAction::KEEP_CONTEXT:
- return CheckKeepContext(policy_app_id);
- case SystemAction::DEFAULT_ACTION:
- return true;
- default:
- break;
+ case SystemAction::STEAL_FOCUS:
+ return CheckStealFocus(policy_app_id);
+ case SystemAction::KEEP_CONTEXT:
+ return CheckKeepContext(policy_app_id);
+ case SystemAction::DEFAULT_ACTION:
+ return true;
+ default:
+ break;
}
LOG4CXX_DEBUG(logger_, "Unknown system action");
return false;
}
-uint16_t PolicyHandler::HeartBeatTimeout(const std::string& app_id) const {
+uint16_t PolicyHandler::HeartBeatTimeout(const std::string &app_id) const {
POLICY_LIB_CHECK(0);
return policy_manager_->HeartBeatTimeout(app_id);
}
@@ -1281,13 +1248,17 @@ void policy::PolicyHandler::OnAppsSearchCompleted() {
policy_manager_->OnAppsSearchCompleted();
}
+void PolicyHandler::OnAppRegisteredOnMobile(const std::string &application_id) {
+ POLICY_LIB_CHECK_VOID();
+ policy_manager_->OnAppRegisteredOnMobile(application_id);
+}
+
bool PolicyHandler::IsRequestTypeAllowed(
- const std::string& policy_app_id,
+ const std::string &policy_app_id,
mobile_apis::RequestType::eType type) const {
POLICY_LIB_CHECK(false);
using namespace mobile_apis;
-
std::string stringified_type = RequestTypeToString(type);
if (stringified_type.empty()) {
LOG4CXX_ERROR(logger_, "Unknown request type.");
@@ -1307,8 +1278,8 @@ bool PolicyHandler::IsRequestTypeAllowed(
return request_types.end() != it;
}
-const std::vector<std::string> PolicyHandler::GetAppRequestTypes(
- const std::string& policy_app_id) const {
+const std::vector<std::string>
+PolicyHandler::GetAppRequestTypes(const std::string &policy_app_id) const {
POLICY_LIB_CHECK(std::vector<std::string>());
return policy_manager_->GetAppRequestTypes(policy_app_id);
}
@@ -1318,24 +1289,24 @@ void PolicyHandler::Increment(usage_statistics::GlobalCounterId type) {
policy_manager_->Increment(type);
}
-void PolicyHandler::Increment(const std::string& app_id, usage_statistics::AppCounterId type) {
+void PolicyHandler::Increment(const std::string &app_id,
+ usage_statistics::AppCounterId type) {
POLICY_LIB_CHECK();
policy_manager_->Increment(app_id, type);
}
-void PolicyHandler::Set(const std::string& app_id,
+void PolicyHandler::Set(const std::string &app_id,
usage_statistics::AppInfoId type,
- const std::string& value) {
+ const std::string &value) {
POLICY_LIB_CHECK();
policy_manager_->Set(app_id, type, value);
}
-void PolicyHandler::Add(const std::string& app_id,
+void PolicyHandler::Add(const std::string &app_id,
usage_statistics::AppStopwatchId type,
int32_t timespan_seconds) {
POLICY_LIB_CHECK();
policy_manager_->Add(app_id, type, timespan_seconds);
}
-} // namespace policy
-
+} // namespace policy
diff --git a/src/components/application_manager/src/state_controller.cc b/src/components/application_manager/src/state_controller.cc
index 720312adb3..05aaa2d2eb 100644
--- a/src/components/application_manager/src/state_controller.cc
+++ b/src/components/application_manager/src/state_controller.cc
@@ -39,17 +39,17 @@ namespace application_manager {
CREATE_LOGGERPTR_GLOBAL(logger_, "StateController");
-bool IsStatusChanged(HmiStatePtr old_state,
- HmiStatePtr new_state) {
- if (old_state->hmi_level() != new_state->hmi_level()
- || old_state->audio_streaming_state() != new_state->audio_streaming_state()
- || old_state->system_context() != new_state->system_context() ) {
+bool IsStatusChanged(HmiStatePtr old_state, HmiStatePtr new_state) {
+ if (old_state->hmi_level() != new_state->hmi_level() ||
+ old_state->audio_streaming_state() !=
+ new_state->audio_streaming_state() ||
+ old_state->system_context() != new_state->system_context()) {
return true;
}
return false;
}
-StateController::StateController():EventObserver() {
+StateController::StateController() : EventObserver() {
subscribe_on_event(hmi_apis::FunctionID::BasicCommunication_OnEmergencyEvent);
subscribe_on_event(hmi_apis::FunctionID::BasicCommunication_OnPhoneCall);
subscribe_on_event(hmi_apis::FunctionID::TTS_Started);
@@ -58,15 +58,16 @@ StateController::StateController():EventObserver() {
subscribe_on_event(hmi_apis::FunctionID::VR_Stopped);
}
-void StateController::SetRegularState(ApplicationSharedPtr app,
- const mobile_apis::AudioStreamingState::eType audio_state) {
+void StateController::SetRegularState(
+ ApplicationSharedPtr app,
+ const mobile_apis::AudioStreamingState::eType audio_state) {
if (!app) {
return;
}
HmiStatePtr prev_state = app->RegularHmiState();
DCHECK_OR_RETURN_VOID(prev_state);
- HmiStatePtr hmi_state = CreateHmiState(app->app_id(),
- HmiState::StateID::STATE_ID_REGULAR);
+ HmiStatePtr hmi_state =
+ CreateHmiState(app->app_id(), HmiState::StateID::STATE_ID_REGULAR);
DCHECK_OR_RETURN_VOID(hmi_state);
hmi_state->set_hmi_level(prev_state->hmi_level());
hmi_state->set_audio_streaming_state(audio_state);
@@ -74,26 +75,26 @@ void StateController::SetRegularState(ApplicationSharedPtr app,
SetRegularState<false>(app, hmi_state);
}
-void StateController::HmiLevelConflictResolver::operator ()
- (ApplicationSharedPtr to_resolve) {
+void StateController::HmiLevelConflictResolver::
+operator()(ApplicationSharedPtr to_resolve) {
using namespace mobile_apis;
using namespace helpers;
DCHECK_OR_RETURN_VOID(state_ctrl_);
if (to_resolve == applied_)
return;
- if (Compare<HMILevel::eType, EQ, ONE>(state_->hmi_level(),
- HMILevel::HMI_FULL,
+ if (Compare<HMILevel::eType, EQ, ONE>(state_->hmi_level(), HMILevel::HMI_FULL,
HMILevel::HMI_LIMITED)) {
HmiStatePtr cur_state = to_resolve->RegularHmiState();
if (Compare<HMILevel::eType, EQ, ONE>(cur_state->hmi_level(),
HMILevel::HMI_FULL,
HMILevel::HMI_LIMITED)) {
- if (applied_->IsAudioApplication() && state_ctrl_->IsSameAppType(applied_, to_resolve)) {
+ if (applied_->IsAudioApplication() &&
+ state_ctrl_->IsSameAppType(applied_, to_resolve)) {
state_ctrl_->SetupRegularHmiState(to_resolve, HMILevel::HMI_BACKGROUND,
- AudioStreamingState::NOT_AUDIBLE);
+ AudioStreamingState::NOT_AUDIBLE);
} else {
state_ctrl_->SetupRegularHmiState(to_resolve, HMILevel::HMI_LIMITED,
- AudioStreamingState::AUDIBLE);
+ AudioStreamingState::AUDIBLE);
}
}
}
@@ -104,12 +105,13 @@ void StateController::SetupRegularHmiState(ApplicationSharedPtr app,
using namespace mobile_apis;
LOG4CXX_AUTO_TRACE(logger_);
DCHECK_OR_RETURN_VOID(state);
- LOG4CXX_DEBUG(logger_, "hmi_level " << state->hmi_level() <<
- ", audio_state " << state->audio_streaming_state() <<
- ", system_context " << state->system_context());
+ LOG4CXX_DEBUG(logger_, "hmi_level " << state->hmi_level() << ", audio_state "
+ << state->audio_streaming_state()
+ << ", system_context "
+ << state->system_context());
HmiStatePtr curr_state = app->CurrentHmiState();
- HmiStatePtr old_state = CreateHmiState(app->app_id(),
- HmiState::StateID::STATE_ID_REGULAR);
+ HmiStatePtr old_state =
+ CreateHmiState(app->app_id(), HmiState::StateID::STATE_ID_REGULAR);
DCHECK_OR_RETURN_VOID(old_state);
old_state->set_hmi_level(curr_state->hmi_level());
old_state->set_audio_streaming_state(curr_state->audio_streaming_state());
@@ -124,8 +126,9 @@ void StateController::SetupRegularHmiState(ApplicationSharedPtr app,
state->set_hmi_level(HMILevel::HMI_BACKGROUND);
}
if (state->audio_streaming_state() != AudioStreamingState::NOT_AUDIBLE) {
- LOG4CXX_ERROR(logger_, "Trying to setup audio state " <<
- state->audio_streaming_state() <<" to non audio app");
+ LOG4CXX_ERROR(logger_, "Trying to setup audio state "
+ << state->audio_streaming_state()
+ << " to non audio app");
state->set_audio_streaming_state(AudioStreamingState::NOT_AUDIBLE);
}
}
@@ -133,17 +136,17 @@ void StateController::SetupRegularHmiState(ApplicationSharedPtr app,
OnStateChanged(app, old_state, new_state);
}
-void StateController::SetupRegularHmiState(ApplicationSharedPtr app,
- const mobile_apis::HMILevel::eType hmi_level,
- const mobile_apis::AudioStreamingState::eType audio_state) {
+void StateController::SetupRegularHmiState(
+ ApplicationSharedPtr app, const mobile_apis::HMILevel::eType hmi_level,
+ const mobile_apis::AudioStreamingState::eType audio_state) {
using namespace mobile_apis;
using namespace helpers;
LOG4CXX_AUTO_TRACE(logger_);
DCHECK_OR_RETURN_VOID(app);
HmiStatePtr prev_state = app->RegularHmiState();
DCHECK_OR_RETURN_VOID(prev_state);
- HmiStatePtr new_state = CreateHmiState(app->app_id(),
- HmiState::StateID::STATE_ID_REGULAR);
+ HmiStatePtr new_state =
+ CreateHmiState(app->app_id(), HmiState::StateID::STATE_ID_REGULAR);
DCHECK_OR_RETURN_VOID(new_state);
new_state->set_hmi_level(hmi_level);
new_state->set_audio_streaming_state(audio_state);
@@ -152,73 +155,74 @@ void StateController::SetupRegularHmiState(ApplicationSharedPtr app,
}
void StateController::ApplyRegularState(ApplicationSharedPtr app,
- HmiStatePtr state) {
+ HmiStatePtr state) {
DCHECK_OR_RETURN_VOID(app);
DCHECK_OR_RETURN_VOID(state);
DCHECK_OR_RETURN_VOID(state->state_id() == HmiState::STATE_ID_REGULAR);
SetupRegularHmiState(app, state);
- ForEachApplication<HmiLevelConflictResolver, ApplicationManagerImpl>
- (HmiLevelConflictResolver(app, state, this));
+ ForEachApplication<HmiLevelConflictResolver, ApplicationManagerImpl>(
+ HmiLevelConflictResolver(app, state, this));
}
bool StateController::IsSameAppType(ApplicationConstSharedPtr app1,
- ApplicationConstSharedPtr app2) {
- return app1->is_media_application() == app2->is_media_application() ||
- app1->is_navi() == app2->is_navi() ||
- app1->is_voice_communication_supported() == app2->is_voice_communication_supported();
+ ApplicationConstSharedPtr app2) {
+ return app1->is_media_application() == app2->is_media_application() ||
+ app1->is_navi() == app2->is_navi() ||
+ app1->is_voice_communication_supported() ==
+ app2->is_voice_communication_supported();
}
-void StateController::on_event(const event_engine::Event& event) {
+void StateController::on_event(const event_engine::Event &event) {
using namespace smart_objects;
using namespace event_engine;
using namespace hmi_apis;
LOG4CXX_AUTO_TRACE(logger_);
- const SmartObject& message = event.smart_object();
- const FunctionID::eType id = static_cast<FunctionID::eType> (event.id());
+ const SmartObject &message = event.smart_object();
+ const FunctionID::eType id = static_cast<FunctionID::eType>(event.id());
switch (id) {
- case FunctionID::BasicCommunication_ActivateApp: {
- OnActivateAppResponse(message);
- break;
- }
- case FunctionID::BasicCommunication_OnEmergencyEvent: {
- bool is_active =
- message[strings::msg_params][hmi_response::enabled].asBool();
- if (is_active) {
- OnSafetyModeEnabled();
- } else {
- OnSafetyModeDisabled();
- }
- break;
- }
- case FunctionID::BasicCommunication_OnPhoneCall: {
- bool is_active =
- message[strings::msg_params][hmi_notification::is_active].asBool();
- if (is_active) {
- OnPhoneCallStarted();
- } else {
- OnPhoneCallEnded();
- }
- break;
- }
- case FunctionID::VR_Started: {
- OnVRStarted();
- break;
- }
- case FunctionID::VR_Stopped: {
- OnVREnded();
- break;
- }
- case FunctionID::TTS_Started: {
- OnTTSStarted();
- break;
+ case FunctionID::BasicCommunication_ActivateApp: {
+ OnActivateAppResponse(message);
+ break;
+ }
+ case FunctionID::BasicCommunication_OnEmergencyEvent: {
+ bool is_active =
+ message[strings::msg_params][hmi_response::enabled].asBool();
+ if (is_active) {
+ OnSafetyModeEnabled();
+ } else {
+ OnSafetyModeDisabled();
}
- case FunctionID::TTS_Stopped: {
- OnTTSStopped();
- break;
+ break;
+ }
+ case FunctionID::BasicCommunication_OnPhoneCall: {
+ bool is_active =
+ message[strings::msg_params][hmi_notification::is_active].asBool();
+ if (is_active) {
+ OnPhoneCallStarted();
+ } else {
+ OnPhoneCallEnded();
}
- default:
- break;
+ break;
+ }
+ case FunctionID::VR_Started: {
+ OnVRStarted();
+ break;
+ }
+ case FunctionID::VR_Stopped: {
+ OnVREnded();
+ break;
+ }
+ case FunctionID::TTS_Started: {
+ OnTTSStarted();
+ break;
+ }
+ case FunctionID::TTS_Stopped: {
+ OnTTSStopped();
+ break;
+ }
+ default:
+ break;
}
}
@@ -233,19 +237,25 @@ void StateController::OnStateChanged(ApplicationSharedPtr app,
if (new_state->hmi_level() == mobile_apis::HMILevel::HMI_NONE) {
app->ResetDataInNone();
}
- ApplicationManagerImpl::instance()->OnHMILevelChanged(app->app_id(),
- old_state->hmi_level(), new_state->hmi_level());
+ ApplicationManagerImpl::instance()->OnHMILevelChanged(
+ app->app_id(), old_state->hmi_level(), new_state->hmi_level());
} else {
LOG4CXX_ERROR(logger_, "Status not changed");
}
}
-void StateController::ApplyStatesForApp(ApplicationSharedPtr app) {
+void StateController::OnApplicationRegistered(
+ ApplicationSharedPtr app,
+ const mobile_apis::HMILevel::eType default_level) {
+ namespace HMILevel = mobile_apis::HMILevel;
+ namespace AudioStreamingState = mobile_apis::AudioStreamingState;
+ namespace SystemContext = mobile_apis::SystemContext;
LOG4CXX_AUTO_TRACE(logger_);
- sync_primitives::AutoLock autolock(active_states_lock_);
DCHECK_OR_RETURN_VOID(app);
+
+ active_states_lock_.Acquire();
StateIDList::iterator it = active_states_.begin();
- for(; it != active_states_.end(); ++it) {
+ for (; it != active_states_.end(); ++it) {
HmiStatePtr new_state = CreateHmiState(app->app_id(), *it);
DCHECK_OR_RETURN_VOID(new_state);
DCHECK_OR_RETURN_VOID(new_state->state_id() != HmiState::STATE_ID_REGULAR);
@@ -253,7 +263,22 @@ void StateController::ApplyStatesForApp(ApplicationSharedPtr app) {
new_state->set_parent(old_hmi_state);
app->AddHMIState(new_state);
}
+ active_states_lock_.Release();
+
+ HmiStatePtr default_state =
+ CreateHmiState(app->app_id(), HmiState::StateID::STATE_ID_REGULAR);
+ DCHECK_OR_RETURN_VOID(default_state);
+ default_state->set_hmi_level(default_level);
+ default_state->set_audio_streaming_state(CalcAudioState(app, default_level));
+ default_state->set_system_context(SystemContext::SYSCTXT_MAIN);
+
+ HmiStatePtr initial_state = app->RegularHmiState();
+ app->SetRegularState(default_state);
+
+ HmiStatePtr new_state = app->CurrentHmiState();
+
+ OnStateChanged(app, initial_state, new_state);
}
void StateController::TempStateStarted(HmiState::StateID ID) {
@@ -262,9 +287,9 @@ void StateController::TempStateStarted(HmiState::StateID ID) {
StateIDList::iterator it =
std::find(active_states_.begin(), active_states_.end(), ID);
if (it == active_states_.end()) {
- active_states_.push_back(ID);
+ active_states_.push_back(ID);
} else {
- LOG4CXX_ERROR(logger_, "StateID " << ID <<" is already active");
+ LOG4CXX_ERROR(logger_, "StateID " << ID << " is already active");
}
}
@@ -274,16 +299,16 @@ void StateController::TempStateStopped(HmiState::StateID ID) {
active_states_.remove(ID);
}
void StateController::OnActivateAppResponse(
- const smart_objects::SmartObject& message) {
+ const smart_objects::SmartObject &message) {
const hmi_apis::Common_Result::eType code =
static_cast<hmi_apis::Common_Result::eType>(
- message[strings::params][hmi_response::code].asInt());
- const int32_t correlation_id = message[strings::params]
- [strings::correlation_id].asInt();
- const uint32_t hmi_app_id = ApplicationManagerImpl::instance()->
- application_id(correlation_id);
- ApplicationSharedPtr application = ApplicationManagerImpl::instance()->
- application_by_hmi_app(hmi_app_id);
+ message[strings::params][hmi_response::code].asInt());
+ const int32_t correlation_id =
+ message[strings::params][strings::correlation_id].asInt();
+ const uint32_t hmi_app_id =
+ ApplicationManagerImpl::instance()->application_id(correlation_id);
+ ApplicationSharedPtr application =
+ ApplicationManagerImpl::instance()->application_by_hmi_app(hmi_app_id);
if (application) {
HmiStatePtr pending_state = waiting_for_activate[application->app_id()];
DCHECK_OR_RETURN_VOID(pending_state);
@@ -295,34 +320,30 @@ void StateController::OnActivateAppResponse(
}
}
-
void StateController::OnPhoneCallStarted() {
LOG4CXX_AUTO_TRACE(logger_);
ForEachApplication(std::bind1st(
- std::mem_fun(
- &StateController::HMIStateStarted<HmiState::STATE_ID_PHONE_CALL>),
- this)
- );
+ std::mem_fun(
+ &StateController::HMIStateStarted<HmiState::STATE_ID_PHONE_CALL>),
+ this));
TempStateStarted(HmiState::STATE_ID_PHONE_CALL);
}
void StateController::OnPhoneCallEnded() {
LOG4CXX_AUTO_TRACE(logger_);
ForEachApplication(std::bind1st(
- std::mem_fun(
- &StateController::HMIStateStopped<HmiState::STATE_ID_PHONE_CALL>),
- this)
- );
+ std::mem_fun(
+ &StateController::HMIStateStopped<HmiState::STATE_ID_PHONE_CALL>),
+ this));
TempStateStopped(HmiState::STATE_ID_PHONE_CALL);
}
void StateController::OnSafetyModeEnabled() {
LOG4CXX_AUTO_TRACE(logger_);
ForEachApplication(std::bind1st(
- std::mem_fun(
- &StateController::HMIStateStarted<HmiState::STATE_ID_SAFETY_MODE>),
- this)
- );
+ std::mem_fun(
+ &StateController::HMIStateStarted<HmiState::STATE_ID_SAFETY_MODE>),
+ this));
TempStateStarted(HmiState::STATE_ID_SAFETY_MODE);
}
@@ -330,107 +351,119 @@ void StateController::OnSafetyModeDisabled() {
LOG4CXX_AUTO_TRACE(logger_);
ForEachApplication(std::bind1st(
- std::mem_fun(
- &StateController::HMIStateStopped<HmiState::STATE_ID_SAFETY_MODE>),
- this)
- );
+ std::mem_fun(
+ &StateController::HMIStateStopped<HmiState::STATE_ID_SAFETY_MODE>),
+ this));
TempStateStopped(HmiState::STATE_ID_SAFETY_MODE);
}
void StateController::OnVRStarted() {
LOG4CXX_AUTO_TRACE(logger_);
ForEachApplication(std::bind1st(
- std::mem_fun(
- &StateController::HMIStateStarted<HmiState::STATE_ID_VR_SESSION>),
- this)
- );
+ std::mem_fun(
+ &StateController::HMIStateStarted<HmiState::STATE_ID_VR_SESSION>),
+ this));
TempStateStarted(HmiState::STATE_ID_VR_SESSION);
}
void StateController::OnVREnded() {
LOG4CXX_AUTO_TRACE(logger_);
ForEachApplication(std::bind1st(
- std::mem_fun(
- &StateController::HMIStateStopped<HmiState::STATE_ID_VR_SESSION>),
- this)
- );
+ std::mem_fun(
+ &StateController::HMIStateStopped<HmiState::STATE_ID_VR_SESSION>),
+ this));
TempStateStopped(HmiState::STATE_ID_VR_SESSION);
}
void StateController::OnTTSStarted() {
LOG4CXX_AUTO_TRACE(logger_);
ForEachApplication(std::bind1st(
- std::mem_fun(
- &StateController::HMIStateStarted<HmiState::STATE_ID_TTS_SESSION>),
- this)
- );
- TempStateStarted(HmiState::STATE_ID_TTS_SESSION);
+ std::mem_fun(
+ &StateController::HMIStateStarted<HmiState::STATE_ID_TTS_SESSION>),
+ this));
+ TempStateStarted(HmiState::STATE_ID_TTS_SESSION);
}
void StateController::OnTTSStopped() {
LOG4CXX_AUTO_TRACE(logger_);
ForEachApplication(std::bind1st(
- std::mem_fun(
- &StateController::HMIStateStopped<HmiState::STATE_ID_TTS_SESSION>),
- this)
- );
+ std::mem_fun(
+ &StateController::HMIStateStopped<HmiState::STATE_ID_TTS_SESSION>),
+ this));
TempStateStopped(HmiState::STATE_ID_TTS_SESSION);
}
void StateController::OnNaviStreamingStarted() {
LOG4CXX_AUTO_TRACE(logger_);
ForEachApplication(std::bind1st(
- std::mem_fun(
- &StateController::HMIStateStarted<HmiState::STATE_ID_NAVI_STREAMING>),
- this)
- );
- TempStateStarted(HmiState::STATE_ID_NAVI_STREAMING);
+ std::mem_fun(
+ &StateController::HMIStateStarted<HmiState::STATE_ID_NAVI_STREAMING>),
+ this));
+ TempStateStarted(HmiState::STATE_ID_NAVI_STREAMING);
}
void StateController::OnNaviStreamingStopped() {
LOG4CXX_AUTO_TRACE(logger_);
ForEachApplication(std::bind1st(
- std::mem_fun(
- &StateController::HMIStateStopped<HmiState::STATE_ID_NAVI_STREAMING>),
- this)
- );
+ std::mem_fun(
+ &StateController::HMIStateStopped<HmiState::STATE_ID_NAVI_STREAMING>),
+ this));
TempStateStopped(HmiState::STATE_ID_NAVI_STREAMING);
}
-HmiStatePtr StateController::CreateHmiState(uint32_t app_id, HmiState::StateID state_id) {
+HmiStatePtr StateController::CreateHmiState(uint32_t app_id,
+ HmiState::StateID state_id) {
LOG4CXX_AUTO_TRACE(logger_);
HmiStatePtr new_state;
switch (state_id) {
- case HmiState::STATE_ID_PHONE_CALL: {
- new_state.reset(new PhoneCallHmiState(app_id, state_context_));
- break;
- }
- case HmiState::STATE_ID_SAFETY_MODE: {
- new_state.reset(new SafetyModeHmiState(app_id, state_context_));
- break;
- }
- case HmiState::STATE_ID_VR_SESSION: {
- new_state.reset(new VRHmiState(app_id, state_context_));
- break;
- }
- case HmiState::STATE_ID_TTS_SESSION: {
- new_state.reset(new TTSHmiState(app_id, state_context_));
- break;
- }
- case HmiState::STATE_ID_NAVI_STREAMING: {
- new_state.reset(new NaviStreamingHmiState(app_id, state_context_));
- break;
- }
- case HmiState::STATE_ID_REGULAR: {
- new_state.reset(new HmiState(app_id, state_context_));
- break;
- }
- default:
- LOG4CXX_FATAL(logger_, "Invalid state_id " << state_id);
- NOTREACHED();
- break;
+ case HmiState::STATE_ID_PHONE_CALL: {
+ new_state.reset(new PhoneCallHmiState(app_id, state_context_));
+ break;
+ }
+ case HmiState::STATE_ID_SAFETY_MODE: {
+ new_state.reset(new SafetyModeHmiState(app_id, state_context_));
+ break;
+ }
+ case HmiState::STATE_ID_VR_SESSION: {
+ new_state.reset(new VRHmiState(app_id, state_context_));
+ break;
+ }
+ case HmiState::STATE_ID_TTS_SESSION: {
+ new_state.reset(new TTSHmiState(app_id, state_context_));
+ break;
+ }
+ case HmiState::STATE_ID_NAVI_STREAMING: {
+ new_state.reset(new NaviStreamingHmiState(app_id, state_context_));
+ break;
+ }
+ case HmiState::STATE_ID_REGULAR: {
+ new_state.reset(new HmiState(app_id, state_context_));
+ break;
+ }
+ default:
+ LOG4CXX_FATAL(logger_, "Invalid state_id " << state_id);
+ NOTREACHED();
+ break;
}
return new_state;
}
+mobile_apis::AudioStreamingState::eType StateController::CalcAudioState(
+ ApplicationSharedPtr app,
+ const mobile_apis::HMILevel::eType hmi_level) const {
+ namespace HMILevel = mobile_apis::HMILevel;
+ namespace AudioStreamingState = mobile_apis::AudioStreamingState;
+ using helpers::Compare;
+ using helpers::EQ;
+ using helpers::ONE;
+
+ AudioStreamingState::eType audio_state = AudioStreamingState::NOT_AUDIBLE;
+ if (Compare<HMILevel::eType, EQ, ONE>(hmi_level, HMILevel::HMI_FULL,
+ HMILevel::HMI_LIMITED)) {
+ if (app->IsAudioApplication()) {
+ audio_state = AudioStreamingState::AUDIBLE;
+ }
+ }
+ return audio_state;
+}
}
diff --git a/src/components/policy/src/policy/include/policy/policy_listener.h b/src/components/policy/src/policy/include/policy/policy_listener.h
index 332b50521d..9046af4201 100644
--- a/src/components/policy/src/policy/include/policy/policy_listener.h
+++ b/src/components/policy/src/policy/include/policy/policy_listener.h
@@ -1,5 +1,5 @@
/*
- Copyright (c) 2013, Ford Motor Company
+ Copyright (c) 2016, Ford Motor Company
All rights reserved.
Redistribution and use in source and binary forms, with or without
@@ -39,29 +39,29 @@
namespace policy {
class PolicyListener {
- public:
- virtual ~PolicyListener() {
- }
- virtual void OnPermissionsUpdated(const std::string& policy_app_id,
- const Permissions& permissions,
- const policy::HMILevel& default_hmi) = 0;
- virtual void OnPermissionsUpdated(const std::string& policy_app_id,
- const Permissions& permissions) = 0;
- virtual void OnPendingPermissionChange(const std::string& policy_app_id) = 0;
- virtual void OnUpdateStatusChanged(const std::string&) = 0;
- virtual std::string OnCurrentDeviceIdUpdateRequired(
- const std::string& policy_app_id) = 0;
+public:
+ virtual ~PolicyListener() {}
+ virtual void OnPermissionsUpdated(const std::string &policy_app_id,
+ const Permissions &permissions,
+ const policy::HMILevel &default_hmi) = 0;
+ virtual void OnPermissionsUpdated(const std::string &policy_app_id,
+ const Permissions &permissions) = 0;
+ virtual void OnPendingPermissionChange(const std::string &policy_app_id) = 0;
+ virtual void OnUpdateStatusChanged(const std::string &) = 0;
+ virtual std::string
+ OnCurrentDeviceIdUpdateRequired(const std::string &policy_app_id) = 0;
virtual void OnSystemInfoUpdateRequired() = 0;
- virtual std::string GetAppName(const std::string& policy_app_id) = 0;
- virtual void OnUpdateHMIAppType(std::map<std::string, StringArray> app_hmi_types) = 0;
+ virtual std::string GetAppName(const std::string &policy_app_id) = 0;
+ virtual void
+ OnUpdateHMIAppType(std::map<std::string, StringArray> app_hmi_types) = 0;
- /**
- * @brief CanUpdate allows to find active application
- * and check whether related device consented.
- *
- * @return true if there are at least one application has been registered
- * with consented device.
- */
+ /**
+ * @brief CanUpdate allows to find active application
+ * and check whether related device consented.
+ *
+ * @return true if there are at least one application has been registered
+ * with consented device.
+ */
virtual bool CanUpdate() = 0;
/**
@@ -69,8 +69,9 @@ class PolicyListener {
* when snapshot for PTU has been created.
*
* @param pt_string the snapshot
+ *
*/
- virtual void OnSnapshotCreated(const BinaryMessage& pt_string) = 0;
+ virtual void OnSnapshotCreated(const BinaryMessage &pt_string) = 0;
/**
* @brief Make appropriate changes for related applications permissions and
@@ -78,13 +79,13 @@ class PolicyListener {
* @param device_id Unique device id, which consent had been changed
* @param device_consent Device consent, which is done by user
*/
- virtual void OnDeviceConsentChanged(const std::string& device_id,
+ virtual void OnDeviceConsentChanged(const std::string &device_id,
bool is_allowed) = 0;
/**
* @brief GetAvailableApps allows to obtain list of registered applications.
*/
- virtual void GetAvailableApps(std::queue<std::string>&) = 0;
+ virtual void GetAvailableApps(std::queue<std::string> &) = 0;
/**
* @brief OnCertificateUpdated the callback which signals if certificate field
@@ -92,7 +93,7 @@ class PolicyListener {
*
* @param certificate_data the value of the updated field.
*/
- virtual void OnCertificateUpdated(const std::string& certificate_data) = 0;
+ virtual void OnCertificateUpdated(const std::string &certificate_data) = 0;
};
-} // namespace policy
-#endif // SRC_COMPONENTS_POLICY_INCLUDE_POLICY_LISTENER_H_
+} // namespace policy
+#endif // SRC_COMPONENTS_POLICY_INCLUDE_POLICY_LISTENER_H_
diff --git a/src/components/policy/src/policy/include/policy/policy_manager.h b/src/components/policy/src/policy/include/policy/policy_manager.h
index 4a31df4437..0a62c94e7d 100644
--- a/src/components/policy/src/policy/include/policy/policy_manager.h
+++ b/src/components/policy/src/policy/include/policy/policy_manager.h
@@ -1,5 +1,5 @@
/*
- Copyright (c) 2013, Ford Motor Company
+ Copyright (c) 2016, Ford Motor Company
All rights reserved.
Redistribution and use in source and binary forms, with or without
@@ -34,6 +34,7 @@
#define SRC_COMPONENTS_POLICY_INCLUDE_POLICY_POLICY_MANAGER_H_
#include <vector>
+#include <cstdint>
#include "policy/policy_types.h"
#include "policy/policy_listener.h"
@@ -41,398 +42,412 @@
namespace policy {
class PolicyManager : public usage_statistics::StatisticsManager {
- public:
- virtual ~PolicyManager() {
- }
-
- virtual void set_listener(PolicyListener* listener) = 0;
-
- /**
- * Inits Policy Table
- * @param file_name Path to preloaded PT file
- * @return true if successfully
- */
- virtual bool InitPT(const std::string& file_name) = 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 bool Success of operation
- */
- virtual bool LoadPT(const std::string& file, const BinaryMessage& pt_content) = 0;
-
- /**
- * 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 GetLockScreenIcon allows to obtain lock screen icon url;
- *
- * @return url which point to the resourse where lock screen icon could be obtained.
- */
- virtual std::string GetLockScreenIconUrl() const = 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 GetServiceUrls(const std::string& service_type,
- EndpointUrls& end_points) = 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 app_id Id of application provided during registration
- * @param hmi_level Current HMI Level of application
- * @param rpc Name of RPC
- * @param CheckPermissionResult containing flag if HMI Level is allowed
- * and list of allowed params.
- */
- virtual void CheckPermissions(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;
-
- /**
- * Checks is PT exceeded kilometers
- * @param kilometers current kilometers at odometer
- * @return true if exceeded
- */
- virtual void KmsChanged(int kilometers) = 0;
-
- /**
- * Increments counter of ignition cycles
- */
- virtual void IncrementIgnitionCycles() = 0;
-
- /**
- * @brief ExchangeByUserRequest
- */
- virtual std::string ForcePTExchange() = 0;
-
- /**
- * Resets retry sequence
- */
- virtual void ResetRetrySequence() = 0;
-
- /**
- * 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;
-
- /**
- * Gets timeout to wait until receive response
- * @return timeout in seconds
- */
- virtual int TimeoutExchange() = 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;
-
- /**
- * Handler of exceeding timeout of exchanging policy table
- */
- virtual void OnExceededTimeout() = 0;
-
- /**
- * @brief Handler of PTS sending out
- */
- virtual void OnUpdateStarted() = 0;
-
- /**
- * @brief Check 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) = 0;
-
- /**
- * @brief Get 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,
- bool is_allowed) = 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;
- /**
- * Sets number of kilometers and days after epoch, that passed for
- * receiving PT UPdate.
- */
- virtual void PTUpdatedAt(int kilometers, int days_after_epoch) = 0;
-
- /**
- * @brief Retrieves data from app_policies about app on its registration:
- * @param app_id - id of registered app
- * @param app_types Section on HMI where app can appear (Navigation, Phone etc)
- * @param nicknames Synonyms for application
- */
- virtual bool GetInitialAppData(const std::string& application_id,
- StringArray* nicknames = NULL,
- StringArray* app_hmi_types = NULL) = 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.
- */
- virtual void SetUserConsentForApp(const PermissionConsent& permissions) = 0;
-
- /**
- * @brief Get default HMI level for 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 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) = 0;
-
- /**
- * @brief Get user friendly messages for given RPC messages and language
- * @param message_codes RPC message codes
- * @param language 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) = 0;
-
- /**
- * 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 policy_app_id Unique application id
- * @return Permissions changes
- */
- virtual AppPermissions GetAppPermissionsChanges(
- const std::string& policy_app_id) = 0;
-
- virtual void RemovePendingPermissionChanges(const std::string& app_id) = 0;
-
- /**
- * @brief Return device id, which hosts specific application
- * @param Application id, which is required to update device id
- */
- virtual std::string& GetCurrentDeviceId(const std::string& policy_app_id) = 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 application_id
- */
- virtual void SendNotificationOnPermissionsUpdated(
- const std::string& application_id) = 0;
-
- /**
- * 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 Application id assigned by Ford to the application
- */
- virtual void AddApplication(const std::string& application_id) = 0;
-
- /**
- * @brief Removes unpaired device records and related records from DB
- * @param device_ids List of device_id, which should be removed
- * @return true, if succedeed, otherwise - false
- */
- virtual bool CleanupUnpairedDevices() = 0;
-
- /**
- * @brief Check if app can keep context.
- */
- virtual bool CanAppKeepContext(const std::string& app_id) = 0;
-
- /**
- * @brief Check if app can steal focus.
- */
- virtual bool CanAppStealFocus(const std::string& app_id) = 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 GetNotificationNumber
- * @param priority
- * @return
- */
- virtual uint32_t GetNotificationsNumber(const std::string& priority) = 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) = 0;
-
- /**
- * Returns heart beat timeout
- * @param app_id application id
- * @return if timeout was set then value in seconds greater zero
- * otherwise heart beat for specific application isn't set
- */
- virtual uint16_t HeartBeatTimeout(const std::string& app_id) const = 0;
-
- /**
- * @brief SaveUpdateStatusRequired alows to save update status.
- */
- virtual void SaveUpdateStatusRequired(bool is_update_needed) = 0;
-
- /**
- * @brief Handler on applications search started
- */
- virtual void OnAppsSearchStarted() = 0;
-
- /**
- * @brief Handler on applications search completed
- */
- virtual void OnAppsSearchCompleted() = 0;
- /**
- * @brief Gets request types for application
- * @param policy_app_id Unique application id
- * @return request_types Request types of application
- */
- virtual const std::vector<std::string> GetAppRequestTypes(
- const std::string policy_app_id) const = 0;
-
- protected:
- /**
- * Checks is PT exceeded IgnitionCycles
- * @return true if exceeded
- */
- virtual bool ExceededIgnitionCycles() = 0;
-
- /**
- * 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;
+
+public:
+ virtual ~PolicyManager() {}
+
+ virtual void set_listener(PolicyListener *listener) = 0;
+
+ /**
+ * Inits Policy Table
+ * @param file_name Path to preloaded PT file
+ * @return true if successfully
+ */
+ virtual bool InitPT(const std::string &file_name) = 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 bool Success of operation
+ */
+ virtual bool LoadPT(const std::string &file,
+ const BinaryMessage &pt_content) = 0;
+
+ /**
+ * 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 GetLockScreenIcon allows to obtain lock screen icon url;
+ *
+ * @return url which point to the resourse where lock screen icon could be
+ *obtained.
+ */
+ virtual std::string GetLockScreenIconUrl() const = 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 GetServiceUrls(const std::string &service_type,
+ EndpointUrls &end_points) = 0;
+
+ /**
+ * @brief PTU is needed, for this PTS has to be formed and sent.
+ */
+ virtual bool 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 app_id Id of application provided during registration
+ * @param hmi_level Current HMI Level of application
+ * @param rpc Name of RPC
+ * @param CheckPermissionResult containing flag if HMI Level is allowed
+ * and list of allowed params.
+ */
+ virtual void CheckPermissions(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;
+
+ /**
+ * Checks is PT exceeded kilometers
+ * @param kilometers current kilometers at odometer
+ * @return true if exceeded
+ */
+ virtual void KmsChanged(int kilometers) = 0;
+
+ /**
+ * Increments counter of ignition cycles
+ */
+ virtual void IncrementIgnitionCycles() = 0;
+
+ /**
+ * @brief ExchangeByUserRequest
+ */
+ virtual std::string ForcePTExchange() = 0;
+
+ /**
+ * Resets retry sequence
+ */
+ virtual void ResetRetrySequence() = 0;
+
+ /**
+ * Gets timeout to wait before next retry updating PT
+ * If timeout is equal to zero then the retry sequence is not need.
+ * @return timeout in seconds
+ */
+ virtual uint32_t NextRetryTimeout() = 0;
+
+ /**
+ * Gets timeout to wait until receive response
+ * @return timeout in seconds
+ */
+ virtual int TimeoutExchange() = 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;
+
+ /**
+ * Handler of exceeding timeout of exchanging policy table
+ */
+ virtual void OnExceededTimeout() = 0;
+
+ /**
+ * @brief Handler of PTS sending out
+ */
+ virtual void OnUpdateStarted() = 0;
+
+ /**
+ * @brief Check 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) = 0;
+
+ /**
+ * @brief Get 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,
+ bool is_allowed) = 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;
+ /**
+ * Sets number of kilometers and days after epoch, that passed for
+ * receiving PT UPdate.
+ */
+ virtual void PTUpdatedAt(int kilometers, int days_after_epoch) = 0;
+
+ /**
+ * @brief Retrieves data from app_policies about app on its registration:
+ * @param app_id - id of registered app
+ * @param app_types Section on HMI where app can appear (Navigation, Phone
+ * etc)
+ * @param nicknames Synonyms for application
+ */
+ virtual bool GetInitialAppData(const std::string &application_id,
+ StringArray *nicknames = NULL,
+ StringArray *app_hmi_types = NULL) = 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.
+ */
+ virtual void SetUserConsentForApp(const PermissionConsent &permissions) = 0;
+
+ /**
+ * @brief Get default HMI level for 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 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) = 0;
+
+ /**
+ * @brief Get user friendly messages for given RPC messages and language
+ * @param message_codes RPC message codes
+ * @param language 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) = 0;
+
+ /**
+ * 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 policy_app_id Unique application id
+ * @return Permissions changes
+ */
+ virtual AppPermissions
+ GetAppPermissionsChanges(const std::string &policy_app_id) = 0;
+
+ virtual void RemovePendingPermissionChanges(const std::string &app_id) = 0;
+
+ /**
+ * @brief Return device id, which hosts specific application
+ * @param Application id, which is required to update device id
+ */
+ virtual std::string &GetCurrentDeviceId(const std::string &policy_app_id) = 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 application_id
+ */
+ virtual void
+ SendNotificationOnPermissionsUpdated(const std::string &application_id) = 0;
+
+ /**
+ * 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 Application id assigned by Ford to the application
+ */
+ virtual void AddApplication(const std::string &application_id) = 0;
+
+ /**
+ * @brief Removes unpaired device records and related records from DB
+ * @param device_ids List of device_id, which should be removed
+ * @return true, if succedeed, otherwise - false
+ */
+ virtual bool CleanupUnpairedDevices() = 0;
+
+ /**
+ * @brief Check if app can keep context.
+ */
+ virtual bool CanAppKeepContext(const std::string &app_id) = 0;
+
+ /**
+ * @brief Check if app can steal focus.
+ */
+ virtual bool CanAppStealFocus(const std::string &app_id) = 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 GetNotificationNumber
+ * @param priority
+ * @return
+ */
+ virtual uint32_t GetNotificationsNumber(const std::string &priority) = 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) = 0;
+
+ /**
+ * Returns heart beat timeout
+ * @param app_id application id
+ * @return if timeout was set then value in seconds greater zero
+ * otherwise heart beat for specific application isn't set
+ */
+ virtual uint16_t HeartBeatTimeout(const std::string &app_id) const = 0;
+
+ /**
+ * @brief SaveUpdateStatusRequired alows to save update status.
+ */
+ virtual void SaveUpdateStatusRequired(bool is_update_needed) = 0;
+
+ /**
+ * @brief Handler on applications search started
+ */
+ virtual void OnAppsSearchStarted() = 0;
+
+ /**
+ * @brief Handler on applications search completed
+ */
+ virtual void OnAppsSearchCompleted() = 0;
+
+ /**
+ * @brief OnAppRegisteredOnMobile alows to handle event when application were
+ * succesfully registered on mobile device.
+ * It will send OnAppPermissionSend notification and will try to start PTU.
+ *
+ * @param application_id registered application.
+ */
+ virtual void OnAppRegisteredOnMobile(const std::string &application_id) = 0;
+
+ /**
+ * @brief Gets request types for application
+ * @param policy_app_id Unique application id
+ * @return request_types Request types of application
+ */
+ virtual const std::vector<std::string>
+ GetAppRequestTypes(const std::string policy_app_id) const = 0;
+
+protected:
+ /**
+ * Checks is PT exceeded IgnitionCycles
+ * @return true if exceeded
+ */
+ virtual bool ExceededIgnitionCycles() = 0;
+
+ /**
+ * 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
+} // namespace policy
-extern "C" policy::PolicyManager* CreateManager();
+extern "C" policy::PolicyManager *CreateManager();
-#endif // SRC_COMPONENTS_POLICY_INCLUDE_POLICY_POLICY_MANAGER_H_
+#endif // SRC_COMPONENTS_POLICY_INCLUDE_POLICY_POLICY_MANAGER_H_
diff --git a/src/components/policy/src/policy/include/policy/policy_manager_impl.h b/src/components/policy/src/policy/include/policy/policy_manager_impl.h
index 50f9cf1481..78688c8fd5 100644
--- a/src/components/policy/src/policy/include/policy/policy_manager_impl.h
+++ b/src/components/policy/src/policy/include/policy/policy_manager_impl.h
@@ -1,5 +1,5 @@
/*
- Copyright (c) 2013, Ford Motor Company
+ Copyright (c) 2016, Ford Motor Company
All rights reserved.
Redistribution and use in source and binary forms, with or without
@@ -34,6 +34,8 @@
#define SRC_COMPONENTS_POLICY_INCLUDE_POLICY_POLICY_MANAGER_IMPL_H_
#include <list>
+#include <cstdint>
+
#include "utils/shared_ptr.h"
#include "utils/lock.h"
#include "policy/policy_manager.h"
@@ -42,6 +44,8 @@
#include "policy/update_status_manager.h"
#include "./functions.h"
#include "usage_statistics/statistics_manager.h"
+#include "policy/policy_helper.h"
+#include "utils/timer_thread.h"
namespace policy_table = rpc::policy_table_interface_base;
@@ -49,270 +53,280 @@ namespace policy {
struct CheckAppPolicy;
class PolicyManagerImpl : public PolicyManager {
- public:
- PolicyManagerImpl();
- virtual void set_listener(PolicyListener* listener);
- PolicyListener* listener() const {
- return listener_;
- }
- virtual bool InitPT(const std::string& file_name);
- virtual bool LoadPT(const std::string& file, const BinaryMessage& pt_content);
- virtual bool ResetPT(const std::string& file_name);
-
- virtual void GetServiceUrls(const std::string& service_type,
- EndpointUrls& end_points);
-
- virtual std::string GetLockScreenIconUrl() const;
- virtual void RequestPTUpdate();
- virtual void CheckPermissions(const PTString& app_id,
- const PTString& hmi_level,
- const PTString& rpc,
- const RPCParams& rpc_params,
- CheckPermissionResult& result);
- virtual bool ResetUserConsent();
- virtual void KmsChanged(int kilometers);
- virtual void IncrementIgnitionCycles();
- virtual std::string ForcePTExchange();
- virtual std::string GetPolicyTableStatus() const;
- virtual void ResetRetrySequence();
- virtual int NextRetryTimeout();
- virtual int TimeoutExchange();
- virtual const std::vector<int> RetrySequenceDelaysSeconds();
- virtual void OnExceededTimeout();
- virtual void OnUpdateStarted();
- virtual void PTUpdatedAt(int kilometers, int days_after_epoch);
-
- /**
- * Refresh data about retry sequence from policy table
- */
- virtual void RefreshRetrySequence();
- virtual DeviceConsent GetUserConsentForDevice(const std::string& device_id);
- virtual void GetUserConsentForApp(
- const std::string& device_id, const std::string& policy_app_id,
- std::vector<FunctionalGroupPermission>& permissions);
- virtual void SetUserConsentForDevice(const std::string& device_id,
- bool is_allowed);
- virtual bool ReactOnUserDevConsentForApp(const std::string app_id,
- bool is_device_allowed);
- virtual bool GetInitialAppData(const std::string& application_id,
- StringArray* nicknames = NULL,
- StringArray* app_hmi_types = NULL);
-
- virtual void SetDeviceInfo(const std::string& device_id,
- const DeviceInfo& device_info);
-
- virtual void SetUserConsentForApp(const PermissionConsent& permissions);
-
- virtual bool GetDefaultHmi(const std::string& policy_app_id,
- std::string* default_hmi);
-
- virtual bool GetPriority(const std::string& policy_app_id,
- std::string* priority);
-
- virtual std::vector<UserFriendlyMessage> GetUserFriendlyMessages(
- const std::vector<std::string>& message_code, const std::string& language);
-
- virtual bool IsApplicationRevoked(const std::string& app_id) const;
-
- virtual void GetPermissionsForApp(
- const std::string& device_id, const std::string& policy_app_id,
- std::vector<FunctionalGroupPermission>& permissions);
-
- virtual std::string& GetCurrentDeviceId(const std::string& policy_app_id);
-
- virtual void SetSystemLanguage(const std::string& language);
-
- virtual void SetSystemInfo(const std::string& ccpu_version,
- const std::string& wers_country_code,
- const std::string& language);
- virtual void OnSystemReady();
-
- virtual uint32_t GetNotificationsNumber(const std::string& priority);
-
- virtual void SetVINValue(const std::string& value);
-
- // Interface StatisticsManager (begin)
- virtual void Increment(usage_statistics::GlobalCounterId type);
- virtual void Increment(const std::string& app_id,
- usage_statistics::AppCounterId type);
- virtual void Set(const std::string& app_id, usage_statistics::AppInfoId type,
- const std::string& value);
- virtual void Add(const std::string& app_id,
- usage_statistics::AppStopwatchId type,
- int32_t timespan_seconds);
- // Interface StatisticsManager (end)
-
- AppPermissions GetAppPermissionsChanges(const std::string& policy_app_id);
- void RemovePendingPermissionChanges(const std::string& app_id);
-
- void SendNotificationOnPermissionsUpdated(const std::string& application_id);
-
- bool CleanupUnpairedDevices();
-
- bool CanAppKeepContext(const std::string& app_id);
- bool CanAppStealFocus(const std::string& app_id);
- void MarkUnpairedDevice(const std::string& device_id);
-
- void AddApplication(const std::string& application_id);
-
- virtual void RemoveAppConsentForGroup(const std::string& app_id,
- const std::string& group_name);
-
- virtual uint16_t HeartBeatTimeout(const std::string& app_id) const;
-
- virtual void SaveUpdateStatusRequired(bool is_update_needed);
-
- virtual bool IsPredataPolicy(const std::string& policy_app_id);
- void set_cache_manager(CacheManagerInterface* cache_manager);
-
- virtual void OnAppsSearchStarted();
-
- virtual void OnAppsSearchCompleted();
-
- virtual const std::vector<std::string> GetAppRequestTypes(
- const std::string policy_app_id) const;
- protected:
- #ifdef USE_HMI_PTU_DECRYPTION
- virtual utils::SharedPtr<policy_table::Table> Parse(
- const BinaryMessage& pt_content);
- #else
- virtual utils::SharedPtr<policy_table::Table> ParseArray(
- const BinaryMessage& pt_content);
- #endif
-
- private:
- void CheckTriggers();
- /*
- * @brief Checks policy table update along with current data for any changes
- * in assigned functional group list of application
- *
- * @param Policy table update struct
- */
- void CheckPermissionsChanges(
- const utils::SharedPtr<policy_table::Table> update,
- const utils::SharedPtr<policy_table::Table> snapshot);
-
- /**
- * @brief Fill structure to be sent with OnPermissionsChanged notification
- *
- * @param Policy table struct, which contains rpc functional groups data
- * @param List of rpc functional group names, which should be checked
- * @param group_permission User permissions for functional groups
- * @param Notification struct to be filled and sent
- */
- void PrepareNotificationData(
- const policy_table::FunctionalGroupings& groups,
- const policy_table::Strings& group_names,
- const std::vector<FunctionalGroupPermission>& group_permission,
- Permissions& notification_data);
-
- /**
- * @brief Validate PermissionConsent structure according to currently
- * assigned groups
- * @param permissions PermissionConsent structure that should be validated.
- * @return PermissonConsent struct, which contains no foreign groups
- */
- PermissionConsent EnsureCorrectPermissionConsent(
- const PermissionConsent& permissions_to_check);
-
- /**
- * @brief Allows to process case when added application is not present in
- * policy db.
- * @param policy application id.
- * @param cuuren consent for application's device.
- */
- void AddNewApplication(const std::string& application_id,
- DeviceConsent device_consent);
-
- /**
- * @brief Allows to process case when added application is already
- * in policy db.
- * @param policy application id.
- * @param cuuren consent for application's device.
- */
- void PromoteExistedApplication(const std::string& application_id,
- DeviceConsent device_consent);
-
- /**
- * @brief Check if certain application already in policy db.
- * @param policy application id.
- * @return true if application presents false otherwise.
- */
- bool IsNewApplication(const std::string& application_id) const;
-
- /**
- * Checks existing and permissions of AppStorageFolder
- * @return true if AppStorageFolder exists and has permissions read/write
- */
- bool CheckAppStorageFolder() const;
-
- /**
- * @brief Checks whether need ask the permission of users
- * @return true if user consent is needed
- */
- virtual bool IsConsentNeeded(const std::string& app_id);
-
- /**
- * @brief Changes isConsentNeeded for app pending permissions, in case
- * user set permissions before app activation.
- * @param Unique app id
- * @param Current permissions for app
- */
- void CheckPendingPermissionsChanges(
- const std::string& policy_app_id,
- const std::vector<FunctionalGroupPermission>& current_permissions);
-
- virtual void StartPTExchange();
- virtual bool ExceededDays();
- virtual bool ExceededIgnitionCycles();
- bool IsPTValid(utils::SharedPtr<policy_table::Table> policy_table,
- policy_table::PolicyTableType type) const;
+public:
+ PolicyManagerImpl();
+ virtual void set_listener(PolicyListener *listener);
+ PolicyListener *listener() const { return listener_; }
+ virtual bool InitPT(const std::string &file_name);
+ virtual bool LoadPT(const std::string &file, const BinaryMessage &pt_content);
+ virtual bool ResetPT(const std::string &file_name);
+
+ virtual void GetServiceUrls(const std::string &service_type,
+ EndpointUrls &end_points);
+
+ virtual std::string GetLockScreenIconUrl() const;
+ virtual bool RequestPTUpdate();
+ virtual void CheckPermissions(const PTString &app_id,
+ const PTString &hmi_level, const PTString &rpc,
+ const RPCParams &rpc_params,
+ CheckPermissionResult &result);
+ virtual bool ResetUserConsent();
+ virtual void KmsChanged(int kilometers);
+ virtual void IncrementIgnitionCycles();
+ virtual std::string ForcePTExchange();
+ virtual std::string GetPolicyTableStatus() const;
+ virtual void ResetRetrySequence();
+ virtual uint32_t NextRetryTimeout();
+ virtual int TimeoutExchange();
+ virtual const std::vector<int> RetrySequenceDelaysSeconds();
+ virtual void OnExceededTimeout();
+ virtual void OnUpdateStarted();
+ virtual void PTUpdatedAt(int kilometers, int days_after_epoch);
+
+ /**
+ * Refresh data about retry sequence from policy table
+ */
+ virtual void RefreshRetrySequence();
+ virtual DeviceConsent GetUserConsentForDevice(const std::string &device_id);
+ virtual void
+ GetUserConsentForApp(const std::string &device_id,
+ const std::string &policy_app_id,
+ std::vector<FunctionalGroupPermission> &permissions);
+ virtual void SetUserConsentForDevice(const std::string &device_id,
+ bool is_allowed);
+ virtual bool ReactOnUserDevConsentForApp(const std::string app_id,
+ bool is_device_allowed);
+ virtual bool GetInitialAppData(const std::string &application_id,
+ StringArray *nicknames = NULL,
+ StringArray *app_hmi_types = NULL);
+
+ virtual void SetDeviceInfo(const std::string &device_id,
+ const DeviceInfo &device_info);
+
+ virtual void SetUserConsentForApp(const PermissionConsent &permissions);
+
+ virtual bool GetDefaultHmi(const std::string &policy_app_id,
+ std::string *default_hmi);
+
+ virtual bool GetPriority(const std::string &policy_app_id,
+ std::string *priority);
+
+ virtual std::vector<UserFriendlyMessage>
+ GetUserFriendlyMessages(const std::vector<std::string> &message_code,
+ const std::string &language);
+
+ virtual bool IsApplicationRevoked(const std::string &app_id) const;
+
+ virtual void
+ GetPermissionsForApp(const std::string &device_id,
+ const std::string &policy_app_id,
+ std::vector<FunctionalGroupPermission> &permissions);
+
+ virtual std::string &GetCurrentDeviceId(const std::string &policy_app_id);
+
+ virtual void SetSystemLanguage(const std::string &language);
+
+ virtual void SetSystemInfo(const std::string &ccpu_version,
+ const std::string &wers_country_code,
+ const std::string &language);
+ virtual void OnSystemReady();
+
+ virtual uint32_t GetNotificationsNumber(const std::string &priority);
+
+ virtual void SetVINValue(const std::string &value);
+
+ // Interface StatisticsManager (begin)
+ virtual void Increment(usage_statistics::GlobalCounterId type);
+ virtual void Increment(const std::string &app_id,
+ usage_statistics::AppCounterId type);
+ virtual void Set(const std::string &app_id, usage_statistics::AppInfoId type,
+ const std::string &value);
+ virtual void Add(const std::string &app_id,
+ usage_statistics::AppStopwatchId type,
+ int32_t timespan_seconds);
+ // Interface StatisticsManager (end)
+
+ AppPermissions GetAppPermissionsChanges(const std::string &policy_app_id);
+ void RemovePendingPermissionChanges(const std::string &app_id);
+
+ void SendNotificationOnPermissionsUpdated(const std::string &application_id);
+
+ bool CleanupUnpairedDevices();
+
+ bool CanAppKeepContext(const std::string &app_id);
+ bool CanAppStealFocus(const std::string &app_id);
+ void MarkUnpairedDevice(const std::string &device_id);
+
+ void AddApplication(const std::string &application_id);
+
+ virtual void RemoveAppConsentForGroup(const std::string &app_id,
+ const std::string &group_name);
+
+ virtual uint16_t HeartBeatTimeout(const std::string &app_id) const;
+
+ virtual void SaveUpdateStatusRequired(bool is_update_needed);
+
+ virtual bool IsPredataPolicy(const std::string &policy_app_id);
+ void set_cache_manager(CacheManagerInterface *cache_manager);
+
+ virtual void OnAppsSearchStarted();
+
+ virtual void OnAppsSearchCompleted();
+
+ virtual void OnAppRegisteredOnMobile(const std::string &application_id);
+
+ virtual const std::vector<std::string>
+ GetAppRequestTypes(const std::string policy_app_id) const;
+
+protected:
+#ifdef USE_HMI_PTU_DECRYPTION
+ virtual utils::SharedPtr<policy_table::Table>
+ Parse(const BinaryMessage &pt_content);
+#else
+ virtual utils::SharedPtr<policy_table::Table>
+ ParseArray(const BinaryMessage &pt_content);
+#endif
+
+private:
+ void CheckTriggers();
+ /*
+ * @brief Checks policy table update along with current data for any changes
+ * in assigned functional group list of application
+ *
+ * @param Policy table update struct
+ */
+ void
+ CheckPermissionsChanges(const utils::SharedPtr<policy_table::Table> update,
+ const utils::SharedPtr<policy_table::Table> snapshot);
+
+ /**
+ * @brief Fill structure to be sent with OnPermissionsChanged notification
+ *
+ * @param Policy table struct, which contains rpc functional groups data
+ * @param List of rpc functional group names, which should be checked
+ * @param group_permission User permissions for functional groups
+ * @param Notification struct to be filled and sent
+ */
+ void PrepareNotificationData(
+ const policy_table::FunctionalGroupings &groups,
+ const policy_table::Strings &group_names,
+ const std::vector<FunctionalGroupPermission> &group_permission,
+ Permissions &notification_data);
+
+ /**
+ * @brief Validate PermissionConsent structure according to currently
+ * assigned groups
+ * @param permissions PermissionConsent structure that should be validated.
+ * @return PermissonConsent struct, which contains no foreign groups
+ */
+ PermissionConsent
+ EnsureCorrectPermissionConsent(const PermissionConsent &permissions_to_check);
+
+ /**
+ * @brief Allows to process case when added application is not present in
+ * policy db.
+ * @param policy application id.
+ * @param cuuren consent for application's device.
+ */
+ void AddNewApplication(const std::string &application_id,
+ DeviceConsent device_consent);
+
+ /**
+ * @brief Allows to process case when added application is already
+ * in policy db.
+ * @param policy application id.
+ * @param cuuren consent for application's device.
+ */
+ void PromoteExistedApplication(const std::string &application_id,
+ DeviceConsent device_consent);
+
+ /**
+ * @brief Check if certain application already in policy db.
+ * @param policy application id.
+ * @return true if application presents false otherwise.
+ */
+ bool IsNewApplication(const std::string &application_id) const;
+
+ /**
+ * Checks existing and permissions of AppStorageFolder
+ * @return true if AppStorageFolder exists and has permissions read/write
+ */
+ bool CheckAppStorageFolder() const;
+
+ /**
+ * @brief Checks whether need ask the permission of users
+ * @return true if user consent is needed
+ */
+ virtual bool IsConsentNeeded(const std::string &app_id);
+
+ /**
+ * @brief Changes isConsentNeeded for app pending permissions, in case
+ * user set permissions before app activation.
+ * @param Unique app id
+ * @param Current permissions for app
+ */
+ void CheckPendingPermissionsChanges(
+ const std::string &policy_app_id,
+ const std::vector<FunctionalGroupPermission> &current_permissions);
+
+ virtual void StartPTExchange();
+ virtual bool ExceededDays();
+ virtual bool ExceededIgnitionCycles();
+ bool IsPTValid(utils::SharedPtr<policy_table::Table> policy_table,
+ policy_table::PolicyTableType type) const;
+
+ void RetrySequence();
private:
- PolicyListener* listener_;
-
- UpdateStatusManager update_status_manager_;
- CacheManagerInterfaceSPtr cache_;
- sync_primitives::Lock apps_registration_lock_;
- sync_primitives::Lock app_permissions_diff_lock_;
- std::map<std::string, AppPermissions> app_permissions_diff_;
-
- /**
- * Timeout to wait response with UpdatePT
- */
- int retry_sequence_timeout_;
-
- /**
- * Seconds between retries to update PT
- */
- std::vector<int> retry_sequence_seconds_;
-
- /**
- * Current index trying of retry sequence
- */
- uint32_t retry_sequence_index_;
-
- /**
- * Lock for guarding retry sequence
- */
- sync_primitives::Lock retry_sequence_lock_;
-
- /**
- * Lock for guarding recording statistics
- */
- sync_primitives::Lock statistics_lock_;
-
- /**
- * @brief Device id, which is used during PTU handling for specific
- * application
- */
- std::string last_device_id_;
-
- bool ignition_check;
-
- friend struct CheckAppPolicy;
+ PolicyListener *listener_;
+
+ UpdateStatusManager update_status_manager_;
+ CacheManagerInterfaceSPtr cache_;
+ sync_primitives::Lock apps_registration_lock_;
+ sync_primitives::Lock app_permissions_diff_lock_;
+ std::map<std::string, AppPermissions> app_permissions_diff_;
+
+ /**
+ * Timeout to wait response with UpdatePT
+ */
+ uint32_t retry_sequence_timeout_;
+
+ /**
+ * Seconds between retries to update PT
+ */
+ std::vector<int> retry_sequence_seconds_;
+
+ /**
+ * Current index trying of retry sequence
+ */
+ uint32_t retry_sequence_index_;
+
+ /**
+ * Lock for guarding retry sequence
+ */
+ sync_primitives::Lock retry_sequence_lock_;
+
+ /**
+ * Timer to retry UpdatePT
+ */
+ timer::TimerThread<PolicyManagerImpl> timer_retry_sequence_;
+
+ /**
+ * Lock for guarding recording statistics
+ */
+ sync_primitives::Lock statistics_lock_;
+
+ /**
+ * @brief Device id, which is used during PTU handling for specific
+ * application
+ */
+ std::string last_device_id_;
+
+ bool ignition_check;
+
+ friend struct CheckAppPolicy;
};
-} // namespace policy
+} // namespace policy
-#endif // SRC_COMPONENTS_POLICY_INCLUDE_POLICY_POLICY_MANAGER_IMPL_H_
+#endif // SRC_COMPONENTS_POLICY_INCLUDE_POLICY_POLICY_MANAGER_IMPL_H_
diff --git a/src/components/policy/src/policy/policy_table/table_struct/types.cc b/src/components/policy/src/policy/policy_table/table_struct/types.cc
index fb1daf2b33..08ed6ca7df 100644
--- a/src/components/policy/src/policy/policy_table/table_struct/types.cc
+++ b/src/components/policy/src/policy/policy_table/table_struct/types.cc
@@ -5,234 +5,154 @@
namespace rpc {
namespace policy_table_interface_base {
- std::string PolicyTableTypeToString(const PolicyTableType pt_type) {
- switch (pt_type) {
- case PT_PRELOADED: {
- return "PT_PRELOADED";
- }
- case PT_UPDATE: {
- return "PT_UPDATE";
- }
- case PT_SNAPSHOT: {
- return "PT_SNAPSHOT";
- }
- default :{
- return "INVALID_PT_TYPE";
- }
- }
+std::string PolicyTableTypeToString(const PolicyTableType pt_type) {
+ switch (pt_type) {
+ case PT_PRELOADED: {
+ return "PT_PRELOADED";
}
-
- // PolicyBase methods
- PolicyBase::PolicyBase()
- : CompositeType(kUninitialized) {
+ case PT_UPDATE: {
+ return "PT_UPDATE";
}
- PolicyBase::PolicyBase(const Strings& groups, Priority priority, HmiLevel default_hmi, bool keep_context, bool steal_focus)
- : CompositeType(kUninitialized),
- groups(groups),
- priority(priority),
- default_hmi(default_hmi),
- keep_context(keep_context),
- steal_focus(steal_focus) {
+ case PT_SNAPSHOT: {
+ return "PT_SNAPSHOT";
}
- PolicyBase::~PolicyBase() {
+ default: { return "INVALID_PT_TYPE"; }
}
- PolicyBase::PolicyBase(const Json::Value* value__)
+}
+
+// PolicyBase methods
+PolicyBase::PolicyBase() : CompositeType(kUninitialized) {}
+PolicyBase::PolicyBase(Priority priority)
+ : CompositeType(kUninitialized), priority(priority) {}
+PolicyBase::~PolicyBase() {}
+PolicyBase::PolicyBase(const Json::Value *value__)
: CompositeType(InitHelper(value__, &Json::Value::isObject)),
- groups(impl::ValueMember(value__, "groups")),
- preconsented_groups(impl::ValueMember(value__, "preconsented_groups")),
- priority(impl::ValueMember(value__, "priority")),
- default_hmi(impl::ValueMember(value__, "default_hmi")),
- keep_context(impl::ValueMember(value__, "keep_context")),
- steal_focus(impl::ValueMember(value__, "steal_focus")) {
- }
- Json::Value PolicyBase::ToJsonValue() const {
- Json::Value result__(Json::objectValue);
- impl::WriteJsonField("groups", groups, &result__);
- impl::WriteJsonField("preconsented_groups", preconsented_groups, &result__);
- impl::WriteJsonField("priority", priority, &result__);
- impl::WriteJsonField("default_hmi", default_hmi, &result__);
- impl::WriteJsonField("keep_context", keep_context, &result__);
- impl::WriteJsonField("steal_focus", steal_focus, &result__);
- return result__;
- }
- bool PolicyBase::is_valid() const {
- if (!groups.is_valid()) {
- return false;
- }
- if (!preconsented_groups.is_valid()) {
- return false;
- }
- if (!priority.is_valid()) {
- return false;
- }
- if (!default_hmi.is_valid()) {
- return false;
- }
- if (!keep_context.is_valid()) {
- return false;
- }
- if (!steal_focus.is_valid()) {
- return false;
- }
- return Validate();
+ priority(impl::ValueMember(value__, "priority")) {}
+Json::Value PolicyBase::ToJsonValue() const {
+ Json::Value result__(Json::objectValue);
+ impl::WriteJsonField("priority", priority, &result__);
+ return result__;
+}
+bool PolicyBase::is_valid() const {
+ if (!priority.is_valid()) {
+ return false;
}
- bool PolicyBase::is_initialized() const {
- return (initialization_state__ != kUninitialized) || (!struct_empty());
+ return Validate();
+}
+bool PolicyBase::is_initialized() const {
+ return (initialization_state__ != kUninitialized) || (!struct_empty());
+}
+bool PolicyBase::struct_empty() const {
+ if (priority.is_initialized()) {
+ return false;
}
- bool PolicyBase::struct_empty() const {
- if (groups.is_initialized()) {
- return false;
- }
- if (preconsented_groups.is_initialized()) {
- return false;
- }
- if (priority.is_initialized()) {
- return false;
- }
- if (default_hmi.is_initialized()) {
- return false;
- }
- if (keep_context.is_initialized()) {
- return false;
- }
- if (steal_focus.is_initialized()) {
- return false;
- }
- return true;
+ return true;
+}
+void PolicyBase::ReportErrors(rpc::ValidationReport *report__) const {
+ if (struct_empty()) {
+ rpc::CompositeType::ReportErrors(report__);
}
- void PolicyBase::ReportErrors(rpc::ValidationReport* report__) const {
- if (struct_empty()) {
- rpc::CompositeType::ReportErrors(report__);
- }
- if (!groups.is_valid()) {
- groups.ReportErrors(&report__->ReportSubobject("groups"));
- }
- if (!preconsented_groups.is_valid()) {
- preconsented_groups.ReportErrors(&report__->ReportSubobject("preconsented_groups"));
- }
- if (!priority.is_valid()) {
- priority.ReportErrors(&report__->ReportSubobject("priority"));
- }
- if (!default_hmi.is_valid()) {
- default_hmi.ReportErrors(&report__->ReportSubobject("default_hmi"));
- }
- if (!keep_context.is_valid()) {
- keep_context.ReportErrors(&report__->ReportSubobject("keep_context"));
- }
- if (!steal_focus.is_valid()) {
- steal_focus.ReportErrors(&report__->ReportSubobject("steal_focus"));
- }
+ if (!priority.is_valid()) {
+ priority.ReportErrors(&report__->ReportSubobject("priority"));
}
+}
- void PolicyBase::SetPolicyTableType(PolicyTableType pt_type) {
- CompositeType::SetPolicyTableType(pt_type);
- groups.SetPolicyTableType(pt_type);
- priority.SetPolicyTableType(pt_type);
- }
+void PolicyBase::SetPolicyTableType(PolicyTableType pt_type) {
+ CompositeType::SetPolicyTableType(pt_type);
+ priority.SetPolicyTableType(pt_type);
+}
- // DevicePolicy methods
- DevicePolicy::DevicePolicy()
- : PolicyBase() {
- }
- DevicePolicy::DevicePolicy(const Strings& groups, Priority priority, HmiLevel default_hmi, bool keep_context, bool steal_focus)
- : PolicyBase(groups, priority, default_hmi, keep_context, steal_focus) {
- }
- DevicePolicy::~DevicePolicy() {
- }
- DevicePolicy::DevicePolicy(const Json::Value* value__)
- : PolicyBase(value__) {
- }
+// DevicePolicy methods
+DevicePolicy::DevicePolicy() : PolicyBase() {}
+DevicePolicy::DevicePolicy(Priority priority) : PolicyBase(priority) {}
+DevicePolicy::~DevicePolicy() {}
+DevicePolicy::DevicePolicy(const Json::Value *value__) : PolicyBase(value__) {}
- // AppPoliciesSection methods
- ApplicationPoliciesSection::ApplicationPoliciesSection()
- : CompositeType(kUninitialized) {
+// AppPoliciesSection methods
+ApplicationPoliciesSection::ApplicationPoliciesSection()
+ : CompositeType(kUninitialized) {}
+ApplicationPoliciesSection::ApplicationPoliciesSection(
+ const ApplicationPolicies &apps, const DevicePolicy &device)
+ : CompositeType(kUninitialized), apps(apps), device(device) {}
+ApplicationPoliciesSection::~ApplicationPoliciesSection() {}
+ApplicationPoliciesSection::ApplicationPoliciesSection(
+ const Json::Value *value__)
+ : CompositeType(InitHelper(value__, &Json::Value::isObject)), apps(value__),
+ device(impl::ValueMember(value__, "device")) {
+ // Since "device" is moved to separate struct, we have to delete it from
+ // parsed apps to avoid validation issues due to possible wrong params in
+ // device section
+ apps.erase("device");
+}
+Json::Value ApplicationPoliciesSection::ToJsonValue() const {
+ Json::Value result__(Json::objectValue);
+ result__ = apps.ToJsonValue();
+ impl::WriteJsonField("device", device, &result__);
+ return result__;
+}
+bool ApplicationPoliciesSection::is_valid() const {
+ if (!device.is_valid()) {
+ return false;
}
- ApplicationPoliciesSection::ApplicationPoliciesSection(const ApplicationPolicies& apps, const DevicePolicy& device)
- : CompositeType(kUninitialized),
- apps(apps),
- device(device) {
+ if (!apps.is_valid()) {
+ return false;
}
- ApplicationPoliciesSection::~ApplicationPoliciesSection() {
+ return Validate();
+}
+bool ApplicationPoliciesSection::is_initialized() const {
+ return (initialization_state__ != kUninitialized) || (!struct_empty());
+}
+bool ApplicationPoliciesSection::struct_empty() const {
+ if (device.is_initialized()) {
+ return false;
}
- ApplicationPoliciesSection::ApplicationPoliciesSection(const Json::Value* value__)
- : CompositeType(InitHelper(value__, &Json::Value::isObject)),
- apps(value__),
- device(impl::ValueMember(value__, "device")) {
- // Since "device" is moved to separate struct, we have to delete it from
- // parsed apps to avoid validation issues due to possible wrong params in
- // device section
- apps.erase("device");
- }
- Json::Value ApplicationPoliciesSection::ToJsonValue() const {
- Json::Value result__(Json::objectValue);
- result__ = apps.ToJsonValue();
- impl::WriteJsonField("device", device, &result__);
- return result__;
- }
- bool ApplicationPoliciesSection::is_valid() const {
- if (!device.is_valid()) {
- return false;
- }
- if (!apps.is_valid()) {
- return false;
- }
- return Validate();
+ if (apps.is_initialized()) {
+ return false;
}
- bool ApplicationPoliciesSection::is_initialized() const {
- return (initialization_state__ != kUninitialized) || (!struct_empty());
+ return true;
+}
+void ApplicationPoliciesSection::ReportErrors(
+ rpc::ValidationReport *report__) const {
+ if (struct_empty()) {
+ rpc::CompositeType::ReportErrors(report__);
}
- bool ApplicationPoliciesSection::struct_empty() const {
- if (device.is_initialized()) {
- return false;
- }
- if (apps.is_initialized()) {
- return false;
- }
- return true;
+ if (!device.is_valid()) {
+ device.ReportErrors(&report__->ReportSubobject("device"));
}
- void ApplicationPoliciesSection::ReportErrors(rpc::ValidationReport* report__) const {
- if (struct_empty()) {
- rpc::CompositeType::ReportErrors(report__);
- }
- if (!device.is_valid()) {
- device.ReportErrors(&report__->ReportSubobject("device"));
- }
- if (!apps.is_valid()) {
- apps.ReportErrors(&report__->ReportSubobject("apps"));
- }
+ if (!apps.is_valid()) {
+ apps.ReportErrors(&report__->ReportSubobject("apps"));
}
+}
- void ApplicationPoliciesSection::SetPolicyTableType(PolicyTableType pt_type) {
- CompositeType::SetPolicyTableType(pt_type);
- device.SetPolicyTableType(pt_type);
- apps.SetPolicyTableType(pt_type);
- }
+void ApplicationPoliciesSection::SetPolicyTableType(PolicyTableType pt_type) {
+ CompositeType::SetPolicyTableType(pt_type);
+ device.SetPolicyTableType(pt_type);
+ apps.SetPolicyTableType(pt_type);
+}
// ApplicationParams methods
-ApplicationParams::ApplicationParams()
- : PolicyBase() {
-}
-ApplicationParams::ApplicationParams(const Strings& groups, Priority priority, HmiLevel default_hmi, bool keep_context, bool steal_focus)
- : PolicyBase(groups, priority, default_hmi, keep_context, steal_focus) {
-}
-ApplicationParams::~ApplicationParams() {
-}
-ApplicationParams::ApplicationParams(const Json::Value* value__)
- : PolicyBase(value__),
- nicknames(impl::ValueMember(value__, "nicknames")),
- AppHMIType(impl::ValueMember(value__, "AppHMIType")),
- RequestType(impl::ValueMember(value__, "RequestType")),
- memory_kb(impl::ValueMember(value__, "memory_kb"), 0),
- heart_beat_timeout_ms(impl::ValueMember(value__, "heart_beat_timeout_ms")),
- certificate(impl::ValueMember(value__, "certificate"), "not_specified") {
-}
+ApplicationParams::ApplicationParams() : PolicyBase() {}
+ApplicationParams::ApplicationParams(const Strings &groups, Priority priority)
+ : PolicyBase(priority), groups(groups) {}
+ApplicationParams::~ApplicationParams() {}
+ApplicationParams::ApplicationParams(const Json::Value *value__)
+ : PolicyBase(value__), groups(impl::ValueMember(value__, "groups")),
+ nicknames(impl::ValueMember(value__, "nicknames")),
+ AppHMIType(impl::ValueMember(value__, "AppHMIType")),
+ RequestType(impl::ValueMember(value__, "RequestType")),
+ memory_kb(impl::ValueMember(value__, "memory_kb"), 0),
+ heart_beat_timeout_ms(
+ impl::ValueMember(value__, "heart_beat_timeout_ms")),
+ certificate(impl::ValueMember(value__, "certificate"), "not_specified") {}
Json::Value ApplicationParams::ToJsonValue() const {
Json::Value result__(PolicyBase::ToJsonValue());
+ impl::WriteJsonField("groups", groups, &result__);
impl::WriteJsonField("nicknames", nicknames, &result__);
impl::WriteJsonField("AppHMIType", AppHMIType, &result__);
impl::WriteJsonField("RequestType", RequestType, &result__);
impl::WriteJsonField("memory_kb", memory_kb, &result__);
- impl::WriteJsonField("heart_beat_timeout_ms", heart_beat_timeout_ms, &result__);
+ impl::WriteJsonField("heart_beat_timeout_ms", heart_beat_timeout_ms,
+ &result__);
impl::WriteJsonField("certificate", certificate, &result__);
return result__;
}
@@ -242,6 +162,9 @@ bool ApplicationParams::is_valid() const {
if (!PolicyBase::is_valid()) {
return false;
}
+ if (!groups.is_valid()) {
+ return false;
+ }
if (!nicknames.is_valid()) {
return false;
}
@@ -266,6 +189,9 @@ bool ApplicationParams::struct_empty() const {
if (!PolicyBase::is_initialized()) {
return false;
}
+ if (groups.is_initialized()) {
+ return false;
+ }
if (nicknames.is_initialized()) {
return false;
}
@@ -286,7 +212,7 @@ bool ApplicationParams::struct_empty() const {
}
return true;
}
-void ApplicationParams::ReportErrors(rpc::ValidationReport* report__) const {
+void ApplicationParams::ReportErrors(rpc::ValidationReport *report__) const {
if (struct_empty()) {
rpc::CompositeType::ReportErrors(report__);
}
@@ -296,9 +222,6 @@ void ApplicationParams::ReportErrors(rpc::ValidationReport* report__) const {
if (!nicknames.is_valid()) {
nicknames.ReportErrors(&report__->ReportSubobject("nicknames"));
}
- if (!preconsented_groups.is_valid()) {
- preconsented_groups.ReportErrors(&report__->ReportSubobject("preconsented_groups"));
- }
if (!AppHMIType.is_valid()) {
AppHMIType.ReportErrors(&report__->ReportSubobject("AppHMIType"));
}
@@ -308,20 +231,12 @@ void ApplicationParams::ReportErrors(rpc::ValidationReport* report__) const {
if (!priority.is_valid()) {
priority.ReportErrors(&report__->ReportSubobject("priority"));
}
- if (!default_hmi.is_valid()) {
- default_hmi.ReportErrors(&report__->ReportSubobject("default_hmi"));
- }
- if (!keep_context.is_valid()) {
- keep_context.ReportErrors(&report__->ReportSubobject("keep_context"));
- }
- if (!steal_focus.is_valid()) {
- steal_focus.ReportErrors(&report__->ReportSubobject("steal_focus"));
- }
if (!memory_kb.is_valid()) {
memory_kb.ReportErrors(&report__->ReportSubobject("memory_kb"));
}
if (!heart_beat_timeout_ms.is_valid()) {
- heart_beat_timeout_ms.ReportErrors(&report__->ReportSubobject("heart_beat_timeout_ms"));
+ heart_beat_timeout_ms.ReportErrors(
+ &report__->ReportSubobject("heart_beat_timeout_ms"));
}
if (!certificate.is_valid()) {
certificate.ReportErrors(&report__->ReportSubobject("certificate"));
@@ -330,6 +245,7 @@ void ApplicationParams::ReportErrors(rpc::ValidationReport* report__) const {
void ApplicationParams::SetPolicyTableType(PolicyTableType pt_type) {
PolicyBase::SetPolicyTableType(pt_type);
+ groups.SetPolicyTableType(pt_type);
AppHMIType.SetPolicyTableType(pt_type);
RequestType.SetPolicyTableType(pt_type);
memory_kb.SetPolicyTableType(pt_type);
@@ -337,20 +253,14 @@ void ApplicationParams::SetPolicyTableType(PolicyTableType pt_type) {
certificate.SetPolicyTableType(pt_type);
}
// RpcParameters methods
-RpcParameters::RpcParameters()
- : CompositeType(kUninitialized) {
-}
-RpcParameters::RpcParameters(const HmiLevels& hmi_levels)
- : CompositeType(kUninitialized),
- hmi_levels(hmi_levels) {
-}
-RpcParameters::~RpcParameters() {
-}
-RpcParameters::RpcParameters(const Json::Value* value__)
- : CompositeType(InitHelper(value__, &Json::Value::isObject)),
- hmi_levels(impl::ValueMember(value__, "hmi_levels")),
- parameters(impl::ValueMember(value__, "parameters")) {
-}
+RpcParameters::RpcParameters() : CompositeType(kUninitialized) {}
+RpcParameters::RpcParameters(const HmiLevels &hmi_levels)
+ : CompositeType(kUninitialized), hmi_levels(hmi_levels) {}
+RpcParameters::~RpcParameters() {}
+RpcParameters::RpcParameters(const Json::Value *value__)
+ : CompositeType(InitHelper(value__, &Json::Value::isObject)),
+ hmi_levels(impl::ValueMember(value__, "hmi_levels")),
+ parameters(impl::ValueMember(value__, "parameters")) {}
Json::Value RpcParameters::ToJsonValue() const {
Json::Value result__(Json::objectValue);
impl::WriteJsonField("hmi_levels", hmi_levels, &result__);
@@ -379,7 +289,7 @@ bool RpcParameters::struct_empty() const {
return true;
}
-void RpcParameters::ReportErrors(rpc::ValidationReport* report__) const {
+void RpcParameters::ReportErrors(rpc::ValidationReport *report__) const {
if (struct_empty()) {
rpc::CompositeType::ReportErrors(report__);
}
@@ -398,20 +308,13 @@ void RpcParameters::SetPolicyTableType(PolicyTableType pt_type) {
}
// Rpcs methods
-Rpcs::Rpcs()
- : CompositeType(kUninitialized) {
-}
-Rpcs::Rpcs(const Rpc& rpcs)
- : CompositeType(kUninitialized),
- rpcs(rpcs) {
-}
-Rpcs::~Rpcs() {
-}
-Rpcs::Rpcs(const Json::Value* value__)
- : CompositeType(InitHelper(value__, &Json::Value::isObject)),
- user_consent_prompt(impl::ValueMember(value__, "user_consent_prompt")),
- rpcs(impl::ValueMember(value__, "rpcs")) {
-}
+Rpcs::Rpcs() : CompositeType(kUninitialized) {}
+Rpcs::Rpcs(const Rpc &rpcs) : CompositeType(kUninitialized), rpcs(rpcs) {}
+Rpcs::~Rpcs() {}
+Rpcs::Rpcs(const Json::Value *value__)
+ : CompositeType(InitHelper(value__, &Json::Value::isObject)),
+ user_consent_prompt(impl::ValueMember(value__, "user_consent_prompt")),
+ rpcs(impl::ValueMember(value__, "rpcs")) {}
Json::Value Rpcs::ToJsonValue() const {
Json::Value result__(Json::objectValue);
impl::WriteJsonField("user_consent_prompt", user_consent_prompt, &result__);
@@ -440,12 +343,13 @@ bool Rpcs::struct_empty() const {
return true;
}
-void Rpcs::ReportErrors(rpc::ValidationReport* report__) const {
+void Rpcs::ReportErrors(rpc::ValidationReport *report__) const {
if (struct_empty()) {
rpc::CompositeType::ReportErrors(report__);
}
if (!user_consent_prompt.is_valid()) {
- user_consent_prompt.ReportErrors(&report__->ReportSubobject("user_consent_prompt"));
+ user_consent_prompt.ReportErrors(
+ &report__->ReportSubobject("user_consent_prompt"));
}
if (!rpcs.is_valid()) {
rpcs.ReportErrors(&report__->ReportSubobject("rpcs"));
@@ -459,74 +363,82 @@ void Rpcs::SetPolicyTableType(PolicyTableType pt_type) {
}
// ModuleConfig methods
-ModuleConfig::ModuleConfig()
- : CompositeType(kUninitialized) {
-}
-ModuleConfig::ModuleConfig(uint8_t exchange_after_x_ignition_cycles, int64_t exchange_after_x_kilometers, uint8_t exchange_after_x_days, uint16_t timeout_after_x_seconds, const SecondsBetweenRetries& seconds_between_retries, const ServiceEndpoints& endpoints, const NumberOfNotificationsPerMinute& notifications_per_minute_by_priority)
- : CompositeType(kUninitialized),
- exchange_after_x_ignition_cycles(exchange_after_x_ignition_cycles),
- exchange_after_x_kilometers(exchange_after_x_kilometers),
- exchange_after_x_days(exchange_after_x_days),
- timeout_after_x_seconds(timeout_after_x_seconds),
- seconds_between_retries(seconds_between_retries),
- endpoints(endpoints),
- notifications_per_minute_by_priority(notifications_per_minute_by_priority) {
-}
-ModuleConfig::~ModuleConfig() {
-}
-ModuleConfig::ModuleConfig(const Json::Value* value__)
- : CompositeType(InitHelper(value__, &Json::Value::isObject)),
- device_certificates(impl::ValueMember(value__, "device_certificates")),
- preloaded_pt(impl::ValueMember(value__, "preloaded_pt")),
- exchange_after_x_ignition_cycles(impl::ValueMember(value__, "exchange_after_x_ignition_cycles")),
- exchange_after_x_kilometers(impl::ValueMember(value__, "exchange_after_x_kilometers")),
- exchange_after_x_days(impl::ValueMember(value__, "exchange_after_x_days")),
- timeout_after_x_seconds(impl::ValueMember(value__, "timeout_after_x_seconds")),
- seconds_between_retries(impl::ValueMember(value__, "seconds_between_retries")),
- endpoints(impl::ValueMember(value__, "endpoints")),
- notifications_per_minute_by_priority(impl::ValueMember(value__, "notifications_per_minute_by_priority")),
- vehicle_make(impl::ValueMember(value__, "vehicle_make")),
- vehicle_model(impl::ValueMember(value__, "vehicle_model")),
- vehicle_year(impl::ValueMember(value__, "vehicle_year")) {
-}
+ModuleConfig::ModuleConfig() : CompositeType(kUninitialized) {}
+ModuleConfig::ModuleConfig(
+ uint8_t exchange_after_x_ignition_cycles,
+ int64_t exchange_after_x_kilometers, uint8_t exchange_after_x_days,
+ uint16_t timeout_after_x_seconds,
+ const SecondsBetweenRetries &seconds_between_retries,
+ const ServiceEndpoints &endpoints,
+ const NumberOfNotificationsPerMinute &notifications_per_minute_by_priority)
+ : CompositeType(kUninitialized),
+ exchange_after_x_ignition_cycles(exchange_after_x_ignition_cycles),
+ exchange_after_x_kilometers(exchange_after_x_kilometers),
+ exchange_after_x_days(exchange_after_x_days),
+ timeout_after_x_seconds(timeout_after_x_seconds),
+ seconds_between_retries(seconds_between_retries), endpoints(endpoints),
+ notifications_per_minute_by_priority(
+ notifications_per_minute_by_priority) {}
+ModuleConfig::~ModuleConfig() {}
+ModuleConfig::ModuleConfig(const Json::Value *value__)
+ : CompositeType(InitHelper(value__, &Json::Value::isObject)),
+ preloaded_pt(impl::ValueMember(value__, "preloaded_pt")),
+ exchange_after_x_ignition_cycles(
+ impl::ValueMember(value__, "exchange_after_x_ignition_cycles")),
+ exchange_after_x_kilometers(
+ impl::ValueMember(value__, "exchange_after_x_kilometers")),
+ exchange_after_x_days(
+ impl::ValueMember(value__, "exchange_after_x_days")),
+ timeout_after_x_seconds(
+ impl::ValueMember(value__, "timeout_after_x_seconds")),
+ seconds_between_retries(
+ impl::ValueMember(value__, "seconds_between_retries")),
+ endpoints(impl::ValueMember(value__, "endpoints")),
+ notifications_per_minute_by_priority(
+ impl::ValueMember(value__, "notifications_per_minute_by_priority")),
+ vehicle_make(impl::ValueMember(value__, "vehicle_make")),
+ vehicle_model(impl::ValueMember(value__, "vehicle_model")),
+ vehicle_year(impl::ValueMember(value__, "vehicle_year")) {}
-void ModuleConfig::SafeCopyFrom(const ModuleConfig& from) {
-// device_certificates = from.device_certificates; // According to the requirements this is optional.
+void ModuleConfig::SafeCopyFrom(const ModuleConfig &from) {
+ // device_certificates = from.device_certificates; // According to the
+ // requirements this is optional.
exchange_after_x_ignition_cycles = from.exchange_after_x_ignition_cycles;
exchange_after_x_kilometers = from.exchange_after_x_kilometers;
exchange_after_x_days = from.exchange_after_x_days;
timeout_after_x_seconds = from.timeout_after_x_seconds;
seconds_between_retries = from.seconds_between_retries;
endpoints = from.endpoints;
- notifications_per_minute_by_priority = from.notifications_per_minute_by_priority;
+ notifications_per_minute_by_priority =
+ from.notifications_per_minute_by_priority;
vehicle_make.assign_if_valid(from.vehicle_make);
vehicle_model.assign_if_valid(from.vehicle_model);
vehicle_year.assign_if_valid(from.vehicle_year);
- certificate .assign_if_valid(from.certificate);
-
}
Json::Value ModuleConfig::ToJsonValue() const {
Json::Value result__(Json::objectValue);
- impl::WriteJsonField("device_certificates", device_certificates, &result__);
impl::WriteJsonField("preloaded_pt", preloaded_pt, &result__);
- impl::WriteJsonField("exchange_after_x_ignition_cycles", exchange_after_x_ignition_cycles, &result__);
- impl::WriteJsonField("exchange_after_x_kilometers", exchange_after_x_kilometers, &result__);
- impl::WriteJsonField("exchange_after_x_days", exchange_after_x_days, &result__);
- impl::WriteJsonField("timeout_after_x_seconds", timeout_after_x_seconds, &result__);
- impl::WriteJsonField("seconds_between_retries", seconds_between_retries, &result__);
+ impl::WriteJsonField("exchange_after_x_ignition_cycles",
+ exchange_after_x_ignition_cycles, &result__);
+ impl::WriteJsonField("exchange_after_x_kilometers",
+ exchange_after_x_kilometers, &result__);
+ impl::WriteJsonField("exchange_after_x_days", exchange_after_x_days,
+ &result__);
+ impl::WriteJsonField("timeout_after_x_seconds", timeout_after_x_seconds,
+ &result__);
+ impl::WriteJsonField("seconds_between_retries", seconds_between_retries,
+ &result__);
impl::WriteJsonField("endpoints", endpoints, &result__);
- impl::WriteJsonField("notifications_per_minute_by_priority", notifications_per_minute_by_priority, &result__);
+ impl::WriteJsonField("notifications_per_minute_by_priority",
+ notifications_per_minute_by_priority, &result__);
impl::WriteJsonField("vehicle_make", vehicle_make, &result__);
impl::WriteJsonField("vehicle_model", vehicle_model, &result__);
impl::WriteJsonField("vehicle_year", vehicle_year, &result__);
return result__;
}
bool ModuleConfig::is_valid() const {
- if (!device_certificates.is_valid()) {
- return false;
- }
if (!preloaded_pt.is_valid()) {
return false;
}
@@ -566,9 +478,6 @@ bool ModuleConfig::is_initialized() const {
return (initialization_state__ != kUninitialized) || (!struct_empty());
}
bool ModuleConfig::struct_empty() const {
- if (device_certificates.is_initialized()) {
- return false;
- }
if (preloaded_pt.is_initialized()) {
return false;
}
@@ -610,36 +519,39 @@ bool ModuleConfig::struct_empty() const {
return true;
}
-void ModuleConfig::ReportErrors(rpc::ValidationReport* report__) const {
+void ModuleConfig::ReportErrors(rpc::ValidationReport *report__) const {
if (struct_empty()) {
rpc::CompositeType::ReportErrors(report__);
}
- if (!device_certificates.is_valid()) {
- device_certificates.ReportErrors(&report__->ReportSubobject("device_certificates"));
- }
if (!preloaded_pt.is_valid()) {
preloaded_pt.ReportErrors(&report__->ReportSubobject("preloaded_pt"));
}
if (!exchange_after_x_ignition_cycles.is_valid()) {
- exchange_after_x_ignition_cycles.ReportErrors(&report__->ReportSubobject("exchange_after_x_ignition_cycles"));
+ exchange_after_x_ignition_cycles.ReportErrors(
+ &report__->ReportSubobject("exchange_after_x_ignition_cycles"));
}
if (!exchange_after_x_kilometers.is_valid()) {
- exchange_after_x_kilometers.ReportErrors(&report__->ReportSubobject("exchange_after_x_kilometers"));
+ exchange_after_x_kilometers.ReportErrors(
+ &report__->ReportSubobject("exchange_after_x_kilometers"));
}
if (!exchange_after_x_days.is_valid()) {
- exchange_after_x_days.ReportErrors(&report__->ReportSubobject("exchange_after_x_days"));
+ exchange_after_x_days.ReportErrors(
+ &report__->ReportSubobject("exchange_after_x_days"));
}
if (!timeout_after_x_seconds.is_valid()) {
- timeout_after_x_seconds.ReportErrors(&report__->ReportSubobject("timeout_after_x_seconds"));
+ timeout_after_x_seconds.ReportErrors(
+ &report__->ReportSubobject("timeout_after_x_seconds"));
}
if (!seconds_between_retries.is_valid()) {
- seconds_between_retries.ReportErrors(&report__->ReportSubobject("seconds_between_retries"));
+ seconds_between_retries.ReportErrors(
+ &report__->ReportSubobject("seconds_between_retries"));
}
if (!endpoints.is_valid()) {
endpoints.ReportErrors(&report__->ReportSubobject("endpoints"));
}
if (!notifications_per_minute_by_priority.is_valid()) {
- notifications_per_minute_by_priority.ReportErrors(&report__->ReportSubobject("notifications_per_minute_by_priority"));
+ notifications_per_minute_by_priority.ReportErrors(
+ &report__->ReportSubobject("notifications_per_minute_by_priority"));
}
if (!vehicle_make.is_valid()) {
vehicle_make.ReportErrors(&report__->ReportSubobject("vehicle_make"));
@@ -651,9 +563,9 @@ void ModuleConfig::ReportErrors(rpc::ValidationReport* report__) const {
vehicle_year.ReportErrors(&report__->ReportSubobject("vehicle_year"));
}
if (PT_PRELOADED == GetPolicyTableType()) {
- std::string validation_info = ommited_validation_info +
- PolicyTableTypeToString(GetPolicyTableType());
- rpc::ValidationReport* ommited_field_report;
+ std::string validation_info =
+ ommited_validation_info + PolicyTableTypeToString(GetPolicyTableType());
+ rpc::ValidationReport *ommited_field_report;
if (vehicle_make.is_initialized()) {
ommited_field_report = &report__->ReportSubobject("vehicle_make");
ommited_field_report->set_validation_info(validation_info);
@@ -671,7 +583,6 @@ void ModuleConfig::ReportErrors(rpc::ValidationReport* report__) const {
void ModuleConfig::SetPolicyTableType(PolicyTableType pt_type) {
CompositeType::SetPolicyTableType(pt_type);
- device_certificates.SetPolicyTableType(pt_type);
preloaded_pt.SetPolicyTableType(pt_type);
exchange_after_x_ignition_cycles.SetPolicyTableType(pt_type);
exchange_after_x_kilometers.SetPolicyTableType(pt_type);
@@ -686,19 +597,15 @@ void ModuleConfig::SetPolicyTableType(PolicyTableType pt_type) {
}
// MessageString methods
-MessageString::MessageString()
- : CompositeType(kUninitialized) {
-}
-MessageString::~MessageString() {
-}
-MessageString::MessageString(const Json::Value* value__)
- : CompositeType(InitHelper(value__, &Json::Value::isObject)),
- line1(impl::ValueMember(value__, "line1")),
- line2(impl::ValueMember(value__, "line2")),
- tts(impl::ValueMember(value__, "tts")),
- label(impl::ValueMember(value__, "label")),
- textBody(impl::ValueMember(value__, "textBody")) {
-}
+MessageString::MessageString() : CompositeType(kUninitialized) {}
+MessageString::~MessageString() {}
+MessageString::MessageString(const Json::Value *value__)
+ : CompositeType(InitHelper(value__, &Json::Value::isObject)),
+ line1(impl::ValueMember(value__, "line1")),
+ line2(impl::ValueMember(value__, "line2")),
+ tts(impl::ValueMember(value__, "tts")),
+ label(impl::ValueMember(value__, "label")),
+ textBody(impl::ValueMember(value__, "textBody")) {}
Json::Value MessageString::ToJsonValue() const {
Json::Value result__(Json::objectValue);
impl::WriteJsonField("line1", line1, &result__);
@@ -752,7 +659,7 @@ bool MessageString::struct_empty() const {
}
return true;
}
-void MessageString::ReportErrors(rpc::ValidationReport* report__) const {
+void MessageString::ReportErrors(rpc::ValidationReport *report__) const {
if (struct_empty()) {
rpc::CompositeType::ReportErrors(report__);
}
@@ -783,19 +690,13 @@ void MessageString::SetPolicyTableType(PolicyTableType pt_type) {
}
// MessageLanguages methods
-MessageLanguages::MessageLanguages()
- : CompositeType(kUninitialized) {
-}
-MessageLanguages::MessageLanguages(const Languages& languages)
- : CompositeType(kUninitialized),
- languages(languages) {
-}
-MessageLanguages::~MessageLanguages() {
-}
-MessageLanguages::MessageLanguages(const Json::Value* value__)
- : CompositeType(InitHelper(value__, &Json::Value::isObject)),
- languages(impl::ValueMember(value__, "languages")) {
-}
+MessageLanguages::MessageLanguages() : CompositeType(kUninitialized) {}
+MessageLanguages::MessageLanguages(const Languages &languages)
+ : CompositeType(kUninitialized), languages(languages) {}
+MessageLanguages::~MessageLanguages() {}
+MessageLanguages::MessageLanguages(const Json::Value *value__)
+ : CompositeType(InitHelper(value__, &Json::Value::isObject)),
+ languages(impl::ValueMember(value__, "languages")) {}
Json::Value MessageLanguages::ToJsonValue() const {
Json::Value result__(Json::objectValue);
impl::WriteJsonField("languages", languages, &result__);
@@ -817,15 +718,17 @@ bool MessageLanguages::struct_empty() const {
return true;
}
-void MessageLanguages::ReportErrors(rpc::ValidationReport* report__) const {
+void MessageLanguages::ReportErrors(rpc::ValidationReport *report__) const {
if (struct_empty()) {
rpc::CompositeType::ReportErrors(report__);
}
if (PT_SNAPSHOT == GetPolicyTableType()) {
if (languages.is_initialized()) {
- std::string validation_info = ommited_validation_info +
- PolicyTableTypeToString(GetPolicyTableType());
- report__->ReportSubobject("languages").set_validation_info(validation_info);
+ std::string validation_info =
+ ommited_validation_info +
+ PolicyTableTypeToString(GetPolicyTableType());
+ report__->ReportSubobject("languages")
+ .set_validation_info(validation_info);
}
}
if (!languages.is_valid()) {
@@ -840,19 +743,14 @@ void MessageLanguages::SetPolicyTableType(PolicyTableType pt_type) {
// ConsumerFriendlyMessages methods
ConsumerFriendlyMessages::ConsumerFriendlyMessages()
- : CompositeType(kUninitialized) {
-}
-ConsumerFriendlyMessages::ConsumerFriendlyMessages(const std::string& version)
- : CompositeType(kUninitialized),
- version(version) {
-}
-ConsumerFriendlyMessages::~ConsumerFriendlyMessages() {
-}
-ConsumerFriendlyMessages::ConsumerFriendlyMessages(const Json::Value* value__)
- : CompositeType(InitHelper(value__, &Json::Value::isObject)),
- version(impl::ValueMember(value__, "version")),
- messages(impl::ValueMember(value__, "messages")) {
-}
+ : CompositeType(kUninitialized) {}
+ConsumerFriendlyMessages::ConsumerFriendlyMessages(const std::string &version)
+ : CompositeType(kUninitialized), version(version) {}
+ConsumerFriendlyMessages::~ConsumerFriendlyMessages() {}
+ConsumerFriendlyMessages::ConsumerFriendlyMessages(const Json::Value *value__)
+ : CompositeType(InitHelper(value__, &Json::Value::isObject)),
+ version(impl::ValueMember(value__, "version")),
+ messages(impl::ValueMember(value__, "messages")) {}
Json::Value ConsumerFriendlyMessages::ToJsonValue() const {
Json::Value result__(Json::objectValue);
impl::WriteJsonField("version", version, &result__);
@@ -881,7 +779,8 @@ bool ConsumerFriendlyMessages::struct_empty() const {
return true;
}
-void ConsumerFriendlyMessages::ReportErrors(rpc::ValidationReport* report__) const {
+void ConsumerFriendlyMessages::ReportErrors(
+ rpc::ValidationReport *report__) const {
if (struct_empty()) {
rpc::CompositeType::ReportErrors(report__);
}
@@ -890,9 +789,11 @@ void ConsumerFriendlyMessages::ReportErrors(rpc::ValidationReport* report__) con
}
if (PT_SNAPSHOT == GetPolicyTableType()) {
if (messages.is_initialized()) {
- std::string validation_info = ommited_validation_info +
- PolicyTableTypeToString(GetPolicyTableType());
- report__->ReportSubobject("messages").set_validation_info(validation_info);
+ std::string validation_info =
+ ommited_validation_info +
+ PolicyTableTypeToString(GetPolicyTableType());
+ report__->ReportSubobject("messages")
+ .set_validation_info(validation_info);
}
}
if (!messages.is_valid()) {
@@ -907,14 +808,10 @@ void ConsumerFriendlyMessages::SetPolicyTableType(PolicyTableType pt_type) {
}
// ModuleMeta methods
-ModuleMeta::ModuleMeta()
- : CompositeType(kUninitialized) {
-}
-ModuleMeta::~ModuleMeta() {
-}
-ModuleMeta::ModuleMeta(const Json::Value* value__)
- : CompositeType(InitHelper(value__, &Json::Value::isObject)) {
-}
+ModuleMeta::ModuleMeta() : CompositeType(kUninitialized) {}
+ModuleMeta::~ModuleMeta() {}
+ModuleMeta::ModuleMeta(const Json::Value *value__)
+ : CompositeType(InitHelper(value__, &Json::Value::isObject)) {}
Json::Value ModuleMeta::ToJsonValue() const {
Json::Value result__(Json::objectValue);
return result__;
@@ -928,24 +825,18 @@ bool ModuleMeta::is_valid() const {
bool ModuleMeta::is_initialized() const {
return (initialization_state__ != kUninitialized) || (!struct_empty());
}
-bool ModuleMeta::struct_empty() const {
- return true;
-}
-void ModuleMeta::ReportErrors(rpc::ValidationReport* report__) const {
+bool ModuleMeta::struct_empty() const { return true; }
+void ModuleMeta::ReportErrors(rpc::ValidationReport *report__) const {
if (struct_empty()) {
rpc::CompositeType::ReportErrors(report__);
}
}
// AppLevel methods
-AppLevel::AppLevel()
- : CompositeType(kUninitialized) {
-}
-AppLevel::~AppLevel() {
-}
-AppLevel::AppLevel(const Json::Value* value__)
- : CompositeType(InitHelper(value__, &Json::Value::isObject)) {
-}
+AppLevel::AppLevel() : CompositeType(kUninitialized) {}
+AppLevel::~AppLevel() {}
+AppLevel::AppLevel(const Json::Value *value__)
+ : CompositeType(InitHelper(value__, &Json::Value::isObject)) {}
Json::Value AppLevel::ToJsonValue() const {
Json::Value result__(Json::objectValue);
return result__;
@@ -959,32 +850,26 @@ bool AppLevel::is_valid() const {
bool AppLevel::is_initialized() const {
return (initialization_state__ != kUninitialized) || (!struct_empty());
}
-bool AppLevel::struct_empty() const {
- return true;
-}
-void AppLevel::ReportErrors(rpc::ValidationReport* report__) const {
+bool AppLevel::struct_empty() const { return true; }
+void AppLevel::ReportErrors(rpc::ValidationReport *report__) const {
if (struct_empty()) {
rpc::CompositeType::ReportErrors(report__);
}
if (PT_PRELOADED == GetPolicyTableType() ||
PT_UPDATE == GetPolicyTableType()) {
- std::string validation_info = ommited_validation_info +
- PolicyTableTypeToString(GetPolicyTableType());
+ std::string validation_info =
+ ommited_validation_info + PolicyTableTypeToString(GetPolicyTableType());
report__->set_validation_info(validation_info);
}
}
// UsageAndErrorCounts methods
-UsageAndErrorCounts::UsageAndErrorCounts()
- : CompositeType(kUninitialized) {
-}
+UsageAndErrorCounts::UsageAndErrorCounts() : CompositeType(kUninitialized) {}
-UsageAndErrorCounts::~UsageAndErrorCounts() {
-}
-UsageAndErrorCounts::UsageAndErrorCounts(const Json::Value* value__)
- : CompositeType(InitHelper(value__, &Json::Value::isObject)),
- app_level(impl::ValueMember(value__, "app_level")) {
-}
+UsageAndErrorCounts::~UsageAndErrorCounts() {}
+UsageAndErrorCounts::UsageAndErrorCounts(const Json::Value *value__)
+ : CompositeType(InitHelper(value__, &Json::Value::isObject)),
+ app_level(impl::ValueMember(value__, "app_level")) {}
Json::Value UsageAndErrorCounts::ToJsonValue() const {
Json::Value result__(Json::objectValue);
impl::WriteJsonField("app_level", app_level, &result__);
@@ -1008,14 +893,14 @@ bool UsageAndErrorCounts::struct_empty() const {
}
return true;
}
-void UsageAndErrorCounts::ReportErrors(rpc::ValidationReport* report__) const {
+void UsageAndErrorCounts::ReportErrors(rpc::ValidationReport *report__) const {
if (struct_empty()) {
rpc::CompositeType::ReportErrors(report__);
}
if (PT_PRELOADED == GetPolicyTableType() ||
PT_UPDATE == GetPolicyTableType()) {
- std::string validation_info = ommited_validation_info +
- PolicyTableTypeToString(GetPolicyTableType());
+ std::string validation_info =
+ ommited_validation_info + PolicyTableTypeToString(GetPolicyTableType());
report__->set_validation_info(validation_info);
}
if (!app_level.is_valid()) {
@@ -1029,14 +914,10 @@ void UsageAndErrorCounts::SetPolicyTableType(PolicyTableType pt_type) {
}
// DeviceParams methods
-DeviceParams::DeviceParams()
- : CompositeType(kUninitialized) {
-}
-DeviceParams::~DeviceParams() {
-}
-DeviceParams::DeviceParams(const Json::Value* value__)
- : CompositeType(InitHelper(value__, &Json::Value::isObject)) {
-}
+DeviceParams::DeviceParams() : CompositeType(kUninitialized) {}
+DeviceParams::~DeviceParams() {}
+DeviceParams::DeviceParams(const Json::Value *value__)
+ : CompositeType(InitHelper(value__, &Json::Value::isObject)) {}
Json::Value DeviceParams::ToJsonValue() const {
Json::Value result__(Json::objectValue);
return result__;
@@ -1050,46 +931,46 @@ bool DeviceParams::is_valid() const {
bool DeviceParams::is_initialized() const {
return (initialization_state__ != kUninitialized) || (!struct_empty());
}
-bool DeviceParams::struct_empty() const {
- return true;
-}
-void DeviceParams::ReportErrors(rpc::ValidationReport* report__) const {
+bool DeviceParams::struct_empty() const { return true; }
+void DeviceParams::ReportErrors(rpc::ValidationReport *report__) const {
if (struct_empty()) {
rpc::CompositeType::ReportErrors(report__);
}
}
// PolicyTable methods
-PolicyTable::PolicyTable()
- : CompositeType(kUninitialized) {
-}
-PolicyTable::PolicyTable(const ApplicationPoliciesSection& app_policies_section, const FunctionalGroupings& functional_groupings, const ConsumerFriendlyMessages& consumer_friendly_messages, const ModuleConfig& module_config)
- : CompositeType(kUninitialized),
- app_policies_section(app_policies_section),
- functional_groupings(functional_groupings),
- consumer_friendly_messages(consumer_friendly_messages),
- module_config(module_config) {
-}
-PolicyTable::~PolicyTable() {
-}
-PolicyTable::PolicyTable(const Json::Value* value__)
- : CompositeType(InitHelper(value__, &Json::Value::isObject)),
- app_policies_section(impl::ValueMember(value__, "app_policies")),
- functional_groupings(impl::ValueMember(value__, "functional_groupings")),
- consumer_friendly_messages(impl::ValueMember(value__, "consumer_friendly_messages")),
- module_config(impl::ValueMember(value__, "module_config")),
- module_meta(impl::ValueMember(value__, "module_meta")),
- usage_and_error_counts(impl::ValueMember(value__, "usage_and_error_counts")),
- device_data(impl::ValueMember(value__, "device_data")) {
-}
+PolicyTable::PolicyTable() : CompositeType(kUninitialized) {}
+PolicyTable::PolicyTable(
+ const ApplicationPoliciesSection &app_policies_section,
+ const FunctionalGroupings &functional_groupings,
+ const ConsumerFriendlyMessages &consumer_friendly_messages,
+ const ModuleConfig &module_config)
+ : CompositeType(kUninitialized), app_policies_section(app_policies_section),
+ functional_groupings(functional_groupings),
+ consumer_friendly_messages(consumer_friendly_messages),
+ module_config(module_config) {}
+PolicyTable::~PolicyTable() {}
+PolicyTable::PolicyTable(const Json::Value *value__)
+ : CompositeType(InitHelper(value__, &Json::Value::isObject)),
+ app_policies_section(impl::ValueMember(value__, "app_policies")),
+ functional_groupings(impl::ValueMember(value__, "functional_groupings")),
+ consumer_friendly_messages(
+ impl::ValueMember(value__, "consumer_friendly_messages")),
+ module_config(impl::ValueMember(value__, "module_config")),
+ module_meta(impl::ValueMember(value__, "module_meta")),
+ usage_and_error_counts(
+ impl::ValueMember(value__, "usage_and_error_counts")),
+ device_data(impl::ValueMember(value__, "device_data")) {}
Json::Value PolicyTable::ToJsonValue() const {
Json::Value result__(Json::objectValue);
impl::WriteJsonField("app_policies", app_policies_section, &result__);
impl::WriteJsonField("functional_groupings", functional_groupings, &result__);
- impl::WriteJsonField("consumer_friendly_messages", consumer_friendly_messages, &result__);
+ impl::WriteJsonField("consumer_friendly_messages", consumer_friendly_messages,
+ &result__);
impl::WriteJsonField("module_config", module_config, &result__);
impl::WriteJsonField("module_meta", module_meta, &result__);
- impl::WriteJsonField("usage_and_error_counts", usage_and_error_counts, &result__);
+ impl::WriteJsonField("usage_and_error_counts", usage_and_error_counts,
+ &result__);
impl::WriteJsonField("device_data", device_data, &result__);
return result__;
}
@@ -1147,27 +1028,31 @@ bool PolicyTable::struct_empty() const {
}
return true;
}
-void PolicyTable::ReportErrors(rpc::ValidationReport* report__) const {
+void PolicyTable::ReportErrors(rpc::ValidationReport *report__) const {
if (struct_empty()) {
rpc::CompositeType::ReportErrors(report__);
}
if (PT_PRELOADED == GetPolicyTableType() ||
PT_UPDATE == GetPolicyTableType()) {
- std::string validation_info = ommited_validation_info +
- PolicyTableTypeToString(GetPolicyTableType());
+ std::string validation_info =
+ ommited_validation_info + PolicyTableTypeToString(GetPolicyTableType());
if (device_data.is_initialized()) {
- report__->ReportSubobject("device_data").set_validation_info(validation_info);
+ report__->ReportSubobject("device_data")
+ .set_validation_info(validation_info);
}
}
if (!app_policies_section.is_valid()) {
- app_policies_section.ReportErrors(&report__->ReportSubobject("app_policies"));
+ app_policies_section.ReportErrors(
+ &report__->ReportSubobject("app_policies"));
}
if (!functional_groupings.is_valid()) {
- functional_groupings.ReportErrors(&report__->ReportSubobject("functional_groupings"));
+ functional_groupings.ReportErrors(
+ &report__->ReportSubobject("functional_groupings"));
}
if (!consumer_friendly_messages.is_valid()) {
- consumer_friendly_messages.ReportErrors(&report__->ReportSubobject("consumer_friendly_messages"));
+ consumer_friendly_messages.ReportErrors(
+ &report__->ReportSubobject("consumer_friendly_messages"));
}
if (!module_config.is_valid()) {
module_config.ReportErrors(&report__->ReportSubobject("module_config"));
@@ -1176,7 +1061,8 @@ void PolicyTable::ReportErrors(rpc::ValidationReport* report__) const {
module_meta.ReportErrors(&report__->ReportSubobject("module_meta"));
}
if (!usage_and_error_counts.is_valid()) {
- usage_and_error_counts.ReportErrors(&report__->ReportSubobject("usage_and_error_counts"));
+ usage_and_error_counts.ReportErrors(
+ &report__->ReportSubobject("usage_and_error_counts"));
}
if (!device_data.is_valid()) {
device_data.ReportErrors(&report__->ReportSubobject("device_data"));
@@ -1195,19 +1081,13 @@ void PolicyTable::SetPolicyTableType(PolicyTableType pt_type) {
}
// Table methods
-Table::Table()
- : CompositeType(kUninitialized) {
-}
-Table::Table(const PolicyTable& policy_table)
- : CompositeType(kUninitialized),
- policy_table(policy_table) {
-}
-Table::~Table() {
-}
-Table::Table(const Json::Value* value__)
- : CompositeType(InitHelper(value__, &Json::Value::isObject)),
- policy_table(impl::ValueMember(value__, "policy_table")) {
-}
+Table::Table() : CompositeType(kUninitialized) {}
+Table::Table(const PolicyTable &policy_table)
+ : CompositeType(kUninitialized), policy_table(policy_table) {}
+Table::~Table() {}
+Table::Table(const Json::Value *value__)
+ : CompositeType(InitHelper(value__, &Json::Value::isObject)),
+ policy_table(impl::ValueMember(value__, "policy_table")) {}
Json::Value Table::ToJsonValue() const {
Json::Value result__(Json::objectValue);
impl::WriteJsonField("policy_table", policy_table, &result__);
@@ -1228,7 +1108,7 @@ bool Table::struct_empty() const {
}
return true;
}
-void Table::ReportErrors(rpc::ValidationReport* report__) const {
+void Table::ReportErrors(rpc::ValidationReport *report__) const {
if (struct_empty()) {
rpc::CompositeType::ReportErrors(report__);
}
@@ -1242,6 +1122,5 @@ void Table::SetPolicyTableType(PolicyTableType pt_type) {
policy_table.SetPolicyTableType(pt_type);
}
-} // namespace policy_table_interface_base
-} // namespace rpc
-
+} // namespace policy_table_interface_base
+} // namespace rpc
diff --git a/src/components/policy/src/policy/policy_table/table_struct/types.h b/src/components/policy/src/policy/policy_table/table_struct/types.h
index a7b0e2d492..1ac850ae9a 100644
--- a/src/components/policy/src/policy/policy_table/table_struct/types.h
+++ b/src/components/policy/src/policy/policy_table/table_struct/types.h
@@ -5,7 +5,7 @@
#include "rpc_base/rpc_message.h"
namespace Json {
class Value;
-} // namespace Json
+} // namespace Json
namespace rpc {
namespace policy_table_interface_base {
struct AppLevel;
@@ -15,354 +15,382 @@ struct MessageLanguages;
struct MessageString;
struct RpcParameters;
struct Rpcs;
-} // namespace policy_table_interface_base
-} // namespace rpc
-
+} // namespace policy_table_interface_base
+} // namespace rpc
namespace rpc {
namespace policy_table_interface_base {
-typedef Array< String<1, 255>, 0, 255 > Strings;
+typedef Array<String<1, 255>, 0, 255> Strings;
-typedef Array< Enum<AppHMIType>, 0, 255 > AppHMITypes;
+typedef Array<Enum<AppHMIType>, 0, 255> AppHMITypes;
-typedef Array< Enum<HmiLevel>, 0, 4 > HmiLevels;
+typedef Array<Enum<HmiLevel>, 0, 4> HmiLevels;
-typedef Array< Enum<Parameter>, 0, 24 > Parameters;
+typedef Array<Enum<Parameter>, 0, 24> Parameters;
-typedef Map< RpcParameters, 0, 50 > Rpc;
+typedef Map<RpcParameters, 0, 50> Rpc;
-typedef Array< String<10, 255>, 1, 255 > URL;
+typedef Array<String<10, 255>, 1, 255> URL;
-typedef Map< URL, 1, 255 > URLList;
+typedef Map<URL, 1, 255> URLList;
-typedef Map< URLList, 1, 255 > ServiceEndpoints;
+typedef Map<URLList, 1, 255> ServiceEndpoints;
-typedef Map< Integer<uint8_t, 0, 255>, 0, 6 > NumberOfNotificationsPerMinute;
+typedef Map<Integer<uint8_t, 0, 255>, 0, 6> NumberOfNotificationsPerMinute;
-typedef Array< Integer<uint16_t, 1, 1000>, 0, 10 > SecondsBetweenRetries;
+typedef Array<Integer<uint16_t, 1, 1000>, 0, 10> SecondsBetweenRetries;
-typedef Map< MessageString, 0, 500 > Languages;
+typedef Map<MessageString, 0, 500> Languages;
-typedef Map< MessageLanguages, 0, 255 > Messages;
+typedef Map<MessageLanguages, 0, 255> Messages;
-typedef Map< AppLevel, 0, 255 > AppLevels;
+typedef Map<AppLevel, 0, 255> AppLevels;
-typedef Map< Stringifyable < Nullable< ApplicationParams > >, 1, 1000 > ApplicationPolicies;
+typedef Map<Stringifyable<Nullable<ApplicationParams>>, 1, 1000>
+ ApplicationPolicies;
-typedef Map< Rpcs, 1, 255 > FunctionalGroupings;
+typedef Map<Rpcs, 1, 255> FunctionalGroupings;
-typedef Map< DeviceParams, 0, 255 > DeviceData;
+typedef Map<DeviceParams, 0, 255> DeviceData;
-typedef Array< Enum<RequestType>, 0, 255 > RequestTypes;
+typedef Array<Enum<RequestType>, 0, 255> RequestTypes;
struct PolicyBase : CompositeType {
- public:
- Strings groups;
- Optional< Strings > preconsented_groups;
- Enum<Priority> priority;
- Enum<HmiLevel> default_hmi;
- Boolean keep_context;
- Boolean steal_focus;
- public:
- PolicyBase();
- PolicyBase(const Strings& groups, Priority priority, HmiLevel default_hmi, bool keep_context, bool steal_focus);
- virtual ~PolicyBase();
- explicit PolicyBase(const Json::Value* value__);
- Json::Value ToJsonValue() const;
- bool is_valid() const;
- bool is_initialized() const;
- bool struct_empty() const;
- void ReportErrors(rpc::ValidationReport* report__) const;
- virtual void SetPolicyTableType(PolicyTableType pt_type);
- private:
- bool Validate() const;
+public:
+ Enum<Priority> priority;
+
+public:
+ PolicyBase();
+ PolicyBase(Priority priority);
+ virtual ~PolicyBase();
+ explicit PolicyBase(const Json::Value *value__);
+ Json::Value ToJsonValue() const;
+ bool is_valid() const;
+ bool is_initialized() const;
+ bool struct_empty() const;
+ void ReportErrors(rpc::ValidationReport *report__) const;
+ virtual void SetPolicyTableType(PolicyTableType pt_type);
+
+private:
+ bool Validate() const;
};
struct DevicePolicy : PolicyBase {
- public:
- DevicePolicy();
- DevicePolicy(const Strings& groups, Priority priority, HmiLevel default_hmi, bool keep_context, bool steal_focus);
- ~DevicePolicy();
- explicit DevicePolicy(const Json::Value* value__);
+public:
+ DevicePolicy();
+ DevicePolicy(Priority priority);
+ ~DevicePolicy();
+ explicit DevicePolicy(const Json::Value *value__);
};
struct ApplicationParams : PolicyBase {
- public:
- Optional< Strings > nicknames;
- Optional< AppHMITypes > AppHMIType;
- Optional< RequestTypes > RequestType;
- Optional< Integer<uint16_t, 0, 65225> > memory_kb;
- Optional< Integer<uint16_t, 0, 65225> > heart_beat_timeout_ms;
- Optional< String<0, 255> > certificate;
- public:
- ApplicationParams();
- ApplicationParams(const Strings& groups, Priority priority, HmiLevel default_hmi, bool keep_context, bool steal_focus);
- ~ApplicationParams();
- explicit ApplicationParams(const Json::Value* value__);
- Json::Value ToJsonValue() const;
- bool is_valid() const;
- bool is_initialized() const;
- bool struct_empty() const;
- void ReportErrors(rpc::ValidationReport* report__) const;
- virtual void SetPolicyTableType(PolicyTableType pt_type);
- private:
- bool Validate() const;
+public:
+ Strings groups;
+ Optional<Strings> nicknames;
+ Optional<AppHMITypes> AppHMIType;
+ Optional<RequestTypes> RequestType;
+ Optional<Integer<uint16_t, 0, 65225>> memory_kb;
+ Optional<Integer<uint16_t, 0, 65225>> heart_beat_timeout_ms;
+ Optional<String<0, 255>> certificate;
+
+public:
+ ApplicationParams();
+ ApplicationParams(const Strings &groups, Priority priority);
+ ~ApplicationParams();
+ explicit ApplicationParams(const Json::Value *value__);
+ Json::Value ToJsonValue() const;
+ bool is_valid() const;
+ bool is_initialized() const;
+ bool struct_empty() const;
+ void ReportErrors(rpc::ValidationReport *report__) const;
+ virtual void SetPolicyTableType(PolicyTableType pt_type);
+
+private:
+ bool Validate() const;
};
struct ApplicationPoliciesSection : CompositeType {
- public:
- mutable ApplicationPolicies apps;
- DevicePolicy device;
- public:
- ApplicationPoliciesSection();
- ApplicationPoliciesSection(const ApplicationPolicies& apps, const DevicePolicy& device);
- ~ApplicationPoliciesSection();
- explicit ApplicationPoliciesSection(const Json::Value* value__);
- Json::Value ToJsonValue() const;
- bool is_valid() const;
- bool is_initialized() const;
- bool struct_empty() const;
- void ReportErrors(rpc::ValidationReport* report__) const;
- virtual void SetPolicyTableType(PolicyTableType pt_type);
- private:
- bool Validate() const;
+public:
+ mutable ApplicationPolicies apps;
+ DevicePolicy device;
+
+public:
+ ApplicationPoliciesSection();
+ ApplicationPoliciesSection(const ApplicationPolicies &apps,
+ const DevicePolicy &device);
+ ~ApplicationPoliciesSection();
+ explicit ApplicationPoliciesSection(const Json::Value *value__);
+ Json::Value ToJsonValue() const;
+ bool is_valid() const;
+ bool is_initialized() const;
+ bool struct_empty() const;
+ void ReportErrors(rpc::ValidationReport *report__) const;
+ virtual void SetPolicyTableType(PolicyTableType pt_type);
+
+private:
+ bool Validate() const;
};
struct RpcParameters : CompositeType {
- public:
- HmiLevels hmi_levels;
- Optional< Parameters > parameters;
- public:
- RpcParameters();
- explicit RpcParameters(const HmiLevels& hmi_levels);
- ~RpcParameters();
- explicit RpcParameters(const Json::Value* value__);
- Json::Value ToJsonValue() const;
- bool is_valid() const;
- bool is_initialized() const;
- bool struct_empty() const;
- void ReportErrors(rpc::ValidationReport* report__) const;
- virtual void SetPolicyTableType(PolicyTableType pt_type);
- private:
- bool Validate() const;
+public:
+ HmiLevels hmi_levels;
+ Optional<Parameters> parameters;
+
+public:
+ RpcParameters();
+ explicit RpcParameters(const HmiLevels &hmi_levels);
+ ~RpcParameters();
+ explicit RpcParameters(const Json::Value *value__);
+ Json::Value ToJsonValue() const;
+ bool is_valid() const;
+ bool is_initialized() const;
+ bool struct_empty() const;
+ void ReportErrors(rpc::ValidationReport *report__) const;
+ virtual void SetPolicyTableType(PolicyTableType pt_type);
+
+private:
+ bool Validate() const;
};
struct Rpcs : CompositeType {
- public:
- Optional< String<1, 255> > user_consent_prompt;
- Nullable< Rpc > rpcs;
- public:
- Rpcs();
- explicit Rpcs(const Rpc& rpcs);
- ~Rpcs();
- explicit Rpcs(const Json::Value* value__);
- Json::Value ToJsonValue() const;
- bool is_valid() const;
- bool is_initialized() const;
- bool struct_empty() const;
- void ReportErrors(rpc::ValidationReport* report__) const;
- virtual void SetPolicyTableType(PolicyTableType pt_type);
- private:
- bool Validate() const;
+public:
+ Optional<String<1, 255>> user_consent_prompt;
+ Nullable<Rpc> rpcs;
+
+public:
+ Rpcs();
+ explicit Rpcs(const Rpc &rpcs);
+ ~Rpcs();
+ explicit Rpcs(const Json::Value *value__);
+ Json::Value ToJsonValue() const;
+ bool is_valid() const;
+ bool is_initialized() const;
+ bool struct_empty() const;
+ void ReportErrors(rpc::ValidationReport *report__) const;
+ virtual void SetPolicyTableType(PolicyTableType pt_type);
+
+private:
+ bool Validate() const;
};
struct ModuleConfig : CompositeType {
- public:
- Optional< Map< String<0, 100>, 0, 255 > > device_certificates;
- Optional< Boolean > preloaded_pt;
- Integer<uint8_t, 0, 255> exchange_after_x_ignition_cycles;
- Integer<int64_t, 0, 4294967296ll> exchange_after_x_kilometers;
- Integer<uint8_t, 0, 255> exchange_after_x_days;
- Integer<uint16_t, 0, 65535> timeout_after_x_seconds;
- SecondsBetweenRetries seconds_between_retries;
- ServiceEndpoints endpoints;
- NumberOfNotificationsPerMinute notifications_per_minute_by_priority;
- Optional< String<1, 100> > vehicle_make;
- Optional< String<1, 100> > vehicle_model;
- Optional< String<4, 4> > vehicle_year;
- Optional< String<0, 65535> > certificate;
- public:
- ModuleConfig();
- ModuleConfig(uint8_t exchange_after_x_ignition_cycles, int64_t exchange_after_x_kilometers, uint8_t exchange_after_x_days, uint16_t timeout_after_x_seconds, const SecondsBetweenRetries& seconds_between_retries, const ServiceEndpoints& endpoints, const NumberOfNotificationsPerMinute& notifications_per_minute_by_priority);
- ~ModuleConfig();
- explicit ModuleConfig(const Json::Value* value__);
- void SafeCopyFrom(const ModuleConfig& from);
- Json::Value ToJsonValue() const;
- bool is_valid() const;
- bool is_initialized() const;
- bool struct_empty() const;
- void ReportErrors(rpc::ValidationReport* report__) const;
- virtual void SetPolicyTableType(PolicyTableType pt_type);
- private:
- bool Validate() const;
+public:
+ Optional<Boolean> preloaded_pt;
+ Integer<uint8_t, 0, 255> exchange_after_x_ignition_cycles;
+ Integer<int64_t, 0, 4294967296ll> exchange_after_x_kilometers;
+ Integer<uint8_t, 0, 255> exchange_after_x_days;
+ Integer<uint16_t, 0, 65535> timeout_after_x_seconds;
+ SecondsBetweenRetries seconds_between_retries;
+ ServiceEndpoints endpoints;
+ NumberOfNotificationsPerMinute notifications_per_minute_by_priority;
+ Optional<String<1, 100>> vehicle_make;
+ Optional<String<1, 100>> vehicle_model;
+ Optional<String<4, 4>> vehicle_year;
+
+public:
+ ModuleConfig();
+ ModuleConfig(uint8_t exchange_after_x_ignition_cycles,
+ int64_t exchange_after_x_kilometers,
+ uint8_t exchange_after_x_days, uint16_t timeout_after_x_seconds,
+ const SecondsBetweenRetries &seconds_between_retries,
+ const ServiceEndpoints &endpoints,
+ const NumberOfNotificationsPerMinute &
+ notifications_per_minute_by_priority);
+ ~ModuleConfig();
+ explicit ModuleConfig(const Json::Value *value__);
+ void SafeCopyFrom(const ModuleConfig &from);
+ Json::Value ToJsonValue() const;
+ bool is_valid() const;
+ bool is_initialized() const;
+ bool struct_empty() const;
+ void ReportErrors(rpc::ValidationReport *report__) const;
+ virtual void SetPolicyTableType(PolicyTableType pt_type);
+
+private:
+ bool Validate() const;
};
struct MessageString : CompositeType {
- public:
- Optional< String<1, 65535> > line1;
- Optional< String<1, 65535> > line2;
- Optional< String<1, 65535> > tts;
- Optional< String<1, 65535> > label;
- Optional< String<1, 65535> > textBody;
- public:
- MessageString();
- ~MessageString();
- explicit MessageString(const Json::Value* value__);
- Json::Value ToJsonValue() const;
- bool is_valid() const;
- bool is_initialized() const;
- bool struct_empty() const;
- void ReportErrors(rpc::ValidationReport* report__) const;
- virtual void SetPolicyTableType(PolicyTableType pt_type);
- private:
- bool Validate() const;
+public:
+ Optional<String<1, 65535>> line1;
+ Optional<String<1, 65535>> line2;
+ Optional<String<1, 65535>> tts;
+ Optional<String<1, 65535>> label;
+ Optional<String<1, 65535>> textBody;
+
+public:
+ MessageString();
+ ~MessageString();
+ explicit MessageString(const Json::Value *value__);
+ Json::Value ToJsonValue() const;
+ bool is_valid() const;
+ bool is_initialized() const;
+ bool struct_empty() const;
+ void ReportErrors(rpc::ValidationReport *report__) const;
+ virtual void SetPolicyTableType(PolicyTableType pt_type);
+
+private:
+ bool Validate() const;
};
struct MessageLanguages : CompositeType {
- public:
- Languages languages;
- public:
- MessageLanguages();
- explicit MessageLanguages(const Languages& languages);
- ~MessageLanguages();
- explicit MessageLanguages(const Json::Value* value__);
- Json::Value ToJsonValue() const;
- bool is_valid() const;
- bool is_initialized() const;
- bool struct_empty() const;
- void ReportErrors(rpc::ValidationReport* report__) const;
- virtual void SetPolicyTableType(PolicyTableType pt_type);
- private:
- bool Validate() const;
+public:
+ Languages languages;
+
+public:
+ MessageLanguages();
+ explicit MessageLanguages(const Languages &languages);
+ ~MessageLanguages();
+ explicit MessageLanguages(const Json::Value *value__);
+ Json::Value ToJsonValue() const;
+ bool is_valid() const;
+ bool is_initialized() const;
+ bool struct_empty() const;
+ void ReportErrors(rpc::ValidationReport *report__) const;
+ virtual void SetPolicyTableType(PolicyTableType pt_type);
+
+private:
+ bool Validate() const;
};
struct ConsumerFriendlyMessages : CompositeType {
- public:
- String<1, 100> version;
- Optional< Messages > messages;
- public:
- ConsumerFriendlyMessages();
- explicit ConsumerFriendlyMessages(const std::string& version);
- ~ConsumerFriendlyMessages();
- explicit ConsumerFriendlyMessages(const Json::Value* value__);
- Json::Value ToJsonValue() const;
- bool is_valid() const;
- bool is_initialized() const;
- bool struct_empty() const;
- void ReportErrors(rpc::ValidationReport* report__) const;
- virtual void SetPolicyTableType(PolicyTableType pt_type);
- private:
- bool Validate() const;
+public:
+ String<1, 100> version;
+ Optional<Messages> messages;
+
+public:
+ ConsumerFriendlyMessages();
+ explicit ConsumerFriendlyMessages(const std::string &version);
+ ~ConsumerFriendlyMessages();
+ explicit ConsumerFriendlyMessages(const Json::Value *value__);
+ Json::Value ToJsonValue() const;
+ bool is_valid() const;
+ bool is_initialized() const;
+ bool struct_empty() const;
+ void ReportErrors(rpc::ValidationReport *report__) const;
+ virtual void SetPolicyTableType(PolicyTableType pt_type);
+
+private:
+ bool Validate() const;
};
struct ModuleMeta : CompositeType {
- public:
- public:
- ModuleMeta();
- ~ModuleMeta();
- explicit ModuleMeta(const Json::Value* value__);
- Json::Value ToJsonValue() const;
- bool is_valid() const;
- bool is_initialized() const;
- bool struct_empty() const;
- void ReportErrors(rpc::ValidationReport* report__) const;
- private:
- bool Validate() const;
+public:
+public:
+ ModuleMeta();
+ ~ModuleMeta();
+ explicit ModuleMeta(const Json::Value *value__);
+ Json::Value ToJsonValue() const;
+ bool is_valid() const;
+ bool is_initialized() const;
+ bool struct_empty() const;
+ void ReportErrors(rpc::ValidationReport *report__) const;
+
+private:
+ bool Validate() const;
};
struct AppLevel : CompositeType {
- public:
- public:
- AppLevel();
- ~AppLevel();
- explicit AppLevel(const Json::Value* value__);
- Json::Value ToJsonValue() const;
- bool is_valid() const;
- bool is_initialized() const;
- bool struct_empty() const;
- void ReportErrors(rpc::ValidationReport* report__) const;
- private:
- bool Validate() const;
+public:
+public:
+ AppLevel();
+ ~AppLevel();
+ explicit AppLevel(const Json::Value *value__);
+ Json::Value ToJsonValue() const;
+ bool is_valid() const;
+ bool is_initialized() const;
+ bool struct_empty() const;
+ void ReportErrors(rpc::ValidationReport *report__) const;
+
+private:
+ bool Validate() const;
};
struct UsageAndErrorCounts : CompositeType {
- public:
- Optional< AppLevels > app_level;
- public:
- UsageAndErrorCounts();
- ~UsageAndErrorCounts();
- explicit UsageAndErrorCounts(const Json::Value* value__);
- Json::Value ToJsonValue() const;
- bool is_valid() const;
- bool is_initialized() const;
- bool struct_empty() const;
- void ReportErrors(rpc::ValidationReport* report__) const;
- virtual void SetPolicyTableType(PolicyTableType pt_type);
- private:
- bool Validate() const;
+public:
+ Optional<AppLevels> app_level;
+
+public:
+ UsageAndErrorCounts();
+ ~UsageAndErrorCounts();
+ explicit UsageAndErrorCounts(const Json::Value *value__);
+ Json::Value ToJsonValue() const;
+ bool is_valid() const;
+ bool is_initialized() const;
+ bool struct_empty() const;
+ void ReportErrors(rpc::ValidationReport *report__) const;
+ virtual void SetPolicyTableType(PolicyTableType pt_type);
+
+private:
+ bool Validate() const;
};
struct DeviceParams : CompositeType {
- public:
- public:
- DeviceParams();
- ~DeviceParams();
- explicit DeviceParams(const Json::Value* value__);
- Json::Value ToJsonValue() const;
- bool is_valid() const;
- bool is_initialized() const;
- bool struct_empty() const;
- void ReportErrors(rpc::ValidationReport* report__) const;
- private:
- bool Validate() const;
+public:
+public:
+ DeviceParams();
+ ~DeviceParams();
+ explicit DeviceParams(const Json::Value *value__);
+ Json::Value ToJsonValue() const;
+ bool is_valid() const;
+ bool is_initialized() const;
+ bool struct_empty() const;
+ void ReportErrors(rpc::ValidationReport *report__) const;
+
+private:
+ bool Validate() const;
};
struct PolicyTable : CompositeType {
- public:
- ApplicationPoliciesSection app_policies_section;
- FunctionalGroupings functional_groupings;
- Optional < ConsumerFriendlyMessages > consumer_friendly_messages;
- ModuleConfig module_config;
- Optional< ModuleMeta > module_meta;
- Optional< UsageAndErrorCounts > usage_and_error_counts;
- Optional< DeviceData > device_data;
- public:
- PolicyTable();
- PolicyTable(const ApplicationPoliciesSection& app_policies_section,
- const FunctionalGroupings& functional_groupings,
- const ConsumerFriendlyMessages& consumer_friendly_messages,
- const ModuleConfig& module_config);
- ~PolicyTable();
- explicit PolicyTable(const Json::Value* value__);
- Json::Value ToJsonValue() const;
- bool is_valid() const;
- bool is_initialized() const;
- bool struct_empty() const;
- void ReportErrors(rpc::ValidationReport* report__) const;
- virtual void SetPolicyTableType(PolicyTableType pt_type);
- private:
- bool Validate() const;
+public:
+ ApplicationPoliciesSection app_policies_section;
+ FunctionalGroupings functional_groupings;
+ Optional<ConsumerFriendlyMessages> consumer_friendly_messages;
+ ModuleConfig module_config;
+ Optional<ModuleMeta> module_meta;
+ Optional<UsageAndErrorCounts> usage_and_error_counts;
+ Optional<DeviceData> device_data;
+
+public:
+ PolicyTable();
+ PolicyTable(const ApplicationPoliciesSection &app_policies_section,
+ const FunctionalGroupings &functional_groupings,
+ const ConsumerFriendlyMessages &consumer_friendly_messages,
+ const ModuleConfig &module_config);
+ ~PolicyTable();
+ explicit PolicyTable(const Json::Value *value__);
+ Json::Value ToJsonValue() const;
+ bool is_valid() const;
+ bool is_initialized() const;
+ bool struct_empty() const;
+ void ReportErrors(rpc::ValidationReport *report__) const;
+ virtual void SetPolicyTableType(PolicyTableType pt_type);
+
+private:
+ bool Validate() const;
};
struct Table : CompositeType {
- public:
- PolicyTable policy_table;
- public:
- Table();
- explicit Table(const PolicyTable& policy_table);
- ~Table();
- explicit Table(const Json::Value* value__);
- Json::Value ToJsonValue() const;
- bool is_valid() const;
- bool is_initialized() const;
- bool struct_empty() const;
- void ReportErrors(rpc::ValidationReport* report__) const;
- virtual void SetPolicyTableType(PolicyTableType pt_type);
- private:
- bool Validate() const;
+public:
+ PolicyTable policy_table;
+
+public:
+ Table();
+ explicit Table(const PolicyTable &policy_table);
+ ~Table();
+ explicit Table(const Json::Value *value__);
+ Json::Value ToJsonValue() const;
+ bool is_valid() const;
+ bool is_initialized() const;
+ bool struct_empty() const;
+ void ReportErrors(rpc::ValidationReport *report__) const;
+ virtual void SetPolicyTableType(PolicyTableType pt_type);
+
+private:
+ bool Validate() const;
};
-} // namespace policy_table_interface_base
-} // namespace rpc
+} // namespace policy_table_interface_base
+} // namespace rpc
-#endif // POLICY_TABLE_INTERFACE_BASE_POLICY_TABLE_INTERFACE_BASE_TYPES_H_
+#endif // POLICY_TABLE_INTERFACE_BASE_POLICY_TABLE_INTERFACE_BASE_TYPES_H_
diff --git a/src/components/policy/src/policy/src/cache_manager.cc b/src/components/policy/src/policy/src/cache_manager.cc
index b679f27c15..0481997b50 100644
--- a/src/components/policy/src/policy/src/cache_manager.cc
+++ b/src/components/policy/src/policy/src/cache_manager.cc
@@ -43,7 +43,7 @@
#include "json/writer.h"
#include "utils/logger.h"
-# include "policy/sql_pt_representation.h"
+#include "policy/sql_pt_representation.h"
namespace policy_table = rpc::policy_table_interface_base;
@@ -51,38 +51,35 @@ namespace policy {
CREATE_LOGGERPTR_GLOBAL(logger_, "CacheManager")
-#define CACHE_MANAGER_CHECK(return_value) {\
- if (!pt_) {\
- LOG4CXX_WARN(logger_, "The cache manager is not initialized");\
- return return_value;\
- }\
-}
+#define CACHE_MANAGER_CHECK(return_value) \
+ { \
+ if (!pt_) { \
+ LOG4CXX_WARN(logger_, "The cache manager is not initialized"); \
+ return return_value; \
+ } \
+ }
-#define CACHE_MANAGER_CHECK_VOID() {\
- if (!pt_) {\
- LOG4CXX_WARN(logger_, "The cache manager is not initialized");\
- return;\
- }\
-}
+#define CACHE_MANAGER_CHECK_VOID() \
+ { \
+ if (!pt_) { \
+ LOG4CXX_WARN(logger_, "The cache manager is not initialized"); \
+ return; \
+ } \
+ }
struct LanguageFinder {
- LanguageFinder(const std::string& language):
- language_(language) {
- }
- bool operator()(const policy_table::Languages::value_type& lang) const {
+ LanguageFinder(const std::string &language) : language_(language) {}
+ bool operator()(const policy_table::Languages::value_type &lang) const {
return !strcasecmp(language_.c_str(), lang.first.c_str());
}
private:
- const std::string& language_;
+ const std::string &language_;
};
CacheManager::CacheManager()
- : CacheManagerInterface(),
- backup_(
- new SQLPTRepresentation()
- ),
- update_required(false) {
+ : CacheManagerInterface(), backup_(new SQLPTRepresentation()),
+ update_required(false) {
LOG4CXX_AUTO_TRACE(logger_);
backuper_ = new BackgroundBackuper(this);
@@ -108,9 +105,10 @@ uint16_t CacheManager::HeartBeatTimeout(const std::string &app_id) const {
CACHE_MANAGER_CHECK(0);
uint16_t result = 0;
if (AppExists(app_id)) {
- if (pt_->policy_table.app_policies_section.apps[app_id].heart_beat_timeout_ms
- .is_initialized()) {
- result = *(pt_->policy_table.app_policies_section.apps[app_id].heart_beat_timeout_ms);
+ if (pt_->policy_table.app_policies_section.apps[app_id]
+ .heart_beat_timeout_ms.is_initialized()) {
+ result = *(pt_->policy_table.app_policies_section.apps[app_id]
+ .heart_beat_timeout_ms);
}
}
return result;
@@ -123,7 +121,7 @@ bool CacheManager::CanAppStealFocus(const std::string &app_id) {
}
bool CacheManager::GetDefaultHMI(const std::string &app_id,
- std::string& default_hmi) {
+ std::string &default_hmi) {
CACHE_MANAGER_CHECK(false);
bool result = true;
return result;
@@ -131,38 +129,26 @@ bool CacheManager::GetDefaultHMI(const std::string &app_id,
bool CacheManager::ResetUserConsent() {
CACHE_MANAGER_CHECK(false);
- sync_primitives::AutoLock lock (cache_lock_);
+ sync_primitives::AutoLock lock(cache_lock_);
return true;
}
-
bool CacheManager::GetUserPermissionsForDevice(const std::string &device_id,
- StringArray& consented_groups,
- StringArray& disallowed_groups) {
+ StringArray &consented_groups,
+ StringArray &disallowed_groups) {
LOG4CXX_AUTO_TRACE(logger_);
CACHE_MANAGER_CHECK(false);
return true;
}
-void CacheManager::GetAllAppGroups(const std::string& app_id,
- FunctionalGroupIDs& all_group_ids) {
+void CacheManager::GetAllAppGroups(const std::string &app_id,
+ FunctionalGroupIDs &all_group_ids) {
LOG4CXX_AUTO_TRACE(logger_);
CACHE_MANAGER_CHECK_VOID();
if (kDeviceId == app_id) {
- policy_table::DevicePolicy& device =
- pt_->policy_table.app_policies_section.device;
-
- policy_table::Strings::const_iterator iter = device.groups.begin();
- policy_table::Strings::const_iterator iter_end = device.groups.end();
-
- for (; iter != iter_end; ++iter) {
- const uint32_t group_id =
- static_cast<uint32_t> ((GenerateHash(*iter)));
- all_group_ids.push_back(group_id);
- }
-
+ LOG4CXX_INFO(logger_, "Devices doesn't have groups");
return;
}
@@ -176,15 +162,14 @@ void CacheManager::GetAllAppGroups(const std::string& app_id,
(*app_params_iter).second.groups.end();
for (; iter != iter_end; ++iter) {
- const uint32_t group_id =
- static_cast<uint32_t> ((GenerateHash(*iter)));
+ const uint32_t group_id = static_cast<uint32_t>((GenerateHash(*iter)));
all_group_ids.push_back(group_id);
}
}
}
-void CacheManager::GetPreConsentedGroups(const std::string &app_id,
- FunctionalGroupIDs& preconsented_groups) {
+void CacheManager::GetPreConsentedGroups(
+ const std::string &app_id, FunctionalGroupIDs &preconsented_groups) {
LOG4CXX_AUTO_TRACE(logger_);
CACHE_MANAGER_CHECK_VOID();
@@ -192,26 +177,26 @@ void CacheManager::GetPreConsentedGroups(const std::string &app_id,
void CacheManager::GetConsentedGroups(const std::string &device_id,
const std::string &app_id,
- FunctionalGroupIDs& allowed_groups,
- FunctionalGroupIDs& disallowed_groups) {
+ FunctionalGroupIDs &allowed_groups,
+ FunctionalGroupIDs &disallowed_groups) {
LOG4CXX_AUTO_TRACE(logger_);
CACHE_MANAGER_CHECK_VOID();
}
-void CacheManager::GetUnconsentedGroups(const std::string& device_id,
- const std::string& policy_app_id,
- FunctionalGroupIDs& unconsented_groups) {
+void CacheManager::GetUnconsentedGroups(
+ const std::string &device_id, const std::string &policy_app_id,
+ FunctionalGroupIDs &unconsented_groups) {
LOG4CXX_AUTO_TRACE(logger_);
CACHE_MANAGER_CHECK_VOID();
}
-void CacheManager::RemoveAppConsentForGroup(const std::string& app_id,
- const std::string& group_name) {
+void CacheManager::RemoveAppConsentForGroup(const std::string &app_id,
+ const std::string &group_name) {
CACHE_MANAGER_CHECK_VOID();
}
-bool CacheManager::ApplyUpdate(const policy_table::Table& update_pt) {
+bool CacheManager::ApplyUpdate(const policy_table::Table &update_pt) {
LOG4CXX_AUTO_TRACE(logger_);
CACHE_MANAGER_CHECK(false);
sync_primitives::AutoLock auto_lock(cache_lock_);
@@ -223,18 +208,21 @@ bool CacheManager::ApplyUpdate(const policy_table::Table& update_pt) {
policy_table::ApplicationPolicies::const_iterator iter_end =
update_pt.policy_table.app_policies_section.apps.end();
- for (;iter != iter_end; ++iter) {
+ for (; iter != iter_end; ++iter) {
if (iter->second.is_null()) {
pt_->policy_table.app_policies_section.apps[iter->first].set_to_null();
- pt_->policy_table.app_policies_section.apps[iter->first].set_to_string("");
+ pt_->policy_table.app_policies_section.apps[iter->first].set_to_string(
+ "");
} else if (policy::kDefaultId == (iter->second).get_string()) {
- policy_table::ApplicationPolicies::const_iterator iter_default =
- update_pt.policy_table.app_policies_section.apps.find(kDefaultId);
- if (update_pt.policy_table.app_policies_section.apps.end() == iter_default) {
- LOG4CXX_ERROR(logger_, "The default section was not found in PTU");
- continue;
- }
- pt_->policy_table.app_policies_section.apps[iter->first] = iter_default->second;
+ policy_table::ApplicationPolicies::const_iterator iter_default =
+ update_pt.policy_table.app_policies_section.apps.find(kDefaultId);
+ if (update_pt.policy_table.app_policies_section.apps.end() ==
+ iter_default) {
+ LOG4CXX_ERROR(logger_, "The default section was not found in PTU");
+ continue;
+ }
+ pt_->policy_table.app_policies_section.apps[iter->first] =
+ iter_default->second;
} else {
pt_->policy_table.app_policies_section.apps[iter->first] = iter->second;
}
@@ -243,17 +231,19 @@ bool CacheManager::ApplyUpdate(const policy_table::Table& update_pt) {
pt_->policy_table.app_policies_section.device =
update_pt.policy_table.app_policies_section.device;
- pt_->policy_table.module_config.SafeCopyFrom(update_pt.policy_table.module_config);
+ pt_->policy_table.module_config.SafeCopyFrom(
+ update_pt.policy_table.module_config);
pt_->policy_table.consumer_friendly_messages.assign_if_valid(
- update_pt.policy_table.consumer_friendly_messages);
+ update_pt.policy_table.consumer_friendly_messages);
ResetCalculatedPermissions();
Backup();
return true;
}
-void CacheManager::GetHMIAppTypeAfterUpdate(std::map<std::string, StringArray>& app_hmi_types) {
+void CacheManager::GetHMIAppTypeAfterUpdate(
+ std::map<std::string, StringArray> &app_hmi_types) {
LOG4CXX_AUTO_TRACE(logger_);
CACHE_MANAGER_CHECK_VOID();
policy_table::ApplicationPolicies::const_iterator policy_iter_begin =
@@ -261,14 +251,16 @@ void CacheManager::GetHMIAppTypeAfterUpdate(std::map<std::string, StringArray>&
policy_table::ApplicationPolicies::const_iterator policy_iter_end =
pt_->policy_table.app_policies_section.apps.end();
std::vector<std::string> transform_app_hmi_types;
- for(; policy_iter_begin != policy_iter_end; ++policy_iter_begin) {
- const policy_table::ApplicationParams& app_params = (*policy_iter_begin).second;
- if(app_params.AppHMIType.is_initialized()) {
- if(!(transform_app_hmi_types.empty())) {
+ for (; policy_iter_begin != policy_iter_end; ++policy_iter_begin) {
+ const policy_table::ApplicationParams &app_params =
+ (*policy_iter_begin).second;
+ if (app_params.AppHMIType.is_initialized()) {
+ if (!(transform_app_hmi_types.empty())) {
transform_app_hmi_types.clear();
}
- std::transform(app_params.AppHMIType->begin(), app_params.AppHMIType->end(),
- std::back_inserter(transform_app_hmi_types), AppHMITypeToString());
+ std::transform(
+ app_params.AppHMIType->begin(), app_params.AppHMIType->end(),
+ std::back_inserter(transform_app_hmi_types), AppHMITypeToString());
app_hmi_types[(*policy_iter_begin).first] = transform_app_hmi_types;
}
}
@@ -281,9 +273,9 @@ void CacheManager::Backup() {
}
std::string CacheManager::currentDateTime() {
- time_t now = time(0);
- struct tm tstruct;
- char buf[80];
+ time_t now = time(0);
+ struct tm tstruct;
+ char buf[80];
tstruct = *localtime(&now);
// ISO_8601 format is expected, e.g. “2000-01-01T12:18:53Z”
strftime(buf, sizeof(buf), "%Y-%m-%dT%XZ", &tstruct);
@@ -292,7 +284,7 @@ std::string CacheManager::currentDateTime() {
bool CacheManager::GetPermissionsForApp(const std::string &device_id,
const std::string &app_id,
- FunctionalIdType& group_types) {
+ FunctionalIdType &group_types) {
LOG4CXX_AUTO_TRACE(logger_);
GetAllAppGroups(app_id, group_types[kTypeGeneral]);
@@ -302,21 +294,17 @@ bool CacheManager::GetPermissionsForApp(const std::string &device_id,
}
bool CacheManager::GetDeviceGroupsFromPolicies(
- policy_table::Strings& groups,
- policy_table::Strings& preconsented_groups) {
+ policy_table::Strings &groups, policy_table::Strings &preconsented_groups) {
LOG4CXX_AUTO_TRACE(logger_);
CACHE_MANAGER_CHECK(false);
return true;
}
-bool CacheManager::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,
- const std::string &connection_type) {
+bool CacheManager::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, const std::string &connection_type) {
LOG4CXX_AUTO_TRACE(logger_);
sync_primitives::AutoLock auto_lock(cache_lock_);
@@ -326,8 +314,7 @@ bool CacheManager::SetDeviceData(const std::string &device_id,
}
bool CacheManager::SetUserPermissionsForDevice(
- const std::string &device_id,
- const StringArray &consented_groups,
+ const std::string &device_id, const StringArray &consented_groups,
const StringArray &disallowed_groups) {
LOG4CXX_AUTO_TRACE(logger_);
sync_primitives::AutoLock auto_lock(cache_lock_);
@@ -346,7 +333,7 @@ bool CacheManager::ReactOnUserDevConsentForApp(const std::string &app_id,
}
void CacheManager::GetGroupNameByHashID(const int32_t group_id,
- std::string& group_name) {
+ std::string &group_name) {
CACHE_MANAGER_CHECK_VOID();
policy_table::FunctionalGroupings::const_iterator fg_iter =
@@ -371,16 +358,14 @@ bool CacheManager::SetUserPermissionsForApp(
return true;
}
-bool CacheManager::UpdateRequired() const {
- return update_required;
-}
+bool CacheManager::UpdateRequired() const { return update_required; }
void CacheManager::SaveUpdateRequired(bool status) {
update_required = status;
Backup();
}
-bool CacheManager::IsApplicationRevoked(const std::string& app_id) const {
+bool CacheManager::IsApplicationRevoked(const std::string &app_id) const {
CACHE_MANAGER_CHECK(false);
bool is_revoked = false;
if (pt_->policy_table.app_policies_section.apps.end() !=
@@ -401,7 +386,7 @@ void CacheManager::CheckPermissions(const PTString &app_id,
if (pt_->policy_table.app_policies_section.apps.end() ==
pt_->policy_table.app_policies_section.apps.find(app_id)) {
LOG4CXX_ERROR(logger_, "Application id " << app_id
- << " was not found in policy DB.");
+ << " was not found in policy DB.");
return;
}
@@ -414,9 +399,10 @@ void CacheManager::CheckPermissions(const PTString &app_id,
policy_table::FunctionalGroupings::const_iterator concrete_group;
for (; app_groups_iter != app_groups_iter_end; ++app_groups_iter) {
- concrete_group = pt_->policy_table.functional_groupings.find(*app_groups_iter);
+ concrete_group =
+ pt_->policy_table.functional_groupings.find(*app_groups_iter);
if (pt_->policy_table.functional_groupings.end() != concrete_group) {
- const policy_table::Rpcs& rpcs = concrete_group->second;
+ const policy_table::Rpcs &rpcs = concrete_group->second;
policy_table::Rpc::const_iterator rpc_iter = rpcs.rpcs.find(rpc);
if (rpcs.rpcs.end() != rpc_iter) {
@@ -427,7 +413,7 @@ void CacheManager::CheckPermissions(const PTString &app_id,
policy_table::HmiLevels::const_iterator hmi_iter =
std::find(rpc_param.hmi_levels.begin(), rpc_param.hmi_levels.end(),
- hmi_level_e);
+ hmi_level_e);
if (rpc_param.hmi_levels.end() != hmi_iter) {
result.hmi_level_permitted = PermitResult::kRpcAllowed;
@@ -437,9 +423,9 @@ void CacheManager::CheckPermissions(const PTString &app_id,
policy_table::Parameters::const_iterator params_iter_end =
rpc_param.parameters->end();
- for (;params_iter != params_iter_end; ++params_iter) {
+ for (; params_iter != params_iter_end; ++params_iter) {
result.list_of_allowed_params.push_back(
- policy_table::EnumToJsonString(*params_iter));
+ policy_table::EnumToJsonString(*params_iter));
}
}
}
@@ -455,24 +441,24 @@ bool CacheManager::IsPTPreloaded() {
int CacheManager::IgnitionCyclesBeforeExchange() {
CACHE_MANAGER_CHECK(0);
const uint8_t limit = std::max(
- static_cast<int>(
- pt_->policy_table.module_config.exchange_after_x_ignition_cycles), 0);
+ static_cast<int>(
+ pt_->policy_table.module_config.exchange_after_x_ignition_cycles),
+ 0);
LOG4CXX_DEBUG(logger_, "IgnitionCyclesBeforeExchange limit:" << limit);
uint8_t current = 0;
-
return std::max(limit - current, 0);
}
int CacheManager::KilometersBeforeExchange(int current) {
CACHE_MANAGER_CHECK(0);
- const int limit = std::max(
- static_cast<int>(
- pt_->policy_table.module_config.exchange_after_x_kilometers), 0);
+ const int limit =
+ std::max(static_cast<int>(
+ pt_->policy_table.module_config.exchange_after_x_kilometers),
+ 0);
LOG4CXX_DEBUG(logger_, "KilometersBeforeExchange limit:" << limit);
int last = 0;
-
const int actual = std::max((current - last), 0);
LOG4CXX_DEBUG(logger_, "KilometersBeforeExchange actual:" << actual);
return std::max(limit - actual, 0);
@@ -488,12 +474,11 @@ bool CacheManager::SetCountersPassedForSuccessfulUpdate(int kilometers,
int CacheManager::DaysBeforeExchange(int current) {
CACHE_MANAGER_CHECK(0);
const uint8_t limit = std::max(
- static_cast<int>(
- pt_->policy_table.module_config.exchange_after_x_days), 0);
+ static_cast<int>(pt_->policy_table.module_config.exchange_after_x_days),
+ 0);
LOG4CXX_DEBUG(logger_, "DaysBeforeExchange limit:" << limit);
uint8_t last = 0;
-
const uint8_t actaul = std::max((current - last), 0);
LOG4CXX_DEBUG(logger_, "DaysBeforeExchange actual:" << actaul);
return std::max(limit - actaul, 0);
@@ -514,17 +499,17 @@ int CacheManager::TimeoutResponse() {
return pt_->policy_table.module_config.timeout_after_x_seconds;
}
-bool CacheManager::SecondsBetweenRetries(std::vector<int>& seconds) {
+bool CacheManager::SecondsBetweenRetries(std::vector<int> &seconds) {
CACHE_MANAGER_CHECK(false);
rpc::policy_table_interface_base::SecondsBetweenRetries::iterator iter =
- pt_->policy_table.module_config.seconds_between_retries.begin();
+ pt_->policy_table.module_config.seconds_between_retries.begin();
rpc::policy_table_interface_base::SecondsBetweenRetries::iterator iter_end =
- pt_->policy_table.module_config.seconds_between_retries.end();
+ pt_->policy_table.module_config.seconds_between_retries.end();
const std::size_t size =
pt_->policy_table.module_config.seconds_between_retries.size();
seconds.reserve(size);
- for (;iter != iter_end; ++iter) {
+ for (; iter != iter_end; ++iter) {
seconds.push_back(*iter);
}
return true;
@@ -535,8 +520,9 @@ VehicleData CacheManager::GetVehicleData() {
return VehicleData();
}
-std::vector<UserFriendlyMessage> CacheManager::GetUserFriendlyMsg(
- const std::vector<std::string> &msg_codes, const std::string &language) {
+std::vector<UserFriendlyMessage>
+CacheManager::GetUserFriendlyMsg(const std::vector<std::string> &msg_codes,
+ const std::string &language) {
LOG4CXX_AUTO_TRACE(logger_);
std::vector<UserFriendlyMessage> result;
@@ -554,25 +540,24 @@ std::vector<UserFriendlyMessage> CacheManager::GetUserFriendlyMsg(
// If message has no records with required language, fallback language
// should be used instead.
LanguageFinder finder(language);
- policy_table::Languages::const_iterator it_language =
- std::find_if(msg_languages.languages.begin(),
- msg_languages.languages.end(),
- finder);
+ policy_table::Languages::const_iterator it_language = std::find_if(
+ msg_languages.languages.begin(), msg_languages.languages.end(), finder);
if (msg_languages.languages.end() == it_language) {
- LOG4CXX_WARN(logger_, "Language " << language <<
- " haven't been found for message code: " << *it);
+ LOG4CXX_WARN(logger_,
+ "Language "
+ << language
+ << " haven't been found for message code: " << *it);
LanguageFinder fallback_language_finder("en-us");
policy_table::Languages::const_iterator it_fallback_language =
std::find_if(msg_languages.languages.begin(),
- msg_languages.languages.end(),
- fallback_language_finder);
+ msg_languages.languages.end(), fallback_language_finder);
if (msg_languages.languages.end() == it_fallback_language) {
- LOG4CXX_ERROR(logger_, "No fallback language found for message code: "
- << *it);
+ LOG4CXX_ERROR(logger_,
+ "No fallback language found for message code: " << *it);
continue;
}
@@ -588,8 +573,8 @@ std::vector<UserFriendlyMessage> CacheManager::GetUserFriendlyMsg(
return result;
}
-void CacheManager::GetServiceUrls(const std::string& service_type,
- EndpointUrls& end_points) {
+void CacheManager::GetServiceUrls(const std::string &service_type,
+ EndpointUrls &end_points) {
LOG4CXX_AUTO_TRACE(logger_);
CACHE_MANAGER_CHECK_VOID();
std::string search_value;
@@ -603,13 +588,15 @@ void CacheManager::GetServiceUrls(const std::string& service_type,
pt_->policy_table.module_config.endpoints.find(search_value);
if (pt_->policy_table.module_config.endpoints.end() != iter) {
- policy_table::URLList::const_iterator url_list_iter = (*iter).second.begin();
- policy_table::URLList::const_iterator url_list_iter_end = (*iter).second.end();
+ policy_table::URLList::const_iterator url_list_iter =
+ (*iter).second.begin();
+ policy_table::URLList::const_iterator url_list_iter_end =
+ (*iter).second.end();
for (; url_list_iter != url_list_iter_end; ++url_list_iter) {
EndpointData data;
data.app_id = (*url_list_iter).first;
std::copy((*url_list_iter).second.begin(), (*url_list_iter).second.end(),
- std::back_inserter(data.url));
+ std::back_inserter(data.url));
end_points.push_back(data);
}
@@ -620,19 +607,20 @@ std::string CacheManager::GetLockScreenIconUrl() const {
if (backup_) {
return backup_->GetLockScreenIconUrl();
}
- return std::string ("");
+ return std::string("");
}
int CacheManager::GetNotificationsNumber(const std::string &priority) {
CACHE_MANAGER_CHECK(0);
typedef rpc::policy_table_interface_base::NumberOfNotificationsPerMinute NNPM;
- const NNPM& nnpm =
+ const NNPM &nnpm =
pt_->policy_table.module_config.notifications_per_minute_by_priority;
NNPM::const_iterator priority_iter = nnpm.find(priority);
- const int result = (nnpm.end() != priority_iter ? (*priority_iter).second : 0);
+ const int result =
+ (nnpm.end() != priority_iter ? (*priority_iter).second : 0);
return result;
}
@@ -641,11 +629,11 @@ bool CacheManager::GetPriority(const std::string &policy_app_id,
CACHE_MANAGER_CHECK(false);
if (kDeviceId == policy_app_id) {
priority = EnumToJsonString(
- pt_->policy_table.app_policies_section.device.priority);
+ pt_->policy_table.app_policies_section.device.priority);
return true;
}
- const policy_table::ApplicationPolicies& policies =
+ const policy_table::ApplicationPolicies &policies =
pt_->policy_table.app_policies_section.apps;
policy_table::ApplicationPolicies::const_iterator policy_iter =
@@ -695,28 +683,31 @@ void CacheManager::PersistData() {
if (copy_pt.policy_table.app_policies_section.apps.end() !=
copy_pt.policy_table.app_policies_section.apps.find(app_id)) {
- is_revoked = copy_pt.policy_table.app_policies_section.apps[app_id].is_null();
+ is_revoked =
+ copy_pt.policy_table.app_policies_section.apps[app_id].is_null();
}
- is_default_policy = copy_pt.policy_table.app_policies_section.apps.end() !=
- copy_pt.policy_table.app_policies_section.apps.find(app_id) &&
+ is_default_policy =
+ copy_pt.policy_table.app_policies_section.apps.end() !=
+ copy_pt.policy_table.app_policies_section.apps.find(app_id) &&
policy::kDefaultId ==
- copy_pt.policy_table.app_policies_section.apps[app_id].get_string();
+ copy_pt.policy_table.app_policies_section.apps[app_id]
+ .get_string();
// TODO(AOleynik): Remove this field from DB
- is_predata_policy = copy_pt.policy_table.app_policies_section.apps.end() !=
- copy_pt.policy_table.app_policies_section.apps.find(app_id) &&
+ is_predata_policy =
+ copy_pt.policy_table.app_policies_section.apps.end() !=
+ copy_pt.policy_table.app_policies_section.apps.find(app_id) &&
policy::kPreDataConsentId ==
- copy_pt.policy_table.app_policies_section.apps[app_id].get_string();
+ copy_pt.policy_table.app_policies_section.apps[app_id]
+ .get_string();
- backup_->SaveApplicationCustomData(app_id,
- is_revoked,
- is_default_policy,
- is_predata_policy);
+ backup_->SaveApplicationCustomData(
+ app_id, is_revoked, is_default_policy, is_predata_policy);
is_revoked = false;
}
- // In case of extended policy the meta info should be backuped as well.
+ // In case of extended policy the meta info should be backuped as well.
backup_->WriteDb();
}
}
@@ -728,22 +719,20 @@ void CacheManager::ResetCalculatedPermissions() {
calculated_permissions_.clear();
}
-void CacheManager::AddCalculatedPermissions(
- const std::string& device_id,
- const std::string& policy_app_id,
- const Permissions& permissions) {
- LOG4CXX_DEBUG(logger_, "AddCalculatedPermissions for device: " << device_id
- << " and app: " << policy_app_id);
+void CacheManager::AddCalculatedPermissions(const std::string &device_id,
+ const std::string &policy_app_id,
+ const Permissions &permissions) {
+ LOG4CXX_DEBUG(logger_, "AddCalculatedPermissions for device: "
+ << device_id << " and app: " << policy_app_id);
sync_primitives::AutoLock lock(calculated_permissions_lock_);
calculated_permissions_[device_id][policy_app_id] = permissions;
}
-bool CacheManager::IsPermissionsCalculated(
- const std::string& device_id,
- const std::string& policy_app_id,
- Permissions& permission) {
- LOG4CXX_DEBUG(logger_, "IsPermissionsCalculated for device: " << device_id
- << " and app: " << policy_app_id);
+bool CacheManager::IsPermissionsCalculated(const std::string &device_id,
+ const std::string &policy_app_id,
+ Permissions &permission) {
+ LOG4CXX_DEBUG(logger_, "IsPermissionsCalculated for device: "
+ << device_id << " and app: " << policy_app_id);
sync_primitives::AutoLock lock(calculated_permissions_lock_);
CalculatedPermissions::const_iterator it =
calculated_permissions_.find(device_id);
@@ -763,10 +752,10 @@ bool CacheManager::IsPermissionsCalculated(
return false;
}
-bool policy::CacheManager::IsNumberService(const std::string& input,
- std::string& output) const {
- const char* input_value = input.c_str();
- char* endptr;
+bool policy::CacheManager::IsNumberService(const std::string &input,
+ std::string &output) const {
+ const char *input_value = input.c_str();
+ char *endptr;
const int base = 10;
errno = 0;
uint32_t service_value = strtoul(input_value, &endptr, base);
@@ -778,16 +767,15 @@ bool policy::CacheManager::IsNumberService(const std::string& input,
output = input;
if (service_value <= 9) {
- output.insert(0,"0x0", 3);
+ output.insert(0, "0x0", 3);
} else {
- output.insert(0,"0x", 2);
+ output.insert(0, "0x", 2);
}
return true;
}
-utils::SharedPtr<policy_table::Table>
-CacheManager::GenerateSnapshot() {
+utils::SharedPtr<policy_table::Table> CacheManager::GenerateSnapshot() {
CACHE_MANAGER_CHECK(snapshot_);
sync_primitives::AutoLock lock(cache_lock_);
@@ -810,9 +798,9 @@ CacheManager::GenerateSnapshot() {
return snapshot_;
}
-bool CacheManager::GetInitialAppData(const std::string& app_id,
- StringArray& nicknames,
- StringArray& app_hmi_types) {
+bool CacheManager::GetInitialAppData(const std::string &app_id,
+ StringArray &nicknames,
+ StringArray &app_hmi_types) {
LOG4CXX_AUTO_TRACE(logger_);
CACHE_MANAGER_CHECK(false);
@@ -820,7 +808,7 @@ bool CacheManager::GetInitialAppData(const std::string& app_id,
pt_->policy_table.app_policies_section.apps.find(app_id);
if (pt_->policy_table.app_policies_section.apps.end() != policy_iter) {
- const policy_table::ApplicationParams& app_params = (*policy_iter).second;
+ const policy_table::ApplicationParams &app_params = (*policy_iter).second;
std::copy(app_params.nicknames->begin(), app_params.nicknames->end(),
std::back_inserter(nicknames));
@@ -832,19 +820,19 @@ bool CacheManager::GetInitialAppData(const std::string& app_id,
}
bool CacheManager::GetFunctionalGroupings(
- policy_table::FunctionalGroupings& groups) {
+ policy_table::FunctionalGroupings &groups) {
LOG4CXX_AUTO_TRACE(logger_);
CACHE_MANAGER_CHECK(false);
- const policy_table::FunctionalGroupings& f_groupings =
- pt_->policy_table.functional_groupings;
+ const policy_table::FunctionalGroupings &f_groupings =
+ pt_->policy_table.functional_groupings;
groups.insert(f_groupings.begin(), f_groupings.end());
return true;
}
-int CacheManager::CountUnconsentedGroups(const std::string& policy_app_id,
- const std::string& device_id) {
+int CacheManager::CountUnconsentedGroups(const std::string &policy_app_id,
+ const std::string &device_id) {
LOG4CXX_AUTO_TRACE(logger_);
CACHE_MANAGER_CHECK(false);
LOG4CXX_DEBUG(logger_, "Application id: " << policy_app_id);
@@ -888,9 +876,10 @@ bool CacheManager::GetFunctionalGroupNames(FunctionalGroupNames &names) {
for (; iter != iter_end; ++iter) {
const int32_t id = GenerateHash((*iter).first);
std::pair<std::string, std::string> value =
- std::make_pair( *(*iter).second.user_consent_prompt, (*iter).first);
+ std::make_pair(*(*iter).second.user_consent_prompt, (*iter).first);
- names.insert(std::pair<uint32_t, std::pair<std::string, std::string> >(id, value));
+ names.insert(
+ std::pair<uint32_t, std::pair<std::string, std::string>>(id, value));
}
return true;
}
@@ -920,8 +909,7 @@ void CacheManager::Set(const std::string &app_id,
}
void CacheManager::Add(const std::string &app_id,
- usage_statistics::AppStopwatchId type,
- int seconds) {
+ usage_statistics::AppStopwatchId type, int seconds) {
CACHE_MANAGER_CHECK_VOID();
Backup();
}
@@ -945,23 +933,24 @@ bool CacheManager::SetDefaultPolicy(const std::string &app_id) {
return true;
}
-bool CacheManager::IsDefaultPolicy(const std::string& app_id) {
+bool CacheManager::IsDefaultPolicy(const std::string &app_id) {
CACHE_MANAGER_CHECK(false);
const bool result =
pt_->policy_table.app_policies_section.apps.end() !=
- pt_->policy_table.app_policies_section.apps.find(app_id) &&
+ pt_->policy_table.app_policies_section.apps.find(app_id) &&
policy::kDefaultId ==
- pt_->policy_table.app_policies_section.apps[app_id].get_string();
+ pt_->policy_table.app_policies_section.apps[app_id].get_string();
return result;
}
-bool CacheManager::SetIsDefault(const std::string& app_id) {
+bool CacheManager::SetIsDefault(const std::string &app_id) {
CACHE_MANAGER_CHECK(false);
policy_table::ApplicationPolicies::const_iterator iter =
pt_->policy_table.app_policies_section.apps.find(app_id);
if (pt_->policy_table.app_policies_section.apps.end() != iter) {
- pt_->policy_table.app_policies_section.apps[app_id].set_to_string(kDefaultId);
+ pt_->policy_table.app_policies_section.apps[app_id].set_to_string(
+ kDefaultId);
}
return true;
}
@@ -973,14 +962,16 @@ bool CacheManager::SetPredataPolicy(const std::string &app_id) {
if (pt_->policy_table.app_policies_section.apps.end() == iter) {
LOG4CXX_ERROR(logger_, "Could not set " << kPreDataConsentId
- << " permissions for app " << app_id);
+ << " permissions for app "
+ << app_id);
return false;
}
pt_->policy_table.app_policies_section.apps[app_id] =
pt_->policy_table.app_policies_section.apps[kPreDataConsentId];
- pt_->policy_table.app_policies_section.apps[app_id].set_to_string(kPreDataConsentId);
+ pt_->policy_table.app_policies_section.apps[app_id].set_to_string(
+ kPreDataConsentId);
Backup();
return true;
@@ -989,16 +980,14 @@ bool CacheManager::SetPredataPolicy(const std::string &app_id) {
bool CacheManager::IsPredataPolicy(const std::string &app_id) {
// TODO(AOleynik): Maybe change for comparison with pre_DataConsent
// permissions or check string value from get_string()
- policy_table::ApplicationParams& pre_data_app =
- pt_->policy_table.app_policies_section.apps[kPreDataConsentId];
- policy_table::ApplicationParams& specific_app =
- pt_->policy_table.app_policies_section.apps[app_id];
+ policy_table::ApplicationParams &pre_data_app =
+ pt_->policy_table.app_policies_section.apps[kPreDataConsentId];
+ policy_table::ApplicationParams &specific_app =
+ pt_->policy_table.app_policies_section.apps[app_id];
policy_table::Strings res;
- std::set_intersection(pre_data_app.groups.begin(),
- pre_data_app.groups.end(),
- specific_app.groups.begin(),
- specific_app.groups.end(),
+ std::set_intersection(pre_data_app.groups.begin(), pre_data_app.groups.end(),
+ specific_app.groups.begin(), specific_app.groups.end(),
std::back_inserter(res));
bool is_marked_as_predata =
@@ -1009,13 +998,12 @@ bool CacheManager::IsPredataPolicy(const std::string &app_id) {
}
bool CacheManager::SetUnpairedDevice(const std::string &device_id,
- bool unpaired) {
- const bool result =
- pt_->policy_table.device_data->end() !=
- pt_->policy_table.device_data->find(device_id);
+ bool unpaired) {
+ const bool result = pt_->policy_table.device_data->end() !=
+ pt_->policy_table.device_data->find(device_id);
if (!result) {
LOG4CXX_DEBUG(logger_, "Couldn't set unpaired flag for device id "
- << device_id << " , since it wasn't found.");
+ << device_id << " , since it wasn't found.");
return false;
}
@@ -1025,18 +1013,19 @@ bool CacheManager::SetUnpairedDevice(const std::string &device_id,
LOG4CXX_DEBUG(logger_, "Unpaired flag was set for device id " << device_id);
} else {
is_unpaired_.erase(device_id);
- LOG4CXX_DEBUG(logger_, "Unpaired flag was removed for device id " << device_id);
+ LOG4CXX_DEBUG(logger_, "Unpaired flag was removed for device id "
+ << device_id);
}
return result;
}
-bool CacheManager::SetVINValue(const std::string& value) {
+bool CacheManager::SetVINValue(const std::string &value) {
CACHE_MANAGER_CHECK(false);
Backup();
return true;
}
-bool CacheManager::IsApplicationRepresented(const std::string& app_id) const {
+bool CacheManager::IsApplicationRepresented(const std::string &app_id) const {
CACHE_MANAGER_CHECK(false);
if (kDeviceId == app_id) {
return true;
@@ -1046,42 +1035,41 @@ bool CacheManager::IsApplicationRepresented(const std::string& app_id) const {
return pt_->policy_table.app_policies_section.apps.end() != iter;
}
-bool CacheManager::Init(const std::string& file_name) {
+bool CacheManager::Init(const std::string &file_name) {
LOG4CXX_AUTO_TRACE(logger_);
InitResult init_result = backup_->Init();
bool result = true;
switch (init_result) {
- case InitResult::EXISTS: {
- LOG4CXX_INFO(logger_, "Policy Table exists, was loaded correctly.");
- result = LoadFromBackup();
- } break;
- case InitResult::SUCCESS: {
- LOG4CXX_INFO(logger_, "Policy Table was inited successfully");
- result = LoadFromFile(file_name);
-
- utils::SharedPtr<policy_table::Table> snapshot = GenerateSnapshot();
- result &= snapshot->is_valid();
- LOG4CXX_DEBUG(logger_, "Check if snapshot is valid: "
- << std::boolalpha << result);
- if(!result) {
- rpc::ValidationReport report("policy_table");
- snapshot->ReportErrors(&report);
- }
+ case InitResult::EXISTS: {
+ LOG4CXX_INFO(logger_, "Policy Table exists, was loaded correctly.");
+ result = LoadFromBackup();
+ } break;
+ case InitResult::SUCCESS: {
+ LOG4CXX_INFO(logger_, "Policy Table was inited successfully");
+ result = LoadFromFile(file_name);
+
+ utils::SharedPtr<policy_table::Table> snapshot = GenerateSnapshot();
+ result &= snapshot->is_valid();
+ LOG4CXX_DEBUG(logger_, "Check if snapshot is valid: " << std::boolalpha
+ << result);
+ if (!result) {
+ rpc::ValidationReport report("policy_table");
+ snapshot->ReportErrors(&report);
+ }
- } break;
- default: {
- result = false;
- LOG4CXX_ERROR(logger_, "Failed to init policy table.");
- } break;
+ } break;
+ default: {
+ result = false;
+ LOG4CXX_ERROR(logger_, "Failed to init policy table.");
+ } break;
}
return result;
}
-void CacheManager::FillDeviceSpecificData() {
-}
+void CacheManager::FillDeviceSpecificData() {}
bool CacheManager::LoadFromBackup() {
sync_primitives::AutoLock lock(cache_lock_);
@@ -1093,7 +1081,7 @@ bool CacheManager::LoadFromBackup() {
return true;
}
-bool CacheManager::LoadFromFile(const std::string& file_name) {
+bool CacheManager::LoadFromFile(const std::string &file_name) {
LOG4CXX_AUTO_TRACE(logger_);
BinaryMessage json_string;
if (!file_system::ReadBinaryFile(file_name, json_string)) {
@@ -1105,9 +1093,8 @@ bool CacheManager::LoadFromFile(const std::string& file_name) {
Json::Reader reader(Json::Features::strictMode());
std::string json(json_string.begin(), json_string.end());
if (!reader.parse(json.c_str(), value)) {
- LOG4CXX_FATAL(
- logger_,
- "Preloaded PT is corrupted: " << reader.getFormattedErrorMessages());
+ LOG4CXX_FATAL(logger_, "Preloaded PT is corrupted: "
+ << reader.getFormattedErrorMessages());
return false;
}
@@ -1127,13 +1114,13 @@ bool CacheManager::LoadFromFile(const std::string& file_name) {
} else {
rpc::ValidationReport report("policy_table");
pt_->ReportErrors(&report);
- LOG4CXX_FATAL(logger_,
- "Parsed table is not valid " << rpc::PrettyFormat(report));
+ LOG4CXX_FATAL(logger_, "Parsed table is not valid "
+ << rpc::PrettyFormat(report));
return false;
}
}
-bool CacheManager::ResetPT(const std::string& file_name) {
+bool CacheManager::ResetPT(const std::string &file_name) {
bool result = true;
Backup();
return result;
@@ -1149,14 +1136,14 @@ bool CacheManager::AppExists(const std::string &app_id) const {
return pt_->policy_table.app_policies_section.apps.end() != policy_iter;
}
-int32_t CacheManager::GenerateHash(const std::string& str_to_hash) {
+int32_t CacheManager::GenerateHash(const std::string &str_to_hash) {
uint32_t hash = 5381U;
std::string::const_iterator it = str_to_hash.begin();
std::string::const_iterator it_end = str_to_hash.end();
- for (;it != it_end; ++it) {
- hash = ((hash << 5) + hash) + (*it);
+ for (; it != it_end; ++it) {
+ hash = ((hash << 5) + hash) + (*it);
}
// Reset sign bit in case it has been set.
@@ -1166,30 +1153,30 @@ int32_t CacheManager::GenerateHash(const std::string& str_to_hash) {
}
void CacheManager::GetAppRequestTypes(
- const std::string& policy_app_id,
- std::vector<std::string>& request_types) const {
+ const std::string &policy_app_id,
+ std::vector<std::string> &request_types) const {
LOG4CXX_AUTO_TRACE(logger_);
CACHE_MANAGER_CHECK_VOID();
policy_table::ApplicationPolicies::iterator policy_iter =
pt_->policy_table.app_policies_section.apps.find(policy_app_id);
if (pt_->policy_table.app_policies_section.apps.end() == policy_iter) {
LOG4CXX_DEBUG(logger_, "Can't find request types for app_id "
- << policy_app_id);
+ << policy_app_id);
return;
}
policy_table::RequestTypes::iterator it_request_type =
policy_iter->second.RequestType->begin();
- for (;it_request_type != policy_iter->second.RequestType->end();
+ for (; it_request_type != policy_iter->second.RequestType->end();
++it_request_type) {
request_types.push_back(EnumToJsonString(*it_request_type));
}
return;
}
-CacheManager::BackgroundBackuper::BackgroundBackuper(CacheManager* cache_manager)
- : cache_manager_(cache_manager),
- stop_flag_(false),
- new_data_available_(false) {
+CacheManager::BackgroundBackuper::BackgroundBackuper(
+ CacheManager *cache_manager)
+ : cache_manager_(cache_manager), stop_flag_(false),
+ new_data_available_(false) {
LOG4CXX_AUTO_TRACE(logger_);
}
@@ -1237,4 +1224,4 @@ void CacheManager::BackgroundBackuper::DoBackup() {
backup_notifier_.NotifyOne();
}
-} // namespace policy
+} // namespace policy
diff --git a/src/components/policy/src/policy/src/policy_manager_impl.cc b/src/components/policy/src/policy/src/policy_manager_impl.cc
index 1489df6e7f..0e73a465d8 100644
--- a/src/components/policy/src/policy/src/policy_manager_impl.cc
+++ b/src/components/policy/src/policy/src/policy_manager_impl.cc
@@ -1,5 +1,5 @@
/*
- Copyright (c) 2013, Ford Motor Company
+ Copyright (c) 2016, Ford Motor Company
All rights reserved.
Redistribution and use in source and binary forms, with or without
@@ -43,36 +43,40 @@
#include "utils/file_system.h"
#include "utils/logger.h"
#include "utils/date_time.h"
+#include "utils/make_shared.h"
#include "policy/cache_manager.h"
#include "policy/update_status_manager.h"
#include "config_profile/profile.h"
-policy::PolicyManager* CreateManager() {
+policy::PolicyManager *CreateManager() {
return new policy::PolicyManagerImpl();
}
+namespace {
+const uint32_t kDefaultRetryTimeoutInSec = 60u;
+} // namespace
+
namespace policy {
CREATE_LOGGERPTR_GLOBAL(logger_, "PolicyManagerImpl")
PolicyManagerImpl::PolicyManagerImpl()
- : PolicyManager(),
- listener_(NULL),
- cache_(new CacheManager),
- retry_sequence_timeout_(60),
- retry_sequence_index_(0),
- ignition_check(true) {
-}
-
-void PolicyManagerImpl::set_listener(PolicyListener* listener) {
+ : PolicyManager(), listener_(NULL), cache_(new CacheManager),
+ retry_sequence_timeout_(kDefaultRetryTimeoutInSec),
+ retry_sequence_index_(0),
+ timer_retry_sequence_("Retry sequence timer", this,
+ &PolicyManagerImpl::RetrySequence),
+ ignition_check(true) {}
+
+void PolicyManagerImpl::set_listener(PolicyListener *listener) {
listener_ = listener;
update_status_manager_.set_listener(listener);
}
#ifdef USE_HMI_PTU_DECRYPTION
-utils::SharedPtr<policy_table::Table> PolicyManagerImpl::Parse(
- const BinaryMessage& pt_content) {
+utils::SharedPtr<policy_table::Table>
+PolicyManagerImpl::Parse(const BinaryMessage &pt_content) {
std::string json(pt_content.begin(), pt_content.end());
Json::Value value;
Json::Reader reader;
@@ -85,16 +89,16 @@ utils::SharedPtr<policy_table::Table> PolicyManagerImpl::Parse(
#else
-utils::SharedPtr<policy_table::Table> PolicyManagerImpl::ParseArray(
- const BinaryMessage& pt_content) {
+utils::SharedPtr<policy_table::Table>
+PolicyManagerImpl::ParseArray(const BinaryMessage &pt_content) {
std::string json(pt_content.begin(), pt_content.end());
Json::Value value;
Json::Reader reader;
if (reader.parse(json.c_str(), value)) {
- //For PT Update received from SDL Server.
- if (value["data"].size()!=0) {
+ // For PT Update received from SDL Server.
+ if (value["data"].size() != 0) {
Json::Value data = value["data"];
- //First Element in
+ // First Element in
return new policy_table::Table(&data[0]);
} else {
return new policy_table::Table(&value);
@@ -111,37 +115,36 @@ void PolicyManagerImpl::CheckTriggers() {
const bool exceed_ignition_cycles = ExceededIgnitionCycles();
const bool exceed_days = ExceededDays();
- LOG4CXX_DEBUG(
- logger_,
- "\nDays exceeded: " << std::boolalpha << exceed_ignition_cycles <<
- "\nStatusUpdateRequired: " << std::boolalpha<< exceed_days);
+ LOG4CXX_DEBUG(logger_, "\nDays exceeded: "
+ << std::boolalpha << exceed_ignition_cycles
+ << "\nStatusUpdateRequired: " << std::boolalpha
+ << exceed_days);
if (exceed_ignition_cycles || exceed_days) {
update_status_manager_.ScheduleUpdate();
}
}
-bool PolicyManagerImpl::LoadPT(const std::string& file,
- const BinaryMessage& pt_content) {
+bool PolicyManagerImpl::LoadPT(const std::string &file,
+ const BinaryMessage &pt_content) {
LOG4CXX_INFO(logger_, "LoadPT of size " << pt_content.size());
- #ifdef USE_HMI_PTU_DECRYPTION
+#ifdef USE_HMI_PTU_DECRYPTION
// Assuemes Policy Table was parsed, formatted, and/or decrypted by
// the HMI after system request before calling OnReceivedPolicyUpdate
// Parse message into table struct
utils::SharedPtr<policy_table::Table> pt_update = Parse(pt_content);
- #else
- //Message Received from server unecnrypted with PTU in first element
- //of 'data' array. No Parsing was done by HMI.
+#else
+ // Message Received from server unecnrypted with PTU in first element
+ // of 'data' array. No Parsing was done by HMI.
utils::SharedPtr<policy_table::Table> pt_update = ParseArray(pt_content);
- #endif
+#endif
if (!pt_update) {
LOG4CXX_WARN(logger_, "Parsed table pointer is 0.");
update_status_manager_.OnWrongUpdateReceived();
return false;
}
-
if (!IsPTValid(pt_update, policy_table::PT_UPDATE)) {
update_status_manager_.OnWrongUpdateReceived();
return false;
@@ -150,6 +153,12 @@ bool PolicyManagerImpl::LoadPT(const std::string& file,
update_status_manager_.OnValidUpdateReceived();
cache_->SaveUpdateRequired(false);
+ // Update finished, no need retry
+ if (timer_retry_sequence_.isRunning()) {
+ LOG4CXX_INFO(logger_, "Stop retry sequence");
+ timer_retry_sequence_.stop();
+ }
+
apps_registration_lock_.Acquire();
// Get current DB data, since it could be updated during awaiting of PTU
@@ -173,10 +182,6 @@ bool PolicyManagerImpl::LoadPT(const std::string& file,
return false;
}
- if (pt_update->policy_table.module_config.certificate.is_initialized()) {
- listener_->OnCertificateUpdated(*(pt_update->policy_table.module_config.certificate));
- }
-
std::map<std::string, StringArray> app_hmi_types;
cache_->GetHMIAppTypeAfterUpdate(app_hmi_types);
if (!app_hmi_types.empty()) {
@@ -214,29 +219,29 @@ void PolicyManagerImpl::CheckPermissionsChanges(
}
void PolicyManagerImpl::PrepareNotificationData(
- const policy_table::FunctionalGroupings& groups,
- const policy_table::Strings& group_names,
- const std::vector<FunctionalGroupPermission>& group_permission,
- Permissions& notification_data) {
+ const policy_table::FunctionalGroupings &groups,
+ const policy_table::Strings &group_names,
+ const std::vector<FunctionalGroupPermission> &group_permission,
+ Permissions &notification_data) {
LOG4CXX_INFO(logger_, "Preparing data for notification.");
ProcessFunctionalGroup processor(groups, group_permission, notification_data);
std::for_each(group_names.begin(), group_names.end(), processor);
}
-void PolicyManagerImpl::GetServiceUrls(const std::string& service_type,
- EndpointUrls& end_points) {
+void PolicyManagerImpl::GetServiceUrls(const std::string &service_type,
+ EndpointUrls &end_points) {
LOG4CXX_AUTO_TRACE(logger_);
cache_->GetServiceUrls(service_type, end_points);
}
-void PolicyManagerImpl::RequestPTUpdate() {
+bool PolicyManagerImpl::RequestPTUpdate() {
LOG4CXX_AUTO_TRACE(logger_);
utils::SharedPtr<policy_table::Table> policy_table_snapshot =
cache_->GenerateSnapshot();
if (!policy_table_snapshot) {
LOG4CXX_ERROR(logger_, "Failed to create snapshot of policy table");
- return;
+ return false;
}
IsPTValid(policy_table_snapshot, policy_table::PT_SNAPSHOT);
@@ -245,16 +250,17 @@ void PolicyManagerImpl::RequestPTUpdate() {
Json::FastWriter writer;
std::string message_string = writer.write(value);
- LOG4CXX_DEBUG(logger_, "Snapshot contents is : " << message_string );
+ LOG4CXX_DEBUG(logger_, "Snapshot contents is : " << message_string);
BinaryMessage update(message_string.begin(), message_string.end());
-
listener_->OnSnapshotCreated(update);
// Need to reset update schedule since all currenly registered applications
// were already added to the snapshot so no update for them required.
update_status_manager_.ResetUpdateSchedule();
+
+ return true;
}
std::string PolicyManagerImpl::GetLockScreenIconUrl() const {
@@ -264,17 +270,19 @@ std::string PolicyManagerImpl::GetLockScreenIconUrl() const {
void PolicyManagerImpl::StartPTExchange() {
LOG4CXX_AUTO_TRACE(logger_);
- if (update_status_manager_.IsAppsSearchInProgress()) {
+ const bool update_required = update_status_manager_.IsUpdateRequired();
+
+ if (update_status_manager_.IsAppsSearchInProgress() && update_required) {
update_status_manager_.ScheduleUpdate();
LOG4CXX_INFO(logger_, "Starting exchange skipped, since applications "
- "search is in progress.");
+ "search is in progress.");
return;
}
- if (update_status_manager_.IsUpdatePending()) {
+ if (update_status_manager_.IsUpdatePending() && update_required) {
update_status_manager_.ScheduleUpdate();
LOG4CXX_INFO(logger_, "Starting exchange skipped, since another exchange "
- "is in progress.");
+ "is in progress.");
return;
}
@@ -284,8 +292,11 @@ void PolicyManagerImpl::StartPTExchange() {
ignition_check = false;
}
- if (update_status_manager_.IsUpdateRequired()) {
- RequestPTUpdate();
+ if (update_required) {
+ if (RequestPTUpdate() && !timer_retry_sequence_.isRunning()) {
+ LOG4CXX_DEBUG(logger_, "Starting retry sequence.");
+ timer_retry_sequence_.start(NextRetryTimeout());
+ }
}
}
}
@@ -303,21 +314,26 @@ void PolicyManagerImpl::OnAppsSearchCompleted() {
}
}
-const std::vector<std::string> PolicyManagerImpl::GetAppRequestTypes(
- const std::string policy_app_id) const {
+void PolicyManagerImpl::OnAppRegisteredOnMobile(
+ const std::string &application_id) {
+ StartPTExchange();
+ SendNotificationOnPermissionsUpdated(application_id);
+}
+
+const std::vector<std::string>
+PolicyManagerImpl::GetAppRequestTypes(const std::string policy_app_id) const {
std::vector<std::string> request_types;
cache_->GetAppRequestTypes(policy_app_id, request_types);
return request_types;
}
-void PolicyManagerImpl::CheckPermissions(const PTString& app_id,
- const PTString& hmi_level,
- const PTString& rpc,
- const RPCParams& rpc_params,
- CheckPermissionResult& result) {
- LOG4CXX_INFO(
- logger_,
- "CheckPermissions for " << app_id << " and rpc " << rpc << " for "
- << hmi_level << " level.");
+void PolicyManagerImpl::CheckPermissions(const PTString &app_id,
+ const PTString &hmi_level,
+ const PTString &rpc,
+ const RPCParams &rpc_params,
+ CheckPermissionResult &result) {
+ LOG4CXX_INFO(logger_, "CheckPermissions for " << app_id << " and rpc " << rpc
+ << " for " << hmi_level
+ << " level.");
cache_->CheckPermissions(app_id, hmi_level, rpc, result);
}
@@ -329,12 +345,12 @@ bool PolicyManagerImpl::ResetUserConsent() {
}
void PolicyManagerImpl::SendNotificationOnPermissionsUpdated(
- const std::string& application_id) {
+ const std::string &application_id) {
LOG4CXX_AUTO_TRACE(logger_);
const std::string device_id = GetCurrentDeviceId(application_id);
if (device_id.empty()) {
LOG4CXX_WARN(logger_, "Couldn't find device info for application id "
- "'" << application_id << "'");
+ "'" << application_id << "'");
return;
}
@@ -346,18 +362,19 @@ void PolicyManagerImpl::SendNotificationOnPermissionsUpdated(
policy_table::Strings app_groups;
std::vector<FunctionalGroupPermission>::const_iterator it =
- app_group_permissions.begin();
+ app_group_permissions.begin();
std::vector<FunctionalGroupPermission>::const_iterator it_end =
- app_group_permissions.end();
+ app_group_permissions.end();
for (; it != it_end; ++it) {
app_groups.push_back((*it).group_name);
}
Permissions notification_data;
- PrepareNotificationData(functional_groupings, app_groups, app_group_permissions,
- notification_data);
+ PrepareNotificationData(functional_groupings, app_groups,
+ app_group_permissions, notification_data);
- LOG4CXX_INFO(logger_, "Send notification for application_id:" << application_id);
+ LOG4CXX_INFO(logger_,
+ "Send notification for application_id:" << application_id);
std::string default_hmi;
default_hmi = "NONE";
@@ -372,14 +389,14 @@ bool PolicyManagerImpl::CleanupUnpairedDevices() {
return true;
}
-DeviceConsent PolicyManagerImpl::GetUserConsentForDevice(
- const std::string& device_id) {
+DeviceConsent
+PolicyManagerImpl::GetUserConsentForDevice(const std::string &device_id) {
LOG4CXX_AUTO_TRACE(logger_);
return kDeviceAllowed;
}
-void PolicyManagerImpl::SetUserConsentForDevice(const std::string& device_id,
- bool is_allowed) {
+void PolicyManagerImpl::SetUserConsentForDevice(const std::string &device_id,
+ bool is_allowed) {
LOG4CXX_INFO(logger_, "SetUserConsentForDevice");
LOG4CXX_DEBUG(logger_, "Device :" << device_id);
DeviceConsent current_consent = GetUserConsentForDevice(device_id);
@@ -394,13 +411,13 @@ void PolicyManagerImpl::SetUserConsentForDevice(const std::string& device_id,
}
bool PolicyManagerImpl::ReactOnUserDevConsentForApp(const std::string app_id,
- bool is_device_allowed) {
+ bool is_device_allowed) {
return true;
}
-bool PolicyManagerImpl::GetInitialAppData(const std::string& application_id,
- StringArray* nicknames,
- StringArray* app_hmi_types) {
+bool PolicyManagerImpl::GetInitialAppData(const std::string &application_id,
+ StringArray *nicknames,
+ StringArray *app_hmi_types) {
LOG4CXX_INFO(logger_, "GetInitialAppData");
const bool result = nicknames && app_hmi_types;
if (result) {
@@ -409,14 +426,14 @@ bool PolicyManagerImpl::GetInitialAppData(const std::string& application_id,
return result;
}
-void PolicyManagerImpl::SetDeviceInfo(const std::string& device_id,
- const DeviceInfo& device_info) {
+void PolicyManagerImpl::SetDeviceInfo(const std::string &device_id,
+ const DeviceInfo &device_info) {
LOG4CXX_INFO(logger_, "SetDeviceInfo");
LOG4CXX_DEBUG(logger_, "Device :" << device_id);
}
PermissionConsent PolicyManagerImpl::EnsureCorrectPermissionConsent(
- const PermissionConsent& permissions_to_check) {
+ const PermissionConsent &permissions_to_check) {
std::vector<FunctionalGroupPermission> current_user_consents;
GetUserConsentForApp(permissions_to_check.device_id,
permissions_to_check.policy_app_id,
@@ -432,7 +449,7 @@ PermissionConsent PolicyManagerImpl::EnsureCorrectPermissionConsent(
std::vector<FunctionalGroupPermission>::const_iterator it_end =
permissions_to_check.group_permissions.end();
- for (;it != it_end; ++it) {
+ for (; it != it_end; ++it) {
std::vector<FunctionalGroupPermission>::const_iterator it_curr =
current_user_consents.begin();
std::vector<FunctionalGroupPermission>::const_iterator it_curr_end =
@@ -450,22 +467,20 @@ PermissionConsent PolicyManagerImpl::EnsureCorrectPermissionConsent(
}
void PolicyManagerImpl::CheckPendingPermissionsChanges(
- const std::string& policy_app_id,
- const std::vector<FunctionalGroupPermission>& current_permissions) {
+ const std::string &policy_app_id,
+ const std::vector<FunctionalGroupPermission> &current_permissions) {
LOG4CXX_INFO(logger_, "CheckPendingPermissionsChanges");
sync_primitives::AutoLock lock(app_permissions_diff_lock_);
std::map<std::string, AppPermissions>::iterator it_pending =
app_permissions_diff_.find(policy_app_id);
if (app_permissions_diff_.end() == it_pending) {
- LOG4CXX_WARN(logger_,
- "No pending permissions had been found for appID: "
- << policy_app_id);
+ LOG4CXX_WARN(logger_, "No pending permissions had been found for appID: "
+ << policy_app_id);
return;
}
- LOG4CXX_DEBUG(logger_,
- "Pending permissions had been found for appID: "
- << policy_app_id);
+ LOG4CXX_DEBUG(logger_, "Pending permissions had been found for appID: "
+ << policy_app_id);
// Change appPermissionsConsentNeeded depending on unconsented groups
// presence
@@ -476,34 +491,32 @@ void PolicyManagerImpl::CheckPendingPermissionsChanges(
for (; it_groups != it_end_groups; ++it_groups) {
if (policy::kGroupUndefined == it_groups->state) {
- LOG4CXX_DEBUG(logger_,
- "Unconsented groups still present for appID: "
- << policy_app_id);
+ LOG4CXX_DEBUG(logger_, "Unconsented groups still present for appID: "
+ << policy_app_id);
it_pending->second.appPermissionsConsentNeeded = true;
return;
}
}
- LOG4CXX_DEBUG(logger_,
- "Unconsented groups not present anymore for appID: "
- << policy_app_id);
+ LOG4CXX_DEBUG(logger_, "Unconsented groups not present anymore for appID: "
+ << policy_app_id);
it_pending->second.appPermissionsConsentNeeded = false;
return;
}
void PolicyManagerImpl::SetUserConsentForApp(
- const PermissionConsent& permissions) {
+ const PermissionConsent &permissions) {
LOG4CXX_INFO(logger_, "SetUserConsentForApp");
}
-bool PolicyManagerImpl::GetDefaultHmi(const std::string& policy_app_id,
- std::string* default_hmi) {
+bool PolicyManagerImpl::GetDefaultHmi(const std::string &policy_app_id,
+ std::string *default_hmi) {
LOG4CXX_INFO(logger_, "GetDefaultHmi");
return false;
}
-bool PolicyManagerImpl::GetPriority(const std::string& policy_app_id,
- std::string* priority) {
+bool PolicyManagerImpl::GetPriority(const std::string &policy_app_id,
+ std::string *priority) {
LOG4CXX_INFO(logger_, "GetPriority");
if (!priority) {
LOG4CXX_WARN(logger_, "Input priority parameter is null.");
@@ -514,20 +527,19 @@ bool PolicyManagerImpl::GetPriority(const std::string& policy_app_id,
}
std::vector<UserFriendlyMessage> PolicyManagerImpl::GetUserFriendlyMessages(
- const std::vector<std::string>& message_code, const std::string& language) {
+ const std::vector<std::string> &message_code, const std::string &language) {
return cache_->GetUserFriendlyMsg(message_code, language);
}
void PolicyManagerImpl::GetUserConsentForApp(
- const std::string& device_id, const std::string& policy_app_id,
- std::vector<FunctionalGroupPermission>& permissions) {
+ const std::string &device_id, const std::string &policy_app_id,
+ std::vector<FunctionalGroupPermission> &permissions) {
LOG4CXX_INFO(logger_, "GetUserConsentForApp");
FunctionalIdType group_types;
- if (!cache_->GetPermissionsForApp(device_id, policy_app_id,
- group_types)) {
+ if (!cache_->GetPermissionsForApp(device_id, policy_app_id, group_types)) {
LOG4CXX_WARN(logger_, "Can't get user permissions for app "
- << policy_app_id);
+ << policy_app_id);
return;
}
@@ -542,7 +554,7 @@ void PolicyManagerImpl::GetUserConsentForApp(
FunctionalGroupNames::const_iterator it = group_names.begin();
FunctionalGroupNames::const_iterator it_end = group_names.end();
FunctionalGroupIDs auto_allowed_groups;
- for (;it != it_end; ++it) {
+ for (; it != it_end; ++it) {
if (it->second.first.empty()) {
auto_allowed_groups.push_back(it->first);
}
@@ -562,13 +574,13 @@ void PolicyManagerImpl::GetUserConsentForApp(
} else if (cache_->IsPredataPolicy(policy_app_id)) {
allowed_groups = ExcludeSame(no_auto, predataconsented_groups);
}
- FillFunctionalGroupPermissions(allowed_groups, group_names,
- kGroupAllowed, permissions);
+ FillFunctionalGroupPermissions(allowed_groups, group_names, kGroupAllowed,
+ permissions);
}
void PolicyManagerImpl::GetPermissionsForApp(
- const std::string& device_id, const std::string& policy_app_id,
- std::vector<FunctionalGroupPermission>& permissions) {
+ const std::string &device_id, const std::string &policy_app_id,
+ std::vector<FunctionalGroupPermission> &permissions) {
LOG4CXX_INFO(logger_, "GetPermissionsForApp");
std::string app_id_to_check = policy_app_id;
@@ -583,10 +595,9 @@ void PolicyManagerImpl::GetPermissionsForApp(
}
FunctionalIdType group_types;
- if (!cache_->GetPermissionsForApp(device_id, app_id_to_check,
- group_types)) {
+ if (!cache_->GetPermissionsForApp(device_id, app_id_to_check, group_types)) {
LOG4CXX_WARN(logger_, "Can't get user permissions for app "
- << policy_app_id);
+ << policy_app_id);
return;
}
@@ -602,8 +613,8 @@ void PolicyManagerImpl::GetPermissionsForApp(
// So, check if application in the one of these mode.
if (allowed_by_default) {
LOG4CXX_INFO(logger_, "Get auto allowed groups");
- GroupType type = (kDefaultId == app_id_to_check ?
- kTypeDefault : kTypePreDataConsented);
+ GroupType type =
+ (kDefaultId == app_id_to_check ? kTypeDefault : kTypePreDataConsented);
FillFunctionalGroupPermissions(group_types[type], group_names,
kGroupAllowed, permissions);
@@ -617,26 +628,24 @@ void PolicyManagerImpl::GetPermissionsForApp(
// In case of GENIVI all groups are allowed
FunctionalGroupIDs common_allowed = all_groups;
- FillFunctionalGroupPermissions(common_allowed, group_names,
- kGroupAllowed, permissions);
+ FillFunctionalGroupPermissions(common_allowed, group_names, kGroupAllowed,
+ permissions);
}
return;
}
-std::string& PolicyManagerImpl::GetCurrentDeviceId(
- const std::string& policy_app_id) {
+std::string &
+PolicyManagerImpl::GetCurrentDeviceId(const std::string &policy_app_id) {
LOG4CXX_INFO(logger_, "GetDeviceInfo");
- last_device_id_ =
- listener()->OnCurrentDeviceIdUpdateRequired(policy_app_id);
+ last_device_id_ = listener()->OnCurrentDeviceIdUpdateRequired(policy_app_id);
return last_device_id_;
}
-void PolicyManagerImpl::SetSystemLanguage(const std::string& language) {
-}
+void PolicyManagerImpl::SetSystemLanguage(const std::string &language) {}
-void PolicyManagerImpl::SetSystemInfo(const std::string& ccpu_version,
- const std::string& wers_country_code,
- const std::string& language) {
+void PolicyManagerImpl::SetSystemInfo(const std::string &ccpu_version,
+ const std::string &wers_country_code,
+ const std::string &language) {
LOG4CXX_INFO(logger_, "SetSystemInfo");
}
@@ -648,8 +657,8 @@ void PolicyManagerImpl::OnSystemReady() {
}
}
-uint32_t PolicyManagerImpl::GetNotificationsNumber(
- const std::string& priority) {
+uint32_t
+PolicyManagerImpl::GetNotificationsNumber(const std::string &priority) {
LOG4CXX_INFO(logger_, "GetNotificationsNumber");
return cache_->GetNotificationsNumber(priority);
}
@@ -663,12 +672,10 @@ bool PolicyManagerImpl::IsPTValid(
policy_table::PolicyTableType type) const {
policy_table->SetPolicyTableType(type);
if (!policy_table->is_valid()) {
- LOG4CXX_ERROR(
- logger_, "Policy table is not valid.");
+ LOG4CXX_ERROR(logger_, "Policy table is not valid.");
rpc::ValidationReport report("policy_table");
policy_table->ReportErrors(&report);
- LOG4CXX_DEBUG(logger_,
- "Errors: " << rpc::PrettyFormat(report));
+ LOG4CXX_DEBUG(logger_, "Errors: " << rpc::PrettyFormat(report));
return false;
}
return true;
@@ -687,6 +694,7 @@ void PolicyManagerImpl::KmsChanged(int kilometers) {
LOG4CXX_AUTO_TRACE(logger_);
if (0 == cache_->KilometersBeforeExchange(kilometers)) {
LOG4CXX_INFO(logger_, "Enough kilometers passed to send for PT update.");
+ update_status_manager_.ScheduleUpdate();
StartPTExchange();
}
}
@@ -705,15 +713,25 @@ std::string PolicyManagerImpl::GetPolicyTableStatus() const {
return update_status_manager_.StringifiedUpdateStatus();
}
-int PolicyManagerImpl::NextRetryTimeout() {
+uint32_t PolicyManagerImpl::NextRetryTimeout() {
sync_primitives::AutoLock auto_lock(retry_sequence_lock_);
LOG4CXX_DEBUG(logger_, "Index: " << retry_sequence_index_);
- int next = 0;
- if (!retry_sequence_seconds_.empty()
- && retry_sequence_index_ < retry_sequence_seconds_.size()) {
- next = retry_sequence_seconds_[retry_sequence_index_];
- ++retry_sequence_index_;
+ uint32_t next = 0u;
+ if (retry_sequence_seconds_.empty() ||
+ retry_sequence_index_ >= retry_sequence_seconds_.size()) {
+ LOG4CXX_WARN(logger_, "Next retry timeout is " << next);
+ return next;
}
+
+ ++retry_sequence_index_;
+
+ for (uint32_t i = 0u; i < retry_sequence_index_; ++i) {
+ next += retry_sequence_seconds_[i];
+ LOG4CXX_DEBUG(logger_, "Next retry timeout to add is " << next);
+ // According to requirement APPLINK-18244
+ }
+ next += retry_sequence_timeout_;
+ LOG4CXX_DEBUG(logger_, "Total retry timeout is " << next);
return next;
}
@@ -730,9 +748,7 @@ void PolicyManagerImpl::ResetRetrySequence() {
update_status_manager_.OnResetRetrySequence();
}
-int PolicyManagerImpl::TimeoutExchange() {
- return retry_sequence_timeout_;
-}
+int PolicyManagerImpl::TimeoutExchange() { return retry_sequence_timeout_; }
const std::vector<int> PolicyManagerImpl::RetrySequenceDelaysSeconds() {
sync_primitives::AutoLock auto_lock(retry_sequence_lock_);
@@ -752,52 +768,50 @@ void PolicyManagerImpl::OnUpdateStarted() {
void PolicyManagerImpl::PTUpdatedAt(int kilometers, int days_after_epoch) {
LOG4CXX_INFO(logger_, "PTUpdatedAt");
- LOG4CXX_INFO(logger_,
- "Kilometers: " << kilometers << " Days: " << days_after_epoch);
- cache_->SetCountersPassedForSuccessfulUpdate(
- kilometers, days_after_epoch);
+ LOG4CXX_INFO(logger_, "Kilometers: " << kilometers
+ << " Days: " << days_after_epoch);
+ cache_->SetCountersPassedForSuccessfulUpdate(kilometers, days_after_epoch);
cache_->ResetIgnitionCycles();
}
void PolicyManagerImpl::Increment(usage_statistics::GlobalCounterId type) {
- LOG4CXX_INFO(logger_, "Increment without app id" );
+ LOG4CXX_INFO(logger_, "Increment without app id");
sync_primitives::AutoLock locker(statistics_lock_);
}
-void PolicyManagerImpl::Increment(const std::string& app_id,
- usage_statistics::AppCounterId type){
+void PolicyManagerImpl::Increment(const std::string &app_id,
+ usage_statistics::AppCounterId type) {
LOG4CXX_INFO(logger_, "Increment " << app_id);
sync_primitives::AutoLock locker(statistics_lock_);
}
-void PolicyManagerImpl::Set(const std::string& app_id,
+void PolicyManagerImpl::Set(const std::string &app_id,
usage_statistics::AppInfoId type,
- const std::string& value) {
+ const std::string &value) {
LOG4CXX_INFO(logger_, "Set " << app_id);
sync_primitives::AutoLock locker(statistics_lock_);
}
-void PolicyManagerImpl::Add(const std::string& app_id,
+void PolicyManagerImpl::Add(const std::string &app_id,
usage_statistics::AppStopwatchId type,
int32_t timespan_seconds) {
LOG4CXX_INFO(logger_, "Add " << app_id);
sync_primitives::AutoLock locker(statistics_lock_);
}
-bool PolicyManagerImpl::IsApplicationRevoked(const std::string& app_id) const {
+bool PolicyManagerImpl::IsApplicationRevoked(const std::string &app_id) const {
return cache_->IsApplicationRevoked(app_id);
}
-bool PolicyManagerImpl::IsConsentNeeded(const std::string& app_id) {
+bool PolicyManagerImpl::IsConsentNeeded(const std::string &app_id) {
LOG4CXX_AUTO_TRACE(logger_);
return false;
}
-void PolicyManagerImpl::SetVINValue(const std::string& value) {
-}
+void PolicyManagerImpl::SetVINValue(const std::string &value) {}
-AppPermissions PolicyManagerImpl::GetAppPermissionsChanges(
- const std::string& policy_app_id) {
+AppPermissions
+PolicyManagerImpl::GetAppPermissionsChanges(const std::string &policy_app_id) {
typedef std::map<std::string, AppPermissions>::iterator PermissionsIt;
PermissionsIt app_id_diff = app_permissions_diff_.find(policy_app_id);
AppPermissions permissions(policy_app_id);
@@ -812,22 +826,21 @@ AppPermissions PolicyManagerImpl::GetAppPermissionsChanges(
}
void PolicyManagerImpl::RemovePendingPermissionChanges(
- const std::string& app_id) {
+ const std::string &app_id) {
app_permissions_diff_.erase(app_id);
}
-bool PolicyManagerImpl::CanAppKeepContext(const std::string& app_id) {
+bool PolicyManagerImpl::CanAppKeepContext(const std::string &app_id) {
return cache_->CanAppKeepContext(app_id);
}
-bool PolicyManagerImpl::CanAppStealFocus(const std::string& app_id) {
+bool PolicyManagerImpl::CanAppStealFocus(const std::string &app_id) {
return cache_->CanAppStealFocus(app_id);
}
-void PolicyManagerImpl::MarkUnpairedDevice(const std::string& device_id) {
-}
+void PolicyManagerImpl::MarkUnpairedDevice(const std::string &device_id) {}
-void PolicyManagerImpl::AddApplication(const std::string& application_id) {
+void PolicyManagerImpl::AddApplication(const std::string &application_id) {
LOG4CXX_INFO(logger_, "AddApplication");
const std::string device_id = GetCurrentDeviceId(application_id);
DeviceConsent device_consent = GetUserConsentForDevice(device_id);
@@ -839,21 +852,19 @@ void PolicyManagerImpl::AddApplication(const std::string& application_id) {
} else {
PromoteExistedApplication(application_id, device_consent);
}
- StartPTExchange();
- SendNotificationOnPermissionsUpdated(application_id);
}
-void PolicyManagerImpl::RemoveAppConsentForGroup(const std::string& app_id,
- const std::string& group_name) {
- cache_->RemoveAppConsentForGroup(app_id, group_name);
+void PolicyManagerImpl::RemoveAppConsentForGroup(
+ const std::string &app_id, const std::string &group_name) {
+ cache_->RemoveAppConsentForGroup(app_id, group_name);
}
bool PolicyManagerImpl::IsPredataPolicy(const std::string &policy_app_id) {
- LOG4CXX_INFO(logger_, "IsPredataApp");
- return cache_->IsPredataPolicy(policy_app_id);
+ LOG4CXX_INFO(logger_, "IsPredataApp");
+ return cache_->IsPredataPolicy(policy_app_id);
}
-void PolicyManagerImpl::AddNewApplication(const std::string& application_id,
+void PolicyManagerImpl::AddNewApplication(const std::string &application_id,
DeviceConsent device_consent) {
LOG4CXX_AUTO_TRACE(logger_);
@@ -861,21 +872,21 @@ void PolicyManagerImpl::AddNewApplication(const std::string& application_id,
}
void PolicyManagerImpl::PromoteExistedApplication(
- const std::string& application_id, DeviceConsent device_consent) {
+ const std::string &application_id, DeviceConsent device_consent) {
// If device consent changed to allowed during application being
// disconnected, app permissions should be changed also
- if (kDeviceAllowed == device_consent
- && cache_->IsPredataPolicy(application_id)) {
+ if (kDeviceAllowed == device_consent &&
+ cache_->IsPredataPolicy(application_id)) {
cache_->SetDefaultPolicy(application_id);
}
}
bool PolicyManagerImpl::IsNewApplication(
- const std::string& application_id) const {
+ const std::string &application_id) const {
return false == cache_->IsApplicationRepresented(application_id);
}
-bool PolicyManagerImpl::ResetPT(const std::string& file_name) {
+bool PolicyManagerImpl::ResetPT(const std::string &file_name) {
cache_->ResetCalculatedPermissions();
const bool result = cache_->ResetPT(file_name);
if (result) {
@@ -890,21 +901,21 @@ bool PolicyManagerImpl::CheckAppStorageFolder() const {
profile::Profile::instance()->app_storage_folder();
LOG4CXX_DEBUG(logger_, "AppStorageFolder " << app_storage_folder);
if (!file_system::DirectoryExists(app_storage_folder)) {
- LOG4CXX_WARN(logger_,
- "Storage directory doesn't exist " << app_storage_folder);
+ LOG4CXX_WARN(logger_, "Storage directory doesn't exist "
+ << app_storage_folder);
return false;
}
if (!(file_system::IsWritingAllowed(app_storage_folder) &&
file_system::IsReadingAllowed(app_storage_folder))) {
- LOG4CXX_WARN(
- logger_,
- "Storage directory doesn't have read/write permissions " << app_storage_folder);
+ LOG4CXX_WARN(logger_,
+ "Storage directory doesn't have read/write permissions "
+ << app_storage_folder);
return false;
}
return true;
}
-bool PolicyManagerImpl::InitPT(const std::string& file_name) {
+bool PolicyManagerImpl::InitPT(const std::string &file_name) {
LOG4CXX_AUTO_TRACE(logger_);
if (!CheckAppStorageFolder()) {
LOG4CXX_ERROR(logger_, "Can not read/write into AppStorageFolder");
@@ -918,7 +929,7 @@ bool PolicyManagerImpl::InitPT(const std::string& file_name) {
return ret;
}
-uint16_t PolicyManagerImpl::HeartBeatTimeout(const std::string& app_id) const {
+uint16_t PolicyManagerImpl::HeartBeatTimeout(const std::string &app_id) const {
return cache_->HeartBeatTimeout(app_id);
}
@@ -927,9 +938,22 @@ void PolicyManagerImpl::SaveUpdateStatusRequired(bool is_update_needed) {
}
void PolicyManagerImpl::set_cache_manager(
- CacheManagerInterface* cache_manager) {
+ CacheManagerInterface *cache_manager) {
cache_ = cache_manager;
}
-} // namespace policy
+void PolicyManagerImpl::RetrySequence() {
+ LOG4CXX_INFO(logger_, "Start new retry sequence");
+ RequestPTUpdate();
+
+ uint32_t timeout = NextRetryTimeout();
+
+ if (!timeout && timer_retry_sequence_.isRunning()) {
+ timer_retry_sequence_.stop();
+ return;
+ }
+
+ timer_retry_sequence_.start(timeout);
+}
+} // namespace policy
diff --git a/src/components/policy/src/policy/src/sql_pt_queries.cc b/src/components/policy/src/policy/src/sql_pt_queries.cc
index efc2d60c2f..150934615f 100644
--- a/src/components/policy/src/policy/src/sql_pt_queries.cc
+++ b/src/components/policy/src/policy/src/sql_pt_queries.cc
@@ -1,4 +1,4 @@
-/*
+/*
Copyright (c) 2013, " Ford Motor Company
All rights reserved.
@@ -38,483 +38,505 @@ namespace sql_pt {
const std::string kSelectPriority =
"SELECT `priority_value` FROM `application` WHERE `id` = ? LIMIT 1";
const std::string kCreateSchema =
- "BEGIN; "
- "CREATE TABLE IF NOT EXISTS `device`( "
- " `id` VARCHAR(100) PRIMARY KEY NOT NULL, "
- " `hardware` VARCHAR(45), "
- " `firmware_rev` VARCHAR(45), "
- " `os` VARCHAR(45), "
- " `os_version` VARCHAR(45), "
- " `carrier` VARCHAR(45), "
- " `max_number_rfcom_ports` INTEGER,"
- " `connection_type` VARCHAR(45), "
- " `unpaired` BOOL "
- "); "
- "CREATE TABLE IF NOT EXISTS `usage_and_error_count`( "
- " `count_of_iap_buffer_full` INTEGER, "
- " `count_sync_out_of_memory` INTEGER, "
- " `count_of_sync_reboots` INTEGER "
- "); "
- "CREATE TABLE IF NOT EXISTS `module_meta`( "
- " `ccpu_version` VARCHAR(45), "
- " `language` VARCHAR(45), "
- " `wers_country_code` VARCHAR(45), "
- " `pt_exchanged_at_odometer_x` INTEGER NOT NULL DEFAULT 0, "
- " `pt_exchanged_x_days_after_epoch` INTEGER NOT NULL DEFAULT 0, "
- " `ignition_cycles_since_last_exchange` INTEGER NOT NULL DEFAULT 0, "
- " `vin` VARCHAR(45),"
- " `flag_update_required` BOOL NOT NULL "
- "); "
- "CREATE TABLE IF NOT EXISTS `module_config`( "
- " `preloaded_pt` BOOL NOT NULL, "
- " `is_first_run` BOOL NOT NULL, "
- " `exchange_after_x_ignition_cycles` INTEGER NOT NULL, "
- " `exchange_after_x_kilometers` INTEGER NOT NULL, "
- " `exchange_after_x_days` INTEGER NOT NULL, "
- " `timeout_after_x_seconds` INTEGER NOT NULL, "
- " `vehicle_make` VARCHAR(45), "
- " `vehicle_model` VARCHAR(45), "
- " `vehicle_year` VARCHAR(4) "
- "); "
- "CREATE TABLE IF NOT EXISTS `functional_group`( "
- " `id` INTEGER PRIMARY KEY NOT NULL, "
- " `user_consent_prompt` TEXT UNIQUE ON CONFLICT REPLACE, "
- " `name` VARCHAR(100) NOT NULL "
- "); "
- "CREATE TABLE IF NOT EXISTS `priority`( "
- " `value` VARCHAR(45) PRIMARY KEY NOT NULL "
- "); "
- "CREATE TABLE IF NOT EXISTS `hmi_level`( "
- " `value` VARCHAR(45) PRIMARY KEY NOT NULL "
- "); "
- "CREATE TABLE IF NOT EXISTS `notifications_by_priority`( "
- " `priority_value` VARCHAR(45) PRIMARY KEY NOT NULL, "
- " `value` INTEGER NOT NULL, "
- " CONSTRAINT `fk_notifications_by_priority_priority1` "
- " FOREIGN KEY(`priority_value`) "
- " REFERENCES `priority`(`value`) "
- "); "
- "CREATE INDEX IF NOT EXISTS "
- "`notifications_by_priority.fk_notifications_by_priority_priority1_idx` "
- " ON `notifications_by_priority`(`priority_value`); "
- "CREATE TABLE IF NOT EXISTS `language`( "
- " `code` VARCHAR(25) PRIMARY KEY NOT NULL "
- "); "
- "CREATE TABLE IF NOT EXISTS `message_type`( "
- " `name` VARCHAR(45) PRIMARY KEY NOT NULL "
- "); "
- "CREATE TABLE IF NOT EXISTS `version`( "
- " `number` VARCHAR(45) NOT NULL "
- "); "
- "CREATE TABLE IF NOT EXISTS `rpc`( "
- " `id` INTEGER PRIMARY KEY NOT NULL, "
- " `name` VARCHAR(45) NOT NULL, "
- " `parameter` VARCHAR(45), "
- " `hmi_level_value` VARCHAR(45) NOT NULL, "
- " `functional_group_id` INTEGER NOT NULL, "
- " CONSTRAINT `fk_rpc_hmi_level1` "
- " FOREIGN KEY(`hmi_level_value`) "
- " REFERENCES `hmi_level`(`value`), "
- " CONSTRAINT `fk_rpc_functional_group1` "
- " FOREIGN KEY(`functional_group_id`) "
- " REFERENCES `functional_group`(`id`) "
- "); "
- "CREATE INDEX IF NOT EXISTS `rpc.fk_rpc_hmi_level1_idx` "
- " ON `rpc`(`hmi_level_value`); "
- "CREATE INDEX IF NOT EXISTS `rpc.fk_rpc_functional_group1_idx` "
- " ON `rpc`(`functional_group_id`); "
- "CREATE INDEX `rpc.select_rpc_name_hmi_level` "
- " ON `rpc`(`name`,`hmi_level_value`);"
- "CREATE TABLE IF NOT EXISTS `application`( "
- " `id` VARCHAR(45) PRIMARY KEY NOT NULL, "
- " `keep_context` BOOLEAN, "
- " `steal_focus` BOOLEAN, "
- " `default_hmi` VARCHAR(45), "
- " `priority_value` VARCHAR(45), "
- " `is_revoked` BOOLEAN, "
- " `is_default` BOOLEAN, "
- " `is_predata` BOOLEAN, "
- " `memory_kb` INTEGER NOT NULL, "
- " `heart_beat_timeout_ms` INTEGER NOT NULL, "
- " `certificate` VARCHAR(45), "
- " CONSTRAINT `fk_application_hmi_level1` "
- " FOREIGN KEY(`default_hmi`) "
- " REFERENCES `hmi_level`(`value`), "
- " CONSTRAINT `fk_application_priorities1` "
- " FOREIGN KEY(`priority_value`) "
- " REFERENCES `priority`(`value`) "
- "); "
- "CREATE INDEX IF NOT EXISTS `application.fk_application_hmi_level1_idx` "
- " ON `application`(`default_hmi`); "
- "CREATE INDEX IF NOT EXISTS `application.fk_application_priorities1_idx` "
- " ON `application`(`priority_value`); "
- "CREATE TABLE IF NOT EXISTS `app_group`( "
- " `application_id` VARCHAR(45) NOT NULL, "
- " `functional_group_id` INTEGER NOT NULL, "
- " PRIMARY KEY(`application_id`,`functional_group_id`), "
- " CONSTRAINT `fk_application_has_functional_group_application1` "
- " FOREIGN KEY(`application_id`) "
- " REFERENCES `application`(`id`), "
- " CONSTRAINT `fk_application_has_functional_group_functional_group1` "
- " FOREIGN KEY(`functional_group_id`) "
- " REFERENCES `functional_group`(`id`) "
- "); "
- "CREATE INDEX IF NOT EXISTS `app_group.fk_application_has_functional_group_functional_group1_idx` "
- " ON `app_group`(`functional_group_id`); "
- "CREATE INDEX IF NOT EXISTS `app_group.fk_application_has_functional_group_application1_idx` "
- " ON `app_group`(`application_id`); "
- "CREATE TABLE IF NOT EXISTS `preconsented_group`( "
- " `application_id` VARCHAR(45) NOT NULL, "
- " `functional_group_id` INTEGER NOT NULL, "
- " PRIMARY KEY(`application_id`,`functional_group_id`), "
- " CONSTRAINT `fk_application_has_functional_group_application2` "
- " FOREIGN KEY(`application_id`) "
- " REFERENCES `application`(`id`), "
- " CONSTRAINT `fk_application_has_functional_group_functional_group2` "
- " FOREIGN KEY(`functional_group_id`) "
- " REFERENCES `functional_group`(`id`) "
- "); "
- "CREATE INDEX IF NOT EXISTS "
- "`preconsented_group.fk_application_has_functional_group_functional_group2_idx` "
- " ON `preconsented_group`(`functional_group_id`); "
- "CREATE INDEX IF NOT EXISTS "
- "`preconsented_group.fk_application_has_functional_group_application2_idx` "
- " ON `preconsented_group`(`application_id`); "
- "CREATE TABLE IF NOT EXISTS `seconds_between_retry`( "
- " `index` INTEGER PRIMARY KEY NOT NULL, "
- " `value` INTEGER NOT NULL "
- "); "
- "CREATE TABLE IF NOT EXISTS `device_consent_group`( "
- " `device_id` VARCHAR(100) NOT NULL, "
- " `functional_group_id` INTEGER NOT NULL, "
- " `is_consented` BOOL NOT NULL, "
- " `input` VARCHAR(45), "
- " `time_stamp` VARCHAR(45), "
- " PRIMARY KEY(`device_id`,`functional_group_id`), "
- " CONSTRAINT `fk_device_has_functional_group_device1` "
- " FOREIGN KEY(`device_id`) "
- " REFERENCES `device`(`id`), "
- " CONSTRAINT `fk_device_has_functional_group_functional_group1` "
- " FOREIGN KEY(`functional_group_id`) "
- " REFERENCES `functional_group`(`id`) "
- "); "
- "CREATE INDEX IF NOT EXISTS "
- "`device_consent_group.fk_device_has_functional_group_functional_group1_idx` "
- " ON `device_consent_group`(`functional_group_id`); "
- "CREATE INDEX IF NOT EXISTS "
- "`device_consent_group.fk_device_has_functional_group_device1_idx` "
- " ON `device_consent_group`(`device_id`); "
- "CREATE TABLE IF NOT EXISTS `app_level`( "
- " `application_id` VARCHAR(45) PRIMARY KEY NOT NULL, "
- " `minutes_in_hmi_full` INTEGER DEFAULT 0, "
- " `minutes_in_hmi_limited` INTEGER DEFAULT 0, "
- " `minutes_in_hmi_background` INTEGER DEFAULT 0, "
- " `minutes_in_hmi_none` INTEGER DEFAULT 0, "
- " `count_of_user_selections` INTEGER DEFAULT 0, "
- " `count_of_rejections_sync_out_of_memory` INTEGER DEFAULT 0, "
- " `count_of_rejections_nickname_mismatch` INTEGER DEFAULT 0, "
- " `count_of_rejections_duplicate_name` INTEGER DEFAULT 0, "
- " `count_of_rejected_rpcs_calls` INTEGER DEFAULT 0, "
- " `count_of_rpcs_sent_in_hmi_none` INTEGER DEFAULT 0, "
- " `count_of_removals_for_bad_behavior` INTEGER DEFAULT 0, "
- " `count_of_run_attempts_while_revoked` INTEGER DEFAULT 0, "
- " `app_registration_language_gui` VARCHAR(25), "
- " `app_registration_language_vui` VARCHAR(25), "
- " CONSTRAINT `fk_app_levels_application1` "
- " FOREIGN KEY(`application_id`) "
- " REFERENCES `application`(`id`), "
- " CONSTRAINT `fk_app_level_language1` "
- " FOREIGN KEY(`app_registration_language_gui`) "
- " REFERENCES `language`(`code`), "
- " CONSTRAINT `fk_app_level_language2` "
- " FOREIGN KEY(`app_registration_language_vui`) "
- " REFERENCES `language`(`code`) "
- "); "
- "CREATE INDEX IF NOT EXISTS `app_level.fk_app_levels_application1_idx` "
- " ON `app_level`(`application_id`); "
- "CREATE INDEX IF NOT EXISTS `app_level.fk_app_level_language1_idx` "
- " ON `app_level`(`app_registration_language_gui`); "
- "CREATE INDEX IF NOT EXISTS `app_level.fk_app_level_language2_idx` "
- " ON `app_level`(`app_registration_language_vui`); "
- "CREATE TABLE IF NOT EXISTS `nickname`( "
- " `name` VARCHAR(100) NOT NULL, "
- " `application_id` VARCHAR(45) NOT NULL, "
- " PRIMARY KEY(`name`,`application_id`), "
- " CONSTRAINT `fk_nickname_application1` "
- " FOREIGN KEY(`application_id`) "
- " REFERENCES `application`(`id`) "
- "); "
- "CREATE INDEX IF NOT EXISTS `nickname.fk_nickname_application1_idx` "
- " ON `nickname`(`application_id`); "
- "CREATE TABLE IF NOT EXISTS `app_type`( "
- " `name` VARCHAR(50) NOT NULL, "
- " `application_id` VARCHAR(45) NOT NULL, "
- " PRIMARY KEY(`name`,`application_id`), "
- " CONSTRAINT `fk_app_type_application1` "
- " FOREIGN KEY(`application_id`) "
- " REFERENCES `application`(`id`) "
- "); "
- "CREATE TABLE IF NOT EXISTS `request_type`( "
- " `request_type` VARCHAR(50) NOT NULL, "
- " `application_id` VARCHAR(45) NOT NULL, "
- " PRIMARY KEY(`request_type`,`application_id`), "
- " CONSTRAINT `fk_app_type_application1` "
- " FOREIGN KEY(`application_id`) "
- " REFERENCES `application`(`id`) "
- "); "
- "CREATE INDEX IF NOT EXISTS `app_type.fk_app_type_application1_idx` "
- " ON `app_type`(`application_id`); "
- "CREATE TABLE IF NOT EXISTS `consent_group`( "
- " `device_id` VARCHAR(100) NOT NULL, "
- " `application_id` VARCHAR(45) NOT NULL, "
- " `functional_group_id` INTEGER NOT NULL, "
- " `is_consented` BOOL NOT NULL, "
- " `input` VARCHAR(45), "
- " `time_stamp` VARCHAR(45), "
- " PRIMARY KEY(`application_id`,`functional_group_id`,`device_id`), "
- " CONSTRAINT `fk_consent_group_device1` "
- " FOREIGN KEY(`device_id`) "
- " REFERENCES `device`(`id`), "
- " CONSTRAINT `fk_consent_group_application1` "
- " FOREIGN KEY(`application_id`) "
- " REFERENCES `application`(`id`), "
- " CONSTRAINT `fk_consent_group_functional_group1` "
- " FOREIGN KEY(`functional_group_id`) "
- " REFERENCES `functional_group`(`id`) "
- "); "
- "CREATE INDEX IF NOT EXISTS "
- "`consent_group.fk_consent_group_device1_idx` "
- " ON `device_consent_group`(`device_id`); "
- "CREATE INDEX IF NOT EXISTS `consent_group.fk_consent_group_functional_group1_idx` "
- " ON `consent_group`(`functional_group_id`); "
- "CREATE TABLE IF NOT EXISTS `endpoint`( "
- " `service` VARCHAR(100) NOT NULL, "
- " `url` VARCHAR(100) NOT NULL, "
- " `application_id` VARCHAR(45) NOT NULL, "
- " CONSTRAINT `fk_endpoint_application1` "
- " FOREIGN KEY(`application_id`) "
- " REFERENCES `application`(`id`) "
- "); "
- "CREATE INDEX IF NOT EXISTS `endpoint.fk_endpoint_application1_idx` "
- " ON `endpoint`(`application_id`); "
- "CREATE TABLE IF NOT EXISTS `message`( "
- " `id` INTEGER PRIMARY KEY NOT NULL, "
- " `tts` TEXT, "
- " `label` TEXT, "
- " `line1` TEXT, "
- " `line2` TEXT, "
- " `textBody` TEXT, "
- " `language_code` VARCHAR(25) NOT NULL, "
- " `message_type_name` VARCHAR(45) NOT NULL, "
- " CONSTRAINT `fk_messages_languages1` "
- " FOREIGN KEY(`language_code`) "
- " REFERENCES `language`(`code`), "
- " CONSTRAINT `fk_message_consumer_friendly_messages1` "
- " FOREIGN KEY(`message_type_name`) "
- " REFERENCES `message_type`(`name`) "
- "); "
- "CREATE INDEX IF NOT EXISTS `message.fk_messages_languages1_idx` "
- " ON `message`(`language_code`);"
- "CREATE INDEX IF NOT EXISTS `message.fk_message_consumer_friendly_messages1_idx` "
- " ON `message`(`message_type_name`);"
- "COMMIT;";
+ "BEGIN; "
+ "CREATE TABLE IF NOT EXISTS `device`( "
+ " `id` VARCHAR(100) PRIMARY KEY NOT NULL, "
+ " `hardware` VARCHAR(45), "
+ " `firmware_rev` VARCHAR(45), "
+ " `os` VARCHAR(45), "
+ " `os_version` VARCHAR(45), "
+ " `carrier` VARCHAR(45), "
+ " `max_number_rfcom_ports` INTEGER,"
+ " `connection_type` VARCHAR(45), "
+ " `unpaired` BOOL "
+ "); "
+ "CREATE TABLE IF NOT EXISTS `usage_and_error_count`( "
+ " `count_of_iap_buffer_full` INTEGER, "
+ " `count_sync_out_of_memory` INTEGER, "
+ " `count_of_sync_reboots` INTEGER "
+ "); "
+ "CREATE TABLE IF NOT EXISTS `module_meta`( "
+ " `ccpu_version` VARCHAR(45), "
+ " `language` VARCHAR(45), "
+ " `wers_country_code` VARCHAR(45), "
+ " `pt_exchanged_at_odometer_x` INTEGER NOT NULL DEFAULT 0, "
+ " `pt_exchanged_x_days_after_epoch` INTEGER NOT NULL DEFAULT 0, "
+ " `ignition_cycles_since_last_exchange` INTEGER NOT NULL DEFAULT 0, "
+ " `vin` VARCHAR(45),"
+ " `flag_update_required` BOOL NOT NULL "
+ "); "
+ "CREATE TABLE IF NOT EXISTS `module_config`( "
+ " `preloaded_pt` BOOL NOT NULL, "
+ " `is_first_run` BOOL NOT NULL, "
+ " `exchange_after_x_ignition_cycles` INTEGER NOT NULL, "
+ " `exchange_after_x_kilometers` INTEGER NOT NULL, "
+ " `exchange_after_x_days` INTEGER NOT NULL, "
+ " `timeout_after_x_seconds` INTEGER NOT NULL, "
+ " `vehicle_make` VARCHAR(45), "
+ " `vehicle_model` VARCHAR(45), "
+ " `vehicle_year` VARCHAR(4)"
+ "); "
+ "CREATE TABLE IF NOT EXISTS `functional_group`( "
+ " `id` INTEGER PRIMARY KEY NOT NULL, "
+ " `user_consent_prompt` TEXT UNIQUE ON CONFLICT REPLACE, "
+ " `name` VARCHAR(100) NOT NULL "
+ "); "
+ "CREATE TABLE IF NOT EXISTS `priority`( "
+ " `value` VARCHAR(45) PRIMARY KEY NOT NULL "
+ "); "
+ "CREATE TABLE IF NOT EXISTS `hmi_level`( "
+ " `value` VARCHAR(45) PRIMARY KEY NOT NULL "
+ "); "
+ "CREATE TABLE IF NOT EXISTS `notifications_by_priority`( "
+ " `priority_value` VARCHAR(45) PRIMARY KEY NOT NULL, "
+ " `value` INTEGER NOT NULL, "
+ " CONSTRAINT `fk_notifications_by_priority_priority1` "
+ " FOREIGN KEY(`priority_value`) "
+ " REFERENCES `priority`(`value`) "
+ "); "
+ "CREATE INDEX IF NOT EXISTS "
+ "`notifications_by_priority.fk_notifications_by_priority_priority1_idx` "
+ " ON `notifications_by_priority`(`priority_value`); "
+ "CREATE TABLE IF NOT EXISTS `language`( "
+ " `code` VARCHAR(25) PRIMARY KEY NOT NULL "
+ "); "
+ "CREATE TABLE IF NOT EXISTS `message_type`( "
+ " `name` VARCHAR(45) PRIMARY KEY NOT NULL "
+ "); "
+ "CREATE TABLE IF NOT EXISTS `version`( "
+ " `number` VARCHAR(45) NOT NULL "
+ "); "
+ "CREATE TABLE IF NOT EXISTS `rpc`( "
+ " `id` INTEGER PRIMARY KEY NOT NULL, "
+ " `name` VARCHAR(45) NOT NULL, "
+ " `parameter` VARCHAR(45), "
+ " `hmi_level_value` VARCHAR(45) NOT NULL, "
+ " `functional_group_id` INTEGER NOT NULL, "
+ " CONSTRAINT `fk_rpc_hmi_level1` "
+ " FOREIGN KEY(`hmi_level_value`) "
+ " REFERENCES `hmi_level`(`value`), "
+ " CONSTRAINT `fk_rpc_functional_group1` "
+ " FOREIGN KEY(`functional_group_id`) "
+ " REFERENCES `functional_group`(`id`) "
+ "); "
+ "CREATE INDEX IF NOT EXISTS `rpc.fk_rpc_hmi_level1_idx` "
+ " ON `rpc`(`hmi_level_value`); "
+ "CREATE INDEX IF NOT EXISTS `rpc.fk_rpc_functional_group1_idx` "
+ " ON `rpc`(`functional_group_id`); "
+ "CREATE INDEX `rpc.select_rpc_name_hmi_level` "
+ " ON `rpc`(`name`,`hmi_level_value`);"
+ "CREATE TABLE IF NOT EXISTS `application`( "
+ " `id` VARCHAR(45) PRIMARY KEY NOT NULL, "
+ " `keep_context` BOOLEAN, "
+ " `steal_focus` BOOLEAN, "
+ " `default_hmi` VARCHAR(45), "
+ " `priority_value` VARCHAR(45), "
+ " `is_revoked` BOOLEAN, "
+ " `is_default` BOOLEAN, "
+ " `is_predata` BOOLEAN, "
+ " `memory_kb` INTEGER NOT NULL, "
+ " `heart_beat_timeout_ms` INTEGER NOT NULL, "
+ " `certificate` VARCHAR(45), "
+ " CONSTRAINT `fk_application_hmi_level1` "
+ " FOREIGN KEY(`default_hmi`) "
+ " REFERENCES `hmi_level`(`value`), "
+ " CONSTRAINT `fk_application_priorities1` "
+ " FOREIGN KEY(`priority_value`) "
+ " REFERENCES `priority`(`value`) "
+ "); "
+ "CREATE INDEX IF NOT EXISTS `application.fk_application_hmi_level1_idx` "
+ " ON `application`(`default_hmi`); "
+ "CREATE INDEX IF NOT EXISTS `application.fk_application_priorities1_idx` "
+ " ON `application`(`priority_value`); "
+ "CREATE TABLE IF NOT EXISTS `app_group`( "
+ " `application_id` VARCHAR(45) NOT NULL, "
+ " `functional_group_id` INTEGER NOT NULL, "
+ " PRIMARY KEY(`application_id`,`functional_group_id`), "
+ " CONSTRAINT `fk_application_has_functional_group_application1` "
+ " FOREIGN KEY(`application_id`) "
+ " REFERENCES `application`(`id`), "
+ " CONSTRAINT `fk_application_has_functional_group_functional_group1` "
+ " FOREIGN KEY(`functional_group_id`) "
+ " REFERENCES `functional_group`(`id`) "
+ "); "
+ "CREATE INDEX IF NOT EXISTS "
+ "`app_group.fk_application_has_functional_group_functional_group1_idx` "
+ " ON `app_group`(`functional_group_id`); "
+ "CREATE INDEX IF NOT EXISTS "
+ "`app_group.fk_application_has_functional_group_application1_idx` "
+ " ON `app_group`(`application_id`); "
+ "CREATE TABLE IF NOT EXISTS `preconsented_group`( "
+ " `application_id` VARCHAR(45) NOT NULL, "
+ " `functional_group_id` INTEGER NOT NULL, "
+ " PRIMARY KEY(`application_id`,`functional_group_id`), "
+ " CONSTRAINT `fk_application_has_functional_group_application2` "
+ " FOREIGN KEY(`application_id`) "
+ " REFERENCES `application`(`id`), "
+ " CONSTRAINT `fk_application_has_functional_group_functional_group2` "
+ " FOREIGN KEY(`functional_group_id`) "
+ " REFERENCES `functional_group`(`id`) "
+ "); "
+ "CREATE INDEX IF NOT EXISTS "
+ "`preconsented_group.fk_application_has_functional_group_functional_group2_"
+ "idx` "
+ " ON `preconsented_group`(`functional_group_id`); "
+ "CREATE INDEX IF NOT EXISTS "
+ "`preconsented_group.fk_application_has_functional_group_application2_idx` "
+ " ON `preconsented_group`(`application_id`); "
+ "CREATE TABLE IF NOT EXISTS `seconds_between_retry`( "
+ " `index` INTEGER PRIMARY KEY NOT NULL, "
+ " `value` INTEGER NOT NULL "
+ "); "
+ "CREATE TABLE IF NOT EXISTS `device_consent_group`( "
+ " `device_id` VARCHAR(100) NOT NULL, "
+ " `functional_group_id` INTEGER NOT NULL, "
+ " `is_consented` BOOL NOT NULL, "
+ " `input` VARCHAR(45), "
+ " `time_stamp` VARCHAR(45), "
+ " PRIMARY KEY(`device_id`,`functional_group_id`), "
+ " CONSTRAINT `fk_device_has_functional_group_device1` "
+ " FOREIGN KEY(`device_id`) "
+ " REFERENCES `device`(`id`), "
+ " CONSTRAINT `fk_device_has_functional_group_functional_group1` "
+ " FOREIGN KEY(`functional_group_id`) "
+ " REFERENCES `functional_group`(`id`) "
+ "); "
+ "CREATE INDEX IF NOT EXISTS "
+ "`device_consent_group.fk_device_has_functional_group_functional_group1_"
+ "idx` "
+ " ON `device_consent_group`(`functional_group_id`); "
+ "CREATE INDEX IF NOT EXISTS "
+ "`device_consent_group.fk_device_has_functional_group_device1_idx` "
+ " ON `device_consent_group`(`device_id`); "
+ "CREATE TABLE IF NOT EXISTS `app_level`( "
+ " `application_id` VARCHAR(45) PRIMARY KEY NOT NULL, "
+ " `minutes_in_hmi_full` INTEGER DEFAULT 0, "
+ " `minutes_in_hmi_limited` INTEGER DEFAULT 0, "
+ " `minutes_in_hmi_background` INTEGER DEFAULT 0, "
+ " `minutes_in_hmi_none` INTEGER DEFAULT 0, "
+ " `count_of_user_selections` INTEGER DEFAULT 0, "
+ " `count_of_rejections_sync_out_of_memory` INTEGER DEFAULT 0, "
+ " `count_of_rejections_nickname_mismatch` INTEGER DEFAULT 0, "
+ " `count_of_rejections_duplicate_name` INTEGER DEFAULT 0, "
+ " `count_of_rejected_rpcs_calls` INTEGER DEFAULT 0, "
+ " `count_of_rpcs_sent_in_hmi_none` INTEGER DEFAULT 0, "
+ " `count_of_removals_for_bad_behavior` INTEGER DEFAULT 0, "
+ " `count_of_run_attempts_while_revoked` INTEGER DEFAULT 0, "
+ " `app_registration_language_gui` VARCHAR(25), "
+ " `app_registration_language_vui` VARCHAR(25), "
+ " CONSTRAINT `fk_app_levels_application1` "
+ " FOREIGN KEY(`application_id`) "
+ " REFERENCES `application`(`id`), "
+ " CONSTRAINT `fk_app_level_language1` "
+ " FOREIGN KEY(`app_registration_language_gui`) "
+ " REFERENCES `language`(`code`), "
+ " CONSTRAINT `fk_app_level_language2` "
+ " FOREIGN KEY(`app_registration_language_vui`) "
+ " REFERENCES `language`(`code`) "
+ "); "
+ "CREATE INDEX IF NOT EXISTS `app_level.fk_app_levels_application1_idx` "
+ " ON `app_level`(`application_id`); "
+ "CREATE INDEX IF NOT EXISTS `app_level.fk_app_level_language1_idx` "
+ " ON `app_level`(`app_registration_language_gui`); "
+ "CREATE INDEX IF NOT EXISTS `app_level.fk_app_level_language2_idx` "
+ " ON `app_level`(`app_registration_language_vui`); "
+ "CREATE TABLE IF NOT EXISTS `nickname`( "
+ " `name` VARCHAR(100) NOT NULL, "
+ " `application_id` VARCHAR(45) NOT NULL, "
+ " PRIMARY KEY(`name`,`application_id`), "
+ " CONSTRAINT `fk_nickname_application1` "
+ " FOREIGN KEY(`application_id`) "
+ " REFERENCES `application`(`id`) "
+ "); "
+ "CREATE INDEX IF NOT EXISTS `nickname.fk_nickname_application1_idx` "
+ " ON `nickname`(`application_id`); "
+ "CREATE TABLE IF NOT EXISTS `app_type`( "
+ " `name` VARCHAR(50) NOT NULL, "
+ " `application_id` VARCHAR(45) NOT NULL, "
+ " PRIMARY KEY(`name`,`application_id`), "
+ " CONSTRAINT `fk_app_type_application1` "
+ " FOREIGN KEY(`application_id`) "
+ " REFERENCES `application`(`id`) "
+ "); "
+ "CREATE TABLE IF NOT EXISTS `request_type`( "
+ " `request_type` VARCHAR(50) NOT NULL, "
+ " `application_id` VARCHAR(45) NOT NULL, "
+ " PRIMARY KEY(`request_type`,`application_id`), "
+ " CONSTRAINT `fk_app_type_application1` "
+ " FOREIGN KEY(`application_id`) "
+ " REFERENCES `application`(`id`) "
+ "); "
+ "CREATE INDEX IF NOT EXISTS `app_type.fk_app_type_application1_idx` "
+ " ON `app_type`(`application_id`); "
+ "CREATE TABLE IF NOT EXISTS `consent_group`( "
+ " `device_id` VARCHAR(100) NOT NULL, "
+ " `application_id` VARCHAR(45) NOT NULL, "
+ " `functional_group_id` INTEGER NOT NULL, "
+ " `is_consented` BOOL NOT NULL, "
+ " `input` VARCHAR(45), "
+ " `time_stamp` VARCHAR(45), "
+ " PRIMARY KEY(`application_id`,`functional_group_id`,`device_id`), "
+ " CONSTRAINT `fk_consent_group_device1` "
+ " FOREIGN KEY(`device_id`) "
+ " REFERENCES `device`(`id`), "
+ " CONSTRAINT `fk_consent_group_application1` "
+ " FOREIGN KEY(`application_id`) "
+ " REFERENCES `application`(`id`), "
+ " CONSTRAINT `fk_consent_group_functional_group1` "
+ " FOREIGN KEY(`functional_group_id`) "
+ " REFERENCES `functional_group`(`id`) "
+ "); "
+ "CREATE INDEX IF NOT EXISTS "
+ "`consent_group.fk_consent_group_device1_idx` "
+ " ON `device_consent_group`(`device_id`); "
+ "CREATE INDEX IF NOT EXISTS "
+ "`consent_group.fk_consent_group_functional_group1_idx` "
+ " ON `consent_group`(`functional_group_id`); "
+ "CREATE TABLE IF NOT EXISTS `endpoint`( "
+ " `service` VARCHAR(100) NOT NULL, "
+ " `url` VARCHAR(100) NOT NULL, "
+ " `application_id` VARCHAR(45) NOT NULL, "
+ " CONSTRAINT `fk_endpoint_application1` "
+ " FOREIGN KEY(`application_id`) "
+ " REFERENCES `application`(`id`) "
+ "); "
+ "CREATE INDEX IF NOT EXISTS `endpoint.fk_endpoint_application1_idx` "
+ " ON `endpoint`(`application_id`); "
+ "CREATE TABLE IF NOT EXISTS `message`( "
+ " `id` INTEGER PRIMARY KEY NOT NULL, "
+ " `tts` TEXT, "
+ " `label` TEXT, "
+ " `line1` TEXT, "
+ " `line2` TEXT, "
+ " `textBody` TEXT, "
+ " `language_code` VARCHAR(25) NOT NULL, "
+ " `message_type_name` VARCHAR(45) NOT NULL, "
+ " CONSTRAINT `fk_messages_languages1` "
+ " FOREIGN KEY(`language_code`) "
+ " REFERENCES `language`(`code`), "
+ " CONSTRAINT `fk_message_consumer_friendly_messages1` "
+ " FOREIGN KEY(`message_type_name`) "
+ " REFERENCES `message_type`(`name`) "
+ "); "
+ "CREATE INDEX IF NOT EXISTS `message.fk_messages_languages1_idx` "
+ " ON `message`(`language_code`);"
+ "CREATE INDEX IF NOT EXISTS "
+ "`message.fk_message_consumer_friendly_messages1_idx` "
+ " ON `message`(`message_type_name`);"
+ "COMMIT;";
const std::string kInsertInitData =
- "INSERT OR IGNORE INTO `usage_and_error_count` ( "
- " `count_of_iap_buffer_full`, `count_sync_out_of_memory`, "
- " `count_of_sync_reboots`) VALUES (0, 0, 0); "
- "INSERT OR IGNORE INTO `module_meta` (`pt_exchanged_at_odometer_x`, "
- " `pt_exchanged_x_days_after_epoch`, `ignition_cycles_since_last_exchange`,"
- " `flag_update_required`) "
- " VALUES (0, 0, 0, 0); "
- "INSERT OR IGNORE INTO `module_config` (`preloaded_pt`, `is_first_run`,"
- " `exchange_after_x_ignition_cycles`, `exchange_after_x_kilometers`, "
- " `exchange_after_x_days`, `timeout_after_x_seconds`) "
- " VALUES(1, 0, 0, 0, 0, 0); "
- "INSERT OR IGNORE INTO `priority`(`value`) VALUES ('EMERGENCY'); "
- "INSERT OR IGNORE INTO `priority`(`value`) VALUES ('NAVIGATION'); "
- "INSERT OR IGNORE INTO `priority`(`value`) VALUES ('VOICECOMMUNICATION'); "
- "INSERT OR IGNORE INTO `priority`(`value`) VALUES ('COMMUNICATION'); "
- "INSERT OR IGNORE INTO `priority`(`value`) VALUES ('NORMAL'); "
- "INSERT OR IGNORE INTO `priority`(`value`) VALUES ('NONE'); "
- "INSERT OR IGNORE INTO `hmi_level`(`value`) VALUES ('FULL'); "
- "INSERT OR IGNORE INTO `hmi_level`(`value`) VALUES ('LIMITED'); "
- "INSERT OR IGNORE INTO `hmi_level`(`value`) VALUES ('BACKGROUND'); "
- "INSERT OR IGNORE INTO `hmi_level`(`value`) VALUES ('NONE'); "
- "INSERT OR IGNORE INTO `version` (`number`) VALUES('0'); "
- "";
+ "INSERT OR IGNORE INTO `usage_and_error_count` ( "
+ " `count_of_iap_buffer_full`, `count_sync_out_of_memory`, "
+ " `count_of_sync_reboots`) VALUES (0, 0, 0); "
+ "INSERT OR IGNORE INTO `module_meta` (`pt_exchanged_at_odometer_x`, "
+ " `pt_exchanged_x_days_after_epoch`, "
+ "`ignition_cycles_since_last_exchange`,"
+ " `flag_update_required`) "
+ " VALUES (0, 0, 0, 0); "
+ "INSERT OR IGNORE INTO `module_config` (`preloaded_pt`, `is_first_run`,"
+ " `exchange_after_x_ignition_cycles`, `exchange_after_x_kilometers`, "
+ " `exchange_after_x_days`, `timeout_after_x_seconds`) "
+ " VALUES(1, 0, 0, 0, 0, 0); "
+ "INSERT OR IGNORE INTO `priority`(`value`) VALUES ('EMERGENCY'); "
+ "INSERT OR IGNORE INTO `priority`(`value`) VALUES ('NAVIGATION'); "
+ "INSERT OR IGNORE INTO `priority`(`value`) VALUES ('VOICECOMMUNICATION'); "
+ "INSERT OR IGNORE INTO `priority`(`value`) VALUES ('COMMUNICATION'); "
+ "INSERT OR IGNORE INTO `priority`(`value`) VALUES ('NORMAL'); "
+ "INSERT OR IGNORE INTO `priority`(`value`) VALUES ('NONE'); "
+ "INSERT OR IGNORE INTO `hmi_level`(`value`) VALUES ('FULL'); "
+ "INSERT OR IGNORE INTO `hmi_level`(`value`) VALUES ('LIMITED'); "
+ "INSERT OR IGNORE INTO `hmi_level`(`value`) VALUES ('BACKGROUND'); "
+ "INSERT OR IGNORE INTO `hmi_level`(`value`) VALUES ('NONE'); "
+ "INSERT OR IGNORE INTO `version` (`number`) VALUES('0'); "
+ "";
const std::string kDropSchema =
- "BEGIN; "
- "DROP INDEX IF EXISTS `message.fk_messages_languages1_idx`; "
- "DROP INDEX IF EXISTS `message.fk_message_consumer_friendly_messages1_idx`; "
- "DROP TABLE IF EXISTS `message`; "
- "DROP INDEX IF EXISTS `endpoint.fk_endpoint_application1_idx`; "
- "DROP TABLE IF EXISTS `endpoint`; "
- "DROP INDEX IF EXISTS `consent_group.fk_consent_group_device1_idx`; "
- "DROP INDEX IF EXISTS `consent_group.fk_consent_group_functional_group1_idx`; "
- "DROP TABLE IF EXISTS `consent_group`; "
- "DROP INDEX IF EXISTS `app_type.fk_app_type_application1_idx`; "
- "DROP TABLE IF EXISTS `app_type`; "
- "DROP INDEX IF EXISTS `nickname.fk_nickname_application1_idx`; "
- "DROP TABLE IF EXISTS `nickname`; "
- "DROP INDEX IF EXISTS `app_level.fk_app_level_language2_idx`; "
- "DROP INDEX IF EXISTS `app_level.fk_app_level_language1_idx`; "
- "DROP INDEX IF EXISTS `app_level.fk_app_levels_application1_idx`; "
- "DROP TABLE IF EXISTS `app_level`; "
- "DROP INDEX IF EXISTS `device_consent_group.fk_device_has_functional_group_device1_idx`; "
- "DROP INDEX IF EXISTS `device_consent_group.fk_device_has_functional_group_functional_group1_idx`; "
- "DROP TABLE IF EXISTS `device_consent_group`; "
- "DROP TABLE IF EXISTS `seconds_between_retry`; "
- "DROP INDEX IF EXISTS `preconsented_group.fk_application_has_functional_group_application2_idx`; "
- "DROP INDEX IF EXISTS `preconsented_group.fk_application_has_functional_group_functional_group2_idx`; "
- "DROP TABLE IF EXISTS `preconsented_group`; "
- "DROP INDEX IF EXISTS `app_group.fk_application_has_functional_group_application1_idx`; "
- "DROP INDEX IF EXISTS `app_group.fk_application_has_functional_group_functional_group1_idx`; "
- "DROP TABLE IF EXISTS `app_group`; "
- "DROP INDEX IF EXISTS `application.fk_application_priorities1_idx`; "
- "DROP INDEX IF EXISTS `application.fk_application_hmi_level1_idx`; "
- "DROP TABLE IF EXISTS `application`; "
- "DROP INDEX IF EXISTS `rpc.select_rpc_name_hmi_level`; "
- "DROP INDEX IF EXISTS `rpc.fk_rpc_functional_group1_idx`; "
- "DROP INDEX IF EXISTS `rpc.fk_rpc_hmi_level1_idx`; "
- "DROP TABLE IF EXISTS `rpc`; "
- "DROP TABLE IF EXISTS `version`; "
- "DROP TABLE IF EXISTS `message_type`; "
- "DROP TABLE IF EXISTS `language`; "
- "DROP INDEX IF EXISTS `notifications_by_priority.fk_notifications_by_priority_priority1_idx`; "
- "DROP TABLE IF EXISTS `notifications_by_priority`; "
- "DROP TABLE IF EXISTS `hmi_level`; "
- "DROP TABLE IF EXISTS `priority`; "
- "DROP TABLE IF EXISTS `functional_group`; "
- "DROP TABLE IF EXISTS `module_config`; "
- "DROP TABLE IF EXISTS `module_meta`; "
- "DROP TABLE IF EXISTS `usage_and_error_count`; "
- "DROP TABLE IF EXISTS `device`; "
- "COMMIT; "
- "VACUUM;";
-
-const std::string kDeleteData =
- "BEGIN; "
- "DELETE FROM `message`; "
- "DELETE FROM `endpoint`; "
- "DELETE FROM `consent_group`; "
- "DELETE FROM `app_type`; "
- "DELETE FROM `nickname`; "
- "DELETE FROM `app_level`; "
- "DELETE FROM `device_consent_group`; "
- "DELETE FROM `seconds_between_retry`; "
- "DELETE FROM `preconsented_group`; "
- "DELETE FROM `app_group`; "
- "DELETE FROM `application`; "
- "DELETE FROM `rpc`; "
- "DELETE FROM `version`; "
- "DELETE FROM `message_type`; "
- "DELETE FROM `language`; "
- "DELETE FROM `notifications_by_priority`; "
- "DELETE FROM `hmi_level`; "
- "DELETE FROM `priority`; "
- "DELETE FROM `functional_group`; "
- "DELETE FROM `module_config`; "
- "DELETE FROM `module_meta`; "
- "DELETE FROM `usage_and_error_count`; "
- "DELETE FROM `device`; "
- "COMMIT; "
- "VACUUM;";
+ "BEGIN; "
+ "DROP INDEX IF EXISTS `message.fk_messages_languages1_idx`; "
+ "DROP INDEX IF EXISTS "
+ "`message.fk_message_consumer_friendly_messages1_idx`; "
+ "DROP TABLE IF EXISTS `message`; "
+ "DROP INDEX IF EXISTS `endpoint.fk_endpoint_application1_idx`; "
+ "DROP TABLE IF EXISTS `endpoint`; "
+ "DROP INDEX IF EXISTS `consent_group.fk_consent_group_device1_idx`; "
+ "DROP INDEX IF EXISTS "
+ "`consent_group.fk_consent_group_functional_group1_idx`; "
+ "DROP TABLE IF EXISTS `consent_group`; "
+ "DROP INDEX IF EXISTS `app_type.fk_app_type_application1_idx`; "
+ "DROP TABLE IF EXISTS `app_type`; "
+ "DROP INDEX IF EXISTS `nickname.fk_nickname_application1_idx`; "
+ "DROP TABLE IF EXISTS `nickname`; "
+ "DROP INDEX IF EXISTS `app_level.fk_app_level_language2_idx`; "
+ "DROP INDEX IF EXISTS `app_level.fk_app_level_language1_idx`; "
+ "DROP INDEX IF EXISTS `app_level.fk_app_levels_application1_idx`; "
+ "DROP TABLE IF EXISTS `app_level`; "
+ "DROP INDEX IF EXISTS "
+ "`device_consent_group.fk_device_has_functional_group_device1_idx`; "
+ "DROP INDEX IF EXISTS "
+ "`device_consent_group.fk_device_has_functional_group_functional_group1_"
+ "idx`; "
+ "DROP TABLE IF EXISTS `device_consent_group`; "
+ "DROP TABLE IF EXISTS `seconds_between_retry`; "
+ "DROP INDEX IF EXISTS "
+ "`preconsented_group.fk_application_has_functional_group_application2_idx`;"
+ " "
+ "DROP INDEX IF EXISTS "
+ "`preconsented_group.fk_application_has_functional_group_functional_group2_"
+ "idx`; "
+ "DROP TABLE IF EXISTS `preconsented_group`; "
+ "DROP INDEX IF EXISTS "
+ "`app_group.fk_application_has_functional_group_application1_idx`; "
+ "DROP INDEX IF EXISTS "
+ "`app_group.fk_application_has_functional_group_functional_group1_idx`; "
+ "DROP TABLE IF EXISTS `app_group`; "
+ "DROP INDEX IF EXISTS `application.fk_application_priorities1_idx`; "
+ "DROP INDEX IF EXISTS `application.fk_application_hmi_level1_idx`; "
+ "DROP TABLE IF EXISTS `application`; "
+ "DROP INDEX IF EXISTS `rpc.select_rpc_name_hmi_level`; "
+ "DROP INDEX IF EXISTS `rpc.fk_rpc_functional_group1_idx`; "
+ "DROP INDEX IF EXISTS `rpc.fk_rpc_hmi_level1_idx`; "
+ "DROP TABLE IF EXISTS `rpc`; "
+ "DROP TABLE IF EXISTS `version`; "
+ "DROP TABLE IF EXISTS `message_type`; "
+ "DROP TABLE IF EXISTS `language`; "
+ "DROP INDEX IF EXISTS "
+ "`notifications_by_priority.fk_notifications_by_priority_priority1_idx`; "
+ "DROP TABLE IF EXISTS `notifications_by_priority`; "
+ "DROP TABLE IF EXISTS `hmi_level`; "
+ "DROP TABLE IF EXISTS `priority`; "
+ "DROP TABLE IF EXISTS `functional_group`; "
+ "DROP TABLE IF EXISTS `module_config`; "
+ "DROP TABLE IF EXISTS `module_meta`; "
+ "DROP TABLE IF EXISTS `usage_and_error_count`; "
+ "DROP TABLE IF EXISTS `device`; "
+ "COMMIT; "
+ "VACUUM;";
+
+const std::string kDeleteData = "BEGIN; "
+ "DELETE FROM `message`; "
+ "DELETE FROM `endpoint`; "
+ "DELETE FROM `consent_group`; "
+ "DELETE FROM `app_type`; "
+ "DELETE FROM `nickname`; "
+ "DELETE FROM `app_level`; "
+ "DELETE FROM `device_consent_group`; "
+ "DELETE FROM `seconds_between_retry`; "
+ "DELETE FROM `preconsented_group`; "
+ "DELETE FROM `app_group`; "
+ "DELETE FROM `application`; "
+ "DELETE FROM `rpc`; "
+ "DELETE FROM `version`; "
+ "DELETE FROM `message_type`; "
+ "DELETE FROM `language`; "
+ "DELETE FROM `notifications_by_priority`; "
+ "DELETE FROM `hmi_level`; "
+ "DELETE FROM `priority`; "
+ "DELETE FROM `functional_group`; "
+ "DELETE FROM `module_config`; "
+ "DELETE FROM `module_meta`; "
+ "DELETE FROM `usage_and_error_count`; "
+ "DELETE FROM `device`; "
+ "COMMIT; "
+ "VACUUM;";
const std::string kCheckDBIntegrity = "PRAGMA integrity_check";
const std::string kCheckPgNumber = "PRAGMA page_count";
const std::string kSelectRpc =
- "SELECT DISTINCT `rpc`.`parameter` FROM `rpc` "
- " JOIN `app_group` AS `g` ON (`g`.`functional_group_id` = `rpc`.`functional_group_id` "
- " AND (`g`.`application_id` = ?)) "
- "WHERE `rpc`.`hmi_level_value` = ? AND `rpc`.`name` = ?";
+ "SELECT DISTINCT `rpc`.`parameter` FROM `rpc` "
+ " JOIN `app_group` AS `g` ON (`g`.`functional_group_id` = "
+ "`rpc`.`functional_group_id` "
+ " AND (`g`.`application_id` = ?)) "
+ "WHERE `rpc`.`hmi_level_value` = ? AND `rpc`.`name` = ?";
const std::string kSelectPreloaded =
- "SELECT `preloaded_pt` FROM `module_config` "
- "WHERE `preloaded_pt` = 1 LIMIT 1";
+ "SELECT `preloaded_pt` FROM `module_config` "
+ "WHERE `preloaded_pt` = 1 LIMIT 1";
const std::string kUpdatePreloaded =
- "UPDATE `module_config` SET `preloaded_pt` = ?";
+ "UPDATE `module_config` SET `preloaded_pt` = ?";
-const std::string kIsFirstRun =
- "SELECT `is_first_run` FROM `module_config` ";
+const std::string kIsFirstRun = "SELECT `is_first_run` FROM `module_config` ";
const std::string kSetNotFirstRun =
- "UPDATE `module_config` SET `is_first_run`= 0 ";
+ "UPDATE `module_config` SET `is_first_run`= 0 ";
const std::string kSelectEndpoint =
- "SELECT `url`, `application_id` FROM `endpoint` WHERE `service` = ? ";
+ "SELECT `url`, `application_id` FROM `endpoint` WHERE `service` = ? ";
const std::string kSelectLockScreenIcon =
- "SELECT `url` FROM `endpoint` WHERE `service` = ? AND `application_id` = ?";
+ "SELECT `url` FROM `endpoint` WHERE `service` = ? AND `application_id` = ?";
const std::string kInsertFunctionalGroup =
- "INSERT INTO `functional_group` (`id`, `name`, `user_consent_prompt`) "
- " VALUES (?, ?, ?)";
+ "INSERT INTO `functional_group` (`id`, `name`, `user_consent_prompt`) "
+ " VALUES (?, ?, ?)";
const std::string kInsertRpc =
- "INSERT INTO `rpc` (`name`, `hmi_level_value`, `functional_group_id`) "
- " VALUES (?, ?, ?)";
+ "INSERT INTO `rpc` (`name`, `hmi_level_value`, `functional_group_id`) "
+ " VALUES (?, ?, ?)";
-const std::string kInsertRpcWithParameter =
- "INSERT INTO `rpc` (`name`, `hmi_level_value`, `parameter`, `functional_group_id`) "
- " VALUES (?, ?, ?, ?)";
+const std::string kInsertRpcWithParameter = "INSERT INTO `rpc` (`name`, "
+ "`hmi_level_value`, `parameter`, "
+ "`functional_group_id`) "
+ " VALUES (?, ?, ?, ?)";
const std::string kInsertApplication =
- "INSERT OR IGNORE INTO `application` (`id`, `priority_value`, `is_revoked`, `memory_kb`,"
- " `heart_beat_timeout_ms`, `certificate`) VALUES (?,?,?,?,?,?)";
+ "INSERT OR IGNORE INTO `application` (`id`, `priority_value`, "
+ "`is_revoked`, `memory_kb`,"
+ " `heart_beat_timeout_ms`, `certificate`) VALUES (?,?,?,?,?,?)";
const std::string kInsertAppGroup =
- "INSERT INTO `app_group` (`application_id`, `functional_group_id`)"
- " SELECT ?, `id` FROM `functional_group` WHERE `name` = ? LIMIT 1";
+ "INSERT INTO `app_group` (`application_id`, `functional_group_id`)"
+ " SELECT ?, `id` FROM `functional_group` WHERE `name` = ? LIMIT 1";
const std::string kInsertNickname =
- "INSERT OR IGNORE INTO `nickname` (`application_id`, `name`) VALUES (?, ?)";
+ "INSERT OR IGNORE INTO `nickname` (`application_id`, `name`) VALUES (?, ?)";
const std::string kInsertAppType =
- "INSERT OR IGNORE INTO `app_type` (`application_id`, `name`) VALUES (?, ?)";
+ "INSERT OR IGNORE INTO `app_type` (`application_id`, `name`) VALUES (?, ?)";
-const std::string kInsertRequestType =
- "INSERT OR IGNORE INTO `request_type` (`application_id`, `request_type`) VALUES (?, ?)";
+const std::string kInsertRequestType = "INSERT OR IGNORE INTO `request_type` "
+ "(`application_id`, `request_type`) "
+ "VALUES (?, ?)";
const std::string kUpdateVersion = "UPDATE `version` SET `number`= ?";
const std::string kInsertMessageType =
- "INSERT OR IGNORE INTO `message_type` (`name`) VALUES (?)";
+ "INSERT OR IGNORE INTO `message_type` (`name`) VALUES (?)";
const std::string kInsertLanguage =
- "INSERT OR IGNORE INTO `language` (`code`) VALUES (?)";
+ "INSERT OR IGNORE INTO `language` (`code`) VALUES (?)";
const std::string kInsertMessageString =
- "INSERT INTO `message` (`tts`, `label`, `line1`, `line2`, `language_code`, "
- " `message_type_name`, `textBody`) VALUES (?, ?, ?, ?, ?, ?, ?)";
+ "INSERT INTO `message` (`tts`, `label`, `line1`, `line2`, `language_code`, "
+ " `message_type_name`, `textBody`) VALUES (?, ?, ?, ?, ?, ?, ?)";
const std::string kUpdateModuleConfig =
- "UPDATE `module_config` SET `preloaded_pt` = ?, "
- " `exchange_after_x_ignition_cycles` = ?,"
- " `exchange_after_x_kilometers` = ?, `exchange_after_x_days` = ?, "
- " `timeout_after_x_seconds` = ?, `vehicle_make` = ?, "
- " `vehicle_model` = ?, `vehicle_year` = ?";
+ "UPDATE `module_config` SET `preloaded_pt` = ?, "
+ " `exchange_after_x_ignition_cycles` = ?,"
+ " `exchange_after_x_kilometers` = ?, `exchange_after_x_days` = ?, "
+ " `timeout_after_x_seconds` = ?, `vehicle_make` = ?, "
+ " `vehicle_model` = ?, `vehicle_year` = ?";
const std::string kInsertEndpoint =
- "INSERT INTO `endpoint` (`service`, `url`, `application_id`) "
- " VALUES (?, ?, ?)";
+ "INSERT INTO `endpoint` (`service`, `url`, `application_id`) "
+ " VALUES (?, ?, ?)";
const std::string kInsertSecondsBetweenRetry =
- "INSERT INTO `seconds_between_retry` (`index`, `value`) VALUES (?, ?)";
+ "INSERT INTO `seconds_between_retry` (`index`, `value`) VALUES (?, ?)";
const std::string kInsertNotificationsByPriority =
- "INSERT OR REPLACE INTO `notifications_by_priority` (`priority_value`, `value`) "
- " VALUES (?, ?)";
+ "INSERT OR REPLACE INTO `notifications_by_priority` (`priority_value`, "
+ "`value`) "
+ " VALUES (?, ?)";
const std::string kInsertDeviceData =
- "INSERT OR IGNORE INTO `device` (`id`) VALUES (?)";
+ "INSERT OR IGNORE INTO `device` (`id`) VALUES (?)";
const std::string kInsertAppLevel =
- "INSERT INTO `app_level` (`application_id`, `minutes_in_hmi_full`,"
+ "INSERT INTO `app_level` (`application_id`, `minutes_in_hmi_full`,"
"`minutes_in_hmi_limited` ,`minutes_in_hmi_background`,"
"`minutes_in_hmi_none`,`count_of_user_selections`,"
"`count_of_rejections_sync_out_of_memory`,"
@@ -525,7 +547,7 @@ const std::string kInsertAppLevel =
"`app_registration_language_vui`) VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
const std::string kDeleteSecondsBetweenRetries =
- "DELETE FROM `seconds_between_retry`";
+ "DELETE FROM `seconds_between_retry`";
const std::string kDeleteEndpoint = "DELETE FROM `endpoint`";
@@ -540,17 +562,17 @@ const std::string kDeleteRpc = "DELETE FROM `rpc`";
const std::string kDeleteAppGroup = "DELETE FROM `app_group`";
const std::string kSelectModuleConfig =
- "SELECT `preloaded_pt`, `exchange_after_x_ignition_cycles`, "
- " `exchange_after_x_kilometers`, `exchange_after_x_days`, "
- " `timeout_after_x_seconds`, `vehicle_make`,"
- " `vehicle_model`, `vehicle_year` "
- " FROM `module_config`";
+ "SELECT `preloaded_pt`, `exchange_after_x_ignition_cycles`, "
+ " `exchange_after_x_kilometers`, `exchange_after_x_days`, "
+ " `timeout_after_x_seconds`, `vehicle_make`,"
+ " `vehicle_model`, `vehicle_year` "
+ " FROM `module_config`";
const std::string kSelectEndpoints =
- "SELECT `url`, `service`, `application_id` FROM `endpoint` ";
+ "SELECT `url`, `service`, `application_id` FROM `endpoint` ";
const std::string kSelectNotificationsPerMin =
- "SELECT `priority_value`, `value` FROM notifications_by_priority";
+ "SELECT `priority_value`, `value` FROM notifications_by_priority";
const std::string kSelectNotificationsPerPriority =
"SELECT `value` FROM notifications_by_priority WHERE `priority_value` = ? ";
@@ -560,23 +582,25 @@ const std::string kSelectAppLevels = "SELECT `application_id` FROM `app_level`";
const std::string kSelectDeviceData = "SELECT * FROM `device`";
const std::string kSelectFunctionalGroups =
- "SELECT `id`,`name`, `user_consent_prompt` "
- "FROM `functional_group`";
+ "SELECT `id`,`name`, `user_consent_prompt` "
+ "FROM `functional_group`";
const std::string kSelectAllRpcs =
- "SELECT `name`, `hmi_level_value`, `parameter` "
- "FROM `rpc` WHERE `functional_group_id` = ? ";
+ "SELECT `name`, `hmi_level_value`, `parameter` "
+ "FROM `rpc` WHERE `functional_group_id` = ? ";
const std::string kSelectUserMsgsVersion =
- "SELECT DISTINCT `number` FROM `version`";
+ "SELECT DISTINCT `number` FROM `version`";
-const std::string kSelectAppPolicies = "SELECT `id`, `priority_value`, `memory_kb`, "
- " `heart_beat_timeout_ms`, `certificate` FROM `application`";
+const std::string kSelectAppPolicies =
+ "SELECT `id`, `priority_value`, `memory_kb`, "
+ " `heart_beat_timeout_ms`, `certificate` FROM `application`";
-const std::string kSelectAppGroups = "SELECT `f`.`name` FROM `app_group` AS `a`"
- " LEFT JOIN `functional_group` AS `f` "
- " ON (`f`.`id` = `a`.`functional_group_id`)"
- " WHERE `a`.`application_id` = ?";
+const std::string kSelectAppGroups =
+ "SELECT `f`.`name` FROM `app_group` AS `a`"
+ " LEFT JOIN `functional_group` AS `f` "
+ " ON (`f`.`id` = `a`.`functional_group_id`)"
+ " WHERE `a`.`application_id` = ?";
const std::string kSelectNicknames = "SELECT DISTINCT `name` FROM `nickname` "
"WHERE `application_id` = ?";
@@ -584,85 +608,88 @@ const std::string kSelectNicknames = "SELECT DISTINCT `name` FROM `nickname` "
const std::string kSelectAppTypes = "SELECT DISTINCT `name` FROM `app_type` "
"WHERE `application_id` = ?";
-const std::string kSelectRequestTypes =
- "SELECT DISTINCT `request_type` FROM `request_type` WHERE `application_id` = ?";
+const std::string kSelectRequestTypes = "SELECT DISTINCT `request_type` FROM "
+ "`request_type` WHERE `application_id` "
+ "= ?";
const std::string kSelectSecondsBetweenRetries =
- "SELECT `value` FROM `seconds_between_retry` ORDER BY `index`";
+ "SELECT `value` FROM `seconds_between_retry` ORDER BY `index`";
const std::string kSelectIgnitionCycles =
- "SELECT `c`.`exchange_after_x_ignition_cycles`, "
- " `m`.`ignition_cycles_since_last_exchange` "
- " FROM `module_config` AS `c`, `module_meta` AS `m` "
- "LIMIT 1";
+ "SELECT `c`.`exchange_after_x_ignition_cycles`, "
+ " `m`.`ignition_cycles_since_last_exchange` "
+ " FROM `module_config` AS `c`, `module_meta` AS `m` "
+ "LIMIT 1";
const std::string kSelectKilometers =
- "SELECT `c`.`exchange_after_x_kilometers`, "
- " `m`.`pt_exchanged_at_odometer_x` "
- " FROM `module_config` AS `c`, `module_meta` AS `m` "
- "LIMIT 1";
+ "SELECT `c`.`exchange_after_x_kilometers`, "
+ " `m`.`pt_exchanged_at_odometer_x` "
+ " FROM `module_config` AS `c`, `module_meta` AS `m` "
+ "LIMIT 1";
-const std::string kSelectDays = "SELECT `c`.`exchange_after_x_days`, "
- " `m`.`pt_exchanged_x_days_after_epoch` "
- " FROM `module_config` AS `c`, `module_meta` AS `m` "
- "LIMIT 1";
+const std::string kSelectDays =
+ "SELECT `c`.`exchange_after_x_days`, "
+ " `m`.`pt_exchanged_x_days_after_epoch` "
+ " FROM `module_config` AS `c`, `module_meta` AS `m` "
+ "LIMIT 1";
const std::string kIncrementIgnitionCycles =
- "UPDATE `module_meta` SET `ignition_cycles_since_last_exchange` = 1 + "
- " `ignition_cycles_since_last_exchange`";
+ "UPDATE `module_meta` SET `ignition_cycles_since_last_exchange` = 1 + "
+ " `ignition_cycles_since_last_exchange`";
const std::string kResetIgnitionCycles =
- "UPDATE `module_meta` SET `ignition_cycles_since_last_exchange` = 0";
+ "UPDATE `module_meta` SET `ignition_cycles_since_last_exchange` = 0";
const std::string kSelectTimeoutResponse =
- "SELECT `timeout_after_x_seconds` FROM `module_config` LIMIT 1";
+ "SELECT `timeout_after_x_seconds` FROM `module_config` LIMIT 1";
const std::string kUpdateFlagUpdateRequired =
- "UPDATE `module_meta` SET `flag_update_required` = ?";
+ "UPDATE `module_meta` SET `flag_update_required` = ?";
const std::string kSelectFlagUpdateRequired =
- "SELECT `flag_update_required` FROM `module_meta` LIMIT 1";
+ "SELECT `flag_update_required` FROM `module_meta` LIMIT 1";
const std::string kUpdateCountersSuccessfulUpdate =
- "UPDATE `module_meta` SET `pt_exchanged_at_odometer_x` = ?,"
- "`pt_exchanged_x_days_after_epoch` = ?";
+ "UPDATE `module_meta` SET `pt_exchanged_at_odometer_x` = ?,"
+ "`pt_exchanged_x_days_after_epoch` = ?";
const std::string kDeleteApplication = "DELETE FROM `application`";
const std::string kDeleteRequestType = "DELETE FROM `request_type`";
const std::string kSelectApplicationRevoked =
- "SELECT `is_revoked` FROM `application` WHERE `id` = ?";
+ "SELECT `is_revoked` FROM `application` WHERE `id` = ?";
const std::string kUpdateApplicationCustomData =
- "UPDATE `application` SET `is_revoked` = ?, `is_default` = ?,"
- "`is_predata` = ? WHERE `id` = ?";
+ "UPDATE `application` SET `is_revoked` = ?, `is_default` = ?,"
+ "`is_predata` = ? WHERE `id` = ?";
const std::string kSelectApplicationRepresented =
- "SELECT COUNT(`id`) FROM `application` WHERE `id` = ?";
+ "SELECT COUNT(`id`) FROM `application` WHERE `id` = ?";
const std::string kSelectApplicationIsDefault =
- "SELECT `is_default` FROM `application` WHERE `id` = ?";
+ "SELECT `is_default` FROM `application` WHERE `id` = ?";
const std::string kUpdateIsDefault =
- "UPDATE `application` SET `is_default` = ? WHERE `id` = ?";
+ "UPDATE `application` SET `is_default` = ? WHERE `id` = ?";
const std::string kDeleteDevice = "DELETE FROM `device` WHERE `id` = ?";
const std::string kDeleteAppGroupByApplicationId =
- "DELETE FROM `app_group` WHERE `application_id` = ?";
+ "DELETE FROM `app_group` WHERE `application_id` = ?";
const std::string kInsertApplicationFull =
- "INSERT OR IGNORE INTO `application` (`id`, `keep_context`, `steal_focus`, "
- " `default_hmi`, `priority_value`, `is_revoked`, `is_default`, `is_predata`, "
- " `memory_kb`, `heart_beat_timeout_ms`, `certificate`) "
- " VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
+ "INSERT OR IGNORE INTO `application` (`id`, `keep_context`, `steal_focus`, "
+ " `default_hmi`, `priority_value`, `is_revoked`, `is_default`, "
+ "`is_predata`, "
+ " `memory_kb`, `heart_beat_timeout_ms`, `certificate`) "
+ " VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
const std::string kSelectApplicationFull =
- "SELECT `keep_context`, `steal_focus`, `default_hmi`, `priority_value`, "
- " `is_revoked`, `is_default`, `is_predata`, `memory_kb`,"
- " `heart_beat_timeout_ms`, `certificate` FROM `application` WHERE `id` = ?";
-
-} // namespace sql_pt
-} // namespace policy
+ "SELECT `keep_context`, `steal_focus`, `default_hmi`, `priority_value`, "
+ " `is_revoked`, `is_default`, `is_predata`, `memory_kb`,"
+ " `heart_beat_timeout_ms`, `certificate` FROM `application` WHERE `id` = "
+ "?";
+} // namespace sql_pt
+} // namespace policy
diff --git a/src/components/policy/src/policy/src/sql_pt_representation.cc b/src/components/policy/src/policy/src/sql_pt_representation.cc
index 47eae02dd7..b0afde343e 100644
--- a/src/components/policy/src/policy/src/sql_pt_representation.cc
+++ b/src/components/policy/src/policy/src/sql_pt_representation.cc
@@ -1,4 +1,4 @@
-/*
+/*
Copyright (c) 2013, Ford Motor Company
All rights reserved.
@@ -49,7 +49,7 @@ namespace policy {
CREATE_LOGGERPTR_GLOBAL(logger_, "SQLPTRepresentation")
namespace {
-template<typename T, typename K> void InsertUnique(K value, T* array) {
+template <typename T, typename K> void InsertUnique(K value, T *array) {
uint32_t i = 0;
for (; i < array->size() && array->at(i) != value; ++i) {
continue;
@@ -58,18 +58,18 @@ template<typename T, typename K> void InsertUnique(K value, T* array) {
array->push_back(value);
}
}
-} // namespace
+} // namespace
const std::string SQLPTRepresentation::kDatabaseName = "policy";
SQLPTRepresentation::SQLPTRepresentation()
- : db_(new dbms::SQLDatabase(kDatabaseName)) {
+ : db_(new dbms::SQLDatabase(kDatabaseName)) {
#ifndef __QNX__
std::string path = profile::Profile::instance()->app_storage_folder();
if (!path.empty()) {
db_->set_path(path + "/");
}
-#endif // __QNX__
+#endif // __QNX__
}
SQLPTRepresentation::~SQLPTRepresentation() {
@@ -77,16 +77,15 @@ SQLPTRepresentation::~SQLPTRepresentation() {
delete db_;
}
-void SQLPTRepresentation::CheckPermissions(const PTString& app_id,
- const PTString& hmi_level,
- const PTString& rpc,
- CheckPermissionResult& result) {
+void SQLPTRepresentation::CheckPermissions(const PTString &app_id,
+ const PTString &hmi_level,
+ const PTString &rpc,
+ CheckPermissionResult &result) {
dbms::SQLQuery query(db());
if (!query.Prepare(sql_pt::kSelectRpc)) {
- LOG4CXX_WARN(
- logger_,
- "Incorrect select statement from rpcs" << query.LastError().text());
+ LOG4CXX_WARN(logger_, "Incorrect select statement from rpcs"
+ << query.LastError().text());
return;
}
query.Bind(0, app_id);
@@ -95,11 +94,10 @@ void SQLPTRepresentation::CheckPermissions(const PTString& app_id,
bool ret = query.Next();
result.hmi_level_permitted = ret ? kRpcAllowed : kRpcDisallowed;
- LOG4CXX_INFO(
- logger_,
- "Level is "
- << (result.hmi_level_permitted == kRpcAllowed ? "permitted"
- : "not permitted"));
+ LOG4CXX_INFO(logger_, "Level is "
+ << (result.hmi_level_permitted == kRpcAllowed
+ ? "permitted"
+ : "not permitted"));
std::string parameter;
while (ret) {
if (!query.IsNull(0)) {
@@ -140,8 +138,8 @@ int SQLPTRepresentation::KilometersBeforeExchange(int current) {
int limit = query.GetInteger(0);
int last = query.GetInteger(1);
- if (limit < 0 || last < 0 || current < 0 || current < last
- || limit < (current - last)) {
+ if (limit < 0 || last < 0 || current < 0 || current < last ||
+ limit < (current - last)) {
return 0;
}
@@ -149,7 +147,7 @@ int SQLPTRepresentation::KilometersBeforeExchange(int current) {
}
bool SQLPTRepresentation::SetCountersPassedForSuccessfulUpdate(
- int kilometers, int days_after_epoch) {
+ int kilometers, int days_after_epoch) {
LOG4CXX_AUTO_TRACE(logger_);
dbms::SQLQuery query(db());
if (!query.Prepare(sql_pt::kUpdateCountersSuccessfulUpdate)) {
@@ -179,8 +177,8 @@ int SQLPTRepresentation::DaysBeforeExchange(int current) {
return limit;
}
- if (limit < 0 || last < 0 || current < 0 || current < last
- || limit < (current - last)) {
+ if (limit < 0 || last < 0 || current < 0 || current < last ||
+ limit < (current - last)) {
return 0;
}
@@ -197,7 +195,7 @@ int SQLPTRepresentation::TimeoutResponse() {
return query.GetInteger(0);
}
-bool SQLPTRepresentation::SecondsBetweenRetries(std::vector<int>* seconds) {
+bool SQLPTRepresentation::SecondsBetweenRetries(std::vector<int> *seconds) {
dbms::SQLQuery query(db());
if (!query.Prepare(sql_pt::kSelectSecondsBetweenRetries)) {
LOG4CXX_INFO(logger_,
@@ -211,7 +209,7 @@ bool SQLPTRepresentation::SecondsBetweenRetries(std::vector<int>* seconds) {
}
std::vector<UserFriendlyMessage> SQLPTRepresentation::GetUserFriendlyMsg(
- const std::vector<std::string>& msg_codes, const std::string& language) {
+ const std::vector<std::string> &msg_codes, const std::string &language) {
std::vector<UserFriendlyMessage> result;
std::vector<std::string>::const_iterator it = msg_codes.begin();
std::vector<std::string>::const_iterator it_end = msg_codes.end();
@@ -225,7 +223,7 @@ std::vector<UserFriendlyMessage> SQLPTRepresentation::GetUserFriendlyMsg(
EndpointUrls SQLPTRepresentation::GetUpdateUrls(int service_type) {
LOG4CXX_INFO(logger_, "SQLPTRepresentation::GetUpdateUrls for "
- << service_type);
+ << service_type);
dbms::SQLQuery query(db());
EndpointUrls ret;
if (query.Prepare(sql_pt::kSelectEndpoint)) {
@@ -252,7 +250,7 @@ std::string SQLPTRepresentation::GetLockScreenIconUrl() const {
query.Bind(0, std::string("lock_screen_icon_url"));
query.Bind(1, std::string("default"));
- if(!query.Exec()) {
+ if (!query.Exec()) {
LOG4CXX_WARN(logger_, "Incorrect select from notifications by priority.");
return ret;
}
@@ -267,13 +265,12 @@ std::string SQLPTRepresentation::GetLockScreenIconUrl() const {
return ret;
}
-
-int SQLPTRepresentation::GetNotificationsNumber(const std::string& priority) {
+int SQLPTRepresentation::GetNotificationsNumber(const std::string &priority) {
LOG4CXX_INFO(logger_, "GetNotificationsNumber");
dbms::SQLQuery query(db());
if (!query.Prepare(sql_pt::kSelectNotificationsPerPriority)) {
LOG4CXX_WARN(logger_, "Incorrect select statement for priority "
- "notification number.");
+ "notification number.");
return 0;
}
query.Bind(0, priority);
@@ -289,8 +286,8 @@ int SQLPTRepresentation::GetNotificationsNumber(const std::string& priority) {
return 0;
}
-bool SQLPTRepresentation::GetPriority(const std::string& policy_app_id,
- std::string* priority) {
+bool SQLPTRepresentation::GetPriority(const std::string &policy_app_id,
+ std::string *priority) {
LOG4CXX_INFO(logger_, "GetPriority");
if (NULL == priority) {
LOG4CXX_WARN(logger_, "Input priority parameter is null.");
@@ -332,12 +329,12 @@ InitResult SQLPTRepresentation::Init() {
const uint16_t open_attempt_timeout_ms =
profile::Profile::instance()->open_attempt_timeout_ms();
const useconds_t sleep_interval_mcsec = open_attempt_timeout_ms * 1000;
- LOG4CXX_DEBUG(logger_, "Open attempt timeout(ms) is: "
- << open_attempt_timeout_ms);
+ LOG4CXX_DEBUG(logger_,
+ "Open attempt timeout(ms) is: " << open_attempt_timeout_ms);
for (int i = 0; i < attempts; ++i) {
usleep(sleep_interval_mcsec);
- LOG4CXX_INFO(logger_, "Attempt: " << i+1);
- if (db_->Open()){
+ LOG4CXX_INFO(logger_, "Attempt: " << i + 1);
+ if (db_->Open()) {
LOG4CXX_INFO(logger_, "Database opened.");
is_opened = true;
break;
@@ -345,9 +342,9 @@ InitResult SQLPTRepresentation::Init() {
}
if (!is_opened) {
LOG4CXX_ERROR(logger_, "Open retry sequence failed. Tried "
- << attempts << " attempts with "
- << open_attempt_timeout_ms
- << " open timeout(ms) for each.");
+ << attempts << " attempts with "
+ << open_attempt_timeout_ms
+ << " open timeout(ms) for each.");
return InitResult::FAIL;
}
}
@@ -356,7 +353,7 @@ InitResult SQLPTRepresentation::Init() {
LOG4CXX_ERROR(logger_, "There are no read/write permissions for database");
return InitResult::FAIL;
}
-#endif // __QNX__
+#endif // __QNX__
dbms::SQLQuery check_pages(db());
if (!check_pages.Prepare(sql_pt::kCheckPgNumber) || !check_pages.Next()) {
LOG4CXX_WARN(logger_, "Incorrect pragma for page counting.");
@@ -372,7 +369,7 @@ InitResult SQLPTRepresentation::Init() {
if (check_first_run.Prepare(sql_pt::kIsFirstRun) &&
check_first_run.Next()) {
LOG4CXX_INFO(logger_, "Selecting is first run "
- << check_first_run.GetBoolean(0));
+ << check_first_run.GetBoolean(0));
if (check_first_run.GetBoolean(0)) {
dbms::SQLQuery set_not_first_run(db());
set_not_first_run.Exec(sql_pt::kSetNotFirstRun);
@@ -394,15 +391,13 @@ InitResult SQLPTRepresentation::Init() {
}
dbms::SQLQuery query(db());
if (!query.Exec(sql_pt::kCreateSchema)) {
- LOG4CXX_ERROR(
- logger_,
- "Failed creating schema of database: " << query.LastError().text());
+ LOG4CXX_ERROR(logger_, "Failed creating schema of database: "
+ << query.LastError().text());
return InitResult::FAIL;
}
if (!query.Exec(sql_pt::kInsertInitData)) {
- LOG4CXX_ERROR(
- logger_,
- "Failed insert init data to database: " << query.LastError().text());
+ LOG4CXX_ERROR(logger_, "Failed insert init data to database: "
+ << query.LastError().text());
return InitResult::FAIL;
}
return InitResult::SUCCESS;
@@ -413,9 +408,7 @@ bool SQLPTRepresentation::Close() {
return db_->LastError().number() == dbms::OK;
}
-VehicleData SQLPTRepresentation::GetVehicleData() {
- return VehicleData();
-}
+VehicleData SQLPTRepresentation::GetVehicleData() { return VehicleData(); }
bool SQLPTRepresentation::Drop() {
dbms::SQLQuery query(db());
@@ -427,21 +420,18 @@ bool SQLPTRepresentation::Drop() {
return true;
}
-void SQLPTRepresentation::WriteDb() {
- db_->Backup();
-}
+void SQLPTRepresentation::WriteDb() { db_->Backup(); }
bool SQLPTRepresentation::Clear() {
dbms::SQLQuery query(db());
if (!query.Exec(sql_pt::kDeleteData)) {
LOG4CXX_ERROR(logger_,
- "Failed clearing database: " << query.LastError().text());
+ "Failed clearing database: " << query.LastError().text());
return false;
}
if (!query.Exec(sql_pt::kInsertInitData)) {
- LOG4CXX_ERROR(
- logger_,
- "Failed insert init data to database: " << query.LastError().text());
+ LOG4CXX_ERROR(logger_, "Failed insert init data to database: "
+ << query.LastError().text());
return false;
}
return true;
@@ -455,15 +445,13 @@ bool SQLPTRepresentation::RefreshDB() {
return false;
}
if (!query.Exec(sql_pt::kCreateSchema)) {
- LOG4CXX_ERROR(
- logger_,
- "Failed creating schema of database: " << query.LastError().text());
+ LOG4CXX_ERROR(logger_, "Failed creating schema of database: "
+ << query.LastError().text());
return false;
}
if (!query.Exec(sql_pt::kInsertInitData)) {
- LOG4CXX_ERROR(
- logger_,
- "Failed insert init data to database: " << query.LastError().text());
+ LOG4CXX_ERROR(logger_, "Failed insert init data to database: "
+ << query.LastError().text());
return false;
}
return true;
@@ -479,20 +467,20 @@ SQLPTRepresentation::GenerateSnapshot() const {
GatherDeviceData(&*table->policy_table.device_data);
GatherFunctionalGroupings(&table->policy_table.functional_groupings);
GatherConsumerFriendlyMessages(
- &*table->policy_table.consumer_friendly_messages);
+ &*table->policy_table.consumer_friendly_messages);
GatherApplicationPoliciesSection(&table->policy_table.app_policies_section);
return table;
}
void SQLPTRepresentation::GatherModuleMeta(
- policy_table::ModuleMeta* meta) const {
+ policy_table::ModuleMeta *meta) const {
LOG4CXX_INFO(logger_, "Gather Module Meta Info");
meta->mark_initialized();
// Section Module Meta is empty for SDL specific
}
void SQLPTRepresentation::GatherModuleConfig(
- policy_table::ModuleConfig* config) const {
+ policy_table::ModuleConfig *config) const {
LOG4CXX_INFO(logger_, "Gather Configuration Info");
dbms::SQLQuery query(db());
if (!query.Prepare(sql_pt::kSelectModuleConfig) || !query.Next()) {
@@ -514,7 +502,7 @@ void SQLPTRepresentation::GatherModuleConfig(
} else {
while (endpoints.Next()) {
config->endpoints[endpoints.GetString(1)][endpoints.GetString(2)]
- .push_back(endpoints.GetString(0));
+ .push_back(endpoints.GetString(0));
}
}
@@ -524,7 +512,7 @@ void SQLPTRepresentation::GatherModuleConfig(
} else {
while (notifications.Next()) {
config->notifications_per_minute_by_priority[notifications.GetString(0)] =
- notifications.GetInteger(1);
+ notifications.GetInteger(1);
}
}
dbms::SQLQuery seconds(db());
@@ -539,7 +527,7 @@ void SQLPTRepresentation::GatherModuleConfig(
}
bool SQLPTRepresentation::GatherUsageAndErrorCounts(
- policy_table::UsageAndErrorCounts* counts) const {
+ policy_table::UsageAndErrorCounts *counts) const {
LOG4CXX_INFO(logger_, "Gather Usage and Error Counts.");
dbms::SQLQuery query(db());
if (query.Prepare(sql_pt::kSelectAppLevels)) {
@@ -553,7 +541,7 @@ bool SQLPTRepresentation::GatherUsageAndErrorCounts(
}
void SQLPTRepresentation::GatherDeviceData(
- policy_table::DeviceData* data) const {
+ policy_table::DeviceData *data) const {
LOG4CXX_INFO(logger_, "Gather device data.");
data->mark_initialized();
@@ -568,7 +556,7 @@ void SQLPTRepresentation::GatherDeviceData(
}
bool SQLPTRepresentation::GatherFunctionalGroupings(
- policy_table::FunctionalGroupings* groups) const {
+ policy_table::FunctionalGroupings *groups) const {
LOG4CXX_INFO(logger_, "Gather Functional Groupings info");
dbms::SQLQuery func_group(db());
if (!func_group.Prepare(sql_pt::kSelectFunctionalGroups)) {
@@ -611,7 +599,7 @@ bool SQLPTRepresentation::GatherFunctionalGroupings(
}
bool SQLPTRepresentation::GatherConsumerFriendlyMessages(
- policy_table::ConsumerFriendlyMessages* messages) const {
+ policy_table::ConsumerFriendlyMessages *messages) const {
LOG4CXX_INFO(logger_, "Gather Consumer Friendly Messages");
dbms::SQLQuery query(db());
if (!query.Prepare(sql_pt::kSelectUserMsgsVersion) || !query.Next()) {
@@ -623,7 +611,7 @@ bool SQLPTRepresentation::GatherConsumerFriendlyMessages(
}
bool SQLPTRepresentation::GatherApplicationPoliciesSection(
- policy_table::ApplicationPoliciesSection* policies) const {
+ policy_table::ApplicationPoliciesSection *policies) const {
LOG4CXX_INFO(logger_, "Gather applications policies");
dbms::SQLQuery query(db());
if (!query.Prepare(sql_pt::kSelectAppPolicies)) {
@@ -633,7 +621,7 @@ bool SQLPTRepresentation::GatherApplicationPoliciesSection(
while (query.Next()) {
rpc::Nullable<policy_table::ApplicationParams> params;
- const std::string& app_id = query.GetString(0);
+ const std::string &app_id = query.GetString(0);
if (IsApplicationRevoked(app_id)) {
params.set_to_null();
(*policies).apps[app_id] = params;
@@ -679,14 +667,15 @@ bool SQLPTRepresentation::GatherApplicationPoliciesSection(
return true;
}
-bool SQLPTRepresentation::Save(const policy_table::Table& table) {
+bool SQLPTRepresentation::Save(const policy_table::Table &table) {
LOG4CXX_AUTO_TRACE(logger_);
db_->BeginTransaction();
if (!SaveFunctionalGroupings(table.policy_table.functional_groupings)) {
db_->RollbackTransaction();
return false;
}
- if (!SaveApplicationPoliciesSection(table.policy_table.app_policies_section)) {
+ if (!SaveApplicationPoliciesSection(
+ table.policy_table.app_policies_section)) {
db_->RollbackTransaction();
return false;
}
@@ -695,7 +684,7 @@ bool SQLPTRepresentation::Save(const policy_table::Table& table) {
return false;
}
if (!SaveConsumerFriendlyMessages(
- *table.policy_table.consumer_friendly_messages)) {
+ *table.policy_table.consumer_friendly_messages)) {
db_->RollbackTransaction();
return false;
}
@@ -717,7 +706,7 @@ bool SQLPTRepresentation::Save(const policy_table::Table& table) {
}
bool SQLPTRepresentation::SaveFunctionalGroupings(
- const policy_table::FunctionalGroupings& groups) {
+ const policy_table::FunctionalGroupings &groups) {
dbms::SQLQuery query_delete(db());
if (!query_delete.Exec(sql_pt::kDeleteRpc)) {
LOG4CXX_WARN(logger_, "Incorrect delete from rpc.");
@@ -748,8 +737,9 @@ bool SQLPTRepresentation::SaveFunctionalGroupings(
// to avoid ambiguity.
query.Bind(0, static_cast<int64_t>(id));
query.Bind(1, it->first);
- it->second.user_consent_prompt.is_initialized() ?
- query.Bind(2, *(it->second.user_consent_prompt)) : query.Bind(2);
+ it->second.user_consent_prompt.is_initialized()
+ ? query.Bind(2, *(it->second.user_consent_prompt))
+ : query.Bind(2);
if (!query.Exec() || !query.Reset()) {
LOG4CXX_WARN(logger_, "Incorrect insert into functional groups");
@@ -764,20 +754,20 @@ bool SQLPTRepresentation::SaveFunctionalGroupings(
}
bool SQLPTRepresentation::SaveRpcs(int64_t group_id,
- const policy_table::Rpc& rpcs) {
+ const policy_table::Rpc &rpcs) {
dbms::SQLQuery query(db());
dbms::SQLQuery query_parameter(db());
- if (!query.Prepare(sql_pt::kInsertRpc)
- || !query_parameter.Prepare(sql_pt::kInsertRpcWithParameter)) {
+ if (!query.Prepare(sql_pt::kInsertRpc) ||
+ !query_parameter.Prepare(sql_pt::kInsertRpcWithParameter)) {
LOG4CXX_WARN(logger_, "Incorrect insert statement for rpc");
return false;
}
policy_table::Rpc::const_iterator it;
for (it = rpcs.begin(); it != rpcs.end(); ++it) {
- const policy_table::HmiLevels& hmi_levels = it->second.hmi_levels;
+ const policy_table::HmiLevels &hmi_levels = it->second.hmi_levels;
// TODO(IKozyrenko): Check logic if optional container is missing
- const policy_table::Parameters& parameters = *it->second.parameters;
+ const policy_table::Parameters &parameters = *it->second.parameters;
policy_table::HmiLevels::const_iterator hmi_it;
policy_table::Parameters::const_iterator ps_it;
for (hmi_it = hmi_levels.begin(); hmi_it != hmi_levels.end(); ++hmi_it) {
@@ -785,9 +775,9 @@ bool SQLPTRepresentation::SaveRpcs(int64_t group_id,
for (ps_it = parameters.begin(); ps_it != parameters.end(); ++ps_it) {
query_parameter.Bind(0, it->first);
query_parameter.Bind(
- 1, std::string(policy_table::EnumToJsonString(*hmi_it)));
+ 1, std::string(policy_table::EnumToJsonString(*hmi_it)));
query_parameter.Bind(
- 2, std::string(policy_table::EnumToJsonString(*ps_it)));
+ 2, std::string(policy_table::EnumToJsonString(*ps_it)));
query_parameter.Bind(3, group_id);
if (!query_parameter.Exec() || !query_parameter.Reset()) {
LOG4CXX_WARN(logger_, "Incorrect insert into rpc with parameter");
@@ -810,7 +800,7 @@ bool SQLPTRepresentation::SaveRpcs(int64_t group_id,
}
bool SQLPTRepresentation::SaveApplicationPoliciesSection(
- const policy_table::ApplicationPoliciesSection& policies) {
+ const policy_table::ApplicationPoliciesSection &policies) {
dbms::SQLQuery query_delete(db());
if (!query_delete.Exec(sql_pt::kDeleteAppGroup)) {
LOG4CXX_WARN(logger_, "Incorrect delete from app_group.");
@@ -863,20 +853,23 @@ bool SQLPTRepresentation::SaveApplicationPoliciesSection(
}
bool SQLPTRepresentation::SaveSpecificAppPolicy(
- const policy_table::ApplicationPolicies::value_type& app) {
+ const policy_table::ApplicationPolicies::value_type &app) {
dbms::SQLQuery app_query(db());
if (!app_query.Prepare(sql_pt::kInsertApplication)) {
- LOG4CXX_WARN(logger_, "Incorrect insert statement into application (device).");
+ LOG4CXX_WARN(logger_,
+ "Incorrect insert statement into application (device).");
return false;
}
app_query.Bind(0, app.first);
- app_query.Bind(1, std::string(policy_table::EnumToJsonString(app.second.priority)));
+ app_query.Bind(
+ 1, std::string(policy_table::EnumToJsonString(app.second.priority)));
app_query.Bind(2, app.second.is_null());
app_query.Bind(3, *app.second.memory_kb);
app_query.Bind(4, *app.second.heart_beat_timeout_ms);
- app.second.certificate.is_initialized() ?
- app_query.Bind(5, *app.second.certificate) : app_query.Bind(5);
+ app.second.certificate.is_initialized()
+ ? app_query.Bind(5, *app.second.certificate)
+ : app_query.Bind(5);
if (!app_query.Exec() || !app_query.Reset()) {
LOG4CXX_WARN(logger_, "Incorrect insert into application.");
@@ -911,7 +904,7 @@ bool SQLPTRepresentation::SaveSpecificAppPolicy(
}
bool policy::SQLPTRepresentation::SaveDevicePolicy(
- const policy_table::DevicePolicy& device) {
+ const policy_table::DevicePolicy &device) {
dbms::SQLQuery app_query(db());
if (!app_query.Prepare(sql_pt::kInsertApplication)) {
LOG4CXX_WARN(logger_, "Incorrect insert statement into application.");
@@ -919,7 +912,8 @@ bool policy::SQLPTRepresentation::SaveDevicePolicy(
}
app_query.Bind(0, kDeviceId);
- app_query.Bind(1, std::string(policy_table::EnumToJsonString(device.priority)));
+ app_query.Bind(1,
+ std::string(policy_table::EnumToJsonString(device.priority)));
app_query.Bind(2, false);
app_query.Bind(3, 0);
app_query.Bind(4, 0);
@@ -930,15 +924,11 @@ bool policy::SQLPTRepresentation::SaveDevicePolicy(
return false;
}
- if (!SaveAppGroup(kDeviceId, device.groups)) {
- return false;
- }
-
return true;
}
bool SQLPTRepresentation::SaveAppGroup(
- const std::string& app_id, const policy_table::Strings& app_groups) {
+ const std::string &app_id, const policy_table::Strings &app_groups) {
dbms::SQLQuery query(db());
if (!query.Prepare(sql_pt::kInsertAppGroup)) {
LOG4CXX_WARN(logger_, "Incorrect insert statement for app group");
@@ -952,9 +942,8 @@ bool SQLPTRepresentation::SaveAppGroup(
query.Bind(0, app_id);
query.Bind(1, *it);
if (!query.Exec() || !query.Reset()) {
- LOG4CXX_WARN(
- logger_,
- "Incorrect insert into app group." << query.LastError().text());
+ LOG4CXX_WARN(logger_, "Incorrect insert into app group."
+ << query.LastError().text());
return false;
}
}
@@ -962,8 +951,8 @@ bool SQLPTRepresentation::SaveAppGroup(
return true;
}
-bool SQLPTRepresentation::SaveNickname(const std::string& app_id,
- const policy_table::Strings& nicknames) {
+bool SQLPTRepresentation::SaveNickname(const std::string &app_id,
+ const policy_table::Strings &nicknames) {
dbms::SQLQuery query(db());
if (!query.Prepare(sql_pt::kInsertNickname)) {
LOG4CXX_WARN(logger_, "Incorrect insert statement for nickname");
@@ -983,8 +972,8 @@ bool SQLPTRepresentation::SaveNickname(const std::string& app_id,
return true;
}
-bool SQLPTRepresentation::SaveAppType(const std::string& app_id,
- const policy_table::AppHMITypes& types) {
+bool SQLPTRepresentation::SaveAppType(const std::string &app_id,
+ const policy_table::AppHMITypes &types) {
dbms::SQLQuery query(db());
if (!query.Prepare(sql_pt::kInsertAppType)) {
LOG4CXX_WARN(logger_, "Incorrect insert statement for app type");
@@ -1005,8 +994,7 @@ bool SQLPTRepresentation::SaveAppType(const std::string& app_id,
}
bool SQLPTRepresentation::SaveRequestType(
- const std::string& app_id,
- const policy_table::RequestTypes& types) {
+ const std::string &app_id, const policy_table::RequestTypes &types) {
dbms::SQLQuery query(db());
if (!query.Prepare(sql_pt::kInsertRequestType)) {
LOG4CXX_WARN(logger_, "Incorrect insert statement for request types.");
@@ -1026,33 +1014,33 @@ bool SQLPTRepresentation::SaveRequestType(
return true;
}
-bool SQLPTRepresentation::SaveModuleMeta(const policy_table::ModuleMeta& meta) {
+bool SQLPTRepresentation::SaveModuleMeta(const policy_table::ModuleMeta &meta) {
// Section Module Meta is empty for SDL specific
return true;
}
bool SQLPTRepresentation::SaveModuleConfig(
- const policy_table::ModuleConfig& config) {
+ const policy_table::ModuleConfig &config) {
dbms::SQLQuery query(db());
if (!query.Prepare(sql_pt::kUpdateModuleConfig)) {
LOG4CXX_WARN(logger_, "Incorrect update statement for module config");
return false;
}
- bool is_preloaded = config.preloaded_pt.is_initialized() &&
- *config.preloaded_pt;
+ bool is_preloaded =
+ config.preloaded_pt.is_initialized() && *config.preloaded_pt;
query.Bind(0, is_preloaded);
query.Bind(1, config.exchange_after_x_ignition_cycles);
query.Bind(2, config.exchange_after_x_kilometers);
query.Bind(3, config.exchange_after_x_days);
query.Bind(4, config.timeout_after_x_seconds);
- config.vehicle_make.is_initialized() ?
- query.Bind(5, *(config.vehicle_make)) : query.Bind(5);
- config.vehicle_model.is_initialized() ?
- query.Bind(6, *(config.vehicle_model)) : query.Bind(6);
- config.vehicle_year.is_initialized() ?
- query.Bind(7, *(config.vehicle_year)) : query.Bind(7);
+ config.vehicle_make.is_initialized() ? query.Bind(5, *(config.vehicle_make))
+ : query.Bind(5);
+ config.vehicle_model.is_initialized() ? query.Bind(6, *(config.vehicle_model))
+ : query.Bind(6);
+ config.vehicle_year.is_initialized() ? query.Bind(7, *(config.vehicle_year))
+ : query.Bind(7);
if (!query.Exec()) {
LOG4CXX_WARN(logger_, "Incorrect update module config");
@@ -1064,7 +1052,7 @@ bool SQLPTRepresentation::SaveModuleConfig(
}
if (!SaveNumberOfNotificationsPerMinute(
- config.notifications_per_minute_by_priority)) {
+ config.notifications_per_minute_by_priority)) {
return false;
}
@@ -1076,7 +1064,7 @@ bool SQLPTRepresentation::SaveModuleConfig(
}
bool SQLPTRepresentation::SaveServiceEndpoints(
- const policy_table::ServiceEndpoints& endpoints) {
+ const policy_table::ServiceEndpoints &endpoints) {
dbms::SQLQuery query(db());
if (!query.Exec(sql_pt::kDeleteEndpoint)) {
LOG4CXX_WARN(logger_, "Incorrect delete from endpoint.");
@@ -1090,10 +1078,10 @@ bool SQLPTRepresentation::SaveServiceEndpoints(
policy_table::ServiceEndpoints::const_iterator it;
for (it = endpoints.begin(); it != endpoints.end(); ++it) {
- const policy_table::URLList& apps = it->second;
+ const policy_table::URLList &apps = it->second;
policy_table::URLList::const_iterator app_it;
for (app_it = apps.begin(); app_it != apps.end(); ++app_it) {
- const policy_table::URL& urls = app_it->second;
+ const policy_table::URL &urls = app_it->second;
policy_table::URL::const_iterator url_it;
for (url_it = urls.begin(); url_it != urls.end(); ++url_it) {
query.Bind(0, it->first);
@@ -1111,7 +1099,7 @@ bool SQLPTRepresentation::SaveServiceEndpoints(
}
bool SQLPTRepresentation::SaveConsumerFriendlyMessages(
- const policy_table::ConsumerFriendlyMessages& messages) {
+ const policy_table::ConsumerFriendlyMessages &messages) {
LOG4CXX_AUTO_TRACE(logger_);
// According CRS-2419 If there is no “consumer_friendly_messages” key,
@@ -1137,11 +1125,12 @@ bool SQLPTRepresentation::SaveConsumerFriendlyMessages(
policy_table::Messages::const_iterator it;
// TODO(IKozyrenko): Check logic if optional container is missing
- for (it = messages.messages->begin(); it != messages.messages->end(); ++it) {
+ for (it = messages.messages->begin(); it != messages.messages->end();
+ ++it) {
if (!SaveMessageType(it->first)) {
return false;
}
- const policy_table::Languages& langs = it->second.languages;
+ const policy_table::Languages &langs = it->second.languages;
policy_table::Languages::const_iterator lang_it;
for (lang_it = langs.begin(); lang_it != langs.end(); ++lang_it) {
if (!SaveLanguage(lang_it->first)) {
@@ -1159,7 +1148,7 @@ bool SQLPTRepresentation::SaveConsumerFriendlyMessages(
return true;
}
-bool SQLPTRepresentation::SaveMessageType(const std::string& type) {
+bool SQLPTRepresentation::SaveMessageType(const std::string &type) {
dbms::SQLQuery query(db());
if (!query.Prepare(sql_pt::kInsertMessageType)) {
LOG4CXX_WARN(logger_, "Incorrect insert statement for message type.");
@@ -1175,7 +1164,7 @@ bool SQLPTRepresentation::SaveMessageType(const std::string& type) {
return true;
}
-bool SQLPTRepresentation::SaveLanguage(const std::string& code) {
+bool SQLPTRepresentation::SaveLanguage(const std::string &code) {
dbms::SQLQuery query(db());
if (!query.Prepare(sql_pt::kInsertLanguage)) {
LOG4CXX_WARN(logger_, "Incorrect insert statement for language.");
@@ -1192,14 +1181,14 @@ bool SQLPTRepresentation::SaveLanguage(const std::string& code) {
}
bool SQLPTRepresentation::SaveMessageString(
- const std::string& type, const std::string& lang,
- const policy_table::MessageString& strings) {
+ const std::string &type, const std::string &lang,
+ const policy_table::MessageString &strings) {
// Section is empty for SDL specific
return true;
}
bool SQLPTRepresentation::SaveSecondsBetweenRetries(
- const policy_table::SecondsBetweenRetries& seconds) {
+ const policy_table::SecondsBetweenRetries &seconds) {
dbms::SQLQuery query(db());
if (!query.Exec(sql_pt::kDeleteSecondsBetweenRetries)) {
LOG4CXX_WARN(logger_, "Incorrect delete from seconds between retries.");
@@ -1224,7 +1213,7 @@ bool SQLPTRepresentation::SaveSecondsBetweenRetries(
}
bool SQLPTRepresentation::SaveNumberOfNotificationsPerMinute(
- const policy_table::NumberOfNotificationsPerMinute& notifications) {
+ const policy_table::NumberOfNotificationsPerMinute &notifications) {
dbms::SQLQuery query(db());
if (!query.Prepare(sql_pt::kInsertNotificationsByPriority)) {
LOG4CXX_WARN(logger_,
@@ -1246,7 +1235,7 @@ bool SQLPTRepresentation::SaveNumberOfNotificationsPerMinute(
}
bool SQLPTRepresentation::SaveDeviceData(
- const policy_table::DeviceData& devices) {
+ const policy_table::DeviceData &devices) {
dbms::SQLQuery query(db());
if (!query.Prepare(sql_pt::kInsertDeviceData)) {
LOG4CXX_WARN(logger_, "Incorrect insert statement for device data.");
@@ -1266,8 +1255,8 @@ bool SQLPTRepresentation::SaveDeviceData(
}
bool SQLPTRepresentation::SaveUsageAndErrorCounts(
- const policy_table::UsageAndErrorCounts& counts) {
- const_cast<policy_table::UsageAndErrorCounts&>(counts).mark_initialized();
+ const policy_table::UsageAndErrorCounts &counts) {
+ const_cast<policy_table::UsageAndErrorCounts &>(counts).mark_initialized();
dbms::SQLQuery query(db());
if (!query.Exec(sql_pt::kDeleteAppLevel)) {
LOG4CXX_WARN(logger_, "Incorrect delete from app level.");
@@ -1279,8 +1268,8 @@ bool SQLPTRepresentation::SaveUsageAndErrorCounts(
}
policy_table::AppLevels::const_iterator it;
- const policy_table::AppLevels& app_levels = *counts.app_level;
- const_cast<policy_table::AppLevels&>(*counts.app_level).mark_initialized();
+ const policy_table::AppLevels &app_levels = *counts.app_level;
+ const_cast<policy_table::AppLevels &>(*counts.app_level).mark_initialized();
for (it = app_levels.begin(); it != app_levels.end(); ++it) {
query.Bind(0, it->first);
if (!query.Exec()) {
@@ -1322,8 +1311,8 @@ void SQLPTRepresentation::SaveUpdateRequired(bool value) {
if (!query.Prepare(/*sql_pt::kUpdateFlagUpdateRequired*/
"UPDATE `module_meta` SET `flag_update_required` = ?")) {
LOG4CXX_WARN(logger_,
- "Incorrect update into module meta (update_required): " <<
- strerror(errno));
+ "Incorrect update into module meta (update_required): "
+ << strerror(errno));
return;
}
query.Bind(0, value);
@@ -1332,9 +1321,9 @@ void SQLPTRepresentation::SaveUpdateRequired(bool value) {
}
}
-bool SQLPTRepresentation::GetInitialAppData(const std::string& app_id,
- StringArray* nicknames,
- StringArray* app_types) {
+bool SQLPTRepresentation::GetInitialAppData(const std::string &app_id,
+ StringArray *nicknames,
+ StringArray *app_types) {
LOG4CXX_INFO(logger_, "Getting initial application data.");
dbms::SQLQuery app_names(db());
if (!app_names.Prepare(sql_pt::kSelectNicknames)) {
@@ -1360,13 +1349,13 @@ bool SQLPTRepresentation::GetInitialAppData(const std::string& app_id,
}
bool SQLPTRepresentation::GetFunctionalGroupings(
- policy_table::FunctionalGroupings& groups) {
+ policy_table::FunctionalGroupings &groups) {
LOG4CXX_INFO(logger_, "GetFunctionalGroupings");
return GatherFunctionalGroupings(&groups);
}
bool SQLPTRepresentation::GatherAppType(
- const std::string& app_id, policy_table::AppHMITypes* app_types) const {
+ const std::string &app_id, policy_table::AppHMITypes *app_types) const {
dbms::SQLQuery query(db());
if (!query.Prepare(sql_pt::kSelectAppTypes)) {
LOG4CXX_WARN(logger_, "Incorrect select from app types");
@@ -1385,8 +1374,8 @@ bool SQLPTRepresentation::GatherAppType(
}
bool SQLPTRepresentation::GatherRequestType(
- const std::string& app_id,
- policy_table::RequestTypes* request_types) const {
+ const std::string &app_id,
+ policy_table::RequestTypes *request_types) const {
dbms::SQLQuery query(db());
if (!query.Prepare(sql_pt::kSelectRequestTypes)) {
LOG4CXX_WARN(logger_, "Incorrect select from request types.");
@@ -1405,7 +1394,7 @@ bool SQLPTRepresentation::GatherRequestType(
}
bool SQLPTRepresentation::GatherNickName(
- const std::string& app_id, policy_table::Strings* nicknames) const {
+ const std::string &app_id, policy_table::Strings *nicknames) const {
dbms::SQLQuery query(db());
if (!query.Prepare(sql_pt::kSelectNicknames)) {
LOG4CXX_WARN(logger_, "Incorrect select from app nicknames");
@@ -1420,7 +1409,7 @@ bool SQLPTRepresentation::GatherNickName(
}
bool SQLPTRepresentation::GatherAppGroup(
- const std::string& app_id, policy_table::Strings* app_groups) const {
+ const std::string &app_id, policy_table::Strings *app_groups) const {
dbms::SQLQuery query(db());
if (!query.Prepare(sql_pt::kSelectAppGroups)) {
LOG4CXX_WARN(logger_, "Incorrect select from app groups");
@@ -1434,7 +1423,7 @@ bool SQLPTRepresentation::GatherAppGroup(
return true;
}
-bool SQLPTRepresentation::SaveApplicationCustomData(const std::string& app_id,
+bool SQLPTRepresentation::SaveApplicationCustomData(const std::string &app_id,
bool is_revoked,
bool is_default,
bool is_predata) {
@@ -1458,7 +1447,7 @@ bool SQLPTRepresentation::SaveApplicationCustomData(const std::string& app_id,
}
bool SQLPTRepresentation::IsApplicationRevoked(
- const std::string& app_id) const {
+ const std::string &app_id) const {
dbms::SQLQuery query(db());
if (!query.Prepare(sql_pt::kSelectApplicationRevoked)) {
@@ -1472,9 +1461,9 @@ bool SQLPTRepresentation::IsApplicationRevoked(
return false;
}
return query.IsNull(0) ? false : query.GetBoolean(0);
- }
+}
bool SQLPTRepresentation::IsApplicationRepresented(
- const std::string& app_id) const {
+ const std::string &app_id) const {
dbms::SQLQuery query(db());
if (!query.Prepare(sql_pt::kSelectApplicationRepresented)) {
LOG4CXX_WARN(logger_, "Incorrect select application by id");
@@ -1489,7 +1478,7 @@ bool SQLPTRepresentation::IsApplicationRepresented(
return query.GetInteger(0) != 0;
}
-bool SQLPTRepresentation::IsDefaultPolicy(const std::string& app_id) const {
+bool SQLPTRepresentation::IsDefaultPolicy(const std::string &app_id) const {
dbms::SQLQuery query(db());
if (!query.Prepare(sql_pt::kSelectApplicationIsDefault)) {
LOG4CXX_WARN(logger_, "Incorrect select application by id");
@@ -1504,11 +1493,11 @@ bool SQLPTRepresentation::IsDefaultPolicy(const std::string& app_id) const {
return query.IsNull(0) ? false : query.GetBoolean(0);
}
-bool SQLPTRepresentation::IsPredataPolicy(const std::string& app_id) const {
+bool SQLPTRepresentation::IsPredataPolicy(const std::string &app_id) const {
return false;
}
-bool SQLPTRepresentation::SetDefaultPolicy(const std::string& app_id) {
+bool SQLPTRepresentation::SetDefaultPolicy(const std::string &app_id) {
dbms::SQLQuery query(db());
if (!query.Prepare(sql_pt::kDeleteAppGroupByApplicationId)) {
LOG4CXX_ERROR(logger_, "Incorrect statement to delete from app_group.");
@@ -1534,7 +1523,7 @@ bool SQLPTRepresentation::SetDefaultPolicy(const std::string& app_id) {
return false;
}
-bool SQLPTRepresentation::SetIsDefault(const std::string& app_id,
+bool SQLPTRepresentation::SetIsDefault(const std::string &app_id,
bool is_default) const {
LOG4CXX_TRACE(logger_, "Set flag is_default of application");
dbms::SQLQuery query(db());
@@ -1552,9 +1541,9 @@ bool SQLPTRepresentation::SetIsDefault(const std::string& app_id,
return true;
}
-dbms::SQLDatabase* SQLPTRepresentation::db() const {
+dbms::SQLDatabase *SQLPTRepresentation::db() const {
#ifdef __QNX__
- dbms::SQLDatabase* db = new dbms::SQLDatabase(kDatabaseName);
+ dbms::SQLDatabase *db = new dbms::SQLDatabase(kDatabaseName);
db->Open();
return db;
#else
@@ -1562,8 +1551,8 @@ dbms::SQLDatabase* SQLPTRepresentation::db() const {
#endif
}
-bool SQLPTRepresentation::CopyApplication(const std::string& source,
- const std::string& destination) {
+bool SQLPTRepresentation::CopyApplication(const std::string &source,
+ const std::string &destination) {
dbms::SQLQuery source_app(db());
if (!source_app.Prepare(sql_pt::kSelectApplicationFull)) {
LOG4CXX_WARN(logger_, "Incorrect select statement from application.");
@@ -1585,10 +1574,8 @@ bool SQLPTRepresentation::CopyApplication(const std::string& source,
: query.Bind(1, source_app.GetBoolean(0));
source_app.IsNull(1) ? query.Bind(2)
: query.Bind(2, source_app.GetBoolean(1));
- source_app.IsNull(2) ? query.Bind(3)
- : query.Bind(3, source_app.GetString(2));
- source_app.IsNull(3) ? query.Bind(4)
- : query.Bind(4, source_app.GetString(3));
+ source_app.IsNull(2) ? query.Bind(3) : query.Bind(3, source_app.GetString(2));
+ source_app.IsNull(3) ? query.Bind(4) : query.Bind(4, source_app.GetString(3));
source_app.IsNull(4) ? query.Bind(5)
: query.Bind(5, source_app.GetBoolean(4));
source_app.IsNull(5) ? query.Bind(6)
@@ -1620,8 +1607,6 @@ void SQLPTRepresentation::SetPreloaded(bool value) {
}
}
-bool SQLPTRepresentation::SetVINValue(const std::string& value) {
- return true;
-}
+bool SQLPTRepresentation::SetVINValue(const std::string &value) { return true; }
-} // namespace policy
+} // namespace policy
diff --git a/src/components/policy/test/include/mock_policy_listener.h b/src/components/policy/test/include/mock_policy_listener.h
index 6cbca0557a..681b85740b 100644
--- a/src/components/policy/test/include/mock_policy_listener.h
+++ b/src/components/policy/test/include/mock_policy_listener.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2014, Ford Motor Company
+/* Copyright (c) 2016, Ford Motor Company
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -32,7 +32,6 @@
#ifndef SRC_COMPONENTS_POLICY_TEST_POLICY_INCLUDE_MOCK_POLICY_LISTENER_H_
#define SRC_COMPONENTS_POLICY_TEST_POLICY_INCLUDE_MOCK_POLICY_LISTENER_H_
-
#include <string>
#include "gmock/gmock.h"
@@ -46,42 +45,31 @@ namespace policy_table = ::rpc::policy_table_interface_base;
namespace policy {
class MockPolicyListener : public PolicyListener {
- public:
- MOCK_METHOD3(OnPermissionsUpdated,
- void(const std::string& policy_app_id,
- const Permissions& permissions,
- const policy::HMILevel& default_hmi));
- MOCK_METHOD2(OnPermissionsUpdated,
- void(const std::string& policy_app_id,
- const Permissions& permissions));
+public:
+ MOCK_METHOD3(OnPermissionsUpdated, void(const std::string &policy_app_id,
+ const Permissions &permissions,
+ const policy::HMILevel &default_hmi));
+ MOCK_METHOD2(OnPermissionsUpdated, void(const std::string &policy_app_id,
+ const Permissions &permissions));
MOCK_METHOD1(OnPendingPermissionChange,
- void(const std::string& policy_app_id));
- MOCK_METHOD1(OnUpdateStatusChanged,
- void(const std::string& status));
+ void(const std::string &policy_app_id));
+ MOCK_METHOD1(OnUpdateStatusChanged, void(const std::string &status));
MOCK_METHOD1(OnCurrentDeviceIdUpdateRequired,
- std::string(const std::string& policy_app_id));
- MOCK_METHOD0(OnSystemInfoUpdateRequired,
- void());
- MOCK_METHOD1(GetAppName,
- std::string(const std::string& policy_app_id));
- MOCK_METHOD0(OnUserRequestedUpdateCheckRequired,
- void());
+ std::string(const std::string &policy_app_id));
+ MOCK_METHOD0(OnSystemInfoUpdateRequired, void());
+ MOCK_METHOD1(GetAppName, std::string(const std::string &policy_app_id));
+ MOCK_METHOD0(OnUserRequestedUpdateCheckRequired, void());
MOCK_METHOD2(OnDeviceConsentChanged,
- void(const std::string& device_id,
- bool is_allowed));
- MOCK_METHOD1(OnUpdateHMIAppType,
- void(std::map<std::string, StringArray>));
- MOCK_METHOD1(GetAvailableApps,
- void(std::queue<std::string>&));
- MOCK_METHOD3(OnSnapshotCreated,
- void(const BinaryMessage& pt_string,
- const std::vector<int>& retry_seconds,
- int timeout_exceed));
- MOCK_METHOD0(CanUpdate,
- bool());
- MOCK_METHOD1(OnCertificateUpdated, void (const std::string&));
+ void(const std::string &device_id, bool is_allowed));
+ MOCK_METHOD1(OnUpdateHMIAppType, void(std::map<std::string, StringArray>));
+ MOCK_METHOD1(GetAvailableApps, void(std::queue<std::string> &));
+ MOCK_METHOD1(OnSnapshotCreated, void(const BinaryMessage &pt_string));
+ MOCK_METHOD0(CanUpdate, bool());
+ MOCK_METHOD1(OnCertificateUpdated, void(const std::string &));
+ MOCK_CONST_METHOD2(SendOnAppPermissionsChanged,
+ void(const AppPermissions &, const std::string &));
};
-} // namespace policy
+} // namespace policy
-#endif // SRC_COMPONENTS_POLICY_TEST_POLICY_INCLUDE_MOCK_POLICY_LISTENER_H_
+#endif // SRC_COMPONENTS_POLICY_TEST_POLICY_INCLUDE_MOCK_POLICY_LISTENER_H_
diff --git a/src/components/policy/test/policy_manager_impl_test.cc b/src/components/policy/test/policy_manager_impl_test.cc
index 84fbcf1116..9bc30b3508 100644
--- a/src/components/policy/test/policy_manager_impl_test.cc
+++ b/src/components/policy/test/policy_manager_impl_test.cc
@@ -1,4 +1,5 @@
-/* Copyright (c) 2014, Ford Motor Company
+/*
+ * Copyright (c) 2016, Ford Motor Company
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -64,11 +65,11 @@ namespace components {
namespace policy {
class PolicyManagerImplTest : public ::testing::Test {
- protected:
- PolicyManagerImpl* manager;
- MockCacheManagerInterface* cache_manager;
+protected:
+ PolicyManagerImpl *manager;
+ MockCacheManagerInterface *cache_manager;
MockUpdateStatusManager update_manager;
- MockPolicyListener* listener;
+ MockPolicyListener *listener;
void SetUp() {
manager = new PolicyManagerImpl();
@@ -85,7 +86,7 @@ class PolicyManagerImplTest : public ::testing::Test {
delete listener;
}
- ::testing::AssertionResult IsValid(const policy_table::Table& table) {
+ ::testing::AssertionResult IsValid(const policy_table::Table &table) {
if (table.is_valid()) {
return ::testing::AssertionSuccess();
} else {
@@ -96,23 +97,25 @@ class PolicyManagerImplTest : public ::testing::Test {
}
};
-TEST_F(PolicyManagerImplTest, RefreshRetrySequence_SetSecondsBetweenRetries_ExpectRetryTimeoutSequenceWithSameSeconds) {
+TEST_F(
+ PolicyManagerImplTest,
+ RefreshRetrySequence_SetSecondsBetweenRetries_ExpectRetryTimeoutSequenceWithSameSeconds) {
- //arrange
+ // arrange
std::vector<int> seconds;
seconds.push_back(50);
seconds.push_back(100);
seconds.push_back(200);
- //assert
+ // assert
EXPECT_CALL(*cache_manager, TimeoutResponse()).WillOnce(Return(60));
- EXPECT_CALL(*cache_manager, SecondsBetweenRetries(_)).WillOnce(
- DoAll(SetArgReferee<0>(seconds), Return(true)));
+ EXPECT_CALL(*cache_manager, SecondsBetweenRetries(_))
+ .WillOnce(DoAll(SetArgReferee<0>(seconds), Return(true)));
- //act
+ // act
manager->RefreshRetrySequence();
- //assert
+ // assert
EXPECT_EQ(50, manager->NextRetryTimeout());
EXPECT_EQ(100, manager->NextRetryTimeout());
EXPECT_EQ(200, manager->NextRetryTimeout());
@@ -121,23 +124,22 @@ TEST_F(PolicyManagerImplTest, RefreshRetrySequence_SetSecondsBetweenRetries_Expe
TEST_F(PolicyManagerImplTest, DISABLED_GetUpdateUrl) {
- EXPECT_CALL(*cache_manager, GetServiceUrls("7",_));
- EXPECT_CALL(*cache_manager, GetServiceUrls("4",_));
+ EXPECT_CALL(*cache_manager, GetServiceUrls("7", _));
+ EXPECT_CALL(*cache_manager, GetServiceUrls("4", _));
EndpointUrls ep_7;
manager->GetServiceUrls("7", ep_7);
- EXPECT_EQ("http://policies.telematics.ford.com/api/policies", ep_7[0].url[0] );
+ EXPECT_EQ("http://policies.telematics.ford.com/api/policies", ep_7[0].url[0]);
EndpointUrls ep_4;
manager->GetServiceUrls("4", ep_4);
EXPECT_EQ("http://policies.ford.com/api/policies", ep_4[0].url[0]);
-
}
-
TEST_F(PolicyManagerImplTest, ResetPT) {
- EXPECT_CALL(*cache_manager, ResetPT("filename")).WillOnce(Return(true))
+ EXPECT_CALL(*cache_manager, ResetPT("filename"))
+ .WillOnce(Return(true))
.WillOnce(Return(false));
EXPECT_CALL(*cache_manager, TimeoutResponse());
EXPECT_CALL(*cache_manager, SecondsBetweenRetries(_));
@@ -146,24 +148,25 @@ TEST_F(PolicyManagerImplTest, ResetPT) {
EXPECT_FALSE(manager->ResetPT("filename"));
}
-TEST_F(PolicyManagerImplTest, CheckPermissions_SetHmiLevelFullForAlert_ExpectAllowedPermissions) {
+TEST_F(PolicyManagerImplTest,
+ CheckPermissions_SetHmiLevelFullForAlert_ExpectAllowedPermissions) {
- //arrange
+ // arrange
::policy::CheckPermissionResult expected;
expected.hmi_level_permitted = ::policy::kRpcAllowed;
expected.list_of_allowed_params.push_back("speed");
expected.list_of_allowed_params.push_back("gps");
- //assert
- EXPECT_CALL(*cache_manager, CheckPermissions("12345678", "FULL", "Alert", _)).
- WillOnce(SetArgReferee<3>(expected));
+ // assert
+ EXPECT_CALL(*cache_manager, CheckPermissions("12345678", "FULL", "Alert", _))
+ .WillOnce(SetArgReferee<3>(expected));
- //act
+ // act
::policy::RPCParams input_params;
::policy::CheckPermissionResult output;
manager->CheckPermissions("12345678", "FULL", "Alert", input_params, output);
- //assert
+ // assert
EXPECT_EQ(::policy::kRpcAllowed, output.hmi_level_permitted);
ASSERT_TRUE(!output.list_of_allowed_params.empty());
@@ -174,17 +177,17 @@ TEST_F(PolicyManagerImplTest, CheckPermissions_SetHmiLevelFullForAlert_ExpectAll
TEST_F(PolicyManagerImplTest, LoadPT_SetPT_PTIsLoaded) {
- //arrange
+ // arrange
Json::Value table(Json::objectValue);
table["policy_table"] = Json::Value(Json::objectValue);
- Json::Value& policy_table = table["policy_table"];
+ Json::Value &policy_table = table["policy_table"];
policy_table["module_config"] = Json::Value(Json::objectValue);
policy_table["functional_groupings"] = Json::Value(Json::objectValue);
policy_table["consumer_friendly_messages"] = Json::Value(Json::objectValue);
policy_table["app_policies"] = Json::Value(Json::objectValue);
- Json::Value& module_config = policy_table["module_config"];
+ Json::Value &module_config = policy_table["module_config"];
module_config["preloaded_pt"] = Json::Value(true);
module_config["exchange_after_x_ignition_cycles"] = Json::Value(10);
module_config["exchange_after_x_kilometers"] = Json::Value(100);
@@ -197,10 +200,10 @@ TEST_F(PolicyManagerImplTest, LoadPT_SetPT_PTIsLoaded) {
module_config["endpoints"] = Json::Value(Json::objectValue);
module_config["endpoints"]["0x00"] = Json::Value(Json::objectValue);
module_config["endpoints"]["0x00"]["default"] = Json::Value(Json::arrayValue);
- module_config["endpoints"]["0x00"]["default"][0] = Json::Value(
- "http://ford.com/cloud/default");
- module_config["notifications_per_minute_by_priority"] = Json::Value(
- Json::objectValue);
+ module_config["endpoints"]["0x00"]["default"][0] =
+ Json::Value("http://ford.com/cloud/default");
+ module_config["notifications_per_minute_by_priority"] =
+ Json::Value(Json::objectValue);
module_config["notifications_per_minute_by_priority"]["emergency"] =
Json::Value(1);
module_config["notifications_per_minute_by_priority"]["navigation"] =
@@ -209,17 +212,17 @@ TEST_F(PolicyManagerImplTest, LoadPT_SetPT_PTIsLoaded) {
Json::Value(3);
module_config["notifications_per_minute_by_priority"]["communication"] =
Json::Value(4);
- module_config["notifications_per_minute_by_priority"]["normal"] = Json::Value(
- 5);
- module_config["notifications_per_minute_by_priority"]["none"] = Json::Value(
- 6);
+ module_config["notifications_per_minute_by_priority"]["normal"] =
+ Json::Value(5);
+ module_config["notifications_per_minute_by_priority"]["none"] =
+ Json::Value(6);
module_config["vehicle_make"] = Json::Value("MakeT");
module_config["vehicle_model"] = Json::Value("ModelT");
module_config["vehicle_year"] = Json::Value("2014");
- Json::Value& functional_groupings = policy_table["functional_groupings"];
+ Json::Value &functional_groupings = policy_table["functional_groupings"];
functional_groupings["default"] = Json::Value(Json::objectValue);
- Json::Value& default_group = functional_groupings["default"];
+ Json::Value &default_group = functional_groupings["default"];
default_group["rpcs"] = Json::Value(Json::objectValue);
default_group["rpcs"]["Update"] = Json::Value(Json::objectValue);
default_group["rpcs"]["Update"]["hmi_levels"] = Json::Value(Json::arrayValue);
@@ -227,11 +230,11 @@ TEST_F(PolicyManagerImplTest, LoadPT_SetPT_PTIsLoaded) {
default_group["rpcs"]["Update"]["parameters"] = Json::Value(Json::arrayValue);
default_group["rpcs"]["Update"]["parameters"][0] = Json::Value("speed");
- Json::Value& consumer_friendly_messages =
+ Json::Value &consumer_friendly_messages =
policy_table["consumer_friendly_messages"];
consumer_friendly_messages["version"] = Json::Value("1.2");
- Json::Value& app_policies = policy_table["app_policies"];
+ Json::Value &app_policies = policy_table["app_policies"];
app_policies["default"] = Json::Value(Json::objectValue);
app_policies["default"]["memory_kb"] = Json::Value(50);
app_policies["default"]["heart_beat_timeout_ms"] = Json::Value(100);
@@ -256,18 +259,17 @@ TEST_F(PolicyManagerImplTest, LoadPT_SetPT_PTIsLoaded) {
policy_table::Table update(&table);
update.SetPolicyTableType(rpc::policy_table_interface_base::PT_UPDATE);
- //assert
+ // assert
ASSERT_TRUE(IsValid(update));
-
- //act
+ // act
std::string json = table.toStyledString();
::policy::BinaryMessage msg(json.begin(), json.end());
- utils::SharedPtr<policy_table::Table> snapshot = new policy_table::Table(
- update.policy_table);
+ utils::SharedPtr<policy_table::Table> snapshot =
+ new policy_table::Table(update.policy_table);
- //assert
+ // assert
EXPECT_CALL(*cache_manager, GenerateSnapshot()).WillOnce(Return(snapshot));
EXPECT_CALL(*cache_manager, ApplyUpdate(_)).WillOnce(Return(true));
EXPECT_CALL(*listener, GetAppName("1234")).WillOnce(Return(""));
@@ -276,36 +278,56 @@ TEST_F(PolicyManagerImplTest, LoadPT_SetPT_PTIsLoaded) {
EXPECT_CALL(*cache_manager, TimeoutResponse());
EXPECT_CALL(*cache_manager, SecondsBetweenRetries(_));
- EXPECT_TRUE(manager->LoadPT("file_pt_update.json", msg));
-}
-
-TEST_F(PolicyManagerImplTest, RequestPTUpdate_SetPT_GeneratedSnapshotAndPTUpdate) {
-
- //arrange
- ::utils::SharedPtr< ::policy_table::Table > p_table =
- new ::policy_table::Table();
-
- //assert
- EXPECT_CALL(*cache_manager, GenerateSnapshot()).WillOnce(Return(p_table));
+ TEST_F(PolicyManagerImplTest2, NextRetryTimeout_ExpectTimeoutsFromPT) {
+ // Arrange
+ std::ifstream ifile("sdl_preloaded_pt.json");
+ Json::Reader reader;
+ Json::Value root(Json::objectValue);
+ if (ifile.is_open() && reader.parse(ifile, root, true)) {
+ Json::Value seconds_between_retries = Json::Value(Json::arrayValue);
+ seconds_between_retries =
+ root["policy_table"]["module_config"]["seconds_between_retries"];
+ uint32_t size = seconds_between_retries.size();
+ CreateLocalPT("sdl_preloaded_pt.json");
+
+ uint32_t waiting_timeout = 0u;
+
+ for (uint32_t retry_number = 0u; retry_number < size; ++retry_number) {
+ waiting_timeout += seconds_between_retries[retry_number].asInt();
+ waiting_timeout += manager->TimeoutExchange();
+
+ // it's in miliseconds
+ EXPECT_EQ(waiting_timeout * date_time::DateTime::MILLISECONDS_IN_SECOND,
+ manager->NextRetryTimeout());
+ }
+ }
+ }
- //act
- manager->RequestPTUpdate();
-}
+ TEST_F(PolicyManagerImplTest,
+ RequestPTUpdate_SetPT_GeneratedSnapshotAndPTUpdate) {
+ // arrange
+ ::utils::SharedPtr<::policy_table::Table> p_table =
+ new ::policy_table::Table();
-TEST_F(PolicyManagerImplTest, DISABLED_AddApplication) {
- // TODO(AOleynik): Implementation of method should be changed to avoid
- // using of snapshot
- //manager->AddApplication("12345678");
-}
+ // assert
+ EXPECT_CALL(*cache_manager, GenerateSnapshot()).WillOnce(Return(p_table));
-TEST_F(PolicyManagerImplTest, DISABLED_GetPolicyTableStatus) {
- // TODO(AOleynik): Test is not finished, to be continued
- //manager->GetPolicyTableStatus();
-}
+ // act
+ manager->RequestPTUpdate();
+ }
+ TEST_F(PolicyManagerImplTest, DISABLED_AddApplication) {
+ // TODO(AOleynik): Implementation of method should be changed to avoid
+ // using of snapshot
+ // manager->AddApplication("12345678");
+ }
+ TEST_F(PolicyManagerImplTest, DISABLED_GetPolicyTableStatus) {
+ // TODO(AOleynik): Test is not finished, to be continued
+ // manager->GetPolicyTableStatus();
+ }
}
// namespace policy
-}// namespace components
-} // namespace test
+} // namespace components
+} // namespace test