summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShobhit Adlakha <ShobhitAd@users.noreply.github.com>2022-08-31 14:07:39 -0400
committerGitHub <noreply@github.com>2022-08-31 14:07:39 -0400
commit9f94fcde4cd2d1a48171ca0e171cffdd5b437e87 (patch)
tree756448a754b904f37bdb46fb2890307edc29f58e
parent8dbee748657b06cbb4d7731810ae962cbe951f97 (diff)
downloadsdl_core-9f94fcde4cd2d1a48171ca0e171cffdd5b437e87.tar.gz
Fix CheckButtonName check for module types other than CLIMATE and RADIO (#3944)
* Fix CheckButtonName to work with module types other than climate and radio * Move SOURCE button name from buttons_radio to buttons_audio * Revert "Move SOURCE button name from buttons_radio to buttons_audio" This reverts commit fde9b4bfee4cc1b1e98346c670e92816b52084cd. * Address review comment
-rw-r--r--src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/rc_capabilities_manager_impl.cc25
1 files changed, 13 insertions, 12 deletions
diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/rc_capabilities_manager_impl.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/rc_capabilities_manager_impl.cc
index 75ccd46e4d..875455f545 100644
--- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/rc_capabilities_manager_impl.cc
+++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/rc_capabilities_manager_impl.cc
@@ -371,23 +371,24 @@ bool RCCapabilitiesManagerImpl::CheckButtonName(
SDL_LOG_AUTO_TRACE();
auto rc_capabilities = hmi_capabilities_.rc_capability();
if (!rc_capabilities) {
- SDL_LOG_ERROR("No remote controll capabilities available");
+ SDL_LOG_ERROR("No remote control capabilities available");
return false;
}
- if (enums_value::kRadio == module_type) {
- if (!helpers::in_range(RCHelpers::buttons_radio(), button_name)) {
- SDL_LOG_WARN("Trying to acceess climate button with module type radio");
- return false;
- }
- }
+ auto module_type_mismatch = [&button_name, &module_type](
+ const std::string& type,
+ const std::vector<std::string>&& buttons) {
+ return (helpers::in_range(buttons, button_name) && type != module_type);
+ };
- if (enums_value::kClimate == module_type) {
- if (!helpers::in_range(RCHelpers::buttons_climate(), button_name)) {
- SDL_LOG_WARN("Trying to acceess radio button with module type climate");
- return false;
- }
+ if (module_type_mismatch(enums_value::kRadio, RCHelpers::buttons_radio()) ||
+ module_type_mismatch(enums_value::kClimate,
+ RCHelpers::buttons_climate())) {
+ SDL_LOG_WARN("Trying to access incompatible button: "
+ << button_name << " with module type: " << module_type);
+ return false;
}
+
return true;
}