@@ -1790,23 +1790,6 @@ bool ApplicationManagerImpl::StartNaviService(
17901790 LOG4CXX_AUTO_TRACE (logger_);
17911791
17921792 if (HMILevelAllowsStreaming (app_id, service_type)) {
1793- {
1794- sync_primitives::AutoLock lock (navi_service_status_lock_);
1795-
1796- NaviServiceStatusMap::iterator it = navi_service_status_.find (app_id);
1797- if (navi_service_status_.end () == it) {
1798- std::pair<NaviServiceStatusMap::iterator, bool > res =
1799- navi_service_status_.insert (
1800- std::pair<uint32_t , std::pair<bool , bool > >(
1801- app_id, std::make_pair (false , false )));
1802- if (!res.second ) {
1803- LOG4CXX_WARN (logger_, " Navi service refused" );
1804- return false ;
1805- }
1806- it = res.first ;
1807- }
1808- }
1809-
18101793 if (service_type == ServiceType::kMobileNav ) {
18111794 smart_objects::SmartObject converted_params (smart_objects::SmartType_Map);
18121795 ConvertVideoParamsToSO (converted_params, params);
@@ -1866,17 +1849,11 @@ void ApplicationManagerImpl::OnStreamingConfigured(
18661849 sync_primitives::AutoLock lock (navi_service_status_lock_);
18671850
18681851 NaviServiceStatusMap::iterator it = navi_service_status_.find (app_id);
1869- if (navi_service_status_.end () == it) {
1852+ if (navi_service_status_.end () == it && !result ) {
18701853 LOG4CXX_WARN (logger_, " Application not found in navi status map" );
18711854 connection_handler ().NotifyServiceStartedResult (app_id, false , empty);
18721855 return ;
18731856 }
1874-
1875- // Fill NaviServices map. Set true to first value of pair if
1876- // we've started video service or to second value if we've
1877- // started audio service
1878- service_type == ServiceType::kMobileNav ? it->second .first = true
1879- : it->second .second = true ;
18801857 }
18811858
18821859 application (app_id)->StartStreaming (service_type);
@@ -1889,33 +1866,70 @@ void ApplicationManagerImpl::OnStreamingConfigured(
18891866 }
18901867}
18911868
1892- void ApplicationManagerImpl::StopNaviService (
1893- uint32_t app_id, protocol_handler::ServiceType service_type) {
1869+ bool ApplicationManagerImpl::SetNaviServiceStatus (
1870+ uint32_t connection_key,
1871+ protocol_handler::ServiceType service_type,
1872+ bool is_started) {
18941873 using namespace protocol_handler ;
18951874 LOG4CXX_AUTO_TRACE (logger_);
18961875
1876+ auto app = application (connection_key);
1877+ if (!app) {
1878+ LOG4CXX_DEBUG (
1879+ logger_,
1880+ " Application with app_id: " << connection_key << " is not found" );
1881+ return false ;
1882+ }
1883+
18971884 {
18981885 sync_primitives::AutoLock lock (navi_service_status_lock_);
18991886
1900- NaviServiceStatusMap::iterator it = navi_service_status_.find (app_id);
1901- if (navi_service_status_.end () == it) {
1902- LOG4CXX_WARN (logger_,
1903- " No Information about navi service " << service_type);
1887+ NaviServiceStatusMap::iterator it =
1888+ navi_service_status_.find (app->app_id ());
1889+ if (navi_service_status_.end () == it && (is_started)) {
1890+ std::pair<NaviServiceStatusMap::iterator, bool > res =
1891+ navi_service_status_.insert (
1892+ std::pair<uint32_t , std::pair<bool , bool > >(
1893+ app->app_id (), std::make_pair (false , false )));
1894+ if (!res.second ) {
1895+ LOG4CXX_WARN (logger_, " Navi service refused" );
1896+ return false ;
1897+ }
1898+ it = res.first ;
19041899 } else {
1905- // Fill NaviServices map. Set false to first value of pair if
1906- // we've stopped video service or to second value if we've
1907- // stopped audio service
1908- service_type == ServiceType::kMobileNav ? it->second .first = false
1909- : it->second .second = false ;
1900+ LOG4CXX_DEBUG (logger_,
1901+ " Application with app_id: "
1902+ << app->app_id () << " is not found in navi status map" );
1903+ return false ;
19101904 }
1905+
1906+ service_type == ServiceType::kMobileNav ? it->second .first = is_started
1907+ : it->second .second = is_started;
1908+ LOG4CXX_DEBUG (logger_,
1909+ " ServiceType: " << service_type << " is started: "
1910+ << std::boolalpha << is_started);
1911+ return true ;
19111912 }
1913+ }
1914+
1915+ void ApplicationManagerImpl::StopNaviService (
1916+ uint32_t app_id, protocol_handler::ServiceType service_type) {
1917+ using namespace protocol_handler ;
1918+ LOG4CXX_AUTO_TRACE (logger_);
19121919
19131920 ApplicationSharedPtr app = application (app_id);
19141921 if (!app) {
19151922 LOG4CXX_WARN (logger_, " An application is not registered." );
19161923 return ;
19171924 }
19181925
1926+ if (!SetNaviServiceStatus (app->app_id (), service_type, false )) {
1927+ LOG4CXX_DEBUG (logger_,
1928+ " Application with app_id: "
1929+ << app->app_id () << " not found in navi status map" );
1930+ return ;
1931+ }
1932+
19191933 app->StopStreaming (service_type);
19201934}
19211935
@@ -2038,7 +2052,7 @@ void ApplicationManagerImpl::OnServiceEndedCallback(
20382052
20392053 if (Compare<ServiceType, EQ, ONE>(
20402054 type, ServiceType::kMobileNav , ServiceType::kAudio )) {
2041- StopNaviService (session_key, type);
2055+ StopNaviService (static_cast < uint32_t >( session_key) , type);
20422056 }
20432057}
20442058
@@ -2068,6 +2082,18 @@ void ApplicationManagerImpl::ProcessServiceStatusUpdate(
20682082 service_type, service_event, reason, app_id);
20692083
20702084 rpc_service_->ManageHMICommand (notification);
2085+
2086+ if (hmi_apis::Common_ServiceEvent::REQUEST_REJECTED == service_event) {
2087+ if (!app) {
2088+ LOG4CXX_DEBUG (logger_,
2089+ " Application with app_id: " << app_id << " is absent" );
2090+ return ;
2091+ }
2092+ state_ctrl_.SetRegularState (app,
2093+ mobile_apis::PredefinedWindows::DEFAULT_WINDOW,
2094+ mobile_apis::HMILevel::HMI_NONE,
2095+ true );
2096+ }
20712097}
20722098
20732099void ApplicationManagerImpl::OnSecondaryTransportStartedCallback (
@@ -3350,6 +3376,8 @@ void ApplicationManagerImpl::EndNaviServices(uint32_t app_id) {
33503376 LOG4CXX_ERROR (logger_, " No info about navi servicies for app" );
33513377 return ;
33523378 }
3379+ LOG4CXX_DEBUG (logger_, " VEDIO_KEK: " << it->second .first );
3380+ LOG4CXX_DEBUG (logger_, " AUDIO_KEK: " << it->second .second );
33533381 end_video = it->second .first ;
33543382 end_audio = it->second .second ;
33553383 }
0 commit comments