summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShobhit Adlakha <ShobhitAd@users.noreply.github.com>2019-06-28 13:46:03 -0400
committerGitHub <noreply@github.com>2019-06-28 13:46:03 -0400
commit18ca3b719bd2442a4370dfba34e1c4ab885ba6e7 (patch)
treef47eff6b4e5e5a15478f09e26a9b182f226404f5
parentd9ac61f77b1fb39619dc5bf0c0841684d93cff58 (diff)
parenta0a5e1e2016caeefd2cc521a0f35353da092497a (diff)
downloadsdl_core-18ca3b719bd2442a4370dfba34e1c4ab885ba6e7.tar.gz
Merge pull request #2741 from smartdevicelink/feature/gps_shift_support
Feature/GPS Shift support
-rw-r--r--src/components/application_manager/include/application_manager/smart_object_keys.h9
-rw-r--r--src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/rc_helpers.h9
-rw-r--r--src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/get_interior_vehicle_data_response.cc4
-rw-r--r--src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/on_interior_vehicle_data_notification.cc2
-rw-r--r--src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/rc_helpers.cc26
-rw-r--r--src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/commands/get_interior_vehicle_data_request_test.cc14
-rw-r--r--src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/on_vehicle_data_notification.cc2
-rw-r--r--src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/commands/mobile/get_vehicle_data_response_test.cc67
-rw-r--r--src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/commands/mobile/on_vehicle_data_notification_test.cc98
-rw-r--r--src/components/application_manager/src/smart_object_keys.cc8
-rw-r--r--src/components/interfaces/HMI_API.xml7
-rw-r--r--src/components/interfaces/MOBILE_API.xml7
12 files changed, 214 insertions, 39 deletions
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 fc124f7558..11d3f79588 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 cd87ad326e..e85ab758ad 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 a7572f1d62..b1fa8d6ea0 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 53b04ce3ef..06b5218bb3 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<application_manager::ApplicationSharedPtr> 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 b39b67d669..5785e58e5b 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 1adc8caf93..123c22b944 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<rc_rpc_plugin::commands::GetInteriorVehicleDataRequest>
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 6ef76ad125..7d34bbbe37 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 0000000000..fb14373bcf
--- /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<GetVehicleDataResponse> GetVehicleDataResponsePtr;
+
+class GetVehicleDataResponseTest
+ : public CommandsTest<CommandsTestMocks::kIsNice> {};
+
+TEST_F(GetVehicleDataResponseTest, GetVehicleDataResponse_SUCCESS) {
+ MessageSharedPtr message(CreateMessage(smart_objects::SmartType_Map));
+ GetVehicleDataResponsePtr command(
+ CreateCommand<GetVehicleDataResponse>(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 7081746f28..8df00521de 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 <stdint.h>
-#include <map>
-#include <vector>
+#include <strings.h>
#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<OnVehicleDataNotification> NotificationPtr;
+typedef std::shared_ptr<vehicle_info_plugin::VehicleInfoAppExtension>
+ VehicleInfoAppExtensionPtr;
+typedef DataAccessor<application_manager::ApplicationSet> ApplicationSetDA;
namespace {
const uint32_t kAppId = 1u;
+const utils::custom_string::CustomString kAppName("test_app");
} // namespace
class OnVehicleDataNotificationTest
: public CommandsTest<CommandsTestMocks::kIsNice> {
public:
- OnVehicleDataNotificationTest()
- : command_msg_(CreateMessage(smart_objects::SmartType_Map))
- , command_(CreateCommand<OnVehicleDataNotification>(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<bool, EQ, ALL>(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<OnVehicleDataNotification>(message));
+
+ vehicle_info_plugin::VehicleInfoPlugin vi_plugin;
+ VehicleInfoAppExtensionPtr vi_app_extention_ptr =
+ std::make_shared<vehicle_info_plugin::VehicleInfoAppExtension>(
+ 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<sync_primitives::Lock> apps_lock =
+ std::make_shared<sync_primitives::Lock>();
+ 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 872103929f..23b7fd2b34 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 488c986df5..94bb55076b 100644
--- a/src/components/interfaces/HMI_API.xml
+++ b/src/components/interfaces/HMI_API.xml
@@ -1845,6 +1845,13 @@
<param name="speed" type="Float" minvalue="0" maxvalue="500" mandatory="false">
<description>The speed in KPH</description>
</param>
+ <param name="shifted" type="Boolean" mandatory="false">
+ <description>
+ 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.
+ </description>
+ </param>
</struct>
<struct name="SisData">
diff --git a/src/components/interfaces/MOBILE_API.xml b/src/components/interfaces/MOBILE_API.xml
index d6fe4d6cc0..1a7c5d640f 100644
--- a/src/components/interfaces/MOBILE_API.xml
+++ b/src/components/interfaces/MOBILE_API.xml
@@ -2014,6 +2014,13 @@
<param name="speed" type="Float" minvalue="0" maxvalue="500" mandatory="true" since="2.0" until="5.0"/>
</history>
</param>
+ <param name="shifted" type="Boolean" mandatory="false" since="6.0">
+ <description>
+ 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.
+ </description>
+ </param>
</struct>
<struct name="VehicleDataResult" since="2.0">