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/sdl 0315 add rpc conflict management #3814

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions src/appMain/sdl_preloaded_pt.json
Original file line number Diff line number Diff line change
Expand Up @@ -4613,6 +4613,33 @@
"since": "7.1"
}
]
},
"rpc_priority":
{
"DialNumber": 1,
"Alert": 2,
"PerformAudioPassThru": 2,
"PerformInteraction": 3,
"ScrollableMessage": 3,
"Slider": 3,
"Speak": 3
},
"app_priority":
{
"EMERGENCY": 0,
"NAVIGATION": 1,
"VOICE_COMMUNICATION": 2,
"COMMUNICATION": 3,
"NORMAL": 4,
"NONE": 5
},
"hmi_status_priority":
{
"FULL": 1,
"LIMITED": 2,
"BACKGROUND": 3,
"NONE": 4
}
}
}
}
1 change: 1 addition & 0 deletions src/appMain/smartDeviceLink.ini
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,7 @@ AttemptsToOpenPolicyDB = 5
OpenAttemptTimeoutMs = 500
; Whether to use the fullAppID over the short-form appID in policy lookups
UseFullAppID = true
EnableRPCConflictManager = false

[TransportManager]
; Listening port form incoming TCP mobile connection
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@
#include "interfaces/v4_protocol_v1_2_no_extra.h"
#include "interfaces/v4_protocol_v1_2_no_extra_schema.h"

#include "application_manager/interrupt_manager.h"

#ifdef ENABLE_SECURITY
#include "security_manager/security_manager_listener.h"
#include "security_manager/ssl_context.h"
Expand Down Expand Up @@ -1017,6 +1019,11 @@ class ApplicationManagerImpl
return *request_ctrl_;
}

interrupt_manager::InterruptManager& GetInterruptManager() const OVERRIDE{
return *interrupt_manager_;
}


void SetRPCService(std::unique_ptr<rpc_service::RPCService>& rpc_service) {
rpc_service_ = std::move(rpc_service);
}
Expand Down Expand Up @@ -1748,6 +1755,8 @@ class ApplicationManagerImpl

mutable sync_primitives::Lock expired_button_requests_lock_;
mutable ExpiredButtonRequestsMap expired_button_requests_;

std::unique_ptr<interrupt_manager::InterruptManager>interrupt_manager_;

