diff options
author | Andrey Oleynik <AOleynik@luxoft.com> | 2015-02-10 10:10:10 +0200 |
---|---|---|
committer | Aleksandr Galiuzov <AGaliuzov@luxoft.com> | 2015-02-23 13:58:19 +0200 |
commit | 72bce95737b9086f6d7b880227aeed434a16f9f2 (patch) | |
tree | 663aa6ecab5c6c864021bb595881fd67b9e140c2 /src | |
parent | 5f3a297c1d4022bf622f905ed86ad9b1f668d345 (diff) | |
download | sdl_core-72bce95737b9086f6d7b880227aeed434a16f9f2.tar.gz |
APPLINK-11206. Fixed sending OnSystemRequest for second SDL4 app.
Diffstat (limited to 'src')
6 files changed, 54 insertions, 105 deletions
diff --git a/src/components/application_manager/include/application_manager/application.h b/src/components/application_manager/include/application_manager/application.h index 9ce94734bc..8a90e44516 100644 --- a/src/components/application_manager/include/application_manager/application.h +++ b/src/components/application_manager/include/application_manager/application.h @@ -369,7 +369,6 @@ class Application : public virtual InitialApplicationData, public: Application() : - connection_id_(-1), is_greyed_out_(false) { } @@ -612,19 +611,6 @@ class Application : public virtual InitialApplicationData, std::string GetDeviceId() const {return device_id_;} /** - * @brief Returns connection id used by application - */ - ssize_t connection_id() const {return connection_id_;} - - /** - * @brief Set connection id used by application - * @param connection_id Connection id - */ - void set_connection_id(const ssize_t connection_id) { - connection_id_ = connection_id; - } - - /** * @brief Returns is application should be greyed out on HMI */ bool is_greyed_out() const {return is_greyed_out_;} 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 11008b4966..e105382764 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 @@ -917,22 +917,22 @@ class ApplicationManagerImpl : public ApplicationManager, } }; - struct ConnectionIdSDL4Predicate { - ssize_t connection_id_; - ConnectionIdSDL4Predicate(const ssize_t connection_id): - connection_id_(connection_id) {} + struct AppV4DevicePredicate { + connection_handler::DeviceHandle handle_; + AppV4DevicePredicate(const connection_handler::DeviceHandle handle): + handle_(handle) {} bool operator () (const ApplicationSharedPtr app) const { - return app ? connection_id_ == app->connection_id() && + return app ? handle_ == app->device() && ProtocolVersion::kV4 == app->protocol_version() : false; } }; - struct ConnectionIdPredicate { - ssize_t connection_id_; - ConnectionIdPredicate(const ssize_t connection_id): - connection_id_(connection_id) {} + struct DevicePredicate { + connection_handler::DeviceHandle handle_; + DevicePredicate(const connection_handler::DeviceHandle handle): + handle_(handle) {} bool operator () (const ApplicationSharedPtr app) const { - return connection_id_ == app->connection_id() ? true : false; + return handle_ == app->device() ? true : false; } }; @@ -954,18 +954,17 @@ class ApplicationManagerImpl : public ApplicationManager, * @brief Marks applications received through QueryApps as should be * greyed out on HMI * @param is_greyed_out, true, if should be greyed out, otherwise - false - * @param connection_id, ID of connection, related to applications source + * @param handle, device handle */ - void MarkAppsGreyOut(const ssize_t connection_id, bool is_greyed_out); - - bool IsAppsQueriedFrom(ssize_t connection_id) const; + void MarkAppsGreyOut(const connection_handler::DeviceHandle handle, + bool is_greyed_out); /** - * @brief Gets connection id for certain connection key - * @param connection_key Connection key - * @return Connection identified + * @brief Checks, if apps list had been queried already from certain device + * @param handle, Device handle + * @return true, if list had been queried already, otherwise - false */ - const ssize_t get_connection_id(uint32_t connection_key) const; + bool IsAppsQueriedFrom(const connection_handler::DeviceHandle handle) const; /** * @brief Checks, if icons saving to configured folder is enabled @@ -1191,10 +1190,12 @@ private: bool IsReadWriteAllowed(const std::string& path, DirectoryType type) const; /** - * @brief Removes apps, waiting for registration, with certain connection id - * @param connection_id Connection id + * @brief Removes apps, waiting for registration related to + * certain device handle + * @param handle, Device handle */ - void RemoveWaitingApps(const ssize_t connection_id); + void RemoveAppsWaitingForRegistration( + const connection_handler::DeviceHandle handle); private: diff --git a/src/components/application_manager/include/application_manager/commands/hmi/sdl_activate_app_request.h b/src/components/application_manager/include/application_manager/commands/hmi/sdl_activate_app_request.h index 41ff095879..85eafc4b95 100644 --- a/src/components/application_manager/include/application_manager/commands/hmi/sdl_activate_app_request.h +++ b/src/components/application_manager/include/application_manager/commands/hmi/sdl_activate_app_request.h @@ -77,8 +77,8 @@ class SDLActivateAppRequest : public RequestFromHMI { private: uint32_t app_id() const; uint32_t hmi_app_id(const smart_objects::SmartObject& so) const; - ApplicationSharedPtr FindRegularAppOnSameConnection( - int32_t connection_id); + ApplicationSharedPtr FindRegularAppOnSameDevice( + const connection_handler::DeviceHandle handle) const; DISALLOW_COPY_AND_ASSIGN(SDLActivateAppRequest); }; diff --git a/src/components/application_manager/src/application_manager_impl.cc b/src/components/application_manager/src/application_manager_impl.cc index e6251d37cb..fe269c4f12 100644 --- a/src/components/application_manager/src/application_manager_impl.cc +++ b/src/components/application_manager/src/application_manager_impl.cc @@ -391,18 +391,8 @@ ApplicationSharedPtr ApplicationManagerImpl::RegisterApplication( const std::string& app_name = message[strings::msg_params][strings::app_name].asString(); - ssize_t connection_id = get_connection_id(connection_key); - if (-1 == connection_id) { - LOG4CXX_ERROR(logger_, "Can't get connection id for application:" - << app_id); - utils::SharedPtr<smart_objects::SmartObject> response( - MessageHelper::CreateNegativeResponse( - connection_key, mobile_apis::FunctionID::RegisterAppInterfaceID, - message[strings::params][strings::correlation_id].asUInt(), - mobile_apis::Result::GENERIC_ERROR)); - ManageMobileCommand(response); - return ApplicationSharedPtr(); - } + LOG4CXX_DEBUG(logger_, "App with connection key: " << connection_key + << " registered from handle: " << device_id); ApplicationSharedPtr application( new ApplicationImpl(app_id, @@ -423,7 +413,6 @@ ApplicationSharedPtr ApplicationManagerImpl::RegisterApplication( return ApplicationSharedPtr(); } - application->set_connection_id(connection_id); application->set_device(device_id); application->set_grammar_id(GenerateGrammarID()); mobile_api::Language::eType launguage_desired = @@ -791,12 +780,13 @@ ApplicationManagerImpl::apps_waiting_for_registration() const { ApplicationManagerImpl::instance()->apps_to_register_list_lock_); } -bool ApplicationManagerImpl::IsAppsQueriedFrom(ssize_t connection_id) const { +bool ApplicationManagerImpl::IsAppsQueriedFrom( + const connection_handler::DeviceHandle handle) const { sync_primitives::AutoLock lock(apps_to_register_list_lock_); AppsWaitRegistrationSet::iterator it = apps_to_register_.begin(); AppsWaitRegistrationSet::const_iterator it_end = apps_to_register_.end(); for (; it != it_end; ++it) { - if (connection_id == (*it)->connection_id()) { + if (handle == (*it)->device()) { return true; } } @@ -804,13 +794,13 @@ bool ApplicationManagerImpl::IsAppsQueriedFrom(ssize_t connection_id) const { } void application_manager::ApplicationManagerImpl::MarkAppsGreyOut( - const ssize_t connection_id, + const connection_handler::DeviceHandle handle, bool is_greyed_out) { sync_primitives::AutoLock lock(apps_to_register_list_lock_); AppsWaitRegistrationSet::iterator it = apps_to_register_.begin(); AppsWaitRegistrationSet::const_iterator it_end = apps_to_register_.end(); for (; it != it_end; ++it) { - if (connection_id == (*it)->connection_id()) { + if (handle == (*it)->device()) { (*it)->set_greyed_out(is_greyed_out); } } @@ -1949,13 +1939,6 @@ void ApplicationManagerImpl::CreateApplications(SmartArray& obj_array, const std::string app_icon_dir(Profile::instance()->app_icons_folder()); const std::string full_icon_path(app_icon_dir + "/" + mobile_app_id); - ssize_t connection_id = get_connection_id(connection_key); - if (-1 == connection_id) { - LOG4CXX_ERROR(logger_, "Error during getting connection id for " - "application: " << mobile_app_id); - continue; - } - uint32_t device_id = 0; connection_handler::ConnectionHandlerImpl* con_handler_impl = static_cast<connection_handler::ConnectionHandlerImpl*>( @@ -1977,7 +1960,6 @@ void ApplicationManagerImpl::CreateApplications(SmartArray& obj_array, app->SetShemaUrl(url_scheme); app->SetPackageName(package_name); app->set_app_icon_path(full_icon_path); - app->set_connection_id(connection_id); app->set_hmi_application_id(hmi_app_id); app->set_device(device_id); app->set_app_types(app_data[os_type][json::appHmiType]); @@ -2178,12 +2160,13 @@ void ApplicationManagerImpl::UnregisterAllApplications() { request_ctrl_.terminateAllHMIRequests(); } -void ApplicationManagerImpl::RemoveWaitingApps(const ssize_t connection_id) { - ConnectionIdPredicate conn_finder(connection_id); +void ApplicationManagerImpl::RemoveAppsWaitingForRegistration( + const connection_handler::DeviceHandle handle) { + DevicePredicate device_finder(handle); apps_to_register_list_lock_.Acquire(); AppsWaitRegistrationSet::iterator it_app = std::find_if(apps_to_register_.begin(), apps_to_register_.end(), - conn_finder); + device_finder); while (apps_to_register_.end()!= it_app) { LOG4CXX_DEBUG(logger_, "Waiting app: " << (*it_app)->name() @@ -2191,7 +2174,7 @@ void ApplicationManagerImpl::RemoveWaitingApps(const ssize_t connection_id) { apps_to_register_.erase(it_app); it_app = std::find_if(apps_to_register_.begin(), apps_to_register_.end(), - conn_finder); + device_finder); } apps_to_register_list_lock_.Release(); @@ -2230,14 +2213,14 @@ void ApplicationManagerImpl::UnregisterApplication( } ApplicationSharedPtr app_to_remove; - ssize_t connection_id = -1; + connection_handler::DeviceHandle handle = 0; { ApplicationListAccessor accessor; ApplictionSetConstIt it = accessor.begin(); for (; it != accessor.end(); ++it) { if ((*it)->app_id() == app_id) { app_to_remove = *it; - connection_id = app_to_remove->connection_id(); + handle = app_to_remove->device(); break; } } @@ -2247,13 +2230,13 @@ void ApplicationManagerImpl::UnregisterApplication( } accessor.Erase(app_to_remove); - ConnectionIdSDL4Predicate finder(connection_id); + AppV4DevicePredicate finder(handle); ApplicationSharedPtr app = accessor.Find(finder); if (!app) { - LOG4CXX_DEBUG(logger_, "There is no more SDL4 apps with connection id: " - << connection_id); + LOG4CXX_DEBUG(logger_, "There is no more SDL4 apps with device handle: " + << handle); - RemoveWaitingApps(connection_id); + RemoveAppsWaitingForRegistration(handle); SendUpdateAppList(); } } @@ -3103,22 +3086,6 @@ bool ApplicationManagerImpl::IsReadWriteAllowed( return true; } -const ssize_t ApplicationManagerImpl::get_connection_id( - uint32_t connection_key) const { - if (connection_handler_) { - connection_handler::ConnectionHandlerImpl* con_handler_impl = - static_cast<connection_handler::ConnectionHandlerImpl*>( - connection_handler_); - - uint32_t connection_id = 0; - uint8_t session_id = 0; - con_handler_impl->PairFromKey(connection_key, &connection_id, &session_id); - return static_cast<int32_t>(connection_id); - } - - return -1; -} - bool ApplicationManagerImpl::IsIconsSavingEnabled() const { return is_icons_saving_enabled_; } diff --git a/src/components/application_manager/src/commands/hmi/sdl_activate_app_request.cc b/src/components/application_manager/src/commands/hmi/sdl_activate_app_request.cc index 8c069e1f79..38bdbc3d54 100644 --- a/src/components/application_manager/src/commands/hmi/sdl_activate_app_request.cc +++ b/src/components/application_manager/src/commands/hmi/sdl_activate_app_request.cc @@ -69,10 +69,10 @@ void SDLActivateAppRequest::Run() { if (!app->IsRegistered()) { ApplicationSharedPtr app_for_sending = - FindRegularAppOnSameConnection(app->connection_id()); + FindRegularAppOnSameDevice(app->device()); if (!app_for_sending) { LOG4CXX_ERROR(logger_, "Can't find regular app with the same " - "connection id:" << app->connection_id()); + "connection id:" << app->device()); return; } MessageHelper::SendLaunchApp(app_for_sending->app_id(), @@ -144,7 +144,8 @@ uint32_t SDLActivateAppRequest::hmi_app_id( } ApplicationSharedPtr -SDLActivateAppRequest::FindRegularAppOnSameConnection(int32_t connection_id) { +SDLActivateAppRequest::FindRegularAppOnSameDevice( + const connection_handler::DeviceHandle handle) const { ApplicationManagerImpl::ApplicationListAccessor accessor; ApplicationManagerImpl::ApplictionSet app_list = accessor.GetData(); @@ -152,7 +153,7 @@ SDLActivateAppRequest::FindRegularAppOnSameConnection(int32_t connection_id) { ApplicationManagerImpl::ApplictionSetIt it_end = app_list.end(); for (;it != it_end; ++it) { - if (connection_id == (*it)->connection_id()) { + if (handle == (*it)->device()) { return *it; } } diff --git a/src/components/application_manager/src/commands/mobile/on_hmi_status_notification_from_mobile.cc b/src/components/application_manager/src/commands/mobile/on_hmi_status_notification_from_mobile.cc index 4332dc353c..02b4b64aa0 100644 --- a/src/components/application_manager/src/commands/mobile/on_hmi_status_notification_from_mobile.cc +++ b/src/components/application_manager/src/commands/mobile/on_hmi_status_notification_from_mobile.cc @@ -70,19 +70,13 @@ void OnHMIStatusNotificationFromMobile::Run() { app->set_foreground(is_current_state_foreground); - ssize_t connection_id = - application_manager::ApplicationManagerImpl::instance()-> - get_connection_id(connection_key()); - - if (-1 == connection_id) { - LOG4CXX_ERROR(logger_, "Can't get connection id for application:" - << app->mobile_app_id()); - return; - } - + connection_handler::DeviceHandle handle = app->device(); bool is_apps_requested_before = application_manager::ApplicationManagerImpl::instance()-> - IsAppsQueriedFrom(connection_id); + IsAppsQueriedFrom(handle); + + LOG4CXX_DEBUG(logger_, "Mobile HMI state notication came for connection key:" + << connection_key() << " and handle: " << handle); if (!is_apps_requested_before && ProtocolVersion::kV4 == app->protocol_version() && app->is_foreground()) { @@ -95,7 +89,7 @@ void OnHMIStatusNotificationFromMobile::Run() { if (is_apps_requested_before) { LOG4CXX_DEBUG(logger_, "Remote apps list had been requested already " - " for connection id: " << connection_id); + " for handle: " << handle); if (ProtocolVersion::kV4 == app->protocol_version()) { ApplicationManagerImpl::ApplicationListAccessor accessor; @@ -113,7 +107,7 @@ void OnHMIStatusNotificationFromMobile::Run() { if (!is_another_foreground_sdl4_app) { application_manager::ApplicationManagerImpl::instance()-> - MarkAppsGreyOut(connection_id, !is_current_state_foreground); + MarkAppsGreyOut(handle, !is_current_state_foreground); application_manager::ApplicationManagerImpl::instance()-> SendUpdateAppList(); } |