summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJackLivio <jack@livio.io>2020-07-15 14:47:34 -0400
committerJackLivio <jack@livio.io>2020-07-15 14:47:34 -0400
commit6923723764dfc3514e1305a73972c0121e6bef97 (patch)
treefce34b136d2b6751149d40ff1d63145a3165fa43
parent1e59f31353831c4316ed3a70c161ac5611e47a12 (diff)
downloadsdl_core-6923723764dfc3514e1305a73972c0121e6bef97.tar.gz
Address comments
-rw-r--r--src/components/application_manager/include/application_manager/application.h2
-rw-r--r--src/components/application_manager/include/application_manager/application_data_impl.h4
-rw-r--r--src/components/application_manager/include/application_manager/smart_object_keys.h1
-rw-r--r--src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/delete_sub_menu_request.h23
-rw-r--r--src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_get_capabilities_response.cc2
-rw-r--r--src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/add_sub_menu_request.cc5
-rw-r--r--src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/delete_sub_menu_request.cc56
-rw-r--r--src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/get_system_capability_request.cc3
-rw-r--r--src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/register_app_interface_request.cc2
-rw-r--r--src/components/application_manager/src/application_data_impl.cc2
-rw-r--r--src/components/application_manager/src/smart_object_keys.cc1
-rw-r--r--src/components/application_manager/test/include/application_manager/mock_application.h2
-rw-r--r--src/components/interfaces/HMI_API.xml2
13 files changed, 81 insertions, 24 deletions
diff --git a/src/components/application_manager/include/application_manager/application.h b/src/components/application_manager/include/application_manager/application.h
index a97da79d15..a595fc7379 100644
--- a/src/components/application_manager/include/application_manager/application.h
+++ b/src/components/application_manager/include/application_manager/application.h
@@ -370,7 +370,7 @@ class DynamicApplicationData {
* @brief Returns true if sub menu with such name already exist
*/
virtual bool IsSubMenuNameAlreadyExist(const std::string& name,
- const int32_t parent_id) = 0;
+ const uint32_t parent_id) = 0;
/*
* @brief Adds a interaction choice set to the application
diff --git a/src/components/application_manager/include/application_manager/application_data_impl.h b/src/components/application_manager/include/application_manager/application_data_impl.h
index decd3b51a3..f04d3122fa 100644
--- a/src/components/application_manager/include/application_manager/application_data_impl.h
+++ b/src/components/application_manager/include/application_manager/application_data_impl.h
@@ -195,7 +195,7 @@ class DynamicApplicationDataImpl : public virtual Application {
* @brief Returns true if sub menu with such name already exist
*/
bool IsSubMenuNameAlreadyExist(const std::string& name,
- const int32_t parent_id);
+ const uint32_t parent_id);
void SetWindowInfo(const WindowID window_id,
const smart_objects::SmartObject& window_info) OVERRIDE;
@@ -330,7 +330,7 @@ class DynamicApplicationDataImpl : public virtual Application {
CommandsMap commands_;
mutable std::shared_ptr<sync_primitives::RecursiveLock> commands_lock_ptr_;
SubMenuMap sub_menu_;
- mutable std::shared_ptr<sync_primitives::Lock> sub_menu_lock_ptr_;
+ mutable std::shared_ptr<sync_primitives::RecursiveLock> sub_menu_lock_ptr_;
ChoiceSetMap choice_set_map_;
mutable std::shared_ptr<sync_primitives::Lock> choice_set_map_lock_ptr_;
PerformChoiceSetMap performinteraction_choice_set_map_;
diff --git a/src/components/application_manager/include/application_manager/smart_object_keys.h b/src/components/application_manager/include/application_manager/smart_object_keys.h
index beb050c7b3..0bfc07d10a 100644
--- a/src/components/application_manager/include/application_manager/smart_object_keys.h
+++ b/src/components/application_manager/include/application_manager/smart_object_keys.h
@@ -199,6 +199,7 @@ extern const char* phone_capability;
extern const char* video_streaming_capability;
extern const char* rc_capability;
extern const char* driver_distraction_capability;
+extern const char* driver_distraction;
extern const char* seat_location_capability;
extern const char* app_services_capabilities;
extern const char* day_color_scheme;
diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/delete_sub_menu_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/delete_sub_menu_request.h
index 2f85065ee7..af2ba4a1ea 100644
--- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/delete_sub_menu_request.h
+++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/delete_sub_menu_request.h
@@ -83,22 +83,33 @@ class DeleteSubMenuRequest : public app_mngr::commands::CommandRequestImpl {
private:
/*
- * @brief Deletes VR commands from SDL for corresponding submenu ID
+ * @brief Deletes submenus that have a parentID that matches the parentID
+ * parameter
*
* @param app_id Application ID
+ * @param parentID Parent ID of a nested submenu
+ */
+ void DeleteNestedSubMenus(app_mngr::ApplicationSharedPtr const app,
+ uint32_t parentID,
+ const app_mngr::SubMenuMap& subMenus);
+
+ /*
+ * @brief Deletes VR commands from SDL for corresponding submenu ID
*
- * @return TRUE on success, otherwise FALSE
+ * @param app_id Application ID
+ * @param parentID Parent ID of a nested submenu
*/
- void DeleteSubMenuVRCommands(app_mngr::ApplicationConstSharedPtr app);
+ void DeleteSubMenuVRCommands(app_mngr::ApplicationConstSharedPtr app,
+ uint32_t parentID);
/*
* @brief Deletes UI commands from SDL for corresponding submenu ID
*
* @param app_id Application ID
- *
- * @return TRUE on success, otherwise FALSE
+ * @param parentID Parent ID of a nested submenu
*/
- void DeleteSubMenuUICommands(app_mngr::ApplicationSharedPtr const app);
+ void DeleteSubMenuUICommands(app_mngr::ApplicationSharedPtr const app,
+ uint32_t parentID);
DISALLOW_COPY_AND_ASSIGN(DeleteSubMenuRequest);
};
diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_get_capabilities_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_get_capabilities_response.cc
index b2e6cd2cf3..2712ea2d12 100644
--- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_get_capabilities_response.cc
+++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_get_capabilities_response.cc
@@ -143,4 +143,4 @@ void UIGetCapabilitiesResponse::Run() {
} // namespace commands
-} // namespace commands
+} // namespace sdl_rpc_plugin
diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/add_sub_menu_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/add_sub_menu_request.cc
index 4918d02eb2..71bf867054 100644
--- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/add_sub_menu_request.cc
+++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/add_sub_menu_request.cc
@@ -94,7 +94,10 @@ void AddSubMenuRequest::Run() {
const std::string& menu_name =
received_msg_params[strings::menu_name].asString();
- const uint32_t parent_id = received_msg_params[strings::parent_id].asUInt();
+ const uint32_t parent_id =
+ received_msg_params.keyExists(strings::parent_id)
+ ? received_msg_params[strings::parent_id].asUInt()
+ : 0;
if (app->IsSubMenuNameAlreadyExist(menu_name, parent_id)) {
LOG4CXX_ERROR(logger_, "Menu name " << menu_name << " is duplicated.");
diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/delete_sub_menu_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/delete_sub_menu_request.cc
index 6aaa2406e8..383daa9b83 100644
--- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/delete_sub_menu_request.cc
+++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/delete_sub_menu_request.cc
@@ -33,6 +33,7 @@
#include "sdl_rpc_plugin/commands/mobile/delete_sub_menu_request.h"
+#include "application_manager/application.h"
#include "application_manager/application_impl.h"
#include "application_manager/message_helper.h"
#include "interfaces/HMI_API.h"
@@ -88,8 +89,41 @@ void DeleteSubMenuRequest::Run() {
SendHMIRequest(hmi_apis::FunctionID::UI_DeleteSubMenu, &msg_params, true);
}
+void DeleteSubMenuRequest::DeleteNestedSubMenus(ApplicationSharedPtr const app,
+ uint32_t parentID,
+ const SubMenuMap& subMenus) {
+ LOG4CXX_AUTO_TRACE(logger_);
+
+ SubMenuMap::const_iterator it = subMenus.begin();
+ LOG4CXX_DEBUG(logger_, "Delete Submenus with Parent ID: " << parentID);
+ while (subMenus.end() != it) {
+ if (!(*it->second).keyExists(strings::parent_id)) {
+ LOG4CXX_ERROR(logger_, "parent ID does not exist");
+ ++it;
+ continue;
+ }
+
+ if (parentID == (*it->second)[strings::parent_id].asUInt()) {
+ uint32_t menuID = (*it->second)[strings::menu_id].asUInt();
+ DeleteNestedSubMenus(app, menuID, subMenus);
+ DeleteSubMenuVRCommands(app, menuID);
+ DeleteSubMenuUICommands(app, menuID);
+ smart_objects::SmartObject msg_params =
+ smart_objects::SmartObject(smart_objects::SmartType_Map);
+ msg_params[strings::menu_id] = menuID;
+ msg_params[strings::app_id] = app->app_id();
+ SendHMIRequest(hmi_apis::FunctionID::UI_DeleteSubMenu, &msg_params);
+ ++it;
+ LOG4CXX_DEBUG(logger_, "Removing submenuID: " << menuID);
+ app->RemoveSubMenu(menuID);
+ } else {
+ ++it;
+ }
+ }
+}
+
void DeleteSubMenuRequest::DeleteSubMenuVRCommands(
- ApplicationConstSharedPtr app) {
+ ApplicationConstSharedPtr app, uint32_t parentID) {
LOG4CXX_AUTO_TRACE(logger_);
const DataAccessor<CommandsMap> accessor = app->commands_map();
@@ -101,7 +135,7 @@ void DeleteSubMenuRequest::DeleteSubMenuVRCommands(
continue;
}
- if ((*message_)[strings::msg_params][strings::menu_id].asInt() ==
+ if (parentID ==
(*it->second)[strings::menu_params][hmi_request::parent_id].asInt()) {
smart_objects::SmartObject msg_params =
smart_objects::SmartObject(smart_objects::SmartType_Map);
@@ -116,9 +150,9 @@ void DeleteSubMenuRequest::DeleteSubMenuVRCommands(
}
void DeleteSubMenuRequest::DeleteSubMenuUICommands(
- ApplicationSharedPtr const app) {
+ ApplicationSharedPtr const app, uint32_t parentID) {
LOG4CXX_AUTO_TRACE(logger_);
-
+ LOG4CXX_DEBUG(logger_, "Delete UI Commands with Parent ID: " << parentID);
const DataAccessor<CommandsMap> accessor(app->commands_map());
const CommandsMap& commands = accessor.GetData();
CommandsMap::const_iterator it = commands.begin();
@@ -130,13 +164,14 @@ void DeleteSubMenuRequest::DeleteSubMenuUICommands(
continue;
}
- if ((*message_)[strings::msg_params][strings::menu_id].asInt() ==
- (*it->second)[strings::menu_params][hmi_request::parent_id].asInt()) {
+ if (parentID ==
+ (*it->second)[strings::menu_params][hmi_request::parent_id].asUInt()) {
smart_objects::SmartObject msg_params =
smart_objects::SmartObject(smart_objects::SmartType_Map);
const uint32_t cmd_id = (*it->second)[strings::cmd_id].asUInt();
msg_params[strings::app_id] = app->app_id();
msg_params[strings::cmd_id] = cmd_id;
+ LOG4CXX_DEBUG(logger_, "Removing UI Command: " << cmd_id);
app->RemoveCommand(cmd_id);
app->help_prompt_manager().OnVrCommandDeleted(cmd_id, false);
it = commands.begin(); // Can not relay on
@@ -174,8 +209,13 @@ void DeleteSubMenuRequest::on_event(const event_engine::Event& event) {
if (result) {
// delete sub menu items from SDL and HMI
- DeleteSubMenuVRCommands(application);
- DeleteSubMenuUICommands(application);
+ uint32_t parentID =
+ (*message_)[strings::msg_params][strings::menu_id].asUInt();
+ const DataAccessor<SubMenuMap> accessor = application->sub_menu_map();
+ const SubMenuMap& subMenus = accessor.GetData();
+ DeleteNestedSubMenus(application, parentID, subMenus);
+ DeleteSubMenuVRCommands(application, parentID);
+ DeleteSubMenuUICommands(application, parentID);
application->RemoveSubMenu(
(*message_)[strings::msg_params][strings::menu_id].asInt());
}
diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/get_system_capability_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/get_system_capability_request.cc
index b3aa1867c3..8b557efc5d 100644
--- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/get_system_capability_request.cc
+++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/get_system_capability_request.cc
@@ -164,8 +164,7 @@ void GetSystemCapabilityRequest::Run() {
break;
}
case mobile_apis::SystemCapabilityType::DRIVER_DISTRACTION:
- if (hmi_capabilities.driver_distraction_capability() &&
- hmi_capabilities.driver_distraction_supported()) {
+ if (hmi_capabilities.driver_distraction_capability()) {
response_params[strings::system_capability]
[strings::driver_distraction_capability] =
*hmi_capabilities.driver_distraction_capability();
diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/register_app_interface_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/register_app_interface_request.cc
index 5fb66c25ac..70bd47e232 100644
--- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/register_app_interface_request.cc
+++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/register_app_interface_request.cc
@@ -677,6 +677,8 @@ void FillUIRelatedFields(smart_objects::SmartObject& response_params,
response_params[strings::hmi_capabilities][strings::displays] = true;
response_params[strings::hmi_capabilities][strings::seat_location] =
hmi_capabilities.seat_location_capability() ? true : false;
+ response_params[strings::hmi_capabilities][strings::driver_distraction] =
+ hmi_capabilities.driver_distraction_supported();
}
void RegisterAppInterfaceRequest::SendRegisterAppInterfaceResponseToMobile(
diff --git a/src/components/application_manager/src/application_data_impl.cc b/src/components/application_manager/src/application_data_impl.cc
index ba86e6cb25..0bf992d68b 100644
--- a/src/components/application_manager/src/application_data_impl.cc
+++ b/src/components/application_manager/src/application_data_impl.cc
@@ -205,7 +205,7 @@ DynamicApplicationDataImpl::DynamicApplicationDataImpl()
, commands_()
, commands_lock_ptr_(std::make_shared<sync_primitives::RecursiveLock>())
, sub_menu_()
- , sub_menu_lock_ptr_(std::make_shared<sync_primitives::Lock>())
+ , sub_menu_lock_ptr_(std::make_shared<sync_primitives::RecursiveLock>())
, choice_set_map_()
, choice_set_map_lock_ptr_(std::make_shared<sync_primitives::Lock>())
, performinteraction_choice_set_map_()
diff --git a/src/components/application_manager/src/smart_object_keys.cc b/src/components/application_manager/src/smart_object_keys.cc
index 32342aba8a..7acad8d035 100644
--- a/src/components/application_manager/src/smart_object_keys.cc
+++ b/src/components/application_manager/src/smart_object_keys.cc
@@ -165,6 +165,7 @@ const char* navigation_capability = "navigationCapability";
const char* phone_capability = "phoneCapability";
const char* video_streaming_capability = "videoStreamingCapability";
const char* driver_distraction_capability = "driverDistractionCapability";
+const char* driver_distraction = "driverDistraction";
const char* rc_capability = "remoteControlCapability";
const char* seat_location_capability = "seatLocationCapability";
const char* app_services_capabilities = "appServicesCapabilities";
diff --git a/src/components/application_manager/test/include/application_manager/mock_application.h b/src/components/application_manager/test/include/application_manager/mock_application.h
index 6eb56cb53e..175c39513e 100644
--- a/src/components/application_manager/test/include/application_manager/mock_application.h
+++ b/src/components/application_manager/test/include/application_manager/mock_application.h
@@ -322,7 +322,7 @@ class MockApplication : public ::application_manager::Application {
MOCK_CONST_METHOD1(FindSubMenu,
smart_objects::SmartObject*(uint32_t menu_id));
MOCK_METHOD2(IsSubMenuNameAlreadyExist,
- bool(const std::string& name, const int32_t parent_id));
+ bool(const std::string& name, const uint32_t parent_id));
MOCK_METHOD2(AddChoiceSet,
void(uint32_t choice_set_id,
const smart_objects::SmartObject& choice_set));
diff --git a/src/components/interfaces/HMI_API.xml b/src/components/interfaces/HMI_API.xml
index fe53e9a93c..1983b20057 100644
--- a/src/components/interfaces/HMI_API.xml
+++ b/src/components/interfaces/HMI_API.xml
@@ -2817,7 +2817,7 @@
<struct name="MenuParams">
<param name="parentID" type="Integer" minvalue="0" maxvalue="2000000000" mandatory="false">
<description>unique ID of the sub menu, the command must be added to.</description>
- <description>If not provided, the command must be added to the top level of the in application menu.</description>
+ <description>If not provided or is 0, the command must be added to the top level of the in application menu.</description>
</param>
<param name="position" type="Integer" minvalue="0" maxvalue="1000" mandatory="false">
<description>Position within the items that are at the top level of the in application menu.</description>