#ifdef BUILD_TESTS
public:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,8 @@ class Command {
*/
virtual void SetAllowedToTerminate(const bool allowed) = 0;

virtual void Reject() = 0;

enum CommandSource {
SOURCE_SDL,
SOURCE_MOBILE,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,8 @@ class CommandImpl : public Command {
bool IsHMIResultSuccess(hmi_apis::Common_Result::eType result_code,
HmiInterfaces::InterfaceID interface) const;

void Reject() OVERRIDE;

// members
static const int32_t hmi_protocol_type_;
static const int32_t mobile_protocol_type_;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,8 @@ class CommandRequestImpl : public CommandImpl,

bool DecrementReferenceCount() const OVERRIDE;

void Reject() OVERRIDE;

protected:
/**
* @brief Checks message permissions and parameters according to policy table
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
/*
InterruptManager header file (under construction)
*/

#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_INTERRUPT_MANAGER_H
#define SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_INTERRUPT_MANAGER_H

#include "application_manager/rpc_handler_impl.h"
#include "config_profile/profile.h"
#include "application_manager/application_manager.h"
#include "utils/logger.h"

namespace application_manager {

namespace interrupt_manager {

enum IMStatus
{
IM_DEACTIVATE = 0,
IM_ACTIVATE,
IM_ACTIVATE_DEFAULT
};

enum InterruptCheckResult
{
NO_INTERRUPT = 0,
REJECT_ONS_IN_QUEUE,
REJECT_RECEIVED_ONS,
INTERRUPT_ERROR,
};

class InterruptManager
{
public:
InterruptManager();
InterruptManager(ApplicationManager& app_manager, const policy::PolicySettings& policy_settings);
~InterruptManager();

void Init();

InterruptCheckResult CheckRpcInterrupt(const std::shared_ptr<Message> outgoing_message);
bool DoRpcReject(int32_t function_id);
IMStatus GetRunningStatus();
bool ReadInterruptSetting();
bool IsSubjectMessageToPrioritized(std::shared_ptr<Message> outgoing_message);
std::shared_ptr<Message> highest_priority_ons_rpc_;
std::list<int32_t> reject_rpc_list_;
std::string appPriority;
std::string firstAppPriority;
std::string app_hmi_level;
std::string first_app_hmi_level;
ns_smart_device_link::ns_smart_objects::SmartObject message_;
ns_smart_device_link::ns_smart_objects::SmartObject first_message_;
int32_t app_id;
int32_t first_app_id;
ApplicationSharedPtr app;
ApplicationSharedPtr first_app;
int32_t function_id;
int32_t first_function_id;

std::string function_name;
std::string first_function_name;

// Priority Table
rpc::policy_table_interface_base::rpc_priority_type rpc_priority_table_;
rpc::policy_table_interface_base::app_priority_type apptype_priority_table_;
rpc::policy_table_interface_base::hmi_status_priority_type hmists_priority_table_;

private:
InterruptCheckResult CheckRpcPriority(const std::shared_ptr<Message> outgoing_message);
InterruptCheckResult CheckAppTypePriority(const std::shared_ptr<Message> outgoing_message);
InterruptCheckResult CheckHmiStatusPriority(const std::shared_ptr<Message> outgoing_message);
bool ReadRpcPriorityTable();
bool ReadAppTypePriorityTable();
bool ReadHmiStatusPriorityTable();

private:
IMStatus im_status_;
ApplicationManager& app_manager_;
const policy::PolicySettings& policy_settings_;
};

} // namespace interrupt_manager
} // namespace application_manager
#endif // SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_INTERRUPT_MANAGER_H

Original file line number Diff line number Diff line change
Expand Up @@ -684,6 +684,10 @@ class PolicyHandler : public PolicyHandlerInterface,
const std::vector<std::string> GetAppRequestSubTypes(
const std::string& policy_app_id) const OVERRIDE;

virtual rpc::policy_table_interface_base::rpc_priority_type GetRpcPriority() const OVERRIDE;
virtual rpc::policy_table_interface_base::app_priority_type GetAppPriority() const OVERRIDE;
virtual rpc::policy_table_interface_base::hmi_status_priority_type GetHmiStatusPriority() const OVERRIDE;

#ifdef EXTERNAL_PROPRIETARY_MODE
/**
* @brief Gets meta information
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ class AlertRequest : public app_mngr::commands::RequestFromMobileImpl {

void OnTimeOut() FINAL;

void Reject();

protected:
private:
/*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ class DialNumberRequest : public app_mngr::commands::RequestFromMobileImpl {
*/
void on_event(const app_mngr::event_engine::Event& event);

void Reject();

private:
/**
* @brief Removes from number param all characters
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ class PerformAudioPassThruRequest
*/
void OnTimeOut() FINAL;

void Reject();

private:
/**
* @brief Prepare result code, result and info for sending to mobile
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ class PerformInteractionRequest

void OnTimeOut() FINAL;

void Reject();

protected:
/**
* @brief Prepare result code for sending to mobile application
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ class ScrollableMessageRequest
*/
void on_event(const app_mngr::event_engine::Event& event) OVERRIDE;

void Reject();

private:
DISALLOW_COPY_AND_ASSIGN(ScrollableMessageRequest);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ class SliderRequest : public app_mngr::commands::RequestFromMobileImpl {
*/
void on_event(const app_mngr::event_engine::Event& event) OVERRIDE;

void Reject();

private:
/**
* @brief Checks slider params(sliderHeader, sliderFooter, ...).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ class SpeakRequest : public app_mngr::commands::RequestFromMobileImpl {
*/
void on_event(const app_mngr::event_engine::Event& event) OVERRIDE;

void Reject();

private:
/*
* @brief Sends Speak response to mobile side
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -461,6 +461,12 @@ bool AlertRequest::IsPendingResponseExist() {
awaiting_tts_stop_speaking_response_;
}

void AlertRequest::Reject(){
SDL_LOG_INFO("Interrupt Rejected");
SendResponse(false, mobile_apis::Result::REJECTED);
return;
}

} // namespace commands

} // namespace sdl_rpc_plugin
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,12 @@ void DialNumberRequest::StripNumberParam(std::string& number) {
(*message_)[strings::msg_params][strings::number] = number;
}

void DialNumberRequest::Reject(){
SDL_LOG_INFO("Interrupt Rejected");
SendResponse(false, mobile_apis::Result::REJECTED);
return;
}

} // namespace commands

} // namespace sdl_rpc_plugin
Original file line number Diff line number Diff line change
Expand Up @@ -441,6 +441,12 @@ bool PerformAudioPassThruRequest::IsWaitingHMIResponse() {
IsInterfaceAwaited(HmiInterfaces::HMI_INTERFACE_UI);
}

void PerformAudioPassThruRequest::Reject(){
SDL_LOG_INFO("Interrupt Rejected");
SendResponse(false, mobile_apis::Result::REJECTED);
return;
}

} // namespace commands

} // namespace sdl_rpc_plugin
Original file line number Diff line number Diff line change
Expand Up @@ -1121,5 +1121,11 @@ bool PerformInteractionRequest::SetChoiceIdToResponseMsgParams(
return true;
}

void PerformInteractionRequest::Reject(){
SDL_LOG_ERROR("Interrupt Rejected");
SendResponse(false, mobile_apis::Result::REJECTED);
return;
}

} // namespace commands
} // namespace sdl_rpc_plugin
Original file line number Diff line number Diff line change
Expand Up @@ -155,5 +155,11 @@ void ScrollableMessageRequest::on_event(const event_engine::Event& event) {
}
}

void ScrollableMessageRequest::Reject(){
SDL_LOG_INFO("Interrupt Rejected");
SendResponse(false, mobile_apis::Result::REJECTED);
return;
}

} // namespace commands
} // namespace sdl_rpc_plugin
Original file line number Diff line number Diff line change
Expand Up @@ -183,5 +183,11 @@ bool SliderRequest::IsWhiteSpaceExist() {
return false;
}

void SliderRequest::Reject() {
SDL_LOG_INFO("Interrupt Rejected");
SendResponse(false, mobile_apis::Result::REJECTED);
return;
}

} // namespace commands
} // namespace sdl_rpc_plugin
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,12 @@ bool SpeakRequest::IsWhiteSpaceExist() {
return false;
}

void SpeakRequest::Reject(){
SDL_LOG_INFO("Interrupt Rejected");
SendResponse(false, mobile_apis::Result::REJECTED);
return;
}

} // namespace commands

} // namespace sdl_rpc_plugin
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@
#include "utils/threads/thread.h"
#include "utils/timer_task_impl.h"

#include "application_manager/interrupt_manager.h"

namespace {
int get_rand_from_range(uint32_t from = 0, int to = RAND_MAX) {
return std::rand() % to + from;
Expand Down Expand Up @@ -227,6 +229,7 @@ ApplicationManagerImpl::ApplicationManagerImpl(
rpc_protection_manager,
hmi_so_factory(),
mobile_so_factory()));
interrupt_manager_.reset(new interrupt_manager::InterruptManager(*this, policy_settings));
}

ApplicationManagerImpl::~ApplicationManagerImpl() {
Expand All @@ -240,7 +243,7 @@ ApplicationManagerImpl::~ApplicationManagerImpl() {
protocol_handler_ = NULL;
SDL_LOG_DEBUG("Destroying Policy Handler");
RemovePolicyObserver(this);

interrupt_manager_ = NULL;
{
sync_primitives::AutoLock lock(navi_app_to_stop_lock_);
navi_app_to_stop_.clear();
Expand Down Expand Up @@ -2644,6 +2647,8 @@ bool ApplicationManagerImpl::Init(

plugin_manager_->ForEachPlugin(on_app_policy_updated);

interrupt_manager_->Init();

return true;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,8 @@ void CommandImpl::Run() {}

void CommandImpl::OnUpdateTimeOut() {}

void CommandImpl::Reject() {}

uint32_t CommandImpl::default_timeout() const {
return default_timeout_;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -216,5 +216,7 @@ void CommandRequestImpl::set_current_state(
current_state_ = state;
}

void CommandRequestImpl::Reject() {}

} // namespace commands
} // namespace application_manager
Loading