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 fc124f75584..11d3f795882 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 @@ -1,5 +1,5 @@ /* - Copyright (c) 2013, Ford Motor Company + Copyright (c) 2019, Ford Motor Company All rights reserved. Redistribution and use in source and binary forms, with or without @@ -344,6 +344,10 @@ extern const char* activate; extern const char* set_as_default; extern const char* origin_app; +// sis data +extern const char* station_short_name; +extern const char* station_location; + // resuming extern const char* application_commands; extern const char* application_submenus; @@ -367,8 +371,11 @@ extern const char* global_ign_on_counter; extern const char* connection_info; extern const char* is_download_complete; +extern const char* shifted; +extern const char* altitude; extern const char* longitude_degrees; extern const char* latitude_degrees; + extern const char* address; extern const char* country_name; extern const char* country_code; diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/rc_helpers.h b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/rc_helpers.h index cd87ad326ee..e85ab758ad5 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/rc_helpers.h +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/rc_helpers.h @@ -91,6 +91,15 @@ class RCHelpers { AppsModules; static AppsModules GetApplicationsAllowedModules( application_manager::ApplicationManager& app_mngr); + + /** + * @brief RemoveRedundantGPSDataFromVIDataMsg removes redundant GPS data + * params from interior vehicle data response message if one contains radio + * station location data + * @param msg_params Params of the interior vehicle data response message + */ + static void RemoveRedundantGPSDataFromIVDataMsg( + smart_objects::SmartObject& msg_params); }; } // namespace rc_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/get_interior_vehicle_data_response.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/get_interior_vehicle_data_response.cc index a7572f1d627..b1fa8d6ea0a 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/get_interior_vehicle_data_response.cc +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/get_interior_vehicle_data_response.cc @@ -31,6 +31,7 @@ */ #include "rc_rpc_plugin/commands/mobile/get_interior_vehicle_data_response.h" +#include "rc_rpc_plugin/rc_helpers.h" #include "utils/macro.h" namespace rc_rpc_plugin { @@ -49,6 +50,9 @@ GetInteriorVehicleDataResponse::~GetInteriorVehicleDataResponse() {} void GetInteriorVehicleDataResponse::Run() { LOG4CXX_AUTO_TRACE(logger_); + + RCHelpers::RemoveRedundantGPSDataFromIVDataMsg( + (*message_)[app_mngr::strings::msg_params]); application_manager_.GetRPCService().SendMessageToMobile(message_); } diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/on_interior_vehicle_data_notification.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/on_interior_vehicle_data_notification.cc index 53b04ce3efb..06b5218bb33 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/on_interior_vehicle_data_notification.cc +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/on_interior_vehicle_data_notification.cc @@ -75,6 +75,8 @@ void OnInteriorVehicleDataNotification::Run() { typedef std::vector AppPtrs; AppPtrs apps = RCRPCPlugin::GetRCApplications(application_manager_); + RCHelpers::RemoveRedundantGPSDataFromIVDataMsg( + (*message_)[app_mngr::strings::msg_params]); for (AppPtrs::iterator it = apps.begin(); it != apps.end(); ++it) { DCHECK(*it); application_manager::Application& app = **it; diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/rc_helpers.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/rc_helpers.cc index b39b67d669c..5785e58e5bf 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/rc_helpers.cc +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/rc_helpers.cc @@ -115,4 +115,30 @@ RCHelpers::AppsModules RCHelpers::GetApplicationsAllowedModules( } return result; } + +void RCHelpers::RemoveRedundantGPSDataFromIVDataMsg( + smart_objects::SmartObject& msg_params) { + using namespace message_params; + using namespace application_manager::strings; + + LOG4CXX_AUTO_TRACE(logger_); + auto& module_data = msg_params[kModuleData]; + if (!module_data.keyExists(kRadioControlData) || + !module_data[kRadioControlData].keyExists(kSisData) || + !module_data[kRadioControlData][kSisData].keyExists(station_location)) { + return; + } + + auto& location_data = + module_data[kRadioControlData][kSisData][station_location]; + auto new_location_data = + smart_objects::SmartObject(smart_objects::SmartType_Map); + new_location_data[latitude_degrees] = location_data[latitude_degrees]; + new_location_data[longitude_degrees] = location_data[longitude_degrees]; + if (location_data.keyExists(altitude)) { + new_location_data[altitude] = location_data[altitude]; + + location_data = new_location_data; + } +} } // namespace rc_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/commands/get_interior_vehicle_data_request_test.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/commands/get_interior_vehicle_data_request_test.cc index 1adc8caf939..123c22b944b 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/commands/get_interior_vehicle_data_request_test.cc +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/commands/get_interior_vehicle_data_request_test.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Ford Motor Company + * Copyright (c) 2019, Ford Motor Company * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -248,7 +248,19 @@ TEST_F( (*mobile_message)[application_manager::strings::msg_params] [message_params::kModuleType] = module_type; smart_objects::SmartObject radio_data; + smart_objects::SmartObject sis_data; + smart_objects::SmartObject gps_data; + + gps_data[application_manager::strings::longitude_degrees] = 1.0; + gps_data[application_manager::strings::latitude_degrees] = 1.0; + + sis_data[application_manager::strings::station_short_name] = + "dummy_short_name"; + sis_data[application_manager::strings::station_location] = gps_data; + radio_data[message_params::kBand] = enums_value::kAM; + radio_data[message_params::kSisData] = sis_data; + std::shared_ptr command = CreateRCCommand< rc_rpc_plugin::commands::GetInteriorVehicleDataRequest>( diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/on_vehicle_data_notification.cc b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/on_vehicle_data_notification.cc index 6ef76ad1259..7d34bbbe370 100644 --- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/on_vehicle_data_notification.cc +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/on_vehicle_data_notification.cc @@ -72,7 +72,7 @@ void OnVehicleDataNotification::Run() { for (; vehicle_data.end() != it; ++it) { if (true == (*message_)[strings::msg_params].keyExists(it->first)) { - LOG4CXX_ERROR(logger_, "vehicle_data nanme" << it->first); + LOG4CXX_DEBUG(logger_, "vehicle_data name" << it->first); auto vehicle_data_value = (*message_)[strings::msg_params][it->first].asInt(); diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/commands/mobile/get_vehicle_data_response_test.cc b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/commands/mobile/get_vehicle_data_response_test.cc new file mode 100644 index 00000000000..fb14373bcf7 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/commands/mobile/get_vehicle_data_response_test.cc @@ -0,0 +1,67 @@ +/* + * Copyright (c) 2019, 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 "gtest/gtest.h" + +#include "application_manager/commands/commands_test.h" +#include "mobile/get_vehicle_data_response.h" +#include "smart_objects/smart_object.h" + +namespace test { +namespace components { +namespace commands_test { +namespace mobile_commands_test { +namespace get_vehicle_data_response { + +namespace am = ::application_manager; +using am::commands::MessageSharedPtr; +using vehicle_info_plugin::commands::GetVehicleDataResponse; + +typedef std::shared_ptr GetVehicleDataResponsePtr; + +class GetVehicleDataResponseTest + : public CommandsTest {}; + +TEST_F(GetVehicleDataResponseTest, GetVehicleDataResponse_SUCCESS) { + MessageSharedPtr message(CreateMessage(smart_objects::SmartType_Map)); + GetVehicleDataResponsePtr command( + CreateCommand(message)); + + EXPECT_CALL(mock_rpc_service_, SendMessageToMobile(message, _)); + command->Run(); +} + +} // namespace get_vehicle_data_response +} // namespace mobile_commands_test +} // namespace commands_test +} // namespace components +} // namespace test diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/commands/mobile/on_vehicle_data_notification_test.cc b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/commands/mobile/on_vehicle_data_notification_test.cc index 7081746f284..8df00521ded 100644 --- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/commands/mobile/on_vehicle_data_notification_test.cc +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/commands/mobile/on_vehicle_data_notification_test.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Ford Motor Company + * Copyright (c) 2019, Ford Motor Company * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -30,9 +30,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#include -#include -#include +#include #include "gtest/gtest.h" #include "mobile/on_vehicle_data_notification.h" @@ -45,6 +43,8 @@ #include "smart_objects/smart_object.h" #include "utils/custom_string.h" #include "utils/helpers.h" +#include "vehicle_info_plugin/vehicle_info_app_extension.h" +#include "vehicle_info_plugin/vehicle_info_plugin.h" namespace test { namespace components { @@ -62,49 +62,75 @@ using am::commands::MessageSharedPtr; using vehicle_info_plugin::commands::OnVehicleDataNotification; typedef std::shared_ptr NotificationPtr; +typedef std::shared_ptr + VehicleInfoAppExtensionPtr; +typedef DataAccessor ApplicationSetDA; namespace { const uint32_t kAppId = 1u; +const utils::custom_string::CustomString kAppName("test_app"); } // namespace class OnVehicleDataNotificationTest : public CommandsTest { public: - OnVehicleDataNotificationTest() - : command_msg_(CreateMessage(smart_objects::SmartType_Map)) - , command_(CreateCommand(command_msg_)) {} + OnVehicleDataNotificationTest() : mock_app_(CreateMockApp()) {} - MessageSharedPtr command_msg_; - NotificationPtr command_; + protected: + void SetUp() OVERRIDE { + ON_CALL(*mock_app_, app_id()).WillByDefault(Return(kAppId)); + ON_CALL(*mock_app_, name()).WillByDefault(ReturnRef(kAppName)); + + ON_CALL(mock_message_helper_, PrintSmartObject(_)) + .WillByDefault(Return(false)); + } + MockAppPtr mock_app_; }; -MATCHER_P2(CheckMessageData, key, value, "") { - const bool kIsMobileProtocolTypeCorrect = - (*arg)[am::strings::params][am::strings::protocol_type].asInt() == - am::commands::CommandImpl::mobile_protocol_type_; - - const bool kIsProtocolVersionCorrect = - (*arg)[am::strings::params][am::strings::protocol_version].asInt() == - am::commands::CommandImpl::protocol_version_; - - const bool kIsNotificationCorrect = - (*arg)[am::strings::params][am::strings::message_type].asInt() == - am::MessageType::kNotification; - - const bool kIsConnectionKeyCorrect = - (*arg)[am::strings::params][am::strings::connection_key].asUInt() == - kAppId; - - const bool kAreMsgParamsCorrect = - (*arg)[am::strings::msg_params][key].asInt() == value; - - using namespace helpers; - return Compare(true, - kIsMobileProtocolTypeCorrect, - kIsProtocolVersionCorrect, - kIsNotificationCorrect, - kIsConnectionKeyCorrect, - kAreMsgParamsCorrect); +TEST_F(OnVehicleDataNotificationTest, OnVehicleDataNotification_SUCCESS) { + MessageSharedPtr message(CreateMessage(smart_objects::SmartType_Map)); + smart_objects::SmartObject gps_data; + gps_data[am::strings::longitude_degrees] = 1.0; + gps_data[am::strings::latitude_degrees] = 1.0; + gps_data[am::strings::shifted] = true; + + (*message)[am::strings::msg_params][am::strings::gps] = gps_data; + (*message)[am::strings::msg_params][am::strings::speed] = 0; + + NotificationPtr command(CreateCommand(message)); + + vehicle_info_plugin::VehicleInfoPlugin vi_plugin; + VehicleInfoAppExtensionPtr vi_app_extention_ptr = + std::make_shared( + vi_plugin, *mock_app_); + vi_app_extention_ptr->subscribeToVehicleInfo( + mobile_apis::VehicleDataType::VEHICLEDATA_GPS); + vi_app_extention_ptr->subscribeToVehicleInfo( + mobile_apis::VehicleDataType::VEHICLEDATA_SPEED); + + EXPECT_CALL(*mock_app_, + QueryInterface(vehicle_info_plugin::VehicleInfoAppExtension:: + VehicleInfoAppExtensionUID)) + .WillOnce(Return(vi_app_extention_ptr)); + + application_manager::ApplicationSet apps; + apps.insert(mock_app_); + std::shared_ptr apps_lock = + std::make_shared(); + ApplicationSetDA apps_da(apps, apps_lock); + EXPECT_CALL(app_mngr_, applications()).WillOnce(Return(apps_da)); + + am::VehicleData vehicle_data; + vehicle_data.insert(am::VehicleData::value_type( + am::strings::gps, mobile_apis::VehicleDataType::VEHICLEDATA_GPS)); + vehicle_data.insert(am::VehicleData::value_type( + am::strings::gps, mobile_apis::VehicleDataType::VEHICLEDATA_SPEED)); + EXPECT_CALL(mock_message_helper_, vehicle_data()) + .WillOnce(ReturnRef(vehicle_data)); + + EXPECT_CALL(mock_rpc_service_, SendMessageToMobile(message, _)); + + command->Run(); } } // namespace on_vehicle_data_notification diff --git a/src/components/application_manager/src/smart_object_keys.cc b/src/components/application_manager/src/smart_object_keys.cc index 872103929fc..23b7fd2b34c 100644 --- a/src/components/application_manager/src/smart_object_keys.cc +++ b/src/components/application_manager/src/smart_object_keys.cc @@ -311,6 +311,10 @@ const char* activate = "activate"; const char* set_as_default = "setAsDefault"; const char* origin_app = "originApp"; +// sis data +const char* station_short_name = "stationShortName"; +const char* station_location = "stationLocation"; + // resuming const char* application_commands = "applicationCommands"; const char* application_submenus = "applicationSubMenus"; @@ -339,8 +343,12 @@ const char* time_stamp = "timeStamp"; const char* manual_text_entry = "manualTextEntry"; const char* image_type_supported = "imageTypeSupported"; const char* unexpected_disconnect = "unexpectedDisconnect"; + +const char* shifted = "shifted"; +const char* altitude = "altitude"; const char* longitude_degrees = "longitudeDegrees"; const char* latitude_degrees = "latitudeDegrees"; + const char* address = "address"; const char* country_name = "countryName"; const char* country_code = "countryCode"; diff --git a/src/components/interfaces/HMI_API.xml b/src/components/interfaces/HMI_API.xml index 488c986df51..94bb55076b4 100644 --- a/src/components/interfaces/HMI_API.xml +++ b/src/components/interfaces/HMI_API.xml @@ -1845,6 +1845,13 @@ The speed in KPH + + + True, if GPS lat/long, time, and altitude have been purposefully shifted (requires a proprietary algorithm to unshift). + False, if the GPS data is raw and un-shifted. + If not provided, then value is assumed False. + + diff --git a/src/components/interfaces/MOBILE_API.xml b/src/components/interfaces/MOBILE_API.xml index d6fe4d6cc0d..1a7c5d640ff 100644 --- a/src/components/interfaces/MOBILE_API.xml +++ b/src/components/interfaces/MOBILE_API.xml @@ -2014,6 +2014,13 @@ + + + True, if GPS lat/long, time, and altitude have been purposefully shifted (requires a proprietary algorithm to unshift). + False, if the GPS data is raw and un-shifted. + If not provided, then value is assumed False. + +