summaryrefslogtreecommitdiff
path: root/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/vehicle_info_mobile_command_factory.cc
diff options
context:
space:
mode:
authorAlexander Kutsan (GitHub) <akutsan@luxoft.com>2019-08-30 21:10:04 +0300
committerJacob Keeler <jacob.keeler@livioradio.com>2019-08-30 14:10:04 -0400
commit0186b8c46584aa86e96f0bfa8c38e735c3f0ac0a (patch)
tree88bb8aa0c100284fb4dfb838ebc6cf0903123035 /src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/vehicle_info_mobile_command_factory.cc
parent4566d5196109591fd3cc515826ecfc725c95c79b (diff)
downloadsdl_core-0186b8c46584aa86e96f0bfa8c38e735c3f0ac0a.tar.gz
[SDL 0173] - Read Generic Network Signal Data Implementation (#2977)
* Generate policy enums from MOBILE_API Policy manager HMI level enum reorder * Add RPC vehicle data and endpoint_properties to sdl_preloaded_pt Set default version of custom vehicle data mapping * Add VehicleDataItem to policy table SQL storage implementation for VehicleDataItems Fix validation of double values in policy table Change isDouble to isNumeric during validation double values "0" should be validated as correct double value Add validation vehicle data during PTU Send in PT snapshot only version of custom VDI - During snapshot generation remove vehicle data items section - Add validation for Policy table depended on PT type Fix wrong check for vehicle data snapshot Allow empty vehicle data in PTU Change max value of string for URL from 255 to INT_MAX * Make Policy Handler forward declared to avoid high coupling * Add vehicle_info_command_params for vehicle info plugin Vehicle info params added to hmi commands * Process CustomVehicleData in GetVehicleData request * CustomVehicleDataManager implementation * Process Custom vehicle data subscriptions Refactored code. Extracted CheckFrequency to separate method in class * Check update of content of functional groups Fixes https://github.com/smartdevicelink/sdl_core/issues/2962 Add additional check for functional group content before OnPermissionChangeNotification. * rename comparing functions to make more clear their return value sense * change variable names * extra check for null values in HasNewGroups() New unit test to cover changes within functional group * Add GetPolicyConfigurationData GetPolicyCOnfigurationData Implementation * Add CustomVehicleData functionality for POLICY_EXTERNAL flow Change max value url for external policy fixes for external flow * since unti validation for the database * empty vehicle data validation * Convert data_type to VehicleDataType enum value * Validation of VehicleDataItem name and key Introduces validation of vehicle_data_item name and key validation: * they should not contain spaces; * they should not be empty or consist only spaces; * they should not contain invalid chars like '!@#$%^&*'. * Add engineOilLife to HMI_API * Remove deprecated RPC GetUrls due to major version update * Add ability to extend Smart schema with parameters Extract SMember from CObjectSchemaItem Add methods to ISchemaItem (Using composite pattern) - GetMemberSchemaItem - AddMemberSchemaItem Add implementation of VehicleDataItemSchema class Add appropriate unit tests Add creation of vehicle_data items schemes on policy event
Diffstat (limited to 'src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/vehicle_info_mobile_command_factory.cc')
-rw-r--r--src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/vehicle_info_mobile_command_factory.cc99
1 files changed, 88 insertions, 11 deletions
diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/vehicle_info_mobile_command_factory.cc b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/vehicle_info_mobile_command_factory.cc
index dffc836a89..c3c8d9c8d7 100644
--- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/vehicle_info_mobile_command_factory.cc
+++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/vehicle_info_mobile_command_factory.cc
@@ -34,6 +34,9 @@
#include "application_manager/message.h"
#include "interfaces/MOBILE_API.h"
+#include "vehicle_info_plugin/vehicle_info_command_params.h"
+
+#include "vehicle_info_plugin/custom_vehicle_data_manager.h"
#include "vehicle_info_plugin/commands/mobile/diagnostic_message_request.h"
#include "vehicle_info_plugin/commands/mobile/diagnostic_message_response.h"
@@ -54,21 +57,83 @@ CREATE_LOGGERPTR_GLOBAL(logger_, "VehicleInfoPlugin")
namespace vehicle_info_plugin {
namespace strings = app_mngr::strings;
+template <typename VehicleInfoCommandType>
+class VehicleInfoCommandCreator : public application_manager::CommandCreator {
+ public:
+ VehicleInfoCommandCreator(const VehicleInfoCommandParams& params)
+ : params_(params) {}
+
+ private:
+ bool CanBeCreated() const override {
+ return true;
+ }
+
+ application_manager::CommandSharedPtr create(
+ const application_manager::commands::MessageSharedPtr& message)
+ const override {
+ application_manager::CommandSharedPtr command(
+ new VehicleInfoCommandType(message, params_));
+ return command;
+ }
+
+ VehicleInfoCommandParams params_;
+};
+
+struct VehicleInfoInvalidCommand {};
+
+template <>
+class VehicleInfoCommandCreator<VehicleInfoInvalidCommand>
+ : public application_manager::CommandCreator {
+ public:
+ VehicleInfoCommandCreator(const VehicleInfoCommandParams& params) {
+ UNUSED(params);
+ }
+
+ private:
+ bool CanBeCreated() const override {
+ return false;
+ }
+
+ application_manager::CommandSharedPtr create(
+ const application_manager::commands::MessageSharedPtr& message)
+ const override {
+ UNUSED(message);
+ return application_manager::CommandSharedPtr();
+ }
+};
+
+struct VehicleInfoCommandCreatorFactory {
+ VehicleInfoCommandCreatorFactory(const VehicleInfoCommandParams& params)
+ : params_(params) {}
+
+ template <typename VehicleInfoCommandType>
+ application_manager::CommandCreator& GetCreator() {
+ LOG4CXX_AUTO_TRACE(logger_);
+ static VehicleInfoCommandCreator<VehicleInfoCommandType> res(params_);
+ return res;
+ }
+ const VehicleInfoCommandParams params_;
+};
+
VehicleInfoMobileCommandFactory::VehicleInfoMobileCommandFactory(
application_manager::ApplicationManager& application_manager,
application_manager::rpc_service::RPCService& rpc_service,
application_manager::HMICapabilities& hmi_capabilities,
- policy::PolicyHandlerInterface& policy_handler)
+ policy::PolicyHandlerInterface& policy_handler,
+ CustomVehicleDataManager& custom_vehicle_data_manager)
: application_manager_(application_manager)
, rpc_service_(rpc_service)
, hmi_capabilities_(hmi_capabilities)
- , policy_handler_(policy_handler) {
+ , policy_handler_(policy_handler)
+ , custom_vehicle_data_manager_(custom_vehicle_data_manager) {
LOG4CXX_AUTO_TRACE(logger_);
}
app_mngr::CommandSharedPtr VehicleInfoMobileCommandFactory::CreateCommand(
const app_mngr::commands::MessageSharedPtr& message,
app_mngr::commands::Command::CommandSource source) {
+ UNUSED(source);
+
const mobile_apis::FunctionID::eType function_id =
static_cast<mobile_apis::FunctionID::eType>(
(*message)[strings::params][strings::function_id].asInt());
@@ -105,8 +170,12 @@ bool VehicleInfoMobileCommandFactory::IsAbleToProcess(
app_mngr::CommandCreator& VehicleInfoMobileCommandFactory::get_command_creator(
const mobile_apis::FunctionID::eType id,
const mobile_apis::messageType::eType message_type) const {
- auto factory = app_mngr::CommandCreatorFactory(
- application_manager_, rpc_service_, hmi_capabilities_, policy_handler_);
+ VehicleInfoCommandParams params = {application_manager_,
+ rpc_service_,
+ hmi_capabilities_,
+ policy_handler_,
+ custom_vehicle_data_manager_};
+ auto factory = VehicleInfoCommandCreatorFactory(params);
switch (id) {
case mobile_apis::FunctionID::GetVehicleDataID: {
return mobile_apis::messageType::request == message_type
@@ -141,21 +210,25 @@ app_mngr::CommandCreator& VehicleInfoMobileCommandFactory::get_command_creator(
}
default: {}
}
- return factory.GetCreator<app_mngr::InvalidCommand>();
+ return factory.GetCreator<VehicleInfoInvalidCommand>();
}
app_mngr::CommandCreator&
VehicleInfoMobileCommandFactory::get_notification_creator(
const mobile_apis::FunctionID::eType id) const {
- auto factory = app_mngr::CommandCreatorFactory(
- application_manager_, rpc_service_, hmi_capabilities_, policy_handler_);
+ VehicleInfoCommandParams params = {application_manager_,
+ rpc_service_,
+ hmi_capabilities_,
+ policy_handler_,
+ custom_vehicle_data_manager_};
+ auto factory = VehicleInfoCommandCreatorFactory(params);
switch (id) {
case mobile_apis::FunctionID::OnVehicleDataID: {
return factory.GetCreator<commands::OnVehicleDataNotification>();
}
default: {}
}
- return factory.GetCreator<app_mngr::InvalidCommand>();
+ return factory.GetCreator<VehicleInfoInvalidCommand>();
}
app_mngr::CommandCreator& VehicleInfoMobileCommandFactory::get_creator_factory(
@@ -183,8 +256,12 @@ app_mngr::CommandCreator& VehicleInfoMobileCommandFactory::get_creator_factory(
}
default: {}
}
- auto factory = app_mngr::CommandCreatorFactory(
- application_manager_, rpc_service_, hmi_capabilities_, policy_handler_);
- return factory.GetCreator<app_mngr::InvalidCommand>();
+ VehicleInfoCommandParams params = {application_manager_,
+ rpc_service_,
+ hmi_capabilities_,
+ policy_handler_,
+ custom_vehicle_data_manager_};
+ auto factory = VehicleInfoCommandCreatorFactory(params);
+ return factory.GetCreator<VehicleInfoInvalidCommand>();
}
} // namespace vehicle_info_plugin