-
Notifications
You must be signed in to change notification settings - Fork 244
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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.
- Loading branch information
Showing
7 changed files
with
433 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
102 changes: 102 additions & 0 deletions
102
...plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/close_application_request.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
/* | ||
Copyright (c) 2018, Ford Motor Company | ||
All rights reserved. | ||
Redistribution and use in source and binary forms, with or without | ||
modification, are permitted provided that the following conditions are met: | ||
Redistributions of source code must retain the above copyright notice, this | ||
list of conditions and the following disclaimer. | ||
Redistributions in binary form must reproduce the above copyright notice, | ||
this list of conditions and the following | ||
disclaimer in the documentation and/or other materials provided with the | ||
distribution. | ||
Neither the name of the Ford Motor Company nor the names of its contributors | ||
may be used to endorse or promote products derived from this software | ||
without specific prior written permission. | ||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | ||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE | ||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | ||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | ||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | ||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | ||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | ||
POSSIBILITY OF SUCH DAMAGE. | ||
*/ | ||
|
||
#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_CLOSE_APPLICATION_REQUEST_H_ | ||
#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_CLOSE_APPLICATION_REQUEST_H_ | ||
|
||
#include <cstdint> | ||
|
||
#include "application_manager/commands/command_request_impl.h" | ||
#include "application_manager/event_engine/event_observer.h" | ||
#include "utils/macro.h" | ||
|
||
namespace sdl_rpc_plugin { | ||
namespace app_mngr = application_manager; | ||
|
||
namespace commands { | ||
|
||
/** | ||
* @brief CloseApplicationRequest command class | ||
*/ | ||
class CloseApplicationRequest : public app_mngr::commands::CommandRequestImpl { | ||
public: | ||
/** | ||
* @brief CloseApplicationRequest class constructor | ||
* | ||
* @param message Incoming SmartObject message | ||
*/ | ||
CloseApplicationRequest(const app_mngr::commands::MessageSharedPtr& message, | ||
app_mngr::ApplicationManager& application_manager, | ||
app_mngr::rpc_service::RPCService& rpc_service, | ||
app_mngr::HMICapabilities& hmi_capabilities, | ||
policy::PolicyHandlerInterface& policy_handler); | ||
/** | ||
* @brief CloseApplicationRequest class destructor | ||
*/ | ||
~CloseApplicationRequest() FINAL; | ||
|
||
/** | ||
* @brief Execute command | ||
*/ | ||
void Run() FINAL; | ||
|
||
/** | ||
* @brief Interface method that is called whenever new event received | ||
* | ||
* @param event The received event | ||
*/ | ||
void on_event(const app_mngr::event_engine::Event& event) FINAL; | ||
|
||
private: | ||
DISALLOW_COPY_AND_ASSIGN(CloseApplicationRequest); | ||
|
||
/** | ||
* @brief Send Basic Communication Request to HMI. | ||
* | ||
* @param app - Application which have to set specified HMI level. | ||
* @param hmi_level - New HMI level for specified application. | ||
* @param send_policy_priority - Defines whether to send "priority" field | ||
* with request | ||
* @param activate_app_corr_id - Variable for detting ActivateAppRequest | ||
* correlation id. | ||
* @return - True if command is executed, otherwise return false. | ||
*/ | ||
bool SendBCActivateApp(app_mngr::ApplicationConstSharedPtr app, | ||
const hmi_apis::Common_HMILevel::eType hmi_level, | ||
const bool send_policy_priority); | ||
}; | ||
|
||
} // namespace commands | ||
} // namespace sdl_rpc_plugin | ||
|
||
#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_CLOSE_APPLICATION_REQUEST_H_ |
79 changes: 79 additions & 0 deletions
79
...lugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/close_application_response.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
/* | ||
Copyright (c) 2018, Ford Motor Company | ||
All rights reserved. | ||
Redistribution and use in source and binary forms, with or without | ||
modification, are permitted provided that the following conditions are met: | ||
Redistributions of source code must retain the above copyright notice, this | ||
list of conditions and the following disclaimer. | ||
Redistributions in binary form must reproduce the above copyright notice, | ||
this list of conditions and the following | ||
disclaimer in the documentation and/or other materials provided with the | ||
distribution. | ||
Neither the name of the Ford Motor Company nor the names of its contributors | ||
may be used to endorse or promote products derived from this software | ||
without specific prior written permission. | ||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | ||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE | ||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | ||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | ||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | ||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | ||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | ||
POSSIBILITY OF SUCH DAMAGE. | ||
*/ | ||
|
||
#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_CLOSE_APPLICATION_RESPONSE_H_ | ||
#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_CLOSE_APPLICATION_RESPONSE_H_ | ||
|
||
#include "application_manager/commands/command_response_impl.h" | ||
#include "utils/macro.h" | ||
|
||
namespace sdl_rpc_plugin { | ||
namespace app_mngr = application_manager; | ||
|
||
namespace commands { | ||
|
||
/** | ||
* @brief CloseApplicationResponse command class | ||
**/ | ||
class CloseApplicationResponse | ||
: public app_mngr::commands::CommandResponseImpl { | ||
public: | ||
/** | ||
* @brief CloseApplicationResponse class constructor | ||
* | ||
* @param message - Incoming SmartObject message | ||
**/ | ||
CloseApplicationResponse(const app_mngr::commands::MessageSharedPtr& message, | ||
app_mngr::ApplicationManager& application_manager, | ||
app_mngr::rpc_service::RPCService& rpc_service, | ||
app_mngr::HMICapabilities& hmi_capabilities, | ||
policy::PolicyHandlerInterface& policy_handler); | ||
|
||
/** | ||
* @brief CloseApplicationResponse class destructor | ||
**/ | ||
~CloseApplicationResponse() FINAL; | ||
|
||
/** | ||
* @brief Execute command | ||
**/ | ||
void Run() FINAL; | ||
|
||
private: | ||
DISALLOW_COPY_AND_ASSIGN(CloseApplicationResponse); | ||
}; | ||
|
||
} // namespace commands | ||
} // namespace sdl_rpc_plugin | ||
|
||
#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_CLOSE_APPLICATION_RESPONSE_H_ |
155 changes: 155 additions & 0 deletions
155
...ation_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/close_application_request.cc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,155 @@ | ||
/* | ||
Copyright (c) 2018, Ford Motor Company | ||
All rights reserved. | ||
Redistribution and use in source and binary forms, with or without | ||
modification, are permitted provided that the following conditions are met: | ||
Redistributions of source code must retain the above copyright notice, this | ||
list of conditions and the following disclaimer. | ||
Redistributions in binary form must reproduce the above copyright notice, | ||
this list of conditions and the following | ||
disclaimer in the documentation and/or other materials provided with the | ||
distribution. | ||
Neither the name of the Ford Motor Company nor the names of its contributors | ||
may be used to endorse or promote products derived from this software | ||
without specific prior written permission. | ||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | ||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE | ||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | ||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | ||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | ||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | ||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | ||
POSSIBILITY OF SUCH DAMAGE. | ||
*/ | ||
|
||
#include "sdl_rpc_plugin/commands/mobile/close_application_request.h" | ||
#include "application_manager/rpc_service.h" | ||
#include "application_manager/message_helper.h" | ||
#include "utils/include/utils/helpers.h" | ||
|
||
namespace sdl_rpc_plugin { | ||
using namespace application_manager; | ||
|
||
namespace commands { | ||
|
||
CloseApplicationRequest::CloseApplicationRequest( | ||
const app_mngr::commands::MessageSharedPtr& message, | ||
app_mngr::ApplicationManager& application_manager, | ||
app_mngr::rpc_service::RPCService& rpc_service, | ||
app_mngr::HMICapabilities& hmi_capabilities, | ||
policy::PolicyHandlerInterface& policy_handler) | ||
: CommandRequestImpl(message, | ||
application_manager, | ||
rpc_service, | ||
hmi_capabilities, | ||
policy_handler) {} | ||
|
||
CloseApplicationRequest::~CloseApplicationRequest() {} | ||
|
||
void CloseApplicationRequest::Run() { | ||
LOG4CXX_AUTO_TRACE(logger_); | ||
|
||
auto application = application_manager_.application(connection_key()); | ||
|
||
if (!application) { | ||
LOG4CXX_ERROR(logger_, "No such application registered."); | ||
SendResponse(false, mobile_apis::Result::APPLICATION_NOT_REGISTERED); | ||
return; | ||
} | ||
|
||
const auto app_hmi_level = application->hmi_level(); | ||
|
||
if (mobile_apis::HMILevel::HMI_NONE == app_hmi_level) { | ||
LOG4CXX_DEBUG(logger_, | ||
"Application with id " << connection_key() | ||
<< " is already in hmi_level NONE."); | ||
SendResponse(false, mobile_apis::Result::IGNORED); | ||
return; | ||
} | ||
|
||
const bool sent_success = | ||
SendBCActivateApp(application, hmi_apis::Common_HMILevel::NONE, true); | ||
|
||
if (!sent_success) { | ||
LOG4CXX_ERROR(logger_, "Unable to send BC.ActivateApp"); | ||
SendResponse(false, mobile_apis::Result::INVALID_DATA); | ||
} | ||
} | ||
|
||
void CloseApplicationRequest::on_event(const event_engine::Event& event) { | ||
using namespace helpers; | ||
LOG4CXX_AUTO_TRACE(logger_); | ||
const auto message = event.smart_object(); | ||
|
||
if (hmi_apis::FunctionID::BasicCommunication_ActivateApp != event.id()) { | ||
LOG4CXX_ERROR(logger_, "Received unknown event" << event.id()); | ||
return; | ||
} | ||
|
||
const auto hmi_result = static_cast<hmi_apis::Common_Result::eType>( | ||
message[strings::params][hmi_response::code].asInt()); | ||
|
||
const auto mobile_result = MessageHelper::HMIToMobileResult(hmi_result); | ||
const bool success = Compare<hmi_apis::Common_Result::eType, EQ, ONE>( | ||
hmi_result, | ||
hmi_apis::Common_Result::SUCCESS, | ||
hmi_apis::Common_Result::WARNINGS); | ||
|
||
if (success) { | ||
auto application = application_manager_.application(connection_key()); | ||
if (!application) { | ||
LOG4CXX_DEBUG(logger_, "No such application registered"); | ||
SendResponse(false, mobile_apis::Result::INVALID_DATA); | ||
return; | ||
} | ||
application->set_hmi_level(mobile_apis::HMILevel::HMI_NONE); | ||
LOG4CXX_DEBUG(logger_, | ||
"Application with id " << application->app_id() | ||
<< " has switched to HMI_level NONE."); | ||
} else { | ||
LOG4CXX_WARN(logger_, "Application hasn't switched to HMI_level NONE."); | ||
} | ||
SendResponse(success, mobile_result); | ||
} | ||
|
||
bool CloseApplicationRequest::SendBCActivateApp( | ||
ApplicationConstSharedPtr app, | ||
const hmi_apis::Common_HMILevel::eType hmi_level, | ||
const bool send_policy_priority) { | ||
LOG4CXX_AUTO_TRACE(logger_); | ||
auto bc_activate_app_request = MessageHelper::GetBCActivateAppRequestToHMI( | ||
app, | ||
application_manager_.connection_handler().get_session_observer(), | ||
application_manager_.GetPolicyHandler(), | ||
hmi_level, | ||
send_policy_priority, | ||
application_manager_); | ||
if (!bc_activate_app_request) { | ||
LOG4CXX_ERROR(logger_, "Unable to create BC.ActivateAppRequest"); | ||
return false; | ||
} | ||
|
||
if (!application_manager_.GetRPCService().ManageHMICommand( | ||
bc_activate_app_request)) { | ||
LOG4CXX_ERROR(logger_, "Unable to send BC.ActivateAppRequest"); | ||
return false; | ||
} | ||
const auto activate_app_corr_id = | ||
(*bc_activate_app_request)[strings::params][strings::correlation_id] | ||
.asUInt(); | ||
subscribe_on_event(hmi_apis::FunctionID::BasicCommunication_ActivateApp, | ||
activate_app_corr_id); | ||
return true; | ||
} | ||
|
||
} // namespace commands | ||
} // namespace sdl_rpc_plugin |
Oops, something went wrong.