summaryrefslogtreecommitdiff
path: root/src/components/application_manager
diff options
context:
space:
mode:
Diffstat (limited to 'src/components/application_manager')
-rw-r--r--src/components/application_manager/CMakeLists.txt13
-rw-r--r--src/components/application_manager/include/application_manager/application.h11
-rw-r--r--src/components/application_manager/include/application_manager/application_impl.h11
-rw-r--r--src/components/application_manager/include/application_manager/application_manager_impl.h101
-rw-r--r--src/components/application_manager/include/application_manager/commands/command.h18
-rw-r--r--src/components/application_manager/include/application_manager/commands/command_impl.h17
-rw-r--r--src/components/application_manager/include/application_manager/commands/command_request_impl.h18
-rw-r--r--src/components/application_manager/include/application_manager/commands/hmi/on_phone_call_notification.h77
-rw-r--r--src/components/application_manager/include/application_manager/message_helper.h6
-rw-r--r--src/components/application_manager/include/application_manager/mobile_message_handler.h6
-rw-r--r--src/components/application_manager/include/application_manager/policies/policy_handler.h43
-rw-r--r--src/components/application_manager/include/application_manager/policies/pt_exchange_handler_impl.h2
-rw-r--r--src/components/application_manager/include/application_manager/request_controller.h20
-rw-r--r--src/components/application_manager/include/application_manager/request_info.h120
-rw-r--r--src/components/application_manager/include/application_manager/smart_object_keys.h1
-rw-r--r--src/components/application_manager/src/application_impl.cc16
-rw-r--r--src/components/application_manager/src/application_manager_impl.cc301
-rw-r--r--src/components/application_manager/src/commands/command_impl.cc12
-rw-r--r--src/components/application_manager/src/commands/hmi/activate_app_request.cc16
-rw-r--r--src/components/application_manager/src/commands/hmi/on_app_deactivated_notification.cc10
-rw-r--r--src/components/application_manager/src/commands/hmi/on_exit_all_applications_notification.cc9
-rw-r--r--src/components/application_manager/src/commands/hmi/on_phone_call_notification.cc70
-rw-r--r--src/components/application_manager/src/commands/mobile/perform_audio_pass_thru_request.cc3
-rw-r--r--src/components/application_manager/src/commands/mobile/put_file_request.cc16
-rw-r--r--src/components/application_manager/src/commands/mobile/register_app_interface_request.cc38
-rw-r--r--src/components/application_manager/src/commands/mobile/set_icon_request.cc2
-rw-r--r--src/components/application_manager/src/commands/mobile/slider_request.cc4
-rw-r--r--src/components/application_manager/src/hmi_capabilities.cc14
-rw-r--r--src/components/application_manager/src/hmi_command_factory.cc9
-rw-r--r--src/components/application_manager/src/message_helper.cc10
-rw-r--r--src/components/application_manager/src/mobile_message_handler.cc4
-rw-r--r--src/components/application_manager/src/policies/policy_event_observer.cc2
-rw-r--r--src/components/application_manager/src/policies/policy_handler.cc55
-rw-r--r--src/components/application_manager/src/policies/pt_exchange_handler_impl.cc15
-rw-r--r--src/components/application_manager/src/request_controller.cc73
-rw-r--r--src/components/application_manager/src/request_info.cc16
-rw-r--r--src/components/application_manager/src/resume_ctrl.cpp81
-rw-r--r--src/components/application_manager/test/CMakeLists.txt11
-rw-r--r--src/components/application_manager/test/mock/include/application_manager/application.h11
-rw-r--r--src/components/application_manager/test/mock/include/application_manager/application_impl.h11
-rw-r--r--src/components/application_manager/test/mock/include/application_manager/application_manager_impl.h11
-rw-r--r--src/components/application_manager/test/mock/include/application_manager/commands/command.h18
-rw-r--r--src/components/application_manager/test/mock/include/application_manager/commands/command_impl.h17
-rw-r--r--src/components/application_manager/test/mock/include/application_manager/commands/command_request_impl.h18
-rw-r--r--src/components/application_manager/test/mock/include/application_manager/commands/hmi/on_phone_call_notification.h77
-rw-r--r--src/components/application_manager/test/mock/include/application_manager/message_helper.h6
-rw-r--r--src/components/application_manager/test/mock/include/application_manager/mobile_message_handler.h6
-rw-r--r--src/components/application_manager/test/mock/include/application_manager/policies/policy_handler.h43
-rw-r--r--src/components/application_manager/test/mock/include/application_manager/policies/pt_exchange_handler_impl.h2
-rw-r--r--src/components/application_manager/test/mock/include/application_manager/request_controller.h20
-rw-r--r--src/components/application_manager/test/mock/include/application_manager/request_info.h120
-rw-r--r--src/components/application_manager/test/mock/include/application_manager/smart_object_keys.h1
52 files changed, 1158 insertions, 454 deletions
diff --git a/src/components/application_manager/CMakeLists.txt b/src/components/application_manager/CMakeLists.txt
index 1a23890c0e..07d8de458e 100644
--- a/src/components/application_manager/CMakeLists.txt
+++ b/src/components/application_manager/CMakeLists.txt
@@ -4,9 +4,6 @@ set (AM_TEST_DIR ${AM_SOURCE_DIR}/test)
set (AM_MOCK_DIR ${AM_TEST_DIR}/mock)
-if (EXTENDED_POLICY_FLAG)
- add_definitions(-DEXTENDED_POLICY)
-endif()
include_directories (
include/
@@ -40,14 +37,6 @@ ${AM_SOURCE_DIR}/src/policies/policy_handler.cc
${AM_SOURCE_DIR}/src/policies/policy_event_observer.cc
)
-if (EXTENDED_POLICY_FLAG)
- include_directories(
- ${COMPONENTS_DIR}/policy/src/policy/policy_table/table_struct_ext
- )
- list(APPEND POLICIES_MANAGER
- ${AM_SOURCE_DIR}/src/policies/pt_exchange_handler_ext.cc
- )
-else ()
include_directories(
${COMPONENTS_DIR}/policy/src/policy/policy_table/table_struct
)
@@ -55,7 +44,6 @@ else ()
${AM_SOURCE_DIR}/src/policies/pt_exchange_handler_impl.cc
${AM_SOURCE_DIR}/src/policies/policy_retry_sequence.cc
)
-endif ()
file (GLOB EVENT_ENGINE
${AM_SOURCE_DIR}/src/event_engine/*
@@ -258,6 +246,7 @@ file (GLOB MOBILE_COMMANDS_SOURCES
${AM_SOURCE_DIR}/src/commands/hmi/get_urls_response.cc
${AM_SOURCE_DIR}/src/commands/hmi/on_device_state_changed_notification.cc
${AM_SOURCE_DIR}/src/commands/hmi/on_tts_reset_timeout_notification.cc
+ ${AM_SOURCE_DIR}/src/commands/hmi/on_phone_call_notification.cc
)
set (HMI_COMMANDS_SOURCES_JSON
diff --git a/src/components/application_manager/include/application_manager/application.h b/src/components/application_manager/include/application_manager/application.h
index 636b0aaa41..5f1f598851 100644
--- a/src/components/application_manager/include/application_manager/application.h
+++ b/src/components/application_manager/include/application_manager/application.h
@@ -393,7 +393,6 @@ class Application : public virtual InitialApplicationData,
virtual bool MakeFullscreen() = 0;
virtual bool IsAudible() const = 0;
virtual void MakeNotAudible() = 0;
-
virtual bool allowed_support_navigation() const = 0;
virtual void set_allowed_support_navigation(bool allow) = 0;
virtual bool hmi_supports_navi_video_streaming() const = 0;
@@ -401,6 +400,9 @@ class Application : public virtual InitialApplicationData,
virtual bool hmi_supports_navi_audio_streaming() const = 0;
virtual void set_hmi_supports_navi_audio_streaming(bool supports) = 0;
+ virtual bool is_voice_communication_supported() const = 0;
+ virtual void set_voice_communication_supported(
+ bool is_voice_communication_supported) = 0;
virtual bool app_allowed() const = 0;
virtual bool has_been_activated() const = 0;
@@ -530,6 +532,13 @@ class Application : public virtual InitialApplicationData,
*/
virtual void UnsubscribeFromSoftButtons(int32_t cmd_id) = 0;
+ /**
+ * @brief Check's if it is media, voice communication or navigation application
+ *
+ * @return true if application is media, voice communication or navigation
+ */
+ virtual bool IsAudioApplication() const = 0;
+
protected:
// interfaces for NAVI retry sequence
diff --git a/src/components/application_manager/include/application_manager/application_impl.h b/src/components/application_manager/include/application_manager/application_impl.h
index 0a056df92b..dadfce0929 100644
--- a/src/components/application_manager/include/application_manager/application_impl.h
+++ b/src/components/application_manager/include/application_manager/application_impl.h
@@ -82,6 +82,9 @@ class ApplicationImpl : public virtual InitialApplicationDataImpl,
bool hmi_supports_navi_audio_streaming() const;
void set_hmi_supports_navi_audio_streaming(bool supports);
+ virtual bool is_voice_communication_supported() const;
+ virtual void set_voice_communication_supported(
+ bool is_voice_communication_supported);
inline bool app_allowed() const;
bool has_been_activated() const;
@@ -166,6 +169,13 @@ class ApplicationImpl : public virtual InitialApplicationDataImpl,
virtual void UnsubscribeFromSoftButtons(int32_t cmd_id);
+ /**
+ * @brief Check's if it is media, voice communication or navigation application
+ *
+ * @return true if application is media, voice communication or navigation
+ */
+ virtual bool IsAudioApplication() const;
+
protected:
/**
@@ -220,6 +230,7 @@ class ApplicationImpl : public virtual InitialApplicationDataImpl,
std::set<uint32_t> subscribed_vehicle_info_;
UsageStatistics usage_report_;
ProtocolVersion protocol_version_;
+ bool is_voice_communication_application_;
// NAVI retry stream
volatile bool is_video_stream_retry_active_;
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 b29bd10252..dacac9e010 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
@@ -203,6 +203,41 @@ class ApplicationManagerImpl : public ApplicationManager,
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 Check's if there are audio(media, voice communication or navi) applications
+ * exist in HMI_FULL or HMI_LIMITED level with same audible HMI type.
+ * Used for resumption.
+ *
+ * @param app Pointer to application to compare with
+ *
+ * @return true if exist otherwise false
+ */
+ bool DoesAudioAppWithSameHMITypeExistInFullOrLimited(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.
@@ -281,14 +316,6 @@ class ApplicationManagerImpl : public ApplicationManager,
bool RemoveAppDataFromHMI(ApplicationSharedPtr app);
bool LoadAppDataToHMI(ApplicationSharedPtr app);
bool ActivateApplication(ApplicationSharedPtr app);
- /**
- * @brief Put application in Limited 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 Limeted
- * @return seted HMI Level
- */
- mobile_api::HMILevel::eType PutApplicationInLimited(ApplicationSharedPtr app);
/**
* @brief Put application in FULL HMI Level if possible,
@@ -404,27 +431,27 @@ class ApplicationManagerImpl : public ApplicationManager,
// if |final_message| parameter is set connection to mobile will be closed
// after processing this message
void SendMessageToMobile(
- const utils::SharedPtr<smart_objects::SmartObject>& message,
+ const utils::SharedPtr<smart_objects::SmartObject> message,
bool final_message = false);
bool ManageMobileCommand(
- const utils::SharedPtr<smart_objects::SmartObject>& message);
+ const utils::SharedPtr<smart_objects::SmartObject> message);
void SendMessageToHMI(
- const utils::SharedPtr<smart_objects::SmartObject>& message);
+ const utils::SharedPtr<smart_objects::SmartObject> message);
bool ManageHMICommand(
- const utils::SharedPtr<smart_objects::SmartObject>& message);
+ const utils::SharedPtr<smart_objects::SmartObject> message);
/////////////////////////////////////////////////////////
/*
* @brief Overriden ProtocolObserver method
*/
virtual void OnMessageReceived(
- const RawMessagePtr message);
+ const ::protocol_handler::RawMessagePtr message);
/*
* @brief Overriden ProtocolObserver method
*/
virtual void OnMobileMessageSent(
- const RawMessagePtr message);
+ const ::protocol_handler::RawMessagePtr message);
void OnMessageReceived(hmi_message_handler::MessageSharedPointer message);
void OnErrorSending(hmi_message_handler::MessageSharedPointer message);
@@ -458,7 +485,7 @@ class ApplicationManagerImpl : public ApplicationManager,
*
* @param connection_key Connection key of application
* @param mobile_correlation_id Correlation ID of the mobile request
- * @param new_timeout_value New timeout to be set
+ * @param new_timeout_value New timeout in milliseconds to be set
*/
void updateRequestTimeout(uint32_t connection_key,
uint32_t mobile_correlation_id,
@@ -601,6 +628,20 @@ class ApplicationManagerImpl : public ApplicationManager,
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
@@ -684,10 +725,10 @@ class ApplicationManagerImpl : public ApplicationManager,
bool ConvertSOtoMessage(const smart_objects::SmartObject& message,
Message& output);
utils::SharedPtr<Message> ConvertRawMsgToMessage(
- const RawMessagePtr message);
+ const ::protocol_handler::RawMessagePtr message);
- void ProcessMessageFromMobile(const utils::SharedPtr<Message>& message);
- void ProcessMessageFromHMI(const utils::SharedPtr<Message>& message);
+ void ProcessMessageFromMobile(const utils::SharedPtr<Message> message);
+ void ProcessMessageFromHMI(const utils::SharedPtr<Message> message);
// threads::MessageLoopThread<*>::Handler implementations
/*
@@ -738,6 +779,27 @@ class ApplicationManagerImpl : public ApplicationManager,
*/
std::map<uint32_t, TimevalStruct> tts_global_properties_app_list_;
+
+ struct AppState {
+ AppState(const mobile_apis::HMILevel::eType& level,
+ const mobile_apis::AudioStreamingState::eType& streaming_state,
+ const mobile_apis::SystemContext::eType& context)
+ : hmi_level(level),
+ audio_streaming_state(streaming_state),
+ system_context(context) { }
+
+ mobile_apis::HMILevel::eType hmi_level;
+ mobile_apis::AudioStreamingState::eType audio_streaming_state;
+ mobile_apis::SystemContext::eType system_context;
+ };
+
+ /**
+ * @brief Map contains apps with HMI state before incoming call
+ * After incoming call ends previous HMI state must restore
+ *
+ */
+ std::map<uint32_t, AppState> on_phone_call_app_list_;
+
bool audio_pass_thru_active_;
sync_primitives::Lock audio_pass_thru_lock_;
sync_primitives::Lock tts_global_properties_app_list_lock_;
@@ -790,8 +852,7 @@ class ApplicationManagerImpl : public ApplicationManager,
public:
ApplicationListUpdateTimer(ApplicationManagerImpl* callee) :
timer::TimerThread<ApplicationManagerImpl>("AM ListUpdater",
- callee, &ApplicationManagerImpl::OnApplicationListUpdateTimer
- ) {
+ callee, &ApplicationManagerImpl::OnApplicationListUpdateTimer) {
}
};
typedef utils::SharedPtr<ApplicationListUpdateTimer> ApplicationListUpdateTimerSptr;
diff --git a/src/components/application_manager/include/application_manager/commands/command.h b/src/components/application_manager/include/application_manager/commands/command.h
index 28c77b6229..587c3d834c 100644
--- a/src/components/application_manager/include/application_manager/commands/command.h
+++ b/src/components/application_manager/include/application_manager/commands/command.h
@@ -90,6 +90,24 @@ class Command {
* @brief Retrieves correlation ID
*/
virtual uint32_t correlation_id() const = 0;
+
+ /*
+ * @brief Retrieves connection_key
+ */
+ virtual uint32_t connection_key() const = 0;
+
+ /*
+ * @brief Retrieves request ID
+ */
+ virtual int32_t function_id() const = 0;
+
+ /*
+ * @brief Function is called by RequestController when request execution time
+ * has exceed it's limit
+ *
+ */
+ virtual void onTimeOut() = 0;
+
};
} // namespace commands
diff --git a/src/components/application_manager/include/application_manager/commands/command_impl.h b/src/components/application_manager/include/application_manager/commands/command_impl.h
index 06637d7d84..a34716bd62 100644
--- a/src/components/application_manager/include/application_manager/commands/command_impl.h
+++ b/src/components/application_manager/include/application_manager/commands/command_impl.h
@@ -101,6 +101,23 @@ class CommandImpl : public Command {
*/
virtual uint32_t correlation_id() const;
+ /*
+ * @brief Retrieves connection key
+ */
+ virtual uint32_t connection_key() const;
+
+ /*
+ * @brief Retrieves request ID
+ */
+ virtual int32_t function_id() const;
+
+ /*
+ * @brief Function is called by RequestController when request execution time
+ * has exceed it's limit
+ *
+ */
+ virtual void onTimeOut();
+
// members
static const int32_t hmi_protocol_type_;
static const int32_t mobile_protocol_type_;
diff --git a/src/components/application_manager/include/application_manager/commands/command_request_impl.h b/src/components/application_manager/include/application_manager/commands/command_request_impl.h
index fb14078961..1bbba5aa0b 100644
--- a/src/components/application_manager/include/application_manager/commands/command_request_impl.h
+++ b/src/components/application_manager/include/application_manager/commands/command_request_impl.h
@@ -81,16 +81,6 @@ class CommandRequestImpl : public CommandImpl,
virtual void on_event(const event_engine::Event& event);
/*
- * @brief Retrieves request ID
- */
- inline int32_t function_id() const;
-
- /*
- * @brief Retrieves connection key
- */
- inline uint32_t connection_key() const;
-
- /*
* @brief Creates Mobile response
*
* @param success true if successful; false, if failed
@@ -194,14 +184,6 @@ protected:
void AddDisallowedParametersToInfo(smart_objects::SmartObject& response) const;
};
-int32_t CommandRequestImpl::function_id() const {
- return (*message_)[strings::params][strings::function_id].asInt();
-}
-
-uint32_t CommandRequestImpl::connection_key() const {
- return (*message_)[strings::params][strings::connection_key].asUInt();
-}
-
} // namespace commands
} // namespace application_manager
diff --git a/src/components/application_manager/include/application_manager/commands/hmi/on_phone_call_notification.h b/src/components/application_manager/include/application_manager/commands/hmi/on_phone_call_notification.h
new file mode 100644
index 0000000000..45d831eb03
--- /dev/null
+++ b/src/components/application_manager/include/application_manager/commands/hmi/on_phone_call_notification.h
@@ -0,0 +1,77 @@
+/*
+ * Copyright (c) 2013, Ford Motor Company
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * Neither the name of the Ford Motor Company nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_COMMANDS_HMI_ON_PHONE_CALL_NOTIFICATION_H_
+#define SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_COMMANDS_HMI_ON_PHONE_CALL_NOTIFICATION_H_
+
+#include "application_manager/commands/hmi/notification_from_hmi.h"
+
+namespace application_manager {
+
+namespace commands {
+
+namespace hmi {
+
+
+/**
+ * @brief OnPhoneCallNotification command class
+ **/
+class OnPhoneCallNotification : public NotificationFromHMI {
+ public:
+ /**
+ * @brief OnPhoneCallNotification class constructor
+ *
+ * @param message Incoming SmartObject message
+ **/
+ explicit OnPhoneCallNotification(const MessageSharedPtr& message);
+
+ /**
+ * @brief OnPhoneCallNotification class destructor
+ **/
+ virtual ~OnPhoneCallNotification();
+
+ /**
+ * @brief Execute command
+ **/
+ virtual void Run();
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(OnPhoneCallNotification);
+};
+
+} // namespace hmi
+
+} // namespace commands
+
+} // namespace application_manager
+
+#endif // SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_COMMANDS_HMI_ON_PHONE_CALL_NOTIFICATION_H_
diff --git a/src/components/application_manager/include/application_manager/message_helper.h b/src/components/application_manager/include/application_manager/message_helper.h
index e7a7631d69..69c7b7bba7 100644
--- a/src/components/application_manager/include/application_manager/message_helper.h
+++ b/src/components/application_manager/include/application_manager/message_helper.h
@@ -1,4 +1,4 @@
-/*
+/*
Copyright (c) 2013, Ford Motor Company
All rights reserved.
@@ -92,7 +92,9 @@ class MessageHelper {
*
**/
static void SendOnAppRegisteredNotificationToHMI(
- const Application& application_impl, bool resumption = false);
+ const Application& application_impl,
+ bool resumption = false,
+ bool need_restore_vr = false);
/**
* @brief Create mobile HashUpdateNotification
diff --git a/src/components/application_manager/include/application_manager/mobile_message_handler.h b/src/components/application_manager/include/application_manager/mobile_message_handler.h
index c84ba54212..67d51c0dab 100644
--- a/src/components/application_manager/include/application_manager/mobile_message_handler.h
+++ b/src/components/application_manager/include/application_manager/mobile_message_handler.h
@@ -1,4 +1,4 @@
-/**
+/*
* Copyright (c) 2013, Ford Motor Company
* All rights reserved.
*
@@ -42,10 +42,10 @@ typedef utils::SharedPtr<application_manager::Message> MobileMessage;
class MobileMessageHandler {
public:
static application_manager::Message* HandleIncomingMessageProtocolV1(
- const RawMessagePtr message);
+ const protocol_handler::RawMessagePtr message);
static application_manager::Message* HandleIncomingMessageProtocolV2(
- const RawMessagePtr message);
+ const protocol_handler::RawMessagePtr message);
//! -------------------------------------------------------------
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 5bc23c106a..dfc29fe00a 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
@@ -303,6 +303,18 @@ class PolicyHandler :
*/
uint16_t HeartBeatTimeout(const std::string& app_id) const;
+//TODO(AKutsan) REMOVE THIS UGLY HOTFIX
+ virtual void Increment(usage_statistics::GlobalCounterId type);
+ virtual void Increment(const std::string& app_id,
+ usage_statistics::AppCounterId type);
+ virtual void Set(const std::string& app_id,
+ usage_statistics::AppInfoId type,
+ const std::string& value);
+ virtual void Add(const std::string& app_id,
+ usage_statistics::AppStopwatchId type,
+ int32_t timespan_seconds);
+
+
protected:
/**
@@ -338,6 +350,33 @@ protected:
const std::string ConvertUpdateStatus(policy::PolicyTableStatus status);
private:
+
+ class StatisticManagerImpl: public usage_statistics::StatisticsManager {
+ //TODO(AKutsan) REMOVE THIS UGLY HOTFIX
+ virtual void Increment(usage_statistics::GlobalCounterId type) {
+ return PolicyHandler::instance()->Increment(type);
+ }
+
+ virtual void Increment(const std::string& app_id,
+ usage_statistics::AppCounterId type) {
+ return PolicyHandler::instance()->Increment(app_id, type);
+ }
+
+ virtual void Set(const std::string& app_id,
+ usage_statistics::AppInfoId type,
+ const std::string& value) {
+ return PolicyHandler::instance()->Set(app_id, type, value);
+ }
+
+ virtual void Add(const std::string& app_id,
+ usage_statistics::AppStopwatchId type,
+ int32_t timespan_seconds) {
+ return PolicyHandler::instance()->Add(app_id, type, timespan_seconds);
+ }
+ };
+ //TODO(AKutsan) REMOVE THIS UGLY HOTFIX
+
+
PolicyHandler();
static PolicyHandler* instance_;
static const std::string kLibrary;
@@ -365,6 +404,10 @@ private:
*/
std::map<std::string, std::string> app_to_device_link_;
+
+ utils::SharedPtr<StatisticManagerImpl> statistic_manager_impl_;
+
+
DISALLOW_COPY_AND_ASSIGN(PolicyHandler);
FRIEND_BASE_SINGLETON_CLASS_WITH_DELETER(PolicyHandler,
utils::deleters::Deleter<PolicyHandler>);
diff --git a/src/components/application_manager/include/application_manager/policies/pt_exchange_handler_impl.h b/src/components/application_manager/include/application_manager/policies/pt_exchange_handler_impl.h
index e1e67b1505..29c74aa96e 100644
--- a/src/components/application_manager/include/application_manager/policies/pt_exchange_handler_impl.h
+++ b/src/components/application_manager/include/application_manager/policies/pt_exchange_handler_impl.h
@@ -50,7 +50,7 @@ class PTExchangeHandlerImpl : public PTExchangeHandler {
protected:
PolicyHandler* policy_handler_;
- threads::Thread retry_sequence_;
+ threads::Thread* retry_sequence_;
sync_primitives::Lock retry_sequence_lock_;
friend class RetrySequence;
diff --git a/src/components/application_manager/include/application_manager/request_controller.h b/src/components/application_manager/include/application_manager/request_controller.h
index b70608fbc2..2bc5f54666 100644
--- a/src/components/application_manager/include/application_manager/request_controller.h
+++ b/src/components/application_manager/include/application_manager/request_controller.h
@@ -131,7 +131,7 @@ class RequestController {
* @return Result code
*
*/
- TResult addHMIRequest(const RequestPtr& request);
+ TResult addHMIRequest(const RequestPtr request);
/**
* @ Add notification to collection
@@ -182,7 +182,7 @@ class RequestController {
*
* @param app_id Connection key of application
* @param mobile_correlation_id Correlation ID of the mobile request
- * @param new_timeout_value New timeout to be set
+ * @param new_timeout_value New timeout to be set in milliseconds
*/
void updateRequestTimeout(const uint32_t& app_id,
const uint32_t& mobile_correlation_id,
@@ -196,7 +196,9 @@ class RequestController {
* @param app_time_scale - time scale (seconds)
* @param max_request_per_time_scale - maximum count of request that should be allowed for app_time_scale secconds
*/
- bool checkTimeScaleMaxRequest(const uint32_t& app_id, const uint32_t& app_time_scale, const uint32_t& max_request_per_time_scale);
+ bool checkTimeScaleMaxRequest(const uint32_t& app_id,
+ const uint32_t& app_time_scale,
+ const uint32_t& max_request_per_time_scale);
/**
* @brief Checs if this app as able to add new requests in current hmi_level, or limits was exceeded
@@ -205,7 +207,10 @@ class RequestController {
* @param app_time_scale - time scale (seconds)
* @param max_request_per_time_scale - maximum count of request that should be allowed for app_time_scale secconds
*/
- bool checkHMILevelTimeScaleMaxRequest(const mobile_apis::HMILevel::eType& hmi_level, const uint32_t& app_id, const uint32_t& app_time_scale, const uint32_t& max_request_per_time_scale);
+ bool checkHMILevelTimeScaleMaxRequest(const mobile_apis::HMILevel::eType& hmi_level,
+ const uint32_t& app_id,
+ const uint32_t& app_time_scale,
+ const uint32_t& max_request_per_time_scale);
void onTimer();
@@ -232,12 +237,7 @@ class RequestController {
volatile bool stop_flag_;
};
- /**
- * @brief Typedef for thread shared pointer
- */
- typedef utils::SharedPtr<Thread> ThreadSharedPtr;
-
- std::vector<ThreadSharedPtr> pool_;
+ std::vector<Thread*> pool_;
volatile TPoolState pool_state_;
uint32_t pool_size_;
sync_primitives::ConditionalVariable cond_var_;
diff --git a/src/components/application_manager/include/application_manager/request_info.h b/src/components/application_manager/include/application_manager/request_info.h
index 778e72c916..b1409488fd 100644
--- a/src/components/application_manager/include/application_manager/request_info.h
+++ b/src/components/application_manager/include/application_manager/request_info.h
@@ -1,4 +1,4 @@
-/**
+/**
* \file request_info.h
* \brief request information structure header file.
*
@@ -55,26 +55,30 @@ namespace request_controller {
typedef utils::SharedPtr<commands::CommandRequestImpl> MobileRequestPtr;
struct RequestInfo {
- RequestInfo(const uint64_t timeout_sec):
- timeout_sec_(timeout_sec) {
+ RequestInfo(const uint64_t timeout_sec)
+ : timeout_sec_(timeout_sec) {
start_time_ = date_time::DateTime::getCurrentTime();
updateEndTime();
}
- RequestInfo(const TimevalStruct& start_time,const uint64_t timeout_sec):
- start_time_(start_time),
+ RequestInfo(const TimevalStruct& start_time,const uint64_t timeout_sec)
+ : start_time_(start_time),
timeout_sec_(timeout_sec) {
updateEndTime();
- }
+ }
- virtual ~RequestInfo(){}
+ virtual ~RequestInfo(){}
- virtual uint32_t requestId() = 0;
- virtual commands::Command* request() = 0;
+ virtual uint32_t requestId() = 0;
+ virtual commands::Command* request() = 0;
void updateEndTime() {
end_time_ = date_time::DateTime::getCurrentTime();
end_time_.tv_sec += timeout_sec_;
+
+ // possible delay during IPC
+ const uint32_t hmi_delay_sec = 1;
+ end_time_.tv_sec += hmi_delay_sec;
}
void updateTimeOut(const uint64_t& timeout_sec) {
@@ -89,9 +93,11 @@ namespace request_controller {
}
return true;
}
+
TimevalStruct start_time() {
return start_time_;
}
+
uint64_t timeout_sec() {
return timeout_sec_;
}
@@ -100,42 +106,62 @@ namespace request_controller {
return end_time_;
}
+ uint32_t app_id() {
+ return app_id_;
+ }
+
+ mobile_apis::HMILevel::eType hmi_level() {
+ return hmi_level_;
+ }
+
protected:
- TimevalStruct start_time_;
- uint64_t timeout_sec_;
- TimevalStruct end_time_;
+ TimevalStruct start_time_;
+ uint64_t timeout_sec_;
+ TimevalStruct end_time_;
+ uint32_t app_id_;
+ mobile_apis::HMILevel::eType hmi_level_;
};
typedef utils::SharedPtr<RequestInfo> RequestInfoPtr;
struct RequestInfoComparator {
- bool operator() (const RequestInfoPtr lhs, const RequestInfoPtr rhs) const {
- date_time::TimeCompare compare_result = date_time::DateTime::compareTime(lhs->end_time(), rhs->end_time());
- return compare_result == date_time::LESS;
+ bool operator() (const RequestInfoPtr lhs,
+ const RequestInfoPtr rhs) const {
+ date_time::TimeCompare compare_result =
+ date_time::DateTime::compareTime(lhs->end_time(), rhs->end_time());
+
+ return compare_result == date_time::LESS;
}
};
typedef std::set<RequestInfoPtr,RequestInfoComparator> RequestInfoSet;
struct HMIRequestInfo: public RequestInfo {
- HMIRequestInfo(RequestPtr request, const uint64_t timeout_sec);
- HMIRequestInfo(RequestPtr request, const TimevalStruct& start_time,const uint64_t timeout_sec);
+ HMIRequestInfo(RequestPtr request, const uint64_t timeout_sec);
+ HMIRequestInfo(RequestPtr request, const TimevalStruct& start_time,
+ const uint64_t timeout_sec);
+
RequestPtr request_;
uint32_t correlation_id_;
+
virtual uint32_t requestId() {
return correlation_id_;
}
+
virtual commands::Command* request() {
return request_.get();
}
};
struct MobileRequestInfo: public RequestInfo {
- MobileRequestInfo(MobileRequestPtr request, const uint64_t timeout_sec);
- MobileRequestInfo(MobileRequestPtr request, const TimevalStruct& start_time, const uint64_t timeout_sec);
- MobileRequestPtr request_;
- uint32_t app_id_;
- mobile_apis::HMILevel::eType hmi_level_;
+ MobileRequestInfo(RequestPtr request,
+ const uint64_t timeout_sec);
+
+ MobileRequestInfo(RequestPtr request,
+ const TimevalStruct& start_time,
+ const uint64_t timeout_sec);
+
+ RequestPtr request_;
uint32_t mobile_correlation_id_;
virtual uint32_t requestId() {
@@ -152,27 +178,26 @@ namespace request_controller {
* during time scale
*/
struct TimeScale {
- explicit TimeScale(const TimevalStruct& start, const TimevalStruct& end,
- const int32_t& app_id)
+ TimeScale(const TimevalStruct& start,
+ const TimevalStruct& end,
+ const uint32_t& app_id)
: start_(start),
end_(end),
app_id_(app_id) {}
bool operator()(RequestInfoPtr setEntry) {
- MobileRequestInfo* mobile_request_info = NULL;
- RequestInfo* request = setEntry.get();
- mobile_request_info = dynamic_cast<MobileRequestInfo*>(request);
- if (NULL == mobile_request_info) {
+
+ if (!setEntry.valid()) {
return false;
}
- if (mobile_request_info->app_id_ != app_id_) {
+ if (setEntry->app_id() != app_id_) {
return false;
}
- if (date_time::DateTime::getmSecs(mobile_request_info->start_time())
+ if (date_time::DateTime::getmSecs(setEntry->start_time())
< date_time::DateTime::getmSecs(start_) ||
- date_time::DateTime::getmSecs(mobile_request_info->start_time())
+ date_time::DateTime::getmSecs(setEntry->start_time())
> date_time::DateTime::getmSecs(end_)) {
return false;
}
@@ -181,9 +206,9 @@ namespace request_controller {
}
private:
- TimevalStruct start_;
- TimevalStruct end_;
- uint32_t app_id_;
+ TimevalStruct start_;
+ TimevalStruct end_;
+ uint32_t app_id_;
};
/**
@@ -191,30 +216,31 @@ namespace request_controller {
* during time scale for application in defined hmi level
*/
struct HMILevelTimeScale {
- explicit HMILevelTimeScale(
- const TimevalStruct& start, const TimevalStruct& end,
- const uint32_t& app_id, const mobile_apis::HMILevel::eType& hmi_level)
+ HMILevelTimeScale(const TimevalStruct& start,
+ const TimevalStruct& end,
+ const uint32_t& app_id,
+ const mobile_apis::HMILevel::eType& hmi_level)
: start_(start),
end_(end),
app_id_(app_id),
hmi_level_(hmi_level) {}
bool operator()(RequestInfoPtr setEntry) {
- MobileRequestInfo* mobile_request_info = NULL;
- mobile_request_info = dynamic_cast<MobileRequestInfo*>(setEntry.get());
- if (NULL == mobile_request_info) {
+ if (!setEntry.valid()) {
return false;
}
- if (mobile_request_info->app_id_ != app_id_) {
+
+ if (setEntry->app_id() != app_id_) {
return false;
}
- if (mobile_request_info->hmi_level_ != hmi_level_) {
+
+ if (setEntry->hmi_level() != hmi_level_) {
return false;
}
- if (date_time::DateTime::getSecs(mobile_request_info->start_time())
+ if (date_time::DateTime::getSecs(setEntry->start_time())
< date_time::DateTime::getSecs(start_) ||
- date_time::DateTime::getSecs(mobile_request_info->start_time())
+ date_time::DateTime::getSecs(setEntry->start_time())
> date_time::DateTime::getSecs(end_)) {
return false;
}
@@ -222,9 +248,9 @@ namespace request_controller {
return true;
}
private:
- TimevalStruct start_;
- TimevalStruct end_;
- uint32_t app_id_;
+ TimevalStruct start_;
+ TimevalStruct end_;
+ uint32_t app_id_;
mobile_apis::HMILevel::eType hmi_level_;
};
diff --git a/src/components/application_manager/include/application_manager/smart_object_keys.h b/src/components/application_manager/include/application_manager/smart_object_keys.h
index 1df8b21ad9..3d03989874 100644
--- a/src/components/application_manager/include/application_manager/smart_object_keys.h
+++ b/src/components/application_manager/include/application_manager/smart_object_keys.h
@@ -361,6 +361,7 @@ const char result[] = "result";
const char statistic_type[] = "statisticType";
const char error[] = "error";
const char policyfile[] = "policyfile";
+const char is_active[] = "isActive";
} // namespace hmi_notification
diff --git a/src/components/application_manager/src/application_impl.cc b/src/components/application_manager/src/application_impl.cc
index 2812c17ffb..f52467f751 100644
--- a/src/components/application_manager/src/application_impl.cc
+++ b/src/components/application_manager/src/application_impl.cc
@@ -99,6 +99,7 @@ ApplicationImpl::ApplicationImpl(uint32_t application_id,
device_(0),
usage_report_(mobile_app_id, statistics_manager),
protocol_version_(ProtocolVersion::kV3),
+ is_voice_communication_application_(false),
is_video_stream_retry_active_(false),
is_audio_stream_retry_active_(false),
video_stream_retry_number_(0),
@@ -176,6 +177,21 @@ void ApplicationImpl::set_allowed_support_navigation(bool allow) {
allowed_support_navigation_ = allow;
}
+bool ApplicationImpl::is_voice_communication_supported() const {
+ return is_voice_communication_application_;
+}
+
+void ApplicationImpl::set_voice_communication_supported(
+ bool is_voice_communication_supported) {
+ is_voice_communication_application_ = is_voice_communication_supported;
+}
+
+bool ApplicationImpl::IsAudioApplication() const {
+ return is_media_ ||
+ is_voice_communication_application_ ||
+ allowed_support_navigation_;
+}
+
const smart_objects::SmartObject* ApplicationImpl::active_message() const {
return active_message_;
}
diff --git a/src/components/application_manager/src/application_manager_impl.cc b/src/components/application_manager/src/application_manager_impl.cc
index d6beb3c497..6d7fdeec61 100644
--- a/src/components/application_manager/src/application_manager_impl.cc
+++ b/src/components/application_manager/src/application_manager_impl.cc
@@ -190,6 +190,104 @@ ApplicationSharedPtr ApplicationManagerImpl::active_application() const {
return ApplicationSharedPtr();
}
+
+ApplicationSharedPtr
+ApplicationManagerImpl::get_limited_media_application() const {
+ sync_primitives::AutoLock lock(applications_list_lock_);
+
+ for (TAppListIt it = application_list_.begin();
+ application_list_.end() != it; ++it) {
+ if ((*it)->is_media_application() &&
+ (mobile_api::HMILevel::HMI_LIMITED == (*it)->hmi_level())) {
+ return *it;
+ }
+ }
+
+ return ApplicationSharedPtr();
+}
+
+ApplicationSharedPtr
+ApplicationManagerImpl::get_limited_navi_application() const {
+ sync_primitives::AutoLock lock(applications_list_lock_);
+
+ for (TAppListIt it = application_list_.begin();
+ application_list_.end() != it; ++it) {
+ if ((*it)->allowed_support_navigation() &&
+ (mobile_api::HMILevel::HMI_LIMITED == (*it)->hmi_level())) {
+ return *it;
+ }
+ }
+
+ return ApplicationSharedPtr();
+}
+
+ApplicationSharedPtr
+ApplicationManagerImpl::get_limited_voice_application() const {
+ sync_primitives::AutoLock lock(applications_list_lock_);
+
+ for (TAppListIt it = application_list_.begin();
+ application_list_.end() != it; ++it) {
+ if ((*it)->is_voice_communication_supported() &&
+ (mobile_api::HMILevel::HMI_LIMITED == (*it)->hmi_level())) {
+ return *it;
+ }
+ }
+
+ return ApplicationSharedPtr();
+}
+
+bool ApplicationManagerImpl::DoesAudioAppWithSameHMITypeExistInFullOrLimited(
+ ApplicationSharedPtr app) const {
+ bool voice_state = app->is_voice_communication_supported();
+ bool media_state = app->is_media_application();
+ bool navi_state = app->hmi_supports_navi_video_streaming();
+ ApplicationSharedPtr active_app = active_application();
+ // 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
+ if (active_app->app_id() == app->app_id()) {
+ return false;
+ }
+
+ if (voice_state && active_app->is_voice_communication_supported()) {
+ return true;
+ }
+
+ if (media_state && active_app->is_media_application()) {
+ return true;
+ }
+
+ if (navi_state && active_app->hmi_supports_navi_video_streaming()) {
+ return true;
+ }
+ }
+
+ // Check LIMITED apps
+ if (voice_state) {
+ if (get_limited_voice_application().valid() &&
+ (get_limited_voice_application()->app_id() != app->app_id())) {
+ return true;
+ }
+ }
+
+ if (media_state) {
+ if (get_limited_media_application().valid() &&
+ (get_limited_media_application()->app_id() != app->app_id())) {
+ return true;
+ }
+ }
+
+ if (navi_state) {
+ if (get_limited_navi_application().valid() &&
+ (get_limited_navi_application()->app_id() != app->app_id())) {
+ return true;
+ }
+ }
+
+ return false;
+}
+
std::vector<ApplicationSharedPtr> ApplicationManagerImpl::applications_by_button(
uint32_t button) {
std::vector<ApplicationSharedPtr> result;
@@ -399,116 +497,90 @@ bool ApplicationManagerImpl::ActivateApplication(ApplicationSharedPtr app) {
return false;
}
- bool is_new_app_media = app->is_media_application();
-
if (app->IsFullscreen()) {
LOG4CXX_WARN(logger_, "Application is already active.");
return false;
}
- if (mobile_api::HMILevel::eType::HMI_LIMITED !=
- app->hmi_level()) {
+
+ bool is_new_app_media = app->is_media_application();
+ ApplicationSharedPtr current_active_app = active_application();
+
+ if (mobile_api::HMILevel::eType::HMI_LIMITED != app->hmi_level()) {
if (app->has_been_activated()) {
MessageHelper::SendAppDataToHMI(app);
}
}
- app->MakeFullscreen();
- for (std::set<ApplicationSharedPtr>::iterator it = application_list_.begin();
- application_list_.end() != it;
- ++it) {
- ApplicationSharedPtr curr_app = *it;
- if (app->app_id() == curr_app->app_id()) {
- continue;
+
+ if (current_active_app.valid()) {
+ if (is_new_app_media && current_active_app->is_media_application()) {
+ current_active_app->MakeNotAudible();
+ } else if (!(current_active_app->IsAudioApplication())) {
+ current_active_app->set_hmi_level(mobile_api::HMILevel::HMI_BACKGROUND);
} else {
- if (is_new_app_media) {
- if (curr_app->IsAudible()) {
- curr_app->MakeNotAudible();
- MessageHelper::SendHMIStatusNotification(*curr_app);
- }
- }
- if (curr_app->IsFullscreen()) {
- if (true == curr_app->is_media_application()) {
- PutApplicationInLimited(app);
- } else {
- app->set_hmi_level(mobile_api::HMILevel::HMI_BACKGROUND);
- }
- MessageHelper::SendHMIStatusNotification(*curr_app);
- }
+ current_active_app->set_hmi_level(mobile_api::HMILevel::HMI_LIMITED);
}
- }
- return true;
-}
-mobile_apis::HMILevel::eType ApplicationManagerImpl::PutApplicationInLimited(
- ApplicationSharedPtr app) {
- DCHECK(app.get())
+ MessageHelper::SendHMIStatusNotification(*current_active_app);
+ }
- mobile_api::HMILevel::eType result = mobile_api::HMILevel::HMI_LIMITED;
+ app->MakeFullscreen();
- for (std::set<ApplicationSharedPtr>::iterator it = application_list_.begin();
- application_list_.end() != it;
- ++it) {
- ApplicationSharedPtr curr_app = *it;
- if (app->app_id() == curr_app->app_id()) {
- continue;
+ if (is_new_app_media) {
+ ApplicationSharedPtr limited_app = get_limited_media_application();
+ if (limited_app.valid()) {
+ limited_app->MakeNotAudible();
+ MessageHelper::SendHMIStatusNotification(*limited_app);
}
+ }
- if (curr_app->hmi_level() == mobile_api::HMILevel::HMI_LIMITED) {
- result = mobile_api::HMILevel::HMI_BACKGROUND;
- break;
- }
- if (curr_app->hmi_level() == mobile_api::HMILevel::HMI_FULL) {
- if (curr_app->is_media_application()) {
- result = mobile_api::HMILevel::HMI_BACKGROUND;
- break;
- } else {
- result = mobile_api::HMILevel::HMI_LIMITED;
+ if (app->is_voice_communication_supported()) {
+ ApplicationSharedPtr limited_app = get_limited_voice_application();
+ if (limited_app.valid()) {
+ if (limited_app->is_media_application()) {
+ limited_app->set_audio_streaming_state(
+ mobile_api::AudioStreamingState::NOT_AUDIBLE);
}
+ limited_app->set_hmi_level(mobile_api::HMILevel::HMI_BACKGROUND);
+ MessageHelper::SendHMIStatusNotification(*limited_app);
}
+ }
+ if (app->allowed_support_navigation()) {
+ ApplicationSharedPtr limited_app = get_limited_navi_application();
+ if (limited_app.valid()) {
+ if (limited_app->is_media_application()) {
+ limited_app->set_audio_streaming_state(
+ mobile_api::AudioStreamingState::NOT_AUDIBLE);
+ }
+ limited_app->set_hmi_level(mobile_api::HMILevel::HMI_BACKGROUND);
+ MessageHelper::SendHMIStatusNotification(*limited_app);
+ }
}
- app->set_hmi_level(result);
- return result;
+
+ return true;
}
mobile_api::HMILevel::eType ApplicationManagerImpl::PutApplicationInFull(
ApplicationSharedPtr app) {
DCHECK(app.get())
- bool is_new_app_media = app->is_media_application();
+ bool is_audio_app = app->IsAudioApplication();
+ bool does_audio_app_with_same_type_exist =
+ DoesAudioAppWithSameHMITypeExistInFullOrLimited(app);
+
mobile_api::HMILevel::eType result = mobile_api::HMILevel::HMI_FULL;
- std::set<ApplicationSharedPtr>::iterator it = application_list_.begin();
- for (; application_list_.end() != it; ++it) {
- ApplicationSharedPtr curr_app = *it;
- if (app->app_id() == curr_app->app_id()) {
- continue;
- }
+ bool is_active_app_exist = active_application().valid();
- if (is_new_app_media) {
- if (curr_app->hmi_level() == mobile_api::HMILevel::HMI_FULL) {
- if (curr_app->is_media_application()) {
- result = mobile_api::HMILevel::HMI_BACKGROUND;
- break;
- } else {
- result = mobile_api::HMILevel::HMI_LIMITED;
- }
- }
- if (curr_app->hmi_level() == mobile_api::HMILevel::HMI_LIMITED) {
- result = mobile_api::HMILevel::HMI_BACKGROUND;
- break;
- }
- } else {
- if (curr_app->hmi_level() == mobile_api::HMILevel::HMI_FULL) {
- result = mobile_api::HMILevel::HMI_BACKGROUND;
- break;
- }
- if (curr_app->hmi_level() == mobile_api::HMILevel::HMI_LIMITED) {
- result = mobile_api::HMILevel::HMI_FULL;
- }
- }
+ if (is_audio_app && does_audio_app_with_same_type_exist) {
+ result = mobile_apis::HMILevel::HMI_BACKGROUND;
+ } else if (is_active_app_exist && is_audio_app) {
+ result = mobile_apis::HMILevel::HMI_LIMITED;
+ } else if (is_active_app_exist && (!is_audio_app)) {
+ result = mobile_apis::HMILevel::HMI_BACKGROUND;
}
- if (result == mobile_api::HMILevel::HMI_FULL) {
+ if (mobile_api::HMILevel::HMI_FULL == result) {
app->set_hmi_level(result);
MessageHelper::SendActivateAppToHMI(app->app_id());
}
@@ -688,7 +760,7 @@ std::string ApplicationManagerImpl::GetDeviceName(
}
void ApplicationManagerImpl::OnMessageReceived(
- const RawMessagePtr message) {
+ const ::protocol_handler::RawMessagePtr message) {
LOG4CXX_INFO(logger_, "ApplicationManagerImpl::OnMessageReceived");
if (!message) {
@@ -706,7 +778,7 @@ void ApplicationManagerImpl::OnMessageReceived(
}
void ApplicationManagerImpl::OnMobileMessageSent(
- const RawMessagePtr message) {
+ const ::protocol_handler::RawMessagePtr message) {
LOG4CXX_INFO(logger_, "ApplicationManagerImpl::OnMobileMessageSent");
}
@@ -1041,7 +1113,7 @@ void ApplicationManagerImpl::StartDevicesDiscovery() {
}
void ApplicationManagerImpl::SendMessageToMobile(
- const utils::SharedPtr<smart_objects::SmartObject>& message,
+ const utils::SharedPtr<smart_objects::SmartObject> message,
bool final_message) {
LOG4CXX_INFO(logger_, "ApplicationManagerImpl::SendMessageToMobile");
@@ -1131,7 +1203,7 @@ void ApplicationManagerImpl::SendMessageToMobile(
}
bool ApplicationManagerImpl::ManageMobileCommand(
- const utils::SharedPtr<smart_objects::SmartObject>& message) {
+ const utils::SharedPtr<smart_objects::SmartObject> message) {
LOG4CXX_INFO(logger_, "ApplicationManagerImpl::ManageMobileCommand");
if (!message) {
@@ -1288,7 +1360,7 @@ bool ApplicationManagerImpl::ManageMobileCommand(
}
void ApplicationManagerImpl::SendMessageToHMI(
- const utils::SharedPtr<smart_objects::SmartObject>& message) {
+ const utils::SharedPtr<smart_objects::SmartObject> message) {
LOG4CXX_INFO(logger_, "ApplicationManagerImpl::SendMessageToHMI");
if (!message) {
@@ -1330,7 +1402,7 @@ void ApplicationManagerImpl::SendMessageToHMI(
}
bool ApplicationManagerImpl::ManageHMICommand(
- const utils::SharedPtr<smart_objects::SmartObject>& message) {
+ const utils::SharedPtr<smart_objects::SmartObject> message) {
LOG4CXX_INFO(logger_, "ApplicationManagerImpl::ManageHMICommand");
if (!message) {
@@ -1642,7 +1714,7 @@ bool ApplicationManagerImpl::ConvertSOtoMessage(
}
utils::SharedPtr<Message> ApplicationManagerImpl::ConvertRawMsgToMessage(
- const RawMessagePtr message) {
+ const ::protocol_handler::RawMessagePtr message) {
DCHECK(message);
utils::SharedPtr<Message> outgoing_message;
@@ -1678,7 +1750,7 @@ 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());
@@ -1712,7 +1784,7 @@ void ApplicationManagerImpl::ProcessMessageFromMobile(
}
void ApplicationManagerImpl::ProcessMessageFromHMI(
- const utils::SharedPtr<Message>& message) {
+ const utils::SharedPtr<Message> message) {
LOG4CXX_INFO(logger_, "ApplicationManagerImpl::ProcessMessageFromHMI()");
utils::SharedPtr<smart_objects::SmartObject> smart_object(
new smart_objects::SmartObject);
@@ -2335,4 +2407,55 @@ void ApplicationManagerImpl::RemoveAppFromTTSGlobalPropertiesList(
}
}
+void ApplicationManagerImpl::CreatePhoneCallAppList() {
+ LOG4CXX_TRACE_ENTER(logger_);
+
+ ApplicationManagerImpl::ApplicationListAccessor accessor;
+ ApplicationManagerImpl::TAppList local_app_list = accessor.applications();
+
+ ApplicationManagerImpl::TAppListIt it = local_app_list.begin();
+ ApplicationManagerImpl::TAppListIt itEnd = local_app_list.end();
+
+ for (; it != itEnd; ++it) {
+ if (mobile_api::HMILevel::HMI_FULL == (*it)->hmi_level() ||
+ mobile_api::HMILevel::HMI_LIMITED == (*it)->hmi_level()) {
+
+ // back up app state
+ on_phone_call_app_list_.insert(std::pair<uint32_t, AppState>(
+ (*it)->app_id(), AppState((*it)->hmi_level(),
+ (*it)->audio_streaming_state(),
+ (*it)->system_context())));
+
+ // app state during phone call
+ (*it)->set_hmi_level(mobile_api::HMILevel::HMI_BACKGROUND);
+ (*it)->set_audio_streaming_state(mobile_api::AudioStreamingState::NOT_AUDIBLE);
+ (*it)->set_system_context(mobile_api::SystemContext::SYSCTXT_MAIN);
+ MessageHelper::SendHMIStatusNotification(*(*it));
+ }
+ }
+}
+
+void ApplicationManagerImpl::ResetPhoneCallAppList() {
+ LOG4CXX_TRACE_ENTER(logger_);
+
+ ApplicationManagerImpl::ApplicationListAccessor accessor;
+ ApplicationManagerImpl::TAppList local_app_list = accessor.applications();
+
+ std::map<uint32_t, AppState>::iterator it =
+ on_phone_call_app_list_.begin();
+ std::map<uint32_t, AppState>::iterator it_end =
+ on_phone_call_app_list_.end();
+ for (; it != it_end; ++it) {
+ ApplicationSharedPtr app = application(it->first);
+ if (app) {
+ app->set_hmi_level(it->second.hmi_level);
+ app->set_audio_streaming_state(it->second.audio_streaming_state);
+ app->set_system_context(it->second.system_context);
+ MessageHelper::SendHMIStatusNotification(*app);
+ }
+ }
+
+ on_phone_call_app_list_.clear();
+}
+
} // namespace application_manager
diff --git a/src/components/application_manager/src/commands/command_impl.cc b/src/components/application_manager/src/commands/command_impl.cc
index af666b22c4..86b764c46a 100644
--- a/src/components/application_manager/src/commands/command_impl.cc
+++ b/src/components/application_manager/src/commands/command_impl.cc
@@ -70,11 +70,21 @@ uint32_t CommandImpl::default_timeout() const {
return default_timeout_;
}
-
uint32_t CommandImpl::correlation_id() const {
return (*message_)[strings::params][strings::correlation_id].asUInt();
}
+int32_t CommandImpl::function_id() const {
+ return (*message_)[strings::params][strings::function_id].asInt();
+}
+
+uint32_t CommandImpl::connection_key() const {
+ return (*message_)[strings::params][strings::connection_key].asUInt();
+}
+
+void CommandImpl::onTimeOut() {
+
+}
} // namespace commands
} // namespace application_manager
diff --git a/src/components/application_manager/src/commands/hmi/activate_app_request.cc b/src/components/application_manager/src/commands/hmi/activate_app_request.cc
index a1b17f5229..29d998640e 100644
--- a/src/components/application_manager/src/commands/hmi/activate_app_request.cc
+++ b/src/components/application_manager/src/commands/hmi/activate_app_request.cc
@@ -52,9 +52,14 @@ namespace application_manager {
uint32_t app_id = RequestToHMI::application_id();
ApplicationManagerImpl::instance()->set_application_id(correlation_id(), app_id);
#ifdef ENABLE_LOG
- mobile_apis::HMILevel::eType requested_hmi_level = static_cast<mobile_apis::HMILevel::eType>(
- (*message_)[strings::msg_params][strings::activate_app_hmi_level].asInt());
- LOG4CXX_TRACE(logger_, "requested_hmi_level = " << requested_hmi_level);
+ if ((*message_)[strings::msg_params].keyExists(
+ strings::activate_app_hmi_level)) {
+ mobile_apis::HMILevel::eType requested_hmi_level =
+ static_cast<mobile_apis::HMILevel::eType>(
+ (*message_)[strings::msg_params][strings::activate_app_hmi_level].asInt());
+ LOG4CXX_TRACE(logger_, "requested_hmi_level = "
+ << requested_hmi_level);
+ }
#endif
SendRequest();
subscribe_on_event(hmi_apis::FunctionID::BasicCommunication_ActivateApp,
@@ -91,8 +96,9 @@ namespace application_manager {
return;
}
if (mobile_apis::HMILevel::HMI_FULL == requested_hmi_level) {
- ApplicationManagerImpl::instance()->ActivateApplication(application);
- MessageHelper::SendHMIStatusNotification(*(application.get()));
+ if (ApplicationManagerImpl::instance()->ActivateApplication(application)) {
+ MessageHelper::SendHMIStatusNotification(*(application.get()));
+ }
}
}
} // namespace commands
diff --git a/src/components/application_manager/src/commands/hmi/on_app_deactivated_notification.cc b/src/components/application_manager/src/commands/hmi/on_app_deactivated_notification.cc
index 152546b24b..19dd91ab2a 100644
--- a/src/components/application_manager/src/commands/hmi/on_app_deactivated_notification.cc
+++ b/src/components/application_manager/src/commands/hmi/on_app_deactivated_notification.cc
@@ -116,12 +116,12 @@ void OnAppDeactivatedNotification::Run() {
case hmi_apis::Common_DeactivateReason::PHONEMENU:
case hmi_apis::Common_DeactivateReason::SYNCSETTINGS:
case hmi_apis::Common_DeactivateReason::GENERAL: {
- if (app->is_media_application()) {
- if (mobile_api::HMILevel::HMI_FULL == app->hmi_level()) {
- app->set_hmi_level(mobile_api::HMILevel::HMI_LIMITED);
- }
- } else {
+ if ((!app->IsAudioApplication()) ||
+ ApplicationManagerImpl::instance()->
+ DoesAudioAppWithSameHMITypeExistInFullOrLimited(app)) {
app->set_hmi_level(mobile_api::HMILevel::HMI_BACKGROUND);
+ } else {
+ app->set_hmi_level(mobile_api::HMILevel::HMI_LIMITED);
}
break;
}
diff --git a/src/components/application_manager/src/commands/hmi/on_exit_all_applications_notification.cc b/src/components/application_manager/src/commands/hmi/on_exit_all_applications_notification.cc
index 3d027ff1c6..b284c81f21 100644
--- a/src/components/application_manager/src/commands/hmi/on_exit_all_applications_notification.cc
+++ b/src/components/application_manager/src/commands/hmi/on_exit_all_applications_notification.cc
@@ -31,9 +31,14 @@
*/
#include "application_manager/commands/hmi/on_exit_all_applications_notification.h"
+
+#include <sys/types.h>
+#include <unistd.h>
+#include <signal.h>
+
#include "application_manager/application_manager_impl.h"
#include "interfaces/HMI_API.h"
-#include "utils/signals.h"
+
namespace application_manager {
@@ -89,7 +94,7 @@ void OnExitAllApplicationsNotification::Run() {
app_manager->HeadUnitReset(mob_reason);
}
- threads::Thread::InterruptMainThread();
+ kill(getpid(), SIGINT);
}
void OnExitAllApplicationsNotification::SendOnSDLPersistenceComplete() {
diff --git a/src/components/application_manager/src/commands/hmi/on_phone_call_notification.cc b/src/components/application_manager/src/commands/hmi/on_phone_call_notification.cc
new file mode 100644
index 0000000000..9bd9099c75
--- /dev/null
+++ b/src/components/application_manager/src/commands/hmi/on_phone_call_notification.cc
@@ -0,0 +1,70 @@
+/**
+ * Copyright (c) 2013, Ford Motor Company
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * Neither the name of the Ford Motor Company nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "application_manager/commands/hmi/on_phone_call_notification.h"
+#include "application_manager/application_manager_impl.h"
+#include "application_manager/application_impl.h"
+#include "application_manager/message_helper.h"
+
+namespace application_manager {
+
+namespace commands {
+
+namespace hmi {
+
+OnPhoneCallNotification::OnPhoneCallNotification(
+ const MessageSharedPtr& message)
+ : NotificationFromHMI(message) {
+}
+
+OnPhoneCallNotification::~OnPhoneCallNotification() {
+}
+
+void OnPhoneCallNotification::Run() {
+ LOG4CXX_INFO(logger_, "OnPhoneCallNotification::Run");
+
+ bool is_active =
+ (*message_)[strings::msg_params][hmi_notification::is_active].asBool();
+
+ if (is_active) {
+ ApplicationManagerImpl::instance()->CreatePhoneCallAppList();
+ } else {
+ ApplicationManagerImpl::instance()->ResetPhoneCallAppList();
+ }
+}
+
+} // namespace hmi
+
+} // namespace commands
+
+} // namespace application_manager
+
diff --git a/src/components/application_manager/src/commands/mobile/perform_audio_pass_thru_request.cc b/src/components/application_manager/src/commands/mobile/perform_audio_pass_thru_request.cc
index c5f269fc48..a730995f5d 100644
--- a/src/components/application_manager/src/commands/mobile/perform_audio_pass_thru_request.cc
+++ b/src/components/application_manager/src/commands/mobile/perform_audio_pass_thru_request.cc
@@ -67,7 +67,8 @@ void PerformAudioPassThruRequest::onTimeOut() {
}
bool PerformAudioPassThruRequest::Init() {
- default_timeout_ += (((*message_)[str::msg_params][str::max_duration].asInt())/1000);
+ default_timeout_ +=
+ (((*message_)[str::msg_params][str::max_duration].asUInt()));
return true;
}
diff --git a/src/components/application_manager/src/commands/mobile/put_file_request.cc b/src/components/application_manager/src/commands/mobile/put_file_request.cc
index 8bb83888d6..1da7e08e47 100644
--- a/src/components/application_manager/src/commands/mobile/put_file_request.cc
+++ b/src/components/application_manager/src/commands/mobile/put_file_request.cc
@@ -150,8 +150,14 @@ void PutFileRequest::Run() {
file_path = profile::Profile::instance()->app_storage_folder();
file_path += "/" + application->folder_name();
- if (binary_data.size() >
- ApplicationManagerImpl::instance()->GetAvailableSpaceForApp(application->name())) {
+ uint32_t space_available = ApplicationManagerImpl::instance()->
+ GetAvailableSpaceForApp(application->folder_name());
+
+ if (binary_data.size() > space_available) {
+
+ response_params[strings::space_available] =
+ static_cast<uint32_t>(space_available);
+
LOG4CXX_ERROR(logger_, "Out of memory");
SendResponse(false, mobile_apis::Result::OUT_OF_MEMORY,
"Out of memory", &response_params);
@@ -169,9 +175,11 @@ void PutFileRequest::Run() {
mobile_apis::Result::eType save_result =
ApplicationManagerImpl::instance()->SaveBinary(binary_data, file_path,
sync_file_name_, offset_);
+
if (!is_system_file) {
- response_params[strings::space_available] = static_cast<int32_t>(
- ApplicationManagerImpl::instance()->GetAvailableSpaceForApp(application->folder_name()));
+ response_params[strings::space_available] = static_cast<uint32_t>(
+ ApplicationManagerImpl::instance()->GetAvailableSpaceForApp(
+ application->folder_name()));
}
sync_file_name_ = file_path + "/" + sync_file_name_;
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 d33a99a0a9..a035e86f2d 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
@@ -152,12 +152,8 @@ void RegisterAppInterfaceRequest::Run() {
}
}
- std::string mobile_app_id = (*message_)[strings::msg_params][strings::app_id]
+ const std::string mobile_app_id = (*message_)[strings::msg_params][strings::app_id]
.asString();
- if (policy::PolicyHandler::instance()->IsApplicationRevoked(mobile_app_id)) {
- SendResponse(false, mobile_apis::Result::DISALLOWED);
- return;
- }
ApplicationSharedPtr application =
ApplicationManagerImpl::instance()->application(connection_key());
@@ -167,6 +163,11 @@ void RegisterAppInterfaceRequest::Run() {
return;
}
+ if (IsApplicationWithSameAppIdRegistered()) {
+ SendResponse(false, mobile_apis::Result::DISALLOWED);
+ return;
+ }
+
mobile_apis::Result::eType policy_result = CheckWithPolicyData();
if (mobile_apis::Result::SUCCESS != policy_result
&& mobile_apis::Result::WARNINGS != policy_result) {
@@ -188,11 +189,6 @@ void RegisterAppInterfaceRequest::Run() {
return;
}
- if (IsApplicationWithSameAppIdRegistered()) {
- SendResponse(false, mobile_apis::Result::DISALLOWED);
- return;
- }
-
mobile_apis::Result::eType restriction_result = CheckRestrictions();
if (mobile_apis::Result::SUCCESS != restriction_result) {
LOG4CXX_ERROR_EXT(logger_, "Param names restrictions check failed.");
@@ -250,15 +246,21 @@ void RegisterAppInterfaceRequest::Run() {
if (msg_params.keyExists(strings::app_hmi_type)) {
app->set_app_types(msg_params[strings::app_hmi_type]);
- // check if app is NAVI
- const int32_t is_navi_type = mobile_apis::AppHMIType::NAVIGATION;
+ // check app 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 (is_navi_type == app_type.getElement(i).asInt()) {
+ if (mobile_apis::AppHMIType::NAVIGATION ==
+ static_cast<mobile_apis::AppHMIType::eType>(
+ app_type.getElement(i).asUInt())) {
app->set_allowed_support_navigation(true);
}
+ if (mobile_apis::AppHMIType::COMMUNICATION ==
+ static_cast<mobile_apis::AppHMIType::eType>(
+ app_type.getElement(i).asUInt())) {
+ app->set_voice_communication_supported(true);
+ }
}
}
@@ -464,19 +466,20 @@ void RegisterAppInterfaceRequest::SendRegisterAppInterfaceResponseToMobile(
uint32_t hash_id = 0;
const char* add_info = "";
- bool resumption = (*message_)[strings::msg_params].keyExists(strings::hash_id);
+ const 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].asUInt();
if (!resumer.CheckApplicationHash(application, hash_id)) {
LOG4CXX_WARN(logger_, "Hash does not matches");
result = mobile_apis::Result::RESUME_FAILED;
add_info = "Hash does not matches";
- resumption = false;
+ need_restore_vr = false;
} else if (!resumer.CheckPersistenceFilesForResumption(application)) {
LOG4CXX_WARN(logger_, "Persistent data is missed");
result = mobile_apis::Result::RESUME_FAILED;
add_info = "Persistent data is missed";
- resumption = false;
+ need_restore_vr = false;
} else {
add_info = " Resume Succeed";
}
@@ -485,7 +488,8 @@ void RegisterAppInterfaceRequest::SendRegisterAppInterfaceResponseToMobile(
SendResponse(true, result, add_info, params);
MessageHelper::SendOnAppRegisteredNotificationToHMI(*(application.get()),
- resumption);
+ resumption,
+ need_restore_vr);
MessageHelper::SendChangeRegistrationRequestToHMI(application);
diff --git a/src/components/application_manager/src/commands/mobile/set_icon_request.cc b/src/components/application_manager/src/commands/mobile/set_icon_request.cc
index 4b78833057..4b06730752 100644
--- a/src/components/application_manager/src/commands/mobile/set_icon_request.cc
+++ b/src/components/application_manager/src/commands/mobile/set_icon_request.cc
@@ -84,7 +84,7 @@ void SetIconRequest::Run() {
msg_params[strings::sync_file_name] = smart_objects::SmartObject(
smart_objects::SmartType_Map);
-// Requires unchanged path value without encoded special characters
+// Panasonic requres unchanged path value without encoded special characters
const std::string full_file_path_for_hmi = file_system::ConvertPathForURL(
full_file_path);
diff --git a/src/components/application_manager/src/commands/mobile/slider_request.cc b/src/components/application_manager/src/commands/mobile/slider_request.cc
index bf200d72d3..52f3c7dee7 100644
--- a/src/components/application_manager/src/commands/mobile/slider_request.cc
+++ b/src/components/application_manager/src/commands/mobile/slider_request.cc
@@ -142,9 +142,7 @@ void SliderRequest::on_event(const event_engine::Event& event) {
const bool is_response_success =
(mobile_apis::Result::SUCCESS == response_code) ||
//Aborted has slider_position data
- (mobile_apis::Result::ABORTED == response_code) ||
- //according with SDLAQ-CRS-2904
- (mobile_apis::Result::TIMED_OUT == response_code);
+ (mobile_apis::Result::ABORTED == response_code);
SendResponse(is_response_success,
mobile_apis::Result::eType(response_code),
diff --git a/src/components/application_manager/src/hmi_capabilities.cc b/src/components/application_manager/src/hmi_capabilities.cc
index 5c67492b48..5a3ce71ec6 100644
--- a/src/components/application_manager/src/hmi_capabilities.cc
+++ b/src/components/application_manager/src/hmi_capabilities.cc
@@ -49,8 +49,6 @@
namespace application_manager {
namespace Formatters = NsSmartDeviceLink::NsJSONHandler::Formatters;
-CREATE_LOGGERPTR_GLOBAL(logger_, "HMICapabilities")
-
std::map<std::string, hmi_apis::Common_Language::eType> languages_enum_values =
{
{"EN_US", hmi_apis::Common_Language::EN_US},
@@ -79,6 +77,8 @@ std::map<std::string, hmi_apis::Common_Language::eType> languages_enum_values =
{"NO_NO", hmi_apis::Common_Language::NO_NO}
};
+CREATE_LOGGERPTR_GLOBAL(logger_, "HMICapabilities")
+
std::map<std::string, hmi_apis::Common_VrCapabilities::eType> vr_enum_capabilities =
{
{"TEXT", hmi_apis::Common_VrCapabilities::VR_TEXT}
@@ -577,11 +577,15 @@ bool HMICapabilities::load_capabilities_from_file() {
}
// UI
if (check_existing_json_member(root_json, "UI")) {
- Json::Value ui = root_json.get("UI", "");
+ Json::Value ui = root_json.get("UI", Json::Value::null);
if (check_existing_json_member(ui, "language")) {
- set_active_ui_language(
- languages_enum_values.find(ui.get("language", "").asString())->second);
+ std::string lang = ui.get("language", "EN_US").asString();
+ std::map<std::string, hmi_apis::Common_Language::eType>::const_iterator
+ it = languages_enum_values.find(lang);
+ if (it != languages_enum_values.end()) {
+ set_active_ui_language(it->second);
+ }
}
if (check_existing_json_member(ui, "languages")) {
diff --git a/src/components/application_manager/src/hmi_command_factory.cc b/src/components/application_manager/src/hmi_command_factory.cc
index 1416b6c0fa..c9d241a9a4 100644
--- a/src/components/application_manager/src/hmi_command_factory.cc
+++ b/src/components/application_manager/src/hmi_command_factory.cc
@@ -259,6 +259,7 @@
#include "application_manager/commands/hmi/navi_send_location_request.h"
#include "application_manager/commands/hmi/navi_send_location_response.h"
#include "application_manager/commands/hmi/on_tts_reset_timeout_notification.h"
+#include "application_manager/commands/hmi/on_phone_call_notification.h"
namespace application_manager {
@@ -275,8 +276,8 @@ CommandSharedPtr HMICommandFactory::CreateCommand(
new application_manager::commands::CommandImpl(message));
bool is_response = false;
- if ((*message)[strings::params][strings::message_type]
- == static_cast<int>(application_manager::MessageType::kResponse)) {
+ const int msg_type = (*message)[strings::params][strings::message_type].asInt();
+ if (msg_type == static_cast<int>(application_manager::MessageType::kResponse)) {
is_response = true;
LOG4CXX_INFO(logger_, "HMICommandFactory::CreateCommand response");
} else if ((*message)[strings::params][strings::message_type]
@@ -2035,6 +2036,10 @@ CommandSharedPtr HMICommandFactory::CreateCommand(
command.reset(new commands::hmi::OnTTSResetTimeoutNotification(message));
break;
}
+ case hmi_apis::FunctionID::BasicCommunication_OnPhoneCall: {
+ command.reset(new commands::hmi::OnPhoneCallNotification(message));
+ break;
+ }
}
return command;
diff --git a/src/components/application_manager/src/message_helper.cc b/src/components/application_manager/src/message_helper.cc
index b97b01c0d6..ffde928db6 100644
--- a/src/components/application_manager/src/message_helper.cc
+++ b/src/components/application_manager/src/message_helper.cc
@@ -288,7 +288,7 @@ void MessageHelper::SendHMIStatusNotification(
}
void MessageHelper::SendOnAppRegisteredNotificationToHMI(
- const Application& application_impl, bool resumption) {
+ const Application& application_impl, bool resumption, bool need_restore_vr) {
smart_objects::SmartObject* notification = new smart_objects::SmartObject;
if (!notification) {
// TODO(VS): please add logger.
@@ -307,8 +307,10 @@ void MessageHelper::SendOnAppRegisteredNotificationToHMI(
const smart_objects::SmartObject* ngn_media_screen_name = application_impl
.ngn_media_screen_name();
+ // Due to current requirements in case when we're in resumption mode
+ // we have to always send resumeVRGrammar field.
if (resumption) {
- message[strings::msg_params][strings::resume_vr_grammars] = true;
+ message[strings::msg_params][strings::resume_vr_grammars] = need_restore_vr;
}
if (ngn_media_screen_name) {
@@ -1277,7 +1279,9 @@ void MessageHelper::SendActivateAppToHMI(uint32_t const app_id,
(*message)[strings::msg_params]["priority"] = GetPriorityCode(priority);
}
- if (hmi_apis::Common_HMILevel::INVALID_ENUM != level) {
+ // We haven't send HMI level to HMI in case it FULL.
+ if (hmi_apis::Common_HMILevel::INVALID_ENUM != level &&
+ hmi_apis::Common_HMILevel::FULL != level) {
(*message)[strings::msg_params][strings::activate_app_hmi_level] = level;
}
diff --git a/src/components/application_manager/src/mobile_message_handler.cc b/src/components/application_manager/src/mobile_message_handler.cc
index e2293e3816..22260e214e 100644
--- a/src/components/application_manager/src/mobile_message_handler.cc
+++ b/src/components/application_manager/src/mobile_message_handler.cc
@@ -56,7 +56,7 @@ CREATE_LOGGERPTR_GLOBAL(logger_, "MobileMessageHandler")
application_manager::Message*
MobileMessageHandler::HandleIncomingMessageProtocolV1(
- const RawMessagePtr message) {
+ const ::protocol_handler::RawMessagePtr message) {
LOG4CXX_INFO(logger_,
"MobileMessageHandler HandleIncomingMessageProtocolV1()");
application_manager::Message* outgoing_message =
@@ -86,7 +86,7 @@ MobileMessageHandler::HandleIncomingMessageProtocolV1(
application_manager::Message*
MobileMessageHandler::HandleIncomingMessageProtocolV2(
- const RawMessagePtr message) {
+ const ::protocol_handler::RawMessagePtr message) {
LOG4CXX_INFO(logger_,
"MobileMessageHandler HandleIncomingMessageProtocolV2()");
diff --git a/src/components/application_manager/src/policies/policy_event_observer.cc b/src/components/application_manager/src/policies/policy_event_observer.cc
index e7b259e6b5..488097761a 100644
--- a/src/components/application_manager/src/policies/policy_event_observer.cc
+++ b/src/components/application_manager/src/policies/policy_event_observer.cc
@@ -45,7 +45,7 @@ PolicyEventObserver::PolicyEventObserver(utils::SharedPtr<PolicyManager> policy_
}
void PolicyEventObserver::on_event(const event_engine::Event& event) {
- if (policy_manager_.valid()) {
+ if (!policy_manager_) {
return;
}
const smart_objects::SmartObject& message = event.smart_object();
diff --git a/src/components/application_manager/src/policies/policy_handler.cc b/src/components/application_manager/src/policies/policy_handler.cc
index ea1045247a..0033743e75 100644
--- a/src/components/application_manager/src/policies/policy_handler.cc
+++ b/src/components/application_manager/src/policies/policy_handler.cc
@@ -50,6 +50,7 @@
#include "application_manager/usage_statistics.h"
#include "policy/policy_types.h"
#include "interfaces/MOBILE_API.h"
+#include "utils/file_system.h"
namespace policy {
@@ -206,13 +207,15 @@ PolicyHandler* PolicyHandler::instance_ = NULL;
const std::string PolicyHandler::kLibrary = "libPolicy.so";
PolicyHandler::PolicyHandler()
+
: dl_handle_(0),
// EXTENDED_POLICY
exchange_handler_(new PTExchangeHandlerImpl(this)),
on_ignition_check_done_(false),
last_activated_app_id_(0),
registration_in_progress(false),
- is_user_requested_policy_table_update_(false) {
+ is_user_requested_policy_table_update_(false),
+ statistic_manager_impl_(new StatisticManagerImpl()) {
}
PolicyHandler::~PolicyHandler() {
@@ -266,7 +269,11 @@ bool PolicyHandler::InitPolicyTable() {
hmi_apis::FunctionID::BasicCommunication_OnReady);
std::string preloaded_file =
profile::Profile::instance()->preloaded_pt_file();
- return policy_manager_->InitPT(preloaded_file);
+ if (file_system::FileExists(preloaded_file)) {
+ return policy_manager_->InitPT(preloaded_file);
+ }
+ LOG4CXX_WARN(logger_, "The file which contains preloaded PT is not exist");
+ return false;
}
bool PolicyHandler::ResetPolicyTable() {
@@ -274,7 +281,11 @@ bool PolicyHandler::ResetPolicyTable() {
POLICY_LIB_CHECK(false);
std::string preloaded_file =
profile::Profile::instance()->preloaded_pt_file();
- return policy_manager_->ResetPT(preloaded_file);
+ if (file_system::FileExists(preloaded_file)) {
+ return policy_manager_->ResetPT(preloaded_file);
+ }
+ LOG4CXX_WARN(logger_, "The file which contains preloaded PT is not exist");
+ return false;
}
bool PolicyHandler::ClearUserConsent() {
@@ -677,15 +688,10 @@ void PolicyHandler::OnAppRevoked(const std::string& policy_app_id) {
permissions.appRevoked = true;
application_manager::MessageHelper::SendOnAppPermissionsChangedNotification(
app->app_id(), permissions);
- application_manager::MessageHelper::
- SendOnAppInterfaceUnregisteredNotificationToMobile(
- app->app_id(),
- mobile_apis::AppInterfaceUnregisteredReason::APP_UNAUTHORIZED);
-
- application_manager::ApplicationManagerImpl::instance()->
- UnregisterRevokedApplication(app->app_id(),
- mobile_apis::Result::INVALID_ENUM);
app->set_hmi_level(mobile_apis::HMILevel::HMI_NONE);
+ application_manager::MessageHelper::SendActivateAppToHMI(
+ app->app_id(), hmi_apis::Common_HMILevel::NONE);
+ application_manager::MessageHelper::SendHMIStatusNotification(*app);
policy_manager_->RemovePendingPermissionChanges(policy_app_id);
return;
}
@@ -1203,8 +1209,7 @@ const std::vector<int> PolicyHandler::RetrySequenceDelaysSeconds() {
utils::SharedPtr<usage_statistics::StatisticsManager>
PolicyHandler::GetStatisticManager() {
- return utils::SharedPtr<PolicyManager>::
- static_pointer_cast<usage_statistics::StatisticsManager>(policy_manager_);
+ return statistic_manager_impl_;
}
void PolicyHandler::AddStatisticsInfo(int type) {
@@ -1315,5 +1320,29 @@ uint16_t PolicyHandler::HeartBeatTimeout(const std::string& app_id) const {
return policy_manager_->HeartBeatTimeout(app_id);
}
+void PolicyHandler::Increment(usage_statistics::GlobalCounterId type) {
+ POLICY_LIB_CHECK();
+ policy_manager_->Increment(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,
+ usage_statistics::AppInfoId type,
+ const std::string& value) {
+ POLICY_LIB_CHECK();
+ policy_manager_->Set(app_id, type, value);
+}
+
+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
diff --git a/src/components/application_manager/src/policies/pt_exchange_handler_impl.cc b/src/components/application_manager/src/policies/pt_exchange_handler_impl.cc
index e28455aa33..5a01e28d6d 100644
--- a/src/components/application_manager/src/policies/pt_exchange_handler_impl.cc
+++ b/src/components/application_manager/src/policies/pt_exchange_handler_impl.cc
@@ -35,6 +35,7 @@
#include "utils/logger.h"
#include "application_manager/policies/policy_handler.h"
#include "application_manager/policies/policy_retry_sequence.h"
+#include "utils/threads/thread_manager.h"
namespace policy {
@@ -42,7 +43,7 @@ CREATE_LOGGERPTR_GLOBAL(logger_, "PolicyHandler")
PTExchangeHandlerImpl::PTExchangeHandlerImpl(PolicyHandler* handler)
: policy_handler_(handler),
- retry_sequence_("RetrySequence", new RetrySequence(handler)) {
+ retry_sequence_(threads::CreateThread("RetrySequence", new RetrySequence(handler))) {
DCHECK(policy_handler_);
LOG4CXX_INFO(logger_, "Exchan created");
}
@@ -56,20 +57,20 @@ void PTExchangeHandlerImpl::Start() {
sync_primitives::AutoLock locker(retry_sequence_lock_);
LOG4CXX_INFO(logger_, "Exchan started");
- if (retry_sequence_.is_running()) {
- retry_sequence_.stop();
- }
+ retry_sequence_->stop();
+ threads::DeleteThread(retry_sequence_);
+ retry_sequence_ = threads::CreateThread("RetrySequence", new RetrySequence(policy_handler_));
if (policy_handler_) {
policy_handler_->ResetRetrySequence();
}
- retry_sequence_.start();
+ retry_sequence_->start();
}
void PTExchangeHandlerImpl::Stop() {
sync_primitives::AutoLock locker(retry_sequence_lock_);
- if (retry_sequence_.is_running()) {
- retry_sequence_.stop();
+ if (retry_sequence_->is_running()) {
+ retry_sequence_->stop();
}
}
diff --git a/src/components/application_manager/src/request_controller.cc b/src/components/application_manager/src/request_controller.cc
index 48fee42920..5faabde458 100644
--- a/src/components/application_manager/src/request_controller.cc
+++ b/src/components/application_manager/src/request_controller.cc
@@ -1,4 +1,4 @@
-/**
+/*
* Copyright (c) 2014, Ford Motor Company
* All rights reserved.
*
@@ -77,7 +77,7 @@ void RequestController::InitializeThreadpool()
char name [50];
snprintf(name, sizeof(name)/sizeof(name[0]),
"AM Pool %d", i);
- pool_.push_back(ThreadSharedPtr(new Thread(name, new Worker(this))));
+ pool_.push_back(threads::CreateThread(name, new Worker(this)));
pool_[i]->start();
LOG4CXX_INFO(logger_, "Request thread initialized: " << name);
}
@@ -93,6 +93,7 @@ void RequestController::DestroyThreadpool() {
}
for (uint32_t i = 0; i < pool_size_; i++) {
pool_[i]->stop();
+ threads::DeleteThread(pool_[i]);
}
LOG4CXX_INFO(logger_, "Threads exited from the thread pool " << pool_size_);
}
@@ -128,8 +129,9 @@ RequestController::TResult RequestController::addMobileRequest(
profile::Profile::instance()->pending_requests_amount();
if (!checkHMILevelTimeScaleMaxRequest(mobile_apis::HMILevel::HMI_NONE,
- request_impl->connection_key(), app_hmi_level_none_time_scale,
- app_hmi_level_none_max_request_per_time_scale)) {
+ request_impl->connection_key(),
+ app_hmi_level_none_time_scale,
+ app_hmi_level_none_max_request_per_time_scale)) {
LOG4CXX_ERROR(logger_, "Too many application requests in hmi level NONE");
result = RequestController::NONE_HMI_LEVEL_MANY_REQUESTS;
} else if (!checkTimeScaleMaxRequest(
@@ -159,14 +161,17 @@ RequestController::TResult RequestController::addMobileRequest(
}
RequestController::TResult RequestController::addHMIRequest(
- const RequestPtr& request) {
+ const RequestPtr request) {
LOG4CXX_TRACE_ENTER(logger_);
DCHECK(request.valid());
LOG4CXX_DEBUG(logger_, "addHMIRequest " << request->correlation_id());
- RequestInfoPtr request_info_ptr = new HMIRequestInfo(request, request->default_timeout());
+ uint32_t timeout_in_seconds = request->default_timeout()/date_time::DateTime::MILLISECONDS_IN_SECOND;
+ RequestInfoPtr request_info_ptr =
+ new HMIRequestInfo(request,
+ timeout_in_seconds);
- if (0 != request->default_timeout()) {
+ if (0 != timeout_in_seconds) {
pending_request_set_lock_.Acquire();
pending_request_set_.insert(request_info_ptr);
LOG4CXX_INFO(logger_, "pending_request_set_ size is "
@@ -206,14 +211,15 @@ void RequestController::terminateMobileRequest(
AutoLock auto_lock(pending_request_set_lock_);
RequestInfoSet::iterator it = pending_request_set_.begin();
for (; pending_request_set_.end() != it; ++it) {
- MobileRequestInfo* mobile_request_info = dynamic_cast<MobileRequestInfo*>(it->get());
+ RequestInfo* mobile_request_info = it->get();
if (NULL == mobile_request_info) {
continue;
}
- if (mobile_correlation_id == mobile_request_info->mobile_correlation_id_) {
- mobile_request_info->request_->CleanUp();
+ if (mobile_correlation_id == mobile_request_info->requestId()) {
+ mobile_request_info->request()->CleanUp();
pending_request_set_.erase(it);
- LOG4CXX_INFO(logger_, "Mobile request terminated: " << mobile_correlation_id);
+ LOG4CXX_INFO(logger_, "Mobile request terminated: " << mobile_correlation_id <<
+ " pending_request_set_ size : " << pending_request_set_.size());
UpdateTimer();
LOG4CXX_TRACE_EXIT(logger_);
return;
@@ -229,12 +235,12 @@ void RequestController::terminateHMIRequest(const uint32_t &correlation_id) {
AutoLock auto_lock(pending_request_set_lock_);
RequestInfoSet::iterator it = pending_request_set_.begin();
for (; pending_request_set_.end() != it; ++it) {
- HMIRequestInfo* hmi_request_info = dynamic_cast<HMIRequestInfo*>(it->get());
+ RequestInfo* hmi_request_info = it->get();
if (NULL == hmi_request_info) {
continue;
}
if (correlation_id == hmi_request_info->requestId()) {
- hmi_request_info->request_->CleanUp();
+ hmi_request_info->request()->CleanUp();
pending_request_set_.erase(it);
LOG4CXX_DEBUG(logger_, "HMI request terminated: " << correlation_id);
UpdateTimer();
@@ -254,14 +260,14 @@ void RequestController::terminateAppRequests(
AutoLock auto_lock(pending_request_set_lock_);
RequestInfoSet::iterator it = pending_request_set_.begin();
while (pending_request_set_.end() != it) {
- MobileRequestInfo* mobile_request_info = dynamic_cast<MobileRequestInfo*>(it->get());
+ RequestInfo* mobile_request_info = it->get();
if (NULL == mobile_request_info) {
++it;
continue;
}
- if (mobile_request_info->app_id_ == app_id) {
- mobile_request_info->request_->CleanUp();
+ if (mobile_request_info->app_id() == app_id) {
+ mobile_request_info->request()->CleanUp();
pending_request_set_.erase(it++);
LOG4CXX_INFO(logger_, "terminated all app requests : " << app_id);
} else {
@@ -277,12 +283,12 @@ void RequestController::terminateAllHMIRequests() {
AutoLock auto_lock(pending_request_set_lock_);
RequestInfoSet::iterator it = pending_request_set_.begin();
while (pending_request_set_.end() != it) {
- HMIRequestInfo* hmi_request_info = dynamic_cast<HMIRequestInfo*>(it->get());
+ RequestInfo* hmi_request_info = it->get();
if (NULL == hmi_request_info) {
++it;
continue;
}
- hmi_request_info->request_->CleanUp();
+ hmi_request_info->request()->CleanUp();
pending_request_set_.erase(it++);
LOG4CXX_INFO(logger_, "HMI request terminated: ");
}
@@ -298,7 +304,7 @@ void RequestController::updateRequestTimeout(
AutoLock auto_lock(pending_request_set_lock_);
RequestInfoSet::iterator it = pending_request_set_.begin();
- MobileRequestInfo* mobile_request_info = NULL;
+ RequestInfo* mobile_request_info = NULL;
RequestInfoPtr request_info;
for (; pending_request_set_.end() != it; ++it) {
request_info = *it;
@@ -306,12 +312,12 @@ void RequestController::updateRequestTimeout(
LOG4CXX_ERROR(logger_, "Invalid request, can't update timeout");
continue;
}
- mobile_request_info = dynamic_cast<MobileRequestInfo*>(request_info.get());
+ mobile_request_info = request_info.get();
if (NULL == mobile_request_info) {
continue;
}
- if (app_id == mobile_request_info->app_id_ &&
- mobile_correlation_id == mobile_request_info->mobile_correlation_id_) {
+ if (app_id == mobile_request_info->app_id() &&
+ mobile_correlation_id == mobile_request_info->requestId()) {
break;
}
}
@@ -320,7 +326,8 @@ void RequestController::updateRequestTimeout(
DCHECK(mobile_request_info);
DCHECK(request_info.valid());
- mobile_request_info->updateTimeOut(new_timeout);
+ uint32_t timeout_in_seconds = new_timeout/date_time::DateTime::MILLISECONDS_IN_SECOND;
+ mobile_request_info->updateTimeOut(timeout_in_seconds);
pending_request_set_.erase(it);
pending_request_set_.insert(request_info);
// erase and insert need to update ordering of set
@@ -330,7 +337,7 @@ void RequestController::updateRequestTimeout(
<< " mobile_correlation_id " << mobile_correlation_id
<< " new_timeout " << new_timeout);
} else {
- LOG4CXX_ERROR(logger_, "Cant find request with "
+ LOG4CXX_ERROR(logger_, "Can't find request with "
<< " app_id " << app_id
<< " mobile_correlation_id " << mobile_correlation_id );
}
@@ -350,12 +357,7 @@ void RequestController::onTimer() {
}
if (request->isExpired()) {
pending_request_set_.erase(probably_expired);
- commands::CommandRequestImpl* mobile_expired_request =
- dynamic_cast<commands::CommandRequestImpl*>(request->request());
- if (mobile_expired_request) {
-
- mobile_expired_request->onTimeOut();
- }
+ request->request()->onTimeOut();
request->request()->CleanUp();
LOG4CXX_INFO(logger_, "Timeout for request id " << request->requestId() << " expired");
probably_expired = pending_request_set_.begin();
@@ -399,14 +401,16 @@ void RequestController::Worker::threadMain() {
request_controller_->mobile_request_list_.pop_front();
bool init_res = request->Init(); // to setup specific default timeout
- RequestInfoPtr request_info_ptr(new MobileRequestInfo(request, request->default_timeout()));
+
+ uint32_t timeout_in_seconds = request->default_timeout()/date_time::DateTime::MILLISECONDS_IN_SECOND;
+ RequestInfoPtr request_info_ptr(new MobileRequestInfo(request,
+ timeout_in_seconds));
request_controller_->pending_request_set_lock_.Acquire();
request_controller_->pending_request_set_.insert(request_info_ptr);
- //pending_request_list_.Acquire();
- if (0 != request->default_timeout()) {
+ if (0 != timeout_in_seconds) {
LOG4CXX_INFO(logger_, "Add Request " << request_info_ptr->requestId() <<
- "with timeout: " << request->default_timeout());
+ " with timeout: " << timeout_in_seconds);
request_controller_->UpdateTimer();
} else {
LOG4CXX_INFO(logger_, "Default timeout was set to 0."
@@ -427,6 +431,7 @@ bool RequestController::Worker::exitThreadMain() {
stop_flag_ = true;
sync_primitives::AutoLock auto_lock(thread_lock_);
// setup stop flag and whit while threadMain will be finished correctly
+ // FIXME (dchmerev@luxoft.com): There is no wating
return true;
}
diff --git a/src/components/application_manager/src/request_info.cc b/src/components/application_manager/src/request_info.cc
index 58b939f857..0b448c9e47 100644
--- a/src/components/application_manager/src/request_info.cc
+++ b/src/components/application_manager/src/request_info.cc
@@ -56,26 +56,22 @@ HMIRequestInfo::HMIRequestInfo(
}
MobileRequestInfo::MobileRequestInfo(
- MobileRequestPtr request,
+ RequestPtr request,
const uint64_t timeout_sec):
RequestInfo(timeout_sec),
request_(request) {
- commands::CommandRequestImpl* request_from_mobile =
- static_cast<commands::CommandRequestImpl*>(request_.get());
- mobile_correlation_id_ = request_from_mobile->correlation_id();
- app_id_ = request_from_mobile->connection_key();
+ mobile_correlation_id_ = request_.get()->correlation_id();
+ app_id_ = request_.get()->connection_key();
}
MobileRequestInfo::MobileRequestInfo(
- MobileRequestPtr request,
+ RequestPtr request,
const TimevalStruct &start_time,
const uint64_t timeout_sec):
RequestInfo(start_time, timeout_sec),
request_(request) {
- commands::CommandRequestImpl* request_to_hmi =
- static_cast<commands::CommandRequestImpl*>(request_.get());
- mobile_correlation_id_ = request_to_hmi->correlation_id();
- app_id_ = request_to_hmi->connection_key();
+ mobile_correlation_id_ = request_.get()->correlation_id();
+ app_id_ = request_.get()->connection_key();
}
} // namespace request_controller
diff --git a/src/components/application_manager/src/resume_ctrl.cpp b/src/components/application_manager/src/resume_ctrl.cpp
index dff90a6383..cdbd6dc1cf 100644
--- a/src/components/application_manager/src/resume_ctrl.cpp
+++ b/src/components/application_manager/src/resume_ctrl.cpp
@@ -171,9 +171,6 @@ bool ResumeCtrl::SetupHMILevel(ApplicationSharedPtr application,
LOG4CXX_ERROR(logger_, "SetupHMILevel() application pointer in invalid");
return false;
}
-#ifdef ENABLE_LOG
- bool seted_up_hmi_level = hmi_level;
-#endif
const std::string device_id =
MessageHelper::GetDeviceMacAddressForHandle(application->device());
@@ -195,53 +192,57 @@ bool ResumeCtrl::SetupHMILevel(ApplicationSharedPtr application,
return false;
}
- if (hmi_level == mobile_apis::HMILevel::HMI_FULL) {
-#ifdef ENABLE_LOG
- seted_up_hmi_level = app_mngr_->PutApplicationInFull(application);
-#else
- app_mngr_->PutApplicationInFull(application);
-#endif
- } else if (hmi_level == mobile_apis::HMILevel::HMI_LIMITED) {
-#ifdef ENABLE_LOG
- seted_up_hmi_level = app_mngr_->PutApplicationInLimited(application);
-#else
- app_mngr_->PutApplicationInLimited(application);
-#endif
- if (audio_streaming_state == mobile_apis::AudioStreamingState::AUDIBLE) {
- //implemented SDLAQ-CRS-839
- //checking the existence of application with AudioStreamingState=AUDIBLE
- //notification resumeAudioSource is sent if only resumed application has
- //AudioStreamingState=AUDIBLE
- bool application_exist_with_audible_state = false;
- ApplicationManagerImpl::ApplicationListAccessor accessor;
- const std::set<ApplicationSharedPtr> app_list = accessor.applications();
- std::set<ApplicationSharedPtr>::const_iterator app_list_it = app_list.begin();
- uint32_t app_id = application->app_id();
- for (; app_list.end() != app_list_it; ++app_list_it) {
- if (((*app_list_it)->audio_streaming_state() ==
- mobile_apis::AudioStreamingState::AUDIBLE) &&
- ((*app_list_it))->app_id() != app_id) {
- application_exist_with_audible_state = true;
- break;
+ if (mobile_apis::HMILevel::HMI_FULL == hmi_level) {
+ hmi_level = app_mngr_->PutApplicationInFull(application);
+
+ if ((mobile_apis::HMILevel::HMI_FULL == hmi_level ||
+ mobile_apis::HMILevel::HMI_LIMITED == hmi_level) &&
+ (mobile_apis::AudioStreamingState::AUDIBLE == audio_streaming_state)) {
+ application->set_audio_streaming_state(audio_streaming_state);
+ }
+ } else if (mobile_apis::HMILevel::HMI_LIMITED == hmi_level) {
+ if ((false == application->IsAudioApplication()) ||
+ app_mngr_->DoesAudioAppWithSameHMITypeExistInFullOrLimited(application)) {
+ hmi_level = mobile_apis::HMILevel::HMI_BACKGROUND;
+ } else {
+ if (audio_streaming_state == mobile_apis::AudioStreamingState::AUDIBLE) {
+ //implemented SDLAQ-CRS-839
+ //checking the existence of application with AudioStreamingState=AUDIBLE
+ //notification resumeAudioSource is sent if only resumed application has
+ //AudioStreamingState=AUDIBLE
+ bool application_exist_with_audible_state = false;
+ ApplicationManagerImpl::ApplicationListAccessor accessor;
+ const std::set<ApplicationSharedPtr> app_list = accessor.applications();
+ std::set<ApplicationSharedPtr>::const_iterator app_list_it = app_list
+ .begin();
+ uint32_t app_id = application->app_id();
+ for (; app_list.end() != app_list_it; ++app_list_it) {
+ if ((mobile_apis::AudioStreamingState::AUDIBLE ==
+ (*app_list_it)->audio_streaming_state())
+ && ((*app_list_it))->app_id() != app_id) {
+ application_exist_with_audible_state = true;
+ break;
+ }
}
- }
- if (application_exist_with_audible_state) {
- application->set_audio_streaming_state(
+ if (application_exist_with_audible_state) {
+ application->set_audio_streaming_state(
mobile_apis::AudioStreamingState::NOT_AUDIBLE);
- } else {
- MessageHelper::SendOnResumeAudioSourceToHMI(application->app_id());
+ } else {
+ MessageHelper::SendOnResumeAudioSourceToHMI(application->app_id());
+ }
}
}
}
- application->set_hmi_level(hmi_level);
+
if (hmi_level != mobile_apis::HMILevel::HMI_FULL) {
- //APPLINK-7244
- MessageHelper::SendHMIStatusNotification(*(application.get()));
+ application->set_hmi_level(hmi_level);
}
+ MessageHelper::SendHMIStatusNotification(*(application.get()));
+
LOG4CXX_INFO(logger_, "Set up application "
<< application->mobile_app_id()->asString()
- << " to HMILevel " << seted_up_hmi_level);
+ << " to HMILevel " << hmi_level);
return true;
}
diff --git a/src/components/application_manager/test/CMakeLists.txt b/src/components/application_manager/test/CMakeLists.txt
index d3dee343d5..4d0e7a738f 100644
--- a/src/components/application_manager/test/CMakeLists.txt
+++ b/src/components/application_manager/test/CMakeLists.txt
@@ -44,22 +44,13 @@ set (AM_SOURCES
${AM_SOURCE_DIR}/src/mobile_message_handler.cc
)
-if (EXTENDED_POLICY_FLAG)
include_directories(
- ${COMPONENTS_DIR}/policy/src/policy/policy_table/table_struct_ext
- )
- list(APPEND AM_SOURCES
- ${COMPONENTS_DIR}/src/policies/pt_exchange_handler_ext.cc
- )
-else ()
- include_directories(
- ${COMPONENTS_DIR}/policy/src/policy/policy_table/table_struct
+ ${AM_SOURCE_DIR}/policy/src/policy/policy_table/table_struct
)
list(APPEND AM_SOURCES
${COMPONENTS_DIR}/application_manager/src/policies/pt_exchange_handler_impl.cc
${COMPONENTS_DIR}/application_manager/src/policies/policy_retry_sequence.cc
)
-endif ()
set(testLibraries
gmock
diff --git a/src/components/application_manager/test/mock/include/application_manager/application.h b/src/components/application_manager/test/mock/include/application_manager/application.h
index 636b0aaa41..5f1f598851 100644
--- a/src/components/application_manager/test/mock/include/application_manager/application.h
+++ b/src/components/application_manager/test/mock/include/application_manager/application.h
@@ -393,7 +393,6 @@ class Application : public virtual InitialApplicationData,
virtual bool MakeFullscreen() = 0;
virtual bool IsAudible() const = 0;
virtual void MakeNotAudible() = 0;
-
virtual bool allowed_support_navigation() const = 0;
virtual void set_allowed_support_navigation(bool allow) = 0;
virtual bool hmi_supports_navi_video_streaming() const = 0;
@@ -401,6 +400,9 @@ class Application : public virtual InitialApplicationData,
virtual bool hmi_supports_navi_audio_streaming() const = 0;
virtual void set_hmi_supports_navi_audio_streaming(bool supports) = 0;
+ virtual bool is_voice_communication_supported() const = 0;
+ virtual void set_voice_communication_supported(
+ bool is_voice_communication_supported) = 0;
virtual bool app_allowed() const = 0;
virtual bool has_been_activated() const = 0;
@@ -530,6 +532,13 @@ class Application : public virtual InitialApplicationData,
*/
virtual void UnsubscribeFromSoftButtons(int32_t cmd_id) = 0;
+ /**
+ * @brief Check's if it is media, voice communication or navigation application
+ *
+ * @return true if application is media, voice communication or navigation
+ */
+ virtual bool IsAudioApplication() const = 0;
+
protected:
// interfaces for NAVI retry sequence
diff --git a/src/components/application_manager/test/mock/include/application_manager/application_impl.h b/src/components/application_manager/test/mock/include/application_manager/application_impl.h
index 0a056df92b..dadfce0929 100644
--- a/src/components/application_manager/test/mock/include/application_manager/application_impl.h
+++ b/src/components/application_manager/test/mock/include/application_manager/application_impl.h
@@ -82,6 +82,9 @@ class ApplicationImpl : public virtual InitialApplicationDataImpl,
bool hmi_supports_navi_audio_streaming() const;
void set_hmi_supports_navi_audio_streaming(bool supports);
+ virtual bool is_voice_communication_supported() const;
+ virtual void set_voice_communication_supported(
+ bool is_voice_communication_supported);
inline bool app_allowed() const;
bool has_been_activated() const;
@@ -166,6 +169,13 @@ class ApplicationImpl : public virtual InitialApplicationDataImpl,
virtual void UnsubscribeFromSoftButtons(int32_t cmd_id);
+ /**
+ * @brief Check's if it is media, voice communication or navigation application
+ *
+ * @return true if application is media, voice communication or navigation
+ */
+ virtual bool IsAudioApplication() const;
+
protected:
/**
@@ -220,6 +230,7 @@ class ApplicationImpl : public virtual InitialApplicationDataImpl,
std::set<uint32_t> subscribed_vehicle_info_;
UsageStatistics usage_report_;
ProtocolVersion protocol_version_;
+ bool is_voice_communication_application_;
// NAVI retry stream
volatile bool is_video_stream_retry_active_;
diff --git a/src/components/application_manager/test/mock/include/application_manager/application_manager_impl.h b/src/components/application_manager/test/mock/include/application_manager/application_manager_impl.h
index dbee738564..85048477a5 100644
--- a/src/components/application_manager/test/mock/include/application_manager/application_manager_impl.h
+++ b/src/components/application_manager/test/mock/include/application_manager/application_manager_impl.h
@@ -156,8 +156,8 @@ class ApplicationManagerImpl : public ApplicationManager,
MOCK_METHOD0(Stop, bool());
MOCK_METHOD1(OnMessageReceived, void (utils::SharedPtr<application_manager::Message>));
MOCK_METHOD1(OnErrorSending, void (utils::SharedPtr<application_manager::Message>));
- MOCK_METHOD1(OnMessageReceived, void (const RawMessagePtr));
- MOCK_METHOD1(OnMobileMessageSent, void (const RawMessagePtr));
+ MOCK_METHOD1(OnMessageReceived, void (const ::protocol_handler::RawMessagePtr));
+ MOCK_METHOD1(OnMobileMessageSent, void (const ::protocol_handler::RawMessagePtr));
MOCK_METHOD1(OnDeviceListUpdated, void (const connection_handler::DeviceMap&));
MOCK_METHOD0(OnFindNewApplicationsRequest, void ());
MOCK_METHOD1(RemoveDevice, void (const connection_handler::DeviceHandle&));
@@ -196,7 +196,6 @@ class ApplicationManagerImpl : public ApplicationManager,
MOCK_METHOD0(HeadUnitSuspend, void());
MOCK_METHOD1(LoadAppDataToHMI, bool(ApplicationSharedPtr));
MOCK_METHOD1(ActivateApplication, bool (ApplicationSharedPtr));
- MOCK_METHOD1(PutApplicationInLimited, mobile_api::HMILevel::eType (ApplicationSharedPtr));
MOCK_METHOD1(PutApplicationInFull, mobile_api::HMILevel::eType (ApplicationSharedPtr));
MOCK_METHOD2(UnregisterRevokedApplication, void(uint32_t, mobile_apis::Result::eType));
MOCK_METHOD1(SetUnregisterAllApplicationsReason, void(mobile_api::AppInterfaceUnregisteredReason::eType));
@@ -251,6 +250,8 @@ class ApplicationManagerImpl : public ApplicationManager,
MOCK_METHOD0(GetNextHMICorrelationID, uint32_t ());
MOCK_CONST_METHOD0(IsHMICooperating, bool());
MOCK_METHOD0(OnTimerSendTTSGlobalProperties, void());
+ MOCK_METHOD0(CreatePhoneCallAppList, void());
+ MOCK_METHOD0(ResetPhoneCallAppList, void());
MOCK_METHOD1(AddAppToTTSGlobalPropertiesList, void(const uint32_t));
MOCK_METHOD1(RemoveAppFromTTSGlobalPropertiesList, void(const uint32_t));
MOCK_METHOD1(application_by_hmi_app, ApplicationSharedPtr(uint32_t));
@@ -259,6 +260,10 @@ class ApplicationManagerImpl : public ApplicationManager,
bool));
MOCK_METHOD4(UnregisterApplication, void(const uint32_t,mobile_apis::Result::eType,
bool, bool));
+ MOCK_CONST_METHOD0(get_limited_media_application, ApplicationSharedPtr());
+ MOCK_CONST_METHOD0(get_limited_navi_application, ApplicationSharedPtr());
+ MOCK_CONST_METHOD0(get_limited_voice_application, ApplicationSharedPtr());
+ MOCK_CONST_METHOD1(DoesAudioAppWithSameHMITypeExistInFullOrLimited, bool(ApplicationSharedPtr));
MOCK_CONST_METHOD0(active_application, ApplicationSharedPtr ());
MOCK_METHOD0(OnApplicationListUpdateTimer, void());
diff --git a/src/components/application_manager/test/mock/include/application_manager/commands/command.h b/src/components/application_manager/test/mock/include/application_manager/commands/command.h
index 28c77b6229..587c3d834c 100644
--- a/src/components/application_manager/test/mock/include/application_manager/commands/command.h
+++ b/src/components/application_manager/test/mock/include/application_manager/commands/command.h
@@ -90,6 +90,24 @@ class Command {
* @brief Retrieves correlation ID
*/
virtual uint32_t correlation_id() const = 0;
+
+ /*
+ * @brief Retrieves connection_key
+ */
+ virtual uint32_t connection_key() const = 0;
+
+ /*
+ * @brief Retrieves request ID
+ */
+ virtual int32_t function_id() const = 0;
+
+ /*
+ * @brief Function is called by RequestController when request execution time
+ * has exceed it's limit
+ *
+ */
+ virtual void onTimeOut() = 0;
+
};
} // namespace commands
diff --git a/src/components/application_manager/test/mock/include/application_manager/commands/command_impl.h b/src/components/application_manager/test/mock/include/application_manager/commands/command_impl.h
index 06637d7d84..a34716bd62 100644
--- a/src/components/application_manager/test/mock/include/application_manager/commands/command_impl.h
+++ b/src/components/application_manager/test/mock/include/application_manager/commands/command_impl.h
@@ -101,6 +101,23 @@ class CommandImpl : public Command {
*/
virtual uint32_t correlation_id() const;
+ /*
+ * @brief Retrieves connection key
+ */
+ virtual uint32_t connection_key() const;
+
+ /*
+ * @brief Retrieves request ID
+ */
+ virtual int32_t function_id() const;
+
+ /*
+ * @brief Function is called by RequestController when request execution time
+ * has exceed it's limit
+ *
+ */
+ virtual void onTimeOut();
+
// members
static const int32_t hmi_protocol_type_;
static const int32_t mobile_protocol_type_;
diff --git a/src/components/application_manager/test/mock/include/application_manager/commands/command_request_impl.h b/src/components/application_manager/test/mock/include/application_manager/commands/command_request_impl.h
index fb14078961..1bbba5aa0b 100644
--- a/src/components/application_manager/test/mock/include/application_manager/commands/command_request_impl.h
+++ b/src/components/application_manager/test/mock/include/application_manager/commands/command_request_impl.h
@@ -81,16 +81,6 @@ class CommandRequestImpl : public CommandImpl,
virtual void on_event(const event_engine::Event& event);
/*
- * @brief Retrieves request ID
- */
- inline int32_t function_id() const;
-
- /*
- * @brief Retrieves connection key
- */
- inline uint32_t connection_key() const;
-
- /*
* @brief Creates Mobile response
*
* @param success true if successful; false, if failed
@@ -194,14 +184,6 @@ protected:
void AddDisallowedParametersToInfo(smart_objects::SmartObject& response) const;
};
-int32_t CommandRequestImpl::function_id() const {
- return (*message_)[strings::params][strings::function_id].asInt();
-}
-
-uint32_t CommandRequestImpl::connection_key() const {
- return (*message_)[strings::params][strings::connection_key].asUInt();
-}
-
} // namespace commands
} // namespace application_manager
diff --git a/src/components/application_manager/test/mock/include/application_manager/commands/hmi/on_phone_call_notification.h b/src/components/application_manager/test/mock/include/application_manager/commands/hmi/on_phone_call_notification.h
new file mode 100644
index 0000000000..45d831eb03
--- /dev/null
+++ b/src/components/application_manager/test/mock/include/application_manager/commands/hmi/on_phone_call_notification.h
@@ -0,0 +1,77 @@
+/*
+ * Copyright (c) 2013, Ford Motor Company
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * Neither the name of the Ford Motor Company nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_COMMANDS_HMI_ON_PHONE_CALL_NOTIFICATION_H_
+#define SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_COMMANDS_HMI_ON_PHONE_CALL_NOTIFICATION_H_
+
+#include "application_manager/commands/hmi/notification_from_hmi.h"
+
+namespace application_manager {
+
+namespace commands {
+
+namespace hmi {
+
+
+/**
+ * @brief OnPhoneCallNotification command class
+ **/
+class OnPhoneCallNotification : public NotificationFromHMI {
+ public:
+ /**
+ * @brief OnPhoneCallNotification class constructor
+ *
+ * @param message Incoming SmartObject message
+ **/
+ explicit OnPhoneCallNotification(const MessageSharedPtr& message);
+
+ /**
+ * @brief OnPhoneCallNotification class destructor
+ **/
+ virtual ~OnPhoneCallNotification();
+
+ /**
+ * @brief Execute command
+ **/
+ virtual void Run();
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(OnPhoneCallNotification);
+};
+
+} // namespace hmi
+
+} // namespace commands
+
+} // namespace application_manager
+
+#endif // SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_COMMANDS_HMI_ON_PHONE_CALL_NOTIFICATION_H_
diff --git a/src/components/application_manager/test/mock/include/application_manager/message_helper.h b/src/components/application_manager/test/mock/include/application_manager/message_helper.h
index e7a7631d69..69c7b7bba7 100644
--- a/src/components/application_manager/test/mock/include/application_manager/message_helper.h
+++ b/src/components/application_manager/test/mock/include/application_manager/message_helper.h
@@ -1,4 +1,4 @@
-/*
+/*
Copyright (c) 2013, Ford Motor Company
All rights reserved.
@@ -92,7 +92,9 @@ class MessageHelper {
*
**/
static void SendOnAppRegisteredNotificationToHMI(
- const Application& application_impl, bool resumption = false);
+ const Application& application_impl,
+ bool resumption = false,
+ bool need_restore_vr = false);
/**
* @brief Create mobile HashUpdateNotification
diff --git a/src/components/application_manager/test/mock/include/application_manager/mobile_message_handler.h b/src/components/application_manager/test/mock/include/application_manager/mobile_message_handler.h
index c84ba54212..67d51c0dab 100644
--- a/src/components/application_manager/test/mock/include/application_manager/mobile_message_handler.h
+++ b/src/components/application_manager/test/mock/include/application_manager/mobile_message_handler.h
@@ -1,4 +1,4 @@
-/**
+/*
* Copyright (c) 2013, Ford Motor Company
* All rights reserved.
*
@@ -42,10 +42,10 @@ typedef utils::SharedPtr<application_manager::Message> MobileMessage;
class MobileMessageHandler {
public:
static application_manager::Message* HandleIncomingMessageProtocolV1(
- const RawMessagePtr message);
+ const protocol_handler::RawMessagePtr message);
static application_manager::Message* HandleIncomingMessageProtocolV2(
- const RawMessagePtr message);
+ const protocol_handler::RawMessagePtr message);
//! -------------------------------------------------------------
diff --git a/src/components/application_manager/test/mock/include/application_manager/policies/policy_handler.h b/src/components/application_manager/test/mock/include/application_manager/policies/policy_handler.h
index 5bc23c106a..dfc29fe00a 100644
--- a/src/components/application_manager/test/mock/include/application_manager/policies/policy_handler.h
+++ b/src/components/application_manager/test/mock/include/application_manager/policies/policy_handler.h
@@ -303,6 +303,18 @@ class PolicyHandler :
*/
uint16_t HeartBeatTimeout(const std::string& app_id) const;
+//TODO(AKutsan) REMOVE THIS UGLY HOTFIX
+ virtual void Increment(usage_statistics::GlobalCounterId type);
+ virtual void Increment(const std::string& app_id,
+ usage_statistics::AppCounterId type);
+ virtual void Set(const std::string& app_id,
+ usage_statistics::AppInfoId type,
+ const std::string& value);
+ virtual void Add(const std::string& app_id,
+ usage_statistics::AppStopwatchId type,
+ int32_t timespan_seconds);
+
+
protected:
/**
@@ -338,6 +350,33 @@ protected:
const std::string ConvertUpdateStatus(policy::PolicyTableStatus status);
private:
+
+ class StatisticManagerImpl: public usage_statistics::StatisticsManager {
+ //TODO(AKutsan) REMOVE THIS UGLY HOTFIX
+ virtual void Increment(usage_statistics::GlobalCounterId type) {
+ return PolicyHandler::instance()->Increment(type);
+ }
+
+ virtual void Increment(const std::string& app_id,
+ usage_statistics::AppCounterId type) {
+ return PolicyHandler::instance()->Increment(app_id, type);
+ }
+
+ virtual void Set(const std::string& app_id,
+ usage_statistics::AppInfoId type,
+ const std::string& value) {
+ return PolicyHandler::instance()->Set(app_id, type, value);
+ }
+
+ virtual void Add(const std::string& app_id,
+ usage_statistics::AppStopwatchId type,
+ int32_t timespan_seconds) {
+ return PolicyHandler::instance()->Add(app_id, type, timespan_seconds);
+ }
+ };
+ //TODO(AKutsan) REMOVE THIS UGLY HOTFIX
+
+
PolicyHandler();
static PolicyHandler* instance_;
static const std::string kLibrary;
@@ -365,6 +404,10 @@ private:
*/
std::map<std::string, std::string> app_to_device_link_;
+
+ utils::SharedPtr<StatisticManagerImpl> statistic_manager_impl_;
+
+
DISALLOW_COPY_AND_ASSIGN(PolicyHandler);
FRIEND_BASE_SINGLETON_CLASS_WITH_DELETER(PolicyHandler,
utils::deleters::Deleter<PolicyHandler>);
diff --git a/src/components/application_manager/test/mock/include/application_manager/policies/pt_exchange_handler_impl.h b/src/components/application_manager/test/mock/include/application_manager/policies/pt_exchange_handler_impl.h
index e1e67b1505..29c74aa96e 100644
--- a/src/components/application_manager/test/mock/include/application_manager/policies/pt_exchange_handler_impl.h
+++ b/src/components/application_manager/test/mock/include/application_manager/policies/pt_exchange_handler_impl.h
@@ -50,7 +50,7 @@ class PTExchangeHandlerImpl : public PTExchangeHandler {
protected:
PolicyHandler* policy_handler_;
- threads::Thread retry_sequence_;
+ threads::Thread* retry_sequence_;
sync_primitives::Lock retry_sequence_lock_;
friend class RetrySequence;
diff --git a/src/components/application_manager/test/mock/include/application_manager/request_controller.h b/src/components/application_manager/test/mock/include/application_manager/request_controller.h
index b70608fbc2..2bc5f54666 100644
--- a/src/components/application_manager/test/mock/include/application_manager/request_controller.h
+++ b/src/components/application_manager/test/mock/include/application_manager/request_controller.h
@@ -131,7 +131,7 @@ class RequestController {
* @return Result code
*
*/
- TResult addHMIRequest(const RequestPtr& request);
+ TResult addHMIRequest(const RequestPtr request);
/**
* @ Add notification to collection
@@ -182,7 +182,7 @@ class RequestController {
*
* @param app_id Connection key of application
* @param mobile_correlation_id Correlation ID of the mobile request
- * @param new_timeout_value New timeout to be set
+ * @param new_timeout_value New timeout to be set in milliseconds
*/
void updateRequestTimeout(const uint32_t& app_id,
const uint32_t& mobile_correlation_id,
@@ -196,7 +196,9 @@ class RequestController {
* @param app_time_scale - time scale (seconds)
* @param max_request_per_time_scale - maximum count of request that should be allowed for app_time_scale secconds
*/
- bool checkTimeScaleMaxRequest(const uint32_t& app_id, const uint32_t& app_time_scale, const uint32_t& max_request_per_time_scale);
+ bool checkTimeScaleMaxRequest(const uint32_t& app_id,
+ const uint32_t& app_time_scale,
+ const uint32_t& max_request_per_time_scale);
/**
* @brief Checs if this app as able to add new requests in current hmi_level, or limits was exceeded
@@ -205,7 +207,10 @@ class RequestController {
* @param app_time_scale - time scale (seconds)
* @param max_request_per_time_scale - maximum count of request that should be allowed for app_time_scale secconds
*/
- bool checkHMILevelTimeScaleMaxRequest(const mobile_apis::HMILevel::eType& hmi_level, const uint32_t& app_id, const uint32_t& app_time_scale, const uint32_t& max_request_per_time_scale);
+ bool checkHMILevelTimeScaleMaxRequest(const mobile_apis::HMILevel::eType& hmi_level,
+ const uint32_t& app_id,
+ const uint32_t& app_time_scale,
+ const uint32_t& max_request_per_time_scale);
void onTimer();
@@ -232,12 +237,7 @@ class RequestController {
volatile bool stop_flag_;
};
- /**
- * @brief Typedef for thread shared pointer
- */
- typedef utils::SharedPtr<Thread> ThreadSharedPtr;
-
- std::vector<ThreadSharedPtr> pool_;
+ std::vector<Thread*> pool_;
volatile TPoolState pool_state_;
uint32_t pool_size_;
sync_primitives::ConditionalVariable cond_var_;
diff --git a/src/components/application_manager/test/mock/include/application_manager/request_info.h b/src/components/application_manager/test/mock/include/application_manager/request_info.h
index 778e72c916..b1409488fd 100644
--- a/src/components/application_manager/test/mock/include/application_manager/request_info.h
+++ b/src/components/application_manager/test/mock/include/application_manager/request_info.h
@@ -1,4 +1,4 @@
-/**
+/**
* \file request_info.h
* \brief request information structure header file.
*
@@ -55,26 +55,30 @@ namespace request_controller {
typedef utils::SharedPtr<commands::CommandRequestImpl> MobileRequestPtr;
struct RequestInfo {
- RequestInfo(const uint64_t timeout_sec):
- timeout_sec_(timeout_sec) {
+ RequestInfo(const uint64_t timeout_sec)
+ : timeout_sec_(timeout_sec) {
start_time_ = date_time::DateTime::getCurrentTime();
updateEndTime();
}
- RequestInfo(const TimevalStruct& start_time,const uint64_t timeout_sec):
- start_time_(start_time),
+ RequestInfo(const TimevalStruct& start_time,const uint64_t timeout_sec)
+ : start_time_(start_time),
timeout_sec_(timeout_sec) {
updateEndTime();
- }
+ }
- virtual ~RequestInfo(){}
+ virtual ~RequestInfo(){}
- virtual uint32_t requestId() = 0;
- virtual commands::Command* request() = 0;
+ virtual uint32_t requestId() = 0;
+ virtual commands::Command* request() = 0;
void updateEndTime() {
end_time_ = date_time::DateTime::getCurrentTime();
end_time_.tv_sec += timeout_sec_;
+
+ // possible delay during IPC
+ const uint32_t hmi_delay_sec = 1;
+ end_time_.tv_sec += hmi_delay_sec;
}
void updateTimeOut(const uint64_t& timeout_sec) {
@@ -89,9 +93,11 @@ namespace request_controller {
}
return true;
}
+
TimevalStruct start_time() {
return start_time_;
}
+
uint64_t timeout_sec() {
return timeout_sec_;
}
@@ -100,42 +106,62 @@ namespace request_controller {
return end_time_;
}
+ uint32_t app_id() {
+ return app_id_;
+ }
+
+ mobile_apis::HMILevel::eType hmi_level() {
+ return hmi_level_;
+ }
+
protected:
- TimevalStruct start_time_;
- uint64_t timeout_sec_;
- TimevalStruct end_time_;
+ TimevalStruct start_time_;
+ uint64_t timeout_sec_;
+ TimevalStruct end_time_;
+ uint32_t app_id_;
+ mobile_apis::HMILevel::eType hmi_level_;
};
typedef utils::SharedPtr<RequestInfo> RequestInfoPtr;
struct RequestInfoComparator {
- bool operator() (const RequestInfoPtr lhs, const RequestInfoPtr rhs) const {
- date_time::TimeCompare compare_result = date_time::DateTime::compareTime(lhs->end_time(), rhs->end_time());
- return compare_result == date_time::LESS;
+ bool operator() (const RequestInfoPtr lhs,
+ const RequestInfoPtr rhs) const {
+ date_time::TimeCompare compare_result =
+ date_time::DateTime::compareTime(lhs->end_time(), rhs->end_time());
+
+ return compare_result == date_time::LESS;
}
};
typedef std::set<RequestInfoPtr,RequestInfoComparator> RequestInfoSet;
struct HMIRequestInfo: public RequestInfo {
- HMIRequestInfo(RequestPtr request, const uint64_t timeout_sec);
- HMIRequestInfo(RequestPtr request, const TimevalStruct& start_time,const uint64_t timeout_sec);
+ HMIRequestInfo(RequestPtr request, const uint64_t timeout_sec);
+ HMIRequestInfo(RequestPtr request, const TimevalStruct& start_time,
+ const uint64_t timeout_sec);
+
RequestPtr request_;
uint32_t correlation_id_;
+
virtual uint32_t requestId() {
return correlation_id_;
}
+
virtual commands::Command* request() {
return request_.get();
}
};
struct MobileRequestInfo: public RequestInfo {
- MobileRequestInfo(MobileRequestPtr request, const uint64_t timeout_sec);
- MobileRequestInfo(MobileRequestPtr request, const TimevalStruct& start_time, const uint64_t timeout_sec);
- MobileRequestPtr request_;
- uint32_t app_id_;
- mobile_apis::HMILevel::eType hmi_level_;
+ MobileRequestInfo(RequestPtr request,
+ const uint64_t timeout_sec);
+
+ MobileRequestInfo(RequestPtr request,
+ const TimevalStruct& start_time,
+ const uint64_t timeout_sec);
+
+ RequestPtr request_;
uint32_t mobile_correlation_id_;
virtual uint32_t requestId() {
@@ -152,27 +178,26 @@ namespace request_controller {
* during time scale
*/
struct TimeScale {
- explicit TimeScale(const TimevalStruct& start, const TimevalStruct& end,
- const int32_t& app_id)
+ TimeScale(const TimevalStruct& start,
+ const TimevalStruct& end,
+ const uint32_t& app_id)
: start_(start),
end_(end),
app_id_(app_id) {}
bool operator()(RequestInfoPtr setEntry) {
- MobileRequestInfo* mobile_request_info = NULL;
- RequestInfo* request = setEntry.get();
- mobile_request_info = dynamic_cast<MobileRequestInfo*>(request);
- if (NULL == mobile_request_info) {
+
+ if (!setEntry.valid()) {
return false;
}
- if (mobile_request_info->app_id_ != app_id_) {
+ if (setEntry->app_id() != app_id_) {
return false;
}
- if (date_time::DateTime::getmSecs(mobile_request_info->start_time())
+ if (date_time::DateTime::getmSecs(setEntry->start_time())
< date_time::DateTime::getmSecs(start_) ||
- date_time::DateTime::getmSecs(mobile_request_info->start_time())
+ date_time::DateTime::getmSecs(setEntry->start_time())
> date_time::DateTime::getmSecs(end_)) {
return false;
}
@@ -181,9 +206,9 @@ namespace request_controller {
}
private:
- TimevalStruct start_;
- TimevalStruct end_;
- uint32_t app_id_;
+ TimevalStruct start_;
+ TimevalStruct end_;
+ uint32_t app_id_;
};
/**
@@ -191,30 +216,31 @@ namespace request_controller {
* during time scale for application in defined hmi level
*/
struct HMILevelTimeScale {
- explicit HMILevelTimeScale(
- const TimevalStruct& start, const TimevalStruct& end,
- const uint32_t& app_id, const mobile_apis::HMILevel::eType& hmi_level)
+ HMILevelTimeScale(const TimevalStruct& start,
+ const TimevalStruct& end,
+ const uint32_t& app_id,
+ const mobile_apis::HMILevel::eType& hmi_level)
: start_(start),
end_(end),
app_id_(app_id),
hmi_level_(hmi_level) {}
bool operator()(RequestInfoPtr setEntry) {
- MobileRequestInfo* mobile_request_info = NULL;
- mobile_request_info = dynamic_cast<MobileRequestInfo*>(setEntry.get());
- if (NULL == mobile_request_info) {
+ if (!setEntry.valid()) {
return false;
}
- if (mobile_request_info->app_id_ != app_id_) {
+
+ if (setEntry->app_id() != app_id_) {
return false;
}
- if (mobile_request_info->hmi_level_ != hmi_level_) {
+
+ if (setEntry->hmi_level() != hmi_level_) {
return false;
}
- if (date_time::DateTime::getSecs(mobile_request_info->start_time())
+ if (date_time::DateTime::getSecs(setEntry->start_time())
< date_time::DateTime::getSecs(start_) ||
- date_time::DateTime::getSecs(mobile_request_info->start_time())
+ date_time::DateTime::getSecs(setEntry->start_time())
> date_time::DateTime::getSecs(end_)) {
return false;
}
@@ -222,9 +248,9 @@ namespace request_controller {
return true;
}
private:
- TimevalStruct start_;
- TimevalStruct end_;
- uint32_t app_id_;
+ TimevalStruct start_;
+ TimevalStruct end_;
+ uint32_t app_id_;
mobile_apis::HMILevel::eType hmi_level_;
};
diff --git a/src/components/application_manager/test/mock/include/application_manager/smart_object_keys.h b/src/components/application_manager/test/mock/include/application_manager/smart_object_keys.h
index 1df8b21ad9..3d03989874 100644
--- a/src/components/application_manager/test/mock/include/application_manager/smart_object_keys.h
+++ b/src/components/application_manager/test/mock/include/application_manager/smart_object_keys.h
@@ -361,6 +361,7 @@ const char result[] = "result";
const char statistic_type[] = "statisticType";
const char error[] = "error";
const char policyfile[] = "policyfile";
+const char is_active[] = "isActive";
} // namespace hmi_notification