summaryrefslogtreecommitdiff
path: root/src/components/application_manager
diff options
context:
space:
mode:
authorAndrey Oleynik <aoleynik@luxoft.com>2016-05-13 13:55:04 +0300
committerAndrey Oleynik <aoleynik@luxoft.com>2016-05-13 17:42:46 +0300
commit8766c99f18b785c8e93d0cac0938a836b02ed060 (patch)
tree7fccaf851ce2c69a44e1bf4cca126a8319b8cc44 /src/components/application_manager
parent2b17b5546d4d94665a37697d73f10adfb14b6dd3 (diff)
downloadsdl_core-8766c99f18b785c8e93d0cac0938a836b02ed060.tar.gz
Fixes setting of default HMI level during application registration
During registration default HMI level must be set before sending of any RPCs to mobile side since every RPC must be validated by policy. These changes have been taken from develop branch and were originally related to APPLINK-20111. Closes-bug: APPLINK-24294
Diffstat (limited to 'src/components/application_manager')
-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.h218
-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.cc721
-rw-r--r--src/components/application_manager/src/state_controller.cc365
9 files changed, 3328 insertions, 3325 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..1676331fbc 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
@@ -59,46 +59,45 @@ 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);
+
+ 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);
std::string GetLockScreenIconUrl() const;
void ResetRetrySequence();
@@ -107,8 +106,8 @@ class PolicyHandler :
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 +120,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 +147,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 +160,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 +178,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 +202,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,9 +223,9 @@ 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
@@ -242,13 +241,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 +267,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);
+ virtual void
+ OnUpdateHMIAppType(std::map<std::string, StringArray> app_hmi_types);
- virtual void OnCertificateUpdated(const std::string& certificate_data);
+ virtual void OnCertificateUpdated(const std::string &certificate_data);
virtual bool CanUpdate();
- virtual void OnDeviceConsentChanged(const std::string& device_id,
+ virtual void OnDeviceConsentChanged(const std::string &device_id,
bool is_allowed);
virtual void OnPTExchangeNeeded();
- virtual void GetAvailableApps(std::queue<std::string>& apps);
+ virtual void GetAvailableApps(std::queue<std::string> &apps);
/**
* @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 +308,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 +326,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 +348,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 +396,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 +448,7 @@ private:
inline bool CreateManager();
- typedef std::list <PolicyHandlerObserver*> HandlersCollection;
+ typedef std::list<PolicyHandlerObserver *> HandlersCollection;
HandlersCollection listeners_;
sync_primitives::Lock listeners_lock_;
@@ -460,11 +466,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..99750aaccc 100644
--- a/src/components/application_manager/src/policies/policy_handler.cc
+++ b/src/components/application_manager/src/policies/policy_handler.cc
@@ -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);
}
@@ -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;
+}
}