summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaksym Ked <mked@luxoft.com>2019-06-07 13:56:16 +0300
committermked-luxoft <mked@luxoft.com>2019-08-29 17:56:41 +0300
commit8e009255bb5914de1b56c5cb2fb1f85bfc667588 (patch)
tree1b5fb440644841b15d45f1919d923a2066b0ddf0
parent237d8f377fc4ea6bfe6621c89ea42a9b3e8dcaa7 (diff)
downloadsdl_core-8e009255bb5914de1b56c5cb2fb1f85bfc667588.tar.gz
Updates according to proposal changes
Added new result codes for ServiceStatusUpdateReasonStructure
-rw-r--r--src/components/interfaces/HMI_API.xml6
-rw-r--r--src/components/protocol_handler/include/protocol_handler/service_status_update_handler.h4
-rw-r--r--src/components/protocol_handler/src/handshake_handler.cc2
-rw-r--r--src/components/protocol_handler/src/protocol_handler_impl.cc2
-rw-r--r--src/components/protocol_handler/src/service_status_update_handler.cc19
-rw-r--r--src/components/protocol_handler/test/service_status_update_handler_test.cc32
6 files changed, 60 insertions, 5 deletions
diff --git a/src/components/interfaces/HMI_API.xml b/src/components/interfaces/HMI_API.xml
index 717ddb04f3..ff4947e7a8 100644
--- a/src/components/interfaces/HMI_API.xml
+++ b/src/components/interfaces/HMI_API.xml
@@ -3585,6 +3585,12 @@
<element name="INVALID_TIME" >
<description>When a Service is rejected because the system was unable to get a valid SystemTime from HMI, which is required for certificate authentication.</description>
</element>
+ <element name="PROTECTION_ENFORCED" >
+ <description>When a Service is rejected because the system configuration ini file requires the service must be protected, but the app asks for an unprotected service.</description>
+ </element>
+ <element name="PROTECTION_DISABLED" >
+ <description>When a mobile app requests a protected service, but the system starts an unprotected service instead.</description>
+ </element>
</enum>
<!-- App Services -->
diff --git a/src/components/protocol_handler/include/protocol_handler/service_status_update_handler.h b/src/components/protocol_handler/include/protocol_handler/service_status_update_handler.h
index 125f3b2909..cbe374d515 100644
--- a/src/components/protocol_handler/include/protocol_handler/service_status_update_handler.h
+++ b/src/components/protocol_handler/include/protocol_handler/service_status_update_handler.h
@@ -49,7 +49,9 @@ enum class ServiceStatus {
SERVICE_START_FAILED,
PTU_FAILED,
CERT_INVALID,
- INVALID_TIME
+ INVALID_TIME,
+ PROTECTION_ENFORCED,
+ PROTECTION_DISABLED
};
/**
diff --git a/src/components/protocol_handler/src/handshake_handler.cc b/src/components/protocol_handler/src/handshake_handler.cc
index 405715fe1b..669b73c18b 100644
--- a/src/components/protocol_handler/src/handshake_handler.cc
+++ b/src/components/protocol_handler/src/handshake_handler.cc
@@ -225,7 +225,7 @@ void HandshakeHandler::ProcessFailedHandshake(BsonObject& params,
service_status_update_handler_.OnServiceUpdate(
this->connection_key(),
context_.service_type_,
- ServiceStatus::SERVICE_ACCEPTED);
+ ServiceStatus::PROTECTION_DISABLED);
protocol_handler_.SendStartSessionAck(context_.connection_id_,
context_.new_session_id_,
protocol_version_,
diff --git a/src/components/protocol_handler/src/protocol_handler_impl.cc b/src/components/protocol_handler/src/protocol_handler_impl.cc
index c2423b2fb6..ec4b96e385 100644
--- a/src/components/protocol_handler/src/protocol_handler_impl.cc
+++ b/src/components/protocol_handler/src/protocol_handler_impl.cc
@@ -1672,7 +1672,7 @@ RESULT_CODE ProtocolHandlerImpl::HandleControlMessageStartSession(
<< service_type << ", over transport: " << transport
<< ", disallowed by settings.");
service_status_update_handler_->OnServiceUpdate(
- connection_key, service_type, ServiceStatus::SERVICE_START_FAILED);
+ connection_key, service_type, ServiceStatus::PROTECTION_ENFORCED);
SendStartSessionNAck(
connection_id, session_id, protocol_version, service_type);
return RESULT_OK;
diff --git a/src/components/protocol_handler/src/service_status_update_handler.cc b/src/components/protocol_handler/src/service_status_update_handler.cc
index e81f59677d..9bef1b973f 100644
--- a/src/components/protocol_handler/src/service_status_update_handler.cc
+++ b/src/components/protocol_handler/src/service_status_update_handler.cc
@@ -30,6 +30,7 @@ void ServiceStatusUpdateHandler::OnServiceUpdate(
using namespace hmi_apis;
typedef utils::Optional<Common_ServiceStatusUpdateReason::eType>
UpdateReasonOptional;
+ LOG4CXX_AUTO_TRACE(logger_);
auto hmi_service_type = GetHMIServiceType(service_type);
switch (service_status) {
@@ -78,6 +79,24 @@ void ServiceStatusUpdateHandler::OnServiceUpdate(
Common_ServiceEvent::REQUEST_REJECTED,
update_reason);
}
+ case ServiceStatus::PROTECTION_ENFORCED: {
+ auto update_reason =
+ Common_ServiceStatusUpdateReason::PROTECTION_ENFORCED;
+ return listener_->ProcessServiceStatusUpdate(
+ connection_key,
+ hmi_service_type,
+ Common_ServiceEvent::REQUEST_REJECTED,
+ update_reason);
+ }
+ case ServiceStatus::PROTECTION_DISABLED: {
+ auto update_reason =
+ Common_ServiceStatusUpdateReason::PROTECTION_DISABLED;
+ return listener_->ProcessServiceStatusUpdate(
+ connection_key,
+ hmi_service_type,
+ Common_ServiceEvent::REQUEST_ACCEPTED,
+ update_reason);
+ }
default: {
LOG4CXX_WARN(logger_,
"Received unknown ServiceStatus: "
diff --git a/src/components/protocol_handler/test/service_status_update_handler_test.cc b/src/components/protocol_handler/test/service_status_update_handler_test.cc
index b587194d98..8da89bdcd1 100644
--- a/src/components/protocol_handler/test/service_status_update_handler_test.cc
+++ b/src/components/protocol_handler/test/service_status_update_handler_test.cc
@@ -73,7 +73,8 @@ class ServiceStatusUpdateHandlerTest
Common_ServiceEvent::eType GetServiceEvent(ServiceStatus status) {
switch (status) {
- case ServiceStatus::SERVICE_ACCEPTED: {
+ case ServiceStatus::SERVICE_ACCEPTED:
+ case ServiceStatus::PROTECTION_DISABLED: {
return Common_ServiceEvent::REQUEST_ACCEPTED;
}
case ServiceStatus::SERVICE_RECEIVED: {
@@ -82,7 +83,8 @@ class ServiceStatusUpdateHandlerTest
case ServiceStatus::SERVICE_START_FAILED:
case ServiceStatus::PTU_FAILED:
case ServiceStatus::CERT_INVALID:
- case ServiceStatus::INVALID_TIME: {
+ case ServiceStatus::INVALID_TIME:
+ case ServiceStatus::PROTECTION_ENFORCED: {
return Common_ServiceEvent::REQUEST_REJECTED;
}
default: { return Common_ServiceEvent::INVALID_ENUM; }
@@ -108,6 +110,14 @@ class ServiceStatusUpdateHandlerTest
auto reason = Common_ServiceStatusUpdateReason::INVALID_TIME;
return reason;
}
+ case ServiceStatus::PROTECTION_ENFORCED: {
+ auto reason = Common_ServiceStatusUpdateReason::PROTECTION_ENFORCED;
+ return reason;
+ }
+ case ServiceStatus::PROTECTION_DISABLED: {
+ auto reason = Common_ServiceStatusUpdateReason::PROTECTION_DISABLED;
+ return reason;
+ }
default: {
auto reason = Common_ServiceStatusUpdateReason::INVALID_ENUM;
return reason;
@@ -170,6 +180,24 @@ INSTANTIATE_TEST_CASE_P(
ServiceUpdate(ServiceType::kMobileNav, ServiceStatus::PTU_FAILED),
ServiceUpdate(ServiceType::kRpc, ServiceStatus::PTU_FAILED)));
+INSTANTIATE_TEST_CASE_P(
+ OnServiceUpdate_PROTECTION_ENFRORCED,
+ ServiceStatusUpdateHandlerTest,
+ ::testing::Values(
+ ServiceUpdate(ServiceType::kAudio, ServiceStatus::PROTECTION_ENFORCED),
+ ServiceUpdate(ServiceType::kMobileNav,
+ ServiceStatus::PROTECTION_ENFORCED),
+ ServiceUpdate(ServiceType::kRpc, ServiceStatus::PROTECTION_ENFORCED)));
+
+INSTANTIATE_TEST_CASE_P(
+ OnServiceUpdate_PROTECTION_DISABLED,
+ ServiceStatusUpdateHandlerTest,
+ ::testing::Values(
+ ServiceUpdate(ServiceType::kAudio, ServiceStatus::PROTECTION_DISABLED),
+ ServiceUpdate(ServiceType::kMobileNav,
+ ServiceStatus::PROTECTION_DISABLED),
+ ServiceUpdate(ServiceType::kRpc, ServiceStatus::PROTECTION_DISABLED)));
+
TEST_P(ServiceStatusUpdateHandlerTest, OnServiceUpdate) {
auto service_event_ = GetServiceEvent(GetParam().service_status_);
auto reason_ = GetUpdateReason(GetParam().service_status_);