diff options
author | Vladislav Smenyuk <VSmenyuk@luxoft.com> | 2014-03-26 07:56:41 -0700 |
---|---|---|
committer | Justin Dickow <jjdickow@gmail.com> | 2014-07-08 16:01:23 -0400 |
commit | 46061dc55af4d6e4d9b69a4feafd5010efcb8242 (patch) | |
tree | 6c5d493e5e2d74bf5423ed8564c912252acf4853 | |
parent | df165be3d4c5dbb5b8bfc5ad11db619ece5a04e6 (diff) | |
download | smartdevicelink-dev/merge_3.3.tar.gz |
APPLINK-6387 Core sends OnAppRegistered notification to HMI without check whether connection is established.dev/merge_3.3
Signed-off-by: Justin Dickow <jjdickow@gmail.com>
Conflicts:
src/components/application_manager/src/application_manager_impl.cc
3 files changed, 40 insertions, 26 deletions
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 2c688f094..a1f553cb5 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 @@ -464,6 +464,11 @@ class ApplicationManagerImpl : public ApplicationManager, const std::string& save_path, const uint32_t offset = 0); + /* + * @brief returns true if HMI is cooperating + */ + bool IsHMICooperating() const; + private: ApplicationManagerImpl(); bool InitThread(threads::Thread* thread); diff --git a/src/components/application_manager/src/application_manager_impl.cc b/src/components/application_manager/src/application_manager_impl.cc index 3e5b2a99a..8c79eb356 100644 --- a/src/components/application_manager/src/application_manager_impl.cc +++ b/src/components/application_manager/src/application_manager_impl.cc @@ -441,6 +441,7 @@ mobile_api::HMILevel::eType ApplicationManagerImpl::PutApplicationInFull( } if ( result == mobile_api::HMILevel::HMI_FULL) { + app->set_hmi_level(result); MessageHelper::SendActivateAppToHMI(app->app_id()); } return result; @@ -1061,17 +1062,17 @@ void ApplicationManagerImpl::SendMessageToHMI( logger_, "Attached schema to message, result if valid: " << message->isValid()); -#ifdef WEB_HMI +#ifdef HMI_JSON_API if (!ConvertSOtoMessage(*message, *message_to_send)) { LOG4CXX_WARN(logger_, "Cannot send message to HMI: failed to create string"); return; } -#endif // WEB_HMI +#endif // HMI_JSON_API -#ifdef QT_HMI +#ifdef HMI_DBUS_API message_to_send->set_smart_object(*message); -#endif // QT_HMI +#endif // HMI_DBUS_API messages_to_hmi_.PostMessage(impl::MessageToHmi(message_to_send)); } @@ -1396,16 +1397,16 @@ void ApplicationManagerImpl::ProcessMessageFromHMI( return; } -#ifdef WEB_HMI +#ifdef HMI_JSON_API if (!ConvertMessageToSO(*message, *smart_object)) { LOG4CXX_ERROR(logger_, "Cannot create smart object from message"); return; } -#endif // WEB_HMI +#endif // HMI_JSON_API -#ifdef QT_HMI +#ifdef HMI_DBUS_API *smart_object = message->smart_object(); -#endif // QT_HMI +#endif // HMI_DBUS_API LOG4CXX_INFO(logger_, "Converted message, trying to create hmi command"); if (!ManageHMICommand(smart_object)) { @@ -1633,32 +1634,38 @@ void ApplicationManagerImpl::Unmute(VRTTSSessionChanging changing_state) { } mobile_apis::Result::eType ApplicationManagerImpl::SaveBinary( - const std::string& app_name, const std::vector<uint8_t>& binary_data, - const std::string& save_path, const uint32_t offset) { - if (binary_data.size() > file_system::GetAvailableSpaceForApp(app_name)) { + const std::vector<uint8_t>& binary_data, const std::string& file_path, + const uint32_t offset) { + LOG4CXX_INFO( + logger_, + "SaveBinaryWithOffset binary_size = " << binary_data.size() + << " offset = " << offset); + + if (binary_data.size() > file_system::GetAvailableDiskSpace()) { + LOG4CXX_ERROR(logger_, "Out of free disc space."); return mobile_apis::Result::OUT_OF_MEMORY; } - LOG4CXX_INFO(logger_, "SaveBinaryWithOffset binary_size = " - << binary_data.size() << " offset = " << offset); - - uint32_t file_size = file_system::FileSize(file_system::FullPath(save_path)); + uint32_t file_size = file_system::FileSize(file_path); std::ofstream* file_stream; if (offset != 0) { if (file_size != offset) { - LOG4CXX_INFO(logger_, "ApplicationManagerImpl::SaveBinaryWithOffset offset does'n match existing filesize"); + LOG4CXX_INFO( + logger_, + "ApplicationManagerImpl::SaveBinaryWithOffset offset does'n match existing filesize"); return mobile_apis::Result::INVALID_DATA; } - file_stream = file_system::Open(file_system::FullPath(save_path), - std::ios_base::app); + file_stream = file_system::Open(file_path, std::ios_base::app); } else { - LOG4CXX_INFO(logger_, "ApplicationManagerImpl::SaveBinaryWithOffset offset is 0, rewrite"); + LOG4CXX_INFO( + logger_, + "ApplicationManagerImpl::SaveBinaryWithOffset offset is 0, rewrite"); // if offset == 0: rewrite file - file_stream = file_system::Open(file_system::FullPath(save_path), - std::ios_base::out); + file_stream = file_system::Open(file_path, std::ios_base::out); } - if (!file_system::Write(file_stream,binary_data.data(), binary_data.size())) { + if (!file_system::Write(file_stream, binary_data.data(), + binary_data.size())) { file_system::Close(file_stream); return mobile_apis::Result::GENERIC_ERROR; } @@ -1667,4 +1674,8 @@ mobile_apis::Result::eType ApplicationManagerImpl::SaveBinary( return mobile_apis::Result::SUCCESS; } +bool ApplicationManagerImpl::IsHMICooperating() const { + return hmi_cooperating_; +} + } // namespace application_manager diff --git a/src/components/application_manager/src/commands/mobile/register_app_interface_request.cc b/src/components/application_manager/src/commands/mobile/register_app_interface_request.cc index e838e53e7..1eff7408c 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 @@ -62,10 +62,8 @@ bool RegisterAppInterfaceRequest::Init() { void RegisterAppInterfaceRequest::Run() { LOG4CXX_INFO(logger_, "RegisterAppInterfaceRequest::Run "<< connection_key()); - // wait till all HMI capabilities initialized - const HMICapabilities& hmi_capabilities = - ApplicationManagerImpl::instance()->hmi_capabilities(); - while (!hmi_capabilities.is_hmi_capabilities_initialized()) { + // wait till HMI started + while (!ApplicationManagerImpl::instance()->IsHMICooperating()) { sleep(1); // TODO(DK): timer_->StartWait(1); ApplicationManagerImpl::instance()->updateRequestTimeout(connection_key(), |