summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnatoly Leshin <ALeshin@luxoft.com>2015-12-17 21:05:06 +0400
committerAnatoliy-Leshin <aleshin@luxoft.com>2016-01-21 18:01:52 +0200
commit53ef50032cae973caa9f9fa672eaaf1f697ba551 (patch)
tree2f579b8e67e4a00e4a578a21f3e373db6d743b9d
parentae477d681c400f3c233a87b83f7431cf46cf8639 (diff)
downloadsdl_core-53ef50032cae973caa9f9fa672eaaf1f697ba551.tar.gz
Process EndServiceAck from mobile;
Add EndServiceAck message processing on protocol_handler level. PH notify connection_handler, CH notify application_manager. On AM level SDL turns off video/audio service for application. Fix: APPLINK-19170, APPLINK-19923
-rw-r--r--src/components/application_manager/src/application_manager_impl.cc9
-rw-r--r--src/components/include/protocol_handler/session_observer.h2
-rw-r--r--src/components/protocol_handler/include/protocol_handler/protocol_handler_impl.h5
-rw-r--r--src/components/protocol_handler/src/protocol_handler_impl.cc46
4 files changed, 52 insertions, 10 deletions
diff --git a/src/components/application_manager/src/application_manager_impl.cc b/src/components/application_manager/src/application_manager_impl.cc
index 26350a012a..f63c82c8f1 100644
--- a/src/components/application_manager/src/application_manager_impl.cc
+++ b/src/components/application_manager/src/application_manager_impl.cc
@@ -2767,7 +2767,8 @@ bool ApplicationManagerImpl::CanAppStream(
} else {
LOG4CXX_WARN(logger_, "Unsupported service_type " << service_type);
}
- return HMILevelAllowsStreaming(app_id, service_type) && is_allowed;
+
+ return HMILevelAllowsStreaming(app_id, service_type) && is_allowed;
}
void ApplicationManagerImpl::ForbidStreaming(uint32_t app_id) {
@@ -2840,17 +2841,18 @@ void ApplicationManagerImpl::EndNaviServices(uint32_t app_id) {
return;
}
+
if (connection_handler_) {
if (it->second.first) {
LOG4CXX_DEBUG(logger_, "Going to end video service");
connection_handler_->SendEndService(app_id, ServiceType::kMobileNav);
- StopNaviService(app_id, ServiceType::kMobileNav);
}
if (it->second.second) {
LOG4CXX_DEBUG(logger_, "Going to end audio service");
connection_handler_->SendEndService(app_id, ServiceType::kAudio);
- StopNaviService(app_id, ServiceType::kAudio);
}
+ DisallowStreaming(app_id);
+
navi_app_to_stop_.push_back(app_id);
ApplicationManagerTimerPtr closeTimer(
@@ -2968,6 +2970,7 @@ void ApplicationManagerImpl::CloseNaviApp() {
NaviServiceStatusMap::iterator it = navi_service_status_.find(app_id);
if (navi_service_status_.end() != it) {
if (it->second.first || it->second.second) {
+ LOG4CXX_INFO(logger_, "App haven't answered for EndService. Unregister it.");
MessageHelper::SendOnAppInterfaceUnregisteredNotificationToMobile(
app_id, PROTOCOL_VIOLATION);
UnregisterApplication(app_id, ABORTED);
diff --git a/src/components/include/protocol_handler/session_observer.h b/src/components/include/protocol_handler/session_observer.h
index ed341b3926..cea1dfbb41 100644
--- a/src/components/include/protocol_handler/session_observer.h
+++ b/src/components/include/protocol_handler/session_observer.h
@@ -53,6 +53,7 @@ enum {
HASH_ID_NOT_SUPPORTED = 0,
HASH_ID_WRONG = 0xFFFF0000
};
+
/**
* \class SessionObserver
* \brief Interface for making a bridge between ProtocolHandler and
@@ -79,6 +80,7 @@ class SessionObserver {
const uint8_t sessionId,
const protocol_handler::ServiceType &service_type,
const bool is_protected, uint32_t* hash_id) = 0;
+
/**
* \brief Callback function used by ProtocolHandler
* when Mobile Application initiates session ending.
diff --git a/src/components/protocol_handler/include/protocol_handler/protocol_handler_impl.h b/src/components/protocol_handler/include/protocol_handler/protocol_handler_impl.h
index fb10811f14..3e1a1d8ad3 100644
--- a/src/components/protocol_handler/include/protocol_handler/protocol_handler_impl.h
+++ b/src/components/protocol_handler/include/protocol_handler/protocol_handler_impl.h
@@ -430,11 +430,12 @@ class ProtocolHandlerImpl
* \param packet Received message with protocol header.
* \return \saRESULT_CODE Status of operation
*/
- RESULT_CODE HandleControlMessage(
- const ProtocolFramePtr packet);
+ RESULT_CODE HandleControlMessage(const ProtocolFramePtr packet);
RESULT_CODE HandleControlMessageEndSession(const ProtocolPacket &packet);
+ RESULT_CODE HandleControlMessageEndServiceACK(const ProtocolPacket &packet);
+
RESULT_CODE HandleControlMessageStartSession(const ProtocolPacket &packet);
RESULT_CODE HandleControlMessageHeartBeat(const ProtocolPacket &packet);
diff --git a/src/components/protocol_handler/src/protocol_handler_impl.cc b/src/components/protocol_handler/src/protocol_handler_impl.cc
index 792cbefa16..0019d05830 100644
--- a/src/components/protocol_handler/src/protocol_handler_impl.cc
+++ b/src/components/protocol_handler/src/protocol_handler_impl.cc
@@ -804,18 +804,28 @@ RESULT_CODE ProtocolHandlerImpl::HandleControlMessage(const ProtocolFramePtr pac
return RESULT_FAIL;
}
+ // TODO{ALeshin}: Rename "Session" to "Service" on PH, CH, AM levels
switch (packet->frame_data()) {
- case FRAME_DATA_START_SERVICE:
+ case FRAME_DATA_START_SERVICE: {
+ LOG4CXX_TRACE(logger_, "FrameData: StartService");
return HandleControlMessageStartSession(*packet);
- case FRAME_DATA_END_SERVICE:
+ }
+ case FRAME_DATA_END_SERVICE: {
+ LOG4CXX_TRACE(logger_, "FrameData: StopService");
return HandleControlMessageEndSession(*packet);
+ }
+ case FRAME_DATA_END_SERVICE_ACK: {
+ LOG4CXX_TRACE(logger_, "FrameData: StopService ACK");
+ return HandleControlMessageEndServiceACK(*packet);
+ }
case FRAME_DATA_HEART_BEAT: {
- LOG4CXX_TRACE(logger_, "FRAME_DATA_HEART_BEAT");
+ LOG4CXX_TRACE(logger_, "FrameData: Heartbeat");
return HandleControlMessageHeartBeat(*packet);
}
case FRAME_DATA_HEART_BEAT_ACK: {
- LOG4CXX_DEBUG(logger_, "Received heart beat ack from mobile app"
- " for connection " << packet->connection_id());
+ LOG4CXX_TRACE(logger_, "FrameData Heartbeat ACK");
+ LOG4CXX_DEBUG(logger_, "Received Heartbeat ACK from mobile,"
+ " connection: " << packet->connection_id());
return RESULT_OK;
}
default:
@@ -867,6 +877,31 @@ RESULT_CODE ProtocolHandlerImpl::HandleControlMessageEndSession(const ProtocolPa
}
return RESULT_OK;
}
+
+RESULT_CODE ProtocolHandlerImpl::HandleControlMessageEndServiceACK(const ProtocolPacket &packet) {
+ LOG4CXX_AUTO_TRACE(logger_);
+
+ if (!session_observer_) {
+ LOG4CXX_ERROR(logger_, "No ISessionObserver set.");
+ return RESULT_FAIL;
+ }
+
+ const uint8_t current_session_id = packet.session_id();
+ const uint32_t hash_id = get_hash_id(packet);
+ const ServiceType service_type = ServiceTypeFromByte(packet.service_type());
+ const ConnectionID connection_id = packet.connection_id();
+
+ const uint32_t session_key = session_observer_->OnSessionEndedCallback(
+ connection_id, current_session_id, hash_id, service_type);
+
+ if (session_key == 0) {
+ LOG4CXX_WARN(logger_, "Refused to end service");
+ return RESULT_FAIL;
+ }
+
+ return RESULT_OK;
+}
+
#ifdef ENABLE_SECURITY
namespace {
/**
@@ -946,6 +981,7 @@ class StartSessionHandler : public security_manager::SecurityManagerListener {
#endif // ENABLE_SECURITY
RESULT_CODE ProtocolHandlerImpl::HandleControlMessageStartSession(const ProtocolPacket &packet) {
+ LOG4CXX_AUTO_TRACE(logger_);
LOG4CXX_DEBUG(logger_,
"Protocol version:" <<
static_cast<int>(packet.protocol_version()));