Skip to content
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

Conversation

IGapchuk
Copy link

@IGapchuk IGapchuk commented Dec 11, 2018

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

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.
*
* @param message Incoming SmartObject message
*/
CloseApplicationRequest(const app_mngr::commands::MessageSharedPtr& message,
Copy link
Collaborator

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

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

void on_event(const app_mngr::event_engine::Event& event) FINAL;

private:
DISALLOW_COPY_AND_ASSIGN(CloseApplicationRequest);
Copy link
Collaborator

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

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DISALLOW_COPY_AND_ASSIGN(CloseApplicationRequest);

/**
* @brief Send Basic Communication Request to HMI.
Copy link
Collaborator

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

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

*
* @param message - Incoming SmartObject message
**/
CloseApplicationResponse(const app_mngr::commands::MessageSharedPtr& message,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@IGapchuk update description

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

return;
}

const bool sent_success =
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@IGapchuk just sending_result

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

void CloseApplicationRequest::on_event(const event_engine::Event& event) {
using namespace helpers;
LOG4CXX_AUTO_TRACE(logger_);
const auto message = event.smart_object();
Copy link
Collaborator

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

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SendResponse(false, mobile_apis::Result::INVALID_DATA);
return;
}
application->set_hmi_level(mobile_apis::HMILevel::HMI_NONE);
Copy link
Collaborator

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

Copy link
Author

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) {
Copy link
Collaborator

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

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


<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>

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;

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

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;

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;

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))

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))

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))

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));

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_));

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

@IGapchuk
Copy link
Author

Not actual because of smartdevicelink#2948

@IGapchuk IGapchuk closed this Jun 27, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants