-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature/close application rpc #5
Feature/close application rpc #5
Conversation
This PR provides a new RPC called CloseApplication, which can be used by an app to send itself into HMI_NONE. A registered application sends CloseApplicationRequest to SDL. SDL will checks if specified application is registered and it is not in HMI level NONE. After that, SDL will sends ActivateAppRequest to HMI with HMI level parameter as NONE. When SDL will received ActivateAppResponse from HMI, if result code will be as SUCCESS or WARNING, SDL will sets application(which has sent this request) HMI level NONE and sends OnHMIStatusNotification to Mobile with HMI level NONE. After that SDL will sends CloseApplicationResponse to Mobile.
e06b6d6
to
c579aa3
Compare
* | ||
* @param message Incoming SmartObject message | ||
*/ | ||
CloseApplicationRequest(const app_mngr::commands::MessageSharedPtr& message, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@IGapchuk please update description as your ctor contains more parameters than described
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@AKalinich-Luxoft Updated in 552836a.
void on_event(const app_mngr::event_engine::Event& event) FINAL; | ||
|
||
private: | ||
DISALLOW_COPY_AND_ASSIGN(CloseApplicationRequest); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@IGapchuk as I remember this macro should be in the end of private section
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@AKalinich-Luxoft Moved in 552836a.
DISALLOW_COPY_AND_ASSIGN(CloseApplicationRequest); | ||
|
||
/** | ||
* @brief Send Basic Communication Request to HMI. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@IGapchuk sends ActivateApp
request to HMI
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@AKalinich-Luxoft Fixed in 552836a.
* | ||
* @param message - Incoming SmartObject message | ||
**/ | ||
CloseApplicationResponse(const app_mngr::commands::MessageSharedPtr& message, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@IGapchuk update description
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@AKalinich-Luxoft Updated 552836a.
return; | ||
} | ||
|
||
const bool sent_success = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@IGapchuk just sending_result
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@AKalinich-Luxoft Renamed in 552836a.
void CloseApplicationRequest::on_event(const event_engine::Event& event) { | ||
using namespace helpers; | ||
LOG4CXX_AUTO_TRACE(logger_); | ||
const auto message = event.smart_object(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@IGapchuk move this line down to the place of first usage
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@AKalinich-Luxoft Moved in 552836a.
SendResponse(false, mobile_apis::Result::INVALID_DATA); | ||
return; | ||
} | ||
application->set_hmi_level(mobile_apis::HMILevel::HMI_NONE); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@IGapchuk I think you must do this via state controller otherwise you will get an inconsistent state of application against state controller. For example check how it works for ApplicationManagerImpl::ActivateApplication
. You definitely should have something similar for your case
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@AKalinich-Luxoft Inside ApplicationImpl::set_hmi_level calls SetRegularState method from state controller and sets the specified hmi_state.
} | ||
|
||
TEST_F(CloseApplicationRequestTest, | ||
CloseApplicationRequestSendsResponse_GENERIC_ERROR) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@IGapchuk please use naming pattern "WhatIsTested_TestScenario_ExpectedResult" pattern for your unit tests
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@AKalinich-Luxoft Renamed in 552836a.
|
||
<function name="CloseApplication" functionID="CloseApplicationID" messagetype="response" since="5.0"> | ||
<param name="success" type="Boolean" platform="documentation" mandatory="true"> | ||
<description> true if successful; false, if failed </description> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@IGapchuk without such description sense of parameter will still be clear.
return Command::CommandSource::SOURCE_MOBILE == source | ||
? factory.GetCreator<commands::CloseApplicationRequest>() | ||
: factory.GetCreator<commands::CloseApplicationResponse>(); | ||
} break; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@IGapchuk Please, check indentation and do we really need break here?
@@ -396,6 +398,12 @@ CommandCreator& MobileCommandFactory::get_creator_factory( | |||
using app_mngr::commands::Command; | |||
return factory.GetCreator<commands::GenericResponse>(); | |||
} | |||
case mobile_apis::FunctionID::CloseApplicationID: { | |||
using app_mngr::commands::Command; | |||
return Command::CommandSource::SOURCE_MOBILE == source |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@IGapchuk please, consider filtering by messageType not by commandSource
|
||
TEST_F(CloseApplicationResponseTest, CloseApplicationResponse_SUCCESS) { | ||
using namespace am; | ||
using namespace mobile_apis; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@IGapchuk i believe, this namespace is used only for Result. So, please consider removing mobile_apis in result_code declaration or removing this using and using of mobile_apis:: for Result (I believe, the second option is preferrable).
|
||
namespace { | ||
const uint32_t kConnectionKey = 1u; | ||
const uint32_t kCorrelationId = 2u; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@IGapchuk kCorrelationId is not used here.
|
||
EXPECT_CALL( | ||
mock_rpc_service_, | ||
ManageMobileCommand(_, am::commands::Command::CommandSource::SOURCE_SDL)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@IGapchuk please, remove am:: or using namespace am
|
||
EXPECT_CALL( | ||
mock_rpc_service_, | ||
ManageMobileCommand(_, am::commands::Command::CommandSource::SOURCE_SDL)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@IGapchuk please, remove am:: or using namespace am
|
||
EXPECT_CALL( | ||
mock_rpc_service_, | ||
ManageMobileCommand(_, am::commands::Command::CommandSource::SOURCE_SDL)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@IGapchuk please, remove am:: or using namespace am
MockAppPtr mock_app(CreateMockApp()); | ||
|
||
EXPECT_CALL(app_mngr_, application(kConnectionKey)) | ||
.WillOnce(Return(mock_app)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@IGapchuk can't you simply use mock_app_?
|
||
void DeffaultRequestRunCheck(const bool success_send_to_hmi) { | ||
EXPECT_CALL(app_mngr_, application(kConnectionKey)) | ||
.WillOnce(Return(mock_app_)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@IGapchuk Please, double check this Return, since in SetUp section there is already ON_CALL which returns mock_app_ by default
Not actual because of smartdevicelink#2948 |
Implements smartdevicelink#1931
This PR is ready for review.
Risk
This PR makes major API changes.
Testing Plan
Unit tests.
Summary
This PR provides a new RPC called CloseApplication, which can be used by an app
to send itself into HMI_NONE.
A registered application can send this RPC to transit from any HMI level
to HMI_NONE. The application will receive an OnHMIStatus notification
which then leads to remove the lock screen from the phone app. Different
to unregister or re-register the application stays registered but will
CLA