From fc9f7d13c0e03caee9e196a636815e791213ad66 Mon Sep 17 00:00:00 2001 From: JackLivio Date: Fri, 1 Mar 2019 15:00:38 -0500 Subject: Get Icon URL Request (#2823) * Fix regex command for reading paths post port number * Add Icon URL to policies * Create Icon Request and save to icon folder. * Fixes for get icon url * Fix unit tests * Send Icon_url request after PTU * Address comments * Address Comments --- .../application_manager/application_manager_impl.h | 24 ++- .../helpers/application_helper.h | 12 ++ .../application_manager/policies/policy_handler.h | 2 + .../mobile/register_app_interface_request.cc | 3 + .../src/commands/mobile/system_request.cc | 26 +++- .../src/application_manager_impl.cc | 162 ++++++++++++++++++++- .../src/message_helper/message_helper.cc | 1 + .../src/policies/policy_handler.cc | 8 +- .../application_manager/application_manager.h | 12 ++ .../policies/policy_handler_interface.h | 1 + .../policy/policy_external/policy/policy_manager.h | 11 +- .../policy/policy_regular/policy/policy_manager.h | 11 +- .../application_manager/mock_application_manager.h | 11 ++ .../policies/mock_policy_handler_interface.h | 1 + .../policy_external/policy/mock_cache_manager.h | 1 + .../policy_external/policy/mock_policy_manager.h | 1 + .../policy_regular/policy/mock_cache_manager.h | 1 + .../policy_regular/policy/mock_policy_manager.h | 1 + src/components/interfaces/HMI_API.xml | 1 + src/components/interfaces/MOBILE_API.xml | 1 + .../policy_external/include/policy/cache_manager.h | 9 ++ .../include/policy/cache_manager_interface.h | 9 ++ .../include/policy/policy_manager_impl.h | 9 ++ .../include/policy/policy_table/enums.h | 1 + .../include/policy/policy_table/types.h | 1 + .../include/policy/policy_table_interface_ext.xml | 2 + .../policy/policy_external/src/cache_manager.cc | 15 ++ .../policy_external/src/policy_manager_impl.cc | 5 + .../policy_external/src/policy_table/enums.cc | 8 + .../policy_external/src/policy_table/types.cc | 15 +- .../policy_external/src/sql_pt_ext_queries.cc | 6 +- .../src/sql_pt_ext_representation.cc | 4 + .../policy/policy_external/src/sql_pt_queries.cc | 14 +- .../policy_external/src/sql_pt_representation.cc | 6 + .../policy_regular/include/policy/cache_manager.h | 9 ++ .../include/policy/cache_manager_interface.h | 9 ++ .../include/policy/policy_manager_impl.h | 9 ++ .../include/policy/policy_table/types.h | 1 + .../policy/policy_regular/src/cache_manager.cc | 15 ++ .../policy_regular/src/policy_manager_impl.cc | 5 + .../policy_regular/src/policy_table/types.cc | 15 +- .../policy/policy_regular/src/sql_pt_queries.cc | 14 +- .../policy_regular/src/sql_pt_representation.cc | 6 + .../src/cloud/cloud_websocket_transport_adapter.cc | 3 +- 44 files changed, 449 insertions(+), 32 deletions(-) (limited to 'src') 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 1f3f0c327c..ae00108591 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 @@ -117,6 +117,14 @@ struct CommandParametersPermissions; typedef std::map DeviceTypes; +struct AppIconInfo { + std::string endpoint; + bool pending_request; + AppIconInfo(); + AppIconInfo(std::string ws_endpoint, bool pending) + : endpoint(ws_endpoint), pending_request(pending) {} +}; + CREATE_LOGGERPTR_GLOBAL(logger_, "ApplicationManager") typedef std::shared_ptr TimerSPtr; @@ -156,6 +164,7 @@ class ApplicationManagerImpl bool Stop() OVERRIDE; DataAccessor applications() const OVERRIDE; + DataAccessor pending_applications() const OVERRIDE; ApplicationSharedPtr application(uint32_t app_id) const OVERRIDE; ApplicationSharedPtr active_application() const OVERRIDE; @@ -164,6 +173,8 @@ class ApplicationManagerImpl uint32_t hmi_app_id) const OVERRIDE; ApplicationSharedPtr application_by_policy_id( const std::string& policy_app_id) const OVERRIDE; + ApplicationSharedPtr pending_application_by_policy_id( + const std::string& policy_app_id) const OVERRIDE; std::vector applications_by_button( uint32_t button) OVERRIDE; @@ -194,6 +205,9 @@ class ApplicationManagerImpl void SendDriverDistractionState(ApplicationSharedPtr application); + void SendGetIconUrlNotifications(const uint32_t connection_key, + ApplicationSharedPtr application); + ApplicationSharedPtr application( const std::string& device_id, const std::string& policy_app_id) const OVERRIDE; @@ -373,6 +387,10 @@ class ApplicationManagerImpl const transport_manager::ConnectionUID connection_id, const transport_manager::DeviceInfo& device_info); + std::string PolicyIDByIconUrl(const std::string url) OVERRIDE; + + void SetIconFileFromSystemRequest(const std::string policy_id) OVERRIDE; + /** * @brief Notifies the applicaiton manager that a cloud connection status has * updated and should trigger an UpdateAppList RPC to the HMI @@ -504,9 +522,6 @@ class ApplicationManagerImpl // typedef for Applications list typedef std::set ApplictionSet; - typedef std::set - AppsWaitRegistrationSet; - // typedef for Applications list iterator typedef ApplictionSet::iterator ApplictionSetIt; @@ -1478,6 +1493,9 @@ class ApplicationManagerImpl pending_device_map_lock_ptr_; std::map pending_device_map_; + sync_primitives::Lock app_icon_map_lock_ptr_; + std::map app_icon_map_; + #ifdef TELEMETRY_MONITOR AMTelemetryObserver* metric_observer_; #endif // TELEMETRY_MONITOR diff --git a/src/components/application_manager/include/application_manager/helpers/application_helper.h b/src/components/application_manager/include/application_manager/helpers/application_helper.h index 145bef659e..18267c9e7f 100644 --- a/src/components/application_manager/include/application_manager/helpers/application_helper.h +++ b/src/components/application_manager/include/application_manager/helpers/application_helper.h @@ -57,6 +57,18 @@ ApplicationSharedPtr FindApp(DataAccessor accessor, return app; } +template +ApplicationSharedPtr FindPendingApp( + DataAccessor accessor, UnaryPredicate finder) { + AppsWaitRegistrationSet::iterator it = std::find_if( + accessor.GetData().begin(), accessor.GetData().end(), finder); + if (accessor.GetData().end() == it) { + return ApplicationSharedPtr(); + } + ApplicationSharedPtr app = *it; + return app; +} + /** * Helper function for lookup through applications list and returning all * applications satisfying predicate logic 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 1cc5fc0156..b912c489e4 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 @@ -187,6 +187,8 @@ class PolicyHandler : public PolicyHandlerInterface, void GetUpdateUrls(const uint32_t service_type, EndpointUrls& out_end_points) OVERRIDE; virtual std::string GetLockScreenIconUrl() const OVERRIDE; + virtual std::string GetIconUrl( + const std::string& policy_app_id) const OVERRIDE; uint32_t NextRetryTimeout() OVERRIDE; /** diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/register_app_interface_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/register_app_interface_request.cc index b346ee5798..6317d9b068 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/register_app_interface_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/register_app_interface_request.cc @@ -447,6 +447,9 @@ void RegisterAppInterfaceRequest::Run() { GetLockScreenIconUrlNotification(connection_key(), application); rpc_service_.ManageMobileCommand(so, SOURCE_SDL); application_manager_.SendDriverDistractionState(application); + // Create onSystemRequest to mobile to obtain cloud app icons + application_manager_.SendGetIconUrlNotifications(connection_key(), + application); } smart_objects::SmartObjectSPtr diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/system_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/system_request.cc index cea00a9d5e..da39aefd6a 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/system_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/system_request.cc @@ -511,7 +511,8 @@ void SystemRequest::Run() { return; } - if (!file_system::IsFileNameValid(file_name)) { + if (!file_system::IsFileNameValid(file_name) && + mobile_apis::RequestType::ICON_URL != request_type) { const std::string err_msg = "Sync file name contains forbidden symbols."; LOG4CXX_ERROR(logger_, err_msg); SendResponse(false, mobile_apis::Result::INVALID_DATA, err_msg.c_str()); @@ -533,8 +534,21 @@ void SystemRequest::Run() { std::string binary_data_folder; if ((*message_)[strings::params].keyExists(strings::binary_data)) { binary_data = (*message_)[strings::params][strings::binary_data].asBinary(); - binary_data_folder = - application_manager_.get_settings().system_files_path(); + if (mobile_apis::RequestType::ICON_URL == request_type) { + binary_data_folder = + application_manager_.get_settings().app_icons_folder(); + // Use the URL file name to identify the policy id. + // Save the icon file with the policy id as the name. + file_name = application_manager_.PolicyIDByIconUrl(file_name); + if (file_name.empty()) { + const std::string err_msg = "Invalid file name"; + SendResponse(false, mobile_apis::Result::INVALID_DATA, err_msg.c_str()); + } + LOG4CXX_DEBUG(logger_, "Got ICON_URL Request. File name: " << file_name); + } else { + binary_data_folder = + application_manager_.get_settings().system_files_path(); + } } else { binary_data_folder = application_manager_.get_settings().app_storage_folder(); @@ -581,6 +595,12 @@ void SystemRequest::Run() { LOG4CXX_DEBUG(logger_, "Binary data ok."); + if (mobile_apis::RequestType::ICON_URL == request_type) { + application_manager_.SetIconFileFromSystemRequest(file_name); + SendResponse(true, mobile_apis::Result::SUCCESS); + return; + } + if (mobile_apis::RequestType::HTTP == request_type && (*message_)[strings::msg_params].keyExists(strings::file_name)) { const std::string& file = diff --git a/src/components/application_manager/src/application_manager_impl.cc b/src/components/application_manager/src/application_manager_impl.cc index 9903342ae1..a9ae2e5ca7 100644 --- a/src/components/application_manager/src/application_manager_impl.cc +++ b/src/components/application_manager/src/application_manager_impl.cc @@ -73,6 +73,7 @@ #include "policy/usage_statistics/counter.h" #include "utils/custom_string.h" #include +#include namespace { int get_rand_from_range(uint32_t from = 0, int to = RAND_MAX) { @@ -240,6 +241,13 @@ DataAccessor ApplicationManagerImpl::applications() const { return accessor; } +DataAccessor +ApplicationManagerImpl::pending_applications() const { + DataAccessor accessor( + apps_to_register_, apps_to_register_list_lock_ptr_); + return accessor; +} + ApplicationSharedPtr ApplicationManagerImpl::application( uint32_t app_id) const { AppIdPredicate finder(app_id); @@ -261,6 +269,13 @@ ApplicationSharedPtr ApplicationManagerImpl::application_by_policy_id( return FindApp(accessor, finder); } +ApplicationSharedPtr ApplicationManagerImpl::pending_application_by_policy_id( + const std::string& policy_app_id) const { + PolicyAppIdPredicate finder(policy_app_id); + DataAccessor accessor = pending_applications(); + return FindPendingApp(accessor, finder); +} + bool ActiveAppPredicate(const ApplicationSharedPtr app) { return app ? app->IsFullscreen() : false; } @@ -808,6 +823,60 @@ void ApplicationManagerImpl::OnHMIStartedCooperation() { RefreshCloudAppInformation(); } +std::string ApplicationManagerImpl::PolicyIDByIconUrl(const std::string url) { + sync_primitives::AutoLock lock(app_icon_map_lock_ptr_); + for (auto& x : app_icon_map_) { + auto policy_id = x.first; + std::string icon_url = GetPolicyHandler().GetIconUrl(policy_id); + if (icon_url == url) { + LOG4CXX_DEBUG(logger_, "Matched icon url: " << url); + x.second.pending_request = false; + return policy_id; + } + } + return std::string(""); +} + +void ApplicationManagerImpl::SetIconFileFromSystemRequest( + const std::string policy_id) { + app_icon_map_lock_ptr_.Acquire(); + auto app_icon_it = app_icon_map_.find(policy_id); + if (app_icon_it != app_icon_map_.end()) { + app_icon_map_.erase(app_icon_it); + } + app_icon_map_lock_ptr_.Release(); + + // Find pending application and set icon path + auto app = pending_application_by_policy_id(policy_id); + if (!app) { + return; + } + const std::string app_icon_dir(settings_.app_icons_folder()); + const std::string full_icon_path(app_icon_dir + "/" + policy_id); + if (file_system::FileExists(full_icon_path)) { + LOG4CXX_DEBUG(logger_, "Set Icon Path: " << full_icon_path); + AppFile file; + file.is_persistent = true; + file.is_download_complete = true; + file.file_name = full_icon_path; + + std::string icon_url = GetPolicyHandler().GetIconUrl(policy_id); + std::string extension = boost::filesystem::extension(icon_url); + if (extension == "bmp" || extension == "BMP") { + file.file_type = mobile_apis::FileType::GRAPHIC_BMP; + } else if (extension == "JPEG" || extension == "jpeg" || + extension == "JPG" || extension == "jpg") { + file.file_type = mobile_apis::FileType::GRAPHIC_JPEG; + } else { + file.file_type = mobile_apis::FileType::GRAPHIC_PNG; + } + + app->AddFile(file); + app->set_app_icon_path(full_icon_path); + } + SendUpdateAppList(); +} + void ApplicationManagerImpl::DisconnectCloudApp(ApplicationSharedPtr app) { std::string endpoint; std::string certificate; @@ -857,6 +926,7 @@ void ApplicationManagerImpl::RefreshCloudAppInformation() { // Store old device map and clear the current map pending_device_map_lock_ptr_->Acquire(); + app_icon_map_lock_ptr_.Acquire(); std::map old_device_map = pending_device_map_; pending_device_map_ = std::map(); // Create a device for each newly enabled cloud app @@ -868,9 +938,9 @@ void ApplicationManagerImpl::RefreshCloudAppInformation() { auth_token, cloud_transport_type, hybrid_app_preference); - + auto policy_id = *enabled_it; pending_device_map_.insert( - std::pair(endpoint, *enabled_it)); + std::pair(endpoint, policy_id)); // Determine which endpoints were disabled by erasing all enabled apps from // the old device list auto old_device_it = old_device_map.find(endpoint); @@ -880,8 +950,34 @@ void ApplicationManagerImpl::RefreshCloudAppInformation() { // If the device was disconnected, this will reinitialize the device connection_handler().AddCloudAppDevice( - *enabled_it, endpoint, cloud_transport_type); + policy_id, endpoint, cloud_transport_type); + + // Look for app icon url data and add to app_icon_url_map + std::string url = GetPolicyHandler().GetIconUrl(policy_id); + + if (url.empty()) { + LOG4CXX_DEBUG(logger_, "No Icon Url for cloud app"); + continue; + } + + auto app_icon_it = app_icon_map_.find(policy_id); + if (app_icon_it != app_icon_map_.end()) { + LOG4CXX_DEBUG(logger_, "Cloud App Already Exists in Icon Map"); + continue; + } + + const std::string app_icon_dir(settings_.app_icons_folder()); + const std::string full_icon_path(app_icon_dir + "/" + policy_id); + if (!file_system::FileExists(full_icon_path)) { + int icon_map_size = app_icon_map_.size(); + AppIconInfo icon_info(endpoint, false); + LOG4CXX_DEBUG(logger_, + "Inserting cloud app into icon map: " << icon_map_size); + app_icon_map_.insert( + std::pair(policy_id, icon_info)); + } } + app_icon_map_lock_ptr_.Release(); pending_device_map_lock_ptr_->Release(); int removed_app_count = 0; @@ -3660,7 +3756,15 @@ void ApplicationManagerImpl::OnPTUFinished(const bool ptu_result) { if (!ptu_result) { return; } + RefreshCloudAppInformation(); + + auto app_id = policy_handler_->GetAppIdForSending(); + auto app = application(app_id); + if (app) { + SendGetIconUrlNotifications(app->app_id(), app); + } + auto on_app_policy_updated = [](plugin_manager::RPCPlugin& plugin) { plugin.OnPolicyEvent(plugin_manager::kApplicationPolicyUpdated); }; @@ -3703,6 +3807,58 @@ void ApplicationManagerImpl::SendDriverDistractionState( } } +void ApplicationManagerImpl::SendGetIconUrlNotifications( + const uint32_t connection_key, ApplicationSharedPtr application) { + LOG4CXX_AUTO_TRACE(logger_); + std::vector enabled_apps; + GetPolicyHandler().GetEnabledCloudApps(enabled_apps); + std::vector::iterator enabled_it = enabled_apps.begin(); + std::vector::iterator enabled_end = enabled_apps.end(); + sync_primitives::AutoLock lock(app_icon_map_lock_ptr_); + for (; enabled_it != enabled_end; ++enabled_it) { + auto app_icon_it = app_icon_map_.find(*enabled_it); + if (app_icon_it == app_icon_map_.end()) { + LOG4CXX_WARN(logger_, "Could not find cloud app in icon map"); + continue; + } + + std::string endpoint = app_icon_it->second.endpoint; + bool pending_request = app_icon_it->second.pending_request; + + if (pending_request) { + LOG4CXX_DEBUG(logger_, "Cloud app has already sent request"); + continue; + } + + std::string url = GetPolicyHandler().GetIconUrl(*enabled_it); + + if (url.empty()) { + LOG4CXX_DEBUG(logger_, "No Icon Url for cloud app"); + continue; + } + + LOG4CXX_DEBUG(logger_, "Creating Get Icon Request"); + + smart_objects::SmartObjectSPtr message = + std::make_shared( + smart_objects::SmartType_Map); + (*message)[strings::params][strings::function_id] = + mobile_apis::FunctionID::OnSystemRequestID; + (*message)[strings::params][strings::connection_key] = connection_key; + (*message)[strings::params][strings::message_type] = + mobile_apis::messageType::notification; + (*message)[strings::params][strings::protocol_version] = + application->protocol_version(); + (*message)[strings::msg_params][strings::request_type] = + mobile_apis::RequestType::ICON_URL; + (*message)[strings::msg_params][strings::url] = url; + + app_icon_it->second.pending_request = true; + + rpc_service_->ManageMobileCommand(message, commands::Command::SOURCE_SDL); + } +} + protocol_handler::MajorProtocolVersion ApplicationManagerImpl::SupportedSDLVersion() const { LOG4CXX_AUTO_TRACE(logger_); diff --git a/src/components/application_manager/src/message_helper/message_helper.cc b/src/components/application_manager/src/message_helper/message_helper.cc index 58d5171f84..cc162b03ea 100644 --- a/src/components/application_manager/src/message_helper/message_helper.cc +++ b/src/components/application_manager/src/message_helper/message_helper.cc @@ -1547,6 +1547,7 @@ bool MessageHelper::CreateHMIApplicationStruct( message[hmi_response::policy_app_id] = policy_app_id; const std::string icon_path = app->app_icon_path(); + if (file_system::FileExists(app->app_icon_path())) { message[strings::icon] = icon_path; } diff --git a/src/components/application_manager/src/policies/policy_handler.cc b/src/components/application_manager/src/policies/policy_handler.cc index 02b848d9c6..05aa9154ea 100644 --- a/src/components/application_manager/src/policies/policy_handler.cc +++ b/src/components/application_manager/src/policies/policy_handler.cc @@ -91,7 +91,8 @@ RequestTypeMap TypeToString = { {mobile_apis::RequestType::EMERGENCY, "EMERGENCY"}, {mobile_apis::RequestType::MEDIA, "MEDIA"}, {mobile_apis::RequestType::FOTA, "FOTA"}, - {mobile_apis::RequestType::OEM_SPECIFIC, "OEM_SPECIFIC"}}; + {mobile_apis::RequestType::OEM_SPECIFIC, "OEM_SPECIFIC"}, + {mobile_apis::RequestType::ICON_URL, "ICON_URL"}}; const std::string RequestTypeToString(mobile_apis::RequestType::eType type) { RequestTypeMap::const_iterator it = TypeToString.find(type); @@ -1576,6 +1577,11 @@ std::string PolicyHandler::GetLockScreenIconUrl() const { return policy_manager_->GetLockScreenIconUrl(); } +std::string PolicyHandler::GetIconUrl(const std::string& policy_app_id) const { + POLICY_LIB_CHECK(std::string("")); + return policy_manager_->GetIconUrl(policy_app_id); +} + uint32_t PolicyHandler::NextRetryTimeout() { POLICY_LIB_CHECK(0); LOG4CXX_AUTO_TRACE(logger_); diff --git a/src/components/include/application_manager/application_manager.h b/src/components/include/application_manager/application_manager.h index f9b302be06..cfd6cbe61c 100644 --- a/src/components/include/application_manager/application_manager.h +++ b/src/components/include/application_manager/application_manager.h @@ -152,6 +152,8 @@ class ApplicationManager { connection_handler::ConnectionHandler* handler) = 0; virtual DataAccessor applications() const = 0; + virtual DataAccessor pending_applications() + const = 0; virtual ApplicationSharedPtr application(uint32_t app_id) const = 0; virtual ApplicationSharedPtr active_application() const = 0; @@ -167,6 +169,9 @@ class ApplicationManager { virtual ApplicationSharedPtr application_by_policy_id( const std::string& policy_app_id) const = 0; + virtual ApplicationSharedPtr pending_application_by_policy_id( + const std::string& policy_app_id) const = 0; + virtual AppSharedPtrs applications_by_button(uint32_t button) = 0; virtual AppSharedPtrs applications_with_navi() = 0; @@ -283,6 +288,9 @@ class ApplicationManager { */ virtual void SendDriverDistractionState(ApplicationSharedPtr application) = 0; + virtual void SendGetIconUrlNotifications( + const uint32_t connection_key, ApplicationSharedPtr application) = 0; + /** * @brief Checks if Application is subscribed for way points * @param Application pointer @@ -431,6 +439,10 @@ class ApplicationManager { virtual void RefreshCloudAppInformation() = 0; + virtual std::string PolicyIDByIconUrl(const std::string url) = 0; + + virtual void SetIconFileFromSystemRequest(const std::string policy_id) = 0; + /** * @brief Retrieve the current connection status of a cloud app * @param app A cloud application diff --git a/src/components/include/application_manager/policies/policy_handler_interface.h b/src/components/include/application_manager/policies/policy_handler_interface.h index 8c8a12ced3..c9feacabd4 100644 --- a/src/components/include/application_manager/policies/policy_handler_interface.h +++ b/src/components/include/application_manager/policies/policy_handler_interface.h @@ -105,6 +105,7 @@ class PolicyHandlerInterface { virtual void GetUpdateUrls(const uint32_t service_type, EndpointUrls& out_end_points) = 0; virtual std::string GetLockScreenIconUrl() const = 0; + virtual std::string GetIconUrl(const std::string& policy_app_id) const = 0; virtual uint32_t NextRetryTimeout() = 0; /** diff --git a/src/components/include/policy/policy_external/policy/policy_manager.h b/src/components/include/policy/policy_external/policy/policy_manager.h index 92c0305279..f342c2a07a 100644 --- a/src/components/include/policy/policy_external/policy/policy_manager.h +++ b/src/components/include/policy/policy_external/policy/policy_manager.h @@ -109,11 +109,20 @@ class PolicyManager : public usage_statistics::StatisticsManager { /** * @brief GetLockScreenIcon allows to obtain lock screen icon url; - * @return url which point to the resourse where lock screen icon could be + * @return url which point to the resource where lock screen icon could be *obtained. */ virtual std::string GetLockScreenIconUrl() const = 0; + /** + * @brief Get Icon Url used for showing a cloud apps icon before the initial + *registration + * + * @return url which point to the resource where icon could be + *obtained. + */ + virtual std::string GetIconUrl(const std::string& policy_app_id) const = 0; + /** * @brief PTU is needed, for this PTS has to be formed and sent. */ diff --git a/src/components/include/policy/policy_regular/policy/policy_manager.h b/src/components/include/policy/policy_regular/policy/policy_manager.h index b2d48585f4..6876611b3f 100644 --- a/src/components/include/policy/policy_regular/policy/policy_manager.h +++ b/src/components/include/policy/policy_regular/policy/policy_manager.h @@ -87,11 +87,20 @@ class PolicyManager : public usage_statistics::StatisticsManager { /** * @brief GetLockScreenIcon allows to obtain lock screen icon url; - * @return url which point to the resourse where lock screen icon could be + * @return url which point to the resource where lock screen icon could be *obtained. */ virtual std::string GetLockScreenIconUrl() const = 0; + /** + * @brief Get Icon Url used for showing a cloud apps icon before the initial + *registration + * + * @return url which point to the resource where icon could be + *obtained. + */ + virtual std::string GetIconUrl(const std::string& policy_app_id) const = 0; + /** * @brief Gets all URLs for sending PTS to from PT itself. * @param service_type Service specifies user of URL diff --git a/src/components/include/test/application_manager/mock_application_manager.h b/src/components/include/test/application_manager/mock_application_manager.h index ca03864dfa..7cae217371 100644 --- a/src/components/include/test/application_manager/mock_application_manager.h +++ b/src/components/include/test/application_manager/mock_application_manager.h @@ -74,6 +74,9 @@ class MockApplicationManager : public application_manager::ApplicationManager { void(connection_handler::ConnectionHandler* handler)); MOCK_CONST_METHOD0(applications, DataAccessor()); + MOCK_CONST_METHOD0( + pending_applications, + DataAccessor()); MOCK_CONST_METHOD1( application, application_manager::ApplicationSharedPtr(uint32_t app_id)); MOCK_CONST_METHOD0(active_application, @@ -97,6 +100,9 @@ class MockApplicationManager : public application_manager::ApplicationManager { MOCK_CONST_METHOD1(application_by_policy_id, application_manager::ApplicationSharedPtr( const std::string& policy_app_id)); + MOCK_CONST_METHOD1(pending_application_by_policy_id, + application_manager::ApplicationSharedPtr( + const std::string& policy_app_id)); MOCK_METHOD1( applications_by_button, std::vector(uint32_t button)); @@ -124,6 +130,9 @@ class MockApplicationManager : public application_manager::ApplicationManager { void(const std::shared_ptr app)); MOCK_METHOD1(SendDriverDistractionState, void(application_manager::ApplicationSharedPtr app)); + MOCK_METHOD2(SendGetIconUrlNotifications, + void(const uint32_t connection_key, + application_manager::ApplicationSharedPtr application)); MOCK_METHOD2(RemoveHMIFakeParameters, void(application_manager::commands::MessageSharedPtr& message, const hmi_apis::FunctionID::eType& function_id)); @@ -172,6 +181,8 @@ class MockApplicationManager : public application_manager::ApplicationManager { MOCK_CONST_METHOD1(GetCloudAppConnectionStatus, hmi_apis::Common_CloudConnectionStatus::eType( application_manager::ApplicationConstSharedPtr app)); + MOCK_METHOD1(PolicyIDByIconUrl, std::string(const std::string url)); + MOCK_METHOD1(SetIconFileFromSystemRequest, void(const std::string policy_id)); MOCK_CONST_METHOD0(IsHMICooperating, bool()); MOCK_METHOD2(IviInfoUpdated, void(mobile_apis::VehicleDataType::eType vehicle_info, diff --git a/src/components/include/test/application_manager/policies/mock_policy_handler_interface.h b/src/components/include/test/application_manager/policies/mock_policy_handler_interface.h index 02a0d73086..3d3fb31af7 100644 --- a/src/components/include/test/application_manager/policies/mock_policy_handler_interface.h +++ b/src/components/include/test/application_manager/policies/mock_policy_handler_interface.h @@ -102,6 +102,7 @@ class MockPolicyHandlerInterface : public policy::PolicyHandlerInterface { void(const uint32_t service_type, policy::EndpointUrls& end_points)); MOCK_CONST_METHOD0(GetLockScreenIconUrl, std::string()); + MOCK_CONST_METHOD1(GetIconUrl, std::string(const std::string& policy_app_id)); MOCK_METHOD0(ResetRetrySequence, void()); MOCK_METHOD0(NextRetryTimeout, uint32_t()); MOCK_CONST_METHOD0(TimeoutExchangeSec, uint32_t()); diff --git a/src/components/include/test/policy/policy_external/policy/mock_cache_manager.h b/src/components/include/test/policy/policy_external/policy/mock_cache_manager.h index da2b4cc2a1..82d4a866c4 100644 --- a/src/components/include/test/policy/policy_external/policy/mock_cache_manager.h +++ b/src/components/include/test/policy/policy_external/policy/mock_cache_manager.h @@ -119,6 +119,7 @@ class MockCacheManagerInterface : public ::policy::CacheManagerInterface { MOCK_METHOD2(GetUpdateUrls, void(const uint32_t service_type, EndpointUrls& out_end_points)); MOCK_CONST_METHOD0(GetLockScreenIconUrl, std::string()); + MOCK_CONST_METHOD1(GetIconUrl, std::string(const std::string& policy_app_id)); MOCK_METHOD1( GetNotificationsNumber, policy_table::NumberOfNotificationsType(const std::string& priority)); diff --git a/src/components/include/test/policy/policy_external/policy/mock_policy_manager.h b/src/components/include/test/policy/policy_external/policy/mock_policy_manager.h index 72dcb147e3..9fe96e1544 100644 --- a/src/components/include/test/policy/policy_external/policy/mock_policy_manager.h +++ b/src/components/include/test/policy/policy_external/policy/mock_policy_manager.h @@ -180,6 +180,7 @@ class MockPolicyManager : public PolicyManager { MOCK_METHOD1(OnAppRegisteredOnMobile, void(const std::string& application_id)); MOCK_CONST_METHOD0(GetLockScreenIconUrl, std::string()); + MOCK_CONST_METHOD1(GetIconUrl, std::string(const std::string& policy_app_id)); MOCK_CONST_METHOD1( GetAppRequestTypes, const std::vector(const std::string policy_app_id)); diff --git a/src/components/include/test/policy/policy_regular/policy/mock_cache_manager.h b/src/components/include/test/policy/policy_regular/policy/mock_cache_manager.h index 24fe9b2393..e7c9502db9 100644 --- a/src/components/include/test/policy/policy_regular/policy/mock_cache_manager.h +++ b/src/components/include/test/policy/policy_regular/policy/mock_cache_manager.h @@ -103,6 +103,7 @@ class MockCacheManagerInterface : public CacheManagerInterface { MOCK_METHOD2(GetUpdateUrls, void(const uint32_t service_type, EndpointUrls& out_end_points)); MOCK_CONST_METHOD0(GetLockScreenIconUrl, std::string()); + MOCK_CONST_METHOD1(GetIconUrl, std::string(const std::string& policy_app_id)); MOCK_METHOD2(Init, bool(const std::string& file_name, const PolicySettings* settings)); diff --git a/src/components/include/test/policy/policy_regular/policy/mock_policy_manager.h b/src/components/include/test/policy/policy_regular/policy/mock_policy_manager.h index a5ce488e1a..7283397187 100644 --- a/src/components/include/test/policy/policy_regular/policy/mock_policy_manager.h +++ b/src/components/include/test/policy/policy_regular/policy/mock_policy_manager.h @@ -226,6 +226,7 @@ class MockPolicyManager : public PolicyManager { MOCK_CONST_METHOD0(get_settings, const PolicySettings&()); MOCK_METHOD1(set_settings, void(const PolicySettings* get_settings)); MOCK_CONST_METHOD0(GetLockScreenIconUrl, std::string()); + MOCK_CONST_METHOD1(GetIconUrl, std::string(const std::string& policy_app_id)); MOCK_METHOD1(GetNextUpdateUrl, AppIdURL(const EndpointUrls& urls)); MOCK_CONST_METHOD2(RetrySequenceUrl, AppIdURL(const struct RetrySequenceURL&, diff --git a/src/components/interfaces/HMI_API.xml b/src/components/interfaces/HMI_API.xml index 24b1858d3b..b056ae3910 100644 --- a/src/components/interfaces/HMI_API.xml +++ b/src/components/interfaces/HMI_API.xml @@ -1271,6 +1271,7 @@ + diff --git a/src/components/interfaces/MOBILE_API.xml b/src/components/interfaces/MOBILE_API.xml index 714399bce6..66f5a19208 100644 --- a/src/components/interfaces/MOBILE_API.xml +++ b/src/components/interfaces/MOBILE_API.xml @@ -2419,6 +2419,7 @@ + diff --git a/src/components/policy/policy_external/include/policy/cache_manager.h b/src/components/policy/policy_external/include/policy/cache_manager.h index 3344b149e4..90783b7a46 100644 --- a/src/components/policy/policy_external/include/policy/cache_manager.h +++ b/src/components/policy/policy_external/include/policy/cache_manager.h @@ -261,6 +261,15 @@ class CacheManager : public CacheManagerInterface { */ virtual std::string GetLockScreenIconUrl() const; + /** + * @brief Get Icon Url used for showing a cloud apps icon before the intial + *registration + * + * @return url which point to the resourse where icon could be + *obtained. + */ + virtual std::string GetIconUrl(const std::string& policy_app_id) const; + /** * @brief Gets list of URL to send PTS to * @param service_type If URLs for specific service are preset, diff --git a/src/components/policy/policy_external/include/policy/cache_manager_interface.h b/src/components/policy/policy_external/include/policy/cache_manager_interface.h index 6a172e6f4b..58baf5ce99 100644 --- a/src/components/policy/policy_external/include/policy/cache_manager_interface.h +++ b/src/components/policy/policy_external/include/policy/cache_manager_interface.h @@ -279,6 +279,15 @@ class CacheManagerInterface { */ virtual std::string GetLockScreenIconUrl() const = 0; + /** + * @brief Get Icon Url used for showing a cloud apps icon before the intial + *registration + * + * @return url which point to the resourse where icon could be + *obtained. + */ + virtual std::string GetIconUrl(const std::string& policy_app_id) const = 0; + /** * @brief Get allowed number of notifications * depending on application priority. diff --git a/src/components/policy/policy_external/include/policy/policy_manager_impl.h b/src/components/policy/policy_external/include/policy/policy_manager_impl.h index 2802af1706..caa1b0dc95 100644 --- a/src/components/policy/policy_external/include/policy/policy_manager_impl.h +++ b/src/components/policy/policy_external/include/policy/policy_manager_impl.h @@ -208,6 +208,15 @@ class PolicyManagerImpl : public PolicyManager { */ std::string GetLockScreenIconUrl() const OVERRIDE; + /** + * @brief Get Icon Url used for showing a cloud apps icon before the intial + *registration + * + * @return url which point to the resourse where icon could be + *obtained. + */ + std::string GetIconUrl(const std::string& policy_app_id) const OVERRIDE; + /** * @brief Handler of PTS sending out */ diff --git a/src/components/policy/policy_external/include/policy/policy_table/enums.h b/src/components/policy/policy_external/include/policy/policy_table/enums.h index 5b494629bb..2477d7eb04 100644 --- a/src/components/policy/policy_external/include/policy/policy_table/enums.h +++ b/src/components/policy/policy_external/include/policy/policy_table/enums.h @@ -154,6 +154,7 @@ enum RequestType { RT_MEDIA, RT_FOTA, RT_OEM_SPECIFIC, + RT_ICON_URL, RT_EMPTY // Added to allow empty Request Types handling }; diff --git a/src/components/policy/policy_external/include/policy/policy_table/types.h b/src/components/policy/policy_external/include/policy/policy_table/types.h index f37531eb63..e844381707 100644 --- a/src/components/policy/policy_external/include/policy/policy_table/types.h +++ b/src/components/policy/policy_external/include/policy/policy_table/types.h @@ -184,6 +184,7 @@ struct ApplicationParams : PolicyBase { Optional enabled; Optional > auth_token; Optional > cloud_transport_type; + Optional > icon_url; public: ApplicationParams(); diff --git a/src/components/policy/policy_external/include/policy/policy_table_interface_ext.xml b/src/components/policy/policy_external/include/policy/policy_table_interface_ext.xml index 5ed852cf45..f90edca8aa 100644 --- a/src/components/policy/policy_external/include/policy/policy_table_interface_ext.xml +++ b/src/components/policy/policy_external/include/policy/policy_table_interface_ext.xml @@ -108,6 +108,8 @@ + policy_table.app_policies_section.apps; + policy_table::ApplicationPolicies::const_iterator policy_iter = + policies.find(policy_app_id); + if (policies.end() != policy_iter) { + auto app_policy = (*policy_iter).second; + url = app_policy.icon_url.is_initialized() ? *app_policy.icon_url + : std::string(); + } + return url; +} + rpc::policy_table_interface_base::NumberOfNotificationsType CacheManager::GetNotificationsNumber(const std::string& priority) { CACHE_MANAGER_CHECK(0); diff --git a/src/components/policy/policy_external/src/policy_manager_impl.cc b/src/components/policy/policy_external/src/policy_manager_impl.cc index bd7746d720..23101438cb 100644 --- a/src/components/policy/policy_external/src/policy_manager_impl.cc +++ b/src/components/policy/policy_external/src/policy_manager_impl.cc @@ -271,6 +271,11 @@ std::string PolicyManagerImpl::GetLockScreenIconUrl() const { return cache_->GetLockScreenIconUrl(); } +std::string PolicyManagerImpl::GetIconUrl( + const std::string& policy_app_id) const { + return cache_->GetIconUrl(policy_app_id); +} + /** * @brief FilterInvalidFunctions filter functions that are absent in schema * @param rpcs list of functions to filter diff --git a/src/components/policy/policy_external/src/policy_table/enums.cc b/src/components/policy/policy_external/src/policy_table/enums.cc index d7d5a241de..9cc838bd82 100644 --- a/src/components/policy/policy_external/src/policy_table/enums.cc +++ b/src/components/policy/policy_external/src/policy_table/enums.cc @@ -629,6 +629,8 @@ bool IsValidEnum(RequestType val) { return true; case RT_OEM_SPECIFIC: return true; + case RT_ICON_URL: + return true; case RT_EMPTY: return true; default: @@ -680,6 +682,8 @@ const char* EnumToJsonString(RequestType val) { return "FOTA"; case RT_OEM_SPECIFIC: return "OEM_SPECIFIC"; + case RT_ICON_URL: + return "ICON_URL"; case RT_EMPTY: return "EMPTY"; default: @@ -772,6 +776,10 @@ bool EnumFromJsonString(const std::string& literal, RequestType* result) { *result = RT_OEM_SPECIFIC; return true; } + if ("ICON_URL" == literal) { + *result = RT_ICON_URL; + return true; + } if ("EMPTY" == literal) { *result = RT_EMPTY; return true; diff --git a/src/components/policy/policy_external/src/policy_table/types.cc b/src/components/policy/policy_external/src/policy_table/types.cc index 0fe54a683d..12de0cc62b 100644 --- a/src/components/policy/policy_external/src/policy_table/types.cc +++ b/src/components/policy/policy_external/src/policy_table/types.cc @@ -247,8 +247,8 @@ ApplicationParams::ApplicationParams(const Json::Value* value__) , endpoint(impl::ValueMember(value__, "endpoint")) , enabled(impl::ValueMember(value__, "enabled")) , auth_token(impl::ValueMember(value__, "auth_token")) - , cloud_transport_type(impl::ValueMember(value__, "cloud_transport_type")) { -} + , cloud_transport_type(impl::ValueMember(value__, "cloud_transport_type")) + , icon_url(impl::ValueMember(value__, "icon_url")) {} Json::Value ApplicationParams::ToJsonValue() const { Json::Value result__(PolicyBase::ToJsonValue()); @@ -267,6 +267,7 @@ Json::Value ApplicationParams::ToJsonValue() const { impl::WriteJsonField("enabled", enabled, &result__); impl::WriteJsonField("auth_token", auth_token, &result__); impl::WriteJsonField("cloud_transport_type", cloud_transport_type, &result__); + impl::WriteJsonField("icon_url", auth_token, &result__); return result__; } @@ -309,6 +310,9 @@ bool ApplicationParams::is_valid() const { if (!hybrid_app_preference.is_valid()) { return false; } + if (!icon_url.is_valid()) { + return false; + } return Validate(); } @@ -359,6 +363,9 @@ bool ApplicationParams::struct_empty() const { if (hybrid_app_preference.is_initialized()) { return false; } + if (icon_url.is_initialized()) { + return false; + } return true; } @@ -426,6 +433,9 @@ void ApplicationParams::ReportErrors(rpc::ValidationReport* report__) const { moduleType.ReportErrors( &report__->ReportSubobject("hybrid_app_preference")); } + if (!icon_url.is_valid()) { + moduleType.ReportErrors(&report__->ReportSubobject("icon_url")); + } } void ApplicationParams::SetPolicyTableType(PolicyTableType pt_type) { @@ -441,6 +451,7 @@ void ApplicationParams::SetPolicyTableType(PolicyTableType pt_type) { enabled.SetPolicyTableType(pt_type); cloud_transport_type.SetPolicyTableType(pt_type); hybrid_app_preference.SetPolicyTableType(pt_type); + icon_url.SetPolicyTableType(pt_type); } // RpcParameters methods diff --git a/src/components/policy/policy_external/src/sql_pt_ext_queries.cc b/src/components/policy/policy_external/src/sql_pt_ext_queries.cc index 32320b6d6c..58206e2c69 100644 --- a/src/components/policy/policy_external/src/sql_pt_ext_queries.cc +++ b/src/components/policy/policy_external/src/sql_pt_ext_queries.cc @@ -207,8 +207,8 @@ const std::string kInsertApplication = " `default_hmi`, `priority_value`, `is_revoked`, `memory_kb`, " " `heart_beat_timeout_ms`, `certificate`, `hybrid_app_preference_value`, " " `endpoint`, `enabled`, `auth_token`, " - " `cloud_transport_type`) VALUES " - "(?,?,?,?,?,?,?,?,?,?,?,?,?,?)"; + " `cloud_transport_type`, `icon_url`) VALUES " + "(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)"; const std::string kCollectFriendlyMsg = "SELECT * FROM `message`"; @@ -237,7 +237,7 @@ const std::string kSelectAppPolicies = "SELECT `id`, `priority_value`, `default_hmi`, `keep_context`, " " `steal_focus`, `memory_kb`, `heart_beat_timeout_ms`, `certificate`, " " `hybrid_app_preference_value`, `endpoint`, `enabled`, `auth_token` " - " `cloud_transport_type` FROM `application`"; + " `cloud_transport_type`, `icon_url` FROM `application`"; const std::string kSelectFunctionalGroupNames = "SELECT `id`, `user_consent_prompt`, `name`" diff --git a/src/components/policy/policy_external/src/sql_pt_ext_representation.cc b/src/components/policy/policy_external/src/sql_pt_ext_representation.cc index 43961815d6..c0214f087f 100644 --- a/src/components/policy/policy_external/src/sql_pt_ext_representation.cc +++ b/src/components/policy/policy_external/src/sql_pt_ext_representation.cc @@ -771,6 +771,9 @@ bool SQLPTExtRepresentation::SaveSpecificAppPolicy( app.second.cloud_transport_type.is_initialized() ? app_query.Bind(13, *app.second.cloud_transport_type) : app_query.Bind(13); + app.second.icon_url.is_initialized() + ? app_query.Bind(14, *app.second.icon_url) + : app_query.Bind(14); if (!app_query.Exec() || !app_query.Reset()) { LOG4CXX_WARN(logger_, "Incorrect insert into application."); @@ -908,6 +911,7 @@ bool SQLPTExtRepresentation::GatherApplicationPoliciesSection( } *params.auth_token = query.GetString(11); *params.cloud_transport_type = query.GetString(12); + *params.icon_url = query.GetString(13); const auto& gather_app_id = ((*policies).apps[app_id].is_string()) ? (*policies).apps[app_id].get_string() diff --git a/src/components/policy/policy_external/src/sql_pt_queries.cc b/src/components/policy/policy_external/src/sql_pt_queries.cc index 162d6957e7..66f7ef65be 100644 --- a/src/components/policy/policy_external/src/sql_pt_queries.cc +++ b/src/components/policy/policy_external/src/sql_pt_queries.cc @@ -156,6 +156,7 @@ const std::string kCreateSchema = " `enabled` BOOLEAN, " " `auth_token` VARCHAR(65535), " " `cloud_transport_type` VARCHAR(255), " + " `icon_url` VARCHAR(65535), " " `remote_control_denied` BOOLEAN NOT NULL DEFAULT 0, " " CONSTRAINT `fk_application_hmi_level1` " " FOREIGN KEY(`default_hmi`) " @@ -649,8 +650,8 @@ const std::string kInsertApplication = "INSERT OR IGNORE INTO `application` (`id`, `priority_value`, " "`is_revoked`, `memory_kb`, `heart_beat_timeout_ms`, `certificate`, " "`hybrid_app_preference_value`, `endpoint`, `enabled`, `auth_token`, " - "`cloud_transport_type`) VALUES " - "(?,?,?,?,?,?,?,?,?,?,?)"; + "`cloud_transport_type`, `icon_url`) VALUES " + "(?,?,?,?,?,?,?,?,?,?,?,?)"; const std::string kInsertAppGroup = "INSERT INTO `app_group` (`application_id`, `functional_group_id`)" @@ -774,7 +775,8 @@ const std::string kSelectUserMsgsVersion = const std::string kSelectAppPolicies = "SELECT `id`, `priority_value`, `memory_kb`, " " `heart_beat_timeout_ms`, `certificate`, `hybrid_app_preference_value`, " - " `endpoint`, `enabled`, `auth_token`, `cloud_transport_type` FROM " + " `endpoint`, `enabled`, `auth_token`, `cloud_transport_type`, `icon_url` " + "FROM " " `application`"; const std::string kCollectFriendlyMsg = "SELECT * FROM `message`"; @@ -875,14 +877,14 @@ const std::string kInsertApplicationFull = " `default_hmi`, `priority_value`, `is_revoked`, `is_default`, " " `is_predata`, `memory_kb`, `heart_beat_timeout_ms`, " " `certificate`, `hybrid_app_preference_value`, `endpoint`, `enabled`, " - " `auth_token`, `cloud_transport_type`) " - " VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"; + " `auth_token`, `cloud_transport_type`, `icon_url`) " + " VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"; const std::string kSelectApplicationFull = "SELECT `keep_context`, `steal_focus`, `default_hmi`, `priority_value`, " " `is_revoked`, `is_default`, `is_predata`, `memory_kb`," " `heart_beat_timeout_ms`, `certificate`, `hybrid_app_preference_value`, " - " `endpoint`, `enabled`, `auth_token`, `cloud_transport_type` " + " `endpoint`, `enabled`, `auth_token`, `cloud_transport_type`, `icon_url` " "FROM `application` " "WHERE `id` = ?"; diff --git a/src/components/policy/policy_external/src/sql_pt_representation.cc b/src/components/policy/policy_external/src/sql_pt_representation.cc index b794d4c3a6..885a59ba36 100644 --- a/src/components/policy/policy_external/src/sql_pt_representation.cc +++ b/src/components/policy/policy_external/src/sql_pt_representation.cc @@ -777,6 +777,7 @@ bool SQLPTRepresentation::GatherApplicationPoliciesSection( } *params.auth_token = query.GetString(8); *params.cloud_transport_type = query.GetString(9); + *params.icon_url = query.GetString(10); const auto& gather_app_id = ((*policies).apps[app_id].is_string()) ? (*policies).apps[app_id].get_string() @@ -1070,6 +1071,9 @@ bool SQLPTRepresentation::SaveSpecificAppPolicy( app.second.cloud_transport_type.is_initialized() ? app_query.Bind(10, *app.second.cloud_transport_type) : app_query.Bind(10); + app.second.icon_url.is_initialized() + ? app_query.Bind(11, *app.second.icon_url) + : app_query.Bind(11); if (!app_query.Exec() || !app_query.Reset()) { LOG4CXX_WARN(logger_, "Incorrect insert into application."); @@ -2172,6 +2176,8 @@ bool SQLPTRepresentation::CopyApplication(const std::string& source, : query.Bind(14, source_app.GetString(13)); source_app.IsNull(14) ? query.Bind(15) : query.Bind(15, source_app.GetString(14)); + source_app.IsNull(15) ? query.Bind(16) + : query.Bind(16, source_app.GetString(15)); if (!query.Exec()) { LOG4CXX_WARN(logger_, "Failed inserting into application."); diff --git a/src/components/policy/policy_regular/include/policy/cache_manager.h b/src/components/policy/policy_regular/include/policy/cache_manager.h index 8c8f0c55c6..d23145994a 100644 --- a/src/components/policy/policy_regular/include/policy/cache_manager.h +++ b/src/components/policy/policy_regular/include/policy/cache_manager.h @@ -255,6 +255,15 @@ class CacheManager : public CacheManagerInterface { */ virtual std::string GetLockScreenIconUrl() const; + /** + * @brief Get Icon Url used for showing a cloud apps icon before the intial + *registration + * + * @return url which point to the resourse where icon could be + *obtained. + */ + virtual std::string GetIconUrl(const std::string& policy_app_id) const; + /** * @brief Get allowed number of notifications * depending on application priority. diff --git a/src/components/policy/policy_regular/include/policy/cache_manager_interface.h b/src/components/policy/policy_regular/include/policy/cache_manager_interface.h index 50b546ecc5..ea59a4ef62 100644 --- a/src/components/policy/policy_regular/include/policy/cache_manager_interface.h +++ b/src/components/policy/policy_regular/include/policy/cache_manager_interface.h @@ -263,6 +263,15 @@ class CacheManagerInterface { */ virtual std::string GetLockScreenIconUrl() const = 0; + /** + * @brief Get Icon Url used for showing a cloud apps icon before the intial + *registration + * + * @return url which point to the resourse where icon could be + *obtained. + */ + virtual std::string GetIconUrl(const std::string& policy_app_id) const = 0; + /** * @brief Get allowed number of notifications * depending on application priority. diff --git a/src/components/policy/policy_regular/include/policy/policy_manager_impl.h b/src/components/policy/policy_regular/include/policy/policy_manager_impl.h index fea8bbe0b3..779bea729d 100644 --- a/src/components/policy/policy_regular/include/policy/policy_manager_impl.h +++ b/src/components/policy/policy_regular/include/policy/policy_manager_impl.h @@ -116,6 +116,15 @@ class PolicyManagerImpl : public PolicyManager { */ std::string GetLockScreenIconUrl() const OVERRIDE; + /** + * @brief Get Icon Url used for showing a cloud apps icon before the intial + *registration + * + * @return url which point to the resourse where icon could be + *obtained. + */ + std::string GetIconUrl(const std::string& policy_app_id) const OVERRIDE; + /** * @brief PTU is needed, for this PTS has to be formed and sent. */ diff --git a/src/components/policy/policy_regular/include/policy/policy_table/types.h b/src/components/policy/policy_regular/include/policy/policy_table/types.h index 18f909bb99..63058dee26 100644 --- a/src/components/policy/policy_regular/include/policy/policy_table/types.h +++ b/src/components/policy/policy_regular/include/policy/policy_table/types.h @@ -150,6 +150,7 @@ struct ApplicationParams : PolicyBase { Optional enabled; Optional > auth_token; Optional > cloud_transport_type; + Optional > icon_url; public: ApplicationParams(); diff --git a/src/components/policy/policy_regular/src/cache_manager.cc b/src/components/policy/policy_regular/src/cache_manager.cc index ca61a338f1..677ea66454 100644 --- a/src/components/policy/policy_regular/src/cache_manager.cc +++ b/src/components/policy/policy_regular/src/cache_manager.cc @@ -892,6 +892,21 @@ std::string CacheManager::GetLockScreenIconUrl() const { return std::string(""); } +std::string CacheManager::GetIconUrl(const std::string& policy_app_id) const { + CACHE_MANAGER_CHECK(std::string()); + std::string url; + const policy_table::ApplicationPolicies& policies = + pt_->policy_table.app_policies_section.apps; + policy_table::ApplicationPolicies::const_iterator policy_iter = + policies.find(policy_app_id); + if (policies.end() != policy_iter) { + auto app_policy = (*policy_iter).second; + url = app_policy.icon_url.is_initialized() ? *app_policy.icon_url + : std::string(); + } + return url; +} + rpc::policy_table_interface_base::NumberOfNotificationsType CacheManager::GetNotificationsNumber(const std::string& priority) { CACHE_MANAGER_CHECK(0); diff --git a/src/components/policy/policy_regular/src/policy_manager_impl.cc b/src/components/policy/policy_regular/src/policy_manager_impl.cc index a7e206b51b..b09478bba1 100644 --- a/src/components/policy/policy_regular/src/policy_manager_impl.cc +++ b/src/components/policy/policy_regular/src/policy_manager_impl.cc @@ -449,6 +449,11 @@ std::string PolicyManagerImpl::GetLockScreenIconUrl() const { return cache_->GetLockScreenIconUrl(); } +std::string PolicyManagerImpl::GetIconUrl( + const std::string& policy_app_id) const { + return cache_->GetIconUrl(policy_app_id); +} + void PolicyManagerImpl::StartPTExchange() { LOG4CXX_AUTO_TRACE(logger_); diff --git a/src/components/policy/policy_regular/src/policy_table/types.cc b/src/components/policy/policy_regular/src/policy_table/types.cc index 5faf96a232..2ee8bf1b21 100644 --- a/src/components/policy/policy_regular/src/policy_table/types.cc +++ b/src/components/policy/policy_regular/src/policy_table/types.cc @@ -173,8 +173,8 @@ ApplicationParams::ApplicationParams(const Json::Value* value__) , endpoint(impl::ValueMember(value__, "endpoint")) , enabled(impl::ValueMember(value__, "enabled")) , auth_token(impl::ValueMember(value__, "auth_token")) - , cloud_transport_type(impl::ValueMember(value__, "cloud_transport_type")) { -} + , cloud_transport_type(impl::ValueMember(value__, "cloud_transport_type")) + , icon_url(impl::ValueMember(value__, "icon_url")) {} Json::Value ApplicationParams::ToJsonValue() const { Json::Value result__(PolicyBase::ToJsonValue()); @@ -194,6 +194,7 @@ Json::Value ApplicationParams::ToJsonValue() const { impl::WriteJsonField("enabled", enabled, &result__); impl::WriteJsonField("auth_token", auth_token, &result__); impl::WriteJsonField("cloud_transport_type", cloud_transport_type, &result__); + impl::WriteJsonField("icon_url", auth_token, &result__); return result__; } @@ -240,6 +241,9 @@ bool ApplicationParams::is_valid() const { if (!hybrid_app_preference.is_valid()) { return false; } + if (!icon_url.is_valid()) { + return false; + } return Validate(); } @@ -293,6 +297,9 @@ bool ApplicationParams::struct_empty() const { if (hybrid_app_preference.is_initialized()) { return false; } + if (icon_url.is_initialized()) { + return false; + } return true; } @@ -347,6 +354,9 @@ void ApplicationParams::ReportErrors(rpc::ValidationReport* report__) const { moduleType.ReportErrors( &report__->ReportSubobject("hybrid_app_preference")); } + if (!icon_url.is_valid()) { + moduleType.ReportErrors(&report__->ReportSubobject("icon_url")); + } } void ApplicationParams::SetPolicyTableType(PolicyTableType pt_type) { @@ -363,6 +373,7 @@ void ApplicationParams::SetPolicyTableType(PolicyTableType pt_type) { enabled.SetPolicyTableType(pt_type); cloud_transport_type.SetPolicyTableType(pt_type); hybrid_app_preference.SetPolicyTableType(pt_type); + icon_url.SetPolicyTableType(pt_type); } // RpcParameters methods diff --git a/src/components/policy/policy_regular/src/sql_pt_queries.cc b/src/components/policy/policy_regular/src/sql_pt_queries.cc index 297031d4c0..8d2576866b 100644 --- a/src/components/policy/policy_regular/src/sql_pt_queries.cc +++ b/src/components/policy/policy_regular/src/sql_pt_queries.cc @@ -142,6 +142,7 @@ const std::string kCreateSchema = " `enabled` BOOLEAN, " " `auth_token` VARCHAR(65535), " " `cloud_transport_type` VARCHAR(255), " + " `icon_url` VARCHAR(65535), " " `remote_control_denied` BOOLEAN NOT NULL DEFAULT 0, " " CONSTRAINT `fk_application_hmi_level1` " " FOREIGN KEY(`default_hmi`) " @@ -598,8 +599,8 @@ const std::string kInsertApplication = "INSERT OR IGNORE INTO `application` (`id`, `priority_value`, " "`is_revoked`, `memory_kb`, `heart_beat_timeout_ms`, `certificate`, " "`hybrid_app_preference_value`, `endpoint`, `enabled`, `auth_token`, " - "`cloud_transport_type`) VALUES " - "(?,?,?,?,?,?,?,?,?,?,?)"; + "`cloud_transport_type`, `icon_url`) VALUES " + "(?,?,?,?,?,?,?,?,?,?,?,?)"; const std::string kInsertAppGroup = "INSERT INTO `app_group` (`application_id`, `functional_group_id`)" @@ -709,7 +710,8 @@ const std::string kSelectUserMsgsVersion = const std::string kSelectAppPolicies = "SELECT `id`, `priority_value`, `memory_kb`, " " `heart_beat_timeout_ms`, `certificate`, `hybrid_app_preference_value`, " - " `endpoint`, `enabled`, `auth_token`, `cloud_transport_type` FROM " + " `endpoint`, `enabled`, `auth_token`, `cloud_transport_type`, `icon_url` " + "FROM " " `application`"; const std::string kCollectFriendlyMsg = "SELECT * FROM `message`"; @@ -810,14 +812,14 @@ const std::string kInsertApplicationFull = " `default_hmi`, `priority_value`, `is_revoked`, `is_default`, " " `is_predata`, `memory_kb`, `heart_beat_timeout_ms`, " " `certificate`, `hybrid_app_preference_value`, `endpoint`, `enabled`, " - " `auth_token`, `cloud_transport_type`) " - " VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"; + " `auth_token`, `cloud_transport_type`, `icon_url`) " + " VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"; const std::string kSelectApplicationFull = "SELECT `keep_context`, `steal_focus`, `default_hmi`, `priority_value`, " " `is_revoked`, `is_default`, `is_predata`, `memory_kb`," " `heart_beat_timeout_ms`, `certificate`, `hybrid_app_preference_value`, " - " `endpoint`, `enabled`, `auth_token`, `cloud_transport_type` " + " `endpoint`, `enabled`, `auth_token`, `cloud_transport_type`, `icon_url` " "FROM `application` " "WHERE `id` = " "?"; diff --git a/src/components/policy/policy_regular/src/sql_pt_representation.cc b/src/components/policy/policy_regular/src/sql_pt_representation.cc index 9282caf535..49aeec2642 100644 --- a/src/components/policy/policy_regular/src/sql_pt_representation.cc +++ b/src/components/policy/policy_regular/src/sql_pt_representation.cc @@ -733,6 +733,7 @@ bool SQLPTRepresentation::GatherApplicationPoliciesSection( } *params.auth_token = query.GetString(8); *params.cloud_transport_type = query.GetString(9); + *params.icon_url = query.GetString(10); const auto& gather_app_id = ((*policies).apps[app_id].is_string()) ? (*policies).apps[app_id].get_string() @@ -1011,6 +1012,9 @@ bool SQLPTRepresentation::SaveSpecificAppPolicy( app.second.cloud_transport_type.is_initialized() ? app_query.Bind(10, *app.second.cloud_transport_type) : app_query.Bind(10); + app.second.icon_url.is_initialized() + ? app_query.Bind(11, *app.second.icon_url) + : app_query.Bind(11); if (!app_query.Exec() || !app_query.Reset()) { LOG4CXX_WARN(logger_, "Incorrect insert into application."); @@ -2122,6 +2126,8 @@ bool SQLPTRepresentation::CopyApplication(const std::string& source, : query.Bind(14, source_app.GetString(13)); source_app.IsNull(14) ? query.Bind(15) : query.Bind(15, source_app.GetString(14)); + source_app.IsNull(15) ? query.Bind(16) + : query.Bind(16, source_app.GetString(15)); if (!query.Exec()) { LOG4CXX_WARN(logger_, "Failed inserting into application."); diff --git a/src/components/transport_manager/src/cloud/cloud_websocket_transport_adapter.cc b/src/components/transport_manager/src/cloud/cloud_websocket_transport_adapter.cc index 9f2b8e6ade..a41c4ea30f 100644 --- a/src/components/transport_manager/src/cloud/cloud_websocket_transport_adapter.cc +++ b/src/components/transport_manager/src/cloud/cloud_websocket_transport_adapter.cc @@ -87,7 +87,8 @@ void CloudWebsocketTransportAdapter::CreateDevice(const std::string& uid) { // Extract host and port from endpoint string boost::regex group_pattern( - "(wss?:\\/\\/)([A-Z\\d\\.-]{2,}\\.?([A-Z]{2,})?)(:)(\\d{2,4})(\\/)"); + "(wss?:\\/\\/)([A-Z\\d\\.-]{2,}\\.?([A-Z]{2,})?)(:)(\\d{2,4})(\\/" + ")(((([A-Z\\d\\.-]{1,})(\\/)?){1,})?){1,}"); boost::smatch results; std::string host = ""; -- cgit v1.2.1