From f3c873abfbb9e5ac9a04ddd8ae4a53d436b066f7 Mon Sep 17 00:00:00 2001 From: Iryna Lytvynenko Date: Tue, 16 Oct 2018 10:32:52 -0400 Subject: Fix the Light Name conversion from string to enum value in default capabilities --- .../include/application_manager/message_helper.h | 8 ++++++++ .../application_manager/src/hmi_capabilities_impl.cc | 14 ++++++++++++++ .../src/message_helper/message_helper.cc | 11 +++++++++++ .../test/include/application_manager/mock_message_helper.h | 2 ++ .../application_manager/test/mock_message_helper.cc | 6 ++++++ 5 files changed, 41 insertions(+) diff --git a/src/components/application_manager/include/application_manager/message_helper.h b/src/components/application_manager/include/application_manager/message_helper.h index 609b240301..93cf6f9ad3 100644 --- a/src/components/application_manager/include/application_manager/message_helper.h +++ b/src/components/application_manager/include/application_manager/message_helper.h @@ -786,6 +786,14 @@ class MessageHelper { static hmi_apis::Common_Language::eType CommonLanguageFromString( const std::string& language); + /** + * @brief CommonLightNameFromString convert string to LightName enum value + * @param lightName string to convert + * @return value LightName enum value + */ + static hmi_apis::Common_LightName::eType CommonLightNameFromString( + const std::string& lightName); + static smart_objects::SmartObjectSPtr GetOnAppInterfaceUnregisteredNotificationToMobile( int32_t connection_key, diff --git a/src/components/application_manager/src/hmi_capabilities_impl.cc b/src/components/application_manager/src/hmi_capabilities_impl.cc index f67590543d..6cd6747e99 100644 --- a/src/components/application_manager/src/hmi_capabilities_impl.cc +++ b/src/components/application_manager/src/hmi_capabilities_impl.cc @@ -1170,6 +1170,20 @@ bool HMICapabilitiesImpl::load_capabilities_from_file() { smart_objects::SmartObject rc_capability_so; formatters::CFormatterJsonBase::jsonValueToObj(rc_capability, rc_capability_so); + if (rc_capability_so.keyExists("lightControlCapabilities")) { + if (rc_capability_so["lightControlCapabilities"].keyExists( + "supportedLights")) { + auto& lights = rc_capability_so["lightControlCapabilities"] + ["supportedLights"]; + auto it = lights.asArray()->begin(); + for (; it != lights.asArray()->end(); ++it) { + smart_objects::SmartObject& light_name_so = (*it)["name"]; + auto light_name = MessageHelper::CommonLightNameFromString( + light_name_so.asString()); + light_name_so = light_name; + } + } + } set_rc_capability(rc_capability_so); if (!rc_capability_so.empty()) { set_rc_supported(true); diff --git a/src/components/application_manager/src/message_helper/message_helper.cc b/src/components/application_manager/src/message_helper/message_helper.cc index e99db3bece..d2f338c3ce 100644 --- a/src/components/application_manager/src/message_helper/message_helper.cc +++ b/src/components/application_manager/src/message_helper/message_helper.cc @@ -288,6 +288,17 @@ hmi_apis::Common_Language::eType MessageHelper::CommonLanguageFromString( return hmi_apis::Common_Language::INVALID_ENUM; } +hmi_apis::Common_LightName::eType MessageHelper::CommonLightNameFromString( + const std::string& lightName) { + using namespace ns_smart_device_link::ns_smart_objects; + hmi_apis::Common_LightName::eType value; + if (EnumConversionHelper::StringToEnum( + lightName, &value)) { + return value; + } + return hmi_apis::Common_LightName::INVALID_ENUM; +} + std::string MessageHelper::GetDeviceMacAddressForHandle( const transport_manager::DeviceHandle device_handle, const ApplicationManager& app_mngr) { diff --git a/src/components/application_manager/test/include/application_manager/mock_message_helper.h b/src/components/application_manager/test/include/application_manager/mock_message_helper.h index 84a3b6bc87..1a4c561ab4 100644 --- a/src/components/application_manager/test/include/application_manager/mock_message_helper.h +++ b/src/components/application_manager/test/include/application_manager/mock_message_helper.h @@ -164,6 +164,8 @@ class MockMessageHelper { ApplicationManager& app_mngr)); MOCK_METHOD1(CommonLanguageFromString, hmi_apis::Common_Language::eType(const std::string& language)); + MOCK_METHOD1(CommonLightNameFromString, + hmi_apis::Common_LightName::eType(const std::string& lightName)); MOCK_METHOD1(CommonLanguageToString, std::string(hmi_apis::Common_Language::eType)); MOCK_METHOD2(CreateModuleInfoSO, diff --git a/src/components/application_manager/test/mock_message_helper.cc b/src/components/application_manager/test/mock_message_helper.cc index f091e183dc..180818f401 100644 --- a/src/components/application_manager/test/mock_message_helper.cc +++ b/src/components/application_manager/test/mock_message_helper.cc @@ -277,6 +277,12 @@ hmi_apis::Common_Language::eType MessageHelper::CommonLanguageFromString( language); } +hmi_apis::Common_LightName::eType MessageHelper::CommonLightNameFromString( + const std::string& lightName) { + return MockMessageHelper::message_helper_mock()->CommonLightNameFromString( + lightName); +} + smart_objects::SmartObjectSPtr MessageHelper::CreateModuleInfoSO( uint32_t function_id, ApplicationManager& app_mngr) { return MockMessageHelper::message_helper_mock()->CreateModuleInfoSO( -- cgit v1.2.1 From bbb1d7b1106089e76ec7dc75965d6e6c18fca911 Mon Sep 17 00:00:00 2001 From: theresalech Date: Fri, 26 Oct 2018 09:32:17 -0400 Subject: add link to best practices --- .github/ISSUE_TEMPLATE.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md index 1b58b20e86..d62fd997a0 100644 --- a/.github/ISSUE_TEMPLATE.md +++ b/.github/ISSUE_TEMPLATE.md @@ -1,4 +1,4 @@ -[Delete any non-applicable sections, but we may ask for more information.] +[Delete any non-applicable sections, but we may ask for more information. Please reference the [SmartDeviceLink GitHub Best Practices](https://d83tozu1c8tt6.cloudfront.net/media/resources/SDL_GitHub_BestPractices.pdf) for further instructions on how to enter an issue.] ### Bug Report [Summary] @@ -20,4 +20,4 @@ * Testing Against: [What you tested with to observe this behavior. Proxy, App, HMI etc.] ##### Test Case, Sample Code, and / or Example App -[Paste a link to a PR, gist, or other code that exemplifies this behavior] \ No newline at end of file +[Paste a link to a PR, gist, or other code that exemplifies this behavior] -- cgit v1.2.1 From 0bd19c8c29c6212fa314003428f6d1c81bc3d528 Mon Sep 17 00:00:00 2001 From: theresalech Date: Fri, 26 Oct 2018 09:34:53 -0400 Subject: add best practices link and review information --- .github/PULL_REQUEST_TEMPLATE.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index 83c3261f9b..260d3b55ad 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -1,4 +1,4 @@ -[Things to note: Pull Requests **must** fix an issue. Discussion about the feature / bug takes place in the issue, discussion of the implementation takes place in the PR. Please also see the [Contributing Guide](https://github.com/smartdevicelink/sdl_core/blob/master/.github/CONTRIBUTING.md) for information on branch naming and the CLA. +[Things to note: Pull Requests **must** fix an issue. Discussion about the feature / bug takes place in the issue, discussion of the implementation takes place in the PR. Please also see the [Contributing Guide](https://github.com/smartdevicelink/sdl_core/blob/master/.github/CONTRIBUTING.md) for information on branch naming and the CLA, and the [SmartDeviceLink GitHub Best Practices](https://d83tozu1c8tt6.cloudfront.net/media/resources/SDL_GitHub_BestPractices.pdf) document for more information on how to enter a pull request. Once this PR is ready for review, please request one from @jordynmackool. Delete the above section when you've read it.] @@ -30,4 +30,4 @@ This PR makes **[no / minor / major]** API changes. - [ ] [Task 2] ### CLA -- [ ] I have signed [the CLA](https://docs.google.com/forms/d/e/1FAIpQLSdsgJY33VByaX482zHzi-xUm49JNnmuJOyAM6uegPQ2LXYVfA/viewform) \ No newline at end of file +- [ ] I have signed [the CLA](https://docs.google.com/forms/d/e/1FAIpQLSdsgJY33VByaX482zHzi-xUm49JNnmuJOyAM6uegPQ2LXYVfA/viewform) -- cgit v1.2.1 From 6d14dbb88bdbaf6c699c4736047ac0e5c385a116 Mon Sep 17 00:00:00 2001 From: ShobhitAd Date: Wed, 31 Oct 2018 09:51:05 -0500 Subject: Added CloupAppVehicleID param to MOBILE and HMI API --- src/components/interfaces/HMI_API.xml | 20 ++++++++++++++++++++ src/components/interfaces/MOBILE_API.xml | 8 ++++++++ 2 files changed, 28 insertions(+) diff --git a/src/components/interfaces/HMI_API.xml b/src/components/interfaces/HMI_API.xml index 97df559ef5..4c4a01ed9d 100644 --- a/src/components/interfaces/HMI_API.xml +++ b/src/components/interfaces/HMI_API.xml @@ -1094,6 +1094,7 @@ + @@ -4967,6 +4968,8 @@ Information related to the MyKey feature + + @@ -5055,6 +5058,8 @@ Information related to the MyKey feature + + @@ -5149,6 +5154,7 @@ Information related to the MyKey feature + @@ -5237,6 +5243,8 @@ Information related to the MyKey feature + + Non periodic vehicle data read request. @@ -5312,6 +5320,7 @@ The status of the park brake as provided by Electric Park Brake (EPB) system. + Emergency Call notification and confirmation data @@ -5327,6 +5336,9 @@ Information related to the MyKey feature + + + @@ -5401,6 +5413,7 @@ The status of the park brake as provided by Electric Park Brake (EPB) system. + Emergency Call notification and confirmation data @@ -5416,6 +5429,9 @@ Information related to the MyKey feature + + + Callback for the periodic and non periodic vehicle data read function. @@ -5488,6 +5504,7 @@ Current angle of the steering wheel (in deg) + Emergency Call notification and confirmation data @@ -5503,6 +5520,9 @@ Information related to the MyKey feature + + + diff --git a/src/components/interfaces/MOBILE_API.xml b/src/components/interfaces/MOBILE_API.xml index 76fc6ef2d1..a23414df75 100644 --- a/src/components/interfaces/MOBILE_API.xml +++ b/src/components/interfaces/MOBILE_API.xml @@ -542,6 +542,7 @@ + @@ -4959,6 +4960,7 @@ + @@ -5073,6 +5075,7 @@ + @@ -5166,6 +5169,7 @@ + @@ -5279,6 +5283,7 @@ + @@ -5375,6 +5380,7 @@ + @@ -5492,6 +5498,7 @@ + @@ -6751,6 +6758,7 @@ + -- cgit v1.2.1 From 7fe745b86e4867dd9a33b582a6900c1f8242edbb Mon Sep 17 00:00:00 2001 From: ShobhitAd Date: Thu, 1 Nov 2018 13:53:08 -0500 Subject: Added VehicleData Param CloudAppVehicleID to core --- src/appMain/sdl_preloaded_pt.json | 4 ++++ .../include/application_manager/smart_object_keys.h | 1 + .../application_manager/src/message_helper/message_helper.cc | 2 ++ src/components/application_manager/src/smart_object_keys.cc | 1 + .../policy/policy_external/include/policy/policy_table/enums.h | 1 + .../policy_external/include/policy/policy_table_interface_ext.xml | 1 + src/components/policy/policy_external/src/policy_table/enums.cc | 7 +++++++ .../policy/policy_regular/include/policy/policy_table/enums.h | 1 + src/components/policy/policy_regular/src/policy_table/enums.cc | 7 +++++++ 9 files changed, 25 insertions(+) diff --git a/src/appMain/sdl_preloaded_pt.json b/src/appMain/sdl_preloaded_pt.json index d503ae34e5..8a75cd3dab 100644 --- a/src/appMain/sdl_preloaded_pt.json +++ b/src/appMain/sdl_preloaded_pt.json @@ -412,6 +412,7 @@ "headLampStatus", "instantFuelConsumption", "fuelRange", + "cloudAppVehicleID", "odometer", "tirePressure", "vin", @@ -432,6 +433,7 @@ "headLampStatus", "instantFuelConsumption", "fuelRange", + "cloudAppVehicleID", "odometer", "tirePressure", "vin", @@ -452,6 +454,7 @@ "headLampStatus", "instantFuelConsumption", "fuelRange", + "cloudAppVehicleID", "odometer", "tirePressure", "wiperStatus"] @@ -471,6 +474,7 @@ "headLampStatus", "instantFuelConsumption", "fuelRange", + "cloudAppVehicleID", "odometer", "tirePressure", "wiperStatus"] 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 6e32853a3d..9b5f63809a 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 @@ -253,6 +253,7 @@ extern const char* fuel_level; extern const char* fuel_level_state; extern const char* instant_fuel_consumption; extern const char* fuel_range; +extern const char* cloud_app_vehicle_id; extern const char* external_temp; extern const char* turn_signal; extern const char* vin; diff --git a/src/components/application_manager/src/message_helper/message_helper.cc b/src/components/application_manager/src/message_helper/message_helper.cc index e99db3bece..c5e40a18cf 100644 --- a/src/components/application_manager/src/message_helper/message_helper.cc +++ b/src/components/application_manager/src/message_helper/message_helper.cc @@ -176,6 +176,8 @@ std::pair + diff --git a/src/components/policy/policy_external/src/policy_table/enums.cc b/src/components/policy/policy_external/src/policy_table/enums.cc index 27db505e3f..29227adfc6 100644 --- a/src/components/policy/policy_external/src/policy_table/enums.cc +++ b/src/components/policy/policy_external/src/policy_table/enums.cc @@ -137,6 +137,8 @@ bool IsValidEnum(Parameter val) { return true; case P_FUELRANGE: return true; + case P_CLOUD_APP_VEHICLE_ID: + return true; case P_ODOMETER: return true; case P_TIREPRESSURE: @@ -232,6 +234,8 @@ const char* EnumToJsonString(Parameter val) { return "instantFuelConsumption"; case P_FUELRANGE: return "fuelRange"; + case P_CLOUD_APP_VEHICLE_ID: + return "cloudAppVehicleID"; case P_ODOMETER: return "odometer"; case P_TIREPRESSURE: @@ -336,6 +340,9 @@ bool EnumFromJsonString(const std::string& literal, Parameter* result) { } else if ("fuelRange" == literal) { *result = P_FUELRANGE; return true; + } else if ("cloudAppVehicleID" == literal) { + *result = P_CLOUD_APP_VEHICLE_ID; + return true; } else if ("odometer" == literal) { *result = P_ODOMETER; return true; diff --git a/src/components/policy/policy_regular/include/policy/policy_table/enums.h b/src/components/policy/policy_regular/include/policy/policy_table/enums.h index 1f10db9f6f..f398e16020 100644 --- a/src/components/policy/policy_regular/include/policy/policy_table/enums.h +++ b/src/components/policy/policy_regular/include/policy/policy_table/enums.h @@ -86,6 +86,7 @@ enum Parameter { P_STEERINGWHEELANGLE, P_ENGINEOILLIFE, P_MYKEY, + P_CLOUD_APP_VEHICLE_ID, P_AIRBAGSTATUS, P_BODYINFORMATION, P_CLUSTERMODESTATUS, diff --git a/src/components/policy/policy_regular/src/policy_table/enums.cc b/src/components/policy/policy_regular/src/policy_table/enums.cc index 428e18d0bd..bec9a2ec2d 100644 --- a/src/components/policy/policy_regular/src/policy_table/enums.cc +++ b/src/components/policy/policy_regular/src/policy_table/enums.cc @@ -138,6 +138,8 @@ bool IsValidEnum(Parameter val) { return true; case P_FUELRANGE: return true; + case P_CLOUD_APP_VEHICLE_ID: + return true; case P_ODOMETER: return true; case P_TIREPRESSURE: @@ -204,6 +206,8 @@ const char* EnumToJsonString(Parameter val) { return "instantFuelConsumption"; case P_FUELRANGE: return "fuelRange"; + case P_CLOUD_APP_VEHICLE_ID: + return "cloudAppVehicleID"; case P_ODOMETER: return "odometer"; case P_TIREPRESSURE: @@ -280,6 +284,9 @@ bool EnumFromJsonString(const std::string& literal, Parameter* result) { } else if ("fuelRange" == literal) { *result = P_FUELRANGE; return true; + } else if ("cloudAppVehicleID" == literal) { + *result = P_CLOUD_APP_VEHICLE_ID; + return true; } else if ("odometer" == literal) { *result = P_ODOMETER; return true; -- cgit v1.2.1 From 83e5ba4f27d98528823730225efb411ab5b355a1 Mon Sep 17 00:00:00 2001 From: ShobhitAd Date: Thu, 1 Nov 2018 15:01:26 -0500 Subject: Added CloudAppVehicleID param to all other policy tables --- src/components/application_manager/test/sdl_preloaded_pt.json | 4 ++++ src/components/application_manager/test/sdl_pt_update.json | 4 ++++ src/components/policy/policy_external/test/json/PTU.json | 4 ++++ src/components/policy/policy_external/test/json/PTU2.json | 4 ++++ src/components/policy/policy_external/test/json/PTU3.json | 4 ++++ .../policy_external/test/json/PTU_with_empty_requestType_array.json | 4 ++++ .../test/json/PTU_with_invalid_requestType_between_correct.json | 4 ++++ .../policy_external/test/json/PTU_with_one_invalid_requestType.json | 4 ++++ .../policy_external/test/json/PTU_without_requestType_field.json | 4 ++++ .../preloadedPT_with_invalid_default_reqestType_between_valid.json | 4 ++++ .../test/json/preloadedPT_with_invalid_default_requestType.json | 4 ++++ .../json/preloadedPT_with_several_invalid_default_requestTypes.json | 4 ++++ src/components/policy/policy_external/test/json/ptu2_requestType.json | 4 ++++ src/components/policy/policy_external/test/json/ptu_requestType.json | 4 ++++ src/components/policy/policy_external/test/json/sdl_preloaded_pt.json | 4 ++++ .../policy/policy_external/test/json/sdl_preloaded_pt1.json | 4 ++++ .../policy_external/test/json/sdl_preloaded_pt_send_location.json | 4 ++++ .../policy/policy_external/test/json/sdl_pt_first_update.json | 4 ++++ .../policy/policy_external/test/json/sdl_pt_second_update.json | 4 ++++ src/components/policy/policy_external/test/json/sdl_pt_update.json | 4 ++++ .../policy_external/test/json/sdl_update_pt_2_groups_have_params.json | 4 ++++ .../test/json/sdl_update_pt_2_groups_no_params_in1.json | 4 ++++ .../test/json/sdl_update_pt_2_groups_no_params_in1_omitted_in2.json | 4 ++++ .../policy/policy_external/test/json/sdl_update_pt_send_location.json | 4 ++++ .../test/json/sdl_update_pt_send_location_all_params.json | 4 ++++ .../test/json/sdl_update_pt_send_location_no_params.json | 4 ++++ .../test/json/sdl_update_pt_send_location_some_params.json | 4 ++++ .../policy/policy_external/test/json/valid_sdl_pt_update.json | 4 ++++ src/components/policy/policy_regular/test/PTU.json | 4 ++++ src/components/policy/policy_regular/test/PTU2.json | 4 ++++ src/components/policy/policy_regular/test/PTU3.json | 4 ++++ src/components/policy/policy_regular/test/PTU4.json | 4 ++++ src/components/policy/policy_regular/test/ptu2_requestType.json | 4 ++++ src/components/policy/policy_regular/test/ptu_requestType.json | 4 ++++ src/components/policy/policy_regular/test/sdl_preloaded_pt.json | 4 ++++ src/components/policy/policy_regular/test/sdl_pt_first_update.json | 4 ++++ src/components/policy/policy_regular/test/sdl_pt_second_update.json | 4 ++++ src/components/policy/policy_regular/test/sdl_pt_update.json | 4 ++++ src/components/policy/policy_regular/test/valid_sdl_pt_update.json | 4 ++++ 39 files changed, 156 insertions(+) diff --git a/src/components/application_manager/test/sdl_preloaded_pt.json b/src/components/application_manager/test/sdl_preloaded_pt.json index 59e3f947c3..ad264c8518 100644 --- a/src/components/application_manager/test/sdl_preloaded_pt.json +++ b/src/components/application_manager/test/sdl_preloaded_pt.json @@ -363,6 +363,7 @@ "headLampStatus", "instantFuelConsumption", "fuelRange", + "cloudAppVehicleID", "odometer", "tirePressure", "vin", @@ -383,6 +384,7 @@ "headLampStatus", "instantFuelConsumption", "fuelRange", + "cloudAppVehicleID", "odometer", "tirePressure", "vin", @@ -403,6 +405,7 @@ "headLampStatus", "instantFuelConsumption", "fuelRange", + "cloudAppVehicleID", "odometer", "tirePressure", "wiperStatus"] @@ -422,6 +425,7 @@ "headLampStatus", "instantFuelConsumption", "fuelRange", + "cloudAppVehicleID", "odometer", "tirePressure", "wiperStatus"] diff --git a/src/components/application_manager/test/sdl_pt_update.json b/src/components/application_manager/test/sdl_pt_update.json index 23c75e8475..17b07f797f 100644 --- a/src/components/application_manager/test/sdl_pt_update.json +++ b/src/components/application_manager/test/sdl_pt_update.json @@ -1600,6 +1600,7 @@ "headLampStatus", "instantFuelConsumption", "fuelRange", + "cloudAppVehicleID", "odometer", "tirePressure", "vin", @@ -1618,6 +1619,7 @@ "headLampStatus", "instantFuelConsumption", "fuelRange", + "cloudAppVehicleID", "odometer", "tirePressure", "vin", @@ -1636,6 +1638,7 @@ "headLampStatus", "instantFuelConsumption", "fuelRange", + "cloudAppVehicleID", "odometer", "tirePressure", "wiperStatus" @@ -1653,6 +1656,7 @@ "headLampStatus", "instantFuelConsumption", "fuelRange", + "cloudAppVehicleID", "odometer", "tirePressure", "wiperStatus" diff --git a/src/components/policy/policy_external/test/json/PTU.json b/src/components/policy/policy_external/test/json/PTU.json index 4cd71d6004..c5f4b90120 100644 --- a/src/components/policy/policy_external/test/json/PTU.json +++ b/src/components/policy/policy_external/test/json/PTU.json @@ -485,6 +485,7 @@ "headLampStatus", "instantFuelConsumption", "fuelRange", + "cloudAppVehicleID", "odometer", "tirePressure", "vin", @@ -509,6 +510,7 @@ "headLampStatus", "instantFuelConsumption", "fuelRange", + "cloudAppVehicleID", "odometer", "tirePressure", "vin", @@ -533,6 +535,7 @@ "headLampStatus", "instantFuelConsumption", "fuelRange", + "cloudAppVehicleID", "odometer", "tirePressure", "wiperStatus" @@ -556,6 +559,7 @@ "headLampStatus", "instantFuelConsumption", "fuelRange", + "cloudAppVehicleID", "odometer", "tirePressure", "wiperStatus" diff --git a/src/components/policy/policy_external/test/json/PTU2.json b/src/components/policy/policy_external/test/json/PTU2.json index 9c9436144e..01cca4a6fd 100644 --- a/src/components/policy/policy_external/test/json/PTU2.json +++ b/src/components/policy/policy_external/test/json/PTU2.json @@ -485,6 +485,7 @@ "headLampStatus", "instantFuelConsumption", "fuelRange", + "cloudAppVehicleID", "odometer", "tirePressure", "vin", @@ -509,6 +510,7 @@ "headLampStatus", "instantFuelConsumption", "fuelRange", + "cloudAppVehicleID", "odometer", "tirePressure", "vin", @@ -533,6 +535,7 @@ "headLampStatus", "instantFuelConsumption", "fuelRange", + "cloudAppVehicleID", "odometer", "tirePressure", "wiperStatus" @@ -556,6 +559,7 @@ "headLampStatus", "instantFuelConsumption", "fuelRange", + "cloudAppVehicleID", "odometer", "tirePressure", "wiperStatus" diff --git a/src/components/policy/policy_external/test/json/PTU3.json b/src/components/policy/policy_external/test/json/PTU3.json index 279051e7bf..f48f246114 100644 --- a/src/components/policy/policy_external/test/json/PTU3.json +++ b/src/components/policy/policy_external/test/json/PTU3.json @@ -485,6 +485,7 @@ "headLampStatus", "instantFuelConsumption", "fuelRange", + "cloudAppVehicleID", "odometer", "tirePressure", "vin", @@ -509,6 +510,7 @@ "headLampStatus", "instantFuelConsumption", "fuelRange", + "cloudAppVehicleID", "odometer", "tirePressure", "vin", @@ -533,6 +535,7 @@ "headLampStatus", "instantFuelConsumption", "fuelRange", + "cloudAppVehicleID", "odometer", "tirePressure", "wiperStatus" @@ -556,6 +559,7 @@ "headLampStatus", "instantFuelConsumption", "fuelRange", + "cloudAppVehicleID", "odometer", "tirePressure", "wiperStatus" diff --git a/src/components/policy/policy_external/test/json/PTU_with_empty_requestType_array.json b/src/components/policy/policy_external/test/json/PTU_with_empty_requestType_array.json index 08027f2786..1e99e7442c 100644 --- a/src/components/policy/policy_external/test/json/PTU_with_empty_requestType_array.json +++ b/src/components/policy/policy_external/test/json/PTU_with_empty_requestType_array.json @@ -1605,6 +1605,7 @@ "headLampStatus", "instantFuelConsumption", "fuelRange", + "cloudAppVehicleID", "odometer", "tirePressure", "vin", @@ -1623,6 +1624,7 @@ "headLampStatus", "instantFuelConsumption", "fuelRange", + "cloudAppVehicleID", "odometer", "tirePressure", "vin", @@ -1641,6 +1643,7 @@ "headLampStatus", "instantFuelConsumption", "fuelRange", + "cloudAppVehicleID", "odometer", "tirePressure", "wiperStatus" @@ -1658,6 +1661,7 @@ "headLampStatus", "instantFuelConsumption", "fuelRange", + "cloudAppVehicleID", "odometer", "tirePressure", "wiperStatus" diff --git a/src/components/policy/policy_external/test/json/PTU_with_invalid_requestType_between_correct.json b/src/components/policy/policy_external/test/json/PTU_with_invalid_requestType_between_correct.json index a88bcfbd08..dc40c3a182 100644 --- a/src/components/policy/policy_external/test/json/PTU_with_invalid_requestType_between_correct.json +++ b/src/components/policy/policy_external/test/json/PTU_with_invalid_requestType_between_correct.json @@ -1608,6 +1608,7 @@ "headLampStatus", "instantFuelConsumption", "fuelRange", + "cloudAppVehicleID", "odometer", "tirePressure", "vin", @@ -1626,6 +1627,7 @@ "headLampStatus", "instantFuelConsumption", "fuelRange", + "cloudAppVehicleID", "odometer", "tirePressure", "vin", @@ -1644,6 +1646,7 @@ "headLampStatus", "instantFuelConsumption", "fuelRange", + "cloudAppVehicleID", "odometer", "tirePressure", "wiperStatus" @@ -1661,6 +1664,7 @@ "headLampStatus", "instantFuelConsumption", "fuelRange", + "cloudAppVehicleID", "odometer", "tirePressure", "wiperStatus" diff --git a/src/components/policy/policy_external/test/json/PTU_with_one_invalid_requestType.json b/src/components/policy/policy_external/test/json/PTU_with_one_invalid_requestType.json index 250bfb21f2..3fcc71ca72 100644 --- a/src/components/policy/policy_external/test/json/PTU_with_one_invalid_requestType.json +++ b/src/components/policy/policy_external/test/json/PTU_with_one_invalid_requestType.json @@ -1605,6 +1605,7 @@ "headLampStatus", "instantFuelConsumption", "fuelRange", + "cloudAppVehicleID", "odometer", "tirePressure", "vin", @@ -1623,6 +1624,7 @@ "headLampStatus", "instantFuelConsumption", "fuelRange", + "cloudAppVehicleID", "odometer", "tirePressure", "vin", @@ -1641,6 +1643,7 @@ "headLampStatus", "instantFuelConsumption", "fuelRange", + "cloudAppVehicleID", "odometer", "tirePressure", "wiperStatus" @@ -1658,6 +1661,7 @@ "headLampStatus", "instantFuelConsumption", "fuelRange", + "cloudAppVehicleID", "odometer", "tirePressure", "wiperStatus" diff --git a/src/components/policy/policy_external/test/json/PTU_without_requestType_field.json b/src/components/policy/policy_external/test/json/PTU_without_requestType_field.json index 85910c098c..03a5e8d203 100644 --- a/src/components/policy/policy_external/test/json/PTU_without_requestType_field.json +++ b/src/components/policy/policy_external/test/json/PTU_without_requestType_field.json @@ -1604,6 +1604,7 @@ "headLampStatus", "instantFuelConsumption", "fuelRange", + "cloudAppVehicleID", "odometer", "tirePressure", "vin", @@ -1622,6 +1623,7 @@ "headLampStatus", "instantFuelConsumption", "fuelRange", + "cloudAppVehicleID", "odometer", "tirePressure", "vin", @@ -1640,6 +1642,7 @@ "headLampStatus", "instantFuelConsumption", "fuelRange", + "cloudAppVehicleID", "odometer", "tirePressure", "wiperStatus" @@ -1657,6 +1660,7 @@ "headLampStatus", "instantFuelConsumption", "fuelRange", + "cloudAppVehicleID", "odometer", "tirePressure", "wiperStatus" diff --git a/src/components/policy/policy_external/test/json/preloadedPT_with_invalid_default_reqestType_between_valid.json b/src/components/policy/policy_external/test/json/preloadedPT_with_invalid_default_reqestType_between_valid.json index 1c1b04ca2b..b5dd0bfff5 100644 --- a/src/components/policy/policy_external/test/json/preloadedPT_with_invalid_default_reqestType_between_valid.json +++ b/src/components/policy/policy_external/test/json/preloadedPT_with_invalid_default_reqestType_between_valid.json @@ -362,6 +362,7 @@ "headLampStatus", "instantFuelConsumption", "fuelRange", + "cloudAppVehicleID", "odometer", "tirePressure", "vin", @@ -382,6 +383,7 @@ "headLampStatus", "instantFuelConsumption", "fuelRange", + "cloudAppVehicleID", "odometer", "tirePressure", "vin", @@ -402,6 +404,7 @@ "headLampStatus", "instantFuelConsumption", "fuelRange", + "cloudAppVehicleID", "odometer", "tirePressure", "wiperStatus"] @@ -421,6 +424,7 @@ "headLampStatus", "instantFuelConsumption", "fuelRange", + "cloudAppVehicleID", "odometer", "tirePressure", "wiperStatus"] diff --git a/src/components/policy/policy_external/test/json/preloadedPT_with_invalid_default_requestType.json b/src/components/policy/policy_external/test/json/preloadedPT_with_invalid_default_requestType.json index 51690d7b8e..8fa8e6f3d0 100644 --- a/src/components/policy/policy_external/test/json/preloadedPT_with_invalid_default_requestType.json +++ b/src/components/policy/policy_external/test/json/preloadedPT_with_invalid_default_requestType.json @@ -362,6 +362,7 @@ "headLampStatus", "instantFuelConsumption", "fuelRange", + "cloudAppVehicleID", "odometer", "tirePressure", "vin", @@ -382,6 +383,7 @@ "headLampStatus", "instantFuelConsumption", "fuelRange", + "cloudAppVehicleID", "odometer", "tirePressure", "vin", @@ -402,6 +404,7 @@ "headLampStatus", "instantFuelConsumption", "fuelRange", + "cloudAppVehicleID", "odometer", "tirePressure", "wiperStatus"] @@ -421,6 +424,7 @@ "headLampStatus", "instantFuelConsumption", "fuelRange", + "cloudAppVehicleID", "odometer", "tirePressure", "wiperStatus"] diff --git a/src/components/policy/policy_external/test/json/preloadedPT_with_several_invalid_default_requestTypes.json b/src/components/policy/policy_external/test/json/preloadedPT_with_several_invalid_default_requestTypes.json index cfa6c4010c..589cdc7a81 100644 --- a/src/components/policy/policy_external/test/json/preloadedPT_with_several_invalid_default_requestTypes.json +++ b/src/components/policy/policy_external/test/json/preloadedPT_with_several_invalid_default_requestTypes.json @@ -362,6 +362,7 @@ "headLampStatus", "instantFuelConsumption", "fuelRange", + "cloudAppVehicleID", "odometer", "tirePressure", "vin", @@ -382,6 +383,7 @@ "headLampStatus", "instantFuelConsumption", "fuelRange", + "cloudAppVehicleID", "odometer", "tirePressure", "vin", @@ -402,6 +404,7 @@ "headLampStatus", "instantFuelConsumption", "fuelRange", + "cloudAppVehicleID", "odometer", "tirePressure", "wiperStatus"] @@ -421,6 +424,7 @@ "headLampStatus", "instantFuelConsumption", "fuelRange", + "cloudAppVehicleID", "odometer", "tirePressure", "wiperStatus"] diff --git a/src/components/policy/policy_external/test/json/ptu2_requestType.json b/src/components/policy/policy_external/test/json/ptu2_requestType.json index d7177f2251..9b580b2a08 100644 --- a/src/components/policy/policy_external/test/json/ptu2_requestType.json +++ b/src/components/policy/policy_external/test/json/ptu2_requestType.json @@ -497,6 +497,7 @@ "headLampStatus", "instantFuelConsumption", "fuelRange", + "cloudAppVehicleID", "odometer", "tirePressure", "vin", @@ -521,6 +522,7 @@ "headLampStatus", "instantFuelConsumption", "fuelRange", + "cloudAppVehicleID", "odometer", "tirePressure", "vin", @@ -545,6 +547,7 @@ "headLampStatus", "instantFuelConsumption", "fuelRange", + "cloudAppVehicleID", "odometer", "tirePressure", "wiperStatus" @@ -568,6 +571,7 @@ "headLampStatus", "instantFuelConsumption", "fuelRange", + "cloudAppVehicleID", "odometer", "tirePressure", "wiperStatus" diff --git a/src/components/policy/policy_external/test/json/ptu_requestType.json b/src/components/policy/policy_external/test/json/ptu_requestType.json index 6a531dd2ad..8d18a9e336 100644 --- a/src/components/policy/policy_external/test/json/ptu_requestType.json +++ b/src/components/policy/policy_external/test/json/ptu_requestType.json @@ -496,6 +496,7 @@ "headLampStatus", "instantFuelConsumption", "fuelRange", + "cloudAppVehicleID", "odometer", "tirePressure", "vin", @@ -520,6 +521,7 @@ "headLampStatus", "instantFuelConsumption", "fuelRange", + "cloudAppVehicleID", "odometer", "tirePressure", "vin", @@ -544,6 +546,7 @@ "headLampStatus", "instantFuelConsumption", "fuelRange", + "cloudAppVehicleID", "odometer", "tirePressure", "wiperStatus" @@ -567,6 +570,7 @@ "headLampStatus", "instantFuelConsumption", "fuelRange", + "cloudAppVehicleID", "odometer", "tirePressure", "wiperStatus" diff --git a/src/components/policy/policy_external/test/json/sdl_preloaded_pt.json b/src/components/policy/policy_external/test/json/sdl_preloaded_pt.json index 59e3f947c3..ad264c8518 100644 --- a/src/components/policy/policy_external/test/json/sdl_preloaded_pt.json +++ b/src/components/policy/policy_external/test/json/sdl_preloaded_pt.json @@ -363,6 +363,7 @@ "headLampStatus", "instantFuelConsumption", "fuelRange", + "cloudAppVehicleID", "odometer", "tirePressure", "vin", @@ -383,6 +384,7 @@ "headLampStatus", "instantFuelConsumption", "fuelRange", + "cloudAppVehicleID", "odometer", "tirePressure", "vin", @@ -403,6 +405,7 @@ "headLampStatus", "instantFuelConsumption", "fuelRange", + "cloudAppVehicleID", "odometer", "tirePressure", "wiperStatus"] @@ -422,6 +425,7 @@ "headLampStatus", "instantFuelConsumption", "fuelRange", + "cloudAppVehicleID", "odometer", "tirePressure", "wiperStatus"] diff --git a/src/components/policy/policy_external/test/json/sdl_preloaded_pt1.json b/src/components/policy/policy_external/test/json/sdl_preloaded_pt1.json index a4491fd449..909fd2cb2f 100644 --- a/src/components/policy/policy_external/test/json/sdl_preloaded_pt1.json +++ b/src/components/policy/policy_external/test/json/sdl_preloaded_pt1.json @@ -2321,6 +2321,7 @@ "headLampStatus", "instantFuelConsumption", "fuelRange", + "cloudAppVehicleID", "odometer", "tirePressure", "vin", @@ -2343,6 +2344,7 @@ "headLampStatus", "instantFuelConsumption", "fuelRange", + "cloudAppVehicleID", "odometer", "tirePressure", "vin", @@ -2365,6 +2367,7 @@ "headLampStatus", "instantFuelConsumption", "fuelRange", + "cloudAppVehicleID", "odometer", "tirePressure", "wiperStatus" @@ -2386,6 +2389,7 @@ "headLampStatus", "instantFuelConsumption", "fuelRange", + "cloudAppVehicleID", "odometer", "tirePressure", "wiperStatus" diff --git a/src/components/policy/policy_external/test/json/sdl_preloaded_pt_send_location.json b/src/components/policy/policy_external/test/json/sdl_preloaded_pt_send_location.json index 83c4ccf15c..87fac7c76c 100644 --- a/src/components/policy/policy_external/test/json/sdl_preloaded_pt_send_location.json +++ b/src/components/policy/policy_external/test/json/sdl_preloaded_pt_send_location.json @@ -497,6 +497,7 @@ "headLampStatus", "instantFuelConsumption", "fuelRange", + "cloudAppVehicleID", "odometer", "tirePressure", "vin", @@ -521,6 +522,7 @@ "headLampStatus", "instantFuelConsumption", "fuelRange", + "cloudAppVehicleID", "odometer", "tirePressure", "vin", @@ -545,6 +547,7 @@ "headLampStatus", "instantFuelConsumption", "fuelRange", + "cloudAppVehicleID", "odometer", "tirePressure", "wiperStatus" @@ -568,6 +571,7 @@ "headLampStatus", "instantFuelConsumption", "fuelRange", + "cloudAppVehicleID", "odometer", "tirePressure", "wiperStatus" diff --git a/src/components/policy/policy_external/test/json/sdl_pt_first_update.json b/src/components/policy/policy_external/test/json/sdl_pt_first_update.json index 7b882c6ceb..440963ba48 100644 --- a/src/components/policy/policy_external/test/json/sdl_pt_first_update.json +++ b/src/components/policy/policy_external/test/json/sdl_pt_first_update.json @@ -1622,6 +1622,7 @@ "headLampStatus", "instantFuelConsumption", "fuelRange", + "cloudAppVehicleID", "odometer", "tirePressure", "vin", @@ -1640,6 +1641,7 @@ "headLampStatus", "instantFuelConsumption", "fuelRange", + "cloudAppVehicleID", "odometer", "tirePressure", "vin", @@ -1658,6 +1660,7 @@ "headLampStatus", "instantFuelConsumption", "fuelRange", + "cloudAppVehicleID", "odometer", "tirePressure", "wiperStatus" @@ -1675,6 +1678,7 @@ "headLampStatus", "instantFuelConsumption", "fuelRange", + "cloudAppVehicleID", "odometer", "tirePressure", "wiperStatus" diff --git a/src/components/policy/policy_external/test/json/sdl_pt_second_update.json b/src/components/policy/policy_external/test/json/sdl_pt_second_update.json index 7d90275328..5900acbcfb 100644 --- a/src/components/policy/policy_external/test/json/sdl_pt_second_update.json +++ b/src/components/policy/policy_external/test/json/sdl_pt_second_update.json @@ -1622,6 +1622,7 @@ "headLampStatus", "instantFuelConsumption", "fuelRange", + "cloudAppVehicleID", "odometer", "tirePressure", "vin", @@ -1640,6 +1641,7 @@ "headLampStatus", "instantFuelConsumption", "fuelRange", + "cloudAppVehicleID", "odometer", "tirePressure", "vin", @@ -1658,6 +1660,7 @@ "headLampStatus", "instantFuelConsumption", "fuelRange", + "cloudAppVehicleID", "odometer", "tirePressure", "wiperStatus" @@ -1675,6 +1678,7 @@ "headLampStatus", "instantFuelConsumption", "fuelRange", + "cloudAppVehicleID", "odometer", "tirePressure", "wiperStatus" diff --git a/src/components/policy/policy_external/test/json/sdl_pt_update.json b/src/components/policy/policy_external/test/json/sdl_pt_update.json index 807b0eb312..b3affeb91d 100644 --- a/src/components/policy/policy_external/test/json/sdl_pt_update.json +++ b/src/components/policy/policy_external/test/json/sdl_pt_update.json @@ -1606,6 +1606,7 @@ "headLampStatus", "instantFuelConsumption", "fuelRange", + "cloudAppVehicleID", "odometer", "tirePressure", "vin", @@ -1624,6 +1625,7 @@ "headLampStatus", "instantFuelConsumption", "fuelRange", + "cloudAppVehicleID", "odometer", "tirePressure", "vin", @@ -1642,6 +1644,7 @@ "headLampStatus", "instantFuelConsumption", "fuelRange", + "cloudAppVehicleID", "odometer", "tirePressure", "wiperStatus" @@ -1659,6 +1662,7 @@ "headLampStatus", "instantFuelConsumption", "fuelRange", + "cloudAppVehicleID", "odometer", "tirePressure", "wiperStatus" diff --git a/src/components/policy/policy_external/test/json/sdl_update_pt_2_groups_have_params.json b/src/components/policy/policy_external/test/json/sdl_update_pt_2_groups_have_params.json index 3d0a004dbe..639d0143c8 100644 --- a/src/components/policy/policy_external/test/json/sdl_update_pt_2_groups_have_params.json +++ b/src/components/policy/policy_external/test/json/sdl_update_pt_2_groups_have_params.json @@ -496,6 +496,7 @@ "headLampStatus", "instantFuelConsumption", "fuelRange", + "cloudAppVehicleID", "odometer", "tirePressure", "vin", @@ -520,6 +521,7 @@ "headLampStatus", "instantFuelConsumption", "fuelRange", + "cloudAppVehicleID", "odometer", "tirePressure", "vin", @@ -544,6 +546,7 @@ "headLampStatus", "instantFuelConsumption", "fuelRange", + "cloudAppVehicleID", "odometer", "tirePressure", "wiperStatus" @@ -567,6 +570,7 @@ "headLampStatus", "instantFuelConsumption", "fuelRange", + "cloudAppVehicleID", "odometer", "tirePressure", "wiperStatus" diff --git a/src/components/policy/policy_external/test/json/sdl_update_pt_2_groups_no_params_in1.json b/src/components/policy/policy_external/test/json/sdl_update_pt_2_groups_no_params_in1.json index 6a36f1f9c5..53216cab3d 100644 --- a/src/components/policy/policy_external/test/json/sdl_update_pt_2_groups_no_params_in1.json +++ b/src/components/policy/policy_external/test/json/sdl_update_pt_2_groups_no_params_in1.json @@ -496,6 +496,7 @@ "headLampStatus", "instantFuelConsumption", "fuelRange", + "cloudAppVehicleID", "odometer", "tirePressure", "vin", @@ -520,6 +521,7 @@ "headLampStatus", "instantFuelConsumption", "fuelRange", + "cloudAppVehicleID", "odometer", "tirePressure", "vin", @@ -544,6 +546,7 @@ "headLampStatus", "instantFuelConsumption", "fuelRange", + "cloudAppVehicleID", "odometer", "tirePressure", "wiperStatus" @@ -567,6 +570,7 @@ "headLampStatus", "instantFuelConsumption", "fuelRange", + "cloudAppVehicleID", "odometer", "tirePressure", "wiperStatus" diff --git a/src/components/policy/policy_external/test/json/sdl_update_pt_2_groups_no_params_in1_omitted_in2.json b/src/components/policy/policy_external/test/json/sdl_update_pt_2_groups_no_params_in1_omitted_in2.json index 3303d56844..a529dc9a3b 100644 --- a/src/components/policy/policy_external/test/json/sdl_update_pt_2_groups_no_params_in1_omitted_in2.json +++ b/src/components/policy/policy_external/test/json/sdl_update_pt_2_groups_no_params_in1_omitted_in2.json @@ -496,6 +496,7 @@ "headLampStatus", "instantFuelConsumption", "fuelRange", + "cloudAppVehicleID", "odometer", "tirePressure", "vin", @@ -520,6 +521,7 @@ "headLampStatus", "instantFuelConsumption", "fuelRange", + "cloudAppVehicleID", "odometer", "tirePressure", "vin", @@ -544,6 +546,7 @@ "headLampStatus", "instantFuelConsumption", "fuelRange", + "cloudAppVehicleID", "odometer", "tirePressure", "wiperStatus" @@ -567,6 +570,7 @@ "headLampStatus", "instantFuelConsumption", "fuelRange", + "cloudAppVehicleID", "odometer", "tirePressure", "wiperStatus" diff --git a/src/components/policy/policy_external/test/json/sdl_update_pt_send_location.json b/src/components/policy/policy_external/test/json/sdl_update_pt_send_location.json index e7a33ba2c0..a57791e248 100644 --- a/src/components/policy/policy_external/test/json/sdl_update_pt_send_location.json +++ b/src/components/policy/policy_external/test/json/sdl_update_pt_send_location.json @@ -496,6 +496,7 @@ "headLampStatus", "instantFuelConsumption", "fuelRange", + "cloudAppVehicleID", "odometer", "tirePressure", "vin", @@ -520,6 +521,7 @@ "headLampStatus", "instantFuelConsumption", "fuelRange", + "cloudAppVehicleID", "odometer", "tirePressure", "vin", @@ -544,6 +546,7 @@ "headLampStatus", "instantFuelConsumption", "fuelRange", + "cloudAppVehicleID", "odometer", "tirePressure", "wiperStatus" @@ -567,6 +570,7 @@ "headLampStatus", "instantFuelConsumption", "fuelRange", + "cloudAppVehicleID", "odometer", "tirePressure", "wiperStatus" diff --git a/src/components/policy/policy_external/test/json/sdl_update_pt_send_location_all_params.json b/src/components/policy/policy_external/test/json/sdl_update_pt_send_location_all_params.json index 08739f9d6a..5a633e7c95 100644 --- a/src/components/policy/policy_external/test/json/sdl_update_pt_send_location_all_params.json +++ b/src/components/policy/policy_external/test/json/sdl_update_pt_send_location_all_params.json @@ -496,6 +496,7 @@ "headLampStatus", "instantFuelConsumption", "fuelRange", + "cloudAppVehicleID", "odometer", "tirePressure", "vin", @@ -520,6 +521,7 @@ "headLampStatus", "instantFuelConsumption", "fuelRange", + "cloudAppVehicleID", "odometer", "tirePressure", "vin", @@ -544,6 +546,7 @@ "headLampStatus", "instantFuelConsumption", "fuelRange", + "cloudAppVehicleID", "odometer", "tirePressure", "wiperStatus" @@ -567,6 +570,7 @@ "headLampStatus", "instantFuelConsumption", "fuelRange", + "cloudAppVehicleID", "odometer", "tirePressure", "wiperStatus" diff --git a/src/components/policy/policy_external/test/json/sdl_update_pt_send_location_no_params.json b/src/components/policy/policy_external/test/json/sdl_update_pt_send_location_no_params.json index 21396b8cac..86c121491b 100644 --- a/src/components/policy/policy_external/test/json/sdl_update_pt_send_location_no_params.json +++ b/src/components/policy/policy_external/test/json/sdl_update_pt_send_location_no_params.json @@ -496,6 +496,7 @@ "headLampStatus", "instantFuelConsumption", "fuelRange", + "cloudAppVehicleID", "odometer", "tirePressure", "vin", @@ -520,6 +521,7 @@ "headLampStatus", "instantFuelConsumption", "fuelRange", + "cloudAppVehicleID", "odometer", "tirePressure", "vin", @@ -544,6 +546,7 @@ "headLampStatus", "instantFuelConsumption", "fuelRange", + "cloudAppVehicleID", "odometer", "tirePressure", "wiperStatus" @@ -567,6 +570,7 @@ "headLampStatus", "instantFuelConsumption", "fuelRange", + "cloudAppVehicleID", "odometer", "tirePressure", "wiperStatus" diff --git a/src/components/policy/policy_external/test/json/sdl_update_pt_send_location_some_params.json b/src/components/policy/policy_external/test/json/sdl_update_pt_send_location_some_params.json index 5aa467a23c..2b57912016 100644 --- a/src/components/policy/policy_external/test/json/sdl_update_pt_send_location_some_params.json +++ b/src/components/policy/policy_external/test/json/sdl_update_pt_send_location_some_params.json @@ -496,6 +496,7 @@ "headLampStatus", "instantFuelConsumption", "fuelRange", + "cloudAppVehicleID", "odometer", "tirePressure", "vin", @@ -520,6 +521,7 @@ "headLampStatus", "instantFuelConsumption", "fuelRange", + "cloudAppVehicleID", "odometer", "tirePressure", "vin", @@ -544,6 +546,7 @@ "headLampStatus", "instantFuelConsumption", "fuelRange", + "cloudAppVehicleID", "odometer", "tirePressure", "wiperStatus" @@ -567,6 +570,7 @@ "headLampStatus", "instantFuelConsumption", "fuelRange", + "cloudAppVehicleID", "odometer", "tirePressure", "wiperStatus" diff --git a/src/components/policy/policy_external/test/json/valid_sdl_pt_update.json b/src/components/policy/policy_external/test/json/valid_sdl_pt_update.json index 5827ab287a..35e6b1d1a6 100644 --- a/src/components/policy/policy_external/test/json/valid_sdl_pt_update.json +++ b/src/components/policy/policy_external/test/json/valid_sdl_pt_update.json @@ -1598,6 +1598,7 @@ "headLampStatus", "instantFuelConsumption", "fuelRange", + "cloudAppVehicleID", "odometer", "tirePressure", "vin", @@ -1616,6 +1617,7 @@ "headLampStatus", "instantFuelConsumption", "fuelRange", + "cloudAppVehicleID", "odometer", "tirePressure", "vin", @@ -1634,6 +1636,7 @@ "headLampStatus", "instantFuelConsumption", "fuelRange", + "cloudAppVehicleID", "odometer", "tirePressure", "wiperStatus" @@ -1651,6 +1654,7 @@ "headLampStatus", "instantFuelConsumption", "fuelRange", + "cloudAppVehicleID", "odometer", "tirePressure", "wiperStatus" diff --git a/src/components/policy/policy_regular/test/PTU.json b/src/components/policy/policy_regular/test/PTU.json index 2f4735dd66..dbf16598f0 100644 --- a/src/components/policy/policy_regular/test/PTU.json +++ b/src/components/policy/policy_regular/test/PTU.json @@ -362,6 +362,7 @@ "headLampStatus", "instantFuelConsumption", "fuelRange", + "cloudAppVehicleID", "odometer", "tirePressure", "vin", @@ -382,6 +383,7 @@ "headLampStatus", "instantFuelConsumption", "fuelRange", + "cloudAppVehicleID", "odometer", "tirePressure", "vin", @@ -402,6 +404,7 @@ "headLampStatus", "instantFuelConsumption", "fuelRange", + "cloudAppVehicleID", "odometer", "tirePressure", "wiperStatus"] @@ -421,6 +424,7 @@ "headLampStatus", "instantFuelConsumption", "fuelRange", + "cloudAppVehicleID", "odometer", "tirePressure", "wiperStatus"] diff --git a/src/components/policy/policy_regular/test/PTU2.json b/src/components/policy/policy_regular/test/PTU2.json index 806ab8bcc0..2c0063f69a 100644 --- a/src/components/policy/policy_regular/test/PTU2.json +++ b/src/components/policy/policy_regular/test/PTU2.json @@ -362,6 +362,7 @@ "headLampStatus", "instantFuelConsumption", "fuelRange", + "cloudAppVehicleID", "odometer", "tirePressure", "vin", @@ -382,6 +383,7 @@ "headLampStatus", "instantFuelConsumption", "fuelRange", + "cloudAppVehicleID", "odometer", "tirePressure", "vin", @@ -402,6 +404,7 @@ "headLampStatus", "instantFuelConsumption", "fuelRange", + "cloudAppVehicleID", "odometer", "tirePressure", "wiperStatus"] @@ -421,6 +424,7 @@ "headLampStatus", "instantFuelConsumption", "fuelRange", + "cloudAppVehicleID", "odometer", "tirePressure", "wiperStatus"] diff --git a/src/components/policy/policy_regular/test/PTU3.json b/src/components/policy/policy_regular/test/PTU3.json index 28396be29a..d579fd3e3f 100644 --- a/src/components/policy/policy_regular/test/PTU3.json +++ b/src/components/policy/policy_regular/test/PTU3.json @@ -362,6 +362,7 @@ "headLampStatus", "instantFuelConsumption", "fuelRange", + "cloudAppVehicleID", "odometer", "tirePressure", "vin", @@ -382,6 +383,7 @@ "headLampStatus", "instantFuelConsumption", "fuelRange", + "cloudAppVehicleID", "odometer", "tirePressure", "vin", @@ -402,6 +404,7 @@ "headLampStatus", "instantFuelConsumption", "fuelRange", + "cloudAppVehicleID", "odometer", "tirePressure", "wiperStatus"] @@ -421,6 +424,7 @@ "headLampStatus", "instantFuelConsumption", "fuelRange", + "cloudAppVehicleID", "odometer", "tirePressure", "wiperStatus"] diff --git a/src/components/policy/policy_regular/test/PTU4.json b/src/components/policy/policy_regular/test/PTU4.json index 4592e228df..84b6404010 100644 --- a/src/components/policy/policy_regular/test/PTU4.json +++ b/src/components/policy/policy_regular/test/PTU4.json @@ -362,6 +362,7 @@ "headLampStatus", "instantFuelConsumption", "fuelRange", + "cloudAppVehicleID", "odometer", "tirePressure", "vin", @@ -382,6 +383,7 @@ "headLampStatus", "instantFuelConsumption", "fuelRange", + "cloudAppVehicleID", "odometer", "tirePressure", "vin", @@ -402,6 +404,7 @@ "headLampStatus", "instantFuelConsumption", "fuelRange", + "cloudAppVehicleID", "odometer", "tirePressure", "wiperStatus"] @@ -421,6 +424,7 @@ "headLampStatus", "instantFuelConsumption", "fuelRange", + "cloudAppVehicleID", "odometer", "tirePressure", "wiperStatus"] diff --git a/src/components/policy/policy_regular/test/ptu2_requestType.json b/src/components/policy/policy_regular/test/ptu2_requestType.json index 2a05a94f8b..9013971990 100644 --- a/src/components/policy/policy_regular/test/ptu2_requestType.json +++ b/src/components/policy/policy_regular/test/ptu2_requestType.json @@ -498,6 +498,7 @@ "headLampStatus", "instantFuelConsumption", "fuelRange", + "cloudAppVehicleID", "odometer", "tirePressure", "vin", @@ -522,6 +523,7 @@ "headLampStatus", "instantFuelConsumption", "fuelRange", + "cloudAppVehicleID", "odometer", "tirePressure", "vin", @@ -546,6 +548,7 @@ "headLampStatus", "instantFuelConsumption", "fuelRange", + "cloudAppVehicleID", "odometer", "tirePressure", "wiperStatus" @@ -569,6 +572,7 @@ "headLampStatus", "instantFuelConsumption", "fuelRange", + "cloudAppVehicleID", "odometer", "tirePressure", "wiperStatus" diff --git a/src/components/policy/policy_regular/test/ptu_requestType.json b/src/components/policy/policy_regular/test/ptu_requestType.json index b0d9117568..892a77f970 100644 --- a/src/components/policy/policy_regular/test/ptu_requestType.json +++ b/src/components/policy/policy_regular/test/ptu_requestType.json @@ -498,6 +498,7 @@ "headLampStatus", "instantFuelConsumption", "fuelRange", + "cloudAppVehicleID", "odometer", "tirePressure", "vin", @@ -522,6 +523,7 @@ "headLampStatus", "instantFuelConsumption", "fuelRange", + "cloudAppVehicleID", "odometer", "tirePressure", "vin", @@ -546,6 +548,7 @@ "headLampStatus", "instantFuelConsumption", "fuelRange", + "cloudAppVehicleID", "odometer", "tirePressure", "wiperStatus" @@ -569,6 +572,7 @@ "headLampStatus", "instantFuelConsumption", "fuelRange", + "cloudAppVehicleID", "odometer", "tirePressure", "wiperStatus" diff --git a/src/components/policy/policy_regular/test/sdl_preloaded_pt.json b/src/components/policy/policy_regular/test/sdl_preloaded_pt.json index 59e3f947c3..ad264c8518 100644 --- a/src/components/policy/policy_regular/test/sdl_preloaded_pt.json +++ b/src/components/policy/policy_regular/test/sdl_preloaded_pt.json @@ -363,6 +363,7 @@ "headLampStatus", "instantFuelConsumption", "fuelRange", + "cloudAppVehicleID", "odometer", "tirePressure", "vin", @@ -383,6 +384,7 @@ "headLampStatus", "instantFuelConsumption", "fuelRange", + "cloudAppVehicleID", "odometer", "tirePressure", "vin", @@ -403,6 +405,7 @@ "headLampStatus", "instantFuelConsumption", "fuelRange", + "cloudAppVehicleID", "odometer", "tirePressure", "wiperStatus"] @@ -422,6 +425,7 @@ "headLampStatus", "instantFuelConsumption", "fuelRange", + "cloudAppVehicleID", "odometer", "tirePressure", "wiperStatus"] diff --git a/src/components/policy/policy_regular/test/sdl_pt_first_update.json b/src/components/policy/policy_regular/test/sdl_pt_first_update.json index 7b882c6ceb..440963ba48 100644 --- a/src/components/policy/policy_regular/test/sdl_pt_first_update.json +++ b/src/components/policy/policy_regular/test/sdl_pt_first_update.json @@ -1622,6 +1622,7 @@ "headLampStatus", "instantFuelConsumption", "fuelRange", + "cloudAppVehicleID", "odometer", "tirePressure", "vin", @@ -1640,6 +1641,7 @@ "headLampStatus", "instantFuelConsumption", "fuelRange", + "cloudAppVehicleID", "odometer", "tirePressure", "vin", @@ -1658,6 +1660,7 @@ "headLampStatus", "instantFuelConsumption", "fuelRange", + "cloudAppVehicleID", "odometer", "tirePressure", "wiperStatus" @@ -1675,6 +1678,7 @@ "headLampStatus", "instantFuelConsumption", "fuelRange", + "cloudAppVehicleID", "odometer", "tirePressure", "wiperStatus" diff --git a/src/components/policy/policy_regular/test/sdl_pt_second_update.json b/src/components/policy/policy_regular/test/sdl_pt_second_update.json index 7d90275328..5900acbcfb 100644 --- a/src/components/policy/policy_regular/test/sdl_pt_second_update.json +++ b/src/components/policy/policy_regular/test/sdl_pt_second_update.json @@ -1622,6 +1622,7 @@ "headLampStatus", "instantFuelConsumption", "fuelRange", + "cloudAppVehicleID", "odometer", "tirePressure", "vin", @@ -1640,6 +1641,7 @@ "headLampStatus", "instantFuelConsumption", "fuelRange", + "cloudAppVehicleID", "odometer", "tirePressure", "vin", @@ -1658,6 +1660,7 @@ "headLampStatus", "instantFuelConsumption", "fuelRange", + "cloudAppVehicleID", "odometer", "tirePressure", "wiperStatus" @@ -1675,6 +1678,7 @@ "headLampStatus", "instantFuelConsumption", "fuelRange", + "cloudAppVehicleID", "odometer", "tirePressure", "wiperStatus" diff --git a/src/components/policy/policy_regular/test/sdl_pt_update.json b/src/components/policy/policy_regular/test/sdl_pt_update.json index 909e4d5238..6f5e223cae 100644 --- a/src/components/policy/policy_regular/test/sdl_pt_update.json +++ b/src/components/policy/policy_regular/test/sdl_pt_update.json @@ -1600,6 +1600,7 @@ "headLampStatus", "instantFuelConsumption", "fuelRange", + "cloudAppVehicleID", "odometer", "tirePressure", "vin", @@ -1618,6 +1619,7 @@ "headLampStatus", "instantFuelConsumption", "fuelRange", + "cloudAppVehicleID", "odometer", "tirePressure", "vin", @@ -1636,6 +1638,7 @@ "headLampStatus", "instantFuelConsumption", "fuelRange", + "cloudAppVehicleID", "odometer", "tirePressure", "wiperStatus" @@ -1653,6 +1656,7 @@ "headLampStatus", "instantFuelConsumption", "fuelRange", + "cloudAppVehicleID", "odometer", "tirePressure", "wiperStatus" diff --git a/src/components/policy/policy_regular/test/valid_sdl_pt_update.json b/src/components/policy/policy_regular/test/valid_sdl_pt_update.json index 5827ab287a..35e6b1d1a6 100644 --- a/src/components/policy/policy_regular/test/valid_sdl_pt_update.json +++ b/src/components/policy/policy_regular/test/valid_sdl_pt_update.json @@ -1598,6 +1598,7 @@ "headLampStatus", "instantFuelConsumption", "fuelRange", + "cloudAppVehicleID", "odometer", "tirePressure", "vin", @@ -1616,6 +1617,7 @@ "headLampStatus", "instantFuelConsumption", "fuelRange", + "cloudAppVehicleID", "odometer", "tirePressure", "vin", @@ -1634,6 +1636,7 @@ "headLampStatus", "instantFuelConsumption", "fuelRange", + "cloudAppVehicleID", "odometer", "tirePressure", "wiperStatus" @@ -1651,6 +1654,7 @@ "headLampStatus", "instantFuelConsumption", "fuelRange", + "cloudAppVehicleID", "odometer", "tirePressure", "wiperStatus" -- cgit v1.2.1 From 3d2eb5f2d7c49f0dacfb6c480de9a8fd0d8b0c10 Mon Sep 17 00:00:00 2001 From: ShobhitAd Date: Thu, 1 Nov 2018 15:58:40 -0500 Subject: Added description for param to MOBILE and HMI API files --- src/components/interfaces/HMI_API.xml | 36 +++++++++++++++++++++++++------- src/components/interfaces/MOBILE_API.xml | 34 +++++++++++++++++++++--------- 2 files changed, 53 insertions(+), 17 deletions(-) diff --git a/src/components/interfaces/HMI_API.xml b/src/components/interfaces/HMI_API.xml index 4c4a01ed9d..2d256423bd 100644 --- a/src/components/interfaces/HMI_API.xml +++ b/src/components/interfaces/HMI_API.xml @@ -4951,6 +4951,10 @@ The status of the park brake as provided by Electric Park Brake (EPB) system. + + Parameter used by cloud apps to identify a head unit + + Emergency Call notification and confirmation data @@ -4968,7 +4972,6 @@ Information related to the MyKey feature - @@ -5041,6 +5044,10 @@ The status of the park brake as provided by Electric Park Brake (EPB) system. + + Parameter used by cloud apps to identify a head unit + + Emergency Call notification and confirmation data @@ -5059,7 +5066,6 @@ - @@ -5137,6 +5143,10 @@ The status of the park brake as provided by Electric Park Brake (EPB) system. + + Parameter used by cloud apps to identify a head unit + + Emergency Call notification and confirmation data @@ -5154,7 +5164,7 @@ Information related to the MyKey feature - + @@ -5226,6 +5236,10 @@ The status of the park brake as provided by Electric Park Brake (EPB) system. + + Parameter used by cloud apps to identify a head unit + + Emergency Call notification and confirmation data @@ -5243,7 +5257,6 @@ Information related to the MyKey feature - @@ -5320,6 +5333,10 @@ The status of the park brake as provided by Electric Park Brake (EPB) system. + + Parameter used by cloud apps to identify a head unit + + Emergency Call notification and confirmation data @@ -5337,7 +5354,6 @@ Information related to the MyKey feature - @@ -5413,6 +5429,10 @@ The status of the park brake as provided by Electric Park Brake (EPB) system. + + Parameter used by cloud apps to identify a head unit + + Emergency Call notification and confirmation data @@ -5430,7 +5450,6 @@ Information related to the MyKey feature - @@ -5504,6 +5523,10 @@ Current angle of the steering wheel (in deg) + + Parameter used by cloud apps to identify a head unit + + Emergency Call notification and confirmation data @@ -5521,7 +5544,6 @@ Information related to the MyKey feature - diff --git a/src/components/interfaces/MOBILE_API.xml b/src/components/interfaces/MOBILE_API.xml index a23414df75..0be8e15162 100644 --- a/src/components/interfaces/MOBILE_API.xml +++ b/src/components/interfaces/MOBILE_API.xml @@ -542,7 +542,7 @@ - + @@ -4940,7 +4940,10 @@ The status of the park brake as provided by Electric Park Brake (EPB) system. - + + Parameter used by cloud apps to identify a head unit + + Emergency Call notification and confirmation data @@ -4960,7 +4963,6 @@ - @@ -5056,7 +5058,10 @@ The status of the park brake as provided by Electric Park Brake (EPB) system. - + + Parameter used by cloud apps to identify a head unit + + Emergency Call notification and confirmation data @@ -5075,7 +5080,6 @@ - @@ -5150,6 +5154,9 @@ The status of the park brake as provided by Electric Park Brake (EPB) system. + + Parameter used by cloud apps to identify a head unit + @@ -5169,7 +5176,6 @@ - @@ -5264,6 +5270,9 @@ The status of the park brake as provided by Electric Park Brake (EPB) system. + + Parameter used by cloud apps to identify a head unit + @@ -5283,7 +5292,6 @@ - @@ -5361,6 +5369,9 @@ The status of the park brake as provided by Electric Park Brake (EPB) system. + + Parameter used by cloud apps to identify a head unit + @@ -5380,7 +5391,6 @@ - @@ -5479,6 +5489,9 @@ The status of the park brake as provided by Electric Park Brake (EPB) system. + + Parameter used by cloud apps to identify a head unit + @@ -5498,7 +5511,6 @@ - @@ -6739,6 +6751,9 @@ The status of the park brake as provided by Electric Park Brake (EPB) system. + + Parameter used by cloud apps to identify a head unit + @@ -6758,7 +6773,6 @@ - -- cgit v1.2.1 From 548f512332463e0d4cb5aadd521951fa2cd5bfbe Mon Sep 17 00:00:00 2001 From: ShobhitAd Date: Thu, 1 Nov 2018 16:29:13 -0500 Subject: Style fix --- src/components/application_manager/src/message_helper/message_helper.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/application_manager/src/message_helper/message_helper.cc b/src/components/application_manager/src/message_helper/message_helper.cc index c5e40a18cf..2f86c50013 100644 --- a/src/components/application_manager/src/message_helper/message_helper.cc +++ b/src/components/application_manager/src/message_helper/message_helper.cc @@ -176,7 +176,7 @@ std::pair Date: Thu, 1 Nov 2018 16:08:28 -0400 Subject: Add cloud app parameters to regular policies --- .../application_manager/policies/policy_handler.h | 23 +++++++ .../application_manager/smart_object_keys.h | 4 ++ .../src/policies/policy_handler.cc | 63 ++++++++++++++++++ .../application_manager/src/smart_object_keys.cc | 4 ++ .../policies/policy_handler_interface.h | 39 +++++++++++ .../policy/policy_regular/policy/policy_manager.h | 51 +++++++++++++++ .../policies/mock_policy_handler_interface.h | 10 +++ .../policy_regular/policy/mock_cache_manager.h | 17 +++++ .../policy_regular/policy/mock_policy_manager.h | 17 +++++ .../policy_regular/include/policy/cache_manager.h | 51 +++++++++++++++ .../include/policy/cache_manager_interface.h | 51 +++++++++++++++ .../include/policy/policy_manager_impl.h | 52 +++++++++++++++ .../include/policy/policy_table/enums.h | 6 ++ .../include/policy/policy_table/types.h | 6 ++ .../policy/policy_regular/src/cache_manager.cc | 75 ++++++++++++++++++++++ .../policy_regular/src/policy_manager_impl.cc | 32 ++++++++- .../policy_regular/src/policy_table/enums.cc | 35 +++++++++- .../policy_regular/src/policy_table/types.cc | 65 ++++++++++++++++++- .../policy/policy_regular/src/sql_pt_queries.cc | 43 ++++++++++--- .../policy_regular/src/sql_pt_representation.cc | 43 ++++++++++++- .../test/sql_pt_representation_test.cc | 4 +- 21 files changed, 675 insertions(+), 16 deletions(-) diff --git a/src/components/application_manager/include/application_manager/policies/policy_handler.h b/src/components/application_manager/include/application_manager/policies/policy_handler.h index c8f3bcf888..3af03bf28b 100644 --- a/src/components/application_manager/include/application_manager/policies/policy_handler.h +++ b/src/components/application_manager/include/application_manager/policies/policy_handler.h @@ -398,6 +398,29 @@ class PolicyHandler : public PolicyHandlerInterface, custom_str::CustomString GetAppName( const std::string& policy_app_id) OVERRIDE; + /** + * @brief Checks if a given application is an enabled cloud application + * @param policy_app_id Unique application id + * @return true, if the application is an enabled cloud application, + * otherwise - false + */ + const bool CheckCloudAppEnabled( + const std::string& policy_app_id) const OVERRIDE; + + /**plzfix + * @brief Checks if certain request type is allowed for application + * @param policy_app_id Unique application id + * @return true, if allowed, otherwise - false + */ + const bool GetCloudAppParameters(const std::string& policy_app_id, + std::string& endpoint, + std::string& auth_token, + std::string& cloud_transport_type, + std::string& hybrid_app_preference) const OVERRIDE; + + void OnSetCloudAppProperties( + const smart_objects::SmartObject& message) OVERRIDE; + virtual void OnUpdateHMIAppType( std::map app_hmi_types) OVERRIDE; 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 6e32853a3d..e8d05c14db 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 @@ -188,6 +188,10 @@ extern const char* green; extern const char* blue; extern const char* display_layout; extern const char* icon_resumed; +extern const char* enabled; +extern const char* cloud_app_auth_token; +extern const char* cloud_transport_type; +extern const char* hybrid_app_preference; // PutFile extern const char* sync_file_name; diff --git a/src/components/application_manager/src/policies/policy_handler.cc b/src/components/application_manager/src/policies/policy_handler.cc index 1b64c5d7b4..c73e35768e 100644 --- a/src/components/application_manager/src/policies/policy_handler.cc +++ b/src/components/application_manager/src/policies/policy_handler.cc @@ -1845,6 +1845,69 @@ bool PolicyHandler::CheckSystemAction( return false; } +const bool PolicyHandler::GetCloudAppParameters( + const std::string& policy_app_id, + std::string& endpoint, + std::string& auth_token, + std::string& cloud_transport_type, + std::string& hybrid_app_preference) const { + POLICY_LIB_CHECK(false); + return policy_manager_->GetCloudAppParameters(policy_app_id, + endpoint, + auth_token, + cloud_transport_type, + hybrid_app_preference); +} + +const bool PolicyHandler::CheckCloudAppEnabled(const std::string& policy_app_id) const { + POLICY_LIB_CHECK(false); + std::string endpoint; + std::string auth_token; + std::string cloud_transport_type; + std::string hybrid_app_preference; + return policy_manager_->GetCloudAppParameters(policy_app_id, + endpoint, + auth_token, + cloud_transport_type, + hybrid_app_preference); +} + +void PolicyHandler::OnSetCloudAppProperties( + const smart_objects::SmartObject& message) { + POLICY_LIB_CHECK_VOID(); + if (!message.keyExists(strings::msg_params)) { + LOG4CXX_ERROR( + logger_, + "Message does not contain mandatory section " << strings::msg_params); + return; + } + const smart_objects::SmartObject& msg_params = message[strings::msg_params]; + if (!msg_params.keyExists(strings::app_id)) { + LOG4CXX_ERROR( + logger_, + "Message does not contain mandatory parameter " << strings::app_id); + return; + } + std::string policy_app_id(msg_params[strings::app_id].asString()); + if (msg_params.keyExists(strings::enabled)) { + policy_manager_->SetCloudAppEnabled(policy_app_id, + msg_params[strings::enabled].asBool()); + } + if (msg_params.keyExists(strings::cloud_app_auth_token)) { + policy_manager_->SetAppAuthToken(policy_app_id, + msg_params[strings::cloud_app_auth_token].asString()); + } + if (msg_params.keyExists(strings::cloud_transport_type)) { + policy_manager_->SetAppCloudTransportType( + policy_app_id, msg_params[strings::cloud_transport_type].asString()); + } + if (msg_params.keyExists(strings::hybrid_app_preference)) { + //const std::string hybrid_app_preference = EnumConversionHelper::EnumToString(msg_params[strings::hybrid_app_preference]); + //policy_manager_->SetHybridAppPreference( + // policy_app_id, hybrid_app_preference); + } +} + uint32_t PolicyHandler::HeartBeatTimeout(const std::string& app_id) const { POLICY_LIB_CHECK(0); return policy_manager_->HeartBeatTimeout(app_id); diff --git a/src/components/application_manager/src/smart_object_keys.cc b/src/components/application_manager/src/smart_object_keys.cc index ff9ebb6208..8e53929451 100644 --- a/src/components/application_manager/src/smart_object_keys.cc +++ b/src/components/application_manager/src/smart_object_keys.cc @@ -155,6 +155,10 @@ const char* green = "green"; const char* blue = "blue"; const char* display_layout = "displayLayout"; const char* icon_resumed = "iconResumed"; +const char* enabled = "enabled"; +const char* cloud_app_auth_token = "cloudAppAuthToken"; +const char* cloud_transport_type = "cloudTransportType"; +const char* hybrid_app_preference = "hybridAppPreference"; // PutFile const char* sync_file_name = "syncFileName"; diff --git a/src/components/include/application_manager/policies/policy_handler_interface.h b/src/components/include/application_manager/policies/policy_handler_interface.h index ee9274ead7..69433e6118 100644 --- a/src/components/include/application_manager/policies/policy_handler_interface.h +++ b/src/components/include/application_manager/policies/policy_handler_interface.h @@ -437,6 +437,45 @@ class PolicyHandlerInterface { * @return Structure with vehicle information */ virtual const VehicleInfo GetVehicleInfo() const = 0; + + /** + * @brief Checks if a given application is an enabled cloud application + * @param policy_app_id Unique application id + * @return true if the application is an enabled cloud application, + * false otherwise + */ + virtual const bool CheckCloudAppEnabled( + const std::string& policy_app_id) const = 0; + + /** + * @brief Get cloud app policy information, all fields that aren't set for a + * given app will be filled with empty strings + * @param policy_app_id Unique application id + * @param endpoint Filled the endpoint used to connect to the cloud + * application + * @param auth_token Filled with the token used for authentication when + * reconnecting to the cloud app + * @param cloud_transport_type Filled with the transport type used by the + * cloud application (ex. "WSS") + * @param cloud_transport_type Filled with the hybrid app preference for the + * cloud application set by the user + * @return true if the cloud app is enabled, false otherwise + */ + virtual const bool GetCloudAppParameters( + const std::string& policy_app_id, + std::string& endpoint, + std::string& auth_token, + std::string& cloud_transport_type, + std::string& hybrid_app_preference) const = 0; + + /** + * @brief Callback for when a SetCloudAppProperties message is received from a + * mobile app + * @param message The SetCloudAppProperties message + */ + virtual void OnSetCloudAppProperties( + const smart_objects::SmartObject& message) = 0; + #ifdef EXTERNAL_PROPRIETARY_MODE /** * @brief Gets meta information diff --git a/src/components/include/policy/policy_regular/policy/policy_manager.h b/src/components/include/policy/policy_regular/policy/policy_manager.h index ee0bae7118..9c67e239b7 100644 --- a/src/components/include/policy/policy_regular/policy/policy_manager.h +++ b/src/components/include/policy/policy_regular/policy/policy_manager.h @@ -502,6 +502,57 @@ class PolicyManager : public usage_statistics::StatisticsManager { */ virtual const VehicleInfo GetVehicleInfo() const = 0; + /** + * @brief Get cloud app policy information, all fields that aren't set for a + * given app will be filled with empty strings + * @param policy_app_id Unique application id + * @param endpoint Filled the endpoint used to connect to the cloud + * application + * @param auth_token Filled with the token used for authentication when + * reconnecting to the cloud app + * @param cloud_transport_type Filled with the transport type used by the + * cloud application (ex. "WSS") + * @param cloud_transport_type Filled with the hybrid app preference for the + * cloud application set by the user + * @return true if the cloud app is enabled, false otherwise + */ + virtual const bool GetCloudAppParameters( + const std::string& policy_app_id, + std::string& endpoint, + std::string& auth_token, + std::string& cloud_transport_type, + std::string& hybrid_app_preference) const = 0; + + /** + * @brief Enable or disable a cloud application in the HMI + * @param enabled Cloud app enabled state + */ + virtual void SetCloudAppEnabled(const std::string& policy_app_id, + const bool enabled) = 0; + + /** + * @brief Set an app's auth token + * @param auth_token Cloud app authentication token + */ + virtual void SetAppAuthToken(const std::string& policy_app_id, + const std::string& auth_token) = 0; + + /** + * @brief Set a cloud app's transport type + * @param cloud_transport_type Cloud app transport type + */ + virtual void SetAppCloudTransportType( + const std::string& policy_app_id, + const std::string& cloud_transport_type) = 0; + + /** + * @brief Set the user preference for how a hybrid (cloud and mobile) app + * should be used + * @param hybrid_app_preference Hybrid app user preference + */ + virtual void SetHybridAppPreference(const std::string& policy_app_id, + const std::string& hybrid_app_preference) = 0; + /** * @brief OnAppRegisteredOnMobile allows to handle event when application were * succesfully registered on mobile device. diff --git a/src/components/include/test/application_manager/policies/mock_policy_handler_interface.h b/src/components/include/test/application_manager/policies/mock_policy_handler_interface.h index cb47147074..bd56d78128 100644 --- a/src/components/include/test/application_manager/policies/mock_policy_handler_interface.h +++ b/src/components/include/test/application_manager/policies/mock_policy_handler_interface.h @@ -213,6 +213,16 @@ class MockPolicyHandlerInterface : public policy::PolicyHandlerInterface { GetAppRequestTypes, const std::vector(const std::string& policy_app_id)); MOCK_CONST_METHOD0(GetVehicleInfo, const policy::VehicleInfo()); + MOCK_CONST_METHOD1(CheckCloudAppEnabled, + const bool(const std::string& policy_app_id)); + MOCK_CONST_METHOD5(GetCloudAppParameters, + const bool(const std::string& policy_app_id, + std::string& endpoint, + std::string& auth_token, + std::string& cloud_transport_type, + std::string& hybrid_app_preference)); + MOCK_METHOD1(OnSetCloudAppProperties, + void(const smart_objects::SmartObject& message)); #ifdef EXTERNAL_PROPRIETARY_MODE MOCK_CONST_METHOD0(GetMetaInfo, const policy::MetaInfo()); diff --git a/src/components/include/test/policy/policy_regular/policy/mock_cache_manager.h b/src/components/include/test/policy/policy_regular/policy/mock_cache_manager.h index 440000dbff..745bcd2db5 100644 --- a/src/components/include/test/policy/policy_regular/policy/mock_cache_manager.h +++ b/src/components/include/test/policy/policy_regular/policy/mock_cache_manager.h @@ -63,6 +63,23 @@ class MockCacheManagerInterface : public CacheManagerInterface { MOCK_METHOD0(TimeoutResponse, int()); MOCK_METHOD1(SecondsBetweenRetries, bool(std::vector& seconds)); MOCK_CONST_METHOD0(GetVehicleInfo, const VehicleInfo()); + MOCK_CONST_METHOD5(GetCloudAppParameters, + const bool(const std::string& policy_app_id, + std::string& endpoint, + std::string& auth_token, + std::string& cloud_transport_type, + std::string& hybrid_app_preference)); + MOCK_METHOD2(SetCloudAppEnabled, + void(const std::string& policy_app_id, const bool enabled)); + MOCK_METHOD2(SetAppAuthToken, + void(const std::string& policy_app_id, + const std::string& auth_token)); + MOCK_METHOD2(SetAppCloudTransportType, + void(const std::string& policy_app_id, + const std::string& cloud_transport_type)); + MOCK_METHOD2(SetHybridAppPreference, + void(const std::string& policy_app_id, + const std::string& hybrid_app_preference)); MOCK_METHOD1(SetVINValue, bool(const std::string& value)); MOCK_METHOD2(GetUserFriendlyMsg, std::vector( diff --git a/src/components/include/test/policy/policy_regular/policy/mock_policy_manager.h b/src/components/include/test/policy/policy_regular/policy/mock_policy_manager.h index 0e06e9c1a3..8867c3de80 100644 --- a/src/components/include/test/policy/policy_regular/policy/mock_policy_manager.h +++ b/src/components/include/test/policy/policy_regular/policy/mock_policy_manager.h @@ -181,6 +181,23 @@ class MockPolicyManager : public PolicyManager { GetAppRequestTypes, const std::vector(const std::string policy_app_id)); MOCK_CONST_METHOD0(GetVehicleInfo, const policy::VehicleInfo()); + MOCK_CONST_METHOD5(GetCloudAppParameters, + const bool(const std::string& policy_app_id, + std::string& endpoint, + std::string& auth_token, + std::string& cloud_transport_type, + std::string& hybrid_app_preference)); + MOCK_METHOD2(SetCloudAppEnabled, + void(const std::string& policy_app_id, const bool enabled)); + MOCK_METHOD2(SetAppAuthToken, + void(const std::string& policy_app_id, + const std::string& auth_token)); + MOCK_METHOD2(SetAppCloudTransportType, + void(const std::string& policy_app_id, + const std::string& cloud_transport_type)); + MOCK_METHOD2(SetHybridAppPreference, + void(const std::string& policy_app_id, + const std::string& hybrid_app_preference)); MOCK_CONST_METHOD0(GetMetaInfo, const policy::MetaInfo()); MOCK_CONST_METHOD0(RetrieveCertificate, std::string()); MOCK_CONST_METHOD0(HasCertificate, bool()); diff --git a/src/components/policy/policy_regular/include/policy/cache_manager.h b/src/components/policy/policy_regular/include/policy/cache_manager.h index 48e00f7049..119a0c0519 100644 --- a/src/components/policy/policy_regular/include/policy/cache_manager.h +++ b/src/components/policy/policy_regular/include/policy/cache_manager.h @@ -146,6 +146,57 @@ class CacheManager : public CacheManagerInterface { */ virtual const VehicleInfo GetVehicleInfo() const; + /** + * @brief Get cloud app policy information, all fields that aren't set for a + * given app will be filled with empty strings + * @param policy_app_id Unique application id + * @param endpoint Filled the endpoint used to connect to the cloud + * application + * @param auth_token Filled with the token used for authentication when + * reconnecting to the cloud app + * @param cloud_transport_type Filled with the transport type used by the + * cloud application (ex. "WSS") + * @param cloud_transport_type Filled with the hybrid app preference for the + * cloud application set by the user + * @return true if the cloud app is enabled, false otherwise + */ + virtual const bool GetCloudAppParameters( + const std::string& policy_app_id, + std::string& endpoint, + std::string& auth_token, + std::string& cloud_transport_type, + std::string& hybrid_app_preference) const; + + /** + * @brief Enable or disable a cloud application in the HMI + * @param enabled Cloud app enabled state + */ + virtual void SetCloudAppEnabled(const std::string& policy_app_id, + const bool enabled); + + /** + * @brief Set an app's auth token + * @param auth_token Cloud app authentication token + */ + virtual void SetAppAuthToken(const std::string& policy_app_id, + const std::string& auth_token); + + /** + * @brief Set a cloud app's transport type + * @param cloud_transport_type Cloud app transport type + */ + virtual void SetAppCloudTransportType( + const std::string& policy_app_id, + const std::string& cloud_transport_type); + + /** + * @brief Set the user preference for how a hybrid (cloud and mobile) app + * should be used + * @param hybrid_app_preference Hybrid app user preference + */ + virtual void SetHybridAppPreference(const std::string& policy_app_id, + const std::string& hybrid_app_preference); + /** * @brief Allows to update 'vin' field in module_meta table. * diff --git a/src/components/policy/policy_regular/include/policy/cache_manager_interface.h b/src/components/policy/policy_regular/include/policy/cache_manager_interface.h index 10a6ea7f89..9408809f1e 100644 --- a/src/components/policy/policy_regular/include/policy/cache_manager_interface.h +++ b/src/components/policy/policy_regular/include/policy/cache_manager_interface.h @@ -151,6 +151,57 @@ class CacheManagerInterface { */ virtual const VehicleInfo GetVehicleInfo() const = 0; + /** + * @brief Get cloud app policy information, all fields that aren't set for a + * given app will be filled with empty strings + * @param policy_app_id Unique application id + * @param endpoint Filled the endpoint used to connect to the cloud + * application + * @param auth_token Filled with the token used for authentication when + * reconnecting to the cloud app + * @param cloud_transport_type Filled with the transport type used by the + * cloud application (ex. "WSS") + * @param cloud_transport_type Filled with the hybrid app preference for the + * cloud application set by the user + * @return true if the cloud app is enabled, false otherwise + */ + virtual const bool GetCloudAppParameters( + const std::string& policy_app_id, + std::string& endpoint, + std::string& auth_token, + std::string& cloud_transport_type, + std::string& hybrid_app_preference) const = 0; + + /** + * @brief Enable or disable a cloud application in the HMI + * @param enabled Cloud app enabled state + */ + virtual void SetCloudAppEnabled(const std::string& policy_app_id, + const bool enabled) = 0; + + /** + * @brief Set an app's auth token + * @param auth_token Cloud app authentication token + */ + virtual void SetAppAuthToken(const std::string& policy_app_id, + const std::string& auth_token) = 0; + + /** + * @brief Set a cloud app's transport type + * @param cloud_transport_type Cloud app transport type + */ + virtual void SetAppCloudTransportType( + const std::string& policy_app_id, + const std::string& cloud_transport_type) = 0; + + /** + * @brief Set the user preference for how a hybrid (cloud and mobile) app + * should be used + * @param hybrid_app_preference Hybrid app user preference + */ + virtual void SetHybridAppPreference(const std::string& policy_app_id, + const std::string& hybrid_app_preference) = 0; + /** * @brief Allows to update 'vin' field in module_meta table. * diff --git a/src/components/policy/policy_regular/include/policy/policy_manager_impl.h b/src/components/policy/policy_regular/include/policy/policy_manager_impl.h index 51d4ee88aa..e1221b613f 100644 --- a/src/components/policy/policy_regular/include/policy/policy_manager_impl.h +++ b/src/components/policy/policy_regular/include/policy/policy_manager_impl.h @@ -564,6 +564,58 @@ class PolicyManagerImpl : public PolicyManager { */ const VehicleInfo GetVehicleInfo() const OVERRIDE; + /** + * @brief Get cloud app policy information, all fields that aren't set for a + * given app will be filled with empty strings + * @param policy_app_id Unique application id + * @param endpoint Filled the endpoint used to connect to the cloud + * application + * @param auth_token Filled with the token used for authentication when + * reconnecting to the cloud app + * @param cloud_transport_type Filled with the transport type used by the + * cloud application (ex. "WSS") + * @param cloud_transport_type Filled with the hybrid app preference for the + * cloud application set by the user + * @return true if the cloud app is enabled, false otherwise + */ + const bool GetCloudAppParameters( + const std::string& policy_app_id, + std::string& endpoint, + std::string& auth_token, + std::string& cloud_transport_type, + std::string& hybrid_app_preference) const OVERRIDE; + + /** + * @brief Enable or disable a cloud application in the HMI + * @param enabled Cloud app enabled state + */ + void SetCloudAppEnabled(const std::string& policy_app_id, + const bool enabled) OVERRIDE; + + /** + * @brief Set an app's auth token + * @param auth_token Cloud app authentication token + */ + void SetAppAuthToken(const std::string& policy_app_id, + const std::string& auth_token) OVERRIDE; + + /** + * @brief Set a cloud app's transport type + * @param cloud_transport_type Cloud app transport type + */ + void SetAppCloudTransportType( + const std::string& policy_app_id, + const std::string& cloud_transport_type) OVERRIDE; + + /** + * @brief Set the user preference for how a hybrid (cloud and mobile) app + * should be used + * @param hybrid_app_preference Hybrid app user preference + */ + void SetHybridAppPreference( + const std::string& policy_app_id, + const std::string& hybrid_app_preference) OVERRIDE; + /** * @brief OnAppRegisteredOnMobile allows to handle event when application were * succesfully registered on mobile device. diff --git a/src/components/policy/policy_regular/include/policy/policy_table/enums.h b/src/components/policy/policy_regular/include/policy/policy_table/enums.h index 1f10db9f6f..3cdca195bf 100644 --- a/src/components/policy/policy_regular/include/policy/policy_table/enums.h +++ b/src/components/policy/policy_regular/include/policy/policy_table/enums.h @@ -167,6 +167,12 @@ bool IsValidEnum(ModuleType val); const char* EnumToJsonString(ModuleType val); bool EnumFromJsonString(const std::string& literal, ModuleType* result); +enum HybridAppPreference { HAP_MOBILE, HAP_CLOUD, HAP_BOTH }; +bool IsValidEnum(HybridAppPreference val); +const char* EnumToJsonString(HybridAppPreference val); +bool EnumFromJsonString(const std::string& literal, + HybridAppPreference* result); + /** * @brief Enumeration FunctionID. * diff --git a/src/components/policy/policy_regular/include/policy/policy_table/types.h b/src/components/policy/policy_regular/include/policy/policy_table/types.h index e201251745..58f07492c4 100644 --- a/src/components/policy/policy_regular/include/policy/policy_table/types.h +++ b/src/components/policy/policy_regular/include/policy/policy_table/types.h @@ -144,6 +144,12 @@ struct ApplicationParams : PolicyBase { Optional > heart_beat_timeout_ms; Optional > certificate; mutable Optional moduleType; + // Cloud application params + Optional > hybrid_app_preference; + Optional > endpoint; + Optional enabled; + Optional > auth_token; + Optional > cloud_transport_type; public: ApplicationParams(); diff --git a/src/components/policy/policy_regular/src/cache_manager.cc b/src/components/policy/policy_regular/src/cache_manager.cc index bd95fc8e7c..68e70c107d 100644 --- a/src/components/policy/policy_regular/src/cache_manager.cc +++ b/src/components/policy/policy_regular/src/cache_manager.cc @@ -682,6 +682,81 @@ const policy::VehicleInfo CacheManager::GetVehicleInfo() const { return vehicle_info; } +const bool CacheManager::GetCloudAppParameters( + const std::string& policy_app_id, + std::string& endpoint, + std::string& auth_token, + std::string& cloud_transport_type, + std::string& hybrid_app_preference) const { + const policy_table::ApplicationPolicies& policies = + pt_->policy_table.app_policies_section.apps; + policy_table::ApplicationPolicies::const_iterator policy_iter = + policies.find(policy_app_id); + if (policies.end() != policy_iter) { + auto app_policy = (*policy_iter).second; + endpoint = app_policy.endpoint.is_initialized() ? *app_policy.endpoint + : std::string(); + auth_token = app_policy.auth_token.is_initialized() ? *app_policy.auth_token + : std::string(); + cloud_transport_type = app_policy.cloud_transport_type.is_initialized() + ? *app_policy.cloud_transport_type + : std::string(); + hybrid_app_preference = + app_policy.hybrid_app_preference.is_initialized() + ? EnumToJsonString(*app_policy.hybrid_app_preference) + : std::string(); + return app_policy.enabled.is_initialized() && *app_policy.enabled; + } + return false; +} + +void CacheManager::SetCloudAppEnabled(const std::string& policy_app_id, + const bool enabled) { + policy_table::ApplicationPolicies& policies = + pt_->policy_table.app_policies_section.apps; + policy_table::ApplicationPolicies::iterator policy_iter = + policies.find(policy_app_id); + if (policies.end() != policy_iter) { + *(*policy_iter).second.enabled = enabled; + } +} + +void CacheManager::SetAppAuthToken(const std::string& policy_app_id, + const std::string& auth_token) { + policy_table::ApplicationPolicies& policies = + pt_->policy_table.app_policies_section.apps; + policy_table::ApplicationPolicies::iterator policy_iter = + policies.find(policy_app_id); + if (policies.end() != policy_iter) { + *(*policy_iter).second.auth_token = auth_token; + } +} + +void CacheManager::SetAppCloudTransportType( + const std::string& policy_app_id, const std::string& cloud_transport_type) { + policy_table::ApplicationPolicies& policies = + pt_->policy_table.app_policies_section.apps; + policy_table::ApplicationPolicies::iterator policy_iter = + policies.find(policy_app_id); + if (policies.end() != policy_iter) { + *(*policy_iter).second.cloud_transport_type = cloud_transport_type; + } +} + +void CacheManager::SetHybridAppPreference( + const std::string& policy_app_id, + const std::string& hybrid_app_preference) { + policy_table::HybridAppPreference value; + bool valid = EnumFromJsonString(hybrid_app_preference, &value); + policy_table::ApplicationPolicies& policies = + pt_->policy_table.app_policies_section.apps; + policy_table::ApplicationPolicies::iterator policy_iter = + policies.find(policy_app_id); + if (policies.end() != policy_iter && valid) { + *(*policy_iter).second.hybrid_app_preference = value; + } +} + std::vector CacheManager::GetUserFriendlyMsg( const std::vector& msg_codes, const std::string& language) { LOG4CXX_AUTO_TRACE(logger_); diff --git a/src/components/policy/policy_regular/src/policy_manager_impl.cc b/src/components/policy/policy_regular/src/policy_manager_impl.cc index 4985035629..9317708216 100644 --- a/src/components/policy/policy_regular/src/policy_manager_impl.cc +++ b/src/components/policy/policy_regular/src/policy_manager_impl.cc @@ -217,7 +217,7 @@ void FilterInvalidApplicationParameters( } app_params.AppHMIType->swap(valid_app_hmi_types); - // Filter RquestTypes array + // Filter RequestTypes array policy_table::RequestTypes valid_request_types; const policy_table::RequestTypes& request_types = *(app_params.RequestType); for (const auto& request_type : request_types) { @@ -544,6 +544,36 @@ const VehicleInfo PolicyManagerImpl::GetVehicleInfo() const { return cache_->GetVehicleInfo(); } +const bool PolicyManagerImpl::GetCloudAppParameters( + const std::string& policy_app_id, + std::string& endpoint, + std::string& auth_token, + std::string& cloud_transport_type, + std::string& hybrid_app_preference) const { + return cache_->GetCloudAppParameters(policy_app_id, endpoint, auth_token, cloud_transport_type, hybrid_app_preference); +} + +void PolicyManagerImpl::SetCloudAppEnabled( + const std::string& policy_app_id, const bool enabled) { + cache_->SetCloudAppEnabled(policy_app_id, enabled); +} + +void PolicyManagerImpl::SetAppAuthToken(const std::string& policy_app_id, + const std::string& auth_token) { + cache_->SetAppAuthToken(policy_app_id, auth_token); +} + +void PolicyManagerImpl::SetAppCloudTransportType( + const std::string& policy_app_id, const std::string& cloud_transport_type) { + cache_->SetAppCloudTransportType(policy_app_id, cloud_transport_type); +} + +void PolicyManagerImpl::SetHybridAppPreference( + const std::string& policy_app_id, + const std::string& hybrid_app_preference) { + cache_->SetHybridAppPreference(policy_app_id, hybrid_app_preference); +} + void PolicyManagerImpl::CheckPermissions(const PTString& device_id, const PTString& app_id, const PTString& hmi_level, diff --git a/src/components/policy/policy_regular/src/policy_table/enums.cc b/src/components/policy/policy_regular/src/policy_table/enums.cc index 428e18d0bd..4102db51b3 100644 --- a/src/components/policy/policy_regular/src/policy_table/enums.cc +++ b/src/components/policy/policy_regular/src/policy_table/enums.cc @@ -1,5 +1,5 @@ -// This file is generated, do not edit #include "policy/policy_table/enums.h" +#include namespace rpc { namespace policy_table_interface_base { @@ -662,6 +662,7 @@ bool IsValidEnum(ModuleType val) { return false; } } + const char* EnumToJsonString(ModuleType val) { switch (val) { case MT_CLIMATE: @@ -709,6 +710,38 @@ bool EnumFromJsonString(const std::string& literal, ModuleType* result) { return false; } +bool IsValidEnum(HybridAppPreference val) { + return strlen(EnumToJsonString(val)) > 0; +} + +const char* EnumToJsonString(HybridAppPreference val) { + switch (val) { + case HAP_MOBILE: + return "MOBILE"; + case HAP_CLOUD: + return "CLOUD"; + case HAP_BOTH: + return "BOTH"; + default: + return ""; + } +} + +bool EnumFromJsonString(const std::string& literal, + HybridAppPreference* result) { + if ("MOBILE" == literal) { + *result = HAP_MOBILE; + return true; + } else if ("CLOUD" == literal) { + *result = HAP_CLOUD; + return true; + } else if ("BOTH" == literal) { + *result = HAP_BOTH; + return true; + } + return false; +} + bool IsValidEnum(FunctionID val) { switch (val) { case RegisterAppInterfaceID: diff --git a/src/components/policy/policy_regular/src/policy_table/types.cc b/src/components/policy/policy_regular/src/policy_table/types.cc index 851ed1bd18..88564df050 100644 --- a/src/components/policy/policy_regular/src/policy_table/types.cc +++ b/src/components/policy/policy_regular/src/policy_table/types.cc @@ -168,7 +168,13 @@ ApplicationParams::ApplicationParams(const Json::Value* value__) , memory_kb(impl::ValueMember(value__, "memory_kb"), 0) , heart_beat_timeout_ms(impl::ValueMember(value__, "heart_beat_timeout_ms")) , certificate(impl::ValueMember(value__, "certificate"), "not_specified") - , moduleType(impl::ValueMember(value__, "moduleType")) {} + , moduleType(impl::ValueMember(value__, "moduleType")) + , hybrid_app_preference(impl::ValueMember(value__, "hybrid_app_preference")) + , endpoint(impl::ValueMember(value__, "endpoint")) + , enabled(impl::ValueMember(value__, "enabled")) + , auth_token(impl::ValueMember(value__, "auth_token")) + , cloud_transport_type(impl::ValueMember(value__, "cloud_transport_type")) { +} Json::Value ApplicationParams::ToJsonValue() const { Json::Value result__(PolicyBase::ToJsonValue()); @@ -180,7 +186,14 @@ Json::Value ApplicationParams::ToJsonValue() const { impl::WriteJsonField("memory_kb", memory_kb, &result__); impl::WriteJsonField( "heart_beat_timeout_ms", heart_beat_timeout_ms, &result__); + impl::WriteJsonField("certificate", certificate, &result__); impl::WriteJsonField("moduleType", moduleType, &result__); + impl::WriteJsonField( + "hybrid_app_preference", hybrid_app_preference, &result__); + impl::WriteJsonField("endpoint", endpoint, &result__); + impl::WriteJsonField("enabled", enabled, &result__); + impl::WriteJsonField("auth_token", auth_token, &result__); + impl::WriteJsonField("cloud_transport_type", cloud_transport_type, &result__); return result__; } @@ -212,6 +225,21 @@ bool ApplicationParams::is_valid() const { if (!moduleType.is_valid()) { return false; } + if (!endpoint.is_valid()) { + return false; + } + if (!enabled.is_valid()) { + return false; + } + if (!auth_token.is_valid()) { + return false; + } + if (!cloud_transport_type.is_valid()) { + return false; + } + if (!hybrid_app_preference.is_valid()) { + return false; + } return Validate(); } @@ -250,6 +278,21 @@ bool ApplicationParams::struct_empty() const { if (moduleType.is_initialized()) { return false; } + if (endpoint.is_initialized()) { + return false; + } + if (enabled.is_initialized()) { + return false; + } + if (auth_token.is_initialized()) { + return false; + } + if (cloud_transport_type.is_initialized()) { + return false; + } + if (hybrid_app_preference.is_initialized()) { + return false; + } return true; } @@ -288,6 +331,22 @@ void ApplicationParams::ReportErrors(rpc::ValidationReport* report__) const { if (!moduleType.is_valid()) { moduleType.ReportErrors(&report__->ReportSubobject("moduleType")); } + if (!endpoint.is_valid()) { + moduleType.ReportErrors(&report__->ReportSubobject("endpoint")); + } + if (!enabled.is_valid()) { + moduleType.ReportErrors(&report__->ReportSubobject("enabled")); + } + if (!auth_token.is_valid()) { + moduleType.ReportErrors(&report__->ReportSubobject("auth_token")); + } + if (!cloud_transport_type.is_valid()) { + moduleType.ReportErrors(&report__->ReportSubobject("cloud_transport_type")); + } + if (!hybrid_app_preference.is_valid()) { + moduleType.ReportErrors( + &report__->ReportSubobject("hybrid_app_preference")); + } } void ApplicationParams::SetPolicyTableType(PolicyTableType pt_type) { @@ -300,6 +359,10 @@ void ApplicationParams::SetPolicyTableType(PolicyTableType pt_type) { heart_beat_timeout_ms.SetPolicyTableType(pt_type); certificate.SetPolicyTableType(pt_type); moduleType.SetPolicyTableType(pt_type); + endpoint.SetPolicyTableType(pt_type); + enabled.SetPolicyTableType(pt_type); + cloud_transport_type.SetPolicyTableType(pt_type); + hybrid_app_preference.SetPolicyTableType(pt_type); } // RpcParameters methods diff --git a/src/components/policy/policy_regular/src/sql_pt_queries.cc b/src/components/policy/policy_regular/src/sql_pt_queries.cc index f5ccffce3b..ef6c7f2a03 100644 --- a/src/components/policy/policy_regular/src/sql_pt_queries.cc +++ b/src/components/policy/policy_regular/src/sql_pt_queries.cc @@ -84,6 +84,9 @@ const std::string kCreateSchema = "CREATE TABLE IF NOT EXISTS `hmi_level`( " " `value` VARCHAR(45) PRIMARY KEY NOT NULL " "); " + "CREATE TABLE IF NOT EXISTS `hybrid_app_preference`( " + " `value` VARCHAR(45) PRIMARY KEY NOT NULL " + "); " "CREATE TABLE IF NOT EXISTS `notifications_by_priority`( " " `priority_value` VARCHAR(45) PRIMARY KEY NOT NULL, " " `value` INTEGER NOT NULL, " @@ -133,7 +136,12 @@ const std::string kCreateSchema = " `is_predata` BOOLEAN, " " `memory_kb` INTEGER NOT NULL, " " `heart_beat_timeout_ms` INTEGER NOT NULL, " - " `certificate` VARCHAR(45), " + " `certificate` VARCHAR(65535), " + " `hybrid_app_preference_value` VARCHAR(255), " + " `endpoint` VARCHAR(255), " + " `enabled` BOOLEAN, " + " `auth_token` VARCHAR(65535), " + " `cloud_transport_type` VARCHAR(255), " " `remote_control_denied` BOOLEAN NOT NULL DEFAULT 0, " " CONSTRAINT `fk_application_hmi_level1` " " FOREIGN KEY(`default_hmi`) " @@ -141,11 +149,17 @@ const std::string kCreateSchema = " CONSTRAINT `fk_application_priorities1` " " FOREIGN KEY(`priority_value`) " " REFERENCES `priority`(`value`) " + " CONSTRAINT `fk_application_hybrid_app_preference1` " + " FOREIGN KEY(`hybrid_app_preference_value`) " + " REFERENCES `hybrid_app_preference`(`value`) " "); " "CREATE INDEX IF NOT EXISTS `application.fk_application_hmi_level1_idx` " " ON `application`(`default_hmi`); " "CREATE INDEX IF NOT EXISTS `application.fk_application_priorities1_idx` " " ON `application`(`priority_value`); " + "CREATE INDEX IF NOT EXISTS " + "`application.fk_application_hybrid_app_preference1` " + " ON `application`(`hybrid_app_preference_value`); " "CREATE TABLE IF NOT EXISTS `app_group`( " " `application_id` VARCHAR(45) NOT NULL COLLATE NOCASE, " " `functional_group_id` INTEGER NOT NULL, " @@ -391,6 +405,9 @@ const std::string kInsertInitData = "INSERT OR IGNORE INTO `hmi_level`(`value`) VALUES ('LIMITED'); " "INSERT OR IGNORE INTO `hmi_level`(`value`) VALUES ('BACKGROUND'); " "INSERT OR IGNORE INTO `hmi_level`(`value`) VALUES ('NONE'); " + "INSERT OR IGNORE INTO `hybrid_app_preference`(`value`) VALUES ('MOBILE'); " + "INSERT OR IGNORE INTO `hybrid_app_preference`(`value`) VALUES ('CLOUD'); " + "INSERT OR IGNORE INTO `hybrid_app_preference`(`value`) VALUES ('BOTH'); " "INSERT OR IGNORE INTO `version` (`number`) VALUES('0'); " "INSERT OR IGNORE INTO `_internal_data` (`db_version_hash`) VALUES(0); " ""; @@ -491,6 +508,7 @@ const std::string kDropSchema = "`notifications_by_priority.fk_notifications_by_priority_priority1_idx`; " "DROP TABLE IF EXISTS `notifications_by_priority`; " "DROP TABLE IF EXISTS `hmi_level`; " + "DROP TABLE IF EXISTS `hybrid_app_preference`; " "DROP TABLE IF EXISTS `priority`; " "DROP TABLE IF EXISTS `functional_group`; " "DROP TABLE IF EXISTS `module_config`; " @@ -578,8 +596,10 @@ const std::string kInsertRpcWithParameter = const std::string kInsertApplication = "INSERT OR IGNORE INTO `application` (`id`, `priority_value`, " - "`is_revoked`, `memory_kb`," - " `heart_beat_timeout_ms`, `certificate`) VALUES (?,?,?,?,?,?)"; + "`is_revoked`, `memory_kb`, `heart_beat_timeout_ms`, `certificate`, " + "`hybrid_app_preference_value`, `endpoint`, `enabled`, `auth_token`, " + "`cloud_transport_type`) VALUES " + "(?,?,?,?,?,?,?,?,?,?,?)"; const std::string kInsertAppGroup = "INSERT INTO `app_group` (`application_id`, `functional_group_id`)" @@ -688,7 +708,8 @@ const std::string kSelectUserMsgsVersion = const std::string kSelectAppPolicies = "SELECT `id`, `priority_value`, `memory_kb`, " - " `heart_beat_timeout_ms`, `certificate` FROM `application`"; + " `heart_beat_timeout_ms`, `certificate`, `hybrid_app_preference_value`, " + " `endpoint`, `enabled`, `cloud_transport_type` FROM `application`"; const std::string kCollectFriendlyMsg = "SELECT * FROM `message`"; @@ -785,15 +806,19 @@ const std::string kDeleteAppGroupByApplicationId = const std::string kInsertApplicationFull = "INSERT OR IGNORE INTO `application` (`id`, `keep_context`, `steal_focus`, " - " `default_hmi`, `priority_value`, `is_revoked`, `is_default`, " - "`is_predata`, " - " `memory_kb`, `heart_beat_timeout_ms`, `certificate`) " - " VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"; + " `default_hmi`, `priority_value`, `is_revoked`, `is_default`, " + " `is_predata`, `memory_kb`, `heart_beat_timeout_ms`, " + " `certificate`, `hybrid_app_preference_value`, `endpoint`, `enabled`, " + " `auth_token`, `cloud_transport_type`) " + " VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"; const std::string kSelectApplicationFull = "SELECT `keep_context`, `steal_focus`, `default_hmi`, `priority_value`, " " `is_revoked`, `is_default`, `is_predata`, `memory_kb`," - " `heart_beat_timeout_ms`, `certificate` FROM `application` WHERE `id` = " + " `heart_beat_timeout_ms`, `certificate`, `hybrid_app_preference_value`, " + " `endpoint`, `enabled`, `auth_token`, `cloud_transport_type` " + "FROM `application` " + "WHERE `id` = " "?"; const std::string kSelectDBVersion = diff --git a/src/components/policy/policy_regular/src/sql_pt_representation.cc b/src/components/policy/policy_regular/src/sql_pt_representation.cc index 75f8be74eb..9282caf535 100644 --- a/src/components/policy/policy_regular/src/sql_pt_representation.cc +++ b/src/components/policy/policy_regular/src/sql_pt_representation.cc @@ -716,12 +716,24 @@ bool SQLPTRepresentation::GatherApplicationPoliciesSection( params.priority = priority; *params.memory_kb = query.GetInteger(2); - *params.heart_beat_timeout_ms = query.GetUInteger(3); - if (!query.IsNull(3)) { + if (!query.IsNull(4)) { *params.certificate = query.GetString(4); } + // Read cloud app properties + policy_table::HybridAppPreference hap; + bool valid = policy_table::EnumFromJsonString(query.GetString(5), &hap); + if (valid) { + *params.hybrid_app_preference = hap; + } + *params.endpoint = query.GetString(6); + if (!query.IsNull(7)) { + *params.enabled = query.GetBoolean(7); + } + *params.auth_token = query.GetString(8); + *params.cloud_transport_type = query.GetString(9); + const auto& gather_app_id = ((*policies).apps[app_id].is_string()) ? (*policies).apps[app_id].get_string() : app_id; @@ -984,6 +996,22 @@ bool SQLPTRepresentation::SaveSpecificAppPolicy( app.second.certificate.is_initialized() ? app_query.Bind(5, *app.second.certificate) : app_query.Bind(5); + app.second.hybrid_app_preference.is_initialized() + ? app_query.Bind(6, + std::string(policy_table::EnumToJsonString( + *app.second.hybrid_app_preference))) + : app_query.Bind(6); + app.second.endpoint.is_initialized() ? app_query.Bind(7, *app.second.endpoint) + : app_query.Bind(7); + app.second.enabled.is_initialized() ? app_query.Bind(8, *app.second.enabled) + : app_query.Bind(8); + app.second.auth_token.is_initialized() + ? app_query.Bind(9, *app.second.auth_token) + : app_query.Bind(9); + app.second.cloud_transport_type.is_initialized() + ? app_query.Bind(10, *app.second.cloud_transport_type) + : app_query.Bind(10); + if (!app_query.Exec() || !app_query.Reset()) { LOG4CXX_WARN(logger_, "Incorrect insert into application."); return false; @@ -2084,6 +2112,17 @@ bool SQLPTRepresentation::CopyApplication(const std::string& source, query.Bind(9, source_app.GetInteger(8)); source_app.IsNull(9) ? query.Bind(10) : query.Bind(10, source_app.GetString(9)); + source_app.IsNull(10) ? query.Bind(11) + : query.Bind(11, source_app.GetString(10)); + source_app.IsNull(11) ? query.Bind(12) + : query.Bind(12, source_app.GetString(11)); + source_app.IsNull(12) ? query.Bind(13) + : query.Bind(13, source_app.GetBoolean(12)); + source_app.IsNull(13) ? query.Bind(14) + : query.Bind(14, source_app.GetString(13)); + source_app.IsNull(14) ? query.Bind(15) + : query.Bind(15, source_app.GetString(14)); + if (!query.Exec()) { LOG4CXX_WARN(logger_, "Failed inserting into application."); return false; diff --git a/src/components/policy/policy_regular/test/sql_pt_representation_test.cc b/src/components/policy/policy_regular/test/sql_pt_representation_test.cc index 7d192515dc..030dc374dd 100644 --- a/src/components/policy/policy_regular/test/sql_pt_representation_test.cc +++ b/src/components/policy/policy_regular/test/sql_pt_representation_test.cc @@ -426,8 +426,8 @@ TEST_F(SQLPTRepresentationTest, ASSERT_TRUE(reps->RefreshDB()); // Check PT structure destroyed and tables number is 0 - // There are 29 tables in the database, now. - const int32_t total_tables_number = 29; + // There are 30 tables in the database, now. + const int32_t total_tables_number = 30; ASSERT_EQ(total_tables_number, dbms->FetchOneInt(query_select)); const char* query_select_count_of_iap_buffer_full = "SELECT `count_of_iap_buffer_full` FROM `usage_and_error_count`"; -- cgit v1.2.1 From 9018590ff13671993ea10479cc4d9fe2fbbe7d9a Mon Sep 17 00:00:00 2001 From: jacobkeeler Date: Fri, 2 Nov 2018 14:20:45 -0400 Subject: Add cloud app parameters to external policies --- .../policy/policy_external/policy/policy_manager.h | 52 +++++++++++++++ .../policy_external/policy/mock_cache_manager.h | 17 +++++ .../policy_external/policy/mock_policy_manager.h | 17 +++++ .../policy_external/include/policy/cache_manager.h | 51 +++++++++++++++ .../include/policy/cache_manager_interface.h | 52 +++++++++++++++ .../include/policy/policy_manager_impl.h | 52 +++++++++++++++ .../include/policy/policy_table/enums.h | 10 +++ .../include/policy/policy_table/types.h | 7 ++ .../include/policy/policy_table_interface_ext.xml | 15 ++++- .../policy/policy_external/src/cache_manager.cc | 75 ++++++++++++++++++++++ .../policy_external/src/policy_manager_impl.cc | 34 ++++++++++ .../policy_external/src/policy_table/enums.cc | 33 ++++++++++ .../policy_external/src/policy_table/types.cc | 75 +++++++++++++++++++++- .../policy_external/src/sql_pt_ext_queries.cc | 10 ++- .../src/sql_pt_ext_representation.cc | 34 ++++++++++ .../policy/policy_external/src/sql_pt_queries.cc | 42 +++++++++--- .../policy_external/src/sql_pt_representation.cc | 47 ++++++++++++++ .../test/sql_pt_representation_test.cc | 4 +- 18 files changed, 612 insertions(+), 15 deletions(-) diff --git a/src/components/include/policy/policy_external/policy/policy_manager.h b/src/components/include/policy/policy_external/policy/policy_manager.h index 57f6d2f802..2ea8ef08f1 100644 --- a/src/components/include/policy/policy_external/policy/policy_manager.h +++ b/src/components/include/policy/policy_external/policy/policy_manager.h @@ -521,6 +521,58 @@ class PolicyManager : public usage_statistics::StatisticsManager { * @return vehicle information */ virtual const VehicleInfo GetVehicleInfo() const = 0; + + /** + * @brief Get cloud app policy information, all fields that aren't set for a + * given app will be filled with empty strings + * @param policy_app_id Unique application id + * @param endpoint Filled the endpoint used to connect to the cloud + * application + * @param auth_token Filled with the token used for authentication when + * reconnecting to the cloud app + * @param cloud_transport_type Filled with the transport type used by the + * cloud application (ex. "WSS") + * @param cloud_transport_type Filled with the hybrid app preference for the + * cloud application set by the user + * @return true if the cloud app is enabled, false otherwise + */ + virtual const bool GetCloudAppParameters( + const std::string& policy_app_id, + std::string& endpoint, + std::string& auth_token, + std::string& cloud_transport_type, + std::string& hybrid_app_preference) const = 0; + + /** + * @brief Enable or disable a cloud application in the HMI + * @param enabled Cloud app enabled state + */ + virtual void SetCloudAppEnabled(const std::string& policy_app_id, + const bool enabled) = 0; + + /** + * @brief Set an app's auth token + * @param auth_token Cloud app authentication token + */ + virtual void SetAppAuthToken(const std::string& policy_app_id, + const std::string& auth_token) = 0; + + /** + * @brief Set a cloud app's transport type + * @param cloud_transport_type Cloud app transport type + */ + virtual void SetAppCloudTransportType( + const std::string& policy_app_id, + const std::string& cloud_transport_type) = 0; + + /** + * @brief Set the user preference for how a hybrid (cloud and mobile) app + * should be used + * @param hybrid_app_preference Hybrid app user preference + */ + virtual void SetHybridAppPreference( + const std::string& policy_app_id, + const std::string& hybrid_app_preference) = 0; /** * @brief Gets meta information diff --git a/src/components/include/test/policy/policy_external/policy/mock_cache_manager.h b/src/components/include/test/policy/policy_external/policy/mock_cache_manager.h index a4d50d7cc2..ecbd8c6cd6 100644 --- a/src/components/include/test/policy/policy_external/policy/mock_cache_manager.h +++ b/src/components/include/test/policy/policy_external/policy/mock_cache_manager.h @@ -76,6 +76,23 @@ class MockCacheManagerInterface : public ::policy::CacheManagerInterface { MOCK_METHOD1(SecondsBetweenRetries, bool(std::vector& seconds)); MOCK_CONST_METHOD1(IsDeviceConsentCached, bool(const std::string& device_id)); MOCK_CONST_METHOD0(GetVehicleInfo, const VehicleInfo()); + MOCK_CONST_METHOD5(GetCloudAppParameters, + const bool(const std::string& policy_app_id, + std::string& endpoint, + std::string& auth_token, + std::string& cloud_transport_type, + std::string& hybrid_app_preference)); + MOCK_METHOD2(SetCloudAppEnabled, + void(const std::string& policy_app_id, const bool enabled)); + MOCK_METHOD2(SetAppAuthToken, + void(const std::string& policy_app_id, + const std::string& auth_token)); + MOCK_METHOD2(SetAppCloudTransportType, + void(const std::string& policy_app_id, + const std::string& cloud_transport_type)); + MOCK_METHOD2(SetHybridAppPreference, + void(const std::string& policy_app_id, + const std::string& hybrid_app_preference)); MOCK_CONST_METHOD1(GetDeviceConsent, DeviceConsent(const std::string& device_id)); MOCK_METHOD2(SetDeviceConsent, diff --git a/src/components/include/test/policy/policy_external/policy/mock_policy_manager.h b/src/components/include/test/policy/policy_external/policy/mock_policy_manager.h index aeabf8fdcb..f58ed10934 100644 --- a/src/components/include/test/policy/policy_external/policy/mock_policy_manager.h +++ b/src/components/include/test/policy/policy_external/policy/mock_policy_manager.h @@ -184,6 +184,23 @@ class MockPolicyManager : public PolicyManager { GetAppRequestTypes, const std::vector(const std::string policy_app_id)); MOCK_CONST_METHOD0(GetVehicleInfo, const policy::VehicleInfo()); + MOCK_CONST_METHOD5(GetCloudAppParameters, + const bool(const std::string& policy_app_id, + std::string& endpoint, + std::string& auth_token, + std::string& cloud_transport_type, + std::string& hybrid_app_preference)); + MOCK_METHOD2(SetCloudAppEnabled, + void(const std::string& policy_app_id, const bool enabled)); + MOCK_METHOD2(SetAppAuthToken, + void(const std::string& policy_app_id, + const std::string& auth_token)); + MOCK_METHOD2(SetAppCloudTransportType, + void(const std::string& policy_app_id, + const std::string& cloud_transport_type)); + MOCK_METHOD2(SetHybridAppPreference, + void(const std::string& policy_app_id, + const std::string& hybrid_app_preference)); MOCK_CONST_METHOD0(GetMetaInfo, const policy::MetaInfo()); MOCK_CONST_METHOD0(RetrieveCertificate, std::string()); MOCK_CONST_METHOD0(HasCertificate, bool()); diff --git a/src/components/policy/policy_external/include/policy/cache_manager.h b/src/components/policy/policy_external/include/policy/cache_manager.h index d30e7cea24..d6eeb0457b 100644 --- a/src/components/policy/policy_external/include/policy/cache_manager.h +++ b/src/components/policy/policy_external/include/policy/cache_manager.h @@ -158,6 +158,57 @@ class CacheManager : public CacheManagerInterface { */ virtual const VehicleInfo GetVehicleInfo() const; + /** + * @brief Get cloud app policy information, all fields that aren't set for a + * given app will be filled with empty strings + * @param policy_app_id Unique application id + * @param endpoint Filled the endpoint used to connect to the cloud + * application + * @param auth_token Filled with the token used for authentication when + * reconnecting to the cloud app + * @param cloud_transport_type Filled with the transport type used by the + * cloud application (ex. "WSS") + * @param cloud_transport_type Filled with the hybrid app preference for the + * cloud application set by the user + * @return true if the cloud app is enabled, false otherwise + */ + virtual const bool GetCloudAppParameters( + const std::string& policy_app_id, + std::string& endpoint, + std::string& auth_token, + std::string& cloud_transport_type, + std::string& hybrid_app_preference) const; + + /** + * @brief Enable or disable a cloud application in the HMI + * @param enabled Cloud app enabled state + */ + virtual void SetCloudAppEnabled(const std::string& policy_app_id, + const bool enabled); + + /** + * @brief Set an app's auth token + * @param auth_token Cloud app authentication token + */ + virtual void SetAppAuthToken(const std::string& policy_app_id, + const std::string& auth_token); + + /** + * @brief Set a cloud app's transport type + * @param cloud_transport_type Cloud app transport type + */ + virtual void SetAppCloudTransportType( + const std::string& policy_app_id, + const std::string& cloud_transport_type); + + /** + * @brief Set the user preference for how a hybrid (cloud and mobile) app + * should be used + * @param hybrid_app_preference Hybrid app user preference + */ + virtual void SetHybridAppPreference(const std::string& policy_app_id, + const std::string& hybrid_app_preference); + /** * @brief Allows to update 'vin' field in module_meta table. * diff --git a/src/components/policy/policy_external/include/policy/cache_manager_interface.h b/src/components/policy/policy_external/include/policy/cache_manager_interface.h index bb9ce14c7f..0c094d2edb 100644 --- a/src/components/policy/policy_external/include/policy/cache_manager_interface.h +++ b/src/components/policy/policy_external/include/policy/cache_manager_interface.h @@ -165,6 +165,58 @@ class CacheManagerInterface { */ virtual const VehicleInfo GetVehicleInfo() const = 0; + /** + * @brief Get cloud app policy information, all fields that aren't set for a + * given app will be filled with empty strings + * @param policy_app_id Unique application id + * @param endpoint Filled the endpoint used to connect to the cloud + * application + * @param auth_token Filled with the token used for authentication when + * reconnecting to the cloud app + * @param cloud_transport_type Filled with the transport type used by the + * cloud application (ex. "WSS") + * @param cloud_transport_type Filled with the hybrid app preference for the + * cloud application set by the user + * @return true if the cloud app is enabled, false otherwise + */ + virtual const bool GetCloudAppParameters( + const std::string& policy_app_id, + std::string& endpoint, + std::string& auth_token, + std::string& cloud_transport_type, + std::string& hybrid_app_preference) const = 0; + + /** + * @brief Enable or disable a cloud application in the HMI + * @param enabled Cloud app enabled state + */ + virtual void SetCloudAppEnabled(const std::string& policy_app_id, + const bool enabled) = 0; + + /** + * @brief Set an app's auth token + * @param auth_token Cloud app authentication token + */ + virtual void SetAppAuthToken(const std::string& policy_app_id, + const std::string& auth_token) = 0; + + /** + * @brief Set a cloud app's transport type + * @param cloud_transport_type Cloud app transport type + */ + virtual void SetAppCloudTransportType( + const std::string& policy_app_id, + const std::string& cloud_transport_type) = 0; + + /** + * @brief Set the user preference for how a hybrid (cloud and mobile) app + * should be used + * @param hybrid_app_preference Hybrid app user preference + */ + virtual void SetHybridAppPreference( + const std::string& policy_app_id, + const std::string& hybrid_app_preference) = 0; + /** * @brief Allows to update 'vin' field in module_meta table. * diff --git a/src/components/policy/policy_external/include/policy/policy_manager_impl.h b/src/components/policy/policy_external/include/policy/policy_manager_impl.h index 3837dda1fa..f9648f803c 100644 --- a/src/components/policy/policy_external/include/policy/policy_manager_impl.h +++ b/src/components/policy/policy_external/include/policy/policy_manager_impl.h @@ -569,6 +569,58 @@ class PolicyManagerImpl : public PolicyManager { * @return vehicle information */ const VehicleInfo GetVehicleInfo() const OVERRIDE; + + /** + * @brief Get cloud app policy information, all fields that aren't set for a + * given app will be filled with empty strings + * @param policy_app_id Unique application id + * @param endpoint Filled the endpoint used to connect to the cloud + * application + * @param auth_token Filled with the token used for authentication when + * reconnecting to the cloud app + * @param cloud_transport_type Filled with the transport type used by the + * cloud application (ex. "WSS") + * @param cloud_transport_type Filled with the hybrid app preference for the + * cloud application set by the user + * @return true if the cloud app is enabled, false otherwise + */ + const bool GetCloudAppParameters( + const std::string& policy_app_id, + std::string& endpoint, + std::string& auth_token, + std::string& cloud_transport_type, + std::string& hybrid_app_preference) const OVERRIDE; + + /** + * @brief Enable or disable a cloud application in the HMI + * @param enabled Cloud app enabled state + */ + void SetCloudAppEnabled(const std::string& policy_app_id, + const bool enabled) OVERRIDE; + + /** + * @brief Set an app's auth token + * @param auth_token Cloud app authentication token + */ + void SetAppAuthToken(const std::string& policy_app_id, + const std::string& auth_token) OVERRIDE; + + /** + * @brief Set a cloud app's transport type + * @param cloud_transport_type Cloud app transport type + */ + void SetAppCloudTransportType( + const std::string& policy_app_id, + const std::string& cloud_transport_type) OVERRIDE; + + /** + * @brief Set the user preference for how a hybrid (cloud and mobile) app + * should be used + * @param hybrid_app_preference Hybrid app user preference + */ + void SetHybridAppPreference( + const std::string& policy_app_id, + const std::string& hybrid_app_preference) OVERRIDE; /** * @brief OnAppRegisteredOnMobile allows to handle event when application were diff --git a/src/components/policy/policy_external/include/policy/policy_table/enums.h b/src/components/policy/policy_external/include/policy/policy_table/enums.h index 34864c5602..f5b85f0a4d 100644 --- a/src/components/policy/policy_external/include/policy/policy_table/enums.h +++ b/src/components/policy/policy_external/include/policy/policy_table/enums.h @@ -181,6 +181,16 @@ bool IsValidEnum(ModuleType val); const char* EnumToJsonString(ModuleType val); bool EnumFromJsonString(const std::string& literal, ModuleType* result); +enum HybridAppPreference { + HAP_MOBILE, + HAP_CLOUD, + HAP_BOTH +}; +bool IsValidEnum(HybridAppPreference val); +const char* EnumToJsonString(HybridAppPreference val); +bool EnumFromJsonString(const std::string& literal, + HybridAppPreference* result); + /** * @brief Enumeration FunctionID. * diff --git a/src/components/policy/policy_external/include/policy/policy_table/types.h b/src/components/policy/policy_external/include/policy/policy_table/types.h index 68e29a97ee..f37531eb63 100644 --- a/src/components/policy/policy_external/include/policy/policy_table/types.h +++ b/src/components/policy/policy_external/include/policy/policy_table/types.h @@ -177,6 +177,13 @@ struct ApplicationParams : PolicyBase { Optional > memory_kb; Optional > heart_beat_timeout_ms; mutable Optional moduleType; + Optional > certificate; + // Cloud application params + Optional > hybrid_app_preference; + Optional > endpoint; + Optional enabled; + Optional > auth_token; + Optional > cloud_transport_type; public: ApplicationParams(); diff --git a/src/components/policy/policy_external/include/policy/policy_table_interface_ext.xml b/src/components/policy/policy_external/include/policy/policy_table_interface_ext.xml index 26af165506..f5f0a7dedc 100644 --- a/src/components/policy/policy_external/include/policy/policy_table_interface_ext.xml +++ b/src/components/policy/policy_external/include/policy/policy_table_interface_ext.xml @@ -70,6 +70,12 @@ + + + + + + @@ -92,8 +98,15 @@ - + + + + + policy_table.app_policies_section.apps; + policy_table::ApplicationPolicies::const_iterator policy_iter = + policies.find(policy_app_id); + if (policies.end() != policy_iter) { + auto app_policy = (*policy_iter).second; + endpoint = app_policy.endpoint.is_initialized() ? *app_policy.endpoint + : std::string(); + auth_token = app_policy.auth_token.is_initialized() ? *app_policy.auth_token + : std::string(); + cloud_transport_type = app_policy.cloud_transport_type.is_initialized() + ? *app_policy.cloud_transport_type + : std::string(); + hybrid_app_preference = + app_policy.hybrid_app_preference.is_initialized() + ? EnumToJsonString(*app_policy.hybrid_app_preference) + : std::string(); + return app_policy.enabled.is_initialized() && *app_policy.enabled; + } + return false; +} + +void CacheManager::SetCloudAppEnabled(const std::string& policy_app_id, + const bool enabled) { + policy_table::ApplicationPolicies& policies = + pt_->policy_table.app_policies_section.apps; + policy_table::ApplicationPolicies::iterator policy_iter = + policies.find(policy_app_id); + if (policies.end() != policy_iter) { + *(*policy_iter).second.enabled = enabled; + } +} + +void CacheManager::SetAppAuthToken(const std::string& policy_app_id, + const std::string& auth_token) { + policy_table::ApplicationPolicies& policies = + pt_->policy_table.app_policies_section.apps; + policy_table::ApplicationPolicies::iterator policy_iter = + policies.find(policy_app_id); + if (policies.end() != policy_iter) { + *(*policy_iter).second.auth_token = auth_token; + } +} + +void CacheManager::SetAppCloudTransportType( + const std::string& policy_app_id, const std::string& cloud_transport_type) { + policy_table::ApplicationPolicies& policies = + pt_->policy_table.app_policies_section.apps; + policy_table::ApplicationPolicies::iterator policy_iter = + policies.find(policy_app_id); + if (policies.end() != policy_iter) { + *(*policy_iter).second.cloud_transport_type = cloud_transport_type; + } +} + +void CacheManager::SetHybridAppPreference( + const std::string& policy_app_id, + const std::string& hybrid_app_preference) { + policy_table::HybridAppPreference value; + bool valid = EnumFromJsonString(hybrid_app_preference, &value); + policy_table::ApplicationPolicies& policies = + pt_->policy_table.app_policies_section.apps; + policy_table::ApplicationPolicies::iterator policy_iter = + policies.find(policy_app_id); + if (policies.end() != policy_iter && valid) { + *(*policy_iter).second.hybrid_app_preference = value; + } +} + std::vector CacheManager::GetUserFriendlyMsg( const std::vector& msg_codes, const std::string& language, diff --git a/src/components/policy/policy_external/src/policy_manager_impl.cc b/src/components/policy/policy_external/src/policy_manager_impl.cc index a603f122e2..e7538fa1b0 100644 --- a/src/components/policy/policy_external/src/policy_manager_impl.cc +++ b/src/components/policy/policy_external/src/policy_manager_impl.cc @@ -725,6 +725,40 @@ const VehicleInfo PolicyManagerImpl::GetVehicleInfo() const { return cache_->GetVehicleInfo(); } +const bool PolicyManagerImpl::GetCloudAppParameters( + const std::string& policy_app_id, + std::string& endpoint, + std::string& auth_token, + std::string& cloud_transport_type, + std::string& hybrid_app_preference) const { + return cache_->GetCloudAppParameters(policy_app_id, + endpoint, + auth_token, + cloud_transport_type, + hybrid_app_preference); +} + +void PolicyManagerImpl::SetCloudAppEnabled(const std::string& policy_app_id, + const bool enabled) { + cache_->SetCloudAppEnabled(policy_app_id, enabled); +} + +void PolicyManagerImpl::SetAppAuthToken(const std::string& policy_app_id, + const std::string& auth_token) { + cache_->SetAppAuthToken(policy_app_id, auth_token); +} + +void PolicyManagerImpl::SetAppCloudTransportType( + const std::string& policy_app_id, const std::string& cloud_transport_type) { + cache_->SetAppCloudTransportType(policy_app_id, cloud_transport_type); +} + +void PolicyManagerImpl::SetHybridAppPreference( + const std::string& policy_app_id, + const std::string& hybrid_app_preference) { + cache_->SetHybridAppPreference(policy_app_id, hybrid_app_preference); +} + void PolicyManagerImpl::CheckPermissions(const PTString& app_id, const PTString& hmi_level, const PTString& rpc, diff --git a/src/components/policy/policy_external/src/policy_table/enums.cc b/src/components/policy/policy_external/src/policy_table/enums.cc index 27db505e3f..d8e73670b2 100644 --- a/src/components/policy/policy_external/src/policy_table/enums.cc +++ b/src/components/policy/policy_external/src/policy_table/enums.cc @@ -1,4 +1,5 @@ #include "policy/policy_table/enums.h" +#include namespace rpc { namespace policy_table_interface_base { @@ -840,6 +841,38 @@ bool EnumFromJsonString(const std::string& literal, ModuleType* result) { } } +bool IsValidEnum(HybridAppPreference val) { + return strlen(EnumToJsonString(val)) > 0; +} + +const char* EnumToJsonString(HybridAppPreference val) { + switch (val) { + case HAP_MOBILE: + return "MOBILE"; + case HAP_CLOUD: + return "CLOUD"; + case HAP_BOTH: + return "BOTH"; + default: + return ""; + } +} + +bool EnumFromJsonString(const std::string& literal, + HybridAppPreference* result) { + if ("MOBILE" == literal) { + *result = HAP_MOBILE; + return true; + } else if ("CLOUD" == literal) { + *result = HAP_CLOUD; + return true; + } else if ("BOTH" == literal) { + *result = HAP_BOTH; + return true; + } + return false; +} + bool EnumFromJsonString(const std::string& literal, FunctionID* result) { if ("RegisterAppInterface" == literal) { *result = RegisterAppInterfaceID; diff --git a/src/components/policy/policy_external/src/policy_table/types.cc b/src/components/policy/policy_external/src/policy_table/types.cc index 5922a020e6..4867eef281 100644 --- a/src/components/policy/policy_external/src/policy_table/types.cc +++ b/src/components/policy/policy_external/src/policy_table/types.cc @@ -241,7 +241,13 @@ ApplicationParams::ApplicationParams(const Json::Value* value__) , RequestSubType(impl::ValueMember(value__, "RequestSubType")) , memory_kb(impl::ValueMember(value__, "memory_kb"), 0) , heart_beat_timeout_ms(impl::ValueMember(value__, "heart_beat_timeout_ms")) - , moduleType(impl::ValueMember(value__, "moduleType")) {} + , moduleType(impl::ValueMember(value__, "moduleType")) + , certificate(impl::ValueMember(value__, "certificate"), "not_specified") + , hybrid_app_preference(impl::ValueMember(value__, "hybrid_app_preference")) + , endpoint(impl::ValueMember(value__, "endpoint")) + , enabled(impl::ValueMember(value__, "enabled")) + , auth_token(impl::ValueMember(value__, "auth_token")) + , cloud_transport_type(impl::ValueMember(value__, "cloud_transport_type")) {} Json::Value ApplicationParams::ToJsonValue() const { Json::Value result__(PolicyBase::ToJsonValue()); @@ -253,6 +259,13 @@ Json::Value ApplicationParams::ToJsonValue() const { impl::WriteJsonField( "heart_beat_timeout_ms", heart_beat_timeout_ms, &result__); impl::WriteJsonField("moduleType", moduleType, &result__); + impl::WriteJsonField("certificate", certificate, &result__); + impl::WriteJsonField( + "hybrid_app_preference", hybrid_app_preference, &result__); + impl::WriteJsonField("endpoint", endpoint, &result__); + impl::WriteJsonField("enabled", enabled, &result__); + impl::WriteJsonField("auth_token", auth_token, &result__); + impl::WriteJsonField("cloud_transport_type", cloud_transport_type, &result__); return result__; } @@ -277,6 +290,24 @@ bool ApplicationParams::is_valid() const { if (!moduleType.is_valid()) { return false; } + if (!certificate.is_valid()) { + return false; + } + if (!endpoint.is_valid()) { + return false; + } + if (!enabled.is_valid()) { + return false; + } + if (!auth_token.is_valid()) { + return false; + } + if (!cloud_transport_type.is_valid()) { + return false; + } + if (!hybrid_app_preference.is_valid()) { + return false; + } return Validate(); } @@ -309,6 +340,24 @@ bool ApplicationParams::struct_empty() const { if (moduleType.is_initialized()) { return false; } + if (certificate.is_initialized()) { + return false; + } + if (endpoint.is_initialized()) { + return false; + } + if (enabled.is_initialized()) { + return false; + } + if (auth_token.is_initialized()) { + return false; + } + if (cloud_transport_type.is_initialized()) { + return false; + } + if (hybrid_app_preference.is_initialized()) { + return false; + } return true; } @@ -357,6 +406,25 @@ void ApplicationParams::ReportErrors(rpc::ValidationReport* report__) const { if (!moduleType.is_valid()) { moduleType.ReportErrors(&report__->ReportSubobject("moduleType")); } + if (!certificate.is_valid()) { + certificate.ReportErrors(&report__->ReportSubobject("certificate")); + } + if (!endpoint.is_valid()) { + moduleType.ReportErrors(&report__->ReportSubobject("endpoint")); + } + if (!enabled.is_valid()) { + moduleType.ReportErrors(&report__->ReportSubobject("enabled")); + } + if (!auth_token.is_valid()) { + moduleType.ReportErrors(&report__->ReportSubobject("auth_token")); + } + if (!cloud_transport_type.is_valid()) { + moduleType.ReportErrors(&report__->ReportSubobject("cloud_transport_type")); + } + if (!hybrid_app_preference.is_valid()) { + moduleType.ReportErrors( + &report__->ReportSubobject("hybrid_app_preference")); + } } void ApplicationParams::SetPolicyTableType(PolicyTableType pt_type) { @@ -367,6 +435,11 @@ void ApplicationParams::SetPolicyTableType(PolicyTableType pt_type) { memory_kb.SetPolicyTableType(pt_type); heart_beat_timeout_ms.SetPolicyTableType(pt_type); moduleType.SetPolicyTableType(pt_type); + certificate.SetPolicyTableType(pt_type); + endpoint.SetPolicyTableType(pt_type); + enabled.SetPolicyTableType(pt_type); + cloud_transport_type.SetPolicyTableType(pt_type); + hybrid_app_preference.SetPolicyTableType(pt_type); } // RpcParameters methods diff --git a/src/components/policy/policy_external/src/sql_pt_ext_queries.cc b/src/components/policy/policy_external/src/sql_pt_ext_queries.cc index afb1180692..f7e1acb59a 100644 --- a/src/components/policy/policy_external/src/sql_pt_ext_queries.cc +++ b/src/components/policy/policy_external/src/sql_pt_ext_queries.cc @@ -205,7 +205,10 @@ const std::string kUpdateGroupPermissions = const std::string kInsertApplication = "INSERT OR IGNORE INTO `application`(`id`, `keep_context`, `steal_focus`, " " `default_hmi`, `priority_value`, `is_revoked`, `memory_kb`, " - " `heart_beat_timeout_ms`) VALUES( ?, ?, ?, ?, ?, ?, ?, ?) "; + " `heart_beat_timeout_ms`, `certificate`, `hybrid_app_preference_value`, " + " `endpoint`, `enabled`, `auth_token`, " + " `cloud_transport_type`) VALUES " + "(?,?,?,?,?,?,?,?,?,?,?,?,?,?)"; const std::string kCollectFriendlyMsg = "SELECT * FROM `message`"; @@ -232,8 +235,9 @@ const std::string kSelectPreconsentedGroupsId = const std::string kSelectAppPolicies = "SELECT `id`, `priority_value`, `default_hmi`, `keep_context`, " - "`steal_focus`, " - " `memory_kb`, `heart_beat_timeout_ms` FROM `application`"; + " `steal_focus`, `memory_kb`, `heart_beat_timeout_ms`, `certificate`, " + " `hybrid_app_preference_value`, `endpoint`, `enabled`, " + " `cloud_transport_type` FROM `application`"; const std::string kSelectFunctionalGroupNames = "SELECT `id`, `user_consent_prompt`, `name`" diff --git a/src/components/policy/policy_external/src/sql_pt_ext_representation.cc b/src/components/policy/policy_external/src/sql_pt_ext_representation.cc index a43b22a3b8..6a40e6d135 100644 --- a/src/components/policy/policy_external/src/sql_pt_ext_representation.cc +++ b/src/components/policy/policy_external/src/sql_pt_ext_representation.cc @@ -752,6 +752,24 @@ bool SQLPTExtRepresentation::SaveSpecificAppPolicy( app_query.Bind(5, app.second.is_null()); app_query.Bind(6, *app.second.memory_kb); app_query.Bind(7, static_cast(*app.second.heart_beat_timeout_ms)); + app.second.certificate.is_initialized() + ? app_query.Bind(8, *app.second.certificate) + : app_query.Bind(8); + app.second.hybrid_app_preference.is_initialized() + ? app_query.Bind(9, + std::string(policy_table::EnumToJsonString( + *app.second.hybrid_app_preference))) + : app_query.Bind(9); + app.second.endpoint.is_initialized() ? app_query.Bind(10, *app.second.endpoint) + : app_query.Bind(10); + app.second.enabled.is_initialized() ? app_query.Bind(11, *app.second.enabled) + : app_query.Bind(11); + app.second.auth_token.is_initialized() + ? app_query.Bind(12, *app.second.auth_token) + : app_query.Bind(12); + app.second.cloud_transport_type.is_initialized() + ? app_query.Bind(13, *app.second.cloud_transport_type) + : app_query.Bind(13); if (!app_query.Exec() || !app_query.Reset()) { LOG4CXX_WARN(logger_, "Incorrect insert into application."); @@ -873,6 +891,22 @@ bool SQLPTExtRepresentation::GatherApplicationPoliciesSection( params.steal_focus = query.GetBoolean(4); *params.memory_kb = query.GetInteger(5); *params.heart_beat_timeout_ms = query.GetUInteger(6); + if (!query.IsNull(7)) { + *params.certificate = query.GetString(7); + } + + // Read cloud app properties + policy_table::HybridAppPreference hap; + bool valid = policy_table::EnumFromJsonString(query.GetString(8), &hap); + if (valid) { + *params.hybrid_app_preference = hap; + } + *params.endpoint = query.GetString(9); + if (!query.IsNull(10)) { + *params.enabled = query.GetBoolean(10); + } + *params.auth_token = query.GetString(11); + *params.cloud_transport_type = query.GetString(12); const auto& gather_app_id = ((*policies).apps[app_id].is_string()) ? (*policies).apps[app_id].get_string() diff --git a/src/components/policy/policy_external/src/sql_pt_queries.cc b/src/components/policy/policy_external/src/sql_pt_queries.cc index 97d75731ea..8c4227963a 100644 --- a/src/components/policy/policy_external/src/sql_pt_queries.cc +++ b/src/components/policy/policy_external/src/sql_pt_queries.cc @@ -98,6 +98,9 @@ const std::string kCreateSchema = "CREATE TABLE IF NOT EXISTS `hmi_level`( " " `value` VARCHAR(45) PRIMARY KEY NOT NULL " "); " + "CREATE TABLE IF NOT EXISTS `hybrid_app_preference`( " + " `value` VARCHAR(45) PRIMARY KEY NOT NULL " + "); " "CREATE TABLE IF NOT EXISTS `notifications_by_priority`( " " `priority_value` VARCHAR(45) PRIMARY KEY NOT NULL, " " `value` INTEGER NOT NULL, " @@ -147,6 +150,12 @@ const std::string kCreateSchema = " `is_predata` BOOLEAN, " " `memory_kb` INTEGER NOT NULL, " " `heart_beat_timeout_ms` INTEGER NOT NULL, " + " `certificate` VARCHAR(65535), " + " `hybrid_app_preference_value` VARCHAR(255), " + " `endpoint` VARCHAR(255), " + " `enabled` BOOLEAN, " + " `auth_token` VARCHAR(65535), " + " `cloud_transport_type` VARCHAR(255), " " `remote_control_denied` BOOLEAN NOT NULL DEFAULT 0, " " CONSTRAINT `fk_application_hmi_level1` " " FOREIGN KEY(`default_hmi`) " @@ -154,11 +163,17 @@ const std::string kCreateSchema = " CONSTRAINT `fk_application_priorities1` " " FOREIGN KEY(`priority_value`) " " REFERENCES `priority`(`value`) " + " CONSTRAINT `fk_application_hybrid_app_preference1` " + " FOREIGN KEY(`hybrid_app_preference_value`) " + " REFERENCES `hybrid_app_preference`(`value`) " "); " "CREATE INDEX IF NOT EXISTS `application.fk_application_hmi_level1_idx` " " ON `application`(`default_hmi`); " "CREATE INDEX IF NOT EXISTS `application.fk_application_priorities1_idx` " " ON `application`(`priority_value`); " + "CREATE INDEX IF NOT EXISTS " + "`application.fk_application_hybrid_app_preference1` " + " ON `application`(`hybrid_app_preference_value`); " "CREATE TABLE IF NOT EXISTS `app_group`( " " `application_id` VARCHAR(45) NOT NULL COLLATE NOCASE, " " `functional_group_id` INTEGER NOT NULL, " @@ -430,6 +445,9 @@ const std::string kInsertInitData = "INSERT OR IGNORE INTO `hmi_level`(`value`) VALUES ('LIMITED'); " "INSERT OR IGNORE INTO `hmi_level`(`value`) VALUES ('BACKGROUND'); " "INSERT OR IGNORE INTO `hmi_level`(`value`) VALUES ('NONE'); " + "INSERT OR IGNORE INTO `hybrid_app_preference`(`value`) VALUES ('MOBILE'); " + "INSERT OR IGNORE INTO `hybrid_app_preference`(`value`) VALUES ('CLOUD'); " + "INSERT OR IGNORE INTO `hybrid_app_preference`(`value`) VALUES ('BOTH'); " "INSERT OR IGNORE INTO `version` (`number`) VALUES('0'); " "INSERT OR IGNORE INTO `_internal_data` (`db_version_hash`) VALUES(0); " ""; @@ -532,6 +550,7 @@ const std::string kDropSchema = "`notifications_by_priority.fk_notifications_by_priority_priority1_idx`; " "DROP TABLE IF EXISTS `notifications_by_priority`; " "DROP TABLE IF EXISTS `hmi_level`; " + "DROP TABLE IF EXISTS `hybrid_app_preference`; " "DROP TABLE IF EXISTS `priority`; " "DROP TABLE IF EXISTS `functional_group`; " "DROP TABLE IF EXISTS `module_config`; " @@ -628,8 +647,10 @@ const std::string kInsertRpcWithParameter = const std::string kInsertApplication = "INSERT OR IGNORE INTO `application` (`id`, `priority_value`, " - "`is_revoked`, `memory_kb`," - " `heart_beat_timeout_ms`) VALUES (?,?,?,?,?)"; + "`is_revoked`, `memory_kb`, `heart_beat_timeout_ms`, `certificate`, " + "`hybrid_app_preference_value`, `endpoint`, `enabled`, `auth_token`, " + "`cloud_transport_type`) VALUES " + "(?,?,?,?,?,?,?,?,?,?,?)"; const std::string kInsertAppGroup = "INSERT INTO `app_group` (`application_id`, `functional_group_id`)" @@ -752,7 +773,8 @@ const std::string kSelectUserMsgsVersion = const std::string kSelectAppPolicies = "SELECT `id`, `priority_value`, `memory_kb`, " - " `heart_beat_timeout_ms` FROM `application`"; + " `heart_beat_timeout_ms`, `certificate`, `hybrid_app_preference_value`, " + " `endpoint`, `enabled`, `cloud_transport_type` FROM `application`"; const std::string kCollectFriendlyMsg = "SELECT * FROM `message`"; @@ -849,15 +871,19 @@ const std::string kDeleteAppGroupByApplicationId = const std::string kInsertApplicationFull = "INSERT OR IGNORE INTO `application` (`id`, `keep_context`, `steal_focus`, " - " `default_hmi`, `priority_value`, `is_revoked`, `is_default`, " - "`is_predata`, " - " `memory_kb`, `heart_beat_timeout_ms`) " - " VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"; + " `default_hmi`, `priority_value`, `is_revoked`, `is_default`, " + " `is_predata`, `memory_kb`, `heart_beat_timeout_ms`, " + " `certificate`, `hybrid_app_preference_value`, `endpoint`, `enabled`, " + " `auth_token`, `cloud_transport_type`) " + " VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"; const std::string kSelectApplicationFull = "SELECT `keep_context`, `steal_focus`, `default_hmi`, `priority_value`, " " `is_revoked`, `is_default`, `is_predata`, `memory_kb`," - " `heart_beat_timeout_ms` FROM `application` WHERE `id` = ?"; + " `heart_beat_timeout_ms`, `certificate`, `hybrid_app_preference_value`, " + " `endpoint`, `enabled`, `auth_token`, `cloud_transport_type` " + "FROM `application` " + "WHERE `id` = ?"; const std::string kSelectDBVersion = "SELECT `db_version_hash` from `_internal_data`"; diff --git a/src/components/policy/policy_external/src/sql_pt_representation.cc b/src/components/policy/policy_external/src/sql_pt_representation.cc index c8b367c8ec..b794d4c3a6 100644 --- a/src/components/policy/policy_external/src/sql_pt_representation.cc +++ b/src/components/policy/policy_external/src/sql_pt_representation.cc @@ -761,6 +761,23 @@ bool SQLPTRepresentation::GatherApplicationPoliciesSection( *params.memory_kb = query.GetInteger(2); *params.heart_beat_timeout_ms = query.GetUInteger(3); + if (!query.IsNull(4)) { + *params.certificate = query.GetString(4); + } + + // Read cloud app properties + policy_table::HybridAppPreference hap; + bool valid = policy_table::EnumFromJsonString(query.GetString(5), &hap); + if (valid) { + *params.hybrid_app_preference = hap; + } + *params.endpoint = query.GetString(6); + if (!query.IsNull(7)) { + *params.enabled = query.GetBoolean(7); + } + *params.auth_token = query.GetString(8); + *params.cloud_transport_type = query.GetString(9); + const auto& gather_app_id = ((*policies).apps[app_id].is_string()) ? (*policies).apps[app_id].get_string() : app_id; @@ -1035,6 +1052,24 @@ bool SQLPTRepresentation::SaveSpecificAppPolicy( app_query.Bind(2, app.second.is_null()); app_query.Bind(3, *app.second.memory_kb); app_query.Bind(4, static_cast(*app.second.heart_beat_timeout_ms)); + app.second.certificate.is_initialized() + ? app_query.Bind(5, *app.second.certificate) + : app_query.Bind(5); + app.second.hybrid_app_preference.is_initialized() + ? app_query.Bind(6, + std::string(policy_table::EnumToJsonString( + *app.second.hybrid_app_preference))) + : app_query.Bind(6); + app.second.endpoint.is_initialized() ? app_query.Bind(7, *app.second.endpoint) + : app_query.Bind(7); + app.second.enabled.is_initialized() ? app_query.Bind(8, *app.second.enabled) + : app_query.Bind(8); + app.second.auth_token.is_initialized() + ? app_query.Bind(9, *app.second.auth_token) + : app_query.Bind(9); + app.second.cloud_transport_type.is_initialized() + ? app_query.Bind(10, *app.second.cloud_transport_type) + : app_query.Bind(10); if (!app_query.Exec() || !app_query.Reset()) { LOG4CXX_WARN(logger_, "Incorrect insert into application."); @@ -2125,6 +2160,18 @@ bool SQLPTRepresentation::CopyApplication(const std::string& source, : query.Bind(7, source_app.GetBoolean(6)); query.Bind(8, source_app.GetInteger(7)); query.Bind(9, source_app.GetInteger(8)); + source_app.IsNull(9) ? query.Bind(10) + : query.Bind(10, source_app.GetString(9)); + source_app.IsNull(10) ? query.Bind(11) + : query.Bind(11, source_app.GetString(10)); + source_app.IsNull(11) ? query.Bind(12) + : query.Bind(12, source_app.GetString(11)); + source_app.IsNull(12) ? query.Bind(13) + : query.Bind(13, source_app.GetBoolean(12)); + source_app.IsNull(13) ? query.Bind(14) + : query.Bind(14, source_app.GetString(13)); + source_app.IsNull(14) ? query.Bind(15) + : query.Bind(15, source_app.GetString(14)); if (!query.Exec()) { LOG4CXX_WARN(logger_, "Failed inserting into application."); diff --git a/src/components/policy/policy_external/test/sql_pt_representation_test.cc b/src/components/policy/policy_external/test/sql_pt_representation_test.cc index b0f340b0f2..fddc5e631e 100644 --- a/src/components/policy/policy_external/test/sql_pt_representation_test.cc +++ b/src/components/policy/policy_external/test/sql_pt_representation_test.cc @@ -406,8 +406,8 @@ TEST_F(SQLPTRepresentationTest, query.Prepare(query_select); query.Next(); - // 33 - is current total tables number created by schema - const int policy_tables_number = 33; + // 34 - is current total tables number created by schema + const int policy_tables_number = 34; ASSERT_EQ(policy_tables_number, query.GetInteger(0)); const std::string query_select_count_of_iap_buffer_full = -- cgit v1.2.1 From 5fc3666123213b379c7035493f4713052ef7e462 Mon Sep 17 00:00:00 2001 From: ShobhitAd Date: Mon, 5 Nov 2018 09:46:09 -0500 Subject: Made requested changes --- src/components/interfaces/MOBILE_API.xml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/components/interfaces/MOBILE_API.xml b/src/components/interfaces/MOBILE_API.xml index 0be8e15162..6ed42c3588 100644 --- a/src/components/interfaces/MOBILE_API.xml +++ b/src/components/interfaces/MOBILE_API.xml @@ -1,7 +1,7 @@ - + The request succeeded @@ -4940,7 +4940,7 @@ The status of the park brake as provided by Electric Park Brake (EPB) system. - + Parameter used by cloud apps to identify a head unit @@ -5058,7 +5058,7 @@ The status of the park brake as provided by Electric Park Brake (EPB) system. - + Parameter used by cloud apps to identify a head unit @@ -5154,7 +5154,7 @@ The status of the park brake as provided by Electric Park Brake (EPB) system. - + Parameter used by cloud apps to identify a head unit @@ -5270,7 +5270,7 @@ The status of the park brake as provided by Electric Park Brake (EPB) system. - + Parameter used by cloud apps to identify a head unit @@ -5369,7 +5369,7 @@ The status of the park brake as provided by Electric Park Brake (EPB) system. - + Parameter used by cloud apps to identify a head unit @@ -5489,7 +5489,7 @@ The status of the park brake as provided by Electric Park Brake (EPB) system. - + Parameter used by cloud apps to identify a head unit @@ -6751,7 +6751,7 @@ The status of the park brake as provided by Electric Park Brake (EPB) system. - + Parameter used by cloud apps to identify a head unit -- cgit v1.2.1 From 32b6a07f53e87bc71466656155e8896eb747b277 Mon Sep 17 00:00:00 2001 From: jacobkeeler Date: Mon, 5 Nov 2018 17:56:55 -0500 Subject: Fix style, add certificate, and add GetEnabledCloudApps --- .../application_manager/policies/policy_handler.h | 44 +++++++++++++++++----- .../src/policies/policy_handler.cc | 36 ++++++++++++------ .../policies/policy_handler_interface.h | 15 +++++++- .../policy/policy_external/policy/policy_manager.h | 13 ++++++- .../policy/policy_regular/policy/policy_manager.h | 15 +++++++- .../policies/mock_policy_handler_interface.h | 5 ++- .../policy_external/policy/mock_cache_manager.h | 5 ++- .../policy_external/policy/mock_policy_manager.h | 5 ++- .../policy_regular/policy/mock_cache_manager.h | 15 +++++--- .../policy_regular/policy/mock_policy_manager.h | 5 ++- .../policy_external/include/policy/cache_manager.h | 11 ++++++ .../include/policy/cache_manager_interface.h | 11 ++++++ .../include/policy/policy_manager_impl.h | 12 +++++- .../include/policy/policy_table/enums.h | 6 +-- .../policy/policy_external/src/cache_manager.cc | 18 +++++++++ .../policy_external/src/policy_manager_impl.cc | 7 ++++ .../policy_external/src/policy_table/types.cc | 3 +- .../src/sql_pt_ext_representation.cc | 5 ++- .../policy_regular/include/policy/cache_manager.h | 11 ++++++ .../include/policy/cache_manager_interface.h | 16 +++++++- .../include/policy/policy_manager_impl.h | 11 +++++- .../policy/policy_regular/src/cache_manager.cc | 18 +++++++++ .../policy_regular/src/policy_manager_impl.cc | 15 ++++++-- 23 files changed, 251 insertions(+), 51 deletions(-) diff --git a/src/components/application_manager/include/application_manager/policies/policy_handler.h b/src/components/application_manager/include/application_manager/policies/policy_handler.h index 3af03bf28b..648e856456 100644 --- a/src/components/application_manager/include/application_manager/policies/policy_handler.h +++ b/src/components/application_manager/include/application_manager/policies/policy_handler.h @@ -398,6 +398,13 @@ class PolicyHandler : public PolicyHandlerInterface, custom_str::CustomString GetAppName( const std::string& policy_app_id) OVERRIDE; + /** + * @brief Get a list of enabled cloud applications + * @param enabled_apps List filled with the policy app id of each enabled cloud + * application + */ + void GetEnabledCloudApps(std::vector& enabled_apps) const OVERRIDE; + /** * @brief Checks if a given application is an enabled cloud application * @param policy_app_id Unique application id @@ -407,17 +414,36 @@ class PolicyHandler : public PolicyHandlerInterface, const bool CheckCloudAppEnabled( const std::string& policy_app_id) const OVERRIDE; - /**plzfix - * @brief Checks if certain request type is allowed for application + /** + * @brief Get cloud app policy information, all fields that aren't set for a + * given app will be filled with empty strings * @param policy_app_id Unique application id - * @return true, if allowed, otherwise - false - */ - const bool GetCloudAppParameters(const std::string& policy_app_id, - std::string& endpoint, - std::string& auth_token, - std::string& cloud_transport_type, - std::string& hybrid_app_preference) const OVERRIDE; + * @param endpoint Filled with the endpoint used to connect to the cloud + * application + * @param certificate Filled with the certificate used to for creating a + * secure + * connection to the cloud application + * @param auth_token Filled with the token used for authentication when + * reconnecting to the cloud app + * @param cloud_transport_type Filled with the transport type used by the + * cloud application (ex. "WSS") + * @param cloud_transport_type Filled with the hybrid app preference for the + * cloud application set by the user + * @return true if the cloud app is enabled, false otherwise + */ + const bool GetCloudAppParameters( + const std::string& policy_app_id, + std::string& endpoint, + std::string& certificate, + std::string& auth_token, + std::string& cloud_transport_type, + std::string& hybrid_app_preference) const OVERRIDE; + /** + * @brief Callback for when a SetCloudAppProperties message is received from a + * mobile app + * @param message The SetCloudAppProperties message + */ void OnSetCloudAppProperties( const smart_objects::SmartObject& message) OVERRIDE; diff --git a/src/components/application_manager/src/policies/policy_handler.cc b/src/components/application_manager/src/policies/policy_handler.cc index c73e35768e..cc62d9f6f8 100644 --- a/src/components/application_manager/src/policies/policy_handler.cc +++ b/src/components/application_manager/src/policies/policy_handler.cc @@ -1845,28 +1845,39 @@ bool PolicyHandler::CheckSystemAction( return false; } +void PolicyHandler::GetEnabledCloudApps( + std::vector& enabled_apps) const { + POLICY_LIB_CHECK_VOID(); + policy_manager_->GetEnabledCloudApps(enabled_apps); +} + const bool PolicyHandler::GetCloudAppParameters( const std::string& policy_app_id, std::string& endpoint, + std::string& certificate, std::string& auth_token, std::string& cloud_transport_type, std::string& hybrid_app_preference) const { POLICY_LIB_CHECK(false); return policy_manager_->GetCloudAppParameters(policy_app_id, endpoint, + certificate, auth_token, cloud_transport_type, hybrid_app_preference); } -const bool PolicyHandler::CheckCloudAppEnabled(const std::string& policy_app_id) const { +const bool PolicyHandler::CheckCloudAppEnabled( + const std::string& policy_app_id) const { POLICY_LIB_CHECK(false); std::string endpoint; std::string auth_token; + std::string certificate; std::string cloud_transport_type; std::string hybrid_app_preference; return policy_manager_->GetCloudAppParameters(policy_app_id, endpoint, + certificate, auth_token, cloud_transport_type, hybrid_app_preference); @@ -1876,34 +1887,35 @@ void PolicyHandler::OnSetCloudAppProperties( const smart_objects::SmartObject& message) { POLICY_LIB_CHECK_VOID(); if (!message.keyExists(strings::msg_params)) { - LOG4CXX_ERROR( - logger_, - "Message does not contain mandatory section " << strings::msg_params); + LOG4CXX_ERROR(logger_, + "Message does not contain mandatory section " + << strings::msg_params); return; } const smart_objects::SmartObject& msg_params = message[strings::msg_params]; if (!msg_params.keyExists(strings::app_id)) { - LOG4CXX_ERROR( - logger_, - "Message does not contain mandatory parameter " << strings::app_id); + LOG4CXX_ERROR(logger_, + "Message does not contain mandatory parameter " + << strings::app_id); return; } std::string policy_app_id(msg_params[strings::app_id].asString()); if (msg_params.keyExists(strings::enabled)) { policy_manager_->SetCloudAppEnabled(policy_app_id, - msg_params[strings::enabled].asBool()); + msg_params[strings::enabled].asBool()); } if (msg_params.keyExists(strings::cloud_app_auth_token)) { - policy_manager_->SetAppAuthToken(policy_app_id, - msg_params[strings::cloud_app_auth_token].asString()); + policy_manager_->SetAppAuthToken( + policy_app_id, msg_params[strings::cloud_app_auth_token].asString()); } if (msg_params.keyExists(strings::cloud_transport_type)) { policy_manager_->SetAppCloudTransportType( policy_app_id, msg_params[strings::cloud_transport_type].asString()); } if (msg_params.keyExists(strings::hybrid_app_preference)) { - //const std::string hybrid_app_preference = EnumConversionHelper::EnumToString(msg_params[strings::hybrid_app_preference]); - //policy_manager_->SetHybridAppPreference( + // const std::string hybrid_app_preference = + // EnumConversionHelper::EnumToString(msg_params[strings::hybrid_app_preference]); + // policy_manager_->SetHybridAppPreference( // policy_app_id, hybrid_app_preference); } } diff --git a/src/components/include/application_manager/policies/policy_handler_interface.h b/src/components/include/application_manager/policies/policy_handler_interface.h index 69433e6118..ddeb1da8f7 100644 --- a/src/components/include/application_manager/policies/policy_handler_interface.h +++ b/src/components/include/application_manager/policies/policy_handler_interface.h @@ -437,7 +437,15 @@ class PolicyHandlerInterface { * @return Structure with vehicle information */ virtual const VehicleInfo GetVehicleInfo() const = 0; - + + /** + * @brief Get a list of enabled cloud applications + * @param enabled_apps List filled with the policy app id of each enabled + * cloud application + */ + virtual void GetEnabledCloudApps( + std::vector& enabled_apps) const = 0; + /** * @brief Checks if a given application is an enabled cloud application * @param policy_app_id Unique application id @@ -453,6 +461,8 @@ class PolicyHandlerInterface { * @param policy_app_id Unique application id * @param endpoint Filled the endpoint used to connect to the cloud * application + * @param certificate Filled with the certificate used to for creating a + * secure connection to the cloud application * @param auth_token Filled with the token used for authentication when * reconnecting to the cloud app * @param cloud_transport_type Filled with the transport type used by the @@ -464,6 +474,7 @@ class PolicyHandlerInterface { virtual const bool GetCloudAppParameters( const std::string& policy_app_id, std::string& endpoint, + std::string& certificate, std::string& auth_token, std::string& cloud_transport_type, std::string& hybrid_app_preference) const = 0; @@ -475,7 +486,7 @@ class PolicyHandlerInterface { */ virtual void OnSetCloudAppProperties( const smart_objects::SmartObject& message) = 0; - + #ifdef EXTERNAL_PROPRIETARY_MODE /** * @brief Gets meta information diff --git a/src/components/include/policy/policy_external/policy/policy_manager.h b/src/components/include/policy/policy_external/policy/policy_manager.h index 2ea8ef08f1..b0fac8eae9 100644 --- a/src/components/include/policy/policy_external/policy/policy_manager.h +++ b/src/components/include/policy/policy_external/policy/policy_manager.h @@ -521,13 +521,23 @@ class PolicyManager : public usage_statistics::StatisticsManager { * @return vehicle information */ virtual const VehicleInfo GetVehicleInfo() const = 0; - + + /** + * @brief Get a list of enabled cloud applications + * @param enabled_apps List filled with the policy app id of each enabled + * cloud application + */ + virtual void GetEnabledCloudApps( + std::vector& enabled_apps) const = 0; + /** * @brief Get cloud app policy information, all fields that aren't set for a * given app will be filled with empty strings * @param policy_app_id Unique application id * @param endpoint Filled the endpoint used to connect to the cloud * application + * @param certificate Filled with the certificate used to for creating a + * secure connection to the cloud application * @param auth_token Filled with the token used for authentication when * reconnecting to the cloud app * @param cloud_transport_type Filled with the transport type used by the @@ -539,6 +549,7 @@ class PolicyManager : public usage_statistics::StatisticsManager { virtual const bool GetCloudAppParameters( const std::string& policy_app_id, std::string& endpoint, + std::string& certificate, std::string& auth_token, std::string& cloud_transport_type, std::string& hybrid_app_preference) const = 0; diff --git a/src/components/include/policy/policy_regular/policy/policy_manager.h b/src/components/include/policy/policy_regular/policy/policy_manager.h index 9c67e239b7..4a82c8620b 100644 --- a/src/components/include/policy/policy_regular/policy/policy_manager.h +++ b/src/components/include/policy/policy_regular/policy/policy_manager.h @@ -502,12 +502,22 @@ class PolicyManager : public usage_statistics::StatisticsManager { */ virtual const VehicleInfo GetVehicleInfo() const = 0; + /** + * @brief Get a list of enabled cloud applications + * @param enabled_apps List filled with the policy app id of each enabled + * cloud application + */ + virtual void GetEnabledCloudApps( + std::vector& enabled_apps) const = 0; + /** * @brief Get cloud app policy information, all fields that aren't set for a * given app will be filled with empty strings * @param policy_app_id Unique application id * @param endpoint Filled the endpoint used to connect to the cloud * application + * @param certificate Filled with the certificate used to for creating a + * secure connection to the cloud application * @param auth_token Filled with the token used for authentication when * reconnecting to the cloud app * @param cloud_transport_type Filled with the transport type used by the @@ -550,8 +560,9 @@ class PolicyManager : public usage_statistics::StatisticsManager { * should be used * @param hybrid_app_preference Hybrid app user preference */ - virtual void SetHybridAppPreference(const std::string& policy_app_id, - const std::string& hybrid_app_preference) = 0; + virtual void SetHybridAppPreference( + const std::string& policy_app_id, + const std::string& hybrid_app_preference) = 0; /** * @brief OnAppRegisteredOnMobile allows to handle event when application were diff --git a/src/components/include/test/application_manager/policies/mock_policy_handler_interface.h b/src/components/include/test/application_manager/policies/mock_policy_handler_interface.h index bd56d78128..cea36082c8 100644 --- a/src/components/include/test/application_manager/policies/mock_policy_handler_interface.h +++ b/src/components/include/test/application_manager/policies/mock_policy_handler_interface.h @@ -213,11 +213,14 @@ class MockPolicyHandlerInterface : public policy::PolicyHandlerInterface { GetAppRequestTypes, const std::vector(const std::string& policy_app_id)); MOCK_CONST_METHOD0(GetVehicleInfo, const policy::VehicleInfo()); + MOCK_CONST_METHOD1(GetEnabledCloudApps, + void(std::vector& enabled_apps)); MOCK_CONST_METHOD1(CheckCloudAppEnabled, const bool(const std::string& policy_app_id)); - MOCK_CONST_METHOD5(GetCloudAppParameters, + MOCK_CONST_METHOD6(GetCloudAppParameters, const bool(const std::string& policy_app_id, std::string& endpoint, + std::string& certificate, std::string& auth_token, std::string& cloud_transport_type, std::string& hybrid_app_preference)); diff --git a/src/components/include/test/policy/policy_external/policy/mock_cache_manager.h b/src/components/include/test/policy/policy_external/policy/mock_cache_manager.h index ecbd8c6cd6..03e0882129 100644 --- a/src/components/include/test/policy/policy_external/policy/mock_cache_manager.h +++ b/src/components/include/test/policy/policy_external/policy/mock_cache_manager.h @@ -76,9 +76,12 @@ class MockCacheManagerInterface : public ::policy::CacheManagerInterface { MOCK_METHOD1(SecondsBetweenRetries, bool(std::vector& seconds)); MOCK_CONST_METHOD1(IsDeviceConsentCached, bool(const std::string& device_id)); MOCK_CONST_METHOD0(GetVehicleInfo, const VehicleInfo()); - MOCK_CONST_METHOD5(GetCloudAppParameters, + MOCK_CONST_METHOD1(GetEnabledCloudApps, + void(std::vector& enabled_apps)); + MOCK_CONST_METHOD6(GetCloudAppParameters, const bool(const std::string& policy_app_id, std::string& endpoint, + std::string& certificate, std::string& auth_token, std::string& cloud_transport_type, std::string& hybrid_app_preference)); diff --git a/src/components/include/test/policy/policy_external/policy/mock_policy_manager.h b/src/components/include/test/policy/policy_external/policy/mock_policy_manager.h index f58ed10934..70dab8e99a 100644 --- a/src/components/include/test/policy/policy_external/policy/mock_policy_manager.h +++ b/src/components/include/test/policy/policy_external/policy/mock_policy_manager.h @@ -184,9 +184,12 @@ class MockPolicyManager : public PolicyManager { GetAppRequestTypes, const std::vector(const std::string policy_app_id)); MOCK_CONST_METHOD0(GetVehicleInfo, const policy::VehicleInfo()); - MOCK_CONST_METHOD5(GetCloudAppParameters, + MOCK_CONST_METHOD1(GetEnabledCloudApps, + void(std::vector& enabled_apps)); + MOCK_CONST_METHOD6(GetCloudAppParameters, const bool(const std::string& policy_app_id, std::string& endpoint, + std::string& certificate, std::string& auth_token, std::string& cloud_transport_type, std::string& hybrid_app_preference)); diff --git a/src/components/include/test/policy/policy_regular/policy/mock_cache_manager.h b/src/components/include/test/policy/policy_regular/policy/mock_cache_manager.h index 745bcd2db5..7ac94d278d 100644 --- a/src/components/include/test/policy/policy_regular/policy/mock_cache_manager.h +++ b/src/components/include/test/policy/policy_regular/policy/mock_cache_manager.h @@ -63,12 +63,15 @@ class MockCacheManagerInterface : public CacheManagerInterface { MOCK_METHOD0(TimeoutResponse, int()); MOCK_METHOD1(SecondsBetweenRetries, bool(std::vector& seconds)); MOCK_CONST_METHOD0(GetVehicleInfo, const VehicleInfo()); - MOCK_CONST_METHOD5(GetCloudAppParameters, - const bool(const std::string& policy_app_id, - std::string& endpoint, - std::string& auth_token, - std::string& cloud_transport_type, - std::string& hybrid_app_preference)); + MOCK_CONST_METHOD1(GetEnabledCloudApps, + void(std::vector& enabled_apps)); + MOCK_CONST_METHOD6(GetCloudAppParameters, + const bool(const std::string& policy_app_id, + std::string& endpoint, + std::string& certificate, + std::string& auth_token, + std::string& cloud_transport_type, + std::string& hybrid_app_preference)); MOCK_METHOD2(SetCloudAppEnabled, void(const std::string& policy_app_id, const bool enabled)); MOCK_METHOD2(SetAppAuthToken, diff --git a/src/components/include/test/policy/policy_regular/policy/mock_policy_manager.h b/src/components/include/test/policy/policy_regular/policy/mock_policy_manager.h index 8867c3de80..7441701a34 100644 --- a/src/components/include/test/policy/policy_regular/policy/mock_policy_manager.h +++ b/src/components/include/test/policy/policy_regular/policy/mock_policy_manager.h @@ -181,9 +181,12 @@ class MockPolicyManager : public PolicyManager { GetAppRequestTypes, const std::vector(const std::string policy_app_id)); MOCK_CONST_METHOD0(GetVehicleInfo, const policy::VehicleInfo()); - MOCK_CONST_METHOD5(GetCloudAppParameters, + MOCK_CONST_METHOD1(GetEnabledCloudApps, + void(std::vector& enabled_apps)); + MOCK_CONST_METHOD6(GetCloudAppParameters, const bool(const std::string& policy_app_id, std::string& endpoint, + std::string& certificate, std::string& auth_token, std::string& cloud_transport_type, std::string& hybrid_app_preference)); diff --git a/src/components/policy/policy_external/include/policy/cache_manager.h b/src/components/policy/policy_external/include/policy/cache_manager.h index d6eeb0457b..7660eb2df9 100644 --- a/src/components/policy/policy_external/include/policy/cache_manager.h +++ b/src/components/policy/policy_external/include/policy/cache_manager.h @@ -158,12 +158,22 @@ class CacheManager : public CacheManagerInterface { */ virtual const VehicleInfo GetVehicleInfo() const; + /** + * @brief Get a list of enabled cloud applications + * @param enabled_apps List filled with the policy app id of each enabled + * cloud application + */ + virtual void GetEnabledCloudApps( + std::vector& enabled_apps) const; + /** * @brief Get cloud app policy information, all fields that aren't set for a * given app will be filled with empty strings * @param policy_app_id Unique application id * @param endpoint Filled the endpoint used to connect to the cloud * application + * @param certificate Filled with the certificate used to for creating a + * secure connection to the cloud application * @param auth_token Filled with the token used for authentication when * reconnecting to the cloud app * @param cloud_transport_type Filled with the transport type used by the @@ -175,6 +185,7 @@ class CacheManager : public CacheManagerInterface { virtual const bool GetCloudAppParameters( const std::string& policy_app_id, std::string& endpoint, + std::string& certificate, std::string& auth_token, std::string& cloud_transport_type, std::string& hybrid_app_preference) const; diff --git a/src/components/policy/policy_external/include/policy/cache_manager_interface.h b/src/components/policy/policy_external/include/policy/cache_manager_interface.h index 0c094d2edb..75948e760a 100644 --- a/src/components/policy/policy_external/include/policy/cache_manager_interface.h +++ b/src/components/policy/policy_external/include/policy/cache_manager_interface.h @@ -165,12 +165,22 @@ class CacheManagerInterface { */ virtual const VehicleInfo GetVehicleInfo() const = 0; + /** + * @brief Get a list of enabled cloud applications + * @param enabled_apps List filled with the policy app id of each enabled cloud + * application + */ + virtual void GetEnabledCloudApps( + std::vector& enabled_apps) const = 0; + /** * @brief Get cloud app policy information, all fields that aren't set for a * given app will be filled with empty strings * @param policy_app_id Unique application id * @param endpoint Filled the endpoint used to connect to the cloud * application + * @param certificate Filled with the certificate used to for creating a + * secure connection to the cloud application * @param auth_token Filled with the token used for authentication when * reconnecting to the cloud app * @param cloud_transport_type Filled with the transport type used by the @@ -182,6 +192,7 @@ class CacheManagerInterface { virtual const bool GetCloudAppParameters( const std::string& policy_app_id, std::string& endpoint, + std::string& certificate, std::string& auth_token, std::string& cloud_transport_type, std::string& hybrid_app_preference) const = 0; diff --git a/src/components/policy/policy_external/include/policy/policy_manager_impl.h b/src/components/policy/policy_external/include/policy/policy_manager_impl.h index f9648f803c..3bdf75f19e 100644 --- a/src/components/policy/policy_external/include/policy/policy_manager_impl.h +++ b/src/components/policy/policy_external/include/policy/policy_manager_impl.h @@ -570,12 +570,21 @@ class PolicyManagerImpl : public PolicyManager { */ const VehicleInfo GetVehicleInfo() const OVERRIDE; + /** + * @brief Get a list of enabled cloud applications + * @param enabled_apps List filled with the policy app id of each enabled + * cloud application + */ + void GetEnabledCloudApps(std::vector& enabled_apps) const OVERRIDE; + /** * @brief Get cloud app policy information, all fields that aren't set for a * given app will be filled with empty strings * @param policy_app_id Unique application id * @param endpoint Filled the endpoint used to connect to the cloud * application + * @param certificate Filled with the certificate used to for creating a + * secure connection to the cloud application * @param auth_token Filled with the token used for authentication when * reconnecting to the cloud app * @param cloud_transport_type Filled with the transport type used by the @@ -587,6 +596,7 @@ class PolicyManagerImpl : public PolicyManager { const bool GetCloudAppParameters( const std::string& policy_app_id, std::string& endpoint, + std::string& certificate, std::string& auth_token, std::string& cloud_transport_type, std::string& hybrid_app_preference) const OVERRIDE; @@ -597,7 +607,7 @@ class PolicyManagerImpl : public PolicyManager { */ void SetCloudAppEnabled(const std::string& policy_app_id, const bool enabled) OVERRIDE; - + /** * @brief Set an app's auth token * @param auth_token Cloud app authentication token diff --git a/src/components/policy/policy_external/include/policy/policy_table/enums.h b/src/components/policy/policy_external/include/policy/policy_table/enums.h index f5b85f0a4d..c2148de3b6 100644 --- a/src/components/policy/policy_external/include/policy/policy_table/enums.h +++ b/src/components/policy/policy_external/include/policy/policy_table/enums.h @@ -181,11 +181,7 @@ bool IsValidEnum(ModuleType val); const char* EnumToJsonString(ModuleType val); bool EnumFromJsonString(const std::string& literal, ModuleType* result); -enum HybridAppPreference { - HAP_MOBILE, - HAP_CLOUD, - HAP_BOTH -}; +enum HybridAppPreference { HAP_MOBILE, HAP_CLOUD, HAP_BOTH }; bool IsValidEnum(HybridAppPreference val); const char* EnumToJsonString(HybridAppPreference val); bool EnumFromJsonString(const std::string& literal, diff --git a/src/components/policy/policy_external/src/cache_manager.cc b/src/components/policy/policy_external/src/cache_manager.cc index d6d5f6daa5..116b315755 100644 --- a/src/components/policy/policy_external/src/cache_manager.cc +++ b/src/components/policy/policy_external/src/cache_manager.cc @@ -1389,9 +1389,24 @@ const policy::VehicleInfo CacheManager::GetVehicleInfo() const { return vehicle_info; } +void CacheManager::GetEnabledCloudApps( + std::vector& enabled_apps) const { + const policy_table::ApplicationPolicies& policies = + pt_->policy_table.app_policies_section.apps; + for (policy_table::ApplicationPolicies::const_iterator it = policies.begin(); + it != policies.end(); + ++it) { + auto app_policy = (*it).second; + if (app_policy.enabled.is_initialized() && *app_policy.enabled) { + enabled_apps.push_back((*it).first); + } + } +} + const bool CacheManager::GetCloudAppParameters( const std::string& policy_app_id, std::string& endpoint, + std::string& certificate, std::string& auth_token, std::string& cloud_transport_type, std::string& hybrid_app_preference) const { @@ -1403,6 +1418,9 @@ const bool CacheManager::GetCloudAppParameters( auto app_policy = (*policy_iter).second; endpoint = app_policy.endpoint.is_initialized() ? *app_policy.endpoint : std::string(); + certificate = app_policy.certificate.is_initialized() + ? *app_policy.certificate + : std::string(); auth_token = app_policy.auth_token.is_initialized() ? *app_policy.auth_token : std::string(); cloud_transport_type = app_policy.cloud_transport_type.is_initialized() diff --git a/src/components/policy/policy_external/src/policy_manager_impl.cc b/src/components/policy/policy_external/src/policy_manager_impl.cc index e7538fa1b0..31cc212254 100644 --- a/src/components/policy/policy_external/src/policy_manager_impl.cc +++ b/src/components/policy/policy_external/src/policy_manager_impl.cc @@ -725,14 +725,21 @@ const VehicleInfo PolicyManagerImpl::GetVehicleInfo() const { return cache_->GetVehicleInfo(); } +void PolicyManagerImpl::GetEnabledCloudApps( + std::vector& enabled_apps) const { + cache_->GetEnabledCloudApps(enabled_apps); +} + const bool PolicyManagerImpl::GetCloudAppParameters( const std::string& policy_app_id, std::string& endpoint, + std::string& certificate, std::string& auth_token, std::string& cloud_transport_type, std::string& hybrid_app_preference) const { return cache_->GetCloudAppParameters(policy_app_id, endpoint, + certificate, auth_token, cloud_transport_type, hybrid_app_preference); diff --git a/src/components/policy/policy_external/src/policy_table/types.cc b/src/components/policy/policy_external/src/policy_table/types.cc index 4867eef281..977448dacd 100644 --- a/src/components/policy/policy_external/src/policy_table/types.cc +++ b/src/components/policy/policy_external/src/policy_table/types.cc @@ -247,7 +247,8 @@ ApplicationParams::ApplicationParams(const Json::Value* value__) , endpoint(impl::ValueMember(value__, "endpoint")) , enabled(impl::ValueMember(value__, "enabled")) , auth_token(impl::ValueMember(value__, "auth_token")) - , cloud_transport_type(impl::ValueMember(value__, "cloud_transport_type")) {} + , cloud_transport_type(impl::ValueMember(value__, "cloud_transport_type")) { +} Json::Value ApplicationParams::ToJsonValue() const { Json::Value result__(PolicyBase::ToJsonValue()); diff --git a/src/components/policy/policy_external/src/sql_pt_ext_representation.cc b/src/components/policy/policy_external/src/sql_pt_ext_representation.cc index 6a40e6d135..43961815d6 100644 --- a/src/components/policy/policy_external/src/sql_pt_ext_representation.cc +++ b/src/components/policy/policy_external/src/sql_pt_ext_representation.cc @@ -760,8 +760,9 @@ bool SQLPTExtRepresentation::SaveSpecificAppPolicy( std::string(policy_table::EnumToJsonString( *app.second.hybrid_app_preference))) : app_query.Bind(9); - app.second.endpoint.is_initialized() ? app_query.Bind(10, *app.second.endpoint) - : app_query.Bind(10); + app.second.endpoint.is_initialized() + ? app_query.Bind(10, *app.second.endpoint) + : app_query.Bind(10); app.second.enabled.is_initialized() ? app_query.Bind(11, *app.second.enabled) : app_query.Bind(11); app.second.auth_token.is_initialized() diff --git a/src/components/policy/policy_regular/include/policy/cache_manager.h b/src/components/policy/policy_regular/include/policy/cache_manager.h index 119a0c0519..39f9cc73cd 100644 --- a/src/components/policy/policy_regular/include/policy/cache_manager.h +++ b/src/components/policy/policy_regular/include/policy/cache_manager.h @@ -146,12 +146,22 @@ class CacheManager : public CacheManagerInterface { */ virtual const VehicleInfo GetVehicleInfo() const; + /** + * @brief Get a list of enabled cloud applications + * @param enabled_apps List filled with the policy app id of each enabled + * cloud application + */ + virtual void GetEnabledCloudApps( + std::vector& enabled_apps) const; + /** * @brief Get cloud app policy information, all fields that aren't set for a * given app will be filled with empty strings * @param policy_app_id Unique application id * @param endpoint Filled the endpoint used to connect to the cloud * application + * @param certificate Filled with the certificate used to for creating a + * secure connection to the cloud application * @param auth_token Filled with the token used for authentication when * reconnecting to the cloud app * @param cloud_transport_type Filled with the transport type used by the @@ -163,6 +173,7 @@ class CacheManager : public CacheManagerInterface { virtual const bool GetCloudAppParameters( const std::string& policy_app_id, std::string& endpoint, + std::string& certificate, std::string& auth_token, std::string& cloud_transport_type, std::string& hybrid_app_preference) const; diff --git a/src/components/policy/policy_regular/include/policy/cache_manager_interface.h b/src/components/policy/policy_regular/include/policy/cache_manager_interface.h index 9408809f1e..3b2b10d0bc 100644 --- a/src/components/policy/policy_regular/include/policy/cache_manager_interface.h +++ b/src/components/policy/policy_regular/include/policy/cache_manager_interface.h @@ -151,12 +151,22 @@ class CacheManagerInterface { */ virtual const VehicleInfo GetVehicleInfo() const = 0; + /** + * @brief Get a list of enabled cloud applications + * @param enabled_apps List filled with the policy app id of each enabled + * cloud application + */ + virtual void GetEnabledCloudApps( + std::vector& enabled_apps) const = 0; + /** * @brief Get cloud app policy information, all fields that aren't set for a * given app will be filled with empty strings * @param policy_app_id Unique application id * @param endpoint Filled the endpoint used to connect to the cloud * application + * @param certificate Filled with the certificate used to for creating a + * secure connection to the cloud application * @param auth_token Filled with the token used for authentication when * reconnecting to the cloud app * @param cloud_transport_type Filled with the transport type used by the @@ -168,6 +178,7 @@ class CacheManagerInterface { virtual const bool GetCloudAppParameters( const std::string& policy_app_id, std::string& endpoint, + std::string& certificate, std::string& auth_token, std::string& cloud_transport_type, std::string& hybrid_app_preference) const = 0; @@ -199,8 +210,9 @@ class CacheManagerInterface { * should be used * @param hybrid_app_preference Hybrid app user preference */ - virtual void SetHybridAppPreference(const std::string& policy_app_id, - const std::string& hybrid_app_preference) = 0; + virtual void SetHybridAppPreference( + const std::string& policy_app_id, + const std::string& hybrid_app_preference) = 0; /** * @brief Allows to update 'vin' field in module_meta table. diff --git a/src/components/policy/policy_regular/include/policy/policy_manager_impl.h b/src/components/policy/policy_regular/include/policy/policy_manager_impl.h index e1221b613f..9ee6b416fa 100644 --- a/src/components/policy/policy_regular/include/policy/policy_manager_impl.h +++ b/src/components/policy/policy_regular/include/policy/policy_manager_impl.h @@ -564,12 +564,21 @@ class PolicyManagerImpl : public PolicyManager { */ const VehicleInfo GetVehicleInfo() const OVERRIDE; + /** + * @brief Get a list of enabled cloud applications + * @param enabled_apps List filled with the policy app id of each enabled cloud + * application + */ + void GetEnabledCloudApps(std::vector& enabled_apps) const OVERRIDE; + /** * @brief Get cloud app policy information, all fields that aren't set for a * given app will be filled with empty strings * @param policy_app_id Unique application id * @param endpoint Filled the endpoint used to connect to the cloud * application + * @param certificate Filled with the certificate used to for creating a + * secure connection to the cloud application * @param auth_token Filled with the token used for authentication when * reconnecting to the cloud app * @param cloud_transport_type Filled with the transport type used by the @@ -591,7 +600,7 @@ class PolicyManagerImpl : public PolicyManager { */ void SetCloudAppEnabled(const std::string& policy_app_id, const bool enabled) OVERRIDE; - + /** * @brief Set an app's auth token * @param auth_token Cloud app authentication token diff --git a/src/components/policy/policy_regular/src/cache_manager.cc b/src/components/policy/policy_regular/src/cache_manager.cc index 68e70c107d..9292c389b9 100644 --- a/src/components/policy/policy_regular/src/cache_manager.cc +++ b/src/components/policy/policy_regular/src/cache_manager.cc @@ -682,9 +682,24 @@ const policy::VehicleInfo CacheManager::GetVehicleInfo() const { return vehicle_info; } +void CacheManager::GetEnabledCloudApps( + std::vector& enabled_apps) const { + const policy_table::ApplicationPolicies& policies = + pt_->policy_table.app_policies_section.apps; + for (policy_table::ApplicationPolicies::const_iterator it = policies.begin(); + it != policies.end(); + ++it) { + auto app_policy = (*it).second; + if (app_policy.enabled.is_initialized() && *app_policy.enabled) { + enabled_apps.push_back((*it).first); + } + } +} + const bool CacheManager::GetCloudAppParameters( const std::string& policy_app_id, std::string& endpoint, + std::string& certificate, std::string& auth_token, std::string& cloud_transport_type, std::string& hybrid_app_preference) const { @@ -701,6 +716,9 @@ const bool CacheManager::GetCloudAppParameters( cloud_transport_type = app_policy.cloud_transport_type.is_initialized() ? *app_policy.cloud_transport_type : std::string(); + certificate = app_policy.certificate.is_initialized() + ? *app_policy.certificate + : std::string(); hybrid_app_preference = app_policy.hybrid_app_preference.is_initialized() ? EnumToJsonString(*app_policy.hybrid_app_preference) diff --git a/src/components/policy/policy_regular/src/policy_manager_impl.cc b/src/components/policy/policy_regular/src/policy_manager_impl.cc index 9317708216..f4ffb56027 100644 --- a/src/components/policy/policy_regular/src/policy_manager_impl.cc +++ b/src/components/policy/policy_regular/src/policy_manager_impl.cc @@ -544,17 +544,26 @@ const VehicleInfo PolicyManagerImpl::GetVehicleInfo() const { return cache_->GetVehicleInfo(); } +void PolicyManagerImpl::GetEnabledCloudApps( + std::vector& enabled_apps) const { + cache_->GetEnabledCloudApps(enabled_apps); +} + const bool PolicyManagerImpl::GetCloudAppParameters( const std::string& policy_app_id, std::string& endpoint, std::string& auth_token, std::string& cloud_transport_type, std::string& hybrid_app_preference) const { - return cache_->GetCloudAppParameters(policy_app_id, endpoint, auth_token, cloud_transport_type, hybrid_app_preference); + return cache_->GetCloudAppParameters(policy_app_id, + endpoint, + auth_token, + cloud_transport_type, + hybrid_app_preference); } -void PolicyManagerImpl::SetCloudAppEnabled( - const std::string& policy_app_id, const bool enabled) { +void PolicyManagerImpl::SetCloudAppEnabled(const std::string& policy_app_id, + const bool enabled) { cache_->SetCloudAppEnabled(policy_app_id, enabled); } -- cgit v1.2.1 From 802830a4a50a3f7317478218470e1ab3c07c1322 Mon Sep 17 00:00:00 2001 From: JackLivio Date: Wed, 7 Nov 2018 14:04:17 -0500 Subject: Add Cloud Info to Application Class --- .../include/application_manager/application.h | 20 +++++++++++ .../include/application_manager/application_impl.h | 27 +++++++++++++++ .../application_manager/application_manager_impl.h | 2 ++ .../application_manager/src/application_impl.cc | 40 ++++++++++++++++++++++ .../src/application_manager_impl.cc | 20 +++++++++++ .../connection_handler/connection_handler_impl.h | 2 ++ .../src/connection_handler_impl.cc | 4 +++ .../connection_handler/connection_handler.h | 2 ++ .../policy/policy_regular/policy/policy_manager.h | 1 + .../include/transport_manager/transport_manager.h | 2 ++ .../include/policy/policy_manager_impl.h | 1 + .../policy_regular/src/policy_manager_impl.cc | 2 ++ .../transport_manager/transport_manager_impl.h | 2 ++ .../src/transport_manager_impl.cc | 4 +++ 14 files changed, 129 insertions(+) diff --git a/src/components/application_manager/include/application_manager/application.h b/src/components/application_manager/include/application_manager/application.h index ad7570955e..700c0e5d2c 100644 --- a/src/components/application_manager/include/application_manager/application.h +++ b/src/components/application_manager/include/application_manager/application.h @@ -946,6 +946,26 @@ class Application : public virtual InitialApplicationData, */ virtual const std::list& Extensions() const = 0; + virtual std::string cloud_app_endpoint() = 0; + + virtual std::string cloud_app_authtoken() = 0; + + virtual std::string cloud_app_transport_type() = 0; + + virtual std::string hybrid_app_preference() = 0; + + virtual std::string cloud_app_certificate() = 0; + + virtual void set_cloud_app_endpoint(const std::string& endpoint) = 0; + + virtual void set_cloud_app_auth_token(const std::string& auth_token) = 0; + + virtual void set_cloud_app_transport_type(const std::string& transport_type) = 0; + + virtual void set_hybrid_app_preference(const std::string& hybrid_app_preference) = 0; + + virtual void set_cloud_app_certificate(const std::string& certificate) = 0; + protected: mutable sync_primitives::Lock hmi_states_lock_; diff --git a/src/components/application_manager/include/application_manager/application_impl.h b/src/components/application_manager/include/application_manager/application_impl.h index 8dc3b2da20..0c365fc752 100644 --- a/src/components/application_manager/include/application_manager/application_impl.h +++ b/src/components/application_manager/include/application_manager/application_impl.h @@ -409,6 +409,26 @@ class ApplicationImpl : public virtual Application, void SwapMobileMessageQueue(MobileMessageQueue& mobile_messages) OVERRIDE; + std::string cloud_app_endpoint() OVERRIDE; + + std::string cloud_app_authtoken() OVERRIDE; + + std::string cloud_app_transport_type() OVERRIDE; + + std::string hybrid_app_preference() OVERRIDE; + + std::string cloud_app_certificate() OVERRIDE; + + void set_cloud_app_endpoint(const std::string& endpoint) OVERRIDE; + + void set_cloud_app_auth_token(const std::string& auth_token) OVERRIDE; + + void set_cloud_app_transport_type(const std::string& transport_type) OVERRIDE; + + void set_hybrid_app_preference(const std::string& hybrid_app_preference) OVERRIDE; + + void set_cloud_app_certificate(const std::string& certificate) OVERRIDE; + protected: /** * @brief Clean up application folder. Persistent files will stay @@ -513,6 +533,13 @@ class ApplicationImpl : public virtual Application, std::list extensions_; + // Cloud app properties + std::string endpoint_; + std::string auth_token_; + std::string cloud_transport_type_; + std::string hybrid_app_preference_; + std::string certificate_; + /** * @brief Defines number per time in seconds limits */ diff --git a/src/components/application_manager/include/application_manager/application_manager_impl.h b/src/components/application_manager/include/application_manager/application_manager_impl.h index 6c111dbbb3..23d7fc4892 100644 --- a/src/components/application_manager/include/application_manager/application_manager_impl.h +++ b/src/components/application_manager/include/application_manager/application_manager_impl.h @@ -360,6 +360,8 @@ class ApplicationManagerImpl void ConnectToDevice(const std::string& device_mac) OVERRIDE; void OnHMIStartedCooperation() OVERRIDE; + void CollectCloudAppInformation(); + /* * @brief Returns unique correlation ID for HMI request * diff --git a/src/components/application_manager/src/application_impl.cc b/src/components/application_manager/src/application_impl.cc index 8a611195c7..65f2a36fa8 100644 --- a/src/components/application_manager/src/application_impl.cc +++ b/src/components/application_manager/src/application_impl.cc @@ -1163,6 +1163,46 @@ const std::list& ApplicationImpl::Extensions() const { return extensions_; } +std::string ApplicationImpl::cloud_app_endpoint() { + return endpoint_; +} + +std::string ApplicationImpl::cloud_app_authtoken() { + return auth_token_; +} + +std::string ApplicationImpl::cloud_app_transport_type() { + return cloud_transport_type_; +} + +std::string ApplicationImpl::hybrid_app_preference() { + return hybrid_app_preference_; +} + +std::string ApplicationImpl::cloud_app_certificate() { + return certificate_; +} + +void ApplicationImpl::set_cloud_app_endpoint(const std::string& endpoint) { + endpoint_ = endpoint; +} + +void ApplicationImpl::set_cloud_app_auth_token(const std::string& auth_token) { + auth_token_ = auth_token; +} + +void ApplicationImpl::set_cloud_app_transport_type(const std::string& transport_type) { + cloud_transport_type_ = transport_type; +} + +void ApplicationImpl::set_hybrid_app_preference(const std::string& hybrid_app_preference) { + hybrid_app_preference_ = hybrid_app_preference; +} + +void ApplicationImpl::set_cloud_app_certificate(const std::string& certificate) { + certificate_ = certificate; +} + void ApplicationImpl::PushMobileMessage( smart_objects::SmartObjectSPtr mobile_message) { sync_primitives::AutoLock lock(mobile_message_lock_); diff --git a/src/components/application_manager/src/application_manager_impl.cc b/src/components/application_manager/src/application_manager_impl.cc index 24f27af2e2..4a0bb63bae 100644 --- a/src/components/application_manager/src/application_manager_impl.cc +++ b/src/components/application_manager/src/application_manager_impl.cc @@ -779,6 +779,26 @@ void ApplicationManagerImpl::OnHMIStartedCooperation() { *this)); rpc_service_->ManageHMICommand(mixing_audio_supported_request); resume_controller().ResetLaunchTime(); + + CollectCloudAppInformation(); +} + +void ApplicationManagerImpl::CollectCloudAppInformation() { + std::vector cloud_app_id_vector; + GetPolicyHandler().GetEnabledCloudApps(cloud_app_id_vector); + std::vector::iterator it = cloud_app_id_vector.begin(); + std::vector::iterator end = cloud_app_id_vector.end(); + std::string endpoint = ""; + std::string certificate = ""; + std::string auth_token = ""; + std::string cloud_transport_type = ""; + std::string hybrid_app_preference = ""; + for (; it!=end; ++it) { + GetPolicyHandler().GetCloudAppParameters(*it, endpoint, certificate, auth_token, + cloud_transport_type, hybrid_app_preference); + + connection_handler().AddCloudAppDevice(*it, endpoint, cloud_transport_type); + } } uint32_t ApplicationManagerImpl::GetNextHMICorrelationID() { diff --git a/src/components/connection_handler/include/connection_handler/connection_handler_impl.h b/src/components/connection_handler/include/connection_handler/connection_handler_impl.h index 1ab70ce702..5984f74c34 100644 --- a/src/components/connection_handler/include/connection_handler/connection_handler_impl.h +++ b/src/components/connection_handler/include/connection_handler/connection_handler_impl.h @@ -120,6 +120,8 @@ class ConnectionHandlerImpl void ConnectToAllDevices() OVERRIDE; + void AddCloudAppDevice(const std::string& policy_app_id, const std::string& endpoint, const std::string& cloud_transport_type) OVERRIDE; + void StartTransportManager() OVERRIDE; void OnDeviceListUpdated( diff --git a/src/components/connection_handler/src/connection_handler_impl.cc b/src/components/connection_handler/src/connection_handler_impl.cc index 478127c42a..399dbf90d7 100644 --- a/src/components/connection_handler/src/connection_handler_impl.cc +++ b/src/components/connection_handler/src/connection_handler_impl.cc @@ -1267,6 +1267,10 @@ void ConnectionHandlerImpl::ConnectToAllDevices() { } } +void ConnectionHandlerImpl::AddCloudAppDevice(const std::string& policy_app_id, const std::string& endpoint, const std::string& cloud_transport_type) { + transport_manager_.AddCloudDevice(endpoint, cloud_transport_type); +} + void ConnectionHandlerImpl::StartTransportManager() { LOG4CXX_AUTO_TRACE(logger_); transport_manager_.Visibility(true); diff --git a/src/components/include/connection_handler/connection_handler.h b/src/components/include/connection_handler/connection_handler.h index a50760b547..21c10dc3db 100644 --- a/src/components/include/connection_handler/connection_handler.h +++ b/src/components/include/connection_handler/connection_handler.h @@ -93,6 +93,8 @@ class ConnectionHandler { virtual void ConnectToAllDevices() = 0; + virtual void AddCloudAppDevice(const std::string& policy_app_id, const std::string& endpoint, const std::string& cloud_transport_type) = 0; + /** * @brief Close the connection revoked by Policy * @param connection_key pair of connection and session id diff --git a/src/components/include/policy/policy_regular/policy/policy_manager.h b/src/components/include/policy/policy_regular/policy/policy_manager.h index 4a82c8620b..1f0f520077 100644 --- a/src/components/include/policy/policy_regular/policy/policy_manager.h +++ b/src/components/include/policy/policy_regular/policy/policy_manager.h @@ -529,6 +529,7 @@ class PolicyManager : public usage_statistics::StatisticsManager { virtual const bool GetCloudAppParameters( const std::string& policy_app_id, std::string& endpoint, + std::string& certificate, std::string& auth_token, std::string& cloud_transport_type, std::string& hybrid_app_preference) const = 0; diff --git a/src/components/include/transport_manager/transport_manager.h b/src/components/include/transport_manager/transport_manager.h index 0847886c46..f67923daef 100644 --- a/src/components/include/transport_manager/transport_manager.h +++ b/src/components/include/transport_manager/transport_manager.h @@ -75,6 +75,8 @@ class TransportManager { **/ virtual int SearchDevices() = 0; + virtual void AddCloudDevice(const std::string& endpoint, const std::string& cloud_transport_type) = 0; + /** * @brief Connect to all applications discovered on device. * diff --git a/src/components/policy/policy_regular/include/policy/policy_manager_impl.h b/src/components/policy/policy_regular/include/policy/policy_manager_impl.h index 9ee6b416fa..aee2584ec2 100644 --- a/src/components/policy/policy_regular/include/policy/policy_manager_impl.h +++ b/src/components/policy/policy_regular/include/policy/policy_manager_impl.h @@ -590,6 +590,7 @@ class PolicyManagerImpl : public PolicyManager { const bool GetCloudAppParameters( const std::string& policy_app_id, std::string& endpoint, + std::string& certificate, std::string& auth_token, std::string& cloud_transport_type, std::string& hybrid_app_preference) const OVERRIDE; diff --git a/src/components/policy/policy_regular/src/policy_manager_impl.cc b/src/components/policy/policy_regular/src/policy_manager_impl.cc index f4ffb56027..5aa29fc896 100644 --- a/src/components/policy/policy_regular/src/policy_manager_impl.cc +++ b/src/components/policy/policy_regular/src/policy_manager_impl.cc @@ -552,11 +552,13 @@ void PolicyManagerImpl::GetEnabledCloudApps( const bool PolicyManagerImpl::GetCloudAppParameters( const std::string& policy_app_id, std::string& endpoint, + std::string& certificate, std::string& auth_token, std::string& cloud_transport_type, std::string& hybrid_app_preference) const { return cache_->GetCloudAppParameters(policy_app_id, endpoint, + certificate, auth_token, cloud_transport_type, hybrid_app_preference); diff --git a/src/components/transport_manager/include/transport_manager/transport_manager_impl.h b/src/components/transport_manager/include/transport_manager/transport_manager_impl.h index c1df49f91b..e2ce07ad18 100644 --- a/src/components/transport_manager/include/transport_manager/transport_manager_impl.h +++ b/src/components/transport_manager/include/transport_manager/transport_manager_impl.h @@ -140,6 +140,8 @@ class TransportManagerImpl **/ int SearchDevices() OVERRIDE; + void AddCloudDevice(const std::string& endpoint, const std::string& cloud_transport_type) OVERRIDE; + /** * @brief Connect to all applications discovered on device. * diff --git a/src/components/transport_manager/src/transport_manager_impl.cc b/src/components/transport_manager/src/transport_manager_impl.cc index 2b0296debb..63fa4b451d 100644 --- a/src/components/transport_manager/src/transport_manager_impl.cc +++ b/src/components/transport_manager/src/transport_manager_impl.cc @@ -129,6 +129,10 @@ void TransportManagerImpl::ReconnectionTimeout() { device_to_reconnect_); } +void TransportManagerImpl::AddCloudDevice(const std::string& endpoint, const std::string& cloud_transport_type) { + return; +} + int TransportManagerImpl::ConnectDevice(const DeviceHandle device_handle) { LOG4CXX_TRACE(logger_, "enter. DeviceHandle: " << &device_handle); if (!this->is_initialized_) { -- cgit v1.2.1 From 9d3c712daf5f5b0a461288bcd23f63a2ef883c65 Mon Sep 17 00:00:00 2001 From: jacobkeeler Date: Mon, 5 Nov 2018 17:56:55 -0500 Subject: Fix style, add certificate, and add GetEnabledCloudApps --- .../application_manager/policies/policy_handler.h | 45 +++++++++++++++++----- .../src/policies/policy_handler.cc | 36 +++++++++++------ .../policies/policy_handler_interface.h | 15 +++++++- .../policy/policy_external/policy/policy_manager.h | 13 ++++++- .../policy/policy_regular/policy/policy_manager.h | 16 +++++++- .../policies/mock_policy_handler_interface.h | 5 ++- .../policy_external/policy/mock_cache_manager.h | 5 ++- .../policy_external/policy/mock_policy_manager.h | 5 ++- .../policy_regular/policy/mock_cache_manager.h | 15 +++++--- .../policy_regular/policy/mock_policy_manager.h | 5 ++- .../policy_external/include/policy/cache_manager.h | 11 ++++++ .../include/policy/cache_manager_interface.h | 11 ++++++ .../include/policy/policy_manager_impl.h | 15 +++++++- .../include/policy/policy_table/enums.h | 6 +-- .../policy/policy_external/src/cache_manager.cc | 18 +++++++++ .../policy_external/src/policy_manager_impl.cc | 7 ++++ .../policy_external/src/policy_table/types.cc | 3 +- .../src/sql_pt_ext_representation.cc | 5 ++- .../policy_regular/include/policy/cache_manager.h | 11 ++++++ .../include/policy/cache_manager_interface.h | 16 +++++++- .../include/policy/policy_manager_impl.h | 13 ++++++- .../policy/policy_regular/src/cache_manager.cc | 18 +++++++++ .../policy_regular/src/policy_manager_impl.cc | 17 ++++++-- 23 files changed, 259 insertions(+), 52 deletions(-) diff --git a/src/components/application_manager/include/application_manager/policies/policy_handler.h b/src/components/application_manager/include/application_manager/policies/policy_handler.h index 3af03bf28b..a612c263ca 100644 --- a/src/components/application_manager/include/application_manager/policies/policy_handler.h +++ b/src/components/application_manager/include/application_manager/policies/policy_handler.h @@ -398,6 +398,14 @@ class PolicyHandler : public PolicyHandlerInterface, custom_str::CustomString GetAppName( const std::string& policy_app_id) OVERRIDE; + /** + * @brief Get a list of enabled cloud applications + * @param enabled_apps List filled with the policy app id of each enabled + * cloud application + */ + void GetEnabledCloudApps( + std::vector& enabled_apps) const OVERRIDE; + /** * @brief Checks if a given application is an enabled cloud application * @param policy_app_id Unique application id @@ -407,17 +415,36 @@ class PolicyHandler : public PolicyHandlerInterface, const bool CheckCloudAppEnabled( const std::string& policy_app_id) const OVERRIDE; - /**plzfix - * @brief Checks if certain request type is allowed for application + /** + * @brief Get cloud app policy information, all fields that aren't set for a + * given app will be filled with empty strings * @param policy_app_id Unique application id - * @return true, if allowed, otherwise - false - */ - const bool GetCloudAppParameters(const std::string& policy_app_id, - std::string& endpoint, - std::string& auth_token, - std::string& cloud_transport_type, - std::string& hybrid_app_preference) const OVERRIDE; + * @param endpoint Filled with the endpoint used to connect to the cloud + * application + * @param certificate Filled with the certificate used to for creating a + * secure + * connection to the cloud application + * @param auth_token Filled with the token used for authentication when + * reconnecting to the cloud app + * @param cloud_transport_type Filled with the transport type used by the + * cloud application (ex. "WSS") + * @param cloud_transport_type Filled with the hybrid app preference for the + * cloud application set by the user + * @return true if the cloud app is enabled, false otherwise + */ + const bool GetCloudAppParameters( + const std::string& policy_app_id, + std::string& endpoint, + std::string& certificate, + std::string& auth_token, + std::string& cloud_transport_type, + std::string& hybrid_app_preference) const OVERRIDE; + /** + * @brief Callback for when a SetCloudAppProperties message is received from a + * mobile app + * @param message The SetCloudAppProperties message + */ void OnSetCloudAppProperties( const smart_objects::SmartObject& message) OVERRIDE; diff --git a/src/components/application_manager/src/policies/policy_handler.cc b/src/components/application_manager/src/policies/policy_handler.cc index c73e35768e..cc62d9f6f8 100644 --- a/src/components/application_manager/src/policies/policy_handler.cc +++ b/src/components/application_manager/src/policies/policy_handler.cc @@ -1845,28 +1845,39 @@ bool PolicyHandler::CheckSystemAction( return false; } +void PolicyHandler::GetEnabledCloudApps( + std::vector& enabled_apps) const { + POLICY_LIB_CHECK_VOID(); + policy_manager_->GetEnabledCloudApps(enabled_apps); +} + const bool PolicyHandler::GetCloudAppParameters( const std::string& policy_app_id, std::string& endpoint, + std::string& certificate, std::string& auth_token, std::string& cloud_transport_type, std::string& hybrid_app_preference) const { POLICY_LIB_CHECK(false); return policy_manager_->GetCloudAppParameters(policy_app_id, endpoint, + certificate, auth_token, cloud_transport_type, hybrid_app_preference); } -const bool PolicyHandler::CheckCloudAppEnabled(const std::string& policy_app_id) const { +const bool PolicyHandler::CheckCloudAppEnabled( + const std::string& policy_app_id) const { POLICY_LIB_CHECK(false); std::string endpoint; std::string auth_token; + std::string certificate; std::string cloud_transport_type; std::string hybrid_app_preference; return policy_manager_->GetCloudAppParameters(policy_app_id, endpoint, + certificate, auth_token, cloud_transport_type, hybrid_app_preference); @@ -1876,34 +1887,35 @@ void PolicyHandler::OnSetCloudAppProperties( const smart_objects::SmartObject& message) { POLICY_LIB_CHECK_VOID(); if (!message.keyExists(strings::msg_params)) { - LOG4CXX_ERROR( - logger_, - "Message does not contain mandatory section " << strings::msg_params); + LOG4CXX_ERROR(logger_, + "Message does not contain mandatory section " + << strings::msg_params); return; } const smart_objects::SmartObject& msg_params = message[strings::msg_params]; if (!msg_params.keyExists(strings::app_id)) { - LOG4CXX_ERROR( - logger_, - "Message does not contain mandatory parameter " << strings::app_id); + LOG4CXX_ERROR(logger_, + "Message does not contain mandatory parameter " + << strings::app_id); return; } std::string policy_app_id(msg_params[strings::app_id].asString()); if (msg_params.keyExists(strings::enabled)) { policy_manager_->SetCloudAppEnabled(policy_app_id, - msg_params[strings::enabled].asBool()); + msg_params[strings::enabled].asBool()); } if (msg_params.keyExists(strings::cloud_app_auth_token)) { - policy_manager_->SetAppAuthToken(policy_app_id, - msg_params[strings::cloud_app_auth_token].asString()); + policy_manager_->SetAppAuthToken( + policy_app_id, msg_params[strings::cloud_app_auth_token].asString()); } if (msg_params.keyExists(strings::cloud_transport_type)) { policy_manager_->SetAppCloudTransportType( policy_app_id, msg_params[strings::cloud_transport_type].asString()); } if (msg_params.keyExists(strings::hybrid_app_preference)) { - //const std::string hybrid_app_preference = EnumConversionHelper::EnumToString(msg_params[strings::hybrid_app_preference]); - //policy_manager_->SetHybridAppPreference( + // const std::string hybrid_app_preference = + // EnumConversionHelper::EnumToString(msg_params[strings::hybrid_app_preference]); + // policy_manager_->SetHybridAppPreference( // policy_app_id, hybrid_app_preference); } } diff --git a/src/components/include/application_manager/policies/policy_handler_interface.h b/src/components/include/application_manager/policies/policy_handler_interface.h index 69433e6118..ddeb1da8f7 100644 --- a/src/components/include/application_manager/policies/policy_handler_interface.h +++ b/src/components/include/application_manager/policies/policy_handler_interface.h @@ -437,7 +437,15 @@ class PolicyHandlerInterface { * @return Structure with vehicle information */ virtual const VehicleInfo GetVehicleInfo() const = 0; - + + /** + * @brief Get a list of enabled cloud applications + * @param enabled_apps List filled with the policy app id of each enabled + * cloud application + */ + virtual void GetEnabledCloudApps( + std::vector& enabled_apps) const = 0; + /** * @brief Checks if a given application is an enabled cloud application * @param policy_app_id Unique application id @@ -453,6 +461,8 @@ class PolicyHandlerInterface { * @param policy_app_id Unique application id * @param endpoint Filled the endpoint used to connect to the cloud * application + * @param certificate Filled with the certificate used to for creating a + * secure connection to the cloud application * @param auth_token Filled with the token used for authentication when * reconnecting to the cloud app * @param cloud_transport_type Filled with the transport type used by the @@ -464,6 +474,7 @@ class PolicyHandlerInterface { virtual const bool GetCloudAppParameters( const std::string& policy_app_id, std::string& endpoint, + std::string& certificate, std::string& auth_token, std::string& cloud_transport_type, std::string& hybrid_app_preference) const = 0; @@ -475,7 +486,7 @@ class PolicyHandlerInterface { */ virtual void OnSetCloudAppProperties( const smart_objects::SmartObject& message) = 0; - + #ifdef EXTERNAL_PROPRIETARY_MODE /** * @brief Gets meta information diff --git a/src/components/include/policy/policy_external/policy/policy_manager.h b/src/components/include/policy/policy_external/policy/policy_manager.h index 2ea8ef08f1..b0fac8eae9 100644 --- a/src/components/include/policy/policy_external/policy/policy_manager.h +++ b/src/components/include/policy/policy_external/policy/policy_manager.h @@ -521,13 +521,23 @@ class PolicyManager : public usage_statistics::StatisticsManager { * @return vehicle information */ virtual const VehicleInfo GetVehicleInfo() const = 0; - + + /** + * @brief Get a list of enabled cloud applications + * @param enabled_apps List filled with the policy app id of each enabled + * cloud application + */ + virtual void GetEnabledCloudApps( + std::vector& enabled_apps) const = 0; + /** * @brief Get cloud app policy information, all fields that aren't set for a * given app will be filled with empty strings * @param policy_app_id Unique application id * @param endpoint Filled the endpoint used to connect to the cloud * application + * @param certificate Filled with the certificate used to for creating a + * secure connection to the cloud application * @param auth_token Filled with the token used for authentication when * reconnecting to the cloud app * @param cloud_transport_type Filled with the transport type used by the @@ -539,6 +549,7 @@ class PolicyManager : public usage_statistics::StatisticsManager { virtual const bool GetCloudAppParameters( const std::string& policy_app_id, std::string& endpoint, + std::string& certificate, std::string& auth_token, std::string& cloud_transport_type, std::string& hybrid_app_preference) const = 0; diff --git a/src/components/include/policy/policy_regular/policy/policy_manager.h b/src/components/include/policy/policy_regular/policy/policy_manager.h index 9c67e239b7..1f0f520077 100644 --- a/src/components/include/policy/policy_regular/policy/policy_manager.h +++ b/src/components/include/policy/policy_regular/policy/policy_manager.h @@ -502,12 +502,22 @@ class PolicyManager : public usage_statistics::StatisticsManager { */ virtual const VehicleInfo GetVehicleInfo() const = 0; + /** + * @brief Get a list of enabled cloud applications + * @param enabled_apps List filled with the policy app id of each enabled + * cloud application + */ + virtual void GetEnabledCloudApps( + std::vector& enabled_apps) const = 0; + /** * @brief Get cloud app policy information, all fields that aren't set for a * given app will be filled with empty strings * @param policy_app_id Unique application id * @param endpoint Filled the endpoint used to connect to the cloud * application + * @param certificate Filled with the certificate used to for creating a + * secure connection to the cloud application * @param auth_token Filled with the token used for authentication when * reconnecting to the cloud app * @param cloud_transport_type Filled with the transport type used by the @@ -519,6 +529,7 @@ class PolicyManager : public usage_statistics::StatisticsManager { virtual const bool GetCloudAppParameters( const std::string& policy_app_id, std::string& endpoint, + std::string& certificate, std::string& auth_token, std::string& cloud_transport_type, std::string& hybrid_app_preference) const = 0; @@ -550,8 +561,9 @@ class PolicyManager : public usage_statistics::StatisticsManager { * should be used * @param hybrid_app_preference Hybrid app user preference */ - virtual void SetHybridAppPreference(const std::string& policy_app_id, - const std::string& hybrid_app_preference) = 0; + virtual void SetHybridAppPreference( + const std::string& policy_app_id, + const std::string& hybrid_app_preference) = 0; /** * @brief OnAppRegisteredOnMobile allows to handle event when application were diff --git a/src/components/include/test/application_manager/policies/mock_policy_handler_interface.h b/src/components/include/test/application_manager/policies/mock_policy_handler_interface.h index bd56d78128..cea36082c8 100644 --- a/src/components/include/test/application_manager/policies/mock_policy_handler_interface.h +++ b/src/components/include/test/application_manager/policies/mock_policy_handler_interface.h @@ -213,11 +213,14 @@ class MockPolicyHandlerInterface : public policy::PolicyHandlerInterface { GetAppRequestTypes, const std::vector(const std::string& policy_app_id)); MOCK_CONST_METHOD0(GetVehicleInfo, const policy::VehicleInfo()); + MOCK_CONST_METHOD1(GetEnabledCloudApps, + void(std::vector& enabled_apps)); MOCK_CONST_METHOD1(CheckCloudAppEnabled, const bool(const std::string& policy_app_id)); - MOCK_CONST_METHOD5(GetCloudAppParameters, + MOCK_CONST_METHOD6(GetCloudAppParameters, const bool(const std::string& policy_app_id, std::string& endpoint, + std::string& certificate, std::string& auth_token, std::string& cloud_transport_type, std::string& hybrid_app_preference)); diff --git a/src/components/include/test/policy/policy_external/policy/mock_cache_manager.h b/src/components/include/test/policy/policy_external/policy/mock_cache_manager.h index ecbd8c6cd6..03e0882129 100644 --- a/src/components/include/test/policy/policy_external/policy/mock_cache_manager.h +++ b/src/components/include/test/policy/policy_external/policy/mock_cache_manager.h @@ -76,9 +76,12 @@ class MockCacheManagerInterface : public ::policy::CacheManagerInterface { MOCK_METHOD1(SecondsBetweenRetries, bool(std::vector& seconds)); MOCK_CONST_METHOD1(IsDeviceConsentCached, bool(const std::string& device_id)); MOCK_CONST_METHOD0(GetVehicleInfo, const VehicleInfo()); - MOCK_CONST_METHOD5(GetCloudAppParameters, + MOCK_CONST_METHOD1(GetEnabledCloudApps, + void(std::vector& enabled_apps)); + MOCK_CONST_METHOD6(GetCloudAppParameters, const bool(const std::string& policy_app_id, std::string& endpoint, + std::string& certificate, std::string& auth_token, std::string& cloud_transport_type, std::string& hybrid_app_preference)); diff --git a/src/components/include/test/policy/policy_external/policy/mock_policy_manager.h b/src/components/include/test/policy/policy_external/policy/mock_policy_manager.h index f58ed10934..70dab8e99a 100644 --- a/src/components/include/test/policy/policy_external/policy/mock_policy_manager.h +++ b/src/components/include/test/policy/policy_external/policy/mock_policy_manager.h @@ -184,9 +184,12 @@ class MockPolicyManager : public PolicyManager { GetAppRequestTypes, const std::vector(const std::string policy_app_id)); MOCK_CONST_METHOD0(GetVehicleInfo, const policy::VehicleInfo()); - MOCK_CONST_METHOD5(GetCloudAppParameters, + MOCK_CONST_METHOD1(GetEnabledCloudApps, + void(std::vector& enabled_apps)); + MOCK_CONST_METHOD6(GetCloudAppParameters, const bool(const std::string& policy_app_id, std::string& endpoint, + std::string& certificate, std::string& auth_token, std::string& cloud_transport_type, std::string& hybrid_app_preference)); diff --git a/src/components/include/test/policy/policy_regular/policy/mock_cache_manager.h b/src/components/include/test/policy/policy_regular/policy/mock_cache_manager.h index 745bcd2db5..7ac94d278d 100644 --- a/src/components/include/test/policy/policy_regular/policy/mock_cache_manager.h +++ b/src/components/include/test/policy/policy_regular/policy/mock_cache_manager.h @@ -63,12 +63,15 @@ class MockCacheManagerInterface : public CacheManagerInterface { MOCK_METHOD0(TimeoutResponse, int()); MOCK_METHOD1(SecondsBetweenRetries, bool(std::vector& seconds)); MOCK_CONST_METHOD0(GetVehicleInfo, const VehicleInfo()); - MOCK_CONST_METHOD5(GetCloudAppParameters, - const bool(const std::string& policy_app_id, - std::string& endpoint, - std::string& auth_token, - std::string& cloud_transport_type, - std::string& hybrid_app_preference)); + MOCK_CONST_METHOD1(GetEnabledCloudApps, + void(std::vector& enabled_apps)); + MOCK_CONST_METHOD6(GetCloudAppParameters, + const bool(const std::string& policy_app_id, + std::string& endpoint, + std::string& certificate, + std::string& auth_token, + std::string& cloud_transport_type, + std::string& hybrid_app_preference)); MOCK_METHOD2(SetCloudAppEnabled, void(const std::string& policy_app_id, const bool enabled)); MOCK_METHOD2(SetAppAuthToken, diff --git a/src/components/include/test/policy/policy_regular/policy/mock_policy_manager.h b/src/components/include/test/policy/policy_regular/policy/mock_policy_manager.h index 8867c3de80..7441701a34 100644 --- a/src/components/include/test/policy/policy_regular/policy/mock_policy_manager.h +++ b/src/components/include/test/policy/policy_regular/policy/mock_policy_manager.h @@ -181,9 +181,12 @@ class MockPolicyManager : public PolicyManager { GetAppRequestTypes, const std::vector(const std::string policy_app_id)); MOCK_CONST_METHOD0(GetVehicleInfo, const policy::VehicleInfo()); - MOCK_CONST_METHOD5(GetCloudAppParameters, + MOCK_CONST_METHOD1(GetEnabledCloudApps, + void(std::vector& enabled_apps)); + MOCK_CONST_METHOD6(GetCloudAppParameters, const bool(const std::string& policy_app_id, std::string& endpoint, + std::string& certificate, std::string& auth_token, std::string& cloud_transport_type, std::string& hybrid_app_preference)); diff --git a/src/components/policy/policy_external/include/policy/cache_manager.h b/src/components/policy/policy_external/include/policy/cache_manager.h index d6eeb0457b..7660eb2df9 100644 --- a/src/components/policy/policy_external/include/policy/cache_manager.h +++ b/src/components/policy/policy_external/include/policy/cache_manager.h @@ -158,12 +158,22 @@ class CacheManager : public CacheManagerInterface { */ virtual const VehicleInfo GetVehicleInfo() const; + /** + * @brief Get a list of enabled cloud applications + * @param enabled_apps List filled with the policy app id of each enabled + * cloud application + */ + virtual void GetEnabledCloudApps( + std::vector& enabled_apps) const; + /** * @brief Get cloud app policy information, all fields that aren't set for a * given app will be filled with empty strings * @param policy_app_id Unique application id * @param endpoint Filled the endpoint used to connect to the cloud * application + * @param certificate Filled with the certificate used to for creating a + * secure connection to the cloud application * @param auth_token Filled with the token used for authentication when * reconnecting to the cloud app * @param cloud_transport_type Filled with the transport type used by the @@ -175,6 +185,7 @@ class CacheManager : public CacheManagerInterface { virtual const bool GetCloudAppParameters( const std::string& policy_app_id, std::string& endpoint, + std::string& certificate, std::string& auth_token, std::string& cloud_transport_type, std::string& hybrid_app_preference) const; diff --git a/src/components/policy/policy_external/include/policy/cache_manager_interface.h b/src/components/policy/policy_external/include/policy/cache_manager_interface.h index 0c094d2edb..79d6f4e731 100644 --- a/src/components/policy/policy_external/include/policy/cache_manager_interface.h +++ b/src/components/policy/policy_external/include/policy/cache_manager_interface.h @@ -165,12 +165,22 @@ class CacheManagerInterface { */ virtual const VehicleInfo GetVehicleInfo() const = 0; + /** + * @brief Get a list of enabled cloud applications + * @param enabled_apps List filled with the policy app id of each enabled + * cloud application + */ + virtual void GetEnabledCloudApps( + std::vector& enabled_apps) const = 0; + /** * @brief Get cloud app policy information, all fields that aren't set for a * given app will be filled with empty strings * @param policy_app_id Unique application id * @param endpoint Filled the endpoint used to connect to the cloud * application + * @param certificate Filled with the certificate used to for creating a + * secure connection to the cloud application * @param auth_token Filled with the token used for authentication when * reconnecting to the cloud app * @param cloud_transport_type Filled with the transport type used by the @@ -182,6 +192,7 @@ class CacheManagerInterface { virtual const bool GetCloudAppParameters( const std::string& policy_app_id, std::string& endpoint, + std::string& certificate, std::string& auth_token, std::string& cloud_transport_type, std::string& hybrid_app_preference) const = 0; diff --git a/src/components/policy/policy_external/include/policy/policy_manager_impl.h b/src/components/policy/policy_external/include/policy/policy_manager_impl.h index f9648f803c..778892df13 100644 --- a/src/components/policy/policy_external/include/policy/policy_manager_impl.h +++ b/src/components/policy/policy_external/include/policy/policy_manager_impl.h @@ -569,13 +569,23 @@ class PolicyManagerImpl : public PolicyManager { * @return vehicle information */ const VehicleInfo GetVehicleInfo() const OVERRIDE; - + + /** + * @brief Get a list of enabled cloud applications + * @param enabled_apps List filled with the policy app id of each enabled + * cloud application + */ + void GetEnabledCloudApps( + std::vector& enabled_apps) const OVERRIDE; + /** * @brief Get cloud app policy information, all fields that aren't set for a * given app will be filled with empty strings * @param policy_app_id Unique application id * @param endpoint Filled the endpoint used to connect to the cloud * application + * @param certificate Filled with the certificate used to for creating a + * secure connection to the cloud application * @param auth_token Filled with the token used for authentication when * reconnecting to the cloud app * @param cloud_transport_type Filled with the transport type used by the @@ -587,6 +597,7 @@ class PolicyManagerImpl : public PolicyManager { const bool GetCloudAppParameters( const std::string& policy_app_id, std::string& endpoint, + std::string& certificate, std::string& auth_token, std::string& cloud_transport_type, std::string& hybrid_app_preference) const OVERRIDE; @@ -597,7 +608,7 @@ class PolicyManagerImpl : public PolicyManager { */ void SetCloudAppEnabled(const std::string& policy_app_id, const bool enabled) OVERRIDE; - + /** * @brief Set an app's auth token * @param auth_token Cloud app authentication token diff --git a/src/components/policy/policy_external/include/policy/policy_table/enums.h b/src/components/policy/policy_external/include/policy/policy_table/enums.h index f5b85f0a4d..c2148de3b6 100644 --- a/src/components/policy/policy_external/include/policy/policy_table/enums.h +++ b/src/components/policy/policy_external/include/policy/policy_table/enums.h @@ -181,11 +181,7 @@ bool IsValidEnum(ModuleType val); const char* EnumToJsonString(ModuleType val); bool EnumFromJsonString(const std::string& literal, ModuleType* result); -enum HybridAppPreference { - HAP_MOBILE, - HAP_CLOUD, - HAP_BOTH -}; +enum HybridAppPreference { HAP_MOBILE, HAP_CLOUD, HAP_BOTH }; bool IsValidEnum(HybridAppPreference val); const char* EnumToJsonString(HybridAppPreference val); bool EnumFromJsonString(const std::string& literal, diff --git a/src/components/policy/policy_external/src/cache_manager.cc b/src/components/policy/policy_external/src/cache_manager.cc index d6d5f6daa5..116b315755 100644 --- a/src/components/policy/policy_external/src/cache_manager.cc +++ b/src/components/policy/policy_external/src/cache_manager.cc @@ -1389,9 +1389,24 @@ const policy::VehicleInfo CacheManager::GetVehicleInfo() const { return vehicle_info; } +void CacheManager::GetEnabledCloudApps( + std::vector& enabled_apps) const { + const policy_table::ApplicationPolicies& policies = + pt_->policy_table.app_policies_section.apps; + for (policy_table::ApplicationPolicies::const_iterator it = policies.begin(); + it != policies.end(); + ++it) { + auto app_policy = (*it).second; + if (app_policy.enabled.is_initialized() && *app_policy.enabled) { + enabled_apps.push_back((*it).first); + } + } +} + const bool CacheManager::GetCloudAppParameters( const std::string& policy_app_id, std::string& endpoint, + std::string& certificate, std::string& auth_token, std::string& cloud_transport_type, std::string& hybrid_app_preference) const { @@ -1403,6 +1418,9 @@ const bool CacheManager::GetCloudAppParameters( auto app_policy = (*policy_iter).second; endpoint = app_policy.endpoint.is_initialized() ? *app_policy.endpoint : std::string(); + certificate = app_policy.certificate.is_initialized() + ? *app_policy.certificate + : std::string(); auth_token = app_policy.auth_token.is_initialized() ? *app_policy.auth_token : std::string(); cloud_transport_type = app_policy.cloud_transport_type.is_initialized() diff --git a/src/components/policy/policy_external/src/policy_manager_impl.cc b/src/components/policy/policy_external/src/policy_manager_impl.cc index e7538fa1b0..31cc212254 100644 --- a/src/components/policy/policy_external/src/policy_manager_impl.cc +++ b/src/components/policy/policy_external/src/policy_manager_impl.cc @@ -725,14 +725,21 @@ const VehicleInfo PolicyManagerImpl::GetVehicleInfo() const { return cache_->GetVehicleInfo(); } +void PolicyManagerImpl::GetEnabledCloudApps( + std::vector& enabled_apps) const { + cache_->GetEnabledCloudApps(enabled_apps); +} + const bool PolicyManagerImpl::GetCloudAppParameters( const std::string& policy_app_id, std::string& endpoint, + std::string& certificate, std::string& auth_token, std::string& cloud_transport_type, std::string& hybrid_app_preference) const { return cache_->GetCloudAppParameters(policy_app_id, endpoint, + certificate, auth_token, cloud_transport_type, hybrid_app_preference); diff --git a/src/components/policy/policy_external/src/policy_table/types.cc b/src/components/policy/policy_external/src/policy_table/types.cc index 4867eef281..977448dacd 100644 --- a/src/components/policy/policy_external/src/policy_table/types.cc +++ b/src/components/policy/policy_external/src/policy_table/types.cc @@ -247,7 +247,8 @@ ApplicationParams::ApplicationParams(const Json::Value* value__) , endpoint(impl::ValueMember(value__, "endpoint")) , enabled(impl::ValueMember(value__, "enabled")) , auth_token(impl::ValueMember(value__, "auth_token")) - , cloud_transport_type(impl::ValueMember(value__, "cloud_transport_type")) {} + , cloud_transport_type(impl::ValueMember(value__, "cloud_transport_type")) { +} Json::Value ApplicationParams::ToJsonValue() const { Json::Value result__(PolicyBase::ToJsonValue()); diff --git a/src/components/policy/policy_external/src/sql_pt_ext_representation.cc b/src/components/policy/policy_external/src/sql_pt_ext_representation.cc index 6a40e6d135..43961815d6 100644 --- a/src/components/policy/policy_external/src/sql_pt_ext_representation.cc +++ b/src/components/policy/policy_external/src/sql_pt_ext_representation.cc @@ -760,8 +760,9 @@ bool SQLPTExtRepresentation::SaveSpecificAppPolicy( std::string(policy_table::EnumToJsonString( *app.second.hybrid_app_preference))) : app_query.Bind(9); - app.second.endpoint.is_initialized() ? app_query.Bind(10, *app.second.endpoint) - : app_query.Bind(10); + app.second.endpoint.is_initialized() + ? app_query.Bind(10, *app.second.endpoint) + : app_query.Bind(10); app.second.enabled.is_initialized() ? app_query.Bind(11, *app.second.enabled) : app_query.Bind(11); app.second.auth_token.is_initialized() diff --git a/src/components/policy/policy_regular/include/policy/cache_manager.h b/src/components/policy/policy_regular/include/policy/cache_manager.h index 119a0c0519..39f9cc73cd 100644 --- a/src/components/policy/policy_regular/include/policy/cache_manager.h +++ b/src/components/policy/policy_regular/include/policy/cache_manager.h @@ -146,12 +146,22 @@ class CacheManager : public CacheManagerInterface { */ virtual const VehicleInfo GetVehicleInfo() const; + /** + * @brief Get a list of enabled cloud applications + * @param enabled_apps List filled with the policy app id of each enabled + * cloud application + */ + virtual void GetEnabledCloudApps( + std::vector& enabled_apps) const; + /** * @brief Get cloud app policy information, all fields that aren't set for a * given app will be filled with empty strings * @param policy_app_id Unique application id * @param endpoint Filled the endpoint used to connect to the cloud * application + * @param certificate Filled with the certificate used to for creating a + * secure connection to the cloud application * @param auth_token Filled with the token used for authentication when * reconnecting to the cloud app * @param cloud_transport_type Filled with the transport type used by the @@ -163,6 +173,7 @@ class CacheManager : public CacheManagerInterface { virtual const bool GetCloudAppParameters( const std::string& policy_app_id, std::string& endpoint, + std::string& certificate, std::string& auth_token, std::string& cloud_transport_type, std::string& hybrid_app_preference) const; diff --git a/src/components/policy/policy_regular/include/policy/cache_manager_interface.h b/src/components/policy/policy_regular/include/policy/cache_manager_interface.h index 9408809f1e..3b2b10d0bc 100644 --- a/src/components/policy/policy_regular/include/policy/cache_manager_interface.h +++ b/src/components/policy/policy_regular/include/policy/cache_manager_interface.h @@ -151,12 +151,22 @@ class CacheManagerInterface { */ virtual const VehicleInfo GetVehicleInfo() const = 0; + /** + * @brief Get a list of enabled cloud applications + * @param enabled_apps List filled with the policy app id of each enabled + * cloud application + */ + virtual void GetEnabledCloudApps( + std::vector& enabled_apps) const = 0; + /** * @brief Get cloud app policy information, all fields that aren't set for a * given app will be filled with empty strings * @param policy_app_id Unique application id * @param endpoint Filled the endpoint used to connect to the cloud * application + * @param certificate Filled with the certificate used to for creating a + * secure connection to the cloud application * @param auth_token Filled with the token used for authentication when * reconnecting to the cloud app * @param cloud_transport_type Filled with the transport type used by the @@ -168,6 +178,7 @@ class CacheManagerInterface { virtual const bool GetCloudAppParameters( const std::string& policy_app_id, std::string& endpoint, + std::string& certificate, std::string& auth_token, std::string& cloud_transport_type, std::string& hybrid_app_preference) const = 0; @@ -199,8 +210,9 @@ class CacheManagerInterface { * should be used * @param hybrid_app_preference Hybrid app user preference */ - virtual void SetHybridAppPreference(const std::string& policy_app_id, - const std::string& hybrid_app_preference) = 0; + virtual void SetHybridAppPreference( + const std::string& policy_app_id, + const std::string& hybrid_app_preference) = 0; /** * @brief Allows to update 'vin' field in module_meta table. diff --git a/src/components/policy/policy_regular/include/policy/policy_manager_impl.h b/src/components/policy/policy_regular/include/policy/policy_manager_impl.h index e1221b613f..311ced31d2 100644 --- a/src/components/policy/policy_regular/include/policy/policy_manager_impl.h +++ b/src/components/policy/policy_regular/include/policy/policy_manager_impl.h @@ -564,12 +564,22 @@ class PolicyManagerImpl : public PolicyManager { */ const VehicleInfo GetVehicleInfo() const OVERRIDE; + /** + * @brief Get a list of enabled cloud applications + * @param enabled_apps List filled with the policy app id of each enabled + * cloud application + */ + void GetEnabledCloudApps( + std::vector& enabled_apps) const OVERRIDE; + /** * @brief Get cloud app policy information, all fields that aren't set for a * given app will be filled with empty strings * @param policy_app_id Unique application id * @param endpoint Filled the endpoint used to connect to the cloud * application + * @param certificate Filled with the certificate used to for creating a + * secure connection to the cloud application * @param auth_token Filled with the token used for authentication when * reconnecting to the cloud app * @param cloud_transport_type Filled with the transport type used by the @@ -581,6 +591,7 @@ class PolicyManagerImpl : public PolicyManager { const bool GetCloudAppParameters( const std::string& policy_app_id, std::string& endpoint, + std::string& certificate, std::string& auth_token, std::string& cloud_transport_type, std::string& hybrid_app_preference) const OVERRIDE; @@ -591,7 +602,7 @@ class PolicyManagerImpl : public PolicyManager { */ void SetCloudAppEnabled(const std::string& policy_app_id, const bool enabled) OVERRIDE; - + /** * @brief Set an app's auth token * @param auth_token Cloud app authentication token diff --git a/src/components/policy/policy_regular/src/cache_manager.cc b/src/components/policy/policy_regular/src/cache_manager.cc index 68e70c107d..9292c389b9 100644 --- a/src/components/policy/policy_regular/src/cache_manager.cc +++ b/src/components/policy/policy_regular/src/cache_manager.cc @@ -682,9 +682,24 @@ const policy::VehicleInfo CacheManager::GetVehicleInfo() const { return vehicle_info; } +void CacheManager::GetEnabledCloudApps( + std::vector& enabled_apps) const { + const policy_table::ApplicationPolicies& policies = + pt_->policy_table.app_policies_section.apps; + for (policy_table::ApplicationPolicies::const_iterator it = policies.begin(); + it != policies.end(); + ++it) { + auto app_policy = (*it).second; + if (app_policy.enabled.is_initialized() && *app_policy.enabled) { + enabled_apps.push_back((*it).first); + } + } +} + const bool CacheManager::GetCloudAppParameters( const std::string& policy_app_id, std::string& endpoint, + std::string& certificate, std::string& auth_token, std::string& cloud_transport_type, std::string& hybrid_app_preference) const { @@ -701,6 +716,9 @@ const bool CacheManager::GetCloudAppParameters( cloud_transport_type = app_policy.cloud_transport_type.is_initialized() ? *app_policy.cloud_transport_type : std::string(); + certificate = app_policy.certificate.is_initialized() + ? *app_policy.certificate + : std::string(); hybrid_app_preference = app_policy.hybrid_app_preference.is_initialized() ? EnumToJsonString(*app_policy.hybrid_app_preference) diff --git a/src/components/policy/policy_regular/src/policy_manager_impl.cc b/src/components/policy/policy_regular/src/policy_manager_impl.cc index 9317708216..5aa29fc896 100644 --- a/src/components/policy/policy_regular/src/policy_manager_impl.cc +++ b/src/components/policy/policy_regular/src/policy_manager_impl.cc @@ -544,17 +544,28 @@ const VehicleInfo PolicyManagerImpl::GetVehicleInfo() const { return cache_->GetVehicleInfo(); } +void PolicyManagerImpl::GetEnabledCloudApps( + std::vector& enabled_apps) const { + cache_->GetEnabledCloudApps(enabled_apps); +} + const bool PolicyManagerImpl::GetCloudAppParameters( const std::string& policy_app_id, std::string& endpoint, + std::string& certificate, std::string& auth_token, std::string& cloud_transport_type, std::string& hybrid_app_preference) const { - return cache_->GetCloudAppParameters(policy_app_id, endpoint, auth_token, cloud_transport_type, hybrid_app_preference); + return cache_->GetCloudAppParameters(policy_app_id, + endpoint, + certificate, + auth_token, + cloud_transport_type, + hybrid_app_preference); } -void PolicyManagerImpl::SetCloudAppEnabled( - const std::string& policy_app_id, const bool enabled) { +void PolicyManagerImpl::SetCloudAppEnabled(const std::string& policy_app_id, + const bool enabled) { cache_->SetCloudAppEnabled(policy_app_id, enabled); } -- cgit v1.2.1 From 2e262bb5c5f0d4a8462579024dfe7ef7e64487a9 Mon Sep 17 00:00:00 2001 From: JackLivio Date: Thu, 8 Nov 2018 09:42:04 -0500 Subject: Initial Cloud Transport Component --- CMakeLists.txt | 6 + src/appMain/smartDeviceLink.ini | 6 + .../include/config_profile/profile.h | 12 + src/components/config_profile/src/profile.cc | 33 +++ .../src/connection_handler_impl.cc | 4 +- .../hmi_message_handler/src/websocket_session.cc | 1 + .../transport_adapter/transport_adapter.h | 21 ++ .../transport_manager/transport_manager_settings.h | 10 + .../include/transport_manager/cloud/cloud_device.h | 64 ++++++ .../cloud/cloud_websocket_connection_factory.h | 98 ++++++++ .../cloud/cloud_websocket_transport_adapter.h | 105 +++++++++ .../cloud/websocket_client_connection.h | 180 +++++++++++++++ .../transport_manager/src/cloud/cloud_device.cc | 62 +++++ .../cloud/cloud_websocket_connection_factory.cc | 99 ++++++++ .../src/cloud/cloud_websocket_transport_adapter.cc | 73 ++++++ .../src/cloud/websocket_client_connection.cc | 252 +++++++++++++++++++++ .../src/transport_manager_default.cc | 16 ++ 17 files changed, 1041 insertions(+), 1 deletion(-) create mode 100644 src/components/transport_manager/include/transport_manager/cloud/cloud_device.h create mode 100644 src/components/transport_manager/include/transport_manager/cloud/cloud_websocket_connection_factory.h create mode 100644 src/components/transport_manager/include/transport_manager/cloud/cloud_websocket_transport_adapter.h create mode 100644 src/components/transport_manager/include/transport_manager/cloud/websocket_client_connection.h create mode 100644 src/components/transport_manager/src/cloud/cloud_device.cc create mode 100644 src/components/transport_manager/src/cloud/cloud_websocket_connection_factory.cc create mode 100644 src/components/transport_manager/src/cloud/cloud_websocket_transport_adapter.cc create mode 100644 src/components/transport_manager/src/cloud/websocket_client_connection.cc diff --git a/CMakeLists.txt b/CMakeLists.txt index 1a180b6cf9..f6ee77a143 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -43,6 +43,7 @@ option(EXTENDED_MEDIA_MODE "Turn on and off extended Madia Manager features rela option(BUILD_SHARED_LIBS "Build all libraries as shared (if ON) or static (if OFF)" OFF) option(BUILD_BT_SUPPORT "Bluetooth support" ON) option(BUILD_USB_SUPPORT "libusb support" ON) +option(BUILD_CLOUD_APP_SUPPORT "Cloud App Transport Support" ON) option(BUILD_BACKTRACE_SUPPORT "backtrace support" ON) option(BUILD_TESTS "Possibility to build and run tests" OFF) option(TELEMETRY_MONITOR "Enable profiling time test util" ON) @@ -315,6 +316,11 @@ if (BUILD_BT_SUPPORT) message(STATUS "Bluetooth support enabled") endif() +if (BUILD_CLOUD_APP_SUPPORT) + add_definitions(-DCLOUD_APP_WEBSOCKET_TRANSPORT_SUPPORT) + message(STATUS "Cloud app websocket support enabled") +endif() + if (BUILD_BACKTRACE_SUPPORT) add_definitions(-DBACKTRACE_SUPPORT) message(STATUS "Backtrace support enabled") diff --git a/src/appMain/smartDeviceLink.ini b/src/appMain/smartDeviceLink.ini index b0513c076f..ac3e1c983a 100644 --- a/src/appMain/smartDeviceLink.ini +++ b/src/appMain/smartDeviceLink.ini @@ -202,6 +202,12 @@ TCPAdapterPort = 12345 ; If the name is omitted, Core will listen on all network interfaces by binding to INADDR_ANY. TCPAdapterNetworkInterface = +[Cloud App Connections] +; Value in milliseconds for time between retry attempts on a failed websocket connection +CloudAppRetryTimeout = 1000 +; MaxNn number of retry attempts for a cloud websocket connection +CloudAppMaxRetryAttempts = 5 + [ProtocolHandler] ; SDL supported protocol version MaxSupportedProtocolVersion = 5 diff --git a/src/components/config_profile/include/config_profile/profile.h b/src/components/config_profile/include/config_profile/profile.h index 57e925cd43..da087086c2 100644 --- a/src/components/config_profile/include/config_profile/profile.h +++ b/src/components/config_profile/include/config_profile/profile.h @@ -413,6 +413,16 @@ class Profile : public protocol_handler::ProtocolHandlerSettings, const std::string& transport_manager_tcp_adapter_network_interface() const OVERRIDE; + /** + * @brief Returns retry timeout for cloud app connections + */ + uint16_t cloud_app_retry_timeout() const OVERRIDE; + + /** + * @brief Returns maximum retry attempts for cloud app connections + */ + uint16_t cloud_app_max_retry_attempts() const OVERRIDE; + // TransportManageMMESettings interface const std::string& event_mq_name() const OVERRIDE; @@ -960,6 +970,8 @@ class Profile : public protocol_handler::ProtocolHandlerSettings, std::string system_files_path_; uint16_t transport_manager_tcp_adapter_port_; std::string transport_manager_tcp_adapter_network_interface_; + uint16_t cloud_app_retry_timeout_; + uint16_t cloud_app_max_retry_attempts_; std::string tts_delimiter_; uint32_t audio_data_stopped_timeout_; uint32_t video_data_stopped_timeout_; diff --git a/src/components/config_profile/src/profile.cc b/src/components/config_profile/src/profile.cc index 57984324aa..5b4c2e5f93 100644 --- a/src/components/config_profile/src/profile.cc +++ b/src/components/config_profile/src/profile.cc @@ -81,6 +81,7 @@ const char* kMediaManagerSection = "MEDIA MANAGER"; const char* kGlobalPropertiesSection = "GLOBAL PROPERTIES"; const char* kVrCommandsSection = "VR COMMANDS"; const char* kTransportManagerSection = "TransportManager"; +const char* kCloudAppTransportSection = "Cloud App Connections"; const char* kApplicationManagerSection = "ApplicationManager"; const char* kFilesystemRestrictionsSection = "FILESYSTEM RESTRICTIONS"; const char* kIAPSection = "IAP"; @@ -154,6 +155,8 @@ const char* kMaxSupportedProtocolVersionKey = "MaxSupportedProtocolVersion"; const char* kUseLastStateKey = "UseLastState"; const char* kTCPAdapterPortKey = "TCPAdapterPort"; const char* kTCPAdapterNetworkInterfaceKey = "TCPAdapterNetworkInterface"; +const char* kCloudAppRetryTimeoutKey = "CloudAppRetryTimeout"; +const char* kCloudAppMaxRetryAttemptsKey = "CloudAppMaxRetryAttempts"; const char* kServerPortKey = "ServerPort"; const char* kVideoStreamingPortKey = "VideoStreamingPort"; const char* kAudioStreamingPortKey = "AudioStreamingPort"; @@ -318,6 +321,8 @@ const uint32_t kDefaultHubProtocolIndex = 0; const uint32_t kDefaultHeartBeatTimeout = 0; const uint16_t kDefaultMaxSupportedProtocolVersion = 5; const uint16_t kDefautTransportManagerTCPPort = 12345; +const uint16_t kDefaultCloudAppRetryTimeout = 1000; +const uint16_t kDefaultCloudAppMaxRetryAttempts = 5; const uint16_t kDefaultServerPort = 8087; const uint16_t kDefaultVideoStreamingPort = 5050; const uint16_t kDefaultAudioStreamingPort = 5080; @@ -452,6 +457,8 @@ Profile::Profile() , supported_diag_modes_() , system_files_path_(kDefaultSystemFilesPath) , transport_manager_tcp_adapter_port_(kDefautTransportManagerTCPPort) + , cloud_app_retry_timeout_(kDefaultCloudAppRetryTimeout) + , cloud_app_max_retry_attempts_(kDefaultCloudAppMaxRetryAttempts) , tts_delimiter_(kDefaultTtsDelimiter) , audio_data_stopped_timeout_(kDefaultAudioDataStoppedTimeout) , video_data_stopped_timeout_(kDefaultVideoDataStoppedTimeout) @@ -784,6 +791,14 @@ const std::string& Profile::transport_manager_tcp_adapter_network_interface() return transport_manager_tcp_adapter_network_interface_; } +uint16_t Profile::cloud_app_retry_timeout() const { + return cloud_app_retry_timeout_; +} + +uint16_t Profile::cloud_app_max_retry_attempts() const { + return cloud_app_max_retry_attempts_; +} + const std::string& Profile::tts_delimiter() const { return tts_delimiter_; } @@ -1769,6 +1784,24 @@ void Profile::UpdateValues() { kTCPAdapterNetworkInterfaceKey, kTransportManagerSection); + ReadUIntValue(&cloud_app_retry_timeout_, + kDefaultCloudAppRetryTimeout, + kCloudAppTransportSection, + kCloudAppRetryTimeoutKey); + + LOG_UPDATED_VALUE(cloud_app_retry_timeout_, + kCloudAppRetryTimeoutKey, + kCloudAppTransportSection); + + ReadUIntValue(&cloud_app_max_retry_attempts_, + kDefaultCloudAppMaxRetryAttempts, + kCloudAppTransportSection, + kCloudAppMaxRetryAttemptsKey); + + LOG_UPDATED_VALUE(cloud_app_max_retry_attempts_, + kCloudAppMaxRetryAttemptsKey, + kCloudAppTransportSection); + // Event MQ ReadStringValue( &event_mq_name_, kDefaultEventMQ, kTransportManagerSection, kEventMQKey); diff --git a/src/components/connection_handler/src/connection_handler_impl.cc b/src/components/connection_handler/src/connection_handler_impl.cc index 399dbf90d7..290b1a650e 100644 --- a/src/components/connection_handler/src/connection_handler_impl.cc +++ b/src/components/connection_handler/src/connection_handler_impl.cc @@ -142,6 +142,8 @@ void ConnectionHandlerImpl::OnDeviceAdded( LOG4CXX_AUTO_TRACE(logger_); auto handle = device_info.device_handle(); + LOG4CXX_DEBUG(logger_, "OnDeviceAdded!!!: " << handle << " " << device_info.name() << " " << device_info.mac_address() << " " << device_info.connection_type()); + Device device(handle, device_info.name(), device_info.mac_address(), @@ -248,7 +250,7 @@ void ConnectionHandlerImpl::OnConnectionEstablished( const transport_manager::DeviceInfo& device_info, const transport_manager::ConnectionUID connection_id) { LOG4CXX_AUTO_TRACE(logger_); - + LOG4CXX_DEBUG(logger_, "OnConnectionEstablished!!!: " << device_info.device_handle() << " " << device_info.name() << " " << device_info.mac_address() << " " << device_info.connection_type()); DeviceMap::iterator it = device_list_.find(device_info.device_handle()); if (device_list_.end() == it) { LOG4CXX_ERROR(logger_, "Unknown device!"); diff --git a/src/components/hmi_message_handler/src/websocket_session.cc b/src/components/hmi_message_handler/src/websocket_session.cc index a148f48661..041a89ef82 100644 --- a/src/components/hmi_message_handler/src/websocket_session.cc +++ b/src/components/hmi_message_handler/src/websocket_session.cc @@ -71,6 +71,7 @@ bool WebsocketSession::IsShuttingDown() { } void WebsocketSession::Recv(boost::system::error_code ec) { + printf("!!!server recv connection accepted\n"); if (shutdown_) { return; } diff --git a/src/components/include/transport_manager/transport_adapter/transport_adapter.h b/src/components/include/transport_manager/transport_adapter/transport_adapter.h index ebbf7dae28..6af29aa7c2 100644 --- a/src/components/include/transport_manager/transport_adapter/transport_adapter.h +++ b/src/components/include/transport_manager/transport_adapter/transport_adapter.h @@ -64,12 +64,28 @@ enum DeviceType { IOS_BT, IOS_USB, TCP, + CLOUD_WEBSOCKET, IOS_USB_HOST_MODE, IOS_USB_DEVICE_MODE, IOS_CARPLAY_WIRELESS, // running on iAP over Carplay wireless transport UNKNOWN }; +enum HybridAppPreference { // todo find correct place for this enum defintion. + MOBILE, + CLOUD, + BOTH +}; + +struct CloudAppProperties { + std::string endpoint; + std::string certificate; + bool enabled; + std::string auth_token; + DeviceType cloud_transport_type; + HybridAppPreference hybrid_app_preference; +}; + typedef std::map DeviceTypes; /** @@ -88,6 +104,11 @@ typedef std::list TransportAdapterListenerList; */ typedef std::map TransportConfig; +/** + * @brief Type definition of container indexed by app id that contains connection information for all cloud apps. + */ +typedef std::map CloudAppTransportConfig; + /** * @brief TransportConfig keys */ diff --git a/src/components/include/transport_manager/transport_manager_settings.h b/src/components/include/transport_manager/transport_manager_settings.h index 3912bbe747..d59038e5c6 100644 --- a/src/components/include/transport_manager/transport_manager_settings.h +++ b/src/components/include/transport_manager/transport_manager_settings.h @@ -69,6 +69,16 @@ class TransportManagerSettings : public TransportManagerMMESettings { */ virtual const std::string& transport_manager_tcp_adapter_network_interface() const = 0; + + /** + * @brief Returns retry timeout for cloud app connections + */ + virtual uint16_t cloud_app_retry_timeout() const = 0; + + /** + * @brief Returns maximum retry attempts for cloud app connections + */ + virtual uint16_t cloud_app_max_retry_attempts() const = 0; }; } // namespace transport_manager #endif // SRC_COMPONENTS_INCLUDE_TRANSPORT_MANAGER_TRANSPORT_MANAGER_SETTINGS_H_ diff --git a/src/components/transport_manager/include/transport_manager/cloud/cloud_device.h b/src/components/transport_manager/include/transport_manager/cloud/cloud_device.h new file mode 100644 index 0000000000..5792ba06a1 --- /dev/null +++ b/src/components/transport_manager/include/transport_manager/cloud/cloud_device.h @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2018, Livio + * 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. + */ + +/** + * \file Cloud_device.h + * \brief CloudDevice class header file. + */ + +#ifndef SRC_COMPONENTS_TRANSPORT_MANAGER_INCLUDE_TRANSPORT_MANAGER_CLOUD_CLOUD_DEVICE_H_ +#define SRC_COMPONENTS_TRANSPORT_MANAGER_INCLUDE_TRANSPORT_MANAGER_CLOUD_CLOUD_DEVICE_H_ + +#include "transport_manager/transport_adapter/device.h" + +namespace transport_manager { +namespace transport_adapter { + +class CloudDevice : public Device { + public: + CloudDevice(std::string& host, + std::string& port, + std::string& name); + + protected: + virtual bool IsSameAs(const Device* other_device) const; + + virtual ApplicationList GetApplicationList() const; + + private: + //todo add private varaibles, maybe ip port or other connection information? +}; + +} // namespace transport_adapter +} // namespace transport_manager + +#endif // SRC_COMPONENTS_TRANSPORT_MANAGER_INCLUDE_TRANSPORT_MANAGER_CLOUD_CLOUD_DEVICE_H_ diff --git a/src/components/transport_manager/include/transport_manager/cloud/cloud_websocket_connection_factory.h b/src/components/transport_manager/include/transport_manager/cloud/cloud_websocket_connection_factory.h new file mode 100644 index 0000000000..ef1754a6e7 --- /dev/null +++ b/src/components/transport_manager/include/transport_manager/cloud/cloud_websocket_connection_factory.h @@ -0,0 +1,98 @@ +/* + * \file cloud_websocket_connection_factory.h + * \brief CloudWebsocketConnectionFactory class header file. + * + * Copyright (c) 2018, Livio + * 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. + */ + +#ifndef SRC_COMPONENTS_TRANSPORT_MANAGER_INCLUDE_TRANSPORT_MANAGER_CLOUD_CLOUD_WEBSOCKET_CONNECTION_FACTORY_H_ +#define SRC_COMPONENTS_TRANSPORT_MANAGER_INCLUDE_TRANSPORT_MANAGER_CLOUD_CLOUD_WEBSOCKET_CONNECTION_FACTORY_H_ + +#include "transport_manager/transport_adapter/server_connection_factory.h" + +namespace transport_manager { +namespace transport_adapter { + +class TransportAdapterController; + +/** + * @brief Create connections. + */ +class CloudWebsocketConnectionFactory : public ServerConnectionFactory { + public: + /** + * @brief Constructor. + * + * @param controller Pointer to the device adapter controller. + */ + CloudWebsocketConnectionFactory(TransportAdapterController* controller); + + protected: + /** + * @brief Start cloud websocket connection factory. + */ + virtual TransportAdapter::Error Init(); + + /** + * @brief Create cloud boost websocket connection. + * + * @param device_uid Device unique identifier. + * @param ap_handle Handle of application. + */ + virtual TransportAdapter::Error CreateConnection( + const DeviceUID& device_uid, const ApplicationHandle& app_handle); + + /** + * @brief + */ + virtual void Terminate(); + + /** + * @brief Check for initialization. + * + * @return true - initialized. + * false - not initialized. + */ + virtual bool IsInitialised() const; + + /** + * @brief Destructor. + */ + virtual ~CloudWebsocketConnectionFactory(); + + private: + TransportAdapterController* controller_; +}; + +} // namespace transport_adapter +} // namespace transport_manager + +#endif // SRC_COMPONENTS_TRANSPORT_MANAGER_INCLUDE_TRANSPORT_MANAGER_CLOUD_CLOUD_WEBSOCKET_CONNECTION_FACTORY_H_ diff --git a/src/components/transport_manager/include/transport_manager/cloud/cloud_websocket_transport_adapter.h b/src/components/transport_manager/include/transport_manager/cloud/cloud_websocket_transport_adapter.h new file mode 100644 index 0000000000..ad31bd33b3 --- /dev/null +++ b/src/components/transport_manager/include/transport_manager/cloud/cloud_websocket_transport_adapter.h @@ -0,0 +1,105 @@ +/* + * \file cloud_websocket_transport_adapter.h + * \brief Cloud Websocket Transport Adapterclass header file. + * + * Copyright (c) 2018, Livio + * 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. + */ + +#ifndef SRC_COMPONENTS_TRANSPORT_MANAGER_INCLUDE_TRANSPORT_MANAGER_CLOUD_CLOUD_WEBSOCKET_TRANSPORT_ADAPTER_H_ +#define SRC_COMPONENTS_TRANSPORT_MANAGER_INCLUDE_TRANSPORT_MANAGER_CLOUD_CLOUD_WEBSOCKET_TRANSPORT_ADAPTER_H_ + +#include "transport_manager/transport_adapter/transport_adapter_impl.h" + +namespace transport_manager { +namespace transport_adapter { + +/** + * @brief Cloud transport adapter that uses websockets. + */ +class CloudWebsocketTransportAdapter : public TransportAdapterImpl { + public: + /** + * @brief Constructor. + */ + explicit CloudWebsocketTransportAdapter(resumption::LastState& last_state, const TransportManagerSettings& settings); + + /** + * @brief Destructor. + */ + virtual ~CloudWebsocketTransportAdapter(); + + /** + * @brief Notification that transport's configuration is updated + * + * @param new_config The new configuration of the transport + */ + void CloudTransportConfigUpdated(const CloudAppTransportConfig& new_config); + + /** + * @brief Returns the transport's configuration information + */ + CloudAppTransportConfig GetCloudTransportConfiguration() const; + + protected: + /** + * @brief Return type of device. + * + * @return String with device type. + */ + virtual DeviceType GetDeviceType() const; + + /** + * @brief Store adapter state in last state singleton + */ + virtual void Store() const; + + /** + * @brief Restore adapter state from last state singleton + * + * @return True on success false otherwise + */ + virtual bool Restore(); + + private: + /** + * @brief Keeps transport specific configuration + * + * Cloud websocket transport uses following information: + * - "enabled": whether the transport is currently enabled or not. Value can + * be "true" or "false". + */ + CloudAppTransportConfig transport_config_; +}; + +} // namespace transport_adapter +} // namespace transport_manager + +#endif // SRC_COMPONENTS_TRANSPORT_MANAGER_INCLUDE_TRANSPORT_MANAGER_TCP_TCP_TRANSPORT_ADAPTER_H_ diff --git a/src/components/transport_manager/include/transport_manager/cloud/websocket_client_connection.h b/src/components/transport_manager/include/transport_manager/cloud/websocket_client_connection.h new file mode 100644 index 0000000000..38eb663b1c --- /dev/null +++ b/src/components/transport_manager/include/transport_manager/cloud/websocket_client_connection.h @@ -0,0 +1,180 @@ +/* + * \file websocket_client_connection.h + * \brief WebsocketClientConnection class header file. + * + * Copyright (c) 2018, Livio + * 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. + */ + +#ifndef SRC_COMPONENTS_TRANSPORT_MANAGER_INCLUDE_TRANSPORT_MANAGER_CLOUD_WEBSOCKET_CLIENT_CONNECTION_H_ +#define SRC_COMPONENTS_TRANSPORT_MANAGER_INCLUDE_TRANSPORT_MANAGER_CLOUD_WEBSOCKET_CLIENT_CONNECTION_H_ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "transport_manager/transport_adapter/connection.h" +#include "utils/threads/thread.h" +#include "utils/threads/message_loop_thread.h" +#include "utils/message_queue.h" + +using tcp = boost::asio::ip::tcp; // from +namespace ssl = boost::asio::ssl; // from +namespace websocket = boost::beast::websocket; // from +using ::utils::MessageQueue; + +typedef std::queue AsyncQueue; +typedef protocol_handler::RawMessagePtr Message; + +namespace transport_manager { +namespace transport_adapter { + +class TransportAdapterController; + +/** + * @brief Class responsible for communication over bluetooth sockets. + */ +class WebsocketClientConnection : public std::enable_shared_from_this, public Connection { + public: + /** + * @brief Constructor. + * + * @param device_uid Device unique identifier. + * @param app_handle Handle of device. + * @param controller Pointer to the device adapter controller. + */ + WebsocketClientConnection(const DeviceUID& device_uid, + const ApplicationHandle& app_handle, + TransportAdapterController* controller); + + /** + * @brief Destructor. + */ + virtual ~WebsocketClientConnection(); + + /** + * @brief Check if we can start the connection attempt and establish + *connection status. + * + * @param error contains information of any error that occurred during + *connection attempt. + * + * @return result that states whether we successfully connected or not. + */ + TransportAdapter::Error Start(); + + /** + * @brief Send data frame. + * + * @param message Smart pointer to the raw message. + * + * @return Error Information about possible reason of sending data failure. + */ + TransportAdapter::Error SendData(::protocol_handler::RawMessagePtr message); + + /** + * @brief Disconnect the current connection. + * + * @return Error Information about possible reason of Disconnect failure. + */ + TransportAdapter::Error Disconnect(); + + void Shutdown(); + + void Recv(boost::system::error_code ec); + + void OnRead(boost::system::error_code ec, + std::size_t bytes_transferred); + + + private: + + TransportAdapterController* controller_; + boost::asio::io_context ioc_; + tcp::resolver resolver_; + websocket::stream ws_; + boost::beast::flat_buffer buffer_; + std::string host_; + std::string text_; + + + std::atomic_bool shutdown_; + + typedef std::queue FrameQueue; + FrameQueue frames_to_send_; + mutable sync_primitives::Lock frames_to_send_mutex_; + + MessageQueue message_queue_; + + + class LoopThreadDelegate : public threads::ThreadDelegate { + public: + LoopThreadDelegate(MessageQueue* message_queue, + WebsocketClientConnection* handler); + + virtual void threadMain() OVERRIDE; + virtual void exitThreadMain() OVERRIDE; + + void OnWrite(); + + void SetShutdown(); + + private: + void DrainQueue(); + MessageQueue& message_queue_; + WebsocketClientConnection& handler_; + sync_primitives::Lock queue_lock_; + sync_primitives::ConditionalVariable queue_new_items_; + std::atomic_bool write_pending_; + std::atomic_bool shutdown_; + + sync_primitives::Lock write_lock_; + }; + + LoopThreadDelegate* thread_delegate_; + threads::Thread* write_thread_; + std::thread io_service_thread_; + + const DeviceUID device_uid_; + const ApplicationHandle app_handle_; +}; + +} // namespace transport_adapter +} // namespace transport_manager + +#endif // SRC_COMPONENTS_TRANSPORT_MANAGER_INCLUDE_TRANSPORT_MANAGER_BLUETOOTH_BLUETOOTH_SOCKET_CONNECTION_H_ diff --git a/src/components/transport_manager/src/cloud/cloud_device.cc b/src/components/transport_manager/src/cloud/cloud_device.cc new file mode 100644 index 0000000000..ab7f8db69a --- /dev/null +++ b/src/components/transport_manager/src/cloud/cloud_device.cc @@ -0,0 +1,62 @@ +/* + * + * Copyright (c) 2018, Livio + * 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 "transport_manager/cloud/cloud_device.h" + +#include "utils/logger.h" + +namespace transport_manager { +namespace transport_adapter { +CREATE_LOGGERPTR_GLOBAL(logger_, "TransportManager") + +CloudDevice::CloudDevice(std::string& host, + std::string& port, + std::string& name) + : Device(name, std::string(name+host+port)) {} + + +bool CloudDevice::IsSameAs(const Device* other) const { + LOG4CXX_TRACE(logger_, "enter. device: " << other); + bool result = false; + return result; +} + +//todo implement getApplicationList +//to be populated by policies +ApplicationList CloudDevice::GetApplicationList() const { + return ApplicationList{100}; +} + + +} // namespace transport_adapter +} // namespace transport_manager diff --git a/src/components/transport_manager/src/cloud/cloud_websocket_connection_factory.cc b/src/components/transport_manager/src/cloud/cloud_websocket_connection_factory.cc new file mode 100644 index 0000000000..d566dd9bf8 --- /dev/null +++ b/src/components/transport_manager/src/cloud/cloud_websocket_connection_factory.cc @@ -0,0 +1,99 @@ +/* + * \file cloud_websocket_connection_factory.cc + * \brief CloudWebsocketConnectionFactory class source file. + * + * Copyright (c) 2018, Livio + * 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 "transport_manager/transport_adapter/transport_adapter_controller.h" +#include "transport_manager/cloud/cloud_websocket_connection_factory.h" +#include "transport_manager/cloud/websocket_client_connection.h" +#include "utils/logger.h" + +#include "transport_manager/cloud/cloud_device.h" + +namespace transport_manager { +namespace transport_adapter { + +CREATE_LOGGERPTR_GLOBAL(logger_, "TransportManager") + +CloudWebsocketConnectionFactory::CloudWebsocketConnectionFactory( + TransportAdapterController* controller) + : controller_(controller) {} + +TransportAdapter::Error CloudWebsocketConnectionFactory::Init() { + DeviceUID device_id = "Cloud"; + ApplicationHandle app_handle = 100; + printf("Calling create connection\n"); + + std::string host("192.168.1.69"); + std::string port("8080"); + + //todo move this device logic to the correct place. + auto cloud_device = std::make_shared( + host,port,device_id); + DeviceVector devices{cloud_device}; + + controller_->SearchDeviceDone(devices); + + + const TransportAdapter::Error err = + this->CreateConnection(std::string(device_id+host+port), app_handle); + LOG4CXX_DEBUG(logger_, err); + return TransportAdapter::OK; +} + +TransportAdapter::Error CloudWebsocketConnectionFactory::CreateConnection( + const DeviceUID& device_uid, const ApplicationHandle& app_handle) { + LOG4CXX_AUTO_TRACE(logger_); + printf("Create connection()\n"); + std::shared_ptr connection = + std::make_shared( + device_uid, app_handle, controller_); + controller_->ConnectionCreated(connection, device_uid, app_handle); + TransportAdapter::Error error = connection->Start(); + if (TransportAdapter::OK != error) { + LOG4CXX_ERROR(logger_, + "Cloud Websocket connection::Start() failed with error: " << error); + } + return error; +} + +void CloudWebsocketConnectionFactory::Terminate() {} + +bool CloudWebsocketConnectionFactory::IsInitialised() const { + return true; +} + +CloudWebsocketConnectionFactory::~CloudWebsocketConnectionFactory() {} + +} // namespace transport_adapter +} // namespace transport_manager diff --git a/src/components/transport_manager/src/cloud/cloud_websocket_transport_adapter.cc b/src/components/transport_manager/src/cloud/cloud_websocket_transport_adapter.cc new file mode 100644 index 0000000000..29ea6e5b27 --- /dev/null +++ b/src/components/transport_manager/src/cloud/cloud_websocket_transport_adapter.cc @@ -0,0 +1,73 @@ +/* + * Copyright (c) 2018, Livio + * 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 "transport_manager/cloud/cloud_websocket_transport_adapter.h" +#include "transport_manager/cloud/cloud_websocket_connection_factory.h" + +namespace transport_manager { +namespace transport_adapter { + +CREATE_LOGGERPTR_GLOBAL(logger_, "TransportManager") + +CloudWebsocketTransportAdapter::CloudWebsocketTransportAdapter(resumption::LastState& last_state, const TransportManagerSettings& settings) +: TransportAdapterImpl(NULL, new CloudWebsocketConnectionFactory(this), NULL, last_state, settings) { + + /*DeviceUID device_id = "Cloud"; + ApplicationHandle app_handle = 100; + printf("Calling create connection\n"); + const TransportAdapter::Error err = + server_connection_factory_->CreateConnection(device_id, app_handle); + LOG4CXX_DEBUG(logger_, err);*/ +} + +CloudWebsocketTransportAdapter::~CloudWebsocketTransportAdapter() {} + +void CloudWebsocketTransportAdapter::CloudTransportConfigUpdated(const CloudAppTransportConfig& new_config) {} + +CloudAppTransportConfig CloudWebsocketTransportAdapter::GetCloudTransportConfiguration() const { return transport_config_; } + +DeviceType CloudWebsocketTransportAdapter::GetDeviceType() const { + return CLOUD_WEBSOCKET; +} + +void CloudWebsocketTransportAdapter::Store() const {} // todo decide if this is needed + +bool CloudWebsocketTransportAdapter::Restore() { // todo decide if resumption is needed + return true; +} + + + + + +} +} \ No newline at end of file diff --git a/src/components/transport_manager/src/cloud/websocket_client_connection.cc b/src/components/transport_manager/src/cloud/websocket_client_connection.cc new file mode 100644 index 0000000000..96641f5cb2 --- /dev/null +++ b/src/components/transport_manager/src/cloud/websocket_client_connection.cc @@ -0,0 +1,252 @@ +/* + * + * Copyright (c) 2017, 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 "transport_manager/cloud/websocket_client_connection.h" + +#include "transport_manager/transport_adapter/transport_adapter_controller.h" + +#include "utils/logger.h" + +namespace transport_manager { +namespace transport_adapter { +CREATE_LOGGERPTR_GLOBAL(logger_, "TransportManager") + +WebsocketClientConnection::WebsocketClientConnection( + const DeviceUID& device_uid, + const ApplicationHandle& app_handle, + TransportAdapterController* controller): controller_(controller) + , resolver_(ioc_) + , ws_(ioc_) + , shutdown_(false) + , thread_delegate_(new LoopThreadDelegate(&message_queue_, this)) + , write_thread_(threads::CreateThread("WS Async Send", thread_delegate_)) + , device_uid_(device_uid) + , app_handle_(app_handle) {} + +WebsocketClientConnection::~WebsocketClientConnection() { + ioc_.stop(); + if(io_service_thread_.joinable()) { + io_service_thread_.join(); + } +} + +TransportAdapter::Error WebsocketClientConnection::Start() { + LOG4CXX_AUTO_TRACE(logger_); + printf("Calling websocket start\n"); + auto const host = "192.168.1.69"; + auto const port = "8080"; + boost::system::error_code ec; + auto const results = resolver_.resolve(host, port, ec); + if (ec) { + std::string str_err = "ErrorMessage1: " + ec.message(); + printf("%s\n", str_err.c_str()); + Shutdown(); + return TransportAdapter::FAIL; + } + boost::asio::connect(ws_.next_layer(), results.begin(), results.end(), ec); + if (ec) { + std::string str_err = "ErrorMessage2: " + ec.message(); + printf("%s\n", str_err.c_str()); + Shutdown(); + return TransportAdapter::FAIL; + } + ws_.handshake(host, "/", ec); + if (ec) { + std::string str_err = "ErrorMessage3: " + ec.message(); + printf("%s\n", str_err.c_str()); + Shutdown(); + return TransportAdapter::FAIL; + } + ws_.binary(true); + write_thread_->start(threads::ThreadOptions()); + controller_->ConnectDone(device_uid_, app_handle_); + + // Start async read + ws_.async_read( + buffer_, + std::bind( + &WebsocketClientConnection::OnRead, + this, + std::placeholders::_1, + std::placeholders::_2)); + + // Start IO Service thread. Allows for async reads without blocking. + io_service_thread_ = std::thread([&](){ ioc_.run(); printf("io_service_thread_ END!!!\n"); + }); + + // Start async write thread + + printf("End of websockets\n"); + + return TransportAdapter::OK; +} + +void WebsocketClientConnection::Recv(boost::system::error_code ec) { + printf("Recv\n"); + if (shutdown_) { + printf("shutdown_\n"); + return; + } + + if (ec) { + std::string str_err = "ErrorMessage: " + ec.message(); + printf("%s\n", str_err.c_str()); + LOG4CXX_ERROR(logger_, str_err); + //shutdown_ = true; + //ioc_.stop(); + //thread_delegate_->SetShutdown(); + //controller_->deleteController(this); + Shutdown(); + return; + } + printf("calling async read\n"); + + ws_.async_read( + buffer_, + std::bind( + &WebsocketClientConnection::OnRead, + this, + std::placeholders::_1, + std::placeholders::_2)); +} + +void WebsocketClientConnection::OnRead(boost::system::error_code ec, + std::size_t bytes_transferred) { + printf("OnRead\n"); + boost::ignore_unused(bytes_transferred); + if (ec) { + std::string str_err = "ErrorMessage: " + ec.message(); + printf("%s\n", str_err.c_str()); + LOG4CXX_ERROR(logger_, str_err); + Shutdown(); + controller_->ConnectionAborted( + device_uid_, app_handle_, CommunicationError()); + + printf("return error\n"); + return; + } + + std::string data_str = boost::beast::buffers_to_string(buffer_.data()); + LOG4CXX_DEBUG(logger_, "Cloud Transport Received: " << data_str); + printf("%s\n", data_str.c_str()); + + ssize_t size = (ssize_t)buffer_.size(); + const uint8_t* data = boost::asio::buffer_cast(boost::beast::buffers_front(buffer_.data())); + + ::protocol_handler::RawMessagePtr frame( + new protocol_handler::RawMessage(0, 0, data, size)); + + controller_->DataReceiveDone(device_uid_, app_handle_, frame); + + buffer_.consume(buffer_.size()); + Recv(ec); +} + +TransportAdapter::Error WebsocketClientConnection::SendData( + ::protocol_handler::RawMessagePtr message) { + LOG4CXX_AUTO_TRACE(logger_); + printf("Send DATA!!!\n"); + sync_primitives::AutoLock auto_lock(frames_to_send_mutex_); + message_queue_.push(message); + printf("Data pushed to queue!!!\n"); + return TransportAdapter::OK; +} + +TransportAdapter::Error WebsocketClientConnection::Disconnect() { + LOG4CXX_AUTO_TRACE(logger_); + Shutdown(); + return TransportAdapter::OK; +} + +void WebsocketClientConnection::Shutdown() { + + shutdown_ = true; + + if (thread_delegate_) { + thread_delegate_->SetShutdown(); + write_thread_->join(); + printf("Joined Thread Delegate!!!\n"); + delete thread_delegate_; + } + if (buffer_.size()) { + buffer_.consume(buffer_.size()); + } + printf("End of shutdown!!!\n"); +} + +WebsocketClientConnection::LoopThreadDelegate::LoopThreadDelegate( + MessageQueue* message_queue, WebsocketClientConnection* handler) + : message_queue_(*message_queue), handler_(*handler), shutdown_(false) {} + +void WebsocketClientConnection::LoopThreadDelegate::threadMain() { + printf("Starting write thread\n"); + while (!message_queue_.IsShuttingDown() && !shutdown_) { + DrainQueue(); + message_queue_.wait(); + } + DrainQueue(); +} + +void WebsocketClientConnection::LoopThreadDelegate::exitThreadMain() { + shutdown_ = true; + if (!message_queue_.IsShuttingDown()) { + message_queue_.Shutdown(); + } +} + +void WebsocketClientConnection::LoopThreadDelegate::DrainQueue() { + while (!message_queue_.empty()) { + Message message_ptr; + message_queue_.pop(message_ptr); + if (!shutdown_) { + printf("Calling Write!!!\n"); + boost::system::error_code ec; + handler_.ws_.write(boost::asio::buffer(message_ptr->data(), message_ptr->data_size())); + if (ec) { + LOG4CXX_ERROR(logger_, "Error writing to websocket"); + handler_.Shutdown(); + handler_.controller_->DataSendFailed(handler_.device_uid_, handler_.app_handle_, message_ptr, DataSendError()); + } + } + } +} + +void WebsocketClientConnection::LoopThreadDelegate::SetShutdown() { + shutdown_ = true; + if (!message_queue_.IsShuttingDown()) { + message_queue_.Shutdown(); + } +} + +} // namespace transport_adapter +} // namespace transport_manager \ No newline at end of file diff --git a/src/components/transport_manager/src/transport_manager_default.cc b/src/components/transport_manager/src/transport_manager_default.cc index 196ad09af4..f78c31c0d5 100644 --- a/src/components/transport_manager/src/transport_manager_default.cc +++ b/src/components/transport_manager/src/transport_manager_default.cc @@ -44,6 +44,10 @@ #include "transport_manager/usb/usb_aoa_adapter.h" #endif // USB_SUPPORT +#if defined(CLOUD_APP_WEBSOCKET_TRANSPORT_SUPPORT) +#include "transport_manager/cloud/cloud_websocket_transport_adapter.h" +#endif + #if defined(BUILD_TESTS) #include "transport_manager/iap2_emulation/iap2_transport_adapter.h" #endif // BUILD_TEST @@ -101,6 +105,18 @@ int TransportManagerDefault::Init(resumption::LastState& last_state) { ta_usb = NULL; #endif // USB_SUPPORT +#if defined CLOUD_APP_WEBSOCKET_TRANSPORT_SUPPORT + printf("Creating cloud transport\n"); + transport_adapter::TransportAdapterImpl* ta_cloud = new transport_adapter::CloudWebsocketTransportAdapter(last_state, get_settings()); //Todo add retry connection logic from ini to initializer. +#ifdef TELEMETRY_MONITOR + if (metric_observer_) { + ta_cloud->SetTelemetryObserver(metric_observer_); + } +#endif // TELEMETRY_MONITOR + AddTransportAdapter(ta_cloud); + ta_cloud = NULL; +#endif + #if defined BUILD_TESTS const uint16_t iap2_bt_emu_port = 23456; transport_adapter::IAP2BluetoothEmulationTransportAdapter* -- cgit v1.2.1 From 0ffb1871b58c730429e25728cd91cd0196d84ee3 Mon Sep 17 00:00:00 2001 From: jacobkeeler Date: Thu, 1 Nov 2018 16:08:28 -0400 Subject: Add cloud app parameters to regular policies --- .../application_manager/policies/policy_handler.h | 23 +++++++ .../application_manager/smart_object_keys.h | 4 ++ .../src/policies/policy_handler.cc | 63 ++++++++++++++++++ .../application_manager/src/smart_object_keys.cc | 4 ++ .../policies/policy_handler_interface.h | 39 +++++++++++ .../policy/policy_regular/policy/policy_manager.h | 51 +++++++++++++++ .../policies/mock_policy_handler_interface.h | 10 +++ .../policy_regular/policy/mock_cache_manager.h | 17 +++++ .../policy_regular/policy/mock_policy_manager.h | 17 +++++ .../policy_regular/include/policy/cache_manager.h | 51 +++++++++++++++ .../include/policy/cache_manager_interface.h | 51 +++++++++++++++ .../include/policy/policy_manager_impl.h | 52 +++++++++++++++ .../include/policy/policy_table/enums.h | 6 ++ .../include/policy/policy_table/types.h | 6 ++ .../policy/policy_regular/src/cache_manager.cc | 75 ++++++++++++++++++++++ .../policy_regular/src/policy_manager_impl.cc | 32 ++++++++- .../policy_regular/src/policy_table/enums.cc | 35 +++++++++- .../policy_regular/src/policy_table/types.cc | 65 ++++++++++++++++++- .../policy/policy_regular/src/sql_pt_queries.cc | 43 ++++++++++--- .../policy_regular/src/sql_pt_representation.cc | 43 ++++++++++++- .../test/sql_pt_representation_test.cc | 4 +- 21 files changed, 675 insertions(+), 16 deletions(-) diff --git a/src/components/application_manager/include/application_manager/policies/policy_handler.h b/src/components/application_manager/include/application_manager/policies/policy_handler.h index c8f3bcf888..3af03bf28b 100644 --- a/src/components/application_manager/include/application_manager/policies/policy_handler.h +++ b/src/components/application_manager/include/application_manager/policies/policy_handler.h @@ -398,6 +398,29 @@ class PolicyHandler : public PolicyHandlerInterface, custom_str::CustomString GetAppName( const std::string& policy_app_id) OVERRIDE; + /** + * @brief Checks if a given application is an enabled cloud application + * @param policy_app_id Unique application id + * @return true, if the application is an enabled cloud application, + * otherwise - false + */ + const bool CheckCloudAppEnabled( + const std::string& policy_app_id) const OVERRIDE; + + /**plzfix + * @brief Checks if certain request type is allowed for application + * @param policy_app_id Unique application id + * @return true, if allowed, otherwise - false + */ + const bool GetCloudAppParameters(const std::string& policy_app_id, + std::string& endpoint, + std::string& auth_token, + std::string& cloud_transport_type, + std::string& hybrid_app_preference) const OVERRIDE; + + void OnSetCloudAppProperties( + const smart_objects::SmartObject& message) OVERRIDE; + virtual void OnUpdateHMIAppType( std::map app_hmi_types) OVERRIDE; 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 9b5f63809a..62192da391 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 @@ -188,6 +188,10 @@ extern const char* green; extern const char* blue; extern const char* display_layout; extern const char* icon_resumed; +extern const char* enabled; +extern const char* cloud_app_auth_token; +extern const char* cloud_transport_type; +extern const char* hybrid_app_preference; // PutFile extern const char* sync_file_name; diff --git a/src/components/application_manager/src/policies/policy_handler.cc b/src/components/application_manager/src/policies/policy_handler.cc index 1b64c5d7b4..c73e35768e 100644 --- a/src/components/application_manager/src/policies/policy_handler.cc +++ b/src/components/application_manager/src/policies/policy_handler.cc @@ -1845,6 +1845,69 @@ bool PolicyHandler::CheckSystemAction( return false; } +const bool PolicyHandler::GetCloudAppParameters( + const std::string& policy_app_id, + std::string& endpoint, + std::string& auth_token, + std::string& cloud_transport_type, + std::string& hybrid_app_preference) const { + POLICY_LIB_CHECK(false); + return policy_manager_->GetCloudAppParameters(policy_app_id, + endpoint, + auth_token, + cloud_transport_type, + hybrid_app_preference); +} + +const bool PolicyHandler::CheckCloudAppEnabled(const std::string& policy_app_id) const { + POLICY_LIB_CHECK(false); + std::string endpoint; + std::string auth_token; + std::string cloud_transport_type; + std::string hybrid_app_preference; + return policy_manager_->GetCloudAppParameters(policy_app_id, + endpoint, + auth_token, + cloud_transport_type, + hybrid_app_preference); +} + +void PolicyHandler::OnSetCloudAppProperties( + const smart_objects::SmartObject& message) { + POLICY_LIB_CHECK_VOID(); + if (!message.keyExists(strings::msg_params)) { + LOG4CXX_ERROR( + logger_, + "Message does not contain mandatory section " << strings::msg_params); + return; + } + const smart_objects::SmartObject& msg_params = message[strings::msg_params]; + if (!msg_params.keyExists(strings::app_id)) { + LOG4CXX_ERROR( + logger_, + "Message does not contain mandatory parameter " << strings::app_id); + return; + } + std::string policy_app_id(msg_params[strings::app_id].asString()); + if (msg_params.keyExists(strings::enabled)) { + policy_manager_->SetCloudAppEnabled(policy_app_id, + msg_params[strings::enabled].asBool()); + } + if (msg_params.keyExists(strings::cloud_app_auth_token)) { + policy_manager_->SetAppAuthToken(policy_app_id, + msg_params[strings::cloud_app_auth_token].asString()); + } + if (msg_params.keyExists(strings::cloud_transport_type)) { + policy_manager_->SetAppCloudTransportType( + policy_app_id, msg_params[strings::cloud_transport_type].asString()); + } + if (msg_params.keyExists(strings::hybrid_app_preference)) { + //const std::string hybrid_app_preference = EnumConversionHelper::EnumToString(msg_params[strings::hybrid_app_preference]); + //policy_manager_->SetHybridAppPreference( + // policy_app_id, hybrid_app_preference); + } +} + uint32_t PolicyHandler::HeartBeatTimeout(const std::string& app_id) const { POLICY_LIB_CHECK(0); return policy_manager_->HeartBeatTimeout(app_id); diff --git a/src/components/application_manager/src/smart_object_keys.cc b/src/components/application_manager/src/smart_object_keys.cc index e006b893f6..3e2951c553 100644 --- a/src/components/application_manager/src/smart_object_keys.cc +++ b/src/components/application_manager/src/smart_object_keys.cc @@ -155,6 +155,10 @@ const char* green = "green"; const char* blue = "blue"; const char* display_layout = "displayLayout"; const char* icon_resumed = "iconResumed"; +const char* enabled = "enabled"; +const char* cloud_app_auth_token = "cloudAppAuthToken"; +const char* cloud_transport_type = "cloudTransportType"; +const char* hybrid_app_preference = "hybridAppPreference"; // PutFile const char* sync_file_name = "syncFileName"; diff --git a/src/components/include/application_manager/policies/policy_handler_interface.h b/src/components/include/application_manager/policies/policy_handler_interface.h index ee9274ead7..69433e6118 100644 --- a/src/components/include/application_manager/policies/policy_handler_interface.h +++ b/src/components/include/application_manager/policies/policy_handler_interface.h @@ -437,6 +437,45 @@ class PolicyHandlerInterface { * @return Structure with vehicle information */ virtual const VehicleInfo GetVehicleInfo() const = 0; + + /** + * @brief Checks if a given application is an enabled cloud application + * @param policy_app_id Unique application id + * @return true if the application is an enabled cloud application, + * false otherwise + */ + virtual const bool CheckCloudAppEnabled( + const std::string& policy_app_id) const = 0; + + /** + * @brief Get cloud app policy information, all fields that aren't set for a + * given app will be filled with empty strings + * @param policy_app_id Unique application id + * @param endpoint Filled the endpoint used to connect to the cloud + * application + * @param auth_token Filled with the token used for authentication when + * reconnecting to the cloud app + * @param cloud_transport_type Filled with the transport type used by the + * cloud application (ex. "WSS") + * @param cloud_transport_type Filled with the hybrid app preference for the + * cloud application set by the user + * @return true if the cloud app is enabled, false otherwise + */ + virtual const bool GetCloudAppParameters( + const std::string& policy_app_id, + std::string& endpoint, + std::string& auth_token, + std::string& cloud_transport_type, + std::string& hybrid_app_preference) const = 0; + + /** + * @brief Callback for when a SetCloudAppProperties message is received from a + * mobile app + * @param message The SetCloudAppProperties message + */ + virtual void OnSetCloudAppProperties( + const smart_objects::SmartObject& message) = 0; + #ifdef EXTERNAL_PROPRIETARY_MODE /** * @brief Gets meta information diff --git a/src/components/include/policy/policy_regular/policy/policy_manager.h b/src/components/include/policy/policy_regular/policy/policy_manager.h index ee0bae7118..9c67e239b7 100644 --- a/src/components/include/policy/policy_regular/policy/policy_manager.h +++ b/src/components/include/policy/policy_regular/policy/policy_manager.h @@ -502,6 +502,57 @@ class PolicyManager : public usage_statistics::StatisticsManager { */ virtual const VehicleInfo GetVehicleInfo() const = 0; + /** + * @brief Get cloud app policy information, all fields that aren't set for a + * given app will be filled with empty strings + * @param policy_app_id Unique application id + * @param endpoint Filled the endpoint used to connect to the cloud + * application + * @param auth_token Filled with the token used for authentication when + * reconnecting to the cloud app + * @param cloud_transport_type Filled with the transport type used by the + * cloud application (ex. "WSS") + * @param cloud_transport_type Filled with the hybrid app preference for the + * cloud application set by the user + * @return true if the cloud app is enabled, false otherwise + */ + virtual const bool GetCloudAppParameters( + const std::string& policy_app_id, + std::string& endpoint, + std::string& auth_token, + std::string& cloud_transport_type, + std::string& hybrid_app_preference) const = 0; + + /** + * @brief Enable or disable a cloud application in the HMI + * @param enabled Cloud app enabled state + */ + virtual void SetCloudAppEnabled(const std::string& policy_app_id, + const bool enabled) = 0; + + /** + * @brief Set an app's auth token + * @param auth_token Cloud app authentication token + */ + virtual void SetAppAuthToken(const std::string& policy_app_id, + const std::string& auth_token) = 0; + + /** + * @brief Set a cloud app's transport type + * @param cloud_transport_type Cloud app transport type + */ + virtual void SetAppCloudTransportType( + const std::string& policy_app_id, + const std::string& cloud_transport_type) = 0; + + /** + * @brief Set the user preference for how a hybrid (cloud and mobile) app + * should be used + * @param hybrid_app_preference Hybrid app user preference + */ + virtual void SetHybridAppPreference(const std::string& policy_app_id, + const std::string& hybrid_app_preference) = 0; + /** * @brief OnAppRegisteredOnMobile allows to handle event when application were * succesfully registered on mobile device. diff --git a/src/components/include/test/application_manager/policies/mock_policy_handler_interface.h b/src/components/include/test/application_manager/policies/mock_policy_handler_interface.h index cb47147074..bd56d78128 100644 --- a/src/components/include/test/application_manager/policies/mock_policy_handler_interface.h +++ b/src/components/include/test/application_manager/policies/mock_policy_handler_interface.h @@ -213,6 +213,16 @@ class MockPolicyHandlerInterface : public policy::PolicyHandlerInterface { GetAppRequestTypes, const std::vector(const std::string& policy_app_id)); MOCK_CONST_METHOD0(GetVehicleInfo, const policy::VehicleInfo()); + MOCK_CONST_METHOD1(CheckCloudAppEnabled, + const bool(const std::string& policy_app_id)); + MOCK_CONST_METHOD5(GetCloudAppParameters, + const bool(const std::string& policy_app_id, + std::string& endpoint, + std::string& auth_token, + std::string& cloud_transport_type, + std::string& hybrid_app_preference)); + MOCK_METHOD1(OnSetCloudAppProperties, + void(const smart_objects::SmartObject& message)); #ifdef EXTERNAL_PROPRIETARY_MODE MOCK_CONST_METHOD0(GetMetaInfo, const policy::MetaInfo()); diff --git a/src/components/include/test/policy/policy_regular/policy/mock_cache_manager.h b/src/components/include/test/policy/policy_regular/policy/mock_cache_manager.h index 440000dbff..745bcd2db5 100644 --- a/src/components/include/test/policy/policy_regular/policy/mock_cache_manager.h +++ b/src/components/include/test/policy/policy_regular/policy/mock_cache_manager.h @@ -63,6 +63,23 @@ class MockCacheManagerInterface : public CacheManagerInterface { MOCK_METHOD0(TimeoutResponse, int()); MOCK_METHOD1(SecondsBetweenRetries, bool(std::vector& seconds)); MOCK_CONST_METHOD0(GetVehicleInfo, const VehicleInfo()); + MOCK_CONST_METHOD5(GetCloudAppParameters, + const bool(const std::string& policy_app_id, + std::string& endpoint, + std::string& auth_token, + std::string& cloud_transport_type, + std::string& hybrid_app_preference)); + MOCK_METHOD2(SetCloudAppEnabled, + void(const std::string& policy_app_id, const bool enabled)); + MOCK_METHOD2(SetAppAuthToken, + void(const std::string& policy_app_id, + const std::string& auth_token)); + MOCK_METHOD2(SetAppCloudTransportType, + void(const std::string& policy_app_id, + const std::string& cloud_transport_type)); + MOCK_METHOD2(SetHybridAppPreference, + void(const std::string& policy_app_id, + const std::string& hybrid_app_preference)); MOCK_METHOD1(SetVINValue, bool(const std::string& value)); MOCK_METHOD2(GetUserFriendlyMsg, std::vector( diff --git a/src/components/include/test/policy/policy_regular/policy/mock_policy_manager.h b/src/components/include/test/policy/policy_regular/policy/mock_policy_manager.h index 0e06e9c1a3..8867c3de80 100644 --- a/src/components/include/test/policy/policy_regular/policy/mock_policy_manager.h +++ b/src/components/include/test/policy/policy_regular/policy/mock_policy_manager.h @@ -181,6 +181,23 @@ class MockPolicyManager : public PolicyManager { GetAppRequestTypes, const std::vector(const std::string policy_app_id)); MOCK_CONST_METHOD0(GetVehicleInfo, const policy::VehicleInfo()); + MOCK_CONST_METHOD5(GetCloudAppParameters, + const bool(const std::string& policy_app_id, + std::string& endpoint, + std::string& auth_token, + std::string& cloud_transport_type, + std::string& hybrid_app_preference)); + MOCK_METHOD2(SetCloudAppEnabled, + void(const std::string& policy_app_id, const bool enabled)); + MOCK_METHOD2(SetAppAuthToken, + void(const std::string& policy_app_id, + const std::string& auth_token)); + MOCK_METHOD2(SetAppCloudTransportType, + void(const std::string& policy_app_id, + const std::string& cloud_transport_type)); + MOCK_METHOD2(SetHybridAppPreference, + void(const std::string& policy_app_id, + const std::string& hybrid_app_preference)); MOCK_CONST_METHOD0(GetMetaInfo, const policy::MetaInfo()); MOCK_CONST_METHOD0(RetrieveCertificate, std::string()); MOCK_CONST_METHOD0(HasCertificate, bool()); diff --git a/src/components/policy/policy_regular/include/policy/cache_manager.h b/src/components/policy/policy_regular/include/policy/cache_manager.h index 48e00f7049..119a0c0519 100644 --- a/src/components/policy/policy_regular/include/policy/cache_manager.h +++ b/src/components/policy/policy_regular/include/policy/cache_manager.h @@ -146,6 +146,57 @@ class CacheManager : public CacheManagerInterface { */ virtual const VehicleInfo GetVehicleInfo() const; + /** + * @brief Get cloud app policy information, all fields that aren't set for a + * given app will be filled with empty strings + * @param policy_app_id Unique application id + * @param endpoint Filled the endpoint used to connect to the cloud + * application + * @param auth_token Filled with the token used for authentication when + * reconnecting to the cloud app + * @param cloud_transport_type Filled with the transport type used by the + * cloud application (ex. "WSS") + * @param cloud_transport_type Filled with the hybrid app preference for the + * cloud application set by the user + * @return true if the cloud app is enabled, false otherwise + */ + virtual const bool GetCloudAppParameters( + const std::string& policy_app_id, + std::string& endpoint, + std::string& auth_token, + std::string& cloud_transport_type, + std::string& hybrid_app_preference) const; + + /** + * @brief Enable or disable a cloud application in the HMI + * @param enabled Cloud app enabled state + */ + virtual void SetCloudAppEnabled(const std::string& policy_app_id, + const bool enabled); + + /** + * @brief Set an app's auth token + * @param auth_token Cloud app authentication token + */ + virtual void SetAppAuthToken(const std::string& policy_app_id, + const std::string& auth_token); + + /** + * @brief Set a cloud app's transport type + * @param cloud_transport_type Cloud app transport type + */ + virtual void SetAppCloudTransportType( + const std::string& policy_app_id, + const std::string& cloud_transport_type); + + /** + * @brief Set the user preference for how a hybrid (cloud and mobile) app + * should be used + * @param hybrid_app_preference Hybrid app user preference + */ + virtual void SetHybridAppPreference(const std::string& policy_app_id, + const std::string& hybrid_app_preference); + /** * @brief Allows to update 'vin' field in module_meta table. * diff --git a/src/components/policy/policy_regular/include/policy/cache_manager_interface.h b/src/components/policy/policy_regular/include/policy/cache_manager_interface.h index 10a6ea7f89..9408809f1e 100644 --- a/src/components/policy/policy_regular/include/policy/cache_manager_interface.h +++ b/src/components/policy/policy_regular/include/policy/cache_manager_interface.h @@ -151,6 +151,57 @@ class CacheManagerInterface { */ virtual const VehicleInfo GetVehicleInfo() const = 0; + /** + * @brief Get cloud app policy information, all fields that aren't set for a + * given app will be filled with empty strings + * @param policy_app_id Unique application id + * @param endpoint Filled the endpoint used to connect to the cloud + * application + * @param auth_token Filled with the token used for authentication when + * reconnecting to the cloud app + * @param cloud_transport_type Filled with the transport type used by the + * cloud application (ex. "WSS") + * @param cloud_transport_type Filled with the hybrid app preference for the + * cloud application set by the user + * @return true if the cloud app is enabled, false otherwise + */ + virtual const bool GetCloudAppParameters( + const std::string& policy_app_id, + std::string& endpoint, + std::string& auth_token, + std::string& cloud_transport_type, + std::string& hybrid_app_preference) const = 0; + + /** + * @brief Enable or disable a cloud application in the HMI + * @param enabled Cloud app enabled state + */ + virtual void SetCloudAppEnabled(const std::string& policy_app_id, + const bool enabled) = 0; + + /** + * @brief Set an app's auth token + * @param auth_token Cloud app authentication token + */ + virtual void SetAppAuthToken(const std::string& policy_app_id, + const std::string& auth_token) = 0; + + /** + * @brief Set a cloud app's transport type + * @param cloud_transport_type Cloud app transport type + */ + virtual void SetAppCloudTransportType( + const std::string& policy_app_id, + const std::string& cloud_transport_type) = 0; + + /** + * @brief Set the user preference for how a hybrid (cloud and mobile) app + * should be used + * @param hybrid_app_preference Hybrid app user preference + */ + virtual void SetHybridAppPreference(const std::string& policy_app_id, + const std::string& hybrid_app_preference) = 0; + /** * @brief Allows to update 'vin' field in module_meta table. * diff --git a/src/components/policy/policy_regular/include/policy/policy_manager_impl.h b/src/components/policy/policy_regular/include/policy/policy_manager_impl.h index 51d4ee88aa..e1221b613f 100644 --- a/src/components/policy/policy_regular/include/policy/policy_manager_impl.h +++ b/src/components/policy/policy_regular/include/policy/policy_manager_impl.h @@ -564,6 +564,58 @@ class PolicyManagerImpl : public PolicyManager { */ const VehicleInfo GetVehicleInfo() const OVERRIDE; + /** + * @brief Get cloud app policy information, all fields that aren't set for a + * given app will be filled with empty strings + * @param policy_app_id Unique application id + * @param endpoint Filled the endpoint used to connect to the cloud + * application + * @param auth_token Filled with the token used for authentication when + * reconnecting to the cloud app + * @param cloud_transport_type Filled with the transport type used by the + * cloud application (ex. "WSS") + * @param cloud_transport_type Filled with the hybrid app preference for the + * cloud application set by the user + * @return true if the cloud app is enabled, false otherwise + */ + const bool GetCloudAppParameters( + const std::string& policy_app_id, + std::string& endpoint, + std::string& auth_token, + std::string& cloud_transport_type, + std::string& hybrid_app_preference) const OVERRIDE; + + /** + * @brief Enable or disable a cloud application in the HMI + * @param enabled Cloud app enabled state + */ + void SetCloudAppEnabled(const std::string& policy_app_id, + const bool enabled) OVERRIDE; + + /** + * @brief Set an app's auth token + * @param auth_token Cloud app authentication token + */ + void SetAppAuthToken(const std::string& policy_app_id, + const std::string& auth_token) OVERRIDE; + + /** + * @brief Set a cloud app's transport type + * @param cloud_transport_type Cloud app transport type + */ + void SetAppCloudTransportType( + const std::string& policy_app_id, + const std::string& cloud_transport_type) OVERRIDE; + + /** + * @brief Set the user preference for how a hybrid (cloud and mobile) app + * should be used + * @param hybrid_app_preference Hybrid app user preference + */ + void SetHybridAppPreference( + const std::string& policy_app_id, + const std::string& hybrid_app_preference) OVERRIDE; + /** * @brief OnAppRegisteredOnMobile allows to handle event when application were * succesfully registered on mobile device. diff --git a/src/components/policy/policy_regular/include/policy/policy_table/enums.h b/src/components/policy/policy_regular/include/policy/policy_table/enums.h index f398e16020..fce6b7b865 100644 --- a/src/components/policy/policy_regular/include/policy/policy_table/enums.h +++ b/src/components/policy/policy_regular/include/policy/policy_table/enums.h @@ -168,6 +168,12 @@ bool IsValidEnum(ModuleType val); const char* EnumToJsonString(ModuleType val); bool EnumFromJsonString(const std::string& literal, ModuleType* result); +enum HybridAppPreference { HAP_MOBILE, HAP_CLOUD, HAP_BOTH }; +bool IsValidEnum(HybridAppPreference val); +const char* EnumToJsonString(HybridAppPreference val); +bool EnumFromJsonString(const std::string& literal, + HybridAppPreference* result); + /** * @brief Enumeration FunctionID. * diff --git a/src/components/policy/policy_regular/include/policy/policy_table/types.h b/src/components/policy/policy_regular/include/policy/policy_table/types.h index e201251745..58f07492c4 100644 --- a/src/components/policy/policy_regular/include/policy/policy_table/types.h +++ b/src/components/policy/policy_regular/include/policy/policy_table/types.h @@ -144,6 +144,12 @@ struct ApplicationParams : PolicyBase { Optional > heart_beat_timeout_ms; Optional > certificate; mutable Optional moduleType; + // Cloud application params + Optional > hybrid_app_preference; + Optional > endpoint; + Optional enabled; + Optional > auth_token; + Optional > cloud_transport_type; public: ApplicationParams(); diff --git a/src/components/policy/policy_regular/src/cache_manager.cc b/src/components/policy/policy_regular/src/cache_manager.cc index bd95fc8e7c..68e70c107d 100644 --- a/src/components/policy/policy_regular/src/cache_manager.cc +++ b/src/components/policy/policy_regular/src/cache_manager.cc @@ -682,6 +682,81 @@ const policy::VehicleInfo CacheManager::GetVehicleInfo() const { return vehicle_info; } +const bool CacheManager::GetCloudAppParameters( + const std::string& policy_app_id, + std::string& endpoint, + std::string& auth_token, + std::string& cloud_transport_type, + std::string& hybrid_app_preference) const { + const policy_table::ApplicationPolicies& policies = + pt_->policy_table.app_policies_section.apps; + policy_table::ApplicationPolicies::const_iterator policy_iter = + policies.find(policy_app_id); + if (policies.end() != policy_iter) { + auto app_policy = (*policy_iter).second; + endpoint = app_policy.endpoint.is_initialized() ? *app_policy.endpoint + : std::string(); + auth_token = app_policy.auth_token.is_initialized() ? *app_policy.auth_token + : std::string(); + cloud_transport_type = app_policy.cloud_transport_type.is_initialized() + ? *app_policy.cloud_transport_type + : std::string(); + hybrid_app_preference = + app_policy.hybrid_app_preference.is_initialized() + ? EnumToJsonString(*app_policy.hybrid_app_preference) + : std::string(); + return app_policy.enabled.is_initialized() && *app_policy.enabled; + } + return false; +} + +void CacheManager::SetCloudAppEnabled(const std::string& policy_app_id, + const bool enabled) { + policy_table::ApplicationPolicies& policies = + pt_->policy_table.app_policies_section.apps; + policy_table::ApplicationPolicies::iterator policy_iter = + policies.find(policy_app_id); + if (policies.end() != policy_iter) { + *(*policy_iter).second.enabled = enabled; + } +} + +void CacheManager::SetAppAuthToken(const std::string& policy_app_id, + const std::string& auth_token) { + policy_table::ApplicationPolicies& policies = + pt_->policy_table.app_policies_section.apps; + policy_table::ApplicationPolicies::iterator policy_iter = + policies.find(policy_app_id); + if (policies.end() != policy_iter) { + *(*policy_iter).second.auth_token = auth_token; + } +} + +void CacheManager::SetAppCloudTransportType( + const std::string& policy_app_id, const std::string& cloud_transport_type) { + policy_table::ApplicationPolicies& policies = + pt_->policy_table.app_policies_section.apps; + policy_table::ApplicationPolicies::iterator policy_iter = + policies.find(policy_app_id); + if (policies.end() != policy_iter) { + *(*policy_iter).second.cloud_transport_type = cloud_transport_type; + } +} + +void CacheManager::SetHybridAppPreference( + const std::string& policy_app_id, + const std::string& hybrid_app_preference) { + policy_table::HybridAppPreference value; + bool valid = EnumFromJsonString(hybrid_app_preference, &value); + policy_table::ApplicationPolicies& policies = + pt_->policy_table.app_policies_section.apps; + policy_table::ApplicationPolicies::iterator policy_iter = + policies.find(policy_app_id); + if (policies.end() != policy_iter && valid) { + *(*policy_iter).second.hybrid_app_preference = value; + } +} + std::vector CacheManager::GetUserFriendlyMsg( const std::vector& msg_codes, const std::string& language) { LOG4CXX_AUTO_TRACE(logger_); diff --git a/src/components/policy/policy_regular/src/policy_manager_impl.cc b/src/components/policy/policy_regular/src/policy_manager_impl.cc index 4985035629..9317708216 100644 --- a/src/components/policy/policy_regular/src/policy_manager_impl.cc +++ b/src/components/policy/policy_regular/src/policy_manager_impl.cc @@ -217,7 +217,7 @@ void FilterInvalidApplicationParameters( } app_params.AppHMIType->swap(valid_app_hmi_types); - // Filter RquestTypes array + // Filter RequestTypes array policy_table::RequestTypes valid_request_types; const policy_table::RequestTypes& request_types = *(app_params.RequestType); for (const auto& request_type : request_types) { @@ -544,6 +544,36 @@ const VehicleInfo PolicyManagerImpl::GetVehicleInfo() const { return cache_->GetVehicleInfo(); } +const bool PolicyManagerImpl::GetCloudAppParameters( + const std::string& policy_app_id, + std::string& endpoint, + std::string& auth_token, + std::string& cloud_transport_type, + std::string& hybrid_app_preference) const { + return cache_->GetCloudAppParameters(policy_app_id, endpoint, auth_token, cloud_transport_type, hybrid_app_preference); +} + +void PolicyManagerImpl::SetCloudAppEnabled( + const std::string& policy_app_id, const bool enabled) { + cache_->SetCloudAppEnabled(policy_app_id, enabled); +} + +void PolicyManagerImpl::SetAppAuthToken(const std::string& policy_app_id, + const std::string& auth_token) { + cache_->SetAppAuthToken(policy_app_id, auth_token); +} + +void PolicyManagerImpl::SetAppCloudTransportType( + const std::string& policy_app_id, const std::string& cloud_transport_type) { + cache_->SetAppCloudTransportType(policy_app_id, cloud_transport_type); +} + +void PolicyManagerImpl::SetHybridAppPreference( + const std::string& policy_app_id, + const std::string& hybrid_app_preference) { + cache_->SetHybridAppPreference(policy_app_id, hybrid_app_preference); +} + void PolicyManagerImpl::CheckPermissions(const PTString& device_id, const PTString& app_id, const PTString& hmi_level, diff --git a/src/components/policy/policy_regular/src/policy_table/enums.cc b/src/components/policy/policy_regular/src/policy_table/enums.cc index bec9a2ec2d..2ddf74af7e 100644 --- a/src/components/policy/policy_regular/src/policy_table/enums.cc +++ b/src/components/policy/policy_regular/src/policy_table/enums.cc @@ -1,5 +1,5 @@ -// This file is generated, do not edit #include "policy/policy_table/enums.h" +#include namespace rpc { namespace policy_table_interface_base { @@ -669,6 +669,7 @@ bool IsValidEnum(ModuleType val) { return false; } } + const char* EnumToJsonString(ModuleType val) { switch (val) { case MT_CLIMATE: @@ -716,6 +717,38 @@ bool EnumFromJsonString(const std::string& literal, ModuleType* result) { return false; } +bool IsValidEnum(HybridAppPreference val) { + return strlen(EnumToJsonString(val)) > 0; +} + +const char* EnumToJsonString(HybridAppPreference val) { + switch (val) { + case HAP_MOBILE: + return "MOBILE"; + case HAP_CLOUD: + return "CLOUD"; + case HAP_BOTH: + return "BOTH"; + default: + return ""; + } +} + +bool EnumFromJsonString(const std::string& literal, + HybridAppPreference* result) { + if ("MOBILE" == literal) { + *result = HAP_MOBILE; + return true; + } else if ("CLOUD" == literal) { + *result = HAP_CLOUD; + return true; + } else if ("BOTH" == literal) { + *result = HAP_BOTH; + return true; + } + return false; +} + bool IsValidEnum(FunctionID val) { switch (val) { case RegisterAppInterfaceID: diff --git a/src/components/policy/policy_regular/src/policy_table/types.cc b/src/components/policy/policy_regular/src/policy_table/types.cc index 851ed1bd18..88564df050 100644 --- a/src/components/policy/policy_regular/src/policy_table/types.cc +++ b/src/components/policy/policy_regular/src/policy_table/types.cc @@ -168,7 +168,13 @@ ApplicationParams::ApplicationParams(const Json::Value* value__) , memory_kb(impl::ValueMember(value__, "memory_kb"), 0) , heart_beat_timeout_ms(impl::ValueMember(value__, "heart_beat_timeout_ms")) , certificate(impl::ValueMember(value__, "certificate"), "not_specified") - , moduleType(impl::ValueMember(value__, "moduleType")) {} + , moduleType(impl::ValueMember(value__, "moduleType")) + , hybrid_app_preference(impl::ValueMember(value__, "hybrid_app_preference")) + , endpoint(impl::ValueMember(value__, "endpoint")) + , enabled(impl::ValueMember(value__, "enabled")) + , auth_token(impl::ValueMember(value__, "auth_token")) + , cloud_transport_type(impl::ValueMember(value__, "cloud_transport_type")) { +} Json::Value ApplicationParams::ToJsonValue() const { Json::Value result__(PolicyBase::ToJsonValue()); @@ -180,7 +186,14 @@ Json::Value ApplicationParams::ToJsonValue() const { impl::WriteJsonField("memory_kb", memory_kb, &result__); impl::WriteJsonField( "heart_beat_timeout_ms", heart_beat_timeout_ms, &result__); + impl::WriteJsonField("certificate", certificate, &result__); impl::WriteJsonField("moduleType", moduleType, &result__); + impl::WriteJsonField( + "hybrid_app_preference", hybrid_app_preference, &result__); + impl::WriteJsonField("endpoint", endpoint, &result__); + impl::WriteJsonField("enabled", enabled, &result__); + impl::WriteJsonField("auth_token", auth_token, &result__); + impl::WriteJsonField("cloud_transport_type", cloud_transport_type, &result__); return result__; } @@ -212,6 +225,21 @@ bool ApplicationParams::is_valid() const { if (!moduleType.is_valid()) { return false; } + if (!endpoint.is_valid()) { + return false; + } + if (!enabled.is_valid()) { + return false; + } + if (!auth_token.is_valid()) { + return false; + } + if (!cloud_transport_type.is_valid()) { + return false; + } + if (!hybrid_app_preference.is_valid()) { + return false; + } return Validate(); } @@ -250,6 +278,21 @@ bool ApplicationParams::struct_empty() const { if (moduleType.is_initialized()) { return false; } + if (endpoint.is_initialized()) { + return false; + } + if (enabled.is_initialized()) { + return false; + } + if (auth_token.is_initialized()) { + return false; + } + if (cloud_transport_type.is_initialized()) { + return false; + } + if (hybrid_app_preference.is_initialized()) { + return false; + } return true; } @@ -288,6 +331,22 @@ void ApplicationParams::ReportErrors(rpc::ValidationReport* report__) const { if (!moduleType.is_valid()) { moduleType.ReportErrors(&report__->ReportSubobject("moduleType")); } + if (!endpoint.is_valid()) { + moduleType.ReportErrors(&report__->ReportSubobject("endpoint")); + } + if (!enabled.is_valid()) { + moduleType.ReportErrors(&report__->ReportSubobject("enabled")); + } + if (!auth_token.is_valid()) { + moduleType.ReportErrors(&report__->ReportSubobject("auth_token")); + } + if (!cloud_transport_type.is_valid()) { + moduleType.ReportErrors(&report__->ReportSubobject("cloud_transport_type")); + } + if (!hybrid_app_preference.is_valid()) { + moduleType.ReportErrors( + &report__->ReportSubobject("hybrid_app_preference")); + } } void ApplicationParams::SetPolicyTableType(PolicyTableType pt_type) { @@ -300,6 +359,10 @@ void ApplicationParams::SetPolicyTableType(PolicyTableType pt_type) { heart_beat_timeout_ms.SetPolicyTableType(pt_type); certificate.SetPolicyTableType(pt_type); moduleType.SetPolicyTableType(pt_type); + endpoint.SetPolicyTableType(pt_type); + enabled.SetPolicyTableType(pt_type); + cloud_transport_type.SetPolicyTableType(pt_type); + hybrid_app_preference.SetPolicyTableType(pt_type); } // RpcParameters methods diff --git a/src/components/policy/policy_regular/src/sql_pt_queries.cc b/src/components/policy/policy_regular/src/sql_pt_queries.cc index f5ccffce3b..ef6c7f2a03 100644 --- a/src/components/policy/policy_regular/src/sql_pt_queries.cc +++ b/src/components/policy/policy_regular/src/sql_pt_queries.cc @@ -84,6 +84,9 @@ const std::string kCreateSchema = "CREATE TABLE IF NOT EXISTS `hmi_level`( " " `value` VARCHAR(45) PRIMARY KEY NOT NULL " "); " + "CREATE TABLE IF NOT EXISTS `hybrid_app_preference`( " + " `value` VARCHAR(45) PRIMARY KEY NOT NULL " + "); " "CREATE TABLE IF NOT EXISTS `notifications_by_priority`( " " `priority_value` VARCHAR(45) PRIMARY KEY NOT NULL, " " `value` INTEGER NOT NULL, " @@ -133,7 +136,12 @@ const std::string kCreateSchema = " `is_predata` BOOLEAN, " " `memory_kb` INTEGER NOT NULL, " " `heart_beat_timeout_ms` INTEGER NOT NULL, " - " `certificate` VARCHAR(45), " + " `certificate` VARCHAR(65535), " + " `hybrid_app_preference_value` VARCHAR(255), " + " `endpoint` VARCHAR(255), " + " `enabled` BOOLEAN, " + " `auth_token` VARCHAR(65535), " + " `cloud_transport_type` VARCHAR(255), " " `remote_control_denied` BOOLEAN NOT NULL DEFAULT 0, " " CONSTRAINT `fk_application_hmi_level1` " " FOREIGN KEY(`default_hmi`) " @@ -141,11 +149,17 @@ const std::string kCreateSchema = " CONSTRAINT `fk_application_priorities1` " " FOREIGN KEY(`priority_value`) " " REFERENCES `priority`(`value`) " + " CONSTRAINT `fk_application_hybrid_app_preference1` " + " FOREIGN KEY(`hybrid_app_preference_value`) " + " REFERENCES `hybrid_app_preference`(`value`) " "); " "CREATE INDEX IF NOT EXISTS `application.fk_application_hmi_level1_idx` " " ON `application`(`default_hmi`); " "CREATE INDEX IF NOT EXISTS `application.fk_application_priorities1_idx` " " ON `application`(`priority_value`); " + "CREATE INDEX IF NOT EXISTS " + "`application.fk_application_hybrid_app_preference1` " + " ON `application`(`hybrid_app_preference_value`); " "CREATE TABLE IF NOT EXISTS `app_group`( " " `application_id` VARCHAR(45) NOT NULL COLLATE NOCASE, " " `functional_group_id` INTEGER NOT NULL, " @@ -391,6 +405,9 @@ const std::string kInsertInitData = "INSERT OR IGNORE INTO `hmi_level`(`value`) VALUES ('LIMITED'); " "INSERT OR IGNORE INTO `hmi_level`(`value`) VALUES ('BACKGROUND'); " "INSERT OR IGNORE INTO `hmi_level`(`value`) VALUES ('NONE'); " + "INSERT OR IGNORE INTO `hybrid_app_preference`(`value`) VALUES ('MOBILE'); " + "INSERT OR IGNORE INTO `hybrid_app_preference`(`value`) VALUES ('CLOUD'); " + "INSERT OR IGNORE INTO `hybrid_app_preference`(`value`) VALUES ('BOTH'); " "INSERT OR IGNORE INTO `version` (`number`) VALUES('0'); " "INSERT OR IGNORE INTO `_internal_data` (`db_version_hash`) VALUES(0); " ""; @@ -491,6 +508,7 @@ const std::string kDropSchema = "`notifications_by_priority.fk_notifications_by_priority_priority1_idx`; " "DROP TABLE IF EXISTS `notifications_by_priority`; " "DROP TABLE IF EXISTS `hmi_level`; " + "DROP TABLE IF EXISTS `hybrid_app_preference`; " "DROP TABLE IF EXISTS `priority`; " "DROP TABLE IF EXISTS `functional_group`; " "DROP TABLE IF EXISTS `module_config`; " @@ -578,8 +596,10 @@ const std::string kInsertRpcWithParameter = const std::string kInsertApplication = "INSERT OR IGNORE INTO `application` (`id`, `priority_value`, " - "`is_revoked`, `memory_kb`," - " `heart_beat_timeout_ms`, `certificate`) VALUES (?,?,?,?,?,?)"; + "`is_revoked`, `memory_kb`, `heart_beat_timeout_ms`, `certificate`, " + "`hybrid_app_preference_value`, `endpoint`, `enabled`, `auth_token`, " + "`cloud_transport_type`) VALUES " + "(?,?,?,?,?,?,?,?,?,?,?)"; const std::string kInsertAppGroup = "INSERT INTO `app_group` (`application_id`, `functional_group_id`)" @@ -688,7 +708,8 @@ const std::string kSelectUserMsgsVersion = const std::string kSelectAppPolicies = "SELECT `id`, `priority_value`, `memory_kb`, " - " `heart_beat_timeout_ms`, `certificate` FROM `application`"; + " `heart_beat_timeout_ms`, `certificate`, `hybrid_app_preference_value`, " + " `endpoint`, `enabled`, `cloud_transport_type` FROM `application`"; const std::string kCollectFriendlyMsg = "SELECT * FROM `message`"; @@ -785,15 +806,19 @@ const std::string kDeleteAppGroupByApplicationId = const std::string kInsertApplicationFull = "INSERT OR IGNORE INTO `application` (`id`, `keep_context`, `steal_focus`, " - " `default_hmi`, `priority_value`, `is_revoked`, `is_default`, " - "`is_predata`, " - " `memory_kb`, `heart_beat_timeout_ms`, `certificate`) " - " VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"; + " `default_hmi`, `priority_value`, `is_revoked`, `is_default`, " + " `is_predata`, `memory_kb`, `heart_beat_timeout_ms`, " + " `certificate`, `hybrid_app_preference_value`, `endpoint`, `enabled`, " + " `auth_token`, `cloud_transport_type`) " + " VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"; const std::string kSelectApplicationFull = "SELECT `keep_context`, `steal_focus`, `default_hmi`, `priority_value`, " " `is_revoked`, `is_default`, `is_predata`, `memory_kb`," - " `heart_beat_timeout_ms`, `certificate` FROM `application` WHERE `id` = " + " `heart_beat_timeout_ms`, `certificate`, `hybrid_app_preference_value`, " + " `endpoint`, `enabled`, `auth_token`, `cloud_transport_type` " + "FROM `application` " + "WHERE `id` = " "?"; const std::string kSelectDBVersion = diff --git a/src/components/policy/policy_regular/src/sql_pt_representation.cc b/src/components/policy/policy_regular/src/sql_pt_representation.cc index 75f8be74eb..9282caf535 100644 --- a/src/components/policy/policy_regular/src/sql_pt_representation.cc +++ b/src/components/policy/policy_regular/src/sql_pt_representation.cc @@ -716,12 +716,24 @@ bool SQLPTRepresentation::GatherApplicationPoliciesSection( params.priority = priority; *params.memory_kb = query.GetInteger(2); - *params.heart_beat_timeout_ms = query.GetUInteger(3); - if (!query.IsNull(3)) { + if (!query.IsNull(4)) { *params.certificate = query.GetString(4); } + // Read cloud app properties + policy_table::HybridAppPreference hap; + bool valid = policy_table::EnumFromJsonString(query.GetString(5), &hap); + if (valid) { + *params.hybrid_app_preference = hap; + } + *params.endpoint = query.GetString(6); + if (!query.IsNull(7)) { + *params.enabled = query.GetBoolean(7); + } + *params.auth_token = query.GetString(8); + *params.cloud_transport_type = query.GetString(9); + const auto& gather_app_id = ((*policies).apps[app_id].is_string()) ? (*policies).apps[app_id].get_string() : app_id; @@ -984,6 +996,22 @@ bool SQLPTRepresentation::SaveSpecificAppPolicy( app.second.certificate.is_initialized() ? app_query.Bind(5, *app.second.certificate) : app_query.Bind(5); + app.second.hybrid_app_preference.is_initialized() + ? app_query.Bind(6, + std::string(policy_table::EnumToJsonString( + *app.second.hybrid_app_preference))) + : app_query.Bind(6); + app.second.endpoint.is_initialized() ? app_query.Bind(7, *app.second.endpoint) + : app_query.Bind(7); + app.second.enabled.is_initialized() ? app_query.Bind(8, *app.second.enabled) + : app_query.Bind(8); + app.second.auth_token.is_initialized() + ? app_query.Bind(9, *app.second.auth_token) + : app_query.Bind(9); + app.second.cloud_transport_type.is_initialized() + ? app_query.Bind(10, *app.second.cloud_transport_type) + : app_query.Bind(10); + if (!app_query.Exec() || !app_query.Reset()) { LOG4CXX_WARN(logger_, "Incorrect insert into application."); return false; @@ -2084,6 +2112,17 @@ bool SQLPTRepresentation::CopyApplication(const std::string& source, query.Bind(9, source_app.GetInteger(8)); source_app.IsNull(9) ? query.Bind(10) : query.Bind(10, source_app.GetString(9)); + source_app.IsNull(10) ? query.Bind(11) + : query.Bind(11, source_app.GetString(10)); + source_app.IsNull(11) ? query.Bind(12) + : query.Bind(12, source_app.GetString(11)); + source_app.IsNull(12) ? query.Bind(13) + : query.Bind(13, source_app.GetBoolean(12)); + source_app.IsNull(13) ? query.Bind(14) + : query.Bind(14, source_app.GetString(13)); + source_app.IsNull(14) ? query.Bind(15) + : query.Bind(15, source_app.GetString(14)); + if (!query.Exec()) { LOG4CXX_WARN(logger_, "Failed inserting into application."); return false; diff --git a/src/components/policy/policy_regular/test/sql_pt_representation_test.cc b/src/components/policy/policy_regular/test/sql_pt_representation_test.cc index 7d192515dc..030dc374dd 100644 --- a/src/components/policy/policy_regular/test/sql_pt_representation_test.cc +++ b/src/components/policy/policy_regular/test/sql_pt_representation_test.cc @@ -426,8 +426,8 @@ TEST_F(SQLPTRepresentationTest, ASSERT_TRUE(reps->RefreshDB()); // Check PT structure destroyed and tables number is 0 - // There are 29 tables in the database, now. - const int32_t total_tables_number = 29; + // There are 30 tables in the database, now. + const int32_t total_tables_number = 30; ASSERT_EQ(total_tables_number, dbms->FetchOneInt(query_select)); const char* query_select_count_of_iap_buffer_full = "SELECT `count_of_iap_buffer_full` FROM `usage_and_error_count`"; -- cgit v1.2.1 From e2c2bf8f584aeaed25c4f9b56237537a00b3575b Mon Sep 17 00:00:00 2001 From: jacobkeeler Date: Fri, 2 Nov 2018 14:20:45 -0400 Subject: Add cloud app parameters to external policies --- .../policy/policy_external/policy/policy_manager.h | 52 +++++++++++++++ .../policy_external/policy/mock_cache_manager.h | 17 +++++ .../policy_external/policy/mock_policy_manager.h | 17 +++++ .../policy_external/include/policy/cache_manager.h | 51 +++++++++++++++ .../include/policy/cache_manager_interface.h | 52 +++++++++++++++ .../include/policy/policy_manager_impl.h | 52 +++++++++++++++ .../include/policy/policy_table/enums.h | 10 +++ .../include/policy/policy_table/types.h | 7 ++ .../include/policy/policy_table_interface_ext.xml | 15 ++++- .../policy/policy_external/src/cache_manager.cc | 75 ++++++++++++++++++++++ .../policy_external/src/policy_manager_impl.cc | 34 ++++++++++ .../policy_external/src/policy_table/enums.cc | 33 ++++++++++ .../policy_external/src/policy_table/types.cc | 75 +++++++++++++++++++++- .../policy_external/src/sql_pt_ext_queries.cc | 10 ++- .../src/sql_pt_ext_representation.cc | 34 ++++++++++ .../policy/policy_external/src/sql_pt_queries.cc | 42 +++++++++--- .../policy_external/src/sql_pt_representation.cc | 47 ++++++++++++++ .../test/sql_pt_representation_test.cc | 4 +- 18 files changed, 612 insertions(+), 15 deletions(-) diff --git a/src/components/include/policy/policy_external/policy/policy_manager.h b/src/components/include/policy/policy_external/policy/policy_manager.h index 57f6d2f802..2ea8ef08f1 100644 --- a/src/components/include/policy/policy_external/policy/policy_manager.h +++ b/src/components/include/policy/policy_external/policy/policy_manager.h @@ -521,6 +521,58 @@ class PolicyManager : public usage_statistics::StatisticsManager { * @return vehicle information */ virtual const VehicleInfo GetVehicleInfo() const = 0; + + /** + * @brief Get cloud app policy information, all fields that aren't set for a + * given app will be filled with empty strings + * @param policy_app_id Unique application id + * @param endpoint Filled the endpoint used to connect to the cloud + * application + * @param auth_token Filled with the token used for authentication when + * reconnecting to the cloud app + * @param cloud_transport_type Filled with the transport type used by the + * cloud application (ex. "WSS") + * @param cloud_transport_type Filled with the hybrid app preference for the + * cloud application set by the user + * @return true if the cloud app is enabled, false otherwise + */ + virtual const bool GetCloudAppParameters( + const std::string& policy_app_id, + std::string& endpoint, + std::string& auth_token, + std::string& cloud_transport_type, + std::string& hybrid_app_preference) const = 0; + + /** + * @brief Enable or disable a cloud application in the HMI + * @param enabled Cloud app enabled state + */ + virtual void SetCloudAppEnabled(const std::string& policy_app_id, + const bool enabled) = 0; + + /** + * @brief Set an app's auth token + * @param auth_token Cloud app authentication token + */ + virtual void SetAppAuthToken(const std::string& policy_app_id, + const std::string& auth_token) = 0; + + /** + * @brief Set a cloud app's transport type + * @param cloud_transport_type Cloud app transport type + */ + virtual void SetAppCloudTransportType( + const std::string& policy_app_id, + const std::string& cloud_transport_type) = 0; + + /** + * @brief Set the user preference for how a hybrid (cloud and mobile) app + * should be used + * @param hybrid_app_preference Hybrid app user preference + */ + virtual void SetHybridAppPreference( + const std::string& policy_app_id, + const std::string& hybrid_app_preference) = 0; /** * @brief Gets meta information diff --git a/src/components/include/test/policy/policy_external/policy/mock_cache_manager.h b/src/components/include/test/policy/policy_external/policy/mock_cache_manager.h index a4d50d7cc2..ecbd8c6cd6 100644 --- a/src/components/include/test/policy/policy_external/policy/mock_cache_manager.h +++ b/src/components/include/test/policy/policy_external/policy/mock_cache_manager.h @@ -76,6 +76,23 @@ class MockCacheManagerInterface : public ::policy::CacheManagerInterface { MOCK_METHOD1(SecondsBetweenRetries, bool(std::vector& seconds)); MOCK_CONST_METHOD1(IsDeviceConsentCached, bool(const std::string& device_id)); MOCK_CONST_METHOD0(GetVehicleInfo, const VehicleInfo()); + MOCK_CONST_METHOD5(GetCloudAppParameters, + const bool(const std::string& policy_app_id, + std::string& endpoint, + std::string& auth_token, + std::string& cloud_transport_type, + std::string& hybrid_app_preference)); + MOCK_METHOD2(SetCloudAppEnabled, + void(const std::string& policy_app_id, const bool enabled)); + MOCK_METHOD2(SetAppAuthToken, + void(const std::string& policy_app_id, + const std::string& auth_token)); + MOCK_METHOD2(SetAppCloudTransportType, + void(const std::string& policy_app_id, + const std::string& cloud_transport_type)); + MOCK_METHOD2(SetHybridAppPreference, + void(const std::string& policy_app_id, + const std::string& hybrid_app_preference)); MOCK_CONST_METHOD1(GetDeviceConsent, DeviceConsent(const std::string& device_id)); MOCK_METHOD2(SetDeviceConsent, diff --git a/src/components/include/test/policy/policy_external/policy/mock_policy_manager.h b/src/components/include/test/policy/policy_external/policy/mock_policy_manager.h index aeabf8fdcb..f58ed10934 100644 --- a/src/components/include/test/policy/policy_external/policy/mock_policy_manager.h +++ b/src/components/include/test/policy/policy_external/policy/mock_policy_manager.h @@ -184,6 +184,23 @@ class MockPolicyManager : public PolicyManager { GetAppRequestTypes, const std::vector(const std::string policy_app_id)); MOCK_CONST_METHOD0(GetVehicleInfo, const policy::VehicleInfo()); + MOCK_CONST_METHOD5(GetCloudAppParameters, + const bool(const std::string& policy_app_id, + std::string& endpoint, + std::string& auth_token, + std::string& cloud_transport_type, + std::string& hybrid_app_preference)); + MOCK_METHOD2(SetCloudAppEnabled, + void(const std::string& policy_app_id, const bool enabled)); + MOCK_METHOD2(SetAppAuthToken, + void(const std::string& policy_app_id, + const std::string& auth_token)); + MOCK_METHOD2(SetAppCloudTransportType, + void(const std::string& policy_app_id, + const std::string& cloud_transport_type)); + MOCK_METHOD2(SetHybridAppPreference, + void(const std::string& policy_app_id, + const std::string& hybrid_app_preference)); MOCK_CONST_METHOD0(GetMetaInfo, const policy::MetaInfo()); MOCK_CONST_METHOD0(RetrieveCertificate, std::string()); MOCK_CONST_METHOD0(HasCertificate, bool()); diff --git a/src/components/policy/policy_external/include/policy/cache_manager.h b/src/components/policy/policy_external/include/policy/cache_manager.h index d30e7cea24..d6eeb0457b 100644 --- a/src/components/policy/policy_external/include/policy/cache_manager.h +++ b/src/components/policy/policy_external/include/policy/cache_manager.h @@ -158,6 +158,57 @@ class CacheManager : public CacheManagerInterface { */ virtual const VehicleInfo GetVehicleInfo() const; + /** + * @brief Get cloud app policy information, all fields that aren't set for a + * given app will be filled with empty strings + * @param policy_app_id Unique application id + * @param endpoint Filled the endpoint used to connect to the cloud + * application + * @param auth_token Filled with the token used for authentication when + * reconnecting to the cloud app + * @param cloud_transport_type Filled with the transport type used by the + * cloud application (ex. "WSS") + * @param cloud_transport_type Filled with the hybrid app preference for the + * cloud application set by the user + * @return true if the cloud app is enabled, false otherwise + */ + virtual const bool GetCloudAppParameters( + const std::string& policy_app_id, + std::string& endpoint, + std::string& auth_token, + std::string& cloud_transport_type, + std::string& hybrid_app_preference) const; + + /** + * @brief Enable or disable a cloud application in the HMI + * @param enabled Cloud app enabled state + */ + virtual void SetCloudAppEnabled(const std::string& policy_app_id, + const bool enabled); + + /** + * @brief Set an app's auth token + * @param auth_token Cloud app authentication token + */ + virtual void SetAppAuthToken(const std::string& policy_app_id, + const std::string& auth_token); + + /** + * @brief Set a cloud app's transport type + * @param cloud_transport_type Cloud app transport type + */ + virtual void SetAppCloudTransportType( + const std::string& policy_app_id, + const std::string& cloud_transport_type); + + /** + * @brief Set the user preference for how a hybrid (cloud and mobile) app + * should be used + * @param hybrid_app_preference Hybrid app user preference + */ + virtual void SetHybridAppPreference(const std::string& policy_app_id, + const std::string& hybrid_app_preference); + /** * @brief Allows to update 'vin' field in module_meta table. * diff --git a/src/components/policy/policy_external/include/policy/cache_manager_interface.h b/src/components/policy/policy_external/include/policy/cache_manager_interface.h index bb9ce14c7f..0c094d2edb 100644 --- a/src/components/policy/policy_external/include/policy/cache_manager_interface.h +++ b/src/components/policy/policy_external/include/policy/cache_manager_interface.h @@ -165,6 +165,58 @@ class CacheManagerInterface { */ virtual const VehicleInfo GetVehicleInfo() const = 0; + /** + * @brief Get cloud app policy information, all fields that aren't set for a + * given app will be filled with empty strings + * @param policy_app_id Unique application id + * @param endpoint Filled the endpoint used to connect to the cloud + * application + * @param auth_token Filled with the token used for authentication when + * reconnecting to the cloud app + * @param cloud_transport_type Filled with the transport type used by the + * cloud application (ex. "WSS") + * @param cloud_transport_type Filled with the hybrid app preference for the + * cloud application set by the user + * @return true if the cloud app is enabled, false otherwise + */ + virtual const bool GetCloudAppParameters( + const std::string& policy_app_id, + std::string& endpoint, + std::string& auth_token, + std::string& cloud_transport_type, + std::string& hybrid_app_preference) const = 0; + + /** + * @brief Enable or disable a cloud application in the HMI + * @param enabled Cloud app enabled state + */ + virtual void SetCloudAppEnabled(const std::string& policy_app_id, + const bool enabled) = 0; + + /** + * @brief Set an app's auth token + * @param auth_token Cloud app authentication token + */ + virtual void SetAppAuthToken(const std::string& policy_app_id, + const std::string& auth_token) = 0; + + /** + * @brief Set a cloud app's transport type + * @param cloud_transport_type Cloud app transport type + */ + virtual void SetAppCloudTransportType( + const std::string& policy_app_id, + const std::string& cloud_transport_type) = 0; + + /** + * @brief Set the user preference for how a hybrid (cloud and mobile) app + * should be used + * @param hybrid_app_preference Hybrid app user preference + */ + virtual void SetHybridAppPreference( + const std::string& policy_app_id, + const std::string& hybrid_app_preference) = 0; + /** * @brief Allows to update 'vin' field in module_meta table. * diff --git a/src/components/policy/policy_external/include/policy/policy_manager_impl.h b/src/components/policy/policy_external/include/policy/policy_manager_impl.h index 3837dda1fa..f9648f803c 100644 --- a/src/components/policy/policy_external/include/policy/policy_manager_impl.h +++ b/src/components/policy/policy_external/include/policy/policy_manager_impl.h @@ -569,6 +569,58 @@ class PolicyManagerImpl : public PolicyManager { * @return vehicle information */ const VehicleInfo GetVehicleInfo() const OVERRIDE; + + /** + * @brief Get cloud app policy information, all fields that aren't set for a + * given app will be filled with empty strings + * @param policy_app_id Unique application id + * @param endpoint Filled the endpoint used to connect to the cloud + * application + * @param auth_token Filled with the token used for authentication when + * reconnecting to the cloud app + * @param cloud_transport_type Filled with the transport type used by the + * cloud application (ex. "WSS") + * @param cloud_transport_type Filled with the hybrid app preference for the + * cloud application set by the user + * @return true if the cloud app is enabled, false otherwise + */ + const bool GetCloudAppParameters( + const std::string& policy_app_id, + std::string& endpoint, + std::string& auth_token, + std::string& cloud_transport_type, + std::string& hybrid_app_preference) const OVERRIDE; + + /** + * @brief Enable or disable a cloud application in the HMI + * @param enabled Cloud app enabled state + */ + void SetCloudAppEnabled(const std::string& policy_app_id, + const bool enabled) OVERRIDE; + + /** + * @brief Set an app's auth token + * @param auth_token Cloud app authentication token + */ + void SetAppAuthToken(const std::string& policy_app_id, + const std::string& auth_token) OVERRIDE; + + /** + * @brief Set a cloud app's transport type + * @param cloud_transport_type Cloud app transport type + */ + void SetAppCloudTransportType( + const std::string& policy_app_id, + const std::string& cloud_transport_type) OVERRIDE; + + /** + * @brief Set the user preference for how a hybrid (cloud and mobile) app + * should be used + * @param hybrid_app_preference Hybrid app user preference + */ + void SetHybridAppPreference( + const std::string& policy_app_id, + const std::string& hybrid_app_preference) OVERRIDE; /** * @brief OnAppRegisteredOnMobile allows to handle event when application were diff --git a/src/components/policy/policy_external/include/policy/policy_table/enums.h b/src/components/policy/policy_external/include/policy/policy_table/enums.h index e9d5319f13..b13e6b6f26 100644 --- a/src/components/policy/policy_external/include/policy/policy_table/enums.h +++ b/src/components/policy/policy_external/include/policy/policy_table/enums.h @@ -182,6 +182,16 @@ bool IsValidEnum(ModuleType val); const char* EnumToJsonString(ModuleType val); bool EnumFromJsonString(const std::string& literal, ModuleType* result); +enum HybridAppPreference { + HAP_MOBILE, + HAP_CLOUD, + HAP_BOTH +}; +bool IsValidEnum(HybridAppPreference val); +const char* EnumToJsonString(HybridAppPreference val); +bool EnumFromJsonString(const std::string& literal, + HybridAppPreference* result); + /** * @brief Enumeration FunctionID. * diff --git a/src/components/policy/policy_external/include/policy/policy_table/types.h b/src/components/policy/policy_external/include/policy/policy_table/types.h index 68e29a97ee..f37531eb63 100644 --- a/src/components/policy/policy_external/include/policy/policy_table/types.h +++ b/src/components/policy/policy_external/include/policy/policy_table/types.h @@ -177,6 +177,13 @@ struct ApplicationParams : PolicyBase { Optional > memory_kb; Optional > heart_beat_timeout_ms; mutable Optional moduleType; + Optional > certificate; + // Cloud application params + Optional > hybrid_app_preference; + Optional > endpoint; + Optional enabled; + Optional > auth_token; + Optional > cloud_transport_type; public: ApplicationParams(); diff --git a/src/components/policy/policy_external/include/policy/policy_table_interface_ext.xml b/src/components/policy/policy_external/include/policy/policy_table_interface_ext.xml index 0389986695..5ed852cf45 100644 --- a/src/components/policy/policy_external/include/policy/policy_table_interface_ext.xml +++ b/src/components/policy/policy_external/include/policy/policy_table_interface_ext.xml @@ -71,6 +71,12 @@ + + + + + + @@ -93,8 +99,15 @@ - + + + + + policy_table.app_policies_section.apps; + policy_table::ApplicationPolicies::const_iterator policy_iter = + policies.find(policy_app_id); + if (policies.end() != policy_iter) { + auto app_policy = (*policy_iter).second; + endpoint = app_policy.endpoint.is_initialized() ? *app_policy.endpoint + : std::string(); + auth_token = app_policy.auth_token.is_initialized() ? *app_policy.auth_token + : std::string(); + cloud_transport_type = app_policy.cloud_transport_type.is_initialized() + ? *app_policy.cloud_transport_type + : std::string(); + hybrid_app_preference = + app_policy.hybrid_app_preference.is_initialized() + ? EnumToJsonString(*app_policy.hybrid_app_preference) + : std::string(); + return app_policy.enabled.is_initialized() && *app_policy.enabled; + } + return false; +} + +void CacheManager::SetCloudAppEnabled(const std::string& policy_app_id, + const bool enabled) { + policy_table::ApplicationPolicies& policies = + pt_->policy_table.app_policies_section.apps; + policy_table::ApplicationPolicies::iterator policy_iter = + policies.find(policy_app_id); + if (policies.end() != policy_iter) { + *(*policy_iter).second.enabled = enabled; + } +} + +void CacheManager::SetAppAuthToken(const std::string& policy_app_id, + const std::string& auth_token) { + policy_table::ApplicationPolicies& policies = + pt_->policy_table.app_policies_section.apps; + policy_table::ApplicationPolicies::iterator policy_iter = + policies.find(policy_app_id); + if (policies.end() != policy_iter) { + *(*policy_iter).second.auth_token = auth_token; + } +} + +void CacheManager::SetAppCloudTransportType( + const std::string& policy_app_id, const std::string& cloud_transport_type) { + policy_table::ApplicationPolicies& policies = + pt_->policy_table.app_policies_section.apps; + policy_table::ApplicationPolicies::iterator policy_iter = + policies.find(policy_app_id); + if (policies.end() != policy_iter) { + *(*policy_iter).second.cloud_transport_type = cloud_transport_type; + } +} + +void CacheManager::SetHybridAppPreference( + const std::string& policy_app_id, + const std::string& hybrid_app_preference) { + policy_table::HybridAppPreference value; + bool valid = EnumFromJsonString(hybrid_app_preference, &value); + policy_table::ApplicationPolicies& policies = + pt_->policy_table.app_policies_section.apps; + policy_table::ApplicationPolicies::iterator policy_iter = + policies.find(policy_app_id); + if (policies.end() != policy_iter && valid) { + *(*policy_iter).second.hybrid_app_preference = value; + } +} + std::vector CacheManager::GetUserFriendlyMsg( const std::vector& msg_codes, const std::string& language, diff --git a/src/components/policy/policy_external/src/policy_manager_impl.cc b/src/components/policy/policy_external/src/policy_manager_impl.cc index a603f122e2..e7538fa1b0 100644 --- a/src/components/policy/policy_external/src/policy_manager_impl.cc +++ b/src/components/policy/policy_external/src/policy_manager_impl.cc @@ -725,6 +725,40 @@ const VehicleInfo PolicyManagerImpl::GetVehicleInfo() const { return cache_->GetVehicleInfo(); } +const bool PolicyManagerImpl::GetCloudAppParameters( + const std::string& policy_app_id, + std::string& endpoint, + std::string& auth_token, + std::string& cloud_transport_type, + std::string& hybrid_app_preference) const { + return cache_->GetCloudAppParameters(policy_app_id, + endpoint, + auth_token, + cloud_transport_type, + hybrid_app_preference); +} + +void PolicyManagerImpl::SetCloudAppEnabled(const std::string& policy_app_id, + const bool enabled) { + cache_->SetCloudAppEnabled(policy_app_id, enabled); +} + +void PolicyManagerImpl::SetAppAuthToken(const std::string& policy_app_id, + const std::string& auth_token) { + cache_->SetAppAuthToken(policy_app_id, auth_token); +} + +void PolicyManagerImpl::SetAppCloudTransportType( + const std::string& policy_app_id, const std::string& cloud_transport_type) { + cache_->SetAppCloudTransportType(policy_app_id, cloud_transport_type); +} + +void PolicyManagerImpl::SetHybridAppPreference( + const std::string& policy_app_id, + const std::string& hybrid_app_preference) { + cache_->SetHybridAppPreference(policy_app_id, hybrid_app_preference); +} + void PolicyManagerImpl::CheckPermissions(const PTString& app_id, const PTString& hmi_level, const PTString& rpc, diff --git a/src/components/policy/policy_external/src/policy_table/enums.cc b/src/components/policy/policy_external/src/policy_table/enums.cc index 29227adfc6..48ce4d4f72 100644 --- a/src/components/policy/policy_external/src/policy_table/enums.cc +++ b/src/components/policy/policy_external/src/policy_table/enums.cc @@ -1,4 +1,5 @@ #include "policy/policy_table/enums.h" +#include namespace rpc { namespace policy_table_interface_base { @@ -847,6 +848,38 @@ bool EnumFromJsonString(const std::string& literal, ModuleType* result) { } } +bool IsValidEnum(HybridAppPreference val) { + return strlen(EnumToJsonString(val)) > 0; +} + +const char* EnumToJsonString(HybridAppPreference val) { + switch (val) { + case HAP_MOBILE: + return "MOBILE"; + case HAP_CLOUD: + return "CLOUD"; + case HAP_BOTH: + return "BOTH"; + default: + return ""; + } +} + +bool EnumFromJsonString(const std::string& literal, + HybridAppPreference* result) { + if ("MOBILE" == literal) { + *result = HAP_MOBILE; + return true; + } else if ("CLOUD" == literal) { + *result = HAP_CLOUD; + return true; + } else if ("BOTH" == literal) { + *result = HAP_BOTH; + return true; + } + return false; +} + bool EnumFromJsonString(const std::string& literal, FunctionID* result) { if ("RegisterAppInterface" == literal) { *result = RegisterAppInterfaceID; diff --git a/src/components/policy/policy_external/src/policy_table/types.cc b/src/components/policy/policy_external/src/policy_table/types.cc index 5922a020e6..4867eef281 100644 --- a/src/components/policy/policy_external/src/policy_table/types.cc +++ b/src/components/policy/policy_external/src/policy_table/types.cc @@ -241,7 +241,13 @@ ApplicationParams::ApplicationParams(const Json::Value* value__) , RequestSubType(impl::ValueMember(value__, "RequestSubType")) , memory_kb(impl::ValueMember(value__, "memory_kb"), 0) , heart_beat_timeout_ms(impl::ValueMember(value__, "heart_beat_timeout_ms")) - , moduleType(impl::ValueMember(value__, "moduleType")) {} + , moduleType(impl::ValueMember(value__, "moduleType")) + , certificate(impl::ValueMember(value__, "certificate"), "not_specified") + , hybrid_app_preference(impl::ValueMember(value__, "hybrid_app_preference")) + , endpoint(impl::ValueMember(value__, "endpoint")) + , enabled(impl::ValueMember(value__, "enabled")) + , auth_token(impl::ValueMember(value__, "auth_token")) + , cloud_transport_type(impl::ValueMember(value__, "cloud_transport_type")) {} Json::Value ApplicationParams::ToJsonValue() const { Json::Value result__(PolicyBase::ToJsonValue()); @@ -253,6 +259,13 @@ Json::Value ApplicationParams::ToJsonValue() const { impl::WriteJsonField( "heart_beat_timeout_ms", heart_beat_timeout_ms, &result__); impl::WriteJsonField("moduleType", moduleType, &result__); + impl::WriteJsonField("certificate", certificate, &result__); + impl::WriteJsonField( + "hybrid_app_preference", hybrid_app_preference, &result__); + impl::WriteJsonField("endpoint", endpoint, &result__); + impl::WriteJsonField("enabled", enabled, &result__); + impl::WriteJsonField("auth_token", auth_token, &result__); + impl::WriteJsonField("cloud_transport_type", cloud_transport_type, &result__); return result__; } @@ -277,6 +290,24 @@ bool ApplicationParams::is_valid() const { if (!moduleType.is_valid()) { return false; } + if (!certificate.is_valid()) { + return false; + } + if (!endpoint.is_valid()) { + return false; + } + if (!enabled.is_valid()) { + return false; + } + if (!auth_token.is_valid()) { + return false; + } + if (!cloud_transport_type.is_valid()) { + return false; + } + if (!hybrid_app_preference.is_valid()) { + return false; + } return Validate(); } @@ -309,6 +340,24 @@ bool ApplicationParams::struct_empty() const { if (moduleType.is_initialized()) { return false; } + if (certificate.is_initialized()) { + return false; + } + if (endpoint.is_initialized()) { + return false; + } + if (enabled.is_initialized()) { + return false; + } + if (auth_token.is_initialized()) { + return false; + } + if (cloud_transport_type.is_initialized()) { + return false; + } + if (hybrid_app_preference.is_initialized()) { + return false; + } return true; } @@ -357,6 +406,25 @@ void ApplicationParams::ReportErrors(rpc::ValidationReport* report__) const { if (!moduleType.is_valid()) { moduleType.ReportErrors(&report__->ReportSubobject("moduleType")); } + if (!certificate.is_valid()) { + certificate.ReportErrors(&report__->ReportSubobject("certificate")); + } + if (!endpoint.is_valid()) { + moduleType.ReportErrors(&report__->ReportSubobject("endpoint")); + } + if (!enabled.is_valid()) { + moduleType.ReportErrors(&report__->ReportSubobject("enabled")); + } + if (!auth_token.is_valid()) { + moduleType.ReportErrors(&report__->ReportSubobject("auth_token")); + } + if (!cloud_transport_type.is_valid()) { + moduleType.ReportErrors(&report__->ReportSubobject("cloud_transport_type")); + } + if (!hybrid_app_preference.is_valid()) { + moduleType.ReportErrors( + &report__->ReportSubobject("hybrid_app_preference")); + } } void ApplicationParams::SetPolicyTableType(PolicyTableType pt_type) { @@ -367,6 +435,11 @@ void ApplicationParams::SetPolicyTableType(PolicyTableType pt_type) { memory_kb.SetPolicyTableType(pt_type); heart_beat_timeout_ms.SetPolicyTableType(pt_type); moduleType.SetPolicyTableType(pt_type); + certificate.SetPolicyTableType(pt_type); + endpoint.SetPolicyTableType(pt_type); + enabled.SetPolicyTableType(pt_type); + cloud_transport_type.SetPolicyTableType(pt_type); + hybrid_app_preference.SetPolicyTableType(pt_type); } // RpcParameters methods diff --git a/src/components/policy/policy_external/src/sql_pt_ext_queries.cc b/src/components/policy/policy_external/src/sql_pt_ext_queries.cc index afb1180692..f7e1acb59a 100644 --- a/src/components/policy/policy_external/src/sql_pt_ext_queries.cc +++ b/src/components/policy/policy_external/src/sql_pt_ext_queries.cc @@ -205,7 +205,10 @@ const std::string kUpdateGroupPermissions = const std::string kInsertApplication = "INSERT OR IGNORE INTO `application`(`id`, `keep_context`, `steal_focus`, " " `default_hmi`, `priority_value`, `is_revoked`, `memory_kb`, " - " `heart_beat_timeout_ms`) VALUES( ?, ?, ?, ?, ?, ?, ?, ?) "; + " `heart_beat_timeout_ms`, `certificate`, `hybrid_app_preference_value`, " + " `endpoint`, `enabled`, `auth_token`, " + " `cloud_transport_type`) VALUES " + "(?,?,?,?,?,?,?,?,?,?,?,?,?,?)"; const std::string kCollectFriendlyMsg = "SELECT * FROM `message`"; @@ -232,8 +235,9 @@ const std::string kSelectPreconsentedGroupsId = const std::string kSelectAppPolicies = "SELECT `id`, `priority_value`, `default_hmi`, `keep_context`, " - "`steal_focus`, " - " `memory_kb`, `heart_beat_timeout_ms` FROM `application`"; + " `steal_focus`, `memory_kb`, `heart_beat_timeout_ms`, `certificate`, " + " `hybrid_app_preference_value`, `endpoint`, `enabled`, " + " `cloud_transport_type` FROM `application`"; const std::string kSelectFunctionalGroupNames = "SELECT `id`, `user_consent_prompt`, `name`" diff --git a/src/components/policy/policy_external/src/sql_pt_ext_representation.cc b/src/components/policy/policy_external/src/sql_pt_ext_representation.cc index a43b22a3b8..6a40e6d135 100644 --- a/src/components/policy/policy_external/src/sql_pt_ext_representation.cc +++ b/src/components/policy/policy_external/src/sql_pt_ext_representation.cc @@ -752,6 +752,24 @@ bool SQLPTExtRepresentation::SaveSpecificAppPolicy( app_query.Bind(5, app.second.is_null()); app_query.Bind(6, *app.second.memory_kb); app_query.Bind(7, static_cast(*app.second.heart_beat_timeout_ms)); + app.second.certificate.is_initialized() + ? app_query.Bind(8, *app.second.certificate) + : app_query.Bind(8); + app.second.hybrid_app_preference.is_initialized() + ? app_query.Bind(9, + std::string(policy_table::EnumToJsonString( + *app.second.hybrid_app_preference))) + : app_query.Bind(9); + app.second.endpoint.is_initialized() ? app_query.Bind(10, *app.second.endpoint) + : app_query.Bind(10); + app.second.enabled.is_initialized() ? app_query.Bind(11, *app.second.enabled) + : app_query.Bind(11); + app.second.auth_token.is_initialized() + ? app_query.Bind(12, *app.second.auth_token) + : app_query.Bind(12); + app.second.cloud_transport_type.is_initialized() + ? app_query.Bind(13, *app.second.cloud_transport_type) + : app_query.Bind(13); if (!app_query.Exec() || !app_query.Reset()) { LOG4CXX_WARN(logger_, "Incorrect insert into application."); @@ -873,6 +891,22 @@ bool SQLPTExtRepresentation::GatherApplicationPoliciesSection( params.steal_focus = query.GetBoolean(4); *params.memory_kb = query.GetInteger(5); *params.heart_beat_timeout_ms = query.GetUInteger(6); + if (!query.IsNull(7)) { + *params.certificate = query.GetString(7); + } + + // Read cloud app properties + policy_table::HybridAppPreference hap; + bool valid = policy_table::EnumFromJsonString(query.GetString(8), &hap); + if (valid) { + *params.hybrid_app_preference = hap; + } + *params.endpoint = query.GetString(9); + if (!query.IsNull(10)) { + *params.enabled = query.GetBoolean(10); + } + *params.auth_token = query.GetString(11); + *params.cloud_transport_type = query.GetString(12); const auto& gather_app_id = ((*policies).apps[app_id].is_string()) ? (*policies).apps[app_id].get_string() diff --git a/src/components/policy/policy_external/src/sql_pt_queries.cc b/src/components/policy/policy_external/src/sql_pt_queries.cc index 97d75731ea..8c4227963a 100644 --- a/src/components/policy/policy_external/src/sql_pt_queries.cc +++ b/src/components/policy/policy_external/src/sql_pt_queries.cc @@ -98,6 +98,9 @@ const std::string kCreateSchema = "CREATE TABLE IF NOT EXISTS `hmi_level`( " " `value` VARCHAR(45) PRIMARY KEY NOT NULL " "); " + "CREATE TABLE IF NOT EXISTS `hybrid_app_preference`( " + " `value` VARCHAR(45) PRIMARY KEY NOT NULL " + "); " "CREATE TABLE IF NOT EXISTS `notifications_by_priority`( " " `priority_value` VARCHAR(45) PRIMARY KEY NOT NULL, " " `value` INTEGER NOT NULL, " @@ -147,6 +150,12 @@ const std::string kCreateSchema = " `is_predata` BOOLEAN, " " `memory_kb` INTEGER NOT NULL, " " `heart_beat_timeout_ms` INTEGER NOT NULL, " + " `certificate` VARCHAR(65535), " + " `hybrid_app_preference_value` VARCHAR(255), " + " `endpoint` VARCHAR(255), " + " `enabled` BOOLEAN, " + " `auth_token` VARCHAR(65535), " + " `cloud_transport_type` VARCHAR(255), " " `remote_control_denied` BOOLEAN NOT NULL DEFAULT 0, " " CONSTRAINT `fk_application_hmi_level1` " " FOREIGN KEY(`default_hmi`) " @@ -154,11 +163,17 @@ const std::string kCreateSchema = " CONSTRAINT `fk_application_priorities1` " " FOREIGN KEY(`priority_value`) " " REFERENCES `priority`(`value`) " + " CONSTRAINT `fk_application_hybrid_app_preference1` " + " FOREIGN KEY(`hybrid_app_preference_value`) " + " REFERENCES `hybrid_app_preference`(`value`) " "); " "CREATE INDEX IF NOT EXISTS `application.fk_application_hmi_level1_idx` " " ON `application`(`default_hmi`); " "CREATE INDEX IF NOT EXISTS `application.fk_application_priorities1_idx` " " ON `application`(`priority_value`); " + "CREATE INDEX IF NOT EXISTS " + "`application.fk_application_hybrid_app_preference1` " + " ON `application`(`hybrid_app_preference_value`); " "CREATE TABLE IF NOT EXISTS `app_group`( " " `application_id` VARCHAR(45) NOT NULL COLLATE NOCASE, " " `functional_group_id` INTEGER NOT NULL, " @@ -430,6 +445,9 @@ const std::string kInsertInitData = "INSERT OR IGNORE INTO `hmi_level`(`value`) VALUES ('LIMITED'); " "INSERT OR IGNORE INTO `hmi_level`(`value`) VALUES ('BACKGROUND'); " "INSERT OR IGNORE INTO `hmi_level`(`value`) VALUES ('NONE'); " + "INSERT OR IGNORE INTO `hybrid_app_preference`(`value`) VALUES ('MOBILE'); " + "INSERT OR IGNORE INTO `hybrid_app_preference`(`value`) VALUES ('CLOUD'); " + "INSERT OR IGNORE INTO `hybrid_app_preference`(`value`) VALUES ('BOTH'); " "INSERT OR IGNORE INTO `version` (`number`) VALUES('0'); " "INSERT OR IGNORE INTO `_internal_data` (`db_version_hash`) VALUES(0); " ""; @@ -532,6 +550,7 @@ const std::string kDropSchema = "`notifications_by_priority.fk_notifications_by_priority_priority1_idx`; " "DROP TABLE IF EXISTS `notifications_by_priority`; " "DROP TABLE IF EXISTS `hmi_level`; " + "DROP TABLE IF EXISTS `hybrid_app_preference`; " "DROP TABLE IF EXISTS `priority`; " "DROP TABLE IF EXISTS `functional_group`; " "DROP TABLE IF EXISTS `module_config`; " @@ -628,8 +647,10 @@ const std::string kInsertRpcWithParameter = const std::string kInsertApplication = "INSERT OR IGNORE INTO `application` (`id`, `priority_value`, " - "`is_revoked`, `memory_kb`," - " `heart_beat_timeout_ms`) VALUES (?,?,?,?,?)"; + "`is_revoked`, `memory_kb`, `heart_beat_timeout_ms`, `certificate`, " + "`hybrid_app_preference_value`, `endpoint`, `enabled`, `auth_token`, " + "`cloud_transport_type`) VALUES " + "(?,?,?,?,?,?,?,?,?,?,?)"; const std::string kInsertAppGroup = "INSERT INTO `app_group` (`application_id`, `functional_group_id`)" @@ -752,7 +773,8 @@ const std::string kSelectUserMsgsVersion = const std::string kSelectAppPolicies = "SELECT `id`, `priority_value`, `memory_kb`, " - " `heart_beat_timeout_ms` FROM `application`"; + " `heart_beat_timeout_ms`, `certificate`, `hybrid_app_preference_value`, " + " `endpoint`, `enabled`, `cloud_transport_type` FROM `application`"; const std::string kCollectFriendlyMsg = "SELECT * FROM `message`"; @@ -849,15 +871,19 @@ const std::string kDeleteAppGroupByApplicationId = const std::string kInsertApplicationFull = "INSERT OR IGNORE INTO `application` (`id`, `keep_context`, `steal_focus`, " - " `default_hmi`, `priority_value`, `is_revoked`, `is_default`, " - "`is_predata`, " - " `memory_kb`, `heart_beat_timeout_ms`) " - " VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"; + " `default_hmi`, `priority_value`, `is_revoked`, `is_default`, " + " `is_predata`, `memory_kb`, `heart_beat_timeout_ms`, " + " `certificate`, `hybrid_app_preference_value`, `endpoint`, `enabled`, " + " `auth_token`, `cloud_transport_type`) " + " VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"; const std::string kSelectApplicationFull = "SELECT `keep_context`, `steal_focus`, `default_hmi`, `priority_value`, " " `is_revoked`, `is_default`, `is_predata`, `memory_kb`," - " `heart_beat_timeout_ms` FROM `application` WHERE `id` = ?"; + " `heart_beat_timeout_ms`, `certificate`, `hybrid_app_preference_value`, " + " `endpoint`, `enabled`, `auth_token`, `cloud_transport_type` " + "FROM `application` " + "WHERE `id` = ?"; const std::string kSelectDBVersion = "SELECT `db_version_hash` from `_internal_data`"; diff --git a/src/components/policy/policy_external/src/sql_pt_representation.cc b/src/components/policy/policy_external/src/sql_pt_representation.cc index c8b367c8ec..b794d4c3a6 100644 --- a/src/components/policy/policy_external/src/sql_pt_representation.cc +++ b/src/components/policy/policy_external/src/sql_pt_representation.cc @@ -761,6 +761,23 @@ bool SQLPTRepresentation::GatherApplicationPoliciesSection( *params.memory_kb = query.GetInteger(2); *params.heart_beat_timeout_ms = query.GetUInteger(3); + if (!query.IsNull(4)) { + *params.certificate = query.GetString(4); + } + + // Read cloud app properties + policy_table::HybridAppPreference hap; + bool valid = policy_table::EnumFromJsonString(query.GetString(5), &hap); + if (valid) { + *params.hybrid_app_preference = hap; + } + *params.endpoint = query.GetString(6); + if (!query.IsNull(7)) { + *params.enabled = query.GetBoolean(7); + } + *params.auth_token = query.GetString(8); + *params.cloud_transport_type = query.GetString(9); + const auto& gather_app_id = ((*policies).apps[app_id].is_string()) ? (*policies).apps[app_id].get_string() : app_id; @@ -1035,6 +1052,24 @@ bool SQLPTRepresentation::SaveSpecificAppPolicy( app_query.Bind(2, app.second.is_null()); app_query.Bind(3, *app.second.memory_kb); app_query.Bind(4, static_cast(*app.second.heart_beat_timeout_ms)); + app.second.certificate.is_initialized() + ? app_query.Bind(5, *app.second.certificate) + : app_query.Bind(5); + app.second.hybrid_app_preference.is_initialized() + ? app_query.Bind(6, + std::string(policy_table::EnumToJsonString( + *app.second.hybrid_app_preference))) + : app_query.Bind(6); + app.second.endpoint.is_initialized() ? app_query.Bind(7, *app.second.endpoint) + : app_query.Bind(7); + app.second.enabled.is_initialized() ? app_query.Bind(8, *app.second.enabled) + : app_query.Bind(8); + app.second.auth_token.is_initialized() + ? app_query.Bind(9, *app.second.auth_token) + : app_query.Bind(9); + app.second.cloud_transport_type.is_initialized() + ? app_query.Bind(10, *app.second.cloud_transport_type) + : app_query.Bind(10); if (!app_query.Exec() || !app_query.Reset()) { LOG4CXX_WARN(logger_, "Incorrect insert into application."); @@ -2125,6 +2160,18 @@ bool SQLPTRepresentation::CopyApplication(const std::string& source, : query.Bind(7, source_app.GetBoolean(6)); query.Bind(8, source_app.GetInteger(7)); query.Bind(9, source_app.GetInteger(8)); + source_app.IsNull(9) ? query.Bind(10) + : query.Bind(10, source_app.GetString(9)); + source_app.IsNull(10) ? query.Bind(11) + : query.Bind(11, source_app.GetString(10)); + source_app.IsNull(11) ? query.Bind(12) + : query.Bind(12, source_app.GetString(11)); + source_app.IsNull(12) ? query.Bind(13) + : query.Bind(13, source_app.GetBoolean(12)); + source_app.IsNull(13) ? query.Bind(14) + : query.Bind(14, source_app.GetString(13)); + source_app.IsNull(14) ? query.Bind(15) + : query.Bind(15, source_app.GetString(14)); if (!query.Exec()) { LOG4CXX_WARN(logger_, "Failed inserting into application."); diff --git a/src/components/policy/policy_external/test/sql_pt_representation_test.cc b/src/components/policy/policy_external/test/sql_pt_representation_test.cc index b0f340b0f2..fddc5e631e 100644 --- a/src/components/policy/policy_external/test/sql_pt_representation_test.cc +++ b/src/components/policy/policy_external/test/sql_pt_representation_test.cc @@ -406,8 +406,8 @@ TEST_F(SQLPTRepresentationTest, query.Prepare(query_select); query.Next(); - // 33 - is current total tables number created by schema - const int policy_tables_number = 33; + // 34 - is current total tables number created by schema + const int policy_tables_number = 34; ASSERT_EQ(policy_tables_number, query.GetInteger(0)); const std::string query_select_count_of_iap_buffer_full = -- cgit v1.2.1 From 9174e46f6ba6cde75eab481f85aab7d89f12e570 Mon Sep 17 00:00:00 2001 From: jacobkeeler Date: Mon, 5 Nov 2018 17:56:55 -0500 Subject: Fix style, add certificate, and add GetEnabledCloudApps --- .../application_manager/policies/policy_handler.h | 45 +++++++++++++++++----- .../src/policies/policy_handler.cc | 36 +++++++++++------ .../policies/policy_handler_interface.h | 15 +++++++- .../policy/policy_external/policy/policy_manager.h | 13 ++++++- .../policy/policy_regular/policy/policy_manager.h | 16 +++++++- .../policies/mock_policy_handler_interface.h | 5 ++- .../policy_external/policy/mock_cache_manager.h | 5 ++- .../policy_external/policy/mock_policy_manager.h | 5 ++- .../policy_regular/policy/mock_cache_manager.h | 15 +++++--- .../policy_regular/policy/mock_policy_manager.h | 5 ++- .../policy_external/include/policy/cache_manager.h | 11 ++++++ .../include/policy/cache_manager_interface.h | 11 ++++++ .../include/policy/policy_manager_impl.h | 15 +++++++- .../include/policy/policy_table/enums.h | 6 +-- .../policy/policy_external/src/cache_manager.cc | 18 +++++++++ .../policy_external/src/policy_manager_impl.cc | 7 ++++ .../policy_external/src/policy_table/types.cc | 3 +- .../src/sql_pt_ext_representation.cc | 5 ++- .../policy_regular/include/policy/cache_manager.h | 11 ++++++ .../include/policy/cache_manager_interface.h | 16 +++++++- .../include/policy/policy_manager_impl.h | 13 ++++++- .../policy/policy_regular/src/cache_manager.cc | 18 +++++++++ .../policy_regular/src/policy_manager_impl.cc | 17 ++++++-- 23 files changed, 259 insertions(+), 52 deletions(-) diff --git a/src/components/application_manager/include/application_manager/policies/policy_handler.h b/src/components/application_manager/include/application_manager/policies/policy_handler.h index 3af03bf28b..a612c263ca 100644 --- a/src/components/application_manager/include/application_manager/policies/policy_handler.h +++ b/src/components/application_manager/include/application_manager/policies/policy_handler.h @@ -398,6 +398,14 @@ class PolicyHandler : public PolicyHandlerInterface, custom_str::CustomString GetAppName( const std::string& policy_app_id) OVERRIDE; + /** + * @brief Get a list of enabled cloud applications + * @param enabled_apps List filled with the policy app id of each enabled + * cloud application + */ + void GetEnabledCloudApps( + std::vector& enabled_apps) const OVERRIDE; + /** * @brief Checks if a given application is an enabled cloud application * @param policy_app_id Unique application id @@ -407,17 +415,36 @@ class PolicyHandler : public PolicyHandlerInterface, const bool CheckCloudAppEnabled( const std::string& policy_app_id) const OVERRIDE; - /**plzfix - * @brief Checks if certain request type is allowed for application + /** + * @brief Get cloud app policy information, all fields that aren't set for a + * given app will be filled with empty strings * @param policy_app_id Unique application id - * @return true, if allowed, otherwise - false - */ - const bool GetCloudAppParameters(const std::string& policy_app_id, - std::string& endpoint, - std::string& auth_token, - std::string& cloud_transport_type, - std::string& hybrid_app_preference) const OVERRIDE; + * @param endpoint Filled with the endpoint used to connect to the cloud + * application + * @param certificate Filled with the certificate used to for creating a + * secure + * connection to the cloud application + * @param auth_token Filled with the token used for authentication when + * reconnecting to the cloud app + * @param cloud_transport_type Filled with the transport type used by the + * cloud application (ex. "WSS") + * @param cloud_transport_type Filled with the hybrid app preference for the + * cloud application set by the user + * @return true if the cloud app is enabled, false otherwise + */ + const bool GetCloudAppParameters( + const std::string& policy_app_id, + std::string& endpoint, + std::string& certificate, + std::string& auth_token, + std::string& cloud_transport_type, + std::string& hybrid_app_preference) const OVERRIDE; + /** + * @brief Callback for when a SetCloudAppProperties message is received from a + * mobile app + * @param message The SetCloudAppProperties message + */ void OnSetCloudAppProperties( const smart_objects::SmartObject& message) OVERRIDE; diff --git a/src/components/application_manager/src/policies/policy_handler.cc b/src/components/application_manager/src/policies/policy_handler.cc index c73e35768e..cc62d9f6f8 100644 --- a/src/components/application_manager/src/policies/policy_handler.cc +++ b/src/components/application_manager/src/policies/policy_handler.cc @@ -1845,28 +1845,39 @@ bool PolicyHandler::CheckSystemAction( return false; } +void PolicyHandler::GetEnabledCloudApps( + std::vector& enabled_apps) const { + POLICY_LIB_CHECK_VOID(); + policy_manager_->GetEnabledCloudApps(enabled_apps); +} + const bool PolicyHandler::GetCloudAppParameters( const std::string& policy_app_id, std::string& endpoint, + std::string& certificate, std::string& auth_token, std::string& cloud_transport_type, std::string& hybrid_app_preference) const { POLICY_LIB_CHECK(false); return policy_manager_->GetCloudAppParameters(policy_app_id, endpoint, + certificate, auth_token, cloud_transport_type, hybrid_app_preference); } -const bool PolicyHandler::CheckCloudAppEnabled(const std::string& policy_app_id) const { +const bool PolicyHandler::CheckCloudAppEnabled( + const std::string& policy_app_id) const { POLICY_LIB_CHECK(false); std::string endpoint; std::string auth_token; + std::string certificate; std::string cloud_transport_type; std::string hybrid_app_preference; return policy_manager_->GetCloudAppParameters(policy_app_id, endpoint, + certificate, auth_token, cloud_transport_type, hybrid_app_preference); @@ -1876,34 +1887,35 @@ void PolicyHandler::OnSetCloudAppProperties( const smart_objects::SmartObject& message) { POLICY_LIB_CHECK_VOID(); if (!message.keyExists(strings::msg_params)) { - LOG4CXX_ERROR( - logger_, - "Message does not contain mandatory section " << strings::msg_params); + LOG4CXX_ERROR(logger_, + "Message does not contain mandatory section " + << strings::msg_params); return; } const smart_objects::SmartObject& msg_params = message[strings::msg_params]; if (!msg_params.keyExists(strings::app_id)) { - LOG4CXX_ERROR( - logger_, - "Message does not contain mandatory parameter " << strings::app_id); + LOG4CXX_ERROR(logger_, + "Message does not contain mandatory parameter " + << strings::app_id); return; } std::string policy_app_id(msg_params[strings::app_id].asString()); if (msg_params.keyExists(strings::enabled)) { policy_manager_->SetCloudAppEnabled(policy_app_id, - msg_params[strings::enabled].asBool()); + msg_params[strings::enabled].asBool()); } if (msg_params.keyExists(strings::cloud_app_auth_token)) { - policy_manager_->SetAppAuthToken(policy_app_id, - msg_params[strings::cloud_app_auth_token].asString()); + policy_manager_->SetAppAuthToken( + policy_app_id, msg_params[strings::cloud_app_auth_token].asString()); } if (msg_params.keyExists(strings::cloud_transport_type)) { policy_manager_->SetAppCloudTransportType( policy_app_id, msg_params[strings::cloud_transport_type].asString()); } if (msg_params.keyExists(strings::hybrid_app_preference)) { - //const std::string hybrid_app_preference = EnumConversionHelper::EnumToString(msg_params[strings::hybrid_app_preference]); - //policy_manager_->SetHybridAppPreference( + // const std::string hybrid_app_preference = + // EnumConversionHelper::EnumToString(msg_params[strings::hybrid_app_preference]); + // policy_manager_->SetHybridAppPreference( // policy_app_id, hybrid_app_preference); } } diff --git a/src/components/include/application_manager/policies/policy_handler_interface.h b/src/components/include/application_manager/policies/policy_handler_interface.h index 69433e6118..ddeb1da8f7 100644 --- a/src/components/include/application_manager/policies/policy_handler_interface.h +++ b/src/components/include/application_manager/policies/policy_handler_interface.h @@ -437,7 +437,15 @@ class PolicyHandlerInterface { * @return Structure with vehicle information */ virtual const VehicleInfo GetVehicleInfo() const = 0; - + + /** + * @brief Get a list of enabled cloud applications + * @param enabled_apps List filled with the policy app id of each enabled + * cloud application + */ + virtual void GetEnabledCloudApps( + std::vector& enabled_apps) const = 0; + /** * @brief Checks if a given application is an enabled cloud application * @param policy_app_id Unique application id @@ -453,6 +461,8 @@ class PolicyHandlerInterface { * @param policy_app_id Unique application id * @param endpoint Filled the endpoint used to connect to the cloud * application + * @param certificate Filled with the certificate used to for creating a + * secure connection to the cloud application * @param auth_token Filled with the token used for authentication when * reconnecting to the cloud app * @param cloud_transport_type Filled with the transport type used by the @@ -464,6 +474,7 @@ class PolicyHandlerInterface { virtual const bool GetCloudAppParameters( const std::string& policy_app_id, std::string& endpoint, + std::string& certificate, std::string& auth_token, std::string& cloud_transport_type, std::string& hybrid_app_preference) const = 0; @@ -475,7 +486,7 @@ class PolicyHandlerInterface { */ virtual void OnSetCloudAppProperties( const smart_objects::SmartObject& message) = 0; - + #ifdef EXTERNAL_PROPRIETARY_MODE /** * @brief Gets meta information diff --git a/src/components/include/policy/policy_external/policy/policy_manager.h b/src/components/include/policy/policy_external/policy/policy_manager.h index 2ea8ef08f1..b0fac8eae9 100644 --- a/src/components/include/policy/policy_external/policy/policy_manager.h +++ b/src/components/include/policy/policy_external/policy/policy_manager.h @@ -521,13 +521,23 @@ class PolicyManager : public usage_statistics::StatisticsManager { * @return vehicle information */ virtual const VehicleInfo GetVehicleInfo() const = 0; - + + /** + * @brief Get a list of enabled cloud applications + * @param enabled_apps List filled with the policy app id of each enabled + * cloud application + */ + virtual void GetEnabledCloudApps( + std::vector& enabled_apps) const = 0; + /** * @brief Get cloud app policy information, all fields that aren't set for a * given app will be filled with empty strings * @param policy_app_id Unique application id * @param endpoint Filled the endpoint used to connect to the cloud * application + * @param certificate Filled with the certificate used to for creating a + * secure connection to the cloud application * @param auth_token Filled with the token used for authentication when * reconnecting to the cloud app * @param cloud_transport_type Filled with the transport type used by the @@ -539,6 +549,7 @@ class PolicyManager : public usage_statistics::StatisticsManager { virtual const bool GetCloudAppParameters( const std::string& policy_app_id, std::string& endpoint, + std::string& certificate, std::string& auth_token, std::string& cloud_transport_type, std::string& hybrid_app_preference) const = 0; diff --git a/src/components/include/policy/policy_regular/policy/policy_manager.h b/src/components/include/policy/policy_regular/policy/policy_manager.h index 9c67e239b7..1f0f520077 100644 --- a/src/components/include/policy/policy_regular/policy/policy_manager.h +++ b/src/components/include/policy/policy_regular/policy/policy_manager.h @@ -502,12 +502,22 @@ class PolicyManager : public usage_statistics::StatisticsManager { */ virtual const VehicleInfo GetVehicleInfo() const = 0; + /** + * @brief Get a list of enabled cloud applications + * @param enabled_apps List filled with the policy app id of each enabled + * cloud application + */ + virtual void GetEnabledCloudApps( + std::vector& enabled_apps) const = 0; + /** * @brief Get cloud app policy information, all fields that aren't set for a * given app will be filled with empty strings * @param policy_app_id Unique application id * @param endpoint Filled the endpoint used to connect to the cloud * application + * @param certificate Filled with the certificate used to for creating a + * secure connection to the cloud application * @param auth_token Filled with the token used for authentication when * reconnecting to the cloud app * @param cloud_transport_type Filled with the transport type used by the @@ -519,6 +529,7 @@ class PolicyManager : public usage_statistics::StatisticsManager { virtual const bool GetCloudAppParameters( const std::string& policy_app_id, std::string& endpoint, + std::string& certificate, std::string& auth_token, std::string& cloud_transport_type, std::string& hybrid_app_preference) const = 0; @@ -550,8 +561,9 @@ class PolicyManager : public usage_statistics::StatisticsManager { * should be used * @param hybrid_app_preference Hybrid app user preference */ - virtual void SetHybridAppPreference(const std::string& policy_app_id, - const std::string& hybrid_app_preference) = 0; + virtual void SetHybridAppPreference( + const std::string& policy_app_id, + const std::string& hybrid_app_preference) = 0; /** * @brief OnAppRegisteredOnMobile allows to handle event when application were diff --git a/src/components/include/test/application_manager/policies/mock_policy_handler_interface.h b/src/components/include/test/application_manager/policies/mock_policy_handler_interface.h index bd56d78128..cea36082c8 100644 --- a/src/components/include/test/application_manager/policies/mock_policy_handler_interface.h +++ b/src/components/include/test/application_manager/policies/mock_policy_handler_interface.h @@ -213,11 +213,14 @@ class MockPolicyHandlerInterface : public policy::PolicyHandlerInterface { GetAppRequestTypes, const std::vector(const std::string& policy_app_id)); MOCK_CONST_METHOD0(GetVehicleInfo, const policy::VehicleInfo()); + MOCK_CONST_METHOD1(GetEnabledCloudApps, + void(std::vector& enabled_apps)); MOCK_CONST_METHOD1(CheckCloudAppEnabled, const bool(const std::string& policy_app_id)); - MOCK_CONST_METHOD5(GetCloudAppParameters, + MOCK_CONST_METHOD6(GetCloudAppParameters, const bool(const std::string& policy_app_id, std::string& endpoint, + std::string& certificate, std::string& auth_token, std::string& cloud_transport_type, std::string& hybrid_app_preference)); diff --git a/src/components/include/test/policy/policy_external/policy/mock_cache_manager.h b/src/components/include/test/policy/policy_external/policy/mock_cache_manager.h index ecbd8c6cd6..03e0882129 100644 --- a/src/components/include/test/policy/policy_external/policy/mock_cache_manager.h +++ b/src/components/include/test/policy/policy_external/policy/mock_cache_manager.h @@ -76,9 +76,12 @@ class MockCacheManagerInterface : public ::policy::CacheManagerInterface { MOCK_METHOD1(SecondsBetweenRetries, bool(std::vector& seconds)); MOCK_CONST_METHOD1(IsDeviceConsentCached, bool(const std::string& device_id)); MOCK_CONST_METHOD0(GetVehicleInfo, const VehicleInfo()); - MOCK_CONST_METHOD5(GetCloudAppParameters, + MOCK_CONST_METHOD1(GetEnabledCloudApps, + void(std::vector& enabled_apps)); + MOCK_CONST_METHOD6(GetCloudAppParameters, const bool(const std::string& policy_app_id, std::string& endpoint, + std::string& certificate, std::string& auth_token, std::string& cloud_transport_type, std::string& hybrid_app_preference)); diff --git a/src/components/include/test/policy/policy_external/policy/mock_policy_manager.h b/src/components/include/test/policy/policy_external/policy/mock_policy_manager.h index f58ed10934..70dab8e99a 100644 --- a/src/components/include/test/policy/policy_external/policy/mock_policy_manager.h +++ b/src/components/include/test/policy/policy_external/policy/mock_policy_manager.h @@ -184,9 +184,12 @@ class MockPolicyManager : public PolicyManager { GetAppRequestTypes, const std::vector(const std::string policy_app_id)); MOCK_CONST_METHOD0(GetVehicleInfo, const policy::VehicleInfo()); - MOCK_CONST_METHOD5(GetCloudAppParameters, + MOCK_CONST_METHOD1(GetEnabledCloudApps, + void(std::vector& enabled_apps)); + MOCK_CONST_METHOD6(GetCloudAppParameters, const bool(const std::string& policy_app_id, std::string& endpoint, + std::string& certificate, std::string& auth_token, std::string& cloud_transport_type, std::string& hybrid_app_preference)); diff --git a/src/components/include/test/policy/policy_regular/policy/mock_cache_manager.h b/src/components/include/test/policy/policy_regular/policy/mock_cache_manager.h index 745bcd2db5..7ac94d278d 100644 --- a/src/components/include/test/policy/policy_regular/policy/mock_cache_manager.h +++ b/src/components/include/test/policy/policy_regular/policy/mock_cache_manager.h @@ -63,12 +63,15 @@ class MockCacheManagerInterface : public CacheManagerInterface { MOCK_METHOD0(TimeoutResponse, int()); MOCK_METHOD1(SecondsBetweenRetries, bool(std::vector& seconds)); MOCK_CONST_METHOD0(GetVehicleInfo, const VehicleInfo()); - MOCK_CONST_METHOD5(GetCloudAppParameters, - const bool(const std::string& policy_app_id, - std::string& endpoint, - std::string& auth_token, - std::string& cloud_transport_type, - std::string& hybrid_app_preference)); + MOCK_CONST_METHOD1(GetEnabledCloudApps, + void(std::vector& enabled_apps)); + MOCK_CONST_METHOD6(GetCloudAppParameters, + const bool(const std::string& policy_app_id, + std::string& endpoint, + std::string& certificate, + std::string& auth_token, + std::string& cloud_transport_type, + std::string& hybrid_app_preference)); MOCK_METHOD2(SetCloudAppEnabled, void(const std::string& policy_app_id, const bool enabled)); MOCK_METHOD2(SetAppAuthToken, diff --git a/src/components/include/test/policy/policy_regular/policy/mock_policy_manager.h b/src/components/include/test/policy/policy_regular/policy/mock_policy_manager.h index 8867c3de80..7441701a34 100644 --- a/src/components/include/test/policy/policy_regular/policy/mock_policy_manager.h +++ b/src/components/include/test/policy/policy_regular/policy/mock_policy_manager.h @@ -181,9 +181,12 @@ class MockPolicyManager : public PolicyManager { GetAppRequestTypes, const std::vector(const std::string policy_app_id)); MOCK_CONST_METHOD0(GetVehicleInfo, const policy::VehicleInfo()); - MOCK_CONST_METHOD5(GetCloudAppParameters, + MOCK_CONST_METHOD1(GetEnabledCloudApps, + void(std::vector& enabled_apps)); + MOCK_CONST_METHOD6(GetCloudAppParameters, const bool(const std::string& policy_app_id, std::string& endpoint, + std::string& certificate, std::string& auth_token, std::string& cloud_transport_type, std::string& hybrid_app_preference)); diff --git a/src/components/policy/policy_external/include/policy/cache_manager.h b/src/components/policy/policy_external/include/policy/cache_manager.h index d6eeb0457b..7660eb2df9 100644 --- a/src/components/policy/policy_external/include/policy/cache_manager.h +++ b/src/components/policy/policy_external/include/policy/cache_manager.h @@ -158,12 +158,22 @@ class CacheManager : public CacheManagerInterface { */ virtual const VehicleInfo GetVehicleInfo() const; + /** + * @brief Get a list of enabled cloud applications + * @param enabled_apps List filled with the policy app id of each enabled + * cloud application + */ + virtual void GetEnabledCloudApps( + std::vector& enabled_apps) const; + /** * @brief Get cloud app policy information, all fields that aren't set for a * given app will be filled with empty strings * @param policy_app_id Unique application id * @param endpoint Filled the endpoint used to connect to the cloud * application + * @param certificate Filled with the certificate used to for creating a + * secure connection to the cloud application * @param auth_token Filled with the token used for authentication when * reconnecting to the cloud app * @param cloud_transport_type Filled with the transport type used by the @@ -175,6 +185,7 @@ class CacheManager : public CacheManagerInterface { virtual const bool GetCloudAppParameters( const std::string& policy_app_id, std::string& endpoint, + std::string& certificate, std::string& auth_token, std::string& cloud_transport_type, std::string& hybrid_app_preference) const; diff --git a/src/components/policy/policy_external/include/policy/cache_manager_interface.h b/src/components/policy/policy_external/include/policy/cache_manager_interface.h index 0c094d2edb..79d6f4e731 100644 --- a/src/components/policy/policy_external/include/policy/cache_manager_interface.h +++ b/src/components/policy/policy_external/include/policy/cache_manager_interface.h @@ -165,12 +165,22 @@ class CacheManagerInterface { */ virtual const VehicleInfo GetVehicleInfo() const = 0; + /** + * @brief Get a list of enabled cloud applications + * @param enabled_apps List filled with the policy app id of each enabled + * cloud application + */ + virtual void GetEnabledCloudApps( + std::vector& enabled_apps) const = 0; + /** * @brief Get cloud app policy information, all fields that aren't set for a * given app will be filled with empty strings * @param policy_app_id Unique application id * @param endpoint Filled the endpoint used to connect to the cloud * application + * @param certificate Filled with the certificate used to for creating a + * secure connection to the cloud application * @param auth_token Filled with the token used for authentication when * reconnecting to the cloud app * @param cloud_transport_type Filled with the transport type used by the @@ -182,6 +192,7 @@ class CacheManagerInterface { virtual const bool GetCloudAppParameters( const std::string& policy_app_id, std::string& endpoint, + std::string& certificate, std::string& auth_token, std::string& cloud_transport_type, std::string& hybrid_app_preference) const = 0; diff --git a/src/components/policy/policy_external/include/policy/policy_manager_impl.h b/src/components/policy/policy_external/include/policy/policy_manager_impl.h index f9648f803c..778892df13 100644 --- a/src/components/policy/policy_external/include/policy/policy_manager_impl.h +++ b/src/components/policy/policy_external/include/policy/policy_manager_impl.h @@ -569,13 +569,23 @@ class PolicyManagerImpl : public PolicyManager { * @return vehicle information */ const VehicleInfo GetVehicleInfo() const OVERRIDE; - + + /** + * @brief Get a list of enabled cloud applications + * @param enabled_apps List filled with the policy app id of each enabled + * cloud application + */ + void GetEnabledCloudApps( + std::vector& enabled_apps) const OVERRIDE; + /** * @brief Get cloud app policy information, all fields that aren't set for a * given app will be filled with empty strings * @param policy_app_id Unique application id * @param endpoint Filled the endpoint used to connect to the cloud * application + * @param certificate Filled with the certificate used to for creating a + * secure connection to the cloud application * @param auth_token Filled with the token used for authentication when * reconnecting to the cloud app * @param cloud_transport_type Filled with the transport type used by the @@ -587,6 +597,7 @@ class PolicyManagerImpl : public PolicyManager { const bool GetCloudAppParameters( const std::string& policy_app_id, std::string& endpoint, + std::string& certificate, std::string& auth_token, std::string& cloud_transport_type, std::string& hybrid_app_preference) const OVERRIDE; @@ -597,7 +608,7 @@ class PolicyManagerImpl : public PolicyManager { */ void SetCloudAppEnabled(const std::string& policy_app_id, const bool enabled) OVERRIDE; - + /** * @brief Set an app's auth token * @param auth_token Cloud app authentication token diff --git a/src/components/policy/policy_external/include/policy/policy_table/enums.h b/src/components/policy/policy_external/include/policy/policy_table/enums.h index b13e6b6f26..dc2fdab2fa 100644 --- a/src/components/policy/policy_external/include/policy/policy_table/enums.h +++ b/src/components/policy/policy_external/include/policy/policy_table/enums.h @@ -182,11 +182,7 @@ bool IsValidEnum(ModuleType val); const char* EnumToJsonString(ModuleType val); bool EnumFromJsonString(const std::string& literal, ModuleType* result); -enum HybridAppPreference { - HAP_MOBILE, - HAP_CLOUD, - HAP_BOTH -}; +enum HybridAppPreference { HAP_MOBILE, HAP_CLOUD, HAP_BOTH }; bool IsValidEnum(HybridAppPreference val); const char* EnumToJsonString(HybridAppPreference val); bool EnumFromJsonString(const std::string& literal, diff --git a/src/components/policy/policy_external/src/cache_manager.cc b/src/components/policy/policy_external/src/cache_manager.cc index d6d5f6daa5..116b315755 100644 --- a/src/components/policy/policy_external/src/cache_manager.cc +++ b/src/components/policy/policy_external/src/cache_manager.cc @@ -1389,9 +1389,24 @@ const policy::VehicleInfo CacheManager::GetVehicleInfo() const { return vehicle_info; } +void CacheManager::GetEnabledCloudApps( + std::vector& enabled_apps) const { + const policy_table::ApplicationPolicies& policies = + pt_->policy_table.app_policies_section.apps; + for (policy_table::ApplicationPolicies::const_iterator it = policies.begin(); + it != policies.end(); + ++it) { + auto app_policy = (*it).second; + if (app_policy.enabled.is_initialized() && *app_policy.enabled) { + enabled_apps.push_back((*it).first); + } + } +} + const bool CacheManager::GetCloudAppParameters( const std::string& policy_app_id, std::string& endpoint, + std::string& certificate, std::string& auth_token, std::string& cloud_transport_type, std::string& hybrid_app_preference) const { @@ -1403,6 +1418,9 @@ const bool CacheManager::GetCloudAppParameters( auto app_policy = (*policy_iter).second; endpoint = app_policy.endpoint.is_initialized() ? *app_policy.endpoint : std::string(); + certificate = app_policy.certificate.is_initialized() + ? *app_policy.certificate + : std::string(); auth_token = app_policy.auth_token.is_initialized() ? *app_policy.auth_token : std::string(); cloud_transport_type = app_policy.cloud_transport_type.is_initialized() diff --git a/src/components/policy/policy_external/src/policy_manager_impl.cc b/src/components/policy/policy_external/src/policy_manager_impl.cc index e7538fa1b0..31cc212254 100644 --- a/src/components/policy/policy_external/src/policy_manager_impl.cc +++ b/src/components/policy/policy_external/src/policy_manager_impl.cc @@ -725,14 +725,21 @@ const VehicleInfo PolicyManagerImpl::GetVehicleInfo() const { return cache_->GetVehicleInfo(); } +void PolicyManagerImpl::GetEnabledCloudApps( + std::vector& enabled_apps) const { + cache_->GetEnabledCloudApps(enabled_apps); +} + const bool PolicyManagerImpl::GetCloudAppParameters( const std::string& policy_app_id, std::string& endpoint, + std::string& certificate, std::string& auth_token, std::string& cloud_transport_type, std::string& hybrid_app_preference) const { return cache_->GetCloudAppParameters(policy_app_id, endpoint, + certificate, auth_token, cloud_transport_type, hybrid_app_preference); diff --git a/src/components/policy/policy_external/src/policy_table/types.cc b/src/components/policy/policy_external/src/policy_table/types.cc index 4867eef281..977448dacd 100644 --- a/src/components/policy/policy_external/src/policy_table/types.cc +++ b/src/components/policy/policy_external/src/policy_table/types.cc @@ -247,7 +247,8 @@ ApplicationParams::ApplicationParams(const Json::Value* value__) , endpoint(impl::ValueMember(value__, "endpoint")) , enabled(impl::ValueMember(value__, "enabled")) , auth_token(impl::ValueMember(value__, "auth_token")) - , cloud_transport_type(impl::ValueMember(value__, "cloud_transport_type")) {} + , cloud_transport_type(impl::ValueMember(value__, "cloud_transport_type")) { +} Json::Value ApplicationParams::ToJsonValue() const { Json::Value result__(PolicyBase::ToJsonValue()); diff --git a/src/components/policy/policy_external/src/sql_pt_ext_representation.cc b/src/components/policy/policy_external/src/sql_pt_ext_representation.cc index 6a40e6d135..43961815d6 100644 --- a/src/components/policy/policy_external/src/sql_pt_ext_representation.cc +++ b/src/components/policy/policy_external/src/sql_pt_ext_representation.cc @@ -760,8 +760,9 @@ bool SQLPTExtRepresentation::SaveSpecificAppPolicy( std::string(policy_table::EnumToJsonString( *app.second.hybrid_app_preference))) : app_query.Bind(9); - app.second.endpoint.is_initialized() ? app_query.Bind(10, *app.second.endpoint) - : app_query.Bind(10); + app.second.endpoint.is_initialized() + ? app_query.Bind(10, *app.second.endpoint) + : app_query.Bind(10); app.second.enabled.is_initialized() ? app_query.Bind(11, *app.second.enabled) : app_query.Bind(11); app.second.auth_token.is_initialized() diff --git a/src/components/policy/policy_regular/include/policy/cache_manager.h b/src/components/policy/policy_regular/include/policy/cache_manager.h index 119a0c0519..39f9cc73cd 100644 --- a/src/components/policy/policy_regular/include/policy/cache_manager.h +++ b/src/components/policy/policy_regular/include/policy/cache_manager.h @@ -146,12 +146,22 @@ class CacheManager : public CacheManagerInterface { */ virtual const VehicleInfo GetVehicleInfo() const; + /** + * @brief Get a list of enabled cloud applications + * @param enabled_apps List filled with the policy app id of each enabled + * cloud application + */ + virtual void GetEnabledCloudApps( + std::vector& enabled_apps) const; + /** * @brief Get cloud app policy information, all fields that aren't set for a * given app will be filled with empty strings * @param policy_app_id Unique application id * @param endpoint Filled the endpoint used to connect to the cloud * application + * @param certificate Filled with the certificate used to for creating a + * secure connection to the cloud application * @param auth_token Filled with the token used for authentication when * reconnecting to the cloud app * @param cloud_transport_type Filled with the transport type used by the @@ -163,6 +173,7 @@ class CacheManager : public CacheManagerInterface { virtual const bool GetCloudAppParameters( const std::string& policy_app_id, std::string& endpoint, + std::string& certificate, std::string& auth_token, std::string& cloud_transport_type, std::string& hybrid_app_preference) const; diff --git a/src/components/policy/policy_regular/include/policy/cache_manager_interface.h b/src/components/policy/policy_regular/include/policy/cache_manager_interface.h index 9408809f1e..3b2b10d0bc 100644 --- a/src/components/policy/policy_regular/include/policy/cache_manager_interface.h +++ b/src/components/policy/policy_regular/include/policy/cache_manager_interface.h @@ -151,12 +151,22 @@ class CacheManagerInterface { */ virtual const VehicleInfo GetVehicleInfo() const = 0; + /** + * @brief Get a list of enabled cloud applications + * @param enabled_apps List filled with the policy app id of each enabled + * cloud application + */ + virtual void GetEnabledCloudApps( + std::vector& enabled_apps) const = 0; + /** * @brief Get cloud app policy information, all fields that aren't set for a * given app will be filled with empty strings * @param policy_app_id Unique application id * @param endpoint Filled the endpoint used to connect to the cloud * application + * @param certificate Filled with the certificate used to for creating a + * secure connection to the cloud application * @param auth_token Filled with the token used for authentication when * reconnecting to the cloud app * @param cloud_transport_type Filled with the transport type used by the @@ -168,6 +178,7 @@ class CacheManagerInterface { virtual const bool GetCloudAppParameters( const std::string& policy_app_id, std::string& endpoint, + std::string& certificate, std::string& auth_token, std::string& cloud_transport_type, std::string& hybrid_app_preference) const = 0; @@ -199,8 +210,9 @@ class CacheManagerInterface { * should be used * @param hybrid_app_preference Hybrid app user preference */ - virtual void SetHybridAppPreference(const std::string& policy_app_id, - const std::string& hybrid_app_preference) = 0; + virtual void SetHybridAppPreference( + const std::string& policy_app_id, + const std::string& hybrid_app_preference) = 0; /** * @brief Allows to update 'vin' field in module_meta table. diff --git a/src/components/policy/policy_regular/include/policy/policy_manager_impl.h b/src/components/policy/policy_regular/include/policy/policy_manager_impl.h index e1221b613f..311ced31d2 100644 --- a/src/components/policy/policy_regular/include/policy/policy_manager_impl.h +++ b/src/components/policy/policy_regular/include/policy/policy_manager_impl.h @@ -564,12 +564,22 @@ class PolicyManagerImpl : public PolicyManager { */ const VehicleInfo GetVehicleInfo() const OVERRIDE; + /** + * @brief Get a list of enabled cloud applications + * @param enabled_apps List filled with the policy app id of each enabled + * cloud application + */ + void GetEnabledCloudApps( + std::vector& enabled_apps) const OVERRIDE; + /** * @brief Get cloud app policy information, all fields that aren't set for a * given app will be filled with empty strings * @param policy_app_id Unique application id * @param endpoint Filled the endpoint used to connect to the cloud * application + * @param certificate Filled with the certificate used to for creating a + * secure connection to the cloud application * @param auth_token Filled with the token used for authentication when * reconnecting to the cloud app * @param cloud_transport_type Filled with the transport type used by the @@ -581,6 +591,7 @@ class PolicyManagerImpl : public PolicyManager { const bool GetCloudAppParameters( const std::string& policy_app_id, std::string& endpoint, + std::string& certificate, std::string& auth_token, std::string& cloud_transport_type, std::string& hybrid_app_preference) const OVERRIDE; @@ -591,7 +602,7 @@ class PolicyManagerImpl : public PolicyManager { */ void SetCloudAppEnabled(const std::string& policy_app_id, const bool enabled) OVERRIDE; - + /** * @brief Set an app's auth token * @param auth_token Cloud app authentication token diff --git a/src/components/policy/policy_regular/src/cache_manager.cc b/src/components/policy/policy_regular/src/cache_manager.cc index 68e70c107d..9292c389b9 100644 --- a/src/components/policy/policy_regular/src/cache_manager.cc +++ b/src/components/policy/policy_regular/src/cache_manager.cc @@ -682,9 +682,24 @@ const policy::VehicleInfo CacheManager::GetVehicleInfo() const { return vehicle_info; } +void CacheManager::GetEnabledCloudApps( + std::vector& enabled_apps) const { + const policy_table::ApplicationPolicies& policies = + pt_->policy_table.app_policies_section.apps; + for (policy_table::ApplicationPolicies::const_iterator it = policies.begin(); + it != policies.end(); + ++it) { + auto app_policy = (*it).second; + if (app_policy.enabled.is_initialized() && *app_policy.enabled) { + enabled_apps.push_back((*it).first); + } + } +} + const bool CacheManager::GetCloudAppParameters( const std::string& policy_app_id, std::string& endpoint, + std::string& certificate, std::string& auth_token, std::string& cloud_transport_type, std::string& hybrid_app_preference) const { @@ -701,6 +716,9 @@ const bool CacheManager::GetCloudAppParameters( cloud_transport_type = app_policy.cloud_transport_type.is_initialized() ? *app_policy.cloud_transport_type : std::string(); + certificate = app_policy.certificate.is_initialized() + ? *app_policy.certificate + : std::string(); hybrid_app_preference = app_policy.hybrid_app_preference.is_initialized() ? EnumToJsonString(*app_policy.hybrid_app_preference) diff --git a/src/components/policy/policy_regular/src/policy_manager_impl.cc b/src/components/policy/policy_regular/src/policy_manager_impl.cc index 9317708216..5aa29fc896 100644 --- a/src/components/policy/policy_regular/src/policy_manager_impl.cc +++ b/src/components/policy/policy_regular/src/policy_manager_impl.cc @@ -544,17 +544,28 @@ const VehicleInfo PolicyManagerImpl::GetVehicleInfo() const { return cache_->GetVehicleInfo(); } +void PolicyManagerImpl::GetEnabledCloudApps( + std::vector& enabled_apps) const { + cache_->GetEnabledCloudApps(enabled_apps); +} + const bool PolicyManagerImpl::GetCloudAppParameters( const std::string& policy_app_id, std::string& endpoint, + std::string& certificate, std::string& auth_token, std::string& cloud_transport_type, std::string& hybrid_app_preference) const { - return cache_->GetCloudAppParameters(policy_app_id, endpoint, auth_token, cloud_transport_type, hybrid_app_preference); + return cache_->GetCloudAppParameters(policy_app_id, + endpoint, + certificate, + auth_token, + cloud_transport_type, + hybrid_app_preference); } -void PolicyManagerImpl::SetCloudAppEnabled( - const std::string& policy_app_id, const bool enabled) { +void PolicyManagerImpl::SetCloudAppEnabled(const std::string& policy_app_id, + const bool enabled) { cache_->SetCloudAppEnabled(policy_app_id, enabled); } -- cgit v1.2.1 From bf9a8789f419d054e2ad920725c2079f9d511c15 Mon Sep 17 00:00:00 2001 From: jacobkeeler Date: Fri, 9 Nov 2018 10:38:23 -0500 Subject: Add missing auth token in select app query --- src/components/policy/policy_external/src/sql_pt_ext_queries.cc | 2 +- src/components/policy/policy_external/src/sql_pt_queries.cc | 3 ++- src/components/policy/policy_regular/src/sql_pt_queries.cc | 3 ++- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/components/policy/policy_external/src/sql_pt_ext_queries.cc b/src/components/policy/policy_external/src/sql_pt_ext_queries.cc index f7e1acb59a..32320b6d6c 100644 --- a/src/components/policy/policy_external/src/sql_pt_ext_queries.cc +++ b/src/components/policy/policy_external/src/sql_pt_ext_queries.cc @@ -236,7 +236,7 @@ const std::string kSelectPreconsentedGroupsId = const std::string kSelectAppPolicies = "SELECT `id`, `priority_value`, `default_hmi`, `keep_context`, " " `steal_focus`, `memory_kb`, `heart_beat_timeout_ms`, `certificate`, " - " `hybrid_app_preference_value`, `endpoint`, `enabled`, " + " `hybrid_app_preference_value`, `endpoint`, `enabled`, `auth_token` " " `cloud_transport_type` FROM `application`"; const std::string kSelectFunctionalGroupNames = diff --git a/src/components/policy/policy_external/src/sql_pt_queries.cc b/src/components/policy/policy_external/src/sql_pt_queries.cc index 8c4227963a..162d6957e7 100644 --- a/src/components/policy/policy_external/src/sql_pt_queries.cc +++ b/src/components/policy/policy_external/src/sql_pt_queries.cc @@ -774,7 +774,8 @@ const std::string kSelectUserMsgsVersion = const std::string kSelectAppPolicies = "SELECT `id`, `priority_value`, `memory_kb`, " " `heart_beat_timeout_ms`, `certificate`, `hybrid_app_preference_value`, " - " `endpoint`, `enabled`, `cloud_transport_type` FROM `application`"; + " `endpoint`, `enabled`, `auth_token`, `cloud_transport_type` FROM " + " `application`"; const std::string kCollectFriendlyMsg = "SELECT * FROM `message`"; diff --git a/src/components/policy/policy_regular/src/sql_pt_queries.cc b/src/components/policy/policy_regular/src/sql_pt_queries.cc index ef6c7f2a03..297031d4c0 100644 --- a/src/components/policy/policy_regular/src/sql_pt_queries.cc +++ b/src/components/policy/policy_regular/src/sql_pt_queries.cc @@ -709,7 +709,8 @@ const std::string kSelectUserMsgsVersion = const std::string kSelectAppPolicies = "SELECT `id`, `priority_value`, `memory_kb`, " " `heart_beat_timeout_ms`, `certificate`, `hybrid_app_preference_value`, " - " `endpoint`, `enabled`, `cloud_transport_type` FROM `application`"; + " `endpoint`, `enabled`, `auth_token`, `cloud_transport_type` FROM " + " `application`"; const std::string kCollectFriendlyMsg = "SELECT * FROM `message`"; -- cgit v1.2.1 From 6441bdcc5fecb267ae1f0aa3bd6647b25822d587 Mon Sep 17 00:00:00 2001 From: JackLivio Date: Fri, 9 Nov 2018 13:18:22 -0500 Subject: Pending cloud connection created via policies on startup --- src/3rd_party/CMakeLists.txt | 6 ++-- .../src/application_manager_impl.cc | 14 +++++++- .../connection_handler/connection_handler_impl.h | 8 +++++ .../src/connection_handler_impl.cc | 40 +++++++++++++++++---- .../hmi_message_handler/src/websocket_session.cc | 1 - .../transport_adapter/transport_adapter.h | 2 ++ .../transport_adapter/transport_adapter_event.h | 3 +- .../transport_manager/transport_manager_listener.h | 8 +++++ .../transport_manager_listener_empty.h | 9 +++++ src/components/interfaces/HMI_API.xml | 1 + .../protocol_handler/protocol_handler_impl.h | 4 +++ .../protocol_handler/src/protocol_handler_impl.cc | 5 +++ src/components/transport_manager/CMakeLists.txt | 6 ++++ .../cloud/cloud_websocket_transport_adapter.h | 2 ++ .../transport_adapter_controller.h | 10 ++++++ .../transport_adapter/transport_adapter_impl.h | 16 ++++++++- .../transport_adapter/transport_adapter_listener.h | 13 +++++++ .../transport_adapter_listener_impl.h | 13 +++++++ .../cloud/cloud_websocket_connection_factory.cc | 4 +-- .../src/cloud/cloud_websocket_transport_adapter.cc | 42 ++++++++++++++++++++++ .../transport_adapter/transport_adapter_impl.cc | 22 +++++++++++- .../transport_adapter_listener_impl.cc | 21 +++++++++++ .../src/transport_manager_impl.cc | 35 ++++++++++++++++++ 23 files changed, 269 insertions(+), 16 deletions(-) diff --git a/src/3rd_party/CMakeLists.txt b/src/3rd_party/CMakeLists.txt index bdb96de417..60d68e9d60 100644 --- a/src/3rd_party/CMakeLists.txt +++ b/src/3rd_party/CMakeLists.txt @@ -209,7 +209,7 @@ else() ) endif() -find_package(Boost 1.66.0 COMPONENTS system thread date_time filesystem) +find_package(Boost 1.66.0 COMPONENTS system thread date_time filesystem regex) set(BOOST_LIB_SOURCE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/boost_src) set(BOOST_LIBS_DIRECTORY ${3RD_PARTY_INSTALL_PREFIX}/lib) SET_PROPERTY(GLOBAL PROPERTY GLOBAL_BOOST_LIBS ${BOOST_LIBS_DIRECTORY}) @@ -226,9 +226,9 @@ if (NOT ${Boost_FOUND}) URL https://dl.bintray.com/boostorg/release/1.66.0/source/boost_1_66_0.tar.gz DOWNLOAD_DIR ${BOOST_LIB_SOURCE_DIRECTORY} SOURCE_DIR ${BOOST_LIB_SOURCE_DIRECTORY} - CONFIGURE_COMMAND ./bootstrap.sh --with-libraries=system,thread,date_time,filesystem --prefix=${3RD_PARTY_INSTALL_PREFIX} + CONFIGURE_COMMAND ./bootstrap.sh --with-libraries=system,thread,date_time,filesystem,regex --prefix=${3RD_PARTY_INSTALL_PREFIX} BUILD_COMMAND ./b2 - INSTALL_COMMAND ${BOOST_INSTALL_COMMAND} --with-system --with-thread --with-date_time --with-filesystem --prefix=${3RD_PARTY_INSTALL_PREFIX} > boost_install.log + INSTALL_COMMAND ${BOOST_INSTALL_COMMAND} --with-system --with-thread --with-date_time --with-filesystem --with-regex --prefix=${3RD_PARTY_INSTALL_PREFIX} > boost_install.log INSTALL_DIR ${3RD_PARTY_INSTALL_PREFIX} BUILD_IN_SOURCE true ) diff --git a/src/components/application_manager/src/application_manager_impl.cc b/src/components/application_manager/src/application_manager_impl.cc index 4a0bb63bae..061f3885a9 100644 --- a/src/components/application_manager/src/application_manager_impl.cc +++ b/src/components/application_manager/src/application_manager_impl.cc @@ -98,7 +98,9 @@ DeviceTypes devicesType = { std::make_pair(std::string("USB_IOS_DEVICE_MODE"), hmi_apis::Common_TransportType::USB_IOS), std::make_pair(std::string("CARPLAY_WIRELESS_IOS"), - hmi_apis::Common_TransportType::WIFI)}; + hmi_apis::Common_TransportType::WIFI), + std::make_pair(std::string("CLOUD_WEBSOCKET"), + hmi_apis::Common_TransportType::CLOUD_WEBSOCKET)}; } /** @@ -798,6 +800,16 @@ void ApplicationManagerImpl::CollectCloudAppInformation() { cloud_transport_type, hybrid_app_preference); connection_handler().AddCloudAppDevice(*it, endpoint, cloud_transport_type); + std::string device_mac; + std::string connection_type; + /*ApplicationSharedPtr application( + new ApplicationImpl(app_id, + policy_app_id, + device_mac, + device_id, + app_name, + GetPolicyHandler().GetStatisticManager(), + *this)); */ } } diff --git a/src/components/connection_handler/include/connection_handler/connection_handler_impl.h b/src/components/connection_handler/include/connection_handler/connection_handler_impl.h index 5984f74c34..81db445829 100644 --- a/src/components/connection_handler/include/connection_handler/connection_handler_impl.h +++ b/src/components/connection_handler/include/connection_handler/connection_handler_impl.h @@ -164,6 +164,14 @@ class ConnectionHandlerImpl void OnScanDevicesFailed( const transport_manager::SearchDeviceError& error) OVERRIDE; + /** + * \brief Notifies about pending connection. + * + * \param connection_id ID of new connection. + **/ + void OnConnectionPending( + const transport_manager::DeviceInfo& device_info, + const transport_manager::ConnectionUID connection_id) OVERRIDE; /** * \brief Notifies about established connection. * diff --git a/src/components/connection_handler/src/connection_handler_impl.cc b/src/components/connection_handler/src/connection_handler_impl.cc index 290b1a650e..d1c62e36bb 100644 --- a/src/components/connection_handler/src/connection_handler_impl.cc +++ b/src/components/connection_handler/src/connection_handler_impl.cc @@ -246,6 +246,32 @@ void ConnectionHandlerImpl::OnScanDevicesFailed( LOG4CXX_WARN(logger_, "Scan devices failed. " << error.text()); } +void ConnectionHandlerImpl::OnConnectionPending( + const transport_manager::DeviceInfo& device_info, + const transport_manager::ConnectionUID connection_id) { + LOG4CXX_AUTO_TRACE(logger_); + LOG4CXX_DEBUG(logger_, "OnConnectionEstablished!!!: " << device_info.device_handle() << " " << device_info.name() << " " << device_info.mac_address() << " " << device_info.connection_type()); + DeviceMap::iterator it = device_list_.find(device_info.device_handle()); + if (device_list_.end() == it) { + LOG4CXX_ERROR(logger_, "Unknown device!"); + return; + } + LOG4CXX_DEBUG(logger_, + "Add Pending Connection #" << connection_id << " to the list."); + + + //todo maybe create a seperate "pending_connection_list" + sync_primitives::AutoWriteLock lock(connection_list_lock_); + if (connection_list_.find(connection_id) == connection_list_.end()) { + connection_list_.insert(ConnectionList::value_type( + connection_id, + new Connection(connection_id, + device_info.device_handle(), + this, + get_settings().heart_beat_timeout()))); + } +} + void ConnectionHandlerImpl::OnConnectionEstablished( const transport_manager::DeviceInfo& device_info, const transport_manager::ConnectionUID connection_id) { @@ -259,12 +285,14 @@ void ConnectionHandlerImpl::OnConnectionEstablished( LOG4CXX_DEBUG(logger_, "Add Connection #" << connection_id << " to the list."); sync_primitives::AutoWriteLock lock(connection_list_lock_); - connection_list_.insert(ConnectionList::value_type( - connection_id, - new Connection(connection_id, - device_info.device_handle(), - this, - get_settings().heart_beat_timeout()))); + if (connection_list_.find(connection_id) == connection_list_.end()) { + connection_list_.insert(ConnectionList::value_type( + connection_id, + new Connection(connection_id, + device_info.device_handle(), + this, + get_settings().heart_beat_timeout()))); + } } void ConnectionHandlerImpl::OnConnectionFailed( diff --git a/src/components/hmi_message_handler/src/websocket_session.cc b/src/components/hmi_message_handler/src/websocket_session.cc index 041a89ef82..a148f48661 100644 --- a/src/components/hmi_message_handler/src/websocket_session.cc +++ b/src/components/hmi_message_handler/src/websocket_session.cc @@ -71,7 +71,6 @@ bool WebsocketSession::IsShuttingDown() { } void WebsocketSession::Recv(boost::system::error_code ec) { - printf("!!!server recv connection accepted\n"); if (shutdown_) { return; } diff --git a/src/components/include/transport_manager/transport_adapter/transport_adapter.h b/src/components/include/transport_manager/transport_adapter/transport_adapter.h index 6af29aa7c2..d47c53b69c 100644 --- a/src/components/include/transport_manager/transport_adapter/transport_adapter.h +++ b/src/components/include/transport_manager/transport_adapter/transport_adapter.h @@ -348,6 +348,8 @@ class TransportAdapter { */ virtual TransportConfig GetTransportConfiguration() const = 0; + virtual void CreateDevice(const std::string& uid) = 0; + #ifdef TELEMETRY_MONITOR /** * @brief Return Time metric observer diff --git a/src/components/include/transport_manager/transport_adapter/transport_adapter_event.h b/src/components/include/transport_manager/transport_adapter/transport_adapter_event.h index fd1d693067..921562333b 100644 --- a/src/components/include/transport_manager/transport_adapter/transport_adapter_event.h +++ b/src/components/include/transport_manager/transport_adapter/transport_adapter_event.h @@ -58,7 +58,8 @@ enum class EventTypeEnum { ON_COMMUNICATION_ERROR, ON_UNEXPECTED_DISCONNECT, ON_TRANSPORT_SWITCH_REQUESTED, - ON_TRANSPORT_CONFIG_UPDATED + ON_TRANSPORT_CONFIG_UPDATED, + ON_CONNECT_PENDING }; class TransportAdapterEvent { diff --git a/src/components/include/transport_manager/transport_manager_listener.h b/src/components/include/transport_manager/transport_manager_listener.h index 6c3f6e2eaa..2d7b2510a5 100644 --- a/src/components/include/transport_manager/transport_manager_listener.h +++ b/src/components/include/transport_manager/transport_manager_listener.h @@ -100,6 +100,14 @@ class TransportManagerListener { */ virtual void OnScanDevicesFailed(const SearchDeviceError& error) = 0; + /** + * @brief Reaction to the event, when connection is pending. + * + * @param devcie_info Variable that hold information about device. + * @param connection_id connection unique identifier. + */ + virtual void OnConnectionPending(const DeviceInfo& device_info, + const ConnectionUID connection_id) = 0; /** * @brief Reaction to the event, when connection is established. * diff --git a/src/components/include/transport_manager/transport_manager_listener_empty.h b/src/components/include/transport_manager/transport_manager_listener_empty.h index 08b2b77c30..d8104a62a9 100644 --- a/src/components/include/transport_manager/transport_manager_listener_empty.h +++ b/src/components/include/transport_manager/transport_manager_listener_empty.h @@ -98,6 +98,15 @@ class TransportManagerListenerEmpty : public TransportManagerListener { */ void OnScanDevicesFailed(const SearchDeviceError& error) OVERRIDE {} + /** + * @brief Reaction to the event, when connection is pending. + * + * @param devcie_info Variable that hold information about device. + * @param connection_id connection unique identifier. + */ + void OnConnectionPending(const DeviceInfo& device_info, + const ConnectionUID connection_id) OVERRIDE {} + /** * @brief Reaction to the event, when connection is established. * diff --git a/src/components/interfaces/HMI_API.xml b/src/components/interfaces/HMI_API.xml index 97df559ef5..2c2adc6b36 100644 --- a/src/components/interfaces/HMI_API.xml +++ b/src/components/interfaces/HMI_API.xml @@ -72,6 +72,7 @@ + diff --git a/src/components/protocol_handler/include/protocol_handler/protocol_handler_impl.h b/src/components/protocol_handler/include/protocol_handler/protocol_handler_impl.h index 3e7d64e9d2..ccf6082a18 100644 --- a/src/components/protocol_handler/include/protocol_handler/protocol_handler_impl.h +++ b/src/components/protocol_handler/include/protocol_handler/protocol_handler_impl.h @@ -512,6 +512,10 @@ class ProtocolHandlerImpl void OnTMMessageSendFailed(const transport_manager::DataSendError& error, const RawMessagePtr message) OVERRIDE; + void OnConnectionPending( + const transport_manager::DeviceInfo& device_info, + const transport_manager::ConnectionUID connection_id) OVERRIDE; + void OnConnectionEstablished( const transport_manager::DeviceInfo& device_info, const transport_manager::ConnectionUID connection_id) OVERRIDE; diff --git a/src/components/protocol_handler/src/protocol_handler_impl.cc b/src/components/protocol_handler/src/protocol_handler_impl.cc index d03030b747..3fb21d7d0d 100644 --- a/src/components/protocol_handler/src/protocol_handler_impl.cc +++ b/src/components/protocol_handler/src/protocol_handler_impl.cc @@ -1087,6 +1087,11 @@ void ProtocolHandlerImpl::OnTMMessageSendFailed( << "Error_text: " << error.text()); } +void ProtocolHandlerImpl::OnConnectionPending( + const transport_manager::DeviceInfo& device_info, + const transport_manager::ConnectionUID connection_id) { +} + void ProtocolHandlerImpl::OnConnectionEstablished( const transport_manager::DeviceInfo& device_info, const transport_manager::ConnectionUID connection_id) { diff --git a/src/components/transport_manager/CMakeLists.txt b/src/components/transport_manager/CMakeLists.txt index 2f734b3a05..286e62b795 100644 --- a/src/components/transport_manager/CMakeLists.txt +++ b/src/components/transport_manager/CMakeLists.txt @@ -72,6 +72,11 @@ else() ) endif() +if(BUILD_CLOUD_APP_SUPPORT) + GET_PROPERTY(BOOST_LIBS_DIRECTORY GLOBAL PROPERTY GLOBAL_BOOST_LIBS) + list(APPEND LIBRARIES boost_system boost_regex -L${BOOST_LIBS_DIRECTORY}) +endif() + if(BUILD_USB_SUPPORT) if (CMAKE_SYSTEM_NAME STREQUAL "Linux") set(EXCLUDE_PATHS @@ -129,3 +134,4 @@ endif() if(BUILD_TESTS) add_subdirectory(test) endif() + diff --git a/src/components/transport_manager/include/transport_manager/cloud/cloud_websocket_transport_adapter.h b/src/components/transport_manager/include/transport_manager/cloud/cloud_websocket_transport_adapter.h index ad31bd33b3..062b478c29 100644 --- a/src/components/transport_manager/include/transport_manager/cloud/cloud_websocket_transport_adapter.h +++ b/src/components/transport_manager/include/transport_manager/cloud/cloud_websocket_transport_adapter.h @@ -88,6 +88,8 @@ class CloudWebsocketTransportAdapter : public TransportAdapterImpl { */ virtual bool Restore(); + void CreateDevice(const std::string& uid) OVERRIDE; + private: /** * @brief Keeps transport specific configuration diff --git a/src/components/transport_manager/include/transport_manager/transport_adapter/transport_adapter_controller.h b/src/components/transport_manager/include/transport_manager/transport_adapter/transport_adapter_controller.h index 69d76b4b2b..8bc39596b6 100644 --- a/src/components/transport_manager/include/transport_manager/transport_adapter/transport_adapter_controller.h +++ b/src/components/transport_manager/include/transport_manager/transport_adapter/transport_adapter_controller.h @@ -99,6 +99,16 @@ class TransportAdapterController { const DeviceUID& device_handle, const ApplicationHandle& app_handle) = 0; + /** + * @brief Set state of specified connection - PENDING and launch + *OnConnectPending event in device adapter listener. + * + * @param devcie_handle Device unique identifier. + * @param app_handle Handle of application. + */ + virtual void ConnectPending(const DeviceUID& device_handle, + const ApplicationHandle& app_handle) = 0; + /** * @brief Make state of specified connection - ESTABLISHED and launch *OnConnectDone event in device adapter listener. diff --git a/src/components/transport_manager/include/transport_manager/transport_adapter/transport_adapter_impl.h b/src/components/transport_manager/include/transport_manager/transport_adapter/transport_adapter_impl.h index 078f93b32f..ccc025b60e 100644 --- a/src/components/transport_manager/include/transport_manager/transport_adapter/transport_adapter_impl.h +++ b/src/components/transport_manager/include/transport_manager/transport_adapter/transport_adapter_impl.h @@ -305,6 +305,16 @@ class TransportAdapterImpl : public TransportAdapter, const ApplicationHandle& app_handle, const CommunicationError& error) OVERRIDE; + /** + * @brief Set state of specified connection - PENDING and launch + *OnConnectPending event in device adapter listener. + * + * @param devcie_handle Device unique identifier. + * @param app_handle Handle of application. + */ + void ConnectPending(const DeviceUID& device_handle, + const ApplicationHandle& app_handle) OVERRIDE; + /** * @brief Set state of specified connection - ESTABLISHED and launch *OnConnectDone event in device adapter listener. @@ -434,6 +444,10 @@ class TransportAdapterImpl : public TransportAdapter, return TransportConfig(); } + void CreateDevice(const std::string& uid) OVERRIDE { + return; + } + /** * @brief Return name of device. * @@ -564,7 +578,7 @@ class TransportAdapterImpl : public TransportAdapter, ConnectionSPtr connection; DeviceUID device_id; ApplicationHandle app_handle; - enum { NEW, ESTABLISHED, FINALISING } state; + enum { NEW, ESTABLISHED, FINALISING, PENDING, RETRY } state; }; /** diff --git a/src/components/transport_manager/include/transport_manager/transport_adapter/transport_adapter_listener.h b/src/components/transport_manager/include/transport_manager/transport_adapter/transport_adapter_listener.h index 4606bac2d4..fe71983ab7 100644 --- a/src/components/transport_manager/include/transport_manager/transport_adapter/transport_adapter_listener.h +++ b/src/components/transport_manager/include/transport_manager/transport_adapter/transport_adapter_listener.h @@ -91,6 +91,19 @@ class TransportAdapterListener { virtual void OnFindNewApplicationsRequest( const TransportAdapter* adapter) = 0; + /** + * @brief Search specified device adapter in the container of shared pointers + * to device adapters to be sure it is available, + * launch event ON_CONNECT_PENDING in transport manager. + * + * @param device_adater Pointer to the device adapter. + * @param device_handle Device unique identifier. + * @param app_id Handle of application. + */ + virtual void OnConnectPending(const TransportAdapter* adapter, + const DeviceUID& device_handle, + const ApplicationHandle& app_id) = 0; + /** * @brief Search specified device adapter in the container of shared pointers *to device adapters to be sure it is available, diff --git a/src/components/transport_manager/include/transport_manager/transport_adapter/transport_adapter_listener_impl.h b/src/components/transport_manager/include/transport_manager/transport_adapter/transport_adapter_listener_impl.h index a744400279..f4a5062eac 100644 --- a/src/components/transport_manager/include/transport_manager/transport_adapter/transport_adapter_listener_impl.h +++ b/src/components/transport_manager/include/transport_manager/transport_adapter/transport_adapter_listener_impl.h @@ -87,6 +87,19 @@ class TransportAdapterListenerImpl virtual void OnFindNewApplicationsRequest(const TransportAdapter* adapter); + /** + * @brief Search specified device adapter in the container of shared pointers + * to device adapters to be sure it is available, + * launch event ON_CONNECT_PENDING in transport manager. + * + * @param device_adater Pointer to the device adapter. + * @param device_handle Device unique identifier. + * @param app_id Handle of application. + */ + virtual void OnConnectPending(const TransportAdapter* adapter, + const DeviceUID& device_handle, + const ApplicationHandle& app_id); + /** * @brief Search specified device adapter in the container of shared pointers *to device adapters to be sure it is available, diff --git a/src/components/transport_manager/src/cloud/cloud_websocket_connection_factory.cc b/src/components/transport_manager/src/cloud/cloud_websocket_connection_factory.cc index d566dd9bf8..9265adb7f3 100644 --- a/src/components/transport_manager/src/cloud/cloud_websocket_connection_factory.cc +++ b/src/components/transport_manager/src/cloud/cloud_websocket_connection_factory.cc @@ -50,7 +50,7 @@ CloudWebsocketConnectionFactory::CloudWebsocketConnectionFactory( : controller_(controller) {} TransportAdapter::Error CloudWebsocketConnectionFactory::Init() { - DeviceUID device_id = "Cloud"; + /*DeviceUID device_id = "Cloud"; ApplicationHandle app_handle = 100; printf("Calling create connection\n"); @@ -67,7 +67,7 @@ TransportAdapter::Error CloudWebsocketConnectionFactory::Init() { const TransportAdapter::Error err = this->CreateConnection(std::string(device_id+host+port), app_handle); - LOG4CXX_DEBUG(logger_, err); + LOG4CXX_DEBUG(logger_, err);*/ return TransportAdapter::OK; } diff --git a/src/components/transport_manager/src/cloud/cloud_websocket_transport_adapter.cc b/src/components/transport_manager/src/cloud/cloud_websocket_transport_adapter.cc index 29ea6e5b27..746eafbcc3 100644 --- a/src/components/transport_manager/src/cloud/cloud_websocket_transport_adapter.cc +++ b/src/components/transport_manager/src/cloud/cloud_websocket_transport_adapter.cc @@ -33,6 +33,13 @@ #include "transport_manager/cloud/cloud_websocket_transport_adapter.h" #include "transport_manager/cloud/cloud_websocket_connection_factory.h" + +#include "transport_manager/cloud/cloud_device.h" +#include "transport_manager/cloud/websocket_client_connection.h" + + +#include + namespace transport_manager { namespace transport_adapter { @@ -65,6 +72,41 @@ bool CloudWebsocketTransportAdapter::Restore() { // todo decide if resumption is return true; } +void CloudWebsocketTransportAdapter::CreateDevice(const std::string& uid) { + boost::regex pattern ("(wss?):\\/\\/([A-Z\\d\\.-]{2,})\\.([A-Z]{2,})(:\\d{2,4})", boost::regex::icase); + std::string str = uid; + if (!boost::regex_match(str, pattern)) { + LOG4CXX_DEBUG(logger_, "Invalid Endpoint: " << uid); + return; + } + + LOG4CXX_DEBUG(logger_, "Valid Endpoint: " << uid); + std::size_t pos = uid.find(":"); + pos = uid.find(":", pos+1); + std::size_t size = uid.length(); + std::string host = uid.substr(0, size - pos); + std::string port = uid.substr(pos); + std::string device_id = uid; + + LOG4CXX_DEBUG(logger_, "Creating Cloud Device For Host: " << host << " and Port: " << port); + + auto cloud_device = std::make_shared(host, port, device_id); + + DeviceVector devices{cloud_device}; + + SearchDeviceDone(devices); + + //Create connection object, do not start until app is activated + std::shared_ptr connection = + std::make_shared( + uid, 0, this); + + ConnectionCreated(connection, uid, 0); + ConnectDone(uid, 0); + + return; +} + diff --git a/src/components/transport_manager/src/transport_adapter/transport_adapter_impl.cc b/src/components/transport_manager/src/transport_adapter/transport_adapter_impl.cc index 346139cbd2..088cc2efb5 100644 --- a/src/components/transport_manager/src/transport_adapter/transport_adapter_impl.cc +++ b/src/components/transport_manager/src/transport_adapter/transport_adapter_impl.cc @@ -60,7 +60,9 @@ DeviceTypes devicesType = { std::make_pair(DeviceType::IOS_USB_DEVICE_MODE, std::string("USB_IOS_DEVICE_MODE")), std::make_pair(DeviceType::IOS_CARPLAY_WIRELESS, - std::string("CARPLAY_WIRELESS_IOS"))}; + std::string("CARPLAY_WIRELESS_IOS")), + std::make_pair(DeviceType::CLOUD_WEBSOCKET, std::string("CLOUD_WEBSOCKET")) + }; } TransportAdapterImpl::TransportAdapterImpl( @@ -743,6 +745,24 @@ DeviceSptr TransportAdapterImpl::FindDevice(const DeviceUID& device_id) const { return ret; } +void TransportAdapterImpl::ConnectPending(const DeviceUID& device_id, + const ApplicationHandle& app_handle) { + connections_lock_.AcquireForReading(); + ConnectionMap::iterator it_conn = + connections_.find(std::make_pair(device_id, app_handle)); + if (it_conn != connections_.end()) { + ConnectionInfo& info = it_conn->second; + info.state = ConnectionInfo::PENDING; + } + connections_lock_.Release(); + + for (TransportAdapterListenerList::iterator it = listeners_.begin(); + it != listeners_.end(); + ++it) { + (*it)->OnConnectPending(this, device_id, app_handle); + } +} + void TransportAdapterImpl::ConnectDone(const DeviceUID& device_id, const ApplicationHandle& app_handle) { LOG4CXX_TRACE(logger_, diff --git a/src/components/transport_manager/src/transport_adapter/transport_adapter_listener_impl.cc b/src/components/transport_manager/src/transport_adapter/transport_adapter_listener_impl.cc index 544cdde999..73750fe2f3 100644 --- a/src/components/transport_manager/src/transport_adapter/transport_adapter_listener_impl.cc +++ b/src/components/transport_manager/src/transport_adapter/transport_adapter_listener_impl.cc @@ -116,6 +116,27 @@ void TransportAdapterListenerImpl::OnFindNewApplicationsRequest( LOG4CXX_TRACE(logger_, "exit"); } +void TransportAdapterListenerImpl::OnConnectPending( + const TransportAdapter* adapter, + const DeviceUID& device, + const ApplicationHandle& application_id) { + LOG4CXX_TRACE(logger_, + "enter adapter*: " << adapter << ", device: " << &device + << ", application_id: " << &application_id); + const TransportAdapterEvent event(EventTypeEnum::ON_CONNECT_PENDING, + transport_adapter_, + device, + application_id, + ::protocol_handler::RawMessagePtr(), + BaseErrorPtr(new BaseError())); + if (transport_manager_ != NULL && + transport_manager::E_SUCCESS != + transport_manager_->ReceiveEventFromDevice(event)) { + LOG4CXX_WARN(logger_, "Failed to receive event from device"); + } + LOG4CXX_TRACE(logger_, "exit"); +} + void TransportAdapterListenerImpl::OnConnectDone( const TransportAdapter* adapter, const DeviceUID& device, diff --git a/src/components/transport_manager/src/transport_manager_impl.cc b/src/components/transport_manager/src/transport_manager_impl.cc index 63fa4b451d..693dc4406b 100644 --- a/src/components/transport_manager/src/transport_manager_impl.cc +++ b/src/components/transport_manager/src/transport_manager_impl.cc @@ -130,6 +130,22 @@ void TransportManagerImpl::ReconnectionTimeout() { } void TransportManagerImpl::AddCloudDevice(const std::string& endpoint, const std::string& cloud_transport_type) { + + //todo put conversion into own function + transport_adapter::DeviceType type = transport_adapter::DeviceType::UNKNOWN; + if (cloud_transport_type == "WS") { + type = transport_adapter::DeviceType::CLOUD_WEBSOCKET; + } else { + return; + } + + std::vector::iterator ta = transport_adapters_.begin(); + for (;ta != transport_adapters_.end(); ++ta) { + if ((*ta)->GetDeviceType() == type) { + (*ta)->CreateDevice(endpoint); + } + } + return; } @@ -958,6 +974,25 @@ void TransportManagerImpl::Handle(TransportAdapterEvent event) { LOG4CXX_DEBUG(logger_, "event_type = ON_FIND_NEW_APPLICATIONS_REQUEST"); break; } + case EventTypeEnum::ON_CONNECT_PENDING: { + const DeviceHandle device_handle = converter_.UidToHandle( + event.device_uid, event.transport_adapter->GetConnectionType()); + AddConnection(ConnectionInternal(this, + event.transport_adapter, + ++connection_id_counter_, + event.device_uid, + event.application_id, + device_handle)); + RaiseEvent( + &TransportManagerListener::OnConnectionPending, + DeviceInfo(device_handle, + event.device_uid, + event.transport_adapter->DeviceName(event.device_uid), + event.transport_adapter->GetConnectionType()), + connection_id_counter_); + LOG4CXX_DEBUG(logger_, "event_type = ON_CONNECT_PENDING"); + break; + } case EventTypeEnum::ON_CONNECT_DONE: { const DeviceHandle device_handle = converter_.UidToHandle( event.device_uid, event.transport_adapter->GetConnectionType()); -- cgit v1.2.1 From 6e88b9a92a0c75def3424b75b0a9195597349231 Mon Sep 17 00:00:00 2001 From: JackLivio Date: Fri, 9 Nov 2018 14:01:14 -0500 Subject: Check if connection exists in internal connection list --- .../src/transport_manager_impl.cc | 39 ++++++++++++++++++---- 1 file changed, 32 insertions(+), 7 deletions(-) diff --git a/src/components/transport_manager/src/transport_manager_impl.cc b/src/components/transport_manager/src/transport_manager_impl.cc index 693dc4406b..ea85e9a37b 100644 --- a/src/components/transport_manager/src/transport_manager_impl.cc +++ b/src/components/transport_manager/src/transport_manager_impl.cc @@ -996,19 +996,44 @@ void TransportManagerImpl::Handle(TransportAdapterEvent event) { case EventTypeEnum::ON_CONNECT_DONE: { const DeviceHandle device_handle = converter_.UidToHandle( event.device_uid, event.transport_adapter->GetConnectionType()); - AddConnection(ConnectionInternal(this, - event.transport_adapter, - ++connection_id_counter_, - event.device_uid, - event.application_id, - device_handle)); + + int connection_id = 0; + std::vector::iterator it = connections_.begin(); + std::vector::iterator end = connections_.end(); + for(; it != end; ++it){ + if(it->transport_adapter != event.transport_adapter) { + continue; + } else if(it->Connection::device != event.device_uid) { + continue; + } else if(it->Connection::application != event.application_id) { + continue; + } else if(it->device_handle_ != device_handle) { + continue; + } else { + LOG4CXX_DEBUG(logger_, "Connection Object Already Exists"); + connection_id = it->Connection::id; + break; + } + } + + + if(it == end) { + AddConnection(ConnectionInternal(this, + event.transport_adapter, + ++connection_id_counter_, + event.device_uid, + event.application_id, + device_handle)); + connection_id = connection_id_counter_; + } + RaiseEvent( &TransportManagerListener::OnConnectionEstablished, DeviceInfo(device_handle, event.device_uid, event.transport_adapter->DeviceName(event.device_uid), event.transport_adapter->GetConnectionType()), - connection_id_counter_); + connection_id); LOG4CXX_DEBUG(logger_, "event_type = ON_CONNECT_DONE"); break; } -- cgit v1.2.1 From faa1ac113eae0ab59e37c5aad4fc6fae334b089d Mon Sep 17 00:00:00 2001 From: ShobhitAd Date: Tue, 13 Nov 2018 10:10:53 -0500 Subject: Implement new RPC in MOBILE_API --- src/components/interfaces/MOBILE_API.xml | 53 ++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/src/components/interfaces/MOBILE_API.xml b/src/components/interfaces/MOBILE_API.xml index 6ed42c3588..1707f65bad 100644 --- a/src/components/interfaces/MOBILE_API.xml +++ b/src/components/interfaces/MOBILE_API.xml @@ -545,6 +545,13 @@ + + Enumeration for the user's preference of which app type to use when both are available + + + + + Defines the hard (physical) and soft (touchscreen) buttons available from the module @@ -2609,6 +2616,7 @@ + -- cgit v1.2.1 From 21cfc65da3b1a9e0d66a13884a6b2e067e0e590b Mon Sep 17 00:00:00 2001 From: ShobhitAd Date: Tue, 13 Nov 2018 10:36:42 -0500 Subject: Implement SetCloudAppProperties RPC in core --- .../mobile/set_cloudapp_properties_request.h | 28 +++++++++ .../mobile/set_cloudapp_properties_response.h | 28 +++++++++ .../mobile/set_cloudapp_properties_request.cc | 71 ++++++++++++++++++++++ .../mobile/set_cloudapp_properties_response.cc | 32 ++++++++++ .../sdl_rpc_plugin/src/mobile_command_factory.cc | 7 +++ 5 files changed, 166 insertions(+) create mode 100644 src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/set_cloudapp_properties_request.h create mode 100644 src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/set_cloudapp_properties_response.h create mode 100644 src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/set_cloudapp_properties_request.cc create mode 100644 src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/set_cloudapp_properties_response.cc diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/set_cloudapp_properties_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/set_cloudapp_properties_request.h new file mode 100644 index 0000000000..fc131020a8 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/set_cloudapp_properties_request.h @@ -0,0 +1,28 @@ +#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_SET_CLOUDAPP_PROPERTIES_REQUEST_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_SET_CLOUDAPP_PROPERTIES_REQUEST_H_ + +#include "application_manager/commands/command_request_impl.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands{ + +class SetCloudAppPropertiesRequest : public app_mngr::commands::CommandRequestImpl{ +public: + SetCloudAppPropertiesRequest(const app_mngr::commands::MessageSharedPtr& message, + app_mngr::ApplicationManager& application_manager, + app_mngr::rpc_service::RPCService& rpc_service, + app_mngr::HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handler); + virtual ~SetCloudAppPropertiesRequest(); + virtual void Run(); + virtual void on_event(const app_mngr::event_engine::Event& event); + private: + DISALLOW_COPY_AND_ASSIGN(SetCloudAppPropertiesRequest); +}; // SetCloudAppPropertiesRequest + +} // namespace commands +} // namespace sdl_rpc_plugin + +#endif //SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_SET_CLOUDAPP_PROPERTIES_REQUEST_H_ \ No newline at end of file diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/set_cloudapp_properties_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/set_cloudapp_properties_response.h new file mode 100644 index 0000000000..aae45c52ce --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/set_cloudapp_properties_response.h @@ -0,0 +1,28 @@ +#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_SET_CLOUDAPP_PROPERTIES_RESPONSE_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_SET_CLOUDAPP_PROPERTIES_RESPONSE_H_ + +#include "application_manager/commands/command_response_impl.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +class SetCloudAppPropertiesResponse : public app_mngr::commands::CommandResponseImpl{ +public: + SetCloudAppPropertiesResponse(const app_mngr::commands::MessageSharedPtr& message, + app_mngr::ApplicationManager& application_manager, + app_mngr::rpc_service::RPCService& rpc_service, + app_mngr::HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handler); + virtual ~SetCloudAppPropertiesResponse(); + virtual void Run(); + private: + DISALLOW_COPY_AND_ASSIGN(SetCloudAppPropertiesResponse); + +}; //SetCloudAppPropertiesResponse + +} // namespace commands +} // namespace sdl_rpc_plugin + +#endif //SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_SET_CLOUDAPP_PROPERTIES_RESPONSE_H_ \ No newline at end of file diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/set_cloudapp_properties_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/set_cloudapp_properties_request.cc new file mode 100644 index 0000000000..b5c66e4400 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/set_cloudapp_properties_request.cc @@ -0,0 +1,71 @@ +#include "sdl_rpc_plugin/commands/mobile/set_cloudapp_properties_request.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + + SetCloudAppPropertiesRequest::SetCloudAppPropertiesRequest(const app_mngr::commands::MessageSharedPtr& message, + app_mngr::ApplicationManager& application_manager, + app_mngr::rpc_service::RPCService& rpc_service, + app_mngr::HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handler) + : CommandRequestImpl(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handler){} + + SetCloudAppPropertiesRequest::~SetCloudAppPropertiesRequest(){} + void SetCloudAppPropertiesRequest::Run(){ + LOG4CXX_AUTO_TRACE(logger_); + ApplicationSharedPtr app = application_manager_.application(connection_key()); + + if (!app) { + LOG4CXX_ERROR(logger_, "Application is not registered"); + SendResponse(false, mobile_apis::Result::APPLICATION_NOT_REGISTERED); + return; + } + + if ((*message_)[strings::msg_params].empty()) { + LOG4CXX_ERROR(logger_, strings::msg_params << " is empty."); + SendResponse(false, mobile_apis::Result::INVALID_DATA); + return; + } + + smart_objects::SmartObject cloudapp_properties(smart_objects::SmartType_Map); + + cloudapp_properties[strings::msg_params][strings::app_name] = (*message_)[strings::msg_params][strings::app_name]; + cloudapp_properties[strings::msg_params][strings::app_id] = (*message_)[strings::msg_params][strings::app_id]; + + if ((*message_)[strings::msg_params].keyExists(strings::enabled)) { + smart_objects::SmartObject enabled = (*message_)[strings::msg_params][strings::enabled]; + cloudapp_properties[strings::msg_params][strings::enabled] = enabled; + } + if ((*message_)[strings::msg_params].keyExists(strings::cloud_app_auth_token)) { + smart_objects::SmartObject auth_token = (*message_)[strings::msg_params][strings::cloud_app_auth_token]; + cloudapp_properties[strings::msg_params][strings::cloud_app_auth_token] = auth_token; + } + if ((*message_)[strings::msg_params].keyExists(strings::cloud_transport_type)) { + smart_objects::SmartObject transport_type = (*message_)[strings::msg_params][strings::cloud_transport_type]; + cloudapp_properties[strings::msg_params][strings::cloud_transport_type] = transport_type; + } + if ((*message_)[strings::msg_params].keyExists(strings::hybrid_app_preference)) { + smart_objects::SmartObject hybrid_app_preference = (*message_)[strings::msg_params][strings::hybrid_app_preference]; + cloudapp_properties[strings::msg_params][strings::hybrid_app_preference] = hybrid_app_preference; + } + + policy_handler_.OnSetCloudAppProperties(cloudapp_properties); + SendResponse(true, mobile_apis::Result::SUCCESS); + + + } + + + void SetCloudAppPropertiesRequest::on_event(const app_mngr::event_engine::Event& event){ + LOG4CXX_INFO(logger_, "SetCloudAppPropertiesRequest on_event"); + } + + +} // namespace commands +} // namespace sdl_rpc_plugin \ No newline at end of file diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/set_cloudapp_properties_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/set_cloudapp_properties_response.cc new file mode 100644 index 0000000000..b113f84131 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/set_cloudapp_properties_response.cc @@ -0,0 +1,32 @@ +#include "application_manager/application_manager.h" +#include "application_manager/rpc_service.h" +#include "sdl_rpc_plugin/commands/mobile/set_cloudapp_properties_response.h" + + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + + SetCloudAppPropertiesResponse::SetCloudAppPropertiesResponse(const app_mngr::commands::MessageSharedPtr& message, + app_mngr::ApplicationManager& application_manager, + app_mngr::rpc_service::RPCService& rpc_service, + app_mngr::HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handler) + : CommandResponseImpl(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handler){} + + + SetCloudAppPropertiesResponse::~SetCloudAppPropertiesResponse(){} + + void SetCloudAppPropertiesResponse::Run(){ + LOG4CXX_AUTO_TRACE(logger_); + + rpc_service_.SendMessageToMobile(message_); + } + +} // namespace commands +} //namespace sdl_rpc_plugins diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/mobile_command_factory.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/mobile_command_factory.cc index 5207c7e432..a5b3bf71fe 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/mobile_command_factory.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/mobile_command_factory.cc @@ -124,6 +124,8 @@ #include "sdl_rpc_plugin/commands/mobile/dial_number_response.h" #include "sdl_rpc_plugin/commands/mobile/send_haptic_data_request.h" #include "sdl_rpc_plugin/commands/mobile/send_haptic_data_response.h" +#include "sdl_rpc_plugin/commands/mobile/set_cloudapp_properties_request.h" +#include "sdl_rpc_plugin/commands/mobile/set_cloudapp_properties_response.h" #include "interfaces/MOBILE_API.h" CREATE_LOGGERPTR_GLOBAL(logger_, "ApplicationManager") @@ -337,6 +339,11 @@ CommandCreator& MobileCommandFactory::get_creator_factory( ? factory.GetCreator() : factory.GetCreator(); } + case mobile_apis::FunctionID::SetCloudAppPropertiesID: { + return mobile_api::messageType::request == message_type + ? factory.GetCreator() + : factory.GetCreator(); + } case mobile_apis::FunctionID::OnButtonEventID: { return factory.GetCreator(); } -- cgit v1.2.1 From c9d1e934396dabd1c8604e1884d86882247e4ba1 Mon Sep 17 00:00:00 2001 From: ShobhitAd Date: Tue, 13 Nov 2018 11:08:06 -0500 Subject: Implement RPC in regular and external policies --- src/appMain/sdl_preloaded_pt.json | 41 ++++++++++++++++++++++ .../include/policy/policy_table/enums.h | 5 +++ .../policy_external/src/policy_table/enums.cc | 5 +++ .../include/policy/policy_table/enums.h | 5 +++ .../policy_regular/src/policy_table/enums.cc | 8 +++++ 5 files changed, 64 insertions(+) diff --git a/src/appMain/sdl_preloaded_pt.json b/src/appMain/sdl_preloaded_pt.json index 8a75cd3dab..3c84fc96bd 100644 --- a/src/appMain/sdl_preloaded_pt.json +++ b/src/appMain/sdl_preloaded_pt.json @@ -533,6 +533,47 @@ } } }, + "CloudApp":{ + "rpcs":{ + "SetCloudAppProperties":{ + "hmi_levels":["BACKGROUND", + "FULL", + "LIMITED"] + }, + "GetVehicleData": { + "hmi_levels": ["BACKGROUND", + "FULL", + "LIMITED"], + "parameters": [ + "cloudAppVehicleID" + ] + }, + "OnVehicleData": { + "hmi_levels": ["BACKGROUND", + "FULL", + "LIMITED"], + "parameters": [ + "cloudAppVehicleID" + ] + }, + "SubscribeVehicleData": { + "hmi_levels": ["BACKGROUND", + "FULL", + "LIMITED"], + "parameters": [ + "cloudAppVehicleID" + ] + }, + "UnsubscribeVehicleData": { + "hmi_levels": ["BACKGROUND", + "FULL", + "LIMITED"], + "parameters": [ + "cloudAppVehicleID" + ] + } + } + }, "RemoteControl": { "rpcs": { "ButtonPress": { diff --git a/src/components/policy/policy_external/include/policy/policy_table/enums.h b/src/components/policy/policy_external/include/policy/policy_table/enums.h index dc2fdab2fa..982118a43a 100644 --- a/src/components/policy/policy_external/include/policy/policy_table/enums.h +++ b/src/components/policy/policy_external/include/policy/policy_table/enums.h @@ -440,6 +440,11 @@ enum FunctionID { */ SendHapticDataID = 49, + /** + * @brief SetCloudAppPropertiesID. + */ + SetCloudAppPropertiesID = 50, + /** * @brief OnHMIStatusID. */ diff --git a/src/components/policy/policy_external/src/policy_table/enums.cc b/src/components/policy/policy_external/src/policy_table/enums.cc index 48ce4d4f72..fac3cb86a1 100644 --- a/src/components/policy/policy_external/src/policy_table/enums.cc +++ b/src/components/policy/policy_external/src/policy_table/enums.cc @@ -1120,6 +1120,11 @@ bool EnumFromJsonString(const std::string& literal, FunctionID* result) { *result = SendHapticDataID; return true; } + + if("SetCloudAppProperties" == literal){ + *result = SetCloudAppPropertiesID; + return true; + } if ("OnHMIStatus" == literal) { *result = OnHMIStatusID; diff --git a/src/components/policy/policy_regular/include/policy/policy_table/enums.h b/src/components/policy/policy_regular/include/policy/policy_table/enums.h index fce6b7b865..563e822a36 100644 --- a/src/components/policy/policy_regular/include/policy/policy_table/enums.h +++ b/src/components/policy/policy_regular/include/policy/policy_table/enums.h @@ -426,6 +426,11 @@ enum FunctionID { */ SendHapticDataID = 49, + /** + * @brief SetCloudAppPropertiesID. + */ + SetCloudAppPropertiesID = 50, + /** * @brief OnHMIStatusID. */ diff --git a/src/components/policy/policy_regular/src/policy_table/enums.cc b/src/components/policy/policy_regular/src/policy_table/enums.cc index 2ddf74af7e..0bc0bee954 100644 --- a/src/components/policy/policy_regular/src/policy_table/enums.cc +++ b/src/components/policy/policy_regular/src/policy_table/enums.cc @@ -847,6 +847,8 @@ bool IsValidEnum(FunctionID val) { return true; case SendHapticDataID: return true; + case SetCloudAppPropertiesID: + return true; case OnHMIStatusID: return true; case OnAppInterfaceUnregisteredID: @@ -994,6 +996,8 @@ const char* EnumToJsonString(FunctionID val) { return "GetSystemCapability"; case SendHapticDataID: return "SendHapticData"; + case SetCloudAppPropertiesID: + return "SetCloudAppProperties"; case OnHMIStatusID: return "OnHMIStatus"; case OnAppInterfaceUnregisteredID: @@ -1283,6 +1287,10 @@ bool EnumFromJsonString(const std::string& literal, FunctionID* result) { *result = SendHapticDataID; return true; } + if("SetCloudAppProperties" == literal){ + *result = SetCloudAppPropertiesID; + return true; + } if ("OnHMIStatus" == literal) { *result = OnHMIStatusID; -- cgit v1.2.1 From d8bda5ad6f4f82d5203e27f18a2fc25f05d7a323 Mon Sep 17 00:00:00 2001 From: ShobhitAd Date: Tue, 13 Nov 2018 12:07:45 -0500 Subject: Getting HybridAppPreference from enum --- .../application_manager/src/policies/policy_handler.cc | 11 +++++++---- .../smart_objects/include/smart_objects/enum_schema_item.h | 7 +++---- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/components/application_manager/src/policies/policy_handler.cc b/src/components/application_manager/src/policies/policy_handler.cc index cc62d9f6f8..44f83ab097 100644 --- a/src/components/application_manager/src/policies/policy_handler.cc +++ b/src/components/application_manager/src/policies/policy_handler.cc @@ -54,6 +54,7 @@ #include "interfaces/MOBILE_API.h" #include "utils/file_system.h" #include "utils/scope_guard.h" +#include "smart_objects/enum_schema_item.h" #include "utils/helpers.h" #include "policy/policy_manager.h" @@ -1913,10 +1914,12 @@ void PolicyHandler::OnSetCloudAppProperties( policy_app_id, msg_params[strings::cloud_transport_type].asString()); } if (msg_params.keyExists(strings::hybrid_app_preference)) { - // const std::string hybrid_app_preference = - // EnumConversionHelper::EnumToString(msg_params[strings::hybrid_app_preference]); - // policy_manager_->SetHybridAppPreference( - // policy_app_id, hybrid_app_preference); + std::string hybrid_app_preference; + + mobile_apis::HybridAppPreference::eType value = static_cast + (msg_params[strings::hybrid_app_preference].asUInt()); + smart_objects::EnumConversionHelper::EnumToString(value, &hybrid_app_preference); + policy_manager_->SetHybridAppPreference(policy_app_id, hybrid_app_preference); } } diff --git a/src/components/smart_objects/include/smart_objects/enum_schema_item.h b/src/components/smart_objects/include/smart_objects/enum_schema_item.h index cbba5bd7cd..942b491927 100644 --- a/src/components/smart_objects/include/smart_objects/enum_schema_item.h +++ b/src/components/smart_objects/include/smart_objects/enum_schema_item.h @@ -220,11 +220,10 @@ class EnumConversionHelper { static bool EnumToString(const EnumType value, std::string* str) { const char* cstr; - if (EnumToCString(value, &cstr)) { - return false; - } - if (str) { + bool success = EnumToCString(value, &cstr); + if (success && str) { *str = cstr; + return true; } return false; } -- cgit v1.2.1 From a6912d91f20058789b21c38a0f57a3d9d28b6e57 Mon Sep 17 00:00:00 2001 From: ShobhitAd Date: Tue, 13 Nov 2018 12:13:32 -0500 Subject: Style Fix --- .../mobile/set_cloudapp_properties_request.h | 37 ++++--- .../mobile/set_cloudapp_properties_response.h | 31 +++--- .../mobile/set_cloudapp_properties_request.cc | 120 +++++++++++---------- .../mobile/set_cloudapp_properties_response.cc | 31 +++--- .../sdl_rpc_plugin/src/mobile_command_factory.cc | 5 +- .../src/policies/policy_handler.cc | 14 ++- .../include/policy/policy_table/enums.h | 2 +- .../policy_external/src/policy_table/enums.cc | 4 +- .../policy_regular/src/policy_table/enums.cc | 4 +- 9 files changed, 134 insertions(+), 114 deletions(-) diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/set_cloudapp_properties_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/set_cloudapp_properties_request.h index fc131020a8..0c62b248b4 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/set_cloudapp_properties_request.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/set_cloudapp_properties_request.h @@ -5,24 +5,27 @@ namespace sdl_rpc_plugin { namespace app_mngr = application_manager; - -namespace commands{ -class SetCloudAppPropertiesRequest : public app_mngr::commands::CommandRequestImpl{ -public: - SetCloudAppPropertiesRequest(const app_mngr::commands::MessageSharedPtr& message, - app_mngr::ApplicationManager& application_manager, - app_mngr::rpc_service::RPCService& rpc_service, - app_mngr::HMICapabilities& hmi_capabilities, - policy::PolicyHandlerInterface& policy_handler); - virtual ~SetCloudAppPropertiesRequest(); - virtual void Run(); - virtual void on_event(const app_mngr::event_engine::Event& event); +namespace commands { + +class SetCloudAppPropertiesRequest + : public app_mngr::commands::CommandRequestImpl { + public: + SetCloudAppPropertiesRequest( + const app_mngr::commands::MessageSharedPtr& message, + app_mngr::ApplicationManager& application_manager, + app_mngr::rpc_service::RPCService& rpc_service, + app_mngr::HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handler); + virtual ~SetCloudAppPropertiesRequest(); + virtual void Run(); + virtual void on_event(const app_mngr::event_engine::Event& event); + private: - DISALLOW_COPY_AND_ASSIGN(SetCloudAppPropertiesRequest); -}; // SetCloudAppPropertiesRequest + DISALLOW_COPY_AND_ASSIGN(SetCloudAppPropertiesRequest); +}; // SetCloudAppPropertiesRequest -} // namespace commands -} // namespace sdl_rpc_plugin +} // namespace commands +} // namespace sdl_rpc_plugin -#endif //SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_SET_CLOUDAPP_PROPERTIES_REQUEST_H_ \ No newline at end of file +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_SET_CLOUDAPP_PROPERTIES_REQUEST_H_ \ No newline at end of file diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/set_cloudapp_properties_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/set_cloudapp_properties_response.h index aae45c52ce..9037cb3b73 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/set_cloudapp_properties_response.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/set_cloudapp_properties_response.h @@ -8,21 +8,24 @@ namespace app_mngr = application_manager; namespace commands { -class SetCloudAppPropertiesResponse : public app_mngr::commands::CommandResponseImpl{ -public: - SetCloudAppPropertiesResponse(const app_mngr::commands::MessageSharedPtr& message, - app_mngr::ApplicationManager& application_manager, - app_mngr::rpc_service::RPCService& rpc_service, - app_mngr::HMICapabilities& hmi_capabilities, - policy::PolicyHandlerInterface& policy_handler); - virtual ~SetCloudAppPropertiesResponse(); - virtual void Run(); +class SetCloudAppPropertiesResponse + : public app_mngr::commands::CommandResponseImpl { + public: + SetCloudAppPropertiesResponse( + const app_mngr::commands::MessageSharedPtr& message, + app_mngr::ApplicationManager& application_manager, + app_mngr::rpc_service::RPCService& rpc_service, + app_mngr::HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handler); + virtual ~SetCloudAppPropertiesResponse(); + virtual void Run(); + private: DISALLOW_COPY_AND_ASSIGN(SetCloudAppPropertiesResponse); - -}; //SetCloudAppPropertiesResponse -} // namespace commands -} // namespace sdl_rpc_plugin +}; // SetCloudAppPropertiesResponse + +} // namespace commands +} // namespace sdl_rpc_plugin -#endif //SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_SET_CLOUDAPP_PROPERTIES_RESPONSE_H_ \ No newline at end of file +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_SET_CLOUDAPP_PROPERTIES_RESPONSE_H_ \ No newline at end of file diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/set_cloudapp_properties_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/set_cloudapp_properties_request.cc index b5c66e4400..49cb7029c7 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/set_cloudapp_properties_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/set_cloudapp_properties_request.cc @@ -5,67 +5,77 @@ using namespace application_manager; namespace commands { - SetCloudAppPropertiesRequest::SetCloudAppPropertiesRequest(const app_mngr::commands::MessageSharedPtr& message, - app_mngr::ApplicationManager& application_manager, - app_mngr::rpc_service::RPCService& rpc_service, - app_mngr::HMICapabilities& hmi_capabilities, - policy::PolicyHandlerInterface& policy_handler) - : CommandRequestImpl(message, - application_manager, - rpc_service, - hmi_capabilities, - policy_handler){} +SetCloudAppPropertiesRequest::SetCloudAppPropertiesRequest( + const app_mngr::commands::MessageSharedPtr& message, + app_mngr::ApplicationManager& application_manager, + app_mngr::rpc_service::RPCService& rpc_service, + app_mngr::HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handler) + : CommandRequestImpl(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handler) {} - SetCloudAppPropertiesRequest::~SetCloudAppPropertiesRequest(){} - void SetCloudAppPropertiesRequest::Run(){ - LOG4CXX_AUTO_TRACE(logger_); - ApplicationSharedPtr app = application_manager_.application(connection_key()); +SetCloudAppPropertiesRequest::~SetCloudAppPropertiesRequest() {} +void SetCloudAppPropertiesRequest::Run() { + LOG4CXX_AUTO_TRACE(logger_); + ApplicationSharedPtr app = application_manager_.application(connection_key()); - if (!app) { - LOG4CXX_ERROR(logger_, "Application is not registered"); - SendResponse(false, mobile_apis::Result::APPLICATION_NOT_REGISTERED); - return; - } + if (!app) { + LOG4CXX_ERROR(logger_, "Application is not registered"); + SendResponse(false, mobile_apis::Result::APPLICATION_NOT_REGISTERED); + return; + } - if ((*message_)[strings::msg_params].empty()) { - LOG4CXX_ERROR(logger_, strings::msg_params << " is empty."); - SendResponse(false, mobile_apis::Result::INVALID_DATA); - return; - } + if ((*message_)[strings::msg_params].empty()) { + LOG4CXX_ERROR(logger_, strings::msg_params << " is empty."); + SendResponse(false, mobile_apis::Result::INVALID_DATA); + return; + } - smart_objects::SmartObject cloudapp_properties(smart_objects::SmartType_Map); + smart_objects::SmartObject cloudapp_properties(smart_objects::SmartType_Map); - cloudapp_properties[strings::msg_params][strings::app_name] = (*message_)[strings::msg_params][strings::app_name]; - cloudapp_properties[strings::msg_params][strings::app_id] = (*message_)[strings::msg_params][strings::app_id]; - - if ((*message_)[strings::msg_params].keyExists(strings::enabled)) { - smart_objects::SmartObject enabled = (*message_)[strings::msg_params][strings::enabled]; - cloudapp_properties[strings::msg_params][strings::enabled] = enabled; - } - if ((*message_)[strings::msg_params].keyExists(strings::cloud_app_auth_token)) { - smart_objects::SmartObject auth_token = (*message_)[strings::msg_params][strings::cloud_app_auth_token]; - cloudapp_properties[strings::msg_params][strings::cloud_app_auth_token] = auth_token; - } - if ((*message_)[strings::msg_params].keyExists(strings::cloud_transport_type)) { - smart_objects::SmartObject transport_type = (*message_)[strings::msg_params][strings::cloud_transport_type]; - cloudapp_properties[strings::msg_params][strings::cloud_transport_type] = transport_type; - } - if ((*message_)[strings::msg_params].keyExists(strings::hybrid_app_preference)) { - smart_objects::SmartObject hybrid_app_preference = (*message_)[strings::msg_params][strings::hybrid_app_preference]; - cloudapp_properties[strings::msg_params][strings::hybrid_app_preference] = hybrid_app_preference; - } - - policy_handler_.OnSetCloudAppProperties(cloudapp_properties); - SendResponse(true, mobile_apis::Result::SUCCESS); + cloudapp_properties[strings::msg_params][strings::app_name] = + (*message_)[strings::msg_params][strings::app_name]; + cloudapp_properties[strings::msg_params][strings::app_id] = + (*message_)[strings::msg_params][strings::app_id]; + if ((*message_)[strings::msg_params].keyExists(strings::enabled)) { + smart_objects::SmartObject enabled = + (*message_)[strings::msg_params][strings::enabled]; + cloudapp_properties[strings::msg_params][strings::enabled] = enabled; + } + if ((*message_)[strings::msg_params].keyExists( + strings::cloud_app_auth_token)) { + smart_objects::SmartObject auth_token = + (*message_)[strings::msg_params][strings::cloud_app_auth_token]; + cloudapp_properties[strings::msg_params][strings::cloud_app_auth_token] = + auth_token; + } + if ((*message_)[strings::msg_params].keyExists( + strings::cloud_transport_type)) { + smart_objects::SmartObject transport_type = + (*message_)[strings::msg_params][strings::cloud_transport_type]; + cloudapp_properties[strings::msg_params][strings::cloud_transport_type] = + transport_type; + } + if ((*message_)[strings::msg_params].keyExists( + strings::hybrid_app_preference)) { + smart_objects::SmartObject hybrid_app_preference = + (*message_)[strings::msg_params][strings::hybrid_app_preference]; + cloudapp_properties[strings::msg_params][strings::hybrid_app_preference] = + hybrid_app_preference; + } - } + policy_handler_.OnSetCloudAppProperties(cloudapp_properties); + SendResponse(true, mobile_apis::Result::SUCCESS); +} +void SetCloudAppPropertiesRequest::on_event( + const app_mngr::event_engine::Event& event) { + LOG4CXX_INFO(logger_, "SetCloudAppPropertiesRequest on_event"); +} - void SetCloudAppPropertiesRequest::on_event(const app_mngr::event_engine::Event& event){ - LOG4CXX_INFO(logger_, "SetCloudAppPropertiesRequest on_event"); - } - - -} // namespace commands -} // namespace sdl_rpc_plugin \ No newline at end of file +} // namespace commands +} // namespace sdl_rpc_plugin \ No newline at end of file diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/set_cloudapp_properties_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/set_cloudapp_properties_response.cc index b113f84131..6acfb2423d 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/set_cloudapp_properties_response.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/set_cloudapp_properties_response.cc @@ -2,31 +2,30 @@ #include "application_manager/rpc_service.h" #include "sdl_rpc_plugin/commands/mobile/set_cloudapp_properties_response.h" - namespace sdl_rpc_plugin { using namespace application_manager; namespace commands { - SetCloudAppPropertiesResponse::SetCloudAppPropertiesResponse(const app_mngr::commands::MessageSharedPtr& message, - app_mngr::ApplicationManager& application_manager, - app_mngr::rpc_service::RPCService& rpc_service, - app_mngr::HMICapabilities& hmi_capabilities, - policy::PolicyHandlerInterface& policy_handler) - : CommandResponseImpl(message, +SetCloudAppPropertiesResponse::SetCloudAppPropertiesResponse( + const app_mngr::commands::MessageSharedPtr& message, + app_mngr::ApplicationManager& application_manager, + app_mngr::rpc_service::RPCService& rpc_service, + app_mngr::HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handler) + : CommandResponseImpl(message, application_manager, rpc_service, hmi_capabilities, - policy_handler){} + policy_handler) {} +SetCloudAppPropertiesResponse::~SetCloudAppPropertiesResponse() {} - SetCloudAppPropertiesResponse::~SetCloudAppPropertiesResponse(){} +void SetCloudAppPropertiesResponse::Run() { + LOG4CXX_AUTO_TRACE(logger_); - void SetCloudAppPropertiesResponse::Run(){ - LOG4CXX_AUTO_TRACE(logger_); - - rpc_service_.SendMessageToMobile(message_); - } + rpc_service_.SendMessageToMobile(message_); +} -} // namespace commands -} //namespace sdl_rpc_plugins +} // namespace commands +} // namespace sdl_rpc_plugins diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/mobile_command_factory.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/mobile_command_factory.cc index a5b3bf71fe..dc5298813b 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/mobile_command_factory.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/mobile_command_factory.cc @@ -341,8 +341,9 @@ CommandCreator& MobileCommandFactory::get_creator_factory( } case mobile_apis::FunctionID::SetCloudAppPropertiesID: { return mobile_api::messageType::request == message_type - ? factory.GetCreator() - : factory.GetCreator(); + ? factory.GetCreator() + : factory + .GetCreator(); } case mobile_apis::FunctionID::OnButtonEventID: { return factory.GetCreator(); diff --git a/src/components/application_manager/src/policies/policy_handler.cc b/src/components/application_manager/src/policies/policy_handler.cc index 44f83ab097..8c6de5482c 100644 --- a/src/components/application_manager/src/policies/policy_handler.cc +++ b/src/components/application_manager/src/policies/policy_handler.cc @@ -1915,11 +1915,15 @@ void PolicyHandler::OnSetCloudAppProperties( } if (msg_params.keyExists(strings::hybrid_app_preference)) { std::string hybrid_app_preference; - - mobile_apis::HybridAppPreference::eType value = static_cast - (msg_params[strings::hybrid_app_preference].asUInt()); - smart_objects::EnumConversionHelper::EnumToString(value, &hybrid_app_preference); - policy_manager_->SetHybridAppPreference(policy_app_id, hybrid_app_preference); + + mobile_apis::HybridAppPreference::eType value = + static_cast( + msg_params[strings::hybrid_app_preference].asUInt()); + smart_objects::EnumConversionHelper< + mobile_apis::HybridAppPreference::eType>:: + EnumToString(value, &hybrid_app_preference); + policy_manager_->SetHybridAppPreference(policy_app_id, + hybrid_app_preference); } } diff --git a/src/components/policy/policy_external/include/policy/policy_table/enums.h b/src/components/policy/policy_external/include/policy/policy_table/enums.h index 982118a43a..5b494629bb 100644 --- a/src/components/policy/policy_external/include/policy/policy_table/enums.h +++ b/src/components/policy/policy_external/include/policy/policy_table/enums.h @@ -444,7 +444,7 @@ enum FunctionID { * @brief SetCloudAppPropertiesID. */ SetCloudAppPropertiesID = 50, - + /** * @brief OnHMIStatusID. */ diff --git a/src/components/policy/policy_external/src/policy_table/enums.cc b/src/components/policy/policy_external/src/policy_table/enums.cc index fac3cb86a1..d7d5a241de 100644 --- a/src/components/policy/policy_external/src/policy_table/enums.cc +++ b/src/components/policy/policy_external/src/policy_table/enums.cc @@ -1120,8 +1120,8 @@ bool EnumFromJsonString(const std::string& literal, FunctionID* result) { *result = SendHapticDataID; return true; } - - if("SetCloudAppProperties" == literal){ + + if ("SetCloudAppProperties" == literal) { *result = SetCloudAppPropertiesID; return true; } diff --git a/src/components/policy/policy_regular/src/policy_table/enums.cc b/src/components/policy/policy_regular/src/policy_table/enums.cc index 0bc0bee954..91d0a6990f 100644 --- a/src/components/policy/policy_regular/src/policy_table/enums.cc +++ b/src/components/policy/policy_regular/src/policy_table/enums.cc @@ -848,7 +848,7 @@ bool IsValidEnum(FunctionID val) { case SendHapticDataID: return true; case SetCloudAppPropertiesID: - return true; + return true; case OnHMIStatusID: return true; case OnAppInterfaceUnregisteredID: @@ -1287,7 +1287,7 @@ bool EnumFromJsonString(const std::string& literal, FunctionID* result) { *result = SendHapticDataID; return true; } - if("SetCloudAppProperties" == literal){ + if ("SetCloudAppProperties" == literal) { *result = SetCloudAppPropertiesID; return true; } -- cgit v1.2.1 From 691d5e4c34206daefe685f836a7ac90e2a211379 Mon Sep 17 00:00:00 2001 From: JackLivio Date: Tue, 13 Nov 2018 16:40:23 -0500 Subject: Show pending cloud apps in update app list --- .../application_manager/application_manager_impl.h | 4 ++ .../src/application_manager_impl.cc | 52 +++++++++++++++++----- .../src/connection_handler_impl.cc | 17 +++++-- .../connection_handler_observer.h | 2 + .../transport_manager/src/cloud/cloud_device.cc | 2 +- .../src/cloud/cloud_websocket_transport_adapter.cc | 9 ++-- 6 files changed, 67 insertions(+), 19 deletions(-) diff --git a/src/components/application_manager/include/application_manager/application_manager_impl.h b/src/components/application_manager/include/application_manager/application_manager_impl.h index 23d7fc4892..6f6482e717 100644 --- a/src/components/application_manager/include/application_manager/application_manager_impl.h +++ b/src/components/application_manager/include/application_manager/application_manager_impl.h @@ -362,6 +362,8 @@ class ApplicationManagerImpl void CollectCloudAppInformation(); + void CreatePendingApplication(const transport_manager::ConnectionUID connection_id, const transport_manager::DeviceInfo& device_info, connection_handler::DeviceHandle device_id); + /* * @brief Returns unique correlation ID for HMI request * @@ -1451,6 +1453,8 @@ class ApplicationManagerImpl DeviceMap secondary_transport_devices_cache_; + std::map pending_device_map_; + #ifdef TELEMETRY_MONITOR AMTelemetryObserver* metric_observer_; #endif // TELEMETRY_MONITOR diff --git a/src/components/application_manager/src/application_manager_impl.cc b/src/components/application_manager/src/application_manager_impl.cc index 061f3885a9..76067f1dc7 100644 --- a/src/components/application_manager/src/application_manager_impl.cc +++ b/src/components/application_manager/src/application_manager_impl.cc @@ -799,18 +799,50 @@ void ApplicationManagerImpl::CollectCloudAppInformation() { GetPolicyHandler().GetCloudAppParameters(*it, endpoint, certificate, auth_token, cloud_transport_type, hybrid_app_preference); + pending_device_map_.insert(std::pair(endpoint, *it)); + connection_handler().AddCloudAppDevice(*it, endpoint, cloud_transport_type); - std::string device_mac; - std::string connection_type; - /*ApplicationSharedPtr application( - new ApplicationImpl(app_id, - policy_app_id, - device_mac, - device_id, - app_name, - GetPolicyHandler().GetStatisticManager(), - *this)); */ + + + } +} + +void ApplicationManagerImpl::CreatePendingApplication(const transport_manager::ConnectionUID connection_id, const transport_manager::DeviceInfo& device_info, connection_handler::DeviceHandle device_id) { + LOG4CXX_AUTO_TRACE(logger_); + + std::string policy_app_id = ""; + std::string name = device_info.name(); + auto it = pending_device_map_.find(name); + if (it == pending_device_map_.end()) { + return; + } + + policy_app_id = it->second; + ApplicationSharedPtr application( + new ApplicationImpl(0, + policy_app_id, + device_info.mac_address(), + device_id, + custom_str::CustomString("CloudApp"), //todo replace this with policy nick name + GetPolicyHandler().GetStatisticManager(), + *this)); + + if(!application) { + LOG4CXX_INFO(logger_, "Could not streate application"); + return; } + + application->set_hmi_application_id(GenerateNewHMIAppID()); + + sync_primitives::AutoLock lock(apps_to_register_list_lock_ptr_); + LOG4CXX_DEBUG( + logger_, "apps_to_register_ size before: " << apps_to_register_.size()); + apps_to_register_.insert(application); + LOG4CXX_DEBUG(logger_, + "apps_to_register_ size after: " << apps_to_register_.size()); + + SendUpdateAppList(); + } uint32_t ApplicationManagerImpl::GetNextHMICorrelationID() { diff --git a/src/components/connection_handler/src/connection_handler_impl.cc b/src/components/connection_handler/src/connection_handler_impl.cc index d1c62e36bb..59fef50b0f 100644 --- a/src/components/connection_handler/src/connection_handler_impl.cc +++ b/src/components/connection_handler/src/connection_handler_impl.cc @@ -263,13 +263,22 @@ void ConnectionHandlerImpl::OnConnectionPending( //todo maybe create a seperate "pending_connection_list" sync_primitives::AutoWriteLock lock(connection_list_lock_); if (connection_list_.find(connection_id) == connection_list_.end()) { - connection_list_.insert(ConnectionList::value_type( - connection_id, - new Connection(connection_id, + + Connection* connection = new Connection(connection_id, device_info.device_handle(), this, - get_settings().heart_beat_timeout()))); + get_settings().heart_beat_timeout()); + + connection_list_.insert(ConnectionList::value_type( + connection_id, connection)); + + connection_handler::DeviceHandle device_id = connection->connection_device_handle(); + //uint32_t app_id = KeyFromPair(connection_id, session_id); + + connection_handler_observer_->CreatePendingApplication(connection_id, device_info, device_id); } + + } void ConnectionHandlerImpl::OnConnectionEstablished( diff --git a/src/components/include/connection_handler/connection_handler_observer.h b/src/components/include/connection_handler/connection_handler_observer.h index 154a2a8e34..9716f2c890 100644 --- a/src/components/include/connection_handler/connection_handler_observer.h +++ b/src/components/include/connection_handler/connection_handler_observer.h @@ -161,6 +161,8 @@ class ConnectionHandlerObserver { */ virtual void OnSecondaryTransportEndedCallback(const int32_t session_key) = 0; + virtual void CreatePendingApplication(const transport_manager::ConnectionUID connection_id, const transport_manager::DeviceInfo& device_info, connection_handler::DeviceHandle device_id) = 0; + protected: /** * \brief Destructor diff --git a/src/components/transport_manager/src/cloud/cloud_device.cc b/src/components/transport_manager/src/cloud/cloud_device.cc index ab7f8db69a..df17753ccc 100644 --- a/src/components/transport_manager/src/cloud/cloud_device.cc +++ b/src/components/transport_manager/src/cloud/cloud_device.cc @@ -42,7 +42,7 @@ CREATE_LOGGERPTR_GLOBAL(logger_, "TransportManager") CloudDevice::CloudDevice(std::string& host, std::string& port, std::string& name) - : Device(name, std::string(name+host+port)) {} + : Device(name, std::string(name)) {} bool CloudDevice::IsSameAs(const Device* other) const { diff --git a/src/components/transport_manager/src/cloud/cloud_websocket_transport_adapter.cc b/src/components/transport_manager/src/cloud/cloud_websocket_transport_adapter.cc index 746eafbcc3..49a0020423 100644 --- a/src/components/transport_manager/src/cloud/cloud_websocket_transport_adapter.cc +++ b/src/components/transport_manager/src/cloud/cloud_websocket_transport_adapter.cc @@ -83,13 +83,14 @@ void CloudWebsocketTransportAdapter::CreateDevice(const std::string& uid) { LOG4CXX_DEBUG(logger_, "Valid Endpoint: " << uid); std::size_t pos = uid.find(":"); pos = uid.find(":", pos+1); - std::size_t size = uid.length(); - std::string host = uid.substr(0, size - pos); - std::string port = uid.substr(pos); + //std::size_t size = uid.length(); + std::string host = uid.substr(0, pos); + std::string port = uid.substr(pos+1); std::string device_id = uid; LOG4CXX_DEBUG(logger_, "Creating Cloud Device For Host: " << host << " and Port: " << port); + //todo get nickname from policies to name device auto cloud_device = std::make_shared(host, port, device_id); DeviceVector devices{cloud_device}; @@ -102,7 +103,7 @@ void CloudWebsocketTransportAdapter::CreateDevice(const std::string& uid) { uid, 0, this); ConnectionCreated(connection, uid, 0); - ConnectDone(uid, 0); + ConnectPending(uid, 0); return; } -- cgit v1.2.1 From 07e2490fcec48c6e4937ed3f5c8db150f7327a51 Mon Sep 17 00:00:00 2001 From: ShobhitAd Date: Wed, 14 Nov 2018 14:16:51 -0500 Subject: Made requested changes --- .../commands/mobile/set_cloudapp_properties_request.cc | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/set_cloudapp_properties_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/set_cloudapp_properties_request.cc index 49cb7029c7..ca5a46e3dc 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/set_cloudapp_properties_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/set_cloudapp_properties_request.cc @@ -34,41 +34,41 @@ void SetCloudAppPropertiesRequest::Run() { return; } - smart_objects::SmartObject cloudapp_properties(smart_objects::SmartType_Map); + smart_objects::SmartObject cloud_app_properties(smart_objects::SmartType_Map); - cloudapp_properties[strings::msg_params][strings::app_name] = + cloud_app_properties[strings::msg_params][strings::app_name] = (*message_)[strings::msg_params][strings::app_name]; - cloudapp_properties[strings::msg_params][strings::app_id] = + cloud_app_properties[strings::msg_params][strings::app_id] = (*message_)[strings::msg_params][strings::app_id]; if ((*message_)[strings::msg_params].keyExists(strings::enabled)) { smart_objects::SmartObject enabled = (*message_)[strings::msg_params][strings::enabled]; - cloudapp_properties[strings::msg_params][strings::enabled] = enabled; + cloud_app_properties[strings::msg_params][strings::enabled] = enabled; } if ((*message_)[strings::msg_params].keyExists( strings::cloud_app_auth_token)) { smart_objects::SmartObject auth_token = (*message_)[strings::msg_params][strings::cloud_app_auth_token]; - cloudapp_properties[strings::msg_params][strings::cloud_app_auth_token] = + cloud_app_properties[strings::msg_params][strings::cloud_app_auth_token] = auth_token; } if ((*message_)[strings::msg_params].keyExists( strings::cloud_transport_type)) { smart_objects::SmartObject transport_type = (*message_)[strings::msg_params][strings::cloud_transport_type]; - cloudapp_properties[strings::msg_params][strings::cloud_transport_type] = + cloud_app_properties[strings::msg_params][strings::cloud_transport_type] = transport_type; } if ((*message_)[strings::msg_params].keyExists( strings::hybrid_app_preference)) { smart_objects::SmartObject hybrid_app_preference = (*message_)[strings::msg_params][strings::hybrid_app_preference]; - cloudapp_properties[strings::msg_params][strings::hybrid_app_preference] = + cloud_app_properties[strings::msg_params][strings::hybrid_app_preference] = hybrid_app_preference; } - policy_handler_.OnSetCloudAppProperties(cloudapp_properties); + policy_handler_.OnSetCloudAppProperties(cloud_app_properties); SendResponse(true, mobile_apis::Result::SUCCESS); } -- cgit v1.2.1 From c178b9827d52fe1da535cc68f4628ade32f17f80 Mon Sep 17 00:00:00 2001 From: jacobkeeler Date: Wed, 14 Nov 2018 14:28:35 -0500 Subject: Fix style --- .../include/application_manager/application.h | 6 +- .../include/application_manager/application_impl.h | 5 +- .../application_manager/application_manager_impl.h | 5 +- .../application_manager/src/application_impl.cc | 9 +- .../src/application_manager_impl.cc | 52 +++++----- .../include/config_profile/profile.h | 2 +- .../connection_handler/connection_handler_impl.h | 4 +- .../src/connection_handler_impl.cc | 45 ++++++--- .../connection_handler/connection_handler.h | 4 +- .../connection_handler_observer.h | 5 +- .../transport_adapter/transport_adapter.h | 7 +- .../include/transport_manager/transport_manager.h | 3 +- .../transport_manager/transport_manager_listener.h | 2 +- .../transport_manager_listener_empty.h | 2 +- .../transport_manager/transport_manager_settings.h | 2 +- .../protocol_handler/src/protocol_handler_impl.cc | 3 +- .../include/transport_manager/cloud/cloud_device.h | 6 +- .../cloud/cloud_websocket_transport_adapter.h | 6 +- .../cloud/websocket_client_connection.h | 34 +++---- .../transport_adapter_controller.h | 2 +- .../transport_adapter/transport_adapter_impl.h | 2 +- .../transport_adapter/transport_adapter_listener.h | 4 +- .../transport_adapter_listener_impl.h | 4 +- .../transport_manager/transport_manager_impl.h | 3 +- .../transport_manager/src/cloud/cloud_device.cc | 10 +- .../cloud/cloud_websocket_connection_factory.cc | 7 +- .../src/cloud/cloud_websocket_transport_adapter.cc | 110 +++++++++++---------- .../src/cloud/websocket_client_connection.cc | 82 +++++++-------- .../transport_adapter/transport_adapter_impl.cc | 6 +- .../src/transport_manager_default.cc | 5 +- .../src/transport_manager_impl.cc | 21 ++-- 31 files changed, 252 insertions(+), 206 deletions(-) diff --git a/src/components/application_manager/include/application_manager/application.h b/src/components/application_manager/include/application_manager/application.h index 700c0e5d2c..ef11de90d2 100644 --- a/src/components/application_manager/include/application_manager/application.h +++ b/src/components/application_manager/include/application_manager/application.h @@ -960,9 +960,11 @@ class Application : public virtual InitialApplicationData, virtual void set_cloud_app_auth_token(const std::string& auth_token) = 0; - virtual void set_cloud_app_transport_type(const std::string& transport_type) = 0; + virtual void set_cloud_app_transport_type( + const std::string& transport_type) = 0; - virtual void set_hybrid_app_preference(const std::string& hybrid_app_preference) = 0; + virtual void set_hybrid_app_preference( + const std::string& hybrid_app_preference) = 0; virtual void set_cloud_app_certificate(const std::string& certificate) = 0; diff --git a/src/components/application_manager/include/application_manager/application_impl.h b/src/components/application_manager/include/application_manager/application_impl.h index 0c365fc752..5a1a385d1e 100644 --- a/src/components/application_manager/include/application_manager/application_impl.h +++ b/src/components/application_manager/include/application_manager/application_impl.h @@ -425,7 +425,8 @@ class ApplicationImpl : public virtual Application, void set_cloud_app_transport_type(const std::string& transport_type) OVERRIDE; - void set_hybrid_app_preference(const std::string& hybrid_app_preference) OVERRIDE; + void set_hybrid_app_preference( + const std::string& hybrid_app_preference) OVERRIDE; void set_cloud_app_certificate(const std::string& certificate) OVERRIDE; @@ -537,7 +538,7 @@ class ApplicationImpl : public virtual Application, std::string endpoint_; std::string auth_token_; std::string cloud_transport_type_; - std::string hybrid_app_preference_; + std::string hybrid_app_preference_; std::string certificate_; /** diff --git a/src/components/application_manager/include/application_manager/application_manager_impl.h b/src/components/application_manager/include/application_manager/application_manager_impl.h index 6f6482e717..20b8c561a3 100644 --- a/src/components/application_manager/include/application_manager/application_manager_impl.h +++ b/src/components/application_manager/include/application_manager/application_manager_impl.h @@ -362,7 +362,10 @@ class ApplicationManagerImpl void CollectCloudAppInformation(); - void CreatePendingApplication(const transport_manager::ConnectionUID connection_id, const transport_manager::DeviceInfo& device_info, connection_handler::DeviceHandle device_id); + void CreatePendingApplication( + const transport_manager::ConnectionUID connection_id, + const transport_manager::DeviceInfo& device_info, + connection_handler::DeviceHandle device_id); /* * @brief Returns unique correlation ID for HMI request diff --git a/src/components/application_manager/src/application_impl.cc b/src/components/application_manager/src/application_impl.cc index 65f2a36fa8..027beb9313 100644 --- a/src/components/application_manager/src/application_impl.cc +++ b/src/components/application_manager/src/application_impl.cc @@ -1191,15 +1191,18 @@ void ApplicationImpl::set_cloud_app_auth_token(const std::string& auth_token) { auth_token_ = auth_token; } -void ApplicationImpl::set_cloud_app_transport_type(const std::string& transport_type) { +void ApplicationImpl::set_cloud_app_transport_type( + const std::string& transport_type) { cloud_transport_type_ = transport_type; } -void ApplicationImpl::set_hybrid_app_preference(const std::string& hybrid_app_preference) { +void ApplicationImpl::set_hybrid_app_preference( + const std::string& hybrid_app_preference) { hybrid_app_preference_ = hybrid_app_preference; } -void ApplicationImpl::set_cloud_app_certificate(const std::string& certificate) { +void ApplicationImpl::set_cloud_app_certificate( + const std::string& certificate) { certificate_ = certificate; } diff --git a/src/components/application_manager/src/application_manager_impl.cc b/src/components/application_manager/src/application_manager_impl.cc index 76067f1dc7..192468023d 100644 --- a/src/components/application_manager/src/application_manager_impl.cc +++ b/src/components/application_manager/src/application_manager_impl.cc @@ -100,7 +100,7 @@ DeviceTypes devicesType = { std::make_pair(std::string("CARPLAY_WIRELESS_IOS"), hmi_apis::Common_TransportType::WIFI), std::make_pair(std::string("CLOUD_WEBSOCKET"), - hmi_apis::Common_TransportType::CLOUD_WEBSOCKET)}; + hmi_apis::Common_TransportType::CLOUD_WEBSOCKET)}; } /** @@ -795,39 +795,46 @@ void ApplicationManagerImpl::CollectCloudAppInformation() { std::string auth_token = ""; std::string cloud_transport_type = ""; std::string hybrid_app_preference = ""; - for (; it!=end; ++it) { - GetPolicyHandler().GetCloudAppParameters(*it, endpoint, certificate, auth_token, - cloud_transport_type, hybrid_app_preference); + for (; it != end; ++it) { + GetPolicyHandler().GetCloudAppParameters(*it, + endpoint, + certificate, + auth_token, + cloud_transport_type, + hybrid_app_preference); - pending_device_map_.insert(std::pair(endpoint, *it)); + pending_device_map_.insert( + std::pair(endpoint, *it)); connection_handler().AddCloudAppDevice(*it, endpoint, cloud_transport_type); - - } } -void ApplicationManagerImpl::CreatePendingApplication(const transport_manager::ConnectionUID connection_id, const transport_manager::DeviceInfo& device_info, connection_handler::DeviceHandle device_id) { +void ApplicationManagerImpl::CreatePendingApplication( + const transport_manager::ConnectionUID connection_id, + const transport_manager::DeviceInfo& device_info, + connection_handler::DeviceHandle device_id) { LOG4CXX_AUTO_TRACE(logger_); std::string policy_app_id = ""; std::string name = device_info.name(); auto it = pending_device_map_.find(name); if (it == pending_device_map_.end()) { - return; + return; } - + policy_app_id = it->second; - ApplicationSharedPtr application( - new ApplicationImpl(0, - policy_app_id, - device_info.mac_address(), - device_id, - custom_str::CustomString("CloudApp"), //todo replace this with policy nick name - GetPolicyHandler().GetStatisticManager(), - *this)); - - if(!application) { + ApplicationSharedPtr application(new ApplicationImpl( + 0, + policy_app_id, + device_info.mac_address(), + device_id, + custom_str::CustomString( + "CloudApp"), // todo replace this with policy nick name + GetPolicyHandler().GetStatisticManager(), + *this)); + + if (!application) { LOG4CXX_INFO(logger_, "Could not streate application"); return; } @@ -835,14 +842,13 @@ void ApplicationManagerImpl::CreatePendingApplication(const transport_manager::C application->set_hmi_application_id(GenerateNewHMIAppID()); sync_primitives::AutoLock lock(apps_to_register_list_lock_ptr_); - LOG4CXX_DEBUG( - logger_, "apps_to_register_ size before: " << apps_to_register_.size()); + LOG4CXX_DEBUG(logger_, + "apps_to_register_ size before: " << apps_to_register_.size()); apps_to_register_.insert(application); LOG4CXX_DEBUG(logger_, "apps_to_register_ size after: " << apps_to_register_.size()); SendUpdateAppList(); - } uint32_t ApplicationManagerImpl::GetNextHMICorrelationID() { diff --git a/src/components/config_profile/include/config_profile/profile.h b/src/components/config_profile/include/config_profile/profile.h index da087086c2..b332ed69f5 100644 --- a/src/components/config_profile/include/config_profile/profile.h +++ b/src/components/config_profile/include/config_profile/profile.h @@ -415,7 +415,7 @@ class Profile : public protocol_handler::ProtocolHandlerSettings, /** * @brief Returns retry timeout for cloud app connections - */ + */ uint16_t cloud_app_retry_timeout() const OVERRIDE; /** diff --git a/src/components/connection_handler/include/connection_handler/connection_handler_impl.h b/src/components/connection_handler/include/connection_handler/connection_handler_impl.h index 81db445829..7be94c5f70 100644 --- a/src/components/connection_handler/include/connection_handler/connection_handler_impl.h +++ b/src/components/connection_handler/include/connection_handler/connection_handler_impl.h @@ -120,7 +120,9 @@ class ConnectionHandlerImpl void ConnectToAllDevices() OVERRIDE; - void AddCloudAppDevice(const std::string& policy_app_id, const std::string& endpoint, const std::string& cloud_transport_type) OVERRIDE; + void AddCloudAppDevice(const std::string& policy_app_id, + const std::string& endpoint, + const std::string& cloud_transport_type) OVERRIDE; void StartTransportManager() OVERRIDE; diff --git a/src/components/connection_handler/src/connection_handler_impl.cc b/src/components/connection_handler/src/connection_handler_impl.cc index 59fef50b0f..318224fcc7 100644 --- a/src/components/connection_handler/src/connection_handler_impl.cc +++ b/src/components/connection_handler/src/connection_handler_impl.cc @@ -142,7 +142,10 @@ void ConnectionHandlerImpl::OnDeviceAdded( LOG4CXX_AUTO_TRACE(logger_); auto handle = device_info.device_handle(); - LOG4CXX_DEBUG(logger_, "OnDeviceAdded!!!: " << handle << " " << device_info.name() << " " << device_info.mac_address() << " " << device_info.connection_type()); + LOG4CXX_DEBUG(logger_, + "OnDeviceAdded!!!: " << handle << " " << device_info.name() + << " " << device_info.mac_address() << " " + << device_info.connection_type()); Device device(handle, device_info.name(), @@ -250,7 +253,11 @@ void ConnectionHandlerImpl::OnConnectionPending( const transport_manager::DeviceInfo& device_info, const transport_manager::ConnectionUID connection_id) { LOG4CXX_AUTO_TRACE(logger_); - LOG4CXX_DEBUG(logger_, "OnConnectionEstablished!!!: " << device_info.device_handle() << " " << device_info.name() << " " << device_info.mac_address() << " " << device_info.connection_type()); + LOG4CXX_DEBUG(logger_, + "OnConnectionEstablished!!!: " + << device_info.device_handle() << " " << device_info.name() + << " " << device_info.mac_address() << " " + << device_info.connection_type()); DeviceMap::iterator it = device_list_.find(device_info.device_handle()); if (device_list_.end() == it) { LOG4CXX_ERROR(logger_, "Unknown device!"); @@ -259,33 +266,36 @@ void ConnectionHandlerImpl::OnConnectionPending( LOG4CXX_DEBUG(logger_, "Add Pending Connection #" << connection_id << " to the list."); - - //todo maybe create a seperate "pending_connection_list" + // todo maybe create a seperate "pending_connection_list" sync_primitives::AutoWriteLock lock(connection_list_lock_); if (connection_list_.find(connection_id) == connection_list_.end()) { - - Connection* connection = new Connection(connection_id, + Connection* connection = + new Connection(connection_id, device_info.device_handle(), this, get_settings().heart_beat_timeout()); - connection_list_.insert(ConnectionList::value_type( - connection_id, connection)); - - connection_handler::DeviceHandle device_id = connection->connection_device_handle(); - //uint32_t app_id = KeyFromPair(connection_id, session_id); - - connection_handler_observer_->CreatePendingApplication(connection_id, device_info, device_id); - } + connection_list_.insert( + ConnectionList::value_type(connection_id, connection)); + connection_handler::DeviceHandle device_id = + connection->connection_device_handle(); + // uint32_t app_id = KeyFromPair(connection_id, session_id); + connection_handler_observer_->CreatePendingApplication( + connection_id, device_info, device_id); + } } void ConnectionHandlerImpl::OnConnectionEstablished( const transport_manager::DeviceInfo& device_info, const transport_manager::ConnectionUID connection_id) { LOG4CXX_AUTO_TRACE(logger_); - LOG4CXX_DEBUG(logger_, "OnConnectionEstablished!!!: " << device_info.device_handle() << " " << device_info.name() << " " << device_info.mac_address() << " " << device_info.connection_type()); + LOG4CXX_DEBUG(logger_, + "OnConnectionEstablished!!!: " + << device_info.device_handle() << " " << device_info.name() + << " " << device_info.mac_address() << " " + << device_info.connection_type()); DeviceMap::iterator it = device_list_.find(device_info.device_handle()); if (device_list_.end() == it) { LOG4CXX_ERROR(logger_, "Unknown device!"); @@ -1306,7 +1316,10 @@ void ConnectionHandlerImpl::ConnectToAllDevices() { } } -void ConnectionHandlerImpl::AddCloudAppDevice(const std::string& policy_app_id, const std::string& endpoint, const std::string& cloud_transport_type) { +void ConnectionHandlerImpl::AddCloudAppDevice( + const std::string& policy_app_id, + const std::string& endpoint, + const std::string& cloud_transport_type) { transport_manager_.AddCloudDevice(endpoint, cloud_transport_type); } diff --git a/src/components/include/connection_handler/connection_handler.h b/src/components/include/connection_handler/connection_handler.h index 21c10dc3db..93939fc782 100644 --- a/src/components/include/connection_handler/connection_handler.h +++ b/src/components/include/connection_handler/connection_handler.h @@ -93,7 +93,9 @@ class ConnectionHandler { virtual void ConnectToAllDevices() = 0; - virtual void AddCloudAppDevice(const std::string& policy_app_id, const std::string& endpoint, const std::string& cloud_transport_type) = 0; + virtual void AddCloudAppDevice(const std::string& policy_app_id, + const std::string& endpoint, + const std::string& cloud_transport_type) = 0; /** * @brief Close the connection revoked by Policy diff --git a/src/components/include/connection_handler/connection_handler_observer.h b/src/components/include/connection_handler/connection_handler_observer.h index 9716f2c890..298f98803a 100644 --- a/src/components/include/connection_handler/connection_handler_observer.h +++ b/src/components/include/connection_handler/connection_handler_observer.h @@ -161,7 +161,10 @@ class ConnectionHandlerObserver { */ virtual void OnSecondaryTransportEndedCallback(const int32_t session_key) = 0; - virtual void CreatePendingApplication(const transport_manager::ConnectionUID connection_id, const transport_manager::DeviceInfo& device_info, connection_handler::DeviceHandle device_id) = 0; + virtual void CreatePendingApplication( + const transport_manager::ConnectionUID connection_id, + const transport_manager::DeviceInfo& device_info, + connection_handler::DeviceHandle device_id) = 0; protected: /** diff --git a/src/components/include/transport_manager/transport_adapter/transport_adapter.h b/src/components/include/transport_manager/transport_adapter/transport_adapter.h index d47c53b69c..4aa6e901ad 100644 --- a/src/components/include/transport_manager/transport_adapter/transport_adapter.h +++ b/src/components/include/transport_manager/transport_adapter/transport_adapter.h @@ -71,9 +71,9 @@ enum DeviceType { UNKNOWN }; -enum HybridAppPreference { // todo find correct place for this enum defintion. +enum HybridAppPreference { // todo find correct place for this enum defintion. MOBILE, - CLOUD, + CLOUD, BOTH }; @@ -105,7 +105,8 @@ typedef std::list TransportAdapterListenerList; typedef std::map TransportConfig; /** - * @brief Type definition of container indexed by app id that contains connection information for all cloud apps. + * @brief Type definition of container indexed by app id that contains + * connection information for all cloud apps. */ typedef std::map CloudAppTransportConfig; diff --git a/src/components/include/transport_manager/transport_manager.h b/src/components/include/transport_manager/transport_manager.h index f67923daef..b5dfa3671b 100644 --- a/src/components/include/transport_manager/transport_manager.h +++ b/src/components/include/transport_manager/transport_manager.h @@ -75,7 +75,8 @@ class TransportManager { **/ virtual int SearchDevices() = 0; - virtual void AddCloudDevice(const std::string& endpoint, const std::string& cloud_transport_type) = 0; + virtual void AddCloudDevice(const std::string& endpoint, + const std::string& cloud_transport_type) = 0; /** * @brief Connect to all applications discovered on device. diff --git a/src/components/include/transport_manager/transport_manager_listener.h b/src/components/include/transport_manager/transport_manager_listener.h index 2d7b2510a5..7da4bcc2f5 100644 --- a/src/components/include/transport_manager/transport_manager_listener.h +++ b/src/components/include/transport_manager/transport_manager_listener.h @@ -107,7 +107,7 @@ class TransportManagerListener { * @param connection_id connection unique identifier. */ virtual void OnConnectionPending(const DeviceInfo& device_info, - const ConnectionUID connection_id) = 0; + const ConnectionUID connection_id) = 0; /** * @brief Reaction to the event, when connection is established. * diff --git a/src/components/include/transport_manager/transport_manager_listener_empty.h b/src/components/include/transport_manager/transport_manager_listener_empty.h index d8104a62a9..c0a713f38e 100644 --- a/src/components/include/transport_manager/transport_manager_listener_empty.h +++ b/src/components/include/transport_manager/transport_manager_listener_empty.h @@ -105,7 +105,7 @@ class TransportManagerListenerEmpty : public TransportManagerListener { * @param connection_id connection unique identifier. */ void OnConnectionPending(const DeviceInfo& device_info, - const ConnectionUID connection_id) OVERRIDE {} + const ConnectionUID connection_id) OVERRIDE {} /** * @brief Reaction to the event, when connection is established. diff --git a/src/components/include/transport_manager/transport_manager_settings.h b/src/components/include/transport_manager/transport_manager_settings.h index d59038e5c6..30a5a98ae9 100644 --- a/src/components/include/transport_manager/transport_manager_settings.h +++ b/src/components/include/transport_manager/transport_manager_settings.h @@ -72,7 +72,7 @@ class TransportManagerSettings : public TransportManagerMMESettings { /** * @brief Returns retry timeout for cloud app connections - */ + */ virtual uint16_t cloud_app_retry_timeout() const = 0; /** diff --git a/src/components/protocol_handler/src/protocol_handler_impl.cc b/src/components/protocol_handler/src/protocol_handler_impl.cc index 3fb21d7d0d..ee2dc73780 100644 --- a/src/components/protocol_handler/src/protocol_handler_impl.cc +++ b/src/components/protocol_handler/src/protocol_handler_impl.cc @@ -1089,8 +1089,7 @@ void ProtocolHandlerImpl::OnTMMessageSendFailed( void ProtocolHandlerImpl::OnConnectionPending( const transport_manager::DeviceInfo& device_info, - const transport_manager::ConnectionUID connection_id) { -} + const transport_manager::ConnectionUID connection_id) {} void ProtocolHandlerImpl::OnConnectionEstablished( const transport_manager::DeviceInfo& device_info, diff --git a/src/components/transport_manager/include/transport_manager/cloud/cloud_device.h b/src/components/transport_manager/include/transport_manager/cloud/cloud_device.h index 5792ba06a1..f80ad924e3 100644 --- a/src/components/transport_manager/include/transport_manager/cloud/cloud_device.h +++ b/src/components/transport_manager/include/transport_manager/cloud/cloud_device.h @@ -45,9 +45,7 @@ namespace transport_adapter { class CloudDevice : public Device { public: - CloudDevice(std::string& host, - std::string& port, - std::string& name); + CloudDevice(std::string& host, std::string& port, std::string& name); protected: virtual bool IsSameAs(const Device* other_device) const; @@ -55,7 +53,7 @@ class CloudDevice : public Device { virtual ApplicationList GetApplicationList() const; private: - //todo add private varaibles, maybe ip port or other connection information? + // todo add private varaibles, maybe ip port or other connection information? }; } // namespace transport_adapter diff --git a/src/components/transport_manager/include/transport_manager/cloud/cloud_websocket_transport_adapter.h b/src/components/transport_manager/include/transport_manager/cloud/cloud_websocket_transport_adapter.h index 062b478c29..546ab71fbd 100644 --- a/src/components/transport_manager/include/transport_manager/cloud/cloud_websocket_transport_adapter.h +++ b/src/components/transport_manager/include/transport_manager/cloud/cloud_websocket_transport_adapter.h @@ -49,7 +49,9 @@ class CloudWebsocketTransportAdapter : public TransportAdapterImpl { /** * @brief Constructor. */ - explicit CloudWebsocketTransportAdapter(resumption::LastState& last_state, const TransportManagerSettings& settings); + explicit CloudWebsocketTransportAdapter( + resumption::LastState& last_state, + const TransportManagerSettings& settings); /** * @brief Destructor. @@ -93,7 +95,7 @@ class CloudWebsocketTransportAdapter : public TransportAdapterImpl { private: /** * @brief Keeps transport specific configuration - * + * * Cloud websocket transport uses following information: * - "enabled": whether the transport is currently enabled or not. Value can * be "true" or "false". diff --git a/src/components/transport_manager/include/transport_manager/cloud/websocket_client_connection.h b/src/components/transport_manager/include/transport_manager/cloud/websocket_client_connection.h index 38eb663b1c..da3a80e1b2 100644 --- a/src/components/transport_manager/include/transport_manager/cloud/websocket_client_connection.h +++ b/src/components/transport_manager/include/transport_manager/cloud/websocket_client_connection.h @@ -53,12 +53,13 @@ #include "utils/threads/message_loop_thread.h" #include "utils/message_queue.h" -using tcp = boost::asio::ip::tcp; // from -namespace ssl = boost::asio::ssl; // from -namespace websocket = boost::beast::websocket; // from +using tcp = boost::asio::ip::tcp; // from +namespace ssl = boost::asio::ssl; // from +namespace websocket = + boost::beast::websocket; // from using ::utils::MessageQueue; -typedef std::queue AsyncQueue; +typedef std::queue AsyncQueue; typedef protocol_handler::RawMessagePtr Message; namespace transport_manager { @@ -69,7 +70,9 @@ class TransportAdapterController; /** * @brief Class responsible for communication over bluetooth sockets. */ -class WebsocketClientConnection : public std::enable_shared_from_this, public Connection { +class WebsocketClientConnection + : public std::enable_shared_from_this, + public Connection { public: /** * @brief Constructor. @@ -98,13 +101,13 @@ class WebsocketClientConnection : public std::enable_shared_from_this message_queue_; - class LoopThreadDelegate : public threads::ThreadDelegate { public: LoopThreadDelegate(MessageQueue* message_queue, diff --git a/src/components/transport_manager/include/transport_manager/transport_adapter/transport_adapter_controller.h b/src/components/transport_manager/include/transport_manager/transport_adapter/transport_adapter_controller.h index 8bc39596b6..6d97a55a70 100644 --- a/src/components/transport_manager/include/transport_manager/transport_adapter/transport_adapter_controller.h +++ b/src/components/transport_manager/include/transport_manager/transport_adapter/transport_adapter_controller.h @@ -107,7 +107,7 @@ class TransportAdapterController { * @param app_handle Handle of application. */ virtual void ConnectPending(const DeviceUID& device_handle, - const ApplicationHandle& app_handle) = 0; + const ApplicationHandle& app_handle) = 0; /** * @brief Make state of specified connection - ESTABLISHED and launch diff --git a/src/components/transport_manager/include/transport_manager/transport_adapter/transport_adapter_impl.h b/src/components/transport_manager/include/transport_manager/transport_adapter/transport_adapter_impl.h index ccc025b60e..0af1f2b614 100644 --- a/src/components/transport_manager/include/transport_manager/transport_adapter/transport_adapter_impl.h +++ b/src/components/transport_manager/include/transport_manager/transport_adapter/transport_adapter_impl.h @@ -313,7 +313,7 @@ class TransportAdapterImpl : public TransportAdapter, * @param app_handle Handle of application. */ void ConnectPending(const DeviceUID& device_handle, - const ApplicationHandle& app_handle) OVERRIDE; + const ApplicationHandle& app_handle) OVERRIDE; /** * @brief Set state of specified connection - ESTABLISHED and launch diff --git a/src/components/transport_manager/include/transport_manager/transport_adapter/transport_adapter_listener.h b/src/components/transport_manager/include/transport_manager/transport_adapter/transport_adapter_listener.h index fe71983ab7..b0368869e7 100644 --- a/src/components/transport_manager/include/transport_manager/transport_adapter/transport_adapter_listener.h +++ b/src/components/transport_manager/include/transport_manager/transport_adapter/transport_adapter_listener.h @@ -101,8 +101,8 @@ class TransportAdapterListener { * @param app_id Handle of application. */ virtual void OnConnectPending(const TransportAdapter* adapter, - const DeviceUID& device_handle, - const ApplicationHandle& app_id) = 0; + const DeviceUID& device_handle, + const ApplicationHandle& app_id) = 0; /** * @brief Search specified device adapter in the container of shared pointers diff --git a/src/components/transport_manager/include/transport_manager/transport_adapter/transport_adapter_listener_impl.h b/src/components/transport_manager/include/transport_manager/transport_adapter/transport_adapter_listener_impl.h index f4a5062eac..76271229ad 100644 --- a/src/components/transport_manager/include/transport_manager/transport_adapter/transport_adapter_listener_impl.h +++ b/src/components/transport_manager/include/transport_manager/transport_adapter/transport_adapter_listener_impl.h @@ -97,8 +97,8 @@ class TransportAdapterListenerImpl * @param app_id Handle of application. */ virtual void OnConnectPending(const TransportAdapter* adapter, - const DeviceUID& device_handle, - const ApplicationHandle& app_id); + const DeviceUID& device_handle, + const ApplicationHandle& app_id); /** * @brief Search specified device adapter in the container of shared pointers diff --git a/src/components/transport_manager/include/transport_manager/transport_manager_impl.h b/src/components/transport_manager/include/transport_manager/transport_manager_impl.h index e2ce07ad18..dcb3b6922c 100644 --- a/src/components/transport_manager/include/transport_manager/transport_manager_impl.h +++ b/src/components/transport_manager/include/transport_manager/transport_manager_impl.h @@ -140,7 +140,8 @@ class TransportManagerImpl **/ int SearchDevices() OVERRIDE; - void AddCloudDevice(const std::string& endpoint, const std::string& cloud_transport_type) OVERRIDE; + void AddCloudDevice(const std::string& endpoint, + const std::string& cloud_transport_type) OVERRIDE; /** * @brief Connect to all applications discovered on device. diff --git a/src/components/transport_manager/src/cloud/cloud_device.cc b/src/components/transport_manager/src/cloud/cloud_device.cc index df17753ccc..699d79d52a 100644 --- a/src/components/transport_manager/src/cloud/cloud_device.cc +++ b/src/components/transport_manager/src/cloud/cloud_device.cc @@ -40,23 +40,21 @@ namespace transport_adapter { CREATE_LOGGERPTR_GLOBAL(logger_, "TransportManager") CloudDevice::CloudDevice(std::string& host, - std::string& port, - std::string& name) + std::string& port, + std::string& name) : Device(name, std::string(name)) {} - bool CloudDevice::IsSameAs(const Device* other) const { LOG4CXX_TRACE(logger_, "enter. device: " << other); bool result = false; return result; } -//todo implement getApplicationList -//to be populated by policies +// todo implement getApplicationList +// to be populated by policies ApplicationList CloudDevice::GetApplicationList() const { return ApplicationList{100}; } - } // namespace transport_adapter } // namespace transport_manager diff --git a/src/components/transport_manager/src/cloud/cloud_websocket_connection_factory.cc b/src/components/transport_manager/src/cloud/cloud_websocket_connection_factory.cc index 9265adb7f3..2b2a5ee2aa 100644 --- a/src/components/transport_manager/src/cloud/cloud_websocket_connection_factory.cc +++ b/src/components/transport_manager/src/cloud/cloud_websocket_connection_factory.cc @@ -75,14 +75,15 @@ TransportAdapter::Error CloudWebsocketConnectionFactory::CreateConnection( const DeviceUID& device_uid, const ApplicationHandle& app_handle) { LOG4CXX_AUTO_TRACE(logger_); printf("Create connection()\n"); - std::shared_ptr connection = + std::shared_ptr connection = std::make_shared( device_uid, app_handle, controller_); controller_->ConnectionCreated(connection, device_uid, app_handle); TransportAdapter::Error error = connection->Start(); if (TransportAdapter::OK != error) { - LOG4CXX_ERROR(logger_, - "Cloud Websocket connection::Start() failed with error: " << error); + LOG4CXX_ERROR( + logger_, + "Cloud Websocket connection::Start() failed with error: " << error); } return error; } diff --git a/src/components/transport_manager/src/cloud/cloud_websocket_transport_adapter.cc b/src/components/transport_manager/src/cloud/cloud_websocket_transport_adapter.cc index 49a0020423..978cfd191a 100644 --- a/src/components/transport_manager/src/cloud/cloud_websocket_transport_adapter.cc +++ b/src/components/transport_manager/src/cloud/cloud_websocket_transport_adapter.cc @@ -33,11 +33,9 @@ #include "transport_manager/cloud/cloud_websocket_transport_adapter.h" #include "transport_manager/cloud/cloud_websocket_connection_factory.h" - #include "transport_manager/cloud/cloud_device.h" #include "transport_manager/cloud/websocket_client_connection.h" - #include namespace transport_manager { @@ -45,72 +43,80 @@ namespace transport_adapter { CREATE_LOGGERPTR_GLOBAL(logger_, "TransportManager") -CloudWebsocketTransportAdapter::CloudWebsocketTransportAdapter(resumption::LastState& last_state, const TransportManagerSettings& settings) -: TransportAdapterImpl(NULL, new CloudWebsocketConnectionFactory(this), NULL, last_state, settings) { - - /*DeviceUID device_id = "Cloud"; - ApplicationHandle app_handle = 100; - printf("Calling create connection\n"); - const TransportAdapter::Error err = +CloudWebsocketTransportAdapter::CloudWebsocketTransportAdapter( + resumption::LastState& last_state, const TransportManagerSettings& settings) + : TransportAdapterImpl(NULL, + new CloudWebsocketConnectionFactory(this), + NULL, + last_state, + settings) { + /*DeviceUID device_id = "Cloud"; + ApplicationHandle app_handle = 100; + printf("Calling create connection\n"); + const TransportAdapter::Error err = server_connection_factory_->CreateConnection(device_id, app_handle); LOG4CXX_DEBUG(logger_, err);*/ } CloudWebsocketTransportAdapter::~CloudWebsocketTransportAdapter() {} -void CloudWebsocketTransportAdapter::CloudTransportConfigUpdated(const CloudAppTransportConfig& new_config) {} +void CloudWebsocketTransportAdapter::CloudTransportConfigUpdated( + const CloudAppTransportConfig& new_config) {} -CloudAppTransportConfig CloudWebsocketTransportAdapter::GetCloudTransportConfiguration() const { return transport_config_; } +CloudAppTransportConfig +CloudWebsocketTransportAdapter::GetCloudTransportConfiguration() const { + return transport_config_; +} DeviceType CloudWebsocketTransportAdapter::GetDeviceType() const { return CLOUD_WEBSOCKET; } -void CloudWebsocketTransportAdapter::Store() const {} // todo decide if this is needed +void CloudWebsocketTransportAdapter::Store() const { +} // todo decide if this is needed -bool CloudWebsocketTransportAdapter::Restore() { // todo decide if resumption is needed - return true; +bool CloudWebsocketTransportAdapter::Restore() { // todo decide if resumption + // is needed + return true; } void CloudWebsocketTransportAdapter::CreateDevice(const std::string& uid) { - boost::regex pattern ("(wss?):\\/\\/([A-Z\\d\\.-]{2,})\\.([A-Z]{2,})(:\\d{2,4})", boost::regex::icase); - std::string str = uid; - if (!boost::regex_match(str, pattern)) { - LOG4CXX_DEBUG(logger_, "Invalid Endpoint: " << uid); - return; - } - - LOG4CXX_DEBUG(logger_, "Valid Endpoint: " << uid); - std::size_t pos = uid.find(":"); - pos = uid.find(":", pos+1); - //std::size_t size = uid.length(); - std::string host = uid.substr(0, pos); - std::string port = uid.substr(pos+1); - std::string device_id = uid; - - LOG4CXX_DEBUG(logger_, "Creating Cloud Device For Host: " << host << " and Port: " << port); - - //todo get nickname from policies to name device - auto cloud_device = std::make_shared(host, port, device_id); - - DeviceVector devices{cloud_device}; - - SearchDeviceDone(devices); - - //Create connection object, do not start until app is activated - std::shared_ptr connection = - std::make_shared( - uid, 0, this); - - ConnectionCreated(connection, uid, 0); - ConnectPending(uid, 0); - - return; + boost::regex pattern( + "(wss?):\\/\\/([A-Z\\d\\.-]{2,})\\.([A-Z]{2,})(:\\d{2,4})", + boost::regex::icase); + std::string str = uid; + if (!boost::regex_match(str, pattern)) { + LOG4CXX_DEBUG(logger_, "Invalid Endpoint: " << uid); + return; + } + + LOG4CXX_DEBUG(logger_, "Valid Endpoint: " << uid); + std::size_t pos = uid.find(":"); + pos = uid.find(":", pos + 1); + // std::size_t size = uid.length(); + std::string host = uid.substr(0, pos); + std::string port = uid.substr(pos + 1); + std::string device_id = uid; + + LOG4CXX_DEBUG(logger_, + "Creating Cloud Device For Host: " << host + << " and Port: " << port); + + // todo get nickname from policies to name device + auto cloud_device = std::make_shared(host, port, device_id); + + DeviceVector devices{cloud_device}; + + SearchDeviceDone(devices); + + // Create connection object, do not start until app is activated + std::shared_ptr connection = + std::make_shared(uid, 0, this); + + ConnectionCreated(connection, uid, 0); + ConnectPending(uid, 0); + + return; } - - - - - } } \ No newline at end of file diff --git a/src/components/transport_manager/src/cloud/websocket_client_connection.cc b/src/components/transport_manager/src/cloud/websocket_client_connection.cc index 96641f5cb2..c2dcc9f14a 100644 --- a/src/components/transport_manager/src/cloud/websocket_client_connection.cc +++ b/src/components/transport_manager/src/cloud/websocket_client_connection.cc @@ -44,18 +44,19 @@ CREATE_LOGGERPTR_GLOBAL(logger_, "TransportManager") WebsocketClientConnection::WebsocketClientConnection( const DeviceUID& device_uid, const ApplicationHandle& app_handle, - TransportAdapterController* controller): controller_(controller) - , resolver_(ioc_) - , ws_(ioc_) - , shutdown_(false) - , thread_delegate_(new LoopThreadDelegate(&message_queue_, this)) - , write_thread_(threads::CreateThread("WS Async Send", thread_delegate_)) - , device_uid_(device_uid) - , app_handle_(app_handle) {} + TransportAdapterController* controller) + : controller_(controller) + , resolver_(ioc_) + , ws_(ioc_) + , shutdown_(false) + , thread_delegate_(new LoopThreadDelegate(&message_queue_, this)) + , write_thread_(threads::CreateThread("WS Async Send", thread_delegate_)) + , device_uid_(device_uid) + , app_handle_(app_handle) {} WebsocketClientConnection::~WebsocketClientConnection() { ioc_.stop(); - if(io_service_thread_.joinable()) { + if (io_service_thread_.joinable()) { io_service_thread_.join(); } } @@ -92,20 +93,20 @@ TransportAdapter::Error WebsocketClientConnection::Start() { controller_->ConnectDone(device_uid_, app_handle_); // Start async read - ws_.async_read( - buffer_, - std::bind( - &WebsocketClientConnection::OnRead, - this, - std::placeholders::_1, - std::placeholders::_2)); + ws_.async_read(buffer_, + std::bind(&WebsocketClientConnection::OnRead, + this, + std::placeholders::_1, + std::placeholders::_2)); // Start IO Service thread. Allows for async reads without blocking. - io_service_thread_ = std::thread([&](){ ioc_.run(); printf("io_service_thread_ END!!!\n"); - }); + io_service_thread_ = std::thread([&]() { + ioc_.run(); + printf("io_service_thread_ END!!!\n"); + }); // Start async write thread - + printf("End of websockets\n"); return TransportAdapter::OK; @@ -122,26 +123,24 @@ void WebsocketClientConnection::Recv(boost::system::error_code ec) { std::string str_err = "ErrorMessage: " + ec.message(); printf("%s\n", str_err.c_str()); LOG4CXX_ERROR(logger_, str_err); - //shutdown_ = true; - //ioc_.stop(); - //thread_delegate_->SetShutdown(); - //controller_->deleteController(this); + // shutdown_ = true; + // ioc_.stop(); + // thread_delegate_->SetShutdown(); + // controller_->deleteController(this); Shutdown(); return; } printf("calling async read\n"); - ws_.async_read( - buffer_, - std::bind( - &WebsocketClientConnection::OnRead, - this, - std::placeholders::_1, - std::placeholders::_2)); + ws_.async_read(buffer_, + std::bind(&WebsocketClientConnection::OnRead, + this, + std::placeholders::_1, + std::placeholders::_2)); } void WebsocketClientConnection::OnRead(boost::system::error_code ec, - std::size_t bytes_transferred) { + std::size_t bytes_transferred) { printf("OnRead\n"); boost::ignore_unused(bytes_transferred); if (ec) { @@ -151,7 +150,7 @@ void WebsocketClientConnection::OnRead(boost::system::error_code ec, Shutdown(); controller_->ConnectionAborted( device_uid_, app_handle_, CommunicationError()); - + printf("return error\n"); return; } @@ -160,11 +159,12 @@ void WebsocketClientConnection::OnRead(boost::system::error_code ec, LOG4CXX_DEBUG(logger_, "Cloud Transport Received: " << data_str); printf("%s\n", data_str.c_str()); - ssize_t size = (ssize_t)buffer_.size(); - const uint8_t* data = boost::asio::buffer_cast(boost::beast::buffers_front(buffer_.data())); + ssize_t size = (ssize_t)buffer_.size(); + const uint8_t* data = boost::asio::buffer_cast( + boost::beast::buffers_front(buffer_.data())); ::protocol_handler::RawMessagePtr frame( - new protocol_handler::RawMessage(0, 0, data, size)); + new protocol_handler::RawMessage(0, 0, data, size)); controller_->DataReceiveDone(device_uid_, app_handle_, frame); @@ -189,7 +189,6 @@ TransportAdapter::Error WebsocketClientConnection::Disconnect() { } void WebsocketClientConnection::Shutdown() { - shutdown_ = true; if (thread_delegate_) { @@ -205,7 +204,8 @@ void WebsocketClientConnection::Shutdown() { } WebsocketClientConnection::LoopThreadDelegate::LoopThreadDelegate( - MessageQueue* message_queue, WebsocketClientConnection* handler) + MessageQueue* message_queue, + WebsocketClientConnection* handler) : message_queue_(*message_queue), handler_(*handler), shutdown_(false) {} void WebsocketClientConnection::LoopThreadDelegate::threadMain() { @@ -231,11 +231,15 @@ void WebsocketClientConnection::LoopThreadDelegate::DrainQueue() { if (!shutdown_) { printf("Calling Write!!!\n"); boost::system::error_code ec; - handler_.ws_.write(boost::asio::buffer(message_ptr->data(), message_ptr->data_size())); + handler_.ws_.write( + boost::asio::buffer(message_ptr->data(), message_ptr->data_size())); if (ec) { LOG4CXX_ERROR(logger_, "Error writing to websocket"); handler_.Shutdown(); - handler_.controller_->DataSendFailed(handler_.device_uid_, handler_.app_handle_, message_ptr, DataSendError()); + handler_.controller_->DataSendFailed(handler_.device_uid_, + handler_.app_handle_, + message_ptr, + DataSendError()); } } } diff --git a/src/components/transport_manager/src/transport_adapter/transport_adapter_impl.cc b/src/components/transport_manager/src/transport_adapter/transport_adapter_impl.cc index 088cc2efb5..38b9bd3998 100644 --- a/src/components/transport_manager/src/transport_adapter/transport_adapter_impl.cc +++ b/src/components/transport_manager/src/transport_adapter/transport_adapter_impl.cc @@ -61,8 +61,8 @@ DeviceTypes devicesType = { std::string("USB_IOS_DEVICE_MODE")), std::make_pair(DeviceType::IOS_CARPLAY_WIRELESS, std::string("CARPLAY_WIRELESS_IOS")), - std::make_pair(DeviceType::CLOUD_WEBSOCKET, std::string("CLOUD_WEBSOCKET")) - }; + std::make_pair(DeviceType::CLOUD_WEBSOCKET, + std::string("CLOUD_WEBSOCKET"))}; } TransportAdapterImpl::TransportAdapterImpl( @@ -746,7 +746,7 @@ DeviceSptr TransportAdapterImpl::FindDevice(const DeviceUID& device_id) const { } void TransportAdapterImpl::ConnectPending(const DeviceUID& device_id, - const ApplicationHandle& app_handle) { + const ApplicationHandle& app_handle) { connections_lock_.AcquireForReading(); ConnectionMap::iterator it_conn = connections_.find(std::make_pair(device_id, app_handle)); diff --git a/src/components/transport_manager/src/transport_manager_default.cc b/src/components/transport_manager/src/transport_manager_default.cc index f78c31c0d5..3beed2f763 100644 --- a/src/components/transport_manager/src/transport_manager_default.cc +++ b/src/components/transport_manager/src/transport_manager_default.cc @@ -107,7 +107,10 @@ int TransportManagerDefault::Init(resumption::LastState& last_state) { #if defined CLOUD_APP_WEBSOCKET_TRANSPORT_SUPPORT printf("Creating cloud transport\n"); - transport_adapter::TransportAdapterImpl* ta_cloud = new transport_adapter::CloudWebsocketTransportAdapter(last_state, get_settings()); //Todo add retry connection logic from ini to initializer. + transport_adapter::TransportAdapterImpl* ta_cloud = + new transport_adapter::CloudWebsocketTransportAdapter( + last_state, get_settings()); // Todo add retry connection logic from + // ini to initializer. #ifdef TELEMETRY_MONITOR if (metric_observer_) { ta_cloud->SetTelemetryObserver(metric_observer_); diff --git a/src/components/transport_manager/src/transport_manager_impl.cc b/src/components/transport_manager/src/transport_manager_impl.cc index ea85e9a37b..300ed27718 100644 --- a/src/components/transport_manager/src/transport_manager_impl.cc +++ b/src/components/transport_manager/src/transport_manager_impl.cc @@ -129,9 +129,9 @@ void TransportManagerImpl::ReconnectionTimeout() { device_to_reconnect_); } -void TransportManagerImpl::AddCloudDevice(const std::string& endpoint, const std::string& cloud_transport_type) { - - //todo put conversion into own function +void TransportManagerImpl::AddCloudDevice( + const std::string& endpoint, const std::string& cloud_transport_type) { + // todo put conversion into own function transport_adapter::DeviceType type = transport_adapter::DeviceType::UNKNOWN; if (cloud_transport_type == "WS") { type = transport_adapter::DeviceType::CLOUD_WEBSOCKET; @@ -140,7 +140,7 @@ void TransportManagerImpl::AddCloudDevice(const std::string& endpoint, const std } std::vector::iterator ta = transport_adapters_.begin(); - for (;ta != transport_adapters_.end(); ++ta) { + for (; ta != transport_adapters_.end(); ++ta) { if ((*ta)->GetDeviceType() == type) { (*ta)->CreateDevice(endpoint); } @@ -1000,14 +1000,14 @@ void TransportManagerImpl::Handle(TransportAdapterEvent event) { int connection_id = 0; std::vector::iterator it = connections_.begin(); std::vector::iterator end = connections_.end(); - for(; it != end; ++it){ - if(it->transport_adapter != event.transport_adapter) { + for (; it != end; ++it) { + if (it->transport_adapter != event.transport_adapter) { continue; - } else if(it->Connection::device != event.device_uid) { + } else if (it->Connection::device != event.device_uid) { continue; - } else if(it->Connection::application != event.application_id) { + } else if (it->Connection::application != event.application_id) { continue; - } else if(it->device_handle_ != device_handle) { + } else if (it->device_handle_ != device_handle) { continue; } else { LOG4CXX_DEBUG(logger_, "Connection Object Already Exists"); @@ -1016,8 +1016,7 @@ void TransportManagerImpl::Handle(TransportAdapterEvent event) { } } - - if(it == end) { + if (it == end) { AddConnection(ConnectionInternal(this, event.transport_adapter, ++connection_id_counter_, -- cgit v1.2.1 From ed2b5929389a4de02e74242c47c89e85bd25f5be Mon Sep 17 00:00:00 2001 From: JackLivio Date: Wed, 14 Nov 2018 14:30:23 -0500 Subject: Update regex pattern to allow ip address format --- .../transport_manager/src/cloud/cloud_websocket_transport_adapter.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/transport_manager/src/cloud/cloud_websocket_transport_adapter.cc b/src/components/transport_manager/src/cloud/cloud_websocket_transport_adapter.cc index 49a0020423..bdb52d1387 100644 --- a/src/components/transport_manager/src/cloud/cloud_websocket_transport_adapter.cc +++ b/src/components/transport_manager/src/cloud/cloud_websocket_transport_adapter.cc @@ -73,7 +73,7 @@ bool CloudWebsocketTransportAdapter::Restore() { // todo decide if resumption is } void CloudWebsocketTransportAdapter::CreateDevice(const std::string& uid) { - boost::regex pattern ("(wss?):\\/\\/([A-Z\\d\\.-]{2,})\\.([A-Z]{2,})(:\\d{2,4})", boost::regex::icase); + boost::regex pattern ("(wss?):\\/\\/([A-Z\\d\\.-]{2,})\\.?([A-Z]{2,})?(:\\d{2,4})\\/", boost::regex::icase); std::string str = uid; if (!boost::regex_match(str, pattern)) { LOG4CXX_DEBUG(logger_, "Invalid Endpoint: " << uid); -- cgit v1.2.1 From 232f7f86c3d3e70df70aa14fb6817eb4c9e17c9d Mon Sep 17 00:00:00 2001 From: jacobkeeler Date: Wed, 14 Nov 2018 14:33:25 -0500 Subject: Add SDL.ActivateApp flow changes for cloud apps --- .../include/application_manager/application.h | 2 + .../include/application_manager/application_impl.h | 2 + .../src/commands/hmi/sdl_activate_app_request.cc | 10 +++++ .../mobile/register_app_interface_request.cc | 4 ++ .../application_manager/src/application_impl.cc | 4 ++ .../include/application_manager/mock_application.h | 1 + .../transport_adapter/transport_adapter_impl.h | 9 ++++ .../transport_manager/transport_manager_impl.h | 1 - .../transport_adapter/transport_adapter_impl.cc | 48 +++++++++++++++++++--- 9 files changed, 74 insertions(+), 7 deletions(-) diff --git a/src/components/application_manager/include/application_manager/application.h b/src/components/application_manager/include/application_manager/application.h index ef11de90d2..02fff1cabb 100644 --- a/src/components/application_manager/include/application_manager/application.h +++ b/src/components/application_manager/include/application_manager/application.h @@ -956,6 +956,8 @@ class Application : public virtual InitialApplicationData, virtual std::string cloud_app_certificate() = 0; + virtual bool is_cloud_app() const = 0; + virtual void set_cloud_app_endpoint(const std::string& endpoint) = 0; virtual void set_cloud_app_auth_token(const std::string& auth_token) = 0; diff --git a/src/components/application_manager/include/application_manager/application_impl.h b/src/components/application_manager/include/application_manager/application_impl.h index 5a1a385d1e..3401322d59 100644 --- a/src/components/application_manager/include/application_manager/application_impl.h +++ b/src/components/application_manager/include/application_manager/application_impl.h @@ -419,6 +419,8 @@ class ApplicationImpl : public virtual Application, std::string cloud_app_certificate() OVERRIDE; + bool is_cloud_app() const OVERRIDE; + void set_cloud_app_endpoint(const std::string& endpoint) OVERRIDE; void set_cloud_app_auth_token(const std::string& auth_token) OVERRIDE; diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/sdl_activate_app_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/sdl_activate_app_request.cc index f89ae1f697..c81c53d5a9 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/sdl_activate_app_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/sdl_activate_app_request.cc @@ -124,6 +124,11 @@ void SDLActivateAppRequest::Run() { static_cast(function_id()), hmi_apis::Common_Result::REJECTED, "HMIDeactivate is active"); + } else if (!app_to_activate->IsRegistered() && + app_to_activate->is_cloud_app()) { + LOG4CXX_DEBUG(logger_, "Starting cloud application."); + application_manager_.connection_handler().ConnectToDevice( + app_to_activate->device()); } else { const uint32_t application_id = app_id(); policy_handler_.OnActivateApp(application_id, correlation_id()); @@ -181,6 +186,11 @@ void SDLActivateAppRequest::Run() { LOG4CXX_DEBUG(logger_, "Application is registered. Activating."); policy_handler_.OnActivateApp(application_id, correlation_id()); return; + } else if (app_to_activate->is_cloud_app()) { + LOG4CXX_DEBUG(logger_, "Starting cloud application."); + application_manager_.connection_handler().ConnectToDevice( + app_to_activate->device()); + return; } connection_handler::DeviceHandle device_handle = app_to_activate->device(); 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 7957d9e055..58ee598e02 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 @@ -842,6 +842,10 @@ void RegisterAppInterfaceRequest::SendRegisterAppInterfaceResponseToMobile( // By default app subscribed to CUSTOM_BUTTON SendSubscribeCustomButtonNotification(); SendChangeRegistrationOnHMI(application); + + if (application->is_cloud_app()) { + policy_handler_.OnActivateApp(connection_key(), correlation_id()); + } } void RegisterAppInterfaceRequest::SendChangeRegistration( diff --git a/src/components/application_manager/src/application_impl.cc b/src/components/application_manager/src/application_impl.cc index 027beb9313..23376f944a 100644 --- a/src/components/application_manager/src/application_impl.cc +++ b/src/components/application_manager/src/application_impl.cc @@ -1183,6 +1183,10 @@ std::string ApplicationImpl::cloud_app_certificate() { return certificate_; } +bool ApplicationImpl::is_cloud_app() const { + return !endpoint_.empty() && hybrid_app_preference_ != "MOBILE"; +} + void ApplicationImpl::set_cloud_app_endpoint(const std::string& endpoint) { endpoint_ = endpoint; } 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 fe16e8ce6e..aaa2a105e4 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 @@ -340,6 +340,7 @@ class MockApplication : public ::application_manager::Application { MOCK_METHOD1(RemoveExtension, bool(application_manager::AppExtensionUID uid)); MOCK_CONST_METHOD0(Extensions, const std::list&()); + MOCK_CONST_METHOD1(is_cloud_app, bool()); MOCK_CONST_METHOD0(is_remote_control_supported, bool()); MOCK_METHOD1(set_remote_control_supported, void(const bool allow)); }; diff --git a/src/components/transport_manager/include/transport_manager/transport_adapter/transport_adapter_impl.h b/src/components/transport_manager/include/transport_manager/transport_adapter/transport_adapter_impl.h index 0af1f2b614..13706b5cfc 100644 --- a/src/components/transport_manager/include/transport_manager/transport_adapter/transport_adapter_impl.h +++ b/src/components/transport_manager/include/transport_manager/transport_adapter/transport_adapter_impl.h @@ -41,6 +41,7 @@ #include "utils/lock.h" #include "utils/rwlock.h" +#include "utils/timer.h" #include "transport_manager/transport_adapter/transport_adapter.h" #include "transport_manager/transport_adapter/transport_adapter_controller.h" @@ -61,6 +62,8 @@ class DeviceScanner; class ServerConnectionFactory; class ClientConnectionListener; +typedef std::shared_ptr TimerSPtr; + /* * @brief Implementation of device adapter class. **/ @@ -546,6 +549,8 @@ class TransportAdapterImpl : public TransportAdapter, */ TransportAdapter::Error ConnectDevice(DeviceSptr device); + void RetryConnection(); + /** * @brief Remove specified device * @param device_handle Device unique identifier. @@ -578,6 +583,7 @@ class TransportAdapterImpl : public TransportAdapter, ConnectionSPtr connection; DeviceUID device_id; ApplicationHandle app_handle; + uint16_t retry_count; enum { NEW, ESTABLISHED, FINALISING, PENDING, RETRY } state; }; @@ -607,6 +613,9 @@ class TransportAdapterImpl : public TransportAdapter, **/ ConnectionMap connections_; + std::queue > > + retry_timer_pool_; + /** * @brief Mutex restricting access to connections map. **/ diff --git a/src/components/transport_manager/include/transport_manager/transport_manager_impl.h b/src/components/transport_manager/include/transport_manager/transport_manager_impl.h index dcb3b6922c..0facbb57e7 100644 --- a/src/components/transport_manager/include/transport_manager/transport_manager_impl.h +++ b/src/components/transport_manager/include/transport_manager/transport_manager_impl.h @@ -43,7 +43,6 @@ #include #include "utils/timer.h" -#include "utils/timer_task_impl.h" #include "utils/rwlock.h" #include "transport_manager/transport_manager.h" diff --git a/src/components/transport_manager/src/transport_adapter/transport_adapter_impl.cc b/src/components/transport_manager/src/transport_adapter/transport_adapter_impl.cc index 38b9bd3998..1f58eb5f77 100644 --- a/src/components/transport_manager/src/transport_adapter/transport_adapter_impl.cc +++ b/src/components/transport_manager/src/transport_adapter/transport_adapter_impl.cc @@ -31,8 +31,9 @@ */ #include "config_profile/profile.h" -#include "utils/logger.h" #include "utils/helpers.h" +#include "utils/logger.h" +#include "utils/timer_task_impl.h" #include "transport_manager/transport_adapter/transport_adapter_impl.h" #include "transport_manager/transport_adapter/transport_adapter_listener.h" @@ -209,24 +210,46 @@ TransportAdapter::Error TransportAdapterImpl::Connect( } connections_lock_.AcquireForWriting(); + + std::pair connection_key; const bool already_exists = - connections_.end() != - connections_.find(std::make_pair(device_id, app_handle)); + connections_.end() != connections_.find(connection_key); + ConnectionInfo& info = connections_[connection_key]; if (!already_exists) { - ConnectionInfo& info = connections_[std::make_pair(device_id, app_handle)]; info.app_handle = app_handle; info.device_id = device_id; info.state = ConnectionInfo::NEW; } + const bool pending_app = ConnectionInfo::PENDING == info.state || + ConnectionInfo::RETRY == info.state; connections_lock_.Release(); - if (already_exists) { + if (already_exists && !pending_app) { LOG4CXX_TRACE(logger_, "exit with ALREADY_EXISTS"); return ALREADY_EXISTS; } const TransportAdapter::Error err = server_connection_factory_->CreateConnection(device_id, app_handle); - if (TransportAdapter::OK != err) { + if (pending_app && TransportAdapter::FAIL == err) { + connections_lock_.AcquireForWriting(); + if (ConnectionInfo::PENDING == info.state) { + info.state = ConnectionInfo::RETRY; + info.retry_count = 0; + } + if (info.retry_count++ > get_settings().cloud_app_max_retry_attempts()) { + info.state = ConnectionInfo::PENDING; + info.retry_count = 0; + return err; + } + TimerSPtr retry_timer(std::make_shared( + "RetryConnectionTimer", + new timer::TimerTaskImpl( + this, &TransportAdapterImpl::RetryConnection))); + retry_timer_pool_.push(std::make_pair(retry_timer, connection_key)); + retry_timer->Start(get_settings().cloud_app_retry_timeout(), + timer::kSingleShot); + connections_lock_.Release(); + } else if (TransportAdapter::OK != err) { connections_lock_.AcquireForWriting(); connections_.erase(std::make_pair(device_id, app_handle)); connections_lock_.Release(); @@ -235,6 +258,19 @@ TransportAdapter::Error TransportAdapterImpl::Connect( return err; } +void TransportAdapterImpl::RetryConnection() { + if (retry_timer_pool_.empty()) { + LOG4CXX_ERROR(logger_, + "Unable to find timer, ignoring RetryConnection request"); + return; + } + auto connection_key = retry_timer_pool_.front().second; + retry_timer_pool_.pop(); + const DeviceUID device_id = connection_key.first; + const ApplicationHandle app_handle = connection_key.second; + Connect(device_id, app_handle); +} + TransportAdapter::Error TransportAdapterImpl::ConnectDevice( const DeviceUID& device_handle) { LOG4CXX_TRACE(logger_, "enter with device_handle: " << &device_handle); -- cgit v1.2.1 From 00a81813d4de6e20bda021d4c19d7054f27d875c Mon Sep 17 00:00:00 2001 From: JackLivio Date: Wed, 14 Nov 2018 16:27:05 -0500 Subject: Set Application Parameters --- .../src/application_manager_impl.cc | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/components/application_manager/src/application_manager_impl.cc b/src/components/application_manager/src/application_manager_impl.cc index 192468023d..c5daf4bdc0 100644 --- a/src/components/application_manager/src/application_manager_impl.cc +++ b/src/components/application_manager/src/application_manager_impl.cc @@ -817,6 +817,12 @@ void ApplicationManagerImpl::CreatePendingApplication( LOG4CXX_AUTO_TRACE(logger_); std::string policy_app_id = ""; + std::string endpoint = ""; + std::string certificate = ""; + std::string auth_token = ""; + std::string cloud_transport_type = ""; + std::string hybrid_app_preference = ""; + std::string name = device_info.name(); auto it = pending_device_map_.find(name); if (it == pending_device_map_.end()) { @@ -824,6 +830,7 @@ void ApplicationManagerImpl::CreatePendingApplication( } policy_app_id = it->second; + ApplicationSharedPtr application(new ApplicationImpl( 0, policy_app_id, @@ -839,7 +846,19 @@ void ApplicationManagerImpl::CreatePendingApplication( return; } + GetPolicyHandler().GetCloudAppParameters(*it, + endpoint, + certificate, + auth_token, + cloud_transport_type, + hybrid_app_preference); + application->set_hmi_application_id(GenerateNewHMIAppID()); + application->set_cloud_app_endpoint(endpoint); + application->set_cloud_app_auth_token(auth_token); + application->set_cloud_app_transport_type(cloud_transport_type); + application->set_hybrid_app_preference(hybrid_app_preference); + application->set_cloud_app_certificate(certificate); sync_primitives::AutoLock lock(apps_to_register_list_lock_ptr_); LOG4CXX_DEBUG(logger_, -- cgit v1.2.1 From 1411b1b98c37ca6d483425562b01d9f40a20d52b Mon Sep 17 00:00:00 2001 From: jacobkeeler Date: Thu, 15 Nov 2018 14:17:30 -0500 Subject: Fix issues with ActivateApp flow --- .../application_manager/application_manager_impl.h | 3 -- .../src/commands/hmi/sdl_activate_app_request.cc | 14 ++++--- .../mobile/register_app_interface_request.cc | 19 +--------- .../src/application_manager_impl.cc | 44 ++++++++++++++++++++-- 4 files changed, 50 insertions(+), 30 deletions(-) diff --git a/src/components/application_manager/include/application_manager/application_manager_impl.h b/src/components/application_manager/include/application_manager/application_manager_impl.h index 20b8c561a3..8fb7f1c227 100644 --- a/src/components/application_manager/include/application_manager/application_manager_impl.h +++ b/src/components/application_manager/include/application_manager/application_manager_impl.h @@ -492,9 +492,6 @@ class ApplicationManagerImpl // typedef for Applications list const iterator typedef ApplictionSet::const_iterator ApplictionSetConstIt; - DataAccessor apps_waiting_for_registration() const; - ApplicationConstSharedPtr waiting_app(const uint32_t hmi_id) const; - /** * @brief Notification from PolicyHandler about PTU. * Compares AppHMIType between saved in app and received from PTU. If they are diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/sdl_activate_app_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/sdl_activate_app_request.cc index c81c53d5a9..bfe7adec11 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/sdl_activate_app_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/sdl_activate_app_request.cc @@ -115,6 +115,8 @@ void SDLActivateAppRequest::Run() { LOG4CXX_AUTO_TRACE(logger_); using namespace hmi_apis::FunctionID; + ApplicationConstSharedPtr app = + application_manager_.WaitingApplicationByID(app_id()); if (application_manager_.state_controller().IsStateActive( HmiState::STATE_ID_DEACTIVATE_HMI)) { LOG4CXX_DEBUG(logger_, @@ -124,11 +126,10 @@ void SDLActivateAppRequest::Run() { static_cast(function_id()), hmi_apis::Common_Result::REJECTED, "HMIDeactivate is active"); - } else if (!app_to_activate->IsRegistered() && - app_to_activate->is_cloud_app()) { + } else if (app && !app->IsRegistered() && app->is_cloud_app()) { LOG4CXX_DEBUG(logger_, "Starting cloud application."); - application_manager_.connection_handler().ConnectToDevice( - app_to_activate->device()); + subscribe_on_event(BasicCommunication_OnAppRegistered); + application_manager_.connection_handler().ConnectToDevice(app->device()); } else { const uint32_t application_id = app_id(); policy_handler_.OnActivateApp(application_id, correlation_id()); @@ -144,7 +145,7 @@ void SDLActivateAppRequest::Run() { const uint32_t application_id = app_id(); ApplicationConstSharedPtr app_to_activate = - application_manager_.application(application_id); + application_manager_.application_by_hmi_app(application_id); if (!app_to_activate) { LOG4CXX_WARN( @@ -188,6 +189,7 @@ void SDLActivateAppRequest::Run() { return; } else if (app_to_activate->is_cloud_app()) { LOG4CXX_DEBUG(logger_, "Starting cloud application."); + subscribe_on_event(BasicCommunication_OnAppRegistered); application_manager_.connection_handler().ConnectToDevice( app_to_activate->device()); return; @@ -272,7 +274,7 @@ uint32_t SDLActivateAppRequest::hmi_app_id( LOG4CXX_DEBUG(logger_, application << " section is absent in the message."); return 0; } - if (so[msg_params][application].keyExists(strings::app_id)) { + if (!so[msg_params][application].keyExists(strings::app_id)) { LOG4CXX_DEBUG(logger_, strings::app_id << " section is absent in the message."); return 0; 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 58ee598e02..8f06e8c51a 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 @@ -346,19 +346,6 @@ void RegisterAppInterfaceRequest::Run() { application->set_msg_version(module_version); } - // For resuming application need to restore hmi_app_id from resumeCtrl - resumption::ResumeCtrl& resumer = application_manager_.resume_controller(); - const std::string& device_mac = application->mac_address(); - - // there is side affect with 2 mobile app with the same mobile app_id - if (resumer.IsApplicationSaved(policy_app_id, device_mac)) { - application->set_hmi_application_id( - resumer.GetHMIApplicationID(policy_app_id, device_mac)); - } else { - application->set_hmi_application_id( - application_manager_.GenerateNewHMIAppID()); - } - application->set_is_media_application( msg_params[strings::is_media_application].asBool()); @@ -451,6 +438,8 @@ void RegisterAppInterfaceRequest::Run() { FillDeviceInfo(&device_info); } + const std::string& device_mac = application->mac_address(); + GetPolicyHandler().SetDeviceInfo(device_mac, device_info); SendRegisterAppInterfaceResponseToMobile(ApplicationType::kNewApplication); @@ -842,10 +831,6 @@ void RegisterAppInterfaceRequest::SendRegisterAppInterfaceResponseToMobile( // By default app subscribed to CUSTOM_BUTTON SendSubscribeCustomButtonNotification(); SendChangeRegistrationOnHMI(application); - - if (application->is_cloud_app()) { - policy_handler_.OnActivateApp(connection_key(), correlation_id()); - } } void RegisterAppInterfaceRequest::SendChangeRegistration( diff --git a/src/components/application_manager/src/application_manager_impl.cc b/src/components/application_manager/src/application_manager_impl.cc index 192468023d..d48e850fa6 100644 --- a/src/components/application_manager/src/application_manager_impl.cc +++ b/src/components/application_manager/src/application_manager_impl.cc @@ -541,6 +541,7 @@ ApplicationSharedPtr ApplicationManagerImpl::RegisterApplication( app_name, GetPolicyHandler().GetStatisticManager(), *this)); + if (!application) { std::shared_ptr response( MessageHelper::CreateNegativeResponse( @@ -610,10 +611,45 @@ ApplicationSharedPtr ApplicationManagerImpl::RegisterApplication( // Keep HMI add id in case app is present in "waiting for registration" list apps_to_register_list_lock_ptr_->Acquire(); - AppsWaitRegistrationSet::iterator it = apps_to_register_.find(application); - if (apps_to_register_.end() != it) { + PolicyAppIdPredicate finder(application->policy_app_id()); + ApplicationSet::iterator it = + std::find_if(apps_to_register_.begin(), apps_to_register_.end(), finder); + + if (apps_to_register_.end() == it) { + DevicePredicate finder(application->device()); + it = std::find_if( + apps_to_register_.begin(), apps_to_register_.end(), finder); + + bool found = apps_to_register_.end() != it; + bool is_mismatched_cloud_app = found && (*it)->is_cloud_app() && + policy_app_id != (*it)->policy_app_id(); + + // Reject registration request if a cloud app registers with the incorrect + // appID + if (is_mismatched_cloud_app) { + std::shared_ptr response( + MessageHelper::CreateNegativeResponse( + connection_key, + mobile_apis::FunctionID::RegisterAppInterfaceID, + message[strings::params][strings::correlation_id].asUInt(), + mobile_apis::Result::DISALLOWED)); + (*response)[strings::msg_params][strings::info] = + "Cloud app registered with incorrect app id"; + rpc_service_->ManageMobileCommand(response, + commands::Command::SOURCE_SDL); + return ApplicationSharedPtr(); + } + } else { application->set_hmi_application_id((*it)->hmi_app_id()); - apps_to_register_.erase(application); + + // Set cloud app parameters + application->set_cloud_app_endpoint((*it)->cloud_app_endpoint()); + application->set_cloud_app_certificate((*it)->cloud_app_certificate()); + application->set_cloud_app_auth_token((*it)->cloud_app_authtoken()); + application->set_cloud_app_transport_type( + (*it)->cloud_app_transport_type()); + application->set_hybrid_app_preference((*it)->hybrid_app_preference()); + apps_to_register_.erase(it); } apps_to_register_list_lock_ptr_->Release(); @@ -835,7 +871,7 @@ void ApplicationManagerImpl::CreatePendingApplication( *this)); if (!application) { - LOG4CXX_INFO(logger_, "Could not streate application"); + LOG4CXX_INFO(logger_, "Could not create application"); return; } -- cgit v1.2.1 From 5f3cf62d06049b9ee64a75d205581914c4c90929 Mon Sep 17 00:00:00 2001 From: jacobkeeler Date: Thu, 15 Nov 2018 15:54:08 -0500 Subject: Address review comments --- .../application_manager/policies/policy_handler.h | 21 +++++++------- .../src/policies/policy_handler.cc | 33 +++++++++++++--------- .../policies/policy_handler_interface.h | 9 +++--- .../policy/policy_external/policy/policy_manager.h | 9 +++--- .../policy/policy_regular/policy/policy_manager.h | 9 +++--- .../policies/mock_policy_handler_interface.h | 15 +++++----- .../policy_external/policy/mock_cache_manager.h | 15 +++++----- .../policy_external/policy/mock_policy_manager.h | 15 +++++----- .../policy_regular/policy/mock_cache_manager.h | 15 +++++----- .../policy_regular/policy/mock_policy_manager.h | 15 +++++----- .../policy_external/include/policy/cache_manager.h | 20 ++++++------- .../include/policy/cache_manager_interface.h | 9 +++--- .../include/policy/policy_manager_impl.h | 20 ++++++------- .../policy/policy_external/src/cache_manager.cc | 12 ++++---- .../policy_external/src/policy_manager_impl.cc | 16 ++++++----- .../policy_regular/include/policy/cache_manager.h | 20 ++++++------- .../include/policy/cache_manager_interface.h | 9 +++--- .../include/policy/policy_manager_impl.h | 20 ++++++------- .../policy/policy_regular/src/cache_manager.cc | 6 ++-- .../policy_regular/src/policy_manager_impl.cc | 16 ++++++----- 20 files changed, 161 insertions(+), 143 deletions(-) diff --git a/src/components/application_manager/include/application_manager/policies/policy_handler.h b/src/components/application_manager/include/application_manager/policies/policy_handler.h index a612c263ca..8ee5ff64f6 100644 --- a/src/components/application_manager/include/application_manager/policies/policy_handler.h +++ b/src/components/application_manager/include/application_manager/policies/policy_handler.h @@ -419,26 +419,25 @@ class PolicyHandler : public PolicyHandlerInterface, * @brief Get cloud app policy information, all fields that aren't set for a * given app will be filled with empty strings * @param policy_app_id Unique application id + * @param enabled Whether or not the app is enabled * @param endpoint Filled with the endpoint used to connect to the cloud * application * @param certificate Filled with the certificate used to for creating a - * secure - * connection to the cloud application + * secure connection to the cloud application * @param auth_token Filled with the token used for authentication when * reconnecting to the cloud app * @param cloud_transport_type Filled with the transport type used by the * cloud application (ex. "WSS") - * @param cloud_transport_type Filled with the hybrid app preference for the + * @param hybrid_app_preference Filled with the hybrid app preference for the * cloud application set by the user - * @return true if the cloud app is enabled, false otherwise */ - const bool GetCloudAppParameters( - const std::string& policy_app_id, - std::string& endpoint, - std::string& certificate, - std::string& auth_token, - std::string& cloud_transport_type, - std::string& hybrid_app_preference) const OVERRIDE; + void GetCloudAppParameters(const std::string& policy_app_id, + bool& enabled, + std::string& endpoint, + std::string& certificate, + std::string& auth_token, + std::string& cloud_transport_type, + std::string& hybrid_app_preference) const OVERRIDE; /** * @brief Callback for when a SetCloudAppProperties message is received from a diff --git a/src/components/application_manager/src/policies/policy_handler.cc b/src/components/application_manager/src/policies/policy_handler.cc index cc62d9f6f8..505f29e13b 100644 --- a/src/components/application_manager/src/policies/policy_handler.cc +++ b/src/components/application_manager/src/policies/policy_handler.cc @@ -1851,36 +1851,41 @@ void PolicyHandler::GetEnabledCloudApps( policy_manager_->GetEnabledCloudApps(enabled_apps); } -const bool PolicyHandler::GetCloudAppParameters( +void PolicyHandler::GetCloudAppParameters( const std::string& policy_app_id, + bool& enabled, std::string& endpoint, std::string& certificate, std::string& auth_token, std::string& cloud_transport_type, std::string& hybrid_app_preference) const { - POLICY_LIB_CHECK(false); - return policy_manager_->GetCloudAppParameters(policy_app_id, - endpoint, - certificate, - auth_token, - cloud_transport_type, - hybrid_app_preference); + POLICY_LIB_CHECK_VOID(); + policy_manager_->GetCloudAppParameters(policy_app_id, + enabled, + endpoint, + certificate, + auth_token, + cloud_transport_type, + hybrid_app_preference); } const bool PolicyHandler::CheckCloudAppEnabled( const std::string& policy_app_id) const { POLICY_LIB_CHECK(false); + bool enabled = false; std::string endpoint; std::string auth_token; std::string certificate; std::string cloud_transport_type; std::string hybrid_app_preference; - return policy_manager_->GetCloudAppParameters(policy_app_id, - endpoint, - certificate, - auth_token, - cloud_transport_type, - hybrid_app_preference); + policy_manager_->GetCloudAppParameters(policy_app_id, + enabled, + endpoint, + certificate, + auth_token, + cloud_transport_type, + hybrid_app_preference); + return enabled; } void PolicyHandler::OnSetCloudAppProperties( diff --git a/src/components/include/application_manager/policies/policy_handler_interface.h b/src/components/include/application_manager/policies/policy_handler_interface.h index ddeb1da8f7..8c8a12ced3 100644 --- a/src/components/include/application_manager/policies/policy_handler_interface.h +++ b/src/components/include/application_manager/policies/policy_handler_interface.h @@ -459,7 +459,8 @@ class PolicyHandlerInterface { * @brief Get cloud app policy information, all fields that aren't set for a * given app will be filled with empty strings * @param policy_app_id Unique application id - * @param endpoint Filled the endpoint used to connect to the cloud + * @param enabled Whether or not the app is enabled + * @param endpoint Filled with the endpoint used to connect to the cloud * application * @param certificate Filled with the certificate used to for creating a * secure connection to the cloud application @@ -467,12 +468,12 @@ class PolicyHandlerInterface { * reconnecting to the cloud app * @param cloud_transport_type Filled with the transport type used by the * cloud application (ex. "WSS") - * @param cloud_transport_type Filled with the hybrid app preference for the + * @param hybrid_app_preference Filled with the hybrid app preference for the * cloud application set by the user - * @return true if the cloud app is enabled, false otherwise */ - virtual const bool GetCloudAppParameters( + virtual void GetCloudAppParameters( const std::string& policy_app_id, + bool& enabled, std::string& endpoint, std::string& certificate, std::string& auth_token, diff --git a/src/components/include/policy/policy_external/policy/policy_manager.h b/src/components/include/policy/policy_external/policy/policy_manager.h index b0fac8eae9..37c8a902f1 100644 --- a/src/components/include/policy/policy_external/policy/policy_manager.h +++ b/src/components/include/policy/policy_external/policy/policy_manager.h @@ -534,7 +534,8 @@ class PolicyManager : public usage_statistics::StatisticsManager { * @brief Get cloud app policy information, all fields that aren't set for a * given app will be filled with empty strings * @param policy_app_id Unique application id - * @param endpoint Filled the endpoint used to connect to the cloud + * @param enabled Whether or not the app is enabled + * @param endpoint Filled with the endpoint used to connect to the cloud * application * @param certificate Filled with the certificate used to for creating a * secure connection to the cloud application @@ -542,12 +543,12 @@ class PolicyManager : public usage_statistics::StatisticsManager { * reconnecting to the cloud app * @param cloud_transport_type Filled with the transport type used by the * cloud application (ex. "WSS") - * @param cloud_transport_type Filled with the hybrid app preference for the + * @param hybrid_app_preference Filled with the hybrid app preference for the * cloud application set by the user - * @return true if the cloud app is enabled, false otherwise */ - virtual const bool GetCloudAppParameters( + virtual void GetCloudAppParameters( const std::string& policy_app_id, + bool& enabled, std::string& endpoint, std::string& certificate, std::string& auth_token, diff --git a/src/components/include/policy/policy_regular/policy/policy_manager.h b/src/components/include/policy/policy_regular/policy/policy_manager.h index 1f0f520077..d22f52bfed 100644 --- a/src/components/include/policy/policy_regular/policy/policy_manager.h +++ b/src/components/include/policy/policy_regular/policy/policy_manager.h @@ -514,7 +514,8 @@ class PolicyManager : public usage_statistics::StatisticsManager { * @brief Get cloud app policy information, all fields that aren't set for a * given app will be filled with empty strings * @param policy_app_id Unique application id - * @param endpoint Filled the endpoint used to connect to the cloud + * @param enabled Whether or not the app is enabled + * @param endpoint Filled with the endpoint used to connect to the cloud * application * @param certificate Filled with the certificate used to for creating a * secure connection to the cloud application @@ -522,12 +523,12 @@ class PolicyManager : public usage_statistics::StatisticsManager { * reconnecting to the cloud app * @param cloud_transport_type Filled with the transport type used by the * cloud application (ex. "WSS") - * @param cloud_transport_type Filled with the hybrid app preference for the + * @param hybrid_app_preference Filled with the hybrid app preference for the * cloud application set by the user - * @return true if the cloud app is enabled, false otherwise */ - virtual const bool GetCloudAppParameters( + virtual void GetCloudAppParameters( const std::string& policy_app_id, + bool& enabled, std::string& endpoint, std::string& certificate, std::string& auth_token, diff --git a/src/components/include/test/application_manager/policies/mock_policy_handler_interface.h b/src/components/include/test/application_manager/policies/mock_policy_handler_interface.h index cea36082c8..02a0d73086 100644 --- a/src/components/include/test/application_manager/policies/mock_policy_handler_interface.h +++ b/src/components/include/test/application_manager/policies/mock_policy_handler_interface.h @@ -217,13 +217,14 @@ class MockPolicyHandlerInterface : public policy::PolicyHandlerInterface { void(std::vector& enabled_apps)); MOCK_CONST_METHOD1(CheckCloudAppEnabled, const bool(const std::string& policy_app_id)); - MOCK_CONST_METHOD6(GetCloudAppParameters, - const bool(const std::string& policy_app_id, - std::string& endpoint, - std::string& certificate, - std::string& auth_token, - std::string& cloud_transport_type, - std::string& hybrid_app_preference)); + MOCK_CONST_METHOD7(GetCloudAppParameters, + void(const std::string& policy_app_id, + bool& enabled, + std::string& endpoint, + std::string& certificate, + std::string& auth_token, + std::string& cloud_transport_type, + std::string& hybrid_app_preference)); MOCK_METHOD1(OnSetCloudAppProperties, void(const smart_objects::SmartObject& message)); diff --git a/src/components/include/test/policy/policy_external/policy/mock_cache_manager.h b/src/components/include/test/policy/policy_external/policy/mock_cache_manager.h index 03e0882129..db3f37fb91 100644 --- a/src/components/include/test/policy/policy_external/policy/mock_cache_manager.h +++ b/src/components/include/test/policy/policy_external/policy/mock_cache_manager.h @@ -78,13 +78,14 @@ class MockCacheManagerInterface : public ::policy::CacheManagerInterface { MOCK_CONST_METHOD0(GetVehicleInfo, const VehicleInfo()); MOCK_CONST_METHOD1(GetEnabledCloudApps, void(std::vector& enabled_apps)); - MOCK_CONST_METHOD6(GetCloudAppParameters, - const bool(const std::string& policy_app_id, - std::string& endpoint, - std::string& certificate, - std::string& auth_token, - std::string& cloud_transport_type, - std::string& hybrid_app_preference)); + MOCK_CONST_METHOD7(GetCloudAppParameters, + void(const std::string& policy_app_id, + bool& enabled, + std::string& endpoint, + std::string& certificate, + std::string& auth_token, + std::string& cloud_transport_type, + std::string& hybrid_app_preference)); MOCK_METHOD2(SetCloudAppEnabled, void(const std::string& policy_app_id, const bool enabled)); MOCK_METHOD2(SetAppAuthToken, diff --git a/src/components/include/test/policy/policy_external/policy/mock_policy_manager.h b/src/components/include/test/policy/policy_external/policy/mock_policy_manager.h index 70dab8e99a..1eabb78019 100644 --- a/src/components/include/test/policy/policy_external/policy/mock_policy_manager.h +++ b/src/components/include/test/policy/policy_external/policy/mock_policy_manager.h @@ -186,13 +186,14 @@ class MockPolicyManager : public PolicyManager { MOCK_CONST_METHOD0(GetVehicleInfo, const policy::VehicleInfo()); MOCK_CONST_METHOD1(GetEnabledCloudApps, void(std::vector& enabled_apps)); - MOCK_CONST_METHOD6(GetCloudAppParameters, - const bool(const std::string& policy_app_id, - std::string& endpoint, - std::string& certificate, - std::string& auth_token, - std::string& cloud_transport_type, - std::string& hybrid_app_preference)); + MOCK_CONST_METHOD7(GetCloudAppParameters, + void(const std::string& policy_app_id, + bool& enabled, + std::string& endpoint, + std::string& certificate, + std::string& auth_token, + std::string& cloud_transport_type, + std::string& hybrid_app_preference)); MOCK_METHOD2(SetCloudAppEnabled, void(const std::string& policy_app_id, const bool enabled)); MOCK_METHOD2(SetAppAuthToken, diff --git a/src/components/include/test/policy/policy_regular/policy/mock_cache_manager.h b/src/components/include/test/policy/policy_regular/policy/mock_cache_manager.h index 7ac94d278d..3d8dc4116a 100644 --- a/src/components/include/test/policy/policy_regular/policy/mock_cache_manager.h +++ b/src/components/include/test/policy/policy_regular/policy/mock_cache_manager.h @@ -65,13 +65,14 @@ class MockCacheManagerInterface : public CacheManagerInterface { MOCK_CONST_METHOD0(GetVehicleInfo, const VehicleInfo()); MOCK_CONST_METHOD1(GetEnabledCloudApps, void(std::vector& enabled_apps)); - MOCK_CONST_METHOD6(GetCloudAppParameters, - const bool(const std::string& policy_app_id, - std::string& endpoint, - std::string& certificate, - std::string& auth_token, - std::string& cloud_transport_type, - std::string& hybrid_app_preference)); + MOCK_CONST_METHOD7(GetCloudAppParameters, + void(const std::string& policy_app_id, + bool& enabled, + std::string& endpoint, + std::string& certificate, + std::string& auth_token, + std::string& cloud_transport_type, + std::string& hybrid_app_preference)); MOCK_METHOD2(SetCloudAppEnabled, void(const std::string& policy_app_id, const bool enabled)); MOCK_METHOD2(SetAppAuthToken, diff --git a/src/components/include/test/policy/policy_regular/policy/mock_policy_manager.h b/src/components/include/test/policy/policy_regular/policy/mock_policy_manager.h index 7441701a34..a28ea32108 100644 --- a/src/components/include/test/policy/policy_regular/policy/mock_policy_manager.h +++ b/src/components/include/test/policy/policy_regular/policy/mock_policy_manager.h @@ -183,13 +183,14 @@ class MockPolicyManager : public PolicyManager { MOCK_CONST_METHOD0(GetVehicleInfo, const policy::VehicleInfo()); MOCK_CONST_METHOD1(GetEnabledCloudApps, void(std::vector& enabled_apps)); - MOCK_CONST_METHOD6(GetCloudAppParameters, - const bool(const std::string& policy_app_id, - std::string& endpoint, - std::string& certificate, - std::string& auth_token, - std::string& cloud_transport_type, - std::string& hybrid_app_preference)); + MOCK_CONST_METHOD7(GetCloudAppParameters, + void(const std::string& policy_app_id, + bool& enabled, + std::string& endpoint, + std::string& certificate, + std::string& auth_token, + std::string& cloud_transport_type, + std::string& hybrid_app_preference)); MOCK_METHOD2(SetCloudAppEnabled, void(const std::string& policy_app_id, const bool enabled)); MOCK_METHOD2(SetAppAuthToken, diff --git a/src/components/policy/policy_external/include/policy/cache_manager.h b/src/components/policy/policy_external/include/policy/cache_manager.h index 7660eb2df9..98f279b345 100644 --- a/src/components/policy/policy_external/include/policy/cache_manager.h +++ b/src/components/policy/policy_external/include/policy/cache_manager.h @@ -170,7 +170,8 @@ class CacheManager : public CacheManagerInterface { * @brief Get cloud app policy information, all fields that aren't set for a * given app will be filled with empty strings * @param policy_app_id Unique application id - * @param endpoint Filled the endpoint used to connect to the cloud + * @param enabled Whether or not the app is enabled + * @param endpoint Filled with the endpoint used to connect to the cloud * application * @param certificate Filled with the certificate used to for creating a * secure connection to the cloud application @@ -178,17 +179,16 @@ class CacheManager : public CacheManagerInterface { * reconnecting to the cloud app * @param cloud_transport_type Filled with the transport type used by the * cloud application (ex. "WSS") - * @param cloud_transport_type Filled with the hybrid app preference for the + * @param hybrid_app_preference Filled with the hybrid app preference for the * cloud application set by the user - * @return true if the cloud app is enabled, false otherwise */ - virtual const bool GetCloudAppParameters( - const std::string& policy_app_id, - std::string& endpoint, - std::string& certificate, - std::string& auth_token, - std::string& cloud_transport_type, - std::string& hybrid_app_preference) const; + virtual void GetCloudAppParameters(const std::string& policy_app_id, + bool& enabled, + std::string& endpoint, + std::string& certificate, + std::string& auth_token, + std::string& cloud_transport_type, + std::string& hybrid_app_preference) const; /** * @brief Enable or disable a cloud application in the HMI diff --git a/src/components/policy/policy_external/include/policy/cache_manager_interface.h b/src/components/policy/policy_external/include/policy/cache_manager_interface.h index 79d6f4e731..2a334876ae 100644 --- a/src/components/policy/policy_external/include/policy/cache_manager_interface.h +++ b/src/components/policy/policy_external/include/policy/cache_manager_interface.h @@ -177,7 +177,8 @@ class CacheManagerInterface { * @brief Get cloud app policy information, all fields that aren't set for a * given app will be filled with empty strings * @param policy_app_id Unique application id - * @param endpoint Filled the endpoint used to connect to the cloud + * @param enabled Whether or not the app is enabled + * @param endpoint Filled with the endpoint used to connect to the cloud * application * @param certificate Filled with the certificate used to for creating a * secure connection to the cloud application @@ -185,12 +186,12 @@ class CacheManagerInterface { * reconnecting to the cloud app * @param cloud_transport_type Filled with the transport type used by the * cloud application (ex. "WSS") - * @param cloud_transport_type Filled with the hybrid app preference for the + * @param hybrid_app_preference Filled with the hybrid app preference for the * cloud application set by the user - * @return true if the cloud app is enabled, false otherwise */ - virtual const bool GetCloudAppParameters( + virtual void GetCloudAppParameters( const std::string& policy_app_id, + bool& enabled, std::string& endpoint, std::string& certificate, std::string& auth_token, diff --git a/src/components/policy/policy_external/include/policy/policy_manager_impl.h b/src/components/policy/policy_external/include/policy/policy_manager_impl.h index 778892df13..6d4cbbf773 100644 --- a/src/components/policy/policy_external/include/policy/policy_manager_impl.h +++ b/src/components/policy/policy_external/include/policy/policy_manager_impl.h @@ -582,7 +582,8 @@ class PolicyManagerImpl : public PolicyManager { * @brief Get cloud app policy information, all fields that aren't set for a * given app will be filled with empty strings * @param policy_app_id Unique application id - * @param endpoint Filled the endpoint used to connect to the cloud + * @param enabled Whether or not the app is enabled + * @param endpoint Filled with the endpoint used to connect to the cloud * application * @param certificate Filled with the certificate used to for creating a * secure connection to the cloud application @@ -590,17 +591,16 @@ class PolicyManagerImpl : public PolicyManager { * reconnecting to the cloud app * @param cloud_transport_type Filled with the transport type used by the * cloud application (ex. "WSS") - * @param cloud_transport_type Filled with the hybrid app preference for the + * @param hybrid_app_preference Filled with the hybrid app preference for the * cloud application set by the user - * @return true if the cloud app is enabled, false otherwise */ - const bool GetCloudAppParameters( - const std::string& policy_app_id, - std::string& endpoint, - std::string& certificate, - std::string& auth_token, - std::string& cloud_transport_type, - std::string& hybrid_app_preference) const OVERRIDE; + void GetCloudAppParameters(const std::string& policy_app_id, + bool& enabled, + std::string& endpoint, + std::string& certificate, + std::string& auth_token, + std::string& cloud_transport_type, + std::string& hybrid_app_preference) const OVERRIDE; /** * @brief Enable or disable a cloud application in the HMI diff --git a/src/components/policy/policy_external/src/cache_manager.cc b/src/components/policy/policy_external/src/cache_manager.cc index 116b315755..dc0838d429 100644 --- a/src/components/policy/policy_external/src/cache_manager.cc +++ b/src/components/policy/policy_external/src/cache_manager.cc @@ -1403,8 +1403,9 @@ void CacheManager::GetEnabledCloudApps( } } -const bool CacheManager::GetCloudAppParameters( +void CacheManager::GetCloudAppParameters( const std::string& policy_app_id, + bool& enabled, std::string& endpoint, std::string& certificate, std::string& auth_token, @@ -1418,21 +1419,20 @@ const bool CacheManager::GetCloudAppParameters( auto app_policy = (*policy_iter).second; endpoint = app_policy.endpoint.is_initialized() ? *app_policy.endpoint : std::string(); - certificate = app_policy.certificate.is_initialized() - ? *app_policy.certificate - : std::string(); auth_token = app_policy.auth_token.is_initialized() ? *app_policy.auth_token : std::string(); cloud_transport_type = app_policy.cloud_transport_type.is_initialized() ? *app_policy.cloud_transport_type : std::string(); + certificate = app_policy.certificate.is_initialized() + ? *app_policy.certificate + : std::string(); hybrid_app_preference = app_policy.hybrid_app_preference.is_initialized() ? EnumToJsonString(*app_policy.hybrid_app_preference) : std::string(); - return app_policy.enabled.is_initialized() && *app_policy.enabled; + enabled = app_policy.enabled.is_initialized() && *app_policy.enabled; } - return false; } void CacheManager::SetCloudAppEnabled(const std::string& policy_app_id, diff --git a/src/components/policy/policy_external/src/policy_manager_impl.cc b/src/components/policy/policy_external/src/policy_manager_impl.cc index 31cc212254..df474268ba 100644 --- a/src/components/policy/policy_external/src/policy_manager_impl.cc +++ b/src/components/policy/policy_external/src/policy_manager_impl.cc @@ -730,19 +730,21 @@ void PolicyManagerImpl::GetEnabledCloudApps( cache_->GetEnabledCloudApps(enabled_apps); } -const bool PolicyManagerImpl::GetCloudAppParameters( +void PolicyManagerImpl::GetCloudAppParameters( const std::string& policy_app_id, + bool& enabled, std::string& endpoint, std::string& certificate, std::string& auth_token, std::string& cloud_transport_type, std::string& hybrid_app_preference) const { - return cache_->GetCloudAppParameters(policy_app_id, - endpoint, - certificate, - auth_token, - cloud_transport_type, - hybrid_app_preference); + cache_->GetCloudAppParameters(policy_app_id, + enabled, + endpoint, + certificate, + auth_token, + cloud_transport_type, + hybrid_app_preference); } void PolicyManagerImpl::SetCloudAppEnabled(const std::string& policy_app_id, diff --git a/src/components/policy/policy_regular/include/policy/cache_manager.h b/src/components/policy/policy_regular/include/policy/cache_manager.h index 39f9cc73cd..a4ae45d604 100644 --- a/src/components/policy/policy_regular/include/policy/cache_manager.h +++ b/src/components/policy/policy_regular/include/policy/cache_manager.h @@ -158,7 +158,8 @@ class CacheManager : public CacheManagerInterface { * @brief Get cloud app policy information, all fields that aren't set for a * given app will be filled with empty strings * @param policy_app_id Unique application id - * @param endpoint Filled the endpoint used to connect to the cloud + * @param enabled Whether or not the app is enabled + * @param endpoint Filled with the endpoint used to connect to the cloud * application * @param certificate Filled with the certificate used to for creating a * secure connection to the cloud application @@ -166,17 +167,16 @@ class CacheManager : public CacheManagerInterface { * reconnecting to the cloud app * @param cloud_transport_type Filled with the transport type used by the * cloud application (ex. "WSS") - * @param cloud_transport_type Filled with the hybrid app preference for the + * @param hybrid_app_preference Filled with the hybrid app preference for the * cloud application set by the user - * @return true if the cloud app is enabled, false otherwise */ - virtual const bool GetCloudAppParameters( - const std::string& policy_app_id, - std::string& endpoint, - std::string& certificate, - std::string& auth_token, - std::string& cloud_transport_type, - std::string& hybrid_app_preference) const; + virtual void GetCloudAppParameters(const std::string& policy_app_id, + bool& enabled, + std::string& endpoint, + std::string& certificate, + std::string& auth_token, + std::string& cloud_transport_type, + std::string& hybrid_app_preference) const; /** * @brief Enable or disable a cloud application in the HMI diff --git a/src/components/policy/policy_regular/include/policy/cache_manager_interface.h b/src/components/policy/policy_regular/include/policy/cache_manager_interface.h index 3b2b10d0bc..f0ee9c2b25 100644 --- a/src/components/policy/policy_regular/include/policy/cache_manager_interface.h +++ b/src/components/policy/policy_regular/include/policy/cache_manager_interface.h @@ -163,7 +163,8 @@ class CacheManagerInterface { * @brief Get cloud app policy information, all fields that aren't set for a * given app will be filled with empty strings * @param policy_app_id Unique application id - * @param endpoint Filled the endpoint used to connect to the cloud + * @param enabled Whether or not the app is enabled + * @param endpoint Filled with the endpoint used to connect to the cloud * application * @param certificate Filled with the certificate used to for creating a * secure connection to the cloud application @@ -171,12 +172,12 @@ class CacheManagerInterface { * reconnecting to the cloud app * @param cloud_transport_type Filled with the transport type used by the * cloud application (ex. "WSS") - * @param cloud_transport_type Filled with the hybrid app preference for the + * @param hybrid_app_preference Filled with the hybrid app preference for the * cloud application set by the user - * @return true if the cloud app is enabled, false otherwise */ - virtual const bool GetCloudAppParameters( + virtual void GetCloudAppParameters( const std::string& policy_app_id, + bool& enabled, std::string& endpoint, std::string& certificate, std::string& auth_token, diff --git a/src/components/policy/policy_regular/include/policy/policy_manager_impl.h b/src/components/policy/policy_regular/include/policy/policy_manager_impl.h index 311ced31d2..0a0c260a96 100644 --- a/src/components/policy/policy_regular/include/policy/policy_manager_impl.h +++ b/src/components/policy/policy_regular/include/policy/policy_manager_impl.h @@ -576,7 +576,8 @@ class PolicyManagerImpl : public PolicyManager { * @brief Get cloud app policy information, all fields that aren't set for a * given app will be filled with empty strings * @param policy_app_id Unique application id - * @param endpoint Filled the endpoint used to connect to the cloud + * @param enabled Whether or not the app is enabled + * @param endpoint Filled with the endpoint used to connect to the cloud * application * @param certificate Filled with the certificate used to for creating a * secure connection to the cloud application @@ -584,17 +585,16 @@ class PolicyManagerImpl : public PolicyManager { * reconnecting to the cloud app * @param cloud_transport_type Filled with the transport type used by the * cloud application (ex. "WSS") - * @param cloud_transport_type Filled with the hybrid app preference for the + * @param hybrid_app_preference Filled with the hybrid app preference for the * cloud application set by the user - * @return true if the cloud app is enabled, false otherwise */ - const bool GetCloudAppParameters( - const std::string& policy_app_id, - std::string& endpoint, - std::string& certificate, - std::string& auth_token, - std::string& cloud_transport_type, - std::string& hybrid_app_preference) const OVERRIDE; + void GetCloudAppParameters(const std::string& policy_app_id, + bool& enabled, + std::string& endpoint, + std::string& certificate, + std::string& auth_token, + std::string& cloud_transport_type, + std::string& hybrid_app_preference) const OVERRIDE; /** * @brief Enable or disable a cloud application in the HMI diff --git a/src/components/policy/policy_regular/src/cache_manager.cc b/src/components/policy/policy_regular/src/cache_manager.cc index 9292c389b9..c4b3d8db53 100644 --- a/src/components/policy/policy_regular/src/cache_manager.cc +++ b/src/components/policy/policy_regular/src/cache_manager.cc @@ -696,8 +696,9 @@ void CacheManager::GetEnabledCloudApps( } } -const bool CacheManager::GetCloudAppParameters( +void CacheManager::GetCloudAppParameters( const std::string& policy_app_id, + bool& enabled, std::string& endpoint, std::string& certificate, std::string& auth_token, @@ -723,9 +724,8 @@ const bool CacheManager::GetCloudAppParameters( app_policy.hybrid_app_preference.is_initialized() ? EnumToJsonString(*app_policy.hybrid_app_preference) : std::string(); - return app_policy.enabled.is_initialized() && *app_policy.enabled; + enabled = app_policy.enabled.is_initialized() && *app_policy.enabled; } - return false; } void CacheManager::SetCloudAppEnabled(const std::string& policy_app_id, diff --git a/src/components/policy/policy_regular/src/policy_manager_impl.cc b/src/components/policy/policy_regular/src/policy_manager_impl.cc index 5aa29fc896..6e635b7f36 100644 --- a/src/components/policy/policy_regular/src/policy_manager_impl.cc +++ b/src/components/policy/policy_regular/src/policy_manager_impl.cc @@ -549,19 +549,21 @@ void PolicyManagerImpl::GetEnabledCloudApps( cache_->GetEnabledCloudApps(enabled_apps); } -const bool PolicyManagerImpl::GetCloudAppParameters( +void PolicyManagerImpl::GetCloudAppParameters( const std::string& policy_app_id, + bool& enabled, std::string& endpoint, std::string& certificate, std::string& auth_token, std::string& cloud_transport_type, std::string& hybrid_app_preference) const { - return cache_->GetCloudAppParameters(policy_app_id, - endpoint, - certificate, - auth_token, - cloud_transport_type, - hybrid_app_preference); + cache_->GetCloudAppParameters(policy_app_id, + enabled, + endpoint, + certificate, + auth_token, + cloud_transport_type, + hybrid_app_preference); } void PolicyManagerImpl::SetCloudAppEnabled(const std::string& policy_app_id, -- cgit v1.2.1 From a43cbaaafd43be09d2d301c8acc32b053794f108 Mon Sep 17 00:00:00 2001 From: ShobhitAd Date: Fri, 16 Nov 2018 12:54:22 -0500 Subject: Implemented InitCloudApp in policy_regular --- .../src/policies/policy_handler.cc | 3 +++ .../policy/policy_regular/policy/policy_manager.h | 7 +++++++ .../policy_regular/include/policy/cache_manager.h | 9 +++++++++ .../include/policy/cache_manager_interface.h | 8 ++++++++ .../include/policy/policy_manager_impl.h | 7 +++++++ .../policy/policy_regular/src/cache_manager.cc | 21 +++++++++++++++++++++ .../policy_regular/src/policy_manager_impl.cc | 4 ++++ 7 files changed, 59 insertions(+) diff --git a/src/components/application_manager/src/policies/policy_handler.cc b/src/components/application_manager/src/policies/policy_handler.cc index 505f29e13b..e7af4b972e 100644 --- a/src/components/application_manager/src/policies/policy_handler.cc +++ b/src/components/application_manager/src/policies/policy_handler.cc @@ -1905,6 +1905,9 @@ void PolicyHandler::OnSetCloudAppProperties( return; } std::string policy_app_id(msg_params[strings::app_id].asString()); + + policy_manager_->InitCloudApp(policy_app_id); + if (msg_params.keyExists(strings::enabled)) { policy_manager_->SetCloudAppEnabled(policy_app_id, msg_params[strings::enabled].asBool()); diff --git a/src/components/include/policy/policy_regular/policy/policy_manager.h b/src/components/include/policy/policy_regular/policy/policy_manager.h index d22f52bfed..b2d48585f4 100644 --- a/src/components/include/policy/policy_regular/policy/policy_manager.h +++ b/src/components/include/policy/policy_regular/policy/policy_manager.h @@ -535,6 +535,13 @@ class PolicyManager : public usage_statistics::StatisticsManager { std::string& cloud_transport_type, std::string& hybrid_app_preference) const = 0; + /** + * @ brief Initialize new cloud app in the policy table + * @ param policy_app_id Application ID + */ + + virtual void InitCloudApp(const std::string& policy_app_id) = 0; + /** * @brief Enable or disable a cloud application in the HMI * @param enabled Cloud app enabled state diff --git a/src/components/policy/policy_regular/include/policy/cache_manager.h b/src/components/policy/policy_regular/include/policy/cache_manager.h index a4ae45d604..0ce35b5beb 100644 --- a/src/components/policy/policy_regular/include/policy/cache_manager.h +++ b/src/components/policy/policy_regular/include/policy/cache_manager.h @@ -178,6 +178,15 @@ class CacheManager : public CacheManagerInterface { std::string& cloud_transport_type, std::string& hybrid_app_preference) const; + /** + * Initializes a new cloud application with default policies + * Then adds cloud specific policies + * @param app_id application id + * @return true if success + */ + virtual void InitCloudApp(const std::string& policy_app_id); + + /** * @brief Enable or disable a cloud application in the HMI * @param enabled Cloud app enabled state diff --git a/src/components/policy/policy_regular/include/policy/cache_manager_interface.h b/src/components/policy/policy_regular/include/policy/cache_manager_interface.h index f0ee9c2b25..bf0f17d83c 100644 --- a/src/components/policy/policy_regular/include/policy/cache_manager_interface.h +++ b/src/components/policy/policy_regular/include/policy/cache_manager_interface.h @@ -184,6 +184,14 @@ class CacheManagerInterface { std::string& cloud_transport_type, std::string& hybrid_app_preference) const = 0; + /** + * Initializes a new cloud application with default policies + * Then adds cloud specific policies + * @param app_id application id + * @return true if success + */ + virtual void InitCloudApp(const std::string& policy_app_id) = 0; + /** * @brief Enable or disable a cloud application in the HMI * @param enabled Cloud app enabled state diff --git a/src/components/policy/policy_regular/include/policy/policy_manager_impl.h b/src/components/policy/policy_regular/include/policy/policy_manager_impl.h index 0a0c260a96..20a37717a7 100644 --- a/src/components/policy/policy_regular/include/policy/policy_manager_impl.h +++ b/src/components/policy/policy_regular/include/policy/policy_manager_impl.h @@ -596,6 +596,13 @@ class PolicyManagerImpl : public PolicyManager { std::string& cloud_transport_type, std::string& hybrid_app_preference) const OVERRIDE; + /** + * @ brief Initialize new cloud app in the policy table + * @ param policy_app_id Application ID + */ + + void InitCloudApp(const std::string& policy_app_id) OVERRIDE; + /** * @brief Enable or disable a cloud application in the HMI * @param enabled Cloud app enabled state diff --git a/src/components/policy/policy_regular/src/cache_manager.cc b/src/components/policy/policy_regular/src/cache_manager.cc index c4b3d8db53..2c37279baa 100644 --- a/src/components/policy/policy_regular/src/cache_manager.cc +++ b/src/components/policy/policy_regular/src/cache_manager.cc @@ -728,6 +728,27 @@ void CacheManager::GetCloudAppParameters( } } +void CacheManager::InitCloudApp(const std::string& policy_app_id) { + CACHE_MANAGER_CHECK_VOID(); + sync_primitives::AutoLock auto_lock(cache_lock_); + + policy_table::ApplicationPolicies& policies = + pt_->policy_table.app_policies_section.apps; + policy_table::ApplicationPolicies::const_iterator default_iter = + policies.find(kDefaultId); + policy_table::ApplicationPolicies::const_iterator app_iter = + policies.find(policy_app_id); + + if (default_iter != policies.end()) { + if (app_iter == policies.end()){ + policies[policy_app_id] = policies[kDefaultId]; + } + } + //Add cloud app specific policies + + Backup(); +} + void CacheManager::SetCloudAppEnabled(const std::string& policy_app_id, const bool enabled) { policy_table::ApplicationPolicies& policies = diff --git a/src/components/policy/policy_regular/src/policy_manager_impl.cc b/src/components/policy/policy_regular/src/policy_manager_impl.cc index 6e635b7f36..e2adde4524 100644 --- a/src/components/policy/policy_regular/src/policy_manager_impl.cc +++ b/src/components/policy/policy_regular/src/policy_manager_impl.cc @@ -566,6 +566,10 @@ void PolicyManagerImpl::GetCloudAppParameters( hybrid_app_preference); } +void PolicyManagerImpl::InitCloudApp(const std::string& policy_app_id){ + cache_->InitCloudApp(policy_app_id); +} + void PolicyManagerImpl::SetCloudAppEnabled(const std::string& policy_app_id, const bool enabled) { cache_->SetCloudAppEnabled(policy_app_id, enabled); -- cgit v1.2.1 From fbfe1fc119aaecd5cf0a1c9dfd495089ae20dc49 Mon Sep 17 00:00:00 2001 From: JackLivio Date: Fri, 16 Nov 2018 13:09:47 -0500 Subject: Clean up application and app manager code --- .../include/application_manager/application.h | 45 +++++++++++++++++++--- .../include/application_manager/application_impl.h | 45 +++++++++++++++++++--- .../application_manager/src/application_impl.cc | 10 ++--- .../src/application_manager_impl.cc | 19 +++++++-- .../include/config_profile/profile.h | 4 +- src/components/config_profile/src/profile.cc | 2 +- .../transport_manager/transport_manager_settings.h | 2 +- 7 files changed, 104 insertions(+), 23 deletions(-) diff --git a/src/components/application_manager/include/application_manager/application.h b/src/components/application_manager/include/application_manager/application.h index ef11de90d2..b68fc083d7 100644 --- a/src/components/application_manager/include/application_manager/application.h +++ b/src/components/application_manager/include/application_manager/application.h @@ -946,26 +946,61 @@ class Application : public virtual InitialApplicationData, */ virtual const std::list& Extensions() const = 0; - virtual std::string cloud_app_endpoint() = 0; + /** + * @brief Get cloud app endpoint for websocket connection + * @return cloud app endpoint + */ + const virtual std::string cloud_app_endpoint() = 0; - virtual std::string cloud_app_authtoken() = 0; + /** + * @brief Get cloud app authtoken to be used in connection handshake after websocket open. + * @return cloud app authtoken + */ + const virtual std::string cloud_app_authtoken() = 0; - virtual std::string cloud_app_transport_type() = 0; + /** + * @brief Get cloud app tranpsport type. Defines the type of websocket connection used. + * @return cloud app transport type + */ + const virtual std::string cloud_app_transport_type() = 0; - virtual std::string hybrid_app_preference() = 0; + /** + * @brief Get hybrid app preference. Defines behaviour for when a similar mobile and cloud app are connected simultaneously. + * @return hybrid app preference + */ + const virtual std::string hybrid_app_preference() = 0; - virtual std::string cloud_app_certificate() = 0; + /** + * @brief Get cloud app certificate. Used for secured websocket connections. + * @return cloud app certificate. + */ + const virtual std::string cloud_app_certificate() = 0; + /** + * @brief Set cloud app endpoint + */ virtual void set_cloud_app_endpoint(const std::string& endpoint) = 0; + /** + * @brief Set cloud app auth token + */ virtual void set_cloud_app_auth_token(const std::string& auth_token) = 0; + /** + * @brief Set cloud app transport type + */ virtual void set_cloud_app_transport_type( const std::string& transport_type) = 0; + /** + * @brief Set hybrid app preference + */ virtual void set_hybrid_app_preference( const std::string& hybrid_app_preference) = 0; + /** + * @brief Set cloud app certificate + */ virtual void set_cloud_app_certificate(const std::string& certificate) = 0; protected: diff --git a/src/components/application_manager/include/application_manager/application_impl.h b/src/components/application_manager/include/application_manager/application_impl.h index 5a1a385d1e..74b2be0934 100644 --- a/src/components/application_manager/include/application_manager/application_impl.h +++ b/src/components/application_manager/include/application_manager/application_impl.h @@ -409,25 +409,60 @@ class ApplicationImpl : public virtual Application, void SwapMobileMessageQueue(MobileMessageQueue& mobile_messages) OVERRIDE; - std::string cloud_app_endpoint() OVERRIDE; + /** + * @brief Get cloud app endpoint for websocket connection + * @return cloud app endpoint + */ + const std::string cloud_app_endpoint() OVERRIDE; - std::string cloud_app_authtoken() OVERRIDE; + /** + * @brief Get cloud app authtoken to be used in connection handshake after websocket open. + * @return cloud app authtoken + */ + const std::string cloud_app_authtoken() OVERRIDE; - std::string cloud_app_transport_type() OVERRIDE; + /** + * @brief Get cloud app tranpsport type. Defines the type of websocket connection used. + * @return cloud app transport type + */ + const std::string cloud_app_transport_type() OVERRIDE; - std::string hybrid_app_preference() OVERRIDE; + /** + * @brief Get hybrid app preference. Defines behaviour for when a similar mobile and cloud app are connected simultaneously. + * @return hybrid app preference + */ + const std::string hybrid_app_preference() OVERRIDE; - std::string cloud_app_certificate() OVERRIDE; + /** + * @brief Get cloud app certificate. Used for secured websocket connections. + * @return cloud app certificate. + */ + const std::string cloud_app_certificate() OVERRIDE; + /** + * @brief Set cloud app endpoint + */ void set_cloud_app_endpoint(const std::string& endpoint) OVERRIDE; + /** + * @brief Set cloud app auth token + */ void set_cloud_app_auth_token(const std::string& auth_token) OVERRIDE; + /** + * @brief Set cloud app transport type + */ void set_cloud_app_transport_type(const std::string& transport_type) OVERRIDE; + /** + * @brief Set hybrid app preference + */ void set_hybrid_app_preference( const std::string& hybrid_app_preference) OVERRIDE; + /** + * @brief Set cloud app certificate + */ void set_cloud_app_certificate(const std::string& certificate) OVERRIDE; protected: diff --git a/src/components/application_manager/src/application_impl.cc b/src/components/application_manager/src/application_impl.cc index 027beb9313..c92823bf77 100644 --- a/src/components/application_manager/src/application_impl.cc +++ b/src/components/application_manager/src/application_impl.cc @@ -1163,23 +1163,23 @@ const std::list& ApplicationImpl::Extensions() const { return extensions_; } -std::string ApplicationImpl::cloud_app_endpoint() { +const std::string ApplicationImpl::cloud_app_endpoint() { return endpoint_; } -std::string ApplicationImpl::cloud_app_authtoken() { +const std::string ApplicationImpl::cloud_app_authtoken() { return auth_token_; } -std::string ApplicationImpl::cloud_app_transport_type() { +const std::string ApplicationImpl::cloud_app_transport_type() { return cloud_transport_type_; } -std::string ApplicationImpl::hybrid_app_preference() { +const std::string ApplicationImpl::hybrid_app_preference() { return hybrid_app_preference_; } -std::string ApplicationImpl::cloud_app_certificate() { +const std::string ApplicationImpl::cloud_app_certificate() { return certificate_; } diff --git a/src/components/application_manager/src/application_manager_impl.cc b/src/components/application_manager/src/application_manager_impl.cc index c5daf4bdc0..c55adf84cb 100644 --- a/src/components/application_manager/src/application_manager_impl.cc +++ b/src/components/application_manager/src/application_manager_impl.cc @@ -816,7 +816,6 @@ void ApplicationManagerImpl::CreatePendingApplication( connection_handler::DeviceHandle device_id) { LOG4CXX_AUTO_TRACE(logger_); - std::string policy_app_id = ""; std::string endpoint = ""; std::string certificate = ""; std::string auth_token = ""; @@ -829,7 +828,19 @@ void ApplicationManagerImpl::CreatePendingApplication( return; } - policy_app_id = it->second; + const std::string policy_app_id = it->second; + + policy::StringArray nicknames; + policy::StringArray app_hmi_types; + + GetPolicyHandler().GetInitialAppData(policy_app_id, &nicknames, &app_hmi_types); + + if (!nicknames.size()) { + LOG4CXX_ERROR(logger_, "Cloud App missing nickname"); + return; + } + + const std::string display_name = nicknames[0]; ApplicationSharedPtr application(new ApplicationImpl( 0, @@ -837,7 +848,7 @@ void ApplicationManagerImpl::CreatePendingApplication( device_info.mac_address(), device_id, custom_str::CustomString( - "CloudApp"), // todo replace this with policy nick name + display_name), GetPolicyHandler().GetStatisticManager(), *this)); @@ -846,7 +857,7 @@ void ApplicationManagerImpl::CreatePendingApplication( return; } - GetPolicyHandler().GetCloudAppParameters(*it, + GetPolicyHandler().GetCloudAppParameters(policy_app_id, endpoint, certificate, auth_token, diff --git a/src/components/config_profile/include/config_profile/profile.h b/src/components/config_profile/include/config_profile/profile.h index b332ed69f5..4846648b2b 100644 --- a/src/components/config_profile/include/config_profile/profile.h +++ b/src/components/config_profile/include/config_profile/profile.h @@ -416,7 +416,7 @@ class Profile : public protocol_handler::ProtocolHandlerSettings, /** * @brief Returns retry timeout for cloud app connections */ - uint16_t cloud_app_retry_timeout() const OVERRIDE; + uint32_t cloud_app_retry_timeout() const OVERRIDE; /** * @brief Returns maximum retry attempts for cloud app connections @@ -970,7 +970,7 @@ class Profile : public protocol_handler::ProtocolHandlerSettings, std::string system_files_path_; uint16_t transport_manager_tcp_adapter_port_; std::string transport_manager_tcp_adapter_network_interface_; - uint16_t cloud_app_retry_timeout_; + uint32_t cloud_app_retry_timeout_; uint16_t cloud_app_max_retry_attempts_; std::string tts_delimiter_; uint32_t audio_data_stopped_timeout_; diff --git a/src/components/config_profile/src/profile.cc b/src/components/config_profile/src/profile.cc index 5b4c2e5f93..c10f81a869 100644 --- a/src/components/config_profile/src/profile.cc +++ b/src/components/config_profile/src/profile.cc @@ -791,7 +791,7 @@ const std::string& Profile::transport_manager_tcp_adapter_network_interface() return transport_manager_tcp_adapter_network_interface_; } -uint16_t Profile::cloud_app_retry_timeout() const { +uint32_t Profile::cloud_app_retry_timeout() const { return cloud_app_retry_timeout_; } diff --git a/src/components/include/transport_manager/transport_manager_settings.h b/src/components/include/transport_manager/transport_manager_settings.h index 30a5a98ae9..cbc1516c29 100644 --- a/src/components/include/transport_manager/transport_manager_settings.h +++ b/src/components/include/transport_manager/transport_manager_settings.h @@ -73,7 +73,7 @@ class TransportManagerSettings : public TransportManagerMMESettings { /** * @brief Returns retry timeout for cloud app connections */ - virtual uint16_t cloud_app_retry_timeout() const = 0; + virtual uint32_t cloud_app_retry_timeout() const = 0; /** * @brief Returns maximum retry attempts for cloud app connections -- cgit v1.2.1 From 2360fbdd7d634214a4ea86864bf7acfed0bc646d Mon Sep 17 00:00:00 2001 From: jacobkeeler Date: Thu, 15 Nov 2018 15:54:08 -0500 Subject: Address review comments --- .../application_manager/policies/policy_handler.h | 21 +++++++------- .../src/policies/policy_handler.cc | 33 +++++++++++++--------- .../policies/policy_handler_interface.h | 9 +++--- .../policy/policy_external/policy/policy_manager.h | 9 +++--- .../policy/policy_regular/policy/policy_manager.h | 9 +++--- .../policies/mock_policy_handler_interface.h | 15 +++++----- .../policy_external/policy/mock_cache_manager.h | 15 +++++----- .../policy_external/policy/mock_policy_manager.h | 15 +++++----- .../policy_regular/policy/mock_cache_manager.h | 15 +++++----- .../policy_regular/policy/mock_policy_manager.h | 15 +++++----- .../policy_external/include/policy/cache_manager.h | 20 ++++++------- .../include/policy/cache_manager_interface.h | 9 +++--- .../include/policy/policy_manager_impl.h | 20 ++++++------- .../policy/policy_external/src/cache_manager.cc | 12 ++++---- .../policy_external/src/policy_manager_impl.cc | 16 ++++++----- .../policy_regular/include/policy/cache_manager.h | 20 ++++++------- .../include/policy/cache_manager_interface.h | 9 +++--- .../include/policy/policy_manager_impl.h | 20 ++++++------- .../policy/policy_regular/src/cache_manager.cc | 6 ++-- .../policy_regular/src/policy_manager_impl.cc | 16 ++++++----- 20 files changed, 161 insertions(+), 143 deletions(-) diff --git a/src/components/application_manager/include/application_manager/policies/policy_handler.h b/src/components/application_manager/include/application_manager/policies/policy_handler.h index a612c263ca..8ee5ff64f6 100644 --- a/src/components/application_manager/include/application_manager/policies/policy_handler.h +++ b/src/components/application_manager/include/application_manager/policies/policy_handler.h @@ -419,26 +419,25 @@ class PolicyHandler : public PolicyHandlerInterface, * @brief Get cloud app policy information, all fields that aren't set for a * given app will be filled with empty strings * @param policy_app_id Unique application id + * @param enabled Whether or not the app is enabled * @param endpoint Filled with the endpoint used to connect to the cloud * application * @param certificate Filled with the certificate used to for creating a - * secure - * connection to the cloud application + * secure connection to the cloud application * @param auth_token Filled with the token used for authentication when * reconnecting to the cloud app * @param cloud_transport_type Filled with the transport type used by the * cloud application (ex. "WSS") - * @param cloud_transport_type Filled with the hybrid app preference for the + * @param hybrid_app_preference Filled with the hybrid app preference for the * cloud application set by the user - * @return true if the cloud app is enabled, false otherwise */ - const bool GetCloudAppParameters( - const std::string& policy_app_id, - std::string& endpoint, - std::string& certificate, - std::string& auth_token, - std::string& cloud_transport_type, - std::string& hybrid_app_preference) const OVERRIDE; + void GetCloudAppParameters(const std::string& policy_app_id, + bool& enabled, + std::string& endpoint, + std::string& certificate, + std::string& auth_token, + std::string& cloud_transport_type, + std::string& hybrid_app_preference) const OVERRIDE; /** * @brief Callback for when a SetCloudAppProperties message is received from a diff --git a/src/components/application_manager/src/policies/policy_handler.cc b/src/components/application_manager/src/policies/policy_handler.cc index 8c6de5482c..8c026c8c75 100644 --- a/src/components/application_manager/src/policies/policy_handler.cc +++ b/src/components/application_manager/src/policies/policy_handler.cc @@ -1852,36 +1852,41 @@ void PolicyHandler::GetEnabledCloudApps( policy_manager_->GetEnabledCloudApps(enabled_apps); } -const bool PolicyHandler::GetCloudAppParameters( +void PolicyHandler::GetCloudAppParameters( const std::string& policy_app_id, + bool& enabled, std::string& endpoint, std::string& certificate, std::string& auth_token, std::string& cloud_transport_type, std::string& hybrid_app_preference) const { - POLICY_LIB_CHECK(false); - return policy_manager_->GetCloudAppParameters(policy_app_id, - endpoint, - certificate, - auth_token, - cloud_transport_type, - hybrid_app_preference); + POLICY_LIB_CHECK_VOID(); + policy_manager_->GetCloudAppParameters(policy_app_id, + enabled, + endpoint, + certificate, + auth_token, + cloud_transport_type, + hybrid_app_preference); } const bool PolicyHandler::CheckCloudAppEnabled( const std::string& policy_app_id) const { POLICY_LIB_CHECK(false); + bool enabled = false; std::string endpoint; std::string auth_token; std::string certificate; std::string cloud_transport_type; std::string hybrid_app_preference; - return policy_manager_->GetCloudAppParameters(policy_app_id, - endpoint, - certificate, - auth_token, - cloud_transport_type, - hybrid_app_preference); + policy_manager_->GetCloudAppParameters(policy_app_id, + enabled, + endpoint, + certificate, + auth_token, + cloud_transport_type, + hybrid_app_preference); + return enabled; } void PolicyHandler::OnSetCloudAppProperties( diff --git a/src/components/include/application_manager/policies/policy_handler_interface.h b/src/components/include/application_manager/policies/policy_handler_interface.h index ddeb1da8f7..8c8a12ced3 100644 --- a/src/components/include/application_manager/policies/policy_handler_interface.h +++ b/src/components/include/application_manager/policies/policy_handler_interface.h @@ -459,7 +459,8 @@ class PolicyHandlerInterface { * @brief Get cloud app policy information, all fields that aren't set for a * given app will be filled with empty strings * @param policy_app_id Unique application id - * @param endpoint Filled the endpoint used to connect to the cloud + * @param enabled Whether or not the app is enabled + * @param endpoint Filled with the endpoint used to connect to the cloud * application * @param certificate Filled with the certificate used to for creating a * secure connection to the cloud application @@ -467,12 +468,12 @@ class PolicyHandlerInterface { * reconnecting to the cloud app * @param cloud_transport_type Filled with the transport type used by the * cloud application (ex. "WSS") - * @param cloud_transport_type Filled with the hybrid app preference for the + * @param hybrid_app_preference Filled with the hybrid app preference for the * cloud application set by the user - * @return true if the cloud app is enabled, false otherwise */ - virtual const bool GetCloudAppParameters( + virtual void GetCloudAppParameters( const std::string& policy_app_id, + bool& enabled, std::string& endpoint, std::string& certificate, std::string& auth_token, diff --git a/src/components/include/policy/policy_external/policy/policy_manager.h b/src/components/include/policy/policy_external/policy/policy_manager.h index b0fac8eae9..37c8a902f1 100644 --- a/src/components/include/policy/policy_external/policy/policy_manager.h +++ b/src/components/include/policy/policy_external/policy/policy_manager.h @@ -534,7 +534,8 @@ class PolicyManager : public usage_statistics::StatisticsManager { * @brief Get cloud app policy information, all fields that aren't set for a * given app will be filled with empty strings * @param policy_app_id Unique application id - * @param endpoint Filled the endpoint used to connect to the cloud + * @param enabled Whether or not the app is enabled + * @param endpoint Filled with the endpoint used to connect to the cloud * application * @param certificate Filled with the certificate used to for creating a * secure connection to the cloud application @@ -542,12 +543,12 @@ class PolicyManager : public usage_statistics::StatisticsManager { * reconnecting to the cloud app * @param cloud_transport_type Filled with the transport type used by the * cloud application (ex. "WSS") - * @param cloud_transport_type Filled with the hybrid app preference for the + * @param hybrid_app_preference Filled with the hybrid app preference for the * cloud application set by the user - * @return true if the cloud app is enabled, false otherwise */ - virtual const bool GetCloudAppParameters( + virtual void GetCloudAppParameters( const std::string& policy_app_id, + bool& enabled, std::string& endpoint, std::string& certificate, std::string& auth_token, diff --git a/src/components/include/policy/policy_regular/policy/policy_manager.h b/src/components/include/policy/policy_regular/policy/policy_manager.h index 1f0f520077..d22f52bfed 100644 --- a/src/components/include/policy/policy_regular/policy/policy_manager.h +++ b/src/components/include/policy/policy_regular/policy/policy_manager.h @@ -514,7 +514,8 @@ class PolicyManager : public usage_statistics::StatisticsManager { * @brief Get cloud app policy information, all fields that aren't set for a * given app will be filled with empty strings * @param policy_app_id Unique application id - * @param endpoint Filled the endpoint used to connect to the cloud + * @param enabled Whether or not the app is enabled + * @param endpoint Filled with the endpoint used to connect to the cloud * application * @param certificate Filled with the certificate used to for creating a * secure connection to the cloud application @@ -522,12 +523,12 @@ class PolicyManager : public usage_statistics::StatisticsManager { * reconnecting to the cloud app * @param cloud_transport_type Filled with the transport type used by the * cloud application (ex. "WSS") - * @param cloud_transport_type Filled with the hybrid app preference for the + * @param hybrid_app_preference Filled with the hybrid app preference for the * cloud application set by the user - * @return true if the cloud app is enabled, false otherwise */ - virtual const bool GetCloudAppParameters( + virtual void GetCloudAppParameters( const std::string& policy_app_id, + bool& enabled, std::string& endpoint, std::string& certificate, std::string& auth_token, diff --git a/src/components/include/test/application_manager/policies/mock_policy_handler_interface.h b/src/components/include/test/application_manager/policies/mock_policy_handler_interface.h index cea36082c8..02a0d73086 100644 --- a/src/components/include/test/application_manager/policies/mock_policy_handler_interface.h +++ b/src/components/include/test/application_manager/policies/mock_policy_handler_interface.h @@ -217,13 +217,14 @@ class MockPolicyHandlerInterface : public policy::PolicyHandlerInterface { void(std::vector& enabled_apps)); MOCK_CONST_METHOD1(CheckCloudAppEnabled, const bool(const std::string& policy_app_id)); - MOCK_CONST_METHOD6(GetCloudAppParameters, - const bool(const std::string& policy_app_id, - std::string& endpoint, - std::string& certificate, - std::string& auth_token, - std::string& cloud_transport_type, - std::string& hybrid_app_preference)); + MOCK_CONST_METHOD7(GetCloudAppParameters, + void(const std::string& policy_app_id, + bool& enabled, + std::string& endpoint, + std::string& certificate, + std::string& auth_token, + std::string& cloud_transport_type, + std::string& hybrid_app_preference)); MOCK_METHOD1(OnSetCloudAppProperties, void(const smart_objects::SmartObject& message)); diff --git a/src/components/include/test/policy/policy_external/policy/mock_cache_manager.h b/src/components/include/test/policy/policy_external/policy/mock_cache_manager.h index 03e0882129..db3f37fb91 100644 --- a/src/components/include/test/policy/policy_external/policy/mock_cache_manager.h +++ b/src/components/include/test/policy/policy_external/policy/mock_cache_manager.h @@ -78,13 +78,14 @@ class MockCacheManagerInterface : public ::policy::CacheManagerInterface { MOCK_CONST_METHOD0(GetVehicleInfo, const VehicleInfo()); MOCK_CONST_METHOD1(GetEnabledCloudApps, void(std::vector& enabled_apps)); - MOCK_CONST_METHOD6(GetCloudAppParameters, - const bool(const std::string& policy_app_id, - std::string& endpoint, - std::string& certificate, - std::string& auth_token, - std::string& cloud_transport_type, - std::string& hybrid_app_preference)); + MOCK_CONST_METHOD7(GetCloudAppParameters, + void(const std::string& policy_app_id, + bool& enabled, + std::string& endpoint, + std::string& certificate, + std::string& auth_token, + std::string& cloud_transport_type, + std::string& hybrid_app_preference)); MOCK_METHOD2(SetCloudAppEnabled, void(const std::string& policy_app_id, const bool enabled)); MOCK_METHOD2(SetAppAuthToken, diff --git a/src/components/include/test/policy/policy_external/policy/mock_policy_manager.h b/src/components/include/test/policy/policy_external/policy/mock_policy_manager.h index 70dab8e99a..1eabb78019 100644 --- a/src/components/include/test/policy/policy_external/policy/mock_policy_manager.h +++ b/src/components/include/test/policy/policy_external/policy/mock_policy_manager.h @@ -186,13 +186,14 @@ class MockPolicyManager : public PolicyManager { MOCK_CONST_METHOD0(GetVehicleInfo, const policy::VehicleInfo()); MOCK_CONST_METHOD1(GetEnabledCloudApps, void(std::vector& enabled_apps)); - MOCK_CONST_METHOD6(GetCloudAppParameters, - const bool(const std::string& policy_app_id, - std::string& endpoint, - std::string& certificate, - std::string& auth_token, - std::string& cloud_transport_type, - std::string& hybrid_app_preference)); + MOCK_CONST_METHOD7(GetCloudAppParameters, + void(const std::string& policy_app_id, + bool& enabled, + std::string& endpoint, + std::string& certificate, + std::string& auth_token, + std::string& cloud_transport_type, + std::string& hybrid_app_preference)); MOCK_METHOD2(SetCloudAppEnabled, void(const std::string& policy_app_id, const bool enabled)); MOCK_METHOD2(SetAppAuthToken, diff --git a/src/components/include/test/policy/policy_regular/policy/mock_cache_manager.h b/src/components/include/test/policy/policy_regular/policy/mock_cache_manager.h index 7ac94d278d..3d8dc4116a 100644 --- a/src/components/include/test/policy/policy_regular/policy/mock_cache_manager.h +++ b/src/components/include/test/policy/policy_regular/policy/mock_cache_manager.h @@ -65,13 +65,14 @@ class MockCacheManagerInterface : public CacheManagerInterface { MOCK_CONST_METHOD0(GetVehicleInfo, const VehicleInfo()); MOCK_CONST_METHOD1(GetEnabledCloudApps, void(std::vector& enabled_apps)); - MOCK_CONST_METHOD6(GetCloudAppParameters, - const bool(const std::string& policy_app_id, - std::string& endpoint, - std::string& certificate, - std::string& auth_token, - std::string& cloud_transport_type, - std::string& hybrid_app_preference)); + MOCK_CONST_METHOD7(GetCloudAppParameters, + void(const std::string& policy_app_id, + bool& enabled, + std::string& endpoint, + std::string& certificate, + std::string& auth_token, + std::string& cloud_transport_type, + std::string& hybrid_app_preference)); MOCK_METHOD2(SetCloudAppEnabled, void(const std::string& policy_app_id, const bool enabled)); MOCK_METHOD2(SetAppAuthToken, diff --git a/src/components/include/test/policy/policy_regular/policy/mock_policy_manager.h b/src/components/include/test/policy/policy_regular/policy/mock_policy_manager.h index 7441701a34..a28ea32108 100644 --- a/src/components/include/test/policy/policy_regular/policy/mock_policy_manager.h +++ b/src/components/include/test/policy/policy_regular/policy/mock_policy_manager.h @@ -183,13 +183,14 @@ class MockPolicyManager : public PolicyManager { MOCK_CONST_METHOD0(GetVehicleInfo, const policy::VehicleInfo()); MOCK_CONST_METHOD1(GetEnabledCloudApps, void(std::vector& enabled_apps)); - MOCK_CONST_METHOD6(GetCloudAppParameters, - const bool(const std::string& policy_app_id, - std::string& endpoint, - std::string& certificate, - std::string& auth_token, - std::string& cloud_transport_type, - std::string& hybrid_app_preference)); + MOCK_CONST_METHOD7(GetCloudAppParameters, + void(const std::string& policy_app_id, + bool& enabled, + std::string& endpoint, + std::string& certificate, + std::string& auth_token, + std::string& cloud_transport_type, + std::string& hybrid_app_preference)); MOCK_METHOD2(SetCloudAppEnabled, void(const std::string& policy_app_id, const bool enabled)); MOCK_METHOD2(SetAppAuthToken, diff --git a/src/components/policy/policy_external/include/policy/cache_manager.h b/src/components/policy/policy_external/include/policy/cache_manager.h index 7660eb2df9..98f279b345 100644 --- a/src/components/policy/policy_external/include/policy/cache_manager.h +++ b/src/components/policy/policy_external/include/policy/cache_manager.h @@ -170,7 +170,8 @@ class CacheManager : public CacheManagerInterface { * @brief Get cloud app policy information, all fields that aren't set for a * given app will be filled with empty strings * @param policy_app_id Unique application id - * @param endpoint Filled the endpoint used to connect to the cloud + * @param enabled Whether or not the app is enabled + * @param endpoint Filled with the endpoint used to connect to the cloud * application * @param certificate Filled with the certificate used to for creating a * secure connection to the cloud application @@ -178,17 +179,16 @@ class CacheManager : public CacheManagerInterface { * reconnecting to the cloud app * @param cloud_transport_type Filled with the transport type used by the * cloud application (ex. "WSS") - * @param cloud_transport_type Filled with the hybrid app preference for the + * @param hybrid_app_preference Filled with the hybrid app preference for the * cloud application set by the user - * @return true if the cloud app is enabled, false otherwise */ - virtual const bool GetCloudAppParameters( - const std::string& policy_app_id, - std::string& endpoint, - std::string& certificate, - std::string& auth_token, - std::string& cloud_transport_type, - std::string& hybrid_app_preference) const; + virtual void GetCloudAppParameters(const std::string& policy_app_id, + bool& enabled, + std::string& endpoint, + std::string& certificate, + std::string& auth_token, + std::string& cloud_transport_type, + std::string& hybrid_app_preference) const; /** * @brief Enable or disable a cloud application in the HMI diff --git a/src/components/policy/policy_external/include/policy/cache_manager_interface.h b/src/components/policy/policy_external/include/policy/cache_manager_interface.h index 79d6f4e731..2a334876ae 100644 --- a/src/components/policy/policy_external/include/policy/cache_manager_interface.h +++ b/src/components/policy/policy_external/include/policy/cache_manager_interface.h @@ -177,7 +177,8 @@ class CacheManagerInterface { * @brief Get cloud app policy information, all fields that aren't set for a * given app will be filled with empty strings * @param policy_app_id Unique application id - * @param endpoint Filled the endpoint used to connect to the cloud + * @param enabled Whether or not the app is enabled + * @param endpoint Filled with the endpoint used to connect to the cloud * application * @param certificate Filled with the certificate used to for creating a * secure connection to the cloud application @@ -185,12 +186,12 @@ class CacheManagerInterface { * reconnecting to the cloud app * @param cloud_transport_type Filled with the transport type used by the * cloud application (ex. "WSS") - * @param cloud_transport_type Filled with the hybrid app preference for the + * @param hybrid_app_preference Filled with the hybrid app preference for the * cloud application set by the user - * @return true if the cloud app is enabled, false otherwise */ - virtual const bool GetCloudAppParameters( + virtual void GetCloudAppParameters( const std::string& policy_app_id, + bool& enabled, std::string& endpoint, std::string& certificate, std::string& auth_token, diff --git a/src/components/policy/policy_external/include/policy/policy_manager_impl.h b/src/components/policy/policy_external/include/policy/policy_manager_impl.h index 778892df13..6d4cbbf773 100644 --- a/src/components/policy/policy_external/include/policy/policy_manager_impl.h +++ b/src/components/policy/policy_external/include/policy/policy_manager_impl.h @@ -582,7 +582,8 @@ class PolicyManagerImpl : public PolicyManager { * @brief Get cloud app policy information, all fields that aren't set for a * given app will be filled with empty strings * @param policy_app_id Unique application id - * @param endpoint Filled the endpoint used to connect to the cloud + * @param enabled Whether or not the app is enabled + * @param endpoint Filled with the endpoint used to connect to the cloud * application * @param certificate Filled with the certificate used to for creating a * secure connection to the cloud application @@ -590,17 +591,16 @@ class PolicyManagerImpl : public PolicyManager { * reconnecting to the cloud app * @param cloud_transport_type Filled with the transport type used by the * cloud application (ex. "WSS") - * @param cloud_transport_type Filled with the hybrid app preference for the + * @param hybrid_app_preference Filled with the hybrid app preference for the * cloud application set by the user - * @return true if the cloud app is enabled, false otherwise */ - const bool GetCloudAppParameters( - const std::string& policy_app_id, - std::string& endpoint, - std::string& certificate, - std::string& auth_token, - std::string& cloud_transport_type, - std::string& hybrid_app_preference) const OVERRIDE; + void GetCloudAppParameters(const std::string& policy_app_id, + bool& enabled, + std::string& endpoint, + std::string& certificate, + std::string& auth_token, + std::string& cloud_transport_type, + std::string& hybrid_app_preference) const OVERRIDE; /** * @brief Enable or disable a cloud application in the HMI diff --git a/src/components/policy/policy_external/src/cache_manager.cc b/src/components/policy/policy_external/src/cache_manager.cc index 116b315755..dc0838d429 100644 --- a/src/components/policy/policy_external/src/cache_manager.cc +++ b/src/components/policy/policy_external/src/cache_manager.cc @@ -1403,8 +1403,9 @@ void CacheManager::GetEnabledCloudApps( } } -const bool CacheManager::GetCloudAppParameters( +void CacheManager::GetCloudAppParameters( const std::string& policy_app_id, + bool& enabled, std::string& endpoint, std::string& certificate, std::string& auth_token, @@ -1418,21 +1419,20 @@ const bool CacheManager::GetCloudAppParameters( auto app_policy = (*policy_iter).second; endpoint = app_policy.endpoint.is_initialized() ? *app_policy.endpoint : std::string(); - certificate = app_policy.certificate.is_initialized() - ? *app_policy.certificate - : std::string(); auth_token = app_policy.auth_token.is_initialized() ? *app_policy.auth_token : std::string(); cloud_transport_type = app_policy.cloud_transport_type.is_initialized() ? *app_policy.cloud_transport_type : std::string(); + certificate = app_policy.certificate.is_initialized() + ? *app_policy.certificate + : std::string(); hybrid_app_preference = app_policy.hybrid_app_preference.is_initialized() ? EnumToJsonString(*app_policy.hybrid_app_preference) : std::string(); - return app_policy.enabled.is_initialized() && *app_policy.enabled; + enabled = app_policy.enabled.is_initialized() && *app_policy.enabled; } - return false; } void CacheManager::SetCloudAppEnabled(const std::string& policy_app_id, diff --git a/src/components/policy/policy_external/src/policy_manager_impl.cc b/src/components/policy/policy_external/src/policy_manager_impl.cc index 31cc212254..df474268ba 100644 --- a/src/components/policy/policy_external/src/policy_manager_impl.cc +++ b/src/components/policy/policy_external/src/policy_manager_impl.cc @@ -730,19 +730,21 @@ void PolicyManagerImpl::GetEnabledCloudApps( cache_->GetEnabledCloudApps(enabled_apps); } -const bool PolicyManagerImpl::GetCloudAppParameters( +void PolicyManagerImpl::GetCloudAppParameters( const std::string& policy_app_id, + bool& enabled, std::string& endpoint, std::string& certificate, std::string& auth_token, std::string& cloud_transport_type, std::string& hybrid_app_preference) const { - return cache_->GetCloudAppParameters(policy_app_id, - endpoint, - certificate, - auth_token, - cloud_transport_type, - hybrid_app_preference); + cache_->GetCloudAppParameters(policy_app_id, + enabled, + endpoint, + certificate, + auth_token, + cloud_transport_type, + hybrid_app_preference); } void PolicyManagerImpl::SetCloudAppEnabled(const std::string& policy_app_id, diff --git a/src/components/policy/policy_regular/include/policy/cache_manager.h b/src/components/policy/policy_regular/include/policy/cache_manager.h index 39f9cc73cd..a4ae45d604 100644 --- a/src/components/policy/policy_regular/include/policy/cache_manager.h +++ b/src/components/policy/policy_regular/include/policy/cache_manager.h @@ -158,7 +158,8 @@ class CacheManager : public CacheManagerInterface { * @brief Get cloud app policy information, all fields that aren't set for a * given app will be filled with empty strings * @param policy_app_id Unique application id - * @param endpoint Filled the endpoint used to connect to the cloud + * @param enabled Whether or not the app is enabled + * @param endpoint Filled with the endpoint used to connect to the cloud * application * @param certificate Filled with the certificate used to for creating a * secure connection to the cloud application @@ -166,17 +167,16 @@ class CacheManager : public CacheManagerInterface { * reconnecting to the cloud app * @param cloud_transport_type Filled with the transport type used by the * cloud application (ex. "WSS") - * @param cloud_transport_type Filled with the hybrid app preference for the + * @param hybrid_app_preference Filled with the hybrid app preference for the * cloud application set by the user - * @return true if the cloud app is enabled, false otherwise */ - virtual const bool GetCloudAppParameters( - const std::string& policy_app_id, - std::string& endpoint, - std::string& certificate, - std::string& auth_token, - std::string& cloud_transport_type, - std::string& hybrid_app_preference) const; + virtual void GetCloudAppParameters(const std::string& policy_app_id, + bool& enabled, + std::string& endpoint, + std::string& certificate, + std::string& auth_token, + std::string& cloud_transport_type, + std::string& hybrid_app_preference) const; /** * @brief Enable or disable a cloud application in the HMI diff --git a/src/components/policy/policy_regular/include/policy/cache_manager_interface.h b/src/components/policy/policy_regular/include/policy/cache_manager_interface.h index 3b2b10d0bc..f0ee9c2b25 100644 --- a/src/components/policy/policy_regular/include/policy/cache_manager_interface.h +++ b/src/components/policy/policy_regular/include/policy/cache_manager_interface.h @@ -163,7 +163,8 @@ class CacheManagerInterface { * @brief Get cloud app policy information, all fields that aren't set for a * given app will be filled with empty strings * @param policy_app_id Unique application id - * @param endpoint Filled the endpoint used to connect to the cloud + * @param enabled Whether or not the app is enabled + * @param endpoint Filled with the endpoint used to connect to the cloud * application * @param certificate Filled with the certificate used to for creating a * secure connection to the cloud application @@ -171,12 +172,12 @@ class CacheManagerInterface { * reconnecting to the cloud app * @param cloud_transport_type Filled with the transport type used by the * cloud application (ex. "WSS") - * @param cloud_transport_type Filled with the hybrid app preference for the + * @param hybrid_app_preference Filled with the hybrid app preference for the * cloud application set by the user - * @return true if the cloud app is enabled, false otherwise */ - virtual const bool GetCloudAppParameters( + virtual void GetCloudAppParameters( const std::string& policy_app_id, + bool& enabled, std::string& endpoint, std::string& certificate, std::string& auth_token, diff --git a/src/components/policy/policy_regular/include/policy/policy_manager_impl.h b/src/components/policy/policy_regular/include/policy/policy_manager_impl.h index 311ced31d2..0a0c260a96 100644 --- a/src/components/policy/policy_regular/include/policy/policy_manager_impl.h +++ b/src/components/policy/policy_regular/include/policy/policy_manager_impl.h @@ -576,7 +576,8 @@ class PolicyManagerImpl : public PolicyManager { * @brief Get cloud app policy information, all fields that aren't set for a * given app will be filled with empty strings * @param policy_app_id Unique application id - * @param endpoint Filled the endpoint used to connect to the cloud + * @param enabled Whether or not the app is enabled + * @param endpoint Filled with the endpoint used to connect to the cloud * application * @param certificate Filled with the certificate used to for creating a * secure connection to the cloud application @@ -584,17 +585,16 @@ class PolicyManagerImpl : public PolicyManager { * reconnecting to the cloud app * @param cloud_transport_type Filled with the transport type used by the * cloud application (ex. "WSS") - * @param cloud_transport_type Filled with the hybrid app preference for the + * @param hybrid_app_preference Filled with the hybrid app preference for the * cloud application set by the user - * @return true if the cloud app is enabled, false otherwise */ - const bool GetCloudAppParameters( - const std::string& policy_app_id, - std::string& endpoint, - std::string& certificate, - std::string& auth_token, - std::string& cloud_transport_type, - std::string& hybrid_app_preference) const OVERRIDE; + void GetCloudAppParameters(const std::string& policy_app_id, + bool& enabled, + std::string& endpoint, + std::string& certificate, + std::string& auth_token, + std::string& cloud_transport_type, + std::string& hybrid_app_preference) const OVERRIDE; /** * @brief Enable or disable a cloud application in the HMI diff --git a/src/components/policy/policy_regular/src/cache_manager.cc b/src/components/policy/policy_regular/src/cache_manager.cc index 9292c389b9..c4b3d8db53 100644 --- a/src/components/policy/policy_regular/src/cache_manager.cc +++ b/src/components/policy/policy_regular/src/cache_manager.cc @@ -696,8 +696,9 @@ void CacheManager::GetEnabledCloudApps( } } -const bool CacheManager::GetCloudAppParameters( +void CacheManager::GetCloudAppParameters( const std::string& policy_app_id, + bool& enabled, std::string& endpoint, std::string& certificate, std::string& auth_token, @@ -723,9 +724,8 @@ const bool CacheManager::GetCloudAppParameters( app_policy.hybrid_app_preference.is_initialized() ? EnumToJsonString(*app_policy.hybrid_app_preference) : std::string(); - return app_policy.enabled.is_initialized() && *app_policy.enabled; + enabled = app_policy.enabled.is_initialized() && *app_policy.enabled; } - return false; } void CacheManager::SetCloudAppEnabled(const std::string& policy_app_id, diff --git a/src/components/policy/policy_regular/src/policy_manager_impl.cc b/src/components/policy/policy_regular/src/policy_manager_impl.cc index 5aa29fc896..6e635b7f36 100644 --- a/src/components/policy/policy_regular/src/policy_manager_impl.cc +++ b/src/components/policy/policy_regular/src/policy_manager_impl.cc @@ -549,19 +549,21 @@ void PolicyManagerImpl::GetEnabledCloudApps( cache_->GetEnabledCloudApps(enabled_apps); } -const bool PolicyManagerImpl::GetCloudAppParameters( +void PolicyManagerImpl::GetCloudAppParameters( const std::string& policy_app_id, + bool& enabled, std::string& endpoint, std::string& certificate, std::string& auth_token, std::string& cloud_transport_type, std::string& hybrid_app_preference) const { - return cache_->GetCloudAppParameters(policy_app_id, - endpoint, - certificate, - auth_token, - cloud_transport_type, - hybrid_app_preference); + cache_->GetCloudAppParameters(policy_app_id, + enabled, + endpoint, + certificate, + auth_token, + cloud_transport_type, + hybrid_app_preference); } void PolicyManagerImpl::SetCloudAppEnabled(const std::string& policy_app_id, -- cgit v1.2.1 From bb46d3110e06067466a25dcc9973e79909552996 Mon Sep 17 00:00:00 2001 From: ShobhitAd Date: Fri, 16 Nov 2018 12:54:22 -0500 Subject: Implemented InitCloudApp in policy_regular --- .../src/policies/policy_handler.cc | 3 +++ .../policy/policy_regular/policy/policy_manager.h | 7 +++++++ .../policy_regular/include/policy/cache_manager.h | 9 +++++++++ .../include/policy/cache_manager_interface.h | 8 ++++++++ .../include/policy/policy_manager_impl.h | 7 +++++++ .../policy/policy_regular/src/cache_manager.cc | 21 +++++++++++++++++++++ .../policy_regular/src/policy_manager_impl.cc | 4 ++++ 7 files changed, 59 insertions(+) diff --git a/src/components/application_manager/src/policies/policy_handler.cc b/src/components/application_manager/src/policies/policy_handler.cc index 8c026c8c75..c603659353 100644 --- a/src/components/application_manager/src/policies/policy_handler.cc +++ b/src/components/application_manager/src/policies/policy_handler.cc @@ -1906,6 +1906,9 @@ void PolicyHandler::OnSetCloudAppProperties( return; } std::string policy_app_id(msg_params[strings::app_id].asString()); + + policy_manager_->InitCloudApp(policy_app_id); + if (msg_params.keyExists(strings::enabled)) { policy_manager_->SetCloudAppEnabled(policy_app_id, msg_params[strings::enabled].asBool()); diff --git a/src/components/include/policy/policy_regular/policy/policy_manager.h b/src/components/include/policy/policy_regular/policy/policy_manager.h index d22f52bfed..b2d48585f4 100644 --- a/src/components/include/policy/policy_regular/policy/policy_manager.h +++ b/src/components/include/policy/policy_regular/policy/policy_manager.h @@ -535,6 +535,13 @@ class PolicyManager : public usage_statistics::StatisticsManager { std::string& cloud_transport_type, std::string& hybrid_app_preference) const = 0; + /** + * @ brief Initialize new cloud app in the policy table + * @ param policy_app_id Application ID + */ + + virtual void InitCloudApp(const std::string& policy_app_id) = 0; + /** * @brief Enable or disable a cloud application in the HMI * @param enabled Cloud app enabled state diff --git a/src/components/policy/policy_regular/include/policy/cache_manager.h b/src/components/policy/policy_regular/include/policy/cache_manager.h index a4ae45d604..0ce35b5beb 100644 --- a/src/components/policy/policy_regular/include/policy/cache_manager.h +++ b/src/components/policy/policy_regular/include/policy/cache_manager.h @@ -178,6 +178,15 @@ class CacheManager : public CacheManagerInterface { std::string& cloud_transport_type, std::string& hybrid_app_preference) const; + /** + * Initializes a new cloud application with default policies + * Then adds cloud specific policies + * @param app_id application id + * @return true if success + */ + virtual void InitCloudApp(const std::string& policy_app_id); + + /** * @brief Enable or disable a cloud application in the HMI * @param enabled Cloud app enabled state diff --git a/src/components/policy/policy_regular/include/policy/cache_manager_interface.h b/src/components/policy/policy_regular/include/policy/cache_manager_interface.h index f0ee9c2b25..bf0f17d83c 100644 --- a/src/components/policy/policy_regular/include/policy/cache_manager_interface.h +++ b/src/components/policy/policy_regular/include/policy/cache_manager_interface.h @@ -184,6 +184,14 @@ class CacheManagerInterface { std::string& cloud_transport_type, std::string& hybrid_app_preference) const = 0; + /** + * Initializes a new cloud application with default policies + * Then adds cloud specific policies + * @param app_id application id + * @return true if success + */ + virtual void InitCloudApp(const std::string& policy_app_id) = 0; + /** * @brief Enable or disable a cloud application in the HMI * @param enabled Cloud app enabled state diff --git a/src/components/policy/policy_regular/include/policy/policy_manager_impl.h b/src/components/policy/policy_regular/include/policy/policy_manager_impl.h index 0a0c260a96..20a37717a7 100644 --- a/src/components/policy/policy_regular/include/policy/policy_manager_impl.h +++ b/src/components/policy/policy_regular/include/policy/policy_manager_impl.h @@ -596,6 +596,13 @@ class PolicyManagerImpl : public PolicyManager { std::string& cloud_transport_type, std::string& hybrid_app_preference) const OVERRIDE; + /** + * @ brief Initialize new cloud app in the policy table + * @ param policy_app_id Application ID + */ + + void InitCloudApp(const std::string& policy_app_id) OVERRIDE; + /** * @brief Enable or disable a cloud application in the HMI * @param enabled Cloud app enabled state diff --git a/src/components/policy/policy_regular/src/cache_manager.cc b/src/components/policy/policy_regular/src/cache_manager.cc index c4b3d8db53..2c37279baa 100644 --- a/src/components/policy/policy_regular/src/cache_manager.cc +++ b/src/components/policy/policy_regular/src/cache_manager.cc @@ -728,6 +728,27 @@ void CacheManager::GetCloudAppParameters( } } +void CacheManager::InitCloudApp(const std::string& policy_app_id) { + CACHE_MANAGER_CHECK_VOID(); + sync_primitives::AutoLock auto_lock(cache_lock_); + + policy_table::ApplicationPolicies& policies = + pt_->policy_table.app_policies_section.apps; + policy_table::ApplicationPolicies::const_iterator default_iter = + policies.find(kDefaultId); + policy_table::ApplicationPolicies::const_iterator app_iter = + policies.find(policy_app_id); + + if (default_iter != policies.end()) { + if (app_iter == policies.end()){ + policies[policy_app_id] = policies[kDefaultId]; + } + } + //Add cloud app specific policies + + Backup(); +} + void CacheManager::SetCloudAppEnabled(const std::string& policy_app_id, const bool enabled) { policy_table::ApplicationPolicies& policies = diff --git a/src/components/policy/policy_regular/src/policy_manager_impl.cc b/src/components/policy/policy_regular/src/policy_manager_impl.cc index 6e635b7f36..e2adde4524 100644 --- a/src/components/policy/policy_regular/src/policy_manager_impl.cc +++ b/src/components/policy/policy_regular/src/policy_manager_impl.cc @@ -566,6 +566,10 @@ void PolicyManagerImpl::GetCloudAppParameters( hybrid_app_preference); } +void PolicyManagerImpl::InitCloudApp(const std::string& policy_app_id){ + cache_->InitCloudApp(policy_app_id); +} + void PolicyManagerImpl::SetCloudAppEnabled(const std::string& policy_app_id, const bool enabled) { cache_->SetCloudAppEnabled(policy_app_id, enabled); -- cgit v1.2.1 From 23f7544cedbe2d5b6fa8a07d823c1c89338b8753 Mon Sep 17 00:00:00 2001 From: JackLivio Date: Fri, 16 Nov 2018 13:56:17 -0500 Subject: Address comments --- .../include/application_manager/application.h | 14 ++++--- .../include/application_manager/application_impl.h | 20 +++++---- .../application_manager/src/application_impl.cc | 5 ++- .../src/application_manager_impl.cc | 47 ++++++++++++++-------- 4 files changed, 54 insertions(+), 32 deletions(-) diff --git a/src/components/application_manager/include/application_manager/application.h b/src/components/application_manager/include/application_manager/application.h index b68fc083d7..4ddf1e1388 100644 --- a/src/components/application_manager/include/application_manager/application.h +++ b/src/components/application_manager/include/application_manager/application.h @@ -953,22 +953,26 @@ class Application : public virtual InitialApplicationData, const virtual std::string cloud_app_endpoint() = 0; /** - * @brief Get cloud app authtoken to be used in connection handshake after websocket open. + * @brief Get cloud app authtoken to be used in connection handshake after + * websocket open. * @return cloud app authtoken */ const virtual std::string cloud_app_authtoken() = 0; /** - * @brief Get cloud app tranpsport type. Defines the type of websocket connection used. + * @brief Get cloud app tranpsport type. Defines the type of websocket + * connection used. * @return cloud app transport type */ const virtual std::string cloud_app_transport_type() = 0; /** - * @brief Get hybrid app preference. Defines behaviour for when a similar mobile and cloud app are connected simultaneously. + * @brief Get hybrid app preference. Defines behaviour for when a similar + * mobile and cloud app are connected simultaneously. * @return hybrid app preference */ - const virtual std::string hybrid_app_preference() = 0; + const virtual mobile_apis::HybridAppPreference::eType + hybrid_app_preference() = 0; /** * @brief Get cloud app certificate. Used for secured websocket connections. @@ -996,7 +1000,7 @@ class Application : public virtual InitialApplicationData, * @brief Set hybrid app preference */ virtual void set_hybrid_app_preference( - const std::string& hybrid_app_preference) = 0; + const mobile_apis::HybridAppPreference::eType& hybrid_app_preference) = 0; /** * @brief Set cloud app certificate diff --git a/src/components/application_manager/include/application_manager/application_impl.h b/src/components/application_manager/include/application_manager/application_impl.h index 74b2be0934..26d8cd6159 100644 --- a/src/components/application_manager/include/application_manager/application_impl.h +++ b/src/components/application_manager/include/application_manager/application_impl.h @@ -416,27 +416,31 @@ class ApplicationImpl : public virtual Application, const std::string cloud_app_endpoint() OVERRIDE; /** - * @brief Get cloud app authtoken to be used in connection handshake after websocket open. + * @brief Get cloud app authtoken to be used in connection handshake after + * websocket open. * @return cloud app authtoken */ const std::string cloud_app_authtoken() OVERRIDE; /** - * @brief Get cloud app tranpsport type. Defines the type of websocket connection used. + * @brief Get cloud app tranpsport type. Defines the type of websocket + * connection used. * @return cloud app transport type */ const std::string cloud_app_transport_type() OVERRIDE; /** - * @brief Get hybrid app preference. Defines behaviour for when a similar mobile and cloud app are connected simultaneously. + * @brief Get hybrid app preference. Defines behaviour for when a similar + * mobile and cloud app are connected simultaneously. * @return hybrid app preference */ - const std::string hybrid_app_preference() OVERRIDE; + const mobile_apis::HybridAppPreference::eType hybrid_app_preference() + OVERRIDE; /** * @brief Get cloud app certificate. Used for secured websocket connections. * @return cloud app certificate. - */ + */ const std::string cloud_app_certificate() OVERRIDE; /** @@ -457,8 +461,8 @@ class ApplicationImpl : public virtual Application, /** * @brief Set hybrid app preference */ - void set_hybrid_app_preference( - const std::string& hybrid_app_preference) OVERRIDE; + void set_hybrid_app_preference(const mobile_apis::HybridAppPreference::eType& + hybrid_app_preference) OVERRIDE; /** * @brief Set cloud app certificate @@ -573,7 +577,7 @@ class ApplicationImpl : public virtual Application, std::string endpoint_; std::string auth_token_; std::string cloud_transport_type_; - std::string hybrid_app_preference_; + mobile_apis::HybridAppPreference::eType hybrid_app_preference_; std::string certificate_; /** diff --git a/src/components/application_manager/src/application_impl.cc b/src/components/application_manager/src/application_impl.cc index c92823bf77..31df4e821b 100644 --- a/src/components/application_manager/src/application_impl.cc +++ b/src/components/application_manager/src/application_impl.cc @@ -1175,7 +1175,8 @@ const std::string ApplicationImpl::cloud_app_transport_type() { return cloud_transport_type_; } -const std::string ApplicationImpl::hybrid_app_preference() { +const mobile_apis::HybridAppPreference::eType +ApplicationImpl::hybrid_app_preference() { return hybrid_app_preference_; } @@ -1197,7 +1198,7 @@ void ApplicationImpl::set_cloud_app_transport_type( } void ApplicationImpl::set_hybrid_app_preference( - const std::string& hybrid_app_preference) { + const mobile_apis::HybridAppPreference::eType& hybrid_app_preference) { hybrid_app_preference_ = hybrid_app_preference; } diff --git a/src/components/application_manager/src/application_manager_impl.cc b/src/components/application_manager/src/application_manager_impl.cc index c55adf84cb..1cec8b5ca2 100644 --- a/src/components/application_manager/src/application_manager_impl.cc +++ b/src/components/application_manager/src/application_manager_impl.cc @@ -820,7 +820,7 @@ void ApplicationManagerImpl::CreatePendingApplication( std::string certificate = ""; std::string auth_token = ""; std::string cloud_transport_type = ""; - std::string hybrid_app_preference = ""; + std::string hybrid_app_preference_str = ""; std::string name = device_info.name(); auto it = pending_device_map_.find(name); @@ -833,7 +833,8 @@ void ApplicationManagerImpl::CreatePendingApplication( policy::StringArray nicknames; policy::StringArray app_hmi_types; - GetPolicyHandler().GetInitialAppData(policy_app_id, &nicknames, &app_hmi_types); + GetPolicyHandler().GetInitialAppData( + policy_app_id, &nicknames, &app_hmi_types); if (!nicknames.size()) { LOG4CXX_ERROR(logger_, "Cloud App missing nickname"); @@ -842,15 +843,14 @@ void ApplicationManagerImpl::CreatePendingApplication( const std::string display_name = nicknames[0]; - ApplicationSharedPtr application(new ApplicationImpl( - 0, - policy_app_id, - device_info.mac_address(), - device_id, - custom_str::CustomString( - display_name), - GetPolicyHandler().GetStatisticManager(), - *this)); + ApplicationSharedPtr application( + new ApplicationImpl(0, + policy_app_id, + device_info.mac_address(), + device_id, + custom_str::CustomString(display_name), + GetPolicyHandler().GetStatisticManager(), + *this)); if (!application) { LOG4CXX_INFO(logger_, "Could not streate application"); @@ -858,17 +858,30 @@ void ApplicationManagerImpl::CreatePendingApplication( } GetPolicyHandler().GetCloudAppParameters(policy_app_id, - endpoint, - certificate, - auth_token, - cloud_transport_type, - hybrid_app_preference); + endpoint, + certificate, + auth_token, + cloud_transport_type, + hybrid_app_preference_str); + + mobile_apis::HybridAppPreference::eType hybrid_app_preference_enum; + + bool convert_result = smart_objects::EnumConversionHelper< + mobile_apis::HybridAppPreference::eType>:: + StringToEnum(hybrid_app_preference_str, &hybrid_app_preference_enum); + + if (!convert_result) { + LOG4CXX_ERROR( + logger_, + "Could not convert string to enum: " << hybrid_app_preference_str); + return; + } application->set_hmi_application_id(GenerateNewHMIAppID()); application->set_cloud_app_endpoint(endpoint); application->set_cloud_app_auth_token(auth_token); application->set_cloud_app_transport_type(cloud_transport_type); - application->set_hybrid_app_preference(hybrid_app_preference); + application->set_hybrid_app_preference(hybrid_app_preference_enum); application->set_cloud_app_certificate(certificate); sync_primitives::AutoLock lock(apps_to_register_list_lock_ptr_); -- cgit v1.2.1 From 61f6a0e75b1550689becf07e6b9aaad16c7a4910 Mon Sep 17 00:00:00 2001 From: ShobhitAd Date: Fri, 16 Nov 2018 14:26:11 -0500 Subject: Implement InitCloudApp in policy_external --- .../policy/policy_external/policy/policy_manager.h | 8 +++++++- .../policy_external/include/policy/cache_manager.h | 8 ++++++++ .../include/policy/cache_manager_interface.h | 8 ++++++++ .../include/policy/policy_manager_impl.h | 6 ++++++ .../policy/policy_external/src/cache_manager.cc | 19 +++++++++++++++++++ .../policy/policy_external/src/policy_manager_impl.cc | 4 ++++ 6 files changed, 52 insertions(+), 1 deletion(-) diff --git a/src/components/include/policy/policy_external/policy/policy_manager.h b/src/components/include/policy/policy_external/policy/policy_manager.h index 37c8a902f1..54dde0d8cf 100644 --- a/src/components/include/policy/policy_external/policy/policy_manager.h +++ b/src/components/include/policy/policy_external/policy/policy_manager.h @@ -554,7 +554,13 @@ class PolicyManager : public usage_statistics::StatisticsManager { std::string& auth_token, std::string& cloud_transport_type, std::string& hybrid_app_preference) const = 0; - + + /** + * @ brief Initialize new cloud app in the policy table + * @ param policy_app_id Application ID + */ + virtual void InitCloudApp(const std::string& policy_app_id) = 0; + /** * @brief Enable or disable a cloud application in the HMI * @param enabled Cloud app enabled state diff --git a/src/components/policy/policy_external/include/policy/cache_manager.h b/src/components/policy/policy_external/include/policy/cache_manager.h index 98f279b345..e5258e36c8 100644 --- a/src/components/policy/policy_external/include/policy/cache_manager.h +++ b/src/components/policy/policy_external/include/policy/cache_manager.h @@ -189,6 +189,14 @@ class CacheManager : public CacheManagerInterface { std::string& auth_token, std::string& cloud_transport_type, std::string& hybrid_app_preference) const; + + /** + * Initializes a new cloud application with default policies + * Then adds cloud specific policies + * @param app_id application id + * @return true if success + */ + virtual void InitCloudApp(const std::string& policy_app_id); /** * @brief Enable or disable a cloud application in the HMI diff --git a/src/components/policy/policy_external/include/policy/cache_manager_interface.h b/src/components/policy/policy_external/include/policy/cache_manager_interface.h index 2a334876ae..aba3e32004 100644 --- a/src/components/policy/policy_external/include/policy/cache_manager_interface.h +++ b/src/components/policy/policy_external/include/policy/cache_manager_interface.h @@ -198,6 +198,14 @@ class CacheManagerInterface { std::string& cloud_transport_type, std::string& hybrid_app_preference) const = 0; + /** + * Initializes a new cloud application with default policies + * Then adds cloud specific policies + * @param app_id application id + * @return true if success + */ + virtual void InitCloudApp(const std::string& policy_app_id) = 0; + /** * @brief Enable or disable a cloud application in the HMI * @param enabled Cloud app enabled state diff --git a/src/components/policy/policy_external/include/policy/policy_manager_impl.h b/src/components/policy/policy_external/include/policy/policy_manager_impl.h index 6d4cbbf773..d9bec20791 100644 --- a/src/components/policy/policy_external/include/policy/policy_manager_impl.h +++ b/src/components/policy/policy_external/include/policy/policy_manager_impl.h @@ -602,6 +602,12 @@ class PolicyManagerImpl : public PolicyManager { std::string& cloud_transport_type, std::string& hybrid_app_preference) const OVERRIDE; + /** + * @ brief Initialize new cloud app in the policy table + * @ param policy_app_id Application ID + */ + void InitCloudApp(const std::string& policy_app_id) OVERRIDE; + /** * @brief Enable or disable a cloud application in the HMI * @param enabled Cloud app enabled state diff --git a/src/components/policy/policy_external/src/cache_manager.cc b/src/components/policy/policy_external/src/cache_manager.cc index dc0838d429..31f0f4110e 100644 --- a/src/components/policy/policy_external/src/cache_manager.cc +++ b/src/components/policy/policy_external/src/cache_manager.cc @@ -1435,6 +1435,25 @@ void CacheManager::GetCloudAppParameters( } } +void CacheManager::InitCloudApp(const std::string& policy_app_id) { + CACHE_MANAGER_CHECK_VOID(); + sync_primitives::AutoLock auto_lock(cache_lock_); + + policy_table::ApplicationPolicies& policies = + pt_->policy_table.app_policies_section.apps; + policy_table::ApplicationPolicies::const_iterator default_iter = + policies.find(kDefaultId); + policy_table::ApplicationPolicies::const_iterator app_iter = + policies.find(policy_app_id); + if (default_iter != policies.end()) { + if (app_iter == policies.end()){ + policies[policy_app_id] = policies[kDefaultId]; + } + } + //Add cloud app specific policies + Backup(); +} + void CacheManager::SetCloudAppEnabled(const std::string& policy_app_id, const bool enabled) { policy_table::ApplicationPolicies& policies = diff --git a/src/components/policy/policy_external/src/policy_manager_impl.cc b/src/components/policy/policy_external/src/policy_manager_impl.cc index df474268ba..1aa6776011 100644 --- a/src/components/policy/policy_external/src/policy_manager_impl.cc +++ b/src/components/policy/policy_external/src/policy_manager_impl.cc @@ -747,6 +747,10 @@ void PolicyManagerImpl::GetCloudAppParameters( hybrid_app_preference); } +void PolicyManagerImpl::InitCloudApp(const std::string& policy_app_id){ + cache_->InitCloudApp(policy_app_id); +} + void PolicyManagerImpl::SetCloudAppEnabled(const std::string& policy_app_id, const bool enabled) { cache_->SetCloudAppEnabled(policy_app_id, enabled); -- cgit v1.2.1 From 293eff01d166b8b7e214bf9e0f1cd36d930b764e Mon Sep 17 00:00:00 2001 From: ShobhitAd Date: Fri, 16 Nov 2018 14:39:14 -0500 Subject: Added InitCloudApp to mock policy files --- .../include/test/policy/policy_external/policy/mock_cache_manager.h | 2 ++ .../include/test/policy/policy_external/policy/mock_policy_manager.h | 2 ++ .../include/test/policy/policy_regular/policy/mock_cache_manager.h | 2 ++ .../include/test/policy/policy_regular/policy/mock_policy_manager.h | 2 ++ 4 files changed, 8 insertions(+) diff --git a/src/components/include/test/policy/policy_external/policy/mock_cache_manager.h b/src/components/include/test/policy/policy_external/policy/mock_cache_manager.h index db3f37fb91..d426107200 100644 --- a/src/components/include/test/policy/policy_external/policy/mock_cache_manager.h +++ b/src/components/include/test/policy/policy_external/policy/mock_cache_manager.h @@ -86,6 +86,8 @@ class MockCacheManagerInterface : public ::policy::CacheManagerInterface { std::string& auth_token, std::string& cloud_transport_type, std::string& hybrid_app_preference)); + MOCK_METHOD1(InitCloudApp, + void(const std::string& policy_app_id)); MOCK_METHOD2(SetCloudAppEnabled, void(const std::string& policy_app_id, const bool enabled)); MOCK_METHOD2(SetAppAuthToken, diff --git a/src/components/include/test/policy/policy_external/policy/mock_policy_manager.h b/src/components/include/test/policy/policy_external/policy/mock_policy_manager.h index 1eabb78019..dfcea6c65c 100644 --- a/src/components/include/test/policy/policy_external/policy/mock_policy_manager.h +++ b/src/components/include/test/policy/policy_external/policy/mock_policy_manager.h @@ -194,6 +194,8 @@ class MockPolicyManager : public PolicyManager { std::string& auth_token, std::string& cloud_transport_type, std::string& hybrid_app_preference)); + MOCK_METHOD1(InitCloudApp, + void(const std::string& policy_app_id)); MOCK_METHOD2(SetCloudAppEnabled, void(const std::string& policy_app_id, const bool enabled)); MOCK_METHOD2(SetAppAuthToken, diff --git a/src/components/include/test/policy/policy_regular/policy/mock_cache_manager.h b/src/components/include/test/policy/policy_regular/policy/mock_cache_manager.h index 3d8dc4116a..703c1c9c8b 100644 --- a/src/components/include/test/policy/policy_regular/policy/mock_cache_manager.h +++ b/src/components/include/test/policy/policy_regular/policy/mock_cache_manager.h @@ -73,6 +73,8 @@ class MockCacheManagerInterface : public CacheManagerInterface { std::string& auth_token, std::string& cloud_transport_type, std::string& hybrid_app_preference)); + MOCK_METHOD1(InitCloudApp, + void(const std::string& policy_app_id)); MOCK_METHOD2(SetCloudAppEnabled, void(const std::string& policy_app_id, const bool enabled)); MOCK_METHOD2(SetAppAuthToken, diff --git a/src/components/include/test/policy/policy_regular/policy/mock_policy_manager.h b/src/components/include/test/policy/policy_regular/policy/mock_policy_manager.h index a28ea32108..f63cc21c83 100644 --- a/src/components/include/test/policy/policy_regular/policy/mock_policy_manager.h +++ b/src/components/include/test/policy/policy_regular/policy/mock_policy_manager.h @@ -191,6 +191,8 @@ class MockPolicyManager : public PolicyManager { std::string& auth_token, std::string& cloud_transport_type, std::string& hybrid_app_preference)); + MOCK_METHOD1(InitCloudApp, + void(const std::string& policy_app_id)); MOCK_METHOD2(SetCloudAppEnabled, void(const std::string& policy_app_id, const bool enabled)); MOCK_METHOD2(SetAppAuthToken, -- cgit v1.2.1 From 9fd56f753dd18e002b8b85a3a328e393113a72fa Mon Sep 17 00:00:00 2001 From: ShobhitAd Date: Fri, 16 Nov 2018 14:42:38 -0500 Subject: Style fix --- .../policy/policy_external/policy/policy_manager.h | 6 +++--- .../policy_external/policy/mock_cache_manager.h | 3 +-- .../policy_external/policy/mock_policy_manager.h | 3 +-- .../policy_regular/policy/mock_cache_manager.h | 3 +-- .../policy_regular/policy/mock_policy_manager.h | 3 +-- .../policy_external/include/policy/cache_manager.h | 2 +- .../include/policy/cache_manager_interface.h | 12 ++++++------ .../include/policy/policy_manager_impl.h | 2 +- .../policy/policy_external/src/cache_manager.cc | 20 ++++++++++---------- .../policy_external/src/policy_manager_impl.cc | 2 +- .../policy_regular/include/policy/cache_manager.h | 1 - .../include/policy/cache_manager_interface.h | 2 +- .../policy/policy_regular/src/cache_manager.cc | 16 ++++++++-------- .../policy/policy_regular/src/policy_manager_impl.cc | 2 +- 14 files changed, 36 insertions(+), 41 deletions(-) diff --git a/src/components/include/policy/policy_external/policy/policy_manager.h b/src/components/include/policy/policy_external/policy/policy_manager.h index 54dde0d8cf..92c0305279 100644 --- a/src/components/include/policy/policy_external/policy/policy_manager.h +++ b/src/components/include/policy/policy_external/policy/policy_manager.h @@ -554,13 +554,13 @@ class PolicyManager : public usage_statistics::StatisticsManager { std::string& auth_token, std::string& cloud_transport_type, std::string& hybrid_app_preference) const = 0; - + /** * @ brief Initialize new cloud app in the policy table * @ param policy_app_id Application ID */ - virtual void InitCloudApp(const std::string& policy_app_id) = 0; - + virtual void InitCloudApp(const std::string& policy_app_id) = 0; + /** * @brief Enable or disable a cloud application in the HMI * @param enabled Cloud app enabled state diff --git a/src/components/include/test/policy/policy_external/policy/mock_cache_manager.h b/src/components/include/test/policy/policy_external/policy/mock_cache_manager.h index d426107200..da2b4cc2a1 100644 --- a/src/components/include/test/policy/policy_external/policy/mock_cache_manager.h +++ b/src/components/include/test/policy/policy_external/policy/mock_cache_manager.h @@ -86,8 +86,7 @@ class MockCacheManagerInterface : public ::policy::CacheManagerInterface { std::string& auth_token, std::string& cloud_transport_type, std::string& hybrid_app_preference)); - MOCK_METHOD1(InitCloudApp, - void(const std::string& policy_app_id)); + MOCK_METHOD1(InitCloudApp, void(const std::string& policy_app_id)); MOCK_METHOD2(SetCloudAppEnabled, void(const std::string& policy_app_id, const bool enabled)); MOCK_METHOD2(SetAppAuthToken, diff --git a/src/components/include/test/policy/policy_external/policy/mock_policy_manager.h b/src/components/include/test/policy/policy_external/policy/mock_policy_manager.h index dfcea6c65c..72dcb147e3 100644 --- a/src/components/include/test/policy/policy_external/policy/mock_policy_manager.h +++ b/src/components/include/test/policy/policy_external/policy/mock_policy_manager.h @@ -194,8 +194,7 @@ class MockPolicyManager : public PolicyManager { std::string& auth_token, std::string& cloud_transport_type, std::string& hybrid_app_preference)); - MOCK_METHOD1(InitCloudApp, - void(const std::string& policy_app_id)); + MOCK_METHOD1(InitCloudApp, void(const std::string& policy_app_id)); MOCK_METHOD2(SetCloudAppEnabled, void(const std::string& policy_app_id, const bool enabled)); MOCK_METHOD2(SetAppAuthToken, diff --git a/src/components/include/test/policy/policy_regular/policy/mock_cache_manager.h b/src/components/include/test/policy/policy_regular/policy/mock_cache_manager.h index 703c1c9c8b..24fe9b2393 100644 --- a/src/components/include/test/policy/policy_regular/policy/mock_cache_manager.h +++ b/src/components/include/test/policy/policy_regular/policy/mock_cache_manager.h @@ -73,8 +73,7 @@ class MockCacheManagerInterface : public CacheManagerInterface { std::string& auth_token, std::string& cloud_transport_type, std::string& hybrid_app_preference)); - MOCK_METHOD1(InitCloudApp, - void(const std::string& policy_app_id)); + MOCK_METHOD1(InitCloudApp, void(const std::string& policy_app_id)); MOCK_METHOD2(SetCloudAppEnabled, void(const std::string& policy_app_id, const bool enabled)); MOCK_METHOD2(SetAppAuthToken, diff --git a/src/components/include/test/policy/policy_regular/policy/mock_policy_manager.h b/src/components/include/test/policy/policy_regular/policy/mock_policy_manager.h index f63cc21c83..a5ce488e1a 100644 --- a/src/components/include/test/policy/policy_regular/policy/mock_policy_manager.h +++ b/src/components/include/test/policy/policy_regular/policy/mock_policy_manager.h @@ -191,8 +191,7 @@ class MockPolicyManager : public PolicyManager { std::string& auth_token, std::string& cloud_transport_type, std::string& hybrid_app_preference)); - MOCK_METHOD1(InitCloudApp, - void(const std::string& policy_app_id)); + MOCK_METHOD1(InitCloudApp, void(const std::string& policy_app_id)); MOCK_METHOD2(SetCloudAppEnabled, void(const std::string& policy_app_id, const bool enabled)); MOCK_METHOD2(SetAppAuthToken, diff --git a/src/components/policy/policy_external/include/policy/cache_manager.h b/src/components/policy/policy_external/include/policy/cache_manager.h index e5258e36c8..3344b149e4 100644 --- a/src/components/policy/policy_external/include/policy/cache_manager.h +++ b/src/components/policy/policy_external/include/policy/cache_manager.h @@ -189,7 +189,7 @@ class CacheManager : public CacheManagerInterface { std::string& auth_token, std::string& cloud_transport_type, std::string& hybrid_app_preference) const; - + /** * Initializes a new cloud application with default policies * Then adds cloud specific policies diff --git a/src/components/policy/policy_external/include/policy/cache_manager_interface.h b/src/components/policy/policy_external/include/policy/cache_manager_interface.h index aba3e32004..6a172e6f4b 100644 --- a/src/components/policy/policy_external/include/policy/cache_manager_interface.h +++ b/src/components/policy/policy_external/include/policy/cache_manager_interface.h @@ -198,12 +198,12 @@ class CacheManagerInterface { std::string& cloud_transport_type, std::string& hybrid_app_preference) const = 0; - /** - * Initializes a new cloud application with default policies - * Then adds cloud specific policies - * @param app_id application id - * @return true if success - */ + /** + * Initializes a new cloud application with default policies + * Then adds cloud specific policies + * @param app_id application id + * @return true if success + */ virtual void InitCloudApp(const std::string& policy_app_id) = 0; /** diff --git a/src/components/policy/policy_external/include/policy/policy_manager_impl.h b/src/components/policy/policy_external/include/policy/policy_manager_impl.h index d9bec20791..399c95170d 100644 --- a/src/components/policy/policy_external/include/policy/policy_manager_impl.h +++ b/src/components/policy/policy_external/include/policy/policy_manager_impl.h @@ -606,7 +606,7 @@ class PolicyManagerImpl : public PolicyManager { * @ brief Initialize new cloud app in the policy table * @ param policy_app_id Application ID */ - void InitCloudApp(const std::string& policy_app_id) OVERRIDE; + void InitCloudApp(const std::string& policy_app_id) OVERRIDE; /** * @brief Enable or disable a cloud application in the HMI diff --git a/src/components/policy/policy_external/src/cache_manager.cc b/src/components/policy/policy_external/src/cache_manager.cc index 31f0f4110e..8cec6ef91c 100644 --- a/src/components/policy/policy_external/src/cache_manager.cc +++ b/src/components/policy/policy_external/src/cache_manager.cc @@ -1439,19 +1439,19 @@ void CacheManager::InitCloudApp(const std::string& policy_app_id) { CACHE_MANAGER_CHECK_VOID(); sync_primitives::AutoLock auto_lock(cache_lock_); - policy_table::ApplicationPolicies& policies = - pt_->policy_table.app_policies_section.apps; - policy_table::ApplicationPolicies::const_iterator default_iter = - policies.find(kDefaultId); - policy_table::ApplicationPolicies::const_iterator app_iter = - policies.find(policy_app_id); - if (default_iter != policies.end()) { - if (app_iter == policies.end()){ + policy_table::ApplicationPolicies& policies = + pt_->policy_table.app_policies_section.apps; + policy_table::ApplicationPolicies::const_iterator default_iter = + policies.find(kDefaultId); + policy_table::ApplicationPolicies::const_iterator app_iter = + policies.find(policy_app_id); + if (default_iter != policies.end()) { + if (app_iter == policies.end()) { policies[policy_app_id] = policies[kDefaultId]; } } - //Add cloud app specific policies - Backup(); + // Add cloud app specific policies + Backup(); } void CacheManager::SetCloudAppEnabled(const std::string& policy_app_id, diff --git a/src/components/policy/policy_external/src/policy_manager_impl.cc b/src/components/policy/policy_external/src/policy_manager_impl.cc index 1aa6776011..0844edd8eb 100644 --- a/src/components/policy/policy_external/src/policy_manager_impl.cc +++ b/src/components/policy/policy_external/src/policy_manager_impl.cc @@ -747,7 +747,7 @@ void PolicyManagerImpl::GetCloudAppParameters( hybrid_app_preference); } -void PolicyManagerImpl::InitCloudApp(const std::string& policy_app_id){ +void PolicyManagerImpl::InitCloudApp(const std::string& policy_app_id) { cache_->InitCloudApp(policy_app_id); } diff --git a/src/components/policy/policy_regular/include/policy/cache_manager.h b/src/components/policy/policy_regular/include/policy/cache_manager.h index 0ce35b5beb..8c8f0c55c6 100644 --- a/src/components/policy/policy_regular/include/policy/cache_manager.h +++ b/src/components/policy/policy_regular/include/policy/cache_manager.h @@ -186,7 +186,6 @@ class CacheManager : public CacheManagerInterface { */ virtual void InitCloudApp(const std::string& policy_app_id); - /** * @brief Enable or disable a cloud application in the HMI * @param enabled Cloud app enabled state diff --git a/src/components/policy/policy_regular/include/policy/cache_manager_interface.h b/src/components/policy/policy_regular/include/policy/cache_manager_interface.h index bf0f17d83c..50b546ecc5 100644 --- a/src/components/policy/policy_regular/include/policy/cache_manager_interface.h +++ b/src/components/policy/policy_regular/include/policy/cache_manager_interface.h @@ -191,7 +191,7 @@ class CacheManagerInterface { * @return true if success */ virtual void InitCloudApp(const std::string& policy_app_id) = 0; - + /** * @brief Enable or disable a cloud application in the HMI * @param enabled Cloud app enabled state diff --git a/src/components/policy/policy_regular/src/cache_manager.cc b/src/components/policy/policy_regular/src/cache_manager.cc index 2c37279baa..ca61a338f1 100644 --- a/src/components/policy/policy_regular/src/cache_manager.cc +++ b/src/components/policy/policy_regular/src/cache_manager.cc @@ -732,19 +732,19 @@ void CacheManager::InitCloudApp(const std::string& policy_app_id) { CACHE_MANAGER_CHECK_VOID(); sync_primitives::AutoLock auto_lock(cache_lock_); - policy_table::ApplicationPolicies& policies = - pt_->policy_table.app_policies_section.apps; - policy_table::ApplicationPolicies::const_iterator default_iter = - policies.find(kDefaultId); - policy_table::ApplicationPolicies::const_iterator app_iter = - policies.find(policy_app_id); + policy_table::ApplicationPolicies& policies = + pt_->policy_table.app_policies_section.apps; + policy_table::ApplicationPolicies::const_iterator default_iter = + policies.find(kDefaultId); + policy_table::ApplicationPolicies::const_iterator app_iter = + policies.find(policy_app_id); if (default_iter != policies.end()) { - if (app_iter == policies.end()){ + if (app_iter == policies.end()) { policies[policy_app_id] = policies[kDefaultId]; } } - //Add cloud app specific policies + // Add cloud app specific policies Backup(); } diff --git a/src/components/policy/policy_regular/src/policy_manager_impl.cc b/src/components/policy/policy_regular/src/policy_manager_impl.cc index e2adde4524..9b2392a015 100644 --- a/src/components/policy/policy_regular/src/policy_manager_impl.cc +++ b/src/components/policy/policy_regular/src/policy_manager_impl.cc @@ -566,7 +566,7 @@ void PolicyManagerImpl::GetCloudAppParameters( hybrid_app_preference); } -void PolicyManagerImpl::InitCloudApp(const std::string& policy_app_id){ +void PolicyManagerImpl::InitCloudApp(const std::string& policy_app_id) { cache_->InitCloudApp(policy_app_id); } -- cgit v1.2.1 From d8ad4e0427b33087340aa34cf1e1d3954cdb793e Mon Sep 17 00:00:00 2001 From: JackLivio Date: Fri, 16 Nov 2018 14:44:29 -0500 Subject: Remove printfs and hardcoded values --- .../include/transport_manager/cloud/cloud_device.h | 7 ++- .../transport_manager/src/cloud/cloud_device.cc | 10 ++++- .../cloud/cloud_websocket_connection_factory.cc | 19 -------- .../src/cloud/cloud_websocket_transport_adapter.cc | 9 +--- .../src/cloud/websocket_client_connection.cc | 52 +++++++++------------- .../src/transport_manager_default.cc | 1 - 6 files changed, 36 insertions(+), 62 deletions(-) diff --git a/src/components/transport_manager/include/transport_manager/cloud/cloud_device.h b/src/components/transport_manager/include/transport_manager/cloud/cloud_device.h index f80ad924e3..8eac8c6f75 100644 --- a/src/components/transport_manager/include/transport_manager/cloud/cloud_device.h +++ b/src/components/transport_manager/include/transport_manager/cloud/cloud_device.h @@ -47,13 +47,18 @@ class CloudDevice : public Device { public: CloudDevice(std::string& host, std::string& port, std::string& name); + virtual const std::string& GetHost(); + + virtual const std::string& GetPort(); + protected: virtual bool IsSameAs(const Device* other_device) const; virtual ApplicationList GetApplicationList() const; private: - // todo add private varaibles, maybe ip port or other connection information? + const std::string host_; + const std::string port_; }; } // namespace transport_adapter diff --git a/src/components/transport_manager/src/cloud/cloud_device.cc b/src/components/transport_manager/src/cloud/cloud_device.cc index 699d79d52a..6196bcc87e 100644 --- a/src/components/transport_manager/src/cloud/cloud_device.cc +++ b/src/components/transport_manager/src/cloud/cloud_device.cc @@ -42,7 +42,7 @@ CREATE_LOGGERPTR_GLOBAL(logger_, "TransportManager") CloudDevice::CloudDevice(std::string& host, std::string& port, std::string& name) - : Device(name, std::string(name)) {} + : Device(name, std::string(name)), host_(host), port_(port) {} bool CloudDevice::IsSameAs(const Device* other) const { LOG4CXX_TRACE(logger_, "enter. device: " << other); @@ -56,5 +56,13 @@ ApplicationList CloudDevice::GetApplicationList() const { return ApplicationList{100}; } +const std::string& CloudDevice::GetHost() { + return host_; +} + +const std::string& CloudDevice::GetPort() { + return port_; +} + } // namespace transport_adapter } // namespace transport_manager diff --git a/src/components/transport_manager/src/cloud/cloud_websocket_connection_factory.cc b/src/components/transport_manager/src/cloud/cloud_websocket_connection_factory.cc index 2b2a5ee2aa..cdc27ed8ef 100644 --- a/src/components/transport_manager/src/cloud/cloud_websocket_connection_factory.cc +++ b/src/components/transport_manager/src/cloud/cloud_websocket_connection_factory.cc @@ -50,31 +50,12 @@ CloudWebsocketConnectionFactory::CloudWebsocketConnectionFactory( : controller_(controller) {} TransportAdapter::Error CloudWebsocketConnectionFactory::Init() { - /*DeviceUID device_id = "Cloud"; - ApplicationHandle app_handle = 100; - printf("Calling create connection\n"); - - std::string host("192.168.1.69"); - std::string port("8080"); - - //todo move this device logic to the correct place. - auto cloud_device = std::make_shared( - host,port,device_id); - DeviceVector devices{cloud_device}; - - controller_->SearchDeviceDone(devices); - - - const TransportAdapter::Error err = - this->CreateConnection(std::string(device_id+host+port), app_handle); - LOG4CXX_DEBUG(logger_, err);*/ return TransportAdapter::OK; } TransportAdapter::Error CloudWebsocketConnectionFactory::CreateConnection( const DeviceUID& device_uid, const ApplicationHandle& app_handle) { LOG4CXX_AUTO_TRACE(logger_); - printf("Create connection()\n"); std::shared_ptr connection = std::make_shared( device_uid, app_handle, controller_); diff --git a/src/components/transport_manager/src/cloud/cloud_websocket_transport_adapter.cc b/src/components/transport_manager/src/cloud/cloud_websocket_transport_adapter.cc index 23cee31002..874f158145 100644 --- a/src/components/transport_manager/src/cloud/cloud_websocket_transport_adapter.cc +++ b/src/components/transport_manager/src/cloud/cloud_websocket_transport_adapter.cc @@ -49,14 +49,7 @@ CloudWebsocketTransportAdapter::CloudWebsocketTransportAdapter( new CloudWebsocketConnectionFactory(this), NULL, last_state, - settings) { - /*DeviceUID device_id = "Cloud"; - ApplicationHandle app_handle = 100; - printf("Calling create connection\n"); - const TransportAdapter::Error err = - server_connection_factory_->CreateConnection(device_id, app_handle); - LOG4CXX_DEBUG(logger_, err);*/ -} + settings) {} CloudWebsocketTransportAdapter::~CloudWebsocketTransportAdapter() {} diff --git a/src/components/transport_manager/src/cloud/websocket_client_connection.cc b/src/components/transport_manager/src/cloud/websocket_client_connection.cc index c2dcc9f14a..0912a07999 100644 --- a/src/components/transport_manager/src/cloud/websocket_client_connection.cc +++ b/src/components/transport_manager/src/cloud/websocket_client_connection.cc @@ -32,6 +32,7 @@ */ #include "transport_manager/cloud/websocket_client_connection.h" +#include "transport_manager/cloud/cloud_device.h" #include "transport_manager/transport_adapter/transport_adapter_controller.h" @@ -63,28 +64,34 @@ WebsocketClientConnection::~WebsocketClientConnection() { TransportAdapter::Error WebsocketClientConnection::Start() { LOG4CXX_AUTO_TRACE(logger_); - printf("Calling websocket start\n"); - auto const host = "192.168.1.69"; - auto const port = "8080"; + DeviceSptr device = controller_->FindDevice(device_uid_); + CloudDevice* cloud_device = static_cast(device.get()); + auto const host = cloud_device->GetHost(); + auto const port = cloud_device->GetPort(); boost::system::error_code ec; auto const results = resolver_.resolve(host, port, ec); if (ec) { - std::string str_err = "ErrorMessage1: " + ec.message(); - printf("%s\n", str_err.c_str()); + std::string str_err = "ErrorMessage: " + ec.message(); + LOG4CXX_ERROR(logger_, "Could not resolve host/port: " << str_err); Shutdown(); return TransportAdapter::FAIL; } boost::asio::connect(ws_.next_layer(), results.begin(), results.end(), ec); if (ec) { - std::string str_err = "ErrorMessage2: " + ec.message(); - printf("%s\n", str_err.c_str()); + std::string str_err = "ErrorMessage: " + ec.message(); + LOG4CXX_ERROR(logger_, + "Could not connect to websocket: " << host << ":" << port); + LOG4CXX_ERROR(logger_, str_err); Shutdown(); return TransportAdapter::FAIL; } ws_.handshake(host, "/", ec); if (ec) { - std::string str_err = "ErrorMessage3: " + ec.message(); - printf("%s\n", str_err.c_str()); + std::string str_err = "ErrorMessage: " + ec.message(); + LOG4CXX_ERROR(logger_, + "Could not complete handshake with host/port: " << host << ":" + << port); + LOG4CXX_ERROR(logger_, str_err); Shutdown(); return TransportAdapter::FAIL; } @@ -102,35 +109,27 @@ TransportAdapter::Error WebsocketClientConnection::Start() { // Start IO Service thread. Allows for async reads without blocking. io_service_thread_ = std::thread([&]() { ioc_.run(); - printf("io_service_thread_ END!!!\n"); + LOG4CXX_DEBUG(logger_, "Ending Boost IO Thread"); }); - // Start async write thread - - printf("End of websockets\n"); + LOG4CXX_DEBUG(logger_, + "Successfully started websocket connection @: " << host << ":" + << port); return TransportAdapter::OK; } void WebsocketClientConnection::Recv(boost::system::error_code ec) { - printf("Recv\n"); if (shutdown_) { - printf("shutdown_\n"); return; } if (ec) { std::string str_err = "ErrorMessage: " + ec.message(); - printf("%s\n", str_err.c_str()); LOG4CXX_ERROR(logger_, str_err); - // shutdown_ = true; - // ioc_.stop(); - // thread_delegate_->SetShutdown(); - // controller_->deleteController(this); Shutdown(); return; } - printf("calling async read\n"); ws_.async_read(buffer_, std::bind(&WebsocketClientConnection::OnRead, @@ -141,23 +140,18 @@ void WebsocketClientConnection::Recv(boost::system::error_code ec) { void WebsocketClientConnection::OnRead(boost::system::error_code ec, std::size_t bytes_transferred) { - printf("OnRead\n"); boost::ignore_unused(bytes_transferred); if (ec) { std::string str_err = "ErrorMessage: " + ec.message(); - printf("%s\n", str_err.c_str()); LOG4CXX_ERROR(logger_, str_err); Shutdown(); controller_->ConnectionAborted( device_uid_, app_handle_, CommunicationError()); - - printf("return error\n"); return; } std::string data_str = boost::beast::buffers_to_string(buffer_.data()); LOG4CXX_DEBUG(logger_, "Cloud Transport Received: " << data_str); - printf("%s\n", data_str.c_str()); ssize_t size = (ssize_t)buffer_.size(); const uint8_t* data = boost::asio::buffer_cast( @@ -175,10 +169,8 @@ void WebsocketClientConnection::OnRead(boost::system::error_code ec, TransportAdapter::Error WebsocketClientConnection::SendData( ::protocol_handler::RawMessagePtr message) { LOG4CXX_AUTO_TRACE(logger_); - printf("Send DATA!!!\n"); sync_primitives::AutoLock auto_lock(frames_to_send_mutex_); message_queue_.push(message); - printf("Data pushed to queue!!!\n"); return TransportAdapter::OK; } @@ -194,13 +186,11 @@ void WebsocketClientConnection::Shutdown() { if (thread_delegate_) { thread_delegate_->SetShutdown(); write_thread_->join(); - printf("Joined Thread Delegate!!!\n"); delete thread_delegate_; } if (buffer_.size()) { buffer_.consume(buffer_.size()); } - printf("End of shutdown!!!\n"); } WebsocketClientConnection::LoopThreadDelegate::LoopThreadDelegate( @@ -209,7 +199,6 @@ WebsocketClientConnection::LoopThreadDelegate::LoopThreadDelegate( : message_queue_(*message_queue), handler_(*handler), shutdown_(false) {} void WebsocketClientConnection::LoopThreadDelegate::threadMain() { - printf("Starting write thread\n"); while (!message_queue_.IsShuttingDown() && !shutdown_) { DrainQueue(); message_queue_.wait(); @@ -229,7 +218,6 @@ void WebsocketClientConnection::LoopThreadDelegate::DrainQueue() { Message message_ptr; message_queue_.pop(message_ptr); if (!shutdown_) { - printf("Calling Write!!!\n"); boost::system::error_code ec; handler_.ws_.write( boost::asio::buffer(message_ptr->data(), message_ptr->data_size())); diff --git a/src/components/transport_manager/src/transport_manager_default.cc b/src/components/transport_manager/src/transport_manager_default.cc index 3beed2f763..bf692de24c 100644 --- a/src/components/transport_manager/src/transport_manager_default.cc +++ b/src/components/transport_manager/src/transport_manager_default.cc @@ -106,7 +106,6 @@ int TransportManagerDefault::Init(resumption::LastState& last_state) { #endif // USB_SUPPORT #if defined CLOUD_APP_WEBSOCKET_TRANSPORT_SUPPORT - printf("Creating cloud transport\n"); transport_adapter::TransportAdapterImpl* ta_cloud = new transport_adapter::CloudWebsocketTransportAdapter( last_state, get_settings()); // Todo add retry connection logic from -- cgit v1.2.1 From dc2dc33575394ae16d72a745e278279e0a2700a1 Mon Sep 17 00:00:00 2001 From: jacobkeeler Date: Fri, 16 Nov 2018 15:19:58 -0500 Subject: Add cloud connection status Also required some refactoring regarding the retry process for cloud apps, as well as how the HMIApplication struct was filled. --- .../application_manager/application_manager_impl.h | 3 + .../application_manager/smart_object_keys.h | 4 +- .../mobile/register_app_interface_request.h | 2 +- .../mobile/register_app_interface_request.cc | 113 +++------------------ .../src/application_manager_impl.cc | 18 ++++ .../src/message_helper/message_helper.cc | 54 +++++++++- .../application_manager/src/smart_object_keys.cc | 4 +- .../connection_handler/connection_handler_impl.h | 3 + .../src/connection_handler_impl.cc | 5 + .../application_manager/application_manager.h | 3 + .../connection_handler/connection_handler.h | 3 + .../application_manager/mock_application_manager.h | 3 + .../connection_handler/mock_connection_handler.h | 2 + .../transport_manager/mock_transport_manager.h | 2 + .../transport_adapter/mock_transport_adapter.h | 2 + src/components/include/transport_manager/common.h | 2 + .../transport_manager/transport_adapter/device.h | 24 +++++ .../transport_adapter/transport_adapter.h | 3 + .../include/transport_manager/transport_manager.h | 3 + src/components/interfaces/HMI_API.xml | 28 +++-- .../transport_adapter/transport_adapter_impl.h | 9 +- .../transport_manager/transport_manager_impl.h | 7 +- .../src/cloud/cloud_websocket_transport_adapter.cc | 2 +- .../transport_adapter/transport_adapter_impl.cc | 67 +++++++----- .../src/transport_manager_impl.cc | 16 +++ 25 files changed, 236 insertions(+), 146 deletions(-) diff --git a/src/components/application_manager/include/application_manager/application_manager_impl.h b/src/components/application_manager/include/application_manager/application_manager_impl.h index 8fb7f1c227..f235a4e482 100644 --- a/src/components/application_manager/include/application_manager/application_manager_impl.h +++ b/src/components/application_manager/include/application_manager/application_manager_impl.h @@ -367,6 +367,9 @@ class ApplicationManagerImpl const transport_manager::DeviceInfo& device_info, connection_handler::DeviceHandle device_id); + hmi_apis::Common_CloudConnectionStatus::eType GetCloudAppConnectionStatus( + ApplicationConstSharedPtr app) const; + /* * @brief Returns unique correlation ID for HMI request * 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 62192da391..5e6a3bb377 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 @@ -76,7 +76,7 @@ extern const char* ngn_media_screen_app_name; extern const char* vr_synonyms; extern const char* uses_vehicle_data; extern const char* is_media_application; -extern const char* greyOut; +extern const char* grey_out; extern const char* language_desired; extern const char* auto_activated_id; extern const char* app_type; @@ -192,6 +192,8 @@ extern const char* enabled; extern const char* cloud_app_auth_token; extern const char* cloud_transport_type; extern const char* hybrid_app_preference; +extern const char* is_cloud_application; +extern const char* cloud_connection_status; // PutFile extern const char* sync_file_name; diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/register_app_interface_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/register_app_interface_request.h index 542fdac5f8..d0e70e906a 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/register_app_interface_request.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/register_app_interface_request.h @@ -128,7 +128,7 @@ class RegisterAppInterfaceRequest * **/ void SendOnAppRegisteredNotificationToHMI( - const app_mngr::Application& application_impl, + app_mngr::ApplicationConstSharedPtr app, bool resumption = false, bool need_restore_vr = false); /* 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 8f06e8c51a..f8d3267441 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 @@ -806,7 +806,7 @@ void RegisterAppInterfaceRequest::SendRegisterAppInterfaceResponseToMobile( SendResponse(true, result_code, add_info.c_str(), &response_params); SendOnAppRegisteredNotificationToHMI( - *(application.get()), resumption, need_restore_vr); + application, resumption, need_restore_vr); if (msg_params.keyExists(strings::app_hmi_type)) { GetPolicyHandler().SetDefaultHmiTypes(application->policy_app_id(), &(msg_params[strings::app_hmi_type])); @@ -866,9 +866,7 @@ void RegisterAppInterfaceRequest::SendChangeRegistrationOnHMI( } void RegisterAppInterfaceRequest::SendOnAppRegisteredNotificationToHMI( - const app_mngr::Application& application_impl, - bool resumption, - bool need_restore_vr) { + ApplicationConstSharedPtr app, bool resumption, bool need_restore_vr) { using namespace smart_objects; SmartObjectSPtr notification = std::make_shared(SmartType_Map); if (!notification) { @@ -892,15 +890,15 @@ void RegisterAppInterfaceRequest::SendOnAppRegisteredNotificationToHMI( msg_params[strings::resume_vr_grammars] = need_restore_vr; } - if (application_impl.vr_synonyms()) { - msg_params[strings::vr_synonyms] = *(application_impl.vr_synonyms()); + if (app->vr_synonyms()) { + msg_params[strings::vr_synonyms] = *(app->vr_synonyms()); } - if (application_impl.tts_name()) { - msg_params[strings::tts_name] = *(application_impl.tts_name()); + if (app->tts_name()) { + msg_params[strings::tts_name] = *(app->tts_name()); } - const std::string policy_app_id = application_impl.policy_app_id(); + const std::string policy_app_id = app->policy_app_id(); std::string priority; GetPolicyHandler().GetPriority(policy_app_id, &priority); @@ -910,100 +908,13 @@ void RegisterAppInterfaceRequest::SendOnAppRegisteredNotificationToHMI( msg_params[strings::msg_params] = SmartObject(SmartType_Map); smart_objects::SmartObject& application = msg_params[strings::application]; - application[strings::app_name] = application_impl.name(); - application[strings::app_id] = application_impl.app_id(); - application[hmi_response::policy_app_id] = policy_app_id; - if (file_system::FileExists(application_impl.app_icon_path())) { - application[strings::icon] = application_impl.app_icon_path(); - } - - const smart_objects::SmartObject* ngn_media_screen_name = - application_impl.ngn_media_screen_name(); - if (ngn_media_screen_name) { - application[strings::ngn_media_screen_app_name] = *ngn_media_screen_name; - } - - application[strings::hmi_display_language_desired] = - static_cast(application_impl.ui_language()); - - application[strings::is_media_application] = - application_impl.is_media_application(); - - const smart_objects::SmartObject* app_type = application_impl.app_types(); - if (app_type) { - application[strings::app_type] = *app_type; - } - - const policy::RequestType::State app_request_types_state = - GetPolicyHandler().GetAppRequestTypeState(policy_app_id); - if (policy::RequestType::State::AVAILABLE == app_request_types_state) { - const auto request_types = - GetPolicyHandler().GetAppRequestTypes(policy_app_id); - application[strings::request_type] = SmartObject(SmartType_Array); - smart_objects::SmartObject& request_types_array = - application[strings::request_type]; - - size_t index = 0; - for (auto it : request_types) { - request_types_array[index] = it; - ++index; - } - } else if (policy::RequestType::State::EMPTY == app_request_types_state) { - application[strings::request_type] = SmartObject(SmartType_Array); - } - - const policy::RequestSubType::State app_request_subtypes_state = - GetPolicyHandler().GetAppRequestSubTypeState(policy_app_id); - if (policy::RequestSubType::State::AVAILABLE == app_request_subtypes_state) { - const auto request_subtypes = - GetPolicyHandler().GetAppRequestSubTypes(policy_app_id); - application[strings::request_subtype] = SmartObject(SmartType_Array); - smart_objects::SmartObject& request_subtypes_array = - application[strings::request_subtype]; - - size_t index = 0; - for (auto it : request_subtypes) { - request_subtypes_array[index] = it; - ++index; - } - } else if (policy::RequestSubType::State::EMPTY == - app_request_subtypes_state) { - application[strings::request_subtype] = SmartObject(SmartType_Array); - } - const protocol_handler::SessionObserver& session_observer = application_manager_.connection_handler().get_session_observer(); - - application[strings::device_info] = SmartObject(SmartType_Map); - smart_objects::SmartObject& device_info = application[strings::device_info]; - MessageHelper::CreateDeviceInfo(application_impl.device(), - session_observer, - GetPolicyHandler(), - application_manager_, - &device_info); - - if (application_impl.secondary_device() != 0) { - application[strings::secondary_device_info] = SmartObject(SmartType_Map); - smart_objects::SmartObject& secondary_device_info = - application[strings::secondary_device_info]; - MessageHelper::CreateDeviceInfo(application_impl.secondary_device(), - session_observer, - GetPolicyHandler(), - application_manager_, - &secondary_device_info); - } - - const smart_objects::SmartObject* day_color_scheme = - application_impl.day_color_scheme(); - if (day_color_scheme) { - application[strings::day_color_scheme] = *day_color_scheme; - } - - const smart_objects::SmartObject* night_color_scheme = - application_impl.night_color_scheme(); - if (night_color_scheme) { - application[strings::night_color_scheme] = *night_color_scheme; - } + MessageHelper::CreateHMIApplicationStruct(app, + session_observer, + GetPolicyHandler(), + &application, + application_manager_); DCHECK(rpc_service_.ManageHMICommand(notification)); } diff --git a/src/components/application_manager/src/application_manager_impl.cc b/src/components/application_manager/src/application_manager_impl.cc index d48e850fa6..174e134ca8 100644 --- a/src/components/application_manager/src/application_manager_impl.cc +++ b/src/components/application_manager/src/application_manager_impl.cc @@ -887,6 +887,24 @@ void ApplicationManagerImpl::CreatePendingApplication( SendUpdateAppList(); } +hmi_apis::Common_CloudConnectionStatus::eType +ApplicationManagerImpl::GetCloudAppConnectionStatus( + ApplicationConstSharedPtr app) const { + transport_manager::ConnectionStatus status = + connection_handler().GetConnectionStatus(app->device()); + switch (status) { + case transport_manager::ConnectionStatus::CONNECTED: + return hmi_apis::Common_CloudConnectionStatus::CONNECTED; + case transport_manager::ConnectionStatus::RETRY: + return hmi_apis::Common_CloudConnectionStatus::RETRY; + case transport_manager::ConnectionStatus::PENDING: + case transport_manager::ConnectionStatus::CLOSING: + return hmi_apis::Common_CloudConnectionStatus::NOT_CONNECTED; + default: + return hmi_apis::Common_CloudConnectionStatus::INVALID_ENUM; + } +} + uint32_t ApplicationManagerImpl::GetNextHMICorrelationID() { if (corelation_id_ < max_corelation_id_) { corelation_id_++; diff --git a/src/components/application_manager/src/message_helper/message_helper.cc b/src/components/application_manager/src/message_helper/message_helper.cc index 2f86c50013..58d5171f84 100644 --- a/src/components/application_manager/src/message_helper/message_helper.cc +++ b/src/components/application_manager/src/message_helper/message_helper.cc @@ -1542,15 +1542,19 @@ bool MessageHelper::CreateHMIApplicationStruct( message = smart_objects::SmartObject(smart_objects::SmartType_Map); message[strings::app_name] = app->name(); message[strings::app_id] = app->hmi_app_id(); + + const std::string policy_app_id = app->policy_app_id(); + message[hmi_response::policy_app_id] = policy_app_id; + const std::string icon_path = app->app_icon_path(); - if (!icon_path.empty()) { + if (file_system::FileExists(app->app_icon_path())) { message[strings::icon] = icon_path; } if (app->IsRegistered()) { message[strings::hmi_display_language_desired] = app->ui_language(); message[strings::is_media_application] = app->is_media_application(); } else { - message[strings::greyOut] = app->is_greyed_out(); + message[strings::grey_out] = app->is_greyed_out(); } if (app->tts_name() && !app->tts_name()->empty()) { message[json::ttsName] = *(app->tts_name()); @@ -1566,6 +1570,46 @@ bool MessageHelper::CreateHMIApplicationStruct( message[strings::app_type] = *app_types; } + const policy::RequestType::State app_request_types_state = + policy_handler.GetAppRequestTypeState(policy_app_id); + if (policy::RequestType::State::AVAILABLE == app_request_types_state) { + const auto request_types = policy_handler.GetAppRequestTypes(policy_app_id); + message[strings::request_type] = + SmartObject(smart_objects::SmartType_Array); + smart_objects::SmartObject& request_types_array = + message[strings::request_type]; + + size_t index = 0; + for (auto it : request_types) { + request_types_array[index] = it; + ++index; + } + } else if (policy::RequestType::State::EMPTY == app_request_types_state) { + message[strings::request_type] = + SmartObject(smart_objects::SmartType_Array); + } + + const policy::RequestSubType::State app_request_subtypes_state = + policy_handler.GetAppRequestSubTypeState(policy_app_id); + if (policy::RequestSubType::State::AVAILABLE == app_request_subtypes_state) { + const auto request_subtypes = + policy_handler.GetAppRequestSubTypes(policy_app_id); + message[strings::request_subtype] = + SmartObject(smart_objects::SmartType_Array); + smart_objects::SmartObject& request_subtypes_array = + message[strings::request_subtype]; + + size_t index = 0; + for (auto it : request_subtypes) { + request_subtypes_array[index] = it; + ++index; + } + } else if (policy::RequestSubType::State::EMPTY == + app_request_subtypes_state) { + message[strings::request_subtype] = + SmartObject(smart_objects::SmartType_Array); + } + if (day_color_scheme) { message[strings::day_color_scheme] = *day_color_scheme; } @@ -1592,6 +1636,12 @@ bool MessageHelper::CreateHMIApplicationStruct( &secondary_device_info); } + message[strings::is_cloud_application] = app->is_cloud_app(); + if (app->is_cloud_app()) { + message[strings::cloud_connection_status] = + app_mngr.GetCloudAppConnectionStatus(app); + } + return true; } diff --git a/src/components/application_manager/src/smart_object_keys.cc b/src/components/application_manager/src/smart_object_keys.cc index 3e2951c553..70581466eb 100644 --- a/src/components/application_manager/src/smart_object_keys.cc +++ b/src/components/application_manager/src/smart_object_keys.cc @@ -43,7 +43,7 @@ const char* ngn_media_screen_app_name = "ngnMediaScreenAppName"; const char* vr_synonyms = "vrSynonyms"; const char* uses_vehicle_data = "usesVehicleData"; const char* is_media_application = "isMediaApplication"; -const char* greyOut = "greyOut"; +const char* grey_out = "greyOut"; const char* language_desired = "languageDesired"; const char* auto_activated_id = "autoActivateID"; const char* app_type = "appType"; @@ -159,6 +159,8 @@ const char* enabled = "enabled"; const char* cloud_app_auth_token = "cloudAppAuthToken"; const char* cloud_transport_type = "cloudTransportType"; const char* hybrid_app_preference = "hybridAppPreference"; +const char* is_cloud_application = "isCloudApplication"; +const char* cloud_connection_status = "cloudConnectionStatus"; // PutFile const char* sync_file_name = "syncFileName"; diff --git a/src/components/connection_handler/include/connection_handler/connection_handler_impl.h b/src/components/connection_handler/include/connection_handler/connection_handler_impl.h index 7be94c5f70..4d4e31f999 100644 --- a/src/components/connection_handler/include/connection_handler/connection_handler_impl.h +++ b/src/components/connection_handler/include/connection_handler/connection_handler_impl.h @@ -106,6 +106,9 @@ class ConnectionHandlerImpl */ void ConnectToDevice(connection_handler::DeviceHandle device_handle) OVERRIDE; + transport_manager::ConnectionStatus GetConnectionStatus( + const DeviceHandle& device_handle) const OVERRIDE; + /** * @brief RunAppOnDevice allows to run specific application on the certain *device. diff --git a/src/components/connection_handler/src/connection_handler_impl.cc b/src/components/connection_handler/src/connection_handler_impl.cc index 318224fcc7..77eb38b8bc 100644 --- a/src/components/connection_handler/src/connection_handler_impl.cc +++ b/src/components/connection_handler/src/connection_handler_impl.cc @@ -1294,6 +1294,11 @@ void ConnectionHandlerImpl::ConnectToDevice( } } +transport_manager::ConnectionStatus ConnectionHandlerImpl::GetConnectionStatus( + const DeviceHandle& device_handle) const { + return transport_manager_.GetConnectionStatus(device_handle); +} + void ConnectionHandlerImpl::RunAppOnDevice(const std::string& device_mac, const std::string& bundle_id) const { for (DeviceMap::const_iterator i = device_list_.begin(); diff --git a/src/components/include/application_manager/application_manager.h b/src/components/include/application_manager/application_manager.h index e6e5c89f45..e1907e25f0 100644 --- a/src/components/include/application_manager/application_manager.h +++ b/src/components/include/application_manager/application_manager.h @@ -427,6 +427,9 @@ class ApplicationManager { virtual void OnHMIStartedCooperation() = 0; + virtual hmi_apis::Common_CloudConnectionStatus::eType + GetCloudAppConnectionStatus(ApplicationConstSharedPtr app) const = 0; + virtual bool IsHMICooperating() const = 0; /** * @brief Notifies all components interested in Vehicle Data update diff --git a/src/components/include/connection_handler/connection_handler.h b/src/components/include/connection_handler/connection_handler.h index 93939fc782..6d1e9e7c97 100644 --- a/src/components/include/connection_handler/connection_handler.h +++ b/src/components/include/connection_handler/connection_handler.h @@ -79,6 +79,9 @@ class ConnectionHandler { virtual void ConnectToDevice( connection_handler::DeviceHandle device_handle) = 0; + virtual transport_manager::ConnectionStatus GetConnectionStatus( + const DeviceHandle& device_handle) const = 0; + /** * @brief RunAppOnDevice allows to run specific application on the certain *device. diff --git a/src/components/include/test/application_manager/mock_application_manager.h b/src/components/include/test/application_manager/mock_application_manager.h index 7f5f17a93d..e18d68cfba 100644 --- a/src/components/include/test/application_manager/mock_application_manager.h +++ b/src/components/include/test/application_manager/mock_application_manager.h @@ -166,6 +166,9 @@ class MockApplicationManager : public application_manager::ApplicationManager { MOCK_METHOD1(EndAudioPassThru, bool(uint32_t app_id)); MOCK_METHOD1(ConnectToDevice, void(const std::string& device_mac)); MOCK_METHOD0(OnHMIStartedCooperation, void()); + MOCK_CONST_METHOD1(GetCloudAppConnectionStatus, + hmi_apis::Common_CloudConnectionStatus::eType( + ApplicationConstSharedPtr app)); MOCK_CONST_METHOD0(IsHMICooperating, bool()); MOCK_METHOD2(IviInfoUpdated, void(mobile_apis::VehicleDataType::eType vehicle_info, diff --git a/src/components/include/test/connection_handler/mock_connection_handler.h b/src/components/include/test/connection_handler/mock_connection_handler.h index 2de3a0f9a7..c8d977b61c 100644 --- a/src/components/include/test/connection_handler/mock_connection_handler.h +++ b/src/components/include/test/connection_handler/mock_connection_handler.h @@ -60,6 +60,8 @@ class MockConnectionHandler : public connection_handler::ConnectionHandler { MOCK_METHOD0(StartTransportManager, void()); MOCK_METHOD1(ConnectToDevice, void(connection_handler::DeviceHandle device_handle)); + MOCK_CONST_METHOD1(GetConnectionStatus, + ConnectionStatus(const DeviceHandle& device_handle)); MOCK_CONST_METHOD2(RunAppOnDevice, void(const std::string&, const std::string&)); MOCK_METHOD0(ConnectToAllDevices, void()); diff --git a/src/components/include/test/transport_manager/mock_transport_manager.h b/src/components/include/test/transport_manager/mock_transport_manager.h index cc8bd5ab85..657aa08fb5 100644 --- a/src/components/include/test/transport_manager/mock_transport_manager.h +++ b/src/components/include/test/transport_manager/mock_transport_manager.h @@ -60,6 +60,8 @@ class MockTransportManager : public ::transport_manager::TransportManager, MOCK_METHOD0(Reinit, int()); MOCK_METHOD0(SearchDevices, int()); MOCK_METHOD1(ConnectDevice, int(const DeviceHandle)); + MOCK_CONST_METHOD1(GetConnectionStatus, + ConnectionStatus(const DeviceHandle& device_handle)); MOCK_METHOD1(DisconnectDevice, int(const DeviceHandle)); MOCK_METHOD1(Disconnect, int(const ConnectionUID)); MOCK_METHOD1(DisconnectForce, int(const ConnectionUID)); diff --git a/src/components/include/test/transport_manager/transport_adapter/mock_transport_adapter.h b/src/components/include/test/transport_manager/transport_adapter/mock_transport_adapter.h index eff0abdcd3..42ccd18e38 100644 --- a/src/components/include/test/transport_manager/transport_adapter/mock_transport_adapter.h +++ b/src/components/include/test/transport_manager/transport_adapter/mock_transport_adapter.h @@ -66,6 +66,8 @@ class MockTransportAdapter MOCK_METHOD1(ConnectDevice, ::transport_manager::transport_adapter::TransportAdapter::Error( const ::transport_manager::DeviceUID& device_handle)); + MOCK_CONST_METHOD1(GetConnectionStatus, + ConnectionStatus(const DeviceUID& device_handle)); MOCK_METHOD2(RunAppOnDevice, void(const std::string&, const std::string&)); MOCK_CONST_METHOD0(IsClientOriginatedConnectSupported, bool()); MOCK_METHOD0( diff --git a/src/components/include/transport_manager/common.h b/src/components/include/transport_manager/common.h index 58bcf6bb17..b36dcde67e 100644 --- a/src/components/include/transport_manager/common.h +++ b/src/components/include/transport_manager/common.h @@ -56,6 +56,8 @@ enum { E_INTERNAL_ERROR }; +enum ConnectionStatus { INVALID = -1, PENDING, RETRY, CONNECTED, CLOSING }; + /** * @brief Type definition for variable that hold handle of device. */ diff --git a/src/components/include/transport_manager/transport_adapter/device.h b/src/components/include/transport_manager/transport_adapter/device.h index 1ac1424477..448df9668a 100644 --- a/src/components/include/transport_manager/transport_adapter/device.h +++ b/src/components/include/transport_manager/transport_adapter/device.h @@ -131,6 +131,26 @@ class Device { keep_on_disconnect_ = keep_on_disconnect; } + inline ConnectionStatus connection_status() const { + return status_; + } + + inline void set_connection_status(ConnectionStatus status) { + status_ = status; + } + + inline uint16_t retry_count() const { + return retry_count_; + } + + inline void next_retry() { + retry_count_++; + } + + inline void reset_retry_count() { + retry_count_ = 0; + } + /** * @brief transport_switch_id Returns id used for transport switching * flow of device. Filled if applicable, otherwise - empty. @@ -160,6 +180,10 @@ class Device { *finished. **/ bool keep_on_disconnect_; + + ConnectionStatus status_; + + uint16_t retry_count_; }; typedef std::shared_ptr DeviceSptr; typedef std::vector DeviceVector; diff --git a/src/components/include/transport_manager/transport_adapter/transport_adapter.h b/src/components/include/transport_manager/transport_adapter/transport_adapter.h index 4aa6e901ad..c136148936 100644 --- a/src/components/include/transport_manager/transport_adapter/transport_adapter.h +++ b/src/components/include/transport_manager/transport_adapter/transport_adapter.h @@ -217,6 +217,9 @@ class TransportAdapter { */ virtual Error ConnectDevice(const DeviceUID& device_handle) = 0; + virtual ConnectionStatus GetConnectionStatus( + const DeviceUID& device_handle) const = 0; + /** * @brief RunAppOnDevice allows to run specific application on the certain *device. diff --git a/src/components/include/transport_manager/transport_manager.h b/src/components/include/transport_manager/transport_manager.h index b5dfa3671b..8fee6db6a5 100644 --- a/src/components/include/transport_manager/transport_manager.h +++ b/src/components/include/transport_manager/transport_manager.h @@ -87,6 +87,9 @@ class TransportManager { **/ virtual int ConnectDevice(const DeviceHandle device_id) = 0; + virtual ConnectionStatus GetConnectionStatus( + const DeviceHandle& device_handle) const = 0; + /** * @brief Disconnect from all applications connected on device. * diff --git a/src/components/interfaces/HMI_API.xml b/src/components/interfaces/HMI_API.xml index a11cfbfd8a..7adb5fb51e 100644 --- a/src/components/interfaces/HMI_API.xml +++ b/src/components/interfaces/HMI_API.xml @@ -292,6 +292,18 @@ + + + No active websocket session or ongoing connection attempts + + + Websocket is active + + + Websocket connection failed and retry attempts are ongoing + + + Describes what kind of waypoint is requested/provided. @@ -2620,16 +2632,18 @@ If SDL omits this parameter - none RequestType is allowed for this app (either this is a pre-registered app or such is dictated by policies). - - - The list of SystemRequest's requestSubTypes allowed by policies for the named application. - If the app sends a requestSubType which is not specified in this list, then that request should be rejected. - An empty array signifies that any value of requestSubType is allowed for this app. - If this parameter is omitted, then a request with any value of requestSubType is now allowed for this app - + + + The list of SystemRequest's requestSubTypes allowed by policies for the named application. + If the app sends a requestSubType which is not specified in this list, then that request should be rejected. + An empty array signifies that any value of requestSubType is allowed for this app. + If this parameter is omitted, then a request with any value of requestSubType is now allowed for this app + + + diff --git a/src/components/transport_manager/include/transport_manager/transport_adapter/transport_adapter_impl.h b/src/components/transport_manager/include/transport_manager/transport_adapter/transport_adapter_impl.h index 13706b5cfc..e06537677a 100644 --- a/src/components/transport_manager/include/transport_manager/transport_adapter/transport_adapter_impl.h +++ b/src/components/transport_manager/include/transport_manager/transport_adapter/transport_adapter_impl.h @@ -149,6 +149,9 @@ class TransportAdapterImpl : public TransportAdapter, TransportAdapter::Error ConnectDevice( const DeviceUID& device_handle) OVERRIDE; + ConnectionStatus GetConnectionStatus( + const DeviceUID& device_handle) const OVERRIDE; + /** * @brief Disconnect from specified session. * @@ -583,8 +586,7 @@ class TransportAdapterImpl : public TransportAdapter, ConnectionSPtr connection; DeviceUID device_id; ApplicationHandle app_handle; - uint16_t retry_count; - enum { NEW, ESTABLISHED, FINALISING, PENDING, RETRY } state; + enum { NEW, ESTABLISHED, FINALISING, PENDING } state; }; /** @@ -613,8 +615,7 @@ class TransportAdapterImpl : public TransportAdapter, **/ ConnectionMap connections_; - std::queue > > - retry_timer_pool_; + std::queue > retry_timer_pool_; /** * @brief Mutex restricting access to connections map. diff --git a/src/components/transport_manager/include/transport_manager/transport_manager_impl.h b/src/components/transport_manager/include/transport_manager/transport_manager_impl.h index 0facbb57e7..69f38304a7 100644 --- a/src/components/transport_manager/include/transport_manager/transport_manager_impl.h +++ b/src/components/transport_manager/include/transport_manager/transport_manager_impl.h @@ -151,6 +151,9 @@ class TransportManagerImpl **/ int ConnectDevice(const DeviceHandle device_id) OVERRIDE; + ConnectionStatus GetConnectionStatus( + const DeviceHandle& device_handle) const OVERRIDE; + /** * @brief Disconnect from all applications connected on device. * @@ -367,7 +370,7 @@ class TransportManagerImpl * @brief Converter variable (Device ID -> Device Handle; Device Handle -> * Device ID) */ - Handle2GUIDConverter converter_; + mutable Handle2GUIDConverter converter_; #ifdef BUILD_TESTS public: @@ -382,7 +385,7 @@ class TransportManagerImpl int connection_id_counter_; sync_primitives::RWLock connections_lock_; std::vector connections_; - sync_primitives::RWLock device_to_adapter_map_lock_; + mutable sync_primitives::RWLock device_to_adapter_map_lock_; typedef std::map DeviceToAdapterMap; DeviceToAdapterMap device_to_adapter_map_; std::vector transport_adapters_; diff --git a/src/components/transport_manager/src/cloud/cloud_websocket_transport_adapter.cc b/src/components/transport_manager/src/cloud/cloud_websocket_transport_adapter.cc index 23cee31002..2ec2e5d1a0 100644 --- a/src/components/transport_manager/src/cloud/cloud_websocket_transport_adapter.cc +++ b/src/components/transport_manager/src/cloud/cloud_websocket_transport_adapter.cc @@ -119,4 +119,4 @@ void CloudWebsocketTransportAdapter::CreateDevice(const std::string& uid) { return; } } -} \ No newline at end of file +} diff --git a/src/components/transport_manager/src/transport_adapter/transport_adapter_impl.cc b/src/components/transport_manager/src/transport_adapter/transport_adapter_impl.cc index 1f58eb5f77..b73f3140d3 100644 --- a/src/components/transport_manager/src/transport_adapter/transport_adapter_impl.cc +++ b/src/components/transport_manager/src/transport_adapter/transport_adapter_impl.cc @@ -220,9 +220,9 @@ TransportAdapter::Error TransportAdapterImpl::Connect( info.device_id = device_id; info.state = ConnectionInfo::NEW; } - const bool pending_app = ConnectionInfo::PENDING == info.state || - ConnectionInfo::RETRY == info.state; + const bool pending_app = ConnectionInfo::PENDING == info.state; connections_lock_.Release(); + if (already_exists && !pending_app) { LOG4CXX_TRACE(logger_, "exit with ALREADY_EXISTS"); return ALREADY_EXISTS; @@ -230,26 +230,7 @@ TransportAdapter::Error TransportAdapterImpl::Connect( const TransportAdapter::Error err = server_connection_factory_->CreateConnection(device_id, app_handle); - if (pending_app && TransportAdapter::FAIL == err) { - connections_lock_.AcquireForWriting(); - if (ConnectionInfo::PENDING == info.state) { - info.state = ConnectionInfo::RETRY; - info.retry_count = 0; - } - if (info.retry_count++ > get_settings().cloud_app_max_retry_attempts()) { - info.state = ConnectionInfo::PENDING; - info.retry_count = 0; - return err; - } - TimerSPtr retry_timer(std::make_shared( - "RetryConnectionTimer", - new timer::TimerTaskImpl( - this, &TransportAdapterImpl::RetryConnection))); - retry_timer_pool_.push(std::make_pair(retry_timer, connection_key)); - retry_timer->Start(get_settings().cloud_app_retry_timeout(), - timer::kSingleShot); - connections_lock_.Release(); - } else if (TransportAdapter::OK != err) { + if (TransportAdapter::OK != err) { connections_lock_.AcquireForWriting(); connections_.erase(std::make_pair(device_id, app_handle)); connections_lock_.Release(); @@ -264,11 +245,9 @@ void TransportAdapterImpl::RetryConnection() { "Unable to find timer, ignoring RetryConnection request"); return; } - auto connection_key = retry_timer_pool_.front().second; + const DeviceUID device_id = retry_timer_pool_.front().second; retry_timer_pool_.pop(); - const DeviceUID device_id = connection_key.first; - const ApplicationHandle app_handle = connection_key.second; - Connect(device_id, app_handle); + ConnectDevice(device_id); } TransportAdapter::Error TransportAdapterImpl::ConnectDevice( @@ -277,6 +256,32 @@ TransportAdapter::Error TransportAdapterImpl::ConnectDevice( DeviceSptr device = FindDevice(device_handle); if (device) { TransportAdapter::Error err = ConnectDevice(device); + if (FAIL == err && GetDeviceType() == DeviceType::CLOUD_WEBSOCKET) { + LOG4CXX_TRACE(logger_, + "Error occurred while connecting cloud app: " << err); + if (device->connection_status() == ConnectionStatus::PENDING) { + device->set_connection_status(ConnectionStatus::RETRY); + device->reset_retry_count(); + } + + if (device->retry_count() > + get_settings().cloud_app_max_retry_attempts()) { + device->set_connection_status(ConnectionStatus::PENDING); + device->reset_retry_count(); + return err; + } + + device->next_retry(); + TimerSPtr retry_timer(std::make_shared( + "RetryConnectionTimer", + new timer::TimerTaskImpl( + this, &TransportAdapterImpl::RetryConnection))); + retry_timer_pool_.push(std::make_pair(retry_timer, device_handle)); + retry_timer->Start(get_settings().cloud_app_retry_timeout(), + timer::kSingleShot); + } else if (OK == err) { + device->set_connection_status(ConnectionStatus::CONNECTED); + } LOG4CXX_TRACE(logger_, "exit with error: " << err); return err; } else { @@ -285,6 +290,13 @@ TransportAdapter::Error TransportAdapterImpl::ConnectDevice( } } +ConnectionStatus TransportAdapterImpl::GetConnectionStatus( + const DeviceUID& device_handle) const { + DeviceSptr device = FindDevice(device_handle); + return device.use_count() == 0 ? ConnectionStatus::INVALID + : device->connection_status(); +} + TransportAdapter::Error TransportAdapterImpl::Disconnect( const DeviceUID& device_id, const ApplicationHandle& app_handle) { LOG4CXX_TRACE(logger_, @@ -314,6 +326,8 @@ TransportAdapter::Error TransportAdapterImpl::DisconnectDevice( } Error error = OK; + DeviceSptr device = FindDevice(device_id); + device->set_connection_status(ConnectionStatus::CLOSING); std::vector to_disconnect; connections_lock_.AcquireForReading(); @@ -433,6 +447,7 @@ DeviceSptr TransportAdapterImpl::AddDevice(DeviceSptr device) { LOG4CXX_TRACE(logger_, "exit with TRUE. Condition: same_device_found"); return existing_device; } else { + device->set_connection_status(ConnectionStatus::PENDING); for (TransportAdapterListenerList::iterator it = listeners_.begin(); it != listeners_.end(); ++it) { diff --git a/src/components/transport_manager/src/transport_manager_impl.cc b/src/components/transport_manager/src/transport_manager_impl.cc index 300ed27718..1c5a6dae32 100644 --- a/src/components/transport_manager/src/transport_manager_impl.cc +++ b/src/components/transport_manager/src/transport_manager_impl.cc @@ -177,6 +177,22 @@ int TransportManagerImpl::ConnectDevice(const DeviceHandle device_handle) { return err; } +ConnectionStatus TransportManagerImpl::GetConnectionStatus( + const DeviceHandle& device_handle) const { + DeviceUID device_id = converter_.HandleToUid(device_handle); + + sync_primitives::AutoReadLock lock(device_to_adapter_map_lock_); + DeviceToAdapterMap::const_iterator it = + device_to_adapter_map_.find(device_id); + if (it == device_to_adapter_map_.end()) { + LOG4CXX_ERROR(logger_, "No device adapter found by id " << device_handle); + LOG4CXX_TRACE(logger_, "exit with E_INVALID_HANDLE. Condition: NULL == ta"); + return ConnectionStatus::INVALID; + } + transport_adapter::TransportAdapter* ta = it->second; + return ta->GetConnectionStatus(device_id); +} + int TransportManagerImpl::DisconnectDevice(const DeviceHandle device_handle) { LOG4CXX_TRACE(logger_, "enter. DeviceHandle: " << &device_handle); if (!this->is_initialized_) { -- cgit v1.2.1 From 2af82c8d6f0cfc2b8907d28a2e6453d0506fdb64 Mon Sep 17 00:00:00 2001 From: ShobhitAd Date: Fri, 16 Nov 2018 16:35:50 -0500 Subject: Removed redundant smart object --- .../mobile/set_cloudapp_properties_request.cc | 37 ++-------------------- 1 file changed, 2 insertions(+), 35 deletions(-) diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/set_cloudapp_properties_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/set_cloudapp_properties_request.cc index ca5a46e3dc..d92f458587 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/set_cloudapp_properties_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/set_cloudapp_properties_request.cc @@ -18,6 +18,7 @@ SetCloudAppPropertiesRequest::SetCloudAppPropertiesRequest( policy_handler) {} SetCloudAppPropertiesRequest::~SetCloudAppPropertiesRequest() {} + void SetCloudAppPropertiesRequest::Run() { LOG4CXX_AUTO_TRACE(logger_); ApplicationSharedPtr app = application_manager_.application(connection_key()); @@ -34,41 +35,7 @@ void SetCloudAppPropertiesRequest::Run() { return; } - smart_objects::SmartObject cloud_app_properties(smart_objects::SmartType_Map); - - cloud_app_properties[strings::msg_params][strings::app_name] = - (*message_)[strings::msg_params][strings::app_name]; - cloud_app_properties[strings::msg_params][strings::app_id] = - (*message_)[strings::msg_params][strings::app_id]; - - if ((*message_)[strings::msg_params].keyExists(strings::enabled)) { - smart_objects::SmartObject enabled = - (*message_)[strings::msg_params][strings::enabled]; - cloud_app_properties[strings::msg_params][strings::enabled] = enabled; - } - if ((*message_)[strings::msg_params].keyExists( - strings::cloud_app_auth_token)) { - smart_objects::SmartObject auth_token = - (*message_)[strings::msg_params][strings::cloud_app_auth_token]; - cloud_app_properties[strings::msg_params][strings::cloud_app_auth_token] = - auth_token; - } - if ((*message_)[strings::msg_params].keyExists( - strings::cloud_transport_type)) { - smart_objects::SmartObject transport_type = - (*message_)[strings::msg_params][strings::cloud_transport_type]; - cloud_app_properties[strings::msg_params][strings::cloud_transport_type] = - transport_type; - } - if ((*message_)[strings::msg_params].keyExists( - strings::hybrid_app_preference)) { - smart_objects::SmartObject hybrid_app_preference = - (*message_)[strings::msg_params][strings::hybrid_app_preference]; - cloud_app_properties[strings::msg_params][strings::hybrid_app_preference] = - hybrid_app_preference; - } - - policy_handler_.OnSetCloudAppProperties(cloud_app_properties); + policy_handler_.OnSetCloudAppProperties(*message_); SendResponse(true, mobile_apis::Result::SUCCESS); } -- cgit v1.2.1 From 1d1d4325b5ded10c53bfc314acd9b65d0d336d10 Mon Sep 17 00:00:00 2001 From: ShobhitAd Date: Tue, 20 Nov 2018 11:08:49 -0500 Subject: Style fix in MOBILE_API --- src/components/interfaces/MOBILE_API.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/components/interfaces/MOBILE_API.xml b/src/components/interfaces/MOBILE_API.xml index 1707f65bad..714399bce6 100644 --- a/src/components/interfaces/MOBILE_API.xml +++ b/src/components/interfaces/MOBILE_API.xml @@ -547,9 +547,9 @@ Enumeration for the user's preference of which app type to use when both are available - - - + + + -- cgit v1.2.1 From 0eb0f386f0cc43a1497b569d27415d775ea40ab5 Mon Sep 17 00:00:00 2001 From: ShobhitAd Date: Tue, 13 Nov 2018 10:10:53 -0500 Subject: Implement new RPC in MOBILE_API --- src/components/interfaces/MOBILE_API.xml | 53 ++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/src/components/interfaces/MOBILE_API.xml b/src/components/interfaces/MOBILE_API.xml index 6ed42c3588..1707f65bad 100644 --- a/src/components/interfaces/MOBILE_API.xml +++ b/src/components/interfaces/MOBILE_API.xml @@ -545,6 +545,13 @@ + + Enumeration for the user's preference of which app type to use when both are available + + + + + Defines the hard (physical) and soft (touchscreen) buttons available from the module @@ -2609,6 +2616,7 @@ + -- cgit v1.2.1 From 1669b8e19869bbdcee2702a13c9e04ff94e649b5 Mon Sep 17 00:00:00 2001 From: ShobhitAd Date: Tue, 13 Nov 2018 10:36:42 -0500 Subject: Implement SetCloudAppProperties RPC in core --- .../mobile/set_cloudapp_properties_request.h | 28 +++++++++ .../mobile/set_cloudapp_properties_response.h | 28 +++++++++ .../mobile/set_cloudapp_properties_request.cc | 71 ++++++++++++++++++++++ .../mobile/set_cloudapp_properties_response.cc | 32 ++++++++++ .../sdl_rpc_plugin/src/mobile_command_factory.cc | 7 +++ 5 files changed, 166 insertions(+) create mode 100644 src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/set_cloudapp_properties_request.h create mode 100644 src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/set_cloudapp_properties_response.h create mode 100644 src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/set_cloudapp_properties_request.cc create mode 100644 src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/set_cloudapp_properties_response.cc diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/set_cloudapp_properties_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/set_cloudapp_properties_request.h new file mode 100644 index 0000000000..fc131020a8 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/set_cloudapp_properties_request.h @@ -0,0 +1,28 @@ +#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_SET_CLOUDAPP_PROPERTIES_REQUEST_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_SET_CLOUDAPP_PROPERTIES_REQUEST_H_ + +#include "application_manager/commands/command_request_impl.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands{ + +class SetCloudAppPropertiesRequest : public app_mngr::commands::CommandRequestImpl{ +public: + SetCloudAppPropertiesRequest(const app_mngr::commands::MessageSharedPtr& message, + app_mngr::ApplicationManager& application_manager, + app_mngr::rpc_service::RPCService& rpc_service, + app_mngr::HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handler); + virtual ~SetCloudAppPropertiesRequest(); + virtual void Run(); + virtual void on_event(const app_mngr::event_engine::Event& event); + private: + DISALLOW_COPY_AND_ASSIGN(SetCloudAppPropertiesRequest); +}; // SetCloudAppPropertiesRequest + +} // namespace commands +} // namespace sdl_rpc_plugin + +#endif //SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_SET_CLOUDAPP_PROPERTIES_REQUEST_H_ \ No newline at end of file diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/set_cloudapp_properties_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/set_cloudapp_properties_response.h new file mode 100644 index 0000000000..aae45c52ce --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/set_cloudapp_properties_response.h @@ -0,0 +1,28 @@ +#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_SET_CLOUDAPP_PROPERTIES_RESPONSE_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_SET_CLOUDAPP_PROPERTIES_RESPONSE_H_ + +#include "application_manager/commands/command_response_impl.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +class SetCloudAppPropertiesResponse : public app_mngr::commands::CommandResponseImpl{ +public: + SetCloudAppPropertiesResponse(const app_mngr::commands::MessageSharedPtr& message, + app_mngr::ApplicationManager& application_manager, + app_mngr::rpc_service::RPCService& rpc_service, + app_mngr::HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handler); + virtual ~SetCloudAppPropertiesResponse(); + virtual void Run(); + private: + DISALLOW_COPY_AND_ASSIGN(SetCloudAppPropertiesResponse); + +}; //SetCloudAppPropertiesResponse + +} // namespace commands +} // namespace sdl_rpc_plugin + +#endif //SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_SET_CLOUDAPP_PROPERTIES_RESPONSE_H_ \ No newline at end of file diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/set_cloudapp_properties_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/set_cloudapp_properties_request.cc new file mode 100644 index 0000000000..b5c66e4400 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/set_cloudapp_properties_request.cc @@ -0,0 +1,71 @@ +#include "sdl_rpc_plugin/commands/mobile/set_cloudapp_properties_request.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + + SetCloudAppPropertiesRequest::SetCloudAppPropertiesRequest(const app_mngr::commands::MessageSharedPtr& message, + app_mngr::ApplicationManager& application_manager, + app_mngr::rpc_service::RPCService& rpc_service, + app_mngr::HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handler) + : CommandRequestImpl(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handler){} + + SetCloudAppPropertiesRequest::~SetCloudAppPropertiesRequest(){} + void SetCloudAppPropertiesRequest::Run(){ + LOG4CXX_AUTO_TRACE(logger_); + ApplicationSharedPtr app = application_manager_.application(connection_key()); + + if (!app) { + LOG4CXX_ERROR(logger_, "Application is not registered"); + SendResponse(false, mobile_apis::Result::APPLICATION_NOT_REGISTERED); + return; + } + + if ((*message_)[strings::msg_params].empty()) { + LOG4CXX_ERROR(logger_, strings::msg_params << " is empty."); + SendResponse(false, mobile_apis::Result::INVALID_DATA); + return; + } + + smart_objects::SmartObject cloudapp_properties(smart_objects::SmartType_Map); + + cloudapp_properties[strings::msg_params][strings::app_name] = (*message_)[strings::msg_params][strings::app_name]; + cloudapp_properties[strings::msg_params][strings::app_id] = (*message_)[strings::msg_params][strings::app_id]; + + if ((*message_)[strings::msg_params].keyExists(strings::enabled)) { + smart_objects::SmartObject enabled = (*message_)[strings::msg_params][strings::enabled]; + cloudapp_properties[strings::msg_params][strings::enabled] = enabled; + } + if ((*message_)[strings::msg_params].keyExists(strings::cloud_app_auth_token)) { + smart_objects::SmartObject auth_token = (*message_)[strings::msg_params][strings::cloud_app_auth_token]; + cloudapp_properties[strings::msg_params][strings::cloud_app_auth_token] = auth_token; + } + if ((*message_)[strings::msg_params].keyExists(strings::cloud_transport_type)) { + smart_objects::SmartObject transport_type = (*message_)[strings::msg_params][strings::cloud_transport_type]; + cloudapp_properties[strings::msg_params][strings::cloud_transport_type] = transport_type; + } + if ((*message_)[strings::msg_params].keyExists(strings::hybrid_app_preference)) { + smart_objects::SmartObject hybrid_app_preference = (*message_)[strings::msg_params][strings::hybrid_app_preference]; + cloudapp_properties[strings::msg_params][strings::hybrid_app_preference] = hybrid_app_preference; + } + + policy_handler_.OnSetCloudAppProperties(cloudapp_properties); + SendResponse(true, mobile_apis::Result::SUCCESS); + + + } + + + void SetCloudAppPropertiesRequest::on_event(const app_mngr::event_engine::Event& event){ + LOG4CXX_INFO(logger_, "SetCloudAppPropertiesRequest on_event"); + } + + +} // namespace commands +} // namespace sdl_rpc_plugin \ No newline at end of file diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/set_cloudapp_properties_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/set_cloudapp_properties_response.cc new file mode 100644 index 0000000000..b113f84131 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/set_cloudapp_properties_response.cc @@ -0,0 +1,32 @@ +#include "application_manager/application_manager.h" +#include "application_manager/rpc_service.h" +#include "sdl_rpc_plugin/commands/mobile/set_cloudapp_properties_response.h" + + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + + SetCloudAppPropertiesResponse::SetCloudAppPropertiesResponse(const app_mngr::commands::MessageSharedPtr& message, + app_mngr::ApplicationManager& application_manager, + app_mngr::rpc_service::RPCService& rpc_service, + app_mngr::HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handler) + : CommandResponseImpl(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handler){} + + + SetCloudAppPropertiesResponse::~SetCloudAppPropertiesResponse(){} + + void SetCloudAppPropertiesResponse::Run(){ + LOG4CXX_AUTO_TRACE(logger_); + + rpc_service_.SendMessageToMobile(message_); + } + +} // namespace commands +} //namespace sdl_rpc_plugins diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/mobile_command_factory.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/mobile_command_factory.cc index 5207c7e432..a5b3bf71fe 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/mobile_command_factory.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/mobile_command_factory.cc @@ -124,6 +124,8 @@ #include "sdl_rpc_plugin/commands/mobile/dial_number_response.h" #include "sdl_rpc_plugin/commands/mobile/send_haptic_data_request.h" #include "sdl_rpc_plugin/commands/mobile/send_haptic_data_response.h" +#include "sdl_rpc_plugin/commands/mobile/set_cloudapp_properties_request.h" +#include "sdl_rpc_plugin/commands/mobile/set_cloudapp_properties_response.h" #include "interfaces/MOBILE_API.h" CREATE_LOGGERPTR_GLOBAL(logger_, "ApplicationManager") @@ -337,6 +339,11 @@ CommandCreator& MobileCommandFactory::get_creator_factory( ? factory.GetCreator() : factory.GetCreator(); } + case mobile_apis::FunctionID::SetCloudAppPropertiesID: { + return mobile_api::messageType::request == message_type + ? factory.GetCreator() + : factory.GetCreator(); + } case mobile_apis::FunctionID::OnButtonEventID: { return factory.GetCreator(); } -- cgit v1.2.1 From 5d16aa31477d0835da6bcd3668f53ae0bd0d1439 Mon Sep 17 00:00:00 2001 From: ShobhitAd Date: Tue, 13 Nov 2018 11:08:06 -0500 Subject: Implement RPC in regular and external policies --- src/appMain/sdl_preloaded_pt.json | 41 ++++++++++++++++++++++ .../include/policy/policy_table/enums.h | 5 +++ .../policy_external/src/policy_table/enums.cc | 5 +++ .../include/policy/policy_table/enums.h | 5 +++ .../policy_regular/src/policy_table/enums.cc | 8 +++++ 5 files changed, 64 insertions(+) diff --git a/src/appMain/sdl_preloaded_pt.json b/src/appMain/sdl_preloaded_pt.json index 8a75cd3dab..3c84fc96bd 100644 --- a/src/appMain/sdl_preloaded_pt.json +++ b/src/appMain/sdl_preloaded_pt.json @@ -533,6 +533,47 @@ } } }, + "CloudApp":{ + "rpcs":{ + "SetCloudAppProperties":{ + "hmi_levels":["BACKGROUND", + "FULL", + "LIMITED"] + }, + "GetVehicleData": { + "hmi_levels": ["BACKGROUND", + "FULL", + "LIMITED"], + "parameters": [ + "cloudAppVehicleID" + ] + }, + "OnVehicleData": { + "hmi_levels": ["BACKGROUND", + "FULL", + "LIMITED"], + "parameters": [ + "cloudAppVehicleID" + ] + }, + "SubscribeVehicleData": { + "hmi_levels": ["BACKGROUND", + "FULL", + "LIMITED"], + "parameters": [ + "cloudAppVehicleID" + ] + }, + "UnsubscribeVehicleData": { + "hmi_levels": ["BACKGROUND", + "FULL", + "LIMITED"], + "parameters": [ + "cloudAppVehicleID" + ] + } + } + }, "RemoteControl": { "rpcs": { "ButtonPress": { diff --git a/src/components/policy/policy_external/include/policy/policy_table/enums.h b/src/components/policy/policy_external/include/policy/policy_table/enums.h index dc2fdab2fa..982118a43a 100644 --- a/src/components/policy/policy_external/include/policy/policy_table/enums.h +++ b/src/components/policy/policy_external/include/policy/policy_table/enums.h @@ -440,6 +440,11 @@ enum FunctionID { */ SendHapticDataID = 49, + /** + * @brief SetCloudAppPropertiesID. + */ + SetCloudAppPropertiesID = 50, + /** * @brief OnHMIStatusID. */ diff --git a/src/components/policy/policy_external/src/policy_table/enums.cc b/src/components/policy/policy_external/src/policy_table/enums.cc index 48ce4d4f72..fac3cb86a1 100644 --- a/src/components/policy/policy_external/src/policy_table/enums.cc +++ b/src/components/policy/policy_external/src/policy_table/enums.cc @@ -1120,6 +1120,11 @@ bool EnumFromJsonString(const std::string& literal, FunctionID* result) { *result = SendHapticDataID; return true; } + + if("SetCloudAppProperties" == literal){ + *result = SetCloudAppPropertiesID; + return true; + } if ("OnHMIStatus" == literal) { *result = OnHMIStatusID; diff --git a/src/components/policy/policy_regular/include/policy/policy_table/enums.h b/src/components/policy/policy_regular/include/policy/policy_table/enums.h index fce6b7b865..563e822a36 100644 --- a/src/components/policy/policy_regular/include/policy/policy_table/enums.h +++ b/src/components/policy/policy_regular/include/policy/policy_table/enums.h @@ -426,6 +426,11 @@ enum FunctionID { */ SendHapticDataID = 49, + /** + * @brief SetCloudAppPropertiesID. + */ + SetCloudAppPropertiesID = 50, + /** * @brief OnHMIStatusID. */ diff --git a/src/components/policy/policy_regular/src/policy_table/enums.cc b/src/components/policy/policy_regular/src/policy_table/enums.cc index 2ddf74af7e..0bc0bee954 100644 --- a/src/components/policy/policy_regular/src/policy_table/enums.cc +++ b/src/components/policy/policy_regular/src/policy_table/enums.cc @@ -847,6 +847,8 @@ bool IsValidEnum(FunctionID val) { return true; case SendHapticDataID: return true; + case SetCloudAppPropertiesID: + return true; case OnHMIStatusID: return true; case OnAppInterfaceUnregisteredID: @@ -994,6 +996,8 @@ const char* EnumToJsonString(FunctionID val) { return "GetSystemCapability"; case SendHapticDataID: return "SendHapticData"; + case SetCloudAppPropertiesID: + return "SetCloudAppProperties"; case OnHMIStatusID: return "OnHMIStatus"; case OnAppInterfaceUnregisteredID: @@ -1283,6 +1287,10 @@ bool EnumFromJsonString(const std::string& literal, FunctionID* result) { *result = SendHapticDataID; return true; } + if("SetCloudAppProperties" == literal){ + *result = SetCloudAppPropertiesID; + return true; + } if ("OnHMIStatus" == literal) { *result = OnHMIStatusID; -- cgit v1.2.1 From 4391bd0909caecbf640fba21769c32f415699f18 Mon Sep 17 00:00:00 2001 From: ShobhitAd Date: Tue, 13 Nov 2018 12:07:45 -0500 Subject: Getting HybridAppPreference from enum --- .../application_manager/src/policies/policy_handler.cc | 11 +++++++---- .../smart_objects/include/smart_objects/enum_schema_item.h | 7 +++---- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/components/application_manager/src/policies/policy_handler.cc b/src/components/application_manager/src/policies/policy_handler.cc index 505f29e13b..8e74ae99b9 100644 --- a/src/components/application_manager/src/policies/policy_handler.cc +++ b/src/components/application_manager/src/policies/policy_handler.cc @@ -54,6 +54,7 @@ #include "interfaces/MOBILE_API.h" #include "utils/file_system.h" #include "utils/scope_guard.h" +#include "smart_objects/enum_schema_item.h" #include "utils/helpers.h" #include "policy/policy_manager.h" @@ -1918,10 +1919,12 @@ void PolicyHandler::OnSetCloudAppProperties( policy_app_id, msg_params[strings::cloud_transport_type].asString()); } if (msg_params.keyExists(strings::hybrid_app_preference)) { - // const std::string hybrid_app_preference = - // EnumConversionHelper::EnumToString(msg_params[strings::hybrid_app_preference]); - // policy_manager_->SetHybridAppPreference( - // policy_app_id, hybrid_app_preference); + std::string hybrid_app_preference; + + mobile_apis::HybridAppPreference::eType value = static_cast + (msg_params[strings::hybrid_app_preference].asUInt()); + smart_objects::EnumConversionHelper::EnumToString(value, &hybrid_app_preference); + policy_manager_->SetHybridAppPreference(policy_app_id, hybrid_app_preference); } } diff --git a/src/components/smart_objects/include/smart_objects/enum_schema_item.h b/src/components/smart_objects/include/smart_objects/enum_schema_item.h index cbba5bd7cd..942b491927 100644 --- a/src/components/smart_objects/include/smart_objects/enum_schema_item.h +++ b/src/components/smart_objects/include/smart_objects/enum_schema_item.h @@ -220,11 +220,10 @@ class EnumConversionHelper { static bool EnumToString(const EnumType value, std::string* str) { const char* cstr; - if (EnumToCString(value, &cstr)) { - return false; - } - if (str) { + bool success = EnumToCString(value, &cstr); + if (success && str) { *str = cstr; + return true; } return false; } -- cgit v1.2.1 From ef15358324149bb3c1d278524f9690ce572336c7 Mon Sep 17 00:00:00 2001 From: ShobhitAd Date: Tue, 13 Nov 2018 12:13:32 -0500 Subject: Style Fix --- .../mobile/set_cloudapp_properties_request.h | 37 ++++--- .../mobile/set_cloudapp_properties_response.h | 31 +++--- .../mobile/set_cloudapp_properties_request.cc | 120 +++++++++++---------- .../mobile/set_cloudapp_properties_response.cc | 31 +++--- .../sdl_rpc_plugin/src/mobile_command_factory.cc | 5 +- .../src/policies/policy_handler.cc | 14 ++- .../include/policy/policy_table/enums.h | 2 +- .../policy_external/src/policy_table/enums.cc | 4 +- .../policy_regular/src/policy_table/enums.cc | 4 +- 9 files changed, 134 insertions(+), 114 deletions(-) diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/set_cloudapp_properties_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/set_cloudapp_properties_request.h index fc131020a8..0c62b248b4 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/set_cloudapp_properties_request.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/set_cloudapp_properties_request.h @@ -5,24 +5,27 @@ namespace sdl_rpc_plugin { namespace app_mngr = application_manager; - -namespace commands{ -class SetCloudAppPropertiesRequest : public app_mngr::commands::CommandRequestImpl{ -public: - SetCloudAppPropertiesRequest(const app_mngr::commands::MessageSharedPtr& message, - app_mngr::ApplicationManager& application_manager, - app_mngr::rpc_service::RPCService& rpc_service, - app_mngr::HMICapabilities& hmi_capabilities, - policy::PolicyHandlerInterface& policy_handler); - virtual ~SetCloudAppPropertiesRequest(); - virtual void Run(); - virtual void on_event(const app_mngr::event_engine::Event& event); +namespace commands { + +class SetCloudAppPropertiesRequest + : public app_mngr::commands::CommandRequestImpl { + public: + SetCloudAppPropertiesRequest( + const app_mngr::commands::MessageSharedPtr& message, + app_mngr::ApplicationManager& application_manager, + app_mngr::rpc_service::RPCService& rpc_service, + app_mngr::HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handler); + virtual ~SetCloudAppPropertiesRequest(); + virtual void Run(); + virtual void on_event(const app_mngr::event_engine::Event& event); + private: - DISALLOW_COPY_AND_ASSIGN(SetCloudAppPropertiesRequest); -}; // SetCloudAppPropertiesRequest + DISALLOW_COPY_AND_ASSIGN(SetCloudAppPropertiesRequest); +}; // SetCloudAppPropertiesRequest -} // namespace commands -} // namespace sdl_rpc_plugin +} // namespace commands +} // namespace sdl_rpc_plugin -#endif //SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_SET_CLOUDAPP_PROPERTIES_REQUEST_H_ \ No newline at end of file +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_SET_CLOUDAPP_PROPERTIES_REQUEST_H_ \ No newline at end of file diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/set_cloudapp_properties_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/set_cloudapp_properties_response.h index aae45c52ce..9037cb3b73 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/set_cloudapp_properties_response.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/set_cloudapp_properties_response.h @@ -8,21 +8,24 @@ namespace app_mngr = application_manager; namespace commands { -class SetCloudAppPropertiesResponse : public app_mngr::commands::CommandResponseImpl{ -public: - SetCloudAppPropertiesResponse(const app_mngr::commands::MessageSharedPtr& message, - app_mngr::ApplicationManager& application_manager, - app_mngr::rpc_service::RPCService& rpc_service, - app_mngr::HMICapabilities& hmi_capabilities, - policy::PolicyHandlerInterface& policy_handler); - virtual ~SetCloudAppPropertiesResponse(); - virtual void Run(); +class SetCloudAppPropertiesResponse + : public app_mngr::commands::CommandResponseImpl { + public: + SetCloudAppPropertiesResponse( + const app_mngr::commands::MessageSharedPtr& message, + app_mngr::ApplicationManager& application_manager, + app_mngr::rpc_service::RPCService& rpc_service, + app_mngr::HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handler); + virtual ~SetCloudAppPropertiesResponse(); + virtual void Run(); + private: DISALLOW_COPY_AND_ASSIGN(SetCloudAppPropertiesResponse); - -}; //SetCloudAppPropertiesResponse -} // namespace commands -} // namespace sdl_rpc_plugin +}; // SetCloudAppPropertiesResponse + +} // namespace commands +} // namespace sdl_rpc_plugin -#endif //SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_SET_CLOUDAPP_PROPERTIES_RESPONSE_H_ \ No newline at end of file +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_SET_CLOUDAPP_PROPERTIES_RESPONSE_H_ \ No newline at end of file diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/set_cloudapp_properties_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/set_cloudapp_properties_request.cc index b5c66e4400..49cb7029c7 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/set_cloudapp_properties_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/set_cloudapp_properties_request.cc @@ -5,67 +5,77 @@ using namespace application_manager; namespace commands { - SetCloudAppPropertiesRequest::SetCloudAppPropertiesRequest(const app_mngr::commands::MessageSharedPtr& message, - app_mngr::ApplicationManager& application_manager, - app_mngr::rpc_service::RPCService& rpc_service, - app_mngr::HMICapabilities& hmi_capabilities, - policy::PolicyHandlerInterface& policy_handler) - : CommandRequestImpl(message, - application_manager, - rpc_service, - hmi_capabilities, - policy_handler){} +SetCloudAppPropertiesRequest::SetCloudAppPropertiesRequest( + const app_mngr::commands::MessageSharedPtr& message, + app_mngr::ApplicationManager& application_manager, + app_mngr::rpc_service::RPCService& rpc_service, + app_mngr::HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handler) + : CommandRequestImpl(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handler) {} - SetCloudAppPropertiesRequest::~SetCloudAppPropertiesRequest(){} - void SetCloudAppPropertiesRequest::Run(){ - LOG4CXX_AUTO_TRACE(logger_); - ApplicationSharedPtr app = application_manager_.application(connection_key()); +SetCloudAppPropertiesRequest::~SetCloudAppPropertiesRequest() {} +void SetCloudAppPropertiesRequest::Run() { + LOG4CXX_AUTO_TRACE(logger_); + ApplicationSharedPtr app = application_manager_.application(connection_key()); - if (!app) { - LOG4CXX_ERROR(logger_, "Application is not registered"); - SendResponse(false, mobile_apis::Result::APPLICATION_NOT_REGISTERED); - return; - } + if (!app) { + LOG4CXX_ERROR(logger_, "Application is not registered"); + SendResponse(false, mobile_apis::Result::APPLICATION_NOT_REGISTERED); + return; + } - if ((*message_)[strings::msg_params].empty()) { - LOG4CXX_ERROR(logger_, strings::msg_params << " is empty."); - SendResponse(false, mobile_apis::Result::INVALID_DATA); - return; - } + if ((*message_)[strings::msg_params].empty()) { + LOG4CXX_ERROR(logger_, strings::msg_params << " is empty."); + SendResponse(false, mobile_apis::Result::INVALID_DATA); + return; + } - smart_objects::SmartObject cloudapp_properties(smart_objects::SmartType_Map); + smart_objects::SmartObject cloudapp_properties(smart_objects::SmartType_Map); - cloudapp_properties[strings::msg_params][strings::app_name] = (*message_)[strings::msg_params][strings::app_name]; - cloudapp_properties[strings::msg_params][strings::app_id] = (*message_)[strings::msg_params][strings::app_id]; - - if ((*message_)[strings::msg_params].keyExists(strings::enabled)) { - smart_objects::SmartObject enabled = (*message_)[strings::msg_params][strings::enabled]; - cloudapp_properties[strings::msg_params][strings::enabled] = enabled; - } - if ((*message_)[strings::msg_params].keyExists(strings::cloud_app_auth_token)) { - smart_objects::SmartObject auth_token = (*message_)[strings::msg_params][strings::cloud_app_auth_token]; - cloudapp_properties[strings::msg_params][strings::cloud_app_auth_token] = auth_token; - } - if ((*message_)[strings::msg_params].keyExists(strings::cloud_transport_type)) { - smart_objects::SmartObject transport_type = (*message_)[strings::msg_params][strings::cloud_transport_type]; - cloudapp_properties[strings::msg_params][strings::cloud_transport_type] = transport_type; - } - if ((*message_)[strings::msg_params].keyExists(strings::hybrid_app_preference)) { - smart_objects::SmartObject hybrid_app_preference = (*message_)[strings::msg_params][strings::hybrid_app_preference]; - cloudapp_properties[strings::msg_params][strings::hybrid_app_preference] = hybrid_app_preference; - } - - policy_handler_.OnSetCloudAppProperties(cloudapp_properties); - SendResponse(true, mobile_apis::Result::SUCCESS); + cloudapp_properties[strings::msg_params][strings::app_name] = + (*message_)[strings::msg_params][strings::app_name]; + cloudapp_properties[strings::msg_params][strings::app_id] = + (*message_)[strings::msg_params][strings::app_id]; + if ((*message_)[strings::msg_params].keyExists(strings::enabled)) { + smart_objects::SmartObject enabled = + (*message_)[strings::msg_params][strings::enabled]; + cloudapp_properties[strings::msg_params][strings::enabled] = enabled; + } + if ((*message_)[strings::msg_params].keyExists( + strings::cloud_app_auth_token)) { + smart_objects::SmartObject auth_token = + (*message_)[strings::msg_params][strings::cloud_app_auth_token]; + cloudapp_properties[strings::msg_params][strings::cloud_app_auth_token] = + auth_token; + } + if ((*message_)[strings::msg_params].keyExists( + strings::cloud_transport_type)) { + smart_objects::SmartObject transport_type = + (*message_)[strings::msg_params][strings::cloud_transport_type]; + cloudapp_properties[strings::msg_params][strings::cloud_transport_type] = + transport_type; + } + if ((*message_)[strings::msg_params].keyExists( + strings::hybrid_app_preference)) { + smart_objects::SmartObject hybrid_app_preference = + (*message_)[strings::msg_params][strings::hybrid_app_preference]; + cloudapp_properties[strings::msg_params][strings::hybrid_app_preference] = + hybrid_app_preference; + } - } + policy_handler_.OnSetCloudAppProperties(cloudapp_properties); + SendResponse(true, mobile_apis::Result::SUCCESS); +} +void SetCloudAppPropertiesRequest::on_event( + const app_mngr::event_engine::Event& event) { + LOG4CXX_INFO(logger_, "SetCloudAppPropertiesRequest on_event"); +} - void SetCloudAppPropertiesRequest::on_event(const app_mngr::event_engine::Event& event){ - LOG4CXX_INFO(logger_, "SetCloudAppPropertiesRequest on_event"); - } - - -} // namespace commands -} // namespace sdl_rpc_plugin \ No newline at end of file +} // namespace commands +} // namespace sdl_rpc_plugin \ No newline at end of file diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/set_cloudapp_properties_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/set_cloudapp_properties_response.cc index b113f84131..6acfb2423d 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/set_cloudapp_properties_response.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/set_cloudapp_properties_response.cc @@ -2,31 +2,30 @@ #include "application_manager/rpc_service.h" #include "sdl_rpc_plugin/commands/mobile/set_cloudapp_properties_response.h" - namespace sdl_rpc_plugin { using namespace application_manager; namespace commands { - SetCloudAppPropertiesResponse::SetCloudAppPropertiesResponse(const app_mngr::commands::MessageSharedPtr& message, - app_mngr::ApplicationManager& application_manager, - app_mngr::rpc_service::RPCService& rpc_service, - app_mngr::HMICapabilities& hmi_capabilities, - policy::PolicyHandlerInterface& policy_handler) - : CommandResponseImpl(message, +SetCloudAppPropertiesResponse::SetCloudAppPropertiesResponse( + const app_mngr::commands::MessageSharedPtr& message, + app_mngr::ApplicationManager& application_manager, + app_mngr::rpc_service::RPCService& rpc_service, + app_mngr::HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handler) + : CommandResponseImpl(message, application_manager, rpc_service, hmi_capabilities, - policy_handler){} + policy_handler) {} +SetCloudAppPropertiesResponse::~SetCloudAppPropertiesResponse() {} - SetCloudAppPropertiesResponse::~SetCloudAppPropertiesResponse(){} +void SetCloudAppPropertiesResponse::Run() { + LOG4CXX_AUTO_TRACE(logger_); - void SetCloudAppPropertiesResponse::Run(){ - LOG4CXX_AUTO_TRACE(logger_); - - rpc_service_.SendMessageToMobile(message_); - } + rpc_service_.SendMessageToMobile(message_); +} -} // namespace commands -} //namespace sdl_rpc_plugins +} // namespace commands +} // namespace sdl_rpc_plugins diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/mobile_command_factory.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/mobile_command_factory.cc index a5b3bf71fe..dc5298813b 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/mobile_command_factory.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/mobile_command_factory.cc @@ -341,8 +341,9 @@ CommandCreator& MobileCommandFactory::get_creator_factory( } case mobile_apis::FunctionID::SetCloudAppPropertiesID: { return mobile_api::messageType::request == message_type - ? factory.GetCreator() - : factory.GetCreator(); + ? factory.GetCreator() + : factory + .GetCreator(); } case mobile_apis::FunctionID::OnButtonEventID: { return factory.GetCreator(); diff --git a/src/components/application_manager/src/policies/policy_handler.cc b/src/components/application_manager/src/policies/policy_handler.cc index 8e74ae99b9..8c026c8c75 100644 --- a/src/components/application_manager/src/policies/policy_handler.cc +++ b/src/components/application_manager/src/policies/policy_handler.cc @@ -1920,11 +1920,15 @@ void PolicyHandler::OnSetCloudAppProperties( } if (msg_params.keyExists(strings::hybrid_app_preference)) { std::string hybrid_app_preference; - - mobile_apis::HybridAppPreference::eType value = static_cast - (msg_params[strings::hybrid_app_preference].asUInt()); - smart_objects::EnumConversionHelper::EnumToString(value, &hybrid_app_preference); - policy_manager_->SetHybridAppPreference(policy_app_id, hybrid_app_preference); + + mobile_apis::HybridAppPreference::eType value = + static_cast( + msg_params[strings::hybrid_app_preference].asUInt()); + smart_objects::EnumConversionHelper< + mobile_apis::HybridAppPreference::eType>:: + EnumToString(value, &hybrid_app_preference); + policy_manager_->SetHybridAppPreference(policy_app_id, + hybrid_app_preference); } } diff --git a/src/components/policy/policy_external/include/policy/policy_table/enums.h b/src/components/policy/policy_external/include/policy/policy_table/enums.h index 982118a43a..5b494629bb 100644 --- a/src/components/policy/policy_external/include/policy/policy_table/enums.h +++ b/src/components/policy/policy_external/include/policy/policy_table/enums.h @@ -444,7 +444,7 @@ enum FunctionID { * @brief SetCloudAppPropertiesID. */ SetCloudAppPropertiesID = 50, - + /** * @brief OnHMIStatusID. */ diff --git a/src/components/policy/policy_external/src/policy_table/enums.cc b/src/components/policy/policy_external/src/policy_table/enums.cc index fac3cb86a1..d7d5a241de 100644 --- a/src/components/policy/policy_external/src/policy_table/enums.cc +++ b/src/components/policy/policy_external/src/policy_table/enums.cc @@ -1120,8 +1120,8 @@ bool EnumFromJsonString(const std::string& literal, FunctionID* result) { *result = SendHapticDataID; return true; } - - if("SetCloudAppProperties" == literal){ + + if ("SetCloudAppProperties" == literal) { *result = SetCloudAppPropertiesID; return true; } diff --git a/src/components/policy/policy_regular/src/policy_table/enums.cc b/src/components/policy/policy_regular/src/policy_table/enums.cc index 0bc0bee954..91d0a6990f 100644 --- a/src/components/policy/policy_regular/src/policy_table/enums.cc +++ b/src/components/policy/policy_regular/src/policy_table/enums.cc @@ -848,7 +848,7 @@ bool IsValidEnum(FunctionID val) { case SendHapticDataID: return true; case SetCloudAppPropertiesID: - return true; + return true; case OnHMIStatusID: return true; case OnAppInterfaceUnregisteredID: @@ -1287,7 +1287,7 @@ bool EnumFromJsonString(const std::string& literal, FunctionID* result) { *result = SendHapticDataID; return true; } - if("SetCloudAppProperties" == literal){ + if ("SetCloudAppProperties" == literal) { *result = SetCloudAppPropertiesID; return true; } -- cgit v1.2.1 From e07013316897e2a7e9b0a12809ac084755a73d99 Mon Sep 17 00:00:00 2001 From: ShobhitAd Date: Wed, 14 Nov 2018 14:16:51 -0500 Subject: Made requested changes --- .../commands/mobile/set_cloudapp_properties_request.cc | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/set_cloudapp_properties_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/set_cloudapp_properties_request.cc index 49cb7029c7..ca5a46e3dc 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/set_cloudapp_properties_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/set_cloudapp_properties_request.cc @@ -34,41 +34,41 @@ void SetCloudAppPropertiesRequest::Run() { return; } - smart_objects::SmartObject cloudapp_properties(smart_objects::SmartType_Map); + smart_objects::SmartObject cloud_app_properties(smart_objects::SmartType_Map); - cloudapp_properties[strings::msg_params][strings::app_name] = + cloud_app_properties[strings::msg_params][strings::app_name] = (*message_)[strings::msg_params][strings::app_name]; - cloudapp_properties[strings::msg_params][strings::app_id] = + cloud_app_properties[strings::msg_params][strings::app_id] = (*message_)[strings::msg_params][strings::app_id]; if ((*message_)[strings::msg_params].keyExists(strings::enabled)) { smart_objects::SmartObject enabled = (*message_)[strings::msg_params][strings::enabled]; - cloudapp_properties[strings::msg_params][strings::enabled] = enabled; + cloud_app_properties[strings::msg_params][strings::enabled] = enabled; } if ((*message_)[strings::msg_params].keyExists( strings::cloud_app_auth_token)) { smart_objects::SmartObject auth_token = (*message_)[strings::msg_params][strings::cloud_app_auth_token]; - cloudapp_properties[strings::msg_params][strings::cloud_app_auth_token] = + cloud_app_properties[strings::msg_params][strings::cloud_app_auth_token] = auth_token; } if ((*message_)[strings::msg_params].keyExists( strings::cloud_transport_type)) { smart_objects::SmartObject transport_type = (*message_)[strings::msg_params][strings::cloud_transport_type]; - cloudapp_properties[strings::msg_params][strings::cloud_transport_type] = + cloud_app_properties[strings::msg_params][strings::cloud_transport_type] = transport_type; } if ((*message_)[strings::msg_params].keyExists( strings::hybrid_app_preference)) { smart_objects::SmartObject hybrid_app_preference = (*message_)[strings::msg_params][strings::hybrid_app_preference]; - cloudapp_properties[strings::msg_params][strings::hybrid_app_preference] = + cloud_app_properties[strings::msg_params][strings::hybrid_app_preference] = hybrid_app_preference; } - policy_handler_.OnSetCloudAppProperties(cloudapp_properties); + policy_handler_.OnSetCloudAppProperties(cloud_app_properties); SendResponse(true, mobile_apis::Result::SUCCESS); } -- cgit v1.2.1 From ce76a8b072f3c11386534d823df530a6a826b514 Mon Sep 17 00:00:00 2001 From: ShobhitAd Date: Fri, 16 Nov 2018 16:35:50 -0500 Subject: Removed redundant smart object --- .../mobile/set_cloudapp_properties_request.cc | 37 ++-------------------- 1 file changed, 2 insertions(+), 35 deletions(-) diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/set_cloudapp_properties_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/set_cloudapp_properties_request.cc index ca5a46e3dc..d92f458587 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/set_cloudapp_properties_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/set_cloudapp_properties_request.cc @@ -18,6 +18,7 @@ SetCloudAppPropertiesRequest::SetCloudAppPropertiesRequest( policy_handler) {} SetCloudAppPropertiesRequest::~SetCloudAppPropertiesRequest() {} + void SetCloudAppPropertiesRequest::Run() { LOG4CXX_AUTO_TRACE(logger_); ApplicationSharedPtr app = application_manager_.application(connection_key()); @@ -34,41 +35,7 @@ void SetCloudAppPropertiesRequest::Run() { return; } - smart_objects::SmartObject cloud_app_properties(smart_objects::SmartType_Map); - - cloud_app_properties[strings::msg_params][strings::app_name] = - (*message_)[strings::msg_params][strings::app_name]; - cloud_app_properties[strings::msg_params][strings::app_id] = - (*message_)[strings::msg_params][strings::app_id]; - - if ((*message_)[strings::msg_params].keyExists(strings::enabled)) { - smart_objects::SmartObject enabled = - (*message_)[strings::msg_params][strings::enabled]; - cloud_app_properties[strings::msg_params][strings::enabled] = enabled; - } - if ((*message_)[strings::msg_params].keyExists( - strings::cloud_app_auth_token)) { - smart_objects::SmartObject auth_token = - (*message_)[strings::msg_params][strings::cloud_app_auth_token]; - cloud_app_properties[strings::msg_params][strings::cloud_app_auth_token] = - auth_token; - } - if ((*message_)[strings::msg_params].keyExists( - strings::cloud_transport_type)) { - smart_objects::SmartObject transport_type = - (*message_)[strings::msg_params][strings::cloud_transport_type]; - cloud_app_properties[strings::msg_params][strings::cloud_transport_type] = - transport_type; - } - if ((*message_)[strings::msg_params].keyExists( - strings::hybrid_app_preference)) { - smart_objects::SmartObject hybrid_app_preference = - (*message_)[strings::msg_params][strings::hybrid_app_preference]; - cloud_app_properties[strings::msg_params][strings::hybrid_app_preference] = - hybrid_app_preference; - } - - policy_handler_.OnSetCloudAppProperties(cloud_app_properties); + policy_handler_.OnSetCloudAppProperties(*message_); SendResponse(true, mobile_apis::Result::SUCCESS); } -- cgit v1.2.1 From 27d02ac7c4b30c5fd0af3a455537d0b4b60a12f4 Mon Sep 17 00:00:00 2001 From: ShobhitAd Date: Tue, 20 Nov 2018 11:08:49 -0500 Subject: Style fix in MOBILE_API --- src/components/interfaces/MOBILE_API.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/components/interfaces/MOBILE_API.xml b/src/components/interfaces/MOBILE_API.xml index 1707f65bad..714399bce6 100644 --- a/src/components/interfaces/MOBILE_API.xml +++ b/src/components/interfaces/MOBILE_API.xml @@ -547,9 +547,9 @@ Enumeration for the user's preference of which app type to use when both are available - - - + + + -- cgit v1.2.1 From 4103779a0b69a029720141dbda934151e8321ba0 Mon Sep 17 00:00:00 2001 From: JackLivio Date: Tue, 20 Nov 2018 13:28:58 -0500 Subject: Address comments, fix unit test failures --- .../include/application_manager/application.h | 12 ++++++------ .../include/application_manager/application_impl.h | 12 ++++++------ src/components/application_manager/src/application_impl.cc | 12 ++++++------ .../test/include/application_manager/mock_application.h | 14 ++++++++++++++ .../test/connection_handler/mock_connection_handler.h | 4 ++++ .../connection_handler/mock_connection_handler_observer.h | 4 ++++ .../test/transport_manager/mock_transport_manager.h | 3 +++ .../transport_manager/mock_transport_manager_listener.h | 3 +++ .../transport_manager/mock_transport_manager_settings.h | 2 ++ .../transport_adapter/mock_transport_adapter.h | 2 ++ src/components/transport_manager/test/CMakeLists.txt | 5 +++++ .../transport_manager/mock_transport_manager_listener.h | 3 +++ .../transport_adapter/mock_transport_adapter_listener.h | 4 ++++ .../transport_manager/test/tcp_client_listener_test.cc | 3 +++ 14 files changed, 65 insertions(+), 18 deletions(-) diff --git a/src/components/application_manager/include/application_manager/application.h b/src/components/application_manager/include/application_manager/application.h index 4ddf1e1388..963f93ce5c 100644 --- a/src/components/application_manager/include/application_manager/application.h +++ b/src/components/application_manager/include/application_manager/application.h @@ -950,35 +950,35 @@ class Application : public virtual InitialApplicationData, * @brief Get cloud app endpoint for websocket connection * @return cloud app endpoint */ - const virtual std::string cloud_app_endpoint() = 0; + virtual const std::string& cloud_app_endpoint() const = 0; /** * @brief Get cloud app authtoken to be used in connection handshake after * websocket open. * @return cloud app authtoken */ - const virtual std::string cloud_app_authtoken() = 0; + virtual const std::string& cloud_app_authtoken() const = 0; /** * @brief Get cloud app tranpsport type. Defines the type of websocket * connection used. * @return cloud app transport type */ - const virtual std::string cloud_app_transport_type() = 0; + virtual const std::string& cloud_app_transport_type() const = 0; /** * @brief Get hybrid app preference. Defines behaviour for when a similar * mobile and cloud app are connected simultaneously. * @return hybrid app preference */ - const virtual mobile_apis::HybridAppPreference::eType - hybrid_app_preference() = 0; + virtual const mobile_apis::HybridAppPreference::eType& hybrid_app_preference() + const = 0; /** * @brief Get cloud app certificate. Used for secured websocket connections. * @return cloud app certificate. */ - const virtual std::string cloud_app_certificate() = 0; + virtual const std::string& cloud_app_certificate() const = 0; /** * @brief Set cloud app endpoint diff --git a/src/components/application_manager/include/application_manager/application_impl.h b/src/components/application_manager/include/application_manager/application_impl.h index 26d8cd6159..8fa1553811 100644 --- a/src/components/application_manager/include/application_manager/application_impl.h +++ b/src/components/application_manager/include/application_manager/application_impl.h @@ -413,35 +413,35 @@ class ApplicationImpl : public virtual Application, * @brief Get cloud app endpoint for websocket connection * @return cloud app endpoint */ - const std::string cloud_app_endpoint() OVERRIDE; + const std::string& cloud_app_endpoint() const OVERRIDE; /** * @brief Get cloud app authtoken to be used in connection handshake after * websocket open. * @return cloud app authtoken */ - const std::string cloud_app_authtoken() OVERRIDE; + const std::string& cloud_app_authtoken() const OVERRIDE; /** * @brief Get cloud app tranpsport type. Defines the type of websocket * connection used. * @return cloud app transport type */ - const std::string cloud_app_transport_type() OVERRIDE; + const std::string& cloud_app_transport_type() const OVERRIDE; /** * @brief Get hybrid app preference. Defines behaviour for when a similar * mobile and cloud app are connected simultaneously. * @return hybrid app preference */ - const mobile_apis::HybridAppPreference::eType hybrid_app_preference() - OVERRIDE; + const mobile_apis::HybridAppPreference::eType& hybrid_app_preference() + const OVERRIDE; /** * @brief Get cloud app certificate. Used for secured websocket connections. * @return cloud app certificate. */ - const std::string cloud_app_certificate() OVERRIDE; + const std::string& cloud_app_certificate() const OVERRIDE; /** * @brief Set cloud app endpoint diff --git a/src/components/application_manager/src/application_impl.cc b/src/components/application_manager/src/application_impl.cc index 31df4e821b..732e5bc804 100644 --- a/src/components/application_manager/src/application_impl.cc +++ b/src/components/application_manager/src/application_impl.cc @@ -1163,24 +1163,24 @@ const std::list& ApplicationImpl::Extensions() const { return extensions_; } -const std::string ApplicationImpl::cloud_app_endpoint() { +const std::string& ApplicationImpl::cloud_app_endpoint() const { return endpoint_; } -const std::string ApplicationImpl::cloud_app_authtoken() { +const std::string& ApplicationImpl::cloud_app_authtoken() const { return auth_token_; } -const std::string ApplicationImpl::cloud_app_transport_type() { +const std::string& ApplicationImpl::cloud_app_transport_type() const { return cloud_transport_type_; } -const mobile_apis::HybridAppPreference::eType -ApplicationImpl::hybrid_app_preference() { +const mobile_apis::HybridAppPreference::eType& +ApplicationImpl::hybrid_app_preference() const { return hybrid_app_preference_; } -const std::string ApplicationImpl::cloud_app_certificate() { +const std::string& ApplicationImpl::cloud_app_certificate() const { return certificate_; } 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 fe16e8ce6e..486871b5de 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 @@ -342,6 +342,20 @@ class MockApplication : public ::application_manager::Application { const std::list&()); MOCK_CONST_METHOD0(is_remote_control_supported, bool()); MOCK_METHOD1(set_remote_control_supported, void(const bool allow)); + MOCK_CONST_METHOD0(cloud_app_endpoint, const std::string&()); + MOCK_CONST_METHOD0(cloud_app_authtoken, const std::string&()); + MOCK_CONST_METHOD0(cloud_app_transport_type, const std::string&()); + MOCK_CONST_METHOD0(hybrid_app_preference, + const mobile_apis::HybridAppPreference::eType&()); + MOCK_CONST_METHOD0(cloud_app_certificate, const std::string&()); + MOCK_METHOD1(set_cloud_app_endpoint, void(const std::string& endpoint)); + MOCK_METHOD1(set_cloud_app_auth_token, void(const std::string& auth_token)); + MOCK_METHOD1(set_cloud_app_transport_type, + void(const std::string& transport_type)); + MOCK_METHOD1(set_hybrid_app_preference, + void(const mobile_apis::HybridAppPreference::eType& + hybrid_app_preference)); + MOCK_METHOD1(set_cloud_app_certificate, void(const std::string& certificate)); }; } // namespace application_manager_test diff --git a/src/components/include/test/connection_handler/mock_connection_handler.h b/src/components/include/test/connection_handler/mock_connection_handler.h index 2de3a0f9a7..bdc0469844 100644 --- a/src/components/include/test/connection_handler/mock_connection_handler.h +++ b/src/components/include/test/connection_handler/mock_connection_handler.h @@ -63,6 +63,10 @@ class MockConnectionHandler : public connection_handler::ConnectionHandler { MOCK_CONST_METHOD2(RunAppOnDevice, void(const std::string&, const std::string&)); MOCK_METHOD0(ConnectToAllDevices, void()); + MOCK_METHOD3(AddCloudAppDevice, + void(const std::string& policy_app_id, + const std::string& endpoint, + const std::string& cloud_transport_type)); MOCK_METHOD1(CloseRevokedConnection, void(uint32_t connection_key)); MOCK_METHOD1(CloseConnection, void(ConnectionHandle connection_handle)); MOCK_METHOD1(GetConnectionSessionsCount, uint32_t(uint32_t connection_key)); diff --git a/src/components/include/test/connection_handler/mock_connection_handler_observer.h b/src/components/include/test/connection_handler/mock_connection_handler_observer.h index a9e4349bec..2984b2e471 100644 --- a/src/components/include/test/connection_handler/mock_connection_handler_observer.h +++ b/src/components/include/test/connection_handler/mock_connection_handler_observer.h @@ -74,6 +74,10 @@ class MockConnectionHandlerObserver const int32_t session_key)); MOCK_METHOD1(OnSecondaryTransportEndedCallback, void(const int32_t session_key)); + MOCK_METHOD3(CreatePendingApplication, + void(const transport_manager::ConnectionUID connection_id, + const transport_manager::DeviceInfo& device_info, + connection_handler::DeviceHandle device_id)); }; } // namespace connection_handler_test diff --git a/src/components/include/test/transport_manager/mock_transport_manager.h b/src/components/include/test/transport_manager/mock_transport_manager.h index cc8bd5ab85..e3f01fccb5 100644 --- a/src/components/include/test/transport_manager/mock_transport_manager.h +++ b/src/components/include/test/transport_manager/mock_transport_manager.h @@ -59,6 +59,9 @@ class MockTransportManager : public ::transport_manager::TransportManager, MOCK_METHOD1(Init, int(resumption::LastState& last_state)); MOCK_METHOD0(Reinit, int()); MOCK_METHOD0(SearchDevices, int()); + MOCK_METHOD2(AddCloudDevice, + void(const std::string& endpoint, + const std::string& cloud_transport_type)); MOCK_METHOD1(ConnectDevice, int(const DeviceHandle)); MOCK_METHOD1(DisconnectDevice, int(const DeviceHandle)); MOCK_METHOD1(Disconnect, int(const ConnectionUID)); diff --git a/src/components/include/test/transport_manager/mock_transport_manager_listener.h b/src/components/include/test/transport_manager/mock_transport_manager_listener.h index 133dabe732..734651f455 100644 --- a/src/components/include/test/transport_manager/mock_transport_manager_listener.h +++ b/src/components/include/test/transport_manager/mock_transport_manager_listener.h @@ -55,6 +55,9 @@ class MockTransportManagerListener : public TransportManagerListener { MOCK_METHOD1(OnDeviceRemoved, void(const DeviceInfo& device_info)); MOCK_METHOD0(OnScanDevicesFinished, void()); MOCK_METHOD1(OnScanDevicesFailed, void(const SearchDeviceError& error)); + MOCK_METHOD2(OnConnectionPending, + void(const DeviceInfo& device_info, + const ConnectionUID connection_id)); MOCK_METHOD2(OnConnectionEstablished, void(const DeviceInfo& device_info, const ConnectionUID connection_id)); diff --git a/src/components/include/test/transport_manager/mock_transport_manager_settings.h b/src/components/include/test/transport_manager/mock_transport_manager_settings.h index 3e7c8f36f7..bed0d5e6e6 100644 --- a/src/components/include/test/transport_manager/mock_transport_manager_settings.h +++ b/src/components/include/test/transport_manager/mock_transport_manager_settings.h @@ -63,6 +63,8 @@ class MockTransportManagerSettings MOCK_CONST_METHOD0(app_transport_change_timer_addition, uint32_t()); MOCK_CONST_METHOD0(transport_manager_tcp_adapter_network_interface, std::string&()); + MOCK_CONST_METHOD0(cloud_app_retry_timeout, uint32_t()); + MOCK_CONST_METHOD0(cloud_app_max_retry_attempts, uint16_t()); }; } // namespace transport_manager_test diff --git a/src/components/include/test/transport_manager/transport_adapter/mock_transport_adapter.h b/src/components/include/test/transport_manager/transport_adapter/mock_transport_adapter.h index eff0abdcd3..0be4da1063 100644 --- a/src/components/include/test/transport_manager/transport_adapter/mock_transport_adapter.h +++ b/src/components/include/test/transport_manager/transport_adapter/mock_transport_adapter.h @@ -105,6 +105,8 @@ class MockTransportAdapter transport_manager::SwitchableDevices()); MOCK_CONST_METHOD0(GetTransportConfiguration, transport_manager::transport_adapter::TransportConfig()); + MOCK_METHOD1(CreateDevice, void(const std::string& uid)); + #ifdef TELEMETRY_MONITOR MOCK_METHOD0(GetTelemetryObserver, ::transport_manager::TMTelemetryObserver*()); diff --git a/src/components/transport_manager/test/CMakeLists.txt b/src/components/transport_manager/test/CMakeLists.txt index 240784436b..5288d8c697 100644 --- a/src/components/transport_manager/test/CMakeLists.txt +++ b/src/components/transport_manager/test/CMakeLists.txt @@ -75,6 +75,11 @@ if (BUILD_BT_SUPPORT) endif() endif() +if(BUILD_CLOUD_APP_SUPPORT) + GET_PROPERTY(BOOST_LIBS_DIRECTORY GLOBAL PROPERTY GLOBAL_BOOST_LIBS) + list(APPEND LIBRARIES boost_system boost_regex crypto ssl -L${BOOST_LIBS_DIRECTORY}) +endif() + create_test("transport_manager_test" "${SOURCES}" "${LIBRARIES}") file(COPY smartDeviceLink_test.ini DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) diff --git a/src/components/transport_manager/test/include/transport_manager/mock_transport_manager_listener.h b/src/components/transport_manager/test/include/transport_manager/mock_transport_manager_listener.h index 58e143342a..4eaf34d041 100644 --- a/src/components/transport_manager/test/include/transport_manager/mock_transport_manager_listener.h +++ b/src/components/transport_manager/test/include/transport_manager/mock_transport_manager_listener.h @@ -56,6 +56,9 @@ class MockTransportManagerListener : public TransportManagerListener { MOCK_METHOD1(OnDeviceRemoved, void(const DeviceInfo& device_info)); MOCK_METHOD0(OnScanDevicesFinished, void()); MOCK_METHOD1(OnScanDevicesFailed, void(const SearchDeviceError& error)); + MOCK_METHOD2(OnConnectionPending, + void(const DeviceInfo& device_info, + const ConnectionUID connection_id)); MOCK_METHOD2(OnConnectionEstablished, void(const DeviceInfo& device_info, const ConnectionUID connection_id)); diff --git a/src/components/transport_manager/test/include/transport_manager/transport_adapter/mock_transport_adapter_listener.h b/src/components/transport_manager/test/include/transport_manager/transport_adapter/mock_transport_adapter_listener.h index dce23189c8..81e133ec2b 100644 --- a/src/components/transport_manager/test/include/transport_manager/transport_adapter/mock_transport_adapter_listener.h +++ b/src/components/transport_manager/test/include/transport_manager/transport_adapter/mock_transport_adapter_listener.h @@ -59,6 +59,10 @@ class MockTransportAdapterListener : public TransportAdapterListener { const SearchDeviceError& error)); MOCK_METHOD1(OnFindNewApplicationsRequest, void(const TransportAdapter* adapter)); + MOCK_METHOD3(OnConnectPending, + void(const TransportAdapter* adapter, + const DeviceUID& device_handle, + const ApplicationHandle& app_id)); MOCK_METHOD1(OnDeviceListUpdated, void(const TransportAdapter* transport_adapter)); MOCK_METHOD3(OnConnectDone, diff --git a/src/components/transport_manager/test/tcp_client_listener_test.cc b/src/components/transport_manager/test/tcp_client_listener_test.cc index 5205d6ae3c..f44f8785aa 100644 --- a/src/components/transport_manager/test/tcp_client_listener_test.cc +++ b/src/components/transport_manager/test/tcp_client_listener_test.cc @@ -73,6 +73,9 @@ class MockTransportAdapterController : public TransportAdapterController { void(ConnectionSPtr connection, const DeviceUID& device_handle, const ApplicationHandle& app_handle)); + MOCK_METHOD2(ConnectPending, + void(const DeviceUID& device_handle, + const ApplicationHandle& app_handle)); MOCK_METHOD2(ConnectDone, void(const DeviceUID& device_handle, const ApplicationHandle& app_handle)); -- cgit v1.2.1 From a6c0deddae788352f4b0e7bf238b37db43386489 Mon Sep 17 00:00:00 2001 From: JackLivio Date: Tue, 20 Nov 2018 13:40:48 -0500 Subject: Fix auth_token typo --- .../application_manager/include/application_manager/application.h | 6 +++--- .../include/application_manager/application_impl.h | 6 +++--- src/components/application_manager/src/application_impl.cc | 2 +- .../test/include/application_manager/mock_application.h | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/components/application_manager/include/application_manager/application.h b/src/components/application_manager/include/application_manager/application.h index 963f93ce5c..2abd2eaea0 100644 --- a/src/components/application_manager/include/application_manager/application.h +++ b/src/components/application_manager/include/application_manager/application.h @@ -953,11 +953,11 @@ class Application : public virtual InitialApplicationData, virtual const std::string& cloud_app_endpoint() const = 0; /** - * @brief Get cloud app authtoken to be used in connection handshake after + * @brief Get cloud app auth token to be used in connection handshake after * websocket open. - * @return cloud app authtoken + * @return cloud app auth token */ - virtual const std::string& cloud_app_authtoken() const = 0; + virtual const std::string& cloud_app_auth_token() const = 0; /** * @brief Get cloud app tranpsport type. Defines the type of websocket diff --git a/src/components/application_manager/include/application_manager/application_impl.h b/src/components/application_manager/include/application_manager/application_impl.h index 8fa1553811..0b43b014b6 100644 --- a/src/components/application_manager/include/application_manager/application_impl.h +++ b/src/components/application_manager/include/application_manager/application_impl.h @@ -416,11 +416,11 @@ class ApplicationImpl : public virtual Application, const std::string& cloud_app_endpoint() const OVERRIDE; /** - * @brief Get cloud app authtoken to be used in connection handshake after + * @brief Get cloud app auth token to be used in connection handshake after * websocket open. - * @return cloud app authtoken + * @return cloud app auth token */ - const std::string& cloud_app_authtoken() const OVERRIDE; + const std::string& cloud_app_auth_token() const OVERRIDE; /** * @brief Get cloud app tranpsport type. Defines the type of websocket diff --git a/src/components/application_manager/src/application_impl.cc b/src/components/application_manager/src/application_impl.cc index 732e5bc804..558a4638c1 100644 --- a/src/components/application_manager/src/application_impl.cc +++ b/src/components/application_manager/src/application_impl.cc @@ -1167,7 +1167,7 @@ const std::string& ApplicationImpl::cloud_app_endpoint() const { return endpoint_; } -const std::string& ApplicationImpl::cloud_app_authtoken() const { +const std::string& ApplicationImpl::cloud_app_auth_token() const { return auth_token_; } 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 486871b5de..9c9041284c 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 @@ -343,7 +343,7 @@ class MockApplication : public ::application_manager::Application { MOCK_CONST_METHOD0(is_remote_control_supported, bool()); MOCK_METHOD1(set_remote_control_supported, void(const bool allow)); MOCK_CONST_METHOD0(cloud_app_endpoint, const std::string&()); - MOCK_CONST_METHOD0(cloud_app_authtoken, const std::string&()); + MOCK_CONST_METHOD0(cloud_app_auth_token, const std::string&()); MOCK_CONST_METHOD0(cloud_app_transport_type, const std::string&()); MOCK_CONST_METHOD0(hybrid_app_preference, const mobile_apis::HybridAppPreference::eType&()); -- cgit v1.2.1 From 095f9ce3a935ed3a43041b44bf443da8047b1757 Mon Sep 17 00:00:00 2001 From: jacobkeeler Date: Mon, 26 Nov 2018 15:23:24 -0500 Subject: Fix issues with retry sequence Also address review comments and fix build issues. --- .../src/commands/hmi/sdl_activate_app_request.cc | 2 +- .../application_manager/src/application_impl.cc | 2 +- .../src/application_manager_impl.cc | 2 +- .../transport_manager/transport_adapter/device.h | 8 +++-- .../transport_adapter/transport_adapter_impl.h | 2 ++ .../transport_adapter/transport_adapter_impl.cc | 34 +++++++++++++++------- 6 files changed, 34 insertions(+), 16 deletions(-) diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/sdl_activate_app_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/sdl_activate_app_request.cc index bfe7adec11..1704251c17 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/sdl_activate_app_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/sdl_activate_app_request.cc @@ -145,7 +145,7 @@ void SDLActivateAppRequest::Run() { const uint32_t application_id = app_id(); ApplicationConstSharedPtr app_to_activate = - application_manager_.application_by_hmi_app(application_id); + application_manager_.application(application_id); if (!app_to_activate) { LOG4CXX_WARN( diff --git a/src/components/application_manager/src/application_impl.cc b/src/components/application_manager/src/application_impl.cc index 64be323145..379e73bce9 100644 --- a/src/components/application_manager/src/application_impl.cc +++ b/src/components/application_manager/src/application_impl.cc @@ -1187,7 +1187,7 @@ const std::string& ApplicationImpl::cloud_app_certificate() const { bool ApplicationImpl::is_cloud_app() const { return !endpoint_.empty() && hybrid_app_preference_ != - hmi_apis::Common_CloudConnectionStatus::MOBILE; + mobile_apis::HybridAppPreference::MOBILE; } void ApplicationImpl::set_cloud_app_endpoint(const std::string& endpoint) { diff --git a/src/components/application_manager/src/application_manager_impl.cc b/src/components/application_manager/src/application_manager_impl.cc index 79bd00b37d..e9a45001c7 100644 --- a/src/components/application_manager/src/application_manager_impl.cc +++ b/src/components/application_manager/src/application_manager_impl.cc @@ -645,7 +645,7 @@ ApplicationSharedPtr ApplicationManagerImpl::RegisterApplication( // Set cloud app parameters application->set_cloud_app_endpoint((*it)->cloud_app_endpoint()); application->set_cloud_app_certificate((*it)->cloud_app_certificate()); - application->set_cloud_app_auth_token((*it)->cloud_app_authtoken()); + application->set_cloud_app_auth_token((*it)->cloud_app_auth_token()); application->set_cloud_app_transport_type( (*it)->cloud_app_transport_type()); application->set_hybrid_app_preference((*it)->hybrid_app_preference()); diff --git a/src/components/include/transport_manager/transport_adapter/device.h b/src/components/include/transport_manager/transport_adapter/device.h index 448df9668a..17fd6b6950 100644 --- a/src/components/include/transport_manager/transport_adapter/device.h +++ b/src/components/include/transport_manager/transport_adapter/device.h @@ -58,7 +58,9 @@ class Device { Device(const std::string& name, const DeviceUID& unique_device_id) : name_(name) , unique_device_id_(unique_device_id) - , keep_on_disconnect_(false) {} + , keep_on_disconnect_(false) + , status_(ConnectionStatus::PENDING) + , retry_count_(0) {} /** * Constructor for creating device supporting transport switch @@ -73,7 +75,9 @@ class Device { : name_(name) , unique_device_id_(unique_device_id) , transport_switch_id_(transport_switch_id) - , keep_on_disconnect_(false) {} + , keep_on_disconnect_(false) + , status_(ConnectionStatus::PENDING) + , retry_count_(0) {} /** * @brief Destructor. diff --git a/src/components/transport_manager/include/transport_manager/transport_adapter/transport_adapter_impl.h b/src/components/transport_manager/include/transport_manager/transport_adapter/transport_adapter_impl.h index e06537677a..ba50025cda 100644 --- a/src/components/transport_manager/include/transport_manager/transport_adapter/transport_adapter_impl.h +++ b/src/components/transport_manager/include/transport_manager/transport_adapter/transport_adapter_impl.h @@ -553,6 +553,7 @@ class TransportAdapterImpl : public TransportAdapter, TransportAdapter::Error ConnectDevice(DeviceSptr device); void RetryConnection(); + DeviceUID GetNextRetryDevice(); /** * @brief Remove specified device @@ -616,6 +617,7 @@ class TransportAdapterImpl : public TransportAdapter, ConnectionMap connections_; std::queue > retry_timer_pool_; + sync_primitives::RecursiveLock retry_timer_pool_lock_; /** * @brief Mutex restricting access to connections map. diff --git a/src/components/transport_manager/src/transport_adapter/transport_adapter_impl.cc b/src/components/transport_manager/src/transport_adapter/transport_adapter_impl.cc index b73f3140d3..02eb721238 100644 --- a/src/components/transport_manager/src/transport_adapter/transport_adapter_impl.cc +++ b/src/components/transport_manager/src/transport_adapter/transport_adapter_impl.cc @@ -239,17 +239,6 @@ TransportAdapter::Error TransportAdapterImpl::Connect( return err; } -void TransportAdapterImpl::RetryConnection() { - if (retry_timer_pool_.empty()) { - LOG4CXX_ERROR(logger_, - "Unable to find timer, ignoring RetryConnection request"); - return; - } - const DeviceUID device_id = retry_timer_pool_.front().second; - retry_timer_pool_.pop(); - ConnectDevice(device_id); -} - TransportAdapter::Error TransportAdapterImpl::ConnectDevice( const DeviceUID& device_handle) { LOG4CXX_TRACE(logger_, "enter with device_handle: " << &device_handle); @@ -276,6 +265,7 @@ TransportAdapter::Error TransportAdapterImpl::ConnectDevice( "RetryConnectionTimer", new timer::TimerTaskImpl( this, &TransportAdapterImpl::RetryConnection))); + sync_primitives::AutoLock locker(retry_timer_pool_lock_); retry_timer_pool_.push(std::make_pair(retry_timer, device_handle)); retry_timer->Start(get_settings().cloud_app_retry_timeout(), timer::kSingleShot); @@ -290,6 +280,28 @@ TransportAdapter::Error TransportAdapterImpl::ConnectDevice( } } +void TransportAdapterImpl::RetryConnection() { + const DeviceUID device_id = GetNextRetryDevice(); + if (device_id.empty()) { + LOG4CXX_ERROR(logger_, + "Unable to find timer, ignoring RetryConnection request"); + return; + } + ConnectDevice(device_id); +} + +DeviceUID TransportAdapterImpl::GetNextRetryDevice() { + sync_primitives::AutoLock locker(retry_timer_pool_lock_); + while (!retry_timer_pool_.empty()) { + auto timer_entry = retry_timer_pool_.front(); + if (timer_entry.first->is_running()) { + return timer_entry.second; + } + retry_timer_pool_.pop(); + } + return std::string(); +} + ConnectionStatus TransportAdapterImpl::GetConnectionStatus( const DeviceUID& device_handle) const { DeviceSptr device = FindDevice(device_handle); -- cgit v1.2.1 From 43bb36651930d1015a3cae4d84cf4a8609c6733b Mon Sep 17 00:00:00 2001 From: JackLivio Date: Mon, 26 Nov 2018 15:46:56 -0500 Subject: Update regex for endpoint and return 0 for App List handles --- .../transport_manager/src/cloud/cloud_device.cc | 2 +- .../src/cloud/cloud_websocket_transport_adapter.cc | 26 +++++++++++++++++----- 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/src/components/transport_manager/src/cloud/cloud_device.cc b/src/components/transport_manager/src/cloud/cloud_device.cc index 6196bcc87e..770962be47 100644 --- a/src/components/transport_manager/src/cloud/cloud_device.cc +++ b/src/components/transport_manager/src/cloud/cloud_device.cc @@ -53,7 +53,7 @@ bool CloudDevice::IsSameAs(const Device* other) const { // todo implement getApplicationList // to be populated by policies ApplicationList CloudDevice::GetApplicationList() const { - return ApplicationList{100}; + return ApplicationList{0}; } const std::string& CloudDevice::GetHost() { diff --git a/src/components/transport_manager/src/cloud/cloud_websocket_transport_adapter.cc b/src/components/transport_manager/src/cloud/cloud_websocket_transport_adapter.cc index 2ad1a66126..f811f1eeed 100644 --- a/src/components/transport_manager/src/cloud/cloud_websocket_transport_adapter.cc +++ b/src/components/transport_manager/src/cloud/cloud_websocket_transport_adapter.cc @@ -84,11 +84,27 @@ void CloudWebsocketTransportAdapter::CreateDevice(const std::string& uid) { } LOG4CXX_DEBUG(logger_, "Valid Endpoint: " << uid); - std::size_t pos = uid.find(":"); - pos = uid.find(":", pos + 1); - // std::size_t size = uid.length(); - std::string host = uid.substr(0, pos); - std::string port = uid.substr(pos + 1); + + // Port after second colon in valid endpoint string + std::size_t pos_port = uid.find(":"); + pos_port = uid.find(":", pos_port + 1); + + // Extract host and port from endpoint string + boost::regex group_pattern("(wss?:\\/\\/)([A-Z\\d\\.-]{2,}\\.?([A-Z]{2,})?)(:)(\\d{2,4})(\\/)"); + boost::smatch results; + + std::string host = ""; + std::string port = ""; + if (boost::regex_search(str, results, group_pattern)) { + host = results[2]; + port = results[5]; + + LOG4CXX_DEBUG(logger_, "Results: " << results[0] << " " << results[1] << " " << results[2] << " " << results[3] << " " << results[4] << " " << results[5] << " "); + } else { + LOG4CXX_DEBUG(logger_, "Invalid Pattern: " << uid); + return; + } + std::string device_id = uid; LOG4CXX_DEBUG(logger_, -- cgit v1.2.1 From f8f072b8b3a72c093080c397c489e7c1c2e70895 Mon Sep 17 00:00:00 2001 From: JackLivio Date: Mon, 26 Nov 2018 15:48:33 -0500 Subject: Style --- src/components/application_manager/src/application_impl.cc | 3 +-- .../src/cloud/cloud_websocket_transport_adapter.cc | 8 ++++++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/components/application_manager/src/application_impl.cc b/src/components/application_manager/src/application_impl.cc index 379e73bce9..80b25dc814 100644 --- a/src/components/application_manager/src/application_impl.cc +++ b/src/components/application_manager/src/application_impl.cc @@ -1186,8 +1186,7 @@ const std::string& ApplicationImpl::cloud_app_certificate() const { bool ApplicationImpl::is_cloud_app() const { return !endpoint_.empty() && - hybrid_app_preference_ != - mobile_apis::HybridAppPreference::MOBILE; + hybrid_app_preference_ != mobile_apis::HybridAppPreference::MOBILE; } void ApplicationImpl::set_cloud_app_endpoint(const std::string& endpoint) { diff --git a/src/components/transport_manager/src/cloud/cloud_websocket_transport_adapter.cc b/src/components/transport_manager/src/cloud/cloud_websocket_transport_adapter.cc index f811f1eeed..1ef62c6368 100644 --- a/src/components/transport_manager/src/cloud/cloud_websocket_transport_adapter.cc +++ b/src/components/transport_manager/src/cloud/cloud_websocket_transport_adapter.cc @@ -90,7 +90,8 @@ void CloudWebsocketTransportAdapter::CreateDevice(const std::string& uid) { pos_port = uid.find(":", pos_port + 1); // Extract host and port from endpoint string - boost::regex group_pattern("(wss?:\\/\\/)([A-Z\\d\\.-]{2,}\\.?([A-Z]{2,})?)(:)(\\d{2,4})(\\/)"); + boost::regex group_pattern( + "(wss?:\\/\\/)([A-Z\\d\\.-]{2,}\\.?([A-Z]{2,})?)(:)(\\d{2,4})(\\/)"); boost::smatch results; std::string host = ""; @@ -99,7 +100,10 @@ void CloudWebsocketTransportAdapter::CreateDevice(const std::string& uid) { host = results[2]; port = results[5]; - LOG4CXX_DEBUG(logger_, "Results: " << results[0] << " " << results[1] << " " << results[2] << " " << results[3] << " " << results[4] << " " << results[5] << " "); + LOG4CXX_DEBUG(logger_, + "Results: " << results[0] << " " << results[1] << " " + << results[2] << " " << results[3] << " " + << results[4] << " " << results[5] << " "); } else { LOG4CXX_DEBUG(logger_, "Invalid Pattern: " << uid); return; -- cgit v1.2.1 From 72dd30d2a4595d713f47b2719c5eec21c34f7eec Mon Sep 17 00:00:00 2001 From: jacobkeeler Date: Mon, 26 Nov 2018 17:07:32 -0500 Subject: Add is_completed to timer --- .../src/transport_adapter/transport_adapter_impl.cc | 2 +- src/components/utils/include/utils/timer.h | 16 ++++++++++------ src/components/utils/src/timer.cc | 17 ++++++++++++----- 3 files changed, 23 insertions(+), 12 deletions(-) diff --git a/src/components/transport_manager/src/transport_adapter/transport_adapter_impl.cc b/src/components/transport_manager/src/transport_adapter/transport_adapter_impl.cc index 02eb721238..fd6c8e21dc 100644 --- a/src/components/transport_manager/src/transport_adapter/transport_adapter_impl.cc +++ b/src/components/transport_manager/src/transport_adapter/transport_adapter_impl.cc @@ -294,7 +294,7 @@ DeviceUID TransportAdapterImpl::GetNextRetryDevice() { sync_primitives::AutoLock locker(retry_timer_pool_lock_); while (!retry_timer_pool_.empty()) { auto timer_entry = retry_timer_pool_.front(); - if (timer_entry.first->is_running()) { + if (!timer_entry.first->is_completed()) { return timer_entry.second; } retry_timer_pool_.pop(); diff --git a/src/components/utils/include/utils/timer.h b/src/components/utils/include/utils/timer.h index e391db992c..b012b97e6a 100644 --- a/src/components/utils/include/utils/timer.h +++ b/src/components/utils/include/utils/timer.h @@ -102,6 +102,8 @@ class Timer { */ bool is_running() const; + bool is_completed() const; + /** * @brief Gets current timer timeout * @return Current timeout in milliseconds. @@ -119,7 +121,7 @@ class Timer { * @brief Constructor * @param timer Timer instance pointer for callback calling */ - TimerDelegate(const Timer* timer, sync_primitives::Lock& state_lock_ref); + TimerDelegate(Timer* timer, sync_primitives::Lock& state_lock_ref); /** * @brief Sets timer timeout @@ -161,7 +163,7 @@ class Timer { void exitThreadMain() OVERRIDE; private: - const Timer* timer_; + Timer* timer_; Milliseconds timeout_; /** @@ -187,13 +189,13 @@ class Timer { * Not thread-safe * @param timeout Timer timeout */ - void StartDelegate(const Milliseconds timeout) const; + void StartDelegate(const Milliseconds timeout); /** * @brief Sets up timer delegate to stop state. * Not thread-safe */ - void StopDelegate() const; + void StopDelegate(); /** * @brief Starts timer thread. @@ -211,14 +213,14 @@ class Timer { * @brief Callback called on timeout. * Not thread-safe */ - void OnTimeout() const; + void OnTimeout(); const std::string name_; TimerTask* task_; mutable sync_primitives::Lock state_lock_; - mutable std::unique_ptr delegate_; + std::unique_ptr delegate_; threads::Thread* thread_; /** @@ -226,6 +228,8 @@ class Timer { */ bool single_shot_; + bool completed_flag_; + DISALLOW_COPY_AND_ASSIGN(Timer); }; diff --git a/src/components/utils/src/timer.cc b/src/components/utils/src/timer.cc index b819b56f54..68693dfc55 100644 --- a/src/components/utils/src/timer.cc +++ b/src/components/utils/src/timer.cc @@ -49,7 +49,8 @@ timer::Timer::Timer(const std::string& name, TimerTask* task) , state_lock_() , delegate_(new TimerDelegate(this, state_lock_)) , thread_(threads::CreateThread(name_.c_str(), delegate_.get())) - , single_shot_(true) { + , single_shot_(true) + , completed_flag_(false) { LOG4CXX_AUTO_TRACE(logger_); DCHECK(!name_.empty()); DCHECK(task_); @@ -76,6 +77,7 @@ void timer::Timer::Start(const Milliseconds timeout, LOG4CXX_AUTO_TRACE(logger_); sync_primitives::AutoLock auto_lock(state_lock_); StopThread(); + completed_flag_ = false; switch (timer_type) { case kSingleShot: { single_shot_ = true; @@ -106,17 +108,21 @@ bool timer::Timer::is_running() const { return !delegate_->stop_flag(); } +bool timer::Timer::is_completed() const { + return completed_flag_; +} + timer::Milliseconds timer::Timer::timeout() const { sync_primitives::AutoLock auto_lock(state_lock_); return delegate_->timeout(); } -void timer::Timer::StartDelegate(const Milliseconds timeout) const { +void timer::Timer::StartDelegate(const Milliseconds timeout) { delegate_->set_stop_flag(false); delegate_->set_timeout(timeout); } -void timer::Timer::StopDelegate() const { +void timer::Timer::StopDelegate() { delegate_->set_stop_flag(true); delegate_->set_timeout(0); } @@ -148,7 +154,7 @@ void timer::Timer::StopThread() { } } -void timer::Timer::OnTimeout() const { +void timer::Timer::OnTimeout() { { sync_primitives::AutoLock auto_lock(state_lock_); if (single_shot_) { @@ -158,10 +164,11 @@ void timer::Timer::OnTimeout() const { DCHECK_OR_RETURN_VOID(task_); task_->run(); + completed_flag_ = true; } timer::Timer::TimerDelegate::TimerDelegate( - const Timer* timer, sync_primitives::Lock& state_lock_ref) + Timer* timer, sync_primitives::Lock& state_lock_ref) : timer_(timer) , timeout_(0) , stop_flag_(true) -- cgit v1.2.1 From 67ced66e07cab0c8da53848a878ca443edaa373d Mon Sep 17 00:00:00 2001 From: jacobkeeler Date: Tue, 27 Nov 2018 09:08:15 -0500 Subject: Fix unitialized connection key --- .../transport_manager/src/transport_adapter/transport_adapter_impl.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/components/transport_manager/src/transport_adapter/transport_adapter_impl.cc b/src/components/transport_manager/src/transport_adapter/transport_adapter_impl.cc index fd6c8e21dc..95c6ce6fc9 100644 --- a/src/components/transport_manager/src/transport_adapter/transport_adapter_impl.cc +++ b/src/components/transport_manager/src/transport_adapter/transport_adapter_impl.cc @@ -211,7 +211,8 @@ TransportAdapter::Error TransportAdapterImpl::Connect( connections_lock_.AcquireForWriting(); - std::pair connection_key; + std::pair connection_key = + std::make_pair(device_id, app_handle); const bool already_exists = connections_.end() != connections_.find(connection_key); ConnectionInfo& info = connections_[connection_key]; -- cgit v1.2.1 From b8b62f61f838eac48a181bcf715cf8a8141b2f55 Mon Sep 17 00:00:00 2001 From: jacobkeeler Date: Tue, 27 Nov 2018 15:06:13 -0500 Subject: Fix build issues and test failures --- .../test/include/application_manager/mock_application.h | 2 +- .../include/test/application_manager/mock_application_manager.h | 2 +- .../include/test/connection_handler/mock_connection_handler.h | 2 +- src/components/include/test/transport_manager/mock_transport_manager.h | 2 +- .../test/transport_manager/transport_adapter/mock_transport_adapter.h | 3 ++- src/components/transport_manager/test/transport_adapter_test.cc | 3 ++- 6 files changed, 8 insertions(+), 6 deletions(-) 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 ef6b29f2dc..d5b3752936 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 @@ -340,7 +340,6 @@ class MockApplication : public ::application_manager::Application { MOCK_METHOD1(RemoveExtension, bool(application_manager::AppExtensionUID uid)); MOCK_CONST_METHOD0(Extensions, const std::list&()); - MOCK_CONST_METHOD1(is_cloud_app, bool()); MOCK_CONST_METHOD0(is_remote_control_supported, bool()); MOCK_METHOD1(set_remote_control_supported, void(const bool allow)); MOCK_CONST_METHOD0(cloud_app_endpoint, const std::string&()); @@ -349,6 +348,7 @@ class MockApplication : public ::application_manager::Application { MOCK_CONST_METHOD0(hybrid_app_preference, const mobile_apis::HybridAppPreference::eType&()); MOCK_CONST_METHOD0(cloud_app_certificate, const std::string&()); + MOCK_CONST_METHOD0(is_cloud_app, bool()); MOCK_METHOD1(set_cloud_app_endpoint, void(const std::string& endpoint)); MOCK_METHOD1(set_cloud_app_auth_token, void(const std::string& auth_token)); MOCK_METHOD1(set_cloud_app_transport_type, diff --git a/src/components/include/test/application_manager/mock_application_manager.h b/src/components/include/test/application_manager/mock_application_manager.h index e18d68cfba..ca8aa2eb96 100644 --- a/src/components/include/test/application_manager/mock_application_manager.h +++ b/src/components/include/test/application_manager/mock_application_manager.h @@ -168,7 +168,7 @@ class MockApplicationManager : public application_manager::ApplicationManager { MOCK_METHOD0(OnHMIStartedCooperation, void()); MOCK_CONST_METHOD1(GetCloudAppConnectionStatus, hmi_apis::Common_CloudConnectionStatus::eType( - ApplicationConstSharedPtr app)); + application_manager::ApplicationConstSharedPtr app)); MOCK_CONST_METHOD0(IsHMICooperating, bool()); MOCK_METHOD2(IviInfoUpdated, void(mobile_apis::VehicleDataType::eType vehicle_info, diff --git a/src/components/include/test/connection_handler/mock_connection_handler.h b/src/components/include/test/connection_handler/mock_connection_handler.h index 46e1d54bb6..1e843090b4 100644 --- a/src/components/include/test/connection_handler/mock_connection_handler.h +++ b/src/components/include/test/connection_handler/mock_connection_handler.h @@ -61,7 +61,7 @@ class MockConnectionHandler : public connection_handler::ConnectionHandler { MOCK_METHOD1(ConnectToDevice, void(connection_handler::DeviceHandle device_handle)); MOCK_CONST_METHOD1(GetConnectionStatus, - ConnectionStatus(const DeviceHandle& device_handle)); + transport_manager::ConnectionStatus(const DeviceHandle& device_handle)); MOCK_CONST_METHOD2(RunAppOnDevice, void(const std::string&, const std::string&)); MOCK_METHOD0(ConnectToAllDevices, void()); diff --git a/src/components/include/test/transport_manager/mock_transport_manager.h b/src/components/include/test/transport_manager/mock_transport_manager.h index 5af47bdcd9..951cda49b6 100644 --- a/src/components/include/test/transport_manager/mock_transport_manager.h +++ b/src/components/include/test/transport_manager/mock_transport_manager.h @@ -64,7 +64,7 @@ class MockTransportManager : public ::transport_manager::TransportManager, const std::string& cloud_transport_type)); MOCK_METHOD1(ConnectDevice, int(const DeviceHandle)); MOCK_CONST_METHOD1(GetConnectionStatus, - ConnectionStatus(const DeviceHandle& device_handle)); + transport_manager::ConnectionStatus(const DeviceHandle& device_handle)); MOCK_METHOD1(DisconnectDevice, int(const DeviceHandle)); MOCK_METHOD1(Disconnect, int(const ConnectionUID)); MOCK_METHOD1(DisconnectForce, int(const ConnectionUID)); diff --git a/src/components/include/test/transport_manager/transport_adapter/mock_transport_adapter.h b/src/components/include/test/transport_manager/transport_adapter/mock_transport_adapter.h index 6e3ceccd64..65cfdae4d5 100644 --- a/src/components/include/test/transport_manager/transport_adapter/mock_transport_adapter.h +++ b/src/components/include/test/transport_manager/transport_adapter/mock_transport_adapter.h @@ -67,7 +67,8 @@ class MockTransportAdapter ::transport_manager::transport_adapter::TransportAdapter::Error( const ::transport_manager::DeviceUID& device_handle)); MOCK_CONST_METHOD1(GetConnectionStatus, - ConnectionStatus(const DeviceUID& device_handle)); + ::transport_manager::ConnectionStatus( + const ::transport_manager::DeviceUID& device_handle)); MOCK_METHOD2(RunAppOnDevice, void(const std::string&, const std::string&)); MOCK_CONST_METHOD0(IsClientOriginatedConnectSupported, bool()); MOCK_METHOD0( diff --git a/src/components/transport_manager/test/transport_adapter_test.cc b/src/components/transport_manager/test/transport_adapter_test.cc index 9e602332c6..0a7db52c97 100644 --- a/src/components/transport_manager/test/transport_adapter_test.cc +++ b/src/components/transport_manager/test/transport_adapter_test.cc @@ -439,7 +439,8 @@ TEST_F(TransportAdapterTest, DisconnectDevice_DeviceAddedConnectionCreated) { EXPECT_CALL(*serverMock, IsInitialised()).WillOnce(Return(true)); EXPECT_CALL(*serverMock, CreateConnection(uniq_id, app_handle)) .WillOnce(Return(TransportAdapter::OK)); - EXPECT_CALL(transport_adapter, FindDevice(uniq_id)).WillOnce(Return(mockdev)); + EXPECT_CALL(transport_adapter, FindDevice(uniq_id)) + .WillRepeatedly(Return(mockdev)); TransportAdapter::Error res = transport_adapter.ConnectDevice(uniq_id); EXPECT_EQ(TransportAdapter::OK, res); -- cgit v1.2.1 From d157a8bef4619b845febc953f18fd3b0af2d3b7f Mon Sep 17 00:00:00 2001 From: jacobkeeler Date: Tue, 27 Nov 2018 15:07:26 -0500 Subject: Update ActivateApp timeout for cloud apps --- .../src/commands/hmi/sdl_activate_app_request.cc | 10 ++++++++++ .../include/application_manager/application_manager_settings.h | 2 ++ .../application_manager/mock_application_manager_settings.h | 2 ++ 3 files changed, 14 insertions(+) diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/sdl_activate_app_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/sdl_activate_app_request.cc index 1704251c17..12f595e64e 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/sdl_activate_app_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/sdl_activate_app_request.cc @@ -128,6 +128,11 @@ void SDLActivateAppRequest::Run() { "HMIDeactivate is active"); } else if (app && !app->IsRegistered() && app->is_cloud_app()) { LOG4CXX_DEBUG(logger_, "Starting cloud application."); + const ApplicationManagerSettings& settings = application_manager_.get_settings(); + uint32_t total_retry_timeout = (settings.cloud_app_retry_timeout() * + settings.cloud_app_max_retry_attempts()); + application_manager_.updateRequestTimeout( + 0, correlation_id(), default_timeout_ + total_retry_timeout); subscribe_on_event(BasicCommunication_OnAppRegistered); application_manager_.connection_handler().ConnectToDevice(app->device()); } else { @@ -189,6 +194,11 @@ void SDLActivateAppRequest::Run() { return; } else if (app_to_activate->is_cloud_app()) { LOG4CXX_DEBUG(logger_, "Starting cloud application."); + const ApplicationManagerSettings& settings = application_manager_.get_settings(); + uint32_t total_retry_timeout = (settings.cloud_app_retry_timeout() * + settings.cloud_app_max_retry_attempts()); + application_manager_.updateRequestTimeout( + 0, correlation_id(), default_timeout_ + total_retry_timeout); subscribe_on_event(BasicCommunication_OnAppRegistered); application_manager_.connection_handler().ConnectToDevice( app_to_activate->device()); diff --git a/src/components/include/application_manager/application_manager_settings.h b/src/components/include/application_manager/application_manager_settings.h index 8fdca4125f..fc16f1f1ed 100644 --- a/src/components/include/application_manager/application_manager_settings.h +++ b/src/components/include/application_manager/application_manager_settings.h @@ -85,6 +85,8 @@ class ApplicationManagerSettings : public RequestControlerSettings, virtual const std::string& audio_stream_file() const = 0; virtual bool use_full_app_id() const = 0; + virtual uint32_t cloud_app_retry_timeout() const = 0; + virtual uint16_t cloud_app_max_retry_attempts() const = 0; virtual bool use_db_for_resumption() const = 0; virtual const uint32_t& app_resumption_save_persistent_data_timeout() const = 0; diff --git a/src/components/include/test/application_manager/mock_application_manager_settings.h b/src/components/include/test/application_manager/mock_application_manager_settings.h index cfabf41b91..0f9ca194b1 100644 --- a/src/components/include/test/application_manager/mock_application_manager_settings.h +++ b/src/components/include/test/application_manager/mock_application_manager_settings.h @@ -90,6 +90,8 @@ class MockApplicationManagerSettings MOCK_CONST_METHOD0(video_stream_file, const std::string&()); MOCK_CONST_METHOD0(audio_stream_file, const std::string&()); MOCK_CONST_METHOD0(use_full_app_id, bool()); + MOCK_CONST_METHOD0(cloud_app_retry_timeout, uint32_t()); + MOCK_CONST_METHOD0(cloud_app_max_retry_attempts, uint16_t()); MOCK_CONST_METHOD0(use_db_for_resumption, bool()); MOCK_CONST_METHOD0(app_resumption_save_persistent_data_timeout, const uint32_t&()); -- cgit v1.2.1 From b6d7da141931249923729c9f14ae5bf9109e9a82 Mon Sep 17 00:00:00 2001 From: JackLivio Date: Tue, 27 Nov 2018 15:08:05 -0500 Subject: Address Comments and Remove Unused Code --- src/appMain/smartDeviceLink.ini | 2 +- .../src/application_manager_impl.cc | 5 ++++- src/components/config_profile/src/profile.cc | 2 +- .../src/connection_handler_impl.cc | 2 -- .../transport_adapter/transport_adapter.h | 21 --------------------- .../include/transport_manager/cloud/cloud_device.h | 4 ++-- .../cloud/cloud_websocket_transport_adapter.h | 20 -------------------- .../transport_manager/src/cloud/cloud_device.cc | 19 +++++++++++++------ .../src/cloud/cloud_websocket_transport_adapter.cc | 15 ++------------- .../src/cloud/websocket_client_connection.cc | 2 +- 10 files changed, 24 insertions(+), 68 deletions(-) diff --git a/src/appMain/smartDeviceLink.ini b/src/appMain/smartDeviceLink.ini index ac3e1c983a..ccb377d1e6 100644 --- a/src/appMain/smartDeviceLink.ini +++ b/src/appMain/smartDeviceLink.ini @@ -202,7 +202,7 @@ TCPAdapterPort = 12345 ; If the name is omitted, Core will listen on all network interfaces by binding to INADDR_ANY. TCPAdapterNetworkInterface = -[Cloud App Connections] +[CloudAppConnections] ; Value in milliseconds for time between retry attempts on a failed websocket connection CloudAppRetryTimeout = 1000 ; MaxNn number of retry attempts for a cloud websocket connection diff --git a/src/components/application_manager/src/application_manager_impl.cc b/src/components/application_manager/src/application_manager_impl.cc index 1cec8b5ca2..ef008b7200 100644 --- a/src/components/application_manager/src/application_manager_impl.cc +++ b/src/components/application_manager/src/application_manager_impl.cc @@ -795,8 +795,10 @@ void ApplicationManagerImpl::CollectCloudAppInformation() { std::string auth_token = ""; std::string cloud_transport_type = ""; std::string hybrid_app_preference = ""; + bool enabled = true; for (; it != end; ++it) { GetPolicyHandler().GetCloudAppParameters(*it, + enabled, endpoint, certificate, auth_token, @@ -821,7 +823,7 @@ void ApplicationManagerImpl::CreatePendingApplication( std::string auth_token = ""; std::string cloud_transport_type = ""; std::string hybrid_app_preference_str = ""; - + bool enabled = true; std::string name = device_info.name(); auto it = pending_device_map_.find(name); if (it == pending_device_map_.end()) { @@ -858,6 +860,7 @@ void ApplicationManagerImpl::CreatePendingApplication( } GetPolicyHandler().GetCloudAppParameters(policy_app_id, + enabled, endpoint, certificate, auth_token, diff --git a/src/components/config_profile/src/profile.cc b/src/components/config_profile/src/profile.cc index c10f81a869..38afdbf35b 100644 --- a/src/components/config_profile/src/profile.cc +++ b/src/components/config_profile/src/profile.cc @@ -81,7 +81,7 @@ const char* kMediaManagerSection = "MEDIA MANAGER"; const char* kGlobalPropertiesSection = "GLOBAL PROPERTIES"; const char* kVrCommandsSection = "VR COMMANDS"; const char* kTransportManagerSection = "TransportManager"; -const char* kCloudAppTransportSection = "Cloud App Connections"; +const char* kCloudAppTransportSection = "CloudAppConnections"; const char* kApplicationManagerSection = "ApplicationManager"; const char* kFilesystemRestrictionsSection = "FILESYSTEM RESTRICTIONS"; const char* kIAPSection = "IAP"; diff --git a/src/components/connection_handler/src/connection_handler_impl.cc b/src/components/connection_handler/src/connection_handler_impl.cc index 318224fcc7..ed2522593c 100644 --- a/src/components/connection_handler/src/connection_handler_impl.cc +++ b/src/components/connection_handler/src/connection_handler_impl.cc @@ -266,7 +266,6 @@ void ConnectionHandlerImpl::OnConnectionPending( LOG4CXX_DEBUG(logger_, "Add Pending Connection #" << connection_id << " to the list."); - // todo maybe create a seperate "pending_connection_list" sync_primitives::AutoWriteLock lock(connection_list_lock_); if (connection_list_.find(connection_id) == connection_list_.end()) { Connection* connection = @@ -280,7 +279,6 @@ void ConnectionHandlerImpl::OnConnectionPending( connection_handler::DeviceHandle device_id = connection->connection_device_handle(); - // uint32_t app_id = KeyFromPair(connection_id, session_id); connection_handler_observer_->CreatePendingApplication( connection_id, device_info, device_id); diff --git a/src/components/include/transport_manager/transport_adapter/transport_adapter.h b/src/components/include/transport_manager/transport_adapter/transport_adapter.h index 4aa6e901ad..aae4a8b569 100644 --- a/src/components/include/transport_manager/transport_adapter/transport_adapter.h +++ b/src/components/include/transport_manager/transport_adapter/transport_adapter.h @@ -71,21 +71,6 @@ enum DeviceType { UNKNOWN }; -enum HybridAppPreference { // todo find correct place for this enum defintion. - MOBILE, - CLOUD, - BOTH -}; - -struct CloudAppProperties { - std::string endpoint; - std::string certificate; - bool enabled; - std::string auth_token; - DeviceType cloud_transport_type; - HybridAppPreference hybrid_app_preference; -}; - typedef std::map DeviceTypes; /** @@ -104,12 +89,6 @@ typedef std::list TransportAdapterListenerList; */ typedef std::map TransportConfig; -/** - * @brief Type definition of container indexed by app id that contains - * connection information for all cloud apps. - */ -typedef std::map CloudAppTransportConfig; - /** * @brief TransportConfig keys */ diff --git a/src/components/transport_manager/include/transport_manager/cloud/cloud_device.h b/src/components/transport_manager/include/transport_manager/cloud/cloud_device.h index 8eac8c6f75..47a82e7921 100644 --- a/src/components/transport_manager/include/transport_manager/cloud/cloud_device.h +++ b/src/components/transport_manager/include/transport_manager/cloud/cloud_device.h @@ -47,9 +47,9 @@ class CloudDevice : public Device { public: CloudDevice(std::string& host, std::string& port, std::string& name); - virtual const std::string& GetHost(); + virtual const std::string& GetHost() const; - virtual const std::string& GetPort(); + virtual const std::string& GetPort() const; protected: virtual bool IsSameAs(const Device* other_device) const; diff --git a/src/components/transport_manager/include/transport_manager/cloud/cloud_websocket_transport_adapter.h b/src/components/transport_manager/include/transport_manager/cloud/cloud_websocket_transport_adapter.h index 546ab71fbd..d52e4b307d 100644 --- a/src/components/transport_manager/include/transport_manager/cloud/cloud_websocket_transport_adapter.h +++ b/src/components/transport_manager/include/transport_manager/cloud/cloud_websocket_transport_adapter.h @@ -58,18 +58,6 @@ class CloudWebsocketTransportAdapter : public TransportAdapterImpl { */ virtual ~CloudWebsocketTransportAdapter(); - /** - * @brief Notification that transport's configuration is updated - * - * @param new_config The new configuration of the transport - */ - void CloudTransportConfigUpdated(const CloudAppTransportConfig& new_config); - - /** - * @brief Returns the transport's configuration information - */ - CloudAppTransportConfig GetCloudTransportConfiguration() const; - protected: /** * @brief Return type of device. @@ -93,14 +81,6 @@ class CloudWebsocketTransportAdapter : public TransportAdapterImpl { void CreateDevice(const std::string& uid) OVERRIDE; private: - /** - * @brief Keeps transport specific configuration - * - * Cloud websocket transport uses following information: - * - "enabled": whether the transport is currently enabled or not. Value can - * be "true" or "false". - */ - CloudAppTransportConfig transport_config_; }; } // namespace transport_adapter diff --git a/src/components/transport_manager/src/cloud/cloud_device.cc b/src/components/transport_manager/src/cloud/cloud_device.cc index 6196bcc87e..90a485c069 100644 --- a/src/components/transport_manager/src/cloud/cloud_device.cc +++ b/src/components/transport_manager/src/cloud/cloud_device.cc @@ -46,21 +46,28 @@ CloudDevice::CloudDevice(std::string& host, bool CloudDevice::IsSameAs(const Device* other) const { LOG4CXX_TRACE(logger_, "enter. device: " << other); - bool result = false; - return result; + + const CloudDevice* other_cloud_device = + dynamic_cast(other); + + if (host_ != other_cloud_device->GetHost()) { + return false; + } + if (port_ != other_cloud_device->GetPort()) { + return false; + } + return true; } -// todo implement getApplicationList -// to be populated by policies ApplicationList CloudDevice::GetApplicationList() const { return ApplicationList{100}; } -const std::string& CloudDevice::GetHost() { +const std::string& CloudDevice::GetHost() const { return host_; } -const std::string& CloudDevice::GetPort() { +const std::string& CloudDevice::GetPort() const { return port_; } diff --git a/src/components/transport_manager/src/cloud/cloud_websocket_transport_adapter.cc b/src/components/transport_manager/src/cloud/cloud_websocket_transport_adapter.cc index 874f158145..24efdfb2a4 100644 --- a/src/components/transport_manager/src/cloud/cloud_websocket_transport_adapter.cc +++ b/src/components/transport_manager/src/cloud/cloud_websocket_transport_adapter.cc @@ -53,23 +53,13 @@ CloudWebsocketTransportAdapter::CloudWebsocketTransportAdapter( CloudWebsocketTransportAdapter::~CloudWebsocketTransportAdapter() {} -void CloudWebsocketTransportAdapter::CloudTransportConfigUpdated( - const CloudAppTransportConfig& new_config) {} - -CloudAppTransportConfig -CloudWebsocketTransportAdapter::GetCloudTransportConfiguration() const { - return transport_config_; -} - DeviceType CloudWebsocketTransportAdapter::GetDeviceType() const { return CLOUD_WEBSOCKET; } -void CloudWebsocketTransportAdapter::Store() const { -} // todo decide if this is needed +void CloudWebsocketTransportAdapter::Store() const {} -bool CloudWebsocketTransportAdapter::Restore() { // todo decide if resumption - // is needed +bool CloudWebsocketTransportAdapter::Restore() { return true; } @@ -95,7 +85,6 @@ void CloudWebsocketTransportAdapter::CreateDevice(const std::string& uid) { "Creating Cloud Device For Host: " << host << " and Port: " << port); - // todo get nickname from policies to name device auto cloud_device = std::make_shared(host, port, device_id); DeviceVector devices{cloud_device}; diff --git a/src/components/transport_manager/src/cloud/websocket_client_connection.cc b/src/components/transport_manager/src/cloud/websocket_client_connection.cc index 0912a07999..4f585c8efb 100644 --- a/src/components/transport_manager/src/cloud/websocket_client_connection.cc +++ b/src/components/transport_manager/src/cloud/websocket_client_connection.cc @@ -1,6 +1,6 @@ /* * - * Copyright (c) 2017, Ford Motor Company + * Copyright (c) 2018, Livio * All rights reserved. * * Redistribution and use in source and binary forms, with or without -- cgit v1.2.1 From 7b8febf95531d5a576332e9c347eb1aa73d0077b Mon Sep 17 00:00:00 2001 From: jacobkeeler Date: Tue, 27 Nov 2018 17:43:12 -0500 Subject: Add method headers and fix style Also fix issues with retry timer management --- .../include/application_manager/application.h | 4 +++ .../include/application_manager/application_impl.h | 4 +++ .../application_manager/application_manager_impl.h | 5 ++++ .../mobile/register_app_interface_request.h | 7 +++-- .../src/commands/hmi/sdl_activate_app_request.cc | 6 ++-- .../connection_handler/connection_handler_impl.h | 9 +++++- .../application_manager/application_manager.h | 5 ++++ .../connection_handler/connection_handler.h | 7 +++++ .../connection_handler/mock_connection_handler.h | 5 ++-- .../transport_manager/mock_transport_manager.h | 5 ++-- .../transport_manager/transport_adapter/device.h | 18 ++++++++++++ .../transport_adapter/transport_adapter.h | 7 +++++ .../include/transport_manager/transport_manager.h | 7 +++++ .../transport_adapter/transport_adapter_impl.h | 32 +++++++++++++++++++++- .../transport_manager/transport_manager_impl.h | 7 +++++ .../transport_adapter/transport_adapter_impl.cc | 27 ++++++++++++------ 16 files changed, 137 insertions(+), 18 deletions(-) diff --git a/src/components/application_manager/include/application_manager/application.h b/src/components/application_manager/include/application_manager/application.h index 48c2183541..7a59263299 100644 --- a/src/components/application_manager/include/application_manager/application.h +++ b/src/components/application_manager/include/application_manager/application.h @@ -980,6 +980,10 @@ class Application : public virtual InitialApplicationData, */ virtual const std::string& cloud_app_certificate() const = 0; + /** + * @brief Check whether the given application is a cloud app. + * @return true if the application is a cloud application, false otherwise. + */ virtual bool is_cloud_app() const = 0; /** diff --git a/src/components/application_manager/include/application_manager/application_impl.h b/src/components/application_manager/include/application_manager/application_impl.h index d21a742e2f..6d627d0c67 100644 --- a/src/components/application_manager/include/application_manager/application_impl.h +++ b/src/components/application_manager/include/application_manager/application_impl.h @@ -443,6 +443,10 @@ class ApplicationImpl : public virtual Application, */ const std::string& cloud_app_certificate() const OVERRIDE; + /** + * @brief Check whether the given application is a cloud app. + * @return true if the application is a cloud application, false otherwise. + */ bool is_cloud_app() const OVERRIDE; /** diff --git a/src/components/application_manager/include/application_manager/application_manager_impl.h b/src/components/application_manager/include/application_manager/application_manager_impl.h index f235a4e482..58e066461f 100644 --- a/src/components/application_manager/include/application_manager/application_manager_impl.h +++ b/src/components/application_manager/include/application_manager/application_manager_impl.h @@ -367,6 +367,11 @@ class ApplicationManagerImpl const transport_manager::DeviceInfo& device_info, connection_handler::DeviceHandle device_id); + /** + * @brief Retrieve the current connection status of a cloud app + * @param app A cloud application + * @return The current CloudConnectionStatus of app + */ hmi_apis::Common_CloudConnectionStatus::eType GetCloudAppConnectionStatus( ApplicationConstSharedPtr app) const; diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/register_app_interface_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/register_app_interface_request.h index d0e70e906a..f8be896996 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/register_app_interface_request.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/register_app_interface_request.h @@ -124,8 +124,11 @@ class RegisterAppInterfaceRequest /** * @brief Sends OnAppRegistered notification to HMI * - *@param application_impl application with changed HMI status - * + * @param app application with changed HMI status + * @param resumption If true, resumption-related parameters will be sent to + *the HMI + * @param need_restore_vr If resumption is true, whether or not VR commands + *should be resumed **/ void SendOnAppRegisteredNotificationToHMI( app_mngr::ApplicationConstSharedPtr app, diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/sdl_activate_app_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/sdl_activate_app_request.cc index 12f595e64e..4a1fddc508 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/sdl_activate_app_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/sdl_activate_app_request.cc @@ -128,7 +128,8 @@ void SDLActivateAppRequest::Run() { "HMIDeactivate is active"); } else if (app && !app->IsRegistered() && app->is_cloud_app()) { LOG4CXX_DEBUG(logger_, "Starting cloud application."); - const ApplicationManagerSettings& settings = application_manager_.get_settings(); + const ApplicationManagerSettings& settings = + application_manager_.get_settings(); uint32_t total_retry_timeout = (settings.cloud_app_retry_timeout() * settings.cloud_app_max_retry_attempts()); application_manager_.updateRequestTimeout( @@ -194,7 +195,8 @@ void SDLActivateAppRequest::Run() { return; } else if (app_to_activate->is_cloud_app()) { LOG4CXX_DEBUG(logger_, "Starting cloud application."); - const ApplicationManagerSettings& settings = application_manager_.get_settings(); + const ApplicationManagerSettings& settings = + application_manager_.get_settings(); uint32_t total_retry_timeout = (settings.cloud_app_retry_timeout() * settings.cloud_app_max_retry_attempts()); application_manager_.updateRequestTimeout( diff --git a/src/components/connection_handler/include/connection_handler/connection_handler_impl.h b/src/components/connection_handler/include/connection_handler/connection_handler_impl.h index 4d4e31f999..cbf829b226 100644 --- a/src/components/connection_handler/include/connection_handler/connection_handler_impl.h +++ b/src/components/connection_handler/include/connection_handler/connection_handler_impl.h @@ -102,10 +102,17 @@ class ConnectionHandlerImpl /** * \brief Connects to all services of device - * \param deviceHandle Handle of device to connect to + * \param device_handle Handle of device to connect to */ void ConnectToDevice(connection_handler::DeviceHandle device_handle) OVERRIDE; + /** + * @brief Retrieves the connection status of a given device + * + * @param device_handle Handle of device to query + * + * @return The connection status of the given device + */ transport_manager::ConnectionStatus GetConnectionStatus( const DeviceHandle& device_handle) const OVERRIDE; diff --git a/src/components/include/application_manager/application_manager.h b/src/components/include/application_manager/application_manager.h index e1907e25f0..9e979da08e 100644 --- a/src/components/include/application_manager/application_manager.h +++ b/src/components/include/application_manager/application_manager.h @@ -427,6 +427,11 @@ class ApplicationManager { virtual void OnHMIStartedCooperation() = 0; + /** + * @brief Retrieve the current connection status of a cloud app + * @param app A cloud application + * @return The current CloudConnectionStatus of app + */ virtual hmi_apis::Common_CloudConnectionStatus::eType GetCloudAppConnectionStatus(ApplicationConstSharedPtr app) const = 0; diff --git a/src/components/include/connection_handler/connection_handler.h b/src/components/include/connection_handler/connection_handler.h index 6d1e9e7c97..eb41141842 100644 --- a/src/components/include/connection_handler/connection_handler.h +++ b/src/components/include/connection_handler/connection_handler.h @@ -79,6 +79,13 @@ class ConnectionHandler { virtual void ConnectToDevice( connection_handler::DeviceHandle device_handle) = 0; + /** + * @brief Retrieves the connection status of a given device + * + * @param device_handle Handle of device to query + * + * @return The connection status of the given device + */ virtual transport_manager::ConnectionStatus GetConnectionStatus( const DeviceHandle& device_handle) const = 0; diff --git a/src/components/include/test/connection_handler/mock_connection_handler.h b/src/components/include/test/connection_handler/mock_connection_handler.h index 1e843090b4..5836626ae3 100644 --- a/src/components/include/test/connection_handler/mock_connection_handler.h +++ b/src/components/include/test/connection_handler/mock_connection_handler.h @@ -60,8 +60,9 @@ class MockConnectionHandler : public connection_handler::ConnectionHandler { MOCK_METHOD0(StartTransportManager, void()); MOCK_METHOD1(ConnectToDevice, void(connection_handler::DeviceHandle device_handle)); - MOCK_CONST_METHOD1(GetConnectionStatus, - transport_manager::ConnectionStatus(const DeviceHandle& device_handle)); + MOCK_CONST_METHOD1( + GetConnectionStatus, + transport_manager::ConnectionStatus(const DeviceHandle& device_handle)); MOCK_CONST_METHOD2(RunAppOnDevice, void(const std::string&, const std::string&)); MOCK_METHOD0(ConnectToAllDevices, void()); diff --git a/src/components/include/test/transport_manager/mock_transport_manager.h b/src/components/include/test/transport_manager/mock_transport_manager.h index 951cda49b6..555d51bf76 100644 --- a/src/components/include/test/transport_manager/mock_transport_manager.h +++ b/src/components/include/test/transport_manager/mock_transport_manager.h @@ -63,8 +63,9 @@ class MockTransportManager : public ::transport_manager::TransportManager, void(const std::string& endpoint, const std::string& cloud_transport_type)); MOCK_METHOD1(ConnectDevice, int(const DeviceHandle)); - MOCK_CONST_METHOD1(GetConnectionStatus, - transport_manager::ConnectionStatus(const DeviceHandle& device_handle)); + MOCK_CONST_METHOD1( + GetConnectionStatus, + transport_manager::ConnectionStatus(const DeviceHandle& device_handle)); MOCK_METHOD1(DisconnectDevice, int(const DeviceHandle)); MOCK_METHOD1(Disconnect, int(const ConnectionUID)); MOCK_METHOD1(DisconnectForce, int(const ConnectionUID)); diff --git a/src/components/include/transport_manager/transport_adapter/device.h b/src/components/include/transport_manager/transport_adapter/device.h index 17fd6b6950..ad035245d8 100644 --- a/src/components/include/transport_manager/transport_adapter/device.h +++ b/src/components/include/transport_manager/transport_adapter/device.h @@ -135,22 +135,40 @@ class Device { keep_on_disconnect_ = keep_on_disconnect; } + /** + * @brief Get @link status_ @endlink value + * @return current value + */ inline ConnectionStatus connection_status() const { return status_; } + /** + * @brief Set @link status_ @endlink value + * @param status new value + */ inline void set_connection_status(ConnectionStatus status) { status_ = status; } + /** + * @brief Get @link retry_count_ @endlink value + * @return current value + */ inline uint16_t retry_count() const { return retry_count_; } + /** + * @brief Increment @link retry_count_ @endlink value + */ inline void next_retry() { retry_count_++; } + /** + * @brief Reset @link retry_count_ @endlink value to 0 + */ inline void reset_retry_count() { retry_count_ = 0; } diff --git a/src/components/include/transport_manager/transport_adapter/transport_adapter.h b/src/components/include/transport_manager/transport_adapter/transport_adapter.h index c136148936..184ee79a13 100644 --- a/src/components/include/transport_manager/transport_adapter/transport_adapter.h +++ b/src/components/include/transport_manager/transport_adapter/transport_adapter.h @@ -217,6 +217,13 @@ class TransportAdapter { */ virtual Error ConnectDevice(const DeviceUID& device_handle) = 0; + /** + * @brief Retrieves the connection status of a given device + * + * @param device_handle Handle of device to query + * + * @return The connection status of the given device + */ virtual ConnectionStatus GetConnectionStatus( const DeviceUID& device_handle) const = 0; diff --git a/src/components/include/transport_manager/transport_manager.h b/src/components/include/transport_manager/transport_manager.h index 8fee6db6a5..3ecf815097 100644 --- a/src/components/include/transport_manager/transport_manager.h +++ b/src/components/include/transport_manager/transport_manager.h @@ -87,6 +87,13 @@ class TransportManager { **/ virtual int ConnectDevice(const DeviceHandle device_id) = 0; + /** + * @brief Retrieves the connection status of a given device + * + * @param device_handle Handle of device to query + * + * @return The connection status of the given device + */ virtual ConnectionStatus GetConnectionStatus( const DeviceHandle& device_handle) const = 0; diff --git a/src/components/transport_manager/include/transport_manager/transport_adapter/transport_adapter_impl.h b/src/components/transport_manager/include/transport_manager/transport_adapter/transport_adapter_impl.h index ba50025cda..9b860841e9 100644 --- a/src/components/transport_manager/include/transport_manager/transport_adapter/transport_adapter_impl.h +++ b/src/components/transport_manager/include/transport_manager/transport_adapter/transport_adapter_impl.h @@ -149,6 +149,13 @@ class TransportAdapterImpl : public TransportAdapter, TransportAdapter::Error ConnectDevice( const DeviceUID& device_handle) OVERRIDE; + /** + * @brief Retrieves the connection status of a given device + * + * @param device_handle Handle of device to query + * + * @return The connection status of the given device + */ ConnectionStatus GetConnectionStatus( const DeviceUID& device_handle) const OVERRIDE; @@ -552,7 +559,21 @@ class TransportAdapterImpl : public TransportAdapter, */ TransportAdapter::Error ConnectDevice(DeviceSptr device); + /** + * @brief Reattempt the last failed connection to a device + */ void RetryConnection(); + + /** + * @brief Clear any retry timers which have been completed + */ + void TransportAdapterImpl::ClearCompletedTimers(); + + /** + * @brief Retrieve the next device available for a reattempted connection + * @return The handle first device with an expired retry timer if present, + * otherwise an empty string + */ DeviceUID GetNextRetryDevice(); /** @@ -616,8 +637,17 @@ class TransportAdapterImpl : public TransportAdapter, **/ ConnectionMap connections_; + /** + * @brief Queue of retry timers. + */ std::queue > retry_timer_pool_; - sync_primitives::RecursiveLock retry_timer_pool_lock_; + sync_primitives::Lock retry_timer_pool_lock_; + + /** + * @brief Queue of completed retry timers. + */ + std::queue > completed_timer_pool_; + sync_primitives::Lock completed_timer_pool_lock_; /** * @brief Mutex restricting access to connections map. diff --git a/src/components/transport_manager/include/transport_manager/transport_manager_impl.h b/src/components/transport_manager/include/transport_manager/transport_manager_impl.h index 69f38304a7..c84b1e9a39 100644 --- a/src/components/transport_manager/include/transport_manager/transport_manager_impl.h +++ b/src/components/transport_manager/include/transport_manager/transport_manager_impl.h @@ -151,6 +151,13 @@ class TransportManagerImpl **/ int ConnectDevice(const DeviceHandle device_id) OVERRIDE; + /** + * @brief Retrieves the connection status of a given device + * + * @param device_handle Handle of device to query + * + * @return The connection status of the given device + */ ConnectionStatus GetConnectionStatus( const DeviceHandle& device_handle) const OVERRIDE; diff --git a/src/components/transport_manager/src/transport_adapter/transport_adapter_impl.cc b/src/components/transport_manager/src/transport_adapter/transport_adapter_impl.cc index 95c6ce6fc9..ecf04300bb 100644 --- a/src/components/transport_manager/src/transport_adapter/transport_adapter_impl.cc +++ b/src/components/transport_manager/src/transport_adapter/transport_adapter_impl.cc @@ -282,6 +282,7 @@ TransportAdapter::Error TransportAdapterImpl::ConnectDevice( } void TransportAdapterImpl::RetryConnection() { + ClearCompletedTimers(); const DeviceUID device_id = GetNextRetryDevice(); if (device_id.empty()) { LOG4CXX_ERROR(logger_, @@ -291,16 +292,26 @@ void TransportAdapterImpl::RetryConnection() { ConnectDevice(device_id); } -DeviceUID TransportAdapterImpl::GetNextRetryDevice() { - sync_primitives::AutoLock locker(retry_timer_pool_lock_); - while (!retry_timer_pool_.empty()) { - auto timer_entry = retry_timer_pool_.front(); - if (!timer_entry.first->is_completed()) { - return timer_entry.second; +void TransportAdapterImpl::ClearCompletedTimers() { + sync_primitives::AutoLock locker(completed_timer_pool_lock_); + while (!completed_timer_pool_.empty()) { + auto timer_entry = completed_timer_pool_.front(); + if (timer_entry.first->is_completed()) { + completed_timer_pool_.pop(); } - retry_timer_pool_.pop(); } - return std::string(); +} + +DeviceUID TransportAdapterImpl::GetNextRetryDevice() { + sync_primitives::AutoLock locker(retry_timer_pool_lock_); + if (retry_timer_pool_.empty()) { + return std::string(); + } + auto timer_entry = retry_timer_pool_.front(); + retry_timer_pool_.pop(); + sync_primitives::AutoLock locker(completed_timer_pool_lock_); + completed_timer_pool_.push_back(timer_entry); + return timer_entry.second; } ConnectionStatus TransportAdapterImpl::GetConnectionStatus( -- cgit v1.2.1 From 90d1b24267a03cecbf43b7de5331c2d74a876538 Mon Sep 17 00:00:00 2001 From: JackLivio Date: Wed, 28 Nov 2018 12:52:07 -0500 Subject: Connection Status To Trigger UpdateAppList --- .../application_manager/application_manager_impl.h | 7 +++++++ .../src/application_manager_impl.cc | 4 ++++ .../connection_handler/connection_handler_impl.h | 2 ++ .../connection_handler/src/connection_handler_impl.cc | 4 ++++ .../connection_handler/connection_handler_observer.h | 2 ++ .../mock_connection_handler_observer.h | 1 + .../mock_transport_manager_listener.h | 1 + .../transport_adapter/mock_transport_adapter.h | 1 + .../transport_adapter/transport_adapter.h | 2 ++ .../transport_adapter/transport_adapter_event.h | 3 ++- .../transport_manager/transport_manager_listener.h | 5 +++++ .../transport_manager_listener_empty.h | 2 ++ .../transport_adapter/transport_adapter_impl.h | 4 +++- .../transport_adapter/transport_adapter_listener.h | 6 ++++++ .../transport_adapter_listener_impl.h | 5 +++++ .../src/transport_adapter/transport_adapter_impl.cc | 18 +++++++++++++++--- .../transport_adapter_listener_impl.cc | 17 +++++++++++++++++ .../transport_manager/src/transport_manager_impl.cc | 5 +++++ .../mock_transport_adapter_listener.h | 2 ++ 19 files changed, 86 insertions(+), 5 deletions(-) diff --git a/src/components/application_manager/include/application_manager/application_manager_impl.h b/src/components/application_manager/include/application_manager/application_manager_impl.h index 58e066461f..d7c03e0fa0 100644 --- a/src/components/application_manager/include/application_manager/application_manager_impl.h +++ b/src/components/application_manager/include/application_manager/application_manager_impl.h @@ -367,11 +367,18 @@ class ApplicationManagerImpl const transport_manager::DeviceInfo& device_info, connection_handler::DeviceHandle device_id); + /** + * @brief Notifies the applicaiton manager that a cloud connection status has + * updated and should trigger an UpdateAppList RPC to the HMI + */ + void OnConnectionStatusUpdated(); + /** * @brief Retrieve the current connection status of a cloud app * @param app A cloud application * @return The current CloudConnectionStatus of app */ + hmi_apis::Common_CloudConnectionStatus::eType GetCloudAppConnectionStatus( ApplicationConstSharedPtr app) const; diff --git a/src/components/application_manager/src/application_manager_impl.cc b/src/components/application_manager/src/application_manager_impl.cc index e9a45001c7..8fd7f9e455 100644 --- a/src/components/application_manager/src/application_manager_impl.cc +++ b/src/components/application_manager/src/application_manager_impl.cc @@ -930,6 +930,10 @@ void ApplicationManagerImpl::CreatePendingApplication( SendUpdateAppList(); } +void ApplicationManagerImpl::OnConnectionStatusUpdated() { + SendUpdateAppList(); +} + hmi_apis::Common_CloudConnectionStatus::eType ApplicationManagerImpl::GetCloudAppConnectionStatus( ApplicationConstSharedPtr app) const { diff --git a/src/components/connection_handler/include/connection_handler/connection_handler_impl.h b/src/components/connection_handler/include/connection_handler/connection_handler_impl.h index cbf829b226..b8153bcf42 100644 --- a/src/components/connection_handler/include/connection_handler/connection_handler_impl.h +++ b/src/components/connection_handler/include/connection_handler/connection_handler_impl.h @@ -176,6 +176,8 @@ class ConnectionHandlerImpl void OnScanDevicesFailed( const transport_manager::SearchDeviceError& error) OVERRIDE; + void OnConnectionStatusUpdated() OVERRIDE; + /** * \brief Notifies about pending connection. * diff --git a/src/components/connection_handler/src/connection_handler_impl.cc b/src/components/connection_handler/src/connection_handler_impl.cc index 77eb38b8bc..88d57e5d2c 100644 --- a/src/components/connection_handler/src/connection_handler_impl.cc +++ b/src/components/connection_handler/src/connection_handler_impl.cc @@ -249,6 +249,10 @@ void ConnectionHandlerImpl::OnScanDevicesFailed( LOG4CXX_WARN(logger_, "Scan devices failed. " << error.text()); } +void ConnectionHandlerImpl::OnConnectionStatusUpdated() { + connection_handler_observer_->OnConnectionStatusUpdated(); +} + void ConnectionHandlerImpl::OnConnectionPending( const transport_manager::DeviceInfo& device_info, const transport_manager::ConnectionUID connection_id) { diff --git a/src/components/include/connection_handler/connection_handler_observer.h b/src/components/include/connection_handler/connection_handler_observer.h index 298f98803a..f683318ada 100644 --- a/src/components/include/connection_handler/connection_handler_observer.h +++ b/src/components/include/connection_handler/connection_handler_observer.h @@ -161,6 +161,8 @@ class ConnectionHandlerObserver { */ virtual void OnSecondaryTransportEndedCallback(const int32_t session_key) = 0; + virtual void OnConnectionStatusUpdated() = 0; + virtual void CreatePendingApplication( const transport_manager::ConnectionUID connection_id, const transport_manager::DeviceInfo& device_info, diff --git a/src/components/include/test/connection_handler/mock_connection_handler_observer.h b/src/components/include/test/connection_handler/mock_connection_handler_observer.h index 2984b2e471..0a8e71c085 100644 --- a/src/components/include/test/connection_handler/mock_connection_handler_observer.h +++ b/src/components/include/test/connection_handler/mock_connection_handler_observer.h @@ -74,6 +74,7 @@ class MockConnectionHandlerObserver const int32_t session_key)); MOCK_METHOD1(OnSecondaryTransportEndedCallback, void(const int32_t session_key)); + MOCK_METHOD0(OnConnectionStatusUpdated, void()); MOCK_METHOD3(CreatePendingApplication, void(const transport_manager::ConnectionUID connection_id, const transport_manager::DeviceInfo& device_info, diff --git a/src/components/include/test/transport_manager/mock_transport_manager_listener.h b/src/components/include/test/transport_manager/mock_transport_manager_listener.h index 734651f455..04408f945b 100644 --- a/src/components/include/test/transport_manager/mock_transport_manager_listener.h +++ b/src/components/include/test/transport_manager/mock_transport_manager_listener.h @@ -55,6 +55,7 @@ class MockTransportManagerListener : public TransportManagerListener { MOCK_METHOD1(OnDeviceRemoved, void(const DeviceInfo& device_info)); MOCK_METHOD0(OnScanDevicesFinished, void()); MOCK_METHOD1(OnScanDevicesFailed, void(const SearchDeviceError& error)); + MOCK_METHOD0(OnConnectionStatusUpdated, void()); MOCK_METHOD2(OnConnectionPending, void(const DeviceInfo& device_info, const ConnectionUID connection_id)); diff --git a/src/components/include/test/transport_manager/transport_adapter/mock_transport_adapter.h b/src/components/include/test/transport_manager/transport_adapter/mock_transport_adapter.h index 65cfdae4d5..c993f245b9 100644 --- a/src/components/include/test/transport_manager/transport_adapter/mock_transport_adapter.h +++ b/src/components/include/test/transport_manager/transport_adapter/mock_transport_adapter.h @@ -69,6 +69,7 @@ class MockTransportAdapter MOCK_CONST_METHOD1(GetConnectionStatus, ::transport_manager::ConnectionStatus( const ::transport_manager::DeviceUID& device_handle)); + MOCK_METHOD0(ConnectionStatusUpdated, void()); MOCK_METHOD2(RunAppOnDevice, void(const std::string&, const std::string&)); MOCK_CONST_METHOD0(IsClientOriginatedConnectSupported, bool()); MOCK_METHOD0( diff --git a/src/components/include/transport_manager/transport_adapter/transport_adapter.h b/src/components/include/transport_manager/transport_adapter/transport_adapter.h index 184ee79a13..303f677720 100644 --- a/src/components/include/transport_manager/transport_adapter/transport_adapter.h +++ b/src/components/include/transport_manager/transport_adapter/transport_adapter.h @@ -227,6 +227,8 @@ class TransportAdapter { virtual ConnectionStatus GetConnectionStatus( const DeviceUID& device_handle) const = 0; + virtual void ConnectionStatusUpdated() = 0; + /** * @brief RunAppOnDevice allows to run specific application on the certain *device. diff --git a/src/components/include/transport_manager/transport_adapter/transport_adapter_event.h b/src/components/include/transport_manager/transport_adapter/transport_adapter_event.h index 921562333b..63d1678ed0 100644 --- a/src/components/include/transport_manager/transport_adapter/transport_adapter_event.h +++ b/src/components/include/transport_manager/transport_adapter/transport_adapter_event.h @@ -59,7 +59,8 @@ enum class EventTypeEnum { ON_UNEXPECTED_DISCONNECT, ON_TRANSPORT_SWITCH_REQUESTED, ON_TRANSPORT_CONFIG_UPDATED, - ON_CONNECT_PENDING + ON_CONNECT_PENDING, + ON_CONNECTION_STATUS_UPDATED }; class TransportAdapterEvent { diff --git a/src/components/include/transport_manager/transport_manager_listener.h b/src/components/include/transport_manager/transport_manager_listener.h index 7da4bcc2f5..22ee519a67 100644 --- a/src/components/include/transport_manager/transport_manager_listener.h +++ b/src/components/include/transport_manager/transport_manager_listener.h @@ -100,6 +100,11 @@ class TransportManagerListener { */ virtual void OnScanDevicesFailed(const SearchDeviceError& error) = 0; + /** + * @brief Reaction to the event, when the cloud connection status is updated. + */ + virtual void OnConnectionStatusUpdated() = 0; + /** * @brief Reaction to the event, when connection is pending. * diff --git a/src/components/include/transport_manager/transport_manager_listener_empty.h b/src/components/include/transport_manager/transport_manager_listener_empty.h index c0a713f38e..193a86819c 100644 --- a/src/components/include/transport_manager/transport_manager_listener_empty.h +++ b/src/components/include/transport_manager/transport_manager_listener_empty.h @@ -59,6 +59,8 @@ class TransportManagerListenerEmpty : public TransportManagerListener { void OnFindNewApplicationsRequest() OVERRIDE {} + void OnConnectionStatusUpdated() OVERRIDE {} + /** * @brief Reaction to the event, when the device is found. * diff --git a/src/components/transport_manager/include/transport_manager/transport_adapter/transport_adapter_impl.h b/src/components/transport_manager/include/transport_manager/transport_adapter/transport_adapter_impl.h index 9b860841e9..8d03bdb2c7 100644 --- a/src/components/transport_manager/include/transport_manager/transport_adapter/transport_adapter_impl.h +++ b/src/components/transport_manager/include/transport_manager/transport_adapter/transport_adapter_impl.h @@ -159,6 +159,8 @@ class TransportAdapterImpl : public TransportAdapter, ConnectionStatus GetConnectionStatus( const DeviceUID& device_handle) const OVERRIDE; + void ConnectionStatusUpdated() OVERRIDE; + /** * @brief Disconnect from specified session. * @@ -567,7 +569,7 @@ class TransportAdapterImpl : public TransportAdapter, /** * @brief Clear any retry timers which have been completed */ - void TransportAdapterImpl::ClearCompletedTimers(); + void ClearCompletedTimers(); /** * @brief Retrieve the next device available for a reattempted connection diff --git a/src/components/transport_manager/include/transport_manager/transport_adapter/transport_adapter_listener.h b/src/components/transport_manager/include/transport_manager/transport_adapter/transport_adapter_listener.h index b0368869e7..a0e0a51c1e 100644 --- a/src/components/transport_manager/include/transport_manager/transport_adapter/transport_adapter_listener.h +++ b/src/components/transport_manager/include/transport_manager/transport_adapter/transport_adapter_listener.h @@ -91,6 +91,12 @@ class TransportAdapterListener { virtual void OnFindNewApplicationsRequest( const TransportAdapter* adapter) = 0; + /** + * @brief Reaction to connection status update + * @param adapter Current transport adapter + */ + virtual void OnConnectionStatusUpdated(const TransportAdapter* adapter) = 0; + /** * @brief Search specified device adapter in the container of shared pointers * to device adapters to be sure it is available, diff --git a/src/components/transport_manager/include/transport_manager/transport_adapter/transport_adapter_listener_impl.h b/src/components/transport_manager/include/transport_manager/transport_adapter/transport_adapter_listener_impl.h index 76271229ad..0c9c6ef6a2 100644 --- a/src/components/transport_manager/include/transport_manager/transport_adapter/transport_adapter_listener_impl.h +++ b/src/components/transport_manager/include/transport_manager/transport_adapter/transport_adapter_listener_impl.h @@ -87,6 +87,11 @@ class TransportAdapterListenerImpl virtual void OnFindNewApplicationsRequest(const TransportAdapter* adapter); + /** + * @brief Passes notification to that the cloud conection status has updated + */ + virtual void OnConnectionStatusUpdated(const TransportAdapter* adapter); + /** * @brief Search specified device adapter in the container of shared pointers * to device adapters to be sure it is available, diff --git a/src/components/transport_manager/src/transport_adapter/transport_adapter_impl.cc b/src/components/transport_manager/src/transport_adapter/transport_adapter_impl.cc index ecf04300bb..7079a55264 100644 --- a/src/components/transport_manager/src/transport_adapter/transport_adapter_impl.cc +++ b/src/components/transport_manager/src/transport_adapter/transport_adapter_impl.cc @@ -252,12 +252,14 @@ TransportAdapter::Error TransportAdapterImpl::ConnectDevice( if (device->connection_status() == ConnectionStatus::PENDING) { device->set_connection_status(ConnectionStatus::RETRY); device->reset_retry_count(); + ConnectionStatusUpdated(); } if (device->retry_count() > get_settings().cloud_app_max_retry_attempts()) { device->set_connection_status(ConnectionStatus::PENDING); device->reset_retry_count(); + ConnectionStatusUpdated(); return err; } @@ -272,6 +274,7 @@ TransportAdapter::Error TransportAdapterImpl::ConnectDevice( timer::kSingleShot); } else if (OK == err) { device->set_connection_status(ConnectionStatus::CONNECTED); + ConnectionStatusUpdated(); } LOG4CXX_TRACE(logger_, "exit with error: " << err); return err; @@ -303,14 +306,14 @@ void TransportAdapterImpl::ClearCompletedTimers() { } DeviceUID TransportAdapterImpl::GetNextRetryDevice() { - sync_primitives::AutoLock locker(retry_timer_pool_lock_); + sync_primitives::AutoLock retry_locker(retry_timer_pool_lock_); if (retry_timer_pool_.empty()) { return std::string(); } auto timer_entry = retry_timer_pool_.front(); retry_timer_pool_.pop(); - sync_primitives::AutoLock locker(completed_timer_pool_lock_); - completed_timer_pool_.push_back(timer_entry); + sync_primitives::AutoLock completed_locker(completed_timer_pool_lock_); + completed_timer_pool_.push(timer_entry); return timer_entry.second; } @@ -321,6 +324,14 @@ ConnectionStatus TransportAdapterImpl::GetConnectionStatus( : device->connection_status(); } +void TransportAdapterImpl::ConnectionStatusUpdated() { + for (TransportAdapterListenerList::iterator it = listeners_.begin(); + it != listeners_.end(); + ++it) { + (*it)->OnConnectionStatusUpdated(this); + } +} + TransportAdapter::Error TransportAdapterImpl::Disconnect( const DeviceUID& device_id, const ApplicationHandle& app_handle) { LOG4CXX_TRACE(logger_, @@ -352,6 +363,7 @@ TransportAdapter::Error TransportAdapterImpl::DisconnectDevice( Error error = OK; DeviceSptr device = FindDevice(device_id); device->set_connection_status(ConnectionStatus::CLOSING); + ConnectionStatusUpdated(); std::vector to_disconnect; connections_lock_.AcquireForReading(); diff --git a/src/components/transport_manager/src/transport_adapter/transport_adapter_listener_impl.cc b/src/components/transport_manager/src/transport_adapter/transport_adapter_listener_impl.cc index 73750fe2f3..4ef685adbc 100644 --- a/src/components/transport_manager/src/transport_adapter/transport_adapter_listener_impl.cc +++ b/src/components/transport_manager/src/transport_adapter/transport_adapter_listener_impl.cc @@ -116,6 +116,23 @@ void TransportAdapterListenerImpl::OnFindNewApplicationsRequest( LOG4CXX_TRACE(logger_, "exit"); } +void TransportAdapterListenerImpl::OnConnectionStatusUpdated( + const TransportAdapter* adapter) { + LOG4CXX_TRACE(logger_, "enter. adapter* " << adapter); + const TransportAdapterEvent event(EventTypeEnum::ON_CONNECTION_STATUS_UPDATED, + transport_adapter_, + "", + 0, + ::protocol_handler::RawMessagePtr(), + BaseErrorPtr(new BaseError())); + if (transport_manager_ != NULL && + transport_manager::E_SUCCESS != + transport_manager_->ReceiveEventFromDevice(event)) { + LOG4CXX_WARN(logger_, "Failed to receive event from device"); + } + LOG4CXX_TRACE(logger_, "exit"); +} + void TransportAdapterListenerImpl::OnConnectPending( const TransportAdapter* adapter, const DeviceUID& device, diff --git a/src/components/transport_manager/src/transport_manager_impl.cc b/src/components/transport_manager/src/transport_manager_impl.cc index 1c5a6dae32..518a5639db 100644 --- a/src/components/transport_manager/src/transport_manager_impl.cc +++ b/src/components/transport_manager/src/transport_manager_impl.cc @@ -990,6 +990,11 @@ void TransportManagerImpl::Handle(TransportAdapterEvent event) { LOG4CXX_DEBUG(logger_, "event_type = ON_FIND_NEW_APPLICATIONS_REQUEST"); break; } + case EventTypeEnum::ON_CONNECTION_STATUS_UPDATED: { + RaiseEvent(&TransportManagerListener::OnConnectionStatusUpdated); + LOG4CXX_DEBUG(logger_, "event_type = ON_CONNECTION_STATUS_UPDATED"); + break; + } case EventTypeEnum::ON_CONNECT_PENDING: { const DeviceHandle device_handle = converter_.UidToHandle( event.device_uid, event.transport_adapter->GetConnectionType()); diff --git a/src/components/transport_manager/test/include/transport_manager/transport_adapter/mock_transport_adapter_listener.h b/src/components/transport_manager/test/include/transport_manager/transport_adapter/mock_transport_adapter_listener.h index 81e133ec2b..f7bebf69c3 100644 --- a/src/components/transport_manager/test/include/transport_manager/transport_adapter/mock_transport_adapter_listener.h +++ b/src/components/transport_manager/test/include/transport_manager/transport_adapter/mock_transport_adapter_listener.h @@ -59,6 +59,8 @@ class MockTransportAdapterListener : public TransportAdapterListener { const SearchDeviceError& error)); MOCK_METHOD1(OnFindNewApplicationsRequest, void(const TransportAdapter* adapter)); + MOCK_METHOD1(OnConnectionStatusUpdated, + void(const TransportAdapter* adapter)); MOCK_METHOD3(OnConnectPending, void(const TransportAdapter* adapter, const DeviceUID& device_handle, -- cgit v1.2.1 From e443110f744f0aa6ddc03e34a04d12cf556a10dd Mon Sep 17 00:00:00 2001 From: jacobkeeler Date: Thu, 29 Nov 2018 13:03:16 -0500 Subject: Add tests for RegisterApplication and RetryConnection --- .../application_manager/application_manager_impl.h | 18 ++- .../src/application_manager_impl.cc | 43 ++++--- .../test/application_manager_impl_test.cc | 131 ++++++++++++++++++++- .../transport_adapter/transport_adapter_impl.cc | 18 +-- .../mock_transport_adapter_impl.h | 8 +- .../test/transport_adapter_test.cc | 98 ++++++++++++++- 6 files changed, 277 insertions(+), 39 deletions(-) diff --git a/src/components/application_manager/include/application_manager/application_manager_impl.h b/src/components/application_manager/include/application_manager/application_manager_impl.h index d7c03e0fa0..a3e3cece72 100644 --- a/src/components/application_manager/include/application_manager/application_manager_impl.h +++ b/src/components/application_manager/include/application_manager/application_manager_impl.h @@ -1498,13 +1498,29 @@ class ApplicationManagerImpl */ void AddMockApplication(ApplicationSharedPtr mock_app); + /** + * @brief Add a mock application to the pending application list without going + * through the formal registration process. Only for unit testing. + * @param mock_app the mock app to be added to the pending application list + */ + void AddMockPendingApplication(ApplicationSharedPtr mock_app); + /** * @brief set a mock media manager without running Init(). Only for unit * testing. - * @param mock_app the mock app to be registered + * @param mock_media_manager the mock media manager to be assigned */ void SetMockMediaManager(media_manager::MediaManager* mock_media_manager); + /** + * @brief set a mock rpc service directly. Only for unit + * testing. + * @param mock_app the mock rpc service to be assigned + */ + void SetMockRPCService(rpc_service::RPCService* rpc_service) { + rpc_service_.reset(rpc_service); + } + virtual void SetPluginManager( std::unique_ptr& plugin_manager) OVERRIDE { diff --git a/src/components/application_manager/src/application_manager_impl.cc b/src/components/application_manager/src/application_manager_impl.cc index 8fd7f9e455..d2d2458ac0 100644 --- a/src/components/application_manager/src/application_manager_impl.cc +++ b/src/components/application_manager/src/application_manager_impl.cc @@ -614,6 +614,7 @@ ApplicationSharedPtr ApplicationManagerImpl::RegisterApplication( PolicyAppIdPredicate finder(application->policy_app_id()); ApplicationSet::iterator it = std::find_if(apps_to_register_.begin(), apps_to_register_.end(), finder); + bool is_mismatched_cloud_app = false; if (apps_to_register_.end() == it) { DevicePredicate finder(application->device()); @@ -621,24 +622,8 @@ ApplicationSharedPtr ApplicationManagerImpl::RegisterApplication( apps_to_register_.begin(), apps_to_register_.end(), finder); bool found = apps_to_register_.end() != it; - bool is_mismatched_cloud_app = found && (*it)->is_cloud_app() && - policy_app_id != (*it)->policy_app_id(); - - // Reject registration request if a cloud app registers with the incorrect - // appID - if (is_mismatched_cloud_app) { - std::shared_ptr response( - MessageHelper::CreateNegativeResponse( - connection_key, - mobile_apis::FunctionID::RegisterAppInterfaceID, - message[strings::params][strings::correlation_id].asUInt(), - mobile_apis::Result::DISALLOWED)); - (*response)[strings::msg_params][strings::info] = - "Cloud app registered with incorrect app id"; - rpc_service_->ManageMobileCommand(response, - commands::Command::SOURCE_SDL); - return ApplicationSharedPtr(); - } + is_mismatched_cloud_app = found && (*it)->is_cloud_app() && + policy_app_id != (*it)->policy_app_id(); } else { application->set_hmi_application_id((*it)->hmi_app_id()); @@ -653,6 +638,21 @@ ApplicationSharedPtr ApplicationManagerImpl::RegisterApplication( } apps_to_register_list_lock_ptr_->Release(); + // Reject registration request if a cloud app registers with the incorrect + // appID + if (is_mismatched_cloud_app) { + std::shared_ptr response( + MessageHelper::CreateNegativeResponse( + connection_key, + mobile_apis::FunctionID::RegisterAppInterfaceID, + message[strings::params][strings::correlation_id].asUInt(), + mobile_apis::Result::DISALLOWED)); + (*response)[strings::msg_params][strings::info] = + "Cloud app registered with incorrect app id"; + rpc_service_->ManageMobileCommand(response, commands::Command::SOURCE_SDL); + return ApplicationSharedPtr(); + } + if (!application->hmi_app_id()) { const bool is_saved = resume_controller().IsApplicationSaved(policy_app_id, device_mac); @@ -3813,6 +3813,13 @@ void ApplicationManagerImpl::AddMockApplication(ApplicationSharedPtr mock_app) { applications_list_lock_ptr_->Release(); } +void ApplicationManagerImpl::AddMockPendingApplication( + ApplicationSharedPtr mock_app) { + apps_to_register_list_lock_ptr_->Acquire(); + apps_to_register_.insert(mock_app); + apps_to_register_list_lock_ptr_->Release(); +} + void ApplicationManagerImpl::SetMockMediaManager( media_manager::MediaManager* mock_media_manager) { media_manager_ = mock_media_manager; diff --git a/src/components/application_manager/test/application_manager_impl_test.cc b/src/components/application_manager/test/application_manager_impl_test.cc index 7e57b51329..4ea44e5aca 100644 --- a/src/components/application_manager/test/application_manager_impl_test.cc +++ b/src/components/application_manager/test/application_manager_impl_test.cc @@ -96,6 +96,14 @@ connection_handler::DeviceHandle kDeviceId = 12345u; const std::string kAppId = "someID"; const uint32_t kConnectionKey = 1232u; const std::string kAppName = "appName"; + +// Cloud application params +const std::string kEndpoint = "endpoint"; +const std::string kAuthToken = "auth_token"; +const std::string kCertificate = "cert"; +const std::string kTransportType = "WS"; +const mobile_api::HybridAppPreference::eType kHybridAppPreference = + mobile_api::HybridAppPreference::CLOUD; } // namespace class ApplicationManagerImplTest : public ::testing::Test { @@ -122,11 +130,11 @@ class ApplicationManagerImplTest : public ::testing::Test { protected: void SetUp() OVERRIDE { CreateAppManager(); - ON_CALL(mock_connection_handler_, GetDataOnSessionKey(_, _, _, &kDeviceId)) - .WillByDefault(DoAll(SetArgPointee<3u>(app_id_), Return(0))); + ON_CALL(mock_session_observer_, GetDataOnSessionKey(_, _, _, _)) + .WillByDefault(DoAll(SetArgPointee<3u>(kDeviceId), Return(0))); ON_CALL(mock_connection_handler_, get_session_observer()) .WillByDefault(ReturnRef(mock_session_observer_)); - app_manager_impl_->SetRPCService(mock_rpc_service_); + app_manager_impl_->SetMockRPCService(mock_rpc_service_); app_manager_impl_->resume_controller().set_resumption_storage( mock_storage_); app_manager_impl_->set_connection_handler(&mock_connection_handler_); @@ -200,7 +208,7 @@ class ApplicationManagerImplTest : public ::testing::Test { NiceMock mock_policy_settings_; std::shared_ptr > mock_storage_; - std::unique_ptr mock_rpc_service_; + MockRPCService* mock_rpc_service_; NiceMock mock_connection_handler_; NiceMock mock_session_observer_; NiceMock mock_application_manager_settings_; @@ -1413,6 +1421,121 @@ TEST_F(ApplicationManagerImplTest, EXPECT_TRUE(file_system::RemoveDirectory(kDirectoryName, true)); } +TEST_F(ApplicationManagerImplTest, + RegisterApplication_CloudAppRegisterSuccess) { + std::shared_ptr waiting_app = + std::make_shared(); + ON_CALL(*waiting_app, device()).WillByDefault(Return(kDeviceId)); + EXPECT_CALL(*waiting_app, cloud_app_endpoint()) + .WillOnce(ReturnRef(kEndpoint)); + EXPECT_CALL(*waiting_app, cloud_app_auth_token()) + .WillOnce(ReturnRef(kAuthToken)); + EXPECT_CALL(*waiting_app, cloud_app_certificate()) + .WillOnce(ReturnRef(kCertificate)); + EXPECT_CALL(*waiting_app, cloud_app_transport_type()) + .WillOnce(ReturnRef(kTransportType)); + EXPECT_CALL(*waiting_app, hybrid_app_preference()) + .WillOnce(ReturnRef(kHybridAppPreference)); + ON_CALL(*waiting_app, is_cloud_app()).WillByDefault(Return(true)); + EXPECT_CALL(*waiting_app, policy_app_id()).WillRepeatedly(Return(kAppId)); + app_manager_impl_->AddMockPendingApplication(waiting_app); + + EXPECT_CALL( + mock_session_observer_, + GetDataOnSessionKey(kConnectionKey, + _, + _, + testing::An())) + .WillOnce(DoAll(SetArgPointee<3u>(kDeviceId), Return(0))); + EXPECT_CALL(*mock_rpc_service_, + ManageMobileCommand(_, commands::Command::SOURCE_SDL)).Times(0); + smart_objects::SmartObject request_for_registration( + smart_objects::SmartType_Map); + + smart_objects::SmartObject& params = + request_for_registration[strings::msg_params]; + params[strings::app_id] = kAppId; + params[strings::language_desired] = mobile_api::Language::EN_US; + params[strings::hmi_display_language_desired] = mobile_api::Language::EN_US; + + request_for_registration[strings::params][strings::connection_key] = + kConnectionKey; + request_for_registration[strings::msg_params][strings::app_name] = kAppName; + request_for_registration[strings::msg_params][strings::sync_msg_version] + [strings::minor_version] = APIVersion::kAPIV2; + request_for_registration[strings::msg_params][strings::sync_msg_version] + [strings::major_version] = APIVersion::kAPIV3; + + request_for_registration[strings::params][strings::protocol_version] = + protocol_handler::MajorProtocolVersion::PROTOCOL_VERSION_2; + + smart_objects::SmartObjectSPtr request_for_registration_ptr = + std::make_shared(request_for_registration); + + ApplicationSharedPtr application = + app_manager_impl_->RegisterApplication(request_for_registration_ptr); + + EXPECT_EQ(protocol_handler::MajorProtocolVersion::PROTOCOL_VERSION_2, + application->protocol_version()); + EXPECT_EQ(APIVersion::kAPIV2, + application->version().min_supported_api_version); + EXPECT_EQ(APIVersion::kAPIV3, + application->version().max_supported_api_version); + EXPECT_EQ(kEndpoint, application->cloud_app_endpoint()); + EXPECT_EQ(kAuthToken, application->cloud_app_auth_token()); + EXPECT_EQ(kCertificate, application->cloud_app_certificate()); + EXPECT_EQ(kTransportType, application->cloud_app_transport_type()); + EXPECT_EQ(kHybridAppPreference, application->hybrid_app_preference()); +} + +TEST_F(ApplicationManagerImplTest, + RegisterApplication_CloudAppRegisterFailed_DISALLOWED) { + std::shared_ptr waiting_app = + std::make_shared(); + EXPECT_CALL(*waiting_app, device()).WillRepeatedly(Return(kDeviceId)); + EXPECT_CALL(*waiting_app, is_cloud_app()).WillRepeatedly(Return(true)); + EXPECT_CALL(*waiting_app, policy_app_id()) + .WillRepeatedly(Return("Fake" + kAppId)); + app_manager_impl_->AddMockPendingApplication(waiting_app); + + EXPECT_CALL( + mock_session_observer_, + GetDataOnSessionKey(kConnectionKey, + _, + _, + testing::An())) + .WillOnce(DoAll(SetArgPointee<3u>(kDeviceId), Return(0))); + EXPECT_CALL(*mock_rpc_service_, + ManageMobileCommand(_, commands::Command::SOURCE_SDL)) + .WillOnce(Return(true)); + smart_objects::SmartObject request_for_registration( + smart_objects::SmartType_Map); + + smart_objects::SmartObject& params = + request_for_registration[strings::msg_params]; + params[strings::app_id] = kAppId; + params[strings::language_desired] = mobile_api::Language::EN_US; + params[strings::hmi_display_language_desired] = mobile_api::Language::EN_US; + + request_for_registration[strings::params][strings::connection_key] = + kConnectionKey; + request_for_registration[strings::msg_params][strings::app_name] = kAppName; + request_for_registration[strings::msg_params][strings::sync_msg_version] + [strings::minor_version] = APIVersion::kAPIV2; + request_for_registration[strings::msg_params][strings::sync_msg_version] + [strings::major_version] = APIVersion::kAPIV3; + + request_for_registration[strings::params][strings::protocol_version] = + protocol_handler::MajorProtocolVersion::PROTOCOL_VERSION_2; + + smart_objects::SmartObjectSPtr request_for_registration_ptr = + std::make_shared(request_for_registration); + + ApplicationSharedPtr application = + app_manager_impl_->RegisterApplication(request_for_registration_ptr); + EXPECT_EQ(0, application.use_count()); +} + } // application_manager_test } // namespace components } // namespace test diff --git a/src/components/transport_manager/src/transport_adapter/transport_adapter_impl.cc b/src/components/transport_manager/src/transport_adapter/transport_adapter_impl.cc index 7079a55264..8928ecb4d2 100644 --- a/src/components/transport_manager/src/transport_adapter/transport_adapter_impl.cc +++ b/src/components/transport_manager/src/transport_adapter/transport_adapter_impl.cc @@ -249,21 +249,21 @@ TransportAdapter::Error TransportAdapterImpl::ConnectDevice( if (FAIL == err && GetDeviceType() == DeviceType::CLOUD_WEBSOCKET) { LOG4CXX_TRACE(logger_, "Error occurred while connecting cloud app: " << err); - if (device->connection_status() == ConnectionStatus::PENDING) { - device->set_connection_status(ConnectionStatus::RETRY); - device->reset_retry_count(); - ConnectionStatusUpdated(); - } - - if (device->retry_count() > + // Update retry count + if (device->retry_count() >= get_settings().cloud_app_max_retry_attempts()) { device->set_connection_status(ConnectionStatus::PENDING); device->reset_retry_count(); ConnectionStatusUpdated(); return err; + } else if (device->connection_status() == ConnectionStatus::PENDING) { + device->set_connection_status(ConnectionStatus::RETRY); + ConnectionStatusUpdated(); } device->next_retry(); + + // Start timer for next retry TimerSPtr retry_timer(std::make_shared( "RetryConnectionTimer", new timer::TimerTaskImpl( @@ -296,6 +296,7 @@ void TransportAdapterImpl::RetryConnection() { } void TransportAdapterImpl::ClearCompletedTimers() { + // Cleanup any retry timers which have completed execution sync_primitives::AutoLock locker(completed_timer_pool_lock_); while (!completed_timer_pool_.empty()) { auto timer_entry = completed_timer_pool_.front(); @@ -312,8 +313,11 @@ DeviceUID TransportAdapterImpl::GetNextRetryDevice() { } auto timer_entry = retry_timer_pool_.front(); retry_timer_pool_.pop(); + + // Store reference for cleanup later sync_primitives::AutoLock completed_locker(completed_timer_pool_lock_); completed_timer_pool_.push(timer_entry); + return timer_entry.second; } diff --git a/src/components/transport_manager/test/include/transport_manager/transport_adapter/mock_transport_adapter_impl.h b/src/components/transport_manager/test/include/transport_manager/transport_adapter/mock_transport_adapter_impl.h index 384f55605a..e18d1bc53b 100644 --- a/src/components/transport_manager/test/include/transport_manager/transport_adapter/mock_transport_adapter_impl.h +++ b/src/components/transport_manager/test/include/transport_manager/transport_adapter/mock_transport_adapter_impl.h @@ -70,15 +70,15 @@ class MockTransportAdapterImpl : public TransportAdapterImpl { } virtual ~MockTransportAdapterImpl() {} - virtual DeviceType GetDeviceType() const { - return DeviceType::UNKNOWN; - } - MOCK_CONST_METHOD0(Store, void()); MOCK_METHOD0(Restore, bool()); MOCK_CONST_METHOD1(FindDevice, transport_manager::transport_adapter::DeviceSptr( const DeviceUID& device_id)); + MOCK_METHOD0(ConnectionStatusUpdated, void()); + MOCK_CONST_METHOD0(GetDeviceType, + ::transport_manager::transport_adapter::DeviceType()); + MOCK_METHOD0(RetryConnection, void()); }; } // namespace transport_manager_test diff --git a/src/components/transport_manager/test/transport_adapter_test.cc b/src/components/transport_manager/test/transport_adapter_test.cc index 0a7db52c97..b917c60187 100644 --- a/src/components/transport_manager/test/transport_adapter_test.cc +++ b/src/components/transport_manager/test/transport_adapter_test.cc @@ -31,14 +31,15 @@ */ #include "gtest/gtest.h" -#include "transport_manager/transport_adapter/mock_device_scanner.h" +#include "transport_manager/mock_transport_manager_settings.h" #include "transport_manager/transport_adapter/mock_client_connection_listener.h" -#include "transport_manager/transport_adapter/mock_server_connection_factory.h" -#include "transport_manager/transport_adapter/mock_device.h" #include "transport_manager/transport_adapter/mock_connection.h" -#include "transport_manager/transport_adapter/mock_transport_adapter_listener.h" +#include "transport_manager/transport_adapter/mock_device.h" +#include "transport_manager/transport_adapter/mock_device_scanner.h" +#include "transport_manager/transport_adapter/mock_server_connection_factory.h" #include "transport_manager/transport_adapter/mock_transport_adapter_impl.h" -#include "transport_manager/mock_transport_manager_settings.h" +#include "transport_manager/transport_adapter/mock_transport_adapter_listener.h" +#include "utils/test_async_waiter.h" #include "transport_manager/transport_adapter/transport_adapter_impl.h" #include "transport_manager/transport_adapter/transport_adapter_listener.h" @@ -73,6 +74,11 @@ class TransportAdapterTest : public ::testing::Test { .WillByDefault(Return(true)); } + void SetDefaultExpectations(MockTransportAdapterImpl& adapter) { + ON_CALL(adapter, GetDeviceType()) + .WillByDefault(Return(DeviceType::UNKNOWN)); + } + NiceMock transport_manager_settings; resumption::LastStateImpl last_state_; std::string dev_id; @@ -89,6 +95,7 @@ TEST_F(TransportAdapterTest, Init) { clientMock, last_state_, transport_manager_settings); + SetDefaultExpectations(transport_adapter); EXPECT_CALL(*dev_mock, Init()).WillOnce(Return(TransportAdapter::OK)); EXPECT_CALL(*clientMock, Init()).WillOnce(Return(TransportAdapter::OK)); EXPECT_CALL(*serverMock, Init()).WillOnce(Return(TransportAdapter::OK)); @@ -123,6 +130,7 @@ TEST_F(TransportAdapterTest, SearchDevices_DeviceNotInitialized) { MockDeviceScanner* dev_mock = new MockDeviceScanner(); MockTransportAdapterImpl transport_adapter( dev_mock, NULL, NULL, last_state_, transport_manager_settings); + SetDefaultExpectations(transport_adapter); EXPECT_CALL(*dev_mock, Init()).WillOnce(Return(TransportAdapter::OK)); EXPECT_CALL(transport_adapter, Restore()).WillOnce(Return(true)); @@ -138,6 +146,7 @@ TEST_F(TransportAdapterTest, SearchDevices_DeviceInitialized) { MockDeviceScanner* dev_mock = new MockDeviceScanner(); MockTransportAdapterImpl transport_adapter( dev_mock, NULL, NULL, last_state_, transport_manager_settings); + SetDefaultExpectations(transport_adapter); EXPECT_CALL(*dev_mock, Init()).WillOnce(Return(TransportAdapter::OK)); EXPECT_CALL(transport_adapter, Restore()).WillOnce(Return(true)); @@ -153,6 +162,7 @@ TEST_F(TransportAdapterTest, SearchDevices_DeviceInitialized) { TEST_F(TransportAdapterTest, SearchDeviceDone_DeviceExisting) { MockTransportAdapterImpl transport_adapter( NULL, NULL, NULL, last_state_, transport_manager_settings); + SetDefaultExpectations(transport_adapter); EXPECT_CALL(transport_adapter, Restore()).WillOnce(Return(true)); transport_adapter.Init(); @@ -169,6 +179,7 @@ TEST_F(TransportAdapterTest, SearchDeviceDone_DeviceExisting) { TEST_F(TransportAdapterTest, SearchDeviceFailed) { MockTransportAdapterImpl transport_adapter( NULL, NULL, NULL, last_state_, transport_manager_settings); + SetDefaultExpectations(transport_adapter); EXPECT_CALL(transport_adapter, Restore()).WillOnce(Return(true)); transport_adapter.Init(); @@ -183,6 +194,7 @@ TEST_F(TransportAdapterTest, SearchDeviceFailed) { TEST_F(TransportAdapterTest, AddDevice) { MockTransportAdapterImpl transport_adapter( NULL, NULL, NULL, last_state_, transport_manager_settings); + SetDefaultExpectations(transport_adapter); EXPECT_CALL(transport_adapter, Restore()).WillOnce(Return(true)); transport_adapter.Init(); @@ -200,6 +212,7 @@ TEST_F(TransportAdapterTest, Connect_ServerNotSupported) { MockClientConnectionListener* clientMock = new MockClientConnectionListener(); MockTransportAdapterImpl transport_adapter( NULL, NULL, clientMock, last_state_, transport_manager_settings); + SetDefaultExpectations(transport_adapter); EXPECT_CALL(*clientMock, Init()).WillOnce(Return(TransportAdapter::OK)); EXPECT_CALL(transport_adapter, Restore()).WillOnce(Return(true)); @@ -217,6 +230,7 @@ TEST_F(TransportAdapterTest, Connect_ServerNotInitialized) { MockServerConnectionFactory* serverMock = new MockServerConnectionFactory(); MockTransportAdapterImpl transport_adapter( NULL, serverMock, NULL, last_state_, transport_manager_settings); + SetDefaultExpectations(transport_adapter); EXPECT_CALL(*serverMock, Init()).WillOnce(Return(TransportAdapter::OK)); EXPECT_CALL(transport_adapter, Restore()).WillOnce(Return(true)); @@ -234,6 +248,7 @@ TEST_F(TransportAdapterTest, Connect_Success) { MockServerConnectionFactory* serverMock = new MockServerConnectionFactory(); MockTransportAdapterImpl transport_adapter( NULL, serverMock, NULL, last_state_, transport_manager_settings); + SetDefaultExpectations(transport_adapter); EXPECT_CALL(*serverMock, Init()).WillOnce(Return(TransportAdapter::OK)); EXPECT_CALL(transport_adapter, Restore()).WillOnce(Return(true)); @@ -252,6 +267,7 @@ TEST_F(TransportAdapterTest, Connect_DeviceAddedTwice) { MockServerConnectionFactory* serverMock = new MockServerConnectionFactory(); MockTransportAdapterImpl transport_adapter( NULL, serverMock, NULL, last_state_, transport_manager_settings); + SetDefaultExpectations(transport_adapter); EXPECT_CALL(*serverMock, Init()).WillOnce(Return(TransportAdapter::OK)); EXPECT_CALL(transport_adapter, Restore()).WillOnce(Return(true)); @@ -274,6 +290,7 @@ TEST_F(TransportAdapterTest, Connect_DeviceAddedTwice) { TEST_F(TransportAdapterTest, ConnectDevice_ServerNotAdded_DeviceAdded) { MockTransportAdapterImpl transport_adapter( NULL, NULL, NULL, last_state_, transport_manager_settings); + SetDefaultExpectations(transport_adapter); EXPECT_CALL(transport_adapter, Restore()).WillOnce(Return(true)); transport_adapter.Init(); @@ -292,12 +309,14 @@ TEST_F(TransportAdapterTest, ConnectDevice_ServerNotAdded_DeviceAdded) { TransportAdapter::Error res = transport_adapter.ConnectDevice(uniq_id); EXPECT_EQ(TransportAdapter::FAIL, res); + EXPECT_NE(ConnectionStatus::CONNECTED, mockdev->connection_status()); } TEST_F(TransportAdapterTest, ConnectDevice_DeviceNotAdded) { MockServerConnectionFactory* serverMock = new MockServerConnectionFactory(); MockTransportAdapterImpl transport_adapter( NULL, serverMock, NULL, last_state_, transport_manager_settings); + SetDefaultExpectations(transport_adapter); EXPECT_CALL(*serverMock, Init()).WillOnce(Return(TransportAdapter::OK)); EXPECT_CALL(transport_adapter, Restore()).WillOnce(Return(true)); transport_adapter.Init(); @@ -318,6 +337,7 @@ TEST_F(TransportAdapterTest, ConnectDevice_DeviceAdded) { MockServerConnectionFactory* serverMock = new MockServerConnectionFactory(); MockTransportAdapterImpl transport_adapter( NULL, serverMock, NULL, last_state_, transport_manager_settings); + SetDefaultExpectations(transport_adapter); EXPECT_CALL(*serverMock, Init()).WillOnce(Return(TransportAdapter::OK)); EXPECT_CALL(transport_adapter, Restore()).WillOnce(Return(true)); @@ -339,16 +359,58 @@ TEST_F(TransportAdapterTest, ConnectDevice_DeviceAdded) { EXPECT_CALL(*serverMock, CreateConnection(uniq_id, app_handle)) .WillOnce(Return(TransportAdapter::OK)); EXPECT_CALL(transport_adapter, FindDevice(uniq_id)).WillOnce(Return(mockdev)); + EXPECT_CALL(transport_adapter, ConnectionStatusUpdated()); TransportAdapter::Error res = transport_adapter.ConnectDevice(uniq_id); EXPECT_EQ(TransportAdapter::OK, res); + EXPECT_EQ(ConnectionStatus::CONNECTED, mockdev->connection_status()); EXPECT_CALL(*serverMock, Terminate()); } +TEST_F(TransportAdapterTest, ConnectDevice_DeviceAdded_ConnectFailedRetry) { + MockServerConnectionFactory* server_mock = new MockServerConnectionFactory(); + MockTransportAdapterImpl transport_adapter( + NULL, server_mock, NULL, last_state_, transport_manager_settings); + SetDefaultExpectations(transport_adapter); + // transport_adapter.SetDeviceType(DeviceType::CLOUD_WEBSOCKET); + + EXPECT_CALL(*server_mock, Init()).WillOnce(Return(TransportAdapter::OK)); + EXPECT_CALL(transport_adapter, Restore()).WillOnce(Return(true)); + transport_adapter.Init(); + + std::shared_ptr mockdev = + std::make_shared(dev_id, uniq_id); + transport_adapter.AddDevice(mockdev); + + std::vector dev_list = transport_adapter.GetDeviceList(); + ASSERT_EQ(1u, dev_list.size()); + EXPECT_EQ(uniq_id, dev_list[0]); + + int app_handle = 1; + std::vector int_list = {app_handle}; + EXPECT_CALL(*mockdev, GetApplicationList()).WillOnce(Return(int_list)); + + EXPECT_CALL(*server_mock, IsInitialised()).WillOnce(Return(true)); + EXPECT_CALL(*server_mock, CreateConnection(uniq_id, app_handle)) + .WillOnce(Return(TransportAdapter::FAIL)); + EXPECT_CALL(transport_adapter, FindDevice(uniq_id)).WillOnce(Return(mockdev)); + EXPECT_CALL(transport_adapter, GetDeviceType()) + .WillOnce(Return(DeviceType::CLOUD_WEBSOCKET)); + EXPECT_CALL(transport_adapter, ConnectionStatusUpdated()); + EXPECT_CALL(transport_manager_settings, cloud_app_max_retry_attempts()) + .WillOnce(Return(0)); + TransportAdapter::Error res = transport_adapter.ConnectDevice(uniq_id); + EXPECT_EQ(TransportAdapter::FAIL, res); + EXPECT_EQ(ConnectionStatus::PENDING, mockdev->connection_status()); + + EXPECT_CALL(*server_mock, Terminate()); +} + TEST_F(TransportAdapterTest, ConnectDevice_DeviceAddedTwice) { MockServerConnectionFactory* serverMock = new MockServerConnectionFactory(); MockTransportAdapterImpl transport_adapter( NULL, serverMock, NULL, last_state_, transport_manager_settings); + SetDefaultExpectations(transport_adapter); EXPECT_CALL(*serverMock, Init()).WillOnce(Return(TransportAdapter::OK)); EXPECT_CALL(transport_adapter, Restore()).WillOnce(Return(true)); @@ -370,8 +432,10 @@ TEST_F(TransportAdapterTest, ConnectDevice_DeviceAddedTwice) { EXPECT_CALL(*serverMock, CreateConnection(uniq_id, app_handle)) .WillOnce(Return(TransportAdapter::OK)); EXPECT_CALL(transport_adapter, FindDevice(uniq_id)).WillOnce(Return(mockdev)); + EXPECT_CALL(transport_adapter, ConnectionStatusUpdated()); TransportAdapter::Error res = transport_adapter.ConnectDevice(uniq_id); EXPECT_EQ(TransportAdapter::OK, res); + EXPECT_EQ(ConnectionStatus::CONNECTED, mockdev->connection_status()); // Try to connect device second time @@ -380,8 +444,10 @@ TEST_F(TransportAdapterTest, ConnectDevice_DeviceAddedTwice) { EXPECT_CALL(*serverMock, IsInitialised()).WillOnce(Return(true)); EXPECT_CALL(*serverMock, CreateConnection(uniq_id, app_handle)).Times(0); EXPECT_CALL(transport_adapter, FindDevice(uniq_id)).WillOnce(Return(mockdev)); + EXPECT_CALL(transport_adapter, ConnectionStatusUpdated()); TransportAdapter::Error newres = transport_adapter.ConnectDevice(uniq_id); EXPECT_EQ(TransportAdapter::OK, newres); + EXPECT_EQ(ConnectionStatus::CONNECTED, mockdev->connection_status()); EXPECT_CALL(*serverMock, Terminate()); } @@ -390,6 +456,7 @@ TEST_F(TransportAdapterTest, Disconnect_ConnectDoneSuccess) { MockServerConnectionFactory* serverMock = new MockServerConnectionFactory(); MockTransportAdapterImpl transport_adapter( NULL, serverMock, NULL, last_state_, transport_manager_settings); + SetDefaultExpectations(transport_adapter); EXPECT_CALL(*serverMock, Init()).WillOnce(Return(TransportAdapter::OK)); EXPECT_CALL(transport_adapter, Restore()).WillOnce(Return(true)); @@ -420,6 +487,7 @@ TEST_F(TransportAdapterTest, DisconnectDevice_DeviceAddedConnectionCreated) { MockServerConnectionFactory* serverMock = new MockServerConnectionFactory(); MockTransportAdapterImpl transport_adapter( NULL, serverMock, NULL, last_state_, transport_manager_settings); + SetDefaultExpectations(transport_adapter); EXPECT_CALL(*serverMock, Init()).WillOnce(Return(TransportAdapter::OK)); EXPECT_CALL(transport_adapter, Restore()).WillOnce(Return(true)); @@ -441,8 +509,10 @@ TEST_F(TransportAdapterTest, DisconnectDevice_DeviceAddedConnectionCreated) { .WillOnce(Return(TransportAdapter::OK)); EXPECT_CALL(transport_adapter, FindDevice(uniq_id)) .WillRepeatedly(Return(mockdev)); + EXPECT_CALL(transport_adapter, ConnectionStatusUpdated()); TransportAdapter::Error res = transport_adapter.ConnectDevice(uniq_id); EXPECT_EQ(TransportAdapter::OK, res); + EXPECT_EQ(ConnectionStatus::CONNECTED, mockdev->connection_status()); auto mock_connection = std::make_shared(); transport_adapter.ConnectionCreated(mock_connection, uniq_id, app_handle); @@ -450,8 +520,10 @@ TEST_F(TransportAdapterTest, DisconnectDevice_DeviceAddedConnectionCreated) { EXPECT_CALL(*mock_connection, Disconnect()) .WillOnce(Return(TransportAdapter::OK)); + EXPECT_CALL(transport_adapter, ConnectionStatusUpdated()); TransportAdapter::Error new_res = transport_adapter.DisconnectDevice(uniq_id); EXPECT_EQ(TransportAdapter::OK, new_res); + EXPECT_EQ(ConnectionStatus::CLOSING, mockdev->connection_status()); EXPECT_CALL(*serverMock, Terminate()); } @@ -460,6 +532,7 @@ TEST_F(TransportAdapterTest, DeviceDisconnected) { MockServerConnectionFactory* serverMock = new MockServerConnectionFactory(); MockTransportAdapterImpl transport_adapter( NULL, serverMock, NULL, last_state_, transport_manager_settings); + SetDefaultExpectations(transport_adapter); EXPECT_CALL(*serverMock, Init()).WillOnce(Return(TransportAdapter::OK)); EXPECT_CALL(transport_adapter, Restore()).WillOnce(Return(true)); @@ -483,8 +556,10 @@ TEST_F(TransportAdapterTest, DeviceDisconnected) { EXPECT_CALL(*serverMock, IsInitialised()).WillOnce(Return(true)); EXPECT_CALL(*serverMock, CreateConnection(uniq_id, app_handle)) .WillOnce(Return(TransportAdapter::OK)); + EXPECT_CALL(transport_adapter, ConnectionStatusUpdated()); TransportAdapter::Error res = transport_adapter.ConnectDevice(uniq_id); EXPECT_EQ(TransportAdapter::OK, res); + EXPECT_EQ(ConnectionStatus::CONNECTED, mockdev->connection_status()); std::shared_ptr mock_connection = std::make_shared(); @@ -508,6 +583,7 @@ TEST_F(TransportAdapterTest, AbortedConnectSuccess) { MockServerConnectionFactory* serverMock = new MockServerConnectionFactory(); MockTransportAdapterImpl transport_adapter( NULL, serverMock, NULL, last_state_, transport_manager_settings); + SetDefaultExpectations(transport_adapter); EXPECT_CALL(*serverMock, Init()).WillOnce(Return(TransportAdapter::OK)); EXPECT_CALL(transport_adapter, Restore()).WillOnce(Return(true)); @@ -534,6 +610,7 @@ TEST_F(TransportAdapterTest, SendData) { MockServerConnectionFactory* serverMock = new MockServerConnectionFactory(); MockTransportAdapterImpl transport_adapter( dev_mock, serverMock, NULL, last_state_, transport_manager_settings); + SetDefaultExpectations(transport_adapter); EXPECT_CALL(*dev_mock, Init()).WillOnce(Return(TransportAdapter::OK)); EXPECT_CALL(*serverMock, Init()).WillOnce(Return(TransportAdapter::OK)); @@ -575,6 +652,7 @@ TEST_F(TransportAdapterTest, SendData_ConnectionNotEstablished) { clientMock, last_state_, transport_manager_settings); + SetDefaultExpectations(transport_adapter); EXPECT_CALL(*dev_mock, Init()).WillOnce(Return(TransportAdapter::OK)); EXPECT_CALL(*clientMock, Init()).WillOnce(Return(TransportAdapter::OK)); @@ -610,6 +688,7 @@ TEST_F(TransportAdapterTest, StartClientListening_ClientNotInitialized) { MockClientConnectionListener* clientMock = new MockClientConnectionListener(); MockTransportAdapterImpl transport_adapter( dev_mock, NULL, clientMock, last_state_, transport_manager_settings); + SetDefaultExpectations(transport_adapter); EXPECT_CALL(*dev_mock, Init()).WillOnce(Return(TransportAdapter::OK)); EXPECT_CALL(*clientMock, Init()).WillOnce(Return(TransportAdapter::OK)); @@ -631,6 +710,7 @@ TEST_F(TransportAdapterTest, StartClientListening) { MockClientConnectionListener* clientMock = new MockClientConnectionListener(); MockTransportAdapterImpl transport_adapter( dev_mock, NULL, clientMock, last_state_, transport_manager_settings); + SetDefaultExpectations(transport_adapter); EXPECT_CALL(*dev_mock, Init()).WillOnce(Return(TransportAdapter::OK)); EXPECT_CALL(*clientMock, Init()).WillOnce(Return(TransportAdapter::OK)); @@ -657,6 +737,7 @@ TEST_F(TransportAdapterTest, StopClientListening_Success) { clientMock, last_state_, transport_manager_settings); + SetDefaultExpectations(transport_adapter); EXPECT_CALL(*dev_mock, Init()).WillOnce(Return(TransportAdapter::OK)); EXPECT_CALL(*clientMock, Init()).WillOnce(Return(TransportAdapter::OK)); @@ -691,6 +772,7 @@ TEST_F(TransportAdapterTest, FindNewApplicationsRequest) { clientMock, last_state_, transport_manager_settings); + SetDefaultExpectations(transport_adapter); EXPECT_CALL(*dev_mock, Init()).WillOnce(Return(TransportAdapter::OK)); EXPECT_CALL(*clientMock, Init()).WillOnce(Return(TransportAdapter::OK)); @@ -712,6 +794,7 @@ TEST_F(TransportAdapterTest, FindNewApplicationsRequest) { TEST_F(TransportAdapterTest, GetDeviceAndApplicationLists) { MockTransportAdapterImpl transport_adapter( NULL, NULL, NULL, last_state_, transport_manager_settings); + SetDefaultExpectations(transport_adapter); EXPECT_CALL(transport_adapter, Restore()).WillOnce(Return(true)); transport_adapter.Init(); @@ -736,6 +819,7 @@ TEST_F(TransportAdapterTest, FindEstablishedConnection) { MockServerConnectionFactory* serverMock = new MockServerConnectionFactory(); MockTransportAdapterImpl transport_adapter( NULL, serverMock, NULL, last_state_, transport_manager_settings); + SetDefaultExpectations(transport_adapter); EXPECT_CALL(*serverMock, Init()).WillOnce(Return(TransportAdapter::OK)); EXPECT_CALL(transport_adapter, Restore()).WillOnce(Return(true)); @@ -765,6 +849,7 @@ TEST_F(TransportAdapterTest, RunAppOnDevice_NoDeviseWithAskedId_UNSUCCESS) { MockTransportAdapterImpl transport_adapter( NULL, NULL, NULL, last_state_, transport_manager_settings); + SetDefaultExpectations(transport_adapter); std::shared_ptr mock_device = std::make_shared("test_device_name", "test_device_uid0"); @@ -784,6 +869,7 @@ TEST_F(TransportAdapterTest, RunAppOnDevice_DeviseWithAskedIdWasFound_SUCCESS) { MockTransportAdapterImpl transport_adapter( NULL, NULL, NULL, last_state_, transport_manager_settings); + SetDefaultExpectations(transport_adapter); std::shared_ptr mock_device = std::make_shared("test_device_name", device_uid); @@ -815,6 +901,7 @@ TEST_F(TransportAdapterTest, StopDevice) { TEST_F(TransportAdapterTest, TransportConfigUpdated) { MockTransportAdapterImpl transport_adapter( NULL, NULL, NULL, last_state_, transport_manager_settings); + SetDefaultExpectations(transport_adapter); EXPECT_CALL(transport_adapter, Restore()).WillOnce(Return(true)); transport_adapter.Init(); @@ -833,6 +920,7 @@ TEST_F(TransportAdapterTest, TransportConfigUpdated) { TEST_F(TransportAdapterTest, GetTransportConfigration) { MockTransportAdapterImpl transport_adapter( NULL, NULL, NULL, last_state_, transport_manager_settings); + SetDefaultExpectations(transport_adapter); EXPECT_CALL(transport_adapter, Restore()).WillOnce(Return(true)); transport_adapter.Init(); -- cgit v1.2.1 From 6a7fd9f5e533c2acf476ab1ef11e254b3f529b48 Mon Sep 17 00:00:00 2001 From: ShobhitAd Date: Fri, 30 Nov 2018 09:01:33 -0500 Subject: Implement WSS connection --- .../cloud/websocket_client_connection.h | 11 ++- .../src/cloud/websocket_client_connection.cc | 103 ++++++++++++++++++++- 2 files changed, 110 insertions(+), 4 deletions(-) diff --git a/src/components/transport_manager/include/transport_manager/cloud/websocket_client_connection.h b/src/components/transport_manager/include/transport_manager/cloud/websocket_client_connection.h index da3a80e1b2..a5ed0e80db 100644 --- a/src/components/transport_manager/include/transport_manager/cloud/websocket_client_connection.h +++ b/src/components/transport_manager/include/transport_manager/cloud/websocket_client_connection.h @@ -49,6 +49,7 @@ #include #include #include "transport_manager/transport_adapter/connection.h" +#include "transport_manager/cloud/cloud_websocket_transport_adapter.h" #include "utils/threads/thread.h" #include "utils/threads/message_loop_thread.h" #include "utils/message_queue.h" @@ -117,6 +118,13 @@ class WebsocketClientConnection */ TransportAdapter::Error Disconnect(); + /** + * @brief Attempt to open a secure connection with the provided certificate + * + * @return true if secured connection was created successfully + */ + bool AddCertificateAuthority(std::string cert, boost::system::error_code& ec); + void Shutdown(); void Recv(boost::system::error_code ec); @@ -126,8 +134,9 @@ class WebsocketClientConnection private: TransportAdapterController* controller_; boost::asio::io_context ioc_; + ssl::context ctx_; tcp::resolver resolver_; - websocket::stream ws_; + websocket::stream> ws_; boost::beast::flat_buffer buffer_; std::string host_; std::string text_; diff --git a/src/components/transport_manager/src/cloud/websocket_client_connection.cc b/src/components/transport_manager/src/cloud/websocket_client_connection.cc index 0912a07999..4ee6c6b899 100644 --- a/src/components/transport_manager/src/cloud/websocket_client_connection.cc +++ b/src/components/transport_manager/src/cloud/websocket_client_connection.cc @@ -47,13 +47,36 @@ WebsocketClientConnection::WebsocketClientConnection( const ApplicationHandle& app_handle, TransportAdapterController* controller) : controller_(controller) + , ctx_(ssl::context::sslv23_client) , resolver_(ioc_) - , ws_(ioc_) + , ws_{ioc_, ctx_} , shutdown_(false) , thread_delegate_(new LoopThreadDelegate(&message_queue_, this)) , write_thread_(threads::CreateThread("WS Async Send", thread_delegate_)) , device_uid_(device_uid) - , app_handle_(app_handle) {} + , app_handle_(app_handle) { + + LOG4CXX_DEBUG(logger_, "CLOUD_DEBUG_WEBSOCKETCLIENTCONNECTION"); + // LOG4CXX_DEBUG(logger_, controller); + + // CloudWebsocketTransportAdapter* cta = static_cast(controller); + // LOG4CXX_DEBUG(logger_, cta); + + // CloudAppTransportConfig temp = cta->GetCloudTransportConfiguration(); + + + // LOG4CXX_DEBUG(logger_, "Printing CloudAppTransportConfig: " << temp.size()); + // for(auto it = temp.cbegin(); it != temp.cend(); it++){ + // std::string txt = "DEVICE: " + it->first + "\n"; + // txt += "ENDPOINT: " + it->second.endpoint + "\n"; + // txt += "CERTIFICATE: " + it->second.certificate + "\n"; + // txt += "AUTH_TOKEN: " + it->second.auth_token + "\n"; + // LOG4CXX_DEBUG(logger_, txt); + + // } + } + + WebsocketClientConnection::~WebsocketClientConnection() { ioc_.stop(); @@ -62,6 +85,25 @@ WebsocketClientConnection::~WebsocketClientConnection() { } } +bool WebsocketClientConnection::AddCertificateAuthority(const std::string cert, boost::system::error_code& ec){ + if(cert == "not_specified"){ + ws_.next_layer().set_verify_mode(ssl::verify_none); + return false; + } + + ctx_.add_certificate_authority(boost::asio::buffer(cert.data(), cert.size()), ec); + if(ec){ + return false; + } + + ws_.next_layer().set_verify_mode(ssl::verify_peer); + if(ec){ + return false; + } + + return true; +} + TransportAdapter::Error WebsocketClientConnection::Start() { LOG4CXX_AUTO_TRACE(logger_); DeviceSptr device = controller_->FindDevice(device_uid_); @@ -70,13 +112,21 @@ TransportAdapter::Error WebsocketClientConnection::Start() { auto const port = cloud_device->GetPort(); boost::system::error_code ec; auto const results = resolver_.resolve(host, port, ec); + + LOG4CXX_DEBUG(logger_, "CLOUD_CONN_START"); + if (ec) { std::string str_err = "ErrorMessage: " + ec.message(); LOG4CXX_ERROR(logger_, "Could not resolve host/port: " << str_err); Shutdown(); return TransportAdapter::FAIL; } - boost::asio::connect(ws_.next_layer(), results.begin(), results.end(), ec); + + LOG4CXX_DEBUG(logger_, "CLOUD_CONN_RESOLVE"); + + // Make Connection to host IP Address over TCP + boost::asio::connect(ws_.next_layer().next_layer(), results.begin(), results.end(), ec); + if (ec) { std::string str_err = "ErrorMessage: " + ec.message(); LOG4CXX_ERROR(logger_, @@ -85,7 +135,50 @@ TransportAdapter::Error WebsocketClientConnection::Start() { Shutdown(); return TransportAdapter::FAIL; } + + LOG4CXX_DEBUG(logger_, "CLOUD_CONN_TCP"); + + std::string cert = "-----BEGIN CERTIFICATE-----\nMIIDBjCCAe6gAwIBAgIJAOsbkrgCZxgtMA0GCSqGSIb3DQEBCwUAMBgxFjAUBgNV\nBAMMDTE5Mi4xNjguMS4xMjgwHhcNMTgxMTI4MTgxNjQwWhcNMjExMTI3MTgxNjQw\nWjAYMRYwFAYDVQQDDA0xOTIuMTY4LjEuMTI4MIIBIjANBgkqhkiG9w0BAQEFAAOC\nAQ8AMIIBCgKCAQEAlVrHDi+XdO9fNMcknqs2Hn0AQjKQZAq0juy8r7gDqkzHw9zY\nFnfssIUzP7R6F1/80ulyjwUN6G+SI7phbivr2gmSdfkYiJVdwBKf611srIrNF/Eh\nllt/2sjwZNyTai4pzZv9/svix5nIVCHdKZD6wsxCFOdNhVJGBd9uQ4Pk1hQoW/jj\nsUF/NBUa49k31/IQiqQ6T1xQvSkEUYd1kstS7utO2V0Z9rHH4/+4HNyPMKipkCi2\n/7WuvQGDyHTnNUFmEANn4X06iQAVon9L8IVRcGwtgsWJ0fuVGK5POtU4m37Q35MW\n3RWF3OzyP/6PxRX5ljQFmkwGkqzHrNzOZN+zMQIDAQABo1MwUTAdBgNVHQ4EFgQU\nc1BN7ZNXq+OA5hT+vq1NOMoUrR8wHwYDVR0jBBgwFoAUc1BN7ZNXq+OA5hT+vq1N\nOMoUrR8wDwYDVR0TAQH/BAUwAwEB/zANBgkqhkiG9w0BAQsFAAOCAQEANBnwEOwM\nRynBmaRBBVZBxcWsaWQ6h7XETLSU+Pqrv2cm+g8pS1pFwc69OS5ER730UcCADlLv\n7Lu61m9kOxHuDzeQR5ofkVbFx1swUqSZt7GZvopVtwFeto4zUfAyVfCS6n6MGSvN\nWlathEg3mlXlAjtX1qEg1JzJ5DjowiPpJ2FZMsakJrF3Ju0D0Dskg0wgqZLKcHYC\ndV7bm2SpC7kfqeuSXIC8hbfolJBaysFRjIXXWwDhtW2i4KRDq4b54EVON2af6RD7\nbsOiY4Qt4Aw5UOE+DN/dbkXXNHKDWN/VN1MI9wGJiriXf4BWSJWgrrsXHkpzqmMj\nrHR2ik90MT9pkQ==\n-----END CERTIFICATE-----"; + std::string fake_cert = "-----BEGIN CERTIFICATE-----\nMIIDBjCCAe6gAwIBAgIJAOTd19xp9ISxMA0GCSqGSIb3DQEBCwUAMBgxFjAUBgNV\nBAMMDTE5Mi4xNjguMS4xMjgwHhcNMTgxMTI4MTM1NjI0WhcNMjExMTI3MTM1NjI0\nWjAYMRYwFAYDVQQDDA0xOTIuMTY4LjEuMTI4MIIBIjANBgkqhkiG9w0BAQEFAAOC\nAQ8AMIIBCgKCAQEAlVrHDi+XdO9fNMcknqs2Hn0AQjKQZAq0juy8r7gDqkzHw9zY\nFnfssIUzP7R6F1/80ulyjwUN6G+SI7phbivr2gmSdfkYiJVdwBKf611srIrNF/Eh\nllt/2sjwZNyTai4pzZv9/svix5nIVCHdKZD6wsxCFOdNhVJGBd9uQ4Pk1hQoW/jj\nsUF/NBUa49k31/IQiqQ6T1xQvSkEUYd1kstS7utO2V0Z9rHH4/+4HNyPMKipkCi2\n/7WuvQGDyHTnNUFmEANn4X06iQAVon9L8IVRcGwtgsWJ0fuVGK5POtU4m37Q35MW\n3RWF3OzyP/6PxRX5ljQFmkwGkqzHrNzOZN+zMQIDAQABo1MwUTAdBgNVHQ4EFgQU\nc1BN7ZNXq+OA5hT+vq1NOMoUrR8wHwYDVR0jBBgwFoAUc1BN7ZNXq+OA5hT+vq1N\nOMoUrR8wDwYDVR0TAQH/BAUwAwEB/zANBgkqhkiG9w0BAQsFAAOCAQEAUQ8MwCmb\nDrwCNGaUdGNXoiAWrltPE2buzpq8OCVxXBSqSumAe1SkjyKROBbevM7/Cl4V3qgj\nEHjUXNrzFR9WTCOOjJ9W0wiO25FDBguU5VCkuhvfL6lCgVuJRRi9LtiY2hT5fPdM\nrMvS0/iUV3RXcKNyIGOXH1OcOim+PVph2wj0x/N1Nmhqkh+2LtFHhsE/Zgygndla\nsbyRTNQ3bnzGUwMl8jPa7KSeggtfmjIFc4VXEgrOzKHhJO2C96FmVMo97QqKQvq+\nWjPfzHnI3hhr1GPPMHFQQZG5j4a708Qo9fZcKJxUvm0O7kdFFOqcMyo086cu1YUP\nGy5s8MqShPUp1Q==\n-----END CERTIFICATE-----"; + std::string no_cert = "not_specified"; + std::string invalid_cert = "-----BEGIN CERTIFICATE-----\nWjAYMRYwFAYDVQQDDA0xOTIuMTY4LjEuMTI4MIIBIjANBgkqhkiG9w0BAQEFAAOC\nAQ8AMIIBCgKCAQEAlVrHDi+XdO9fNMcknqs2Hn0AQjKQZAq0juy8r7gDqkzHw9zY\nFnfssIUzP7R6F1/80ulyjwUN6G+SI7phbivr2gmSdfkYiJVdwBKf611srIrNF/Eh\nllt/2sjwZNyTai4pzZv9/svix5nIVCHdKZD6wsxCFOdNhVJGBd9uQ4Pk1hQoW/jj\nsUF/NBUa49k31/IQiqQ6T1xQvSkEUYd1kstS7utO2V0Z9rHH4/+4HNyPMKipkCi2\n/7WuvQGDyHTnNUFmEANn4X06iQAVon9L8IVRcGwtgsWJ0fuVGK5POtU4m37Q35MW\n3RWF3OzyP/6PxRX5ljQFmkwGkqzHrNzOZN+zMQIDAQABo1MwUTAdBgNVHQ4EFgQU\nc1BN7ZNXq+OA5hT+vq1NOMoUrR8wHwYDVR0jBBgwFoAUc1BN7ZNXq+OA5hT+vq1N\nOMoUrR8wDwYDVR0TAQH/BAUwAwEB/zANBgkqhkiG9w0BAQsFAAOCAQEAUQ8MwCmb\nDrwCNGaUdGNXoiAWrltPE2buzpq8OCVxXBSqSumAe1SkjyKROBbevM7/Cl4V3qgj\nEHjUXNrzFR9WTCOOjJ9W0wiO25FDBguU5VCkuhvfL6lCgVuJRRi9LtiY2hT5fPdM\nrMvS0/iUV3RXcKNyIGOXH1OcOim+PVph2wj0x/N1Nmhqkh+2LtFHhsE/Zgygndla\nsbyRTNQ3bnzGUwMl8jPa7KSeggtfmjIFc4VXEgrOzKHhJO2C96FmVMo97QqKQvq+\nWjPfzHnI3hhr1GPPMHFQQZG5j4a708Qo9fZcKJxUvm0O7kdFFOqcMyo086cu1YUP\nGy5s8MqShPUp1Q==\n-----END CERTIFICATE-----"; + std::string test_cert = ""; + + bool isAdded = AddCertificateAuthority(cert, ec); + + if(isAdded){ + LOG4CXX_INFO(logger_, "Certificate Authority added successfully"); + }else{ + LOG4CXX_INFO(logger_, "Failed to add certificate authority"); + } + + if(ec){ + std::string str_err = "ErrorMessage: " + ec.message(); + LOG4CXX_ERROR(logger_, + "Failed to add certificate authority: " << invalid_cert); + LOG4CXX_ERROR(logger_, str_err); + Shutdown(); + return TransportAdapter::FAIL; + } + + //Perform SSL Handshake + ws_.next_layer().handshake(ssl::stream_base::client, ec); + + if (ec) { + std::string str_err = "ErrorMessage: " + ec.message(); + LOG4CXX_ERROR(logger_, + "Could not complete SSL Handshake failed with host/port: " << host << ":" + << port); + LOG4CXX_ERROR(logger_, str_err); + Shutdown(); + return TransportAdapter::FAIL; + } + + LOG4CXX_DEBUG(logger_, "CLOUD_CONN_SSL"); + + // Perform websocket handshake ws_.handshake(host, "/", ec); + if (ec) { std::string str_err = "ErrorMessage: " + ec.message(); LOG4CXX_ERROR(logger_, @@ -95,6 +188,10 @@ TransportAdapter::Error WebsocketClientConnection::Start() { Shutdown(); return TransportAdapter::FAIL; } + + LOG4CXX_DEBUG(logger_, "CLOUD_CONN_WEBSOCKET"); + + // Set the binary message write option ws_.binary(true); write_thread_->start(threads::ThreadOptions()); controller_->ConnectDone(device_uid_, app_handle_); -- cgit v1.2.1 From 3838e16a6fe357f77370fa8bac644a4ec227690a Mon Sep 17 00:00:00 2001 From: jacobkeeler Date: Fri, 30 Nov 2018 11:44:08 -0500 Subject: Fix incorrect HMI state after cloud app registration --- .../commands/mobile/register_app_interface_request.cc | 4 ++-- .../application_manager/src/application_manager_impl.cc | 15 --------------- .../src/resumption/resume_ctrl_impl.cc | 16 ++++++++++++++-- 3 files changed, 16 insertions(+), 19 deletions(-) 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 f8d3267441..b346ee5798 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 @@ -805,8 +805,6 @@ void RegisterAppInterfaceRequest::SendRegisterAppInterfaceResponseToMobile( file_system::FileExists(application->app_icon_path()); SendResponse(true, result_code, add_info.c_str(), &response_params); - SendOnAppRegisteredNotificationToHMI( - application, resumption, need_restore_vr); if (msg_params.keyExists(strings::app_hmi_type)) { GetPolicyHandler().SetDefaultHmiTypes(application->policy_app_id(), &(msg_params[strings::app_hmi_type])); @@ -815,6 +813,8 @@ void RegisterAppInterfaceRequest::SendRegisterAppInterfaceResponseToMobile( // Default HMI level should be set before any permissions validation, since it // relies on HMI level. application_manager_.OnApplicationRegistered(application); + SendOnAppRegisteredNotificationToHMI( + application, resumption, need_restore_vr); (*notify_upd_manager)(); // Start PTU after successfull registration diff --git a/src/components/application_manager/src/application_manager_impl.cc b/src/components/application_manager/src/application_manager_impl.cc index d2d2458ac0..938e994ba0 100644 --- a/src/components/application_manager/src/application_manager_impl.cc +++ b/src/components/application_manager/src/application_manager_impl.cc @@ -381,21 +381,6 @@ void ApplicationManagerImpl::OnApplicationRegistered(ApplicationSharedPtr app) { plugin.OnApplicationEvent(plugin_manager::kApplicationRegistered, app); }; plugin_manager_->ForEachPlugin(on_app_registered); - - // TODO(AOleynik): Is neccessary to be able to know that registration process - // has been completed and default HMI level is set, otherwise policy will - // block all the requests/notifications to mobile - // APPLINK-20764 - introduce usage of internal events or re-implement - event_engine::Event event( - hmi_apis::FunctionID::BasicCommunication_OnAppRegistered); - - smart_objects::SmartObject msg; - msg[strings::params][strings::message_type] = - hmi_apis::messageType::notification; - msg[strings::params][strings::app_id] = app->app_id(); - - event.set_smart_object(msg); - event.raise(event_dispatcher()); } void ApplicationManagerImpl::OnApplicationSwitched(ApplicationSharedPtr app) { diff --git a/src/components/application_manager/src/resumption/resume_ctrl_impl.cc b/src/components/application_manager/src/resumption/resume_ctrl_impl.cc index 3e77078ee5..6af8826491 100644 --- a/src/components/application_manager/src/resumption/resume_ctrl_impl.cc +++ b/src/components/application_manager/src/resumption/resume_ctrl_impl.cc @@ -399,7 +399,13 @@ bool ResumeCtrlImpl::StartResumption(ApplicationSharedPtr application, << " hmi_app_id = " << application->hmi_app_id() << " policy_id = " << application->policy_app_id() << " received hash = " << hash); - SetupDefaultHMILevel(application); + if (!application->is_cloud_app()) { + // Default HMI Level is already set before resumption in + // ApplicationManager::OnApplicationRegistered, and handling low bandwidth + // transports doesn't apply to cloud apps, so this step can be skipped for + // such apps + SetupDefaultHMILevel(application); + } smart_objects::SmartObject saved_app; const std::string& device_mac = application->mac_address(); bool result = resumption_storage_->GetSavedApplication( @@ -426,7 +432,13 @@ bool ResumeCtrlImpl::StartResumptionOnlyHMILevel( << application->app_id() << "with hmi_app_id " << application->hmi_app_id() << ", policy_app_id " << application->policy_app_id()); - SetupDefaultHMILevel(application); + if (!application->is_cloud_app()) { + // Default HMI Level is already set before resumption in + // ApplicationManager::OnApplicationRegistered, and handling low bandwidth + // transports doesn't apply to cloud apps, so this step can be skipped for + // such apps + SetupDefaultHMILevel(application); + } const std::string& device_mac = application->mac_address(); smart_objects::SmartObject saved_app; bool result = resumption_storage_->GetSavedApplication( -- cgit v1.2.1 From 712440a5b5592ff447e8f9107d7c749e02b52cd4 Mon Sep 17 00:00:00 2001 From: jacobkeeler Date: Fri, 30 Nov 2018 11:48:10 -0500 Subject: Add ActivateApp test cases for cloud apps --- .../src/commands/hmi/sdl_activate_app_request.cc | 6 ++- .../commands/hmi/sdl_activate_app_request_test.cc | 54 +++++++++++++++++++++- .../test/resumption/resume_ctrl_test.cc | 1 + 3 files changed, 58 insertions(+), 3 deletions(-) diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/sdl_activate_app_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/sdl_activate_app_request.cc index 4a1fddc508..92a7020208 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/sdl_activate_app_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/sdl_activate_app_request.cc @@ -249,8 +249,10 @@ void SDLActivateAppRequest::onTimeOut() { using namespace hmi_apis::Common_Result; using namespace application_manager; unsubscribe_from_event(BasicCommunication_OnAppRegistered); - SendErrorResponse( - correlation_id(), SDL_ActivateApp, APPLICATION_NOT_REGISTERED, ""); + SendErrorResponse(correlation_id(), + SDL_ActivateApp, + APPLICATION_NOT_REGISTERED, + "App registration timed out"); } void SDLActivateAppRequest::on_event(const event_engine::Event& event) { diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/sdl_activate_app_request_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/sdl_activate_app_request_test.cc index 38cbc7b069..ea345e3b83 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/sdl_activate_app_request_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/sdl_activate_app_request_test.cc @@ -61,8 +61,10 @@ using testing::Mock; using testing::Return; using testing::ReturnRef; using testing::Mock; +using testing::Gt; using ::testing::NiceMock; using policy_test::MockPolicyHandlerInterface; +using connection_handler_test::MockConnectionHandler; using am::event_engine::Event; namespace { @@ -148,7 +150,7 @@ TEST_F(SDLActivateAppRequestTest, Run_ActivateApp_SUCCESS) { command->Run(); } -TEST_F(SDLActivateAppRequestTest, DISABLED_Run_DactivateApp_REJECTED) { +TEST_F(SDLActivateAppRequestTest, DISABLED_Run_DeactivateApp_REJECTED) { MessageSharedPtr msg = CreateMessage(); SetCorrelationAndAppID(msg); (*msg)[strings::msg_params][strings::function_id] = @@ -189,6 +191,7 @@ TEST_F(SDLActivateAppRequestTest, FindAppToRegister_SUCCESS) { .WillOnce(Return(false)); EXPECT_CALL(*mock_app, IsRegistered()).WillOnce(Return(false)); + EXPECT_CALL(*mock_app, is_cloud_app()).WillOnce(Return(false)); ON_CALL(*mock_app, device()).WillByDefault(Return(kHandle)); MockAppPtr mock_app_first(CreateMockApp()); @@ -250,6 +253,7 @@ TEST_F(SDLActivateAppRequestTest, DevicesAppsEmpty_SUCCESS) { .WillOnce(Return(false)); EXPECT_CALL(*mock_app, IsRegistered()).WillOnce(Return(false)); + EXPECT_CALL(*mock_app, is_cloud_app()).WillOnce(Return(false)); ON_CALL(*mock_app, device()).WillByDefault(Return(kHandle)); DataAccessor accessor(app_list_, lock_); @@ -336,6 +340,7 @@ TEST_F(SDLActivateAppRequestTest, FirstAppIsForeground_SUCCESS) { EXPECT_CALL(*mock_app, device()).WillOnce(Return(kHandle)); EXPECT_CALL(*mock_app, IsRegistered()).WillOnce(Return(false)); + EXPECT_CALL(*mock_app, is_cloud_app()).WillOnce(Return(false)); EXPECT_CALL(app_mngr_, state_controller()) .WillOnce(ReturnRef(mock_state_controller_)); EXPECT_CALL(mock_state_controller_, @@ -427,6 +432,53 @@ TEST_F(SDLActivateAppRequestTest, FirstAppNotRegistered_SUCCESS) { } #endif +TEST_F(SDLActivateAppRequestTest, WaitingCloudApplication_ConnectDevice) { + MessageSharedPtr msg = CreateMessage(); + SetCorrelationAndAppID(msg); + + std::shared_ptr command( + CreateCommand(msg)); + + MockAppPtr mock_app(CreateMockApp()); + + EXPECT_CALL(*mock_app, device()).WillOnce(Return(kHandle)); + EXPECT_CALL(*mock_app, IsRegistered()).WillOnce(Return(false)); + EXPECT_CALL(*mock_app, is_cloud_app()).WillOnce(Return(true)); + + EXPECT_CALL(app_mngr_, application(kAppID)) + .WillOnce(Return(ApplicationSharedPtr())); + EXPECT_CALL(app_mngr_, WaitingApplicationByID(kAppID)) + .WillOnce(Return(mock_app)); + + EXPECT_CALL(app_mngr_, state_controller()) + .WillOnce(ReturnRef(mock_state_controller_)); + EXPECT_CALL(mock_state_controller_, + IsStateActive(am::HmiState::StateID::STATE_ID_DEACTIVATE_HMI)) + .WillOnce(Return(false)); + + const uint16_t kRetries = 3; + const uint32_t kRetryTimeout = 2000; + const uint32_t kMinimumTimeout = kRetries * kRetryTimeout; + + MockApplicationManagerSettings settings; + EXPECT_CALL(settings, cloud_app_max_retry_attempts()) + .WillOnce(Return(kRetries)); + EXPECT_CALL(settings, cloud_app_retry_timeout()) + .WillOnce(Return(kRetryTimeout)); + EXPECT_CALL(app_mngr_, get_settings()).WillOnce(ReturnRef(settings)); + + EXPECT_CALL( + app_mngr_, + updateRequestTimeout(0, kCorrelationID, Gt(kMinimumTimeout))); + + MockConnectionHandler connection_handler; + EXPECT_CALL(connection_handler, ConnectToDevice(kHandle)); + + EXPECT_CALL(app_mngr_, connection_handler()).WillOnce(ReturnRef(connection_handler)); + + command->Run(); +} + TEST_F(SDLActivateAppRequestTest, OnTimeout_SUCCESS) { MessageSharedPtr msg = CreateMessage(); SetCorrelationAndAppID(msg); diff --git a/src/components/application_manager/test/resumption/resume_ctrl_test.cc b/src/components/application_manager/test/resumption/resume_ctrl_test.cc index 1c2339096c..2413421c7f 100644 --- a/src/components/application_manager/test/resumption/resume_ctrl_test.cc +++ b/src/components/application_manager/test/resumption/resume_ctrl_test.cc @@ -153,6 +153,7 @@ class ResumeCtrlTest : public ::testing::Test { ON_CALL(*mock_app_, mac_address()).WillByDefault(ReturnRef(kMacAddress_)); ON_CALL(*mock_app_, device()).WillByDefault(Return(kTestDevId_)); ON_CALL(*mock_app_, app_id()).WillByDefault(Return(kTestAppId_)); + ON_CALL(*mock_app_, is_cloud_app()).WillByDefault(Return(false)); } NiceMock mock_event_dispatcher_; -- cgit v1.2.1 From 106abc1b824dc3b8c3033548b0803ac1f4563b1a Mon Sep 17 00:00:00 2001 From: JackLivio Date: Fri, 30 Nov 2018 15:31:25 -0500 Subject: Include mock connection handler Ubuntu 14 build issue. --- .../sdl_rpc_plugin/test/commands/hmi/sdl_activate_app_request_test.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/sdl_activate_app_request_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/sdl_activate_app_request_test.cc index ea345e3b83..6adc9c8150 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/sdl_activate_app_request_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/sdl_activate_app_request_test.cc @@ -44,6 +44,7 @@ #include "application_manager/event_engine/event.h" #include "application_manager/mock_event_dispatcher.h" #include "application_manager/mock_state_controller.h" +#include "connection_handler/mock_connection_handler.h" namespace test { namespace components { -- cgit v1.2.1 From 64be1341b106c1b68c8adfb7018f4555d493be75 Mon Sep 17 00:00:00 2001 From: JackLivio Date: Fri, 30 Nov 2018 15:53:49 -0500 Subject: Set HMI None on disconnect. Add reconnection after disconnect. --- .../application_manager/application_manager_impl.h | 4 ++ .../commands/hmi/sdl_activate_app_request_test.cc | 10 ++-- .../src/application_manager_impl.cc | 27 ++++++++++ .../src/connection_handler_impl.cc | 4 +- .../connection_handler_observer.h | 4 ++ .../mock_connection_handler_observer.h | 3 ++ .../cloud/websocket_client_connection.h | 7 ++- .../transport_adapter_controller.h | 4 ++ .../transport_adapter/transport_adapter_impl.h | 4 ++ .../cloud/cloud_websocket_connection_factory.cc | 14 ++++-- .../src/cloud/websocket_client_connection.cc | 57 +++++++++------------- .../transport_adapter/transport_adapter_impl.cc | 37 +++++++++++++- .../src/transport_manager_impl.cc | 37 +++++++++++--- .../mock_transport_adapter_controller.h | 3 ++ .../test/tcp_client_listener_test.cc | 3 ++ 15 files changed, 163 insertions(+), 55 deletions(-) diff --git a/src/components/application_manager/include/application_manager/application_manager_impl.h b/src/components/application_manager/include/application_manager/application_manager_impl.h index a3e3cece72..797044993a 100644 --- a/src/components/application_manager/include/application_manager/application_manager_impl.h +++ b/src/components/application_manager/include/application_manager/application_manager_impl.h @@ -367,6 +367,10 @@ class ApplicationManagerImpl const transport_manager::DeviceInfo& device_info, connection_handler::DeviceHandle device_id); + void SetPendingApplicationState( + const transport_manager::ConnectionUID connection_id, + const transport_manager::DeviceInfo& device_info); + /** * @brief Notifies the applicaiton manager that a cloud connection status has * updated and should trigger an UpdateAppList RPC to the HMI diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/sdl_activate_app_request_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/sdl_activate_app_request_test.cc index 6adc9c8150..8543a201bf 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/sdl_activate_app_request_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/sdl_activate_app_request_test.cc @@ -460,7 +460,7 @@ TEST_F(SDLActivateAppRequestTest, WaitingCloudApplication_ConnectDevice) { const uint16_t kRetries = 3; const uint32_t kRetryTimeout = 2000; const uint32_t kMinimumTimeout = kRetries * kRetryTimeout; - + MockApplicationManagerSettings settings; EXPECT_CALL(settings, cloud_app_max_retry_attempts()) .WillOnce(Return(kRetries)); @@ -468,14 +468,14 @@ TEST_F(SDLActivateAppRequestTest, WaitingCloudApplication_ConnectDevice) { .WillOnce(Return(kRetryTimeout)); EXPECT_CALL(app_mngr_, get_settings()).WillOnce(ReturnRef(settings)); - EXPECT_CALL( - app_mngr_, - updateRequestTimeout(0, kCorrelationID, Gt(kMinimumTimeout))); + EXPECT_CALL(app_mngr_, + updateRequestTimeout(0, kCorrelationID, Gt(kMinimumTimeout))); MockConnectionHandler connection_handler; EXPECT_CALL(connection_handler, ConnectToDevice(kHandle)); - EXPECT_CALL(app_mngr_, connection_handler()).WillOnce(ReturnRef(connection_handler)); + EXPECT_CALL(app_mngr_, connection_handler()) + .WillOnce(ReturnRef(connection_handler)); command->Run(); } diff --git a/src/components/application_manager/src/application_manager_impl.cc b/src/components/application_manager/src/application_manager_impl.cc index 938e994ba0..1c8be1deab 100644 --- a/src/components/application_manager/src/application_manager_impl.cc +++ b/src/components/application_manager/src/application_manager_impl.cc @@ -915,6 +915,33 @@ void ApplicationManagerImpl::CreatePendingApplication( SendUpdateAppList(); } +void ApplicationManagerImpl::SetPendingApplicationState( + const transport_manager::ConnectionUID connection_id, + const transport_manager::DeviceInfo& device_info) { + std::string name = device_info.name(); + auto it = pending_device_map_.find(name); + if (it == pending_device_map_.end()) { + return; + } + + const std::string policy_app_id = it->second; + auto app = application_by_policy_id(policy_app_id); + + if (!app) { + return; + } + LOG4CXX_DEBUG(logger_, + "Unregister application and move into apps_to_register"); + { + sync_primitives::AutoLock lock(apps_to_register_list_lock_ptr_); + apps_to_register_.insert(app); + } + + UnregisterApplication( + app->app_id(), mobile_apis::Result::INVALID_ENUM, true, true); + app->MarkUnregistered(); +} + void ApplicationManagerImpl::OnConnectionStatusUpdated() { SendUpdateAppList(); } diff --git a/src/components/connection_handler/src/connection_handler_impl.cc b/src/components/connection_handler/src/connection_handler_impl.cc index 88d57e5d2c..0d6aabcae4 100644 --- a/src/components/connection_handler/src/connection_handler_impl.cc +++ b/src/components/connection_handler/src/connection_handler_impl.cc @@ -284,10 +284,12 @@ void ConnectionHandlerImpl::OnConnectionPending( connection_handler::DeviceHandle device_id = connection->connection_device_handle(); - // uint32_t app_id = KeyFromPair(connection_id, session_id); connection_handler_observer_->CreatePendingApplication( connection_id, device_info, device_id); + } else { + connection_handler_observer_->SetPendingApplicationState(connection_id, + device_info); } } diff --git a/src/components/include/connection_handler/connection_handler_observer.h b/src/components/include/connection_handler/connection_handler_observer.h index f683318ada..b9d6a18926 100644 --- a/src/components/include/connection_handler/connection_handler_observer.h +++ b/src/components/include/connection_handler/connection_handler_observer.h @@ -168,6 +168,10 @@ class ConnectionHandlerObserver { const transport_manager::DeviceInfo& device_info, connection_handler::DeviceHandle device_id) = 0; + virtual void SetPendingApplicationState( + const transport_manager::ConnectionUID connection_id, + const transport_manager::DeviceInfo& device_info) = 0; + protected: /** * \brief Destructor diff --git a/src/components/include/test/connection_handler/mock_connection_handler_observer.h b/src/components/include/test/connection_handler/mock_connection_handler_observer.h index 0a8e71c085..552be4bee0 100644 --- a/src/components/include/test/connection_handler/mock_connection_handler_observer.h +++ b/src/components/include/test/connection_handler/mock_connection_handler_observer.h @@ -79,6 +79,9 @@ class MockConnectionHandlerObserver void(const transport_manager::ConnectionUID connection_id, const transport_manager::DeviceInfo& device_info, connection_handler::DeviceHandle device_id)); + MOCK_METHOD2(SetPendingApplicationState, + void(const transport_manager::ConnectionUID connection_id, + const transport_manager::DeviceInfo& device_info)); }; } // namespace connection_handler_test diff --git a/src/components/transport_manager/include/transport_manager/cloud/websocket_client_connection.h b/src/components/transport_manager/include/transport_manager/cloud/websocket_client_connection.h index da3a80e1b2..f9a134b1fa 100644 --- a/src/components/transport_manager/include/transport_manager/cloud/websocket_client_connection.h +++ b/src/components/transport_manager/include/transport_manager/cloud/websocket_client_connection.h @@ -42,6 +42,7 @@ #include #include #include +#include #include #include #include @@ -127,7 +128,7 @@ class WebsocketClientConnection TransportAdapterController* controller_; boost::asio::io_context ioc_; tcp::resolver resolver_; - websocket::stream ws_; + std::shared_ptr > ws_; boost::beast::flat_buffer buffer_; std::string host_; std::string text_; @@ -170,6 +171,10 @@ class WebsocketClientConnection const DeviceUID device_uid_; const ApplicationHandle app_handle_; + + bool first_run_; + boost::asio::thread_pool io_pool_; + bool dead_; }; } // namespace transport_adapter diff --git a/src/components/transport_manager/include/transport_manager/transport_adapter/transport_adapter_controller.h b/src/components/transport_manager/include/transport_manager/transport_adapter/transport_adapter_controller.h index 6d97a55a70..7a0a37758c 100644 --- a/src/components/transport_manager/include/transport_manager/transport_adapter/transport_adapter_controller.h +++ b/src/components/transport_manager/include/transport_manager/transport_adapter/transport_adapter_controller.h @@ -88,6 +88,10 @@ class TransportAdapterController { */ virtual DeviceSptr FindDevice(const DeviceUID& device_handle) const = 0; + virtual ConnectionSPtr FindPendingConnection( + const DeviceUID& device_handle, + const ApplicationHandle& app_handle) const = 0; + /** * @brief Create connection and fill its parameters. * diff --git a/src/components/transport_manager/include/transport_manager/transport_adapter/transport_adapter_impl.h b/src/components/transport_manager/include/transport_manager/transport_adapter/transport_adapter_impl.h index 8d03bdb2c7..f1f64ae53a 100644 --- a/src/components/transport_manager/include/transport_manager/transport_adapter/transport_adapter_impl.h +++ b/src/components/transport_manager/include/transport_manager/transport_adapter/transport_adapter_impl.h @@ -260,6 +260,10 @@ class TransportAdapterImpl : public TransportAdapter, */ DeviceSptr FindDevice(const DeviceUID& device_handle) const OVERRIDE; + ConnectionSPtr FindPendingConnection( + const DeviceUID& device_handle, + const ApplicationHandle& app_handle) const OVERRIDE; + /** * @brief Search for device in container of devices, if it is not there - adds *it. diff --git a/src/components/transport_manager/src/cloud/cloud_websocket_connection_factory.cc b/src/components/transport_manager/src/cloud/cloud_websocket_connection_factory.cc index cdc27ed8ef..3db97feed2 100644 --- a/src/components/transport_manager/src/cloud/cloud_websocket_connection_factory.cc +++ b/src/components/transport_manager/src/cloud/cloud_websocket_connection_factory.cc @@ -56,11 +56,15 @@ TransportAdapter::Error CloudWebsocketConnectionFactory::Init() { TransportAdapter::Error CloudWebsocketConnectionFactory::CreateConnection( const DeviceUID& device_uid, const ApplicationHandle& app_handle) { LOG4CXX_AUTO_TRACE(logger_); - std::shared_ptr connection = - std::make_shared( - device_uid, app_handle, controller_); - controller_->ConnectionCreated(connection, device_uid, app_handle); - TransportAdapter::Error error = connection->Start(); + auto connection = controller_->FindPendingConnection(device_uid, app_handle); + + std::shared_ptr ws_connection = + std::dynamic_pointer_cast(connection); + if (!ws_connection) { + return TransportAdapter::Error::BAD_PARAM; + } + + TransportAdapter::Error error = ws_connection->Start(); if (TransportAdapter::OK != error) { LOG4CXX_ERROR( logger_, diff --git a/src/components/transport_manager/src/cloud/websocket_client_connection.cc b/src/components/transport_manager/src/cloud/websocket_client_connection.cc index 0912a07999..f487a9a16a 100644 --- a/src/components/transport_manager/src/cloud/websocket_client_connection.cc +++ b/src/components/transport_manager/src/cloud/websocket_client_connection.cc @@ -48,18 +48,17 @@ WebsocketClientConnection::WebsocketClientConnection( TransportAdapterController* controller) : controller_(controller) , resolver_(ioc_) - , ws_(ioc_) + , ws_(std::make_shared >(ioc_)) , shutdown_(false) , thread_delegate_(new LoopThreadDelegate(&message_queue_, this)) , write_thread_(threads::CreateThread("WS Async Send", thread_delegate_)) , device_uid_(device_uid) - , app_handle_(app_handle) {} + , app_handle_(app_handle) + , io_pool_(1) {} WebsocketClientConnection::~WebsocketClientConnection() { ioc_.stop(); - if (io_service_thread_.joinable()) { - io_service_thread_.join(); - } + io_pool_.join(); } TransportAdapter::Error WebsocketClientConnection::Start() { @@ -73,49 +72,41 @@ TransportAdapter::Error WebsocketClientConnection::Start() { if (ec) { std::string str_err = "ErrorMessage: " + ec.message(); LOG4CXX_ERROR(logger_, "Could not resolve host/port: " << str_err); - Shutdown(); return TransportAdapter::FAIL; } - boost::asio::connect(ws_.next_layer(), results.begin(), results.end(), ec); + boost::asio::connect(ws_->next_layer(), results.begin(), results.end(), ec); if (ec) { std::string str_err = "ErrorMessage: " + ec.message(); LOG4CXX_ERROR(logger_, "Could not connect to websocket: " << host << ":" << port); LOG4CXX_ERROR(logger_, str_err); - Shutdown(); return TransportAdapter::FAIL; } - ws_.handshake(host, "/", ec); + ws_->handshake(host, "/", ec); if (ec) { std::string str_err = "ErrorMessage: " + ec.message(); LOG4CXX_ERROR(logger_, "Could not complete handshake with host/port: " << host << ":" << port); LOG4CXX_ERROR(logger_, str_err); - Shutdown(); return TransportAdapter::FAIL; } - ws_.binary(true); + ws_->binary(true); write_thread_->start(threads::ThreadOptions()); controller_->ConnectDone(device_uid_, app_handle_); // Start async read - ws_.async_read(buffer_, - std::bind(&WebsocketClientConnection::OnRead, - this, - std::placeholders::_1, - std::placeholders::_2)); - - // Start IO Service thread. Allows for async reads without blocking. - io_service_thread_ = std::thread([&]() { - ioc_.run(); - LOG4CXX_DEBUG(logger_, "Ending Boost IO Thread"); - }); + ws_->async_read(buffer_, + std::bind(&WebsocketClientConnection::OnRead, + this, + std::placeholders::_1, + std::placeholders::_2)); + + boost::asio::post(io_pool_, [&]() { ioc_.run(); }); LOG4CXX_DEBUG(logger_, "Successfully started websocket connection @: " << host << ":" << port); - return TransportAdapter::OK; } @@ -131,11 +122,11 @@ void WebsocketClientConnection::Recv(boost::system::error_code ec) { return; } - ws_.async_read(buffer_, - std::bind(&WebsocketClientConnection::OnRead, - this, - std::placeholders::_1, - std::placeholders::_2)); + ws_->async_read(buffer_, + std::bind(&WebsocketClientConnection::OnRead, + this, + std::placeholders::_1, + std::placeholders::_2)); } void WebsocketClientConnection::OnRead(boost::system::error_code ec, @@ -144,14 +135,13 @@ void WebsocketClientConnection::OnRead(boost::system::error_code ec, if (ec) { std::string str_err = "ErrorMessage: " + ec.message(); LOG4CXX_ERROR(logger_, str_err); + ws_->lowest_layer().close(); + ioc_.stop(); Shutdown(); - controller_->ConnectionAborted( - device_uid_, app_handle_, CommunicationError()); + controller_->ConnectPending(device_uid_, app_handle_); return; } - std::string data_str = boost::beast::buffers_to_string(buffer_.data()); - LOG4CXX_DEBUG(logger_, "Cloud Transport Received: " << data_str); ssize_t size = (ssize_t)buffer_.size(); const uint8_t* data = boost::asio::buffer_cast( @@ -219,11 +209,10 @@ void WebsocketClientConnection::LoopThreadDelegate::DrainQueue() { message_queue_.pop(message_ptr); if (!shutdown_) { boost::system::error_code ec; - handler_.ws_.write( + handler_.ws_->write( boost::asio::buffer(message_ptr->data(), message_ptr->data_size())); if (ec) { LOG4CXX_ERROR(logger_, "Error writing to websocket"); - handler_.Shutdown(); handler_.controller_->DataSendFailed(handler_.device_uid_, handler_.app_handle_, message_ptr, diff --git a/src/components/transport_manager/src/transport_adapter/transport_adapter_impl.cc b/src/components/transport_manager/src/transport_adapter/transport_adapter_impl.cc index 8928ecb4d2..e25e21a95f 100644 --- a/src/components/transport_manager/src/transport_adapter/transport_adapter_impl.cc +++ b/src/components/transport_manager/src/transport_adapter/transport_adapter_impl.cc @@ -233,7 +233,9 @@ TransportAdapter::Error TransportAdapterImpl::Connect( server_connection_factory_->CreateConnection(device_id, app_handle); if (TransportAdapter::OK != err) { connections_lock_.AcquireForWriting(); - connections_.erase(std::make_pair(device_id, app_handle)); + if (!pending_app) { + connections_.erase(std::make_pair(device_id, app_handle)); + } connections_lock_.Release(); } LOG4CXX_TRACE(logger_, "exit with error: " << err); @@ -821,6 +823,26 @@ void TransportAdapterImpl::DeviceSwitched(const DeviceUID& device_handle) { UNUSED(device_handle); } +ConnectionSPtr TransportAdapterImpl::FindPendingConnection( + const DeviceUID& device_id, const ApplicationHandle& app_handle) const { + LOG4CXX_TRACE(logger_, + "enter. device_id: " << &device_id + << ", app_handle: " << &app_handle); + ConnectionSPtr connection; + connections_lock_.AcquireForReading(); + ConnectionMap::const_iterator it = + connections_.find(std::make_pair(device_id, app_handle)); + if (it != connections_.end()) { + const ConnectionInfo& info = it->second; + if (info.state == ConnectionInfo::PENDING) { + connection = info.connection; + } + } + connections_lock_.Release(); + LOG4CXX_TRACE(logger_, "exit with Connection: " << connection); + return connection; +} + DeviceSptr TransportAdapterImpl::FindDevice(const DeviceUID& device_id) const { LOG4CXX_TRACE(logger_, "enter. device_id: " << &device_id); DeviceSptr ret; @@ -838,15 +860,26 @@ DeviceSptr TransportAdapterImpl::FindDevice(const DeviceUID& device_id) const { void TransportAdapterImpl::ConnectPending(const DeviceUID& device_id, const ApplicationHandle& app_handle) { - connections_lock_.AcquireForReading(); + connections_lock_.AcquireForWriting(); ConnectionMap::iterator it_conn = connections_.find(std::make_pair(device_id, app_handle)); if (it_conn != connections_.end()) { ConnectionInfo& info = it_conn->second; + if (info.state == ConnectionInfo::ESTABLISHED) { + LOG4CXX_DEBUG(logger_, "Reset Connection Pointer"); + connections_.erase(std::make_pair(device_id, app_handle)); + + connections_lock_.Release(); + CreateDevice(device_id); + connections_lock_.AcquireForWriting(); + } info.state = ConnectionInfo::PENDING; } connections_lock_.Release(); + DeviceSptr device = FindDevice(device_id); + device->set_connection_status(ConnectionStatus::PENDING); + for (TransportAdapterListenerList::iterator it = listeners_.begin(); it != listeners_.end(); ++it) { diff --git a/src/components/transport_manager/src/transport_manager_impl.cc b/src/components/transport_manager/src/transport_manager_impl.cc index 518a5639db..43acd9a9a2 100644 --- a/src/components/transport_manager/src/transport_manager_impl.cc +++ b/src/components/transport_manager/src/transport_manager_impl.cc @@ -998,19 +998,42 @@ void TransportManagerImpl::Handle(TransportAdapterEvent event) { case EventTypeEnum::ON_CONNECT_PENDING: { const DeviceHandle device_handle = converter_.UidToHandle( event.device_uid, event.transport_adapter->GetConnectionType()); - AddConnection(ConnectionInternal(this, - event.transport_adapter, - ++connection_id_counter_, - event.device_uid, - event.application_id, - device_handle)); + int connection_id = 0; + std::vector::iterator it = connections_.begin(); + std::vector::iterator end = connections_.end(); + for (; it != end; ++it) { + if (it->transport_adapter != event.transport_adapter) { + continue; + } else if (it->Connection::device != event.device_uid) { + continue; + } else if (it->Connection::application != event.application_id) { + continue; + } else if (it->device_handle_ != device_handle) { + continue; + } else { + LOG4CXX_DEBUG(logger_, "Connection Object Already Exists"); + connection_id = it->Connection::id; + break; + } + } + + if (it == end) { + AddConnection(ConnectionInternal(this, + event.transport_adapter, + ++connection_id_counter_, + event.device_uid, + event.application_id, + device_handle)); + connection_id = connection_id_counter_; + } + RaiseEvent( &TransportManagerListener::OnConnectionPending, DeviceInfo(device_handle, event.device_uid, event.transport_adapter->DeviceName(event.device_uid), event.transport_adapter->GetConnectionType()), - connection_id_counter_); + connection_id); LOG4CXX_DEBUG(logger_, "event_type = ON_CONNECT_PENDING"); break; } diff --git a/src/components/transport_manager/test/include/transport_manager/transport_adapter/mock_transport_adapter_controller.h b/src/components/transport_manager/test/include/transport_manager/transport_adapter/mock_transport_adapter_controller.h index 642c193d63..1de5eac702 100644 --- a/src/components/transport_manager/test/include/transport_manager/transport_adapter/mock_transport_adapter_controller.h +++ b/src/components/transport_manager/test/include/transport_manager/transport_adapter/mock_transport_adapter_controller.h @@ -55,6 +55,9 @@ class MockTransportAdapterController : public TransportAdapterController { void(ConnectionSPtr connection, const DeviceUID& device_handle, const ApplicationHandle& app_handle)); + MOCK_CONST_METHOD2(FindPendingConnection, + ConnectionSPtr(const DeviceUID& device_handle, + const ApplicationHandle& app_handle)); MOCK_METHOD2(ConnectDone, void(const DeviceUID& device_handle, const ApplicationHandle& app_handle)); diff --git a/src/components/transport_manager/test/tcp_client_listener_test.cc b/src/components/transport_manager/test/tcp_client_listener_test.cc index f44f8785aa..1f4a17cf6c 100644 --- a/src/components/transport_manager/test/tcp_client_listener_test.cc +++ b/src/components/transport_manager/test/tcp_client_listener_test.cc @@ -69,6 +69,9 @@ class MockTransportAdapterController : public TransportAdapterController { MOCK_METHOD1(SearchDeviceDone, void(const DeviceVector& devices)); MOCK_METHOD1(SearchDeviceFailed, void(const SearchDeviceError& error)); MOCK_CONST_METHOD1(FindDevice, DeviceSptr(const DeviceUID& device_handle)); + MOCK_CONST_METHOD2(FindPendingConnection, + ConnectionSPtr(const DeviceUID& device_handle, + const ApplicationHandle& app_handle)); MOCK_METHOD3(ConnectionCreated, void(ConnectionSPtr connection, const DeviceUID& device_handle, -- cgit v1.2.1 From 3f824f36e84a13d29b1d07888e9dedc81e0a13db Mon Sep 17 00:00:00 2001 From: ShobhitAd Date: Mon, 3 Dec 2018 16:30:11 -0500 Subject: Pass CloudAppProperties to websocket client connection --- .../src/application_manager_impl.cc | 15 +++++- .../connection_handler/connection_handler_impl.h | 5 +- .../src/connection_handler_impl.cc | 16 ++++-- .../connection_handler/connection_handler.h | 3 +- .../transport_adapter/transport_adapter.h | 4 +- .../include/transport_manager/transport_manager.h | 3 +- .../cloud/cloud_websocket_transport_adapter.h | 16 ++++-- .../cloud/websocket_client_connection.h | 5 +- .../transport_manager/transport_manager_impl.h | 3 +- .../src/cloud/cloud_websocket_transport_adapter.cc | 27 +++++++++- .../src/cloud/websocket_client_connection.cc | 59 ++++++++++------------ .../src/transport_manager_impl.cc | 21 ++++++-- 12 files changed, 114 insertions(+), 63 deletions(-) diff --git a/src/components/application_manager/src/application_manager_impl.cc b/src/components/application_manager/src/application_manager_impl.cc index e9a45001c7..242349e283 100644 --- a/src/components/application_manager/src/application_manager_impl.cc +++ b/src/components/application_manager/src/application_manager_impl.cc @@ -822,6 +822,7 @@ void ApplicationManagerImpl::OnHMIStartedCooperation() { } void ApplicationManagerImpl::CollectCloudAppInformation() { + LOG4CXX_DEBUG(logger_, "CLOUD_DEBUG_COLLECTCLOUDAPPINFO"); std::vector cloud_app_id_vector; GetPolicyHandler().GetEnabledCloudApps(cloud_app_id_vector); std::vector::iterator it = cloud_app_id_vector.begin(); @@ -832,7 +833,7 @@ void ApplicationManagerImpl::CollectCloudAppInformation() { std::string cloud_transport_type = ""; std::string hybrid_app_preference = ""; for (; it != end; ++it) { - GetPolicyHandler().GetCloudAppParameters(*it, + bool enabled = GetPolicyHandler().GetCloudAppParameters(*it, endpoint, certificate, auth_token, @@ -842,7 +843,17 @@ void ApplicationManagerImpl::CollectCloudAppInformation() { pending_device_map_.insert( std::pair(endpoint, *it)); - connection_handler().AddCloudAppDevice(*it, endpoint, cloud_transport_type); + transport_manager::transport_adapter::CloudAppProperties properties + {endpoint, certificate, enabled, auth_token, cloud_transport_type, hybrid_app_preference}; + LOG4CXX_DEBUG(logger_, "CLOUD_APP_MGR: " << endpoint); + LOG4CXX_DEBUG(logger_, "ENDPOINT: " << properties.endpoint); + LOG4CXX_DEBUG(logger_, "ENABLED: " << properties.enabled); + LOG4CXX_DEBUG(logger_, "CERTIFICATE: " << properties.certificate); + LOG4CXX_DEBUG(logger_, "AUTH_TOKEN: " << properties.auth_token); + LOG4CXX_DEBUG(logger_, "TRANSPORT_TYPE: " << properties.cloud_transport_type); + LOG4CXX_DEBUG(logger_, "HYBRID: " << properties.hybrid_app_preference); + + connection_handler().AddCloudAppDevice(*it, properties); } } diff --git a/src/components/connection_handler/include/connection_handler/connection_handler_impl.h b/src/components/connection_handler/include/connection_handler/connection_handler_impl.h index 4d4e31f999..e3390b773c 100644 --- a/src/components/connection_handler/include/connection_handler/connection_handler_impl.h +++ b/src/components/connection_handler/include/connection_handler/connection_handler_impl.h @@ -81,7 +81,7 @@ class ConnectionHandlerImpl ConnectionHandlerImpl(const ConnectionHandlerSettings& settings, transport_manager::TransportManager& tm); /** - * \brief Destructor + * @brief Destructor */ ~ConnectionHandlerImpl(); @@ -124,8 +124,7 @@ class ConnectionHandlerImpl void ConnectToAllDevices() OVERRIDE; void AddCloudAppDevice(const std::string& policy_app_id, - const std::string& endpoint, - const std::string& cloud_transport_type) OVERRIDE; + const transport_manager::transport_adapter::CloudAppProperties cloud_properties) OVERRIDE; void StartTransportManager() OVERRIDE; diff --git a/src/components/connection_handler/src/connection_handler_impl.cc b/src/components/connection_handler/src/connection_handler_impl.cc index 77eb38b8bc..05dbc4b019 100644 --- a/src/components/connection_handler/src/connection_handler_impl.cc +++ b/src/components/connection_handler/src/connection_handler_impl.cc @@ -1321,11 +1321,17 @@ void ConnectionHandlerImpl::ConnectToAllDevices() { } } -void ConnectionHandlerImpl::AddCloudAppDevice( - const std::string& policy_app_id, - const std::string& endpoint, - const std::string& cloud_transport_type) { - transport_manager_.AddCloudDevice(endpoint, cloud_transport_type); +void ConnectionHandlerImpl::AddCloudAppDevice(const std::string& policy_app_id, + const transport_manager::transport_adapter::CloudAppProperties cloud_properties) { + // LOG4CXX_DEBUG(logger_, "CLOUD_DEBUG_ADDCLOUDAPPDEVICE: " << cloud_properties.endpoint); + // LOG4CXX_DEBUG(logger_, "ENDPOINT: " << cloud_properties.endpoint); + // LOG4CXX_DEBUG(logger_, "ENABLED: " << cloud_properties.enabled); + // LOG4CXX_DEBUG(logger_, "CERTIFICATE: " << cloud_properties.certificate); + // LOG4CXX_DEBUG(logger_, "AUTH_TOKEN: " << cloud_properties.auth_token); + // LOG4CXX_DEBUG(logger_, "TRANSPORT_TYPE: " << cloud_properties.cloud_transport_type); + // LOG4CXX_DEBUG(logger_, "HYBRID: " << cloud_properties.hybrid_app_preference); + + transport_manager_.AddCloudDevice(cloud_properties); } void ConnectionHandlerImpl::StartTransportManager() { diff --git a/src/components/include/connection_handler/connection_handler.h b/src/components/include/connection_handler/connection_handler.h index 6d1e9e7c97..3b292ca7f7 100644 --- a/src/components/include/connection_handler/connection_handler.h +++ b/src/components/include/connection_handler/connection_handler.h @@ -97,8 +97,7 @@ class ConnectionHandler { virtual void ConnectToAllDevices() = 0; virtual void AddCloudAppDevice(const std::string& policy_app_id, - const std::string& endpoint, - const std::string& cloud_transport_type) = 0; + const transport_manager::transport_adapter::CloudAppProperties cloud_properties ) = 0; /** * @brief Close the connection revoked by Policy diff --git a/src/components/include/transport_manager/transport_adapter/transport_adapter.h b/src/components/include/transport_manager/transport_adapter/transport_adapter.h index c136148936..863c48fc0d 100644 --- a/src/components/include/transport_manager/transport_adapter/transport_adapter.h +++ b/src/components/include/transport_manager/transport_adapter/transport_adapter.h @@ -82,8 +82,8 @@ struct CloudAppProperties { std::string certificate; bool enabled; std::string auth_token; - DeviceType cloud_transport_type; - HybridAppPreference hybrid_app_preference; + std::string cloud_transport_type; + std::string hybrid_app_preference; }; typedef std::map DeviceTypes; diff --git a/src/components/include/transport_manager/transport_manager.h b/src/components/include/transport_manager/transport_manager.h index 8fee6db6a5..5d7944d73f 100644 --- a/src/components/include/transport_manager/transport_manager.h +++ b/src/components/include/transport_manager/transport_manager.h @@ -75,8 +75,7 @@ class TransportManager { **/ virtual int SearchDevices() = 0; - virtual void AddCloudDevice(const std::string& endpoint, - const std::string& cloud_transport_type) = 0; + virtual void AddCloudDevice(const transport_manager::transport_adapter::CloudAppProperties cloud_properties) = 0; /** * @brief Connect to all applications discovered on device. diff --git a/src/components/transport_manager/include/transport_manager/cloud/cloud_websocket_transport_adapter.h b/src/components/transport_manager/include/transport_manager/cloud/cloud_websocket_transport_adapter.h index 546ab71fbd..76797ef581 100644 --- a/src/components/transport_manager/include/transport_manager/cloud/cloud_websocket_transport_adapter.h +++ b/src/components/transport_manager/include/transport_manager/cloud/cloud_websocket_transport_adapter.h @@ -59,11 +59,21 @@ class CloudWebsocketTransportAdapter : public TransportAdapterImpl { virtual ~CloudWebsocketTransportAdapter(); /** - * @brief Notification that transport's configuration is updated + * @brief Set CloudTransportConfig for specified app_id * - * @param new_config The new configuration of the transport + * @param app_id app ID string + * @param properties New cloud app properties for the app */ - void CloudTransportConfigUpdated(const CloudAppTransportConfig& new_config); + void SetAppCloudTransportConfig(std::string app_id, CloudAppProperties properties); + + /** + * @brief Get CloudTransportConfig for specified app_id + * + * @param app_id app ID string + * @return CloudAppProperties for the app + */ + const CloudAppProperties& GetAppCloudTransportConfig(std::string app_id); + /** * @brief Returns the transport's configuration information diff --git a/src/components/transport_manager/include/transport_manager/cloud/websocket_client_connection.h b/src/components/transport_manager/include/transport_manager/cloud/websocket_client_connection.h index a5ed0e80db..1ee7696254 100644 --- a/src/components/transport_manager/include/transport_manager/cloud/websocket_client_connection.h +++ b/src/components/transport_manager/include/transport_manager/cloud/websocket_client_connection.h @@ -119,9 +119,10 @@ class WebsocketClientConnection TransportAdapter::Error Disconnect(); /** - * @brief Attempt to open a secure connection with the provided certificate + * @brief Attempt to add provided certificate to the ssl::context * - * @return true if secured connection was created successfully + * @param cert Certificate string from policy table + * @return true if certificate was not invalid and was added successfully */ bool AddCertificateAuthority(std::string cert, boost::system::error_code& ec); diff --git a/src/components/transport_manager/include/transport_manager/transport_manager_impl.h b/src/components/transport_manager/include/transport_manager/transport_manager_impl.h index 69f38304a7..921d7b0b9c 100644 --- a/src/components/transport_manager/include/transport_manager/transport_manager_impl.h +++ b/src/components/transport_manager/include/transport_manager/transport_manager_impl.h @@ -139,8 +139,7 @@ class TransportManagerImpl **/ int SearchDevices() OVERRIDE; - void AddCloudDevice(const std::string& endpoint, - const std::string& cloud_transport_type) OVERRIDE; + void AddCloudDevice(const transport_manager::transport_adapter::CloudAppProperties cloud_properties) OVERRIDE; /** * @brief Connect to all applications discovered on device. diff --git a/src/components/transport_manager/src/cloud/cloud_websocket_transport_adapter.cc b/src/components/transport_manager/src/cloud/cloud_websocket_transport_adapter.cc index 1ef62c6368..6711ab8382 100644 --- a/src/components/transport_manager/src/cloud/cloud_websocket_transport_adapter.cc +++ b/src/components/transport_manager/src/cloud/cloud_websocket_transport_adapter.cc @@ -53,8 +53,21 @@ CloudWebsocketTransportAdapter::CloudWebsocketTransportAdapter( CloudWebsocketTransportAdapter::~CloudWebsocketTransportAdapter() {} -void CloudWebsocketTransportAdapter::CloudTransportConfigUpdated( - const CloudAppTransportConfig& new_config) {} +void CloudWebsocketTransportAdapter::SetAppCloudTransportConfig(std::string app_id, CloudAppProperties properties) { + transport_config_[app_id] = properties; + // LOG4CXX_DEBUG(logger_, "CLOUD_TRANS_ADP: " << app_id); + // LOG4CXX_DEBUG(logger_, "ENDPOINT: " << transport_config_[app_id].endpoint); + // LOG4CXX_DEBUG(logger_, "ENABLED: " << transport_config_[app_id].enabled); + // LOG4CXX_DEBUG(logger_, "CERTIFICATE: " << transport_config_[app_id].certificate); + // LOG4CXX_DEBUG(logger_, "AUTH_TOKEN: " << transport_config_[app_id].auth_token); + // LOG4CXX_DEBUG(logger_, "TRANSPORT_TYPE: " << transport_config_[app_id].cloud_transport_type); + // LOG4CXX_DEBUG(logger_, "HYBRID: " << transport_config_[app_id].hybrid_app_preference); +} + +const CloudAppProperties& CloudWebsocketTransportAdapter::GetAppCloudTransportConfig(std::string app_id){ + return transport_config_[app_id]; +} + CloudAppTransportConfig CloudWebsocketTransportAdapter::GetCloudTransportConfiguration() const { @@ -74,6 +87,7 @@ bool CloudWebsocketTransportAdapter::Restore() { // todo decide if resumption } void CloudWebsocketTransportAdapter::CreateDevice(const std::string& uid) { + LOG4CXX_DEBUG(logger_, "CLOUD_DEBUG_CreateDevice: " << uid); boost::regex pattern( "(wss?):\\/\\/([A-Z\\d\\.-]{2,})\\.?([A-Z]{2,})?(:\\d{2,4})\\/", boost::regex::icase); @@ -83,6 +97,8 @@ void CloudWebsocketTransportAdapter::CreateDevice(const std::string& uid) { return; } + LOG4CXX_DEBUG(logger_, "CLOUD_DEBUG_RegexMatchPassed"); + LOG4CXX_DEBUG(logger_, "Valid Endpoint: " << uid); // Port after second colon in valid endpoint string @@ -109,6 +125,8 @@ void CloudWebsocketTransportAdapter::CreateDevice(const std::string& uid) { return; } + LOG4CXX_DEBUG(logger_, "CLOUD_DEBUG_RegexSearchPassed"); + std::string device_id = uid; LOG4CXX_DEBUG(logger_, @@ -118,6 +136,9 @@ void CloudWebsocketTransportAdapter::CreateDevice(const std::string& uid) { // todo get nickname from policies to name device auto cloud_device = std::make_shared(host, port, device_id); + LOG4CXX_DEBUG(logger_, "CLOUD_DEBUG_CreatedCloudDevice: " << host << ", " << port << ", " << device_id); + + DeviceVector devices{cloud_device}; SearchDeviceDone(devices); @@ -126,6 +147,8 @@ void CloudWebsocketTransportAdapter::CreateDevice(const std::string& uid) { std::shared_ptr connection = std::make_shared(uid, 0, this); + LOG4CXX_DEBUG(logger_, "CLOUD_DEBUG_CreatedConnection"); + ConnectionCreated(connection, uid, 0); ConnectPending(uid, 0); diff --git a/src/components/transport_manager/src/cloud/websocket_client_connection.cc b/src/components/transport_manager/src/cloud/websocket_client_connection.cc index 4ee6c6b899..96c86f558d 100644 --- a/src/components/transport_manager/src/cloud/websocket_client_connection.cc +++ b/src/components/transport_manager/src/cloud/websocket_client_connection.cc @@ -57,23 +57,7 @@ WebsocketClientConnection::WebsocketClientConnection( , app_handle_(app_handle) { LOG4CXX_DEBUG(logger_, "CLOUD_DEBUG_WEBSOCKETCLIENTCONNECTION"); - // LOG4CXX_DEBUG(logger_, controller); - // CloudWebsocketTransportAdapter* cta = static_cast(controller); - // LOG4CXX_DEBUG(logger_, cta); - - // CloudAppTransportConfig temp = cta->GetCloudTransportConfiguration(); - - - // LOG4CXX_DEBUG(logger_, "Printing CloudAppTransportConfig: " << temp.size()); - // for(auto it = temp.cbegin(); it != temp.cend(); it++){ - // std::string txt = "DEVICE: " + it->first + "\n"; - // txt += "ENDPOINT: " + it->second.endpoint + "\n"; - // txt += "CERTIFICATE: " + it->second.certificate + "\n"; - // txt += "AUTH_TOKEN: " + it->second.auth_token + "\n"; - // LOG4CXX_DEBUG(logger_, txt); - - // } } @@ -86,10 +70,10 @@ WebsocketClientConnection::~WebsocketClientConnection() { } bool WebsocketClientConnection::AddCertificateAuthority(const std::string cert, boost::system::error_code& ec){ - if(cert == "not_specified"){ - ws_.next_layer().set_verify_mode(ssl::verify_none); - return false; - } + // if(cert == "not_specified"){ + // ws_.next_layer().set_verify_mode(ssl::verify_none); + // return false; + // } ctx_.add_certificate_authority(boost::asio::buffer(cert.data(), cert.size()), ec); if(ec){ @@ -108,12 +92,19 @@ TransportAdapter::Error WebsocketClientConnection::Start() { LOG4CXX_AUTO_TRACE(logger_); DeviceSptr device = controller_->FindDevice(device_uid_); CloudDevice* cloud_device = static_cast(device.get()); + CloudWebsocketTransportAdapter* cloud_ta = static_cast(controller_); + CloudAppProperties cloud_properties = cloud_ta->GetAppCloudTransportConfig(device_uid_); auto const host = cloud_device->GetHost(); auto const port = cloud_device->GetPort(); boost::system::error_code ec; auto const results = resolver_.resolve(host, port, ec); LOG4CXX_DEBUG(logger_, "CLOUD_CONN_START"); + LOG4CXX_DEBUG(logger_, "ENDPOINT: " << cloud_properties.endpoint); + LOG4CXX_DEBUG(logger_, "CERTIFICATE: " << cloud_properties.certificate); + LOG4CXX_DEBUG(logger_, "AUTH_TOKEN: " << cloud_properties.auth_token); + LOG4CXX_DEBUG(logger_, "TRANSPORT_TYPE: " << cloud_properties.cloud_transport_type); + LOG4CXX_DEBUG(logger_, "HYBRID_APP_PREF: " << cloud_properties.hybrid_app_preference); if (ec) { std::string str_err = "ErrorMessage: " + ec.message(); @@ -144,21 +135,23 @@ TransportAdapter::Error WebsocketClientConnection::Start() { std::string invalid_cert = "-----BEGIN CERTIFICATE-----\nWjAYMRYwFAYDVQQDDA0xOTIuMTY4LjEuMTI4MIIBIjANBgkqhkiG9w0BAQEFAAOC\nAQ8AMIIBCgKCAQEAlVrHDi+XdO9fNMcknqs2Hn0AQjKQZAq0juy8r7gDqkzHw9zY\nFnfssIUzP7R6F1/80ulyjwUN6G+SI7phbivr2gmSdfkYiJVdwBKf611srIrNF/Eh\nllt/2sjwZNyTai4pzZv9/svix5nIVCHdKZD6wsxCFOdNhVJGBd9uQ4Pk1hQoW/jj\nsUF/NBUa49k31/IQiqQ6T1xQvSkEUYd1kstS7utO2V0Z9rHH4/+4HNyPMKipkCi2\n/7WuvQGDyHTnNUFmEANn4X06iQAVon9L8IVRcGwtgsWJ0fuVGK5POtU4m37Q35MW\n3RWF3OzyP/6PxRX5ljQFmkwGkqzHrNzOZN+zMQIDAQABo1MwUTAdBgNVHQ4EFgQU\nc1BN7ZNXq+OA5hT+vq1NOMoUrR8wHwYDVR0jBBgwFoAUc1BN7ZNXq+OA5hT+vq1N\nOMoUrR8wDwYDVR0TAQH/BAUwAwEB/zANBgkqhkiG9w0BAQsFAAOCAQEAUQ8MwCmb\nDrwCNGaUdGNXoiAWrltPE2buzpq8OCVxXBSqSumAe1SkjyKROBbevM7/Cl4V3qgj\nEHjUXNrzFR9WTCOOjJ9W0wiO25FDBguU5VCkuhvfL6lCgVuJRRi9LtiY2hT5fPdM\nrMvS0/iUV3RXcKNyIGOXH1OcOim+PVph2wj0x/N1Nmhqkh+2LtFHhsE/Zgygndla\nsbyRTNQ3bnzGUwMl8jPa7KSeggtfmjIFc4VXEgrOzKHhJO2C96FmVMo97QqKQvq+\nWjPfzHnI3hhr1GPPMHFQQZG5j4a708Qo9fZcKJxUvm0O7kdFFOqcMyo086cu1YUP\nGy5s8MqShPUp1Q==\n-----END CERTIFICATE-----"; std::string test_cert = ""; - bool isAdded = AddCertificateAuthority(cert, ec); + if(cloud_properties.cloud_transport_type == "WSS"){ + bool isAdded = AddCertificateAuthority(cert, ec); - if(isAdded){ - LOG4CXX_INFO(logger_, "Certificate Authority added successfully"); - }else{ - LOG4CXX_INFO(logger_, "Failed to add certificate authority"); - } + if(isAdded){ + LOG4CXX_INFO(logger_, "Certificate Authority added successfully"); + }else{ + LOG4CXX_INFO(logger_, "Failed to add certificate authority"); + } - if(ec){ - std::string str_err = "ErrorMessage: " + ec.message(); - LOG4CXX_ERROR(logger_, - "Failed to add certificate authority: " << invalid_cert); - LOG4CXX_ERROR(logger_, str_err); - Shutdown(); - return TransportAdapter::FAIL; + if(ec){ + std::string str_err = "ErrorMessage: " + ec.message(); + LOG4CXX_ERROR(logger_, + "Failed to add certificate authority: " << invalid_cert); + LOG4CXX_ERROR(logger_, str_err); + Shutdown(); + return TransportAdapter::FAIL; + } } //Perform SSL Handshake diff --git a/src/components/transport_manager/src/transport_manager_impl.cc b/src/components/transport_manager/src/transport_manager_impl.cc index 1c5a6dae32..3e3f486309 100644 --- a/src/components/transport_manager/src/transport_manager_impl.cc +++ b/src/components/transport_manager/src/transport_manager_impl.cc @@ -50,6 +50,7 @@ #include "transport_manager/transport_manager_listener.h" #include "transport_manager/transport_manager_listener_empty.h" #include "transport_manager/transport_adapter/transport_adapter.h" +#include "transport_manager/cloud/cloud_websocket_transport_adapter.h" #include "transport_manager/transport_adapter/transport_adapter_event.h" #include "config_profile/profile.h" @@ -129,12 +130,13 @@ void TransportManagerImpl::ReconnectionTimeout() { device_to_reconnect_); } -void TransportManagerImpl::AddCloudDevice( - const std::string& endpoint, const std::string& cloud_transport_type) { +void TransportManagerImpl::AddCloudDevice(const transport_manager::transport_adapter::CloudAppProperties cloud_properties) { // todo put conversion into own function + LOG4CXX_DEBUG(logger_, "CLOUD_DEBUG_AddCloudDevice: " << cloud_properties.cloud_transport_type); + transport_adapter::DeviceType type = transport_adapter::DeviceType::UNKNOWN; - if (cloud_transport_type == "WS") { - type = transport_adapter::DeviceType::CLOUD_WEBSOCKET; + if ((cloud_properties.cloud_transport_type == "WS") || (cloud_properties.cloud_transport_type == "WSS")) { + type = transport_adapter::DeviceType::CLOUD_WEBSOCKET; } else { return; } @@ -142,7 +144,16 @@ void TransportManagerImpl::AddCloudDevice( std::vector::iterator ta = transport_adapters_.begin(); for (; ta != transport_adapters_.end(); ++ta) { if ((*ta)->GetDeviceType() == type) { - (*ta)->CreateDevice(endpoint); + (*ta)->CreateDevice(cloud_properties.endpoint); + transport_adapter::CloudWebsocketTransportAdapter* cta = static_cast(*ta); + // LOG4CXX_DEBUG(logger_, "CLOUD_TRANS_MGR: "); + // LOG4CXX_DEBUG(logger_, "ENDPOINT: " << cloud_properties.endpoint); + // LOG4CXX_DEBUG(logger_, "ENABLED: " << cloud_properties.enabled); + // LOG4CXX_DEBUG(logger_, "CERTIFICATE: " << cloud_properties.certificate); + // LOG4CXX_DEBUG(logger_, "AUTH_TOKEN: " << cloud_properties.auth_token); + // LOG4CXX_DEBUG(logger_, "TRANSPORT_TYPE: " << cloud_properties.cloud_transport_type); + // LOG4CXX_DEBUG(logger_, "HYBRID: " << cloud_properties.hybrid_app_preference); + cta->SetAppCloudTransportConfig(cloud_properties.endpoint, cloud_properties); } } -- cgit v1.2.1 From a512a58e12dae0f38ad72a157b867d71977654f1 Mon Sep 17 00:00:00 2001 From: jacobkeeler Date: Tue, 4 Dec 2018 09:45:43 -0500 Subject: Fix style and update app list after PTU --- .../test/commands/hmi/sdl_activate_app_request_test.cc | 10 +++++----- .../application_manager/src/application_manager_impl.cc | 2 ++ 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/sdl_activate_app_request_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/sdl_activate_app_request_test.cc index ea345e3b83..f040128097 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/sdl_activate_app_request_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/sdl_activate_app_request_test.cc @@ -459,7 +459,7 @@ TEST_F(SDLActivateAppRequestTest, WaitingCloudApplication_ConnectDevice) { const uint16_t kRetries = 3; const uint32_t kRetryTimeout = 2000; const uint32_t kMinimumTimeout = kRetries * kRetryTimeout; - + MockApplicationManagerSettings settings; EXPECT_CALL(settings, cloud_app_max_retry_attempts()) .WillOnce(Return(kRetries)); @@ -467,14 +467,14 @@ TEST_F(SDLActivateAppRequestTest, WaitingCloudApplication_ConnectDevice) { .WillOnce(Return(kRetryTimeout)); EXPECT_CALL(app_mngr_, get_settings()).WillOnce(ReturnRef(settings)); - EXPECT_CALL( - app_mngr_, - updateRequestTimeout(0, kCorrelationID, Gt(kMinimumTimeout))); + EXPECT_CALL(app_mngr_, + updateRequestTimeout(0, kCorrelationID, Gt(kMinimumTimeout))); MockConnectionHandler connection_handler; EXPECT_CALL(connection_handler, ConnectToDevice(kHandle)); - EXPECT_CALL(app_mngr_, connection_handler()).WillOnce(ReturnRef(connection_handler)); + EXPECT_CALL(app_mngr_, connection_handler()) + .WillOnce(ReturnRef(connection_handler)); command->Run(); } diff --git a/src/components/application_manager/src/application_manager_impl.cc b/src/components/application_manager/src/application_manager_impl.cc index 0923c054cc..d6e80b69bd 100644 --- a/src/components/application_manager/src/application_manager_impl.cc +++ b/src/components/application_manager/src/application_manager_impl.cc @@ -807,6 +807,7 @@ void ApplicationManagerImpl::OnHMIStartedCooperation() { } void ApplicationManagerImpl::CollectCloudAppInformation() { + LOG4CXX_AUTO_TRACE(logger_); std::vector cloud_app_id_vector; GetPolicyHandler().GetEnabledCloudApps(cloud_app_id_vector); std::vector::iterator it = cloud_app_id_vector.begin(); @@ -3522,6 +3523,7 @@ void ApplicationManagerImpl::OnPTUFinished(const bool ptu_result) { if (!ptu_result) { return; } + CollectCloudAppInformation(); auto on_app_policy_updated = [](plugin_manager::RPCPlugin& plugin) { plugin.OnPolicyEvent(plugin_manager::kApplicationPolicyUpdated); }; -- cgit v1.2.1 From 2c3ef60575f48b1b239076be6b2831b19e5fa491 Mon Sep 17 00:00:00 2001 From: jacobkeeler Date: Tue, 4 Dec 2018 14:50:31 -0500 Subject: Fix incorrect value of string in policy table parsing The default value for a string field in the policy table was applied regardless of whether the field was present or not. --- src/components/policy/policy_external/src/policy_table/types.cc | 2 +- .../policy/policy_regular/include/policy/policy_table/types.h | 2 +- src/components/policy/policy_regular/src/policy_table/types.cc | 2 +- src/components/rpc_base/include/rpc_base/rpc_base_json_inl.h | 1 + 4 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/components/policy/policy_external/src/policy_table/types.cc b/src/components/policy/policy_external/src/policy_table/types.cc index 977448dacd..0fe54a683d 100644 --- a/src/components/policy/policy_external/src/policy_table/types.cc +++ b/src/components/policy/policy_external/src/policy_table/types.cc @@ -242,7 +242,7 @@ ApplicationParams::ApplicationParams(const Json::Value* value__) , memory_kb(impl::ValueMember(value__, "memory_kb"), 0) , heart_beat_timeout_ms(impl::ValueMember(value__, "heart_beat_timeout_ms")) , moduleType(impl::ValueMember(value__, "moduleType")) - , certificate(impl::ValueMember(value__, "certificate"), "not_specified") + , certificate(impl::ValueMember(value__, "certificate")) , hybrid_app_preference(impl::ValueMember(value__, "hybrid_app_preference")) , endpoint(impl::ValueMember(value__, "endpoint")) , enabled(impl::ValueMember(value__, "enabled")) diff --git a/src/components/policy/policy_regular/include/policy/policy_table/types.h b/src/components/policy/policy_regular/include/policy/policy_table/types.h index 58f07492c4..18f909bb99 100644 --- a/src/components/policy/policy_regular/include/policy/policy_table/types.h +++ b/src/components/policy/policy_regular/include/policy/policy_table/types.h @@ -142,7 +142,7 @@ struct ApplicationParams : PolicyBase { Optional RequestSubType; Optional > memory_kb; Optional > heart_beat_timeout_ms; - Optional > certificate; + Optional > certificate; mutable Optional moduleType; // Cloud application params Optional > hybrid_app_preference; diff --git a/src/components/policy/policy_regular/src/policy_table/types.cc b/src/components/policy/policy_regular/src/policy_table/types.cc index 88564df050..5faf96a232 100644 --- a/src/components/policy/policy_regular/src/policy_table/types.cc +++ b/src/components/policy/policy_regular/src/policy_table/types.cc @@ -167,7 +167,7 @@ ApplicationParams::ApplicationParams(const Json::Value* value__) , RequestSubType(impl::ValueMember(value__, "RequestSubType")) , memory_kb(impl::ValueMember(value__, "memory_kb"), 0) , heart_beat_timeout_ms(impl::ValueMember(value__, "heart_beat_timeout_ms")) - , certificate(impl::ValueMember(value__, "certificate"), "not_specified") + , certificate(impl::ValueMember(value__, "certificate")) , moduleType(impl::ValueMember(value__, "moduleType")) , hybrid_app_preference(impl::ValueMember(value__, "hybrid_app_preference")) , endpoint(impl::ValueMember(value__, "endpoint")) diff --git a/src/components/rpc_base/include/rpc_base/rpc_base_json_inl.h b/src/components/rpc_base/include/rpc_base/rpc_base_json_inl.h index 6c8bb359af..960ca10e21 100644 --- a/src/components/rpc_base/include/rpc_base/rpc_base_json_inl.h +++ b/src/components/rpc_base/include/rpc_base/rpc_base_json_inl.h @@ -206,6 +206,7 @@ String::String(const Json::Value* value, if (!is_initialized()) { value_state_ = kValid; } else if (is_valid()) { + value_ = value->asString(); value_state_ = length_range_.Includes(value_.length()) ? kValid : kInvalid; } } -- cgit v1.2.1 From e4e0e36d4b2a8569d8cb79428a4577fca0fb1364 Mon Sep 17 00:00:00 2001 From: jacobkeeler Date: Wed, 5 Dec 2018 09:32:10 -0500 Subject: Fix resumption setting HMI level to NONE when already in FULL --- src/components/application_manager/src/state_controller_impl.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/components/application_manager/src/state_controller_impl.cc b/src/components/application_manager/src/state_controller_impl.cc index 3d44709657..5e912ca3be 100644 --- a/src/components/application_manager/src/state_controller_impl.cc +++ b/src/components/application_manager/src/state_controller_impl.cc @@ -475,7 +475,9 @@ mobile_apis::HMILevel::eType StateControllerImpl::GetAvailableHmiLevel( return result; } - const bool is_active_app_exist = (bool)app_mngr_.active_application(); + ApplicationConstSharedPtr active_app = app_mngr_.active_application(); + const bool is_active_app_exist = + (active_app.use_count() != 0) && active_app->app_id() != app->app_id(); if (is_audio_app) { if (does_audio_app_with_same_type_exist) { result = app_mngr_.GetDefaultHmiLevel(app); -- cgit v1.2.1 From 9d3b27f39bfd9ad15ca055ed825a26c3b1665578 Mon Sep 17 00:00:00 2001 From: jacobkeeler Date: Wed, 5 Dec 2018 09:35:03 -0500 Subject: Fix storage directory deletion if app folder is not set --- src/components/application_manager/src/application_impl.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/application_manager/src/application_impl.cc b/src/components/application_manager/src/application_impl.cc index 80b25dc814..02bf5b49fe 100644 --- a/src/components/application_manager/src/application_impl.cc +++ b/src/components/application_manager/src/application_impl.cc @@ -964,7 +964,7 @@ void ApplicationImpl::CleanupFiles() { application_manager_.get_settings().app_storage_folder(); directory_name += "/" + folder_name(); - if (file_system::DirectoryExists(directory_name)) { + if (file_system::DirectoryExists(directory_name) && !folder_name().empty()) { std::vector files = file_system::ListFiles(directory_name); AppFilesMap::const_iterator app_files_it; -- cgit v1.2.1 From 3a2b833dd56ccad4917d6d2d3f88dfe27feca6e9 Mon Sep 17 00:00:00 2001 From: JackLivio Date: Wed, 5 Dec 2018 10:28:07 -0500 Subject: Update ConnectionStatusUpdated method + tests --- .../test/commands/hmi/sdl_activate_app_request_test.cc | 1 + .../transport_adapter/mock_transport_adapter.h | 2 +- .../transport_adapter/transport_adapter.h | 2 -- .../transport_adapter/transport_adapter_impl.h | 6 +++++- .../src/transport_adapter/transport_adapter_impl.cc | 16 +++++++--------- .../mock_transport_adapter_controller.h | 2 +- .../transport_adapter/mock_transport_adapter_impl.h | 6 +++++- .../transport_manager/test/transport_adapter_test.cc | 10 ++-------- 8 files changed, 22 insertions(+), 23 deletions(-) diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/sdl_activate_app_request_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/sdl_activate_app_request_test.cc index f040128097..8543a201bf 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/sdl_activate_app_request_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/sdl_activate_app_request_test.cc @@ -44,6 +44,7 @@ #include "application_manager/event_engine/event.h" #include "application_manager/mock_event_dispatcher.h" #include "application_manager/mock_state_controller.h" +#include "connection_handler/mock_connection_handler.h" namespace test { namespace components { diff --git a/src/components/include/test/transport_manager/transport_adapter/mock_transport_adapter.h b/src/components/include/test/transport_manager/transport_adapter/mock_transport_adapter.h index c993f245b9..3864c3f6f9 100644 --- a/src/components/include/test/transport_manager/transport_adapter/mock_transport_adapter.h +++ b/src/components/include/test/transport_manager/transport_adapter/mock_transport_adapter.h @@ -35,6 +35,7 @@ #include "gmock/gmock.h" #include "transport_manager/transport_adapter/transport_adapter.h" +#include "transport_manager/transport_adapter/device.h" namespace test { namespace components { @@ -69,7 +70,6 @@ class MockTransportAdapter MOCK_CONST_METHOD1(GetConnectionStatus, ::transport_manager::ConnectionStatus( const ::transport_manager::DeviceUID& device_handle)); - MOCK_METHOD0(ConnectionStatusUpdated, void()); MOCK_METHOD2(RunAppOnDevice, void(const std::string&, const std::string&)); MOCK_CONST_METHOD0(IsClientOriginatedConnectSupported, bool()); MOCK_METHOD0( diff --git a/src/components/include/transport_manager/transport_adapter/transport_adapter.h b/src/components/include/transport_manager/transport_adapter/transport_adapter.h index f4ce19eb5f..2b3efd3624 100644 --- a/src/components/include/transport_manager/transport_adapter/transport_adapter.h +++ b/src/components/include/transport_manager/transport_adapter/transport_adapter.h @@ -206,8 +206,6 @@ class TransportAdapter { virtual ConnectionStatus GetConnectionStatus( const DeviceUID& device_handle) const = 0; - virtual void ConnectionStatusUpdated() = 0; - /** * @brief RunAppOnDevice allows to run specific application on the certain *device. diff --git a/src/components/transport_manager/include/transport_manager/transport_adapter/transport_adapter_impl.h b/src/components/transport_manager/include/transport_manager/transport_adapter/transport_adapter_impl.h index 8d03bdb2c7..68d5ba3067 100644 --- a/src/components/transport_manager/include/transport_manager/transport_adapter/transport_adapter_impl.h +++ b/src/components/transport_manager/include/transport_manager/transport_adapter/transport_adapter_impl.h @@ -159,7 +159,11 @@ class TransportAdapterImpl : public TransportAdapter, ConnectionStatus GetConnectionStatus( const DeviceUID& device_handle) const OVERRIDE; - void ConnectionStatusUpdated() OVERRIDE; + /** + * @brief Notifies the application manager that a cloud connection status has + * updated and should trigger an UpdateAppList RPC to the HMI + */ + void ConnectionStatusUpdated(DeviceSptr device, ConnectionStatus status); /** * @brief Disconnect from specified session. diff --git a/src/components/transport_manager/src/transport_adapter/transport_adapter_impl.cc b/src/components/transport_manager/src/transport_adapter/transport_adapter_impl.cc index 8928ecb4d2..34d5a29abd 100644 --- a/src/components/transport_manager/src/transport_adapter/transport_adapter_impl.cc +++ b/src/components/transport_manager/src/transport_adapter/transport_adapter_impl.cc @@ -252,13 +252,11 @@ TransportAdapter::Error TransportAdapterImpl::ConnectDevice( // Update retry count if (device->retry_count() >= get_settings().cloud_app_max_retry_attempts()) { - device->set_connection_status(ConnectionStatus::PENDING); device->reset_retry_count(); - ConnectionStatusUpdated(); + ConnectionStatusUpdated(device, ConnectionStatus::PENDING); return err; } else if (device->connection_status() == ConnectionStatus::PENDING) { - device->set_connection_status(ConnectionStatus::RETRY); - ConnectionStatusUpdated(); + ConnectionStatusUpdated(device, ConnectionStatus::RETRY); } device->next_retry(); @@ -273,8 +271,7 @@ TransportAdapter::Error TransportAdapterImpl::ConnectDevice( retry_timer->Start(get_settings().cloud_app_retry_timeout(), timer::kSingleShot); } else if (OK == err) { - device->set_connection_status(ConnectionStatus::CONNECTED); - ConnectionStatusUpdated(); + ConnectionStatusUpdated(device, ConnectionStatus::CONNECTED); } LOG4CXX_TRACE(logger_, "exit with error: " << err); return err; @@ -328,7 +325,9 @@ ConnectionStatus TransportAdapterImpl::GetConnectionStatus( : device->connection_status(); } -void TransportAdapterImpl::ConnectionStatusUpdated() { +void TransportAdapterImpl::ConnectionStatusUpdated(DeviceSptr device, + ConnectionStatus status) { + device->set_connection_status(status); for (TransportAdapterListenerList::iterator it = listeners_.begin(); it != listeners_.end(); ++it) { @@ -366,8 +365,7 @@ TransportAdapter::Error TransportAdapterImpl::DisconnectDevice( Error error = OK; DeviceSptr device = FindDevice(device_id); - device->set_connection_status(ConnectionStatus::CLOSING); - ConnectionStatusUpdated(); + ConnectionStatusUpdated(device, ConnectionStatus::CLOSING); std::vector to_disconnect; connections_lock_.AcquireForReading(); diff --git a/src/components/transport_manager/test/include/transport_manager/transport_adapter/mock_transport_adapter_controller.h b/src/components/transport_manager/test/include/transport_manager/transport_adapter/mock_transport_adapter_controller.h index 642c193d63..bd8c5d2ed3 100644 --- a/src/components/transport_manager/test/include/transport_manager/transport_adapter/mock_transport_adapter_controller.h +++ b/src/components/transport_manager/test/include/transport_manager/transport_adapter/mock_transport_adapter_controller.h @@ -44,7 +44,7 @@ using namespace ::transport_manager::transport_adapter; class MockTransportAdapterController : public TransportAdapterController { public: - MOCK_METHOD1(AddDevice, DeviceSptr(DeviceSptr device)); + MOCK_METHOD1(AddDevice, DeviceSptr(std::string device)); MOCK_METHOD1(SearchDeviceDone, void(DeviceVector device)); MOCK_METHOD1(ApplicationListUpdated, ApplicationListUpdated(const DeviceUID& device_handle)); diff --git a/src/components/transport_manager/test/include/transport_manager/transport_adapter/mock_transport_adapter_impl.h b/src/components/transport_manager/test/include/transport_manager/transport_adapter/mock_transport_adapter_impl.h index e18d1bc53b..3a1422cee1 100644 --- a/src/components/transport_manager/test/include/transport_manager/transport_adapter/mock_transport_adapter_impl.h +++ b/src/components/transport_manager/test/include/transport_manager/transport_adapter/mock_transport_adapter_impl.h @@ -36,6 +36,8 @@ #include "gmock/gmock.h" #include "transport_manager/transport_manager_settings.h" #include "transport_manager/transport_adapter/transport_adapter_impl.h" +#include "transport_manager/transport_adapter/device.h" +#include "transport_manager/common.h" using ::transport_manager::transport_adapter::TransportAdapterImpl; using ::transport_manager::transport_adapter::DeviceScanner; @@ -75,7 +77,9 @@ class MockTransportAdapterImpl : public TransportAdapterImpl { MOCK_CONST_METHOD1(FindDevice, transport_manager::transport_adapter::DeviceSptr( const DeviceUID& device_id)); - MOCK_METHOD0(ConnectionStatusUpdated, void()); + MOCK_METHOD2(ConnectionStatusUpdated, + void(transport_manager::transport_adapter::DeviceSptr device, + ::transport_manager::ConnectionStatus status)); MOCK_CONST_METHOD0(GetDeviceType, ::transport_manager::transport_adapter::DeviceType()); MOCK_METHOD0(RetryConnection, void()); diff --git a/src/components/transport_manager/test/transport_adapter_test.cc b/src/components/transport_manager/test/transport_adapter_test.cc index b917c60187..72cf0ba76e 100644 --- a/src/components/transport_manager/test/transport_adapter_test.cc +++ b/src/components/transport_manager/test/transport_adapter_test.cc @@ -359,7 +359,6 @@ TEST_F(TransportAdapterTest, ConnectDevice_DeviceAdded) { EXPECT_CALL(*serverMock, CreateConnection(uniq_id, app_handle)) .WillOnce(Return(TransportAdapter::OK)); EXPECT_CALL(transport_adapter, FindDevice(uniq_id)).WillOnce(Return(mockdev)); - EXPECT_CALL(transport_adapter, ConnectionStatusUpdated()); TransportAdapter::Error res = transport_adapter.ConnectDevice(uniq_id); EXPECT_EQ(TransportAdapter::OK, res); EXPECT_EQ(ConnectionStatus::CONNECTED, mockdev->connection_status()); @@ -372,7 +371,6 @@ TEST_F(TransportAdapterTest, ConnectDevice_DeviceAdded_ConnectFailedRetry) { MockTransportAdapterImpl transport_adapter( NULL, server_mock, NULL, last_state_, transport_manager_settings); SetDefaultExpectations(transport_adapter); - // transport_adapter.SetDeviceType(DeviceType::CLOUD_WEBSOCKET); EXPECT_CALL(*server_mock, Init()).WillOnce(Return(TransportAdapter::OK)); EXPECT_CALL(transport_adapter, Restore()).WillOnce(Return(true)); @@ -396,7 +394,6 @@ TEST_F(TransportAdapterTest, ConnectDevice_DeviceAdded_ConnectFailedRetry) { EXPECT_CALL(transport_adapter, FindDevice(uniq_id)).WillOnce(Return(mockdev)); EXPECT_CALL(transport_adapter, GetDeviceType()) .WillOnce(Return(DeviceType::CLOUD_WEBSOCKET)); - EXPECT_CALL(transport_adapter, ConnectionStatusUpdated()); EXPECT_CALL(transport_manager_settings, cloud_app_max_retry_attempts()) .WillOnce(Return(0)); TransportAdapter::Error res = transport_adapter.ConnectDevice(uniq_id); @@ -432,7 +429,6 @@ TEST_F(TransportAdapterTest, ConnectDevice_DeviceAddedTwice) { EXPECT_CALL(*serverMock, CreateConnection(uniq_id, app_handle)) .WillOnce(Return(TransportAdapter::OK)); EXPECT_CALL(transport_adapter, FindDevice(uniq_id)).WillOnce(Return(mockdev)); - EXPECT_CALL(transport_adapter, ConnectionStatusUpdated()); TransportAdapter::Error res = transport_adapter.ConnectDevice(uniq_id); EXPECT_EQ(TransportAdapter::OK, res); EXPECT_EQ(ConnectionStatus::CONNECTED, mockdev->connection_status()); @@ -444,7 +440,6 @@ TEST_F(TransportAdapterTest, ConnectDevice_DeviceAddedTwice) { EXPECT_CALL(*serverMock, IsInitialised()).WillOnce(Return(true)); EXPECT_CALL(*serverMock, CreateConnection(uniq_id, app_handle)).Times(0); EXPECT_CALL(transport_adapter, FindDevice(uniq_id)).WillOnce(Return(mockdev)); - EXPECT_CALL(transport_adapter, ConnectionStatusUpdated()); TransportAdapter::Error newres = transport_adapter.ConnectDevice(uniq_id); EXPECT_EQ(TransportAdapter::OK, newres); EXPECT_EQ(ConnectionStatus::CONNECTED, mockdev->connection_status()); @@ -509,7 +504,7 @@ TEST_F(TransportAdapterTest, DisconnectDevice_DeviceAddedConnectionCreated) { .WillOnce(Return(TransportAdapter::OK)); EXPECT_CALL(transport_adapter, FindDevice(uniq_id)) .WillRepeatedly(Return(mockdev)); - EXPECT_CALL(transport_adapter, ConnectionStatusUpdated()); + // EXPECT_CALL(transport_adapter, ConnectionStatusUpdated(_, _)); TransportAdapter::Error res = transport_adapter.ConnectDevice(uniq_id); EXPECT_EQ(TransportAdapter::OK, res); EXPECT_EQ(ConnectionStatus::CONNECTED, mockdev->connection_status()); @@ -520,7 +515,7 @@ TEST_F(TransportAdapterTest, DisconnectDevice_DeviceAddedConnectionCreated) { EXPECT_CALL(*mock_connection, Disconnect()) .WillOnce(Return(TransportAdapter::OK)); - EXPECT_CALL(transport_adapter, ConnectionStatusUpdated()); + // EXPECT_CALL(transport_adapter, ConnectionStatusUpdated(_, _)); TransportAdapter::Error new_res = transport_adapter.DisconnectDevice(uniq_id); EXPECT_EQ(TransportAdapter::OK, new_res); EXPECT_EQ(ConnectionStatus::CLOSING, mockdev->connection_status()); @@ -556,7 +551,6 @@ TEST_F(TransportAdapterTest, DeviceDisconnected) { EXPECT_CALL(*serverMock, IsInitialised()).WillOnce(Return(true)); EXPECT_CALL(*serverMock, CreateConnection(uniq_id, app_handle)) .WillOnce(Return(TransportAdapter::OK)); - EXPECT_CALL(transport_adapter, ConnectionStatusUpdated()); TransportAdapter::Error res = transport_adapter.ConnectDevice(uniq_id); EXPECT_EQ(TransportAdapter::OK, res); EXPECT_EQ(ConnectionStatus::CONNECTED, mockdev->connection_status()); -- cgit v1.2.1 From 94273e3fd8db6617983def5abd3658f5af8c2983 Mon Sep 17 00:00:00 2001 From: jacobkeeler Date: Wed, 5 Dec 2018 16:53:03 -0500 Subject: Set app icon path for pending apps --- src/components/application_manager/src/application_manager_impl.cc | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/components/application_manager/src/application_manager_impl.cc b/src/components/application_manager/src/application_manager_impl.cc index d6e80b69bd..d188ed9724 100644 --- a/src/components/application_manager/src/application_manager_impl.cc +++ b/src/components/application_manager/src/application_manager_impl.cc @@ -881,6 +881,12 @@ void ApplicationManagerImpl::CreatePendingApplication( return; } + const std::string app_icon_dir(settings_.app_icons_folder()); + const std::string full_icon_path(app_icon_dir + "/" + policy_app_id); + if (file_system::FileExists(full_icon_path)) { + application->set_app_icon_path(full_icon_path); + } + GetPolicyHandler().GetCloudAppParameters(policy_app_id, enabled, endpoint, -- cgit v1.2.1 From 99576e3a44bfe95249e56102e87384101c8becbc Mon Sep 17 00:00:00 2001 From: ShobhitAd Date: Fri, 30 Nov 2018 09:01:33 -0500 Subject: Implement WSS connection --- .../cloud/websocket_client_connection.h | 11 ++- .../src/cloud/websocket_client_connection.cc | 103 ++++++++++++++++++++- 2 files changed, 110 insertions(+), 4 deletions(-) diff --git a/src/components/transport_manager/include/transport_manager/cloud/websocket_client_connection.h b/src/components/transport_manager/include/transport_manager/cloud/websocket_client_connection.h index da3a80e1b2..a5ed0e80db 100644 --- a/src/components/transport_manager/include/transport_manager/cloud/websocket_client_connection.h +++ b/src/components/transport_manager/include/transport_manager/cloud/websocket_client_connection.h @@ -49,6 +49,7 @@ #include #include #include "transport_manager/transport_adapter/connection.h" +#include "transport_manager/cloud/cloud_websocket_transport_adapter.h" #include "utils/threads/thread.h" #include "utils/threads/message_loop_thread.h" #include "utils/message_queue.h" @@ -117,6 +118,13 @@ class WebsocketClientConnection */ TransportAdapter::Error Disconnect(); + /** + * @brief Attempt to open a secure connection with the provided certificate + * + * @return true if secured connection was created successfully + */ + bool AddCertificateAuthority(std::string cert, boost::system::error_code& ec); + void Shutdown(); void Recv(boost::system::error_code ec); @@ -126,8 +134,9 @@ class WebsocketClientConnection private: TransportAdapterController* controller_; boost::asio::io_context ioc_; + ssl::context ctx_; tcp::resolver resolver_; - websocket::stream ws_; + websocket::stream> ws_; boost::beast::flat_buffer buffer_; std::string host_; std::string text_; diff --git a/src/components/transport_manager/src/cloud/websocket_client_connection.cc b/src/components/transport_manager/src/cloud/websocket_client_connection.cc index 4f585c8efb..2ee5b89002 100644 --- a/src/components/transport_manager/src/cloud/websocket_client_connection.cc +++ b/src/components/transport_manager/src/cloud/websocket_client_connection.cc @@ -47,13 +47,36 @@ WebsocketClientConnection::WebsocketClientConnection( const ApplicationHandle& app_handle, TransportAdapterController* controller) : controller_(controller) + , ctx_(ssl::context::sslv23_client) , resolver_(ioc_) - , ws_(ioc_) + , ws_{ioc_, ctx_} , shutdown_(false) , thread_delegate_(new LoopThreadDelegate(&message_queue_, this)) , write_thread_(threads::CreateThread("WS Async Send", thread_delegate_)) , device_uid_(device_uid) - , app_handle_(app_handle) {} + , app_handle_(app_handle) { + + LOG4CXX_DEBUG(logger_, "CLOUD_DEBUG_WEBSOCKETCLIENTCONNECTION"); + // LOG4CXX_DEBUG(logger_, controller); + + // CloudWebsocketTransportAdapter* cta = static_cast(controller); + // LOG4CXX_DEBUG(logger_, cta); + + // CloudAppTransportConfig temp = cta->GetCloudTransportConfiguration(); + + + // LOG4CXX_DEBUG(logger_, "Printing CloudAppTransportConfig: " << temp.size()); + // for(auto it = temp.cbegin(); it != temp.cend(); it++){ + // std::string txt = "DEVICE: " + it->first + "\n"; + // txt += "ENDPOINT: " + it->second.endpoint + "\n"; + // txt += "CERTIFICATE: " + it->second.certificate + "\n"; + // txt += "AUTH_TOKEN: " + it->second.auth_token + "\n"; + // LOG4CXX_DEBUG(logger_, txt); + + // } + } + + WebsocketClientConnection::~WebsocketClientConnection() { ioc_.stop(); @@ -62,6 +85,25 @@ WebsocketClientConnection::~WebsocketClientConnection() { } } +bool WebsocketClientConnection::AddCertificateAuthority(const std::string cert, boost::system::error_code& ec){ + if(cert == "not_specified"){ + ws_.next_layer().set_verify_mode(ssl::verify_none); + return false; + } + + ctx_.add_certificate_authority(boost::asio::buffer(cert.data(), cert.size()), ec); + if(ec){ + return false; + } + + ws_.next_layer().set_verify_mode(ssl::verify_peer); + if(ec){ + return false; + } + + return true; +} + TransportAdapter::Error WebsocketClientConnection::Start() { LOG4CXX_AUTO_TRACE(logger_); DeviceSptr device = controller_->FindDevice(device_uid_); @@ -70,13 +112,21 @@ TransportAdapter::Error WebsocketClientConnection::Start() { auto const port = cloud_device->GetPort(); boost::system::error_code ec; auto const results = resolver_.resolve(host, port, ec); + + LOG4CXX_DEBUG(logger_, "CLOUD_CONN_START"); + if (ec) { std::string str_err = "ErrorMessage: " + ec.message(); LOG4CXX_ERROR(logger_, "Could not resolve host/port: " << str_err); Shutdown(); return TransportAdapter::FAIL; } - boost::asio::connect(ws_.next_layer(), results.begin(), results.end(), ec); + + LOG4CXX_DEBUG(logger_, "CLOUD_CONN_RESOLVE"); + + // Make Connection to host IP Address over TCP + boost::asio::connect(ws_.next_layer().next_layer(), results.begin(), results.end(), ec); + if (ec) { std::string str_err = "ErrorMessage: " + ec.message(); LOG4CXX_ERROR(logger_, @@ -85,7 +135,50 @@ TransportAdapter::Error WebsocketClientConnection::Start() { Shutdown(); return TransportAdapter::FAIL; } + + LOG4CXX_DEBUG(logger_, "CLOUD_CONN_TCP"); + + std::string cert = "-----BEGIN CERTIFICATE-----\nMIIDBjCCAe6gAwIBAgIJAOsbkrgCZxgtMA0GCSqGSIb3DQEBCwUAMBgxFjAUBgNV\nBAMMDTE5Mi4xNjguMS4xMjgwHhcNMTgxMTI4MTgxNjQwWhcNMjExMTI3MTgxNjQw\nWjAYMRYwFAYDVQQDDA0xOTIuMTY4LjEuMTI4MIIBIjANBgkqhkiG9w0BAQEFAAOC\nAQ8AMIIBCgKCAQEAlVrHDi+XdO9fNMcknqs2Hn0AQjKQZAq0juy8r7gDqkzHw9zY\nFnfssIUzP7R6F1/80ulyjwUN6G+SI7phbivr2gmSdfkYiJVdwBKf611srIrNF/Eh\nllt/2sjwZNyTai4pzZv9/svix5nIVCHdKZD6wsxCFOdNhVJGBd9uQ4Pk1hQoW/jj\nsUF/NBUa49k31/IQiqQ6T1xQvSkEUYd1kstS7utO2V0Z9rHH4/+4HNyPMKipkCi2\n/7WuvQGDyHTnNUFmEANn4X06iQAVon9L8IVRcGwtgsWJ0fuVGK5POtU4m37Q35MW\n3RWF3OzyP/6PxRX5ljQFmkwGkqzHrNzOZN+zMQIDAQABo1MwUTAdBgNVHQ4EFgQU\nc1BN7ZNXq+OA5hT+vq1NOMoUrR8wHwYDVR0jBBgwFoAUc1BN7ZNXq+OA5hT+vq1N\nOMoUrR8wDwYDVR0TAQH/BAUwAwEB/zANBgkqhkiG9w0BAQsFAAOCAQEANBnwEOwM\nRynBmaRBBVZBxcWsaWQ6h7XETLSU+Pqrv2cm+g8pS1pFwc69OS5ER730UcCADlLv\n7Lu61m9kOxHuDzeQR5ofkVbFx1swUqSZt7GZvopVtwFeto4zUfAyVfCS6n6MGSvN\nWlathEg3mlXlAjtX1qEg1JzJ5DjowiPpJ2FZMsakJrF3Ju0D0Dskg0wgqZLKcHYC\ndV7bm2SpC7kfqeuSXIC8hbfolJBaysFRjIXXWwDhtW2i4KRDq4b54EVON2af6RD7\nbsOiY4Qt4Aw5UOE+DN/dbkXXNHKDWN/VN1MI9wGJiriXf4BWSJWgrrsXHkpzqmMj\nrHR2ik90MT9pkQ==\n-----END CERTIFICATE-----"; + std::string fake_cert = "-----BEGIN CERTIFICATE-----\nMIIDBjCCAe6gAwIBAgIJAOTd19xp9ISxMA0GCSqGSIb3DQEBCwUAMBgxFjAUBgNV\nBAMMDTE5Mi4xNjguMS4xMjgwHhcNMTgxMTI4MTM1NjI0WhcNMjExMTI3MTM1NjI0\nWjAYMRYwFAYDVQQDDA0xOTIuMTY4LjEuMTI4MIIBIjANBgkqhkiG9w0BAQEFAAOC\nAQ8AMIIBCgKCAQEAlVrHDi+XdO9fNMcknqs2Hn0AQjKQZAq0juy8r7gDqkzHw9zY\nFnfssIUzP7R6F1/80ulyjwUN6G+SI7phbivr2gmSdfkYiJVdwBKf611srIrNF/Eh\nllt/2sjwZNyTai4pzZv9/svix5nIVCHdKZD6wsxCFOdNhVJGBd9uQ4Pk1hQoW/jj\nsUF/NBUa49k31/IQiqQ6T1xQvSkEUYd1kstS7utO2V0Z9rHH4/+4HNyPMKipkCi2\n/7WuvQGDyHTnNUFmEANn4X06iQAVon9L8IVRcGwtgsWJ0fuVGK5POtU4m37Q35MW\n3RWF3OzyP/6PxRX5ljQFmkwGkqzHrNzOZN+zMQIDAQABo1MwUTAdBgNVHQ4EFgQU\nc1BN7ZNXq+OA5hT+vq1NOMoUrR8wHwYDVR0jBBgwFoAUc1BN7ZNXq+OA5hT+vq1N\nOMoUrR8wDwYDVR0TAQH/BAUwAwEB/zANBgkqhkiG9w0BAQsFAAOCAQEAUQ8MwCmb\nDrwCNGaUdGNXoiAWrltPE2buzpq8OCVxXBSqSumAe1SkjyKROBbevM7/Cl4V3qgj\nEHjUXNrzFR9WTCOOjJ9W0wiO25FDBguU5VCkuhvfL6lCgVuJRRi9LtiY2hT5fPdM\nrMvS0/iUV3RXcKNyIGOXH1OcOim+PVph2wj0x/N1Nmhqkh+2LtFHhsE/Zgygndla\nsbyRTNQ3bnzGUwMl8jPa7KSeggtfmjIFc4VXEgrOzKHhJO2C96FmVMo97QqKQvq+\nWjPfzHnI3hhr1GPPMHFQQZG5j4a708Qo9fZcKJxUvm0O7kdFFOqcMyo086cu1YUP\nGy5s8MqShPUp1Q==\n-----END CERTIFICATE-----"; + std::string no_cert = "not_specified"; + std::string invalid_cert = "-----BEGIN CERTIFICATE-----\nWjAYMRYwFAYDVQQDDA0xOTIuMTY4LjEuMTI4MIIBIjANBgkqhkiG9w0BAQEFAAOC\nAQ8AMIIBCgKCAQEAlVrHDi+XdO9fNMcknqs2Hn0AQjKQZAq0juy8r7gDqkzHw9zY\nFnfssIUzP7R6F1/80ulyjwUN6G+SI7phbivr2gmSdfkYiJVdwBKf611srIrNF/Eh\nllt/2sjwZNyTai4pzZv9/svix5nIVCHdKZD6wsxCFOdNhVJGBd9uQ4Pk1hQoW/jj\nsUF/NBUa49k31/IQiqQ6T1xQvSkEUYd1kstS7utO2V0Z9rHH4/+4HNyPMKipkCi2\n/7WuvQGDyHTnNUFmEANn4X06iQAVon9L8IVRcGwtgsWJ0fuVGK5POtU4m37Q35MW\n3RWF3OzyP/6PxRX5ljQFmkwGkqzHrNzOZN+zMQIDAQABo1MwUTAdBgNVHQ4EFgQU\nc1BN7ZNXq+OA5hT+vq1NOMoUrR8wHwYDVR0jBBgwFoAUc1BN7ZNXq+OA5hT+vq1N\nOMoUrR8wDwYDVR0TAQH/BAUwAwEB/zANBgkqhkiG9w0BAQsFAAOCAQEAUQ8MwCmb\nDrwCNGaUdGNXoiAWrltPE2buzpq8OCVxXBSqSumAe1SkjyKROBbevM7/Cl4V3qgj\nEHjUXNrzFR9WTCOOjJ9W0wiO25FDBguU5VCkuhvfL6lCgVuJRRi9LtiY2hT5fPdM\nrMvS0/iUV3RXcKNyIGOXH1OcOim+PVph2wj0x/N1Nmhqkh+2LtFHhsE/Zgygndla\nsbyRTNQ3bnzGUwMl8jPa7KSeggtfmjIFc4VXEgrOzKHhJO2C96FmVMo97QqKQvq+\nWjPfzHnI3hhr1GPPMHFQQZG5j4a708Qo9fZcKJxUvm0O7kdFFOqcMyo086cu1YUP\nGy5s8MqShPUp1Q==\n-----END CERTIFICATE-----"; + std::string test_cert = ""; + + bool isAdded = AddCertificateAuthority(cert, ec); + + if(isAdded){ + LOG4CXX_INFO(logger_, "Certificate Authority added successfully"); + }else{ + LOG4CXX_INFO(logger_, "Failed to add certificate authority"); + } + + if(ec){ + std::string str_err = "ErrorMessage: " + ec.message(); + LOG4CXX_ERROR(logger_, + "Failed to add certificate authority: " << invalid_cert); + LOG4CXX_ERROR(logger_, str_err); + Shutdown(); + return TransportAdapter::FAIL; + } + + //Perform SSL Handshake + ws_.next_layer().handshake(ssl::stream_base::client, ec); + + if (ec) { + std::string str_err = "ErrorMessage: " + ec.message(); + LOG4CXX_ERROR(logger_, + "Could not complete SSL Handshake failed with host/port: " << host << ":" + << port); + LOG4CXX_ERROR(logger_, str_err); + Shutdown(); + return TransportAdapter::FAIL; + } + + LOG4CXX_DEBUG(logger_, "CLOUD_CONN_SSL"); + + // Perform websocket handshake ws_.handshake(host, "/", ec); + if (ec) { std::string str_err = "ErrorMessage: " + ec.message(); LOG4CXX_ERROR(logger_, @@ -95,6 +188,10 @@ TransportAdapter::Error WebsocketClientConnection::Start() { Shutdown(); return TransportAdapter::FAIL; } + + LOG4CXX_DEBUG(logger_, "CLOUD_CONN_WEBSOCKET"); + + // Set the binary message write option ws_.binary(true); write_thread_->start(threads::ThreadOptions()); controller_->ConnectDone(device_uid_, app_handle_); -- cgit v1.2.1 From fd2288be63c1e699388af9d3203d4a875d63e820 Mon Sep 17 00:00:00 2001 From: ShobhitAd Date: Mon, 3 Dec 2018 16:30:11 -0500 Subject: Pass CloudAppProperties to websocket client connection --- .../src/application_manager_impl.cc | 13 ++++- .../connection_handler/connection_handler_impl.h | 5 +- .../src/connection_handler_impl.cc | 16 ++++-- .../connection_handler/connection_handler.h | 3 +- .../transport_adapter/transport_adapter.h | 16 ++++++ .../include/transport_manager/transport_manager.h | 3 +- .../cloud/cloud_websocket_transport_adapter.h | 18 +++++++ .../cloud/websocket_client_connection.h | 5 +- .../transport_manager/transport_manager_impl.h | 3 +- .../src/cloud/cloud_websocket_transport_adapter.cc | 25 +++++++++ .../src/cloud/websocket_client_connection.cc | 59 ++++++++++------------ .../src/transport_manager_impl.cc | 21 ++++++-- 12 files changed, 132 insertions(+), 55 deletions(-) diff --git a/src/components/application_manager/src/application_manager_impl.cc b/src/components/application_manager/src/application_manager_impl.cc index d188ed9724..44d9a4f903 100644 --- a/src/components/application_manager/src/application_manager_impl.cc +++ b/src/components/application_manager/src/application_manager_impl.cc @@ -808,6 +808,7 @@ void ApplicationManagerImpl::OnHMIStartedCooperation() { void ApplicationManagerImpl::CollectCloudAppInformation() { LOG4CXX_AUTO_TRACE(logger_); + LOG4CXX_DEBUG(logger_, "CLOUD_DEBUG_COLLECTCLOUDAPPINFO"); std::vector cloud_app_id_vector; GetPolicyHandler().GetEnabledCloudApps(cloud_app_id_vector); std::vector::iterator it = cloud_app_id_vector.begin(); @@ -830,7 +831,17 @@ void ApplicationManagerImpl::CollectCloudAppInformation() { pending_device_map_.insert( std::pair(endpoint, *it)); - connection_handler().AddCloudAppDevice(*it, endpoint, cloud_transport_type); + transport_manager::transport_adapter::CloudAppProperties properties + {endpoint, certificate, enabled, auth_token, cloud_transport_type, hybrid_app_preference}; + LOG4CXX_DEBUG(logger_, "CLOUD_APP_MGR: " << endpoint); + LOG4CXX_DEBUG(logger_, "ENDPOINT: " << properties.endpoint); + LOG4CXX_DEBUG(logger_, "ENABLED: " << properties.enabled); + LOG4CXX_DEBUG(logger_, "CERTIFICATE: " << properties.certificate); + LOG4CXX_DEBUG(logger_, "AUTH_TOKEN: " << properties.auth_token); + LOG4CXX_DEBUG(logger_, "TRANSPORT_TYPE: " << properties.cloud_transport_type); + LOG4CXX_DEBUG(logger_, "HYBRID: " << properties.hybrid_app_preference); + + connection_handler().AddCloudAppDevice(*it, properties); } } diff --git a/src/components/connection_handler/include/connection_handler/connection_handler_impl.h b/src/components/connection_handler/include/connection_handler/connection_handler_impl.h index b8153bcf42..5819b32f03 100644 --- a/src/components/connection_handler/include/connection_handler/connection_handler_impl.h +++ b/src/components/connection_handler/include/connection_handler/connection_handler_impl.h @@ -81,7 +81,7 @@ class ConnectionHandlerImpl ConnectionHandlerImpl(const ConnectionHandlerSettings& settings, transport_manager::TransportManager& tm); /** - * \brief Destructor + * @brief Destructor */ ~ConnectionHandlerImpl(); @@ -131,8 +131,7 @@ class ConnectionHandlerImpl void ConnectToAllDevices() OVERRIDE; void AddCloudAppDevice(const std::string& policy_app_id, - const std::string& endpoint, - const std::string& cloud_transport_type) OVERRIDE; + const transport_manager::transport_adapter::CloudAppProperties cloud_properties) OVERRIDE; void StartTransportManager() OVERRIDE; diff --git a/src/components/connection_handler/src/connection_handler_impl.cc b/src/components/connection_handler/src/connection_handler_impl.cc index f72cab61f3..55134ebf5b 100644 --- a/src/components/connection_handler/src/connection_handler_impl.cc +++ b/src/components/connection_handler/src/connection_handler_impl.cc @@ -1323,11 +1323,17 @@ void ConnectionHandlerImpl::ConnectToAllDevices() { } } -void ConnectionHandlerImpl::AddCloudAppDevice( - const std::string& policy_app_id, - const std::string& endpoint, - const std::string& cloud_transport_type) { - transport_manager_.AddCloudDevice(endpoint, cloud_transport_type); +void ConnectionHandlerImpl::AddCloudAppDevice(const std::string& policy_app_id, + const transport_manager::transport_adapter::CloudAppProperties cloud_properties) { + // LOG4CXX_DEBUG(logger_, "CLOUD_DEBUG_ADDCLOUDAPPDEVICE: " << cloud_properties.endpoint); + // LOG4CXX_DEBUG(logger_, "ENDPOINT: " << cloud_properties.endpoint); + // LOG4CXX_DEBUG(logger_, "ENABLED: " << cloud_properties.enabled); + // LOG4CXX_DEBUG(logger_, "CERTIFICATE: " << cloud_properties.certificate); + // LOG4CXX_DEBUG(logger_, "AUTH_TOKEN: " << cloud_properties.auth_token); + // LOG4CXX_DEBUG(logger_, "TRANSPORT_TYPE: " << cloud_properties.cloud_transport_type); + // LOG4CXX_DEBUG(logger_, "HYBRID: " << cloud_properties.hybrid_app_preference); + + transport_manager_.AddCloudDevice(cloud_properties); } void ConnectionHandlerImpl::StartTransportManager() { diff --git a/src/components/include/connection_handler/connection_handler.h b/src/components/include/connection_handler/connection_handler.h index eb41141842..81dd24447c 100644 --- a/src/components/include/connection_handler/connection_handler.h +++ b/src/components/include/connection_handler/connection_handler.h @@ -104,8 +104,7 @@ class ConnectionHandler { virtual void ConnectToAllDevices() = 0; virtual void AddCloudAppDevice(const std::string& policy_app_id, - const std::string& endpoint, - const std::string& cloud_transport_type) = 0; + const transport_manager::transport_adapter::CloudAppProperties cloud_properties ) = 0; /** * @brief Close the connection revoked by Policy diff --git a/src/components/include/transport_manager/transport_adapter/transport_adapter.h b/src/components/include/transport_manager/transport_adapter/transport_adapter.h index 2b3efd3624..ab21f1a326 100644 --- a/src/components/include/transport_manager/transport_adapter/transport_adapter.h +++ b/src/components/include/transport_manager/transport_adapter/transport_adapter.h @@ -71,6 +71,21 @@ enum DeviceType { UNKNOWN }; +enum HybridAppPreference { // todo find correct place for this enum defintion. + MOBILE, + CLOUD, + BOTH +}; + +struct CloudAppProperties { + std::string endpoint; + std::string certificate; + bool enabled; + std::string auth_token; + std::string cloud_transport_type; + std::string hybrid_app_preference; +}; + typedef std::map DeviceTypes; /** @@ -89,6 +104,7 @@ typedef std::list TransportAdapterListenerList; */ typedef std::map TransportConfig; +typedef std::map CloudAppTransportConfig; /** * @brief TransportConfig keys */ diff --git a/src/components/include/transport_manager/transport_manager.h b/src/components/include/transport_manager/transport_manager.h index 3ecf815097..fe5b708dd1 100644 --- a/src/components/include/transport_manager/transport_manager.h +++ b/src/components/include/transport_manager/transport_manager.h @@ -75,8 +75,7 @@ class TransportManager { **/ virtual int SearchDevices() = 0; - virtual void AddCloudDevice(const std::string& endpoint, - const std::string& cloud_transport_type) = 0; + virtual void AddCloudDevice(const transport_manager::transport_adapter::CloudAppProperties cloud_properties) = 0; /** * @brief Connect to all applications discovered on device. diff --git a/src/components/transport_manager/include/transport_manager/cloud/cloud_websocket_transport_adapter.h b/src/components/transport_manager/include/transport_manager/cloud/cloud_websocket_transport_adapter.h index d52e4b307d..4270afd25f 100644 --- a/src/components/transport_manager/include/transport_manager/cloud/cloud_websocket_transport_adapter.h +++ b/src/components/transport_manager/include/transport_manager/cloud/cloud_websocket_transport_adapter.h @@ -58,6 +58,23 @@ class CloudWebsocketTransportAdapter : public TransportAdapterImpl { */ virtual ~CloudWebsocketTransportAdapter(); + /** + * @brief Set CloudTransportConfig for specified app_id + * + * @param app_id app ID string + * @param properties New cloud app properties for the app + */ + void SetAppCloudTransportConfig(std::string app_id, CloudAppProperties properties); + + /** + * @brief Get CloudTransportConfig for specified app_id + * + * @param app_id app ID string + * @return CloudAppProperties for the app + */ + const CloudAppProperties& GetAppCloudTransportConfig(std::string app_id); + + protected: /** * @brief Return type of device. @@ -81,6 +98,7 @@ class CloudWebsocketTransportAdapter : public TransportAdapterImpl { void CreateDevice(const std::string& uid) OVERRIDE; private: + CloudAppTransportConfig transport_config_; }; } // namespace transport_adapter diff --git a/src/components/transport_manager/include/transport_manager/cloud/websocket_client_connection.h b/src/components/transport_manager/include/transport_manager/cloud/websocket_client_connection.h index a5ed0e80db..1ee7696254 100644 --- a/src/components/transport_manager/include/transport_manager/cloud/websocket_client_connection.h +++ b/src/components/transport_manager/include/transport_manager/cloud/websocket_client_connection.h @@ -119,9 +119,10 @@ class WebsocketClientConnection TransportAdapter::Error Disconnect(); /** - * @brief Attempt to open a secure connection with the provided certificate + * @brief Attempt to add provided certificate to the ssl::context * - * @return true if secured connection was created successfully + * @param cert Certificate string from policy table + * @return true if certificate was not invalid and was added successfully */ bool AddCertificateAuthority(std::string cert, boost::system::error_code& ec); diff --git a/src/components/transport_manager/include/transport_manager/transport_manager_impl.h b/src/components/transport_manager/include/transport_manager/transport_manager_impl.h index c84b1e9a39..8419f90398 100644 --- a/src/components/transport_manager/include/transport_manager/transport_manager_impl.h +++ b/src/components/transport_manager/include/transport_manager/transport_manager_impl.h @@ -139,8 +139,7 @@ class TransportManagerImpl **/ int SearchDevices() OVERRIDE; - void AddCloudDevice(const std::string& endpoint, - const std::string& cloud_transport_type) OVERRIDE; + void AddCloudDevice(const transport_manager::transport_adapter::CloudAppProperties cloud_properties) OVERRIDE; /** * @brief Connect to all applications discovered on device. diff --git a/src/components/transport_manager/src/cloud/cloud_websocket_transport_adapter.cc b/src/components/transport_manager/src/cloud/cloud_websocket_transport_adapter.cc index 5093e6c2af..68f6ed0a90 100644 --- a/src/components/transport_manager/src/cloud/cloud_websocket_transport_adapter.cc +++ b/src/components/transport_manager/src/cloud/cloud_websocket_transport_adapter.cc @@ -53,6 +53,21 @@ CloudWebsocketTransportAdapter::CloudWebsocketTransportAdapter( CloudWebsocketTransportAdapter::~CloudWebsocketTransportAdapter() {} +void CloudWebsocketTransportAdapter::SetAppCloudTransportConfig(std::string app_id, CloudAppProperties properties) { + transport_config_[app_id] = properties; + // LOG4CXX_DEBUG(logger_, "CLOUD_TRANS_ADP: " << app_id); + // LOG4CXX_DEBUG(logger_, "ENDPOINT: " << transport_config_[app_id].endpoint); + // LOG4CXX_DEBUG(logger_, "ENABLED: " << transport_config_[app_id].enabled); + // LOG4CXX_DEBUG(logger_, "CERTIFICATE: " << transport_config_[app_id].certificate); + // LOG4CXX_DEBUG(logger_, "AUTH_TOKEN: " << transport_config_[app_id].auth_token); + // LOG4CXX_DEBUG(logger_, "TRANSPORT_TYPE: " << transport_config_[app_id].cloud_transport_type); + // LOG4CXX_DEBUG(logger_, "HYBRID: " << transport_config_[app_id].hybrid_app_preference); +} + +const CloudAppProperties& CloudWebsocketTransportAdapter::GetAppCloudTransportConfig(std::string app_id){ + return transport_config_[app_id]; +} + DeviceType CloudWebsocketTransportAdapter::GetDeviceType() const { return CLOUD_WEBSOCKET; } @@ -64,6 +79,7 @@ bool CloudWebsocketTransportAdapter::Restore() { } void CloudWebsocketTransportAdapter::CreateDevice(const std::string& uid) { + LOG4CXX_DEBUG(logger_, "CLOUD_DEBUG_CreateDevice: " << uid); boost::regex pattern( "(wss?):\\/\\/([A-Z\\d\\.-]{2,})\\.?([A-Z]{2,})?(:\\d{2,4})\\/", boost::regex::icase); @@ -73,6 +89,8 @@ void CloudWebsocketTransportAdapter::CreateDevice(const std::string& uid) { return; } + LOG4CXX_DEBUG(logger_, "CLOUD_DEBUG_RegexMatchPassed"); + LOG4CXX_DEBUG(logger_, "Valid Endpoint: " << uid); // Port after second colon in valid endpoint string @@ -99,6 +117,8 @@ void CloudWebsocketTransportAdapter::CreateDevice(const std::string& uid) { return; } + LOG4CXX_DEBUG(logger_, "CLOUD_DEBUG_RegexSearchPassed"); + std::string device_id = uid; LOG4CXX_DEBUG(logger_, @@ -107,6 +127,9 @@ void CloudWebsocketTransportAdapter::CreateDevice(const std::string& uid) { auto cloud_device = std::make_shared(host, port, device_id); + LOG4CXX_DEBUG(logger_, "CLOUD_DEBUG_CreatedCloudDevice: " << host << ", " << port << ", " << device_id); + + DeviceVector devices{cloud_device}; SearchDeviceDone(devices); @@ -115,6 +138,8 @@ void CloudWebsocketTransportAdapter::CreateDevice(const std::string& uid) { std::shared_ptr connection = std::make_shared(uid, 0, this); + LOG4CXX_DEBUG(logger_, "CLOUD_DEBUG_CreatedConnection"); + ConnectionCreated(connection, uid, 0); ConnectPending(uid, 0); diff --git a/src/components/transport_manager/src/cloud/websocket_client_connection.cc b/src/components/transport_manager/src/cloud/websocket_client_connection.cc index 2ee5b89002..05ab03ba29 100644 --- a/src/components/transport_manager/src/cloud/websocket_client_connection.cc +++ b/src/components/transport_manager/src/cloud/websocket_client_connection.cc @@ -57,23 +57,7 @@ WebsocketClientConnection::WebsocketClientConnection( , app_handle_(app_handle) { LOG4CXX_DEBUG(logger_, "CLOUD_DEBUG_WEBSOCKETCLIENTCONNECTION"); - // LOG4CXX_DEBUG(logger_, controller); - // CloudWebsocketTransportAdapter* cta = static_cast(controller); - // LOG4CXX_DEBUG(logger_, cta); - - // CloudAppTransportConfig temp = cta->GetCloudTransportConfiguration(); - - - // LOG4CXX_DEBUG(logger_, "Printing CloudAppTransportConfig: " << temp.size()); - // for(auto it = temp.cbegin(); it != temp.cend(); it++){ - // std::string txt = "DEVICE: " + it->first + "\n"; - // txt += "ENDPOINT: " + it->second.endpoint + "\n"; - // txt += "CERTIFICATE: " + it->second.certificate + "\n"; - // txt += "AUTH_TOKEN: " + it->second.auth_token + "\n"; - // LOG4CXX_DEBUG(logger_, txt); - - // } } @@ -86,10 +70,10 @@ WebsocketClientConnection::~WebsocketClientConnection() { } bool WebsocketClientConnection::AddCertificateAuthority(const std::string cert, boost::system::error_code& ec){ - if(cert == "not_specified"){ - ws_.next_layer().set_verify_mode(ssl::verify_none); - return false; - } + // if(cert == "not_specified"){ + // ws_.next_layer().set_verify_mode(ssl::verify_none); + // return false; + // } ctx_.add_certificate_authority(boost::asio::buffer(cert.data(), cert.size()), ec); if(ec){ @@ -108,12 +92,19 @@ TransportAdapter::Error WebsocketClientConnection::Start() { LOG4CXX_AUTO_TRACE(logger_); DeviceSptr device = controller_->FindDevice(device_uid_); CloudDevice* cloud_device = static_cast(device.get()); + CloudWebsocketTransportAdapter* cloud_ta = static_cast(controller_); + CloudAppProperties cloud_properties = cloud_ta->GetAppCloudTransportConfig(device_uid_); auto const host = cloud_device->GetHost(); auto const port = cloud_device->GetPort(); boost::system::error_code ec; auto const results = resolver_.resolve(host, port, ec); LOG4CXX_DEBUG(logger_, "CLOUD_CONN_START"); + LOG4CXX_DEBUG(logger_, "ENDPOINT: " << cloud_properties.endpoint); + LOG4CXX_DEBUG(logger_, "CERTIFICATE: " << cloud_properties.certificate); + LOG4CXX_DEBUG(logger_, "AUTH_TOKEN: " << cloud_properties.auth_token); + LOG4CXX_DEBUG(logger_, "TRANSPORT_TYPE: " << cloud_properties.cloud_transport_type); + LOG4CXX_DEBUG(logger_, "HYBRID_APP_PREF: " << cloud_properties.hybrid_app_preference); if (ec) { std::string str_err = "ErrorMessage: " + ec.message(); @@ -144,21 +135,23 @@ TransportAdapter::Error WebsocketClientConnection::Start() { std::string invalid_cert = "-----BEGIN CERTIFICATE-----\nWjAYMRYwFAYDVQQDDA0xOTIuMTY4LjEuMTI4MIIBIjANBgkqhkiG9w0BAQEFAAOC\nAQ8AMIIBCgKCAQEAlVrHDi+XdO9fNMcknqs2Hn0AQjKQZAq0juy8r7gDqkzHw9zY\nFnfssIUzP7R6F1/80ulyjwUN6G+SI7phbivr2gmSdfkYiJVdwBKf611srIrNF/Eh\nllt/2sjwZNyTai4pzZv9/svix5nIVCHdKZD6wsxCFOdNhVJGBd9uQ4Pk1hQoW/jj\nsUF/NBUa49k31/IQiqQ6T1xQvSkEUYd1kstS7utO2V0Z9rHH4/+4HNyPMKipkCi2\n/7WuvQGDyHTnNUFmEANn4X06iQAVon9L8IVRcGwtgsWJ0fuVGK5POtU4m37Q35MW\n3RWF3OzyP/6PxRX5ljQFmkwGkqzHrNzOZN+zMQIDAQABo1MwUTAdBgNVHQ4EFgQU\nc1BN7ZNXq+OA5hT+vq1NOMoUrR8wHwYDVR0jBBgwFoAUc1BN7ZNXq+OA5hT+vq1N\nOMoUrR8wDwYDVR0TAQH/BAUwAwEB/zANBgkqhkiG9w0BAQsFAAOCAQEAUQ8MwCmb\nDrwCNGaUdGNXoiAWrltPE2buzpq8OCVxXBSqSumAe1SkjyKROBbevM7/Cl4V3qgj\nEHjUXNrzFR9WTCOOjJ9W0wiO25FDBguU5VCkuhvfL6lCgVuJRRi9LtiY2hT5fPdM\nrMvS0/iUV3RXcKNyIGOXH1OcOim+PVph2wj0x/N1Nmhqkh+2LtFHhsE/Zgygndla\nsbyRTNQ3bnzGUwMl8jPa7KSeggtfmjIFc4VXEgrOzKHhJO2C96FmVMo97QqKQvq+\nWjPfzHnI3hhr1GPPMHFQQZG5j4a708Qo9fZcKJxUvm0O7kdFFOqcMyo086cu1YUP\nGy5s8MqShPUp1Q==\n-----END CERTIFICATE-----"; std::string test_cert = ""; - bool isAdded = AddCertificateAuthority(cert, ec); + if(cloud_properties.cloud_transport_type == "WSS"){ + bool isAdded = AddCertificateAuthority(cert, ec); - if(isAdded){ - LOG4CXX_INFO(logger_, "Certificate Authority added successfully"); - }else{ - LOG4CXX_INFO(logger_, "Failed to add certificate authority"); - } + if(isAdded){ + LOG4CXX_INFO(logger_, "Certificate Authority added successfully"); + }else{ + LOG4CXX_INFO(logger_, "Failed to add certificate authority"); + } - if(ec){ - std::string str_err = "ErrorMessage: " + ec.message(); - LOG4CXX_ERROR(logger_, - "Failed to add certificate authority: " << invalid_cert); - LOG4CXX_ERROR(logger_, str_err); - Shutdown(); - return TransportAdapter::FAIL; + if(ec){ + std::string str_err = "ErrorMessage: " + ec.message(); + LOG4CXX_ERROR(logger_, + "Failed to add certificate authority: " << invalid_cert); + LOG4CXX_ERROR(logger_, str_err); + Shutdown(); + return TransportAdapter::FAIL; + } } //Perform SSL Handshake diff --git a/src/components/transport_manager/src/transport_manager_impl.cc b/src/components/transport_manager/src/transport_manager_impl.cc index 518a5639db..1f57436d60 100644 --- a/src/components/transport_manager/src/transport_manager_impl.cc +++ b/src/components/transport_manager/src/transport_manager_impl.cc @@ -50,6 +50,7 @@ #include "transport_manager/transport_manager_listener.h" #include "transport_manager/transport_manager_listener_empty.h" #include "transport_manager/transport_adapter/transport_adapter.h" +#include "transport_manager/cloud/cloud_websocket_transport_adapter.h" #include "transport_manager/transport_adapter/transport_adapter_event.h" #include "config_profile/profile.h" @@ -129,12 +130,13 @@ void TransportManagerImpl::ReconnectionTimeout() { device_to_reconnect_); } -void TransportManagerImpl::AddCloudDevice( - const std::string& endpoint, const std::string& cloud_transport_type) { +void TransportManagerImpl::AddCloudDevice(const transport_manager::transport_adapter::CloudAppProperties cloud_properties) { // todo put conversion into own function + LOG4CXX_DEBUG(logger_, "CLOUD_DEBUG_AddCloudDevice: " << cloud_properties.cloud_transport_type); + transport_adapter::DeviceType type = transport_adapter::DeviceType::UNKNOWN; - if (cloud_transport_type == "WS") { - type = transport_adapter::DeviceType::CLOUD_WEBSOCKET; + if ((cloud_properties.cloud_transport_type == "WS") || (cloud_properties.cloud_transport_type == "WSS")) { + type = transport_adapter::DeviceType::CLOUD_WEBSOCKET; } else { return; } @@ -142,7 +144,16 @@ void TransportManagerImpl::AddCloudDevice( std::vector::iterator ta = transport_adapters_.begin(); for (; ta != transport_adapters_.end(); ++ta) { if ((*ta)->GetDeviceType() == type) { - (*ta)->CreateDevice(endpoint); + (*ta)->CreateDevice(cloud_properties.endpoint); + transport_adapter::CloudWebsocketTransportAdapter* cta = static_cast(*ta); + // LOG4CXX_DEBUG(logger_, "CLOUD_TRANS_MGR: "); + // LOG4CXX_DEBUG(logger_, "ENDPOINT: " << cloud_properties.endpoint); + // LOG4CXX_DEBUG(logger_, "ENABLED: " << cloud_properties.enabled); + // LOG4CXX_DEBUG(logger_, "CERTIFICATE: " << cloud_properties.certificate); + // LOG4CXX_DEBUG(logger_, "AUTH_TOKEN: " << cloud_properties.auth_token); + // LOG4CXX_DEBUG(logger_, "TRANSPORT_TYPE: " << cloud_properties.cloud_transport_type); + // LOG4CXX_DEBUG(logger_, "HYBRID: " << cloud_properties.hybrid_app_preference); + cta->SetAppCloudTransportConfig(cloud_properties.endpoint, cloud_properties); } } -- cgit v1.2.1 From fe05ccf3155aefe0b3fe3c0710fa2f22c588cc0e Mon Sep 17 00:00:00 2001 From: ShobhitAd Date: Wed, 5 Dec 2018 23:54:56 -0500 Subject: Temporary fix for switching between WS and WSS --- .../cloud/websocket_client_connection.h | 4 +- .../src/cloud/websocket_client_connection.cc | 93 +++++++++++++++------- 2 files changed, 66 insertions(+), 31 deletions(-) diff --git a/src/components/transport_manager/include/transport_manager/cloud/websocket_client_connection.h b/src/components/transport_manager/include/transport_manager/cloud/websocket_client_connection.h index 1ee7696254..4060955eca 100644 --- a/src/components/transport_manager/include/transport_manager/cloud/websocket_client_connection.h +++ b/src/components/transport_manager/include/transport_manager/cloud/websocket_client_connection.h @@ -137,13 +137,15 @@ class WebsocketClientConnection boost::asio::io_context ioc_; ssl::context ctx_; tcp::resolver resolver_; - websocket::stream> ws_; + websocket::stream ws_; + websocket::stream> wss_; boost::beast::flat_buffer buffer_; std::string host_; std::string text_; std::atomic_bool shutdown_; + CloudAppProperties cloud_properties; typedef std::queue FrameQueue; FrameQueue frames_to_send_; mutable sync_primitives::Lock frames_to_send_mutex_; diff --git a/src/components/transport_manager/src/cloud/websocket_client_connection.cc b/src/components/transport_manager/src/cloud/websocket_client_connection.cc index 05ab03ba29..1411f5f804 100644 --- a/src/components/transport_manager/src/cloud/websocket_client_connection.cc +++ b/src/components/transport_manager/src/cloud/websocket_client_connection.cc @@ -1,6 +1,6 @@ /* * - * Copyright (c) 2018, Livio + * Copyright (c) 2017, Ford Motor Company * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -49,7 +49,8 @@ WebsocketClientConnection::WebsocketClientConnection( : controller_(controller) , ctx_(ssl::context::sslv23_client) , resolver_(ioc_) - , ws_{ioc_, ctx_} + , ws_{ioc_} + , wss_{ioc_, ctx_} , shutdown_(false) , thread_delegate_(new LoopThreadDelegate(&message_queue_, this)) , write_thread_(threads::CreateThread("WS Async Send", thread_delegate_)) @@ -71,7 +72,7 @@ WebsocketClientConnection::~WebsocketClientConnection() { bool WebsocketClientConnection::AddCertificateAuthority(const std::string cert, boost::system::error_code& ec){ // if(cert == "not_specified"){ - // ws_.next_layer().set_verify_mode(ssl::verify_none); + // wss_.next_layer().set_verify_mode(ssl::verify_none); // return false; // } @@ -80,7 +81,7 @@ bool WebsocketClientConnection::AddCertificateAuthority(const std::string cert, return false; } - ws_.next_layer().set_verify_mode(ssl::verify_peer); + wss_.next_layer().set_verify_mode(ssl::verify_peer); if(ec){ return false; } @@ -93,7 +94,7 @@ TransportAdapter::Error WebsocketClientConnection::Start() { DeviceSptr device = controller_->FindDevice(device_uid_); CloudDevice* cloud_device = static_cast(device.get()); CloudWebsocketTransportAdapter* cloud_ta = static_cast(controller_); - CloudAppProperties cloud_properties = cloud_ta->GetAppCloudTransportConfig(device_uid_); + cloud_properties = cloud_ta->GetAppCloudTransportConfig(device_uid_); auto const host = cloud_device->GetHost(); auto const port = cloud_device->GetPort(); boost::system::error_code ec; @@ -116,8 +117,11 @@ TransportAdapter::Error WebsocketClientConnection::Start() { LOG4CXX_DEBUG(logger_, "CLOUD_CONN_RESOLVE"); // Make Connection to host IP Address over TCP - boost::asio::connect(ws_.next_layer().next_layer(), results.begin(), results.end(), ec); - + if(cloud_properties.cloud_transport_type == "WSS"){ + boost::asio::connect(wss_.next_layer().next_layer(), results.begin(), results.end(), ec); + }else{ + boost::asio::connect(ws_.next_layer(), results.begin(), results.end(), ec); + } if (ec) { std::string str_err = "ErrorMessage: " + ec.message(); LOG4CXX_ERROR(logger_, @@ -129,7 +133,7 @@ TransportAdapter::Error WebsocketClientConnection::Start() { LOG4CXX_DEBUG(logger_, "CLOUD_CONN_TCP"); - std::string cert = "-----BEGIN CERTIFICATE-----\nMIIDBjCCAe6gAwIBAgIJAOsbkrgCZxgtMA0GCSqGSIb3DQEBCwUAMBgxFjAUBgNV\nBAMMDTE5Mi4xNjguMS4xMjgwHhcNMTgxMTI4MTgxNjQwWhcNMjExMTI3MTgxNjQw\nWjAYMRYwFAYDVQQDDA0xOTIuMTY4LjEuMTI4MIIBIjANBgkqhkiG9w0BAQEFAAOC\nAQ8AMIIBCgKCAQEAlVrHDi+XdO9fNMcknqs2Hn0AQjKQZAq0juy8r7gDqkzHw9zY\nFnfssIUzP7R6F1/80ulyjwUN6G+SI7phbivr2gmSdfkYiJVdwBKf611srIrNF/Eh\nllt/2sjwZNyTai4pzZv9/svix5nIVCHdKZD6wsxCFOdNhVJGBd9uQ4Pk1hQoW/jj\nsUF/NBUa49k31/IQiqQ6T1xQvSkEUYd1kstS7utO2V0Z9rHH4/+4HNyPMKipkCi2\n/7WuvQGDyHTnNUFmEANn4X06iQAVon9L8IVRcGwtgsWJ0fuVGK5POtU4m37Q35MW\n3RWF3OzyP/6PxRX5ljQFmkwGkqzHrNzOZN+zMQIDAQABo1MwUTAdBgNVHQ4EFgQU\nc1BN7ZNXq+OA5hT+vq1NOMoUrR8wHwYDVR0jBBgwFoAUc1BN7ZNXq+OA5hT+vq1N\nOMoUrR8wDwYDVR0TAQH/BAUwAwEB/zANBgkqhkiG9w0BAQsFAAOCAQEANBnwEOwM\nRynBmaRBBVZBxcWsaWQ6h7XETLSU+Pqrv2cm+g8pS1pFwc69OS5ER730UcCADlLv\n7Lu61m9kOxHuDzeQR5ofkVbFx1swUqSZt7GZvopVtwFeto4zUfAyVfCS6n6MGSvN\nWlathEg3mlXlAjtX1qEg1JzJ5DjowiPpJ2FZMsakJrF3Ju0D0Dskg0wgqZLKcHYC\ndV7bm2SpC7kfqeuSXIC8hbfolJBaysFRjIXXWwDhtW2i4KRDq4b54EVON2af6RD7\nbsOiY4Qt4Aw5UOE+DN/dbkXXNHKDWN/VN1MI9wGJiriXf4BWSJWgrrsXHkpzqmMj\nrHR2ik90MT9pkQ==\n-----END CERTIFICATE-----"; + std::string cert = "-----BEGIN CERTIFICATE-----\nMIIDBjCCAe6gAwIBAgIJAOs bkrgCZxgtMA0GCSqGSIb3DQEBCwUAMBgxFjAUBgNV\nBAMMDTE5Mi4xNjguMS4xMjgwHhcNMTgxMTI4MTgxNjQwWhcNMjExMTI3MTgxNjQw\nWjAYMRYwFAYDVQQDDA0xOTIuMTY4LjEuMTI4MIIBIjANBgkqhkiG9w0BAQEFAAOC\nAQ8AMIIBCgKCAQEAlVrHDi+XdO9fNMcknqs2Hn0AQjKQZAq0juy8r7gDqkzHw9zY\nFnfssIUzP7R6F1/80ulyjwUN6G+SI7phbivr2gmSdfkYiJVdwBKf611srIrNF/Eh\nllt/2sjwZNyTai4pzZv9/svix5nIVCHdKZD6wsxCFOdNhVJGBd9uQ4Pk1hQoW/jj\nsUF/NBUa49k31/IQiqQ6T1xQvSkEUYd1kstS7utO2V0Z9rHH4/+4HNyPMKipkCi2\n/7WuvQGDyHTnNUFmEANn4X06iQAVon9L8IVRcGwtgsWJ0fuVGK5POtU4m37Q35MW\n3RWF3OzyP/6PxRX5ljQFmkwGkqzHrNzOZN+zMQIDAQABo1MwUTAdBgNVHQ4EFgQU\nc1BN7ZNXq+OA5hT+vq1NOMoUrR8wHwYDVR0jBBgwFoAUc1BN7ZNXq+OA5hT+vq1N\nOMoUrR8wDwYDVR0TAQH/BAUwAwEB/zANBgkqhkiG9w0BAQsFAAOCAQEANBnwEOwM\nRynBmaRBBVZBxcWsaWQ6h7XETLSU+Pqrv2cm+g8pS1pFwc69OS5ER730UcCADlLv\n7Lu61m9kOxHuDzeQR5ofkVbFx1swUqSZt7GZvopVtwFeto4zUfAyVfCS6n6MGSvN\nWlathEg3mlXlAjtX1qEg1JzJ5DjowiPpJ2FZMsakJrF3Ju0D0Dskg0wgqZLKcHYC\ndV7bm2SpC7kfqeuSXIC8hbfolJBaysFRjIXXWwDhtW2i4KRDq4b54EVON2af6RD7\nbsOiY4Qt4Aw5UOE+DN/dbkXXNHKDWN/VN1MI9wGJiriXf4BWSJWgrrsXHkpzqmMj\nrHR2ik90MT9pkQ==\n-----END CERTIFICATE-----"; std::string fake_cert = "-----BEGIN CERTIFICATE-----\nMIIDBjCCAe6gAwIBAgIJAOTd19xp9ISxMA0GCSqGSIb3DQEBCwUAMBgxFjAUBgNV\nBAMMDTE5Mi4xNjguMS4xMjgwHhcNMTgxMTI4MTM1NjI0WhcNMjExMTI3MTM1NjI0\nWjAYMRYwFAYDVQQDDA0xOTIuMTY4LjEuMTI4MIIBIjANBgkqhkiG9w0BAQEFAAOC\nAQ8AMIIBCgKCAQEAlVrHDi+XdO9fNMcknqs2Hn0AQjKQZAq0juy8r7gDqkzHw9zY\nFnfssIUzP7R6F1/80ulyjwUN6G+SI7phbivr2gmSdfkYiJVdwBKf611srIrNF/Eh\nllt/2sjwZNyTai4pzZv9/svix5nIVCHdKZD6wsxCFOdNhVJGBd9uQ4Pk1hQoW/jj\nsUF/NBUa49k31/IQiqQ6T1xQvSkEUYd1kstS7utO2V0Z9rHH4/+4HNyPMKipkCi2\n/7WuvQGDyHTnNUFmEANn4X06iQAVon9L8IVRcGwtgsWJ0fuVGK5POtU4m37Q35MW\n3RWF3OzyP/6PxRX5ljQFmkwGkqzHrNzOZN+zMQIDAQABo1MwUTAdBgNVHQ4EFgQU\nc1BN7ZNXq+OA5hT+vq1NOMoUrR8wHwYDVR0jBBgwFoAUc1BN7ZNXq+OA5hT+vq1N\nOMoUrR8wDwYDVR0TAQH/BAUwAwEB/zANBgkqhkiG9w0BAQsFAAOCAQEAUQ8MwCmb\nDrwCNGaUdGNXoiAWrltPE2buzpq8OCVxXBSqSumAe1SkjyKROBbevM7/Cl4V3qgj\nEHjUXNrzFR9WTCOOjJ9W0wiO25FDBguU5VCkuhvfL6lCgVuJRRi9LtiY2hT5fPdM\nrMvS0/iUV3RXcKNyIGOXH1OcOim+PVph2wj0x/N1Nmhqkh+2LtFHhsE/Zgygndla\nsbyRTNQ3bnzGUwMl8jPa7KSeggtfmjIFc4VXEgrOzKHhJO2C96FmVMo97QqKQvq+\nWjPfzHnI3hhr1GPPMHFQQZG5j4a708Qo9fZcKJxUvm0O7kdFFOqcMyo086cu1YUP\nGy5s8MqShPUp1Q==\n-----END CERTIFICATE-----"; std::string no_cert = "not_specified"; std::string invalid_cert = "-----BEGIN CERTIFICATE-----\nWjAYMRYwFAYDVQQDDA0xOTIuMTY4LjEuMTI4MIIBIjANBgkqhkiG9w0BAQEFAAOC\nAQ8AMIIBCgKCAQEAlVrHDi+XdO9fNMcknqs2Hn0AQjKQZAq0juy8r7gDqkzHw9zY\nFnfssIUzP7R6F1/80ulyjwUN6G+SI7phbivr2gmSdfkYiJVdwBKf611srIrNF/Eh\nllt/2sjwZNyTai4pzZv9/svix5nIVCHdKZD6wsxCFOdNhVJGBd9uQ4Pk1hQoW/jj\nsUF/NBUa49k31/IQiqQ6T1xQvSkEUYd1kstS7utO2V0Z9rHH4/+4HNyPMKipkCi2\n/7WuvQGDyHTnNUFmEANn4X06iQAVon9L8IVRcGwtgsWJ0fuVGK5POtU4m37Q35MW\n3RWF3OzyP/6PxRX5ljQFmkwGkqzHrNzOZN+zMQIDAQABo1MwUTAdBgNVHQ4EFgQU\nc1BN7ZNXq+OA5hT+vq1NOMoUrR8wHwYDVR0jBBgwFoAUc1BN7ZNXq+OA5hT+vq1N\nOMoUrR8wDwYDVR0TAQH/BAUwAwEB/zANBgkqhkiG9w0BAQsFAAOCAQEAUQ8MwCmb\nDrwCNGaUdGNXoiAWrltPE2buzpq8OCVxXBSqSumAe1SkjyKROBbevM7/Cl4V3qgj\nEHjUXNrzFR9WTCOOjJ9W0wiO25FDBguU5VCkuhvfL6lCgVuJRRi9LtiY2hT5fPdM\nrMvS0/iUV3RXcKNyIGOXH1OcOim+PVph2wj0x/N1Nmhqkh+2LtFHhsE/Zgygndla\nsbyRTNQ3bnzGUwMl8jPa7KSeggtfmjIFc4VXEgrOzKHhJO2C96FmVMo97QqKQvq+\nWjPfzHnI3hhr1GPPMHFQQZG5j4a708Qo9fZcKJxUvm0O7kdFFOqcMyo086cu1YUP\nGy5s8MqShPUp1Q==\n-----END CERTIFICATE-----"; @@ -152,26 +156,30 @@ TransportAdapter::Error WebsocketClientConnection::Start() { Shutdown(); return TransportAdapter::FAIL; } - } + + //Perform SSL Handshake + wss_.next_layer().handshake(ssl::stream_base::client, ec); - //Perform SSL Handshake - ws_.next_layer().handshake(ssl::stream_base::client, ec); + if (ec) { + std::string str_err = "ErrorMessage: " + ec.message(); + LOG4CXX_ERROR(logger_, + "Could not complete SSL Handshake failed with host/port: " << host << ":" + << port); + LOG4CXX_ERROR(logger_, str_err); + Shutdown(); + return TransportAdapter::FAIL; + } - if (ec) { - std::string str_err = "ErrorMessage: " + ec.message(); - LOG4CXX_ERROR(logger_, - "Could not complete SSL Handshake failed with host/port: " << host << ":" - << port); - LOG4CXX_ERROR(logger_, str_err); - Shutdown(); - return TransportAdapter::FAIL; + LOG4CXX_DEBUG(logger_, "CLOUD_CONN_SSL"); } - LOG4CXX_DEBUG(logger_, "CLOUD_CONN_SSL"); // Perform websocket handshake - ws_.handshake(host, "/", ec); - + if(cloud_properties.cloud_transport_type == "WSS"){ + wss_.handshake(host, "/", ec); + }else{ + ws_.handshake(host, "/", ec); + } if (ec) { std::string str_err = "ErrorMessage: " + ec.message(); LOG4CXX_ERROR(logger_, @@ -185,17 +193,28 @@ TransportAdapter::Error WebsocketClientConnection::Start() { LOG4CXX_DEBUG(logger_, "CLOUD_CONN_WEBSOCKET"); // Set the binary message write option - ws_.binary(true); + if(cloud_properties.cloud_transport_type == "WSS"){ + wss_.binary(true); + }else{ + ws_.binary(true); + } write_thread_->start(threads::ThreadOptions()); controller_->ConnectDone(device_uid_, app_handle_); // Start async read - ws_.async_read(buffer_, + if(cloud_properties.cloud_transport_type == "WSS"){ + wss_.async_read(buffer_, + std::bind(&WebsocketClientConnection::OnRead, + this, + std::placeholders::_1, + std::placeholders::_2)); + }else{ + ws_.async_read(buffer_, std::bind(&WebsocketClientConnection::OnRead, this, std::placeholders::_1, std::placeholders::_2)); - + } // Start IO Service thread. Allows for async reads without blocking. io_service_thread_ = std::thread([&]() { ioc_.run(); @@ -220,12 +239,20 @@ void WebsocketClientConnection::Recv(boost::system::error_code ec) { Shutdown(); return; } + if(cloud_properties.cloud_transport_type == "WSS"){ + wss_.async_read(buffer_, + std::bind(&WebsocketClientConnection::OnRead, + this, + std::placeholders::_1, + std::placeholders::_2)); + } else{ + ws_.async_read(buffer_, + std::bind(&WebsocketClientConnection::OnRead, + this, + std::placeholders::_1, + std::placeholders::_2)); - ws_.async_read(buffer_, - std::bind(&WebsocketClientConnection::OnRead, - this, - std::placeholders::_1, - std::placeholders::_2)); + } } void WebsocketClientConnection::OnRead(boost::system::error_code ec, @@ -309,8 +336,14 @@ void WebsocketClientConnection::LoopThreadDelegate::DrainQueue() { message_queue_.pop(message_ptr); if (!shutdown_) { boost::system::error_code ec; + if(handler_.cloud_properties.cloud_transport_type == "WSS"){ + handler_.wss_.write( + boost::asio::buffer(message_ptr->data(), message_ptr->data_size())); + }else{ handler_.ws_.write( boost::asio::buffer(message_ptr->data(), message_ptr->data_size())); + + } if (ec) { LOG4CXX_ERROR(logger_, "Error writing to websocket"); handler_.Shutdown(); -- cgit v1.2.1 From 71a6cd9873df44c244d9354a9cbe56badb16c45e Mon Sep 17 00:00:00 2001 From: ShobhitAd Date: Thu, 6 Dec 2018 22:49:06 -0500 Subject: Created dynamic websocket object with std::variant and shared ptrs --- .../cloud/websocket_client_connection.h | 8 +++- .../src/cloud/websocket_client_connection.cc | 50 ++++++++++------------ 2 files changed, 29 insertions(+), 29 deletions(-) diff --git a/src/components/transport_manager/include/transport_manager/cloud/websocket_client_connection.h b/src/components/transport_manager/include/transport_manager/cloud/websocket_client_connection.h index 4060955eca..64f55106a1 100644 --- a/src/components/transport_manager/include/transport_manager/cloud/websocket_client_connection.h +++ b/src/components/transport_manager/include/transport_manager/cloud/websocket_client_connection.h @@ -42,6 +42,7 @@ #include #include #include +#include #include #include #include @@ -62,6 +63,10 @@ using ::utils::MessageQueue; typedef std::queue AsyncQueue; typedef protocol_handler::RawMessagePtr Message; +typedef websocket::stream WS; +typedef websocket::stream> WSS; +typedef std::shared_ptr WSptr; +typedef std::shared_ptr WSSptr; namespace transport_manager { namespace transport_adapter { @@ -137,11 +142,10 @@ class WebsocketClientConnection boost::asio::io_context ioc_; ssl::context ctx_; tcp::resolver resolver_; - websocket::stream ws_; - websocket::stream> wss_; boost::beast::flat_buffer buffer_; std::string host_; std::string text_; + boost::variant dynamic_ws_; std::atomic_bool shutdown_; diff --git a/src/components/transport_manager/src/cloud/websocket_client_connection.cc b/src/components/transport_manager/src/cloud/websocket_client_connection.cc index 1411f5f804..e4b346654f 100644 --- a/src/components/transport_manager/src/cloud/websocket_client_connection.cc +++ b/src/components/transport_manager/src/cloud/websocket_client_connection.cc @@ -49,8 +49,6 @@ WebsocketClientConnection::WebsocketClientConnection( : controller_(controller) , ctx_(ssl::context::sslv23_client) , resolver_(ioc_) - , ws_{ioc_} - , wss_{ioc_, ctx_} , shutdown_(false) , thread_delegate_(new LoopThreadDelegate(&message_queue_, this)) , write_thread_(threads::CreateThread("WS Async Send", thread_delegate_)) @@ -71,17 +69,12 @@ WebsocketClientConnection::~WebsocketClientConnection() { } bool WebsocketClientConnection::AddCertificateAuthority(const std::string cert, boost::system::error_code& ec){ - // if(cert == "not_specified"){ - // wss_.next_layer().set_verify_mode(ssl::verify_none); - // return false; - // } - ctx_.add_certificate_authority(boost::asio::buffer(cert.data(), cert.size()), ec); if(ec){ return false; } - wss_.next_layer().set_verify_mode(ssl::verify_peer); + boost::get(dynamic_ws_)->next_layer().set_verify_mode(ssl::verify_peer); if(ec){ return false; } @@ -98,7 +91,6 @@ TransportAdapter::Error WebsocketClientConnection::Start() { auto const host = cloud_device->GetHost(); auto const port = cloud_device->GetPort(); boost::system::error_code ec; - auto const results = resolver_.resolve(host, port, ec); LOG4CXX_DEBUG(logger_, "CLOUD_CONN_START"); LOG4CXX_DEBUG(logger_, "ENDPOINT: " << cloud_properties.endpoint); @@ -107,6 +99,7 @@ TransportAdapter::Error WebsocketClientConnection::Start() { LOG4CXX_DEBUG(logger_, "TRANSPORT_TYPE: " << cloud_properties.cloud_transport_type); LOG4CXX_DEBUG(logger_, "HYBRID_APP_PREF: " << cloud_properties.hybrid_app_preference); + auto const results = resolver_.resolve(host, port, ec); if (ec) { std::string str_err = "ErrorMessage: " + ec.message(); LOG4CXX_ERROR(logger_, "Could not resolve host/port: " << str_err); @@ -116,11 +109,17 @@ TransportAdapter::Error WebsocketClientConnection::Start() { LOG4CXX_DEBUG(logger_, "CLOUD_CONN_RESOLVE"); + if(cloud_properties.cloud_transport_type == "WSS"){ + dynamic_ws_ = std::make_shared(ioc_, ctx_); + }else{ + dynamic_ws_ = std::make_shared(ioc_); + } + // Make Connection to host IP Address over TCP if(cloud_properties.cloud_transport_type == "WSS"){ - boost::asio::connect(wss_.next_layer().next_layer(), results.begin(), results.end(), ec); + boost::asio::connect(boost::get(dynamic_ws_)->next_layer().next_layer(), results.begin(), results.end(), ec); }else{ - boost::asio::connect(ws_.next_layer(), results.begin(), results.end(), ec); + boost::asio::connect(boost::get(dynamic_ws_)->next_layer(), results.begin(), results.end(), ec); } if (ec) { std::string str_err = "ErrorMessage: " + ec.message(); @@ -134,10 +133,6 @@ TransportAdapter::Error WebsocketClientConnection::Start() { LOG4CXX_DEBUG(logger_, "CLOUD_CONN_TCP"); std::string cert = "-----BEGIN CERTIFICATE-----\nMIIDBjCCAe6gAwIBAgIJAOs bkrgCZxgtMA0GCSqGSIb3DQEBCwUAMBgxFjAUBgNV\nBAMMDTE5Mi4xNjguMS4xMjgwHhcNMTgxMTI4MTgxNjQwWhcNMjExMTI3MTgxNjQw\nWjAYMRYwFAYDVQQDDA0xOTIuMTY4LjEuMTI4MIIBIjANBgkqhkiG9w0BAQEFAAOC\nAQ8AMIIBCgKCAQEAlVrHDi+XdO9fNMcknqs2Hn0AQjKQZAq0juy8r7gDqkzHw9zY\nFnfssIUzP7R6F1/80ulyjwUN6G+SI7phbivr2gmSdfkYiJVdwBKf611srIrNF/Eh\nllt/2sjwZNyTai4pzZv9/svix5nIVCHdKZD6wsxCFOdNhVJGBd9uQ4Pk1hQoW/jj\nsUF/NBUa49k31/IQiqQ6T1xQvSkEUYd1kstS7utO2V0Z9rHH4/+4HNyPMKipkCi2\n/7WuvQGDyHTnNUFmEANn4X06iQAVon9L8IVRcGwtgsWJ0fuVGK5POtU4m37Q35MW\n3RWF3OzyP/6PxRX5ljQFmkwGkqzHrNzOZN+zMQIDAQABo1MwUTAdBgNVHQ4EFgQU\nc1BN7ZNXq+OA5hT+vq1NOMoUrR8wHwYDVR0jBBgwFoAUc1BN7ZNXq+OA5hT+vq1N\nOMoUrR8wDwYDVR0TAQH/BAUwAwEB/zANBgkqhkiG9w0BAQsFAAOCAQEANBnwEOwM\nRynBmaRBBVZBxcWsaWQ6h7XETLSU+Pqrv2cm+g8pS1pFwc69OS5ER730UcCADlLv\n7Lu61m9kOxHuDzeQR5ofkVbFx1swUqSZt7GZvopVtwFeto4zUfAyVfCS6n6MGSvN\nWlathEg3mlXlAjtX1qEg1JzJ5DjowiPpJ2FZMsakJrF3Ju0D0Dskg0wgqZLKcHYC\ndV7bm2SpC7kfqeuSXIC8hbfolJBaysFRjIXXWwDhtW2i4KRDq4b54EVON2af6RD7\nbsOiY4Qt4Aw5UOE+DN/dbkXXNHKDWN/VN1MI9wGJiriXf4BWSJWgrrsXHkpzqmMj\nrHR2ik90MT9pkQ==\n-----END CERTIFICATE-----"; - std::string fake_cert = "-----BEGIN CERTIFICATE-----\nMIIDBjCCAe6gAwIBAgIJAOTd19xp9ISxMA0GCSqGSIb3DQEBCwUAMBgxFjAUBgNV\nBAMMDTE5Mi4xNjguMS4xMjgwHhcNMTgxMTI4MTM1NjI0WhcNMjExMTI3MTM1NjI0\nWjAYMRYwFAYDVQQDDA0xOTIuMTY4LjEuMTI4MIIBIjANBgkqhkiG9w0BAQEFAAOC\nAQ8AMIIBCgKCAQEAlVrHDi+XdO9fNMcknqs2Hn0AQjKQZAq0juy8r7gDqkzHw9zY\nFnfssIUzP7R6F1/80ulyjwUN6G+SI7phbivr2gmSdfkYiJVdwBKf611srIrNF/Eh\nllt/2sjwZNyTai4pzZv9/svix5nIVCHdKZD6wsxCFOdNhVJGBd9uQ4Pk1hQoW/jj\nsUF/NBUa49k31/IQiqQ6T1xQvSkEUYd1kstS7utO2V0Z9rHH4/+4HNyPMKipkCi2\n/7WuvQGDyHTnNUFmEANn4X06iQAVon9L8IVRcGwtgsWJ0fuVGK5POtU4m37Q35MW\n3RWF3OzyP/6PxRX5ljQFmkwGkqzHrNzOZN+zMQIDAQABo1MwUTAdBgNVHQ4EFgQU\nc1BN7ZNXq+OA5hT+vq1NOMoUrR8wHwYDVR0jBBgwFoAUc1BN7ZNXq+OA5hT+vq1N\nOMoUrR8wDwYDVR0TAQH/BAUwAwEB/zANBgkqhkiG9w0BAQsFAAOCAQEAUQ8MwCmb\nDrwCNGaUdGNXoiAWrltPE2buzpq8OCVxXBSqSumAe1SkjyKROBbevM7/Cl4V3qgj\nEHjUXNrzFR9WTCOOjJ9W0wiO25FDBguU5VCkuhvfL6lCgVuJRRi9LtiY2hT5fPdM\nrMvS0/iUV3RXcKNyIGOXH1OcOim+PVph2wj0x/N1Nmhqkh+2LtFHhsE/Zgygndla\nsbyRTNQ3bnzGUwMl8jPa7KSeggtfmjIFc4VXEgrOzKHhJO2C96FmVMo97QqKQvq+\nWjPfzHnI3hhr1GPPMHFQQZG5j4a708Qo9fZcKJxUvm0O7kdFFOqcMyo086cu1YUP\nGy5s8MqShPUp1Q==\n-----END CERTIFICATE-----"; - std::string no_cert = "not_specified"; - std::string invalid_cert = "-----BEGIN CERTIFICATE-----\nWjAYMRYwFAYDVQQDDA0xOTIuMTY4LjEuMTI4MIIBIjANBgkqhkiG9w0BAQEFAAOC\nAQ8AMIIBCgKCAQEAlVrHDi+XdO9fNMcknqs2Hn0AQjKQZAq0juy8r7gDqkzHw9zY\nFnfssIUzP7R6F1/80ulyjwUN6G+SI7phbivr2gmSdfkYiJVdwBKf611srIrNF/Eh\nllt/2sjwZNyTai4pzZv9/svix5nIVCHdKZD6wsxCFOdNhVJGBd9uQ4Pk1hQoW/jj\nsUF/NBUa49k31/IQiqQ6T1xQvSkEUYd1kstS7utO2V0Z9rHH4/+4HNyPMKipkCi2\n/7WuvQGDyHTnNUFmEANn4X06iQAVon9L8IVRcGwtgsWJ0fuVGK5POtU4m37Q35MW\n3RWF3OzyP/6PxRX5ljQFmkwGkqzHrNzOZN+zMQIDAQABo1MwUTAdBgNVHQ4EFgQU\nc1BN7ZNXq+OA5hT+vq1NOMoUrR8wHwYDVR0jBBgwFoAUc1BN7ZNXq+OA5hT+vq1N\nOMoUrR8wDwYDVR0TAQH/BAUwAwEB/zANBgkqhkiG9w0BAQsFAAOCAQEAUQ8MwCmb\nDrwCNGaUdGNXoiAWrltPE2buzpq8OCVxXBSqSumAe1SkjyKROBbevM7/Cl4V3qgj\nEHjUXNrzFR9WTCOOjJ9W0wiO25FDBguU5VCkuhvfL6lCgVuJRRi9LtiY2hT5fPdM\nrMvS0/iUV3RXcKNyIGOXH1OcOim+PVph2wj0x/N1Nmhqkh+2LtFHhsE/Zgygndla\nsbyRTNQ3bnzGUwMl8jPa7KSeggtfmjIFc4VXEgrOzKHhJO2C96FmVMo97QqKQvq+\nWjPfzHnI3hhr1GPPMHFQQZG5j4a708Qo9fZcKJxUvm0O7kdFFOqcMyo086cu1YUP\nGy5s8MqShPUp1Q==\n-----END CERTIFICATE-----"; - std::string test_cert = ""; if(cloud_properties.cloud_transport_type == "WSS"){ bool isAdded = AddCertificateAuthority(cert, ec); @@ -151,14 +146,14 @@ TransportAdapter::Error WebsocketClientConnection::Start() { if(ec){ std::string str_err = "ErrorMessage: " + ec.message(); LOG4CXX_ERROR(logger_, - "Failed to add certificate authority: " << invalid_cert); + "Failed to add certificate authority: " << cloud_properties.certificate); LOG4CXX_ERROR(logger_, str_err); Shutdown(); return TransportAdapter::FAIL; } //Perform SSL Handshake - wss_.next_layer().handshake(ssl::stream_base::client, ec); + boost::get(dynamic_ws_)->next_layer().handshake(ssl::stream_base::client, ec); if (ec) { std::string str_err = "ErrorMessage: " + ec.message(); @@ -176,9 +171,9 @@ TransportAdapter::Error WebsocketClientConnection::Start() { // Perform websocket handshake if(cloud_properties.cloud_transport_type == "WSS"){ - wss_.handshake(host, "/", ec); + boost::get(dynamic_ws_)->handshake(host, "/", ec); }else{ - ws_.handshake(host, "/", ec); + boost::get(dynamic_ws_)->handshake(host, "/", ec); } if (ec) { std::string str_err = "ErrorMessage: " + ec.message(); @@ -194,22 +189,22 @@ TransportAdapter::Error WebsocketClientConnection::Start() { // Set the binary message write option if(cloud_properties.cloud_transport_type == "WSS"){ - wss_.binary(true); + boost::get(dynamic_ws_)->binary(true); }else{ - ws_.binary(true); + boost::get(dynamic_ws_)->binary(true); } write_thread_->start(threads::ThreadOptions()); controller_->ConnectDone(device_uid_, app_handle_); // Start async read if(cloud_properties.cloud_transport_type == "WSS"){ - wss_.async_read(buffer_, + boost::get(dynamic_ws_)->async_read(buffer_, std::bind(&WebsocketClientConnection::OnRead, this, std::placeholders::_1, std::placeholders::_2)); }else{ - ws_.async_read(buffer_, + boost::get(dynamic_ws_)->async_read(buffer_, std::bind(&WebsocketClientConnection::OnRead, this, std::placeholders::_1, @@ -240,13 +235,13 @@ void WebsocketClientConnection::Recv(boost::system::error_code ec) { return; } if(cloud_properties.cloud_transport_type == "WSS"){ - wss_.async_read(buffer_, + boost::get(dynamic_ws_)->async_read(buffer_, std::bind(&WebsocketClientConnection::OnRead, this, std::placeholders::_1, std::placeholders::_2)); } else{ - ws_.async_read(buffer_, + boost::get(dynamic_ws_)->async_read(buffer_, std::bind(&WebsocketClientConnection::OnRead, this, std::placeholders::_1, @@ -337,10 +332,11 @@ void WebsocketClientConnection::LoopThreadDelegate::DrainQueue() { if (!shutdown_) { boost::system::error_code ec; if(handler_.cloud_properties.cloud_transport_type == "WSS"){ - handler_.wss_.write( + + boost::get(handler_.dynamic_ws_)->write( boost::asio::buffer(message_ptr->data(), message_ptr->data_size())); }else{ - handler_.ws_.write( + boost::get(handler_.dynamic_ws_)->write( boost::asio::buffer(message_ptr->data(), message_ptr->data_size())); } -- cgit v1.2.1 From b1ff805f9956b8c4da3c97368ab4ebbf3579c1a6 Mon Sep 17 00:00:00 2001 From: ShobhitAd Date: Fri, 7 Dec 2018 14:30:14 -0500 Subject: Use certificate from policy table --- .../transport_manager/src/cloud/websocket_client_connection.cc | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/components/transport_manager/src/cloud/websocket_client_connection.cc b/src/components/transport_manager/src/cloud/websocket_client_connection.cc index e4b346654f..5916cb39d8 100644 --- a/src/components/transport_manager/src/cloud/websocket_client_connection.cc +++ b/src/components/transport_manager/src/cloud/websocket_client_connection.cc @@ -132,10 +132,8 @@ TransportAdapter::Error WebsocketClientConnection::Start() { LOG4CXX_DEBUG(logger_, "CLOUD_CONN_TCP"); - std::string cert = "-----BEGIN CERTIFICATE-----\nMIIDBjCCAe6gAwIBAgIJAOs bkrgCZxgtMA0GCSqGSIb3DQEBCwUAMBgxFjAUBgNV\nBAMMDTE5Mi4xNjguMS4xMjgwHhcNMTgxMTI4MTgxNjQwWhcNMjExMTI3MTgxNjQw\nWjAYMRYwFAYDVQQDDA0xOTIuMTY4LjEuMTI4MIIBIjANBgkqhkiG9w0BAQEFAAOC\nAQ8AMIIBCgKCAQEAlVrHDi+XdO9fNMcknqs2Hn0AQjKQZAq0juy8r7gDqkzHw9zY\nFnfssIUzP7R6F1/80ulyjwUN6G+SI7phbivr2gmSdfkYiJVdwBKf611srIrNF/Eh\nllt/2sjwZNyTai4pzZv9/svix5nIVCHdKZD6wsxCFOdNhVJGBd9uQ4Pk1hQoW/jj\nsUF/NBUa49k31/IQiqQ6T1xQvSkEUYd1kstS7utO2V0Z9rHH4/+4HNyPMKipkCi2\n/7WuvQGDyHTnNUFmEANn4X06iQAVon9L8IVRcGwtgsWJ0fuVGK5POtU4m37Q35MW\n3RWF3OzyP/6PxRX5ljQFmkwGkqzHrNzOZN+zMQIDAQABo1MwUTAdBgNVHQ4EFgQU\nc1BN7ZNXq+OA5hT+vq1NOMoUrR8wHwYDVR0jBBgwFoAUc1BN7ZNXq+OA5hT+vq1N\nOMoUrR8wDwYDVR0TAQH/BAUwAwEB/zANBgkqhkiG9w0BAQsFAAOCAQEANBnwEOwM\nRynBmaRBBVZBxcWsaWQ6h7XETLSU+Pqrv2cm+g8pS1pFwc69OS5ER730UcCADlLv\n7Lu61m9kOxHuDzeQR5ofkVbFx1swUqSZt7GZvopVtwFeto4zUfAyVfCS6n6MGSvN\nWlathEg3mlXlAjtX1qEg1JzJ5DjowiPpJ2FZMsakJrF3Ju0D0Dskg0wgqZLKcHYC\ndV7bm2SpC7kfqeuSXIC8hbfolJBaysFRjIXXWwDhtW2i4KRDq4b54EVON2af6RD7\nbsOiY4Qt4Aw5UOE+DN/dbkXXNHKDWN/VN1MI9wGJiriXf4BWSJWgrrsXHkpzqmMj\nrHR2ik90MT9pkQ==\n-----END CERTIFICATE-----"; - if(cloud_properties.cloud_transport_type == "WSS"){ - bool isAdded = AddCertificateAuthority(cert, ec); + bool isAdded = AddCertificateAuthority(cloud_properties.certificate, ec); if(isAdded){ LOG4CXX_INFO(logger_, "Certificate Authority added successfully"); -- cgit v1.2.1 From 74833b87441c0ae351a226a978907a834f737ca9 Mon Sep 17 00:00:00 2001 From: ShobhitAd Date: Fri, 7 Dec 2018 15:06:59 -0500 Subject: Remove debug statements and style fix --- .../src/application_manager_impl.cc | 18 +-- .../connection_handler/connection_handler_impl.h | 6 +- .../src/connection_handler_impl.cc | 14 +- .../connection_handler/connection_handler.h | 6 +- .../include/transport_manager/transport_manager.h | 4 +- .../cloud/cloud_websocket_transport_adapter.h | 6 +- .../cloud/websocket_client_connection.h | 4 +- .../transport_manager/transport_manager_impl.h | 4 +- .../src/cloud/cloud_websocket_transport_adapter.cc | 23 +-- .../src/cloud/websocket_client_connection.cc | 167 +++++++++++---------- .../src/transport_manager_impl.cc | 23 ++- 11 files changed, 135 insertions(+), 140 deletions(-) diff --git a/src/components/application_manager/src/application_manager_impl.cc b/src/components/application_manager/src/application_manager_impl.cc index 44d9a4f903..b08a7c3428 100644 --- a/src/components/application_manager/src/application_manager_impl.cc +++ b/src/components/application_manager/src/application_manager_impl.cc @@ -808,7 +808,6 @@ void ApplicationManagerImpl::OnHMIStartedCooperation() { void ApplicationManagerImpl::CollectCloudAppInformation() { LOG4CXX_AUTO_TRACE(logger_); - LOG4CXX_DEBUG(logger_, "CLOUD_DEBUG_COLLECTCLOUDAPPINFO"); std::vector cloud_app_id_vector; GetPolicyHandler().GetEnabledCloudApps(cloud_app_id_vector); std::vector::iterator it = cloud_app_id_vector.begin(); @@ -831,16 +830,13 @@ void ApplicationManagerImpl::CollectCloudAppInformation() { pending_device_map_.insert( std::pair(endpoint, *it)); - transport_manager::transport_adapter::CloudAppProperties properties - {endpoint, certificate, enabled, auth_token, cloud_transport_type, hybrid_app_preference}; - LOG4CXX_DEBUG(logger_, "CLOUD_APP_MGR: " << endpoint); - LOG4CXX_DEBUG(logger_, "ENDPOINT: " << properties.endpoint); - LOG4CXX_DEBUG(logger_, "ENABLED: " << properties.enabled); - LOG4CXX_DEBUG(logger_, "CERTIFICATE: " << properties.certificate); - LOG4CXX_DEBUG(logger_, "AUTH_TOKEN: " << properties.auth_token); - LOG4CXX_DEBUG(logger_, "TRANSPORT_TYPE: " << properties.cloud_transport_type); - LOG4CXX_DEBUG(logger_, "HYBRID: " << properties.hybrid_app_preference); - + transport_manager::transport_adapter::CloudAppProperties properties{ + endpoint, + certificate, + enabled, + auth_token, + cloud_transport_type, + hybrid_app_preference}; connection_handler().AddCloudAppDevice(*it, properties); } } diff --git a/src/components/connection_handler/include/connection_handler/connection_handler_impl.h b/src/components/connection_handler/include/connection_handler/connection_handler_impl.h index 5819b32f03..2f175f8acc 100644 --- a/src/components/connection_handler/include/connection_handler/connection_handler_impl.h +++ b/src/components/connection_handler/include/connection_handler/connection_handler_impl.h @@ -130,8 +130,10 @@ class ConnectionHandlerImpl void ConnectToAllDevices() OVERRIDE; - void AddCloudAppDevice(const std::string& policy_app_id, - const transport_manager::transport_adapter::CloudAppProperties cloud_properties) OVERRIDE; + void AddCloudAppDevice( + const std::string& policy_app_id, + const transport_manager::transport_adapter::CloudAppProperties + cloud_properties) OVERRIDE; void StartTransportManager() OVERRIDE; diff --git a/src/components/connection_handler/src/connection_handler_impl.cc b/src/components/connection_handler/src/connection_handler_impl.cc index 55134ebf5b..6f24ae226d 100644 --- a/src/components/connection_handler/src/connection_handler_impl.cc +++ b/src/components/connection_handler/src/connection_handler_impl.cc @@ -1323,16 +1323,10 @@ void ConnectionHandlerImpl::ConnectToAllDevices() { } } -void ConnectionHandlerImpl::AddCloudAppDevice(const std::string& policy_app_id, - const transport_manager::transport_adapter::CloudAppProperties cloud_properties) { - // LOG4CXX_DEBUG(logger_, "CLOUD_DEBUG_ADDCLOUDAPPDEVICE: " << cloud_properties.endpoint); - // LOG4CXX_DEBUG(logger_, "ENDPOINT: " << cloud_properties.endpoint); - // LOG4CXX_DEBUG(logger_, "ENABLED: " << cloud_properties.enabled); - // LOG4CXX_DEBUG(logger_, "CERTIFICATE: " << cloud_properties.certificate); - // LOG4CXX_DEBUG(logger_, "AUTH_TOKEN: " << cloud_properties.auth_token); - // LOG4CXX_DEBUG(logger_, "TRANSPORT_TYPE: " << cloud_properties.cloud_transport_type); - // LOG4CXX_DEBUG(logger_, "HYBRID: " << cloud_properties.hybrid_app_preference); - +void ConnectionHandlerImpl::AddCloudAppDevice( + const std::string& policy_app_id, + const transport_manager::transport_adapter::CloudAppProperties + cloud_properties) { transport_manager_.AddCloudDevice(cloud_properties); } diff --git a/src/components/include/connection_handler/connection_handler.h b/src/components/include/connection_handler/connection_handler.h index 81dd24447c..f6bf8aeeb5 100644 --- a/src/components/include/connection_handler/connection_handler.h +++ b/src/components/include/connection_handler/connection_handler.h @@ -103,8 +103,10 @@ class ConnectionHandler { virtual void ConnectToAllDevices() = 0; - virtual void AddCloudAppDevice(const std::string& policy_app_id, - const transport_manager::transport_adapter::CloudAppProperties cloud_properties ) = 0; + virtual void AddCloudAppDevice( + const std::string& policy_app_id, + const transport_manager::transport_adapter::CloudAppProperties + cloud_properties) = 0; /** * @brief Close the connection revoked by Policy diff --git a/src/components/include/transport_manager/transport_manager.h b/src/components/include/transport_manager/transport_manager.h index fe5b708dd1..3ee6da653e 100644 --- a/src/components/include/transport_manager/transport_manager.h +++ b/src/components/include/transport_manager/transport_manager.h @@ -75,7 +75,9 @@ class TransportManager { **/ virtual int SearchDevices() = 0; - virtual void AddCloudDevice(const transport_manager::transport_adapter::CloudAppProperties cloud_properties) = 0; + virtual void AddCloudDevice( + const transport_manager::transport_adapter::CloudAppProperties + cloud_properties) = 0; /** * @brief Connect to all applications discovered on device. diff --git a/src/components/transport_manager/include/transport_manager/cloud/cloud_websocket_transport_adapter.h b/src/components/transport_manager/include/transport_manager/cloud/cloud_websocket_transport_adapter.h index 4270afd25f..138f9ca895 100644 --- a/src/components/transport_manager/include/transport_manager/cloud/cloud_websocket_transport_adapter.h +++ b/src/components/transport_manager/include/transport_manager/cloud/cloud_websocket_transport_adapter.h @@ -64,7 +64,8 @@ class CloudWebsocketTransportAdapter : public TransportAdapterImpl { * @param app_id app ID string * @param properties New cloud app properties for the app */ - void SetAppCloudTransportConfig(std::string app_id, CloudAppProperties properties); + void SetAppCloudTransportConfig(std::string app_id, + CloudAppProperties properties); /** * @brief Get CloudTransportConfig for specified app_id @@ -74,7 +75,6 @@ class CloudWebsocketTransportAdapter : public TransportAdapterImpl { */ const CloudAppProperties& GetAppCloudTransportConfig(std::string app_id); - protected: /** * @brief Return type of device. @@ -98,7 +98,7 @@ class CloudWebsocketTransportAdapter : public TransportAdapterImpl { void CreateDevice(const std::string& uid) OVERRIDE; private: - CloudAppTransportConfig transport_config_; + CloudAppTransportConfig transport_config_; }; } // namespace transport_adapter diff --git a/src/components/transport_manager/include/transport_manager/cloud/websocket_client_connection.h b/src/components/transport_manager/include/transport_manager/cloud/websocket_client_connection.h index 64f55106a1..adbe17112c 100644 --- a/src/components/transport_manager/include/transport_manager/cloud/websocket_client_connection.h +++ b/src/components/transport_manager/include/transport_manager/cloud/websocket_client_connection.h @@ -64,7 +64,7 @@ using ::utils::MessageQueue; typedef std::queue AsyncQueue; typedef protocol_handler::RawMessagePtr Message; typedef websocket::stream WS; -typedef websocket::stream> WSS; +typedef websocket::stream > WSS; typedef std::shared_ptr WSptr; typedef std::shared_ptr WSSptr; @@ -125,7 +125,7 @@ class WebsocketClientConnection /** * @brief Attempt to add provided certificate to the ssl::context - * + * * @param cert Certificate string from policy table * @return true if certificate was not invalid and was added successfully */ diff --git a/src/components/transport_manager/include/transport_manager/transport_manager_impl.h b/src/components/transport_manager/include/transport_manager/transport_manager_impl.h index 8419f90398..2688ee7c19 100644 --- a/src/components/transport_manager/include/transport_manager/transport_manager_impl.h +++ b/src/components/transport_manager/include/transport_manager/transport_manager_impl.h @@ -139,7 +139,9 @@ class TransportManagerImpl **/ int SearchDevices() OVERRIDE; - void AddCloudDevice(const transport_manager::transport_adapter::CloudAppProperties cloud_properties) OVERRIDE; + void AddCloudDevice( + const transport_manager::transport_adapter::CloudAppProperties + cloud_properties) OVERRIDE; /** * @brief Connect to all applications discovered on device. diff --git a/src/components/transport_manager/src/cloud/cloud_websocket_transport_adapter.cc b/src/components/transport_manager/src/cloud/cloud_websocket_transport_adapter.cc index 68f6ed0a90..8f2563a142 100644 --- a/src/components/transport_manager/src/cloud/cloud_websocket_transport_adapter.cc +++ b/src/components/transport_manager/src/cloud/cloud_websocket_transport_adapter.cc @@ -53,18 +53,13 @@ CloudWebsocketTransportAdapter::CloudWebsocketTransportAdapter( CloudWebsocketTransportAdapter::~CloudWebsocketTransportAdapter() {} -void CloudWebsocketTransportAdapter::SetAppCloudTransportConfig(std::string app_id, CloudAppProperties properties) { +void CloudWebsocketTransportAdapter::SetAppCloudTransportConfig( + std::string app_id, CloudAppProperties properties) { transport_config_[app_id] = properties; - // LOG4CXX_DEBUG(logger_, "CLOUD_TRANS_ADP: " << app_id); - // LOG4CXX_DEBUG(logger_, "ENDPOINT: " << transport_config_[app_id].endpoint); - // LOG4CXX_DEBUG(logger_, "ENABLED: " << transport_config_[app_id].enabled); - // LOG4CXX_DEBUG(logger_, "CERTIFICATE: " << transport_config_[app_id].certificate); - // LOG4CXX_DEBUG(logger_, "AUTH_TOKEN: " << transport_config_[app_id].auth_token); - // LOG4CXX_DEBUG(logger_, "TRANSPORT_TYPE: " << transport_config_[app_id].cloud_transport_type); - // LOG4CXX_DEBUG(logger_, "HYBRID: " << transport_config_[app_id].hybrid_app_preference); } -const CloudAppProperties& CloudWebsocketTransportAdapter::GetAppCloudTransportConfig(std::string app_id){ +const CloudAppProperties& +CloudWebsocketTransportAdapter::GetAppCloudTransportConfig(std::string app_id) { return transport_config_[app_id]; } @@ -79,7 +74,6 @@ bool CloudWebsocketTransportAdapter::Restore() { } void CloudWebsocketTransportAdapter::CreateDevice(const std::string& uid) { - LOG4CXX_DEBUG(logger_, "CLOUD_DEBUG_CreateDevice: " << uid); boost::regex pattern( "(wss?):\\/\\/([A-Z\\d\\.-]{2,})\\.?([A-Z]{2,})?(:\\d{2,4})\\/", boost::regex::icase); @@ -89,8 +83,6 @@ void CloudWebsocketTransportAdapter::CreateDevice(const std::string& uid) { return; } - LOG4CXX_DEBUG(logger_, "CLOUD_DEBUG_RegexMatchPassed"); - LOG4CXX_DEBUG(logger_, "Valid Endpoint: " << uid); // Port after second colon in valid endpoint string @@ -117,8 +109,6 @@ void CloudWebsocketTransportAdapter::CreateDevice(const std::string& uid) { return; } - LOG4CXX_DEBUG(logger_, "CLOUD_DEBUG_RegexSearchPassed"); - std::string device_id = uid; LOG4CXX_DEBUG(logger_, @@ -127,9 +117,6 @@ void CloudWebsocketTransportAdapter::CreateDevice(const std::string& uid) { auto cloud_device = std::make_shared(host, port, device_id); - LOG4CXX_DEBUG(logger_, "CLOUD_DEBUG_CreatedCloudDevice: " << host << ", " << port << ", " << device_id); - - DeviceVector devices{cloud_device}; SearchDeviceDone(devices); @@ -138,8 +125,6 @@ void CloudWebsocketTransportAdapter::CreateDevice(const std::string& uid) { std::shared_ptr connection = std::make_shared(uid, 0, this); - LOG4CXX_DEBUG(logger_, "CLOUD_DEBUG_CreatedConnection"); - ConnectionCreated(connection, uid, 0); ConnectPending(uid, 0); diff --git a/src/components/transport_manager/src/cloud/websocket_client_connection.cc b/src/components/transport_manager/src/cloud/websocket_client_connection.cc index 5916cb39d8..e6da3e9b6c 100644 --- a/src/components/transport_manager/src/cloud/websocket_client_connection.cc +++ b/src/components/transport_manager/src/cloud/websocket_client_connection.cc @@ -54,12 +54,8 @@ WebsocketClientConnection::WebsocketClientConnection( , write_thread_(threads::CreateThread("WS Async Send", thread_delegate_)) , device_uid_(device_uid) , app_handle_(app_handle) { - - LOG4CXX_DEBUG(logger_, "CLOUD_DEBUG_WEBSOCKETCLIENTCONNECTION"); - - } - - + LOG4CXX_DEBUG(logger_, "CLOUD_DEBUG_WEBSOCKETCLIENTCONNECTION"); +} WebsocketClientConnection::~WebsocketClientConnection() { ioc_.stop(); @@ -68,14 +64,18 @@ WebsocketClientConnection::~WebsocketClientConnection() { } } -bool WebsocketClientConnection::AddCertificateAuthority(const std::string cert, boost::system::error_code& ec){ - ctx_.add_certificate_authority(boost::asio::buffer(cert.data(), cert.size()), ec); - if(ec){ +bool WebsocketClientConnection::AddCertificateAuthority( + const std::string cert, boost::system::error_code& ec) { + ctx_.add_certificate_authority(boost::asio::buffer(cert.data(), cert.size()), + ec); + if (ec) { return false; } - boost::get(dynamic_ws_)->next_layer().set_verify_mode(ssl::verify_peer); - if(ec){ + boost::get(dynamic_ws_) + ->next_layer() + .set_verify_mode(ssl::verify_peer); + if (ec) { return false; } @@ -86,18 +86,21 @@ TransportAdapter::Error WebsocketClientConnection::Start() { LOG4CXX_AUTO_TRACE(logger_); DeviceSptr device = controller_->FindDevice(device_uid_); CloudDevice* cloud_device = static_cast(device.get()); - CloudWebsocketTransportAdapter* cloud_ta = static_cast(controller_); + CloudWebsocketTransportAdapter* cloud_ta = + static_cast(controller_); cloud_properties = cloud_ta->GetAppCloudTransportConfig(device_uid_); auto const host = cloud_device->GetHost(); auto const port = cloud_device->GetPort(); boost::system::error_code ec; - LOG4CXX_DEBUG(logger_, "CLOUD_CONN_START"); + LOG4CXX_DEBUG(logger_, "CLOUD_CONN_START"); LOG4CXX_DEBUG(logger_, "ENDPOINT: " << cloud_properties.endpoint); LOG4CXX_DEBUG(logger_, "CERTIFICATE: " << cloud_properties.certificate); LOG4CXX_DEBUG(logger_, "AUTH_TOKEN: " << cloud_properties.auth_token); - LOG4CXX_DEBUG(logger_, "TRANSPORT_TYPE: " << cloud_properties.cloud_transport_type); - LOG4CXX_DEBUG(logger_, "HYBRID_APP_PREF: " << cloud_properties.hybrid_app_preference); + LOG4CXX_DEBUG(logger_, + "TRANSPORT_TYPE: " << cloud_properties.cloud_transport_type); + LOG4CXX_DEBUG(logger_, + "HYBRID_APP_PREF: " << cloud_properties.hybrid_app_preference); auto const results = resolver_.resolve(host, port, ec); if (ec) { @@ -107,19 +110,26 @@ TransportAdapter::Error WebsocketClientConnection::Start() { return TransportAdapter::FAIL; } - LOG4CXX_DEBUG(logger_, "CLOUD_CONN_RESOLVE"); + LOG4CXX_DEBUG(logger_, "CLOUD_CONN_RESOLVE"); - if(cloud_properties.cloud_transport_type == "WSS"){ + if (cloud_properties.cloud_transport_type == "WSS") { dynamic_ws_ = std::make_shared(ioc_, ctx_); - }else{ + } else { dynamic_ws_ = std::make_shared(ioc_); } // Make Connection to host IP Address over TCP - if(cloud_properties.cloud_transport_type == "WSS"){ - boost::asio::connect(boost::get(dynamic_ws_)->next_layer().next_layer(), results.begin(), results.end(), ec); - }else{ - boost::asio::connect(boost::get(dynamic_ws_)->next_layer(), results.begin(), results.end(), ec); + if (cloud_properties.cloud_transport_type == "WSS") { + boost::asio::connect( + boost::get(dynamic_ws_)->next_layer().next_layer(), + results.begin(), + results.end(), + ec); + } else { + boost::asio::connect(boost::get(dynamic_ws_)->next_layer(), + results.begin(), + results.end(), + ec); } if (ec) { std::string str_err = "ErrorMessage: " + ec.message(); @@ -130,47 +140,49 @@ TransportAdapter::Error WebsocketClientConnection::Start() { return TransportAdapter::FAIL; } - LOG4CXX_DEBUG(logger_, "CLOUD_CONN_TCP"); - - if(cloud_properties.cloud_transport_type == "WSS"){ + LOG4CXX_DEBUG(logger_, "CLOUD_CONN_TCP"); + + if (cloud_properties.cloud_transport_type == "WSS") { bool isAdded = AddCertificateAuthority(cloud_properties.certificate, ec); - if(isAdded){ + if (isAdded) { LOG4CXX_INFO(logger_, "Certificate Authority added successfully"); - }else{ + } else { LOG4CXX_INFO(logger_, "Failed to add certificate authority"); } - if(ec){ + if (ec) { std::string str_err = "ErrorMessage: " + ec.message(); LOG4CXX_ERROR(logger_, - "Failed to add certificate authority: " << cloud_properties.certificate); + "Failed to add certificate authority: " + << cloud_properties.certificate); LOG4CXX_ERROR(logger_, str_err); Shutdown(); return TransportAdapter::FAIL; } - - //Perform SSL Handshake - boost::get(dynamic_ws_)->next_layer().handshake(ssl::stream_base::client, ec); + + // Perform SSL Handshake + boost::get(dynamic_ws_) + ->next_layer() + .handshake(ssl::stream_base::client, ec); if (ec) { std::string str_err = "ErrorMessage: " + ec.message(); LOG4CXX_ERROR(logger_, - "Could not complete SSL Handshake failed with host/port: " << host << ":" - << port); + "Could not complete SSL Handshake failed with host/port: " + << host << ":" << port); LOG4CXX_ERROR(logger_, str_err); Shutdown(); return TransportAdapter::FAIL; } - LOG4CXX_DEBUG(logger_, "CLOUD_CONN_SSL"); + LOG4CXX_DEBUG(logger_, "CLOUD_CONN_SSL"); } - // Perform websocket handshake - if(cloud_properties.cloud_transport_type == "WSS"){ + if (cloud_properties.cloud_transport_type == "WSS") { boost::get(dynamic_ws_)->handshake(host, "/", ec); - }else{ + } else { boost::get(dynamic_ws_)->handshake(host, "/", ec); } if (ec) { @@ -183,30 +195,32 @@ TransportAdapter::Error WebsocketClientConnection::Start() { return TransportAdapter::FAIL; } - LOG4CXX_DEBUG(logger_, "CLOUD_CONN_WEBSOCKET"); - + LOG4CXX_DEBUG(logger_, "CLOUD_CONN_WEBSOCKET"); + // Set the binary message write option - if(cloud_properties.cloud_transport_type == "WSS"){ + if (cloud_properties.cloud_transport_type == "WSS") { boost::get(dynamic_ws_)->binary(true); - }else{ + } else { boost::get(dynamic_ws_)->binary(true); } write_thread_->start(threads::ThreadOptions()); controller_->ConnectDone(device_uid_, app_handle_); // Start async read - if(cloud_properties.cloud_transport_type == "WSS"){ - boost::get(dynamic_ws_)->async_read(buffer_, - std::bind(&WebsocketClientConnection::OnRead, - this, - std::placeholders::_1, - std::placeholders::_2)); - }else{ - boost::get(dynamic_ws_)->async_read(buffer_, - std::bind(&WebsocketClientConnection::OnRead, - this, - std::placeholders::_1, - std::placeholders::_2)); + if (cloud_properties.cloud_transport_type == "WSS") { + boost::get(dynamic_ws_) + ->async_read(buffer_, + std::bind(&WebsocketClientConnection::OnRead, + this, + std::placeholders::_1, + std::placeholders::_2)); + } else { + boost::get(dynamic_ws_) + ->async_read(buffer_, + std::bind(&WebsocketClientConnection::OnRead, + this, + std::placeholders::_1, + std::placeholders::_2)); } // Start IO Service thread. Allows for async reads without blocking. io_service_thread_ = std::thread([&]() { @@ -232,19 +246,20 @@ void WebsocketClientConnection::Recv(boost::system::error_code ec) { Shutdown(); return; } - if(cloud_properties.cloud_transport_type == "WSS"){ - boost::get(dynamic_ws_)->async_read(buffer_, - std::bind(&WebsocketClientConnection::OnRead, - this, - std::placeholders::_1, - std::placeholders::_2)); - } else{ - boost::get(dynamic_ws_)->async_read(buffer_, - std::bind(&WebsocketClientConnection::OnRead, - this, - std::placeholders::_1, - std::placeholders::_2)); - + if (cloud_properties.cloud_transport_type == "WSS") { + boost::get(dynamic_ws_) + ->async_read(buffer_, + std::bind(&WebsocketClientConnection::OnRead, + this, + std::placeholders::_1, + std::placeholders::_2)); + } else { + boost::get(dynamic_ws_) + ->async_read(buffer_, + std::bind(&WebsocketClientConnection::OnRead, + this, + std::placeholders::_1, + std::placeholders::_2)); } } @@ -329,15 +344,15 @@ void WebsocketClientConnection::LoopThreadDelegate::DrainQueue() { message_queue_.pop(message_ptr); if (!shutdown_) { boost::system::error_code ec; - if(handler_.cloud_properties.cloud_transport_type == "WSS"){ - - boost::get(handler_.dynamic_ws_)->write( - boost::asio::buffer(message_ptr->data(), message_ptr->data_size())); - }else{ - boost::get(handler_.dynamic_ws_)->write( - boost::asio::buffer(message_ptr->data(), message_ptr->data_size())); - - } + if (handler_.cloud_properties.cloud_transport_type == "WSS") { + boost::get(handler_.dynamic_ws_) + ->write(boost::asio::buffer(message_ptr->data(), + message_ptr->data_size())); + } else { + boost::get(handler_.dynamic_ws_) + ->write(boost::asio::buffer(message_ptr->data(), + message_ptr->data_size())); + } if (ec) { LOG4CXX_ERROR(logger_, "Error writing to websocket"); handler_.Shutdown(); diff --git a/src/components/transport_manager/src/transport_manager_impl.cc b/src/components/transport_manager/src/transport_manager_impl.cc index 1f57436d60..3de12fdf9e 100644 --- a/src/components/transport_manager/src/transport_manager_impl.cc +++ b/src/components/transport_manager/src/transport_manager_impl.cc @@ -130,13 +130,15 @@ void TransportManagerImpl::ReconnectionTimeout() { device_to_reconnect_); } -void TransportManagerImpl::AddCloudDevice(const transport_manager::transport_adapter::CloudAppProperties cloud_properties) { +void TransportManagerImpl::AddCloudDevice( + const transport_manager::transport_adapter::CloudAppProperties + cloud_properties) { // todo put conversion into own function - LOG4CXX_DEBUG(logger_, "CLOUD_DEBUG_AddCloudDevice: " << cloud_properties.cloud_transport_type); transport_adapter::DeviceType type = transport_adapter::DeviceType::UNKNOWN; - if ((cloud_properties.cloud_transport_type == "WS") || (cloud_properties.cloud_transport_type == "WSS")) { - type = transport_adapter::DeviceType::CLOUD_WEBSOCKET; + if ((cloud_properties.cloud_transport_type == "WS") || + (cloud_properties.cloud_transport_type == "WSS")) { + type = transport_adapter::DeviceType::CLOUD_WEBSOCKET; } else { return; } @@ -145,15 +147,10 @@ void TransportManagerImpl::AddCloudDevice(const transport_manager::transport_ada for (; ta != transport_adapters_.end(); ++ta) { if ((*ta)->GetDeviceType() == type) { (*ta)->CreateDevice(cloud_properties.endpoint); - transport_adapter::CloudWebsocketTransportAdapter* cta = static_cast(*ta); - // LOG4CXX_DEBUG(logger_, "CLOUD_TRANS_MGR: "); - // LOG4CXX_DEBUG(logger_, "ENDPOINT: " << cloud_properties.endpoint); - // LOG4CXX_DEBUG(logger_, "ENABLED: " << cloud_properties.enabled); - // LOG4CXX_DEBUG(logger_, "CERTIFICATE: " << cloud_properties.certificate); - // LOG4CXX_DEBUG(logger_, "AUTH_TOKEN: " << cloud_properties.auth_token); - // LOG4CXX_DEBUG(logger_, "TRANSPORT_TYPE: " << cloud_properties.cloud_transport_type); - // LOG4CXX_DEBUG(logger_, "HYBRID: " << cloud_properties.hybrid_app_preference); - cta->SetAppCloudTransportConfig(cloud_properties.endpoint, cloud_properties); + transport_adapter::CloudWebsocketTransportAdapter* cta = + static_cast(*ta); + cta->SetAppCloudTransportConfig(cloud_properties.endpoint, + cloud_properties); } } -- cgit v1.2.1 From 1b36f5f570516a13caa9f1baa230e365608ab121 Mon Sep 17 00:00:00 2001 From: ShobhitAd Date: Mon, 10 Dec 2018 09:54:39 -0500 Subject: Fix mock test files --- .../include/connection_handler/connection_handler_impl.h | 2 +- src/components/connection_handler/src/connection_handler_impl.cc | 2 +- src/components/include/connection_handler/connection_handler.h | 2 +- .../include/test/connection_handler/mock_connection_handler.h | 8 ++++---- .../include/test/transport_manager/mock_transport_manager.h | 6 +++--- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/components/connection_handler/include/connection_handler/connection_handler_impl.h b/src/components/connection_handler/include/connection_handler/connection_handler_impl.h index 2f175f8acc..26c5a0ace5 100644 --- a/src/components/connection_handler/include/connection_handler/connection_handler_impl.h +++ b/src/components/connection_handler/include/connection_handler/connection_handler_impl.h @@ -132,7 +132,7 @@ class ConnectionHandlerImpl void AddCloudAppDevice( const std::string& policy_app_id, - const transport_manager::transport_adapter::CloudAppProperties + const transport_manager::transport_adapter::CloudAppProperties& cloud_properties) OVERRIDE; void StartTransportManager() OVERRIDE; diff --git a/src/components/connection_handler/src/connection_handler_impl.cc b/src/components/connection_handler/src/connection_handler_impl.cc index 6f24ae226d..d092f728c6 100644 --- a/src/components/connection_handler/src/connection_handler_impl.cc +++ b/src/components/connection_handler/src/connection_handler_impl.cc @@ -1325,7 +1325,7 @@ void ConnectionHandlerImpl::ConnectToAllDevices() { void ConnectionHandlerImpl::AddCloudAppDevice( const std::string& policy_app_id, - const transport_manager::transport_adapter::CloudAppProperties + const transport_manager::transport_adapter::CloudAppProperties& cloud_properties) { transport_manager_.AddCloudDevice(cloud_properties); } diff --git a/src/components/include/connection_handler/connection_handler.h b/src/components/include/connection_handler/connection_handler.h index f6bf8aeeb5..d8d3225f5f 100644 --- a/src/components/include/connection_handler/connection_handler.h +++ b/src/components/include/connection_handler/connection_handler.h @@ -105,7 +105,7 @@ class ConnectionHandler { virtual void AddCloudAppDevice( const std::string& policy_app_id, - const transport_manager::transport_adapter::CloudAppProperties + const transport_manager::transport_adapter::CloudAppProperties& cloud_properties) = 0; /** diff --git a/src/components/include/test/connection_handler/mock_connection_handler.h b/src/components/include/test/connection_handler/mock_connection_handler.h index 5836626ae3..20c04d933c 100644 --- a/src/components/include/test/connection_handler/mock_connection_handler.h +++ b/src/components/include/test/connection_handler/mock_connection_handler.h @@ -66,10 +66,10 @@ class MockConnectionHandler : public connection_handler::ConnectionHandler { MOCK_CONST_METHOD2(RunAppOnDevice, void(const std::string&, const std::string&)); MOCK_METHOD0(ConnectToAllDevices, void()); - MOCK_METHOD3(AddCloudAppDevice, - void(const std::string& policy_app_id, - const std::string& endpoint, - const std::string& cloud_transport_type)); + MOCK_METHOD2( + AddCloudAppDevice, + void(const std::string& policy_app_id, + const transport_manager::transport_adapter::CloudAppProperties&)); MOCK_METHOD1(CloseRevokedConnection, void(uint32_t connection_key)); MOCK_METHOD1(CloseConnection, void(ConnectionHandle connection_handle)); MOCK_METHOD1(GetConnectionSessionsCount, uint32_t(uint32_t connection_key)); diff --git a/src/components/include/test/transport_manager/mock_transport_manager.h b/src/components/include/test/transport_manager/mock_transport_manager.h index 555d51bf76..8ac515be97 100644 --- a/src/components/include/test/transport_manager/mock_transport_manager.h +++ b/src/components/include/test/transport_manager/mock_transport_manager.h @@ -59,9 +59,9 @@ class MockTransportManager : public ::transport_manager::TransportManager, MOCK_METHOD1(Init, int(resumption::LastState& last_state)); MOCK_METHOD0(Reinit, int()); MOCK_METHOD0(SearchDevices, int()); - MOCK_METHOD2(AddCloudDevice, - void(const std::string& endpoint, - const std::string& cloud_transport_type)); + MOCK_METHOD1( + AddCloudDevice, + void(const transport_manager::transport_adapter::CloudAppProperties)); MOCK_METHOD1(ConnectDevice, int(const DeviceHandle)); MOCK_CONST_METHOD1( GetConnectionStatus, -- cgit v1.2.1 From fbb12b62313cd29dc9b0131b839c0d095a75794a Mon Sep 17 00:00:00 2001 From: ShobhitAd Date: Mon, 10 Dec 2018 11:03:50 -0500 Subject: Remove extra debug statements --- .../cloud/websocket_client_connection.h | 3 +- .../src/cloud/websocket_client_connection.cc | 45 +++++++--------------- 2 files changed, 15 insertions(+), 33 deletions(-) diff --git a/src/components/transport_manager/include/transport_manager/cloud/websocket_client_connection.h b/src/components/transport_manager/include/transport_manager/cloud/websocket_client_connection.h index adbe17112c..4f6e2b02af 100644 --- a/src/components/transport_manager/include/transport_manager/cloud/websocket_client_connection.h +++ b/src/components/transport_manager/include/transport_manager/cloud/websocket_client_connection.h @@ -127,9 +127,8 @@ class WebsocketClientConnection * @brief Attempt to add provided certificate to the ssl::context * * @param cert Certificate string from policy table - * @return true if certificate was not invalid and was added successfully */ - bool AddCertificateAuthority(std::string cert, boost::system::error_code& ec); + void AddCertificateAuthority(std::string cert, boost::system::error_code& ec); void Shutdown(); diff --git a/src/components/transport_manager/src/cloud/websocket_client_connection.cc b/src/components/transport_manager/src/cloud/websocket_client_connection.cc index e6da3e9b6c..5da91871ad 100644 --- a/src/components/transport_manager/src/cloud/websocket_client_connection.cc +++ b/src/components/transport_manager/src/cloud/websocket_client_connection.cc @@ -53,9 +53,7 @@ WebsocketClientConnection::WebsocketClientConnection( , thread_delegate_(new LoopThreadDelegate(&message_queue_, this)) , write_thread_(threads::CreateThread("WS Async Send", thread_delegate_)) , device_uid_(device_uid) - , app_handle_(app_handle) { - LOG4CXX_DEBUG(logger_, "CLOUD_DEBUG_WEBSOCKETCLIENTCONNECTION"); -} + , app_handle_(app_handle) {} WebsocketClientConnection::~WebsocketClientConnection() { ioc_.stop(); @@ -64,22 +62,17 @@ WebsocketClientConnection::~WebsocketClientConnection() { } } -bool WebsocketClientConnection::AddCertificateAuthority( +void WebsocketClientConnection::AddCertificateAuthority( const std::string cert, boost::system::error_code& ec) { ctx_.add_certificate_authority(boost::asio::buffer(cert.data(), cert.size()), ec); if (ec) { - return false; + return; } boost::get(dynamic_ws_) ->next_layer() .set_verify_mode(ssl::verify_peer); - if (ec) { - return false; - } - - return true; } TransportAdapter::Error WebsocketClientConnection::Start() { @@ -93,14 +86,18 @@ TransportAdapter::Error WebsocketClientConnection::Start() { auto const port = cloud_device->GetPort(); boost::system::error_code ec; - LOG4CXX_DEBUG(logger_, "CLOUD_CONN_START"); - LOG4CXX_DEBUG(logger_, "ENDPOINT: " << cloud_properties.endpoint); - LOG4CXX_DEBUG(logger_, "CERTIFICATE: " << cloud_properties.certificate); - LOG4CXX_DEBUG(logger_, "AUTH_TOKEN: " << cloud_properties.auth_token); + LOG4CXX_DEBUG(logger_, "Cloud app endpoint: " << cloud_properties.endpoint); LOG4CXX_DEBUG(logger_, - "TRANSPORT_TYPE: " << cloud_properties.cloud_transport_type); + "Cloud app certificate: " << cloud_properties.certificate); + LOG4CXX_DEBUG( + logger_, + "Cloud app authentication token: " << cloud_properties.auth_token); + LOG4CXX_DEBUG( + logger_, + "Cloud app transport type: " << cloud_properties.cloud_transport_type); LOG4CXX_DEBUG(logger_, - "HYBRID_APP_PREF: " << cloud_properties.hybrid_app_preference); + "Cloud app hybrid app preference: " + << cloud_properties.hybrid_app_preference); auto const results = resolver_.resolve(host, port, ec); if (ec) { @@ -110,8 +107,6 @@ TransportAdapter::Error WebsocketClientConnection::Start() { return TransportAdapter::FAIL; } - LOG4CXX_DEBUG(logger_, "CLOUD_CONN_RESOLVE"); - if (cloud_properties.cloud_transport_type == "WSS") { dynamic_ws_ = std::make_shared(ioc_, ctx_); } else { @@ -140,16 +135,8 @@ TransportAdapter::Error WebsocketClientConnection::Start() { return TransportAdapter::FAIL; } - LOG4CXX_DEBUG(logger_, "CLOUD_CONN_TCP"); - if (cloud_properties.cloud_transport_type == "WSS") { - bool isAdded = AddCertificateAuthority(cloud_properties.certificate, ec); - - if (isAdded) { - LOG4CXX_INFO(logger_, "Certificate Authority added successfully"); - } else { - LOG4CXX_INFO(logger_, "Failed to add certificate authority"); - } + AddCertificateAuthority(cloud_properties.certificate, ec); if (ec) { std::string str_err = "ErrorMessage: " + ec.message(); @@ -175,8 +162,6 @@ TransportAdapter::Error WebsocketClientConnection::Start() { Shutdown(); return TransportAdapter::FAIL; } - - LOG4CXX_DEBUG(logger_, "CLOUD_CONN_SSL"); } // Perform websocket handshake @@ -195,8 +180,6 @@ TransportAdapter::Error WebsocketClientConnection::Start() { return TransportAdapter::FAIL; } - LOG4CXX_DEBUG(logger_, "CLOUD_CONN_WEBSOCKET"); - // Set the binary message write option if (cloud_properties.cloud_transport_type == "WSS") { boost::get(dynamic_ws_)->binary(true); -- cgit v1.2.1 From 64047e5f7fbd07a2a332246dcf07a10f39361561 Mon Sep 17 00:00:00 2001 From: jacobkeeler Date: Wed, 12 Dec 2018 16:39:14 -0500 Subject: Refresh app list when an app is enabled or disabled --- .../application_manager/application_manager_impl.h | 2 +- .../mobile/set_cloud_app_properties_request.h | 31 ++++++++ .../mobile/set_cloud_app_properties_response.h | 31 ++++++++ .../mobile/set_cloudapp_properties_request.h | 31 -------- .../mobile/set_cloudapp_properties_response.h | 31 -------- .../mobile/set_cloud_app_properties_request.cc | 49 +++++++++++++ .../mobile/set_cloud_app_properties_response.cc | 31 ++++++++ .../mobile/set_cloudapp_properties_request.cc | 83 ---------------------- .../mobile/set_cloudapp_properties_response.cc | 31 -------- .../sdl_rpc_plugin/src/mobile_command_factory.cc | 4 +- .../src/application_manager_impl.cc | 65 +++++++++++++++-- .../src/policies/policy_handler.cc | 2 + .../connection_handler/connection_handler_impl.h | 2 + .../src/connection_handler_impl.cc | 4 ++ .../application_manager/application_manager.h | 2 + .../connection_handler/connection_handler.h | 2 + .../application_manager/mock_application_manager.h | 1 + .../connection_handler/mock_connection_handler.h | 1 + .../transport_manager/mock_transport_manager.h | 1 + .../include/transport_manager/transport_manager.h | 2 + .../transport_manager/transport_manager_impl.h | 2 + .../src/cloud/websocket_client_connection.cc | 2 +- .../src/transport_manager_impl.cc | 5 ++ 23 files changed, 228 insertions(+), 187 deletions(-) create mode 100644 src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/set_cloud_app_properties_request.h create mode 100644 src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/set_cloud_app_properties_response.h delete mode 100644 src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/set_cloudapp_properties_request.h delete mode 100644 src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/set_cloudapp_properties_response.h create mode 100644 src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/set_cloud_app_properties_request.cc create mode 100644 src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/set_cloud_app_properties_response.cc delete mode 100644 src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/set_cloudapp_properties_request.cc delete mode 100644 src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/set_cloudapp_properties_response.cc diff --git a/src/components/application_manager/include/application_manager/application_manager_impl.h b/src/components/application_manager/include/application_manager/application_manager_impl.h index a3e3cece72..08421615d4 100644 --- a/src/components/application_manager/include/application_manager/application_manager_impl.h +++ b/src/components/application_manager/include/application_manager/application_manager_impl.h @@ -360,7 +360,7 @@ class ApplicationManagerImpl void ConnectToDevice(const std::string& device_mac) OVERRIDE; void OnHMIStartedCooperation() OVERRIDE; - void CollectCloudAppInformation(); + void RefreshCloudAppInformation() OVERRIDE; void CreatePendingApplication( const transport_manager::ConnectionUID connection_id, diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/set_cloud_app_properties_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/set_cloud_app_properties_request.h new file mode 100644 index 0000000000..a3a3ea12f9 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/set_cloud_app_properties_request.h @@ -0,0 +1,31 @@ +#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_SET_CLOUD_APP_PROPERTIES_REQUEST_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_SET_CLOUD_APP_PROPERTIES_REQUEST_H_ + +#include "application_manager/commands/command_request_impl.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +class SetCloudAppPropertiesRequest + : public app_mngr::commands::CommandRequestImpl { + public: + SetCloudAppPropertiesRequest( + const app_mngr::commands::MessageSharedPtr& message, + app_mngr::ApplicationManager& application_manager, + app_mngr::rpc_service::RPCService& rpc_service, + app_mngr::HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handler); + virtual ~SetCloudAppPropertiesRequest(); + virtual void Run(); + virtual void on_event(const app_mngr::event_engine::Event& event); + + private: + DISALLOW_COPY_AND_ASSIGN(SetCloudAppPropertiesRequest); +}; // SetCloudAppPropertiesRequest + +} // namespace commands +} // namespace sdl_rpc_plugin + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_SET_CLOUD_APP_PROPERTIES_REQUEST_H_ \ No newline at end of file diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/set_cloud_app_properties_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/set_cloud_app_properties_response.h new file mode 100644 index 0000000000..df71a2aaf5 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/set_cloud_app_properties_response.h @@ -0,0 +1,31 @@ +#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_SET_CLOUD_APP_PROPERTIES_RESPONSE_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_SET_CLOUD_APP_PROPERTIES_RESPONSE_H_ + +#include "application_manager/commands/command_response_impl.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +class SetCloudAppPropertiesResponse + : public app_mngr::commands::CommandResponseImpl { + public: + SetCloudAppPropertiesResponse( + const app_mngr::commands::MessageSharedPtr& message, + app_mngr::ApplicationManager& application_manager, + app_mngr::rpc_service::RPCService& rpc_service, + app_mngr::HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handler); + virtual ~SetCloudAppPropertiesResponse(); + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(SetCloudAppPropertiesResponse); + +}; // SetCloudAppPropertiesResponse + +} // namespace commands +} // namespace sdl_rpc_plugin + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_SET_CLOUD_APP_PROPERTIES_RESPONSE_H_ \ No newline at end of file diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/set_cloudapp_properties_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/set_cloudapp_properties_request.h deleted file mode 100644 index 0c62b248b4..0000000000 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/set_cloudapp_properties_request.h +++ /dev/null @@ -1,31 +0,0 @@ -#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_SET_CLOUDAPP_PROPERTIES_REQUEST_H_ -#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_SET_CLOUDAPP_PROPERTIES_REQUEST_H_ - -#include "application_manager/commands/command_request_impl.h" - -namespace sdl_rpc_plugin { -namespace app_mngr = application_manager; - -namespace commands { - -class SetCloudAppPropertiesRequest - : public app_mngr::commands::CommandRequestImpl { - public: - SetCloudAppPropertiesRequest( - const app_mngr::commands::MessageSharedPtr& message, - app_mngr::ApplicationManager& application_manager, - app_mngr::rpc_service::RPCService& rpc_service, - app_mngr::HMICapabilities& hmi_capabilities, - policy::PolicyHandlerInterface& policy_handler); - virtual ~SetCloudAppPropertiesRequest(); - virtual void Run(); - virtual void on_event(const app_mngr::event_engine::Event& event); - - private: - DISALLOW_COPY_AND_ASSIGN(SetCloudAppPropertiesRequest); -}; // SetCloudAppPropertiesRequest - -} // namespace commands -} // namespace sdl_rpc_plugin - -#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_SET_CLOUDAPP_PROPERTIES_REQUEST_H_ \ No newline at end of file diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/set_cloudapp_properties_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/set_cloudapp_properties_response.h deleted file mode 100644 index 9037cb3b73..0000000000 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/set_cloudapp_properties_response.h +++ /dev/null @@ -1,31 +0,0 @@ -#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_SET_CLOUDAPP_PROPERTIES_RESPONSE_H_ -#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_SET_CLOUDAPP_PROPERTIES_RESPONSE_H_ - -#include "application_manager/commands/command_response_impl.h" - -namespace sdl_rpc_plugin { -namespace app_mngr = application_manager; - -namespace commands { - -class SetCloudAppPropertiesResponse - : public app_mngr::commands::CommandResponseImpl { - public: - SetCloudAppPropertiesResponse( - const app_mngr::commands::MessageSharedPtr& message, - app_mngr::ApplicationManager& application_manager, - app_mngr::rpc_service::RPCService& rpc_service, - app_mngr::HMICapabilities& hmi_capabilities, - policy::PolicyHandlerInterface& policy_handler); - virtual ~SetCloudAppPropertiesResponse(); - virtual void Run(); - - private: - DISALLOW_COPY_AND_ASSIGN(SetCloudAppPropertiesResponse); - -}; // SetCloudAppPropertiesResponse - -} // namespace commands -} // namespace sdl_rpc_plugin - -#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_SET_CLOUDAPP_PROPERTIES_RESPONSE_H_ \ No newline at end of file diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/set_cloud_app_properties_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/set_cloud_app_properties_request.cc new file mode 100644 index 0000000000..663881a2ea --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/set_cloud_app_properties_request.cc @@ -0,0 +1,49 @@ +#include "sdl_rpc_plugin/commands/mobile/set_cloud_app_properties_request.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +SetCloudAppPropertiesRequest::SetCloudAppPropertiesRequest( + const app_mngr::commands::MessageSharedPtr& message, + app_mngr::ApplicationManager& application_manager, + app_mngr::rpc_service::RPCService& rpc_service, + app_mngr::HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handler) + : CommandRequestImpl(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handler) {} + +SetCloudAppPropertiesRequest::~SetCloudAppPropertiesRequest() {} + +void SetCloudAppPropertiesRequest::Run() { + LOG4CXX_AUTO_TRACE(logger_); + ApplicationSharedPtr app = application_manager_.application(connection_key()); + + if (!app) { + LOG4CXX_ERROR(logger_, "Application is not registered"); + SendResponse(false, mobile_apis::Result::APPLICATION_NOT_REGISTERED); + return; + } + + if ((*message_)[strings::msg_params].empty()) { + LOG4CXX_ERROR(logger_, strings::msg_params << " is empty."); + SendResponse(false, mobile_apis::Result::INVALID_DATA); + return; + } + + policy_handler_.OnSetCloudAppProperties(*message_); + + SendResponse(true, mobile_apis::Result::SUCCESS); +} + +void SetCloudAppPropertiesRequest::on_event( + const app_mngr::event_engine::Event& event) { + LOG4CXX_INFO(logger_, "SetCloudAppPropertiesRequest on_event"); +} + +} // namespace commands +} // namespace sdl_rpc_plugin \ No newline at end of file diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/set_cloud_app_properties_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/set_cloud_app_properties_response.cc new file mode 100644 index 0000000000..6d27ce8b3e --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/set_cloud_app_properties_response.cc @@ -0,0 +1,31 @@ +#include "application_manager/application_manager.h" +#include "application_manager/rpc_service.h" +#include "sdl_rpc_plugin/commands/mobile/set_cloud_app_properties_response.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +SetCloudAppPropertiesResponse::SetCloudAppPropertiesResponse( + const app_mngr::commands::MessageSharedPtr& message, + app_mngr::ApplicationManager& application_manager, + app_mngr::rpc_service::RPCService& rpc_service, + app_mngr::HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handler) + : CommandResponseImpl(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handler) {} + +SetCloudAppPropertiesResponse::~SetCloudAppPropertiesResponse() {} + +void SetCloudAppPropertiesResponse::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + rpc_service_.SendMessageToMobile(message_); +} + +} // namespace commands +} // namespace sdl_rpc_plugins diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/set_cloudapp_properties_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/set_cloudapp_properties_request.cc deleted file mode 100644 index 0beb7631c7..0000000000 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/set_cloudapp_properties_request.cc +++ /dev/null @@ -1,83 +0,0 @@ -#include "sdl_rpc_plugin/commands/mobile/set_cloudapp_properties_request.h" - -namespace sdl_rpc_plugin { -using namespace application_manager; - -namespace commands { - -SetCloudAppPropertiesRequest::SetCloudAppPropertiesRequest( - const app_mngr::commands::MessageSharedPtr& message, - app_mngr::ApplicationManager& application_manager, - app_mngr::rpc_service::RPCService& rpc_service, - app_mngr::HMICapabilities& hmi_capabilities, - policy::PolicyHandlerInterface& policy_handler) - : CommandRequestImpl(message, - application_manager, - rpc_service, - hmi_capabilities, - policy_handler) {} - -SetCloudAppPropertiesRequest::~SetCloudAppPropertiesRequest() {} - -void SetCloudAppPropertiesRequest::Run() { - LOG4CXX_AUTO_TRACE(logger_); - ApplicationSharedPtr app = application_manager_.application(connection_key()); - - if (!app) { - LOG4CXX_ERROR(logger_, "Application is not registered"); - SendResponse(false, mobile_apis::Result::APPLICATION_NOT_REGISTERED); - return; - } - - if ((*message_)[strings::msg_params].empty()) { - LOG4CXX_ERROR(logger_, strings::msg_params << " is empty."); - SendResponse(false, mobile_apis::Result::INVALID_DATA); - return; - } - - smart_objects::SmartObject cloud_app_properties(smart_objects::SmartType_Map); - - cloud_app_properties[strings::msg_params][strings::app_name] = - (*message_)[strings::msg_params][strings::app_name]; - cloud_app_properties[strings::msg_params][strings::app_id] = - (*message_)[strings::msg_params][strings::app_id]; - - if ((*message_)[strings::msg_params].keyExists(strings::enabled)) { - smart_objects::SmartObject enabled = - (*message_)[strings::msg_params][strings::enabled]; - cloud_app_properties[strings::msg_params][strings::enabled] = enabled; - } - if ((*message_)[strings::msg_params].keyExists( - strings::cloud_app_auth_token)) { - smart_objects::SmartObject auth_token = - (*message_)[strings::msg_params][strings::cloud_app_auth_token]; - cloud_app_properties[strings::msg_params][strings::cloud_app_auth_token] = - auth_token; - } - if ((*message_)[strings::msg_params].keyExists( - strings::cloud_transport_type)) { - smart_objects::SmartObject transport_type = - (*message_)[strings::msg_params][strings::cloud_transport_type]; - cloud_app_properties[strings::msg_params][strings::cloud_transport_type] = - transport_type; - } - if ((*message_)[strings::msg_params].keyExists( - strings::hybrid_app_preference)) { - smart_objects::SmartObject hybrid_app_preference = - (*message_)[strings::msg_params][strings::hybrid_app_preference]; - cloud_app_properties[strings::msg_params][strings::hybrid_app_preference] = - hybrid_app_preference; - } - - policy_handler_.OnSetCloudAppProperties(cloud_app_properties); - - SendResponse(true, mobile_apis::Result::SUCCESS); -} - -void SetCloudAppPropertiesRequest::on_event( - const app_mngr::event_engine::Event& event) { - LOG4CXX_INFO(logger_, "SetCloudAppPropertiesRequest on_event"); -} - -} // namespace commands -} // namespace sdl_rpc_plugin \ No newline at end of file diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/set_cloudapp_properties_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/set_cloudapp_properties_response.cc deleted file mode 100644 index 6acfb2423d..0000000000 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/set_cloudapp_properties_response.cc +++ /dev/null @@ -1,31 +0,0 @@ -#include "application_manager/application_manager.h" -#include "application_manager/rpc_service.h" -#include "sdl_rpc_plugin/commands/mobile/set_cloudapp_properties_response.h" - -namespace sdl_rpc_plugin { -using namespace application_manager; - -namespace commands { - -SetCloudAppPropertiesResponse::SetCloudAppPropertiesResponse( - const app_mngr::commands::MessageSharedPtr& message, - app_mngr::ApplicationManager& application_manager, - app_mngr::rpc_service::RPCService& rpc_service, - app_mngr::HMICapabilities& hmi_capabilities, - policy::PolicyHandlerInterface& policy_handler) - : CommandResponseImpl(message, - application_manager, - rpc_service, - hmi_capabilities, - policy_handler) {} - -SetCloudAppPropertiesResponse::~SetCloudAppPropertiesResponse() {} - -void SetCloudAppPropertiesResponse::Run() { - LOG4CXX_AUTO_TRACE(logger_); - - rpc_service_.SendMessageToMobile(message_); -} - -} // namespace commands -} // namespace sdl_rpc_plugins diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/mobile_command_factory.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/mobile_command_factory.cc index dc5298813b..8eab054be3 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/mobile_command_factory.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/mobile_command_factory.cc @@ -124,8 +124,8 @@ #include "sdl_rpc_plugin/commands/mobile/dial_number_response.h" #include "sdl_rpc_plugin/commands/mobile/send_haptic_data_request.h" #include "sdl_rpc_plugin/commands/mobile/send_haptic_data_response.h" -#include "sdl_rpc_plugin/commands/mobile/set_cloudapp_properties_request.h" -#include "sdl_rpc_plugin/commands/mobile/set_cloudapp_properties_response.h" +#include "sdl_rpc_plugin/commands/mobile/set_cloud_app_properties_request.h" +#include "sdl_rpc_plugin/commands/mobile/set_cloud_app_properties_response.h" #include "interfaces/MOBILE_API.h" CREATE_LOGGERPTR_GLOBAL(logger_, "ApplicationManager") diff --git a/src/components/application_manager/src/application_manager_impl.cc b/src/components/application_manager/src/application_manager_impl.cc index d188ed9724..97d5e66b6b 100644 --- a/src/components/application_manager/src/application_manager_impl.cc +++ b/src/components/application_manager/src/application_manager_impl.cc @@ -803,21 +803,25 @@ void ApplicationManagerImpl::OnHMIStartedCooperation() { rpc_service_->ManageHMICommand(mixing_audio_supported_request); resume_controller().ResetLaunchTime(); - CollectCloudAppInformation(); + RefreshCloudAppInformation(); } -void ApplicationManagerImpl::CollectCloudAppInformation() { +void ApplicationManagerImpl::RefreshCloudAppInformation() { LOG4CXX_AUTO_TRACE(logger_); - std::vector cloud_app_id_vector; - GetPolicyHandler().GetEnabledCloudApps(cloud_app_id_vector); - std::vector::iterator it = cloud_app_id_vector.begin(); - std::vector::iterator end = cloud_app_id_vector.end(); + std::vector enabled_apps; + GetPolicyHandler().GetEnabledCloudApps(enabled_apps); + std::vector::iterator it = enabled_apps.begin(); + std::vector::iterator end = enabled_apps.end(); std::string endpoint = ""; std::string certificate = ""; std::string auth_token = ""; std::string cloud_transport_type = ""; std::string hybrid_app_preference = ""; bool enabled = true; + + // Store old device map and clear the current map + std::map old_device_map = pending_device_map_; + pending_device_map_ = std::map(); for (; it != end; ++it) { GetPolicyHandler().GetCloudAppParameters(*it, enabled, @@ -829,9 +833,56 @@ void ApplicationManagerImpl::CollectCloudAppInformation() { pending_device_map_.insert( std::pair(endpoint, *it)); + auto old_device = old_device_map.find(endpoint); + if (old_device_map.find(endpoint) != old_device_map.end()) { + old_device_map.erase(old_device); + continue; + } connection_handler().AddCloudAppDevice(*it, endpoint, cloud_transport_type); } + + int removed_app_count = 0; + // Clear out devices for existing cloud apps that were disabled + for (auto& device : old_device_map) { + std::string policy_app_id = device.second; + ApplicationSharedPtr app = application_by_policy_id(policy_app_id); + if (app.use_count() == 0) { + sync_primitives::AutoLock lock(apps_to_register_list_lock_ptr_); + PolicyAppIdPredicate finder(policy_app_id); + ApplicationSet::iterator it = std::find_if( + apps_to_register_.begin(), apps_to_register_.end(), finder); + if (it == apps_to_register_.end()) { + continue; + } + app = *it; + apps_to_register_.erase(it); + } + if (app.use_count() == 0) { + LOG4CXX_DEBUG(logger_, + "Unable to find app to remove (" << policy_app_id + << "), skipping"); + continue; + } + if (app->IsRegistered() && app->is_cloud_app()) { + LOG4CXX_DEBUG(logger_, "Disabled app is registered, unregistering now"); + GetRPCService().ManageMobileCommand( + MessageHelper::GetOnAppInterfaceUnregisteredNotificationToMobile( + app->app_id(), + mobile_api::AppInterfaceUnregisteredReason::APP_UNAUTHORIZED), + commands::Command::SOURCE_SDL); + + OnAppUnauthorized(app->app_id()); + } + connection_handler().RemoveCloudAppDevice(app->device()); + removed_app_count++; + } + + // Update app list if disabled apps were removed + if (removed_app_count > 0) { + LOG4CXX_DEBUG(logger_, "Removed " << removed_app_count << " disabled apps"); + SendUpdateAppList(); + } } void ApplicationManagerImpl::CreatePendingApplication( @@ -3529,7 +3580,7 @@ void ApplicationManagerImpl::OnPTUFinished(const bool ptu_result) { if (!ptu_result) { return; } - CollectCloudAppInformation(); + RefreshCloudAppInformation(); auto on_app_policy_updated = [](plugin_manager::RPCPlugin& plugin) { plugin.OnPolicyEvent(plugin_manager::kApplicationPolicyUpdated); }; diff --git a/src/components/application_manager/src/policies/policy_handler.cc b/src/components/application_manager/src/policies/policy_handler.cc index c603659353..3be3ef0da7 100644 --- a/src/components/application_manager/src/policies/policy_handler.cc +++ b/src/components/application_manager/src/policies/policy_handler.cc @@ -1912,6 +1912,8 @@ void PolicyHandler::OnSetCloudAppProperties( if (msg_params.keyExists(strings::enabled)) { policy_manager_->SetCloudAppEnabled(policy_app_id, msg_params[strings::enabled].asBool()); + + application_manager_.RefreshCloudAppInformation(); } if (msg_params.keyExists(strings::cloud_app_auth_token)) { policy_manager_->SetAppAuthToken( diff --git a/src/components/connection_handler/include/connection_handler/connection_handler_impl.h b/src/components/connection_handler/include/connection_handler/connection_handler_impl.h index b8153bcf42..e9e7ba47a3 100644 --- a/src/components/connection_handler/include/connection_handler/connection_handler_impl.h +++ b/src/components/connection_handler/include/connection_handler/connection_handler_impl.h @@ -134,6 +134,8 @@ class ConnectionHandlerImpl const std::string& endpoint, const std::string& cloud_transport_type) OVERRIDE; + void RemoveCloudAppDevice(const DeviceHandle device_id) OVERRIDE; + void StartTransportManager() OVERRIDE; void OnDeviceListUpdated( diff --git a/src/components/connection_handler/src/connection_handler_impl.cc b/src/components/connection_handler/src/connection_handler_impl.cc index f72cab61f3..679cbd1af0 100644 --- a/src/components/connection_handler/src/connection_handler_impl.cc +++ b/src/components/connection_handler/src/connection_handler_impl.cc @@ -1330,6 +1330,10 @@ void ConnectionHandlerImpl::AddCloudAppDevice( transport_manager_.AddCloudDevice(endpoint, cloud_transport_type); } +void ConnectionHandlerImpl::RemoveCloudAppDevice(const DeviceHandle device_id) { + transport_manager_.RemoveCloudDevice(device_id); +} + void ConnectionHandlerImpl::StartTransportManager() { LOG4CXX_AUTO_TRACE(logger_); transport_manager_.Visibility(true); diff --git a/src/components/include/application_manager/application_manager.h b/src/components/include/application_manager/application_manager.h index 9e979da08e..47b6bcbc9d 100644 --- a/src/components/include/application_manager/application_manager.h +++ b/src/components/include/application_manager/application_manager.h @@ -427,6 +427,8 @@ class ApplicationManager { virtual void OnHMIStartedCooperation() = 0; + virtual void RefreshCloudAppInformation() = 0; + /** * @brief Retrieve the current connection status of a cloud app * @param app A cloud application diff --git a/src/components/include/connection_handler/connection_handler.h b/src/components/include/connection_handler/connection_handler.h index eb41141842..a4058c7078 100644 --- a/src/components/include/connection_handler/connection_handler.h +++ b/src/components/include/connection_handler/connection_handler.h @@ -107,6 +107,8 @@ class ConnectionHandler { const std::string& endpoint, const std::string& cloud_transport_type) = 0; + virtual void RemoveCloudAppDevice(const DeviceHandle device_id) = 0; + /** * @brief Close the connection revoked by Policy * @param connection_key pair of connection and session id diff --git a/src/components/include/test/application_manager/mock_application_manager.h b/src/components/include/test/application_manager/mock_application_manager.h index ca8aa2eb96..30a24ad9ce 100644 --- a/src/components/include/test/application_manager/mock_application_manager.h +++ b/src/components/include/test/application_manager/mock_application_manager.h @@ -166,6 +166,7 @@ class MockApplicationManager : public application_manager::ApplicationManager { MOCK_METHOD1(EndAudioPassThru, bool(uint32_t app_id)); MOCK_METHOD1(ConnectToDevice, void(const std::string& device_mac)); MOCK_METHOD0(OnHMIStartedCooperation, void()); + MOCK_METHOD0(RefreshCloudAppInformation, void()); MOCK_CONST_METHOD1(GetCloudAppConnectionStatus, hmi_apis::Common_CloudConnectionStatus::eType( application_manager::ApplicationConstSharedPtr app)); diff --git a/src/components/include/test/connection_handler/mock_connection_handler.h b/src/components/include/test/connection_handler/mock_connection_handler.h index 5836626ae3..219ee7b561 100644 --- a/src/components/include/test/connection_handler/mock_connection_handler.h +++ b/src/components/include/test/connection_handler/mock_connection_handler.h @@ -70,6 +70,7 @@ class MockConnectionHandler : public connection_handler::ConnectionHandler { void(const std::string& policy_app_id, const std::string& endpoint, const std::string& cloud_transport_type)); + MOCK_METHOD1(RemoveCloudAppDevice, void(const DeviceHandle device_id)); MOCK_METHOD1(CloseRevokedConnection, void(uint32_t connection_key)); MOCK_METHOD1(CloseConnection, void(ConnectionHandle connection_handle)); MOCK_METHOD1(GetConnectionSessionsCount, uint32_t(uint32_t connection_key)); diff --git a/src/components/include/test/transport_manager/mock_transport_manager.h b/src/components/include/test/transport_manager/mock_transport_manager.h index 555d51bf76..40168c9c37 100644 --- a/src/components/include/test/transport_manager/mock_transport_manager.h +++ b/src/components/include/test/transport_manager/mock_transport_manager.h @@ -62,6 +62,7 @@ class MockTransportManager : public ::transport_manager::TransportManager, MOCK_METHOD2(AddCloudDevice, void(const std::string& endpoint, const std::string& cloud_transport_type)); + MOCK_METHOD1(RemoveCloudDevice, void(const DeviceHandle device_id)); MOCK_METHOD1(ConnectDevice, int(const DeviceHandle)); MOCK_CONST_METHOD1( GetConnectionStatus, diff --git a/src/components/include/transport_manager/transport_manager.h b/src/components/include/transport_manager/transport_manager.h index 3ecf815097..2596ba1b77 100644 --- a/src/components/include/transport_manager/transport_manager.h +++ b/src/components/include/transport_manager/transport_manager.h @@ -78,6 +78,8 @@ class TransportManager { virtual void AddCloudDevice(const std::string& endpoint, const std::string& cloud_transport_type) = 0; + virtual void RemoveCloudDevice(const DeviceHandle device_id) = 0; + /** * @brief Connect to all applications discovered on device. * diff --git a/src/components/transport_manager/include/transport_manager/transport_manager_impl.h b/src/components/transport_manager/include/transport_manager/transport_manager_impl.h index c84b1e9a39..4b75f4aaa8 100644 --- a/src/components/transport_manager/include/transport_manager/transport_manager_impl.h +++ b/src/components/transport_manager/include/transport_manager/transport_manager_impl.h @@ -142,6 +142,8 @@ class TransportManagerImpl void AddCloudDevice(const std::string& endpoint, const std::string& cloud_transport_type) OVERRIDE; + void RemoveCloudDevice(const DeviceHandle device_id) OVERRIDE; + /** * @brief Connect to all applications discovered on device. * diff --git a/src/components/transport_manager/src/cloud/websocket_client_connection.cc b/src/components/transport_manager/src/cloud/websocket_client_connection.cc index 4f585c8efb..10a2b50baa 100644 --- a/src/components/transport_manager/src/cloud/websocket_client_connection.cc +++ b/src/components/transport_manager/src/cloud/websocket_client_connection.cc @@ -241,4 +241,4 @@ void WebsocketClientConnection::LoopThreadDelegate::SetShutdown() { } } // namespace transport_adapter -} // namespace transport_manager \ No newline at end of file +} // namespace transport_manager diff --git a/src/components/transport_manager/src/transport_manager_impl.cc b/src/components/transport_manager/src/transport_manager_impl.cc index 518a5639db..5b4378efee 100644 --- a/src/components/transport_manager/src/transport_manager_impl.cc +++ b/src/components/transport_manager/src/transport_manager_impl.cc @@ -149,6 +149,11 @@ void TransportManagerImpl::AddCloudDevice( return; } +void TransportManagerImpl::RemoveCloudDevice(const DeviceHandle device_handle) { + DisconnectDevice(device_handle); + RemoveDevice(device_handle); +} + int TransportManagerImpl::ConnectDevice(const DeviceHandle device_handle) { LOG4CXX_TRACE(logger_, "enter. DeviceHandle: " << &device_handle); if (!this->is_initialized_) { -- cgit v1.2.1 From 14b49f0178e62acff40fff1698ef92cb30093a81 Mon Sep 17 00:00:00 2001 From: jacobkeeler Date: Thu, 13 Dec 2018 13:21:03 -0500 Subject: Fix disconnect flow --- .../transport_manager/src/cloud/websocket_client_connection.cc | 1 + src/components/transport_manager/src/transport_manager_impl.cc | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/transport_manager/src/cloud/websocket_client_connection.cc b/src/components/transport_manager/src/cloud/websocket_client_connection.cc index 10a2b50baa..e001e8877d 100644 --- a/src/components/transport_manager/src/cloud/websocket_client_connection.cc +++ b/src/components/transport_manager/src/cloud/websocket_client_connection.cc @@ -191,6 +191,7 @@ void WebsocketClientConnection::Shutdown() { if (buffer_.size()) { buffer_.consume(buffer_.size()); } + controller_->DisconnectDone(device_uid_, app_handle_); } WebsocketClientConnection::LoopThreadDelegate::LoopThreadDelegate( diff --git a/src/components/transport_manager/src/transport_manager_impl.cc b/src/components/transport_manager/src/transport_manager_impl.cc index 5b4378efee..301132d26f 100644 --- a/src/components/transport_manager/src/transport_manager_impl.cc +++ b/src/components/transport_manager/src/transport_manager_impl.cc @@ -151,7 +151,6 @@ void TransportManagerImpl::AddCloudDevice( void TransportManagerImpl::RemoveCloudDevice(const DeviceHandle device_handle) { DisconnectDevice(device_handle); - RemoveDevice(device_handle); } int TransportManagerImpl::ConnectDevice(const DeviceHandle device_handle) { -- cgit v1.2.1 From 2c08aa6e0d8a2885cea64bdd5c8bb39ba7f34dd5 Mon Sep 17 00:00:00 2001 From: Jacob Keeler Date: Thu, 3 Jan 2019 10:17:55 -0500 Subject: Genericize vehicle info in hmi_capabilities.json --- src/appMain/hmi_capabilities.json | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/appMain/hmi_capabilities.json b/src/appMain/hmi_capabilities.json index 93292d1023..873c80d32e 100755 --- a/src/appMain/hmi_capabilities.json +++ b/src/appMain/hmi_capabilities.json @@ -6,7 +6,7 @@ "JA-JP", "AR-SA", "KO-KR", "PT-BR", "CS-CZ", "DA-DK", "NO-NO" ], "displayCapabilities": { - "displayType": "GEN2_8_DMA", + "displayType": "SDL_GENERIC", "displayName": "GENERIC_DISPLAY", "textFields": [{ "name": "mainField1", @@ -921,9 +921,9 @@ } }, "VehicleInfo": { - "make": "Ford", - "model": "Fiesta", - "modelYear": "2013", + "make": "SDL", + "model": "Generic", + "modelYear": "2019", "trim": "SE" }, "SyncMessageVersion": { -- cgit v1.2.1 From 6385c985c7a8b07d2ded26548fa484ca1189b82a Mon Sep 17 00:00:00 2001 From: JackLivio Date: Mon, 14 Jan 2019 16:27:22 -0500 Subject: Add lock for pending device map --- .../include/application_manager/application_manager_impl.h | 2 ++ src/components/application_manager/src/application_manager_impl.cc | 5 +++++ 2 files changed, 7 insertions(+) diff --git a/src/components/application_manager/include/application_manager/application_manager_impl.h b/src/components/application_manager/include/application_manager/application_manager_impl.h index 08421615d4..8c062f9016 100644 --- a/src/components/application_manager/include/application_manager/application_manager_impl.h +++ b/src/components/application_manager/include/application_manager/application_manager_impl.h @@ -1468,6 +1468,8 @@ class ApplicationManagerImpl DeviceMap secondary_transport_devices_cache_; + mutable std::shared_ptr + pending_device_map_lock_ptr_; std::map pending_device_map_; #ifdef TELEMETRY_MONITOR diff --git a/src/components/application_manager/src/application_manager_impl.cc b/src/components/application_manager/src/application_manager_impl.cc index 97d5e66b6b..16ab32dcd2 100644 --- a/src/components/application_manager/src/application_manager_impl.cc +++ b/src/components/application_manager/src/application_manager_impl.cc @@ -168,6 +168,7 @@ ApplicationManagerImpl::ApplicationManagerImpl( , navi_close_app_timeout_(am_settings.stop_streaming_timeout()) , navi_end_stream_timeout_(am_settings.stop_streaming_timeout()) , state_ctrl_(*this) + , pending_device_map_lock_ptr_(std::make_shared()) , application_list_update_timer_( "AM ListUpdater", new TimerTaskImpl( @@ -820,6 +821,7 @@ void ApplicationManagerImpl::RefreshCloudAppInformation() { bool enabled = true; // Store old device map and clear the current map + pending_device_map_lock_ptr_->Acquire(); std::map old_device_map = pending_device_map_; pending_device_map_ = std::map(); for (; it != end; ++it) { @@ -841,6 +843,7 @@ void ApplicationManagerImpl::RefreshCloudAppInformation() { connection_handler().AddCloudAppDevice(*it, endpoint, cloud_transport_type); } + pending_device_map_lock_ptr_->Release(); int removed_app_count = 0; // Clear out devices for existing cloud apps that were disabled @@ -898,10 +901,12 @@ void ApplicationManagerImpl::CreatePendingApplication( std::string hybrid_app_preference_str = ""; bool enabled = true; std::string name = device_info.name(); + pending_device_map_lock_ptr_->Acquire(); auto it = pending_device_map_.find(name); if (it == pending_device_map_.end()) { return; } + pending_device_map_lock_ptr_->Release(); const std::string policy_app_id = it->second; -- cgit v1.2.1 From 899736a8675c63d721d995dc1804789e99631161 Mon Sep 17 00:00:00 2001 From: jacobkeeler Date: Tue, 15 Jan 2019 15:59:28 -0500 Subject: Fix reconnect flow after modified disconnect flow --- .../application_manager/src/application_manager_impl.cc | 4 +++- .../src/cloud/cloud_websocket_transport_adapter.cc | 6 ++++++ .../src/cloud/websocket_client_connection.cc | 1 - .../src/transport_adapter/transport_adapter_impl.cc | 16 +++++++--------- 4 files changed, 16 insertions(+), 11 deletions(-) diff --git a/src/components/application_manager/src/application_manager_impl.cc b/src/components/application_manager/src/application_manager_impl.cc index ba268a7c3f..8187be6f1e 100644 --- a/src/components/application_manager/src/application_manager_impl.cc +++ b/src/components/application_manager/src/application_manager_impl.cc @@ -838,9 +838,9 @@ void ApplicationManagerImpl::RefreshCloudAppInformation() { auto old_device = old_device_map.find(endpoint); if (old_device_map.find(endpoint) != old_device_map.end()) { old_device_map.erase(old_device); - continue; } + // If the device was disconnected, this will reinitialize the device connection_handler().AddCloudAppDevice(*it, endpoint, cloud_transport_type); } pending_device_map_lock_ptr_->Release(); @@ -1252,6 +1252,7 @@ void ApplicationManagerImpl::OnDeviceListUpdated( so_to_send[jhs::S_PARAMS][jhs::S_CORRELATION_ID] = GetNextHMICorrelationID(); so_to_send[jhs::S_MSG_PARAMS] = *msg_params; rpc_service_->ManageHMICommand(update_list); + RefreshCloudAppInformation(); } void ApplicationManagerImpl::OnFindNewApplicationsRequest() { @@ -2728,6 +2729,7 @@ void ApplicationManagerImpl::UnregisterApplication( logger_, "There is no more SDL4 apps with device handle: " << handle); RemoveAppsWaitingForRegistration(handle); + RefreshCloudAppInformation(); SendUpdateAppList(); } } diff --git a/src/components/transport_manager/src/cloud/cloud_websocket_transport_adapter.cc b/src/components/transport_manager/src/cloud/cloud_websocket_transport_adapter.cc index 5093e6c2af..9f2b8e6ade 100644 --- a/src/components/transport_manager/src/cloud/cloud_websocket_transport_adapter.cc +++ b/src/components/transport_manager/src/cloud/cloud_websocket_transport_adapter.cc @@ -64,6 +64,12 @@ bool CloudWebsocketTransportAdapter::Restore() { } void CloudWebsocketTransportAdapter::CreateDevice(const std::string& uid) { + // If the device has already been created, just ignore the request + DeviceSptr device = FindDevice(uid); + if (device.use_count() != 0) { + return; + } + boost::regex pattern( "(wss?):\\/\\/([A-Z\\d\\.-]{2,})\\.?([A-Z]{2,})?(:\\d{2,4})\\/", boost::regex::icase); diff --git a/src/components/transport_manager/src/cloud/websocket_client_connection.cc b/src/components/transport_manager/src/cloud/websocket_client_connection.cc index 22ee9582f4..37721e9591 100644 --- a/src/components/transport_manager/src/cloud/websocket_client_connection.cc +++ b/src/components/transport_manager/src/cloud/websocket_client_connection.cc @@ -138,7 +138,6 @@ void WebsocketClientConnection::OnRead(boost::system::error_code ec, ws_->lowest_layer().close(); ioc_.stop(); Shutdown(); - controller_->ConnectPending(device_uid_, app_handle_); return; } std::string data_str = boost::beast::buffers_to_string(buffer_.data()); diff --git a/src/components/transport_manager/src/transport_adapter/transport_adapter_impl.cc b/src/components/transport_manager/src/transport_adapter/transport_adapter_impl.cc index 13474c03ab..335770bea7 100644 --- a/src/components/transport_manager/src/transport_adapter/transport_adapter_impl.cc +++ b/src/components/transport_manager/src/transport_adapter/transport_adapter_impl.cc @@ -858,25 +858,23 @@ DeviceSptr TransportAdapterImpl::FindDevice(const DeviceUID& device_id) const { void TransportAdapterImpl::ConnectPending(const DeviceUID& device_id, const ApplicationHandle& app_handle) { + LOG4CXX_AUTO_TRACE(logger_); connections_lock_.AcquireForWriting(); ConnectionMap::iterator it_conn = connections_.find(std::make_pair(device_id, app_handle)); if (it_conn != connections_.end()) { ConnectionInfo& info = it_conn->second; - if (info.state == ConnectionInfo::ESTABLISHED) { - LOG4CXX_DEBUG(logger_, "Reset Connection Pointer"); - connections_.erase(std::make_pair(device_id, app_handle)); - - connections_lock_.Release(); - CreateDevice(device_id); - connections_lock_.AcquireForWriting(); - } info.state = ConnectionInfo::PENDING; } connections_lock_.Release(); DeviceSptr device = FindDevice(device_id); - device->set_connection_status(ConnectionStatus::PENDING); + if (device.use_count() == 0) { + LOG4CXX_ERROR( + logger_, "Unable to find device, cannot set connection pending status"); + } else { + device->set_connection_status(ConnectionStatus::PENDING); + } for (TransportAdapterListenerList::iterator it = listeners_.begin(); it != listeners_.end(); -- cgit v1.2.1 From 58f566fcd3dc305e6e9d9edaca6ee90968149790 Mon Sep 17 00:00:00 2001 From: jacobkeeler Date: Tue, 15 Jan 2019 16:42:30 -0500 Subject: Address review comments --- .../src/application_manager_impl.cc | 40 +++++++++++++--------- 1 file changed, 24 insertions(+), 16 deletions(-) diff --git a/src/components/application_manager/src/application_manager_impl.cc b/src/components/application_manager/src/application_manager_impl.cc index 16ab32dcd2..edf4be561b 100644 --- a/src/components/application_manager/src/application_manager_impl.cc +++ b/src/components/application_manager/src/application_manager_impl.cc @@ -168,7 +168,8 @@ ApplicationManagerImpl::ApplicationManagerImpl( , navi_close_app_timeout_(am_settings.stop_streaming_timeout()) , navi_end_stream_timeout_(am_settings.stop_streaming_timeout()) , state_ctrl_(*this) - , pending_device_map_lock_ptr_(std::make_shared()) + , pending_device_map_lock_ptr_( + std::make_shared()) , application_list_update_timer_( "AM ListUpdater", new TimerTaskImpl( @@ -811,8 +812,8 @@ void ApplicationManagerImpl::RefreshCloudAppInformation() { LOG4CXX_AUTO_TRACE(logger_); std::vector enabled_apps; GetPolicyHandler().GetEnabledCloudApps(enabled_apps); - std::vector::iterator it = enabled_apps.begin(); - std::vector::iterator end = enabled_apps.end(); + std::vector::iterator enabled_it = enabled_apps.begin(); + std::vector::iterator enabled_end = enabled_apps.end(); std::string endpoint = ""; std::string certificate = ""; std::string auth_token = ""; @@ -824,8 +825,9 @@ void ApplicationManagerImpl::RefreshCloudAppInformation() { pending_device_map_lock_ptr_->Acquire(); std::map old_device_map = pending_device_map_; pending_device_map_ = std::map(); - for (; it != end; ++it) { - GetPolicyHandler().GetCloudAppParameters(*it, + // Create a device for each newly enabled cloud app + for (; enabled_it != enabled_end; ++enabled_it) { + GetPolicyHandler().GetCloudAppParameters(*enabled_it, enabled, endpoint, certificate, @@ -834,14 +836,17 @@ void ApplicationManagerImpl::RefreshCloudAppInformation() { hybrid_app_preference); pending_device_map_.insert( - std::pair(endpoint, *it)); - auto old_device = old_device_map.find(endpoint); - if (old_device_map.find(endpoint) != old_device_map.end()) { - old_device_map.erase(old_device); + std::pair(endpoint, *enabled_it)); + // Determine which endpoints were disabled by erasing all enabled apps from + // the old device list + auto old_device_it = old_device_map.find(endpoint); + if (old_device_it != old_device_map.end()) { + old_device_map.erase(old_device_it); continue; } - connection_handler().AddCloudAppDevice(*it, endpoint, cloud_transport_type); + connection_handler().AddCloudAppDevice( + *enabled_it, endpoint, cloud_transport_type); } pending_device_map_lock_ptr_->Release(); @@ -849,24 +854,26 @@ void ApplicationManagerImpl::RefreshCloudAppInformation() { // Clear out devices for existing cloud apps that were disabled for (auto& device : old_device_map) { std::string policy_app_id = device.second; + // First search for the disabled app within the registered apps ApplicationSharedPtr app = application_by_policy_id(policy_app_id); if (app.use_count() == 0) { sync_primitives::AutoLock lock(apps_to_register_list_lock_ptr_); + // If the disabled app is not present in the registered app list, check + // the apps awaiting registration PolicyAppIdPredicate finder(policy_app_id); ApplicationSet::iterator it = std::find_if( apps_to_register_.begin(), apps_to_register_.end(), finder); if (it == apps_to_register_.end()) { + LOG4CXX_DEBUG(logger_, + "Unable to find app to remove (" << policy_app_id + << "), skipping"); continue; } app = *it; apps_to_register_.erase(it); } - if (app.use_count() == 0) { - LOG4CXX_DEBUG(logger_, - "Unable to find app to remove (" << policy_app_id - << "), skipping"); - continue; - } + // If the disabled app is registered, unregistered it before destroying the + // device if (app->IsRegistered() && app->is_cloud_app()) { LOG4CXX_DEBUG(logger_, "Disabled app is registered, unregistering now"); GetRPCService().ManageMobileCommand( @@ -877,6 +884,7 @@ void ApplicationManagerImpl::RefreshCloudAppInformation() { OnAppUnauthorized(app->app_id()); } + // Delete the cloud device connection_handler().RemoveCloudAppDevice(app->device()); removed_app_count++; } -- cgit v1.2.1 From b772ded120bd7adefe998d70e97f06471dd47adf Mon Sep 17 00:00:00 2001 From: JackLivio Date: Wed, 16 Jan 2019 10:58:32 -0500 Subject: Address Comments --- .../src/application_manager_impl.cc | 3 +- .../cloud/websocket_client_connection.h | 4 +-- .../cloud/cloud_websocket_connection_factory.cc | 2 +- .../src/cloud/websocket_client_connection.cc | 32 +++++++++++----------- 4 files changed, 20 insertions(+), 21 deletions(-) diff --git a/src/components/application_manager/src/application_manager_impl.cc b/src/components/application_manager/src/application_manager_impl.cc index 8187be6f1e..3535b486aa 100644 --- a/src/components/application_manager/src/application_manager_impl.cc +++ b/src/components/application_manager/src/application_manager_impl.cc @@ -168,7 +168,8 @@ ApplicationManagerImpl::ApplicationManagerImpl( , navi_close_app_timeout_(am_settings.stop_streaming_timeout()) , navi_end_stream_timeout_(am_settings.stop_streaming_timeout()) , state_ctrl_(*this) - , pending_device_map_lock_ptr_(std::make_shared()) + , pending_device_map_lock_ptr_( + std::make_shared()) , application_list_update_timer_( "AM ListUpdater", new TimerTaskImpl( diff --git a/src/components/transport_manager/include/transport_manager/cloud/websocket_client_connection.h b/src/components/transport_manager/include/transport_manager/cloud/websocket_client_connection.h index f9a134b1fa..d4319dfe0f 100644 --- a/src/components/transport_manager/include/transport_manager/cloud/websocket_client_connection.h +++ b/src/components/transport_manager/include/transport_manager/cloud/websocket_client_connection.h @@ -128,7 +128,7 @@ class WebsocketClientConnection TransportAdapterController* controller_; boost::asio::io_context ioc_; tcp::resolver resolver_; - std::shared_ptr > ws_; + websocket::stream ws_; boost::beast::flat_buffer buffer_; std::string host_; std::string text_; @@ -172,9 +172,7 @@ class WebsocketClientConnection const DeviceUID device_uid_; const ApplicationHandle app_handle_; - bool first_run_; boost::asio::thread_pool io_pool_; - bool dead_; }; } // namespace transport_adapter diff --git a/src/components/transport_manager/src/cloud/cloud_websocket_connection_factory.cc b/src/components/transport_manager/src/cloud/cloud_websocket_connection_factory.cc index 3db97feed2..0d9fda6fe5 100644 --- a/src/components/transport_manager/src/cloud/cloud_websocket_connection_factory.cc +++ b/src/components/transport_manager/src/cloud/cloud_websocket_connection_factory.cc @@ -60,7 +60,7 @@ TransportAdapter::Error CloudWebsocketConnectionFactory::CreateConnection( std::shared_ptr ws_connection = std::dynamic_pointer_cast(connection); - if (!ws_connection) { + if (ws_connection.use_count() == 0) { return TransportAdapter::Error::BAD_PARAM; } diff --git a/src/components/transport_manager/src/cloud/websocket_client_connection.cc b/src/components/transport_manager/src/cloud/websocket_client_connection.cc index 37721e9591..2947c510ff 100644 --- a/src/components/transport_manager/src/cloud/websocket_client_connection.cc +++ b/src/components/transport_manager/src/cloud/websocket_client_connection.cc @@ -48,7 +48,7 @@ WebsocketClientConnection::WebsocketClientConnection( TransportAdapterController* controller) : controller_(controller) , resolver_(ioc_) - , ws_(std::make_shared >(ioc_)) + , ws_(ioc_) , shutdown_(false) , thread_delegate_(new LoopThreadDelegate(&message_queue_, this)) , write_thread_(threads::CreateThread("WS Async Send", thread_delegate_)) @@ -74,7 +74,7 @@ TransportAdapter::Error WebsocketClientConnection::Start() { LOG4CXX_ERROR(logger_, "Could not resolve host/port: " << str_err); return TransportAdapter::FAIL; } - boost::asio::connect(ws_->next_layer(), results.begin(), results.end(), ec); + boost::asio::connect(ws_.next_layer(), results.begin(), results.end(), ec); if (ec) { std::string str_err = "ErrorMessage: " + ec.message(); LOG4CXX_ERROR(logger_, @@ -82,7 +82,7 @@ TransportAdapter::Error WebsocketClientConnection::Start() { LOG4CXX_ERROR(logger_, str_err); return TransportAdapter::FAIL; } - ws_->handshake(host, "/", ec); + ws_.handshake(host, "/", ec); if (ec) { std::string str_err = "ErrorMessage: " + ec.message(); LOG4CXX_ERROR(logger_, @@ -91,16 +91,16 @@ TransportAdapter::Error WebsocketClientConnection::Start() { LOG4CXX_ERROR(logger_, str_err); return TransportAdapter::FAIL; } - ws_->binary(true); + ws_.binary(true); write_thread_->start(threads::ThreadOptions()); controller_->ConnectDone(device_uid_, app_handle_); // Start async read - ws_->async_read(buffer_, - std::bind(&WebsocketClientConnection::OnRead, - this, - std::placeholders::_1, - std::placeholders::_2)); + ws_.async_read(buffer_, + std::bind(&WebsocketClientConnection::OnRead, + this, + std::placeholders::_1, + std::placeholders::_2)); boost::asio::post(io_pool_, [&]() { ioc_.run(); }); @@ -122,11 +122,11 @@ void WebsocketClientConnection::Recv(boost::system::error_code ec) { return; } - ws_->async_read(buffer_, - std::bind(&WebsocketClientConnection::OnRead, - this, - std::placeholders::_1, - std::placeholders::_2)); + ws_.async_read(buffer_, + std::bind(&WebsocketClientConnection::OnRead, + this, + std::placeholders::_1, + std::placeholders::_2)); } void WebsocketClientConnection::OnRead(boost::system::error_code ec, @@ -135,7 +135,7 @@ void WebsocketClientConnection::OnRead(boost::system::error_code ec, if (ec) { std::string str_err = "ErrorMessage: " + ec.message(); LOG4CXX_ERROR(logger_, str_err); - ws_->lowest_layer().close(); + ws_.lowest_layer().close(); ioc_.stop(); Shutdown(); return; @@ -209,7 +209,7 @@ void WebsocketClientConnection::LoopThreadDelegate::DrainQueue() { message_queue_.pop(message_ptr); if (!shutdown_) { boost::system::error_code ec; - handler_.ws_->write( + handler_.ws_.write( boost::asio::buffer(message_ptr->data(), message_ptr->data_size())); if (ec) { LOG4CXX_ERROR(logger_, "Error writing to websocket"); -- cgit v1.2.1 From 1c90d11854c8e1144d4ca0cfa9672ef9e7cc3edd Mon Sep 17 00:00:00 2001 From: JackLivio Date: Sun, 20 Jan 2019 14:00:59 -0500 Subject: Address Comments --- .../transport_adapter/mock_transport_adapter_controller.h | 2 +- src/components/transport_manager/test/transport_adapter_test.cc | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/src/components/transport_manager/test/include/transport_manager/transport_adapter/mock_transport_adapter_controller.h b/src/components/transport_manager/test/include/transport_manager/transport_adapter/mock_transport_adapter_controller.h index bd8c5d2ed3..642c193d63 100644 --- a/src/components/transport_manager/test/include/transport_manager/transport_adapter/mock_transport_adapter_controller.h +++ b/src/components/transport_manager/test/include/transport_manager/transport_adapter/mock_transport_adapter_controller.h @@ -44,7 +44,7 @@ using namespace ::transport_manager::transport_adapter; class MockTransportAdapterController : public TransportAdapterController { public: - MOCK_METHOD1(AddDevice, DeviceSptr(std::string device)); + MOCK_METHOD1(AddDevice, DeviceSptr(DeviceSptr device)); MOCK_METHOD1(SearchDeviceDone, void(DeviceVector device)); MOCK_METHOD1(ApplicationListUpdated, ApplicationListUpdated(const DeviceUID& device_handle)); diff --git a/src/components/transport_manager/test/transport_adapter_test.cc b/src/components/transport_manager/test/transport_adapter_test.cc index 72cf0ba76e..dafabf4504 100644 --- a/src/components/transport_manager/test/transport_adapter_test.cc +++ b/src/components/transport_manager/test/transport_adapter_test.cc @@ -504,7 +504,6 @@ TEST_F(TransportAdapterTest, DisconnectDevice_DeviceAddedConnectionCreated) { .WillOnce(Return(TransportAdapter::OK)); EXPECT_CALL(transport_adapter, FindDevice(uniq_id)) .WillRepeatedly(Return(mockdev)); - // EXPECT_CALL(transport_adapter, ConnectionStatusUpdated(_, _)); TransportAdapter::Error res = transport_adapter.ConnectDevice(uniq_id); EXPECT_EQ(TransportAdapter::OK, res); EXPECT_EQ(ConnectionStatus::CONNECTED, mockdev->connection_status()); @@ -515,7 +514,6 @@ TEST_F(TransportAdapterTest, DisconnectDevice_DeviceAddedConnectionCreated) { EXPECT_CALL(*mock_connection, Disconnect()) .WillOnce(Return(TransportAdapter::OK)); - // EXPECT_CALL(transport_adapter, ConnectionStatusUpdated(_, _)); TransportAdapter::Error new_res = transport_adapter.DisconnectDevice(uniq_id); EXPECT_EQ(TransportAdapter::OK, new_res); EXPECT_EQ(ConnectionStatus::CLOSING, mockdev->connection_status()); -- cgit v1.2.1 From 18c1984eb33d846b7cdb1ee0a5d79fdfd0d2fb78 Mon Sep 17 00:00:00 2001 From: jacobkeeler Date: Sun, 20 Jan 2019 15:24:15 -0500 Subject: Add basic handling of app service producer RPCs --- .../application_manager/rpc_plugins/CMakeLists.txt | 1 + .../app_service_rpc_plugin/CMakeLists.txt | 80 ++++++++ .../app_service_command_factory.h | 66 ++++++ .../app_service_hmi_command_factory.h | 75 +++++++ .../app_service_mobile_command_factory.h | 75 +++++++ .../app_service_rpc_plugin.h | 81 ++++++++ .../commands/hmi/as_publish_app_service_request.h | 78 ++++++++ .../commands/hmi/as_publish_app_service_response.h | 78 ++++++++ .../hmi/on_as_app_service_data_notification.h | 79 ++++++++ .../on_as_app_service_data_notification_from_hmi.h | 78 ++++++++ .../mobile/on_app_service_data_notification.h | 79 ++++++++ .../on_app_service_data_notification_from_mobile.h | 79 ++++++++ .../commands/mobile/publish_app_service_request.h | 79 ++++++++ .../commands/mobile/publish_app_service_response.h | 79 ++++++++ .../src/app_service_command_factory.cc | 72 +++++++ .../src/app_service_hmi_command_factory.cc | 119 +++++++++++ .../src/app_service_mobile_command_factory.cc | 118 +++++++++++ .../src/app_service_rpc_plugin.cc | 85 ++++++++ .../commands/hmi/as_publish_app_service_request.cc | 65 ++++++ .../hmi/as_publish_app_service_response.cc | 60 ++++++ .../hmi/on_as_app_service_data_notification.cc | 62 ++++++ ...on_as_app_service_data_notification_from_hmi.cc | 61 ++++++ .../mobile/on_app_service_data_notification.cc | 65 ++++++ ...on_app_service_data_notification_from_mobile.cc | 65 ++++++ .../commands/mobile/publish_app_service_request.cc | 65 ++++++ .../mobile/publish_app_service_response.cc | 63 ++++++ src/components/interfaces/HMI_API.xml | 216 ++++++++++++++++++++ src/components/interfaces/MOBILE_API.xml | 221 +++++++++++++++++++++ 28 files changed, 2344 insertions(+) create mode 100644 src/components/application_manager/rpc_plugins/app_service_rpc_plugin/CMakeLists.txt create mode 100644 src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/app_service_command_factory.h create mode 100644 src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/app_service_hmi_command_factory.h create mode 100644 src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/app_service_mobile_command_factory.h create mode 100644 src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/app_service_rpc_plugin.h create mode 100644 src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/hmi/as_publish_app_service_request.h create mode 100644 src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/hmi/as_publish_app_service_response.h create mode 100644 src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/hmi/on_as_app_service_data_notification.h create mode 100644 src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/hmi/on_as_app_service_data_notification_from_hmi.h create mode 100644 src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/mobile/on_app_service_data_notification.h create mode 100644 src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/mobile/on_app_service_data_notification_from_mobile.h create mode 100644 src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/mobile/publish_app_service_request.h create mode 100644 src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/mobile/publish_app_service_response.h create mode 100644 src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/app_service_command_factory.cc create mode 100644 src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/app_service_hmi_command_factory.cc create mode 100644 src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/app_service_mobile_command_factory.cc create mode 100644 src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/app_service_rpc_plugin.cc create mode 100644 src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_publish_app_service_request.cc create mode 100644 src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_publish_app_service_response.cc create mode 100644 src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/on_as_app_service_data_notification.cc create mode 100644 src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/on_as_app_service_data_notification_from_hmi.cc create mode 100644 src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/on_app_service_data_notification.cc create mode 100644 src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/on_app_service_data_notification_from_mobile.cc create mode 100644 src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/publish_app_service_request.cc create mode 100644 src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/publish_app_service_response.cc diff --git a/src/components/application_manager/rpc_plugins/CMakeLists.txt b/src/components/application_manager/rpc_plugins/CMakeLists.txt index c9ef282c12..e4f0051738 100644 --- a/src/components/application_manager/rpc_plugins/CMakeLists.txt +++ b/src/components/application_manager/rpc_plugins/CMakeLists.txt @@ -32,3 +32,4 @@ add_subdirectory(vehicle_info_plugin) add_subdirectory(sdl_rpc_plugin) add_subdirectory(rc_rpc_plugin) +add_subdirectory(app_service_rpc_plugin) \ No newline at end of file diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/CMakeLists.txt b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/CMakeLists.txt new file mode 100644 index 0000000000..e254c36587 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/CMakeLists.txt @@ -0,0 +1,80 @@ +# Copyright (c) 2019, Ford Motor Company, Livio +# 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 copyright holders nor the names of their 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_directories(include) + +set (COMMANDS_SOURCE_DIR + ${CMAKE_CURRENT_SOURCE_DIR}/src/commands +) + +set (MOBILE_COMMANDS_SOURCE_DIR + ${COMMANDS_SOURCE_DIR}/mobile +) + +set (HMI_COMMANDS_SOURCE_DIR + ${COMMANDS_SOURCE_DIR}/hmi +) + +collect_sources(MOBILE_COMMANDS "${MOBILE_COMMANDS_SOURCE_DIR}") +collect_sources(HMI_COMMANDS "${HMI_COMMANDS_SOURCE_DIR}") +collect_sources(PLUGIN_SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/src") +collect_sources(COMMANDS_SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/src/commands") + +set(LIBRARIES + HMI_API + MOBILE_API + ApplicationManager + v4_protocol_v1_2_no_extra + SmartObjects + Utils +) + +if(ENABLE_LOG) + list(APPEND LIBRARIES log4cxx -L${LOG4CXX_LIBS_DIRECTORY}) +endif() + +add_library("app_service_rpc_plugin" SHARED ${PLUGIN_SOURCES} ${MOBILE_COMMANDS} ${HMI_COMMANDS} ${COMMANDS_SOURCES}) +target_link_libraries("app_service_rpc_plugin" ${LIBRARIES}) + +add_library("AppServiceRpcPluginStaticLib" ${PLUGIN_SOURCES} ${MOBILE_COMMANDS} ${HMI_COMMANDS}) +target_link_libraries("AppServiceRpcPluginStaticLib" ${LIBRARIES}) + +set(INSTALL_DESTINATION bin) + +install(TARGETS app_service_rpc_plugin + DESTINATION ${INSTALL_DESTINATION} + PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE + GROUP_READ GROUP_EXECUTE + WORLD_READ WORLD_EXECUTE +) + +if(BUILD_TESTS) + # add_subdirectory(test) +endif() diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/app_service_command_factory.h b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/app_service_command_factory.h new file mode 100644 index 0000000000..193b79e26f --- /dev/null +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/app_service_command_factory.h @@ -0,0 +1,66 @@ +/* + Copyright (c) 2019, Ford Motor Company, Livio + 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 the copyright holders nor the names of their + 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. + */ + +#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_APP_SERVICE_RPC_PLUGIN_INCLUDE_APP_SERVICE_RPC_PLUGIN_SDL_COMMAND_FACTORY_H +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_APP_SERVICE_RPC_PLUGIN_INCLUDE_APP_SERVICE_RPC_PLUGIN_SDL_COMMAND_FACTORY_H + +#include "app_service_rpc_plugin/app_service_hmi_command_factory.h" +#include "app_service_rpc_plugin/app_service_mobile_command_factory.h" +#include "application_manager/application_manager.h" + +namespace app_service_rpc_plugin { +namespace commands = application_manager::commands; +namespace app_mngr = application_manager; + +class AppServiceCommandFactory : public app_mngr::CommandFactory { + public: + AppServiceCommandFactory(app_mngr::ApplicationManager& app_manager, + app_mngr::rpc_service::RPCService& rpc_service, + app_mngr::HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handler); + virtual ~AppServiceCommandFactory(); + + app_mngr::CommandSharedPtr CreateCommand( + const app_mngr::commands::MessageSharedPtr& message, + app_mngr::commands::Command::CommandSource source) OVERRIDE; + + bool IsAbleToProcess( + const int32_t, + const application_manager::commands::Command::CommandSource) + const OVERRIDE; + + private: + std::unique_ptr hmi_command_factory_; + std::unique_ptr mobile_command_factory_; +}; +} // namespace app_service_rpc_plugin +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_APP_SERVICE_RPC_PLUGIN_INCLUDE_APP_SERVICE_RPC_PLUGIN_SDL_COMMAND_FACTORY_H diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/app_service_hmi_command_factory.h b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/app_service_hmi_command_factory.h new file mode 100644 index 0000000000..dfe333b881 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/app_service_hmi_command_factory.h @@ -0,0 +1,75 @@ +/* + Copyright (c) 2019, Ford Motor Company, Livio + 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 the copyright holders nor the names of their + 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. + */ + +#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_APP_SERVICE_RPC_PLUGIN_INCLUDE_APP_SERVICE_RPC_PLUGIN_APP_SERVICE_RPC_HMI_COMMAND_FACTORY_H +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_APP_SERVICE_RPC_PLUGIN_INCLUDE_APP_SERVICE_RPC_PLUGIN_APP_SERVICE_RPC_HMI_COMMAND_FACTORY_H + +#include "application_manager/application_manager.h" + +namespace app_service_rpc_plugin { +namespace app_mngr = application_manager; + +/** + * @brief The vehicle info hmi command factory. + */ +class AppServiceHmiCommandFactory : public app_mngr::CommandFactory { + public: + AppServiceHmiCommandFactory( + app_mngr::ApplicationManager& application_manager, + app_mngr::rpc_service::RPCService& rpc_service, + app_mngr::HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handler); + + app_mngr::CommandSharedPtr CreateCommand( + const app_mngr::commands::MessageSharedPtr& message, + app_mngr::commands::Command::CommandSource source) OVERRIDE; + + bool IsAbleToProcess( + const int32_t function_id, + const app_mngr::commands::Command::CommandSource source) const OVERRIDE; + + private: + app_mngr::ApplicationManager& application_manager_; + app_mngr::rpc_service::RPCService& rpc_service_; + app_mngr::HMICapabilities& hmi_capabilities_; + policy::PolicyHandlerInterface& policy_handler_; + + app_mngr::CommandCreator& buildCommandCreator( + const int32_t function_id, + const int32_t message_type, + const app_mngr::commands::Command::CommandSource source) const; + + DISALLOW_COPY_AND_ASSIGN(AppServiceHmiCommandFactory); +}; +} // namespace app_service_rpc_plugin + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_APP_SERVICE_RPC_PLUGIN_INCLUDE_APP_SERVICE_RPC_PLUGIN_APP_SERVICE_RPC_HMI_COMMAND_FACTORY_H diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/app_service_mobile_command_factory.h b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/app_service_mobile_command_factory.h new file mode 100644 index 0000000000..bd1e10f267 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/app_service_mobile_command_factory.h @@ -0,0 +1,75 @@ +/* + Copyright (c) 2019, Ford Motor Company, Livio + 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 the copyright holders nor the names of their + 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. + */ + +#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_APP_SERVICE_RPC_PLUGIN_INCLUDE_APP_SERVICE_RPC_PLUGIN_APP_SERVICE_RPC_MOBILE_COMMAND_FACTORY_H +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_APP_SERVICE_RPC_PLUGIN_INCLUDE_APP_SERVICE_RPC_PLUGIN_APP_SERVICE_RPC_MOBILE_COMMAND_FACTORY_H + +#include "application_manager/application_manager.h" + +namespace app_service_rpc_plugin { +namespace app_mngr = application_manager; + +/** + * @brief The vehicle info mobile command factory. + */ +class AppServiceMobileCommandFactory : public app_mngr::CommandFactory { + public: + AppServiceMobileCommandFactory( + app_mngr::ApplicationManager& application_manager, + app_mngr::rpc_service::RPCService& rpc_service, + app_mngr::HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handler); + + app_mngr::CommandSharedPtr CreateCommand( + const app_mngr::commands::MessageSharedPtr& message, + app_mngr::commands::Command::CommandSource source) OVERRIDE; + + bool IsAbleToProcess( + const int32_t function_id, + const app_mngr::commands::Command::CommandSource source) const OVERRIDE; + + private: + app_mngr::ApplicationManager& application_manager_; + app_mngr::rpc_service::RPCService& rpc_service_; + app_mngr::HMICapabilities& hmi_capabilities_; + policy::PolicyHandlerInterface& policy_handler_; + + app_mngr::CommandCreator& buildCommandCreator( + const int32_t function_id, + const int32_t message_type, + const app_mngr::commands::Command::CommandSource source) const; + + DISALLOW_COPY_AND_ASSIGN(AppServiceMobileCommandFactory); +}; +} // namespace app_service_rpc_plugin + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_APP_SERVICE_RPC_PLUGIN_INCLUDE_APP_SERVICE_RPC_PLUGIN_APP_SERVICE_RPC_MOBILE_COMMAND_FACTORY_H diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/app_service_rpc_plugin.h b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/app_service_rpc_plugin.h new file mode 100644 index 0000000000..398711b7a7 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/app_service_rpc_plugin.h @@ -0,0 +1,81 @@ +/* + Copyright (c) 2019, Ford Motor Company, Livio + 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 the copyright holders nor the names of their + 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. + */ + +#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_app_service_PLUGIN_INCLUDE_app_service_PLUGIN_app_service_PLUGIN_H +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_app_service_PLUGIN_INCLUDE_app_service_PLUGIN_app_service_PLUGIN_H + +#include "application_manager/command_factory.h" + +namespace app_service_rpc_plugin { +//class AppServiceAppExtension; +namespace app_mngr = application_manager; +namespace plugins = application_manager::plugin_manager; + +class AppServiceRpcPlugin : public plugins::RPCPlugin { + public: + AppServiceRpcPlugin(); + + bool Init(app_mngr::ApplicationManager& application_manager, + app_mngr::rpc_service::RPCService& rpc_service, + app_mngr::HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handler) OVERRIDE; + + bool IsAbleToProcess( + const int32_t function_id, + const app_mngr::commands::Command::CommandSource source) OVERRIDE; + + std::string PluginName() OVERRIDE; + app_mngr::CommandFactory& GetCommandFactory() OVERRIDE; + + void OnPolicyEvent(plugins::PolicyEvent event) OVERRIDE; + void OnApplicationEvent(plugins::ApplicationEvent event, + app_mngr::ApplicationSharedPtr application) OVERRIDE; + + /** + * @brief ProcessResumptionSubscription send Subscribe vehicle data requests + * to HMI + * @param app application for subscription + * @param ext application extension + */ + // TODO + //void ProcessResumptionSubscription(app_mngr::Application& app, + // AppServiceAppExtension& ext); + + private: + std::unique_ptr command_factory_; + app_mngr::ApplicationManager* application_manager_; +}; +} // namespace app_service_rpc_plugin + +extern "C" application_manager::plugin_manager::RPCPlugin* Create(); + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_app_service_PLUGIN_INCLUDE_app_service_PLUGIN_app_service_PLUGIN_H diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/hmi/as_publish_app_service_request.h b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/hmi/as_publish_app_service_request.h new file mode 100644 index 0000000000..75e6343c9e --- /dev/null +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/hmi/as_publish_app_service_request.h @@ -0,0 +1,78 @@ +/* + Copyright (c) 2019, Ford Motor Company, Livio + 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 the copyright holders nor the names of their + 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. + */ + +#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_APP_SERVICE_RPC_PLUGIN_INCLUDE_APP_SERVICE_RPC_PLUGIN_COMMANDS_HMI_AS_PUBLISH_APP_SERVICE_REQUEST_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_APP_SERVICE_RPC_PLUGIN_INCLUDE_APP_SERVICE_RPC_PLUGIN_COMMANDS_HMI_AS_PUBLISH_APP_SERVICE_REQUEST_H_ + +#include "application_manager/commands/request_from_hmi.h" + +namespace app_service_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief ASPublishAppServiceRequest command class + **/ +class ASPublishAppServiceRequest : public app_mngr::commands::RequestFromHMI { + public: + /** + * @brief ASPublishAppServiceRequest class constructor + * + * @param message Incoming SmartObject message + **/ + ASPublishAppServiceRequest( + const app_mngr::commands::MessageSharedPtr& message, + app_mngr::ApplicationManager& application_manager, + app_mngr::rpc_service::RPCService& rpc_service, + app_mngr::HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle); + + /** + * @brief ASPublishAppServiceRequest class destructor + **/ + virtual ~ASPublishAppServiceRequest(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(ASPublishAppServiceRequest); +}; + +} // namespace commands + +} // namespace app_service_rpc_plugin + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_APP_SERVICE_RPC_PLUGIN_INCLUDE_APP_SERVICE_RPC_PLUGIN_COMMANDS_HMI_AS_PUBLISH_APP_SERVICE_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/hmi/as_publish_app_service_response.h b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/hmi/as_publish_app_service_response.h new file mode 100644 index 0000000000..3943c5f293 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/hmi/as_publish_app_service_response.h @@ -0,0 +1,78 @@ +/* + Copyright (c) 2019, Ford Motor Company, Livio + 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 the copyright holders nor the names of their + 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. + */ + +#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_APP_SERVICE_RPC_PLUGIN_INCLUDE_APP_SERVICE_RPC_PLUGIN_COMMANDS_HMI_AS_PUBLISH_APP_SERVICE_RESPONSE_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_APP_SERVICE_RPC_PLUGIN_INCLUDE_APP_SERVICE_RPC_PLUGIN_COMMANDS_HMI_AS_PUBLISH_APP_SERVICE_RESPONSE_H_ + +#include "application_manager/commands/response_to_hmi.h" + +namespace app_service_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief ASPublishAppServiceResponse command class + **/ +class ASPublishAppServiceResponse : public app_mngr::commands::ResponseToHMI { + public: + /** + * @brief ASPublishAppServiceResponse class constructor + * + * @param message Incoming SmartObject message + **/ + ASPublishAppServiceResponse( + const app_mngr::commands::MessageSharedPtr& message, + app_mngr::ApplicationManager& application_manager, + app_mngr::rpc_service::RPCService& rpc_service, + app_mngr::HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle); + + /** + * @brief ASPublishAppServiceResponse class destructor + **/ + virtual ~ASPublishAppServiceResponse(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(ASPublishAppServiceResponse); +}; + +} // namespace commands + +} // namespace app_service_rpc_plugin + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_APP_SERVICE_RPC_PLUGIN_INCLUDE_APP_SERVICE_RPC_PLUGIN_COMMANDS_HMI_AS_PUBLISH_APP_SERVICE_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/hmi/on_as_app_service_data_notification.h b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/hmi/on_as_app_service_data_notification.h new file mode 100644 index 0000000000..5b2c40b26b --- /dev/null +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/hmi/on_as_app_service_data_notification.h @@ -0,0 +1,79 @@ +/* + Copyright (c) 2019, Ford Motor Company, Livio + 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 the copyright holders nor the names of their + 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. + */ + +#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_APP_SERVICE_RPC_PLUGIN_INCLUDE_APP_SERVICE_RPC_PLUGIN_COMMANDS_HMI_ON_AS_APP_SERVICE_DATA_NOTIFICATION_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_APP_SERVICE_RPC_PLUGIN_INCLUDE_APP_SERVICE_RPC_PLUGIN_COMMANDS_HMI_ON_AS_APP_SERVICE_DATA_NOTIFICATION_H_ + +#include "application_manager/commands/notification_to_hmi.h" + +namespace app_service_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief OnASAppServiceDataNotification command class + **/ +class OnASAppServiceDataNotification + : public app_mngr::commands::NotificationToHMI { + public: + /** + * @brief OnASAppServiceDataNotification class constructor + * + * @param message Incoming SmartObject message + **/ + OnASAppServiceDataNotification( + const app_mngr::commands::MessageSharedPtr& message, + app_mngr::ApplicationManager& application_manager, + app_mngr::rpc_service::RPCService& rpc_service, + app_mngr::HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle); + + /** + * @brief OnASAppServiceDataNotification class destructor + **/ + virtual ~OnASAppServiceDataNotification(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(OnASAppServiceDataNotification); +}; + +} // namespace commands + +} // namespace app_service_rpc_plugin + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_APP_SERVICE_RPC_PLUGIN_INCLUDE_APP_SERVICE_RPC_PLUGIN_COMMANDS_HMI_ON_AS_APP_SERVICE_DATA_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/hmi/on_as_app_service_data_notification_from_hmi.h b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/hmi/on_as_app_service_data_notification_from_hmi.h new file mode 100644 index 0000000000..9a7072590b --- /dev/null +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/hmi/on_as_app_service_data_notification_from_hmi.h @@ -0,0 +1,78 @@ +/* + Copyright (c) 2019, Ford Motor Company, Livio + 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 the copyright holders nor the names of their + 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. + */ + +#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_APP_SERVICE_RPC_PLUGIN_INCLUDE_APP_SERVICE_RPC_PLUGIN_COMMANDS_HMI_ON_AS_APP_SERVICE_DATA_NOTIFICATION_FROM_HMI_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_APP_SERVICE_RPC_PLUGIN_INCLUDE_APP_SERVICE_RPC_PLUGIN_COMMANDS_HMI_ON_AS_APP_SERVICE_DATA_NOTIFICATION_FROM_HMI_H_ + +#include "application_manager/commands/notification_from_hmi.h" + +namespace app_service_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief OnASAppServiceDataNotificationFromHMI command class + **/ +class OnASAppServiceDataNotificationFromHMI : public app_mngr::commands::NotificationFromHMI { + public: + /** + * @brief OnASAppServiceDataNotificationFromHMI class constructor + * + * @param message Incoming SmartObject message + **/ + OnASAppServiceDataNotificationFromHMI( + const app_mngr::commands::MessageSharedPtr& message, + app_mngr::ApplicationManager& application_manager, + app_mngr::rpc_service::RPCService& rpc_service, + app_mngr::HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle); + + /** + * @brief OnASAppServiceDataNotificationFromHMI class destructor + **/ + virtual ~OnASAppServiceDataNotificationFromHMI(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(OnASAppServiceDataNotificationFromHMI); +}; + +} // namespace commands + +} // namespace app_service_rpc_plugin + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_APP_SERVICE_RPC_PLUGIN_INCLUDE_APP_SERVICE_RPC_PLUGIN_COMMANDS_HMI_ON_AS_APP_SERVICE_DATA_NOTIFICATION_FROM_HMI_H_ diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/mobile/on_app_service_data_notification.h b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/mobile/on_app_service_data_notification.h new file mode 100644 index 0000000000..751fac7f94 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/mobile/on_app_service_data_notification.h @@ -0,0 +1,79 @@ +/* + Copyright (c) 2019, Ford Motor Company, Livio + 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 the copyright holders nor the names of their + 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. + */ + +#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_APP_SERVICE_RPC_PLUGIN_INCLUDE_APP_SERVICE_RPC_PLUGIN_COMMANDS_MOBILE_ON_APP_SERVICE_DATA_NOTIFICATION_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_APP_SERVICE_RPC_PLUGIN_INCLUDE_APP_SERVICE_RPC_PLUGIN_COMMANDS_MOBILE_ON_APP_SERVICE_DATA_NOTIFICATION_H_ + +#include "application_manager/commands/command_notification_impl.h" + +namespace app_service_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief OnAppServiceDataNotification command class + **/ +class OnAppServiceDataNotification + : public app_mngr::commands::CommandNotificationImpl { + public: + /** + * @brief OnAppServiceDataNotification class constructor + * + * @param message Incoming SmartObject message + **/ + OnAppServiceDataNotification( + const app_mngr::commands::MessageSharedPtr& message, + app_mngr::ApplicationManager& application_manager, + app_mngr::rpc_service::RPCService& rpc_service, + app_mngr::HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle); + + /** + * @brief OnAppServiceDataNotification class destructor + **/ + virtual ~OnAppServiceDataNotification(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(OnAppServiceDataNotification); +}; + +} // namespace commands + +} // namespace app_service_rpc_plugin + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_APP_SERVICE_RPC_PLUGIN_INCLUDE_APP_SERVICE_RPC_PLUGIN_COMMANDS_MOBILE_ON_APP_SERVICE_DATA_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/mobile/on_app_service_data_notification_from_mobile.h b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/mobile/on_app_service_data_notification_from_mobile.h new file mode 100644 index 0000000000..1d1b2170c2 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/mobile/on_app_service_data_notification_from_mobile.h @@ -0,0 +1,79 @@ +/* + Copyright (c) 2019, Ford Motor Company, Livio + 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 the copyright holders nor the names of their + 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. + */ + +#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_APP_SERVICE_RPC_PLUGIN_INCLUDE_APP_SERVICE_RPC_PLUGIN_COMMANDS_MOBILE_ON_APP_SERVICE_DATA_NOTIFICATION_FROM_MOBILE_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_APP_SERVICE_RPC_PLUGIN_INCLUDE_APP_SERVICE_RPC_PLUGIN_COMMANDS_MOBILE_ON_APP_SERVICE_DATA_NOTIFICATION_FROM_MOBILE_H_ + +#include "application_manager/commands/command_notification_from_mobile_impl.h" + +namespace app_service_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief OnAppServiceDataNotificationFromMobile command class + **/ +class OnAppServiceDataNotificationFromMobile + : public app_mngr::commands::CommandNotificationFromMobileImpl { + public: + /** + * @brief OnAppServiceDataNotificationFromMobile class constructor + * + * @param message Incoming SmartObject message + **/ + OnAppServiceDataNotificationFromMobile( + const app_mngr::commands::MessageSharedPtr& message, + app_mngr::ApplicationManager& application_manager, + app_mngr::rpc_service::RPCService& rpc_service, + app_mngr::HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle); + + /** + * @brief OnAppServiceDataNotificationFromMobile class destructor + **/ + virtual ~OnAppServiceDataNotificationFromMobile(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(OnAppServiceDataNotificationFromMobile); +}; + +} // namespace commands + +} // namespace app_service_rpc_plugin + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_APP_SERVICE_RPC_PLUGIN_INCLUDE_APP_SERVICE_RPC_PLUGIN_COMMANDS_MOBILE_ON_APP_SERVICE_DATA_NOTIFICATION_FROM_MOBILE_H_ diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/mobile/publish_app_service_request.h b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/mobile/publish_app_service_request.h new file mode 100644 index 0000000000..c6351b3b15 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/mobile/publish_app_service_request.h @@ -0,0 +1,79 @@ +/* + Copyright (c) 2019, Ford Motor Company, Livio + 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 the copyright holders nor the names of their + 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. + */ + +#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_APP_SERVICE_RPC_PLUGIN_INCLUDE_APP_SERVICE_RPC_PLUGIN_COMMANDS_MOBILE_PUBLISH_APP_SERVICE_REQUEST_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_APP_SERVICE_RPC_PLUGIN_INCLUDE_APP_SERVICE_RPC_PLUGIN_COMMANDS_MOBILE_PUBLISH_APP_SERVICE_REQUEST_H_ + +#include "application_manager/commands/command_request_impl.h" + +namespace app_service_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief PublishAppServiceRequest command class + **/ +class PublishAppServiceRequest + : public app_mngr::commands::CommandRequestImpl { + public: + /** + * @brief PublishAppServiceRequest class constructor + * + * @param message Incoming SmartObject message + **/ + PublishAppServiceRequest( + const app_mngr::commands::MessageSharedPtr& message, + app_mngr::ApplicationManager& application_manager, + app_mngr::rpc_service::RPCService& rpc_service, + app_mngr::HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle); + + /** + * @brief PublishAppServiceRequest class destructor + **/ + virtual ~PublishAppServiceRequest(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(PublishAppServiceRequest); +}; + +} // namespace commands + +} // namespace app_service_rpc_plugin + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_APP_SERVICE_RPC_PLUGIN_INCLUDE_APP_SERVICE_RPC_PLUGIN_COMMANDS_MOBILE_PUBLISH_APP_SERVICE_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/mobile/publish_app_service_response.h b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/mobile/publish_app_service_response.h new file mode 100644 index 0000000000..694c2906fa --- /dev/null +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/mobile/publish_app_service_response.h @@ -0,0 +1,79 @@ +/* + Copyright (c) 2019, Ford Motor Company, Livio + 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 the copyright holders nor the names of their + 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. + */ + +#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_APP_SERVICE_RPC_PLUGIN_INCLUDE_APP_SERVICE_RPC_PLUGIN_COMMANDS_MOBILE_PUBLISH_APP_SERVICE_RESPONSE_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_APP_SERVICE_RPC_PLUGIN_INCLUDE_APP_SERVICE_RPC_PLUGIN_COMMANDS_MOBILE_PUBLISH_APP_SERVICE_RESPONSE_H_ + +#include "application_manager/commands/command_response_impl.h" + +namespace app_service_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief PublishAppServiceResponse command class + **/ +class PublishAppServiceResponse + : public app_mngr::commands::CommandResponseImpl { + public: + /** + * @brief PublishAppServiceResponse class constructor + * + * @param message Incoming SmartObject message + **/ + PublishAppServiceResponse( + const app_mngr::commands::MessageSharedPtr& message, + app_mngr::ApplicationManager& application_manager, + app_mngr::rpc_service::RPCService& rpc_service, + app_mngr::HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle); + + /** + * @brief PublishAppServiceResponse class destructor + **/ + virtual ~PublishAppServiceResponse(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(PublishAppServiceResponse); +}; + +} // namespace commands + +} // namespace app_service_rpc_plugin + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_APP_SERVICE_RPC_PLUGIN_INCLUDE_APP_SERVICE_RPC_PLUGIN_COMMANDS_MOBILE_PUBLISH_APP_SERVICE_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/app_service_command_factory.cc b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/app_service_command_factory.cc new file mode 100644 index 0000000000..0405bb3e7c --- /dev/null +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/app_service_command_factory.cc @@ -0,0 +1,72 @@ +/* + Copyright (c) 2019, Ford Motor Company, Livio + 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 the copyright holders nor the names of their + 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 "app_service_rpc_plugin/app_service_command_factory.h" + +CREATE_LOGGERPTR_GLOBAL(logger_, "AppServiceRpcPlugin") + +namespace app_service_rpc_plugin { + +AppServiceCommandFactory::AppServiceCommandFactory( + app_mngr::ApplicationManager& application_manager, + app_mngr::rpc_service::RPCService& rpc_service, + app_mngr::HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handler) + : hmi_command_factory_(new AppServiceHmiCommandFactory( + application_manager, rpc_service, hmi_capabilities, policy_handler)) + , mobile_command_factory_(new AppServiceMobileCommandFactory( + application_manager, rpc_service, hmi_capabilities, policy_handler)) { + LOG4CXX_AUTO_TRACE(logger_); +} + +AppServiceCommandFactory::~AppServiceCommandFactory() { + LOG4CXX_AUTO_TRACE(logger_); +} + +app_mngr::CommandSharedPtr AppServiceCommandFactory::CreateCommand( + const app_mngr::commands::MessageSharedPtr& message, + app_mngr::commands::Command::CommandSource source) { + if (app_mngr::commands::Command::SOURCE_HMI == source) { + return hmi_command_factory_->CreateCommand(message, source); + } else { + return mobile_command_factory_->CreateCommand(message, source); + } +} + +bool AppServiceCommandFactory::IsAbleToProcess( + const int32_t function_id, + const commands::Command::CommandSource source) const { + return commands::Command::SOURCE_HMI == source + ? hmi_command_factory_->IsAbleToProcess(function_id, source) + : mobile_command_factory_->IsAbleToProcess(function_id, source); +} +} // namespace service_plugin diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/app_service_hmi_command_factory.cc b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/app_service_hmi_command_factory.cc new file mode 100644 index 0000000000..746636aff0 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/app_service_hmi_command_factory.cc @@ -0,0 +1,119 @@ +/* + Copyright (c) 2019, Ford Motor Company, Livio + 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 the copyright holders nor the names of their + 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 "app_service_rpc_plugin/app_service_hmi_command_factory.h" +#include "application_manager/message.h" +#include "interfaces/HMI_API.h" + +#include "app_service_rpc_plugin/commands/hmi/as_publish_app_service_request.h" +#include "app_service_rpc_plugin/commands/hmi/as_publish_app_service_response.h" +#include "app_service_rpc_plugin/commands/hmi/on_as_app_service_data_notification.h" +#include "app_service_rpc_plugin/commands/hmi/on_as_app_service_data_notification_from_hmi.h" + +CREATE_LOGGERPTR_GLOBAL(logger_, "AppServiceRpcPlugin") + +namespace app_service_rpc_plugin { +namespace strings = app_mngr::strings; + +AppServiceHmiCommandFactory::AppServiceHmiCommandFactory( + application_manager::ApplicationManager& application_manager, + application_manager::rpc_service::RPCService& rpc_service, + application_manager::HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handler) + : application_manager_(application_manager) + , rpc_service_(rpc_service) + , hmi_capabilities_(hmi_capabilities) + , policy_handler_(policy_handler) { + LOG4CXX_AUTO_TRACE(logger_); +} + +app_mngr::CommandSharedPtr AppServiceHmiCommandFactory::CreateCommand( + const app_mngr::commands::MessageSharedPtr& message, + app_mngr::commands::Command::CommandSource source) { + UNUSED(source); + + const hmi_apis::FunctionID::eType function_id = + static_cast( + (*message)[strings::params][strings::function_id].asInt()); + + const hmi_apis::messageType::eType message_type = + static_cast( + (*message)[strings::params][strings::message_type].asInt()); + + auto message_type_str = "request"; + if (hmi_apis::messageType::response == message_type) { + message_type_str = "response"; + } else if (hmi_apis::messageType::error_response == message_type) { + message_type_str = "error response"; + } + + UNUSED(message_type_str); + LOG4CXX_DEBUG(logger_, + "HMICommandFactory::CreateCommand function_id: " + << function_id << ", message type: " << message_type_str); + + return buildCommandCreator(function_id, message_type, source).create(message); +} + +bool AppServiceHmiCommandFactory::IsAbleToProcess( + const int32_t function_id, + const app_mngr::commands::Command::CommandSource source) const { + UNUSED(source); + return buildCommandCreator( + function_id, hmi_apis::messageType::INVALID_ENUM, source) + .CanBeCreated(); +} + +app_mngr::CommandCreator& AppServiceHmiCommandFactory::buildCommandCreator( + const int32_t function_id, + const int32_t message_type, + const app_mngr::commands::Command::CommandSource source) const { + auto factory = app_mngr::CommandCreatorFactory( + application_manager_, rpc_service_, hmi_capabilities_, policy_handler_); + + switch (function_id) { + case hmi_apis::FunctionID::AppService_PublishAppService: + return hmi_apis::messageType::request == message_type + ? factory.GetCreator() + : factory.GetCreator(); + case hmi_apis::FunctionID::AppService_OnAppServiceData: + return app_mngr::commands::Command::CommandSource::SOURCE_HMI == source + ? factory.GetCreator< + commands::OnASAppServiceDataNotificationFromHMI>() + : factory + .GetCreator(); + default: + LOG4CXX_WARN(logger_, "Unsupported function_id: " << function_id); + return factory.GetCreator(); + } +} +} diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/app_service_mobile_command_factory.cc b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/app_service_mobile_command_factory.cc new file mode 100644 index 0000000000..3b4e3490f6 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/app_service_mobile_command_factory.cc @@ -0,0 +1,118 @@ +/* + Copyright (c) 2019, Ford Motor Company, Livio + 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 the copyright holders nor the names of their + 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 "app_service_rpc_plugin/app_service_mobile_command_factory.h" + +#include "application_manager/message.h" +#include "interfaces/MOBILE_API.h" + +#include "app_service_rpc_plugin/commands/mobile/on_app_service_data_notification.h" +#include "app_service_rpc_plugin/commands/mobile/on_app_service_data_notification_from_mobile.h" +#include "app_service_rpc_plugin/commands/mobile/publish_app_service_request.h" +#include "app_service_rpc_plugin/commands/mobile/publish_app_service_response.h" + +CREATE_LOGGERPTR_GLOBAL(logger_, "AppServiceRpcPlugin") + +namespace app_service_rpc_plugin { +namespace strings = app_mngr::strings; + +AppServiceMobileCommandFactory::AppServiceMobileCommandFactory( + application_manager::ApplicationManager& application_manager, + application_manager::rpc_service::RPCService& rpc_service, + application_manager::HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handler) + : application_manager_(application_manager) + , rpc_service_(rpc_service) + , hmi_capabilities_(hmi_capabilities) + , policy_handler_(policy_handler) { + LOG4CXX_AUTO_TRACE(logger_); +} + +app_mngr::CommandSharedPtr AppServiceMobileCommandFactory::CreateCommand( + const app_mngr::commands::MessageSharedPtr& message, + app_mngr::commands::Command::CommandSource source) { + UNUSED(source); + + const mobile_apis::FunctionID::eType function_id = + static_cast( + (*message)[strings::params][strings::function_id].asInt()); + + const mobile_apis::messageType::eType message_type = + static_cast( + (*message)[strings::params][strings::message_type].asInt()); + + auto message_type_str = "request"; + if (mobile_apis::messageType::response == message_type) { + message_type_str = "response"; + } else if (mobile_apis::messageType::notification == message_type) { + message_type_str = "notification"; + } + + UNUSED(message_type_str); + LOG4CXX_DEBUG(logger_, + "HMICommandFactory::CreateCommand function_id: " + << function_id << ", message type: " << message_type_str); + + return buildCommandCreator(function_id, message_type, source).create(message); +} + +bool AppServiceMobileCommandFactory::IsAbleToProcess( + const int32_t function_id, + const app_mngr::commands::Command::CommandSource source) const { + UNUSED(source); + return buildCommandCreator( + function_id, mobile_apis::messageType::INVALID_ENUM, source) + .CanBeCreated(); +} + +app_mngr::CommandCreator& AppServiceMobileCommandFactory::buildCommandCreator( + const int32_t function_id, + const int32_t message_type, + const app_mngr::commands::Command::CommandSource source) const { + auto factory = app_mngr::CommandCreatorFactory( + application_manager_, rpc_service_, hmi_capabilities_, policy_handler_); + + switch (function_id) { + case mobile_apis::FunctionID::PublishAppServiceID: + return mobile_apis::messageType::request == message_type + ? factory.GetCreator() + : factory.GetCreator(); + case mobile_apis::FunctionID::OnAppServiceDataID: + return app_mngr::commands::Command::CommandSource::SOURCE_MOBILE == source + ? factory.GetCreator() + : factory.GetCreator(); + default: + LOG4CXX_WARN(logger_, "Unsupported function_id: " << function_id); + return factory.GetCreator(); + } +} +} // namespace vehicle_info_plugin diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/app_service_rpc_plugin.cc b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/app_service_rpc_plugin.cc new file mode 100644 index 0000000000..739d8bb0e2 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/app_service_rpc_plugin.cc @@ -0,0 +1,85 @@ +/* + Copyright (c) 2019, Ford Motor Company, Livio + 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 the copyright holders nor the names of their + 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 "application_manager/message_helper.h" +#include "application_manager/smart_object_keys.h" +//#include "app_service_rpc_plugin/app_service_app_extension.h" +#include "app_service_rpc_plugin/app_service_command_factory.h" +#include "app_service_rpc_plugin/app_service_rpc_plugin.h" + +namespace app_service_rpc_plugin { +CREATE_LOGGERPTR_GLOBAL(logger_, "AppServiceRpcPlugin") + +namespace strings = application_manager::strings; + +AppServiceRpcPlugin::AppServiceRpcPlugin() : application_manager_(nullptr) {} + +bool AppServiceRpcPlugin::Init( + application_manager::ApplicationManager& app_manager, + application_manager::rpc_service::RPCService& rpc_service, + application_manager::HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handler) { + application_manager_ = &app_manager; + command_factory_.reset(new app_service_rpc_plugin::AppServiceCommandFactory( + app_manager, rpc_service, hmi_capabilities, policy_handler)); + return true; +} + +bool AppServiceRpcPlugin::IsAbleToProcess( + const int32_t function_id, const commands::Command::CommandSource source) { + return command_factory_->IsAbleToProcess(function_id, source); +} + +std::string AppServiceRpcPlugin::PluginName() { + return "App Service RPC Plugin"; +} + +app_mngr::CommandFactory& AppServiceRpcPlugin::GetCommandFactory() { + return *command_factory_; +} + +void AppServiceRpcPlugin::OnPolicyEvent(plugins::PolicyEvent event) {} + +void AppServiceRpcPlugin::OnApplicationEvent( + plugins::ApplicationEvent event, + app_mngr::ApplicationSharedPtr application) {} + +/*void AppServiceRpcPlugin::ProcessResumptionSubscription( + application_manager::Application& app, AppServiceAppExtension& ext) { + LOG4CXX_AUTO_TRACE(logger_); + // TODO +}*/ +} // namespace app_service_rpc_plugin + +extern "C" application_manager::plugin_manager::RPCPlugin* Create() { + return new app_service_rpc_plugin::AppServiceRpcPlugin(); +} diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_publish_app_service_request.cc b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_publish_app_service_request.cc new file mode 100644 index 0000000000..41729cfe5a --- /dev/null +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_publish_app_service_request.cc @@ -0,0 +1,65 @@ +/* + Copyright (c) 2019, Ford Motor Company, Livio + 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 the copyright holders nor the names of their + 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 "app_service_rpc_plugin/commands/hmi/as_publish_app_service_request.h" +#include "application_manager/message_helper.h" + +namespace app_service_rpc_plugin { +using namespace application_manager; +namespace commands { + +ASPublishAppServiceRequest::ASPublishAppServiceRequest( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + app_mngr::rpc_service::RPCService& rpc_service, + app_mngr::HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handler) + : RequestFromHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handler) {} + +ASPublishAppServiceRequest::~ASPublishAppServiceRequest() {} + +void ASPublishAppServiceRequest::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + (*message_)[strings::params][strings::message_type] = MessageType::kResponse; + (*message_)[strings::params][hmi_response::code] = + hmi_apis::Common_Result::SUCCESS; + // TODO: Add AppServiceRecord to response + rpc_service_.ManageHMICommand(message_); +} + +} // namespace commands +} // namespace app_service_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_publish_app_service_response.cc b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_publish_app_service_response.cc new file mode 100644 index 0000000000..c143315b8c --- /dev/null +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_publish_app_service_response.cc @@ -0,0 +1,60 @@ +/* + Copyright (c) 2019, Ford Motor Company, Livio + 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 the copyright holders nor the names of their + 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 "app_service_rpc_plugin/commands/hmi/as_publish_app_service_response.h" +#include "application_manager/message_helper.h" + +namespace app_service_rpc_plugin { +using namespace application_manager; +namespace commands { + +ASPublishAppServiceResponse::ASPublishAppServiceResponse( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + app_mngr::rpc_service::RPCService& rpc_service, + app_mngr::HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handler) + : ResponseToHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handler) {} + +ASPublishAppServiceResponse::~ASPublishAppServiceResponse() {} + +void ASPublishAppServiceResponse::Run() { + LOG4CXX_AUTO_TRACE(logger_); + rpc_service_.SendMessageToHMI(message_); +} + +} // namespace commands +} // namespace app_service_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/on_as_app_service_data_notification.cc b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/on_as_app_service_data_notification.cc new file mode 100644 index 0000000000..0da2ba6784 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/on_as_app_service_data_notification.cc @@ -0,0 +1,62 @@ +/* + Copyright (c) 2019, Ford Motor Company, Livio + 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 the copyright holders nor the names of their + 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 "app_service_rpc_plugin/commands/hmi/on_as_app_service_data_notification.h" +#include "application_manager/message_helper.h" + +namespace app_service_rpc_plugin { +using namespace application_manager; +namespace commands { + +OnASAppServiceDataNotification::OnASAppServiceDataNotification( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + app_mngr::rpc_service::RPCService& rpc_service, + app_mngr::HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handler) + : NotificationToHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handler) {} + +OnASAppServiceDataNotification:: + ~OnASAppServiceDataNotification() {} + +void OnASAppServiceDataNotification::Run() { + LOG4CXX_AUTO_TRACE(logger_); + LOG4CXX_DEBUG(logger_, "Received an OnAppServiceData from HMI"); + MessageHelper::PrintSmartObject(message_); +} + +} // namespace commands +} // namespace app_service_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/on_as_app_service_data_notification_from_hmi.cc b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/on_as_app_service_data_notification_from_hmi.cc new file mode 100644 index 0000000000..3d5bc81c72 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/on_as_app_service_data_notification_from_hmi.cc @@ -0,0 +1,61 @@ +/* + Copyright (c) 2019, Ford Motor Company, Livio + 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 the copyright holders nor the names of their + 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 "app_service_rpc_plugin/commands/hmi/on_as_app_service_data_notification_from_hmi.h" +#include "application_manager/message_helper.h" + +namespace app_service_rpc_plugin { +using namespace application_manager; +namespace commands { + +OnASAppServiceDataNotificationFromHMI::OnASAppServiceDataNotificationFromHMI( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + app_mngr::rpc_service::RPCService& rpc_service, + app_mngr::HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handler) + : NotificationFromHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handler) {} + +OnASAppServiceDataNotificationFromHMI::~OnASAppServiceDataNotificationFromHMI() {} + +void OnASAppServiceDataNotificationFromHMI::Run() { + LOG4CXX_AUTO_TRACE(logger_); + LOG4CXX_DEBUG(logger_, "Received an OnAppServiceData from HMI"); + MessageHelper::PrintSmartObject(message_); +} + +} // namespace commands +} // namespace app_service_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/on_app_service_data_notification.cc b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/on_app_service_data_notification.cc new file mode 100644 index 0000000000..6962e80567 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/on_app_service_data_notification.cc @@ -0,0 +1,65 @@ +/* + Copyright (c) 2019, Ford Motor Company, Livio + 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 the copyright holders nor the names of their + 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 "app_service_rpc_plugin/commands/mobile/on_app_service_data_notification.h" +#include "application_manager/application_impl.h" +#include "application_manager/message_helper.h" +#include "application_manager/rpc_service.h" +#include "interfaces/MOBILE_API.h" + +namespace app_service_rpc_plugin { +using namespace application_manager; +namespace commands { + +OnAppServiceDataNotification::OnAppServiceDataNotification( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + app_mngr::rpc_service::RPCService& rpc_service, + app_mngr::HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handler) + : CommandNotificationImpl(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handler) {} + +OnAppServiceDataNotification::~OnAppServiceDataNotification() {} + +void OnAppServiceDataNotification::Run() { + LOG4CXX_AUTO_TRACE(logger_); + LOG4CXX_DEBUG(logger_, "Sending OnAppServiceData to consumer"); + MessageHelper::PrintSmartObject(message_); + SendNotification(); +} + +} // namespace commands +} // namespace app_service_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/on_app_service_data_notification_from_mobile.cc b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/on_app_service_data_notification_from_mobile.cc new file mode 100644 index 0000000000..168ddaed23 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/on_app_service_data_notification_from_mobile.cc @@ -0,0 +1,65 @@ +/* + Copyright (c) 2019, Ford Motor Company, Livio + 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 the copyright holders nor the names of their + 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 "app_service_rpc_plugin/commands/mobile/on_app_service_data_notification_from_mobile.h" +#include "application_manager/application_impl.h" +#include "application_manager/message_helper.h" +#include "application_manager/rpc_service.h" +#include "interfaces/MOBILE_API.h" + +namespace app_service_rpc_plugin { +using namespace application_manager; +namespace commands { + +OnAppServiceDataNotificationFromMobile::OnAppServiceDataNotificationFromMobile( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + app_mngr::rpc_service::RPCService& rpc_service, + app_mngr::HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handler) + : CommandNotificationFromMobileImpl(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handler) {} + +OnAppServiceDataNotificationFromMobile:: + ~OnAppServiceDataNotificationFromMobile() {} + +void OnAppServiceDataNotificationFromMobile::Run() { + LOG4CXX_AUTO_TRACE(logger_); + LOG4CXX_DEBUG(logger_, "Received an OnAppServiceData"); + MessageHelper::PrintSmartObject(message_); +} + +} // namespace commands +} // namespace app_service_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/publish_app_service_request.cc b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/publish_app_service_request.cc new file mode 100644 index 0000000000..ddde156a44 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/publish_app_service_request.cc @@ -0,0 +1,65 @@ +/* + Copyright (c) 2019, Ford Motor Company, Livio + 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 the copyright holders nor the names of their + 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 "app_service_rpc_plugin/commands/mobile/publish_app_service_request.h" +#include "application_manager/application_impl.h" +#include "application_manager/message_helper.h" +#include "application_manager/rpc_service.h" +#include "interfaces/MOBILE_API.h" + +namespace app_service_rpc_plugin { +using namespace application_manager; +namespace commands { + +PublishAppServiceRequest::PublishAppServiceRequest( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + app_mngr::rpc_service::RPCService& rpc_service, + app_mngr::HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handler) + : CommandRequestImpl(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handler) {} + +PublishAppServiceRequest::~PublishAppServiceRequest() {} + +void PublishAppServiceRequest::Run() { + LOG4CXX_AUTO_TRACE(logger_); + LOG4CXX_DEBUG(logger_, "Received a PublishAppService"); + MessageHelper::PrintSmartObject(message_); + SendResponse(true, mobile_apis::Result::SUCCESS); +} + +} // namespace commands +} // namespace app_service_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/publish_app_service_response.cc b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/publish_app_service_response.cc new file mode 100644 index 0000000000..b1136c79d0 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/publish_app_service_response.cc @@ -0,0 +1,63 @@ +/* + Copyright (c) 2019, Ford Motor Company, Livio + 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 the copyright holders nor the names of their + 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 "app_service_rpc_plugin/commands/mobile/publish_app_service_response.h" +#include "application_manager/application_impl.h" +#include "application_manager/message_helper.h" +#include "application_manager/rpc_service.h" +#include "interfaces/MOBILE_API.h" + +namespace app_service_rpc_plugin { +using namespace application_manager; +namespace commands { + +PublishAppServiceResponse::PublishAppServiceResponse( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + app_mngr::rpc_service::RPCService& rpc_service, + app_mngr::HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handler) + : CommandResponseImpl(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handler) {} + +PublishAppServiceResponse::~PublishAppServiceResponse() {} + +void PublishAppServiceResponse::Run() { + LOG4CXX_AUTO_TRACE(logger_); + rpc_service_.SendMessageToMobile(message_); +} + +} // namespace commands +} // namespace app_service_rpc_plugin diff --git a/src/components/interfaces/HMI_API.xml b/src/components/interfaces/HMI_API.xml index 7adb5fb51e..cc51982080 100644 --- a/src/components/interfaces/HMI_API.xml +++ b/src/components/interfaces/HMI_API.xml @@ -3357,6 +3357,197 @@ The position of the haptic rectangle to be highlighted. The center of this rectangle will be "touched" when a press occurs. + + + Specifies the version number of the SmartDeviceLink protocol that is supported by the mobile application or app service + + + The major version indicates versions that is not-compatible to previous versions. + + + The minor version indicates a change to a previous version that should still allow to be run on an older version (with limited functionality) + + + The patch version indicates a fix to existing functionality in a previous version that should still be able to be run on an older version + + + + + + + + + + + + + + + + + + + + + This data is related to what a media service should provide + + + The type of the currently playing or paused track. + + + + + Music: The name of the current track + Podcast: The name of the current episode + Audiobook: The name of the current chapter + + + + + + Music: The name of the current album artist + Podcast: The provider of the podcast (hosts, network, company) + Audiobook: The book author's name + + + + + + Music: The name of the current album + Podcast: The name of the current podcast show + Audiobook: The name of the current book + + + + + + Music: The name of the playlist or radio station, if the user is playing from a playlist, otherwise, Null + Podcast: The name of the playlist, if the user is playing from a playlist, otherwise, Null + Audiobook: Likely not applicable, possibly a collection or "playlist" of books + + + + + Whether or not the content currently playing (e.g. the track, episode, or book) contains explicit content + + + + + Music: The current progress of the track in seconds + Podcast: The current progress of the episode in seconds + Audiobook: The current progress of the current segment (e.g. the chapter) in seconds + + + + + + Music: The total duration of the track in seconds + Podcast: The total duration of the episode in seconds + Audiobook: The total duration of the current segment (e.g. the chapter) in seconds + + + + + + Music: The current progress of the playback queue in seconds + Podcast: The current progress of the playback queue in seconds + Audiobook: The current progress of the playback queue (e.g. the book) in seconds + + + + + + Music: The total duration of the playback queue in seconds + Podcast: The total duration of the playback queue in seconds + Audiobook: The total duration of the playback queue (e.g. the book) in seconds + + + + + + Music: The current number (1 based) of the track in the playback queue + Podcast: The current number (1 based) of the episode in the playback queue + Audiobook: The current number (1 based) of the episode in the playback queue (e.g. the chapter number in the book) + + + + + + Music: The total number of tracks in the playback queue + Podcast: The total number of episodes in the playback queue + Audiobook: The total number of sections in the playback queue (e.g. the number of chapters in the book) + + + + + + This manfifest contains all the information necessary for the service to be published, activated, and consumers able to interact with it + + + Unique name of this service + + + + The type of service that is to be offered by this app + + + + The file name of the icon to be associated with this service. Most likely the same as the appIcon. + + + + If true, app service consumers beyond the IVI system will be able to access this service. If false, only the IVI system will be able consume the service. If not provided, it is assumed to be false. + + + + The URI prefix for this service. If provided, all PerformAppServiceInteraction requests must start with it. + + + + This is a custom schema for this service. SDL will not do any verification on this param past that it has a correctly formated JSON Object as its base. The uriScheme should contain all available actions to be taken through a PerformAppServiceInteraction request from an app service consumer. + + + + This is the max RPC Spec version the app service understands. This is important during the RPC passthrough functionality. If not included, it is assumed the max version of the module is acceptable. + + + + This field contains the Function IDs for the RPCs that this service intends to handle correctly. This means the service will provide meaningful responses. + + + + + + + This is the record of an app service publisher that the module has. It should contain the most up to date information including the service's active state + + + A unique ID tied to this specific service record. The ID is supplied by the module that services publish themselves. + + + + Manifest for the service that this record is for. + + + + If true, the service is published and available. If false, the service has likely just been unpublished, and should be considered unavailable. + + + + If true, the service is the active primary service of the supplied service type. It will receive all potential RPCs that are passed through to that service type. If false, it is not the primary service of the supplied type. See servicePublished for its availability. + + + + + Contains all the current data of the app service. The serviceType will link to which of the service data objects are included in this object. (eg if service type equals MEDIA, the mediaServiceData param should be included. + + + + + + + + @@ -5837,4 +6028,29 @@ + + + Interface used for interacting with app services as a producer or consumer + + Registers a service offered by this app on the module + + + The manifest of the service that wishes to be published. + + + + + Response to the request to register a service offered by this app on the module + + + If the request was successful, this object will be the current status of the service record for the published service. This will include the Core supplied service ID. + + + + + This notification includes the data that is updated from the specific service. HMI->SDL if the HMI is a producer, SDL->HMI if the HMI is a consumer + + + + diff --git a/src/components/interfaces/MOBILE_API.xml b/src/components/interfaces/MOBILE_API.xml index 714399bce6..496b3cdbc8 100644 --- a/src/components/interfaces/MOBILE_API.xml +++ b/src/components/interfaces/MOBILE_API.xml @@ -2617,6 +2617,7 @@ + + + + + + + + + + + + + + + + + + This data is related to what a media service should provide + + + The type of the currently playing or paused track. + + + + + Music: The name of the current track + Podcast: The name of the current episode + Audiobook: The name of the current chapter + + + + + + Music: The name of the current album artist + Podcast: The provider of the podcast (hosts, network, company) + Audiobook: The book author's name + + + + + + Music: The name of the current album + Podcast: The name of the current podcast show + Audiobook: The name of the current book + + + + + + Music: The name of the playlist or radio station, if the user is playing from a playlist, otherwise, Null + Podcast: The name of the playlist, if the user is playing from a playlist, otherwise, Null + Audiobook: Likely not applicable, possibly a collection or "playlist" of books + + + + + Whether or not the content currently playing (e.g. the track, episode, or book) contains explicit content + + + + + Music: The current progress of the track in seconds + Podcast: The current progress of the episode in seconds + Audiobook: The current progress of the current segment (e.g. the chapter) in seconds + + + + + + Music: The total duration of the track in seconds + Podcast: The total duration of the episode in seconds + Audiobook: The total duration of the current segment (e.g. the chapter) in seconds + + + + + + Music: The current progress of the playback queue in seconds + Podcast: The current progress of the playback queue in seconds + Audiobook: The current progress of the playback queue (e.g. the book) in seconds + + + + + + Music: The total duration of the playback queue in seconds + Podcast: The total duration of the playback queue in seconds + Audiobook: The total duration of the playback queue (e.g. the book) in seconds + + + + + + Music: The current number (1 based) of the track in the playback queue + Podcast: The current number (1 based) of the episode in the playback queue + Audiobook: The current number (1 based) of the episode in the playback queue (e.g. the chapter number in the book) + + + + + + Music: The total number of tracks in the playback queue + Podcast: The total number of episodes in the playback queue + Audiobook: The total number of sections in the playback queue (e.g. the number of chapters in the book) + + + + + + This manfifest contains all the information necessary for the service to be published, activated, and consumers able to interact with it + + + Unique name of this service + + + + The type of service that is to be offered by this app + + + + The file name of the icon to be associated with this service. Most likely the same as the appIcon. + + + + If true, app service consumers beyond the IVI system will be able to access this service. If false, only the IVI system will be able consume the service. If not provided, it is assumed to be false. + + + + The URI prefix for this service. If provided, all PerformAppServiceInteraction requests must start with it. + + + + This is a custom schema for this service. SDL will not do any verification on this param past that it has a correctly formated JSON Object as its base. The uriScheme should contain all available actions to be taken through a PerformAppServiceInteraction request from an app service consumer. + + + + This is the max RPC Spec version the app service understands. This is important during the RPC passthrough functionality. If not included, it is assumed the max version of the module is acceptable. + + + + This field contains the Function IDs for the RPCs that this service intends to handle correctly. This means the service will provide meaningful responses. + + + + + + + This is the record of an app service publisher that the module has. It should contain the most up to date information including the service's active state + + + A unique ID tied to this specific service record. The ID is supplied by the module that services publish themselves. + + + + Manifest for the service that this record is for. + + + + If true, the service is published and available. If false, the service has likely just been unpublished, and should be considered unavailable. + + + + If true, the service is the active primary service of the supplied service type. It will receive all potential RPCs that are passed through to that service type. If false, it is not the primary service of the supplied type. See servicePublished for its availability. + + + + + Contains all the current data of the app service. The serviceType will link to which of the service data objects are included in this object. (eg if service type equals MEDIA, the mediaServiceData param should be included. + + + + + + + + @@ -6678,6 +6857,42 @@ + + + Registers a service offered by this app on the module + + + The manifest of the service that wishes to be published. + + + + + Response to the request to register a service offered by this app on the module + + + true, if successful; false, if failed + + + + See Result + + + + + + + + + + + + Provides additional human readable info regarding the result. + + + + If the request was successful, this object will be the current status of the service record for the published service. This will include the Core supplied service ID. + + @@ -6971,6 +7186,12 @@ Contains a list (zero or more) of module types that are free to access for the application. + + + This notification includes the data that is updated from the specific service + + + -- cgit v1.2.1 From d67a37a5dedfe696dd4308fd0eb53ee48e15daf8 Mon Sep 17 00:00:00 2001 From: JackLivio Date: Mon, 21 Jan 2019 12:28:13 -0500 Subject: Update based on comments --- src/components/application_manager/src/application_manager_impl.cc | 4 ++-- .../include/connection_handler/connection_handler_impl.h | 3 +-- src/components/connection_handler/src/connection_handler_impl.cc | 1 - src/components/include/connection_handler/connection_handler.h | 3 +-- .../include/test/connection_handler/mock_connection_handler.h | 5 ++--- 5 files changed, 6 insertions(+), 10 deletions(-) diff --git a/src/components/application_manager/src/application_manager_impl.cc b/src/components/application_manager/src/application_manager_impl.cc index ef008b7200..3b5c1b2c7c 100644 --- a/src/components/application_manager/src/application_manager_impl.cc +++ b/src/components/application_manager/src/application_manager_impl.cc @@ -808,7 +808,7 @@ void ApplicationManagerImpl::CollectCloudAppInformation() { pending_device_map_.insert( std::pair(endpoint, *it)); - connection_handler().AddCloudAppDevice(*it, endpoint, cloud_transport_type); + connection_handler().AddCloudAppDevice(endpoint, cloud_transport_type); } } @@ -873,7 +873,7 @@ void ApplicationManagerImpl::CreatePendingApplication( mobile_apis::HybridAppPreference::eType>:: StringToEnum(hybrid_app_preference_str, &hybrid_app_preference_enum); - if (!convert_result) { + if (!hybrid_app_preference_str.empty() && !convert_result) { LOG4CXX_ERROR( logger_, "Could not convert string to enum: " << hybrid_app_preference_str); diff --git a/src/components/connection_handler/include/connection_handler/connection_handler_impl.h b/src/components/connection_handler/include/connection_handler/connection_handler_impl.h index 7be94c5f70..899d17995c 100644 --- a/src/components/connection_handler/include/connection_handler/connection_handler_impl.h +++ b/src/components/connection_handler/include/connection_handler/connection_handler_impl.h @@ -120,8 +120,7 @@ class ConnectionHandlerImpl void ConnectToAllDevices() OVERRIDE; - void AddCloudAppDevice(const std::string& policy_app_id, - const std::string& endpoint, + void AddCloudAppDevice(const std::string& endpoint, const std::string& cloud_transport_type) OVERRIDE; void StartTransportManager() OVERRIDE; diff --git a/src/components/connection_handler/src/connection_handler_impl.cc b/src/components/connection_handler/src/connection_handler_impl.cc index ed2522593c..9060350c9b 100644 --- a/src/components/connection_handler/src/connection_handler_impl.cc +++ b/src/components/connection_handler/src/connection_handler_impl.cc @@ -1315,7 +1315,6 @@ void ConnectionHandlerImpl::ConnectToAllDevices() { } void ConnectionHandlerImpl::AddCloudAppDevice( - const std::string& policy_app_id, const std::string& endpoint, const std::string& cloud_transport_type) { transport_manager_.AddCloudDevice(endpoint, cloud_transport_type); diff --git a/src/components/include/connection_handler/connection_handler.h b/src/components/include/connection_handler/connection_handler.h index 93939fc782..9ca9a8d144 100644 --- a/src/components/include/connection_handler/connection_handler.h +++ b/src/components/include/connection_handler/connection_handler.h @@ -93,8 +93,7 @@ class ConnectionHandler { virtual void ConnectToAllDevices() = 0; - virtual void AddCloudAppDevice(const std::string& policy_app_id, - const std::string& endpoint, + virtual void AddCloudAppDevice(const std::string& endpoint, const std::string& cloud_transport_type) = 0; /** diff --git a/src/components/include/test/connection_handler/mock_connection_handler.h b/src/components/include/test/connection_handler/mock_connection_handler.h index bdc0469844..cde835759f 100644 --- a/src/components/include/test/connection_handler/mock_connection_handler.h +++ b/src/components/include/test/connection_handler/mock_connection_handler.h @@ -63,9 +63,8 @@ class MockConnectionHandler : public connection_handler::ConnectionHandler { MOCK_CONST_METHOD2(RunAppOnDevice, void(const std::string&, const std::string&)); MOCK_METHOD0(ConnectToAllDevices, void()); - MOCK_METHOD3(AddCloudAppDevice, - void(const std::string& policy_app_id, - const std::string& endpoint, + MOCK_METHOD2(AddCloudAppDevice, + void(const std::string& endpoint, const std::string& cloud_transport_type)); MOCK_METHOD1(CloseRevokedConnection, void(uint32_t connection_key)); MOCK_METHOD1(CloseConnection, void(ConnectionHandle connection_handle)); -- cgit v1.2.1 From 9f48c541b2ffefb0c34aacc22075cab849dcaea4 Mon Sep 17 00:00:00 2001 From: JackLivio Date: Tue, 22 Jan 2019 13:24:34 -0500 Subject: Fix Style --- src/components/connection_handler/src/connection_handler_impl.cc | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/components/connection_handler/src/connection_handler_impl.cc b/src/components/connection_handler/src/connection_handler_impl.cc index 9060350c9b..9dc78613fc 100644 --- a/src/components/connection_handler/src/connection_handler_impl.cc +++ b/src/components/connection_handler/src/connection_handler_impl.cc @@ -1315,8 +1315,7 @@ void ConnectionHandlerImpl::ConnectToAllDevices() { } void ConnectionHandlerImpl::AddCloudAppDevice( - const std::string& endpoint, - const std::string& cloud_transport_type) { + const std::string& endpoint, const std::string& cloud_transport_type) { transport_manager_.AddCloudDevice(endpoint, cloud_transport_type); } -- cgit v1.2.1 From 73336d81747ab60e38496f2e7416b2388480573d Mon Sep 17 00:00:00 2001 From: jacobkeeler Date: Tue, 22 Jan 2019 13:40:04 -0500 Subject: Add dummy response for PublishAppService --- .../application_manager/commands/request_from_hmi.h | 3 ++- .../include/application_manager/smart_object_keys.h | 17 +++++++++++++++++ .../commands/hmi/as_publish_app_service_request.cc | 20 +++++++++++++++----- .../commands/mobile/publish_app_service_request.cc | 16 +++++++++++++++- .../src/commands/request_from_hmi.cc | 7 ++++++- .../application_manager/src/smart_object_keys.cc | 17 +++++++++++++++++ src/components/interfaces/HMI_API.xml | 4 ++-- src/components/interfaces/MOBILE_API.xml | 4 ++-- 8 files changed, 76 insertions(+), 12 deletions(-) diff --git a/src/components/application_manager/include/application_manager/commands/request_from_hmi.h b/src/components/application_manager/include/application_manager/commands/request_from_hmi.h index 927a45c6a6..d980e98576 100644 --- a/src/components/application_manager/include/application_manager/commands/request_from_hmi.h +++ b/src/components/application_manager/include/application_manager/commands/request_from_hmi.h @@ -64,7 +64,8 @@ class RequestFromHMI : public CommandImpl, public event_engine::EventObserver { void SendResponse(const bool success, const uint32_t correlation_id, const hmi_apis::FunctionID::eType function_id, - const hmi_apis::Common_Result::eType result_code); + const hmi_apis::Common_Result::eType result_code, + const smart_objects::SmartObject* response_params = NULL); /** * @brief SendResponse allows to send error response to hmi 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 5e6a3bb377..19b2daaaf4 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 @@ -300,6 +300,23 @@ extern const char* system_software_version; extern const char* priority; extern const char* engine_oil_life; +// app services +extern const char* app_service_manifest; +extern const char* service_name; +extern const char* service_type; +extern const char* service_icon; +extern const char* allow_app_consumers; +extern const char* uri_prefix; +extern const char* uri_scheme; +extern const char* rpc_spec_version; +extern const char* handled_rpcs; +extern const char* media_service_manifest; +extern const char* app_service_record; +extern const char* service_id; +extern const char* service_manifest; +extern const char* service_published; +extern const char* service_active; + // resuming extern const char* application_commands; extern const char* application_submenus; diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_publish_app_service_request.cc b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_publish_app_service_request.cc index 41729cfe5a..a11e4e8a22 100644 --- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_publish_app_service_request.cc +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_publish_app_service_request.cc @@ -53,12 +53,22 @@ ASPublishAppServiceRequest::~ASPublishAppServiceRequest() {} void ASPublishAppServiceRequest::Run() { LOG4CXX_AUTO_TRACE(logger_); - - (*message_)[strings::params][strings::message_type] = MessageType::kResponse; - (*message_)[strings::params][hmi_response::code] = - hmi_apis::Common_Result::SUCCESS; + smart_objects::SmartObject response_params = + smart_objects::SmartObject(smart_objects::SmartType_Map); + smart_objects::SmartObject service_record = + smart_objects::SmartObject(smart_objects::SmartType_Map); + service_record[strings::service_manifest] = + (*message_)[strings::msg_params][strings::app_service_manifest]; + service_record[strings::service_id] = "This is a service ID"; + service_record[strings::service_published] = true; + service_record[strings::service_active] = true; + response_params[strings::app_service_record] = service_record; // TODO: Add AppServiceRecord to response - rpc_service_.ManageHMICommand(message_); + SendResponse(true, + (*message_)[strings::params][strings::correlation_id].asUInt(), + hmi_apis::FunctionID::AppService_PublishAppService, + hmi_apis::Common_Result::SUCCESS, + &response_params); } } // namespace commands diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/publish_app_service_request.cc b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/publish_app_service_request.cc index ddde156a44..a133695f60 100644 --- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/publish_app_service_request.cc +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/publish_app_service_request.cc @@ -58,7 +58,21 @@ void PublishAppServiceRequest::Run() { LOG4CXX_AUTO_TRACE(logger_); LOG4CXX_DEBUG(logger_, "Received a PublishAppService"); MessageHelper::PrintSmartObject(message_); - SendResponse(true, mobile_apis::Result::SUCCESS); + + smart_objects::SmartObject response_params = + smart_objects::SmartObject(smart_objects::SmartType_Map); + + smart_objects::SmartObject service_record = + smart_objects::SmartObject(smart_objects::SmartType_Map); + service_record[strings::service_manifest] = + (*message_)[strings::msg_params][strings::app_service_manifest]; + service_record[strings::service_id] = "This is a service ID"; + service_record[strings::service_published] = true; + service_record[strings::service_active] = true; + + response_params[strings::app_service_record] = service_record; + + SendResponse(true, mobile_apis::Result::SUCCESS, NULL, &response_params); } } // namespace commands diff --git a/src/components/application_manager/src/commands/request_from_hmi.cc b/src/components/application_manager/src/commands/request_from_hmi.cc index ff760c2d2a..0a6865457e 100644 --- a/src/components/application_manager/src/commands/request_from_hmi.cc +++ b/src/components/application_manager/src/commands/request_from_hmi.cc @@ -71,7 +71,8 @@ void RequestFromHMI::SendResponse( const bool success, const uint32_t correlation_id, const hmi_apis::FunctionID::eType function_id, - const hmi_apis::Common_Result::eType result_code) { + const hmi_apis::Common_Result::eType result_code, + const smart_objects::SmartObject* response_params) { smart_objects::SmartObjectSPtr message = std::make_shared( smart_objects::SmartType_Map); @@ -81,6 +82,10 @@ void RequestFromHMI::SendResponse( (*message)[strings::msg_params][strings::success] = success; (*message)[strings::msg_params][strings::result_code] = result_code; + if (response_params) { + (*message)[strings::msg_params] = *response_params; + } + rpc_service_.ManageHMICommand(message); } diff --git a/src/components/application_manager/src/smart_object_keys.cc b/src/components/application_manager/src/smart_object_keys.cc index 70581466eb..00dabb9480 100644 --- a/src/components/application_manager/src/smart_object_keys.cc +++ b/src/components/application_manager/src/smart_object_keys.cc @@ -267,6 +267,23 @@ const char* system_software_version = "systemSoftwareVersion"; const char* priority = "priority"; const char* engine_oil_life = "engineOilLife"; +// app services +const char* app_service_manifest = "appServiceManifest"; +const char* service_name = "serviceName"; +const char* service_type = "serviceType"; +const char* service_icon = "serviceIcon"; +const char* allow_app_consumers = "allowAppConsumers"; +const char* uri_prefix = "uriPrefix"; +const char* uri_scheme = "uriScheme"; +const char* rpc_spec_version = "rpcSpecVersion"; +const char* handled_rpcs = "handledRPCs"; +const char* media_service_manifest = "mediaServiceManifest"; +const char* app_service_record = "appServiceRecord"; +const char* service_id = "serviceID"; +const char* service_manifest = "serviceManifest"; +const char* service_published = "servicePublished"; +const char* service_active = "serviceActive"; + // resuming const char* application_commands = "applicationCommands"; const char* application_submenus = "applicationSubMenus"; diff --git a/src/components/interfaces/HMI_API.xml b/src/components/interfaces/HMI_API.xml index cc51982080..9ebb7d3239 100644 --- a/src/components/interfaces/HMI_API.xml +++ b/src/components/interfaces/HMI_API.xml @@ -3521,7 +3521,7 @@ This is the record of an app service publisher that the module has. It should contain the most up to date information including the service's active state - + A unique ID tied to this specific service record. The ID is supplied by the module that services publish themselves. @@ -3542,7 +3542,7 @@ Contains all the current data of the app service. The serviceType will link to which of the service data objects are included in this object. (eg if service type equals MEDIA, the mediaServiceData param should be included. - + diff --git a/src/components/interfaces/MOBILE_API.xml b/src/components/interfaces/MOBILE_API.xml index 496b3cdbc8..6605a01b48 100644 --- a/src/components/interfaces/MOBILE_API.xml +++ b/src/components/interfaces/MOBILE_API.xml @@ -3860,7 +3860,7 @@ This is the record of an app service publisher that the module has. It should contain the most up to date information including the service's active state - + A unique ID tied to this specific service record. The ID is supplied by the module that services publish themselves. @@ -3881,7 +3881,7 @@ Contains all the current data of the app service. The serviceType will link to which of the service data objects are included in this object. (eg if service type equals MEDIA, the mediaServiceData param should be included. - + -- cgit v1.2.1 From fc2c76d23dcd8f4016edff90d215940a810d9f86 Mon Sep 17 00:00:00 2001 From: jacobkeeler Date: Tue, 22 Jan 2019 15:29:14 -0500 Subject: Fix PrintSmartObject calls --- .../src/commands/hmi/on_as_app_service_data_notification.cc | 2 +- .../src/commands/hmi/on_as_app_service_data_notification_from_hmi.cc | 2 +- .../src/commands/mobile/on_app_service_data_notification.cc | 2 +- .../commands/mobile/on_app_service_data_notification_from_mobile.cc | 2 +- .../src/commands/mobile/publish_app_service_request.cc | 4 ++-- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/on_as_app_service_data_notification.cc b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/on_as_app_service_data_notification.cc index 0da2ba6784..d242ea1161 100644 --- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/on_as_app_service_data_notification.cc +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/on_as_app_service_data_notification.cc @@ -55,7 +55,7 @@ OnASAppServiceDataNotification:: void OnASAppServiceDataNotification::Run() { LOG4CXX_AUTO_TRACE(logger_); LOG4CXX_DEBUG(logger_, "Received an OnAppServiceData from HMI"); - MessageHelper::PrintSmartObject(message_); + MessageHelper::PrintSmartObject(*message_); } } // namespace commands diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/on_as_app_service_data_notification_from_hmi.cc b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/on_as_app_service_data_notification_from_hmi.cc index 3d5bc81c72..8e8c81b1f1 100644 --- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/on_as_app_service_data_notification_from_hmi.cc +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/on_as_app_service_data_notification_from_hmi.cc @@ -54,7 +54,7 @@ OnASAppServiceDataNotificationFromHMI::~OnASAppServiceDataNotificationFromHMI() void OnASAppServiceDataNotificationFromHMI::Run() { LOG4CXX_AUTO_TRACE(logger_); LOG4CXX_DEBUG(logger_, "Received an OnAppServiceData from HMI"); - MessageHelper::PrintSmartObject(message_); + MessageHelper::PrintSmartObject(*message_); } } // namespace commands diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/on_app_service_data_notification.cc b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/on_app_service_data_notification.cc index 6962e80567..6a6a50dc86 100644 --- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/on_app_service_data_notification.cc +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/on_app_service_data_notification.cc @@ -57,7 +57,7 @@ OnAppServiceDataNotification::~OnAppServiceDataNotification() {} void OnAppServiceDataNotification::Run() { LOG4CXX_AUTO_TRACE(logger_); LOG4CXX_DEBUG(logger_, "Sending OnAppServiceData to consumer"); - MessageHelper::PrintSmartObject(message_); + MessageHelper::PrintSmartObject(*message_); SendNotification(); } diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/on_app_service_data_notification_from_mobile.cc b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/on_app_service_data_notification_from_mobile.cc index 168ddaed23..b46bc7934e 100644 --- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/on_app_service_data_notification_from_mobile.cc +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/on_app_service_data_notification_from_mobile.cc @@ -58,7 +58,7 @@ OnAppServiceDataNotificationFromMobile:: void OnAppServiceDataNotificationFromMobile::Run() { LOG4CXX_AUTO_TRACE(logger_); LOG4CXX_DEBUG(logger_, "Received an OnAppServiceData"); - MessageHelper::PrintSmartObject(message_); + MessageHelper::PrintSmartObject(*message_); } } // namespace commands diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/publish_app_service_request.cc b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/publish_app_service_request.cc index a133695f60..beb5fdc696 100644 --- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/publish_app_service_request.cc +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/publish_app_service_request.cc @@ -57,7 +57,7 @@ PublishAppServiceRequest::~PublishAppServiceRequest() {} void PublishAppServiceRequest::Run() { LOG4CXX_AUTO_TRACE(logger_); LOG4CXX_DEBUG(logger_, "Received a PublishAppService"); - MessageHelper::PrintSmartObject(message_); + MessageHelper::PrintSmartObject(*message_); smart_objects::SmartObject response_params = smart_objects::SmartObject(smart_objects::SmartType_Map); @@ -69,7 +69,7 @@ void PublishAppServiceRequest::Run() { service_record[strings::service_id] = "This is a service ID"; service_record[strings::service_published] = true; service_record[strings::service_active] = true; - + response_params[strings::app_service_record] = service_record; SendResponse(true, mobile_apis::Result::SUCCESS, NULL, &response_params); -- cgit v1.2.1 From ea3832dc24e1502858020cd5774bfd1305725f21 Mon Sep 17 00:00:00 2001 From: jacobkeeler Date: Tue, 22 Jan 2019 17:57:34 -0500 Subject: Add AppServiceRPCPlugin to app service commands --- .../commands/hmi/as_publish_app_service_request.h | 2 ++ .../commands/hmi/as_publish_app_service_response.h | 2 ++ .../commands/hmi/on_as_app_service_data_notification.h | 2 ++ .../hmi/on_as_app_service_data_notification_from_hmi.h | 2 ++ .../commands/mobile/on_app_service_data_notification.h | 2 ++ .../on_app_service_data_notification_from_mobile.h | 2 ++ .../commands/mobile/publish_app_service_request.h | 2 ++ .../commands/mobile/publish_app_service_response.h | 2 ++ .../src/commands/hmi/as_publish_app_service_request.cc | 10 +++++++++- .../src/commands/hmi/as_publish_app_service_response.cc | 10 +++++++++- .../commands/hmi/on_as_app_service_data_notification.cc | 16 ++++++++++++---- .../hmi/on_as_app_service_data_notification_from_hmi.cc | 10 +++++++++- .../commands/mobile/on_app_service_data_notification.cc | 10 +++++++++- .../on_app_service_data_notification_from_mobile.cc | 10 +++++++++- .../src/commands/mobile/publish_app_service_request.cc | 10 +++++++++- .../src/commands/mobile/publish_app_service_response.cc | 10 +++++++++- 16 files changed, 91 insertions(+), 11 deletions(-) diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/hmi/as_publish_app_service_request.h b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/hmi/as_publish_app_service_request.h index 75e6343c9e..b21f99885a 100644 --- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/hmi/as_publish_app_service_request.h +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/hmi/as_publish_app_service_request.h @@ -33,6 +33,7 @@ #ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_APP_SERVICE_RPC_PLUGIN_INCLUDE_APP_SERVICE_RPC_PLUGIN_COMMANDS_HMI_AS_PUBLISH_APP_SERVICE_REQUEST_H_ #define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_APP_SERVICE_RPC_PLUGIN_INCLUDE_APP_SERVICE_RPC_PLUGIN_COMMANDS_HMI_AS_PUBLISH_APP_SERVICE_REQUEST_H_ +#include "app_service_rpc_plugin/app_service_rpc_plugin.h" #include "application_manager/commands/request_from_hmi.h" namespace app_service_rpc_plugin { @@ -68,6 +69,7 @@ class ASPublishAppServiceRequest : public app_mngr::commands::RequestFromHMI { virtual void Run(); private: + AppServiceRpcPlugin* plugin_; DISALLOW_COPY_AND_ASSIGN(ASPublishAppServiceRequest); }; diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/hmi/as_publish_app_service_response.h b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/hmi/as_publish_app_service_response.h index 3943c5f293..c532225632 100644 --- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/hmi/as_publish_app_service_response.h +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/hmi/as_publish_app_service_response.h @@ -33,6 +33,7 @@ #ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_APP_SERVICE_RPC_PLUGIN_INCLUDE_APP_SERVICE_RPC_PLUGIN_COMMANDS_HMI_AS_PUBLISH_APP_SERVICE_RESPONSE_H_ #define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_APP_SERVICE_RPC_PLUGIN_INCLUDE_APP_SERVICE_RPC_PLUGIN_COMMANDS_HMI_AS_PUBLISH_APP_SERVICE_RESPONSE_H_ +#include "app_service_rpc_plugin/app_service_rpc_plugin.h" #include "application_manager/commands/response_to_hmi.h" namespace app_service_rpc_plugin { @@ -68,6 +69,7 @@ class ASPublishAppServiceResponse : public app_mngr::commands::ResponseToHMI { virtual void Run(); private: + AppServiceRpcPlugin* plugin_; DISALLOW_COPY_AND_ASSIGN(ASPublishAppServiceResponse); }; diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/hmi/on_as_app_service_data_notification.h b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/hmi/on_as_app_service_data_notification.h index 5b2c40b26b..44d6d09fd3 100644 --- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/hmi/on_as_app_service_data_notification.h +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/hmi/on_as_app_service_data_notification.h @@ -33,6 +33,7 @@ #ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_APP_SERVICE_RPC_PLUGIN_INCLUDE_APP_SERVICE_RPC_PLUGIN_COMMANDS_HMI_ON_AS_APP_SERVICE_DATA_NOTIFICATION_H_ #define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_APP_SERVICE_RPC_PLUGIN_INCLUDE_APP_SERVICE_RPC_PLUGIN_COMMANDS_HMI_ON_AS_APP_SERVICE_DATA_NOTIFICATION_H_ +#include "app_service_rpc_plugin/app_service_rpc_plugin.h" #include "application_manager/commands/notification_to_hmi.h" namespace app_service_rpc_plugin { @@ -69,6 +70,7 @@ class OnASAppServiceDataNotification virtual void Run(); private: + AppServiceRpcPlugin* plugin_; DISALLOW_COPY_AND_ASSIGN(OnASAppServiceDataNotification); }; diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/hmi/on_as_app_service_data_notification_from_hmi.h b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/hmi/on_as_app_service_data_notification_from_hmi.h index 9a7072590b..df4cec9287 100644 --- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/hmi/on_as_app_service_data_notification_from_hmi.h +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/hmi/on_as_app_service_data_notification_from_hmi.h @@ -33,6 +33,7 @@ #ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_APP_SERVICE_RPC_PLUGIN_INCLUDE_APP_SERVICE_RPC_PLUGIN_COMMANDS_HMI_ON_AS_APP_SERVICE_DATA_NOTIFICATION_FROM_HMI_H_ #define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_APP_SERVICE_RPC_PLUGIN_INCLUDE_APP_SERVICE_RPC_PLUGIN_COMMANDS_HMI_ON_AS_APP_SERVICE_DATA_NOTIFICATION_FROM_HMI_H_ +#include "app_service_rpc_plugin/app_service_rpc_plugin.h" #include "application_manager/commands/notification_from_hmi.h" namespace app_service_rpc_plugin { @@ -68,6 +69,7 @@ class OnASAppServiceDataNotificationFromHMI : public app_mngr::commands::Notific virtual void Run(); private: + AppServiceRpcPlugin* plugin_; DISALLOW_COPY_AND_ASSIGN(OnASAppServiceDataNotificationFromHMI); }; diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/mobile/on_app_service_data_notification.h b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/mobile/on_app_service_data_notification.h index 751fac7f94..4bc818f9be 100644 --- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/mobile/on_app_service_data_notification.h +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/mobile/on_app_service_data_notification.h @@ -33,6 +33,7 @@ #ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_APP_SERVICE_RPC_PLUGIN_INCLUDE_APP_SERVICE_RPC_PLUGIN_COMMANDS_MOBILE_ON_APP_SERVICE_DATA_NOTIFICATION_H_ #define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_APP_SERVICE_RPC_PLUGIN_INCLUDE_APP_SERVICE_RPC_PLUGIN_COMMANDS_MOBILE_ON_APP_SERVICE_DATA_NOTIFICATION_H_ +#include "app_service_rpc_plugin/app_service_rpc_plugin.h" #include "application_manager/commands/command_notification_impl.h" namespace app_service_rpc_plugin { @@ -69,6 +70,7 @@ class OnAppServiceDataNotification virtual void Run(); private: + AppServiceRpcPlugin* plugin_; DISALLOW_COPY_AND_ASSIGN(OnAppServiceDataNotification); }; diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/mobile/on_app_service_data_notification_from_mobile.h b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/mobile/on_app_service_data_notification_from_mobile.h index 1d1b2170c2..f163e5848b 100644 --- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/mobile/on_app_service_data_notification_from_mobile.h +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/mobile/on_app_service_data_notification_from_mobile.h @@ -33,6 +33,7 @@ #ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_APP_SERVICE_RPC_PLUGIN_INCLUDE_APP_SERVICE_RPC_PLUGIN_COMMANDS_MOBILE_ON_APP_SERVICE_DATA_NOTIFICATION_FROM_MOBILE_H_ #define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_APP_SERVICE_RPC_PLUGIN_INCLUDE_APP_SERVICE_RPC_PLUGIN_COMMANDS_MOBILE_ON_APP_SERVICE_DATA_NOTIFICATION_FROM_MOBILE_H_ +#include "app_service_rpc_plugin/app_service_rpc_plugin.h" #include "application_manager/commands/command_notification_from_mobile_impl.h" namespace app_service_rpc_plugin { @@ -69,6 +70,7 @@ class OnAppServiceDataNotificationFromMobile virtual void Run(); private: + AppServiceRpcPlugin* plugin_; DISALLOW_COPY_AND_ASSIGN(OnAppServiceDataNotificationFromMobile); }; diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/mobile/publish_app_service_request.h b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/mobile/publish_app_service_request.h index c6351b3b15..a798bed613 100644 --- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/mobile/publish_app_service_request.h +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/mobile/publish_app_service_request.h @@ -33,6 +33,7 @@ #ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_APP_SERVICE_RPC_PLUGIN_INCLUDE_APP_SERVICE_RPC_PLUGIN_COMMANDS_MOBILE_PUBLISH_APP_SERVICE_REQUEST_H_ #define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_APP_SERVICE_RPC_PLUGIN_INCLUDE_APP_SERVICE_RPC_PLUGIN_COMMANDS_MOBILE_PUBLISH_APP_SERVICE_REQUEST_H_ +#include "app_service_rpc_plugin/app_service_rpc_plugin.h" #include "application_manager/commands/command_request_impl.h" namespace app_service_rpc_plugin { @@ -69,6 +70,7 @@ class PublishAppServiceRequest virtual void Run(); private: + AppServiceRpcPlugin* plugin_; DISALLOW_COPY_AND_ASSIGN(PublishAppServiceRequest); }; diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/mobile/publish_app_service_response.h b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/mobile/publish_app_service_response.h index 694c2906fa..27b4d6ad2f 100644 --- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/mobile/publish_app_service_response.h +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/mobile/publish_app_service_response.h @@ -33,6 +33,7 @@ #ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_APP_SERVICE_RPC_PLUGIN_INCLUDE_APP_SERVICE_RPC_PLUGIN_COMMANDS_MOBILE_PUBLISH_APP_SERVICE_RESPONSE_H_ #define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_APP_SERVICE_RPC_PLUGIN_INCLUDE_APP_SERVICE_RPC_PLUGIN_COMMANDS_MOBILE_PUBLISH_APP_SERVICE_RESPONSE_H_ +#include "app_service_rpc_plugin/app_service_rpc_plugin.h" #include "application_manager/commands/command_response_impl.h" namespace app_service_rpc_plugin { @@ -69,6 +70,7 @@ class PublishAppServiceResponse virtual void Run(); private: + AppServiceRpcPlugin* plugin_; DISALLOW_COPY_AND_ASSIGN(PublishAppServiceResponse); }; diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_publish_app_service_request.cc b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_publish_app_service_request.cc index a11e4e8a22..9acc8c3146 100644 --- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_publish_app_service_request.cc +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_publish_app_service_request.cc @@ -47,7 +47,15 @@ ASPublishAppServiceRequest::ASPublishAppServiceRequest( application_manager, rpc_service, hmi_capabilities, - policy_handler) {} + policy_handler) + , plugin_(NULL) { + auto plugin = (application_manager.GetPluginManager().FindPluginToProcess( + hmi_apis::FunctionID::AppService_PublishAppService, + app_mngr::commands::Command::CommandSource::SOURCE_HMI)); + if (plugin) { + plugin_ = dynamic_cast(&(*plugin)); + } +} ASPublishAppServiceRequest::~ASPublishAppServiceRequest() {} diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_publish_app_service_response.cc b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_publish_app_service_response.cc index c143315b8c..2513a92f15 100644 --- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_publish_app_service_response.cc +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_publish_app_service_response.cc @@ -47,7 +47,15 @@ ASPublishAppServiceResponse::ASPublishAppServiceResponse( application_manager, rpc_service, hmi_capabilities, - policy_handler) {} + policy_handler) + , plugin_(NULL) { + auto plugin = (application_manager.GetPluginManager().FindPluginToProcess( + hmi_apis::FunctionID::AppService_PublishAppService, + app_mngr::commands::Command::CommandSource::SOURCE_HMI)); + if (plugin) { + plugin_ = dynamic_cast(&(*plugin)); + } +} ASPublishAppServiceResponse::~ASPublishAppServiceResponse() {} diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/on_as_app_service_data_notification.cc b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/on_as_app_service_data_notification.cc index d242ea1161..e590d63a05 100644 --- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/on_as_app_service_data_notification.cc +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/on_as_app_service_data_notification.cc @@ -44,10 +44,18 @@ OnASAppServiceDataNotification::OnASAppServiceDataNotification( app_mngr::HMICapabilities& hmi_capabilities, policy::PolicyHandlerInterface& policy_handler) : NotificationToHMI(message, - application_manager, - rpc_service, - hmi_capabilities, - policy_handler) {} + application_manager, + rpc_service, + hmi_capabilities, + policy_handler) + , plugin_(NULL) { + auto plugin = (application_manager.GetPluginManager().FindPluginToProcess( + hmi_apis::FunctionID::AppService_OnAppServiceData, + app_mngr::commands::Command::CommandSource::SOURCE_HMI)); + if (plugin) { + plugin_ = dynamic_cast(&(*plugin)); + } +} OnASAppServiceDataNotification:: ~OnASAppServiceDataNotification() {} diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/on_as_app_service_data_notification_from_hmi.cc b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/on_as_app_service_data_notification_from_hmi.cc index 8e8c81b1f1..3dea2a6a12 100644 --- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/on_as_app_service_data_notification_from_hmi.cc +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/on_as_app_service_data_notification_from_hmi.cc @@ -47,7 +47,15 @@ OnASAppServiceDataNotificationFromHMI::OnASAppServiceDataNotificationFromHMI( application_manager, rpc_service, hmi_capabilities, - policy_handler) {} + policy_handler) + , plugin_(NULL) { + auto plugin = (application_manager.GetPluginManager().FindPluginToProcess( + hmi_apis::FunctionID::AppService_OnAppServiceData, + app_mngr::commands::Command::CommandSource::SOURCE_HMI)); + if (plugin) { + plugin_ = dynamic_cast(&(*plugin)); + } +} OnASAppServiceDataNotificationFromHMI::~OnASAppServiceDataNotificationFromHMI() {} diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/on_app_service_data_notification.cc b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/on_app_service_data_notification.cc index 6a6a50dc86..33ab1a7246 100644 --- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/on_app_service_data_notification.cc +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/on_app_service_data_notification.cc @@ -50,7 +50,15 @@ OnAppServiceDataNotification::OnAppServiceDataNotification( application_manager, rpc_service, hmi_capabilities, - policy_handler) {} + policy_handler) + , plugin_(NULL) { + auto plugin = (application_manager.GetPluginManager().FindPluginToProcess( + mobile_apis::FunctionID::OnAppServiceDataID, + app_mngr::commands::Command::CommandSource::SOURCE_MOBILE)); + if (plugin) { + plugin_ = dynamic_cast(&(*plugin)); + } +} OnAppServiceDataNotification::~OnAppServiceDataNotification() {} diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/on_app_service_data_notification_from_mobile.cc b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/on_app_service_data_notification_from_mobile.cc index b46bc7934e..a7a8042fee 100644 --- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/on_app_service_data_notification_from_mobile.cc +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/on_app_service_data_notification_from_mobile.cc @@ -50,7 +50,15 @@ OnAppServiceDataNotificationFromMobile::OnAppServiceDataNotificationFromMobile( application_manager, rpc_service, hmi_capabilities, - policy_handler) {} + policy_handler) + , plugin_(NULL) { + auto plugin = (application_manager.GetPluginManager().FindPluginToProcess( + mobile_apis::FunctionID::OnAppServiceDataID, + app_mngr::commands::Command::CommandSource::SOURCE_MOBILE)); + if (plugin) { + plugin_ = dynamic_cast(&(*plugin)); + } +} OnAppServiceDataNotificationFromMobile:: ~OnAppServiceDataNotificationFromMobile() {} diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/publish_app_service_request.cc b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/publish_app_service_request.cc index beb5fdc696..e5f7c40471 100644 --- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/publish_app_service_request.cc +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/publish_app_service_request.cc @@ -50,7 +50,15 @@ PublishAppServiceRequest::PublishAppServiceRequest( application_manager, rpc_service, hmi_capabilities, - policy_handler) {} + policy_handler) + , plugin_(NULL) { + auto plugin = (application_manager.GetPluginManager().FindPluginToProcess( + mobile_apis::FunctionID::PublishAppServiceID, + app_mngr::commands::Command::CommandSource::SOURCE_MOBILE)); + if (plugin) { + plugin_ = dynamic_cast(&(*plugin)); + } +} PublishAppServiceRequest::~PublishAppServiceRequest() {} diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/publish_app_service_response.cc b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/publish_app_service_response.cc index b1136c79d0..6c3e9344bf 100644 --- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/publish_app_service_response.cc +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/publish_app_service_response.cc @@ -50,7 +50,15 @@ PublishAppServiceResponse::PublishAppServiceResponse( application_manager, rpc_service, hmi_capabilities, - policy_handler) {} + policy_handler) + , plugin_(NULL) { + auto plugin = (application_manager.GetPluginManager().FindPluginToProcess( + mobile_apis::FunctionID::PublishAppServiceID, + app_mngr::commands::Command::CommandSource::SOURCE_MOBILE)); + if (plugin) { + plugin_ = dynamic_cast(&(*plugin)); + } +} PublishAppServiceResponse::~PublishAppServiceResponse() {} -- cgit v1.2.1 From 91fc054c1f3de59944c4d7030f68a7640a34316f Mon Sep 17 00:00:00 2001 From: JackLivio Date: Tue, 22 Jan 2019 22:14:09 -0500 Subject: Initial regular policy implementation --- .../application_manager/policies/policy_handler.h | 5 ++ .../app_service_hmi_command_factory.h | 9 ++- .../app_service_rpc_plugin.h | 4 +- .../on_as_app_service_data_notification_from_hmi.h | 3 +- .../commands/mobile/publish_app_service_request.h | 14 ++--- .../commands/mobile/publish_app_service_response.h | 11 ++-- .../src/app_service_hmi_command_factory.cc | 6 +- .../src/app_service_mobile_command_factory.cc | 9 +-- .../hmi/on_as_app_service_data_notification.cc | 3 +- ...on_as_app_service_data_notification_from_hmi.cc | 3 +- .../commands/mobile/publish_app_service_request.cc | 36 +++++++++++ .../src/policies/policy_handler.cc | 10 ++++ .../application_manager/src/smart_object_keys.cc | 2 +- .../policies/policy_handler_interface.h | 6 ++ .../policy/policy_regular/policy/policy_manager.h | 6 ++ .../policy_regular/include/policy/cache_manager.h | 6 ++ .../include/policy/cache_manager_interface.h | 6 ++ .../include/policy/policy_manager_impl.h | 6 ++ .../include/policy/policy_table/types.h | 7 +++ .../policy_regular/include/policy/sql_pt_queries.h | 3 + .../include/policy/sql_pt_representation.h | 4 ++ .../policy/policy_regular/src/cache_manager.cc | 27 +++++++++ .../policy_regular/src/policy_manager_impl.cc | 9 +++ .../policy_regular/src/policy_table/types.cc | 40 ++++++++++++- .../policy/policy_regular/src/sql_pt_queries.cc | 38 ++++++++++-- .../policy_regular/src/sql_pt_representation.cc | 70 ++++++++++++++++++++++ 26 files changed, 302 insertions(+), 41 deletions(-) diff --git a/src/components/application_manager/include/application_manager/policies/policy_handler.h b/src/components/application_manager/include/application_manager/policies/policy_handler.h index 8ee5ff64f6..6322f4723b 100644 --- a/src/components/application_manager/include/application_manager/policies/policy_handler.h +++ b/src/components/application_manager/include/application_manager/policies/policy_handler.h @@ -447,6 +447,11 @@ class PolicyHandler : public PolicyHandlerInterface, void OnSetCloudAppProperties( const smart_objects::SmartObject& message) OVERRIDE; + void GetAppServiceParameters(const std::string& policy_app_id, + std::string& app_service_name, + std::string& service_type, + std::vector& handled_rpcs) const; + virtual void OnUpdateHMIAppType( std::map app_hmi_types) OVERRIDE; diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/app_service_hmi_command_factory.h b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/app_service_hmi_command_factory.h index dfe333b881..c42b64f559 100644 --- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/app_service_hmi_command_factory.h +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/app_service_hmi_command_factory.h @@ -43,11 +43,10 @@ namespace app_mngr = application_manager; */ class AppServiceHmiCommandFactory : public app_mngr::CommandFactory { public: - AppServiceHmiCommandFactory( - app_mngr::ApplicationManager& application_manager, - app_mngr::rpc_service::RPCService& rpc_service, - app_mngr::HMICapabilities& hmi_capabilities, - policy::PolicyHandlerInterface& policy_handler); + AppServiceHmiCommandFactory(app_mngr::ApplicationManager& application_manager, + app_mngr::rpc_service::RPCService& rpc_service, + app_mngr::HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handler); app_mngr::CommandSharedPtr CreateCommand( const app_mngr::commands::MessageSharedPtr& message, diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/app_service_rpc_plugin.h b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/app_service_rpc_plugin.h index 398711b7a7..1113911a22 100644 --- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/app_service_rpc_plugin.h +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/app_service_rpc_plugin.h @@ -36,7 +36,7 @@ #include "application_manager/command_factory.h" namespace app_service_rpc_plugin { -//class AppServiceAppExtension; +// class AppServiceAppExtension; namespace app_mngr = application_manager; namespace plugins = application_manager::plugin_manager; @@ -67,7 +67,7 @@ class AppServiceRpcPlugin : public plugins::RPCPlugin { * @param ext application extension */ // TODO - //void ProcessResumptionSubscription(app_mngr::Application& app, + // void ProcessResumptionSubscription(app_mngr::Application& app, // AppServiceAppExtension& ext); private: diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/hmi/on_as_app_service_data_notification_from_hmi.h b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/hmi/on_as_app_service_data_notification_from_hmi.h index df4cec9287..7ca20d692a 100644 --- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/hmi/on_as_app_service_data_notification_from_hmi.h +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/hmi/on_as_app_service_data_notification_from_hmi.h @@ -44,7 +44,8 @@ namespace commands { /** * @brief OnASAppServiceDataNotificationFromHMI command class **/ -class OnASAppServiceDataNotificationFromHMI : public app_mngr::commands::NotificationFromHMI { +class OnASAppServiceDataNotificationFromHMI + : public app_mngr::commands::NotificationFromHMI { public: /** * @brief OnASAppServiceDataNotificationFromHMI class constructor diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/mobile/publish_app_service_request.h b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/mobile/publish_app_service_request.h index a798bed613..ede7afbc73 100644 --- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/mobile/publish_app_service_request.h +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/mobile/publish_app_service_request.h @@ -44,20 +44,18 @@ namespace commands { /** * @brief PublishAppServiceRequest command class **/ -class PublishAppServiceRequest - : public app_mngr::commands::CommandRequestImpl { +class PublishAppServiceRequest : public app_mngr::commands::CommandRequestImpl { public: /** * @brief PublishAppServiceRequest class constructor * * @param message Incoming SmartObject message **/ - PublishAppServiceRequest( - const app_mngr::commands::MessageSharedPtr& message, - app_mngr::ApplicationManager& application_manager, - app_mngr::rpc_service::RPCService& rpc_service, - app_mngr::HMICapabilities& hmi_capabilities, - policy::PolicyHandlerInterface& policy_handle); + PublishAppServiceRequest(const app_mngr::commands::MessageSharedPtr& message, + app_mngr::ApplicationManager& application_manager, + app_mngr::rpc_service::RPCService& rpc_service, + app_mngr::HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle); /** * @brief PublishAppServiceRequest class destructor diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/mobile/publish_app_service_response.h b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/mobile/publish_app_service_response.h index 27b4d6ad2f..a11399c9e1 100644 --- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/mobile/publish_app_service_response.h +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/mobile/publish_app_service_response.h @@ -52,12 +52,11 @@ class PublishAppServiceResponse * * @param message Incoming SmartObject message **/ - PublishAppServiceResponse( - const app_mngr::commands::MessageSharedPtr& message, - app_mngr::ApplicationManager& application_manager, - app_mngr::rpc_service::RPCService& rpc_service, - app_mngr::HMICapabilities& hmi_capabilities, - policy::PolicyHandlerInterface& policy_handle); + PublishAppServiceResponse(const app_mngr::commands::MessageSharedPtr& message, + app_mngr::ApplicationManager& application_manager, + app_mngr::rpc_service::RPCService& rpc_service, + app_mngr::HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle); /** * @brief PublishAppServiceResponse class destructor diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/app_service_hmi_command_factory.cc b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/app_service_hmi_command_factory.cc index 746636aff0..e741d7bfd4 100644 --- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/app_service_hmi_command_factory.cc +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/app_service_hmi_command_factory.cc @@ -88,9 +88,9 @@ bool AppServiceHmiCommandFactory::IsAbleToProcess( const int32_t function_id, const app_mngr::commands::Command::CommandSource source) const { UNUSED(source); - return buildCommandCreator( - function_id, hmi_apis::messageType::INVALID_ENUM, source) - .CanBeCreated(); + return buildCommandCreator(function_id, + hmi_apis::messageType::INVALID_ENUM, + source).CanBeCreated(); } app_mngr::CommandCreator& AppServiceHmiCommandFactory::buildCommandCreator( diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/app_service_mobile_command_factory.cc b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/app_service_mobile_command_factory.cc index 3b4e3490f6..e0e667e975 100644 --- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/app_service_mobile_command_factory.cc +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/app_service_mobile_command_factory.cc @@ -89,9 +89,9 @@ bool AppServiceMobileCommandFactory::IsAbleToProcess( const int32_t function_id, const app_mngr::commands::Command::CommandSource source) const { UNUSED(source); - return buildCommandCreator( - function_id, mobile_apis::messageType::INVALID_ENUM, source) - .CanBeCreated(); + return buildCommandCreator(function_id, + mobile_apis::messageType::INVALID_ENUM, + source).CanBeCreated(); } app_mngr::CommandCreator& AppServiceMobileCommandFactory::buildCommandCreator( @@ -108,7 +108,8 @@ app_mngr::CommandCreator& AppServiceMobileCommandFactory::buildCommandCreator( : factory.GetCreator(); case mobile_apis::FunctionID::OnAppServiceDataID: return app_mngr::commands::Command::CommandSource::SOURCE_MOBILE == source - ? factory.GetCreator() + ? factory.GetCreator< + commands::OnAppServiceDataNotificationFromMobile>() : factory.GetCreator(); default: LOG4CXX_WARN(logger_, "Unsupported function_id: " << function_id); diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/on_as_app_service_data_notification.cc b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/on_as_app_service_data_notification.cc index e590d63a05..0cd269b04e 100644 --- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/on_as_app_service_data_notification.cc +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/on_as_app_service_data_notification.cc @@ -57,8 +57,7 @@ OnASAppServiceDataNotification::OnASAppServiceDataNotification( } } -OnASAppServiceDataNotification:: - ~OnASAppServiceDataNotification() {} +OnASAppServiceDataNotification::~OnASAppServiceDataNotification() {} void OnASAppServiceDataNotification::Run() { LOG4CXX_AUTO_TRACE(logger_); diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/on_as_app_service_data_notification_from_hmi.cc b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/on_as_app_service_data_notification_from_hmi.cc index 3dea2a6a12..01a8e817a2 100644 --- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/on_as_app_service_data_notification_from_hmi.cc +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/on_as_app_service_data_notification_from_hmi.cc @@ -57,7 +57,8 @@ OnASAppServiceDataNotificationFromHMI::OnASAppServiceDataNotificationFromHMI( } } -OnASAppServiceDataNotificationFromHMI::~OnASAppServiceDataNotificationFromHMI() {} +OnASAppServiceDataNotificationFromHMI:: + ~OnASAppServiceDataNotificationFromHMI() {} void OnASAppServiceDataNotificationFromHMI::Run() { LOG4CXX_AUTO_TRACE(logger_); diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/publish_app_service_request.cc b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/publish_app_service_request.cc index e5f7c40471..05fe75c887 100644 --- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/publish_app_service_request.cc +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/publish_app_service_request.cc @@ -78,6 +78,42 @@ void PublishAppServiceRequest::Run() { service_record[strings::service_published] = true; service_record[strings::service_active] = true; + std::string requested_service_name = + (*message_)[strings::msg_params][strings::app_service_manifest] + [strings::service_name].asString(); + std::string requested_service_type = + (*message_)[strings::msg_params][strings::app_service_manifest] + [strings::service_type].asString(); + smart_objects::SmartArray* requested_handled_rpcs = + (*message_)[strings::msg_params][strings::app_service_manifest] + [strings::handled_rpcs].asArray(); + + std::string service_name = std::string(); + std::string service_type = std::string(); + std::vector handled_rpcs = {}; + ApplicationSharedPtr app = application_manager_.application(connection_key()); + + policy_handler_.GetAppServiceParameters( + app->policy_app_id(), service_name, service_type, handled_rpcs); + + if (service_name != requested_service_name) { + SendResponse(false, mobile_apis::Result::DISALLOWED, NULL, NULL); + } + + if (service_type != requested_service_type) { + SendResponse(false, mobile_apis::Result::DISALLOWED, NULL, NULL); + } + + for (auto requested_it = requested_handled_rpcs->begin(); + requested_it != requested_handled_rpcs->end(); + ++requested_it) { + auto find_result = std::find( + handled_rpcs.begin(), handled_rpcs.end(), requested_it->asUInt()); + if (find_result == handled_rpcs.end()) { + SendResponse(false, mobile_apis::Result::DISALLOWED, NULL, NULL); + } + } + response_params[strings::app_service_record] = service_record; SendResponse(true, mobile_apis::Result::SUCCESS, NULL, &response_params); diff --git a/src/components/application_manager/src/policies/policy_handler.cc b/src/components/application_manager/src/policies/policy_handler.cc index 3be3ef0da7..16433f7637 100644 --- a/src/components/application_manager/src/policies/policy_handler.cc +++ b/src/components/application_manager/src/policies/policy_handler.cc @@ -1937,6 +1937,16 @@ void PolicyHandler::OnSetCloudAppProperties( } } +void PolicyHandler::GetAppServiceParameters( + const std::string& policy_app_id, + std::string& app_service_name, + std::string& service_type, + std::vector& handled_rpcs) const { + POLICY_LIB_CHECK_VOID(); + policy_manager_->GetAppServiceParameters( + policy_app_id, app_service_name, service_type, handled_rpcs); +} + uint32_t PolicyHandler::HeartBeatTimeout(const std::string& app_id) const { POLICY_LIB_CHECK(0); return policy_manager_->HeartBeatTimeout(app_id); diff --git a/src/components/application_manager/src/smart_object_keys.cc b/src/components/application_manager/src/smart_object_keys.cc index 00dabb9480..1b6dfe2b8b 100644 --- a/src/components/application_manager/src/smart_object_keys.cc +++ b/src/components/application_manager/src/smart_object_keys.cc @@ -274,7 +274,7 @@ const char* service_type = "serviceType"; const char* service_icon = "serviceIcon"; const char* allow_app_consumers = "allowAppConsumers"; const char* uri_prefix = "uriPrefix"; -const char* uri_scheme = "uriScheme"; +const char* uri_scheme = "uriScheme"; const char* rpc_spec_version = "rpcSpecVersion"; const char* handled_rpcs = "handledRPCs"; const char* media_service_manifest = "mediaServiceManifest"; diff --git a/src/components/include/application_manager/policies/policy_handler_interface.h b/src/components/include/application_manager/policies/policy_handler_interface.h index 8c8a12ced3..3ba165bff9 100644 --- a/src/components/include/application_manager/policies/policy_handler_interface.h +++ b/src/components/include/application_manager/policies/policy_handler_interface.h @@ -488,6 +488,12 @@ class PolicyHandlerInterface { virtual void OnSetCloudAppProperties( const smart_objects::SmartObject& message) = 0; + virtual void GetAppServiceParameters( + const std::string& policy_app_id, + std::string& app_service_name, + std::string& service_type, + std::vector& handled_rpcs) const = 0; + #ifdef EXTERNAL_PROPRIETARY_MODE /** * @brief Gets meta information diff --git a/src/components/include/policy/policy_regular/policy/policy_manager.h b/src/components/include/policy/policy_regular/policy/policy_manager.h index b2d48585f4..e7ff4be7e8 100644 --- a/src/components/include/policy/policy_regular/policy/policy_manager.h +++ b/src/components/include/policy/policy_regular/policy/policy_manager.h @@ -573,6 +573,12 @@ class PolicyManager : public usage_statistics::StatisticsManager { const std::string& policy_app_id, const std::string& hybrid_app_preference) = 0; + virtual void GetAppServiceParameters( + const std::string& policy_app_id, + std::string& app_service_name, + std::string& service_type, + std::vector& handled_rpcs) const = 0; + /** * @brief OnAppRegisteredOnMobile allows to handle event when application were * succesfully registered on mobile device. diff --git a/src/components/policy/policy_regular/include/policy/cache_manager.h b/src/components/policy/policy_regular/include/policy/cache_manager.h index 8c8f0c55c6..a90885d8cc 100644 --- a/src/components/policy/policy_regular/include/policy/cache_manager.h +++ b/src/components/policy/policy_regular/include/policy/cache_manager.h @@ -216,6 +216,12 @@ class CacheManager : public CacheManagerInterface { virtual void SetHybridAppPreference(const std::string& policy_app_id, const std::string& hybrid_app_preference); + virtual void GetAppServiceParameters( + const std::string& policy_app_id, + std::string& app_service_name, + std::string& service_type, + std::vector& handled_rpcs) const; + /** * @brief Allows to update 'vin' field in module_meta table. * diff --git a/src/components/policy/policy_regular/include/policy/cache_manager_interface.h b/src/components/policy/policy_regular/include/policy/cache_manager_interface.h index 50b546ecc5..0dabbbecf5 100644 --- a/src/components/policy/policy_regular/include/policy/cache_manager_interface.h +++ b/src/components/policy/policy_regular/include/policy/cache_manager_interface.h @@ -223,6 +223,12 @@ class CacheManagerInterface { const std::string& policy_app_id, const std::string& hybrid_app_preference) = 0; + virtual void GetAppServiceParameters( + const std::string& policy_app_id, + std::string& app_service_name, + std::string& service_type, + std::vector& handled_rpcs) const = 0; + /** * @brief Allows to update 'vin' field in module_meta table. * diff --git a/src/components/policy/policy_regular/include/policy/policy_manager_impl.h b/src/components/policy/policy_regular/include/policy/policy_manager_impl.h index 20a37717a7..575e688114 100644 --- a/src/components/policy/policy_regular/include/policy/policy_manager_impl.h +++ b/src/components/policy/policy_regular/include/policy/policy_manager_impl.h @@ -634,6 +634,12 @@ class PolicyManagerImpl : public PolicyManager { const std::string& policy_app_id, const std::string& hybrid_app_preference) OVERRIDE; + void GetAppServiceParameters( + const std::string& policy_app_id, + std::string& app_service_name, + std::string& service_type, + std::vector& handled_rpcs) const OVERRIDE; + /** * @brief OnAppRegisteredOnMobile allows to handle event when application were * succesfully registered on mobile device. diff --git a/src/components/policy/policy_regular/include/policy/policy_table/types.h b/src/components/policy/policy_regular/include/policy/policy_table/types.h index 58f07492c4..4a6795b382 100644 --- a/src/components/policy/policy_regular/include/policy/policy_table/types.h +++ b/src/components/policy/policy_regular/include/policy/policy_table/types.h @@ -98,6 +98,8 @@ typedef Array, 0, 255> RequestTypes; typedef Strings RequestSubTypes; +typedef Array, 0, 255> HandledRpcs; + typedef Map RemoteRpcs; typedef Map AccessModules; typedef Array, 0, 255> ModuleTypes; @@ -151,6 +153,11 @@ struct ApplicationParams : PolicyBase { Optional > auth_token; Optional > cloud_transport_type; + // App Service Params + Optional > app_service_name; + Optional > service_type; + Optional handled_rpcs; + public: ApplicationParams(); ApplicationParams(const Strings& groups, Priority priority); diff --git a/src/components/policy/policy_regular/include/policy/sql_pt_queries.h b/src/components/policy/policy_regular/include/policy/sql_pt_queries.h index 191873efe0..c910fbb3df 100644 --- a/src/components/policy/policy_regular/include/policy/sql_pt_queries.h +++ b/src/components/policy/policy_regular/include/policy/sql_pt_queries.h @@ -66,6 +66,7 @@ extern const std::string kSelectNicknames; extern const std::string kSelectAppTypes; extern const std::string kSelectRequestTypes; extern const std::string kSelectRequestSubTypes; +extern const std::string kSelectHandledRpcs; extern const std::string kSelectSecondsBetweenRetries; extern const std::string kSelectIgnitionCycles; extern const std::string kSelectKilometers; @@ -80,6 +81,7 @@ extern const std::string kInsertNickname; extern const std::string kInsertAppType; extern const std::string kInsertRequestType; extern const std::string kInsertRequestSubType; +extern const std::string kInsertHandledRpcs; extern const std::string kInsertMessageType; extern const std::string kInsertLanguage; extern const std::string kInsertMessageString; @@ -100,6 +102,7 @@ extern const std::string kDeleteAppGroup; extern const std::string kDeleteApplication; extern const std::string kDeleteRequestType; extern const std::string kDeleteRequestSubType; +extern const std::string kDeleteHandledRpcs; extern const std::string kDeleteDevice; extern const std::string kIncrementIgnitionCycles; extern const std::string kResetIgnitionCycles; diff --git a/src/components/policy/policy_regular/include/policy/sql_pt_representation.h b/src/components/policy/policy_regular/include/policy/sql_pt_representation.h index 0e9302dfac..f3167d252a 100644 --- a/src/components/policy/policy_regular/include/policy/sql_pt_representation.h +++ b/src/components/policy/policy_regular/include/policy/sql_pt_representation.h @@ -133,6 +133,8 @@ class SQLPTRepresentation : public virtual PTRepresentation { bool GatherRequestSubType( const std::string& app_id, policy_table::RequestSubTypes* request_subtypes) const; + bool GatherHandledRpcs(const std::string& app_id, + policy_table::HandledRpcs* handled_rpcs) const; bool GatherNickName(const std::string& app_id, policy_table::Strings* nicknames) const; @@ -171,6 +173,8 @@ class SQLPTRepresentation : public virtual PTRepresentation { bool SaveRequestSubType( const std::string& app_id, const policy_table::RequestSubTypes& request_subtypes); + bool SaveHandledRpcs(const std::string& app_id, + const policy_table::HandledRpcs& handled_rpcs); public: bool UpdateRequired() const; diff --git a/src/components/policy/policy_regular/src/cache_manager.cc b/src/components/policy/policy_regular/src/cache_manager.cc index ca61a338f1..3fece5e5d6 100644 --- a/src/components/policy/policy_regular/src/cache_manager.cc +++ b/src/components/policy/policy_regular/src/cache_manager.cc @@ -796,6 +796,33 @@ void CacheManager::SetHybridAppPreference( } } +void CacheManager::GetAppServiceParameters( + const std::string& policy_app_id, + std::string& app_service_name, + std::string& service_type, + std::vector& handled_rpcs) const { + LOG4CXX_AUTO_TRACE(logger_); + const policy_table::ApplicationPolicies& policies = + pt_->policy_table.app_policies_section.apps; + policy_table::ApplicationPolicies::const_iterator policy_iter = + policies.find(policy_app_id); + if (policies.end() != policy_iter) { + auto app_policy = (*policy_iter).second; + app_service_name = app_policy.app_service_name.is_initialized() + ? *app_policy.app_service_name + : std::string(); + service_type = app_policy.service_type.is_initialized() + ? *app_policy.service_type + : std::string(); + if (!app_policy.handled_rpcs.is_initialized()) { + return; + } + for (const auto& rpc : *(app_policy.handled_rpcs)) { + handled_rpcs.push_back(rpc); + } + } +} + std::vector CacheManager::GetUserFriendlyMsg( const std::vector& msg_codes, const std::string& language) { LOG4CXX_AUTO_TRACE(logger_); diff --git a/src/components/policy/policy_regular/src/policy_manager_impl.cc b/src/components/policy/policy_regular/src/policy_manager_impl.cc index 9b2392a015..d85ccb14f0 100644 --- a/src/components/policy/policy_regular/src/policy_manager_impl.cc +++ b/src/components/policy/policy_regular/src/policy_manager_impl.cc @@ -591,6 +591,15 @@ void PolicyManagerImpl::SetHybridAppPreference( cache_->SetHybridAppPreference(policy_app_id, hybrid_app_preference); } +void PolicyManagerImpl::GetAppServiceParameters( + const std::string& policy_app_id, + std::string& app_service_name, + std::string& service_type, + std::vector& handled_rpcs) const { + cache_->GetAppServiceParameters( + policy_app_id, app_service_name, service_type, handled_rpcs); +} + void PolicyManagerImpl::CheckPermissions(const PTString& device_id, const PTString& app_id, const PTString& hmi_level, diff --git a/src/components/policy/policy_regular/src/policy_table/types.cc b/src/components/policy/policy_regular/src/policy_table/types.cc index 88564df050..8dda6981b2 100644 --- a/src/components/policy/policy_regular/src/policy_table/types.cc +++ b/src/components/policy/policy_regular/src/policy_table/types.cc @@ -173,8 +173,10 @@ ApplicationParams::ApplicationParams(const Json::Value* value__) , endpoint(impl::ValueMember(value__, "endpoint")) , enabled(impl::ValueMember(value__, "enabled")) , auth_token(impl::ValueMember(value__, "auth_token")) - , cloud_transport_type(impl::ValueMember(value__, "cloud_transport_type")) { -} + , cloud_transport_type(impl::ValueMember(value__, "cloud_transport_type")) + , app_service_name(impl::ValueMember(value__, "app_service_name")) + , service_type(impl::ValueMember(value__, "service_type")) + , handled_rpcs(impl::ValueMember(value__, "handled_rpcs")) {} Json::Value ApplicationParams::ToJsonValue() const { Json::Value result__(PolicyBase::ToJsonValue()); @@ -194,6 +196,9 @@ Json::Value ApplicationParams::ToJsonValue() const { impl::WriteJsonField("enabled", enabled, &result__); impl::WriteJsonField("auth_token", auth_token, &result__); impl::WriteJsonField("cloud_transport_type", cloud_transport_type, &result__); + impl::WriteJsonField("app_service_name", app_service_name, &result__); + impl::WriteJsonField("service_type", service_type, &result__); + impl::WriteJsonField("handled_rpcs", handled_rpcs, &result__); return result__; } @@ -240,6 +245,15 @@ bool ApplicationParams::is_valid() const { if (!hybrid_app_preference.is_valid()) { return false; } + if (!app_service_name.is_valid()) { + return false; + } + if (!service_type.is_valid()) { + return false; + } + if (!handled_rpcs.is_valid()) { + return false; + } return Validate(); } @@ -293,6 +307,15 @@ bool ApplicationParams::struct_empty() const { if (hybrid_app_preference.is_initialized()) { return false; } + if (app_service_name.is_initialized()) { + return false; + } + if (service_type.is_initialized()) { + return false; + } + if (handled_rpcs.is_initialized()) { + return false; + } return true; } @@ -347,6 +370,16 @@ void ApplicationParams::ReportErrors(rpc::ValidationReport* report__) const { moduleType.ReportErrors( &report__->ReportSubobject("hybrid_app_preference")); } + if (!app_service_name.is_valid()) { + app_service_name.ReportErrors( + &report__->ReportSubobject("app_service_name")); + } + if (!service_type.is_valid()) { + service_type.ReportErrors(&report__->ReportSubobject("service_type")); + } + if (!handled_rpcs.is_valid()) { + handled_rpcs.ReportErrors(&report__->ReportSubobject("handled_rpcs")); + } } void ApplicationParams::SetPolicyTableType(PolicyTableType pt_type) { @@ -363,6 +396,9 @@ void ApplicationParams::SetPolicyTableType(PolicyTableType pt_type) { enabled.SetPolicyTableType(pt_type); cloud_transport_type.SetPolicyTableType(pt_type); hybrid_app_preference.SetPolicyTableType(pt_type); + app_service_name.SetPolicyTableType(pt_type); + service_type.SetPolicyTableType(pt_type); + handled_rpcs.SetPolicyTableType(pt_type); } // RpcParameters methods diff --git a/src/components/policy/policy_regular/src/sql_pt_queries.cc b/src/components/policy/policy_regular/src/sql_pt_queries.cc index 297031d4c0..6329662a55 100644 --- a/src/components/policy/policy_regular/src/sql_pt_queries.cc +++ b/src/components/policy/policy_regular/src/sql_pt_queries.cc @@ -142,6 +142,8 @@ const std::string kCreateSchema = " `enabled` BOOLEAN, " " `auth_token` VARCHAR(65535), " " `cloud_transport_type` VARCHAR(255), " + " `app_service_name` VARCHAR(255), " + " `service_type` VARCHAR(255), " " `remote_control_denied` BOOLEAN NOT NULL DEFAULT 0, " " CONSTRAINT `fk_application_hmi_level1` " " FOREIGN KEY(`default_hmi`) " @@ -287,6 +289,14 @@ const std::string kCreateSchema = " FOREIGN KEY(`application_id`) " " REFERENCES `application`(`id`) " "); " + "CREATE TABLE IF NOT EXISTS `handled_rpcs`( " + " `handled_rpcs` INTEGER, " + " `application_id` VARCHAR(45) NOT NULL COLLATE NOCASE, " + " PRIMARY KEY(`handled_rpcs`,`application_id`), " + " CONSTRAINT `fk_handled_rpcs_app_id` " + " FOREIGN KEY(`application_id`) " + " REFERENCES `application`(`id`) " + "); " "CREATE INDEX IF NOT EXISTS `app_type.fk_app_type_application1_idx` " " ON `app_type`(`application_id` COLLATE NOCASE); " "CREATE TABLE IF NOT EXISTS `consent_group`( " @@ -467,6 +477,7 @@ const std::string kDropSchema = "DROP TABLE IF EXISTS `app_type`; " "DROP TABLE IF EXISTS `request_type`; " "DROP TABLE IF EXISTS `request_subtype`; " + "DROP TABLE IF EXISTS `handled_rpcs`; " "DROP INDEX IF EXISTS `nickname.fk_nickname_application1_idx`; " "DROP TABLE IF EXISTS `nickname`; " "DROP INDEX IF EXISTS `app_level.fk_app_level_language2_idx`; " @@ -598,8 +609,8 @@ const std::string kInsertApplication = "INSERT OR IGNORE INTO `application` (`id`, `priority_value`, " "`is_revoked`, `memory_kb`, `heart_beat_timeout_ms`, `certificate`, " "`hybrid_app_preference_value`, `endpoint`, `enabled`, `auth_token`, " - "`cloud_transport_type`) VALUES " - "(?,?,?,?,?,?,?,?,?,?,?)"; + "`cloud_transport_type`, `app_service_name`, `service_type`) VALUES " + "(?,?,?,?,?,?,?,?,?,?,?,?,?)"; const std::string kInsertAppGroup = "INSERT INTO `app_group` (`application_id`, `functional_group_id`)" @@ -620,6 +631,11 @@ const std::string kInsertRequestSubType = "`request_subtype`) " "VALUES (?, ?)"; +const std::string kInsertHandledRpcs = + "INSERT INTO `handled_rpcs` (`application_id`, " + "`handled_rpcs`) " + "VALUES (?, ?)"; + const std::string kUpdateVersion = "UPDATE `version` SET `number`= ?"; const std::string kInsertMessageType = @@ -709,7 +725,8 @@ const std::string kSelectUserMsgsVersion = const std::string kSelectAppPolicies = "SELECT `id`, `priority_value`, `memory_kb`, " " `heart_beat_timeout_ms`, `certificate`, `hybrid_app_preference_value`, " - " `endpoint`, `enabled`, `auth_token`, `cloud_transport_type` FROM " + " `endpoint`, `enabled`, `auth_token`, `cloud_transport_type`, " + "`app_service_name`, `service_type` FROM " " `application`"; const std::string kCollectFriendlyMsg = "SELECT * FROM `message`"; @@ -737,6 +754,11 @@ const std::string kSelectRequestSubTypes = "`application_id` " "= ?"; +const std::string kSelectHandledRpcs = + "SELECT DISTINCT `handled_rpcs` FROM `handled_rpcs` WHERE " + "`application_id` " + "= ?"; + const std::string kSelectSecondsBetweenRetries = "SELECT `value` FROM `seconds_between_retry` ORDER BY `index`"; @@ -784,6 +806,8 @@ const std::string kDeleteRequestType = "DELETE FROM `request_type`"; const std::string kDeleteRequestSubType = "DELETE FROM `request_subtype`"; +const std::string kDeleteHandledRpcs = "DELETE FROM `handled_rpcs`"; + const std::string kSelectApplicationRevoked = "SELECT `is_revoked` FROM `application` WHERE `id` = ?"; @@ -810,14 +834,16 @@ const std::string kInsertApplicationFull = " `default_hmi`, `priority_value`, `is_revoked`, `is_default`, " " `is_predata`, `memory_kb`, `heart_beat_timeout_ms`, " " `certificate`, `hybrid_app_preference_value`, `endpoint`, `enabled`, " - " `auth_token`, `cloud_transport_type`) " - " VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"; + " `auth_token`, `cloud_transport_type`, `app_service_name`, " + "`service_type`) " + " VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"; const std::string kSelectApplicationFull = "SELECT `keep_context`, `steal_focus`, `default_hmi`, `priority_value`, " " `is_revoked`, `is_default`, `is_predata`, `memory_kb`," " `heart_beat_timeout_ms`, `certificate`, `hybrid_app_preference_value`, " - " `endpoint`, `enabled`, `auth_token`, `cloud_transport_type` " + " `endpoint`, `enabled`, `auth_token`, `cloud_transport_type`, " + "`app_service_name`, `service_type` " "FROM `application` " "WHERE `id` = " "?"; diff --git a/src/components/policy/policy_regular/src/sql_pt_representation.cc b/src/components/policy/policy_regular/src/sql_pt_representation.cc index 9282caf535..98c7f1864b 100644 --- a/src/components/policy/policy_regular/src/sql_pt_representation.cc +++ b/src/components/policy/policy_regular/src/sql_pt_representation.cc @@ -734,6 +734,10 @@ bool SQLPTRepresentation::GatherApplicationPoliciesSection( *params.auth_token = query.GetString(8); *params.cloud_transport_type = query.GetString(9); + // AppService Parameters + *params.app_service_name = query.GetString(10); + *params.service_type = query.GetString(11); + const auto& gather_app_id = ((*policies).apps[app_id].is_string()) ? (*policies).apps[app_id].get_string() : app_id; @@ -766,6 +770,10 @@ bool SQLPTRepresentation::GatherApplicationPoliciesSection( return false; } + if (!GatherHandledRpcs(gather_app_id, &*params.handled_rpcs)) { + return false; + } + (*policies).apps[app_id] = params; } return true; @@ -1011,6 +1019,12 @@ bool SQLPTRepresentation::SaveSpecificAppPolicy( app.second.cloud_transport_type.is_initialized() ? app_query.Bind(10, *app.second.cloud_transport_type) : app_query.Bind(10); + app.second.app_service_name.is_initialized() + ? app_query.Bind(11, *app.second.app_service_name) + : app_query.Bind(11); + app.second.service_type.is_initialized() + ? app_query.Bind(12, *app.second.service_type) + : app_query.Bind(12); if (!app_query.Exec() || !app_query.Reset()) { LOG4CXX_WARN(logger_, "Incorrect insert into application."); @@ -1050,6 +1064,10 @@ bool SQLPTRepresentation::SaveSpecificAppPolicy( return false; } + if (!SaveHandledRpcs(app.first, *app.second.handled_rpcs)) { + return false; + } + return true; } @@ -1209,6 +1227,32 @@ bool SQLPTRepresentation::SaveRequestSubType( return true; } +bool SQLPTRepresentation::SaveHandledRpcs( + const std::string& app_id, const policy_table::HandledRpcs& handled_rpcs) { + utils::dbms::SQLQuery query(db()); + if (!query.Prepare(sql_pt::kInsertHandledRpcs)) { + LOG4CXX_WARN(logger_, "Incorrect insert statement for handled rpcs."); + return false; + } + + policy_table::HandledRpcs::const_iterator it; + if (!handled_rpcs.empty()) { + LOG4CXX_TRACE(logger_, "Handled Rpcs are not empty."); + for (it = handled_rpcs.begin(); it != handled_rpcs.end(); ++it) { + query.Bind(0, app_id); + + // TODO: Bind does not like uint64_t. Only takes ints? Not sure why this + // is broken since seconds between retries is able to handle + query.Bind(1, static_cast(*it)); + if (!query.Exec() || !query.Reset()) { + LOG4CXX_WARN(logger_, "Incorrect insert into handled rpcs."); + return false; + } + } + } + return true; +} + bool SQLPTRepresentation::SaveModuleMeta(const policy_table::ModuleMeta& meta) { utils::dbms::SQLQuery query(db()); @@ -1647,6 +1691,22 @@ bool SQLPTRepresentation::GatherRequestSubType( return true; } +bool SQLPTRepresentation::GatherHandledRpcs( + const std::string& app_id, policy_table::HandledRpcs* handled_rpcs) const { + utils::dbms::SQLQuery query(db()); + if (!query.Prepare(sql_pt::kSelectHandledRpcs)) { + LOG4CXX_WARN(logger_, "Incorrect select from handled rpcs."); + return false; + } + + query.Bind(0, app_id); + while (query.Next()) { + const uint64_t rpc_id = query.GetInteger(0); + handled_rpcs->push_back(rpc_id); + } + return true; +} + bool SQLPTRepresentation::GatherNickName( const std::string& app_id, policy_table::Strings* nicknames) const { utils::dbms::SQLQuery query(db()); @@ -1997,6 +2057,12 @@ bool SQLPTRepresentation::SetDefaultPolicy(const std::string& app_id) { return false; } + policy_table::HandledRpcs handled_rpcs; + if (!GatherHandledRpcs(kDefaultId, &handled_rpcs) || + !SaveHandledRpcs(app_id, handled_rpcs)) { + return false; + } + return SetIsDefault(app_id, true); } @@ -2122,6 +2188,10 @@ bool SQLPTRepresentation::CopyApplication(const std::string& source, : query.Bind(14, source_app.GetString(13)); source_app.IsNull(14) ? query.Bind(15) : query.Bind(15, source_app.GetString(14)); + source_app.IsNull(15) ? query.Bind(16) + : query.Bind(16, source_app.GetString(15)); + source_app.IsNull(16) ? query.Bind(17) + : query.Bind(17, source_app.GetString(16)); if (!query.Exec()) { LOG4CXX_WARN(logger_, "Failed inserting into application."); -- cgit v1.2.1 From 5676f89293d1e5a1a95c06a714072564138a47c4 Mon Sep 17 00:00:00 2001 From: JackLivio Date: Wed, 23 Jan 2019 09:41:00 -0500 Subject: Add pending device map locks --- src/components/application_manager/src/application_manager_impl.cc | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/components/application_manager/src/application_manager_impl.cc b/src/components/application_manager/src/application_manager_impl.cc index 475dff895b..7b2475a4e0 100644 --- a/src/components/application_manager/src/application_manager_impl.cc +++ b/src/components/application_manager/src/application_manager_impl.cc @@ -911,6 +911,7 @@ void ApplicationManagerImpl::CreatePendingApplication( pending_device_map_lock_ptr_->Acquire(); auto it = pending_device_map_.find(name); if (it == pending_device_map_.end()) { + pending_device_map_lock_ptr_->Release(); return; } pending_device_map_lock_ptr_->Release(); @@ -992,10 +993,13 @@ void ApplicationManagerImpl::SetPendingApplicationState( const transport_manager::ConnectionUID connection_id, const transport_manager::DeviceInfo& device_info) { std::string name = device_info.name(); + pending_device_map_lock_ptr_->Acquire(); auto it = pending_device_map_.find(name); if (it == pending_device_map_.end()) { + pending_device_map_lock_ptr_->Release(); return; } + pending_device_map_lock_ptr_->Release(); const std::string policy_app_id = it->second; auto app = application_by_policy_id(policy_app_id); -- cgit v1.2.1 From 61d292140068510f8a5602170b02a7a777678f4a Mon Sep 17 00:00:00 2001 From: jacobkeeler Date: Wed, 23 Jan 2019 09:48:44 -0500 Subject: Add WEATHER service type --- src/components/interfaces/HMI_API.xml | 211 +++++++++++++++++++-------- src/components/interfaces/MOBILE_API.xml | 239 +++++++++++++++++++++---------- 2 files changed, 312 insertions(+), 138 deletions(-) diff --git a/src/components/interfaces/HMI_API.xml b/src/components/interfaces/HMI_API.xml index 9ebb7d3239..2a9be1954b 100644 --- a/src/components/interfaces/HMI_API.xml +++ b/src/components/interfaces/HMI_API.xml @@ -3375,7 +3375,8 @@ - + + @@ -3383,15 +3384,15 @@ - - - + + + This data is related to what a media service should provide - + The type of the currently playing or paused track. @@ -3449,9 +3450,9 @@ - Music: The current progress of the playback queue in seconds - Podcast: The current progress of the playback queue in seconds - Audiobook: The current progress of the playback queue (e.g. the book) in seconds + Music: The current progress of the playback queue in seconds + Podcast: The current progress of the playback queue in seconds + Audiobook: The current progress of the playback queue (e.g. the book) in seconds @@ -3480,71 +3481,157 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 0 to 1, percentage humidity + + + 0 to 1, percentage cloud cover + + + 0 to 1, percentage of the moon seen, e.g. 0 = no moon, 0.25 = quarter moon + + + + In degrees, true north at 0 degrees + + + km/hr + + + km/hr + + + + In degrees, true north at 0 degrees + + + In km + + + cm + + + cm of water per hour + + + 0 to 1, percentage chance + + + e.g. "rain", "snow", "sleet", "hail" + + + In km + + + + + + + This data is related to what a weather service would provide + + + + + + + This array should be ordered with the first object being the current day + + + - This manfifest contains all the information necessary for the service to be published, activated, and consumers able to interact with it + This manifest contains all the information necessary for the service to be published, activated, and consumers able to interact with it - - Unique name of this service - + + Unique name of this service + - - The type of service that is to be offered by this app - + + The type of service that is to be offered by this app + - - The file name of the icon to be associated with this service. Most likely the same as the appIcon. - + + The file name of the icon to be associated with this service. Most likely the same as the appIcon. + - - If true, app service consumers beyond the IVI system will be able to access this service. If false, only the IVI system will be able consume the service. If not provided, it is assumed to be false. - + + If true, app service consumers beyond the IVI system will be able to access this service. If false, only the IVI system will be able consume the service. If not provided, it is assumed to be false. + - - The URI prefix for this service. If provided, all PerformAppServiceInteraction requests must start with it. - + + The URI prefix for this service. If provided, all PerformAppServiceInteraction requests must start with it. + - - This is a custom schema for this service. SDL will not do any verification on this param past that it has a correctly formated JSON Object as its base. The uriScheme should contain all available actions to be taken through a PerformAppServiceInteraction request from an app service consumer. - + + This is a custom schema for this service. SDL will not do any verification on this param past that it has a correctly formated JSON Object as its base. The uriScheme should contain all available actions to be taken through a PerformAppServiceInteraction request from an app service consumer. + - - This is the max RPC Spec version the app service understands. This is important during the RPC passthrough functionality. If not included, it is assumed the max version of the module is acceptable. - + + This is the max RPC Spec version the app service understands. This is important during the RPC passthrough functionality. If not included, it is assumed the max version of the module is acceptable. + - - This field contains the Function IDs for the RPCs that this service intends to handle correctly. This means the service will provide meaningful responses. - + + This field contains the Function IDs for the RPCs that this service intends to handle correctly. This means the service will provide meaningful responses. + - - + + + - This is the record of an app service publisher that the module has. It should contain the most up to date information including the service's active state + This is the record of an app service publisher that the module has. It should contain the most up to date information including the service's active state - - A unique ID tied to this specific service record. The ID is supplied by the module that services publish themselves. - + + A unique ID tied to this specific service record. The ID is supplied by the module that services publish themselves. + - - Manifest for the service that this record is for. - + + Manifest for the service that this record is for. + - - If true, the service is published and available. If false, the service has likely just been unpublished, and should be considered unavailable. - + + If true, the service is published and available. If false, the service has likely just been unpublished, and should be considered unavailable. + - - If true, the service is the active primary service of the supplied service type. It will receive all potential RPCs that are passed through to that service type. If false, it is not the primary service of the supplied type. See servicePublished for its availability. - + + If true, the service is the active primary service of the supplied service type. It will receive all potential RPCs that are passed through to that service type. If false, it is not the primary service of the supplied type. See servicePublished for its availability. + - Contains all the current data of the app service. The serviceType will link to which of the service data objects are included in this object. (eg if service type equals MEDIA, the mediaServiceData param should be included. + Contains all the current data of the app service. The serviceType will link to which of the service data objects are included in this object. (eg if service type equals MEDIA, the mediaServiceData param should be included. - - + + - + + @@ -6032,25 +6119,25 @@ Interface used for interacting with app services as a producer or consumer - Registers a service offered by this app on the module + Registers a service offered by this app on the module - - The manifest of the service that wishes to be published. - + + The manifest of the service that wishes to be published. + - Response to the request to register a service offered by this app on the module + Response to the request to register a service offered by this app on the module - - If the request was successful, this object will be the current status of the service record for the published service. This will include the Core supplied service ID. - + + If the request was successful, this object will be the current status of the service record for the published service. This will include the Core supplied service ID. + - This notification includes the data that is updated from the specific service. HMI->SDL if the HMI is a producer, SDL->HMI if the HMI is a consumer + This notification includes the data that is updated from the specific service. HMI->SDL if the HMI is a producer, SDL->HMI if the HMI is a consumer - + diff --git a/src/components/interfaces/MOBILE_API.xml b/src/components/interfaces/MOBILE_API.xml index 6605a01b48..65a88ac22a 100644 --- a/src/components/interfaces/MOBILE_API.xml +++ b/src/components/interfaces/MOBILE_API.xml @@ -945,7 +945,7 @@ Similar to VP8, but VP9 is customized for video resolutions beyond high-definition video (UHD) and also enables lossless compression. - + @@ -3714,7 +3714,8 @@ - + + @@ -3722,9 +3723,9 @@ - - - + + + @@ -3819,71 +3820,157 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 0 to 1, percentage humidity + + + 0 to 1, percentage cloud cover + + + 0 to 1, percentage of the moon seen, e.g. 0 = no moon, 0.25 = quarter moon + + + + In degrees, true north at 0 degrees + + + km/hr + + + km/hr + + + + In degrees, true north at 0 degrees + + + In km + + + cm + + + cm of water per hour + + + 0 to 1, percentage chance + + + e.g. "rain", "snow", "sleet", "hail" + + + In km + + + + + + + This data is related to what a weather service would provide + + + + + + + This array should be ordered with the first object being the current day + + + - This manfifest contains all the information necessary for the service to be published, activated, and consumers able to interact with it + This manifest contains all the information necessary for the service to be published, activated, and consumers able to interact with it - - Unique name of this service - + + Unique name of this service + - - The type of service that is to be offered by this app - + + The type of service that is to be offered by this app + - - The file name of the icon to be associated with this service. Most likely the same as the appIcon. - + + The file name of the icon to be associated with this service. Most likely the same as the appIcon. + - - If true, app service consumers beyond the IVI system will be able to access this service. If false, only the IVI system will be able consume the service. If not provided, it is assumed to be false. - + + If true, app service consumers beyond the IVI system will be able to access this service. If false, only the IVI system will be able consume the service. If not provided, it is assumed to be false. + - - The URI prefix for this service. If provided, all PerformAppServiceInteraction requests must start with it. - + + The URI prefix for this service. If provided, all PerformAppServiceInteraction requests must start with it. + - - This is a custom schema for this service. SDL will not do any verification on this param past that it has a correctly formated JSON Object as its base. The uriScheme should contain all available actions to be taken through a PerformAppServiceInteraction request from an app service consumer. - + + This is a custom schema for this service. SDL will not do any verification on this param past that it has a correctly formated JSON Object as its base. The uriScheme should contain all available actions to be taken through a PerformAppServiceInteraction request from an app service consumer. + - - This is the max RPC Spec version the app service understands. This is important during the RPC passthrough functionality. If not included, it is assumed the max version of the module is acceptable. - + + This is the max RPC Spec version the app service understands. This is important during the RPC passthrough functionality. If not included, it is assumed the max version of the module is acceptable. + - - This field contains the Function IDs for the RPCs that this service intends to handle correctly. This means the service will provide meaningful responses. - + + This field contains the Function IDs for the RPCs that this service intends to handle correctly. This means the service will provide meaningful responses. + - - + + + - This is the record of an app service publisher that the module has. It should contain the most up to date information including the service's active state + This is the record of an app service publisher that the module has. It should contain the most up to date information including the service's active state - - A unique ID tied to this specific service record. The ID is supplied by the module that services publish themselves. - + + A unique ID tied to this specific service record. The ID is supplied by the module that services publish themselves. + - - Manifest for the service that this record is for. - + + Manifest for the service that this record is for. + - - If true, the service is published and available. If false, the service has likely just been unpublished, and should be considered unavailable. - + + If true, the service is published and available. If false, the service has likely just been unpublished, and should be considered unavailable. + - - If true, the service is the active primary service of the supplied service type. It will receive all potential RPCs that are passed through to that service type. If false, it is not the primary service of the supplied type. See servicePublished for its availability. - + + If true, the service is the active primary service of the supplied service type. It will receive all potential RPCs that are passed through to that service type. If false, it is not the primary service of the supplied type. See servicePublished for its availability. + - Contains all the current data of the app service. The serviceType will link to which of the service data objects are included in this object. (eg if service type equals MEDIA, the mediaServiceData param should be included. + Contains all the current data of the app service. The serviceType will link to which of the service data objects are included in this object. (eg if service type equals MEDIA, the mediaServiceData param should be included. - - + + - + + @@ -6859,39 +6946,39 @@ - Registers a service offered by this app on the module + Registers a service offered by this app on the module - - The manifest of the service that wishes to be published. - + + The manifest of the service that wishes to be published. + - Response to the request to register a service offered by this app on the module + Response to the request to register a service offered by this app on the module - - true, if successful; false, if failed - + + true, if successful; false, if failed + - - See Result - - - - - - - - - + + See Result + + + + + + + + + - - Provides additional human readable info regarding the result. - + + Provides additional human readable info regarding the result. + - - If the request was successful, this object will be the current status of the service record for the published service. This will include the Core supplied service ID. - + + If the request was successful, this object will be the current status of the service record for the published service. This will include the Core supplied service ID. + @@ -7188,9 +7275,9 @@ - This notification includes the data that is updated from the specific service + This notification includes the data that is updated from the specific service - + -- cgit v1.2.1 From ec5457edb06cf971b820b7fc79e7f25694dd0829 Mon Sep 17 00:00:00 2001 From: jacobkeeler Date: Wed, 23 Jan 2019 12:44:31 -0500 Subject: Add validation of app service manifest --- .../commands/hmi/as_publish_app_service_request.h | 2 ++ .../commands/mobile/publish_app_service_request.h | 2 ++ .../commands/hmi/as_publish_app_service_request.cc | 23 +++++++++++++++++++++- .../commands/mobile/publish_app_service_request.cc | 22 +++++++++++++++++++-- 4 files changed, 46 insertions(+), 3 deletions(-) diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/hmi/as_publish_app_service_request.h b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/hmi/as_publish_app_service_request.h index b21f99885a..0c7f222c1d 100644 --- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/hmi/as_publish_app_service_request.h +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/hmi/as_publish_app_service_request.h @@ -69,6 +69,8 @@ class ASPublishAppServiceRequest : public app_mngr::commands::RequestFromHMI { virtual void Run(); private: + bool ValidateManifest(smart_objects::SmartObject& manifest); + AppServiceRpcPlugin* plugin_; DISALLOW_COPY_AND_ASSIGN(ASPublishAppServiceRequest); }; diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/mobile/publish_app_service_request.h b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/mobile/publish_app_service_request.h index a798bed613..ac5caa4e6d 100644 --- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/mobile/publish_app_service_request.h +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/mobile/publish_app_service_request.h @@ -70,6 +70,8 @@ class PublishAppServiceRequest virtual void Run(); private: + bool ValidateManifest(smart_objects::SmartObject& manifest); + AppServiceRpcPlugin* plugin_; DISALLOW_COPY_AND_ASSIGN(PublishAppServiceRequest); }; diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_publish_app_service_request.cc b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_publish_app_service_request.cc index 9acc8c3146..835762f78a 100644 --- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_publish_app_service_request.cc +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_publish_app_service_request.cc @@ -59,14 +59,35 @@ ASPublishAppServiceRequest::ASPublishAppServiceRequest( ASPublishAppServiceRequest::~ASPublishAppServiceRequest() {} +bool ASPublishAppServiceRequest::ValidateManifest( + smart_objects::SmartObject& manifest) { + if (manifest.keyExists(strings::uri_scheme)) { + Json::Value value; + Json::Reader reader; + if (!reader.parse(manifest[strings::uri_scheme].asString(), value)) { + SendResponse( + false, + (*message_)[strings::params][strings::correlation_id].asUInt(), + hmi_apis::FunctionID::AppService_PublishAppService, + hmi_apis::Common_Result::INVALID_DATA); + return false; + } + } + return true; +} + void ASPublishAppServiceRequest::Run() { LOG4CXX_AUTO_TRACE(logger_); smart_objects::SmartObject response_params = smart_objects::SmartObject(smart_objects::SmartType_Map); smart_objects::SmartObject service_record = smart_objects::SmartObject(smart_objects::SmartType_Map); - service_record[strings::service_manifest] = + smart_objects::SmartObject manifest = (*message_)[strings::msg_params][strings::app_service_manifest]; + if (!ValidateManifest(manifest)) { + return; + } + service_record[strings::service_manifest] = manifest; service_record[strings::service_id] = "This is a service ID"; service_record[strings::service_published] = true; service_record[strings::service_active] = true; diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/publish_app_service_request.cc b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/publish_app_service_request.cc index e5f7c40471..b22d0a8c6e 100644 --- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/publish_app_service_request.cc +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/publish_app_service_request.cc @@ -62,6 +62,21 @@ PublishAppServiceRequest::PublishAppServiceRequest( PublishAppServiceRequest::~PublishAppServiceRequest() {} +bool PublishAppServiceRequest::ValidateManifest( + smart_objects::SmartObject& manifest) { + if (manifest.keyExists(strings::uri_scheme)) { + Json::Value value; + Json::Reader reader; + if (!reader.parse(manifest[strings::uri_scheme].asString(), value)) { + SendResponse(false, + mobile_apis::Result::INVALID_DATA, + "Provided uriScheme was not valid JSON"); + return false; + } + } + return true; +} + void PublishAppServiceRequest::Run() { LOG4CXX_AUTO_TRACE(logger_); LOG4CXX_DEBUG(logger_, "Received a PublishAppService"); @@ -69,11 +84,14 @@ void PublishAppServiceRequest::Run() { smart_objects::SmartObject response_params = smart_objects::SmartObject(smart_objects::SmartType_Map); - smart_objects::SmartObject service_record = smart_objects::SmartObject(smart_objects::SmartType_Map); - service_record[strings::service_manifest] = + smart_objects::SmartObject manifest = (*message_)[strings::msg_params][strings::app_service_manifest]; + if (!ValidateManifest(manifest)) { + return; + } + service_record[strings::service_manifest] = manifest; service_record[strings::service_id] = "This is a service ID"; service_record[strings::service_published] = true; service_record[strings::service_active] = true; -- cgit v1.2.1 From 7406748f90c18a0544cd0757d388fdcef5f4d8d9 Mon Sep 17 00:00:00 2001 From: jacobkeeler Date: Wed, 23 Jan 2019 13:55:15 -0500 Subject: Fix Style --- .../app_service_hmi_command_factory.h | 9 ++++----- .../app_service_rpc_plugin/app_service_rpc_plugin.h | 4 ++-- .../hmi/on_as_app_service_data_notification_from_hmi.h | 3 ++- .../commands/mobile/publish_app_service_request.h | 14 ++++++-------- .../commands/mobile/publish_app_service_response.h | 11 +++++------ .../src/app_service_hmi_command_factory.cc | 6 +++--- .../src/app_service_mobile_command_factory.cc | 9 +++++---- .../commands/hmi/on_as_app_service_data_notification.cc | 3 +-- .../hmi/on_as_app_service_data_notification_from_hmi.cc | 3 ++- .../application_manager/src/smart_object_keys.cc | 2 +- 10 files changed, 31 insertions(+), 33 deletions(-) diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/app_service_hmi_command_factory.h b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/app_service_hmi_command_factory.h index dfe333b881..c42b64f559 100644 --- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/app_service_hmi_command_factory.h +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/app_service_hmi_command_factory.h @@ -43,11 +43,10 @@ namespace app_mngr = application_manager; */ class AppServiceHmiCommandFactory : public app_mngr::CommandFactory { public: - AppServiceHmiCommandFactory( - app_mngr::ApplicationManager& application_manager, - app_mngr::rpc_service::RPCService& rpc_service, - app_mngr::HMICapabilities& hmi_capabilities, - policy::PolicyHandlerInterface& policy_handler); + AppServiceHmiCommandFactory(app_mngr::ApplicationManager& application_manager, + app_mngr::rpc_service::RPCService& rpc_service, + app_mngr::HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handler); app_mngr::CommandSharedPtr CreateCommand( const app_mngr::commands::MessageSharedPtr& message, diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/app_service_rpc_plugin.h b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/app_service_rpc_plugin.h index 398711b7a7..1113911a22 100644 --- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/app_service_rpc_plugin.h +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/app_service_rpc_plugin.h @@ -36,7 +36,7 @@ #include "application_manager/command_factory.h" namespace app_service_rpc_plugin { -//class AppServiceAppExtension; +// class AppServiceAppExtension; namespace app_mngr = application_manager; namespace plugins = application_manager::plugin_manager; @@ -67,7 +67,7 @@ class AppServiceRpcPlugin : public plugins::RPCPlugin { * @param ext application extension */ // TODO - //void ProcessResumptionSubscription(app_mngr::Application& app, + // void ProcessResumptionSubscription(app_mngr::Application& app, // AppServiceAppExtension& ext); private: diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/hmi/on_as_app_service_data_notification_from_hmi.h b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/hmi/on_as_app_service_data_notification_from_hmi.h index df4cec9287..7ca20d692a 100644 --- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/hmi/on_as_app_service_data_notification_from_hmi.h +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/hmi/on_as_app_service_data_notification_from_hmi.h @@ -44,7 +44,8 @@ namespace commands { /** * @brief OnASAppServiceDataNotificationFromHMI command class **/ -class OnASAppServiceDataNotificationFromHMI : public app_mngr::commands::NotificationFromHMI { +class OnASAppServiceDataNotificationFromHMI + : public app_mngr::commands::NotificationFromHMI { public: /** * @brief OnASAppServiceDataNotificationFromHMI class constructor diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/mobile/publish_app_service_request.h b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/mobile/publish_app_service_request.h index ac5caa4e6d..459fa0457e 100644 --- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/mobile/publish_app_service_request.h +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/mobile/publish_app_service_request.h @@ -44,20 +44,18 @@ namespace commands { /** * @brief PublishAppServiceRequest command class **/ -class PublishAppServiceRequest - : public app_mngr::commands::CommandRequestImpl { +class PublishAppServiceRequest : public app_mngr::commands::CommandRequestImpl { public: /** * @brief PublishAppServiceRequest class constructor * * @param message Incoming SmartObject message **/ - PublishAppServiceRequest( - const app_mngr::commands::MessageSharedPtr& message, - app_mngr::ApplicationManager& application_manager, - app_mngr::rpc_service::RPCService& rpc_service, - app_mngr::HMICapabilities& hmi_capabilities, - policy::PolicyHandlerInterface& policy_handle); + PublishAppServiceRequest(const app_mngr::commands::MessageSharedPtr& message, + app_mngr::ApplicationManager& application_manager, + app_mngr::rpc_service::RPCService& rpc_service, + app_mngr::HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle); /** * @brief PublishAppServiceRequest class destructor diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/mobile/publish_app_service_response.h b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/mobile/publish_app_service_response.h index 27b4d6ad2f..a11399c9e1 100644 --- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/mobile/publish_app_service_response.h +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/mobile/publish_app_service_response.h @@ -52,12 +52,11 @@ class PublishAppServiceResponse * * @param message Incoming SmartObject message **/ - PublishAppServiceResponse( - const app_mngr::commands::MessageSharedPtr& message, - app_mngr::ApplicationManager& application_manager, - app_mngr::rpc_service::RPCService& rpc_service, - app_mngr::HMICapabilities& hmi_capabilities, - policy::PolicyHandlerInterface& policy_handle); + PublishAppServiceResponse(const app_mngr::commands::MessageSharedPtr& message, + app_mngr::ApplicationManager& application_manager, + app_mngr::rpc_service::RPCService& rpc_service, + app_mngr::HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle); /** * @brief PublishAppServiceResponse class destructor diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/app_service_hmi_command_factory.cc b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/app_service_hmi_command_factory.cc index 746636aff0..e741d7bfd4 100644 --- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/app_service_hmi_command_factory.cc +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/app_service_hmi_command_factory.cc @@ -88,9 +88,9 @@ bool AppServiceHmiCommandFactory::IsAbleToProcess( const int32_t function_id, const app_mngr::commands::Command::CommandSource source) const { UNUSED(source); - return buildCommandCreator( - function_id, hmi_apis::messageType::INVALID_ENUM, source) - .CanBeCreated(); + return buildCommandCreator(function_id, + hmi_apis::messageType::INVALID_ENUM, + source).CanBeCreated(); } app_mngr::CommandCreator& AppServiceHmiCommandFactory::buildCommandCreator( diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/app_service_mobile_command_factory.cc b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/app_service_mobile_command_factory.cc index 3b4e3490f6..e0e667e975 100644 --- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/app_service_mobile_command_factory.cc +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/app_service_mobile_command_factory.cc @@ -89,9 +89,9 @@ bool AppServiceMobileCommandFactory::IsAbleToProcess( const int32_t function_id, const app_mngr::commands::Command::CommandSource source) const { UNUSED(source); - return buildCommandCreator( - function_id, mobile_apis::messageType::INVALID_ENUM, source) - .CanBeCreated(); + return buildCommandCreator(function_id, + mobile_apis::messageType::INVALID_ENUM, + source).CanBeCreated(); } app_mngr::CommandCreator& AppServiceMobileCommandFactory::buildCommandCreator( @@ -108,7 +108,8 @@ app_mngr::CommandCreator& AppServiceMobileCommandFactory::buildCommandCreator( : factory.GetCreator(); case mobile_apis::FunctionID::OnAppServiceDataID: return app_mngr::commands::Command::CommandSource::SOURCE_MOBILE == source - ? factory.GetCreator() + ? factory.GetCreator< + commands::OnAppServiceDataNotificationFromMobile>() : factory.GetCreator(); default: LOG4CXX_WARN(logger_, "Unsupported function_id: " << function_id); diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/on_as_app_service_data_notification.cc b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/on_as_app_service_data_notification.cc index e590d63a05..0cd269b04e 100644 --- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/on_as_app_service_data_notification.cc +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/on_as_app_service_data_notification.cc @@ -57,8 +57,7 @@ OnASAppServiceDataNotification::OnASAppServiceDataNotification( } } -OnASAppServiceDataNotification:: - ~OnASAppServiceDataNotification() {} +OnASAppServiceDataNotification::~OnASAppServiceDataNotification() {} void OnASAppServiceDataNotification::Run() { LOG4CXX_AUTO_TRACE(logger_); diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/on_as_app_service_data_notification_from_hmi.cc b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/on_as_app_service_data_notification_from_hmi.cc index 3dea2a6a12..01a8e817a2 100644 --- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/on_as_app_service_data_notification_from_hmi.cc +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/on_as_app_service_data_notification_from_hmi.cc @@ -57,7 +57,8 @@ OnASAppServiceDataNotificationFromHMI::OnASAppServiceDataNotificationFromHMI( } } -OnASAppServiceDataNotificationFromHMI::~OnASAppServiceDataNotificationFromHMI() {} +OnASAppServiceDataNotificationFromHMI:: + ~OnASAppServiceDataNotificationFromHMI() {} void OnASAppServiceDataNotificationFromHMI::Run() { LOG4CXX_AUTO_TRACE(logger_); diff --git a/src/components/application_manager/src/smart_object_keys.cc b/src/components/application_manager/src/smart_object_keys.cc index 00dabb9480..1b6dfe2b8b 100644 --- a/src/components/application_manager/src/smart_object_keys.cc +++ b/src/components/application_manager/src/smart_object_keys.cc @@ -274,7 +274,7 @@ const char* service_type = "serviceType"; const char* service_icon = "serviceIcon"; const char* allow_app_consumers = "allowAppConsumers"; const char* uri_prefix = "uriPrefix"; -const char* uri_scheme = "uriScheme"; +const char* uri_scheme = "uriScheme"; const char* rpc_spec_version = "rpcSpecVersion"; const char* handled_rpcs = "handledRPCs"; const char* media_service_manifest = "mediaServiceManifest"; -- cgit v1.2.1 From 6b86e197ba38f6af3ba6390e920cae6f9abe654d Mon Sep 17 00:00:00 2001 From: JackLivio Date: Wed, 23 Jan 2019 16:12:59 -0500 Subject: External policies --- .../application_manager/policies/policy_handler.h | 2 +- .../src/policies/policy_handler.cc | 4 +- .../policies/policy_handler_interface.h | 2 +- .../policy/policy_external/policy/policy_manager.h | 14 +++++ .../policy/policy_regular/policy/policy_manager.h | 10 +++- .../policy_external/include/policy/cache_manager.h | 14 +++++ .../include/policy/cache_manager_interface.h | 14 +++++ .../include/policy/policy_manager_impl.h | 14 +++++ .../include/policy/policy_table/types.h | 7 +++ .../include/policy/policy_table_interface_ext.xml | 3 + .../include/policy/sql_pt_queries.h | 3 + .../include/policy/sql_pt_representation.h | 4 ++ .../policy/policy_external/src/cache_manager.cc | 27 +++++++++ .../policy_external/src/policy_manager_impl.cc | 9 +++ .../policy_external/src/policy_table/types.cc | 39 ++++++++++++- .../policy_external/src/sql_pt_ext_queries.cc | 7 ++- .../src/sql_pt_ext_representation.cc | 17 ++++++ .../policy/policy_external/src/sql_pt_queries.cc | 38 ++++++++++-- .../policy_external/src/sql_pt_representation.cc | 68 ++++++++++++++++++++++ .../policy_regular/include/policy/cache_manager.h | 10 +++- .../include/policy/cache_manager_interface.h | 10 +++- .../include/policy/policy_manager_impl.h | 10 +++- .../include/policy/policy_table/types.h | 2 +- .../policy/policy_regular/src/cache_manager.cc | 8 +-- .../policy_regular/src/policy_manager_impl.cc | 4 +- .../policy_regular/src/policy_table/types.cc | 15 +++-- .../policy/policy_regular/src/sql_pt_queries.cc | 10 ++-- .../policy_regular/src/sql_pt_representation.cc | 6 +- 28 files changed, 329 insertions(+), 42 deletions(-) diff --git a/src/components/application_manager/include/application_manager/policies/policy_handler.h b/src/components/application_manager/include/application_manager/policies/policy_handler.h index 6322f4723b..ffc5037e3b 100644 --- a/src/components/application_manager/include/application_manager/policies/policy_handler.h +++ b/src/components/application_manager/include/application_manager/policies/policy_handler.h @@ -448,7 +448,7 @@ class PolicyHandler : public PolicyHandlerInterface, const smart_objects::SmartObject& message) OVERRIDE; void GetAppServiceParameters(const std::string& policy_app_id, - std::string& app_service_name, + std::string& service_name, std::string& service_type, std::vector& handled_rpcs) const; diff --git a/src/components/application_manager/src/policies/policy_handler.cc b/src/components/application_manager/src/policies/policy_handler.cc index 16433f7637..6270b4e8b4 100644 --- a/src/components/application_manager/src/policies/policy_handler.cc +++ b/src/components/application_manager/src/policies/policy_handler.cc @@ -1939,12 +1939,12 @@ void PolicyHandler::OnSetCloudAppProperties( void PolicyHandler::GetAppServiceParameters( const std::string& policy_app_id, - std::string& app_service_name, + std::string& service_name, std::string& service_type, std::vector& handled_rpcs) const { POLICY_LIB_CHECK_VOID(); policy_manager_->GetAppServiceParameters( - policy_app_id, app_service_name, service_type, handled_rpcs); + policy_app_id, service_name, service_type, handled_rpcs); } uint32_t PolicyHandler::HeartBeatTimeout(const std::string& app_id) const { diff --git a/src/components/include/application_manager/policies/policy_handler_interface.h b/src/components/include/application_manager/policies/policy_handler_interface.h index 3ba165bff9..914b33204d 100644 --- a/src/components/include/application_manager/policies/policy_handler_interface.h +++ b/src/components/include/application_manager/policies/policy_handler_interface.h @@ -490,7 +490,7 @@ class PolicyHandlerInterface { virtual void GetAppServiceParameters( const std::string& policy_app_id, - std::string& app_service_name, + std::string& service_name, std::string& service_type, std::vector& handled_rpcs) const = 0; diff --git a/src/components/include/policy/policy_external/policy/policy_manager.h b/src/components/include/policy/policy_external/policy/policy_manager.h index 92c0305279..e7d682e257 100644 --- a/src/components/include/policy/policy_external/policy/policy_manager.h +++ b/src/components/include/policy/policy_external/policy/policy_manager.h @@ -592,6 +592,20 @@ class PolicyManager : public usage_statistics::StatisticsManager { const std::string& policy_app_id, const std::string& hybrid_app_preference) = 0; + /** + * @brief Get app service parameters from the policy table + * @param policy_app_id Unique application id + * @param service_name Service name published by app service provider + * @param service_type Service type published by app service provider + * @param handled_rpcs Vector of allowed function ids an app service provider + * can handle + */ + virtual void GetAppServiceParameters( + const std::string& policy_app_id, + std::string& service_name, + std::string& service_type, + std::vector& handled_rpcs) const = 0; + /** * @brief Gets meta information * @return meta information diff --git a/src/components/include/policy/policy_regular/policy/policy_manager.h b/src/components/include/policy/policy_regular/policy/policy_manager.h index e7ff4be7e8..6c8b8fb3e5 100644 --- a/src/components/include/policy/policy_regular/policy/policy_manager.h +++ b/src/components/include/policy/policy_regular/policy/policy_manager.h @@ -573,9 +573,17 @@ class PolicyManager : public usage_statistics::StatisticsManager { const std::string& policy_app_id, const std::string& hybrid_app_preference) = 0; + /** + * @brief Get app service parameters from the policy table + * @param policy_app_id Unique application id + * @param service_name Service name published by app service provider + * @param service_type Service type published by app service provider + * @param handled_rpcs Vector of allowed function ids an app service provider + * can handle + */ virtual void GetAppServiceParameters( const std::string& policy_app_id, - std::string& app_service_name, + std::string& service_name, std::string& service_type, std::vector& handled_rpcs) const = 0; diff --git a/src/components/policy/policy_external/include/policy/cache_manager.h b/src/components/policy/policy_external/include/policy/cache_manager.h index 3344b149e4..9cc1d25bfb 100644 --- a/src/components/policy/policy_external/include/policy/cache_manager.h +++ b/src/components/policy/policy_external/include/policy/cache_manager.h @@ -228,6 +228,20 @@ class CacheManager : public CacheManagerInterface { virtual void SetHybridAppPreference(const std::string& policy_app_id, const std::string& hybrid_app_preference); + /** + * @brief Get app service parameters from the policy table + * @param policy_app_id Unique application id + * @param service_name Service name published by app service provider + * @param service_type Service type published by app service provider + * @param handled_rpcs Vector of allowed function ids an app service provider + * can handle + */ + virtual void GetAppServiceParameters( + const std::string& policy_app_id, + std::string& service_name, + std::string& service_type, + std::vector& handled_rpcs) const; + /** * @brief Allows to update 'vin' field in module_meta table. * diff --git a/src/components/policy/policy_external/include/policy/cache_manager_interface.h b/src/components/policy/policy_external/include/policy/cache_manager_interface.h index 6a172e6f4b..b48b6a1041 100644 --- a/src/components/policy/policy_external/include/policy/cache_manager_interface.h +++ b/src/components/policy/policy_external/include/policy/cache_manager_interface.h @@ -237,6 +237,20 @@ class CacheManagerInterface { const std::string& policy_app_id, const std::string& hybrid_app_preference) = 0; + /** + * @brief Get app service parameters from the policy table + * @param policy_app_id Unique application id + * @param service_name Service name published by app service provider + * @param service_type Service type published by app service provider + * @param handled_rpcs Vector of allowed function ids an app service provider + * can handle + */ + virtual void GetAppServiceParameters( + const std::string& policy_app_id, + std::string& service_name, + std::string& service_type, + std::vector& handled_rpcs) const = 0; + /** * @brief Allows to update 'vin' field in module_meta table. * diff --git a/src/components/policy/policy_external/include/policy/policy_manager_impl.h b/src/components/policy/policy_external/include/policy/policy_manager_impl.h index 399c95170d..fa64614e1f 100644 --- a/src/components/policy/policy_external/include/policy/policy_manager_impl.h +++ b/src/components/policy/policy_external/include/policy/policy_manager_impl.h @@ -639,6 +639,20 @@ class PolicyManagerImpl : public PolicyManager { const std::string& policy_app_id, const std::string& hybrid_app_preference) OVERRIDE; + /** + * @brief Get app service parameters from the policy table + * @param policy_app_id Unique application id + * @param service_name Service name published by app service provider + * @param service_type Service type published by app service provider + * @param handled_rpcs Vector of allowed function ids an app service provider + * can handle + */ + void GetAppServiceParameters( + const std::string& policy_app_id, + std::string& service_name, + std::string& service_type, + std::vector& handled_rpcs) const OVERRIDE; + /** * @brief OnAppRegisteredOnMobile allows to handle event when application were * succesfully registered on mobile device. diff --git a/src/components/policy/policy_external/include/policy/policy_table/types.h b/src/components/policy/policy_external/include/policy/policy_table/types.h index f37531eb63..ed845b1191 100644 --- a/src/components/policy/policy_external/include/policy/policy_table/types.h +++ b/src/components/policy/policy_external/include/policy/policy_table/types.h @@ -104,6 +104,8 @@ typedef Array, 0, 255> RequestsTypeArray; typedef Strings RequestSubTypes; +typedef Array, 0, 255> HandledRpcs; + typedef Map RemoteRpcs; typedef Map AccessModules; typedef Array, 0, 255> ModuleTypes; @@ -185,6 +187,11 @@ struct ApplicationParams : PolicyBase { Optional > auth_token; Optional > cloud_transport_type; + // App Service Params + Optional > service_name; + Optional > service_type; + Optional handled_rpcs; + public: ApplicationParams(); ApplicationParams(const Strings& groups, diff --git a/src/components/policy/policy_external/include/policy/policy_table_interface_ext.xml b/src/components/policy/policy_external/include/policy/policy_table_interface_ext.xml index 5ed852cf45..3b3bc2d7a6 100644 --- a/src/components/policy/policy_external/include/policy/policy_table_interface_ext.xml +++ b/src/components/policy/policy_external/include/policy/policy_table_interface_ext.xml @@ -108,6 +108,9 @@ + + + & handled_rpcs) const { + LOG4CXX_AUTO_TRACE(logger_); + const policy_table::ApplicationPolicies& policies = + pt_->policy_table.app_policies_section.apps; + policy_table::ApplicationPolicies::const_iterator policy_iter = + policies.find(policy_app_id); + if (policies.end() != policy_iter) { + auto app_policy = (*policy_iter).second; + service_name = app_policy.service_name.is_initialized() + ? *app_policy.service_name + : std::string(); + service_type = app_policy.service_type.is_initialized() + ? *app_policy.service_type + : std::string(); + if (!app_policy.handled_rpcs.is_initialized()) { + return; + } + for (const auto& rpc : *(app_policy.handled_rpcs)) { + handled_rpcs.push_back(rpc); + } + } +} + std::vector CacheManager::GetUserFriendlyMsg( const std::vector& msg_codes, const std::string& language, diff --git a/src/components/policy/policy_external/src/policy_manager_impl.cc b/src/components/policy/policy_external/src/policy_manager_impl.cc index 0844edd8eb..56eac75127 100644 --- a/src/components/policy/policy_external/src/policy_manager_impl.cc +++ b/src/components/policy/policy_external/src/policy_manager_impl.cc @@ -772,6 +772,15 @@ void PolicyManagerImpl::SetHybridAppPreference( cache_->SetHybridAppPreference(policy_app_id, hybrid_app_preference); } +void PolicyManagerImpl::GetAppServiceParameters( + const std::string& policy_app_id, + std::string& service_name, + std::string& service_type, + std::vector& handled_rpcs) const { + cache_->GetAppServiceParameters( + policy_app_id, service_name, service_type, handled_rpcs); +} + void PolicyManagerImpl::CheckPermissions(const PTString& app_id, const PTString& hmi_level, const PTString& rpc, diff --git a/src/components/policy/policy_external/src/policy_table/types.cc b/src/components/policy/policy_external/src/policy_table/types.cc index 977448dacd..8e822cb8d2 100644 --- a/src/components/policy/policy_external/src/policy_table/types.cc +++ b/src/components/policy/policy_external/src/policy_table/types.cc @@ -247,8 +247,10 @@ ApplicationParams::ApplicationParams(const Json::Value* value__) , endpoint(impl::ValueMember(value__, "endpoint")) , enabled(impl::ValueMember(value__, "enabled")) , auth_token(impl::ValueMember(value__, "auth_token")) - , cloud_transport_type(impl::ValueMember(value__, "cloud_transport_type")) { -} + , cloud_transport_type(impl::ValueMember(value__, "cloud_transport_type")) + , service_name(impl::ValueMember(value__, "service_name")) + , service_type(impl::ValueMember(value__, "service_type")) + , handled_rpcs(impl::ValueMember(value__, "handled_rpcs")) {} Json::Value ApplicationParams::ToJsonValue() const { Json::Value result__(PolicyBase::ToJsonValue()); @@ -267,6 +269,9 @@ Json::Value ApplicationParams::ToJsonValue() const { impl::WriteJsonField("enabled", enabled, &result__); impl::WriteJsonField("auth_token", auth_token, &result__); impl::WriteJsonField("cloud_transport_type", cloud_transport_type, &result__); + impl::WriteJsonField("service_name", service_name, &result__); + impl::WriteJsonField("service_type", service_type, &result__); + impl::WriteJsonField("handled_rpcs", handled_rpcs, &result__); return result__; } @@ -309,6 +314,15 @@ bool ApplicationParams::is_valid() const { if (!hybrid_app_preference.is_valid()) { return false; } + if (!service_name.is_valid()) { + return false; + } + if (!service_type.is_valid()) { + return false; + } + if (!handled_rpcs.is_valid()) { + return false; + } return Validate(); } @@ -359,6 +373,15 @@ bool ApplicationParams::struct_empty() const { if (hybrid_app_preference.is_initialized()) { return false; } + if (service_name.is_initialized()) { + return false; + } + if (service_type.is_initialized()) { + return false; + } + if (handled_rpcs.is_initialized()) { + return false; + } return true; } @@ -426,6 +449,15 @@ void ApplicationParams::ReportErrors(rpc::ValidationReport* report__) const { moduleType.ReportErrors( &report__->ReportSubobject("hybrid_app_preference")); } + if (!service_name.is_valid()) { + service_name.ReportErrors(&report__->ReportSubobject("service_name")); + } + if (!service_type.is_valid()) { + service_type.ReportErrors(&report__->ReportSubobject("service_type")); + } + if (!handled_rpcs.is_valid()) { + handled_rpcs.ReportErrors(&report__->ReportSubobject("handled_rpcs")); + } } void ApplicationParams::SetPolicyTableType(PolicyTableType pt_type) { @@ -441,6 +473,9 @@ void ApplicationParams::SetPolicyTableType(PolicyTableType pt_type) { enabled.SetPolicyTableType(pt_type); cloud_transport_type.SetPolicyTableType(pt_type); hybrid_app_preference.SetPolicyTableType(pt_type); + service_name.SetPolicyTableType(pt_type); + service_type.SetPolicyTableType(pt_type); + handled_rpcs.SetPolicyTableType(pt_type); } // RpcParameters methods diff --git a/src/components/policy/policy_external/src/sql_pt_ext_queries.cc b/src/components/policy/policy_external/src/sql_pt_ext_queries.cc index 32320b6d6c..25827c719b 100644 --- a/src/components/policy/policy_external/src/sql_pt_ext_queries.cc +++ b/src/components/policy/policy_external/src/sql_pt_ext_queries.cc @@ -207,8 +207,8 @@ const std::string kInsertApplication = " `default_hmi`, `priority_value`, `is_revoked`, `memory_kb`, " " `heart_beat_timeout_ms`, `certificate`, `hybrid_app_preference_value`, " " `endpoint`, `enabled`, `auth_token`, " - " `cloud_transport_type`) VALUES " - "(?,?,?,?,?,?,?,?,?,?,?,?,?,?)"; + " `cloud_transport_type`, `service_name`, `service_type`) VALUES " + "(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)"; const std::string kCollectFriendlyMsg = "SELECT * FROM `message`"; @@ -237,7 +237,8 @@ const std::string kSelectAppPolicies = "SELECT `id`, `priority_value`, `default_hmi`, `keep_context`, " " `steal_focus`, `memory_kb`, `heart_beat_timeout_ms`, `certificate`, " " `hybrid_app_preference_value`, `endpoint`, `enabled`, `auth_token` " - " `cloud_transport_type` FROM `application`"; + " `cloud_transport_type`, `service_name`, `service_type` FROM " + "`application`"; const std::string kSelectFunctionalGroupNames = "SELECT `id`, `user_consent_prompt`, `name`" diff --git a/src/components/policy/policy_external/src/sql_pt_ext_representation.cc b/src/components/policy/policy_external/src/sql_pt_ext_representation.cc index 43961815d6..8f82ca0546 100644 --- a/src/components/policy/policy_external/src/sql_pt_ext_representation.cc +++ b/src/components/policy/policy_external/src/sql_pt_ext_representation.cc @@ -771,6 +771,12 @@ bool SQLPTExtRepresentation::SaveSpecificAppPolicy( app.second.cloud_transport_type.is_initialized() ? app_query.Bind(13, *app.second.cloud_transport_type) : app_query.Bind(13); + app.second.service_name.is_initialized() + ? app_query.Bind(14, *app.second.service_name) + : app_query.Bind(14); + app.second.service_type.is_initialized() + ? app_query.Bind(15, *app.second.service_type) + : app_query.Bind(15); if (!app_query.Exec() || !app_query.Reset()) { LOG4CXX_WARN(logger_, "Incorrect insert into application."); @@ -805,6 +811,10 @@ bool SQLPTExtRepresentation::SaveSpecificAppPolicy( return false; } + if (!SaveHandledRpcs(app.first, *app.second.handled_rpcs)) { + return false; + } + return true; } @@ -909,6 +919,10 @@ bool SQLPTExtRepresentation::GatherApplicationPoliciesSection( *params.auth_token = query.GetString(11); *params.cloud_transport_type = query.GetString(12); + // AppService Parameters + *params.service_name = query.GetString(13); + *params.service_type = query.GetString(14); + const auto& gather_app_id = ((*policies).apps[app_id].is_string()) ? (*policies).apps[app_id].get_string() : app_id; @@ -941,6 +955,9 @@ bool SQLPTExtRepresentation::GatherApplicationPoliciesSection( if (!GatherRequestSubType(gather_app_id, &*params.RequestSubType)) { return false; } + if (!GatherHandledRpcs(gather_app_id, &*params.handled_rpcs)) { + return false; + } GatherPreconsentedGroup(gather_app_id, &*params.preconsented_groups); (*policies).apps[app_id] = params; } diff --git a/src/components/policy/policy_external/src/sql_pt_queries.cc b/src/components/policy/policy_external/src/sql_pt_queries.cc index 162d6957e7..1cf38e64c9 100644 --- a/src/components/policy/policy_external/src/sql_pt_queries.cc +++ b/src/components/policy/policy_external/src/sql_pt_queries.cc @@ -156,6 +156,8 @@ const std::string kCreateSchema = " `enabled` BOOLEAN, " " `auth_token` VARCHAR(65535), " " `cloud_transport_type` VARCHAR(255), " + " `service_name` VARCHAR(255), " + " `service_type` VARCHAR(255), " " `remote_control_denied` BOOLEAN NOT NULL DEFAULT 0, " " CONSTRAINT `fk_application_hmi_level1` " " FOREIGN KEY(`default_hmi`) " @@ -301,6 +303,14 @@ const std::string kCreateSchema = " FOREIGN KEY(`application_id`) " " REFERENCES `application`(`id`) " "); " + "CREATE TABLE IF NOT EXISTS `handled_rpcs`( " + " `handled_rpcs` INTEGER, " + " `application_id` VARCHAR(45) NOT NULL COLLATE NOCASE, " + " PRIMARY KEY(`handled_rpcs`,`application_id`), " + " CONSTRAINT `fk_handled_rpcs_app_id` " + " FOREIGN KEY(`application_id`) " + " REFERENCES `application`(`id`) " + "); " "CREATE INDEX IF NOT EXISTS `app_type.fk_app_type_application1_idx` " " ON `app_type`(`application_id` COLLATE NOCASE); " "CREATE TABLE IF NOT EXISTS `consent_group`( " @@ -509,6 +519,7 @@ const std::string kDropSchema = "DROP TABLE IF EXISTS `app_type`; " "DROP TABLE IF EXISTS `request_type`; " "DROP TABLE IF EXISTS `request_subtype`; " + "DROP TABLE IF EXISTS `handled_rpcs`; " "DROP INDEX IF EXISTS `nickname.fk_nickname_application1_idx`; " "DROP TABLE IF EXISTS `nickname`; " "DROP INDEX IF EXISTS `app_level.fk_app_level_language2_idx`; " @@ -649,8 +660,8 @@ const std::string kInsertApplication = "INSERT OR IGNORE INTO `application` (`id`, `priority_value`, " "`is_revoked`, `memory_kb`, `heart_beat_timeout_ms`, `certificate`, " "`hybrid_app_preference_value`, `endpoint`, `enabled`, `auth_token`, " - "`cloud_transport_type`) VALUES " - "(?,?,?,?,?,?,?,?,?,?,?)"; + "`cloud_transport_type`, `service_name`, `service_type`) VALUES " + "(?,?,?,?,?,?,?,?,?,?,?,?,?)"; const std::string kInsertAppGroup = "INSERT INTO `app_group` (`application_id`, `functional_group_id`)" @@ -671,6 +682,11 @@ const std::string kInsertRequestSubType = "`request_subtype`) " "VALUES (?, ?)"; +const std::string kInsertHandledRpcs = + "INSERT INTO `handled_rpcs` (`application_id`, " + "`handled_rpcs`) " + "VALUES (?, ?)"; + const std::string kUpdateVersion = "UPDATE `version` SET `number`= ?"; const std::string kInsertMessageType = @@ -774,7 +790,8 @@ const std::string kSelectUserMsgsVersion = const std::string kSelectAppPolicies = "SELECT `id`, `priority_value`, `memory_kb`, " " `heart_beat_timeout_ms`, `certificate`, `hybrid_app_preference_value`, " - " `endpoint`, `enabled`, `auth_token`, `cloud_transport_type` FROM " + " `endpoint`, `enabled`, `auth_token`, `cloud_transport_type`, " + "`service_name`, `service_type` FROM " " `application`"; const std::string kCollectFriendlyMsg = "SELECT * FROM `message`"; @@ -802,6 +819,11 @@ const std::string kSelectRequestSubTypes = "`application_id` " "= ?"; +const std::string kSelectHandledRpcs = + "SELECT DISTINCT `handled_rpcs` FROM `handled_rpcs` WHERE " + "`application_id` " + "= ?"; + const std::string kSelectSecondsBetweenRetries = "SELECT `value` FROM `seconds_between_retry` ORDER BY `index`"; @@ -849,6 +871,8 @@ const std::string kDeleteRequestType = "DELETE FROM `request_type`"; const std::string kDeleteRequestSubType = "DELETE FROM `request_subtype`"; +const std::string kDeleteHandledRpcs = "DELETE FROM `handled_rpcs`"; + const std::string kSelectApplicationRevoked = "SELECT `is_revoked` FROM `application` WHERE `id` = ?"; @@ -875,14 +899,16 @@ const std::string kInsertApplicationFull = " `default_hmi`, `priority_value`, `is_revoked`, `is_default`, " " `is_predata`, `memory_kb`, `heart_beat_timeout_ms`, " " `certificate`, `hybrid_app_preference_value`, `endpoint`, `enabled`, " - " `auth_token`, `cloud_transport_type`) " - " VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"; + " `auth_token`, `cloud_transport_type`, `service_name`, " + "`service_type`) " + " VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"; const std::string kSelectApplicationFull = "SELECT `keep_context`, `steal_focus`, `default_hmi`, `priority_value`, " " `is_revoked`, `is_default`, `is_predata`, `memory_kb`," " `heart_beat_timeout_ms`, `certificate`, `hybrid_app_preference_value`, " - " `endpoint`, `enabled`, `auth_token`, `cloud_transport_type` " + " `endpoint`, `enabled`, `auth_token`, `cloud_transport_type`, " + "`service_name`, `service_type` " "FROM `application` " "WHERE `id` = ?"; diff --git a/src/components/policy/policy_external/src/sql_pt_representation.cc b/src/components/policy/policy_external/src/sql_pt_representation.cc index b794d4c3a6..dbddd1bbd6 100644 --- a/src/components/policy/policy_external/src/sql_pt_representation.cc +++ b/src/components/policy/policy_external/src/sql_pt_representation.cc @@ -778,6 +778,10 @@ bool SQLPTRepresentation::GatherApplicationPoliciesSection( *params.auth_token = query.GetString(8); *params.cloud_transport_type = query.GetString(9); + // AppService Parameters + *params.service_name = query.GetString(10); + *params.service_type = query.GetString(11); + const auto& gather_app_id = ((*policies).apps[app_id].is_string()) ? (*policies).apps[app_id].get_string() : app_id; @@ -810,6 +814,9 @@ bool SQLPTRepresentation::GatherApplicationPoliciesSection( if (!GatherRequestSubType(gather_app_id, &*params.RequestSubType)) { return false; } + if (!GatherHandledRpcs(gather_app_id, &*params.handled_rpcs)) { + return false; + } (*policies).apps[app_id] = params; } @@ -1070,6 +1077,12 @@ bool SQLPTRepresentation::SaveSpecificAppPolicy( app.second.cloud_transport_type.is_initialized() ? app_query.Bind(10, *app.second.cloud_transport_type) : app_query.Bind(10); + app.second.service_name.is_initialized() + ? app_query.Bind(11, *app.second.service_name) + : app_query.Bind(11); + app.second.service_type.is_initialized() + ? app_query.Bind(12, *app.second.service_type) + : app_query.Bind(12); if (!app_query.Exec() || !app_query.Reset()) { LOG4CXX_WARN(logger_, "Incorrect insert into application."); @@ -1106,6 +1119,9 @@ bool SQLPTRepresentation::SaveSpecificAppPolicy( if (!SaveRequestType(app.first, *app.second.RequestType)) { return false; } + if (!SaveHandledRpcs(app.first, *app.second.handled_rpcs)) { + return false; + } return true; } @@ -1270,6 +1286,32 @@ bool SQLPTRepresentation::SaveRequestSubType( return true; } +bool SQLPTRepresentation::SaveHandledRpcs( + const std::string& app_id, const policy_table::HandledRpcs& handled_rpcs) { + utils::dbms::SQLQuery query(db()); + if (!query.Prepare(sql_pt::kInsertHandledRpcs)) { + LOG4CXX_WARN(logger_, "Incorrect insert statement for handled rpcs."); + return false; + } + + policy_table::HandledRpcs::const_iterator it; + if (!handled_rpcs.empty()) { + LOG4CXX_TRACE(logger_, "Handled Rpcs are not empty."); + for (it = handled_rpcs.begin(); it != handled_rpcs.end(); ++it) { + query.Bind(0, app_id); + + // TODO: Bind does not like uint64_t. Only takes ints? Not sure why this + // is broken since seconds between retries is able to handle + query.Bind(1, static_cast(*it)); + if (!query.Exec() || !query.Reset()) { + LOG4CXX_WARN(logger_, "Incorrect insert into handled rpcs."); + return false; + } + } + } + return true; +} + bool SQLPTRepresentation::SaveModuleMeta(const policy_table::ModuleMeta& meta) { // Section Module Meta is empty for SDL specific return true; @@ -1696,6 +1738,22 @@ bool SQLPTRepresentation::GatherRequestSubType( return true; } +bool SQLPTRepresentation::GatherHandledRpcs( + const std::string& app_id, policy_table::HandledRpcs* handled_rpcs) const { + utils::dbms::SQLQuery query(db()); + if (!query.Prepare(sql_pt::kSelectHandledRpcs)) { + LOG4CXX_WARN(logger_, "Incorrect select from handled rpcs."); + return false; + } + + query.Bind(0, app_id); + while (query.Next()) { + const uint64_t rpc_id = query.GetInteger(0); + handled_rpcs->push_back(rpc_id); + } + return true; +} + bool SQLPTRepresentation::GatherNickName( const std::string& app_id, policy_table::Strings* nicknames) const { utils::dbms::SQLQuery query(db()); @@ -2041,6 +2099,12 @@ bool SQLPTRepresentation::SetDefaultPolicy(const std::string& app_id) { return false; } + policy_table::HandledRpcs handled_rpcs; + if (!GatherHandledRpcs(kDefaultId, &handled_rpcs) || + !SaveHandledRpcs(app_id, handled_rpcs)) { + return false; + } + policy_table::Strings default_groups; bool ret = (GatherAppGroup(kDefaultId, &default_groups) && SaveAppGroup(app_id, default_groups)); @@ -2172,6 +2236,10 @@ bool SQLPTRepresentation::CopyApplication(const std::string& source, : query.Bind(14, source_app.GetString(13)); source_app.IsNull(14) ? query.Bind(15) : query.Bind(15, source_app.GetString(14)); + source_app.IsNull(15) ? query.Bind(16) + : query.Bind(16, source_app.GetString(15)); + source_app.IsNull(16) ? query.Bind(17) + : query.Bind(17, source_app.GetString(16)); if (!query.Exec()) { LOG4CXX_WARN(logger_, "Failed inserting into application."); diff --git a/src/components/policy/policy_regular/include/policy/cache_manager.h b/src/components/policy/policy_regular/include/policy/cache_manager.h index a90885d8cc..69b3fe4706 100644 --- a/src/components/policy/policy_regular/include/policy/cache_manager.h +++ b/src/components/policy/policy_regular/include/policy/cache_manager.h @@ -216,9 +216,17 @@ class CacheManager : public CacheManagerInterface { virtual void SetHybridAppPreference(const std::string& policy_app_id, const std::string& hybrid_app_preference); + /** + * @brief Get app service parameters from the policy table + * @param policy_app_id Unique application id + * @param service_name Service name published by app service provider + * @param service_type Service type published by app service provider + * @param handled_rpcs Vector of allowed function ids an app service provider + * can handle + */ virtual void GetAppServiceParameters( const std::string& policy_app_id, - std::string& app_service_name, + std::string& service_name, std::string& service_type, std::vector& handled_rpcs) const; diff --git a/src/components/policy/policy_regular/include/policy/cache_manager_interface.h b/src/components/policy/policy_regular/include/policy/cache_manager_interface.h index 0dabbbecf5..ceb30eb4d1 100644 --- a/src/components/policy/policy_regular/include/policy/cache_manager_interface.h +++ b/src/components/policy/policy_regular/include/policy/cache_manager_interface.h @@ -223,9 +223,17 @@ class CacheManagerInterface { const std::string& policy_app_id, const std::string& hybrid_app_preference) = 0; + /** + * @brief Get app service parameters from the policy table + * @param policy_app_id Unique application id + * @param service_name Service name published by app service provider + * @param service_type Service type published by app service provider + * @param handled_rpcs Vector of allowed function ids an app service provider + * can handle + */ virtual void GetAppServiceParameters( const std::string& policy_app_id, - std::string& app_service_name, + std::string& service_name, std::string& service_type, std::vector& handled_rpcs) const = 0; diff --git a/src/components/policy/policy_regular/include/policy/policy_manager_impl.h b/src/components/policy/policy_regular/include/policy/policy_manager_impl.h index 575e688114..6676510df5 100644 --- a/src/components/policy/policy_regular/include/policy/policy_manager_impl.h +++ b/src/components/policy/policy_regular/include/policy/policy_manager_impl.h @@ -634,9 +634,17 @@ class PolicyManagerImpl : public PolicyManager { const std::string& policy_app_id, const std::string& hybrid_app_preference) OVERRIDE; + /** + * @brief Get app service parameters from the policy table + * @param policy_app_id Unique application id + * @param service_name Service name published by app service provider + * @param service_type Service type published by app service provider + * @param handled_rpcs Vector of allowed function ids an app service provider + * can handle + */ void GetAppServiceParameters( const std::string& policy_app_id, - std::string& app_service_name, + std::string& service_name, std::string& service_type, std::vector& handled_rpcs) const OVERRIDE; diff --git a/src/components/policy/policy_regular/include/policy/policy_table/types.h b/src/components/policy/policy_regular/include/policy/policy_table/types.h index 4a6795b382..a1779367cc 100644 --- a/src/components/policy/policy_regular/include/policy/policy_table/types.h +++ b/src/components/policy/policy_regular/include/policy/policy_table/types.h @@ -154,7 +154,7 @@ struct ApplicationParams : PolicyBase { Optional > cloud_transport_type; // App Service Params - Optional > app_service_name; + Optional > service_name; Optional > service_type; Optional handled_rpcs; diff --git a/src/components/policy/policy_regular/src/cache_manager.cc b/src/components/policy/policy_regular/src/cache_manager.cc index 3fece5e5d6..5e92fc7535 100644 --- a/src/components/policy/policy_regular/src/cache_manager.cc +++ b/src/components/policy/policy_regular/src/cache_manager.cc @@ -798,7 +798,7 @@ void CacheManager::SetHybridAppPreference( void CacheManager::GetAppServiceParameters( const std::string& policy_app_id, - std::string& app_service_name, + std::string& service_name, std::string& service_type, std::vector& handled_rpcs) const { LOG4CXX_AUTO_TRACE(logger_); @@ -808,9 +808,9 @@ void CacheManager::GetAppServiceParameters( policies.find(policy_app_id); if (policies.end() != policy_iter) { auto app_policy = (*policy_iter).second; - app_service_name = app_policy.app_service_name.is_initialized() - ? *app_policy.app_service_name - : std::string(); + service_name = app_policy.service_name.is_initialized() + ? *app_policy.service_name + : std::string(); service_type = app_policy.service_type.is_initialized() ? *app_policy.service_type : std::string(); diff --git a/src/components/policy/policy_regular/src/policy_manager_impl.cc b/src/components/policy/policy_regular/src/policy_manager_impl.cc index d85ccb14f0..d223a6a433 100644 --- a/src/components/policy/policy_regular/src/policy_manager_impl.cc +++ b/src/components/policy/policy_regular/src/policy_manager_impl.cc @@ -593,11 +593,11 @@ void PolicyManagerImpl::SetHybridAppPreference( void PolicyManagerImpl::GetAppServiceParameters( const std::string& policy_app_id, - std::string& app_service_name, + std::string& service_name, std::string& service_type, std::vector& handled_rpcs) const { cache_->GetAppServiceParameters( - policy_app_id, app_service_name, service_type, handled_rpcs); + policy_app_id, service_name, service_type, handled_rpcs); } void PolicyManagerImpl::CheckPermissions(const PTString& device_id, diff --git a/src/components/policy/policy_regular/src/policy_table/types.cc b/src/components/policy/policy_regular/src/policy_table/types.cc index 8dda6981b2..e28b260f5f 100644 --- a/src/components/policy/policy_regular/src/policy_table/types.cc +++ b/src/components/policy/policy_regular/src/policy_table/types.cc @@ -174,7 +174,7 @@ ApplicationParams::ApplicationParams(const Json::Value* value__) , enabled(impl::ValueMember(value__, "enabled")) , auth_token(impl::ValueMember(value__, "auth_token")) , cloud_transport_type(impl::ValueMember(value__, "cloud_transport_type")) - , app_service_name(impl::ValueMember(value__, "app_service_name")) + , service_name(impl::ValueMember(value__, "service_name")) , service_type(impl::ValueMember(value__, "service_type")) , handled_rpcs(impl::ValueMember(value__, "handled_rpcs")) {} @@ -196,7 +196,7 @@ Json::Value ApplicationParams::ToJsonValue() const { impl::WriteJsonField("enabled", enabled, &result__); impl::WriteJsonField("auth_token", auth_token, &result__); impl::WriteJsonField("cloud_transport_type", cloud_transport_type, &result__); - impl::WriteJsonField("app_service_name", app_service_name, &result__); + impl::WriteJsonField("service_name", service_name, &result__); impl::WriteJsonField("service_type", service_type, &result__); impl::WriteJsonField("handled_rpcs", handled_rpcs, &result__); return result__; @@ -245,7 +245,7 @@ bool ApplicationParams::is_valid() const { if (!hybrid_app_preference.is_valid()) { return false; } - if (!app_service_name.is_valid()) { + if (!service_name.is_valid()) { return false; } if (!service_type.is_valid()) { @@ -307,7 +307,7 @@ bool ApplicationParams::struct_empty() const { if (hybrid_app_preference.is_initialized()) { return false; } - if (app_service_name.is_initialized()) { + if (service_name.is_initialized()) { return false; } if (service_type.is_initialized()) { @@ -370,9 +370,8 @@ void ApplicationParams::ReportErrors(rpc::ValidationReport* report__) const { moduleType.ReportErrors( &report__->ReportSubobject("hybrid_app_preference")); } - if (!app_service_name.is_valid()) { - app_service_name.ReportErrors( - &report__->ReportSubobject("app_service_name")); + if (!service_name.is_valid()) { + service_name.ReportErrors(&report__->ReportSubobject("service_name")); } if (!service_type.is_valid()) { service_type.ReportErrors(&report__->ReportSubobject("service_type")); @@ -396,7 +395,7 @@ void ApplicationParams::SetPolicyTableType(PolicyTableType pt_type) { enabled.SetPolicyTableType(pt_type); cloud_transport_type.SetPolicyTableType(pt_type); hybrid_app_preference.SetPolicyTableType(pt_type); - app_service_name.SetPolicyTableType(pt_type); + service_name.SetPolicyTableType(pt_type); service_type.SetPolicyTableType(pt_type); handled_rpcs.SetPolicyTableType(pt_type); } diff --git a/src/components/policy/policy_regular/src/sql_pt_queries.cc b/src/components/policy/policy_regular/src/sql_pt_queries.cc index 6329662a55..9027863e22 100644 --- a/src/components/policy/policy_regular/src/sql_pt_queries.cc +++ b/src/components/policy/policy_regular/src/sql_pt_queries.cc @@ -142,7 +142,7 @@ const std::string kCreateSchema = " `enabled` BOOLEAN, " " `auth_token` VARCHAR(65535), " " `cloud_transport_type` VARCHAR(255), " - " `app_service_name` VARCHAR(255), " + " `service_name` VARCHAR(255), " " `service_type` VARCHAR(255), " " `remote_control_denied` BOOLEAN NOT NULL DEFAULT 0, " " CONSTRAINT `fk_application_hmi_level1` " @@ -609,7 +609,7 @@ const std::string kInsertApplication = "INSERT OR IGNORE INTO `application` (`id`, `priority_value`, " "`is_revoked`, `memory_kb`, `heart_beat_timeout_ms`, `certificate`, " "`hybrid_app_preference_value`, `endpoint`, `enabled`, `auth_token`, " - "`cloud_transport_type`, `app_service_name`, `service_type`) VALUES " + "`cloud_transport_type`, `service_name`, `service_type`) VALUES " "(?,?,?,?,?,?,?,?,?,?,?,?,?)"; const std::string kInsertAppGroup = @@ -726,7 +726,7 @@ const std::string kSelectAppPolicies = "SELECT `id`, `priority_value`, `memory_kb`, " " `heart_beat_timeout_ms`, `certificate`, `hybrid_app_preference_value`, " " `endpoint`, `enabled`, `auth_token`, `cloud_transport_type`, " - "`app_service_name`, `service_type` FROM " + "`service_name`, `service_type` FROM " " `application`"; const std::string kCollectFriendlyMsg = "SELECT * FROM `message`"; @@ -834,7 +834,7 @@ const std::string kInsertApplicationFull = " `default_hmi`, `priority_value`, `is_revoked`, `is_default`, " " `is_predata`, `memory_kb`, `heart_beat_timeout_ms`, " " `certificate`, `hybrid_app_preference_value`, `endpoint`, `enabled`, " - " `auth_token`, `cloud_transport_type`, `app_service_name`, " + " `auth_token`, `cloud_transport_type`, `service_name`, " "`service_type`) " " VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"; @@ -843,7 +843,7 @@ const std::string kSelectApplicationFull = " `is_revoked`, `is_default`, `is_predata`, `memory_kb`," " `heart_beat_timeout_ms`, `certificate`, `hybrid_app_preference_value`, " " `endpoint`, `enabled`, `auth_token`, `cloud_transport_type`, " - "`app_service_name`, `service_type` " + "`service_name`, `service_type` " "FROM `application` " "WHERE `id` = " "?"; diff --git a/src/components/policy/policy_regular/src/sql_pt_representation.cc b/src/components/policy/policy_regular/src/sql_pt_representation.cc index 98c7f1864b..4e144d4e69 100644 --- a/src/components/policy/policy_regular/src/sql_pt_representation.cc +++ b/src/components/policy/policy_regular/src/sql_pt_representation.cc @@ -735,7 +735,7 @@ bool SQLPTRepresentation::GatherApplicationPoliciesSection( *params.cloud_transport_type = query.GetString(9); // AppService Parameters - *params.app_service_name = query.GetString(10); + *params.service_name = query.GetString(10); *params.service_type = query.GetString(11); const auto& gather_app_id = ((*policies).apps[app_id].is_string()) @@ -1019,8 +1019,8 @@ bool SQLPTRepresentation::SaveSpecificAppPolicy( app.second.cloud_transport_type.is_initialized() ? app_query.Bind(10, *app.second.cloud_transport_type) : app_query.Bind(10); - app.second.app_service_name.is_initialized() - ? app_query.Bind(11, *app.second.app_service_name) + app.second.service_name.is_initialized() + ? app_query.Bind(11, *app.second.service_name) : app_query.Bind(11); app.second.service_type.is_initialized() ? app_query.Bind(12, *app.second.service_type) -- cgit v1.2.1 From 512f736856ad28572a0470d6ca5afe38d1977af3 Mon Sep 17 00:00:00 2001 From: jacobkeeler Date: Wed, 23 Jan 2019 16:43:11 -0500 Subject: Add basic App Service Manager --- .../application_manager/app_service_manager.h | 83 +++++++++++++++++++++ .../application_manager/application_manager_impl.h | 7 ++ .../application_manager/rpc_plugins/CMakeLists.txt | 2 +- .../application_manager/src/app_service_manager.cc | 85 ++++++++++++++++++++++ .../src/application_manager_impl.cc | 2 + .../application_manager/application_manager.h | 3 + .../application_manager/mock_application_manager.h | 3 + 7 files changed, 184 insertions(+), 1 deletion(-) create mode 100644 src/components/application_manager/include/application_manager/app_service_manager.h create mode 100644 src/components/application_manager/src/app_service_manager.cc diff --git a/src/components/application_manager/include/application_manager/app_service_manager.h b/src/components/application_manager/include/application_manager/app_service_manager.h new file mode 100644 index 0000000000..afbf9b8dcd --- /dev/null +++ b/src/components/application_manager/include/application_manager/app_service_manager.h @@ -0,0 +1,83 @@ +/* + * Copyright (c) 2018, 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. + */ + +#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_APP_SERVICE_MANAGER_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_APP_SERVICE_MANAGER_H_ + +#include "smart_objects/smart_object.h" + +namespace application_manager { + +class ApplicationManager; + +/** + * @brief The AppServiceManager is TODO. + */ +class AppServiceManager { + public: + /** + * @brief Class constructor + * @param app_manager + */ + AppServiceManager(ApplicationManager& app_manager); + + /** + * @brief Class destructor + */ + ~AppServiceManager(); + + /** + * @brief TODO + * @param manifest + */ + bool PublishAppService(const smart_objects::SmartObject& manifest); + + /** + * @brief TODO + * @param manifest + */ + bool UnpublishAppService(const std::string service_id); + + /** + * @brief TODO + * @param manifest + */ + std::vector GetAllServices(); + + private: + ApplicationManager& app_manager_; + std::map published_services_; +}; + +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_APP_SERVICE_MANAGER_H_ diff --git a/src/components/application_manager/include/application_manager/application_manager_impl.h b/src/components/application_manager/include/application_manager/application_manager_impl.h index 8c062f9016..418161b0ff 100644 --- a/src/components/application_manager/include/application_manager/application_manager_impl.h +++ b/src/components/application_manager/include/application_manager/application_manager_impl.h @@ -213,6 +213,12 @@ class ApplicationManagerImpl return *plugin_manager_; } + virtual application_manager::AppServiceManager& GetAppServiceManager() + OVERRIDE { + DCHECK(app_service_manager_); + return *app_service_manager_; + } + std::vector devices( const std::string& policy_app_id) const OVERRIDE; @@ -1401,6 +1407,7 @@ class ApplicationManagerImpl protocol_handler::ProtocolHandler* protocol_handler_; request_controller::RequestController request_ctrl_; std::unique_ptr plugin_manager_; + std::unique_ptr app_service_manager_; /** * @brief Map contains apps with HMI state before incoming call diff --git a/src/components/application_manager/rpc_plugins/CMakeLists.txt b/src/components/application_manager/rpc_plugins/CMakeLists.txt index e4f0051738..8884b30532 100644 --- a/src/components/application_manager/rpc_plugins/CMakeLists.txt +++ b/src/components/application_manager/rpc_plugins/CMakeLists.txt @@ -32,4 +32,4 @@ add_subdirectory(vehicle_info_plugin) add_subdirectory(sdl_rpc_plugin) add_subdirectory(rc_rpc_plugin) -add_subdirectory(app_service_rpc_plugin) \ No newline at end of file +add_subdirectory(app_service_rpc_plugin) diff --git a/src/components/application_manager/src/app_service_manager.cc b/src/components/application_manager/src/app_service_manager.cc new file mode 100644 index 0000000000..2c5a31e86e --- /dev/null +++ b/src/components/application_manager/src/app_service_manager.cc @@ -0,0 +1,85 @@ +/* + * Copyright (c) 2018, 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 "application_manager/help_prompt_manager_impl.h" + +#include +#include + +#include "application_manager/application.h" +#include "application_manager/application_manager.h" +#include "application_manager/commands/command_impl.h" +#include "application_manager/message_helper.h" +#include "application_manager/smart_object_keys.h" +#include "smart_objects/smart_object.h" +#include "utils/logger.h" + +CREATE_LOGGERPTR_GLOBAL(logger_, "AppServiceManager") + +namespace { +const size_t kLimitCommand = 30; +} + +namespace application_manager { + +AppServiceManager::AppServiceManager(ApplicationManager& app_manager) + : app_manager_(app_manager) {} + +AppServiceManager::~AppServiceManager() { + LOG4CXX_AUTO_TRACE(logger_); +} + +bool AppServiceManager::PublishAppService( + const smart_objects::SmartObject& manifest) { + std::string service_id = "SERVICE_UUID"; // TODO: Generate UUID + published_services_.insert( + std::pair(service_id, manifest)); + return true; +} + +bool AppServiceManager::UnpublishAppService(const std::string service_id) { + LOG4CXX_AUTO_TRACE(logger_); + // TODO + return false; +} + +std::vector AppServiceManager::GetAllServices() { + LOG4CXX_AUTO_TRACE(logger_); + std::vector services; + for (auto it = published_services_.begin(); it != published_services_.end(); + ++it) { + services.push_back(it->second); + } + return services; +} + +} // namespace application_manager diff --git a/src/components/application_manager/src/application_manager_impl.cc b/src/components/application_manager/src/application_manager_impl.cc index edf4be561b..d82eeb776c 100644 --- a/src/components/application_manager/src/application_manager_impl.cc +++ b/src/components/application_manager/src/application_manager_impl.cc @@ -2009,6 +2009,8 @@ bool ApplicationManagerImpl::Init(resumption::LastState& last_state, } app_launch_ctrl_.reset(new app_launch::AppLaunchCtrlImpl( *app_launch_dto_.get(), *this, settings_)); + + app_service_manager_.reset(new application_manager::AppServiceManager(*this)); return true; } diff --git a/src/components/include/application_manager/application_manager.h b/src/components/include/application_manager/application_manager.h index 47b6bcbc9d..adb47c8a99 100644 --- a/src/components/include/application_manager/application_manager.h +++ b/src/components/include/application_manager/application_manager.h @@ -51,6 +51,7 @@ #include "application_manager/hmi_interfaces.h" #include "policy/policy_types.h" #include "application_manager/plugin_manager/rpc_plugin_manager.h" +#include "application_manager/app_service_manager.h" namespace resumption { class LastState; } @@ -188,6 +189,8 @@ class ApplicationManager { virtual plugin_manager::RPCPluginManager& GetPluginManager() = 0; + virtual application_manager::AppServiceManager& GetAppServiceManager() = 0; + #ifdef BUILD_TESTS virtual void SetPluginManager( std::unique_ptr& plugin_manager) = 0; diff --git a/src/components/include/test/application_manager/mock_application_manager.h b/src/components/include/test/application_manager/mock_application_manager.h index 30a24ad9ce..582884e1e7 100644 --- a/src/components/include/test/application_manager/mock_application_manager.h +++ b/src/components/include/test/application_manager/mock_application_manager.h @@ -59,6 +59,7 @@ namespace test { namespace components { namespace application_manager_test { using application_manager::plugin_manager::RPCPluginManager; +using application_manager::AppServiceManager; class MockApplicationManager : public application_manager::ApplicationManager { public: @@ -91,6 +92,8 @@ class MockApplicationManager : public application_manager::ApplicationManager { MOCK_METHOD1(SetPluginManager, void(std::unique_ptr& plugin_manager)); + MOCK_METHOD0(GetAppServiceManager, AppServiceManager&()); + MOCK_CONST_METHOD1( application_by_hmi_app, application_manager::ApplicationSharedPtr(uint32_t hmi_app_id)); -- cgit v1.2.1 From 1057d6f4fc933c681ec52365c51268a8f3418a07 Mon Sep 17 00:00:00 2001 From: JackLivio Date: Wed, 23 Jan 2019 21:27:56 -0500 Subject: Change handled_rpc to uint32 --- .../include/application_manager/policies/policy_handler.h | 2 +- .../src/commands/mobile/publish_app_service_request.cc | 2 +- src/components/application_manager/src/policies/policy_handler.cc | 2 +- .../include/application_manager/policies/policy_handler_interface.h | 2 +- src/components/include/policy/policy_external/policy/policy_manager.h | 2 +- src/components/include/policy/policy_regular/policy/policy_manager.h | 2 +- src/components/policy/policy_external/include/policy/cache_manager.h | 2 +- .../policy/policy_external/include/policy/cache_manager_interface.h | 2 +- .../policy/policy_external/include/policy/policy_manager_impl.h | 2 +- src/components/policy/policy_external/src/cache_manager.cc | 2 +- src/components/policy/policy_external/src/policy_manager_impl.cc | 2 +- src/components/policy/policy_regular/include/policy/cache_manager.h | 2 +- .../policy/policy_regular/include/policy/cache_manager_interface.h | 2 +- .../policy/policy_regular/include/policy/policy_manager_impl.h | 2 +- .../policy/policy_regular/include/policy/policy_table/types.h | 2 +- src/components/policy/policy_regular/src/cache_manager.cc | 2 +- src/components/policy/policy_regular/src/policy_manager_impl.cc | 2 +- 17 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/components/application_manager/include/application_manager/policies/policy_handler.h b/src/components/application_manager/include/application_manager/policies/policy_handler.h index ffc5037e3b..1dff9e348c 100644 --- a/src/components/application_manager/include/application_manager/policies/policy_handler.h +++ b/src/components/application_manager/include/application_manager/policies/policy_handler.h @@ -450,7 +450,7 @@ class PolicyHandler : public PolicyHandlerInterface, void GetAppServiceParameters(const std::string& policy_app_id, std::string& service_name, std::string& service_type, - std::vector& handled_rpcs) const; + std::vector& handled_rpcs) const; virtual void OnUpdateHMIAppType( std::map app_hmi_types) OVERRIDE; diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/publish_app_service_request.cc b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/publish_app_service_request.cc index 05fe75c887..b48f844263 100644 --- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/publish_app_service_request.cc +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/publish_app_service_request.cc @@ -90,7 +90,7 @@ void PublishAppServiceRequest::Run() { std::string service_name = std::string(); std::string service_type = std::string(); - std::vector handled_rpcs = {}; + std::vector handled_rpcs = {}; ApplicationSharedPtr app = application_manager_.application(connection_key()); policy_handler_.GetAppServiceParameters( diff --git a/src/components/application_manager/src/policies/policy_handler.cc b/src/components/application_manager/src/policies/policy_handler.cc index 6270b4e8b4..6034e34b18 100644 --- a/src/components/application_manager/src/policies/policy_handler.cc +++ b/src/components/application_manager/src/policies/policy_handler.cc @@ -1941,7 +1941,7 @@ void PolicyHandler::GetAppServiceParameters( const std::string& policy_app_id, std::string& service_name, std::string& service_type, - std::vector& handled_rpcs) const { + std::vector& handled_rpcs) const { POLICY_LIB_CHECK_VOID(); policy_manager_->GetAppServiceParameters( policy_app_id, service_name, service_type, handled_rpcs); diff --git a/src/components/include/application_manager/policies/policy_handler_interface.h b/src/components/include/application_manager/policies/policy_handler_interface.h index 914b33204d..858145e329 100644 --- a/src/components/include/application_manager/policies/policy_handler_interface.h +++ b/src/components/include/application_manager/policies/policy_handler_interface.h @@ -492,7 +492,7 @@ class PolicyHandlerInterface { const std::string& policy_app_id, std::string& service_name, std::string& service_type, - std::vector& handled_rpcs) const = 0; + std::vector& handled_rpcs) const = 0; #ifdef EXTERNAL_PROPRIETARY_MODE /** diff --git a/src/components/include/policy/policy_external/policy/policy_manager.h b/src/components/include/policy/policy_external/policy/policy_manager.h index e7d682e257..96b2d5d659 100644 --- a/src/components/include/policy/policy_external/policy/policy_manager.h +++ b/src/components/include/policy/policy_external/policy/policy_manager.h @@ -604,7 +604,7 @@ class PolicyManager : public usage_statistics::StatisticsManager { const std::string& policy_app_id, std::string& service_name, std::string& service_type, - std::vector& handled_rpcs) const = 0; + std::vector& handled_rpcs) const = 0; /** * @brief Gets meta information diff --git a/src/components/include/policy/policy_regular/policy/policy_manager.h b/src/components/include/policy/policy_regular/policy/policy_manager.h index 6c8b8fb3e5..e62d12cd03 100644 --- a/src/components/include/policy/policy_regular/policy/policy_manager.h +++ b/src/components/include/policy/policy_regular/policy/policy_manager.h @@ -585,7 +585,7 @@ class PolicyManager : public usage_statistics::StatisticsManager { const std::string& policy_app_id, std::string& service_name, std::string& service_type, - std::vector& handled_rpcs) const = 0; + std::vector& handled_rpcs) const = 0; /** * @brief OnAppRegisteredOnMobile allows to handle event when application were diff --git a/src/components/policy/policy_external/include/policy/cache_manager.h b/src/components/policy/policy_external/include/policy/cache_manager.h index 9cc1d25bfb..e31e3e6c34 100644 --- a/src/components/policy/policy_external/include/policy/cache_manager.h +++ b/src/components/policy/policy_external/include/policy/cache_manager.h @@ -240,7 +240,7 @@ class CacheManager : public CacheManagerInterface { const std::string& policy_app_id, std::string& service_name, std::string& service_type, - std::vector& handled_rpcs) const; + std::vector& handled_rpcs) const; /** * @brief Allows to update 'vin' field in module_meta table. diff --git a/src/components/policy/policy_external/include/policy/cache_manager_interface.h b/src/components/policy/policy_external/include/policy/cache_manager_interface.h index b48b6a1041..5b9fe5cfcb 100644 --- a/src/components/policy/policy_external/include/policy/cache_manager_interface.h +++ b/src/components/policy/policy_external/include/policy/cache_manager_interface.h @@ -249,7 +249,7 @@ class CacheManagerInterface { const std::string& policy_app_id, std::string& service_name, std::string& service_type, - std::vector& handled_rpcs) const = 0; + std::vector& handled_rpcs) const = 0; /** * @brief Allows to update 'vin' field in module_meta table. diff --git a/src/components/policy/policy_external/include/policy/policy_manager_impl.h b/src/components/policy/policy_external/include/policy/policy_manager_impl.h index fa64614e1f..b5a9709ecc 100644 --- a/src/components/policy/policy_external/include/policy/policy_manager_impl.h +++ b/src/components/policy/policy_external/include/policy/policy_manager_impl.h @@ -651,7 +651,7 @@ class PolicyManagerImpl : public PolicyManager { const std::string& policy_app_id, std::string& service_name, std::string& service_type, - std::vector& handled_rpcs) const OVERRIDE; + std::vector& handled_rpcs) const OVERRIDE; /** * @brief OnAppRegisteredOnMobile allows to handle event when application were diff --git a/src/components/policy/policy_external/src/cache_manager.cc b/src/components/policy/policy_external/src/cache_manager.cc index b94230548f..663ac7b395 100644 --- a/src/components/policy/policy_external/src/cache_manager.cc +++ b/src/components/policy/policy_external/src/cache_manager.cc @@ -1505,7 +1505,7 @@ void CacheManager::GetAppServiceParameters( const std::string& policy_app_id, std::string& service_name, std::string& service_type, - std::vector& handled_rpcs) const { + std::vector& handled_rpcs) const { LOG4CXX_AUTO_TRACE(logger_); const policy_table::ApplicationPolicies& policies = pt_->policy_table.app_policies_section.apps; diff --git a/src/components/policy/policy_external/src/policy_manager_impl.cc b/src/components/policy/policy_external/src/policy_manager_impl.cc index 56eac75127..e50a3ecedd 100644 --- a/src/components/policy/policy_external/src/policy_manager_impl.cc +++ b/src/components/policy/policy_external/src/policy_manager_impl.cc @@ -776,7 +776,7 @@ void PolicyManagerImpl::GetAppServiceParameters( const std::string& policy_app_id, std::string& service_name, std::string& service_type, - std::vector& handled_rpcs) const { + std::vector& handled_rpcs) const { cache_->GetAppServiceParameters( policy_app_id, service_name, service_type, handled_rpcs); } diff --git a/src/components/policy/policy_regular/include/policy/cache_manager.h b/src/components/policy/policy_regular/include/policy/cache_manager.h index 69b3fe4706..6d042f6ac3 100644 --- a/src/components/policy/policy_regular/include/policy/cache_manager.h +++ b/src/components/policy/policy_regular/include/policy/cache_manager.h @@ -228,7 +228,7 @@ class CacheManager : public CacheManagerInterface { const std::string& policy_app_id, std::string& service_name, std::string& service_type, - std::vector& handled_rpcs) const; + std::vector& handled_rpcs) const; /** * @brief Allows to update 'vin' field in module_meta table. diff --git a/src/components/policy/policy_regular/include/policy/cache_manager_interface.h b/src/components/policy/policy_regular/include/policy/cache_manager_interface.h index ceb30eb4d1..3973eca581 100644 --- a/src/components/policy/policy_regular/include/policy/cache_manager_interface.h +++ b/src/components/policy/policy_regular/include/policy/cache_manager_interface.h @@ -235,7 +235,7 @@ class CacheManagerInterface { const std::string& policy_app_id, std::string& service_name, std::string& service_type, - std::vector& handled_rpcs) const = 0; + std::vector& handled_rpcs) const = 0; /** * @brief Allows to update 'vin' field in module_meta table. diff --git a/src/components/policy/policy_regular/include/policy/policy_manager_impl.h b/src/components/policy/policy_regular/include/policy/policy_manager_impl.h index 6676510df5..f4dd5d0870 100644 --- a/src/components/policy/policy_regular/include/policy/policy_manager_impl.h +++ b/src/components/policy/policy_regular/include/policy/policy_manager_impl.h @@ -646,7 +646,7 @@ class PolicyManagerImpl : public PolicyManager { const std::string& policy_app_id, std::string& service_name, std::string& service_type, - std::vector& handled_rpcs) const OVERRIDE; + std::vector& handled_rpcs) const OVERRIDE; /** * @brief OnAppRegisteredOnMobile allows to handle event when application were diff --git a/src/components/policy/policy_regular/include/policy/policy_table/types.h b/src/components/policy/policy_regular/include/policy/policy_table/types.h index a1779367cc..f2f99003e2 100644 --- a/src/components/policy/policy_regular/include/policy/policy_table/types.h +++ b/src/components/policy/policy_regular/include/policy/policy_table/types.h @@ -98,7 +98,7 @@ typedef Array, 0, 255> RequestTypes; typedef Strings RequestSubTypes; -typedef Array, 0, 255> HandledRpcs; +typedef Array, 0, 255> HandledRpcs; typedef Map RemoteRpcs; typedef Map AccessModules; diff --git a/src/components/policy/policy_regular/src/cache_manager.cc b/src/components/policy/policy_regular/src/cache_manager.cc index 5e92fc7535..9396534677 100644 --- a/src/components/policy/policy_regular/src/cache_manager.cc +++ b/src/components/policy/policy_regular/src/cache_manager.cc @@ -800,7 +800,7 @@ void CacheManager::GetAppServiceParameters( const std::string& policy_app_id, std::string& service_name, std::string& service_type, - std::vector& handled_rpcs) const { + std::vector& handled_rpcs) const { LOG4CXX_AUTO_TRACE(logger_); const policy_table::ApplicationPolicies& policies = pt_->policy_table.app_policies_section.apps; diff --git a/src/components/policy/policy_regular/src/policy_manager_impl.cc b/src/components/policy/policy_regular/src/policy_manager_impl.cc index d223a6a433..12dd322e6c 100644 --- a/src/components/policy/policy_regular/src/policy_manager_impl.cc +++ b/src/components/policy/policy_regular/src/policy_manager_impl.cc @@ -595,7 +595,7 @@ void PolicyManagerImpl::GetAppServiceParameters( const std::string& policy_app_id, std::string& service_name, std::string& service_type, - std::vector& handled_rpcs) const { + std::vector& handled_rpcs) const { cache_->GetAppServiceParameters( policy_app_id, service_name, service_type, handled_rpcs); } -- cgit v1.2.1 From f27fe0bc5980ea19baf89791d45414854fa91325 Mon Sep 17 00:00:00 2001 From: JackLivio Date: Wed, 23 Jan 2019 23:17:25 -0500 Subject: Add policy handler CheckAppServiceParameters --- .../application_manager/policies/policy_handler.h | 7 +++++- .../commands/mobile/publish_app_service_request.cc | 23 +++--------------- .../src/policies/policy_handler.cc | 28 ++++++++++++++++++++++ .../policies/policy_handler_interface.h | 5 ++++ 4 files changed, 42 insertions(+), 21 deletions(-) diff --git a/src/components/application_manager/include/application_manager/policies/policy_handler.h b/src/components/application_manager/include/application_manager/policies/policy_handler.h index 1dff9e348c..fbceef3d6c 100644 --- a/src/components/application_manager/include/application_manager/policies/policy_handler.h +++ b/src/components/application_manager/include/application_manager/policies/policy_handler.h @@ -450,7 +450,12 @@ class PolicyHandler : public PolicyHandlerInterface, void GetAppServiceParameters(const std::string& policy_app_id, std::string& service_name, std::string& service_type, - std::vector& handled_rpcs) const; + std::vector& handled_rpcs) const OVERRIDE; + + bool CheckAppServiceParameters(const std::string& policy_app_id, + const std::string& requested_service_name, + const std::string& requested_service_type, + smart_objects::SmartArray* requested_handled_rpcs) const OVERRIDE; virtual void OnUpdateHMIAppType( std::map app_hmi_types) OVERRIDE; diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/publish_app_service_request.cc b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/publish_app_service_request.cc index b48f844263..d2cc165656 100644 --- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/publish_app_service_request.cc +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/publish_app_service_request.cc @@ -88,32 +88,15 @@ void PublishAppServiceRequest::Run() { (*message_)[strings::msg_params][strings::app_service_manifest] [strings::handled_rpcs].asArray(); - std::string service_name = std::string(); - std::string service_type = std::string(); - std::vector handled_rpcs = {}; ApplicationSharedPtr app = application_manager_.application(connection_key()); - policy_handler_.GetAppServiceParameters( - app->policy_app_id(), service_name, service_type, handled_rpcs); + bool result = policy_handler_.CheckAppServiceParameters( + app->policy_app_id(), requested_service_name, requested_service_type, requested_handled_rpcs); - if (service_name != requested_service_name) { + if (!result) { SendResponse(false, mobile_apis::Result::DISALLOWED, NULL, NULL); } - if (service_type != requested_service_type) { - SendResponse(false, mobile_apis::Result::DISALLOWED, NULL, NULL); - } - - for (auto requested_it = requested_handled_rpcs->begin(); - requested_it != requested_handled_rpcs->end(); - ++requested_it) { - auto find_result = std::find( - handled_rpcs.begin(), handled_rpcs.end(), requested_it->asUInt()); - if (find_result == handled_rpcs.end()) { - SendResponse(false, mobile_apis::Result::DISALLOWED, NULL, NULL); - } - } - response_params[strings::app_service_record] = service_record; SendResponse(true, mobile_apis::Result::SUCCESS, NULL, &response_params); diff --git a/src/components/application_manager/src/policies/policy_handler.cc b/src/components/application_manager/src/policies/policy_handler.cc index 6034e34b18..d6caaec410 100644 --- a/src/components/application_manager/src/policies/policy_handler.cc +++ b/src/components/application_manager/src/policies/policy_handler.cc @@ -1947,6 +1947,34 @@ void PolicyHandler::GetAppServiceParameters( policy_app_id, service_name, service_type, handled_rpcs); } +bool PolicyHandler::CheckAppServiceParameters(const std::string& policy_app_id, + const std::string& requested_service_name, + const std::string& requested_service_type, + smart_objects::SmartArray* requested_handled_rpcs) const { + std::string service_name = std::string(); + std::string service_type = std::string(); + std::vector handled_rpcs = {}; + this->GetAppServiceParameters(policy_app_id, service_name, service_type, handled_rpcs); + if (service_name != requested_service_name) { + return false; + } + + if (service_type != requested_service_type) { + return false; + } + + for (auto requested_it = requested_handled_rpcs->begin(); + requested_it != requested_handled_rpcs->end(); + ++requested_it) { + auto find_result = std::find( + handled_rpcs.begin(), handled_rpcs.end(), requested_it->asUInt()); + if (find_result == handled_rpcs.end()) { + return false; + } + } + return true; +} + uint32_t PolicyHandler::HeartBeatTimeout(const std::string& app_id) const { POLICY_LIB_CHECK(0); return policy_manager_->HeartBeatTimeout(app_id); diff --git a/src/components/include/application_manager/policies/policy_handler_interface.h b/src/components/include/application_manager/policies/policy_handler_interface.h index 858145e329..c8f04fdd02 100644 --- a/src/components/include/application_manager/policies/policy_handler_interface.h +++ b/src/components/include/application_manager/policies/policy_handler_interface.h @@ -494,6 +494,11 @@ class PolicyHandlerInterface { std::string& service_type, std::vector& handled_rpcs) const = 0; + virtual bool CheckAppServiceParameters(const std::string& policy_app_id, + const std::string& requested_service_name, + const std::string& requested_service_type, + smart_objects::SmartArray* requested_handled_rpcs) const = 0; + #ifdef EXTERNAL_PROPRIETARY_MODE /** * @brief Gets meta information -- cgit v1.2.1 From 1bf4124d7cbbc6236a772da2f7c173610b582530 Mon Sep 17 00:00:00 2001 From: jacobkeeler Date: Thu, 24 Jan 2019 09:39:15 -0500 Subject: Update Travis Distro --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 7f7df359b4..7060f4f33f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,5 @@ language: cpp -dist: trusty +dist: xenial sudo: required only: - master -- cgit v1.2.1 From d861c8f7097e331e82c86b926d2db104caade052 Mon Sep 17 00:00:00 2001 From: JackLivio Date: Thu, 24 Jan 2019 09:40:16 -0500 Subject: Fix style --- .../application_manager/policies/policy_handler.h | 20 +++++++++++--------- .../commands/mobile/publish_app_service_request.cc | 7 +++++-- .../src/policies/policy_handler.cc | 8 +++++--- .../policies/policy_handler_interface.h | 9 +++++---- 4 files changed, 26 insertions(+), 18 deletions(-) diff --git a/src/components/application_manager/include/application_manager/policies/policy_handler.h b/src/components/application_manager/include/application_manager/policies/policy_handler.h index fbceef3d6c..3aae747542 100644 --- a/src/components/application_manager/include/application_manager/policies/policy_handler.h +++ b/src/components/application_manager/include/application_manager/policies/policy_handler.h @@ -447,15 +447,17 @@ class PolicyHandler : public PolicyHandlerInterface, void OnSetCloudAppProperties( const smart_objects::SmartObject& message) OVERRIDE; - void GetAppServiceParameters(const std::string& policy_app_id, - std::string& service_name, - std::string& service_type, - std::vector& handled_rpcs) const OVERRIDE; - - bool CheckAppServiceParameters(const std::string& policy_app_id, - const std::string& requested_service_name, - const std::string& requested_service_type, - smart_objects::SmartArray* requested_handled_rpcs) const OVERRIDE; + void GetAppServiceParameters( + const std::string& policy_app_id, + std::string& service_name, + std::string& service_type, + std::vector& handled_rpcs) const OVERRIDE; + + bool CheckAppServiceParameters( + const std::string& policy_app_id, + const std::string& requested_service_name, + const std::string& requested_service_type, + smart_objects::SmartArray* requested_handled_rpcs) const OVERRIDE; virtual void OnUpdateHMIAppType( std::map app_hmi_types) OVERRIDE; diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/publish_app_service_request.cc b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/publish_app_service_request.cc index d2cc165656..da91930509 100644 --- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/publish_app_service_request.cc +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/publish_app_service_request.cc @@ -90,8 +90,11 @@ void PublishAppServiceRequest::Run() { ApplicationSharedPtr app = application_manager_.application(connection_key()); - bool result = policy_handler_.CheckAppServiceParameters( - app->policy_app_id(), requested_service_name, requested_service_type, requested_handled_rpcs); + bool result = + policy_handler_.CheckAppServiceParameters(app->policy_app_id(), + requested_service_name, + requested_service_type, + requested_handled_rpcs); if (!result) { SendResponse(false, mobile_apis::Result::DISALLOWED, NULL, NULL); diff --git a/src/components/application_manager/src/policies/policy_handler.cc b/src/components/application_manager/src/policies/policy_handler.cc index d6caaec410..b8da78aabf 100644 --- a/src/components/application_manager/src/policies/policy_handler.cc +++ b/src/components/application_manager/src/policies/policy_handler.cc @@ -1947,14 +1947,16 @@ void PolicyHandler::GetAppServiceParameters( policy_app_id, service_name, service_type, handled_rpcs); } -bool PolicyHandler::CheckAppServiceParameters(const std::string& policy_app_id, +bool PolicyHandler::CheckAppServiceParameters( + const std::string& policy_app_id, const std::string& requested_service_name, const std::string& requested_service_type, smart_objects::SmartArray* requested_handled_rpcs) const { std::string service_name = std::string(); std::string service_type = std::string(); std::vector handled_rpcs = {}; - this->GetAppServiceParameters(policy_app_id, service_name, service_type, handled_rpcs); + this->GetAppServiceParameters( + policy_app_id, service_name, service_type, handled_rpcs); if (service_name != requested_service_name) { return false; } @@ -1972,7 +1974,7 @@ bool PolicyHandler::CheckAppServiceParameters(const std::string& policy_app_id, return false; } } - return true; + return true; } uint32_t PolicyHandler::HeartBeatTimeout(const std::string& app_id) const { diff --git a/src/components/include/application_manager/policies/policy_handler_interface.h b/src/components/include/application_manager/policies/policy_handler_interface.h index c8f04fdd02..29776aa926 100644 --- a/src/components/include/application_manager/policies/policy_handler_interface.h +++ b/src/components/include/application_manager/policies/policy_handler_interface.h @@ -494,10 +494,11 @@ class PolicyHandlerInterface { std::string& service_type, std::vector& handled_rpcs) const = 0; - virtual bool CheckAppServiceParameters(const std::string& policy_app_id, - const std::string& requested_service_name, - const std::string& requested_service_type, - smart_objects::SmartArray* requested_handled_rpcs) const = 0; + virtual bool CheckAppServiceParameters( + const std::string& policy_app_id, + const std::string& requested_service_name, + const std::string& requested_service_type, + smart_objects::SmartArray* requested_handled_rpcs) const = 0; #ifdef EXTERNAL_PROPRIETARY_MODE /** -- cgit v1.2.1 From 1a1a91088051a6a0d2ac856bb810df3621499a9f Mon Sep 17 00:00:00 2001 From: jacobkeeler Date: Thu, 24 Jan 2019 10:34:39 -0500 Subject: Update PublishAppService in AppServiceManager --- .../include/application_manager/app_service_manager.h | 3 ++- .../include/application_manager/application_manager_impl.h | 2 +- .../src/commands/hmi/as_publish_app_service_request.cc | 9 +++------ .../src/commands/mobile/publish_app_service_request.cc | 8 ++------ .../application_manager/src/app_service_manager.cc | 13 +++++++++---- .../include/application_manager/application_manager.h | 2 +- .../test/application_manager/mock_application_manager.h | 3 +-- 7 files changed, 19 insertions(+), 21 deletions(-) diff --git a/src/components/application_manager/include/application_manager/app_service_manager.h b/src/components/application_manager/include/application_manager/app_service_manager.h index afbf9b8dcd..a15921d9f7 100644 --- a/src/components/application_manager/include/application_manager/app_service_manager.h +++ b/src/components/application_manager/include/application_manager/app_service_manager.h @@ -59,7 +59,8 @@ class AppServiceManager { * @brief TODO * @param manifest */ - bool PublishAppService(const smart_objects::SmartObject& manifest); + smart_objects::SmartObject PublishAppService( + const smart_objects::SmartObject& manifest); /** * @brief TODO diff --git a/src/components/application_manager/include/application_manager/application_manager_impl.h b/src/components/application_manager/include/application_manager/application_manager_impl.h index 418161b0ff..fcdc7dc966 100644 --- a/src/components/application_manager/include/application_manager/application_manager_impl.h +++ b/src/components/application_manager/include/application_manager/application_manager_impl.h @@ -213,7 +213,7 @@ class ApplicationManagerImpl return *plugin_manager_; } - virtual application_manager::AppServiceManager& GetAppServiceManager() + virtual AppServiceManager& GetAppServiceManager() OVERRIDE { DCHECK(app_service_manager_); return *app_service_manager_; diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_publish_app_service_request.cc b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_publish_app_service_request.cc index 835762f78a..1e235c1282 100644 --- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_publish_app_service_request.cc +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_publish_app_service_request.cc @@ -80,17 +80,14 @@ void ASPublishAppServiceRequest::Run() { LOG4CXX_AUTO_TRACE(logger_); smart_objects::SmartObject response_params = smart_objects::SmartObject(smart_objects::SmartType_Map); - smart_objects::SmartObject service_record = - smart_objects::SmartObject(smart_objects::SmartType_Map); smart_objects::SmartObject manifest = (*message_)[strings::msg_params][strings::app_service_manifest]; if (!ValidateManifest(manifest)) { return; } - service_record[strings::service_manifest] = manifest; - service_record[strings::service_id] = "This is a service ID"; - service_record[strings::service_published] = true; - service_record[strings::service_active] = true; + smart_objects::SmartObject service_record = + application_manager_.GetAppServiceManager().PublishAppService(manifest); + response_params[strings::app_service_record] = service_record; // TODO: Add AppServiceRecord to response SendResponse(true, diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/publish_app_service_request.cc b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/publish_app_service_request.cc index b22d0a8c6e..bf1fbae4f5 100644 --- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/publish_app_service_request.cc +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/publish_app_service_request.cc @@ -84,17 +84,13 @@ void PublishAppServiceRequest::Run() { smart_objects::SmartObject response_params = smart_objects::SmartObject(smart_objects::SmartType_Map); - smart_objects::SmartObject service_record = - smart_objects::SmartObject(smart_objects::SmartType_Map); smart_objects::SmartObject manifest = (*message_)[strings::msg_params][strings::app_service_manifest]; if (!ValidateManifest(manifest)) { return; } - service_record[strings::service_manifest] = manifest; - service_record[strings::service_id] = "This is a service ID"; - service_record[strings::service_published] = true; - service_record[strings::service_active] = true; + smart_objects::SmartObject service_record = + application_manager_.GetAppServiceManager().PublishAppService(manifest); response_params[strings::app_service_record] = service_record; diff --git a/src/components/application_manager/src/app_service_manager.cc b/src/components/application_manager/src/app_service_manager.cc index 2c5a31e86e..d11203feec 100644 --- a/src/components/application_manager/src/app_service_manager.cc +++ b/src/components/application_manager/src/app_service_manager.cc @@ -58,12 +58,17 @@ AppServiceManager::~AppServiceManager() { LOG4CXX_AUTO_TRACE(logger_); } -bool AppServiceManager::PublishAppService( +smart_objects::SmartObject AppServiceManager::PublishAppService( const smart_objects::SmartObject& manifest) { std::string service_id = "SERVICE_UUID"; // TODO: Generate UUID - published_services_.insert( - std::pair(service_id, manifest)); - return true; + smart_objects::SmartObject service_record; + service_record[strings::service_manifest] = manifest; + service_record[strings::service_id] = service_id; + service_record[strings::service_published] = true; + service_record[strings::service_active] = true; + published_services_.insert(std::pair( + service_id, service_record)); + return service_record; } bool AppServiceManager::UnpublishAppService(const std::string service_id) { diff --git a/src/components/include/application_manager/application_manager.h b/src/components/include/application_manager/application_manager.h index adb47c8a99..b542a66b83 100644 --- a/src/components/include/application_manager/application_manager.h +++ b/src/components/include/application_manager/application_manager.h @@ -189,7 +189,7 @@ class ApplicationManager { virtual plugin_manager::RPCPluginManager& GetPluginManager() = 0; - virtual application_manager::AppServiceManager& GetAppServiceManager() = 0; + virtual AppServiceManager& GetAppServiceManager() = 0; #ifdef BUILD_TESTS virtual void SetPluginManager( diff --git a/src/components/include/test/application_manager/mock_application_manager.h b/src/components/include/test/application_manager/mock_application_manager.h index 582884e1e7..04029adda3 100644 --- a/src/components/include/test/application_manager/mock_application_manager.h +++ b/src/components/include/test/application_manager/mock_application_manager.h @@ -59,7 +59,6 @@ namespace test { namespace components { namespace application_manager_test { using application_manager::plugin_manager::RPCPluginManager; -using application_manager::AppServiceManager; class MockApplicationManager : public application_manager::ApplicationManager { public: @@ -92,7 +91,7 @@ class MockApplicationManager : public application_manager::ApplicationManager { MOCK_METHOD1(SetPluginManager, void(std::unique_ptr& plugin_manager)); - MOCK_METHOD0(GetAppServiceManager, AppServiceManager&()); + MOCK_METHOD0(GetAppServiceManager, application_manager::AppServiceManager&()); MOCK_CONST_METHOD1( application_by_hmi_app, -- cgit v1.2.1 From f1c9edcbcf2822cc93a38810a592bc6412070214 Mon Sep 17 00:00:00 2001 From: JackLivio Date: Thu, 24 Jan 2019 10:57:15 -0500 Subject: OnAppServiceDataNotificationFromMobile check parameters --- .../on_app_service_data_notification_from_mobile.cc | 16 ++++++++++++++++ .../application_manager/src/policies/policy_handler.cc | 3 ++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/on_app_service_data_notification_from_mobile.cc b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/on_app_service_data_notification_from_mobile.cc index a7a8042fee..20036cc30a 100644 --- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/on_app_service_data_notification_from_mobile.cc +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/on_app_service_data_notification_from_mobile.cc @@ -67,6 +67,22 @@ void OnAppServiceDataNotificationFromMobile::Run() { LOG4CXX_AUTO_TRACE(logger_); LOG4CXX_DEBUG(logger_, "Received an OnAppServiceData"); MessageHelper::PrintSmartObject(*message_); + + std::string service_type = + (*message_)[strings::msg_params][strings::app_service_manifest] + [strings::service_type].asString(); + + ApplicationSharedPtr app = application_manager_.application(connection_key()); + + bool result = policy_handler_.CheckAppServiceParameters( + app->policy_app_id(), std::string(), service_type, {}); + + if (!result) { + LOG4CXX_DEBUG(logger_, + "Incorrect service type received in " + "OnAppServiceDataNotificationFromMobile"); + return; + } } } // namespace commands diff --git a/src/components/application_manager/src/policies/policy_handler.cc b/src/components/application_manager/src/policies/policy_handler.cc index b8da78aabf..480b8f0574 100644 --- a/src/components/application_manager/src/policies/policy_handler.cc +++ b/src/components/application_manager/src/policies/policy_handler.cc @@ -1957,7 +1957,8 @@ bool PolicyHandler::CheckAppServiceParameters( std::vector handled_rpcs = {}; this->GetAppServiceParameters( policy_app_id, service_name, service_type, handled_rpcs); - if (service_name != requested_service_name) { + if (!requested_service_name.empty() && + service_name != requested_service_name) { return false; } -- cgit v1.2.1 From cb01cd11870ce4642ba49f7b86d4bd45562f2f1d Mon Sep 17 00:00:00 2001 From: JackLivio Date: Thu, 24 Jan 2019 11:05:40 -0500 Subject: Check if handled_rpcs is null --- .../on_app_service_data_notification_from_mobile.cc | 2 +- .../application_manager/src/policies/policy_handler.cc | 16 +++++++++------- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/on_app_service_data_notification_from_mobile.cc b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/on_app_service_data_notification_from_mobile.cc index 20036cc30a..6a9dc8f1a7 100644 --- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/on_app_service_data_notification_from_mobile.cc +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/on_app_service_data_notification_from_mobile.cc @@ -75,7 +75,7 @@ void OnAppServiceDataNotificationFromMobile::Run() { ApplicationSharedPtr app = application_manager_.application(connection_key()); bool result = policy_handler_.CheckAppServiceParameters( - app->policy_app_id(), std::string(), service_type, {}); + app->policy_app_id(), std::string(), service_type, NULL); if (!result) { LOG4CXX_DEBUG(logger_, diff --git a/src/components/application_manager/src/policies/policy_handler.cc b/src/components/application_manager/src/policies/policy_handler.cc index 480b8f0574..cbe9dd6812 100644 --- a/src/components/application_manager/src/policies/policy_handler.cc +++ b/src/components/application_manager/src/policies/policy_handler.cc @@ -1966,13 +1966,15 @@ bool PolicyHandler::CheckAppServiceParameters( return false; } - for (auto requested_it = requested_handled_rpcs->begin(); - requested_it != requested_handled_rpcs->end(); - ++requested_it) { - auto find_result = std::find( - handled_rpcs.begin(), handled_rpcs.end(), requested_it->asUInt()); - if (find_result == handled_rpcs.end()) { - return false; + if (requested_handled_rpcs) { + for (auto requested_it = requested_handled_rpcs->begin(); + requested_it != requested_handled_rpcs->end(); + ++requested_it) { + auto find_result = std::find( + handled_rpcs.begin(), handled_rpcs.end(), requested_it->asUInt()); + if (find_result == handled_rpcs.end()) { + return false; + } } } return true; -- cgit v1.2.1 From a811be5a47658fc162357c9982bae789bcb53b6e Mon Sep 17 00:00:00 2001 From: JackLivio Date: Sat, 26 Jan 2019 20:33:29 -0500 Subject: Update app service structure in policies --- .../application_manager/policies/policy_handler.h | 8 +- .../src/policies/policy_handler.cc | 38 +++-- .../policies/policy_handler_interface.h | 4 +- .../policy/policy_regular/policy/policy_manager.h | 4 +- .../policy_regular/include/policy/cache_manager.h | 4 +- .../include/policy/cache_manager_interface.h | 4 +- .../include/policy/policy_manager_impl.h | 8 +- .../include/policy/policy_table/types.h | 30 +++- .../policy_regular/include/policy/sql_pt_queries.h | 12 +- .../include/policy/sql_pt_representation.h | 11 +- .../policy/policy_regular/src/cache_manager.cc | 17 +-- .../policy_regular/src/policy_manager_impl.cc | 7 +- .../policy_regular/src/policy_table/types.cc | 100 +++++++++----- .../policy_regular/src/policy_table/validation.cc | 4 + .../policy/policy_regular/src/sql_pt_queries.cc | 82 ++++++++--- .../policy_regular/src/sql_pt_representation.cc | 153 ++++++++++++++++----- 16 files changed, 331 insertions(+), 155 deletions(-) diff --git a/src/components/application_manager/include/application_manager/policies/policy_handler.h b/src/components/application_manager/include/application_manager/policies/policy_handler.h index 3aae747542..097a0ac563 100644 --- a/src/components/application_manager/include/application_manager/policies/policy_handler.h +++ b/src/components/application_manager/include/application_manager/policies/policy_handler.h @@ -447,11 +447,9 @@ class PolicyHandler : public PolicyHandlerInterface, void OnSetCloudAppProperties( const smart_objects::SmartObject& message) OVERRIDE; - void GetAppServiceParameters( - const std::string& policy_app_id, - std::string& service_name, - std::string& service_type, - std::vector& handled_rpcs) const OVERRIDE; + void GetAppServiceParameters(const std::string& policy_app_id, + policy_table::AppServiceParameters* + app_service_parameters) const OVERRIDE; bool CheckAppServiceParameters( const std::string& policy_app_id, diff --git a/src/components/application_manager/src/policies/policy_handler.cc b/src/components/application_manager/src/policies/policy_handler.cc index cbe9dd6812..22e4cc1131 100644 --- a/src/components/application_manager/src/policies/policy_handler.cc +++ b/src/components/application_manager/src/policies/policy_handler.cc @@ -1939,12 +1939,10 @@ void PolicyHandler::OnSetCloudAppProperties( void PolicyHandler::GetAppServiceParameters( const std::string& policy_app_id, - std::string& service_name, - std::string& service_type, - std::vector& handled_rpcs) const { + policy_table::AppServiceParameters* app_service_parameters) const { POLICY_LIB_CHECK_VOID(); - policy_manager_->GetAppServiceParameters( - policy_app_id, service_name, service_type, handled_rpcs); + policy_manager_->GetAppServiceParameters(policy_app_id, + app_service_parameters); } bool PolicyHandler::CheckAppServiceParameters( @@ -1955,18 +1953,32 @@ bool PolicyHandler::CheckAppServiceParameters( std::string service_name = std::string(); std::string service_type = std::string(); std::vector handled_rpcs = {}; - this->GetAppServiceParameters( - policy_app_id, service_name, service_type, handled_rpcs); - if (!requested_service_name.empty() && - service_name != requested_service_name) { + + policy_table::AppServiceParameters app_service_parameters = + policy_table::AppServiceParameters(); + this->GetAppServiceParameters(policy_app_id, &app_service_parameters); + + if (app_service_parameters.find(requested_service_type) == + app_service_parameters.end()) { + LOG4CXX_DEBUG(logger_, + "Disallowed service type: " << requested_service_type); return false; } - if (service_type != requested_service_type) { - return false; + if (!requested_service_name.empty()) { + auto service_names = + *(app_service_parameters[requested_service_type].service_names); + auto find_name_result = + std::find(service_names.begin(), + service_names.end(), + rpc::String<0, 255>(requested_service_name)); + if (find_name_result == service_names.end()) { + return false; + } } - if (requested_handled_rpcs) { + // todo handled rpcs check + /*if (requested_handled_rpcs) { for (auto requested_it = requested_handled_rpcs->begin(); requested_it != requested_handled_rpcs->end(); ++requested_it) { @@ -1976,7 +1988,7 @@ bool PolicyHandler::CheckAppServiceParameters( return false; } } - } + }*/ return true; } diff --git a/src/components/include/application_manager/policies/policy_handler_interface.h b/src/components/include/application_manager/policies/policy_handler_interface.h index 29776aa926..39118e9acc 100644 --- a/src/components/include/application_manager/policies/policy_handler_interface.h +++ b/src/components/include/application_manager/policies/policy_handler_interface.h @@ -490,9 +490,7 @@ class PolicyHandlerInterface { virtual void GetAppServiceParameters( const std::string& policy_app_id, - std::string& service_name, - std::string& service_type, - std::vector& handled_rpcs) const = 0; + policy_table::AppServiceParameters* app_service_parameters) const = 0; virtual bool CheckAppServiceParameters( const std::string& policy_app_id, diff --git a/src/components/include/policy/policy_regular/policy/policy_manager.h b/src/components/include/policy/policy_regular/policy/policy_manager.h index e62d12cd03..14f10c2036 100644 --- a/src/components/include/policy/policy_regular/policy/policy_manager.h +++ b/src/components/include/policy/policy_regular/policy/policy_manager.h @@ -583,9 +583,7 @@ class PolicyManager : public usage_statistics::StatisticsManager { */ virtual void GetAppServiceParameters( const std::string& policy_app_id, - std::string& service_name, - std::string& service_type, - std::vector& handled_rpcs) const = 0; + policy_table::AppServiceParameters* app_service_parameters) const = 0; /** * @brief OnAppRegisteredOnMobile allows to handle event when application were diff --git a/src/components/policy/policy_regular/include/policy/cache_manager.h b/src/components/policy/policy_regular/include/policy/cache_manager.h index 6d042f6ac3..e8d4e1782e 100644 --- a/src/components/policy/policy_regular/include/policy/cache_manager.h +++ b/src/components/policy/policy_regular/include/policy/cache_manager.h @@ -226,9 +226,7 @@ class CacheManager : public CacheManagerInterface { */ virtual void GetAppServiceParameters( const std::string& policy_app_id, - std::string& service_name, - std::string& service_type, - std::vector& handled_rpcs) const; + policy_table::AppServiceParameters* app_service_parameters) const; /** * @brief Allows to update 'vin' field in module_meta table. diff --git a/src/components/policy/policy_regular/include/policy/cache_manager_interface.h b/src/components/policy/policy_regular/include/policy/cache_manager_interface.h index 3973eca581..4345244e76 100644 --- a/src/components/policy/policy_regular/include/policy/cache_manager_interface.h +++ b/src/components/policy/policy_regular/include/policy/cache_manager_interface.h @@ -233,9 +233,7 @@ class CacheManagerInterface { */ virtual void GetAppServiceParameters( const std::string& policy_app_id, - std::string& service_name, - std::string& service_type, - std::vector& handled_rpcs) const = 0; + policy_table::AppServiceParameters* app_service_parameters) const = 0; /** * @brief Allows to update 'vin' field in module_meta table. diff --git a/src/components/policy/policy_regular/include/policy/policy_manager_impl.h b/src/components/policy/policy_regular/include/policy/policy_manager_impl.h index f4dd5d0870..8628b1a8a0 100644 --- a/src/components/policy/policy_regular/include/policy/policy_manager_impl.h +++ b/src/components/policy/policy_regular/include/policy/policy_manager_impl.h @@ -642,11 +642,9 @@ class PolicyManagerImpl : public PolicyManager { * @param handled_rpcs Vector of allowed function ids an app service provider * can handle */ - void GetAppServiceParameters( - const std::string& policy_app_id, - std::string& service_name, - std::string& service_type, - std::vector& handled_rpcs) const OVERRIDE; + void GetAppServiceParameters(const std::string& policy_app_id, + policy_table::AppServiceParameters* + app_service_parameters) const OVERRIDE; /** * @brief OnAppRegisteredOnMobile allows to handle event when application were diff --git a/src/components/policy/policy_regular/include/policy/policy_table/types.h b/src/components/policy/policy_regular/include/policy/policy_table/types.h index f2f99003e2..4b379ee7b6 100644 --- a/src/components/policy/policy_regular/include/policy/policy_table/types.h +++ b/src/components/policy/policy_regular/include/policy/policy_table/types.h @@ -50,6 +50,7 @@ struct MessageLanguages; struct MessageString; struct RpcParameters; struct Rpcs; +struct AppServiceInfo; } // namespace policy_table_interface_base } // namespace rpc @@ -98,7 +99,12 @@ typedef Array, 0, 255> RequestTypes; typedef Strings RequestSubTypes; -typedef Array, 0, 255> HandledRpcs; +typedef String<0, 255> AppServiceType; +typedef String<0, 255> AppServiceName; +typedef Array AppServiceNames; +typedef Array, 0, 255> AppServiceHandledRpcs; + +typedef Map AppServiceParameters; typedef Map RemoteRpcs; typedef Map AccessModules; @@ -107,6 +113,24 @@ typedef Array, 0, 255> ModuleTypes; typedef AppHMIType AppHmiType; typedef std::vector AppHmiTypes; +struct AppServiceInfo : CompositeType { + public: + Optional service_names; + Optional handled_rpcs; + AppServiceInfo(); + ~AppServiceInfo(); + AppServiceInfo(const Json::Value* value__); + Json::Value ToJsonValue() const; + bool is_valid() const; + bool is_initialized() const; + bool struct_empty() const; + virtual void SetPolicyTableType(PolicyTableType pt_type); + void ReportErrors(rpc::ValidationReport* report__) const; + + private: + bool Validate() const; +}; + struct PolicyBase : CompositeType { public: Enum priority; @@ -154,9 +178,7 @@ struct ApplicationParams : PolicyBase { Optional > cloud_transport_type; // App Service Params - Optional > service_name; - Optional > service_type; - Optional handled_rpcs; + Optional app_service_parameters; public: ApplicationParams(); diff --git a/src/components/policy/policy_regular/include/policy/sql_pt_queries.h b/src/components/policy/policy_regular/include/policy/sql_pt_queries.h index c910fbb3df..bada9a003a 100644 --- a/src/components/policy/policy_regular/include/policy/sql_pt_queries.h +++ b/src/components/policy/policy_regular/include/policy/sql_pt_queries.h @@ -66,7 +66,9 @@ extern const std::string kSelectNicknames; extern const std::string kSelectAppTypes; extern const std::string kSelectRequestTypes; extern const std::string kSelectRequestSubTypes; -extern const std::string kSelectHandledRpcs; +extern const std::string kSelectAppServiceTypes; +extern const std::string kSelectAppServiceNames; +extern const std::string kSelectAppServiceHandledRpcs; extern const std::string kSelectSecondsBetweenRetries; extern const std::string kSelectIgnitionCycles; extern const std::string kSelectKilometers; @@ -81,7 +83,9 @@ extern const std::string kInsertNickname; extern const std::string kInsertAppType; extern const std::string kInsertRequestType; extern const std::string kInsertRequestSubType; -extern const std::string kInsertHandledRpcs; +extern const std::string kInsertAppServiceTypes; +extern const std::string kInsertAppServiceNames; +extern const std::string kInsertAppServiceHandledRpcs; extern const std::string kInsertMessageType; extern const std::string kInsertLanguage; extern const std::string kInsertMessageString; @@ -102,7 +106,9 @@ extern const std::string kDeleteAppGroup; extern const std::string kDeleteApplication; extern const std::string kDeleteRequestType; extern const std::string kDeleteRequestSubType; -extern const std::string kDeleteHandledRpcs; +extern const std::string kDeleteAppServiceTypes; +extern const std::string kDeleteAppServiceNames; +extern const std::string kDeleteAppServiceHandledRpcs; extern const std::string kDeleteDevice; extern const std::string kIncrementIgnitionCycles; extern const std::string kResetIgnitionCycles; diff --git a/src/components/policy/policy_regular/include/policy/sql_pt_representation.h b/src/components/policy/policy_regular/include/policy/sql_pt_representation.h index f3167d252a..dfa318454b 100644 --- a/src/components/policy/policy_regular/include/policy/sql_pt_representation.h +++ b/src/components/policy/policy_regular/include/policy/sql_pt_representation.h @@ -133,8 +133,10 @@ class SQLPTRepresentation : public virtual PTRepresentation { bool GatherRequestSubType( const std::string& app_id, policy_table::RequestSubTypes* request_subtypes) const; - bool GatherHandledRpcs(const std::string& app_id, - policy_table::HandledRpcs* handled_rpcs) const; + bool GatherAppServiceParameters( + const std::string& app_id, + policy_table::AppServiceParameters* app_service_parameters) const; + bool GatherNickName(const std::string& app_id, policy_table::Strings* nicknames) const; @@ -173,8 +175,9 @@ class SQLPTRepresentation : public virtual PTRepresentation { bool SaveRequestSubType( const std::string& app_id, const policy_table::RequestSubTypes& request_subtypes); - bool SaveHandledRpcs(const std::string& app_id, - const policy_table::HandledRpcs& handled_rpcs); + bool SaveAppServiceParameters( + const std::string& app_id, + const policy_table::AppServiceParameters& app_service_parameters); public: bool UpdateRequired() const; diff --git a/src/components/policy/policy_regular/src/cache_manager.cc b/src/components/policy/policy_regular/src/cache_manager.cc index 9396534677..5abe4158f1 100644 --- a/src/components/policy/policy_regular/src/cache_manager.cc +++ b/src/components/policy/policy_regular/src/cache_manager.cc @@ -798,9 +798,7 @@ void CacheManager::SetHybridAppPreference( void CacheManager::GetAppServiceParameters( const std::string& policy_app_id, - std::string& service_name, - std::string& service_type, - std::vector& handled_rpcs) const { + policy_table::AppServiceParameters* app_service_parameters) const { LOG4CXX_AUTO_TRACE(logger_); const policy_table::ApplicationPolicies& policies = pt_->policy_table.app_policies_section.apps; @@ -808,17 +806,8 @@ void CacheManager::GetAppServiceParameters( policies.find(policy_app_id); if (policies.end() != policy_iter) { auto app_policy = (*policy_iter).second; - service_name = app_policy.service_name.is_initialized() - ? *app_policy.service_name - : std::string(); - service_type = app_policy.service_type.is_initialized() - ? *app_policy.service_type - : std::string(); - if (!app_policy.handled_rpcs.is_initialized()) { - return; - } - for (const auto& rpc : *(app_policy.handled_rpcs)) { - handled_rpcs.push_back(rpc); + if (app_policy.app_service_parameters.is_initialized()) { + *app_service_parameters = *(app_policy.app_service_parameters); } } } diff --git a/src/components/policy/policy_regular/src/policy_manager_impl.cc b/src/components/policy/policy_regular/src/policy_manager_impl.cc index 12dd322e6c..5f09d166b1 100644 --- a/src/components/policy/policy_regular/src/policy_manager_impl.cc +++ b/src/components/policy/policy_regular/src/policy_manager_impl.cc @@ -593,11 +593,8 @@ void PolicyManagerImpl::SetHybridAppPreference( void PolicyManagerImpl::GetAppServiceParameters( const std::string& policy_app_id, - std::string& service_name, - std::string& service_type, - std::vector& handled_rpcs) const { - cache_->GetAppServiceParameters( - policy_app_id, service_name, service_type, handled_rpcs); + policy_table::AppServiceParameters* app_service_parameters) const { + cache_->GetAppServiceParameters(policy_app_id, app_service_parameters); } void PolicyManagerImpl::CheckPermissions(const PTString& device_id, diff --git a/src/components/policy/policy_regular/src/policy_table/types.cc b/src/components/policy/policy_regular/src/policy_table/types.cc index e28b260f5f..ed8b5c58ac 100644 --- a/src/components/policy/policy_regular/src/policy_table/types.cc +++ b/src/components/policy/policy_regular/src/policy_table/types.cc @@ -150,6 +150,65 @@ void ApplicationPoliciesSection::SetPolicyTableType(PolicyTableType pt_type) { apps.SetPolicyTableType(pt_type); } +// AppServiceInfo methods +AppServiceInfo::AppServiceInfo() : CompositeType(kUninitialized) {} + +AppServiceInfo::~AppServiceInfo() {} + +AppServiceInfo::AppServiceInfo(const Json::Value* value__) + : CompositeType(InitHelper(value__, &Json::Value::isObject)) + , service_names(impl::ValueMember(value__, "service_names")) + , handled_rpcs(impl::ValueMember(value__, "handled_rpcs")) { +} // todo handled_rpcs struct + +Json::Value AppServiceInfo::ToJsonValue() const { + Json::Value result__(Json::objectValue); + impl::WriteJsonField("service_names", service_names, &result__); + impl::WriteJsonField("parameters", handled_rpcs, &result__); + return result__; +} + +bool AppServiceInfo::is_valid() const { + if (!service_names.is_valid()) { + return false; + } + if (!handled_rpcs.is_valid()) { + return false; + } + return Validate(); +} + +bool AppServiceInfo::is_initialized() const { + return (initialization_state__ != kUninitialized) || (!struct_empty()); +} + +bool AppServiceInfo::struct_empty() const { + if (service_names.is_initialized()) { + return false; + } + if (handled_rpcs.is_initialized()) { + return false; + } + return true; +} + +void AppServiceInfo::SetPolicyTableType(PolicyTableType pt_type) { + service_names.SetPolicyTableType(pt_type); + handled_rpcs.SetPolicyTableType(pt_type); +} + +void AppServiceInfo::ReportErrors(rpc::ValidationReport* report__) const { + if (struct_empty()) { + rpc::CompositeType::ReportErrors(report__); + } + if (!service_names.is_valid()) { + service_names.ReportErrors(&report__->ReportSubobject("service_names")); + } + if (!handled_rpcs.is_valid()) { + handled_rpcs.ReportErrors(&report__->ReportSubobject("handled_rpcs")); + } +} + // ApplicationParams methods ApplicationParams::ApplicationParams() : PolicyBase(), groups() {} @@ -174,9 +233,8 @@ ApplicationParams::ApplicationParams(const Json::Value* value__) , enabled(impl::ValueMember(value__, "enabled")) , auth_token(impl::ValueMember(value__, "auth_token")) , cloud_transport_type(impl::ValueMember(value__, "cloud_transport_type")) - , service_name(impl::ValueMember(value__, "service_name")) - , service_type(impl::ValueMember(value__, "service_type")) - , handled_rpcs(impl::ValueMember(value__, "handled_rpcs")) {} + , app_service_parameters( + impl::ValueMember(value__, "app_service_parameters")) {} Json::Value ApplicationParams::ToJsonValue() const { Json::Value result__(PolicyBase::ToJsonValue()); @@ -196,9 +254,8 @@ Json::Value ApplicationParams::ToJsonValue() const { impl::WriteJsonField("enabled", enabled, &result__); impl::WriteJsonField("auth_token", auth_token, &result__); impl::WriteJsonField("cloud_transport_type", cloud_transport_type, &result__); - impl::WriteJsonField("service_name", service_name, &result__); - impl::WriteJsonField("service_type", service_type, &result__); - impl::WriteJsonField("handled_rpcs", handled_rpcs, &result__); + impl::WriteJsonField( + "app_service_parameters", app_service_parameters, &result__); return result__; } @@ -245,13 +302,7 @@ bool ApplicationParams::is_valid() const { if (!hybrid_app_preference.is_valid()) { return false; } - if (!service_name.is_valid()) { - return false; - } - if (!service_type.is_valid()) { - return false; - } - if (!handled_rpcs.is_valid()) { + if (!app_service_parameters.is_valid()) { return false; } return Validate(); @@ -307,13 +358,7 @@ bool ApplicationParams::struct_empty() const { if (hybrid_app_preference.is_initialized()) { return false; } - if (service_name.is_initialized()) { - return false; - } - if (service_type.is_initialized()) { - return false; - } - if (handled_rpcs.is_initialized()) { + if (app_service_parameters.is_initialized()) { return false; } return true; @@ -370,14 +415,9 @@ void ApplicationParams::ReportErrors(rpc::ValidationReport* report__) const { moduleType.ReportErrors( &report__->ReportSubobject("hybrid_app_preference")); } - if (!service_name.is_valid()) { - service_name.ReportErrors(&report__->ReportSubobject("service_name")); - } - if (!service_type.is_valid()) { - service_type.ReportErrors(&report__->ReportSubobject("service_type")); - } - if (!handled_rpcs.is_valid()) { - handled_rpcs.ReportErrors(&report__->ReportSubobject("handled_rpcs")); + if (!app_service_parameters.is_valid()) { + app_service_parameters.ReportErrors( + &report__->ReportSubobject("app_service_parameters")); } } @@ -395,9 +435,7 @@ void ApplicationParams::SetPolicyTableType(PolicyTableType pt_type) { enabled.SetPolicyTableType(pt_type); cloud_transport_type.SetPolicyTableType(pt_type); hybrid_app_preference.SetPolicyTableType(pt_type); - service_name.SetPolicyTableType(pt_type); - service_type.SetPolicyTableType(pt_type); - handled_rpcs.SetPolicyTableType(pt_type); + app_service_parameters.SetPolicyTableType(pt_type); } // RpcParameters methods diff --git a/src/components/policy/policy_regular/src/policy_table/validation.cc b/src/components/policy/policy_regular/src/policy_table/validation.cc index 714dfaae5a..6804b1266f 100644 --- a/src/components/policy/policy_regular/src/policy_table/validation.cc +++ b/src/components/policy/policy_regular/src/policy_table/validation.cc @@ -177,6 +177,10 @@ bool ApplicationParams::ValidateModuleTypes() const { return true; } +bool AppServiceInfo::Validate() const { + return true; // todo add validation +} + bool ApplicationParams::Validate() const { return ValidateModuleTypes(); } diff --git a/src/components/policy/policy_regular/src/sql_pt_queries.cc b/src/components/policy/policy_regular/src/sql_pt_queries.cc index 9027863e22..b467ae824a 100644 --- a/src/components/policy/policy_regular/src/sql_pt_queries.cc +++ b/src/components/policy/policy_regular/src/sql_pt_queries.cc @@ -142,8 +142,6 @@ const std::string kCreateSchema = " `enabled` BOOLEAN, " " `auth_token` VARCHAR(65535), " " `cloud_transport_type` VARCHAR(255), " - " `service_name` VARCHAR(255), " - " `service_type` VARCHAR(255), " " `remote_control_denied` BOOLEAN NOT NULL DEFAULT 0, " " CONSTRAINT `fk_application_hmi_level1` " " FOREIGN KEY(`default_hmi`) " @@ -289,14 +287,30 @@ const std::string kCreateSchema = " FOREIGN KEY(`application_id`) " " REFERENCES `application`(`id`) " "); " - "CREATE TABLE IF NOT EXISTS `handled_rpcs`( " - " `handled_rpcs` INTEGER, " + "CREATE TABLE IF NOT EXISTS `app_service_types`( " + " `id` INTEGER PRIMARY KEY NOT NULL, " + " `service_type` VARCHAR(50), " " `application_id` VARCHAR(45) NOT NULL COLLATE NOCASE, " - " PRIMARY KEY(`handled_rpcs`,`application_id`), " - " CONSTRAINT `fk_handled_rpcs_app_id` " + " CONSTRAINT `fk_service_type_app_id` " " FOREIGN KEY(`application_id`) " " REFERENCES `application`(`id`) " "); " + "CREATE TABLE IF NOT EXISTS `app_service_names`( " + " `service_type_id` INTEGER NOT NULL, " + " `service_name` VARCHAR(45), " + " PRIMARY KEY(`service_name`,`service_type_id`), " + " CONSTRAINT `fk_service_name_service_type_id` " + " FOREIGN KEY(`service_type_id`) " + " REFERENCES `app_service_types`(`id`) " + "); " + "CREATE TABLE IF NOT EXISTS `app_service_handled_rpcs`( " + " `service_type_id` INTEGER NOT NULL, " + " `function_id` INTEGER, " + " PRIMARY KEY(`function_id`,`service_type_id`), " + " CONSTRAINT `fk_function_id_service_type_id` " + " FOREIGN KEY(`service_type_id`) " + " REFERENCES `app_service_types`(`id`) " + "); " "CREATE INDEX IF NOT EXISTS `app_type.fk_app_type_application1_idx` " " ON `app_type`(`application_id` COLLATE NOCASE); " "CREATE TABLE IF NOT EXISTS `consent_group`( " @@ -477,7 +491,9 @@ const std::string kDropSchema = "DROP TABLE IF EXISTS `app_type`; " "DROP TABLE IF EXISTS `request_type`; " "DROP TABLE IF EXISTS `request_subtype`; " - "DROP TABLE IF EXISTS `handled_rpcs`; " + "DROP TABLE IF EXISTS `app_service_types`; " + "DROP TABLE IF EXISTS `app_service_names`; " + "DROP TABLE IF EXISTS `app_service_handled_rpcs`; " "DROP INDEX IF EXISTS `nickname.fk_nickname_application1_idx`; " "DROP TABLE IF EXISTS `nickname`; " "DROP INDEX IF EXISTS `app_level.fk_app_level_language2_idx`; " @@ -609,8 +625,8 @@ const std::string kInsertApplication = "INSERT OR IGNORE INTO `application` (`id`, `priority_value`, " "`is_revoked`, `memory_kb`, `heart_beat_timeout_ms`, `certificate`, " "`hybrid_app_preference_value`, `endpoint`, `enabled`, `auth_token`, " - "`cloud_transport_type`, `service_name`, `service_type`) VALUES " - "(?,?,?,?,?,?,?,?,?,?,?,?,?)"; + "`cloud_transport_type`) VALUES " + "(?,?,?,?,?,?,?,?,?,?,?)"; const std::string kInsertAppGroup = "INSERT INTO `app_group` (`application_id`, `functional_group_id`)" @@ -631,9 +647,19 @@ const std::string kInsertRequestSubType = "`request_subtype`) " "VALUES (?, ?)"; -const std::string kInsertHandledRpcs = - "INSERT INTO `handled_rpcs` (`application_id`, " - "`handled_rpcs`) " +const std::string kInsertAppServiceTypes = + "INSERT INTO `app_service_types` (`id`, " + "`service_type`, `application_id`) " + "VALUES (?, ?, ?)"; + +const std::string kInsertAppServiceNames = + "INSERT INTO `app_service_names` (`service_type_id`, " + "`service_name`) " + "VALUES (?, ?)"; + +const std::string kInsertAppServiceHandledRpcs = + "INSERT INTO `app_service_handled_rpcs` (`service_type_id`, " + "`function_id`) " "VALUES (?, ?)"; const std::string kUpdateVersion = "UPDATE `version` SET `number`= ?"; @@ -725,8 +751,7 @@ const std::string kSelectUserMsgsVersion = const std::string kSelectAppPolicies = "SELECT `id`, `priority_value`, `memory_kb`, " " `heart_beat_timeout_ms`, `certificate`, `hybrid_app_preference_value`, " - " `endpoint`, `enabled`, `auth_token`, `cloud_transport_type`, " - "`service_name`, `service_type` FROM " + " `endpoint`, `enabled`, `auth_token`, `cloud_transport_type` FROM " " `application`"; const std::string kCollectFriendlyMsg = "SELECT * FROM `message`"; @@ -754,11 +779,21 @@ const std::string kSelectRequestSubTypes = "`application_id` " "= ?"; -const std::string kSelectHandledRpcs = - "SELECT DISTINCT `handled_rpcs` FROM `handled_rpcs` WHERE " +const std::string kSelectAppServiceTypes = + "SELECT `id`, `service_type`` FROM `app_service_types` WHERE " "`application_id` " "= ?"; +const std::string kSelectAppServiceNames = + "SELECT DISTINCT `service_name` FROM `app_service_names` WHERE " + "`service_type_id` " + "= ?"; + +const std::string kSelectAppServiceHandledRpcs = + "SELECT DISTINCT `function_id` FROM `app_service_handled_rpcs` WHERE " + "`service_type_id` " + "= ?"; + const std::string kSelectSecondsBetweenRetries = "SELECT `value` FROM `seconds_between_retry` ORDER BY `index`"; @@ -806,7 +841,12 @@ const std::string kDeleteRequestType = "DELETE FROM `request_type`"; const std::string kDeleteRequestSubType = "DELETE FROM `request_subtype`"; -const std::string kDeleteHandledRpcs = "DELETE FROM `handled_rpcs`"; +const std::string kDeleteAppServiceTypes = "DELETE FROM `app_service_types`"; + +const std::string kDeleteAppServiceNames = "DELETE FROM `app_service_names`"; + +const std::string kDeleteAppServiceHandledRpcs = + "DELETE FROM `app_service_handled_rpcs`"; const std::string kSelectApplicationRevoked = "SELECT `is_revoked` FROM `application` WHERE `id` = ?"; @@ -834,16 +874,14 @@ const std::string kInsertApplicationFull = " `default_hmi`, `priority_value`, `is_revoked`, `is_default`, " " `is_predata`, `memory_kb`, `heart_beat_timeout_ms`, " " `certificate`, `hybrid_app_preference_value`, `endpoint`, `enabled`, " - " `auth_token`, `cloud_transport_type`, `service_name`, " - "`service_type`) " - " VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"; + " `auth_token`, `cloud_transport_type`) " + " VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"; const std::string kSelectApplicationFull = "SELECT `keep_context`, `steal_focus`, `default_hmi`, `priority_value`, " " `is_revoked`, `is_default`, `is_predata`, `memory_kb`," " `heart_beat_timeout_ms`, `certificate`, `hybrid_app_preference_value`, " - " `endpoint`, `enabled`, `auth_token`, `cloud_transport_type`, " - "`service_name`, `service_type` " + " `endpoint`, `enabled`, `auth_token`, `cloud_transport_type` " "FROM `application` " "WHERE `id` = " "?"; diff --git a/src/components/policy/policy_regular/src/sql_pt_representation.cc b/src/components/policy/policy_regular/src/sql_pt_representation.cc index 4e144d4e69..6656bb3162 100644 --- a/src/components/policy/policy_regular/src/sql_pt_representation.cc +++ b/src/components/policy/policy_regular/src/sql_pt_representation.cc @@ -734,10 +734,6 @@ bool SQLPTRepresentation::GatherApplicationPoliciesSection( *params.auth_token = query.GetString(8); *params.cloud_transport_type = query.GetString(9); - // AppService Parameters - *params.service_name = query.GetString(10); - *params.service_type = query.GetString(11); - const auto& gather_app_id = ((*policies).apps[app_id].is_string()) ? (*policies).apps[app_id].get_string() : app_id; @@ -770,7 +766,8 @@ bool SQLPTRepresentation::GatherApplicationPoliciesSection( return false; } - if (!GatherHandledRpcs(gather_app_id, &*params.handled_rpcs)) { + if (!GatherAppServiceParameters(gather_app_id, + &*params.app_service_parameters)) { return false; } @@ -950,6 +947,21 @@ bool SQLPTRepresentation::SaveApplicationPoliciesSection( return false; } + if (!query_delete.Exec(sql_pt::kDeleteAppServiceHandledRpcs)) { + LOG4CXX_WARN(logger_, "Incorrect delete from handled rpcs."); + return false; + } + + if (!query_delete.Exec(sql_pt::kDeleteAppServiceNames)) { + LOG4CXX_WARN(logger_, "Incorrect delete from service names."); + return false; + } + + if (!query_delete.Exec(sql_pt::kDeleteAppServiceTypes)) { + LOG4CXX_WARN(logger_, "Incorrect delete from handled service types."); + return false; + } + // All predefined apps (e.g. default, pre_DataConsent) should be saved first, // otherwise another app with the predefined permissions can get incorrect // permissions @@ -1019,12 +1031,6 @@ bool SQLPTRepresentation::SaveSpecificAppPolicy( app.second.cloud_transport_type.is_initialized() ? app_query.Bind(10, *app.second.cloud_transport_type) : app_query.Bind(10); - app.second.service_name.is_initialized() - ? app_query.Bind(11, *app.second.service_name) - : app_query.Bind(11); - app.second.service_type.is_initialized() - ? app_query.Bind(12, *app.second.service_type) - : app_query.Bind(12); if (!app_query.Exec() || !app_query.Reset()) { LOG4CXX_WARN(logger_, "Incorrect insert into application."); @@ -1064,7 +1070,8 @@ bool SQLPTRepresentation::SaveSpecificAppPolicy( return false; } - if (!SaveHandledRpcs(app.first, *app.second.handled_rpcs)) { + if (!SaveAppServiceParameters(app.first, + *app.second.app_service_parameters)) { return false; } @@ -1227,25 +1234,66 @@ bool SQLPTRepresentation::SaveRequestSubType( return true; } -bool SQLPTRepresentation::SaveHandledRpcs( - const std::string& app_id, const policy_table::HandledRpcs& handled_rpcs) { +bool SQLPTRepresentation::SaveAppServiceParameters( + const std::string& app_id, + const policy_table::AppServiceParameters& app_service_parameters) { + LOG4CXX_INFO(logger_, "Save app service parameters"); utils::dbms::SQLQuery query(db()); - if (!query.Prepare(sql_pt::kInsertHandledRpcs)) { - LOG4CXX_WARN(logger_, "Incorrect insert statement for handled rpcs."); + + if (!query.Prepare(sql_pt::kInsertAppServiceTypes)) { + LOG4CXX_WARN(logger_, "Incorrect insert statement for app service types"); return false; } + policy_table::AppServiceParameters::const_iterator it; + for (it = app_service_parameters.begin(); it != app_service_parameters.end(); + ++it) { + // Create service type id from hashing app_id and service_type + std::string str_to_hash = std::string(app_id + it->first); + const long int id = abs(CacheManager::GenerateHash(str_to_hash)); + query.Bind(0, static_cast(id)); + query.Bind(1, it->first); + query.Bind(2, app_id); + if (!query.Exec() || !query.Reset()) { + LOG4CXX_WARN(logger_, "Insert execute failed for into app service types"); + return false; + } - policy_table::HandledRpcs::const_iterator it; - if (!handled_rpcs.empty()) { - LOG4CXX_TRACE(logger_, "Handled Rpcs are not empty."); - for (it = handled_rpcs.begin(); it != handled_rpcs.end(); ++it) { - query.Bind(0, app_id); + // Insert app names array into db + utils::dbms::SQLQuery service_name_query(db()); + if (!service_name_query.Prepare(sql_pt::kInsertAppServiceNames)) { + LOG4CXX_WARN(logger_, "Incorrect insert statement for app service names"); + return false; + } - // TODO: Bind does not like uint64_t. Only takes ints? Not sure why this - // is broken since seconds between retries is able to handle - query.Bind(1, static_cast(*it)); - if (!query.Exec() || !query.Reset()) { - LOG4CXX_WARN(logger_, "Incorrect insert into handled rpcs."); + auto app_service_names = it->second.service_names; + policy_table::AppServiceNames::const_iterator names_it; + for (names_it = app_service_names->begin(); + names_it != app_service_names->end(); + ++names_it) { + service_name_query.Bind(0, static_cast(id)); + service_name_query.Bind(1, *names_it); + if (!service_name_query.Exec() || !service_name_query.Reset()) { + LOG4CXX_WARN(logger_, "Incorrect insert into app service names"); + return false; + } + } + + // Insert handled rpcs array into db + utils::dbms::SQLQuery handled_rpcs_query(db()); + if (!handled_rpcs_query.Prepare(sql_pt::kInsertAppServiceHandledRpcs)) { + LOG4CXX_WARN(logger_, + "Incorrect insert statement for app service handled rpcs"); + return false; + } + + auto handled_rpcs = it->second.handled_rpcs; + policy_table::AppServiceHandledRpcs::const_iterator rpc_it; + for (rpc_it = handled_rpcs->begin(); rpc_it != handled_rpcs->end(); + ++rpc_it) { + handled_rpcs_query.Bind(0, static_cast(id)); + handled_rpcs_query.Bind(1, static_cast(*rpc_it)); + if (!handled_rpcs_query.Exec() || !handled_rpcs_query.Reset()) { + LOG4CXX_WARN(logger_, "Incorrect insert into app service handled rpcs"); return false; } } @@ -1691,19 +1739,50 @@ bool SQLPTRepresentation::GatherRequestSubType( return true; } -bool SQLPTRepresentation::GatherHandledRpcs( - const std::string& app_id, policy_table::HandledRpcs* handled_rpcs) const { - utils::dbms::SQLQuery query(db()); - if (!query.Prepare(sql_pt::kSelectHandledRpcs)) { - LOG4CXX_WARN(logger_, "Incorrect select from handled rpcs."); +bool SQLPTRepresentation::GatherAppServiceParameters( + const std::string& app_id, + policy_table::AppServiceParameters* app_service_parameters) const { + LOG4CXX_INFO(logger_, "Gather app service info"); + utils::dbms::SQLQuery service_type_query(db()); + if (!service_type_query.Prepare(sql_pt::kSelectAppServiceTypes)) { + LOG4CXX_WARN(logger_, "Incorrect select from service_types"); return false; } - query.Bind(0, app_id); - while (query.Next()) { - const uint64_t rpc_id = query.GetInteger(0); - handled_rpcs->push_back(rpc_id); + utils::dbms::SQLQuery service_name_query(db()); + if (!service_name_query.Prepare(sql_pt::kSelectAppServiceNames)) { + LOG4CXX_WARN(logger_, "Incorrect select all from app_service_names"); + return false; } + + utils::dbms::SQLQuery handled_rpcs_query(db()); + if (!handled_rpcs_query.Prepare(sql_pt::kSelectAppServiceHandledRpcs)) { + LOG4CXX_WARN(logger_, "Incorrect select all from app_service_handled_rpcs"); + return false; + } + + service_type_query.Bind(2, app_id); + while (service_type_query.Next()) { + const int service_type_id = service_type_query.GetInteger(0); + std::string service_type = service_type_query.GetString(1); + (*app_service_parameters)[service_type] = policy_table::AppServiceInfo(); + + service_name_query.Bind(0, service_type_id); + while (service_name_query.Next()) { + (*app_service_parameters)[service_type].service_names->push_back( + service_name_query.GetString(0)); + } + + handled_rpcs_query.Bind(0, service_type_id); + while (handled_rpcs_query.Next()) { + (*app_service_parameters)[service_type].handled_rpcs->push_back( + handled_rpcs_query.GetInteger(0)); + } + + service_name_query.Reset(); + handled_rpcs_query.Reset(); + } + return true; } @@ -2058,8 +2137,8 @@ bool SQLPTRepresentation::SetDefaultPolicy(const std::string& app_id) { } policy_table::HandledRpcs handled_rpcs; - if (!GatherHandledRpcs(kDefaultId, &handled_rpcs) || - !SaveHandledRpcs(app_id, handled_rpcs)) { + if (!GatherAppServiceParameters(kDefaultId, &handled_rpcs) || + !SaveAppServiceParameters(app_id, handled_rpcs)) { return false; } -- cgit v1.2.1 From 852ec29c4b7395e4316be60e85488607387d6123 Mon Sep 17 00:00:00 2001 From: JackLivio Date: Sun, 27 Jan 2019 17:53:10 -0500 Subject: Add HandledRPC struct to policies --- .../src/policies/policy_handler.cc | 15 ++++++-- .../include/policy/policy_table/types.h | 26 ++++++++++++- .../policy_regular/src/policy_table/types.cc | 45 ++++++++++++++++++++++ .../policy_regular/src/policy_table/validation.cc | 4 ++ .../policy_regular/src/sql_pt_representation.cc | 12 +++--- 5 files changed, 91 insertions(+), 11 deletions(-) diff --git a/src/components/application_manager/src/policies/policy_handler.cc b/src/components/application_manager/src/policies/policy_handler.cc index 22e4cc1131..456c127025 100644 --- a/src/components/application_manager/src/policies/policy_handler.cc +++ b/src/components/application_manager/src/policies/policy_handler.cc @@ -1952,7 +1952,7 @@ bool PolicyHandler::CheckAppServiceParameters( smart_objects::SmartArray* requested_handled_rpcs) const { std::string service_name = std::string(); std::string service_type = std::string(); - std::vector handled_rpcs = {}; + std::vector handled_rpcs = {}; policy_table::AppServiceParameters app_service_parameters = policy_table::AppServiceParameters(); @@ -1978,17 +1978,24 @@ bool PolicyHandler::CheckAppServiceParameters( } // todo handled rpcs check - /*if (requested_handled_rpcs) { + if (requested_handled_rpcs) { + auto temp_rpcs = + *(app_service_parameters[requested_service_type].handled_rpcs); + for (auto handled_it = temp_rpcs.begin(); handled_it != temp_rpcs.end(); + ++handled_it) { + handled_rpcs.push_back(handled_it->function_id); + } + for (auto requested_it = requested_handled_rpcs->begin(); requested_it != requested_handled_rpcs->end(); ++requested_it) { auto find_result = std::find( - handled_rpcs.begin(), handled_rpcs.end(), requested_it->asUInt()); + handled_rpcs.begin(), handled_rpcs.end(), requested_it->asInt()); if (find_result == handled_rpcs.end()) { return false; } } - }*/ + } return true; } diff --git a/src/components/policy/policy_regular/include/policy/policy_table/types.h b/src/components/policy/policy_regular/include/policy/policy_table/types.h index 4b379ee7b6..b7522065bd 100644 --- a/src/components/policy/policy_regular/include/policy/policy_table/types.h +++ b/src/components/policy/policy_regular/include/policy/policy_table/types.h @@ -50,6 +50,7 @@ struct MessageLanguages; struct MessageString; struct RpcParameters; struct Rpcs; +struct AppServiceHandledRpc; struct AppServiceInfo; } // namespace policy_table_interface_base } // namespace rpc @@ -102,9 +103,9 @@ typedef Strings RequestSubTypes; typedef String<0, 255> AppServiceType; typedef String<0, 255> AppServiceName; typedef Array AppServiceNames; -typedef Array, 0, 255> AppServiceHandledRpcs; - +typedef Array AppServiceHandledRpcs; typedef Map AppServiceParameters; +typedef Integer FunctionIDInt; typedef Map RemoteRpcs; typedef Map AccessModules; @@ -113,10 +114,31 @@ typedef Array, 0, 255> ModuleTypes; typedef AppHMIType AppHmiType; typedef std::vector AppHmiTypes; +struct AppServiceHandledRpc : CompositeType { + public: + FunctionIDInt function_id; + + public: + AppServiceHandledRpc(); + ~AppServiceHandledRpc(); + AppServiceHandledRpc(const Json::Value* value__); + Json::Value ToJsonValue() const; + bool is_valid() const; + bool is_initialized() const; + bool struct_empty() const; + virtual void SetPolicyTableType(PolicyTableType pt_type); + void ReportErrors(rpc::ValidationReport* report__) const; + + private: + bool Validate() const; +}; + struct AppServiceInfo : CompositeType { public: Optional service_names; Optional handled_rpcs; + + public: AppServiceInfo(); ~AppServiceInfo(); AppServiceInfo(const Json::Value* value__); diff --git a/src/components/policy/policy_regular/src/policy_table/types.cc b/src/components/policy/policy_regular/src/policy_table/types.cc index ed8b5c58ac..d5991b5210 100644 --- a/src/components/policy/policy_regular/src/policy_table/types.cc +++ b/src/components/policy/policy_regular/src/policy_table/types.cc @@ -149,6 +149,51 @@ void ApplicationPoliciesSection::SetPolicyTableType(PolicyTableType pt_type) { device.SetPolicyTableType(pt_type); apps.SetPolicyTableType(pt_type); } +// Handled RPC Methods +AppServiceHandledRpc::AppServiceHandledRpc() : CompositeType(kUninitialized) {} + +AppServiceHandledRpc::~AppServiceHandledRpc() {} + +AppServiceHandledRpc::AppServiceHandledRpc(const Json::Value* value__) + : CompositeType(InitHelper(value__, &Json::Value::isObject)) + , function_id(impl::ValueMember(value__, "function_id")) {} + +Json::Value AppServiceHandledRpc::ToJsonValue() const { + Json::Value result__(Json::objectValue); + impl::WriteJsonField("function_id", function_id, &result__); + return result__; +} + +bool AppServiceHandledRpc::is_valid() const { + if (!function_id.is_valid()) { + return false; + } + return Validate(); +} + +bool AppServiceHandledRpc::is_initialized() const { + return (initialization_state__ != kUninitialized) || (!struct_empty()); +} + +bool AppServiceHandledRpc::struct_empty() const { + if (function_id.is_initialized()) { + return false; + } + return true; +} + +void AppServiceHandledRpc::SetPolicyTableType(PolicyTableType pt_type) { + function_id.SetPolicyTableType(pt_type); +} + +void AppServiceHandledRpc::ReportErrors(rpc::ValidationReport* report__) const { + if (struct_empty()) { + rpc::CompositeType::ReportErrors(report__); + } + if (!function_id.is_valid()) { + function_id.ReportErrors(&report__->ReportSubobject("function_id")); + } +} // AppServiceInfo methods AppServiceInfo::AppServiceInfo() : CompositeType(kUninitialized) {} diff --git a/src/components/policy/policy_regular/src/policy_table/validation.cc b/src/components/policy/policy_regular/src/policy_table/validation.cc index 6804b1266f..6c15d958f5 100644 --- a/src/components/policy/policy_regular/src/policy_table/validation.cc +++ b/src/components/policy/policy_regular/src/policy_table/validation.cc @@ -177,6 +177,10 @@ bool ApplicationParams::ValidateModuleTypes() const { return true; } +bool AppServiceHandledRpc::Validate() const { + return true; // todo add validation +} + bool AppServiceInfo::Validate() const { return true; // todo add validation } diff --git a/src/components/policy/policy_regular/src/sql_pt_representation.cc b/src/components/policy/policy_regular/src/sql_pt_representation.cc index 6656bb3162..dd2c38a72b 100644 --- a/src/components/policy/policy_regular/src/sql_pt_representation.cc +++ b/src/components/policy/policy_regular/src/sql_pt_representation.cc @@ -1291,7 +1291,7 @@ bool SQLPTRepresentation::SaveAppServiceParameters( for (rpc_it = handled_rpcs->begin(); rpc_it != handled_rpcs->end(); ++rpc_it) { handled_rpcs_query.Bind(0, static_cast(id)); - handled_rpcs_query.Bind(1, static_cast(*rpc_it)); + handled_rpcs_query.Bind(1, static_cast(rpc_it->function_id)); if (!handled_rpcs_query.Exec() || !handled_rpcs_query.Reset()) { LOG4CXX_WARN(logger_, "Incorrect insert into app service handled rpcs"); return false; @@ -1775,8 +1775,10 @@ bool SQLPTRepresentation::GatherAppServiceParameters( handled_rpcs_query.Bind(0, service_type_id); while (handled_rpcs_query.Next()) { + policy_table::AppServiceHandledRpc handled_rpc; + handled_rpc.function_id = handled_rpcs_query.GetInteger(0); (*app_service_parameters)[service_type].handled_rpcs->push_back( - handled_rpcs_query.GetInteger(0)); + handled_rpc); } service_name_query.Reset(); @@ -2136,9 +2138,9 @@ bool SQLPTRepresentation::SetDefaultPolicy(const std::string& app_id) { return false; } - policy_table::HandledRpcs handled_rpcs; - if (!GatherAppServiceParameters(kDefaultId, &handled_rpcs) || - !SaveAppServiceParameters(app_id, handled_rpcs)) { + policy_table::AppServiceParameters app_service_parameters; + if (!GatherAppServiceParameters(kDefaultId, &app_service_parameters) || + !SaveAppServiceParameters(app_id, app_service_parameters)) { return false; } -- cgit v1.2.1 From 38d1ad78ea7acab3e7aecc668680c1476f3bf7ec Mon Sep 17 00:00:00 2001 From: JackLivio Date: Sun, 27 Jan 2019 18:50:38 -0500 Subject: Fix pt query --- src/components/policy/policy_regular/src/policy_table/types.cc | 6 +++--- src/components/policy/policy_regular/src/sql_pt_queries.cc | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/components/policy/policy_regular/src/policy_table/types.cc b/src/components/policy/policy_regular/src/policy_table/types.cc index d5991b5210..2e164d3e14 100644 --- a/src/components/policy/policy_regular/src/policy_table/types.cc +++ b/src/components/policy/policy_regular/src/policy_table/types.cc @@ -279,7 +279,7 @@ ApplicationParams::ApplicationParams(const Json::Value* value__) , auth_token(impl::ValueMember(value__, "auth_token")) , cloud_transport_type(impl::ValueMember(value__, "cloud_transport_type")) , app_service_parameters( - impl::ValueMember(value__, "app_service_parameters")) {} + impl::ValueMember(value__, "app_services")) {} Json::Value ApplicationParams::ToJsonValue() const { Json::Value result__(PolicyBase::ToJsonValue()); @@ -300,7 +300,7 @@ Json::Value ApplicationParams::ToJsonValue() const { impl::WriteJsonField("auth_token", auth_token, &result__); impl::WriteJsonField("cloud_transport_type", cloud_transport_type, &result__); impl::WriteJsonField( - "app_service_parameters", app_service_parameters, &result__); + "app_services", app_service_parameters, &result__); return result__; } @@ -462,7 +462,7 @@ void ApplicationParams::ReportErrors(rpc::ValidationReport* report__) const { } if (!app_service_parameters.is_valid()) { app_service_parameters.ReportErrors( - &report__->ReportSubobject("app_service_parameters")); + &report__->ReportSubobject("app_services")); } } diff --git a/src/components/policy/policy_regular/src/sql_pt_queries.cc b/src/components/policy/policy_regular/src/sql_pt_queries.cc index b467ae824a..610a24eb19 100644 --- a/src/components/policy/policy_regular/src/sql_pt_queries.cc +++ b/src/components/policy/policy_regular/src/sql_pt_queries.cc @@ -780,7 +780,7 @@ const std::string kSelectRequestSubTypes = "= ?"; const std::string kSelectAppServiceTypes = - "SELECT `id`, `service_type`` FROM `app_service_types` WHERE " + "SELECT `id`, `service_type` FROM `app_service_types` WHERE " "`application_id` " "= ?"; -- cgit v1.2.1 From 476f1de934d912b6f2fb6bffbe9d3597b1240d5a Mon Sep 17 00:00:00 2001 From: ShobhitAd Date: Mon, 28 Jan 2019 23:45:22 -0500 Subject: Add PublishAppService to policies --- src/appMain/sdl_preloaded_pt.json | 12 +++++++++++- .../policy_external/include/policy/policy_table/enums.h | 5 +++++ .../policy/policy_external/src/policy_table/enums.cc | 5 +++++ .../policy_regular/include/policy/policy_table/enums.h | 5 +++++ .../policy/policy_regular/src/policy_table/enums.cc | 9 +++++++++ 5 files changed, 35 insertions(+), 1 deletion(-) diff --git a/src/appMain/sdl_preloaded_pt.json b/src/appMain/sdl_preloaded_pt.json index 3c84fc96bd..06ab56bc39 100644 --- a/src/appMain/sdl_preloaded_pt.json +++ b/src/appMain/sdl_preloaded_pt.json @@ -574,6 +574,16 @@ } } }, + "AppService":{ + "rpcs":{ + "PublishAppService":{ + "hmi_levels":["BACKGROUND", + "FULL", + "LIMITED", + "NONE"] + } + } + }, "RemoteControl": { "rpcs": { "ButtonPress": { @@ -2414,7 +2424,7 @@ "steal_focus": false, "priority": "NONE", "default_hmi": "NONE", - "groups": ["Base-4"], + "groups": ["Base-4", "AppService"], "RequestType": [], "RequestSubType": [] }, diff --git a/src/components/policy/policy_external/include/policy/policy_table/enums.h b/src/components/policy/policy_external/include/policy/policy_table/enums.h index 5b494629bb..0b571823f9 100644 --- a/src/components/policy/policy_external/include/policy/policy_table/enums.h +++ b/src/components/policy/policy_external/include/policy/policy_table/enums.h @@ -445,6 +445,11 @@ enum FunctionID { */ SetCloudAppPropertiesID = 50, + /** + * @brief PublishAppServiceID + */ + PublishAppServiceID = 52, + /** * @brief OnHMIStatusID. */ diff --git a/src/components/policy/policy_external/src/policy_table/enums.cc b/src/components/policy/policy_external/src/policy_table/enums.cc index d7d5a241de..72dd7aea72 100644 --- a/src/components/policy/policy_external/src/policy_table/enums.cc +++ b/src/components/policy/policy_external/src/policy_table/enums.cc @@ -1126,6 +1126,11 @@ bool EnumFromJsonString(const std::string& literal, FunctionID* result) { return true; } + if ("PublishAppService" == literal) { + *result = PublishAppServiceID; + return true; + } + if ("OnHMIStatus" == literal) { *result = OnHMIStatusID; return true; diff --git a/src/components/policy/policy_regular/include/policy/policy_table/enums.h b/src/components/policy/policy_regular/include/policy/policy_table/enums.h index 563e822a36..f8f4e9e029 100644 --- a/src/components/policy/policy_regular/include/policy/policy_table/enums.h +++ b/src/components/policy/policy_regular/include/policy/policy_table/enums.h @@ -431,6 +431,11 @@ enum FunctionID { */ SetCloudAppPropertiesID = 50, + /** + * @brief PublishAppServiceID + */ + PublishAppServiceID = 52, + /** * @brief OnHMIStatusID. */ diff --git a/src/components/policy/policy_regular/src/policy_table/enums.cc b/src/components/policy/policy_regular/src/policy_table/enums.cc index 91d0a6990f..f53b27776d 100644 --- a/src/components/policy/policy_regular/src/policy_table/enums.cc +++ b/src/components/policy/policy_regular/src/policy_table/enums.cc @@ -849,6 +849,8 @@ bool IsValidEnum(FunctionID val) { return true; case SetCloudAppPropertiesID: return true; + case PublishAppServiceID: + return true; case OnHMIStatusID: return true; case OnAppInterfaceUnregisteredID: @@ -998,6 +1000,8 @@ const char* EnumToJsonString(FunctionID val) { return "SendHapticData"; case SetCloudAppPropertiesID: return "SetCloudAppProperties"; + case PublishAppServiceID: + return "PublishAppService"; case OnHMIStatusID: return "OnHMIStatus"; case OnAppInterfaceUnregisteredID: @@ -1292,6 +1296,11 @@ bool EnumFromJsonString(const std::string& literal, FunctionID* result) { return true; } + if ("PublishAppService" == literal) { + *result = PublishAppServiceID; + return true; + } + if ("OnHMIStatus" == literal) { *result = OnHMIStatusID; return true; -- cgit v1.2.1 From c0bc15dbfcf78eaa3bcecb34b28fe98a5c9a1757 Mon Sep 17 00:00:00 2001 From: ShobhitAd Date: Tue, 29 Jan 2019 11:43:27 -0500 Subject: Style fix --- .../include/application_manager/application_manager_impl.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/components/application_manager/include/application_manager/application_manager_impl.h b/src/components/application_manager/include/application_manager/application_manager_impl.h index fcdc7dc966..f72b02e320 100644 --- a/src/components/application_manager/include/application_manager/application_manager_impl.h +++ b/src/components/application_manager/include/application_manager/application_manager_impl.h @@ -213,8 +213,7 @@ class ApplicationManagerImpl return *plugin_manager_; } - virtual AppServiceManager& GetAppServiceManager() - OVERRIDE { + virtual AppServiceManager& GetAppServiceManager() OVERRIDE { DCHECK(app_service_manager_); return *app_service_manager_; } -- cgit v1.2.1 From bfcae5a747ff5f72de9132c2e992e1bbaa7a23dc Mon Sep 17 00:00:00 2001 From: JackLivio Date: Tue, 29 Jan 2019 15:21:13 -0500 Subject: Update external policies for app services parameters --- .../application_manager/policies/policy_handler.h | 15 +- .../policies/policy_handler_interface.h | 12 ++ .../policy/policy_external/policy/policy_manager.h | 11 +- .../policy/policy_regular/policy/policy_manager.h | 5 +- .../policy_external/include/policy/cache_manager.h | 11 +- .../include/policy/cache_manager_interface.h | 11 +- .../include/policy/policy_manager_impl.h | 13 +- .../include/policy/policy_table/types.h | 52 ++++++- .../include/policy/sql_pt_queries.h | 12 +- .../include/policy/sql_pt_representation.h | 10 +- .../policy/policy_external/src/cache_manager.cc | 17 +-- .../policy_external/src/policy_manager_impl.cc | 7 +- .../policy_external/src/policy_table/types.cc | 149 ++++++++++++++----- .../policy_external/src/policy_table/validation.cc | 8 + .../src/sql_pt_ext_representation.cc | 36 +++-- .../policy/policy_external/src/sql_pt_queries.cc | 83 ++++++++--- .../policy_external/src/sql_pt_representation.cc | 164 +++++++++++++++------ .../policy_regular/include/policy/cache_manager.h | 5 +- .../include/policy/cache_manager_interface.h | 5 +- .../include/policy/policy_manager_impl.h | 5 +- .../policy_regular/src/policy_table/types.cc | 2 +- .../policy_regular/src/sql_pt_representation.cc | 4 - 22 files changed, 441 insertions(+), 196 deletions(-) diff --git a/src/components/application_manager/include/application_manager/policies/policy_handler.h b/src/components/application_manager/include/application_manager/policies/policy_handler.h index 097a0ac563..65432d3741 100644 --- a/src/components/application_manager/include/application_manager/policies/policy_handler.h +++ b/src/components/application_manager/include/application_manager/policies/policy_handler.h @@ -446,11 +446,22 @@ class PolicyHandler : public PolicyHandlerInterface, */ void OnSetCloudAppProperties( const smart_objects::SmartObject& message) OVERRIDE; - + + /** + * @brief Get app service parameters from the policy table + * @param policy_app_id Unique application id + * @param app_service_parameters Pointer to struct containing all app service information + */ void GetAppServiceParameters(const std::string& policy_app_id, policy_table::AppServiceParameters* app_service_parameters) const OVERRIDE; - + /** + * @brief Check app service parameters from an app against policies + * @param policy_app_id Unique application id + * @param requested_service_name Service name published by app service provider + * @param requested_service_type Service type published by app service provider + * @param requested_handled_rpcs Vector of requested function ids an app service wants to handle from consumers + */ bool CheckAppServiceParameters( const std::string& policy_app_id, const std::string& requested_service_name, diff --git a/src/components/include/application_manager/policies/policy_handler_interface.h b/src/components/include/application_manager/policies/policy_handler_interface.h index 39118e9acc..bfd956c4f2 100644 --- a/src/components/include/application_manager/policies/policy_handler_interface.h +++ b/src/components/include/application_manager/policies/policy_handler_interface.h @@ -488,10 +488,22 @@ class PolicyHandlerInterface { virtual void OnSetCloudAppProperties( const smart_objects::SmartObject& message) = 0; + /** + * @brief Get app service parameters from the policy table + * @param policy_app_id Unique application id + * @param app_service_parameters Pointer to struct containing all app service information + */ virtual void GetAppServiceParameters( const std::string& policy_app_id, policy_table::AppServiceParameters* app_service_parameters) const = 0; + /** + * @brief Check app service parameters from an app against policies + * @param policy_app_id Unique application id + * @param requested_service_name Service name published by app service provider + * @param requested_service_type Service type published by app service provider + * @param requested_handled_rpcs Vector of requested function ids an app service wants to handle from consumers + */ virtual bool CheckAppServiceParameters( const std::string& policy_app_id, const std::string& requested_service_name, diff --git a/src/components/include/policy/policy_external/policy/policy_manager.h b/src/components/include/policy/policy_external/policy/policy_manager.h index 96b2d5d659..ec659bd1b1 100644 --- a/src/components/include/policy/policy_external/policy/policy_manager.h +++ b/src/components/include/policy/policy_external/policy/policy_manager.h @@ -595,16 +595,11 @@ class PolicyManager : public usage_statistics::StatisticsManager { /** * @brief Get app service parameters from the policy table * @param policy_app_id Unique application id - * @param service_name Service name published by app service provider - * @param service_type Service type published by app service provider - * @param handled_rpcs Vector of allowed function ids an app service provider - * can handle + * @param app_service_parameters Pointer to struct containing all app service information */ virtual void GetAppServiceParameters( - const std::string& policy_app_id, - std::string& service_name, - std::string& service_type, - std::vector& handled_rpcs) const = 0; + const std::string& policy_app_id, + policy_table::AppServiceParameters* app_service_parameters) const = 0; /** * @brief Gets meta information diff --git a/src/components/include/policy/policy_regular/policy/policy_manager.h b/src/components/include/policy/policy_regular/policy/policy_manager.h index 14f10c2036..b544b9d346 100644 --- a/src/components/include/policy/policy_regular/policy/policy_manager.h +++ b/src/components/include/policy/policy_regular/policy/policy_manager.h @@ -576,10 +576,7 @@ class PolicyManager : public usage_statistics::StatisticsManager { /** * @brief Get app service parameters from the policy table * @param policy_app_id Unique application id - * @param service_name Service name published by app service provider - * @param service_type Service type published by app service provider - * @param handled_rpcs Vector of allowed function ids an app service provider - * can handle + * @param app_service_parameters Pointer to struct containing all app service information */ virtual void GetAppServiceParameters( const std::string& policy_app_id, diff --git a/src/components/policy/policy_external/include/policy/cache_manager.h b/src/components/policy/policy_external/include/policy/cache_manager.h index e31e3e6c34..d7094e19e5 100644 --- a/src/components/policy/policy_external/include/policy/cache_manager.h +++ b/src/components/policy/policy_external/include/policy/cache_manager.h @@ -231,16 +231,11 @@ class CacheManager : public CacheManagerInterface { /** * @brief Get app service parameters from the policy table * @param policy_app_id Unique application id - * @param service_name Service name published by app service provider - * @param service_type Service type published by app service provider - * @param handled_rpcs Vector of allowed function ids an app service provider - * can handle + * @param app_service_parameters Pointer to struct containing all app service information */ virtual void GetAppServiceParameters( - const std::string& policy_app_id, - std::string& service_name, - std::string& service_type, - std::vector& handled_rpcs) const; + const std::string& policy_app_id, + policy_table::AppServiceParameters* app_service_parameters) const; /** * @brief Allows to update 'vin' field in module_meta table. diff --git a/src/components/policy/policy_external/include/policy/cache_manager_interface.h b/src/components/policy/policy_external/include/policy/cache_manager_interface.h index 5b9fe5cfcb..4a904c5829 100644 --- a/src/components/policy/policy_external/include/policy/cache_manager_interface.h +++ b/src/components/policy/policy_external/include/policy/cache_manager_interface.h @@ -240,16 +240,11 @@ class CacheManagerInterface { /** * @brief Get app service parameters from the policy table * @param policy_app_id Unique application id - * @param service_name Service name published by app service provider - * @param service_type Service type published by app service provider - * @param handled_rpcs Vector of allowed function ids an app service provider - * can handle + * @param app_service_parameters Pointer to struct containing all app service information */ virtual void GetAppServiceParameters( - const std::string& policy_app_id, - std::string& service_name, - std::string& service_type, - std::vector& handled_rpcs) const = 0; + const std::string& policy_app_id, + policy_table::AppServiceParameters* app_service_parameters) const = 0; /** * @brief Allows to update 'vin' field in module_meta table. diff --git a/src/components/policy/policy_external/include/policy/policy_manager_impl.h b/src/components/policy/policy_external/include/policy/policy_manager_impl.h index b5a9709ecc..fe982ff59e 100644 --- a/src/components/policy/policy_external/include/policy/policy_manager_impl.h +++ b/src/components/policy/policy_external/include/policy/policy_manager_impl.h @@ -642,16 +642,11 @@ class PolicyManagerImpl : public PolicyManager { /** * @brief Get app service parameters from the policy table * @param policy_app_id Unique application id - * @param service_name Service name published by app service provider - * @param service_type Service type published by app service provider - * @param handled_rpcs Vector of allowed function ids an app service provider - * can handle + * @param app_service_parameters Pointer to struct containing all app service information */ - void GetAppServiceParameters( - const std::string& policy_app_id, - std::string& service_name, - std::string& service_type, - std::vector& handled_rpcs) const OVERRIDE; + void GetAppServiceParameters(const std::string& policy_app_id, + policy_table::AppServiceParameters* + app_service_parameters) const OVERRIDE; /** * @brief OnAppRegisteredOnMobile allows to handle event when application were diff --git a/src/components/policy/policy_external/include/policy/policy_table/types.h b/src/components/policy/policy_external/include/policy/policy_table/types.h index ed845b1191..e74091b8a3 100644 --- a/src/components/policy/policy_external/include/policy/policy_table/types.h +++ b/src/components/policy/policy_external/include/policy/policy_table/types.h @@ -52,6 +52,8 @@ struct MessageLanguages; struct MessageString; struct RpcParameters; struct Rpcs; +struct AppServiceHandledRpc; +struct AppServiceInfo; } // namespace policy_table_interface_base } // namespace rpc @@ -104,7 +106,12 @@ typedef Array, 0, 255> RequestsTypeArray; typedef Strings RequestSubTypes; -typedef Array, 0, 255> HandledRpcs; +typedef String<0, 255> AppServiceType; +typedef String<0, 255> AppServiceName; +typedef Array AppServiceNames; +typedef Array AppServiceHandledRpcs; +typedef Map AppServiceParameters; +typedef Integer FunctionIDInt; typedef Map RemoteRpcs; typedef Map AccessModules; @@ -113,6 +120,45 @@ typedef Array, 0, 255> ModuleTypes; typedef AppHMIType AppHmiType; typedef std::vector AppHmiTypes; +struct AppServiceHandledRpc : CompositeType { + public: + FunctionIDInt function_id; + + public: + AppServiceHandledRpc(); + ~AppServiceHandledRpc(); + AppServiceHandledRpc(const Json::Value* value__); + Json::Value ToJsonValue() const; + bool is_valid() const; + bool is_initialized() const; + bool struct_empty() const; + virtual void SetPolicyTableType(PolicyTableType pt_type); + void ReportErrors(rpc::ValidationReport* report__) const; + + private: + bool Validate() const; +}; + +struct AppServiceInfo : CompositeType { + public: + Optional service_names; + Optional handled_rpcs; + + public: + AppServiceInfo(); + ~AppServiceInfo(); + AppServiceInfo(const Json::Value* value__); + Json::Value ToJsonValue() const; + bool is_valid() const; + bool is_initialized() const; + bool struct_empty() const; + virtual void SetPolicyTableType(PolicyTableType pt_type); + void ReportErrors(rpc::ValidationReport* report__) const; + + private: + bool Validate() const; +}; + struct RequestTypes : public RequestsTypeArray { RequestTypes(); explicit RequestTypes(Json::Value* value); @@ -188,9 +234,7 @@ struct ApplicationParams : PolicyBase { Optional > cloud_transport_type; // App Service Params - Optional > service_name; - Optional > service_type; - Optional handled_rpcs; + Optional app_service_parameters; public: ApplicationParams(); diff --git a/src/components/policy/policy_external/include/policy/sql_pt_queries.h b/src/components/policy/policy_external/include/policy/sql_pt_queries.h index c66d878e5a..5382ff2d6b 100644 --- a/src/components/policy/policy_external/include/policy/sql_pt_queries.h +++ b/src/components/policy/policy_external/include/policy/sql_pt_queries.h @@ -66,7 +66,9 @@ extern const std::string kSelectNicknames; extern const std::string kSelectAppTypes; extern const std::string kSelectRequestTypes; extern const std::string kSelectRequestSubTypes; -extern const std::string kSelectHandledRpcs; +extern const std::string kSelectAppServiceTypes; +extern const std::string kSelectAppServiceNames; +extern const std::string kSelectAppServiceHandledRpcs; extern const std::string kSelectSecondsBetweenRetries; extern const std::string kSelectIgnitionCycles; extern const std::string kSelectKilometers; @@ -81,7 +83,9 @@ extern const std::string kInsertNickname; extern const std::string kInsertAppType; extern const std::string kInsertRequestType; extern const std::string kInsertRequestSubType; -extern const std::string kInsertHandledRpcs; +extern const std::string kInsertAppServiceTypes; +extern const std::string kInsertAppServiceNames; +extern const std::string kInsertAppServiceHandledRpcs; extern const std::string kInsertMessageType; extern const std::string kInsertLanguage; extern const std::string kInsertMessageString; @@ -103,7 +107,9 @@ extern const std::string kDeleteAppGroup; extern const std::string kDeleteApplication; extern const std::string kDeleteRequestType; extern const std::string kDeleteRequestSubType; -extern const std::string kDeleteHandledRpcs; +extern const std::string kDeleteAppServiceTypes; +extern const std::string kDeleteAppServiceNames; +extern const std::string kDeleteAppServiceHandledRpcs; extern const std::string kDeleteDevice; extern const std::string kIncrementIgnitionCycles; extern const std::string kResetIgnitionCycles; diff --git a/src/components/policy/policy_external/include/policy/sql_pt_representation.h b/src/components/policy/policy_external/include/policy/sql_pt_representation.h index ebc307cc8b..0d8e1c7ae9 100644 --- a/src/components/policy/policy_external/include/policy/sql_pt_representation.h +++ b/src/components/policy/policy_external/include/policy/sql_pt_representation.h @@ -134,8 +134,9 @@ class SQLPTRepresentation : public virtual PTRepresentation { bool GatherRequestSubType( const std::string& app_id, policy_table::RequestSubTypes* request_subtypes) const; - bool GatherHandledRpcs(const std::string& app_id, - policy_table::HandledRpcs* handled_rpcs) const; + bool GatherAppServiceParameters( + const std::string& app_id, + policy_table::AppServiceParameters* app_service_parameters) const; bool GatherNickName(const std::string& app_id, policy_table::Strings* nicknames) const; @@ -174,8 +175,9 @@ class SQLPTRepresentation : public virtual PTRepresentation { bool SaveRequestSubType( const std::string& app_id, const policy_table::RequestSubTypes& request_subtypes); - bool SaveHandledRpcs(const std::string& app_id, - const policy_table::HandledRpcs& handled_rpcs); + bool SaveAppServiceParameters( + const std::string& app_id, + const policy_table::AppServiceParameters& app_service_parameters); public: virtual std::string GetLockScreenIconUrl() const; diff --git a/src/components/policy/policy_external/src/cache_manager.cc b/src/components/policy/policy_external/src/cache_manager.cc index 663ac7b395..6d400cd0b4 100644 --- a/src/components/policy/policy_external/src/cache_manager.cc +++ b/src/components/policy/policy_external/src/cache_manager.cc @@ -1503,9 +1503,7 @@ void CacheManager::SetHybridAppPreference( void CacheManager::GetAppServiceParameters( const std::string& policy_app_id, - std::string& service_name, - std::string& service_type, - std::vector& handled_rpcs) const { + policy_table::AppServiceParameters* app_service_parameters) const { LOG4CXX_AUTO_TRACE(logger_); const policy_table::ApplicationPolicies& policies = pt_->policy_table.app_policies_section.apps; @@ -1513,17 +1511,8 @@ void CacheManager::GetAppServiceParameters( policies.find(policy_app_id); if (policies.end() != policy_iter) { auto app_policy = (*policy_iter).second; - service_name = app_policy.service_name.is_initialized() - ? *app_policy.service_name - : std::string(); - service_type = app_policy.service_type.is_initialized() - ? *app_policy.service_type - : std::string(); - if (!app_policy.handled_rpcs.is_initialized()) { - return; - } - for (const auto& rpc : *(app_policy.handled_rpcs)) { - handled_rpcs.push_back(rpc); + if (app_policy.app_service_parameters.is_initialized()) { + *app_service_parameters = *(app_policy.app_service_parameters); } } } diff --git a/src/components/policy/policy_external/src/policy_manager_impl.cc b/src/components/policy/policy_external/src/policy_manager_impl.cc index e50a3ecedd..404c48d2e4 100644 --- a/src/components/policy/policy_external/src/policy_manager_impl.cc +++ b/src/components/policy/policy_external/src/policy_manager_impl.cc @@ -774,11 +774,8 @@ void PolicyManagerImpl::SetHybridAppPreference( void PolicyManagerImpl::GetAppServiceParameters( const std::string& policy_app_id, - std::string& service_name, - std::string& service_type, - std::vector& handled_rpcs) const { - cache_->GetAppServiceParameters( - policy_app_id, service_name, service_type, handled_rpcs); + policy_table::AppServiceParameters* app_service_parameters) const { + cache_->GetAppServiceParameters(policy_app_id, app_service_parameters); } void PolicyManagerImpl::CheckPermissions(const PTString& app_id, diff --git a/src/components/policy/policy_external/src/policy_table/types.cc b/src/components/policy/policy_external/src/policy_table/types.cc index 8e822cb8d2..fb17391332 100644 --- a/src/components/policy/policy_external/src/policy_table/types.cc +++ b/src/components/policy/policy_external/src/policy_table/types.cc @@ -221,6 +221,112 @@ void ApplicationPoliciesSection::SetPolicyTableType(PolicyTableType pt_type) { apps.SetPolicyTableType(pt_type); } +// Handled RPC Methods +AppServiceHandledRpc::AppServiceHandledRpc() : CompositeType(kUninitialized) {} + +AppServiceHandledRpc::~AppServiceHandledRpc() {} + +AppServiceHandledRpc::AppServiceHandledRpc(const Json::Value* value__) + : CompositeType(InitHelper(value__, &Json::Value::isObject)) + , function_id(impl::ValueMember(value__, "function_id")) {} + +Json::Value AppServiceHandledRpc::ToJsonValue() const { + Json::Value result__(Json::objectValue); + impl::WriteJsonField("function_id", function_id, &result__); + return result__; +} + +bool AppServiceHandledRpc::is_valid() const { + if (!function_id.is_valid()) { + return false; + } + return Validate(); +} + +bool AppServiceHandledRpc::is_initialized() const { + return (initialization_state__ != kUninitialized) || (!struct_empty()); +} + +bool AppServiceHandledRpc::struct_empty() const { + if (function_id.is_initialized()) { + return false; + } + return true; +} + +void AppServiceHandledRpc::SetPolicyTableType(PolicyTableType pt_type) { + function_id.SetPolicyTableType(pt_type); +} + +void AppServiceHandledRpc::ReportErrors(rpc::ValidationReport* report__) const { + if (struct_empty()) { + rpc::CompositeType::ReportErrors(report__); + } + if (!function_id.is_valid()) { + function_id.ReportErrors(&report__->ReportSubobject("function_id")); + } +} + +// AppServiceInfo methods +AppServiceInfo::AppServiceInfo() : CompositeType(kUninitialized) {} + +AppServiceInfo::~AppServiceInfo() {} + +AppServiceInfo::AppServiceInfo(const Json::Value* value__) + : CompositeType(InitHelper(value__, &Json::Value::isObject)) + , service_names(impl::ValueMember(value__, "service_names")) + , handled_rpcs(impl::ValueMember(value__, "handled_rpcs")) { +} + +Json::Value AppServiceInfo::ToJsonValue() const { + Json::Value result__(Json::objectValue); + impl::WriteJsonField("service_names", service_names, &result__); + impl::WriteJsonField("parameters", handled_rpcs, &result__); + return result__; +} + +bool AppServiceInfo::is_valid() const { + if (!service_names.is_valid()) { + return false; + } + if (!handled_rpcs.is_valid()) { + return false; + } + return Validate(); +} + +bool AppServiceInfo::is_initialized() const { + return (initialization_state__ != kUninitialized) || (!struct_empty()); +} + +bool AppServiceInfo::struct_empty() const { + if (service_names.is_initialized()) { + return false; + } + if (handled_rpcs.is_initialized()) { + return false; + } + return true; +} + +void AppServiceInfo::SetPolicyTableType(PolicyTableType pt_type) { + service_names.SetPolicyTableType(pt_type); + handled_rpcs.SetPolicyTableType(pt_type); +} + +void AppServiceInfo::ReportErrors(rpc::ValidationReport* report__) const { + if (struct_empty()) { + rpc::CompositeType::ReportErrors(report__); + } + if (!service_names.is_valid()) { + service_names.ReportErrors(&report__->ReportSubobject("service_names")); + } + if (!handled_rpcs.is_valid()) { + handled_rpcs.ReportErrors(&report__->ReportSubobject("handled_rpcs")); + } +} + + // ApplicationParams methods ApplicationParams::ApplicationParams() : PolicyBase() {} @@ -248,9 +354,7 @@ ApplicationParams::ApplicationParams(const Json::Value* value__) , enabled(impl::ValueMember(value__, "enabled")) , auth_token(impl::ValueMember(value__, "auth_token")) , cloud_transport_type(impl::ValueMember(value__, "cloud_transport_type")) - , service_name(impl::ValueMember(value__, "service_name")) - , service_type(impl::ValueMember(value__, "service_type")) - , handled_rpcs(impl::ValueMember(value__, "handled_rpcs")) {} + , app_service_parameters(impl::ValueMember(value__, "app_services")) {} Json::Value ApplicationParams::ToJsonValue() const { Json::Value result__(PolicyBase::ToJsonValue()); @@ -269,9 +373,7 @@ Json::Value ApplicationParams::ToJsonValue() const { impl::WriteJsonField("enabled", enabled, &result__); impl::WriteJsonField("auth_token", auth_token, &result__); impl::WriteJsonField("cloud_transport_type", cloud_transport_type, &result__); - impl::WriteJsonField("service_name", service_name, &result__); - impl::WriteJsonField("service_type", service_type, &result__); - impl::WriteJsonField("handled_rpcs", handled_rpcs, &result__); + impl::WriteJsonField("app_services", app_service_parameters, &result__); return result__; } @@ -314,15 +416,9 @@ bool ApplicationParams::is_valid() const { if (!hybrid_app_preference.is_valid()) { return false; } - if (!service_name.is_valid()) { - return false; - } - if (!service_type.is_valid()) { - return false; - } - if (!handled_rpcs.is_valid()) { - return false; - } + if (!app_service_parameters.is_valid()) { + return false; + } return Validate(); } @@ -373,13 +469,7 @@ bool ApplicationParams::struct_empty() const { if (hybrid_app_preference.is_initialized()) { return false; } - if (service_name.is_initialized()) { - return false; - } - if (service_type.is_initialized()) { - return false; - } - if (handled_rpcs.is_initialized()) { + if (app_service_parameters.is_initialized()) { return false; } return true; @@ -449,14 +539,9 @@ void ApplicationParams::ReportErrors(rpc::ValidationReport* report__) const { moduleType.ReportErrors( &report__->ReportSubobject("hybrid_app_preference")); } - if (!service_name.is_valid()) { - service_name.ReportErrors(&report__->ReportSubobject("service_name")); - } - if (!service_type.is_valid()) { - service_type.ReportErrors(&report__->ReportSubobject("service_type")); - } - if (!handled_rpcs.is_valid()) { - handled_rpcs.ReportErrors(&report__->ReportSubobject("handled_rpcs")); + if (!app_service_parameters.is_valid()) { + app_service_parameters.ReportErrors( + &report__->ReportSubobject("app_services")); } } @@ -473,9 +558,7 @@ void ApplicationParams::SetPolicyTableType(PolicyTableType pt_type) { enabled.SetPolicyTableType(pt_type); cloud_transport_type.SetPolicyTableType(pt_type); hybrid_app_preference.SetPolicyTableType(pt_type); - service_name.SetPolicyTableType(pt_type); - service_type.SetPolicyTableType(pt_type); - handled_rpcs.SetPolicyTableType(pt_type); + app_service_parameters.SetPolicyTableType(pt_type); } // RpcParameters methods diff --git a/src/components/policy/policy_external/src/policy_table/validation.cc b/src/components/policy/policy_external/src/policy_table/validation.cc index 9b227615d8..77056e0d43 100644 --- a/src/components/policy/policy_external/src/policy_table/validation.cc +++ b/src/components/policy/policy_external/src/policy_table/validation.cc @@ -194,6 +194,14 @@ bool ApplicationParams::ValidateModuleTypes() const { return true; } +bool AppServiceHandledRpc::Validate() const { + return true; // todo add validation +} + +bool AppServiceInfo::Validate() const { + return true; // todo add validation +} + bool ApplicationParams::Validate() const { if (is_initialized()) { if (preconsented_groups.is_initialized()) { diff --git a/src/components/policy/policy_external/src/sql_pt_ext_representation.cc b/src/components/policy/policy_external/src/sql_pt_ext_representation.cc index 8f82ca0546..ce35b637a1 100644 --- a/src/components/policy/policy_external/src/sql_pt_ext_representation.cc +++ b/src/components/policy/policy_external/src/sql_pt_ext_representation.cc @@ -675,6 +675,22 @@ bool SQLPTExtRepresentation::SaveApplicationPoliciesSection( return false; } + if (!query_delete.Exec(sql_pt::kDeleteAppServiceHandledRpcs)) { + LOG4CXX_WARN(logger_, "Incorrect delete from handled rpcs."); + return false; + } + + if (!query_delete.Exec(sql_pt::kDeleteAppServiceNames)) { + LOG4CXX_WARN(logger_, "Incorrect delete from service names."); + return false; + } + + if (!query_delete.Exec(sql_pt::kDeleteAppServiceTypes)) { + LOG4CXX_WARN(logger_, "Incorrect delete from handled service types."); + return false; + } + + // First, all predefined apps (e.g. default, pre_DataConsent) should be saved, // otherwise another app with the predefined permissions can get incorrect // permissions @@ -729,6 +745,10 @@ bool SQLPTExtRepresentation::SaveSpecificAppPolicy( if (!SaveRequestSubType(app.first, *app.second.RequestSubType)) { return false; } + if (!SaveAppServiceParameters(app.first, + *app.second.app_service_parameters)) { + return false; + } // Stop saving other params, since predefined permissions already set return true; } @@ -771,12 +791,6 @@ bool SQLPTExtRepresentation::SaveSpecificAppPolicy( app.second.cloud_transport_type.is_initialized() ? app_query.Bind(13, *app.second.cloud_transport_type) : app_query.Bind(13); - app.second.service_name.is_initialized() - ? app_query.Bind(14, *app.second.service_name) - : app_query.Bind(14); - app.second.service_type.is_initialized() - ? app_query.Bind(15, *app.second.service_type) - : app_query.Bind(15); if (!app_query.Exec() || !app_query.Reset()) { LOG4CXX_WARN(logger_, "Incorrect insert into application."); @@ -811,7 +825,8 @@ bool SQLPTExtRepresentation::SaveSpecificAppPolicy( return false; } - if (!SaveHandledRpcs(app.first, *app.second.handled_rpcs)) { + if (!SaveAppServiceParameters(app.first, + *app.second.app_service_parameters)) { return false; } @@ -919,10 +934,6 @@ bool SQLPTExtRepresentation::GatherApplicationPoliciesSection( *params.auth_token = query.GetString(11); *params.cloud_transport_type = query.GetString(12); - // AppService Parameters - *params.service_name = query.GetString(13); - *params.service_type = query.GetString(14); - const auto& gather_app_id = ((*policies).apps[app_id].is_string()) ? (*policies).apps[app_id].get_string() : app_id; @@ -955,7 +966,8 @@ bool SQLPTExtRepresentation::GatherApplicationPoliciesSection( if (!GatherRequestSubType(gather_app_id, &*params.RequestSubType)) { return false; } - if (!GatherHandledRpcs(gather_app_id, &*params.handled_rpcs)) { + if (!GatherAppServiceParameters(gather_app_id, + &*params.app_service_parameters)) { return false; } GatherPreconsentedGroup(gather_app_id, &*params.preconsented_groups); diff --git a/src/components/policy/policy_external/src/sql_pt_queries.cc b/src/components/policy/policy_external/src/sql_pt_queries.cc index 1cf38e64c9..8190a6e4ca 100644 --- a/src/components/policy/policy_external/src/sql_pt_queries.cc +++ b/src/components/policy/policy_external/src/sql_pt_queries.cc @@ -156,8 +156,6 @@ const std::string kCreateSchema = " `enabled` BOOLEAN, " " `auth_token` VARCHAR(65535), " " `cloud_transport_type` VARCHAR(255), " - " `service_name` VARCHAR(255), " - " `service_type` VARCHAR(255), " " `remote_control_denied` BOOLEAN NOT NULL DEFAULT 0, " " CONSTRAINT `fk_application_hmi_level1` " " FOREIGN KEY(`default_hmi`) " @@ -303,14 +301,30 @@ const std::string kCreateSchema = " FOREIGN KEY(`application_id`) " " REFERENCES `application`(`id`) " "); " - "CREATE TABLE IF NOT EXISTS `handled_rpcs`( " - " `handled_rpcs` INTEGER, " + "CREATE TABLE IF NOT EXISTS `app_service_types`( " + " `id` INTEGER PRIMARY KEY NOT NULL, " + " `service_type` VARCHAR(50), " " `application_id` VARCHAR(45) NOT NULL COLLATE NOCASE, " - " PRIMARY KEY(`handled_rpcs`,`application_id`), " - " CONSTRAINT `fk_handled_rpcs_app_id` " + " CONSTRAINT `fk_service_type_app_id` " " FOREIGN KEY(`application_id`) " " REFERENCES `application`(`id`) " "); " + "CREATE TABLE IF NOT EXISTS `app_service_names`( " + " `service_type_id` INTEGER NOT NULL, " + " `service_name` VARCHAR(45), " + " PRIMARY KEY(`service_name`,`service_type_id`), " + " CONSTRAINT `fk_service_name_service_type_id` " + " FOREIGN KEY(`service_type_id`) " + " REFERENCES `app_service_types`(`id`) " + "); " + "CREATE TABLE IF NOT EXISTS `app_service_handled_rpcs`( " + " `service_type_id` INTEGER NOT NULL, " + " `function_id` INTEGER, " + " PRIMARY KEY(`function_id`,`service_type_id`), " + " CONSTRAINT `fk_function_id_service_type_id` " + " FOREIGN KEY(`service_type_id`) " + " REFERENCES `app_service_types`(`id`) " + "); " "CREATE INDEX IF NOT EXISTS `app_type.fk_app_type_application1_idx` " " ON `app_type`(`application_id` COLLATE NOCASE); " "CREATE TABLE IF NOT EXISTS `consent_group`( " @@ -519,7 +533,9 @@ const std::string kDropSchema = "DROP TABLE IF EXISTS `app_type`; " "DROP TABLE IF EXISTS `request_type`; " "DROP TABLE IF EXISTS `request_subtype`; " - "DROP TABLE IF EXISTS `handled_rpcs`; " + "DROP TABLE IF EXISTS `app_service_types`; " + "DROP TABLE IF EXISTS `app_service_names`; " + "DROP TABLE IF EXISTS `app_service_handled_rpcs`; " "DROP INDEX IF EXISTS `nickname.fk_nickname_application1_idx`; " "DROP TABLE IF EXISTS `nickname`; " "DROP INDEX IF EXISTS `app_level.fk_app_level_language2_idx`; " @@ -660,8 +676,8 @@ const std::string kInsertApplication = "INSERT OR IGNORE INTO `application` (`id`, `priority_value`, " "`is_revoked`, `memory_kb`, `heart_beat_timeout_ms`, `certificate`, " "`hybrid_app_preference_value`, `endpoint`, `enabled`, `auth_token`, " - "`cloud_transport_type`, `service_name`, `service_type`) VALUES " - "(?,?,?,?,?,?,?,?,?,?,?,?,?)"; + "`cloud_transport_type`) VALUES " + "(?,?,?,?,?,?,?,?,?,?,?)"; const std::string kInsertAppGroup = "INSERT INTO `app_group` (`application_id`, `functional_group_id`)" @@ -682,9 +698,19 @@ const std::string kInsertRequestSubType = "`request_subtype`) " "VALUES (?, ?)"; -const std::string kInsertHandledRpcs = - "INSERT INTO `handled_rpcs` (`application_id`, " - "`handled_rpcs`) " +const std::string kInsertAppServiceTypes = + "INSERT INTO `app_service_types` (`id`, " + "`service_type`, `application_id`) " + "VALUES (?, ?, ?)"; + +const std::string kInsertAppServiceNames = + "INSERT INTO `app_service_names` (`service_type_id`, " + "`service_name`) " + "VALUES (?, ?)"; + +const std::string kInsertAppServiceHandledRpcs = + "INSERT INTO `app_service_handled_rpcs` (`service_type_id`, " + "`function_id`) " "VALUES (?, ?)"; const std::string kUpdateVersion = "UPDATE `version` SET `number`= ?"; @@ -790,8 +816,7 @@ const std::string kSelectUserMsgsVersion = const std::string kSelectAppPolicies = "SELECT `id`, `priority_value`, `memory_kb`, " " `heart_beat_timeout_ms`, `certificate`, `hybrid_app_preference_value`, " - " `endpoint`, `enabled`, `auth_token`, `cloud_transport_type`, " - "`service_name`, `service_type` FROM " + " `endpoint`, `enabled`, `auth_token`, `cloud_transport_type` FROM " " `application`"; const std::string kCollectFriendlyMsg = "SELECT * FROM `message`"; @@ -819,11 +844,21 @@ const std::string kSelectRequestSubTypes = "`application_id` " "= ?"; -const std::string kSelectHandledRpcs = - "SELECT DISTINCT `handled_rpcs` FROM `handled_rpcs` WHERE " +const std::string kSelectAppServiceTypes = + "SELECT `id`, `service_type` FROM `app_service_types` WHERE " "`application_id` " "= ?"; +const std::string kSelectAppServiceNames = + "SELECT DISTINCT `service_name` FROM `app_service_names` WHERE " + "`service_type_id` " + "= ?"; + +const std::string kSelectAppServiceHandledRpcs = + "SELECT DISTINCT `function_id` FROM `app_service_handled_rpcs` WHERE " + "`service_type_id` " + "= ?"; + const std::string kSelectSecondsBetweenRetries = "SELECT `value` FROM `seconds_between_retry` ORDER BY `index`"; @@ -871,7 +906,13 @@ const std::string kDeleteRequestType = "DELETE FROM `request_type`"; const std::string kDeleteRequestSubType = "DELETE FROM `request_subtype`"; -const std::string kDeleteHandledRpcs = "DELETE FROM `handled_rpcs`"; +const std::string kDeleteAppServiceTypes = "DELETE FROM `app_service_types`"; + +const std::string kDeleteAppServiceNames = "DELETE FROM `app_service_names`"; + +const std::string kDeleteAppServiceHandledRpcs = + "DELETE FROM `app_service_handled_rpcs`"; + const std::string kSelectApplicationRevoked = "SELECT `is_revoked` FROM `application` WHERE `id` = ?"; @@ -899,16 +940,14 @@ const std::string kInsertApplicationFull = " `default_hmi`, `priority_value`, `is_revoked`, `is_default`, " " `is_predata`, `memory_kb`, `heart_beat_timeout_ms`, " " `certificate`, `hybrid_app_preference_value`, `endpoint`, `enabled`, " - " `auth_token`, `cloud_transport_type`, `service_name`, " - "`service_type`) " - " VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"; + " `auth_token`, `cloud_transport_type`) " + " VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"; const std::string kSelectApplicationFull = "SELECT `keep_context`, `steal_focus`, `default_hmi`, `priority_value`, " " `is_revoked`, `is_default`, `is_predata`, `memory_kb`," " `heart_beat_timeout_ms`, `certificate`, `hybrid_app_preference_value`, " - " `endpoint`, `enabled`, `auth_token`, `cloud_transport_type`, " - "`service_name`, `service_type` " + " `endpoint`, `enabled`, `auth_token`, `cloud_transport_type`" "FROM `application` " "WHERE `id` = ?"; diff --git a/src/components/policy/policy_external/src/sql_pt_representation.cc b/src/components/policy/policy_external/src/sql_pt_representation.cc index dbddd1bbd6..0897b11009 100644 --- a/src/components/policy/policy_external/src/sql_pt_representation.cc +++ b/src/components/policy/policy_external/src/sql_pt_representation.cc @@ -778,10 +778,6 @@ bool SQLPTRepresentation::GatherApplicationPoliciesSection( *params.auth_token = query.GetString(8); *params.cloud_transport_type = query.GetString(9); - // AppService Parameters - *params.service_name = query.GetString(10); - *params.service_type = query.GetString(11); - const auto& gather_app_id = ((*policies).apps[app_id].is_string()) ? (*policies).apps[app_id].get_string() : app_id; @@ -814,7 +810,7 @@ bool SQLPTRepresentation::GatherApplicationPoliciesSection( if (!GatherRequestSubType(gather_app_id, &*params.RequestSubType)) { return false; } - if (!GatherHandledRpcs(gather_app_id, &*params.handled_rpcs)) { + if (!GatherAppServiceParameters(gather_app_id, &*params.app_service_parameters)) { return false; } @@ -1008,6 +1004,21 @@ bool SQLPTRepresentation::SaveApplicationPoliciesSection( return false; } + if (!query_delete.Exec(sql_pt::kDeleteAppServiceHandledRpcs)) { + LOG4CXX_WARN(logger_, "Incorrect delete from handled rpcs."); + return false; + } + + if (!query_delete.Exec(sql_pt::kDeleteAppServiceNames)) { + LOG4CXX_WARN(logger_, "Incorrect delete from service names."); + return false; + } + + if (!query_delete.Exec(sql_pt::kDeleteAppServiceTypes)) { + LOG4CXX_WARN(logger_, "Incorrect delete from handled service types."); + return false; + } + // All predefined apps (e.g. default, pre_DataConsent) should be saved first, // otherwise another app with the predefined permissions can get incorrect // permissions @@ -1077,12 +1088,6 @@ bool SQLPTRepresentation::SaveSpecificAppPolicy( app.second.cloud_transport_type.is_initialized() ? app_query.Bind(10, *app.second.cloud_transport_type) : app_query.Bind(10); - app.second.service_name.is_initialized() - ? app_query.Bind(11, *app.second.service_name) - : app_query.Bind(11); - app.second.service_type.is_initialized() - ? app_query.Bind(12, *app.second.service_type) - : app_query.Bind(12); if (!app_query.Exec() || !app_query.Reset()) { LOG4CXX_WARN(logger_, "Incorrect insert into application."); @@ -1119,7 +1124,8 @@ bool SQLPTRepresentation::SaveSpecificAppPolicy( if (!SaveRequestType(app.first, *app.second.RequestType)) { return false; } - if (!SaveHandledRpcs(app.first, *app.second.handled_rpcs)) { + if (!SaveAppServiceParameters(app.first, + *app.second.app_service_parameters)) { return false; } @@ -1286,31 +1292,73 @@ bool SQLPTRepresentation::SaveRequestSubType( return true; } -bool SQLPTRepresentation::SaveHandledRpcs( - const std::string& app_id, const policy_table::HandledRpcs& handled_rpcs) { +bool SQLPTRepresentation::SaveAppServiceParameters( + const std::string& app_id, + const policy_table::AppServiceParameters& app_service_parameters) { + LOG4CXX_INFO(logger_, "Save app service parameters"); utils::dbms::SQLQuery query(db()); - if (!query.Prepare(sql_pt::kInsertHandledRpcs)) { - LOG4CXX_WARN(logger_, "Incorrect insert statement for handled rpcs."); + + if (!query.Prepare(sql_pt::kInsertAppServiceTypes)) { + LOG4CXX_WARN(logger_, "Incorrect insert statement for app service types"); return false; } + policy_table::AppServiceParameters::const_iterator it; + for (it = app_service_parameters.begin(); it != app_service_parameters.end(); + ++it) { + // Create service type id from hashing app_id and service_type + std::string str_to_hash = std::string(app_id + it->first); + const long int id = abs(CacheManager::GenerateHash(str_to_hash)); + query.Bind(0, static_cast(id)); + query.Bind(1, it->first); + query.Bind(2, app_id); + if (!query.Exec() || !query.Reset()) { + LOG4CXX_WARN(logger_, "Insert execute failed for into app service types"); + return false; + } - policy_table::HandledRpcs::const_iterator it; - if (!handled_rpcs.empty()) { - LOG4CXX_TRACE(logger_, "Handled Rpcs are not empty."); - for (it = handled_rpcs.begin(); it != handled_rpcs.end(); ++it) { - query.Bind(0, app_id); + // Insert app names array into db + utils::dbms::SQLQuery service_name_query(db()); + if (!service_name_query.Prepare(sql_pt::kInsertAppServiceNames)) { + LOG4CXX_WARN(logger_, "Incorrect insert statement for app service names"); + return false; + } - // TODO: Bind does not like uint64_t. Only takes ints? Not sure why this - // is broken since seconds between retries is able to handle - query.Bind(1, static_cast(*it)); - if (!query.Exec() || !query.Reset()) { - LOG4CXX_WARN(logger_, "Incorrect insert into handled rpcs."); + auto app_service_names = it->second.service_names; + policy_table::AppServiceNames::const_iterator names_it; + for (names_it = app_service_names->begin(); + names_it != app_service_names->end(); + ++names_it) { + service_name_query.Bind(0, static_cast(id)); + service_name_query.Bind(1, *names_it); + if (!service_name_query.Exec() || !service_name_query.Reset()) { + LOG4CXX_WARN(logger_, "Incorrect insert into app service names"); + return false; + } + } + + // Insert handled rpcs array into db + utils::dbms::SQLQuery handled_rpcs_query(db()); + if (!handled_rpcs_query.Prepare(sql_pt::kInsertAppServiceHandledRpcs)) { + LOG4CXX_WARN(logger_, + "Incorrect insert statement for app service handled rpcs"); + return false; + } + + auto handled_rpcs = it->second.handled_rpcs; + policy_table::AppServiceHandledRpcs::const_iterator rpc_it; + for (rpc_it = handled_rpcs->begin(); rpc_it != handled_rpcs->end(); + ++rpc_it) { + handled_rpcs_query.Bind(0, static_cast(id)); + handled_rpcs_query.Bind(1, static_cast(rpc_it->function_id)); + if (!handled_rpcs_query.Exec() || !handled_rpcs_query.Reset()) { + LOG4CXX_WARN(logger_, "Incorrect insert into app service handled rpcs"); return false; } } } return true; } + bool SQLPTRepresentation::SaveModuleMeta(const policy_table::ModuleMeta& meta) { // Section Module Meta is empty for SDL specific @@ -1738,21 +1786,55 @@ bool SQLPTRepresentation::GatherRequestSubType( return true; } -bool SQLPTRepresentation::GatherHandledRpcs( - const std::string& app_id, policy_table::HandledRpcs* handled_rpcs) const { - utils::dbms::SQLQuery query(db()); - if (!query.Prepare(sql_pt::kSelectHandledRpcs)) { - LOG4CXX_WARN(logger_, "Incorrect select from handled rpcs."); +bool SQLPTRepresentation::GatherAppServiceParameters( + const std::string& app_id, + policy_table::AppServiceParameters* app_service_parameters) const { + LOG4CXX_INFO(logger_, "Gather app service info"); + utils::dbms::SQLQuery service_type_query(db()); + if (!service_type_query.Prepare(sql_pt::kSelectAppServiceTypes)) { + LOG4CXX_WARN(logger_, "Incorrect select from service_types"); return false; } - query.Bind(0, app_id); - while (query.Next()) { - const uint64_t rpc_id = query.GetInteger(0); - handled_rpcs->push_back(rpc_id); + utils::dbms::SQLQuery service_name_query(db()); + if (!service_name_query.Prepare(sql_pt::kSelectAppServiceNames)) { + LOG4CXX_WARN(logger_, "Incorrect select all from app_service_names"); + return false; + } + + utils::dbms::SQLQuery handled_rpcs_query(db()); + if (!handled_rpcs_query.Prepare(sql_pt::kSelectAppServiceHandledRpcs)) { + LOG4CXX_WARN(logger_, "Incorrect select all from app_service_handled_rpcs"); + return false; } + + service_type_query.Bind(2, app_id); + while (service_type_query.Next()) { + const int service_type_id = service_type_query.GetInteger(0); + std::string service_type = service_type_query.GetString(1); + (*app_service_parameters)[service_type] = policy_table::AppServiceInfo(); + + service_name_query.Bind(0, service_type_id); + while (service_name_query.Next()) { + (*app_service_parameters)[service_type].service_names->push_back( + service_name_query.GetString(0)); + } + + handled_rpcs_query.Bind(0, service_type_id); + while (handled_rpcs_query.Next()) { + policy_table::AppServiceHandledRpc handled_rpc; + handled_rpc.function_id = handled_rpcs_query.GetInteger(0); + (*app_service_parameters)[service_type].handled_rpcs->push_back( + handled_rpc); + } + + service_name_query.Reset(); + handled_rpcs_query.Reset(); + } + return true; } + bool SQLPTRepresentation::GatherNickName( const std::string& app_id, policy_table::Strings* nicknames) const { @@ -2099,9 +2181,9 @@ bool SQLPTRepresentation::SetDefaultPolicy(const std::string& app_id) { return false; } - policy_table::HandledRpcs handled_rpcs; - if (!GatherHandledRpcs(kDefaultId, &handled_rpcs) || - !SaveHandledRpcs(app_id, handled_rpcs)) { + policy_table::AppServiceParameters app_service_parameters; + if (!GatherAppServiceParameters(kDefaultId, &app_service_parameters) || + !SaveAppServiceParameters(app_id, app_service_parameters)) { return false; } @@ -2206,7 +2288,7 @@ bool SQLPTRepresentation::CopyApplication(const std::string& source, utils::dbms::SQLQuery query(db()); if (!query.Prepare(sql_pt::kInsertApplicationFull)) { - LOG4CXX_WARN(logger_, "Incorrect insert statement into application."); + LOG4CXX_WARN(logger_, "Incorrect insert statement into application full."); return false; } query.Bind(0, destination); @@ -2236,10 +2318,6 @@ bool SQLPTRepresentation::CopyApplication(const std::string& source, : query.Bind(14, source_app.GetString(13)); source_app.IsNull(14) ? query.Bind(15) : query.Bind(15, source_app.GetString(14)); - source_app.IsNull(15) ? query.Bind(16) - : query.Bind(16, source_app.GetString(15)); - source_app.IsNull(16) ? query.Bind(17) - : query.Bind(17, source_app.GetString(16)); if (!query.Exec()) { LOG4CXX_WARN(logger_, "Failed inserting into application."); diff --git a/src/components/policy/policy_regular/include/policy/cache_manager.h b/src/components/policy/policy_regular/include/policy/cache_manager.h index e8d4e1782e..71e056ee22 100644 --- a/src/components/policy/policy_regular/include/policy/cache_manager.h +++ b/src/components/policy/policy_regular/include/policy/cache_manager.h @@ -219,10 +219,7 @@ class CacheManager : public CacheManagerInterface { /** * @brief Get app service parameters from the policy table * @param policy_app_id Unique application id - * @param service_name Service name published by app service provider - * @param service_type Service type published by app service provider - * @param handled_rpcs Vector of allowed function ids an app service provider - * can handle + * @param app_service_parameters Pointer to struct containing all app service information */ virtual void GetAppServiceParameters( const std::string& policy_app_id, diff --git a/src/components/policy/policy_regular/include/policy/cache_manager_interface.h b/src/components/policy/policy_regular/include/policy/cache_manager_interface.h index 4345244e76..d4ba78c43b 100644 --- a/src/components/policy/policy_regular/include/policy/cache_manager_interface.h +++ b/src/components/policy/policy_regular/include/policy/cache_manager_interface.h @@ -226,10 +226,7 @@ class CacheManagerInterface { /** * @brief Get app service parameters from the policy table * @param policy_app_id Unique application id - * @param service_name Service name published by app service provider - * @param service_type Service type published by app service provider - * @param handled_rpcs Vector of allowed function ids an app service provider - * can handle + * @param app_service_parameters Pointer to struct containing all app service information */ virtual void GetAppServiceParameters( const std::string& policy_app_id, diff --git a/src/components/policy/policy_regular/include/policy/policy_manager_impl.h b/src/components/policy/policy_regular/include/policy/policy_manager_impl.h index 8628b1a8a0..f3b285cbff 100644 --- a/src/components/policy/policy_regular/include/policy/policy_manager_impl.h +++ b/src/components/policy/policy_regular/include/policy/policy_manager_impl.h @@ -637,10 +637,7 @@ class PolicyManagerImpl : public PolicyManager { /** * @brief Get app service parameters from the policy table * @param policy_app_id Unique application id - * @param service_name Service name published by app service provider - * @param service_type Service type published by app service provider - * @param handled_rpcs Vector of allowed function ids an app service provider - * can handle + * @param app_service_parameters Pointer to struct containing all app service information */ void GetAppServiceParameters(const std::string& policy_app_id, policy_table::AppServiceParameters* diff --git a/src/components/policy/policy_regular/src/policy_table/types.cc b/src/components/policy/policy_regular/src/policy_table/types.cc index 2e164d3e14..5269daccb6 100644 --- a/src/components/policy/policy_regular/src/policy_table/types.cc +++ b/src/components/policy/policy_regular/src/policy_table/types.cc @@ -204,7 +204,7 @@ AppServiceInfo::AppServiceInfo(const Json::Value* value__) : CompositeType(InitHelper(value__, &Json::Value::isObject)) , service_names(impl::ValueMember(value__, "service_names")) , handled_rpcs(impl::ValueMember(value__, "handled_rpcs")) { -} // todo handled_rpcs struct +} Json::Value AppServiceInfo::ToJsonValue() const { Json::Value result__(Json::objectValue); diff --git a/src/components/policy/policy_regular/src/sql_pt_representation.cc b/src/components/policy/policy_regular/src/sql_pt_representation.cc index dd2c38a72b..6905af659e 100644 --- a/src/components/policy/policy_regular/src/sql_pt_representation.cc +++ b/src/components/policy/policy_regular/src/sql_pt_representation.cc @@ -2269,10 +2269,6 @@ bool SQLPTRepresentation::CopyApplication(const std::string& source, : query.Bind(14, source_app.GetString(13)); source_app.IsNull(14) ? query.Bind(15) : query.Bind(15, source_app.GetString(14)); - source_app.IsNull(15) ? query.Bind(16) - : query.Bind(16, source_app.GetString(15)); - source_app.IsNull(16) ? query.Bind(17) - : query.Bind(17, source_app.GetString(16)); if (!query.Exec()) { LOG4CXX_WARN(logger_, "Failed inserting into application."); -- cgit v1.2.1 From 2f5fe1b89dc6d15fb9bb2e42083db23edf3de276 Mon Sep 17 00:00:00 2001 From: JackLivio Date: Tue, 29 Jan 2019 15:28:27 -0500 Subject: Fix style --- .../include/application_manager/policies/policy_handler.h | 14 +++++++++----- .../policies/policy_handler_interface.h | 12 ++++++++---- .../policy/policy_external/policy/policy_manager.h | 7 ++++--- .../include/policy/policy_regular/policy/policy_manager.h | 3 ++- .../policy/policy_external/include/policy/cache_manager.h | 7 ++++--- .../include/policy/cache_manager_interface.h | 7 ++++--- .../policy_external/include/policy/policy_manager_impl.h | 7 ++++--- .../policy_external/include/policy/policy_table/types.h | 2 +- .../include/policy/sql_pt_representation.h | 8 ++++---- .../policy/policy_external/src/policy_table/types.cc | 8 +++----- .../policy/policy_external/src/sql_pt_ext_queries.cc | 7 +++---- .../policy_external/src/sql_pt_ext_representation.cc | 7 +++---- .../policy/policy_external/src/sql_pt_queries.cc | 3 +-- .../policy/policy_external/src/sql_pt_representation.cc | 15 +++++++-------- .../policy/policy_regular/include/policy/cache_manager.h | 3 ++- .../include/policy/cache_manager_interface.h | 3 ++- .../policy_regular/include/policy/policy_manager_impl.h | 3 ++- .../policy/policy_regular/src/policy_table/types.cc | 9 +++------ 18 files changed, 66 insertions(+), 59 deletions(-) diff --git a/src/components/application_manager/include/application_manager/policies/policy_handler.h b/src/components/application_manager/include/application_manager/policies/policy_handler.h index 65432d3741..df96ade313 100644 --- a/src/components/application_manager/include/application_manager/policies/policy_handler.h +++ b/src/components/application_manager/include/application_manager/policies/policy_handler.h @@ -446,11 +446,12 @@ class PolicyHandler : public PolicyHandlerInterface, */ void OnSetCloudAppProperties( const smart_objects::SmartObject& message) OVERRIDE; - + /** * @brief Get app service parameters from the policy table * @param policy_app_id Unique application id - * @param app_service_parameters Pointer to struct containing all app service information + * @param app_service_parameters Pointer to struct containing all app service + * information */ void GetAppServiceParameters(const std::string& policy_app_id, policy_table::AppServiceParameters* @@ -458,9 +459,12 @@ class PolicyHandler : public PolicyHandlerInterface, /** * @brief Check app service parameters from an app against policies * @param policy_app_id Unique application id - * @param requested_service_name Service name published by app service provider - * @param requested_service_type Service type published by app service provider - * @param requested_handled_rpcs Vector of requested function ids an app service wants to handle from consumers + * @param requested_service_name Service name published by app service + * provider + * @param requested_service_type Service type published by app service + * provider + * @param requested_handled_rpcs Vector of requested function ids an app + * service wants to handle from consumers */ bool CheckAppServiceParameters( const std::string& policy_app_id, diff --git a/src/components/include/application_manager/policies/policy_handler_interface.h b/src/components/include/application_manager/policies/policy_handler_interface.h index bfd956c4f2..64f0b893b2 100644 --- a/src/components/include/application_manager/policies/policy_handler_interface.h +++ b/src/components/include/application_manager/policies/policy_handler_interface.h @@ -491,7 +491,8 @@ class PolicyHandlerInterface { /** * @brief Get app service parameters from the policy table * @param policy_app_id Unique application id - * @param app_service_parameters Pointer to struct containing all app service information + * @param app_service_parameters Pointer to struct containing all app service + * information */ virtual void GetAppServiceParameters( const std::string& policy_app_id, @@ -500,9 +501,12 @@ class PolicyHandlerInterface { /** * @brief Check app service parameters from an app against policies * @param policy_app_id Unique application id - * @param requested_service_name Service name published by app service provider - * @param requested_service_type Service type published by app service provider - * @param requested_handled_rpcs Vector of requested function ids an app service wants to handle from consumers + * @param requested_service_name Service name published by app service + * provider + * @param requested_service_type Service type published by app service + * provider + * @param requested_handled_rpcs Vector of requested function ids an app + * service wants to handle from consumers */ virtual bool CheckAppServiceParameters( const std::string& policy_app_id, diff --git a/src/components/include/policy/policy_external/policy/policy_manager.h b/src/components/include/policy/policy_external/policy/policy_manager.h index ec659bd1b1..e7aefe9f6c 100644 --- a/src/components/include/policy/policy_external/policy/policy_manager.h +++ b/src/components/include/policy/policy_external/policy/policy_manager.h @@ -595,11 +595,12 @@ class PolicyManager : public usage_statistics::StatisticsManager { /** * @brief Get app service parameters from the policy table * @param policy_app_id Unique application id - * @param app_service_parameters Pointer to struct containing all app service information + * @param app_service_parameters Pointer to struct containing all app service + * information */ virtual void GetAppServiceParameters( - const std::string& policy_app_id, - policy_table::AppServiceParameters* app_service_parameters) const = 0; + const std::string& policy_app_id, + policy_table::AppServiceParameters* app_service_parameters) const = 0; /** * @brief Gets meta information diff --git a/src/components/include/policy/policy_regular/policy/policy_manager.h b/src/components/include/policy/policy_regular/policy/policy_manager.h index b544b9d346..e4ee95fda0 100644 --- a/src/components/include/policy/policy_regular/policy/policy_manager.h +++ b/src/components/include/policy/policy_regular/policy/policy_manager.h @@ -576,7 +576,8 @@ class PolicyManager : public usage_statistics::StatisticsManager { /** * @brief Get app service parameters from the policy table * @param policy_app_id Unique application id - * @param app_service_parameters Pointer to struct containing all app service information + * @param app_service_parameters Pointer to struct containing all app service + * information */ virtual void GetAppServiceParameters( const std::string& policy_app_id, diff --git a/src/components/policy/policy_external/include/policy/cache_manager.h b/src/components/policy/policy_external/include/policy/cache_manager.h index d7094e19e5..3813b58ca3 100644 --- a/src/components/policy/policy_external/include/policy/cache_manager.h +++ b/src/components/policy/policy_external/include/policy/cache_manager.h @@ -231,11 +231,12 @@ class CacheManager : public CacheManagerInterface { /** * @brief Get app service parameters from the policy table * @param policy_app_id Unique application id - * @param app_service_parameters Pointer to struct containing all app service information + * @param app_service_parameters Pointer to struct containing all app service + * information */ virtual void GetAppServiceParameters( - const std::string& policy_app_id, - policy_table::AppServiceParameters* app_service_parameters) const; + const std::string& policy_app_id, + policy_table::AppServiceParameters* app_service_parameters) const; /** * @brief Allows to update 'vin' field in module_meta table. diff --git a/src/components/policy/policy_external/include/policy/cache_manager_interface.h b/src/components/policy/policy_external/include/policy/cache_manager_interface.h index 4a904c5829..21c8a947cc 100644 --- a/src/components/policy/policy_external/include/policy/cache_manager_interface.h +++ b/src/components/policy/policy_external/include/policy/cache_manager_interface.h @@ -240,11 +240,12 @@ class CacheManagerInterface { /** * @brief Get app service parameters from the policy table * @param policy_app_id Unique application id - * @param app_service_parameters Pointer to struct containing all app service information + * @param app_service_parameters Pointer to struct containing all app service + * information */ virtual void GetAppServiceParameters( - const std::string& policy_app_id, - policy_table::AppServiceParameters* app_service_parameters) const = 0; + const std::string& policy_app_id, + policy_table::AppServiceParameters* app_service_parameters) const = 0; /** * @brief Allows to update 'vin' field in module_meta table. diff --git a/src/components/policy/policy_external/include/policy/policy_manager_impl.h b/src/components/policy/policy_external/include/policy/policy_manager_impl.h index fe982ff59e..9cf067c0ec 100644 --- a/src/components/policy/policy_external/include/policy/policy_manager_impl.h +++ b/src/components/policy/policy_external/include/policy/policy_manager_impl.h @@ -642,11 +642,12 @@ class PolicyManagerImpl : public PolicyManager { /** * @brief Get app service parameters from the policy table * @param policy_app_id Unique application id - * @param app_service_parameters Pointer to struct containing all app service information + * @param app_service_parameters Pointer to struct containing all app service + * information */ void GetAppServiceParameters(const std::string& policy_app_id, - policy_table::AppServiceParameters* - app_service_parameters) const OVERRIDE; + policy_table::AppServiceParameters* + app_service_parameters) const OVERRIDE; /** * @brief OnAppRegisteredOnMobile allows to handle event when application were diff --git a/src/components/policy/policy_external/include/policy/policy_table/types.h b/src/components/policy/policy_external/include/policy/policy_table/types.h index e74091b8a3..f3d154dd9f 100644 --- a/src/components/policy/policy_external/include/policy/policy_table/types.h +++ b/src/components/policy/policy_external/include/policy/policy_table/types.h @@ -138,7 +138,7 @@ struct AppServiceHandledRpc : CompositeType { private: bool Validate() const; }; - + struct AppServiceInfo : CompositeType { public: Optional service_names; diff --git a/src/components/policy/policy_external/include/policy/sql_pt_representation.h b/src/components/policy/policy_external/include/policy/sql_pt_representation.h index 0d8e1c7ae9..581340ba02 100644 --- a/src/components/policy/policy_external/include/policy/sql_pt_representation.h +++ b/src/components/policy/policy_external/include/policy/sql_pt_representation.h @@ -135,8 +135,8 @@ class SQLPTRepresentation : public virtual PTRepresentation { const std::string& app_id, policy_table::RequestSubTypes* request_subtypes) const; bool GatherAppServiceParameters( - const std::string& app_id, - policy_table::AppServiceParameters* app_service_parameters) const; + const std::string& app_id, + policy_table::AppServiceParameters* app_service_parameters) const; bool GatherNickName(const std::string& app_id, policy_table::Strings* nicknames) const; @@ -176,8 +176,8 @@ class SQLPTRepresentation : public virtual PTRepresentation { const std::string& app_id, const policy_table::RequestSubTypes& request_subtypes); bool SaveAppServiceParameters( - const std::string& app_id, - const policy_table::AppServiceParameters& app_service_parameters); + const std::string& app_id, + const policy_table::AppServiceParameters& app_service_parameters); public: virtual std::string GetLockScreenIconUrl() const; diff --git a/src/components/policy/policy_external/src/policy_table/types.cc b/src/components/policy/policy_external/src/policy_table/types.cc index fb17391332..db28b5b4fb 100644 --- a/src/components/policy/policy_external/src/policy_table/types.cc +++ b/src/components/policy/policy_external/src/policy_table/types.cc @@ -275,8 +275,7 @@ AppServiceInfo::~AppServiceInfo() {} AppServiceInfo::AppServiceInfo(const Json::Value* value__) : CompositeType(InitHelper(value__, &Json::Value::isObject)) , service_names(impl::ValueMember(value__, "service_names")) - , handled_rpcs(impl::ValueMember(value__, "handled_rpcs")) { -} + , handled_rpcs(impl::ValueMember(value__, "handled_rpcs")) {} Json::Value AppServiceInfo::ToJsonValue() const { Json::Value result__(Json::objectValue); @@ -325,7 +324,6 @@ void AppServiceInfo::ReportErrors(rpc::ValidationReport* report__) const { handled_rpcs.ReportErrors(&report__->ReportSubobject("handled_rpcs")); } } - // ApplicationParams methods ApplicationParams::ApplicationParams() : PolicyBase() {} @@ -417,8 +415,8 @@ bool ApplicationParams::is_valid() const { return false; } if (!app_service_parameters.is_valid()) { - return false; - } + return false; + } return Validate(); } diff --git a/src/components/policy/policy_external/src/sql_pt_ext_queries.cc b/src/components/policy/policy_external/src/sql_pt_ext_queries.cc index 25827c719b..32320b6d6c 100644 --- a/src/components/policy/policy_external/src/sql_pt_ext_queries.cc +++ b/src/components/policy/policy_external/src/sql_pt_ext_queries.cc @@ -207,8 +207,8 @@ const std::string kInsertApplication = " `default_hmi`, `priority_value`, `is_revoked`, `memory_kb`, " " `heart_beat_timeout_ms`, `certificate`, `hybrid_app_preference_value`, " " `endpoint`, `enabled`, `auth_token`, " - " `cloud_transport_type`, `service_name`, `service_type`) VALUES " - "(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)"; + " `cloud_transport_type`) VALUES " + "(?,?,?,?,?,?,?,?,?,?,?,?,?,?)"; const std::string kCollectFriendlyMsg = "SELECT * FROM `message`"; @@ -237,8 +237,7 @@ const std::string kSelectAppPolicies = "SELECT `id`, `priority_value`, `default_hmi`, `keep_context`, " " `steal_focus`, `memory_kb`, `heart_beat_timeout_ms`, `certificate`, " " `hybrid_app_preference_value`, `endpoint`, `enabled`, `auth_token` " - " `cloud_transport_type`, `service_name`, `service_type` FROM " - "`application`"; + " `cloud_transport_type` FROM `application`"; const std::string kSelectFunctionalGroupNames = "SELECT `id`, `user_consent_prompt`, `name`" diff --git a/src/components/policy/policy_external/src/sql_pt_ext_representation.cc b/src/components/policy/policy_external/src/sql_pt_ext_representation.cc index ce35b637a1..6e0da9e5de 100644 --- a/src/components/policy/policy_external/src/sql_pt_ext_representation.cc +++ b/src/components/policy/policy_external/src/sql_pt_ext_representation.cc @@ -689,7 +689,6 @@ bool SQLPTExtRepresentation::SaveApplicationPoliciesSection( LOG4CXX_WARN(logger_, "Incorrect delete from handled service types."); return false; } - // First, all predefined apps (e.g. default, pre_DataConsent) should be saved, // otherwise another app with the predefined permissions can get incorrect @@ -746,9 +745,9 @@ bool SQLPTExtRepresentation::SaveSpecificAppPolicy( return false; } if (!SaveAppServiceParameters(app.first, - *app.second.app_service_parameters)) { - return false; - } + *app.second.app_service_parameters)) { + return false; + } // Stop saving other params, since predefined permissions already set return true; } diff --git a/src/components/policy/policy_external/src/sql_pt_queries.cc b/src/components/policy/policy_external/src/sql_pt_queries.cc index 8190a6e4ca..51f4e4c13e 100644 --- a/src/components/policy/policy_external/src/sql_pt_queries.cc +++ b/src/components/policy/policy_external/src/sql_pt_queries.cc @@ -907,12 +907,11 @@ const std::string kDeleteRequestType = "DELETE FROM `request_type`"; const std::string kDeleteRequestSubType = "DELETE FROM `request_subtype`"; const std::string kDeleteAppServiceTypes = "DELETE FROM `app_service_types`"; - + const std::string kDeleteAppServiceNames = "DELETE FROM `app_service_names`"; const std::string kDeleteAppServiceHandledRpcs = "DELETE FROM `app_service_handled_rpcs`"; - const std::string kSelectApplicationRevoked = "SELECT `is_revoked` FROM `application` WHERE `id` = ?"; diff --git a/src/components/policy/policy_external/src/sql_pt_representation.cc b/src/components/policy/policy_external/src/sql_pt_representation.cc index 0897b11009..33dc98343b 100644 --- a/src/components/policy/policy_external/src/sql_pt_representation.cc +++ b/src/components/policy/policy_external/src/sql_pt_representation.cc @@ -810,7 +810,8 @@ bool SQLPTRepresentation::GatherApplicationPoliciesSection( if (!GatherRequestSubType(gather_app_id, &*params.RequestSubType)) { return false; } - if (!GatherAppServiceParameters(gather_app_id, &*params.app_service_parameters)) { + if (!GatherAppServiceParameters(gather_app_id, + &*params.app_service_parameters)) { return false; } @@ -1304,7 +1305,7 @@ bool SQLPTRepresentation::SaveAppServiceParameters( } policy_table::AppServiceParameters::const_iterator it; for (it = app_service_parameters.begin(); it != app_service_parameters.end(); - ++it) { + ++it) { // Create service type id from hashing app_id and service_type std::string str_to_hash = std::string(app_id + it->first); const long int id = abs(CacheManager::GenerateHash(str_to_hash)); @@ -1326,8 +1327,8 @@ bool SQLPTRepresentation::SaveAppServiceParameters( auto app_service_names = it->second.service_names; policy_table::AppServiceNames::const_iterator names_it; for (names_it = app_service_names->begin(); - names_it != app_service_names->end(); - ++names_it) { + names_it != app_service_names->end(); + ++names_it) { service_name_query.Bind(0, static_cast(id)); service_name_query.Bind(1, *names_it); if (!service_name_query.Exec() || !service_name_query.Reset()) { @@ -1340,14 +1341,14 @@ bool SQLPTRepresentation::SaveAppServiceParameters( utils::dbms::SQLQuery handled_rpcs_query(db()); if (!handled_rpcs_query.Prepare(sql_pt::kInsertAppServiceHandledRpcs)) { LOG4CXX_WARN(logger_, - "Incorrect insert statement for app service handled rpcs"); + "Incorrect insert statement for app service handled rpcs"); return false; } auto handled_rpcs = it->second.handled_rpcs; policy_table::AppServiceHandledRpcs::const_iterator rpc_it; for (rpc_it = handled_rpcs->begin(); rpc_it != handled_rpcs->end(); - ++rpc_it) { + ++rpc_it) { handled_rpcs_query.Bind(0, static_cast(id)); handled_rpcs_query.Bind(1, static_cast(rpc_it->function_id)); if (!handled_rpcs_query.Exec() || !handled_rpcs_query.Reset()) { @@ -1358,7 +1359,6 @@ bool SQLPTRepresentation::SaveAppServiceParameters( } return true; } - bool SQLPTRepresentation::SaveModuleMeta(const policy_table::ModuleMeta& meta) { // Section Module Meta is empty for SDL specific @@ -1834,7 +1834,6 @@ bool SQLPTRepresentation::GatherAppServiceParameters( return true; } - bool SQLPTRepresentation::GatherNickName( const std::string& app_id, policy_table::Strings* nicknames) const { diff --git a/src/components/policy/policy_regular/include/policy/cache_manager.h b/src/components/policy/policy_regular/include/policy/cache_manager.h index 71e056ee22..354a979287 100644 --- a/src/components/policy/policy_regular/include/policy/cache_manager.h +++ b/src/components/policy/policy_regular/include/policy/cache_manager.h @@ -219,7 +219,8 @@ class CacheManager : public CacheManagerInterface { /** * @brief Get app service parameters from the policy table * @param policy_app_id Unique application id - * @param app_service_parameters Pointer to struct containing all app service information + * @param app_service_parameters Pointer to struct containing all app service + * information */ virtual void GetAppServiceParameters( const std::string& policy_app_id, diff --git a/src/components/policy/policy_regular/include/policy/cache_manager_interface.h b/src/components/policy/policy_regular/include/policy/cache_manager_interface.h index d4ba78c43b..639a9f9c18 100644 --- a/src/components/policy/policy_regular/include/policy/cache_manager_interface.h +++ b/src/components/policy/policy_regular/include/policy/cache_manager_interface.h @@ -226,7 +226,8 @@ class CacheManagerInterface { /** * @brief Get app service parameters from the policy table * @param policy_app_id Unique application id - * @param app_service_parameters Pointer to struct containing all app service information + * @param app_service_parameters Pointer to struct containing all app service + * information */ virtual void GetAppServiceParameters( const std::string& policy_app_id, diff --git a/src/components/policy/policy_regular/include/policy/policy_manager_impl.h b/src/components/policy/policy_regular/include/policy/policy_manager_impl.h index f3b285cbff..4ed8903b00 100644 --- a/src/components/policy/policy_regular/include/policy/policy_manager_impl.h +++ b/src/components/policy/policy_regular/include/policy/policy_manager_impl.h @@ -637,7 +637,8 @@ class PolicyManagerImpl : public PolicyManager { /** * @brief Get app service parameters from the policy table * @param policy_app_id Unique application id - * @param app_service_parameters Pointer to struct containing all app service information + * @param app_service_parameters Pointer to struct containing all app service + * information */ void GetAppServiceParameters(const std::string& policy_app_id, policy_table::AppServiceParameters* diff --git a/src/components/policy/policy_regular/src/policy_table/types.cc b/src/components/policy/policy_regular/src/policy_table/types.cc index 5269daccb6..5f7d2e57bf 100644 --- a/src/components/policy/policy_regular/src/policy_table/types.cc +++ b/src/components/policy/policy_regular/src/policy_table/types.cc @@ -203,8 +203,7 @@ AppServiceInfo::~AppServiceInfo() {} AppServiceInfo::AppServiceInfo(const Json::Value* value__) : CompositeType(InitHelper(value__, &Json::Value::isObject)) , service_names(impl::ValueMember(value__, "service_names")) - , handled_rpcs(impl::ValueMember(value__, "handled_rpcs")) { -} + , handled_rpcs(impl::ValueMember(value__, "handled_rpcs")) {} Json::Value AppServiceInfo::ToJsonValue() const { Json::Value result__(Json::objectValue); @@ -278,8 +277,7 @@ ApplicationParams::ApplicationParams(const Json::Value* value__) , enabled(impl::ValueMember(value__, "enabled")) , auth_token(impl::ValueMember(value__, "auth_token")) , cloud_transport_type(impl::ValueMember(value__, "cloud_transport_type")) - , app_service_parameters( - impl::ValueMember(value__, "app_services")) {} + , app_service_parameters(impl::ValueMember(value__, "app_services")) {} Json::Value ApplicationParams::ToJsonValue() const { Json::Value result__(PolicyBase::ToJsonValue()); @@ -299,8 +297,7 @@ Json::Value ApplicationParams::ToJsonValue() const { impl::WriteJsonField("enabled", enabled, &result__); impl::WriteJsonField("auth_token", auth_token, &result__); impl::WriteJsonField("cloud_transport_type", cloud_transport_type, &result__); - impl::WriteJsonField( - "app_services", app_service_parameters, &result__); + impl::WriteJsonField("app_services", app_service_parameters, &result__); return result__; } -- cgit v1.2.1 From b978621cc24a49dbe6c59bb59a8406f52fc2c9db Mon Sep 17 00:00:00 2001 From: JackLivio Date: Wed, 30 Jan 2019 15:52:59 -0500 Subject: Change request type to enum --- .../include/application_manager/policies/policy_handler.h | 2 +- .../mobile/on_app_service_data_notification_from_mobile.cc | 5 +++-- .../src/commands/mobile/publish_app_service_request.cc | 5 +++-- .../application_manager/src/policies/policy_handler.cc | 13 +++++++++---- .../application_manager/policies/policy_handler_interface.h | 2 +- 5 files changed, 17 insertions(+), 10 deletions(-) diff --git a/src/components/application_manager/include/application_manager/policies/policy_handler.h b/src/components/application_manager/include/application_manager/policies/policy_handler.h index df96ade313..37474d75c2 100644 --- a/src/components/application_manager/include/application_manager/policies/policy_handler.h +++ b/src/components/application_manager/include/application_manager/policies/policy_handler.h @@ -469,7 +469,7 @@ class PolicyHandler : public PolicyHandlerInterface, bool CheckAppServiceParameters( const std::string& policy_app_id, const std::string& requested_service_name, - const std::string& requested_service_type, + const mobile_apis::AppServiceType::eType& requested_service_type, smart_objects::SmartArray* requested_handled_rpcs) const OVERRIDE; virtual void OnUpdateHMIAppType( diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/on_app_service_data_notification_from_mobile.cc b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/on_app_service_data_notification_from_mobile.cc index 6a9dc8f1a7..d4396d49a8 100644 --- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/on_app_service_data_notification_from_mobile.cc +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/on_app_service_data_notification_from_mobile.cc @@ -68,9 +68,10 @@ void OnAppServiceDataNotificationFromMobile::Run() { LOG4CXX_DEBUG(logger_, "Received an OnAppServiceData"); MessageHelper::PrintSmartObject(*message_); - std::string service_type = + // Todo: revision make service type string. + mobile_apis::AppServiceType::eType service_type = static_cast( (*message_)[strings::msg_params][strings::app_service_manifest] - [strings::service_type].asString(); + [strings::service_type].asUInt()); ApplicationSharedPtr app = application_manager_.application(connection_key()); diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/publish_app_service_request.cc b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/publish_app_service_request.cc index f975cb0543..03c1b91785 100644 --- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/publish_app_service_request.cc +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/publish_app_service_request.cc @@ -95,9 +95,10 @@ void PublishAppServiceRequest::Run() { std::string requested_service_name = (*message_)[strings::msg_params][strings::app_service_manifest] [strings::service_name].asString(); - std::string requested_service_type = + // Todo: revision make service type string. + mobile_apis::AppServiceType::eType requested_service_type = static_cast( (*message_)[strings::msg_params][strings::app_service_manifest] - [strings::service_type].asString(); + [strings::service_type].asUInt()); smart_objects::SmartArray* requested_handled_rpcs = (*message_)[strings::msg_params][strings::app_service_manifest] [strings::handled_rpcs].asArray(); diff --git a/src/components/application_manager/src/policies/policy_handler.cc b/src/components/application_manager/src/policies/policy_handler.cc index 456c127025..a9f69464b7 100644 --- a/src/components/application_manager/src/policies/policy_handler.cc +++ b/src/components/application_manager/src/policies/policy_handler.cc @@ -1948,7 +1948,7 @@ void PolicyHandler::GetAppServiceParameters( bool PolicyHandler::CheckAppServiceParameters( const std::string& policy_app_id, const std::string& requested_service_name, - const std::string& requested_service_type, + const mobile_apis::AppServiceType::eType& requested_service_type, smart_objects::SmartArray* requested_handled_rpcs) const { std::string service_name = std::string(); std::string service_type = std::string(); @@ -1958,7 +1958,12 @@ bool PolicyHandler::CheckAppServiceParameters( policy_table::AppServiceParameters(); this->GetAppServiceParameters(policy_app_id, &app_service_parameters); - if (app_service_parameters.find(requested_service_type) == + std::string requested_service_type_str = std::string(); + smart_objects::EnumConversionHelper< + mobile_apis::AppServiceType::eType>:: + EnumToString(requested_service_type, &requested_service_type_str); + + if (app_service_parameters.find(requested_service_type_str) == app_service_parameters.end()) { LOG4CXX_DEBUG(logger_, "Disallowed service type: " << requested_service_type); @@ -1967,7 +1972,7 @@ bool PolicyHandler::CheckAppServiceParameters( if (!requested_service_name.empty()) { auto service_names = - *(app_service_parameters[requested_service_type].service_names); + *(app_service_parameters[requested_service_type_str].service_names); auto find_name_result = std::find(service_names.begin(), service_names.end(), @@ -1980,7 +1985,7 @@ bool PolicyHandler::CheckAppServiceParameters( // todo handled rpcs check if (requested_handled_rpcs) { auto temp_rpcs = - *(app_service_parameters[requested_service_type].handled_rpcs); + *(app_service_parameters[requested_service_type_str].handled_rpcs); for (auto handled_it = temp_rpcs.begin(); handled_it != temp_rpcs.end(); ++handled_it) { handled_rpcs.push_back(handled_it->function_id); diff --git a/src/components/include/application_manager/policies/policy_handler_interface.h b/src/components/include/application_manager/policies/policy_handler_interface.h index 64f0b893b2..5f5449fe11 100644 --- a/src/components/include/application_manager/policies/policy_handler_interface.h +++ b/src/components/include/application_manager/policies/policy_handler_interface.h @@ -511,7 +511,7 @@ class PolicyHandlerInterface { virtual bool CheckAppServiceParameters( const std::string& policy_app_id, const std::string& requested_service_name, - const std::string& requested_service_type, + const mobile_apis::AppServiceType::eType& requested_service_type, smart_objects::SmartArray* requested_handled_rpcs) const = 0; #ifdef EXTERNAL_PROPRIETARY_MODE -- cgit v1.2.1 From 09c5a34c1d00ace9af5310aad08e04a077eff121 Mon Sep 17 00:00:00 2001 From: JackLivio Date: Thu, 31 Jan 2019 16:26:38 -0500 Subject: Add service id generation. --- src/components/application_manager/src/app_service_manager.cc | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/components/application_manager/src/app_service_manager.cc b/src/components/application_manager/src/app_service_manager.cc index d11203feec..edfdfa26bc 100644 --- a/src/components/application_manager/src/app_service_manager.cc +++ b/src/components/application_manager/src/app_service_manager.cc @@ -42,6 +42,7 @@ #include "application_manager/smart_object_keys.h" #include "smart_objects/smart_object.h" #include "utils/logger.h" +#include "encryption/hashing.h" CREATE_LOGGERPTR_GLOBAL(logger_, "AppServiceManager") @@ -60,7 +61,15 @@ AppServiceManager::~AppServiceManager() { smart_objects::SmartObject AppServiceManager::PublishAppService( const smart_objects::SmartObject& manifest) { - std::string service_id = "SERVICE_UUID"; // TODO: Generate UUID + std::string str_to_hash = ""; + std::string service_id = ""; + + do { + str_to_hash = manifest[strings::service_type].asString() + + std::to_string(std::rand()); + service_id = encryption::MakeHash(str_to_hash); + } while (published_services_.find(service_id) != published_services_.end()); + smart_objects::SmartObject service_record; service_record[strings::service_manifest] = manifest; service_record[strings::service_id] = service_id; -- cgit v1.2.1 From 000a8e84cbae684537b2edbd34716923e418d938 Mon Sep 17 00:00:00 2001 From: JackLivio Date: Tue, 5 Feb 2019 14:46:10 -0500 Subject: Update PublishAppService --- .../include/application_manager/app_service_manager.h | 12 ++++++++++-- .../src/commands/hmi/as_publish_app_service_request.cc | 3 ++- .../src/commands/mobile/publish_app_service_request.cc | 3 ++- .../application_manager/src/app_service_manager.cc | 18 ++++++++++++++---- 4 files changed, 28 insertions(+), 8 deletions(-) diff --git a/src/components/application_manager/include/application_manager/app_service_manager.h b/src/components/application_manager/include/application_manager/app_service_manager.h index a15921d9f7..a6cd0efcf8 100644 --- a/src/components/application_manager/include/application_manager/app_service_manager.h +++ b/src/components/application_manager/include/application_manager/app_service_manager.h @@ -37,6 +37,12 @@ namespace application_manager { +struct AppService { + uint32_t connection_key; + bool mobile_service; + smart_objects::SmartObject record; +}; + class ApplicationManager; /** @@ -60,7 +66,9 @@ class AppServiceManager { * @param manifest */ smart_objects::SmartObject PublishAppService( - const smart_objects::SmartObject& manifest); + const smart_objects::SmartObject& manifest, + const bool mobile_service, + const uint32_t connection_key); /** * @brief TODO @@ -76,7 +84,7 @@ class AppServiceManager { private: ApplicationManager& app_manager_; - std::map published_services_; + std::map published_services_; }; } // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_publish_app_service_request.cc b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_publish_app_service_request.cc index 1e235c1282..7a71bea57f 100644 --- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_publish_app_service_request.cc +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_publish_app_service_request.cc @@ -86,7 +86,8 @@ void ASPublishAppServiceRequest::Run() { return; } smart_objects::SmartObject service_record = - application_manager_.GetAppServiceManager().PublishAppService(manifest); + application_manager_.GetAppServiceManager().PublishAppService( + manifest, false, UINT32_MAX); response_params[strings::app_service_record] = service_record; // TODO: Add AppServiceRecord to response diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/publish_app_service_request.cc b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/publish_app_service_request.cc index bf1fbae4f5..78372661dc 100644 --- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/publish_app_service_request.cc +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/publish_app_service_request.cc @@ -90,7 +90,8 @@ void PublishAppServiceRequest::Run() { return; } smart_objects::SmartObject service_record = - application_manager_.GetAppServiceManager().PublishAppService(manifest); + application_manager_.GetAppServiceManager().PublishAppService( + manifest, true, connection_key()); response_params[strings::app_service_record] = service_record; diff --git a/src/components/application_manager/src/app_service_manager.cc b/src/components/application_manager/src/app_service_manager.cc index edfdfa26bc..7d91a3cbe5 100644 --- a/src/components/application_manager/src/app_service_manager.cc +++ b/src/components/application_manager/src/app_service_manager.cc @@ -60,7 +60,9 @@ AppServiceManager::~AppServiceManager() { } smart_objects::SmartObject AppServiceManager::PublishAppService( - const smart_objects::SmartObject& manifest) { + const smart_objects::SmartObject& manifest, + const bool mobile_service, + const uint32_t connection_key) { std::string str_to_hash = ""; std::string service_id = ""; @@ -70,13 +72,21 @@ smart_objects::SmartObject AppServiceManager::PublishAppService( service_id = encryption::MakeHash(str_to_hash); } while (published_services_.find(service_id) != published_services_.end()); + AppService app_service; + app_service.connection_key = connection_key; + app_service.mobile_service = mobile_service; + smart_objects::SmartObject service_record; service_record[strings::service_manifest] = manifest; service_record[strings::service_id] = service_id; service_record[strings::service_published] = true; service_record[strings::service_active] = true; - published_services_.insert(std::pair( - service_id, service_record)); + + app_service.record = service_record; + + published_services_.insert( + std::pair(service_id, app_service)); + return service_record; } @@ -91,7 +101,7 @@ std::vector AppServiceManager::GetAllServices() { std::vector services; for (auto it = published_services_.begin(); it != published_services_.end(); ++it) { - services.push_back(it->second); + services.push_back(it->second.record); } return services; } -- cgit v1.2.1 From 35db01e868d559fe4395f2e6c6709d22a862b8a1 Mon Sep 17 00:00:00 2001 From: jacobkeeler Date: Tue, 5 Feb 2019 14:55:06 -0500 Subject: Address review comments. --- .../src/commands/hmi/as_publish_app_service_request.cc | 1 - .../policy/policy_external/include/policy/policy_table/enums.h | 7 ++++++- .../policy/policy_external/src/policy_table/enums.cc | 5 +++++ .../policy/policy_regular/include/policy/policy_table/enums.h | 7 ++++++- src/components/policy/policy_regular/src/policy_table/enums.cc | 10 ++++++++++ 5 files changed, 27 insertions(+), 3 deletions(-) diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_publish_app_service_request.cc b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_publish_app_service_request.cc index 7a71bea57f..ff69c90029 100644 --- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_publish_app_service_request.cc +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_publish_app_service_request.cc @@ -90,7 +90,6 @@ void ASPublishAppServiceRequest::Run() { manifest, false, UINT32_MAX); response_params[strings::app_service_record] = service_record; - // TODO: Add AppServiceRecord to response SendResponse(true, (*message_)[strings::params][strings::correlation_id].asUInt(), hmi_apis::FunctionID::AppService_PublishAppService, diff --git a/src/components/policy/policy_external/include/policy/policy_table/enums.h b/src/components/policy/policy_external/include/policy/policy_table/enums.h index 0b571823f9..094e5cc7c6 100644 --- a/src/components/policy/policy_external/include/policy/policy_table/enums.h +++ b/src/components/policy/policy_external/include/policy/policy_table/enums.h @@ -446,7 +446,7 @@ enum FunctionID { SetCloudAppPropertiesID = 50, /** - * @brief PublishAppServiceID + * @brief PublishAppServiceID. */ PublishAppServiceID = 52, @@ -540,6 +540,11 @@ enum FunctionID { */ OnRCStatusID = 32785, + /** + * @brief OnAppServiceDataID. + */ + OnAppServiceDataID = 32786, + /** * @brief EncodedSyncPDataID. */ diff --git a/src/components/policy/policy_external/src/policy_table/enums.cc b/src/components/policy/policy_external/src/policy_table/enums.cc index 72dd7aea72..2260d7e320 100644 --- a/src/components/policy/policy_external/src/policy_table/enums.cc +++ b/src/components/policy/policy_external/src/policy_table/enums.cc @@ -1221,6 +1221,11 @@ bool EnumFromJsonString(const std::string& literal, FunctionID* result) { return true; } + if ("OnAppServiceData" == literal) { + *result = OnAppServiceDataID; + return true; + } + if ("EncodedSyncPData" == literal) { *result = EncodedSyncPDataID; return true; diff --git a/src/components/policy/policy_regular/include/policy/policy_table/enums.h b/src/components/policy/policy_regular/include/policy/policy_table/enums.h index f8f4e9e029..a62a60f2e9 100644 --- a/src/components/policy/policy_regular/include/policy/policy_table/enums.h +++ b/src/components/policy/policy_regular/include/policy/policy_table/enums.h @@ -432,7 +432,7 @@ enum FunctionID { SetCloudAppPropertiesID = 50, /** - * @brief PublishAppServiceID + * @brief PublishAppServiceID. */ PublishAppServiceID = 52, @@ -526,6 +526,11 @@ enum FunctionID { */ OnRCStatusID = 32785, + /** + * @brief OnAppServiceDataID. + */ + OnAppServiceDataID = 32786, + /** * @brief EncodedSyncPDataID. */ diff --git a/src/components/policy/policy_regular/src/policy_table/enums.cc b/src/components/policy/policy_regular/src/policy_table/enums.cc index f53b27776d..5c011fbfa0 100644 --- a/src/components/policy/policy_regular/src/policy_table/enums.cc +++ b/src/components/policy/policy_regular/src/policy_table/enums.cc @@ -887,6 +887,8 @@ bool IsValidEnum(FunctionID val) { return true; case OnRCStatusID: return true; + case OnAppServiceDataID: + return true; case EncodedSyncPDataID: return true; case SyncPDataID: @@ -1038,6 +1040,8 @@ const char* EnumToJsonString(FunctionID val) { return "OnWayPointChange"; case OnRCStatusID: return "OnRCStatus"; + case OnAppServiceDataID: + return "OnAppServiceData"; case EncodedSyncPDataID: return "EncodedSyncPData"; case SyncPDataID: @@ -1291,6 +1295,7 @@ bool EnumFromJsonString(const std::string& literal, FunctionID* result) { *result = SendHapticDataID; return true; } + if ("SetCloudAppProperties" == literal) { *result = SetCloudAppPropertiesID; return true; @@ -1391,6 +1396,11 @@ bool EnumFromJsonString(const std::string& literal, FunctionID* result) { return true; } + if ("OnAppServiceData" == literal) { + *result = OnAppServiceDataID; + return true; + } + if ("EncodedSyncPData" == literal) { *result = EncodedSyncPDataID; return true; -- cgit v1.2.1 From c303d419687e262b0b345b4c9f5bb0a266572df0 Mon Sep 17 00:00:00 2001 From: Shobhit Adlakha Date: Thu, 7 Feb 2019 10:02:02 -0500 Subject: Addressed review comments --- .../transport_adapter/transport_adapter.h | 6 -- .../cloud/websocket_client_connection.h | 3 +- .../src/cloud/websocket_client_connection.cc | 72 ++++++++-------------- 3 files changed, 28 insertions(+), 53 deletions(-) diff --git a/src/components/include/transport_manager/transport_adapter/transport_adapter.h b/src/components/include/transport_manager/transport_adapter/transport_adapter.h index ab21f1a326..eaa1fa9955 100644 --- a/src/components/include/transport_manager/transport_adapter/transport_adapter.h +++ b/src/components/include/transport_manager/transport_adapter/transport_adapter.h @@ -71,12 +71,6 @@ enum DeviceType { UNKNOWN }; -enum HybridAppPreference { // todo find correct place for this enum defintion. - MOBILE, - CLOUD, - BOTH -}; - struct CloudAppProperties { std::string endpoint; std::string certificate; diff --git a/src/components/transport_manager/include/transport_manager/cloud/websocket_client_connection.h b/src/components/transport_manager/include/transport_manager/cloud/websocket_client_connection.h index 4f6e2b02af..42ade40d35 100644 --- a/src/components/transport_manager/include/transport_manager/cloud/websocket_client_connection.h +++ b/src/components/transport_manager/include/transport_manager/cloud/websocket_client_connection.h @@ -144,7 +144,8 @@ class WebsocketClientConnection boost::beast::flat_buffer buffer_; std::string host_; std::string text_; - boost::variant dynamic_ws_; + WSptr ws_; + WSSptr wss_; std::atomic_bool shutdown_; diff --git a/src/components/transport_manager/src/cloud/websocket_client_connection.cc b/src/components/transport_manager/src/cloud/websocket_client_connection.cc index dcec2de4cf..0c304f04dd 100644 --- a/src/components/transport_manager/src/cloud/websocket_client_connection.cc +++ b/src/components/transport_manager/src/cloud/websocket_client_connection.cc @@ -70,9 +70,7 @@ void WebsocketClientConnection::AddCertificateAuthority( return; } - boost::get(dynamic_ws_) - ->next_layer() - .set_verify_mode(ssl::verify_peer); + wss_->next_layer().set_verify_mode(ssl::verify_peer); } TransportAdapter::Error WebsocketClientConnection::Start() { @@ -107,24 +105,14 @@ TransportAdapter::Error WebsocketClientConnection::Start() { return TransportAdapter::FAIL; } - if (cloud_properties.cloud_transport_type == "WSS") { - dynamic_ws_ = std::make_shared(ioc_, ctx_); - } else { - dynamic_ws_ = std::make_shared(ioc_); - } - // Make Connection to host IP Address over TCP if (cloud_properties.cloud_transport_type == "WSS") { + wss_ = std::make_shared(ioc_, ctx_); boost::asio::connect( - boost::get(dynamic_ws_)->next_layer().next_layer(), - results.begin(), - results.end(), - ec); + wss_->next_layer().next_layer(), results.begin(), results.end(), ec); } else { - boost::asio::connect(boost::get(dynamic_ws_)->next_layer(), - results.begin(), - results.end(), - ec); + ws_ = std::make_shared(ioc_); + boost::asio::connect(ws_->next_layer(), results.begin(), results.end(), ec); } if (ec) { std::string str_err = "ErrorMessage: " + ec.message(); @@ -149,9 +137,7 @@ TransportAdapter::Error WebsocketClientConnection::Start() { } // Perform SSL Handshake - boost::get(dynamic_ws_) - ->next_layer() - .handshake(ssl::stream_base::client, ec); + wss_->next_layer().handshake(ssl::stream_base::client, ec); if (ec) { std::string str_err = "ErrorMessage: " + ec.message(); @@ -166,9 +152,9 @@ TransportAdapter::Error WebsocketClientConnection::Start() { // Perform websocket handshake if (cloud_properties.cloud_transport_type == "WSS") { - boost::get(dynamic_ws_)->handshake(host, "/", ec); + wss_->handshake(host, "/", ec); } else { - boost::get(dynamic_ws_)->handshake(host, "/", ec); + ws_->handshake(host, "/", ec); } if (ec) { std::string str_err = "ErrorMessage: " + ec.message(); @@ -182,28 +168,26 @@ TransportAdapter::Error WebsocketClientConnection::Start() { // Set the binary message write option if (cloud_properties.cloud_transport_type == "WSS") { - boost::get(dynamic_ws_)->binary(true); + wss_->binary(true); } else { - boost::get(dynamic_ws_)->binary(true); + ws_->binary(true); } write_thread_->start(threads::ThreadOptions()); controller_->ConnectDone(device_uid_, app_handle_); // Start async read if (cloud_properties.cloud_transport_type == "WSS") { - boost::get(dynamic_ws_) - ->async_read(buffer_, + wss_->async_read(buffer_, std::bind(&WebsocketClientConnection::OnRead, this, std::placeholders::_1, std::placeholders::_2)); } else { - boost::get(dynamic_ws_) - ->async_read(buffer_, - std::bind(&WebsocketClientConnection::OnRead, - this, - std::placeholders::_1, - std::placeholders::_2)); + ws_->async_read(buffer_, + std::bind(&WebsocketClientConnection::OnRead, + this, + std::placeholders::_1, + std::placeholders::_2)); } // Start IO Service thread. Allows for async reads without blocking. io_service_thread_ = std::thread([&]() { @@ -230,19 +214,17 @@ void WebsocketClientConnection::Recv(boost::system::error_code ec) { return; } if (cloud_properties.cloud_transport_type == "WSS") { - boost::get(dynamic_ws_) - ->async_read(buffer_, + wss_->async_read(buffer_, std::bind(&WebsocketClientConnection::OnRead, this, std::placeholders::_1, std::placeholders::_2)); } else { - boost::get(dynamic_ws_) - ->async_read(buffer_, - std::bind(&WebsocketClientConnection::OnRead, - this, - std::placeholders::_1, - std::placeholders::_2)); + ws_->async_read(buffer_, + std::bind(&WebsocketClientConnection::OnRead, + this, + std::placeholders::_1, + std::placeholders::_2)); } } @@ -329,13 +311,11 @@ void WebsocketClientConnection::LoopThreadDelegate::DrainQueue() { if (!shutdown_) { boost::system::error_code ec; if (handler_.cloud_properties.cloud_transport_type == "WSS") { - boost::get(handler_.dynamic_ws_) - ->write(boost::asio::buffer(message_ptr->data(), - message_ptr->data_size())); + handler_.wss_->write( + boost::asio::buffer(message_ptr->data(), message_ptr->data_size())); } else { - boost::get(handler_.dynamic_ws_) - ->write(boost::asio::buffer(message_ptr->data(), - message_ptr->data_size())); + handler_.ws_->write( + boost::asio::buffer(message_ptr->data(), message_ptr->data_size())); } if (ec) { LOG4CXX_ERROR(logger_, "Error writing to websocket"); -- cgit v1.2.1 From c318edd0a00c67bc55f5da882be73970517399a0 Mon Sep 17 00:00:00 2001 From: Shobhit Adlakha Date: Fri, 8 Feb 2019 10:10:18 -0500 Subject: Address review comments --- .../include/transport_manager/cloud/websocket_client_connection.h | 6 ++---- .../transport_manager/src/cloud/websocket_client_connection.cc | 2 +- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/src/components/transport_manager/include/transport_manager/cloud/websocket_client_connection.h b/src/components/transport_manager/include/transport_manager/cloud/websocket_client_connection.h index 42ade40d35..3c8ac59e4b 100644 --- a/src/components/transport_manager/include/transport_manager/cloud/websocket_client_connection.h +++ b/src/components/transport_manager/include/transport_manager/cloud/websocket_client_connection.h @@ -65,8 +65,6 @@ typedef std::queue AsyncQueue; typedef protocol_handler::RawMessagePtr Message; typedef websocket::stream WS; typedef websocket::stream > WSS; -typedef std::shared_ptr WSptr; -typedef std::shared_ptr WSSptr; namespace transport_manager { namespace transport_adapter { @@ -144,8 +142,8 @@ class WebsocketClientConnection boost::beast::flat_buffer buffer_; std::string host_; std::string text_; - WSptr ws_; - WSSptr wss_; + std::shared_ptr ws_; + std::shared_ptr wss_; std::atomic_bool shutdown_; diff --git a/src/components/transport_manager/src/cloud/websocket_client_connection.cc b/src/components/transport_manager/src/cloud/websocket_client_connection.cc index 0c304f04dd..5755511afc 100644 --- a/src/components/transport_manager/src/cloud/websocket_client_connection.cc +++ b/src/components/transport_manager/src/cloud/websocket_client_connection.cc @@ -1,6 +1,6 @@ /* * - * Copyright (c) 2017, Ford Motor Company + * Copyright (c) 2018, Livio * All rights reserved. * * Redistribution and use in source and binary forms, with or without -- cgit v1.2.1 From 584f41baa474550fcee673149e243e015ae965f6 Mon Sep 17 00:00:00 2001 From: Jacob Keeler Date: Fri, 8 Feb 2019 16:10:52 -0500 Subject: Fix merge conflict typo --- .../include/test/connection_handler/mock_connection_handler.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/include/test/connection_handler/mock_connection_handler.h b/src/components/include/test/connection_handler/mock_connection_handler.h index b4f06e1ec2..28eee3c923 100644 --- a/src/components/include/test/connection_handler/mock_connection_handler.h +++ b/src/components/include/test/connection_handler/mock_connection_handler.h @@ -66,7 +66,7 @@ class MockConnectionHandler : public connection_handler::ConnectionHandler { MOCK_CONST_METHOD2(RunAppOnDevice, void(const std::string&, const std::string&)); MOCK_METHOD0(ConnectToAllDevices, void()); - MOCK_METHOD2( + MOCK_METHOD1( AddCloudAppDevice, void(const transport_manager::transport_adapter::CloudAppProperties&)); MOCK_METHOD1(RemoveCloudAppDevice, void(const DeviceHandle device_id)); -- cgit v1.2.1 From 592d4e335c97332fd49678be804970f93d92a985 Mon Sep 17 00:00:00 2001 From: jacobkeeler Date: Fri, 8 Feb 2019 16:42:22 -0500 Subject: Add functions for finding services. --- .../application_manager/app_service_manager.h | 7 +++++- .../application_manager/src/app_service_manager.cc | 27 ++++++++++++++++++++++ 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/src/components/application_manager/include/application_manager/app_service_manager.h b/src/components/application_manager/include/application_manager/app_service_manager.h index a6cd0efcf8..736302dbc2 100644 --- a/src/components/application_manager/include/application_manager/app_service_manager.h +++ b/src/components/application_manager/include/application_manager/app_service_manager.h @@ -72,7 +72,7 @@ class AppServiceManager { /** * @brief TODO - * @param manifest + * @param service_id */ bool UnpublishAppService(const std::string service_id); @@ -82,6 +82,11 @@ class AppServiceManager { */ std::vector GetAllServices(); + std::pair ActiveServiceByType( + std::string service_type); + + std::pair FindServiceByName(std::string name); + private: ApplicationManager& app_manager_; std::map published_services_; diff --git a/src/components/application_manager/src/app_service_manager.cc b/src/components/application_manager/src/app_service_manager.cc index 7d91a3cbe5..c52e6a12f1 100644 --- a/src/components/application_manager/src/app_service_manager.cc +++ b/src/components/application_manager/src/app_service_manager.cc @@ -106,4 +106,31 @@ std::vector AppServiceManager::GetAllServices() { return services; } + +std::pair AppServiceManager::ActiveServiceByType( + std::string service_type) { + for (auto it = published_services_.begin(); it != published_services_.end(); + ++it) { + if (it->second.record[strings::app_service_manifest][strings::service_type] + .asString() == service_type && + it->second.record[strings::service_active].asBool()) { + return *it; + } + } + AppService empty; + return std::make_pair(std::string(), empty); +} + +std::pair AppServiceManager::FindServiceByName( + std::string name) { + for (auto it = published_services_.begin(); it != published_services_.end(); + ++it) { + if (it->second.record[strings::app_service_manifest][strings::service_name] + .asString() == name) { + return *it; + } + } + AppService empty; + return std::make_pair(std::string(), empty); +} } // namespace application_manager -- cgit v1.2.1 From 6c94329eab4c3bca1ddc066e610accc9a8c58033 Mon Sep 17 00:00:00 2001 From: jacobkeeler Date: Fri, 8 Feb 2019 16:44:56 -0500 Subject: Minor formatting fix --- .../application_manager/app_service_manager.h | 31 +++++++++++++++++++++- .../commands/hmi/as_publish_app_service_request.cc | 4 +-- .../hmi/as_publish_app_service_response.cc | 4 +-- .../hmi/on_as_app_service_data_notification.cc | 4 +-- ...on_as_app_service_data_notification_from_hmi.cc | 4 +-- .../mobile/on_app_service_data_notification.cc | 4 +-- ...on_app_service_data_notification_from_mobile.cc | 4 +-- .../commands/mobile/publish_app_service_request.cc | 4 +-- .../mobile/publish_app_service_response.cc | 4 +-- 9 files changed, 46 insertions(+), 17 deletions(-) diff --git a/src/components/application_manager/include/application_manager/app_service_manager.h b/src/components/application_manager/include/application_manager/app_service_manager.h index 736302dbc2..201fb88954 100644 --- a/src/components/application_manager/include/application_manager/app_service_manager.h +++ b/src/components/application_manager/include/application_manager/app_service_manager.h @@ -40,6 +40,7 @@ namespace application_manager { struct AppService { uint32_t connection_key; bool mobile_service; + bool default_service = false; smart_objects::SmartObject record; }; @@ -54,7 +55,8 @@ class AppServiceManager { * @brief Class constructor * @param app_manager */ - AppServiceManager(ApplicationManager& app_manager); + AppServiceManager(ApplicationManager& app_manager, + resumption::LastState& last_state); /** * @brief Class destructor @@ -76,6 +78,30 @@ class AppServiceManager { */ bool UnpublishAppService(const std::string service_id); + /** + * @brief TODO + * @param service_id + */ + bool SetDefaultService(const std::string service_id); + + /** + * @brief TODO + * @param service_id + */ + bool RemoveDefaultService(const std::string service_id); + + /** + * @brief TODO + * @param service_id + */ + bool ActivateAppService(const std::string service_id); + + /** + * @brief TODO + * @param service_id + */ + bool DeactivateAppService(const std::string service_id); + /** * @brief TODO * @param manifest @@ -87,8 +113,11 @@ class AppServiceManager { std::pair FindServiceByName(std::string name); + std::string DefaultServiceByType(std::string service_type); + private: ApplicationManager& app_manager_; + resumption::LastState& last_state_; std::map published_services_; }; diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_publish_app_service_request.cc b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_publish_app_service_request.cc index ff69c90029..89da1e744c 100644 --- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_publish_app_service_request.cc +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_publish_app_service_request.cc @@ -49,9 +49,9 @@ ASPublishAppServiceRequest::ASPublishAppServiceRequest( hmi_capabilities, policy_handler) , plugin_(NULL) { - auto plugin = (application_manager.GetPluginManager().FindPluginToProcess( + auto plugin = application_manager.GetPluginManager().FindPluginToProcess( hmi_apis::FunctionID::AppService_PublishAppService, - app_mngr::commands::Command::CommandSource::SOURCE_HMI)); + app_mngr::commands::Command::CommandSource::SOURCE_HMI); if (plugin) { plugin_ = dynamic_cast(&(*plugin)); } diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_publish_app_service_response.cc b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_publish_app_service_response.cc index 2513a92f15..1191b07abe 100644 --- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_publish_app_service_response.cc +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_publish_app_service_response.cc @@ -49,9 +49,9 @@ ASPublishAppServiceResponse::ASPublishAppServiceResponse( hmi_capabilities, policy_handler) , plugin_(NULL) { - auto plugin = (application_manager.GetPluginManager().FindPluginToProcess( + auto plugin = application_manager.GetPluginManager().FindPluginToProcess( hmi_apis::FunctionID::AppService_PublishAppService, - app_mngr::commands::Command::CommandSource::SOURCE_HMI)); + app_mngr::commands::Command::CommandSource::SOURCE_HMI); if (plugin) { plugin_ = dynamic_cast(&(*plugin)); } diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/on_as_app_service_data_notification.cc b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/on_as_app_service_data_notification.cc index 0cd269b04e..29562d3086 100644 --- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/on_as_app_service_data_notification.cc +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/on_as_app_service_data_notification.cc @@ -49,9 +49,9 @@ OnASAppServiceDataNotification::OnASAppServiceDataNotification( hmi_capabilities, policy_handler) , plugin_(NULL) { - auto plugin = (application_manager.GetPluginManager().FindPluginToProcess( + auto plugin = application_manager.GetPluginManager().FindPluginToProcess( hmi_apis::FunctionID::AppService_OnAppServiceData, - app_mngr::commands::Command::CommandSource::SOURCE_HMI)); + app_mngr::commands::Command::CommandSource::SOURCE_HMI); if (plugin) { plugin_ = dynamic_cast(&(*plugin)); } diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/on_as_app_service_data_notification_from_hmi.cc b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/on_as_app_service_data_notification_from_hmi.cc index 01a8e817a2..ce68192d13 100644 --- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/on_as_app_service_data_notification_from_hmi.cc +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/on_as_app_service_data_notification_from_hmi.cc @@ -49,9 +49,9 @@ OnASAppServiceDataNotificationFromHMI::OnASAppServiceDataNotificationFromHMI( hmi_capabilities, policy_handler) , plugin_(NULL) { - auto plugin = (application_manager.GetPluginManager().FindPluginToProcess( + auto plugin = application_manager.GetPluginManager().FindPluginToProcess( hmi_apis::FunctionID::AppService_OnAppServiceData, - app_mngr::commands::Command::CommandSource::SOURCE_HMI)); + app_mngr::commands::Command::CommandSource::SOURCE_HMI); if (plugin) { plugin_ = dynamic_cast(&(*plugin)); } diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/on_app_service_data_notification.cc b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/on_app_service_data_notification.cc index 33ab1a7246..ef2ab7a4ab 100644 --- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/on_app_service_data_notification.cc +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/on_app_service_data_notification.cc @@ -52,9 +52,9 @@ OnAppServiceDataNotification::OnAppServiceDataNotification( hmi_capabilities, policy_handler) , plugin_(NULL) { - auto plugin = (application_manager.GetPluginManager().FindPluginToProcess( + auto plugin = application_manager.GetPluginManager().FindPluginToProcess( mobile_apis::FunctionID::OnAppServiceDataID, - app_mngr::commands::Command::CommandSource::SOURCE_MOBILE)); + app_mngr::commands::Command::CommandSource::SOURCE_MOBILE); if (plugin) { plugin_ = dynamic_cast(&(*plugin)); } diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/on_app_service_data_notification_from_mobile.cc b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/on_app_service_data_notification_from_mobile.cc index a7a8042fee..0b0ac0b68c 100644 --- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/on_app_service_data_notification_from_mobile.cc +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/on_app_service_data_notification_from_mobile.cc @@ -52,9 +52,9 @@ OnAppServiceDataNotificationFromMobile::OnAppServiceDataNotificationFromMobile( hmi_capabilities, policy_handler) , plugin_(NULL) { - auto plugin = (application_manager.GetPluginManager().FindPluginToProcess( + auto plugin = application_manager.GetPluginManager().FindPluginToProcess( mobile_apis::FunctionID::OnAppServiceDataID, - app_mngr::commands::Command::CommandSource::SOURCE_MOBILE)); + app_mngr::commands::Command::CommandSource::SOURCE_MOBILE); if (plugin) { plugin_ = dynamic_cast(&(*plugin)); } diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/publish_app_service_request.cc b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/publish_app_service_request.cc index 78372661dc..7a0333e763 100644 --- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/publish_app_service_request.cc +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/publish_app_service_request.cc @@ -52,9 +52,9 @@ PublishAppServiceRequest::PublishAppServiceRequest( hmi_capabilities, policy_handler) , plugin_(NULL) { - auto plugin = (application_manager.GetPluginManager().FindPluginToProcess( + auto plugin = application_manager.GetPluginManager().FindPluginToProcess( mobile_apis::FunctionID::PublishAppServiceID, - app_mngr::commands::Command::CommandSource::SOURCE_MOBILE)); + app_mngr::commands::Command::CommandSource::SOURCE_MOBILE); if (plugin) { plugin_ = dynamic_cast(&(*plugin)); } diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/publish_app_service_response.cc b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/publish_app_service_response.cc index 6c3e9344bf..b302189ef7 100644 --- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/publish_app_service_response.cc +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/publish_app_service_response.cc @@ -52,9 +52,9 @@ PublishAppServiceResponse::PublishAppServiceResponse( hmi_capabilities, policy_handler) , plugin_(NULL) { - auto plugin = (application_manager.GetPluginManager().FindPluginToProcess( + auto plugin = application_manager.GetPluginManager().FindPluginToProcess( mobile_apis::FunctionID::PublishAppServiceID, - app_mngr::commands::Command::CommandSource::SOURCE_MOBILE)); + app_mngr::commands::Command::CommandSource::SOURCE_MOBILE); if (plugin) { plugin_ = dynamic_cast(&(*plugin)); } -- cgit v1.2.1 From cc8cd684d68306a3c09436a6ae8ab7ec70df1a94 Mon Sep 17 00:00:00 2001 From: Jacob Keeler Date: Mon, 11 Feb 2019 17:39:38 -0500 Subject: Remove LastState from AppServiceManager These changes were not meant to be included in this branch --- .../include/application_manager/app_service_manager.h | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/components/application_manager/include/application_manager/app_service_manager.h b/src/components/application_manager/include/application_manager/app_service_manager.h index 201fb88954..97df35e2b4 100644 --- a/src/components/application_manager/include/application_manager/app_service_manager.h +++ b/src/components/application_manager/include/application_manager/app_service_manager.h @@ -55,8 +55,7 @@ class AppServiceManager { * @brief Class constructor * @param app_manager */ - AppServiceManager(ApplicationManager& app_manager, - resumption::LastState& last_state); + AppServiceManager(ApplicationManager& app_manager); /** * @brief Class destructor @@ -117,7 +116,6 @@ class AppServiceManager { private: ApplicationManager& app_manager_; - resumption::LastState& last_state_; std::map published_services_; }; -- cgit v1.2.1 From fe724122fa194196e65e2b3ece2d2916c0e98cc1 Mon Sep 17 00:00:00 2001 From: JackLivio Date: Wed, 13 Feb 2019 16:39:46 -0500 Subject: Address Comments --- ...on_app_service_data_notification_from_mobile.cc | 7 ++--- .../commands/mobile/publish_app_service_request.cc | 30 +++++++++++++++------- .../application_manager/src/app_service_manager.cc | 1 - .../src/policies/policy_handler.cc | 6 ++--- .../policy_external/src/sql_pt_representation.cc | 2 +- .../policy_regular/src/sql_pt_representation.cc | 3 ++- 6 files changed, 30 insertions(+), 19 deletions(-) diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/on_app_service_data_notification_from_mobile.cc b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/on_app_service_data_notification_from_mobile.cc index 6c69eae3b6..1a90572ecf 100644 --- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/on_app_service_data_notification_from_mobile.cc +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/on_app_service_data_notification_from_mobile.cc @@ -69,9 +69,10 @@ void OnAppServiceDataNotificationFromMobile::Run() { MessageHelper::PrintSmartObject(*message_); // Todo: revision make service type string. - mobile_apis::AppServiceType::eType service_type = static_cast( - (*message_)[strings::msg_params][strings::app_service_manifest] - [strings::service_type].asUInt()); + mobile_apis::AppServiceType::eType service_type = + static_cast( + (*message_)[strings::msg_params][strings::app_service_manifest] + [strings::service_type].asUInt()); ApplicationSharedPtr app = application_manager_.application(connection_key()); diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/publish_app_service_request.cc b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/publish_app_service_request.cc index 052ad9751a..06f7f4b13a 100644 --- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/publish_app_service_request.cc +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/publish_app_service_request.cc @@ -93,16 +93,28 @@ void PublishAppServiceRequest::Run() { application_manager_.GetAppServiceManager().PublishAppService( manifest, true, connection_key()); - std::string requested_service_name = - (*message_)[strings::msg_params][strings::app_service_manifest] - [strings::service_name].asString(); + std::string requested_service_name = ""; + + if ((*message_)[strings::msg_params][strings::app_service_manifest].keyExists( + strings::service_name)) { + requested_service_name = + (*message_)[strings::msg_params][strings::app_service_manifest] + [strings::service_name].asString(); + } + // Todo: revision make service type string. - mobile_apis::AppServiceType::eType requested_service_type = static_cast( - (*message_)[strings::msg_params][strings::app_service_manifest] - [strings::service_type].asUInt()); - smart_objects::SmartArray* requested_handled_rpcs = - (*message_)[strings::msg_params][strings::app_service_manifest] - [strings::handled_rpcs].asArray(); + mobile_apis::AppServiceType::eType requested_service_type = + static_cast( + (*message_)[strings::msg_params][strings::app_service_manifest] + [strings::service_type].asUInt()); + + smart_objects::SmartArray* requested_handled_rpcs; + if ((*message_)[strings::msg_params][strings::app_service_manifest].keyExists( + strings::handled_rpcs)) { + requested_handled_rpcs = + (*message_)[strings::msg_params][strings::app_service_manifest] + [strings::handled_rpcs].asArray(); + } ApplicationSharedPtr app = application_manager_.application(connection_key()); diff --git a/src/components/application_manager/src/app_service_manager.cc b/src/components/application_manager/src/app_service_manager.cc index c52e6a12f1..5cb46f968f 100644 --- a/src/components/application_manager/src/app_service_manager.cc +++ b/src/components/application_manager/src/app_service_manager.cc @@ -106,7 +106,6 @@ std::vector AppServiceManager::GetAllServices() { return services; } - std::pair AppServiceManager::ActiveServiceByType( std::string service_type) { for (auto it = published_services_.begin(); it != published_services_.end(); diff --git a/src/components/application_manager/src/policies/policy_handler.cc b/src/components/application_manager/src/policies/policy_handler.cc index a9f69464b7..451a9087d5 100644 --- a/src/components/application_manager/src/policies/policy_handler.cc +++ b/src/components/application_manager/src/policies/policy_handler.cc @@ -1959,9 +1959,8 @@ bool PolicyHandler::CheckAppServiceParameters( this->GetAppServiceParameters(policy_app_id, &app_service_parameters); std::string requested_service_type_str = std::string(); - smart_objects::EnumConversionHelper< - mobile_apis::AppServiceType::eType>:: - EnumToString(requested_service_type, &requested_service_type_str); + smart_objects::EnumConversionHelper:: + EnumToString(requested_service_type, &requested_service_type_str); if (app_service_parameters.find(requested_service_type_str) == app_service_parameters.end()) { @@ -1982,7 +1981,6 @@ bool PolicyHandler::CheckAppServiceParameters( } } - // todo handled rpcs check if (requested_handled_rpcs) { auto temp_rpcs = *(app_service_parameters[requested_service_type_str].handled_rpcs); diff --git a/src/components/policy/policy_external/src/sql_pt_representation.cc b/src/components/policy/policy_external/src/sql_pt_representation.cc index 33dc98343b..435638ddb7 100644 --- a/src/components/policy/policy_external/src/sql_pt_representation.cc +++ b/src/components/policy/policy_external/src/sql_pt_representation.cc @@ -1808,7 +1808,7 @@ bool SQLPTRepresentation::GatherAppServiceParameters( return false; } - service_type_query.Bind(2, app_id); + service_type_query.Bind(0, app_id); while (service_type_query.Next()) { const int service_type_id = service_type_query.GetInteger(0); std::string service_type = service_type_query.GetString(1); diff --git a/src/components/policy/policy_regular/src/sql_pt_representation.cc b/src/components/policy/policy_regular/src/sql_pt_representation.cc index 6905af659e..b2981759ab 100644 --- a/src/components/policy/policy_regular/src/sql_pt_representation.cc +++ b/src/components/policy/policy_regular/src/sql_pt_representation.cc @@ -1761,10 +1761,11 @@ bool SQLPTRepresentation::GatherAppServiceParameters( return false; } - service_type_query.Bind(2, app_id); + service_type_query.Bind(0, app_id); while (service_type_query.Next()) { const int service_type_id = service_type_query.GetInteger(0); std::string service_type = service_type_query.GetString(1); + LOG4CXX_WARN(logger_, "Load service type from pt: " << service_type); (*app_service_parameters)[service_type] = policy_table::AppServiceInfo(); service_name_query.Bind(0, service_type_id); -- cgit v1.2.1 From 25f1211d2988c451ededbab958d9b5fe4a5fcc1d Mon Sep 17 00:00:00 2001 From: Shobhit Adlakha Date: Thu, 14 Feb 2019 13:40:30 -0500 Subject: Added case for handling SmartType UInteger in SmartObject::duplicate function --- src/components/smart_objects/src/smart_object.cc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/components/smart_objects/src/smart_object.cc b/src/components/smart_objects/src/smart_object.cc index 1322757ab1..3235dd619e 100644 --- a/src/components/smart_objects/src/smart_object.cc +++ b/src/components/smart_objects/src/smart_object.cc @@ -701,6 +701,9 @@ void SmartObject::duplicate(const SmartObject& OtherObject) { case SmartType_Integer: newData.int_value = OtherObject.m_data.int_value; break; + case SmartType_UInteger: + newData.int_value = OtherObject.m_data.int_value; + break; case SmartType_Double: newData.double_value = OtherObject.m_data.double_value; break; -- cgit v1.2.1 From 1660c7950143cf1b79b8e5b1fabd2d18ad95af6f Mon Sep 17 00:00:00 2001 From: jacobkeeler Date: Mon, 18 Feb 2019 13:51:54 -0500 Subject: Update AppServiceType usage in RPC spec after revisions --- .../application_manager/src/app_service_manager.cc | 16 ++++++++-------- src/components/interfaces/HMI_API.xml | 4 ++-- src/components/interfaces/MOBILE_API.xml | 4 ++-- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/components/application_manager/src/app_service_manager.cc b/src/components/application_manager/src/app_service_manager.cc index c52e6a12f1..8fea64b228 100644 --- a/src/components/application_manager/src/app_service_manager.cc +++ b/src/components/application_manager/src/app_service_manager.cc @@ -35,21 +35,17 @@ #include #include +#include "application_manager/app_service_manager.h" #include "application_manager/application.h" #include "application_manager/application_manager.h" #include "application_manager/commands/command_impl.h" #include "application_manager/message_helper.h" #include "application_manager/smart_object_keys.h" -#include "smart_objects/smart_object.h" -#include "utils/logger.h" #include "encryption/hashing.h" +#include "utils/logger.h" CREATE_LOGGERPTR_GLOBAL(logger_, "AppServiceManager") -namespace { -const size_t kLimitCommand = 30; -} - namespace application_manager { AppServiceManager::AppServiceManager(ApplicationManager& app_manager) @@ -63,6 +59,7 @@ smart_objects::SmartObject AppServiceManager::PublishAppService( const smart_objects::SmartObject& manifest, const bool mobile_service, const uint32_t connection_key) { + LOG4CXX_AUTO_TRACE(logger_); std::string str_to_hash = ""; std::string service_id = ""; @@ -109,10 +106,12 @@ std::vector AppServiceManager::GetAllServices() { std::pair AppServiceManager::ActiveServiceByType( std::string service_type) { + LOG4CXX_AUTO_TRACE(logger_); for (auto it = published_services_.begin(); it != published_services_.end(); ++it) { - if (it->second.record[strings::app_service_manifest][strings::service_type] + if (it->second.record[strings::service_manifest][strings::service_type] .asString() == service_type && + it->second.record[strings::service_published].asBool() && it->second.record[strings::service_active].asBool()) { return *it; } @@ -123,9 +122,10 @@ std::pair AppServiceManager::ActiveServiceByType( std::pair AppServiceManager::FindServiceByName( std::string name) { + LOG4CXX_AUTO_TRACE(logger_); for (auto it = published_services_.begin(); it != published_services_.end(); ++it) { - if (it->second.record[strings::app_service_manifest][strings::service_name] + if (it->second.record[strings::service_manifest][strings::service_name] .asString() == name) { return *it; } diff --git a/src/components/interfaces/HMI_API.xml b/src/components/interfaces/HMI_API.xml index 2a9be1954b..adef6a87cc 100644 --- a/src/components/interfaces/HMI_API.xml +++ b/src/components/interfaces/HMI_API.xml @@ -3572,7 +3572,7 @@ Unique name of this service - + The type of service that is to be offered by this app @@ -3627,7 +3627,7 @@ Contains all the current data of the app service. The serviceType will link to which of the service data objects are included in this object. (eg if service type equals MEDIA, the mediaServiceData param should be included. - + diff --git a/src/components/interfaces/MOBILE_API.xml b/src/components/interfaces/MOBILE_API.xml index 65a88ac22a..4d9bfbf09d 100644 --- a/src/components/interfaces/MOBILE_API.xml +++ b/src/components/interfaces/MOBILE_API.xml @@ -3911,7 +3911,7 @@ Unique name of this service - + The type of service that is to be offered by this app @@ -3966,7 +3966,7 @@ Contains all the current data of the app service. The serviceType will link to which of the service data objects are included in this object. (eg if service type equals MEDIA, the mediaServiceData param should be included. - + -- cgit v1.2.1 From 6875de18acfa7a65e5693477624395d1509d36a8 Mon Sep 17 00:00:00 2001 From: JackLivio Date: Tue, 19 Feb 2019 12:37:19 -0500 Subject: Update policy unit tests --- .../application_manager/test/message_helper/CMakeLists.txt | 1 + .../test/message_helper/message_helper_test.cc | 3 +++ .../policies/mock_policy_handler_interface.h | 10 ++++++++++ .../test/policy/policy_external/policy/mock_cache_manager.h | 4 ++++ .../test/policy/policy_external/policy/mock_policy_manager.h | 4 ++++ .../test/policy/policy_regular/policy/mock_cache_manager.h | 4 ++++ .../test/policy/policy_regular/policy/mock_policy_manager.h | 4 ++++ .../policy/policy_external/test/sql_pt_representation_test.cc | 4 ++-- .../policy/policy_regular/test/sql_pt_representation_test.cc | 4 ++-- 9 files changed, 34 insertions(+), 4 deletions(-) diff --git a/src/components/application_manager/test/message_helper/CMakeLists.txt b/src/components/application_manager/test/message_helper/CMakeLists.txt index d115ad8b40..99031849f6 100755 --- a/src/components/application_manager/test/message_helper/CMakeLists.txt +++ b/src/components/application_manager/test/message_helper/CMakeLists.txt @@ -40,6 +40,7 @@ set(LIBRARIES ApplicationManager MessageHelper jsoncpp + Policy connectionHandler MediaManager Resumption diff --git a/src/components/application_manager/test/message_helper/message_helper_test.cc b/src/components/application_manager/test/message_helper/message_helper_test.cc index 15a09c33cc..b813c36bb4 100644 --- a/src/components/application_manager/test/message_helper/message_helper_test.cc +++ b/src/components/application_manager/test/message_helper/message_helper_test.cc @@ -49,6 +49,9 @@ #include "application_manager/state_controller.h" #include "application_manager/resumption/resume_ctrl.h" +#include "policy/policy_table/types.h" +#include "rpc_base/rpc_base_json_inl.h" + #ifdef EXTERNAL_PROPRIETARY_MODE #include "policy/policy_external/include/policy/policy_types.h" #endif diff --git a/src/components/include/test/application_manager/policies/mock_policy_handler_interface.h b/src/components/include/test/application_manager/policies/mock_policy_handler_interface.h index 02a0d73086..b817b7a361 100644 --- a/src/components/include/test/application_manager/policies/mock_policy_handler_interface.h +++ b/src/components/include/test/application_manager/policies/mock_policy_handler_interface.h @@ -227,6 +227,16 @@ class MockPolicyHandlerInterface : public policy::PolicyHandlerInterface { std::string& hybrid_app_preference)); MOCK_METHOD1(OnSetCloudAppProperties, void(const smart_objects::SmartObject& message)); + MOCK_CONST_METHOD2( + GetAppServiceParameters, + void(const std::string& policy_app_id, + policy_table::AppServiceParameters* app_service_parameters)); + MOCK_CONST_METHOD4( + CheckAppServiceParameters, + bool(const std::string& policy_app_id, + const std::string& requested_service_name, + const mobile_apis::AppServiceType::eType& requested_service_type, + smart_objects::SmartArray* requested_handled_rpcs)); #ifdef EXTERNAL_PROPRIETARY_MODE MOCK_CONST_METHOD0(GetMetaInfo, const policy::MetaInfo()); diff --git a/src/components/include/test/policy/policy_external/policy/mock_cache_manager.h b/src/components/include/test/policy/policy_external/policy/mock_cache_manager.h index da2b4cc2a1..25c391205d 100644 --- a/src/components/include/test/policy/policy_external/policy/mock_cache_manager.h +++ b/src/components/include/test/policy/policy_external/policy/mock_cache_manager.h @@ -98,6 +98,10 @@ class MockCacheManagerInterface : public ::policy::CacheManagerInterface { MOCK_METHOD2(SetHybridAppPreference, void(const std::string& policy_app_id, const std::string& hybrid_app_preference)); + MOCK_CONST_METHOD2( + GetAppServiceParameters, + void(const std::string& policy_app_id, + policy_table::AppServiceParameters* app_service_parameters)); MOCK_CONST_METHOD1(GetDeviceConsent, DeviceConsent(const std::string& device_id)); MOCK_METHOD2(SetDeviceConsent, diff --git a/src/components/include/test/policy/policy_external/policy/mock_policy_manager.h b/src/components/include/test/policy/policy_external/policy/mock_policy_manager.h index 72dcb147e3..7c47202496 100644 --- a/src/components/include/test/policy/policy_external/policy/mock_policy_manager.h +++ b/src/components/include/test/policy/policy_external/policy/mock_policy_manager.h @@ -206,6 +206,10 @@ class MockPolicyManager : public PolicyManager { MOCK_METHOD2(SetHybridAppPreference, void(const std::string& policy_app_id, const std::string& hybrid_app_preference)); + MOCK_CONST_METHOD2( + GetAppServiceParameters, + void(const std::string& policy_app_id, + policy_table::AppServiceParameters* app_service_parameters)); MOCK_CONST_METHOD0(GetMetaInfo, const policy::MetaInfo()); MOCK_CONST_METHOD0(RetrieveCertificate, std::string()); MOCK_CONST_METHOD0(HasCertificate, bool()); diff --git a/src/components/include/test/policy/policy_regular/policy/mock_cache_manager.h b/src/components/include/test/policy/policy_regular/policy/mock_cache_manager.h index 24fe9b2393..c8bff0bbc0 100644 --- a/src/components/include/test/policy/policy_regular/policy/mock_cache_manager.h +++ b/src/components/include/test/policy/policy_regular/policy/mock_cache_manager.h @@ -90,6 +90,10 @@ class MockCacheManagerInterface : public CacheManagerInterface { std::vector( const std::vector& msg_codes, const std::string& language)); + MOCK_CONST_METHOD2( + GetAppServiceParameters, + void(const std::string& policy_app_id, + policy_table::AppServiceParameters* app_service_parameters)); MOCK_METHOD1( GetNotificationsNumber, diff --git a/src/components/include/test/policy/policy_regular/policy/mock_policy_manager.h b/src/components/include/test/policy/policy_regular/policy/mock_policy_manager.h index a5ce488e1a..fe0a301a58 100644 --- a/src/components/include/test/policy/policy_regular/policy/mock_policy_manager.h +++ b/src/components/include/test/policy/policy_regular/policy/mock_policy_manager.h @@ -203,6 +203,10 @@ class MockPolicyManager : public PolicyManager { MOCK_METHOD2(SetHybridAppPreference, void(const std::string& policy_app_id, const std::string& hybrid_app_preference)); + MOCK_CONST_METHOD2( + GetAppServiceParameters, + void(const std::string& policy_app_id, + policy_table::AppServiceParameters* app_service_parameters)); MOCK_CONST_METHOD0(GetMetaInfo, const policy::MetaInfo()); MOCK_CONST_METHOD0(RetrieveCertificate, std::string()); MOCK_CONST_METHOD0(HasCertificate, bool()); diff --git a/src/components/policy/policy_external/test/sql_pt_representation_test.cc b/src/components/policy/policy_external/test/sql_pt_representation_test.cc index fddc5e631e..c43c9dace6 100644 --- a/src/components/policy/policy_external/test/sql_pt_representation_test.cc +++ b/src/components/policy/policy_external/test/sql_pt_representation_test.cc @@ -406,8 +406,8 @@ TEST_F(SQLPTRepresentationTest, query.Prepare(query_select); query.Next(); - // 34 - is current total tables number created by schema - const int policy_tables_number = 34; + // 37 - is current total tables number created by schema + const int policy_tables_number = 37; ASSERT_EQ(policy_tables_number, query.GetInteger(0)); const std::string query_select_count_of_iap_buffer_full = diff --git a/src/components/policy/policy_regular/test/sql_pt_representation_test.cc b/src/components/policy/policy_regular/test/sql_pt_representation_test.cc index 030dc374dd..6448a47b42 100644 --- a/src/components/policy/policy_regular/test/sql_pt_representation_test.cc +++ b/src/components/policy/policy_regular/test/sql_pt_representation_test.cc @@ -426,8 +426,8 @@ TEST_F(SQLPTRepresentationTest, ASSERT_TRUE(reps->RefreshDB()); // Check PT structure destroyed and tables number is 0 - // There are 30 tables in the database, now. - const int32_t total_tables_number = 30; + // There are 33 tables in the database, now. + const int32_t total_tables_number = 33; ASSERT_EQ(total_tables_number, dbms->FetchOneInt(query_select)); const char* query_select_count_of_iap_buffer_full = "SELECT `count_of_iap_buffer_full` FROM `usage_and_error_count`"; -- cgit v1.2.1 From a090527479222dbb659d6e390d034dd5dc72a107 Mon Sep 17 00:00:00 2001 From: JackLivio Date: Tue, 19 Feb 2019 15:29:55 -0500 Subject: Update AppServiceType to string --- .../include/application_manager/policies/policy_handler.h | 2 +- .../mobile/on_app_service_data_notification_from_mobile.cc | 8 +++----- .../src/commands/mobile/publish_app_service_request.cc | 8 +++----- .../application_manager/src/policies/policy_handler.cc | 12 ++++-------- .../application_manager/policies/policy_handler_interface.h | 2 +- .../policies/mock_policy_handler_interface.h | 11 +++++------ .../include/policy/policy_table_interface_ext.xml | 2 +- 7 files changed, 18 insertions(+), 27 deletions(-) diff --git a/src/components/application_manager/include/application_manager/policies/policy_handler.h b/src/components/application_manager/include/application_manager/policies/policy_handler.h index 37474d75c2..df96ade313 100644 --- a/src/components/application_manager/include/application_manager/policies/policy_handler.h +++ b/src/components/application_manager/include/application_manager/policies/policy_handler.h @@ -469,7 +469,7 @@ class PolicyHandler : public PolicyHandlerInterface, bool CheckAppServiceParameters( const std::string& policy_app_id, const std::string& requested_service_name, - const mobile_apis::AppServiceType::eType& requested_service_type, + const std::string& requested_service_type, smart_objects::SmartArray* requested_handled_rpcs) const OVERRIDE; virtual void OnUpdateHMIAppType( diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/on_app_service_data_notification_from_mobile.cc b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/on_app_service_data_notification_from_mobile.cc index 1a90572ecf..96b085c344 100644 --- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/on_app_service_data_notification_from_mobile.cc +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/on_app_service_data_notification_from_mobile.cc @@ -68,11 +68,9 @@ void OnAppServiceDataNotificationFromMobile::Run() { LOG4CXX_DEBUG(logger_, "Received an OnAppServiceData"); MessageHelper::PrintSmartObject(*message_); - // Todo: revision make service type string. - mobile_apis::AppServiceType::eType service_type = - static_cast( - (*message_)[strings::msg_params][strings::app_service_manifest] - [strings::service_type].asUInt()); + std::string service_type = + (*message_)[strings::msg_params][strings::app_service_manifest] + [strings::service_type].asString(); ApplicationSharedPtr app = application_manager_.application(connection_key()); diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/publish_app_service_request.cc b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/publish_app_service_request.cc index 06f7f4b13a..6ef63aa1b8 100644 --- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/publish_app_service_request.cc +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/publish_app_service_request.cc @@ -102,11 +102,9 @@ void PublishAppServiceRequest::Run() { [strings::service_name].asString(); } - // Todo: revision make service type string. - mobile_apis::AppServiceType::eType requested_service_type = - static_cast( - (*message_)[strings::msg_params][strings::app_service_manifest] - [strings::service_type].asUInt()); + std::string requested_service_type = + (*message_)[strings::msg_params][strings::app_service_manifest] + [strings::service_type].asString(); smart_objects::SmartArray* requested_handled_rpcs; if ((*message_)[strings::msg_params][strings::app_service_manifest].keyExists( diff --git a/src/components/application_manager/src/policies/policy_handler.cc b/src/components/application_manager/src/policies/policy_handler.cc index 451a9087d5..9382a8580b 100644 --- a/src/components/application_manager/src/policies/policy_handler.cc +++ b/src/components/application_manager/src/policies/policy_handler.cc @@ -1948,7 +1948,7 @@ void PolicyHandler::GetAppServiceParameters( bool PolicyHandler::CheckAppServiceParameters( const std::string& policy_app_id, const std::string& requested_service_name, - const mobile_apis::AppServiceType::eType& requested_service_type, + const std::string& requested_service_type, smart_objects::SmartArray* requested_handled_rpcs) const { std::string service_name = std::string(); std::string service_type = std::string(); @@ -1958,11 +1958,7 @@ bool PolicyHandler::CheckAppServiceParameters( policy_table::AppServiceParameters(); this->GetAppServiceParameters(policy_app_id, &app_service_parameters); - std::string requested_service_type_str = std::string(); - smart_objects::EnumConversionHelper:: - EnumToString(requested_service_type, &requested_service_type_str); - - if (app_service_parameters.find(requested_service_type_str) == + if (app_service_parameters.find(requested_service_type) == app_service_parameters.end()) { LOG4CXX_DEBUG(logger_, "Disallowed service type: " << requested_service_type); @@ -1971,7 +1967,7 @@ bool PolicyHandler::CheckAppServiceParameters( if (!requested_service_name.empty()) { auto service_names = - *(app_service_parameters[requested_service_type_str].service_names); + *(app_service_parameters[requested_service_type].service_names); auto find_name_result = std::find(service_names.begin(), service_names.end(), @@ -1983,7 +1979,7 @@ bool PolicyHandler::CheckAppServiceParameters( if (requested_handled_rpcs) { auto temp_rpcs = - *(app_service_parameters[requested_service_type_str].handled_rpcs); + *(app_service_parameters[requested_service_type].handled_rpcs); for (auto handled_it = temp_rpcs.begin(); handled_it != temp_rpcs.end(); ++handled_it) { handled_rpcs.push_back(handled_it->function_id); diff --git a/src/components/include/application_manager/policies/policy_handler_interface.h b/src/components/include/application_manager/policies/policy_handler_interface.h index 5f5449fe11..64f0b893b2 100644 --- a/src/components/include/application_manager/policies/policy_handler_interface.h +++ b/src/components/include/application_manager/policies/policy_handler_interface.h @@ -511,7 +511,7 @@ class PolicyHandlerInterface { virtual bool CheckAppServiceParameters( const std::string& policy_app_id, const std::string& requested_service_name, - const mobile_apis::AppServiceType::eType& requested_service_type, + const std::string& requested_service_type, smart_objects::SmartArray* requested_handled_rpcs) const = 0; #ifdef EXTERNAL_PROPRIETARY_MODE diff --git a/src/components/include/test/application_manager/policies/mock_policy_handler_interface.h b/src/components/include/test/application_manager/policies/mock_policy_handler_interface.h index b817b7a361..1db0338caf 100644 --- a/src/components/include/test/application_manager/policies/mock_policy_handler_interface.h +++ b/src/components/include/test/application_manager/policies/mock_policy_handler_interface.h @@ -231,12 +231,11 @@ class MockPolicyHandlerInterface : public policy::PolicyHandlerInterface { GetAppServiceParameters, void(const std::string& policy_app_id, policy_table::AppServiceParameters* app_service_parameters)); - MOCK_CONST_METHOD4( - CheckAppServiceParameters, - bool(const std::string& policy_app_id, - const std::string& requested_service_name, - const mobile_apis::AppServiceType::eType& requested_service_type, - smart_objects::SmartArray* requested_handled_rpcs)); + MOCK_CONST_METHOD4(CheckAppServiceParameters, + bool(const std::string& policy_app_id, + const std::string& requested_service_name, + const std::string& requested_service_type, + smart_objects::SmartArray* requested_handled_rpcs)); #ifdef EXTERNAL_PROPRIETARY_MODE MOCK_CONST_METHOD0(GetMetaInfo, const policy::MetaInfo()); diff --git a/src/components/policy/policy_external/include/policy/policy_table_interface_ext.xml b/src/components/policy/policy_external/include/policy/policy_table_interface_ext.xml index 3b3bc2d7a6..7749c4ee8f 100644 --- a/src/components/policy/policy_external/include/policy/policy_table_interface_ext.xml +++ b/src/components/policy/policy_external/include/policy/policy_table_interface_ext.xml @@ -109,7 +109,7 @@ mandatory="false" /> - + -- cgit v1.2.1 From 9ff0993c4111cf3b4df966f366b857317b9d50e7 Mon Sep 17 00:00:00 2001 From: Shobhit Adlakha Date: Thu, 21 Feb 2019 11:27:36 -0500 Subject: Implemented RpcPassThroughTimeout param and IncreaseForwardedRequestTimeout function --- src/appMain/smartDeviceLink.ini | 10 ++++++++++ .../application_manager/application_manager_impl.h | 9 +++++++++ .../src/application_manager_impl.cc | 11 +++++++++++ .../config_profile/include/config_profile/profile.h | 2 ++ src/components/config_profile/src/profile.cc | 19 ++++++++++++++++++- .../include/application_manager/application_manager.h | 3 +++ .../application_manager_settings.h | 1 + 7 files changed, 54 insertions(+), 1 deletion(-) diff --git a/src/appMain/smartDeviceLink.ini b/src/appMain/smartDeviceLink.ini index ccb377d1e6..50e27452c0 100644 --- a/src/appMain/smartDeviceLink.ini +++ b/src/appMain/smartDeviceLink.ini @@ -359,6 +359,16 @@ EnableAppLaunchIOS = true ;SecondaryTransportForUSB = ;SecondaryTransportForWiFi = +[AppServices] +; The ID to pass to app service publishers when sending a PerformAppServiceInteraction request +;CoresOriginId = "sdl_core" + +; Services that exist on the module. Values are of AppServiceType in RPC Spec. These services will be used as default and app services will only become primary service publisher with direct user interaction. These services will also be a fallback if no app service publisher is registered with the system of that type. +;EmbeddedServices = MEDIA, WEATHER, NAVIGATION, VOICE_ASSISTANT, COMMUNICATION_VOIP, MESSAGING, TTS + +; Additional time added to RPC timeout when passing through to App service +RpcPassThroughTimeout = 10000 + [ServicesMap] ; A matrix to specify which service is allowed on which transports. The transports are listed ; in preferred order. If a transport is not listed, then the service is not allowed diff --git a/src/components/application_manager/include/application_manager/application_manager_impl.h b/src/components/application_manager/include/application_manager/application_manager_impl.h index f72b02e320..8f53b06594 100644 --- a/src/components/application_manager/include/application_manager/application_manager_impl.h +++ b/src/components/application_manager/include/application_manager/application_manager_impl.h @@ -701,6 +701,15 @@ class ApplicationManagerImpl uint32_t mobile_correlation_id, uint32_t new_timeout_value) OVERRIDE; + /** + * @brief TODO + * + * @param connection_key Connection key of application + * @param mobile_correlation_id Correlation ID of the mobile request + */ + void IncreaseForwardedRequestTimeout(uint32_t connection_key, + uint32_t mobile_correlation_id) OVERRIDE; + /** * @brief AddPolicyObserver allows to subscribe needed component to events * from policy. diff --git a/src/components/application_manager/src/application_manager_impl.cc b/src/components/application_manager/src/application_manager_impl.cc index d82eeb776c..b6f4024426 100644 --- a/src/components/application_manager/src/application_manager_impl.cc +++ b/src/components/application_manager/src/application_manager_impl.cc @@ -2383,6 +2383,17 @@ void ApplicationManagerImpl::updateRequestTimeout( connection_key, mobile_correlation_id, new_timeout_value); } +void ApplicationManagerImpl::IncreaseForwardedRequestTimeout( + uint32_t connection_key, uint32_t mobile_correlation_id) { + LOG4CXX_DEBUG(logger_, + "Increasing Request Timeout by " + << get_settings().rpc_pass_through_timeout()); + uint32_t new_timeout_value = get_settings().default_timeout() + + get_settings().rpc_pass_through_timeout(); + request_ctrl_.updateRequestTimeout( + connection_key, mobile_correlation_id, new_timeout_value); +} + uint32_t ApplicationManagerImpl::application_id(const int32_t correlation_id) { // ykazakov: there is no erase for const iterator for QNX std::map::iterator it = diff --git a/src/components/config_profile/include/config_profile/profile.h b/src/components/config_profile/include/config_profile/profile.h index 4846648b2b..4747e50fdc 100644 --- a/src/components/config_profile/include/config_profile/profile.h +++ b/src/components/config_profile/include/config_profile/profile.h @@ -526,6 +526,7 @@ class Profile : public protocol_handler::ProtocolHandlerSettings, const std::vector& audio_service_transports() const OVERRIDE; const std::vector& video_service_transports() const OVERRIDE; + uint32_t rpc_pass_through_timeout() const; /** * @brief Reads a string value from the profile * @@ -1063,6 +1064,7 @@ class Profile : public protocol_handler::ProtocolHandlerSettings, int low_voltage_signal_offset_; int wake_up_signal_offset_; int ignition_off_signal_offset_; + uint32_t rpc_pass_through_timeout_; DISALLOW_COPY_AND_ASSIGN(Profile); }; diff --git a/src/components/config_profile/src/profile.cc b/src/components/config_profile/src/profile.cc index 38afdbf35b..b324087689 100644 --- a/src/components/config_profile/src/profile.cc +++ b/src/components/config_profile/src/profile.cc @@ -91,6 +91,7 @@ const char* kSDL5Section = "SDL5"; const char* kResumptionSection = "Resumption"; const char* kAppLaunchSection = "AppLaunch"; const char* kMultipleTransportsSection = "MultipleTransports"; +const char* kAppServicesSection = "AppServices"; const char* kServicesMapSection = "ServicesMap"; const char* kTransportRequiredForResumptionSection = "TransportRequiredForResumption"; @@ -238,6 +239,7 @@ const char* kSecondaryTransportForUSBKey = "SecondaryTransportForUSB"; const char* kSecondaryTransportForWiFiKey = "SecondaryTransportForWiFi"; const char* kAudioServiceTransportsKey = "AudioServiceTransports"; const char* kVideoServiceTransportsKey = "VideoServiceTransports"; +const char* kRpcPassThroughTimeoutKey = "RpcPassThroughTimeout"; const char* kDefaultTransportRequiredForResumptionKey = "DefaultTransportRequiredForResumption"; @@ -391,6 +393,7 @@ const std::string kAllowedSymbols = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ01234567890_.-"; const bool kDefaultMultipleTransportsEnabled = false; const char* kDefaultLowBandwidthResumptionLevel = "NONE"; +const uint32_t kDefaultRpcPassThroughTimeout = 10000; } // namespace namespace profile { @@ -506,7 +509,8 @@ Profile::Profile() , error_description_() , low_voltage_signal_offset_(kDefaultLowVoltageSignalOffset) , wake_up_signal_offset_(kDefaultWakeUpSignalOffset) - , ignition_off_signal_offset_(kDefaultIgnitionOffSignalOffset) { + , ignition_off_signal_offset_(kDefaultIgnitionOffSignalOffset) + , rpc_pass_through_timeout_(kDefaultRpcPassThroughTimeout) { // SDL version ReadStringValue( &sdl_version_, kDefaultSDLVersion, kMainSection, kSDLVersionKey); @@ -1078,6 +1082,10 @@ const bool Profile::multiple_transports_enabled() const { return multiple_transports_enabled_; } +uint32_t Profile::rpc_pass_through_timeout() const { + return rpc_pass_through_timeout_; +} + const std::vector& Profile::secondary_transports_for_bluetooth() const { return secondary_transports_for_bluetooth_; @@ -2235,6 +2243,15 @@ void Profile::UpdateValues() { kMultipleTransportsEnabledKey, kMultipleTransportsSection); + ReadUIntValue(&rpc_pass_through_timeout_, + kDefaultRpcPassThroughTimeout, + kAppServicesSection, + kRpcPassThroughTimeoutKey); + + LOG_UPDATED_VALUE(rpc_pass_through_timeout_, + kRpcPassThroughTimeoutKey, + kAppServicesSection); + { // Secondary Transports and ServicesMap struct KeyPair { std::vector* ini_vector; diff --git a/src/components/include/application_manager/application_manager.h b/src/components/include/application_manager/application_manager.h index b542a66b83..b506caa47f 100644 --- a/src/components/include/application_manager/application_manager.h +++ b/src/components/include/application_manager/application_manager.h @@ -559,6 +559,9 @@ class ApplicationManager { uint32_t mobile_correlation_id, uint32_t new_timeout_value) = 0; + virtual void IncreaseForwardedRequestTimeout( + uint32_t connection_key, uint32_t mobile_correlation_id) = 0; + virtual StateController& state_controller() = 0; virtual void SetUnregisterAllApplicationsReason( diff --git a/src/components/include/application_manager/application_manager_settings.h b/src/components/include/application_manager/application_manager_settings.h index fc16f1f1ed..23e903920a 100644 --- a/src/components/include/application_manager/application_manager_settings.h +++ b/src/components/include/application_manager/application_manager_settings.h @@ -85,6 +85,7 @@ class ApplicationManagerSettings : public RequestControlerSettings, virtual const std::string& audio_stream_file() const = 0; virtual bool use_full_app_id() const = 0; + virtual uint32_t rpc_pass_through_timeout() const = 0; virtual uint32_t cloud_app_retry_timeout() const = 0; virtual uint16_t cloud_app_max_retry_attempts() const = 0; virtual bool use_db_for_resumption() const = 0; -- cgit v1.2.1 From 8a442f27a9e408cb9071559757a029bd59a6a58a Mon Sep 17 00:00:00 2001 From: Shobhit Adlakha Date: Thu, 21 Feb 2019 14:06:25 -0500 Subject: Fixed build tests --- src/components/application_manager/src/app_service_manager.cc | 1 - .../include/test/application_manager/mock_application_manager.h | 2 ++ .../test/application_manager/mock_application_manager_settings.h | 1 + 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/components/application_manager/src/app_service_manager.cc b/src/components/application_manager/src/app_service_manager.cc index 8fea64b228..3a01ce1303 100644 --- a/src/components/application_manager/src/app_service_manager.cc +++ b/src/components/application_manager/src/app_service_manager.cc @@ -103,7 +103,6 @@ std::vector AppServiceManager::GetAllServices() { return services; } - std::pair AppServiceManager::ActiveServiceByType( std::string service_type) { LOG4CXX_AUTO_TRACE(logger_); diff --git a/src/components/include/test/application_manager/mock_application_manager.h b/src/components/include/test/application_manager/mock_application_manager.h index 04029adda3..0065ad0a58 100644 --- a/src/components/include/test/application_manager/mock_application_manager.h +++ b/src/components/include/test/application_manager/mock_application_manager.h @@ -217,6 +217,8 @@ class MockApplicationManager : public application_manager::ApplicationManager { void(uint32_t connection_key, uint32_t mobile_correlation_id, uint32_t new_timeout_value)); + MOCK_METHOD2(IncreaseForwardedRequestTimeout, + void(uint32_t connection_key, uint32_t mobile_correlation_id)); MOCK_METHOD0(state_controller, application_manager::StateController&()); MOCK_METHOD1(SetUnregisterAllApplicationsReason, void(mobile_apis::AppInterfaceUnregisteredReason::eType reason)); diff --git a/src/components/include/test/application_manager/mock_application_manager_settings.h b/src/components/include/test/application_manager/mock_application_manager_settings.h index 0f9ca194b1..79ff1813b0 100644 --- a/src/components/include/test/application_manager/mock_application_manager_settings.h +++ b/src/components/include/test/application_manager/mock_application_manager_settings.h @@ -127,6 +127,7 @@ class MockApplicationManagerSettings MOCK_CONST_METHOD0(app_time_scale, const uint32_t&()); MOCK_CONST_METHOD0(app_time_scale_max_requests, const uint32_t&()); MOCK_CONST_METHOD0(pending_requests_amount, const uint32_t&()); + MOCK_CONST_METHOD0(rpc_pass_through_timeout, uint32_t()); // app_launch::AppLaunchSettings MOCK_CONST_METHOD0(app_launch_wait_time, const uint16_t()); -- cgit v1.2.1 From c265243158028a834e84b9ecbfad20f73a64b14a Mon Sep 17 00:00:00 2001 From: JackLivio Date: Thu, 21 Feb 2019 15:50:35 -0500 Subject: Config for embeddedServices and CoresOriginID --- src/appMain/smartDeviceLink.ini | 7 +++ .../include/config_profile/profile.h | 6 +++ src/components/config_profile/src/profile.cc | 50 ++++++++++++++++++++++ .../application_manager_settings.h | 2 + .../mock_application_manager_settings.h | 4 ++ 5 files changed, 69 insertions(+) diff --git a/src/appMain/smartDeviceLink.ini b/src/appMain/smartDeviceLink.ini index ccb377d1e6..54a86113a3 100644 --- a/src/appMain/smartDeviceLink.ini +++ b/src/appMain/smartDeviceLink.ini @@ -369,3 +369,10 @@ EnableAppLaunchIOS = true ; Note: this configuration is applied even if multiple-transports feature is not enabled. ;AudioServiceTransports = TCP_WIFI, IAP_CARPLAY, IAP_USB_HOST_MODE, IAP_USB_DEVICE_MODE, IAP_USB, AOA_USB ;VideoServiceTransports = TCP_WIFI, IAP_CARPLAY, IAP_USB_HOST_MODE, IAP_USB_DEVICE_MODE, IAP_USB, AOA_USB + +[AppServices] +; The ID to pass to app service publishers when sending a PerformAppServiceInteraction request +CoresOriginId = "sdl_core" + +; Services that exist on the module. Values are of AppServiceType in RPC Spec. These services will be used as default and app services will only become primary service publisher with direct user interaction. These services will also be a fallback if no app service publisher is registered with the system of that type. +EmbeddedServices = MEDIA, WEATHER, NAVIGATION, VOICE_ASSISTANT diff --git a/src/components/config_profile/include/config_profile/profile.h b/src/components/config_profile/include/config_profile/profile.h index 4846648b2b..1d3882d88b 100644 --- a/src/components/config_profile/include/config_profile/profile.h +++ b/src/components/config_profile/include/config_profile/profile.h @@ -526,6 +526,8 @@ class Profile : public protocol_handler::ProtocolHandlerSettings, const std::vector& audio_service_transports() const OVERRIDE; const std::vector& video_service_transports() const OVERRIDE; + const std::vector& embedded_services() const OVERRIDE; + const std::string cores_origin_id() const OVERRIDE; /** * @brief Reads a string value from the profile * @@ -1064,6 +1066,10 @@ class Profile : public protocol_handler::ProtocolHandlerSettings, int wake_up_signal_offset_; int ignition_off_signal_offset_; + std::vector embedded_services_; + + std::string cores_origin_id_; + DISALLOW_COPY_AND_ASSIGN(Profile); }; } // namespace profile diff --git a/src/components/config_profile/src/profile.cc b/src/components/config_profile/src/profile.cc index 38afdbf35b..27c45d19ca 100644 --- a/src/components/config_profile/src/profile.cc +++ b/src/components/config_profile/src/profile.cc @@ -96,6 +96,7 @@ const char* kTransportRequiredForResumptionSection = "TransportRequiredForResumption"; const char* kLowBandwidthTransportResumptionLevelSection = "LowBandwidthTransportResumptionLevel"; +const char* kAppServicesSection = "AppServices"; const char* kSDLVersionKey = "SDLVersion"; const char* kHmiCapabilitiesKey = "HMICapabilities"; @@ -284,6 +285,8 @@ const char* kProjectionLowBandwidthResumptionLevelKey = "ProjectionLowBandwidthResumptionLevel"; const char* kMediaLowBandwidthResumptionLevelKey = "MediaLowBandwidthResumptionLevel"; +const char* kCoresOriginIdKey = "CoresOriginId"; +const char* kEmbeddedServicesKey = "EmbeddedServices"; #ifdef WEB_HMI const char* kDefaultLinkToWebHMI = "HMI/index.html"; @@ -391,6 +394,7 @@ const std::string kAllowedSymbols = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ01234567890_.-"; const bool kDefaultMultipleTransportsEnabled = false; const char* kDefaultLowBandwidthResumptionLevel = "NONE"; +const char* kDefaultCoresOriginId = "sdl_core"; } // namespace namespace profile { @@ -1114,6 +1118,14 @@ bool Profile::IsFileNamePortable(const std::string& file_name) const { return true; } +const std::vector& Profile::embedded_services() const { + return embedded_services_; +} + +const std::string Profile::cores_origin_id() const { + return cores_origin_id_; +} + void Profile::UpdateValues() { LOG4CXX_AUTO_TRACE(logger_); @@ -2278,6 +2290,44 @@ void Profile::UpdateValues() { entry++; } } + + ReadStringValue(&cores_origin_id_, + kDefaultCoresOriginId, + kAppServicesSection, + kCoresOriginIdKey); + + LOG_UPDATED_VALUE(cores_origin_id_, kCoresOriginIdKey, kAppServicesSection); + + { // App Services map + struct KeyPair { + std::vector* ini_vector; + const char* ini_section_name; + const char* ini_key_name; + } keys[] = { + {&embedded_services_, kAppServicesSection, kEmbeddedServicesKey}, + {NULL, NULL, NULL}}; + struct KeyPair* entry = keys; + + while (entry->ini_vector != NULL) { + bool exist = false; + std::vector profile_entry = ReadStringContainer( + entry->ini_section_name, entry->ini_key_name, &exist, true); + if (exist) { + *entry->ini_vector = profile_entry; + + const std::string list_with_comma = std::accumulate( + profile_entry.begin(), + profile_entry.end(), + std::string(""), + [](std::string& first, std::string& second) { + return first.empty() ? second : first + ", " + second; + }); + LOG_UPDATED_VALUE( + list_with_comma, entry->ini_key_name, entry->ini_section_name); + } + entry++; + } + } } bool Profile::ReadValue(bool* value, diff --git a/src/components/include/application_manager/application_manager_settings.h b/src/components/include/application_manager/application_manager_settings.h index fc16f1f1ed..3e9830b202 100644 --- a/src/components/include/application_manager/application_manager_settings.h +++ b/src/components/include/application_manager/application_manager_settings.h @@ -109,6 +109,8 @@ class ApplicationManagerSettings : public RequestControlerSettings, virtual const uint32_t& app_icons_amount_to_remove() const = 0; virtual const uint32_t& list_files_response_size() const = 0; virtual const std::string& plugins_folder() const = 0; + virtual const std::vector& embedded_services() const = 0; + virtual const std::string cores_origin_id() const = 0; }; } // namespace application_manager diff --git a/src/components/include/test/application_manager/mock_application_manager_settings.h b/src/components/include/test/application_manager/mock_application_manager_settings.h index 0f9ca194b1..392b5a0ab3 100644 --- a/src/components/include/test/application_manager/mock_application_manager_settings.h +++ b/src/components/include/test/application_manager/mock_application_manager_settings.h @@ -136,6 +136,10 @@ class MockApplicationManagerSettings MOCK_CONST_METHOD0(max_number_of_ios_device, const uint16_t()); MOCK_CONST_METHOD0(wait_time_between_apps, const uint16_t()); MOCK_CONST_METHOD0(enable_app_launch_ios, const bool()); + + // AppServices + MOCK_CONST_METHOD0(embedded_services, const std::vector&()); + MOCK_CONST_METHOD0(cores_origin_id, const std::string()); }; } // namespace application_manager_test -- cgit v1.2.1 From 1155779394444363ff18eb7771aa295f18261566 Mon Sep 17 00:00:00 2001 From: JackLivio Date: Thu, 21 Feb 2019 16:11:51 -0500 Subject: Update to HMIOriginID --- src/appMain/smartDeviceLink.ini | 2 +- .../config_profile/include/config_profile/profile.h | 4 ++-- src/components/config_profile/src/profile.cc | 16 ++++++++-------- .../application_manager/application_manager_settings.h | 2 +- .../mock_application_manager_settings.h | 2 +- 5 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/appMain/smartDeviceLink.ini b/src/appMain/smartDeviceLink.ini index 54a86113a3..954381afeb 100644 --- a/src/appMain/smartDeviceLink.ini +++ b/src/appMain/smartDeviceLink.ini @@ -372,7 +372,7 @@ EnableAppLaunchIOS = true [AppServices] ; The ID to pass to app service publishers when sending a PerformAppServiceInteraction request -CoresOriginId = "sdl_core" +HMIOriginID = "HMI_ID" ; Services that exist on the module. Values are of AppServiceType in RPC Spec. These services will be used as default and app services will only become primary service publisher with direct user interaction. These services will also be a fallback if no app service publisher is registered with the system of that type. EmbeddedServices = MEDIA, WEATHER, NAVIGATION, VOICE_ASSISTANT diff --git a/src/components/config_profile/include/config_profile/profile.h b/src/components/config_profile/include/config_profile/profile.h index 1d3882d88b..02fff3764b 100644 --- a/src/components/config_profile/include/config_profile/profile.h +++ b/src/components/config_profile/include/config_profile/profile.h @@ -527,7 +527,7 @@ class Profile : public protocol_handler::ProtocolHandlerSettings, const std::vector& video_service_transports() const OVERRIDE; const std::vector& embedded_services() const OVERRIDE; - const std::string cores_origin_id() const OVERRIDE; + const std::string hmi_origin_id() const OVERRIDE; /** * @brief Reads a string value from the profile * @@ -1068,7 +1068,7 @@ class Profile : public protocol_handler::ProtocolHandlerSettings, std::vector embedded_services_; - std::string cores_origin_id_; + std::string hmi_origin_id_; DISALLOW_COPY_AND_ASSIGN(Profile); }; diff --git a/src/components/config_profile/src/profile.cc b/src/components/config_profile/src/profile.cc index 27c45d19ca..5a6d3b3808 100644 --- a/src/components/config_profile/src/profile.cc +++ b/src/components/config_profile/src/profile.cc @@ -285,7 +285,7 @@ const char* kProjectionLowBandwidthResumptionLevelKey = "ProjectionLowBandwidthResumptionLevel"; const char* kMediaLowBandwidthResumptionLevelKey = "MediaLowBandwidthResumptionLevel"; -const char* kCoresOriginIdKey = "CoresOriginId"; +const char* kHMIOriginIDKey = "HMIOriginID"; const char* kEmbeddedServicesKey = "EmbeddedServices"; #ifdef WEB_HMI @@ -394,7 +394,7 @@ const std::string kAllowedSymbols = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ01234567890_.-"; const bool kDefaultMultipleTransportsEnabled = false; const char* kDefaultLowBandwidthResumptionLevel = "NONE"; -const char* kDefaultCoresOriginId = "sdl_core"; +const char* kDefaultHMIOriginId = "HMI_ID"; } // namespace namespace profile { @@ -1122,8 +1122,8 @@ const std::vector& Profile::embedded_services() const { return embedded_services_; } -const std::string Profile::cores_origin_id() const { - return cores_origin_id_; +const std::string Profile::hmi_origin_id() const { + return hmi_origin_id_; } void Profile::UpdateValues() { @@ -2291,12 +2291,12 @@ void Profile::UpdateValues() { } } - ReadStringValue(&cores_origin_id_, - kDefaultCoresOriginId, + ReadStringValue(&hmi_origin_id_, + kDefaultHMIOriginId, kAppServicesSection, - kCoresOriginIdKey); + kHMIOriginIDKey); - LOG_UPDATED_VALUE(cores_origin_id_, kCoresOriginIdKey, kAppServicesSection); + LOG_UPDATED_VALUE(hmi_origin_id_, kHMIOriginIDKey, kAppServicesSection); { // App Services map struct KeyPair { diff --git a/src/components/include/application_manager/application_manager_settings.h b/src/components/include/application_manager/application_manager_settings.h index 3e9830b202..a48d0ecc63 100644 --- a/src/components/include/application_manager/application_manager_settings.h +++ b/src/components/include/application_manager/application_manager_settings.h @@ -110,7 +110,7 @@ class ApplicationManagerSettings : public RequestControlerSettings, virtual const uint32_t& list_files_response_size() const = 0; virtual const std::string& plugins_folder() const = 0; virtual const std::vector& embedded_services() const = 0; - virtual const std::string cores_origin_id() const = 0; + virtual const std::string hmi_origin_id() const = 0; }; } // namespace application_manager diff --git a/src/components/include/test/application_manager/mock_application_manager_settings.h b/src/components/include/test/application_manager/mock_application_manager_settings.h index 392b5a0ab3..b95a219111 100644 --- a/src/components/include/test/application_manager/mock_application_manager_settings.h +++ b/src/components/include/test/application_manager/mock_application_manager_settings.h @@ -139,7 +139,7 @@ class MockApplicationManagerSettings // AppServices MOCK_CONST_METHOD0(embedded_services, const std::vector&()); - MOCK_CONST_METHOD0(cores_origin_id, const std::string()); + MOCK_CONST_METHOD0(hmi_origin_id, const std::string()); }; } // namespace application_manager_test -- cgit v1.2.1 From 5a2bd2df26fb3895f76778490f0aa7974215a812 Mon Sep 17 00:00:00 2001 From: JackLivio Date: Thu, 21 Feb 2019 16:53:38 -0500 Subject: Fix regex command for reading paths post port number --- .../transport_manager/src/cloud/cloud_websocket_transport_adapter.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/transport_manager/src/cloud/cloud_websocket_transport_adapter.cc b/src/components/transport_manager/src/cloud/cloud_websocket_transport_adapter.cc index 9f2b8e6ade..8a7acaa5f7 100644 --- a/src/components/transport_manager/src/cloud/cloud_websocket_transport_adapter.cc +++ b/src/components/transport_manager/src/cloud/cloud_websocket_transport_adapter.cc @@ -87,7 +87,7 @@ void CloudWebsocketTransportAdapter::CreateDevice(const std::string& uid) { // Extract host and port from endpoint string boost::regex group_pattern( - "(wss?:\\/\\/)([A-Z\\d\\.-]{2,}\\.?([A-Z]{2,})?)(:)(\\d{2,4})(\\/)"); + "(wss?:\\/\\/)([A-Z\\d\\.-]{2,}\\.?([A-Z]{2,})?)(:)(\\d{2,4})(\\/)(((([A-Z\\d\\.-]{1,})(\\/)?){1,})?){1,}"); boost::smatch results; std::string host = ""; -- cgit v1.2.1 From a4011490d9aa4606d6d835690bc8703c4375526b Mon Sep 17 00:00:00 2001 From: Shobhit Adlakha Date: Thu, 21 Feb 2019 17:53:08 -0500 Subject: SystemCapability Subscription (#2800) * Added subscribe paramater and SystemCapability App Extension * Added SystemCapability app extension in sdl_rpc_plugin * Added enabling/disabling subscription in * Added and implemented OnSystemCapabilityUpdated notification * Add binary data to OEM_SPECIFIC request type * Add check for missing presetBankCapabilities in Buttons.GetCapabilities * Revert "Add missing resource close in LoadPlugin" This reverts commit 35defc42777c57412cbf8b793489ab0dac502f4e. * Genericize vehicle info in hmi_capabilities.json * Added subscribe paramater and SystemCapability App Extension * Added SystemCapability app extension in sdl_rpc_plugin * Added enabling/disabling subscription in * Added and implemented OnSystemCapabilityUpdated notification * Added AppServices structs to MOBILE API * Add binary data to OEM_SPECIFIC request type * Add check for missing presetBankCapabilities in Buttons.GetCapabilities * Revert "Add missing resource close in LoadPlugin" This reverts commit 35defc42777c57412cbf8b793489ab0dac502f4e. * Genericize vehicle info in hmi_capabilities.json * Added subscribe paramater and SystemCapability App Extension * Added SystemCapability app extension in sdl_rpc_plugin * Added enabling/disabling subscription in * Added and implemented OnSystemCapabilityUpdated notification * Added and implemented OnSystemCapabilityUpdated notification * Added AppServices structs to MOBILE API * Add binary data to OEM_SPECIFIC request type * Add check for missing presetBankCapabilities in Buttons.GetCapabilities * Revert "Add missing resource close in LoadPlugin" This reverts commit 35defc42777c57412cbf8b793489ab0dac502f4e. * Genericize vehicle info in hmi_capabilities.json * Added subscribe paramater and SystemCapability App Extension * Added SystemCapability app extension in sdl_rpc_plugin * Added enabling/disabling subscription in * Added and implemented OnSystemCapabilityUpdated notification * Added AppServices structs to MOBILE API * Implemented AppServiceCapabilities response * Renamed SystemCapability App Extension filename and ExtractExtension function * Fix style * Add OnSystemCapabilityUpdated(APP_SERVICES) handling * Fix missing include and unused variables * Made fix in App service manager and added notifcation RPC to policy table * Implemented automatic app system capability subscription of App Service Provider * Add binary data to OEM_SPECIFIC request type * Add check for missing presetBankCapabilities in Buttons.GetCapabilities * Revert "Add missing resource close in LoadPlugin" This reverts commit 35defc42777c57412cbf8b793489ab0dac502f4e. * Genericize vehicle info in hmi_capabilities.json * Added subscribe paramater and SystemCapability App Extension * Added SystemCapability app extension in sdl_rpc_plugin * Added enabling/disabling subscription in * Added and implemented OnSystemCapabilityUpdated notification * Added AppServices structs to MOBILE API * Implemented AppServiceCapabilities response * Renamed SystemCapability App Extension filename and ExtractExtension function * Fix style * Add OnSystemCapabilityUpdated(APP_SERVICES) handling * Fix missing include and unused variables * Made fix in App service manager and added notifcation RPC to policy table * Implemented automatic app system capability subscription of App Service Provider * Rebase and style fix * Added all published app services in OnSystemCapabilityUpdate notification * Add binary data to OEM_SPECIFIC request type * Add check for missing presetBankCapabilities in Buttons.GetCapabilities * Revert "Add missing resource close in LoadPlugin" This reverts commit 35defc42777c57412cbf8b793489ab0dac502f4e. * Genericize vehicle info in hmi_capabilities.json * Added subscribe paramater and SystemCapability App Extension * Added SystemCapability app extension in sdl_rpc_plugin * Added enabling/disabling subscription in * Added and implemented OnSystemCapabilityUpdated notification * Added AppServices structs to MOBILE API * Implemented AppServiceCapabilities response * Renamed SystemCapability App Extension filename and ExtractExtension function * Fix style * Add OnSystemCapabilityUpdated(APP_SERVICES) handling * Fix missing include and unused variables * Made fix in App service manager and added notifcation RPC to policy table * Implemented automatic app system capability subscription of App Service Provider * Added subscribe paramater and SystemCapability App Extension * Added SystemCapability app extension in sdl_rpc_plugin * Added and implemented OnSystemCapabilityUpdated notification * Renamed SystemCapability App Extension filename and ExtractExtension function * Fix style * Add OnSystemCapabilityUpdated(APP_SERVICES) handling * Made fix in App service manager and added notifcation RPC to policy table * Rebase and style fix * Added all published app services in OnSystemCapabilityUpdate notification * Applied parameter updateReason only to published app service which triggers OnSystemCapabilityUpdated notification * Implemented OnSystemCapabilityUpdated notification to HMI * Addressed review comments * Implemented UnPublishAppService in ASM * Implemented ASP removal notification * Moved ASP removal notification to ApplicationManagerImpl::UnregisterApplication * Moved HMI OSCU notification from app services plugin to sdl rpc plugin * Initialize AppServiceManager in Application manager tests * Moved create notification functions to message helper class * Fix style * Removed setServiceActive function * Update SystemCapability structs with new revisions * Fixed error from previous commit and addressed style comments * Addressed review comments * Addressed review comments and removed extra debug statements --- src/appMain/sdl_preloaded_pt.json | 6 ++ .../application_manager/app_service_manager.h | 14 ++++ .../application_manager/application_manager_impl.h | 5 ++ .../include/application_manager/message_helper.h | 10 +++ .../application_manager/smart_object_keys.h | 5 ++ .../app_service_rpc_plugin/CMakeLists.txt | 6 +- .../commands/hmi/as_publish_app_service_request.cc | 1 + .../commands/mobile/publish_app_service_request.cc | 9 +- .../rpc_plugins/sdl_rpc_plugin/CMakeLists.txt | 6 +- .../on_bc_system_capability_updated_notification.h | 79 +++++++++++++++++ .../on_system_capability_updated_notification.h | 84 +++++++++++++++++++ .../extensions/system_capability_app_extension.h | 83 ++++++++++++++++++ .../include/sdl_rpc_plugin/sdl_rpc_plugin.h | 25 +++--- ...on_bc_system_capability_updated_notification.cc | 67 +++++++++++++++ .../mobile/get_system_capability_request.cc | 41 +++++++++ .../on_system_capability_updated_notification.cc | 70 ++++++++++++++++ .../extensions/system_capability_app_extension.cc | 98 ++++++++++++++++++++++ .../sdl_rpc_plugin/src/hmi_command_factory.cc | 6 ++ .../sdl_rpc_plugin/src/mobile_command_factory.cc | 5 ++ .../sdl_rpc_plugin/src/sdl_rpc_plugin.cc | 37 +++++--- .../application_manager/src/app_service_manager.cc | 70 +++++++++++++++- .../src/application_manager_impl.cc | 2 + .../src/message_helper/message_helper.cc | 51 +++++++++++ .../application_manager/src/smart_object_keys.cc | 5 ++ .../test/application_manager_impl_test.cc | 3 + .../application_manager/mock_message_helper.h | 10 +++ .../test/mock_message_helper.cc | 18 ++++ .../src/messagebroker_adapter.cc | 2 + src/components/interfaces/HMI_API.xml | 80 ++++++++++++++++-- src/components/interfaces/MOBILE_API.xml | 86 +++++++++++++++---- .../include/policy/policy_table/enums.h | 5 ++ .../policy_external/src/policy_table/enums.cc | 5 ++ .../include/policy/policy_table/enums.h | 5 ++ .../policy_regular/src/policy_table/enums.cc | 9 ++ 34 files changed, 952 insertions(+), 56 deletions(-) create mode 100644 src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_bc_system_capability_updated_notification.h create mode 100644 src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/on_system_capability_updated_notification.h create mode 100644 src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/extensions/system_capability_app_extension.h create mode 100644 src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_bc_system_capability_updated_notification.cc create mode 100644 src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_system_capability_updated_notification.cc create mode 100644 src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/extensions/system_capability_app_extension.cc diff --git a/src/appMain/sdl_preloaded_pt.json b/src/appMain/sdl_preloaded_pt.json index 06ab56bc39..57f7587542 100644 --- a/src/appMain/sdl_preloaded_pt.json +++ b/src/appMain/sdl_preloaded_pt.json @@ -180,6 +180,12 @@ "LIMITED", "NONE"] }, + "OnSystemCapabilityUpdated": { + "hmi_levels": ["BACKGROUND", + "FULL", + "LIMITED", + "NONE"] + }, "PerformAudioPassThru": { "hmi_levels": ["FULL", "LIMITED"] diff --git a/src/components/application_manager/include/application_manager/app_service_manager.h b/src/components/application_manager/include/application_manager/app_service_manager.h index 97df35e2b4..c1f8a52370 100644 --- a/src/components/application_manager/include/application_manager/app_service_manager.h +++ b/src/components/application_manager/include/application_manager/app_service_manager.h @@ -77,6 +77,20 @@ class AppServiceManager { */ bool UnpublishAppService(const std::string service_id); + /** + * @brief TODO + * @param connection_key + */ + void UnpublishServices(const uint32_t connection_key); + + /** + * @brief TODO + * @param service_id + * @param service_published + */ + void SetServicePublished(const std::string service_id, + bool service_published); + /** * @brief TODO * @param service_id diff --git a/src/components/application_manager/include/application_manager/application_manager_impl.h b/src/components/application_manager/include/application_manager/application_manager_impl.h index f72b02e320..16bfb9e7de 100644 --- a/src/components/application_manager/include/application_manager/application_manager_impl.h +++ b/src/components/application_manager/include/application_manager/application_manager_impl.h @@ -1535,6 +1535,11 @@ class ApplicationManagerImpl plugin_manager_.reset(plugin_manager.release()); } + virtual void SetAppServiceManager( + std::unique_ptr& app_service_manager) { + app_service_manager_.reset(app_service_manager.release()); + } + private: #endif diff --git a/src/components/application_manager/include/application_manager/message_helper.h b/src/components/application_manager/include/application_manager/message_helper.h index 609b240301..0487355056 100644 --- a/src/components/application_manager/include/application_manager/message_helper.h +++ b/src/components/application_manager/include/application_manager/message_helper.h @@ -878,6 +878,16 @@ class MessageHelper { static smart_objects::SmartObjectSPtr CreateMessageForHMI( hmi_apis::messageType::eType message_type, const uint32_t correlation_id); + static smart_objects::SmartObject CreateMobileSystemCapabilityNotification( + std::vector& all_services, + const std::string service_id, + mobile_apis::ServiceUpdateReason::eType update_reason); + + static smart_objects::SmartObject CreateHMISystemCapabilityNotification( + std::vector& all_services, + const std::string service_id, + mobile_apis::ServiceUpdateReason::eType update_reason); + private: /** * @brief Allows to fill SO according to the current permissions. 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 19b2daaaf4..af334d5e97 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 @@ -60,6 +60,7 @@ extern const char* app_launch_last_session; extern const char* policy_app_id; extern const char* hmi_app_id; extern const char* device_id; +extern const char* subscribe; extern const char* subscribed_for_way_points; extern const char* url; extern const char* urlScheme; @@ -178,6 +179,7 @@ extern const char* navigation_capability; extern const char* phone_capability; extern const char* video_streaming_capability; extern const char* rc_capability; +extern const char* app_services_capabilities; extern const char* day_color_scheme; extern const char* night_color_scheme; extern const char* primary_color; @@ -316,6 +318,9 @@ extern const char* service_id; extern const char* service_manifest; extern const char* service_published; extern const char* service_active; +extern const char* app_services; +extern const char* update_reason; +extern const char* updated_app_service_record; // resuming extern const char* application_commands; diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/CMakeLists.txt b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/CMakeLists.txt index e254c36587..2bdc150906 100644 --- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/CMakeLists.txt +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/CMakeLists.txt @@ -28,7 +28,10 @@ # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE # POSSIBILITY OF SUCH DAMAGE. -include_directories(include) +include_directories( + include + ${COMPONENTS_DIR}/application_manager/rpc_plugins/sdl_rpc_plugin/include + ) set (COMMANDS_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/src/commands @@ -54,6 +57,7 @@ set(LIBRARIES v4_protocol_v1_2_no_extra SmartObjects Utils + sdl_rpc_plugin ) if(ENABLE_LOG) diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_publish_app_service_request.cc b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_publish_app_service_request.cc index 89da1e744c..a3e6bfed2a 100644 --- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_publish_app_service_request.cc +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_publish_app_service_request.cc @@ -78,6 +78,7 @@ bool ASPublishAppServiceRequest::ValidateManifest( void ASPublishAppServiceRequest::Run() { LOG4CXX_AUTO_TRACE(logger_); + LOG4CXX_DEBUG(logger_, "Received a PublishAppService request from HMI"); smart_objects::SmartObject response_params = smart_objects::SmartObject(smart_objects::SmartType_Map); smart_objects::SmartObject manifest = diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/publish_app_service_request.cc b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/publish_app_service_request.cc index 7a0333e763..96f17f732a 100644 --- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/publish_app_service_request.cc +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/publish_app_service_request.cc @@ -35,6 +35,7 @@ #include "application_manager/message_helper.h" #include "application_manager/rpc_service.h" #include "interfaces/MOBILE_API.h" +#include "sdl_rpc_plugin/extensions/system_capability_app_extension.h" namespace app_service_rpc_plugin { using namespace application_manager; @@ -79,7 +80,7 @@ bool PublishAppServiceRequest::ValidateManifest( void PublishAppServiceRequest::Run() { LOG4CXX_AUTO_TRACE(logger_); - LOG4CXX_DEBUG(logger_, "Received a PublishAppService"); + LOG4CXX_DEBUG(logger_, "Received a PublishAppService " << connection_key()); MessageHelper::PrintSmartObject(*message_); smart_objects::SmartObject response_params = @@ -89,6 +90,12 @@ void PublishAppServiceRequest::Run() { if (!ValidateManifest(manifest)) { return; } + + ApplicationSharedPtr app = application_manager_.application(connection_key()); + auto& ext = + sdl_rpc_plugin::SystemCapabilityAppExtension::ExtractExtension(*app); + ext.SubscribeTo(mobile_apis::SystemCapabilityType::APP_SERVICES); + smart_objects::SmartObject service_record = application_manager_.GetAppServiceManager().PublishAppService( manifest, true, connection_key()); diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/CMakeLists.txt b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/CMakeLists.txt index 11dd35d061..fdf02b57cb 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/CMakeLists.txt +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/CMakeLists.txt @@ -42,8 +42,12 @@ set (HMI_COMMANDS_SOURCE_DIR ${COMMANDS_SOURCE_DIR}/hmi ) +set (EXTENSIONS_SOURCE_DIR + ${CMAKE_CURRENT_SOURCE_DIR}/src/extensions +) collect_sources(MOBILE_COMMANDS "${MOBILE_COMMANDS_SOURCE_DIR}") collect_sources(HMI_COMMANDS "${HMI_COMMANDS_SOURCE_DIR}") +collect_sources(APP_EXTENSIONS "${EXTENSIONS_SOURCE_DIR}") collect_sources(RPC_PLUGIN_SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/src") set(LIBRARIES @@ -60,7 +64,7 @@ if(ENABLE_LOG) list(APPEND LIBRARIES log4cxx -L${LOG4CXX_LIBS_DIRECTORY}) endif() -add_library("sdl_rpc_plugin" SHARED ${MOBILE_COMMANDS} ${HMI_COMMANDS} ${RPC_PLUGIN_SOURCES}) +add_library("sdl_rpc_plugin" SHARED ${MOBILE_COMMANDS} ${HMI_COMMANDS} ${RPC_PLUGIN_SOURCES} ${APP_EXTENSIONS}) target_link_libraries("sdl_rpc_plugin" ${LIBRARIES}) set(INSTALL_DESTINATION bin) diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_bc_system_capability_updated_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_bc_system_capability_updated_notification.h new file mode 100644 index 0000000000..17f8a5b3c8 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_bc_system_capability_updated_notification.h @@ -0,0 +1,79 @@ +/* + Copyright (c) 2019, Ford Motor Company, Livio + 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 the copyright holders nor the names of their + 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. + */ + +#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_BC_SYSTEM_CAPABILITY_UPDATED_NOTIFICATION_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_BC_SYSTEM_CAPABILITY_UPDATED_NOTIFICATION_H_ + +#include "application_manager/commands/notification_to_hmi.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief OnASSystemCapabilityUpdatedNotification command class + **/ +class OnBCSystemCapabilityUpdatedNotification + : public app_mngr::commands::NotificationToHMI { + public: + /** + * @brief OnASSystemCapabilityUpdatedNotification class constructor + * + * @param message Incoming SmartObject message + **/ + OnBCSystemCapabilityUpdatedNotification( + const app_mngr::commands::MessageSharedPtr& message, + app_mngr::ApplicationManager& application_manager, + app_mngr::rpc_service::RPCService& rpc_service, + app_mngr::HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle); + + /** + * @brief OnASSystemCapabilityUpdatedNotification class destructor + **/ + virtual ~OnBCSystemCapabilityUpdatedNotification(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(OnBCSystemCapabilityUpdatedNotification); +}; + +} // namespace commands + +} // namespace app_service_rpc_plugin + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_BC_SYSTEM_CAPABILITY_UPDATED_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/on_system_capability_updated_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/on_system_capability_updated_notification.h new file mode 100644 index 0000000000..1f7e8468db --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/on_system_capability_updated_notification.h @@ -0,0 +1,84 @@ +/* + Copyright (c) 2018, 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. + */ + +#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_ON_SYSTEM_CAPABILITY_UPDATED_NOTIFICATION_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_ON_SYSTEM_CAPABILITY_UPDATED_NOTIFICATION_H_ + +#include "application_manager/commands/command_notification_impl.h" +#include "policy/policy_table/enums.h" +#include + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +namespace mobile { + +/** + * @brief OnSystemCapabilityUpdatedNotification class + **/ +class OnSystemCapabilityUpdatedNotification + : public app_mngr::commands::CommandNotificationImpl { + public: + typedef std::vector BinaryMessage; + /** + * @brief OnSystemCapabilityUpdatedNotification class constructor + * + * @param message Incoming SmartObject message + **/ + OnSystemCapabilityUpdatedNotification( + const app_mngr::commands::MessageSharedPtr& message, + app_mngr::ApplicationManager& application_manager, + app_mngr::rpc_service::RPCService& rpc_service, + app_mngr::HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handler); + + /** + * @brief OnSystemCapabilityUpdatedNotification class destructor + **/ + ~OnSystemCapabilityUpdatedNotification() OVERRIDE; + + /** + * @brief Execute command + **/ + void Run() OVERRIDE; + + private: + DISALLOW_COPY_AND_ASSIGN(OnSystemCapabilityUpdatedNotification); +}; + +} // namespace mobile +} // namespace commands +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_ON_SYSTEM_CAPABILITY_UPDATED_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/extensions/system_capability_app_extension.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/extensions/system_capability_app_extension.h new file mode 100644 index 0000000000..fb82cf37c2 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/extensions/system_capability_app_extension.h @@ -0,0 +1,83 @@ +/* + Copyright (c) 2018, 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. + */ + +#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_EXTENSIONS_SYSTEM_CAPABILITY_APP_EXTENSION_H +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_EXTENSIONS_SYSTEM_CAPABILITY_APP_EXTENSION_H +#include +#include +#include +#include "sdl_rpc_plugin/sdl_rpc_plugin.h" + +namespace sdl_rpc_plugin { +class SDLRPCPlugin; + +namespace app_mngr_ = application_manager; + +typedef mobile_apis::SystemCapabilityType::eType SystemCapabilityType; +typedef std::set + SystemCapabilitySubscriptions; + +class SystemCapabilityAppExtension : public app_mngr_::AppExtension { + public: + SystemCapabilityAppExtension(SDLRPCPlugin& plugin, + app_mngr_::Application& app); + virtual ~SystemCapabilityAppExtension(); + + bool SubscribeTo(const SystemCapabilityType system_capability_type); + + bool UnsubscribeFrom(const SystemCapabilityType system_capability_type); + + void UnsubscribeFromAll(); + + bool IsSubscribedTo(const SystemCapabilityType system_capability_type) const; + + SystemCapabilitySubscriptions Subscriptions(); + + void SaveResumptionData(ns_smart_device_link::ns_smart_objects::SmartObject& + resumption_data) OVERRIDE; + + void ProcessResumption( + const smart_objects::SmartObject& resumption_data) OVERRIDE; + + static const app_mngr_::AppExtensionUID SystemCapabilityAppExtensionUID; + + static SystemCapabilityAppExtension& ExtractExtension( + app_mngr_::Application& app); + + private: + SystemCapabilitySubscriptions subscribed_data_; + SDLRPCPlugin& plugin_; + app_mngr_::Application& app_; +}; +} + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_EXTENSIONS_SYSTEM_CAPABILITY_APP_EXTENSION_H diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/sdl_rpc_plugin.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/sdl_rpc_plugin.h index 6ae3a0b6bc..b57fcbec12 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/sdl_rpc_plugin.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/sdl_rpc_plugin.h @@ -36,29 +36,32 @@ #include "application_manager/command_factory.h" namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; namespace plugins = application_manager::plugin_manager; + +class SystemCapabilityAppExtension; + class SDLRPCPlugin : public plugins::RPCPlugin { // RPCPlugin interface public: - bool Init(application_manager::ApplicationManager& app_manager, - application_manager::rpc_service::RPCService& rpc_service, - application_manager::HMICapabilities& hmi_capabilities, + bool Init(app_mngr::ApplicationManager& app_manager, + app_mngr::rpc_service::RPCService& rpc_service, + app_mngr::HMICapabilities& hmi_capabilities, policy::PolicyHandlerInterface& policy_handler) OVERRIDE; bool IsAbleToProcess( const int32_t function_id, - const application_manager::commands::Command::CommandSource - message_source) OVERRIDE; + const app_mngr::commands::Command::CommandSource message_source) OVERRIDE; std::string PluginName() OVERRIDE; - application_manager::CommandFactory& GetCommandFactory() OVERRIDE; - void OnPolicyEvent( - application_manager::plugin_manager::PolicyEvent event) OVERRIDE; - void OnApplicationEvent( - application_manager::plugin_manager::ApplicationEvent event, - application_manager::ApplicationSharedPtr application) OVERRIDE; + app_mngr::CommandFactory& GetCommandFactory() OVERRIDE; + void OnPolicyEvent(plugins::PolicyEvent event) OVERRIDE; + void OnApplicationEvent(plugins::ApplicationEvent event, + app_mngr::ApplicationSharedPtr application) OVERRIDE; private: + void ClearSubscriptions(app_mngr::ApplicationSharedPtr app); + std::unique_ptr command_factory_; }; } diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_bc_system_capability_updated_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_bc_system_capability_updated_notification.cc new file mode 100644 index 0000000000..3f8dcf08f6 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_bc_system_capability_updated_notification.cc @@ -0,0 +1,67 @@ +/* + Copyright (c) 2019, Ford Motor Company, Livio + 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 the copyright holders nor the names of their + 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 "sdl_rpc_plugin/commands/hmi/on_bc_system_capability_updated_notification.h" +#include "application_manager/application_impl.h" +#include "application_manager/rpc_service.h" +#include "interfaces/HMI_API.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; +namespace commands { + +OnBCSystemCapabilityUpdatedNotification:: + OnBCSystemCapabilityUpdatedNotification( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + app_mngr::rpc_service::RPCService& rpc_service, + app_mngr::HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handler) + : NotificationToHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handler) {} + +OnBCSystemCapabilityUpdatedNotification:: + ~OnBCSystemCapabilityUpdatedNotification() {} + +void OnBCSystemCapabilityUpdatedNotification::Run() { + LOG4CXX_AUTO_TRACE(logger_); + LOG4CXX_DEBUG(logger_, + "Sending BasicCommunication.OnSystemCapabilityUpdated " + "Notification to HMI"); + SendNotification(); +} + +} // namespace commands +} // namespace app_service_rpc_plugin 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 a6c627aad2..1449f0e061 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 @@ -31,6 +31,9 @@ */ #include "sdl_rpc_plugin/commands/mobile/get_system_capability_request.h" +#include "sdl_rpc_plugin/extensions/system_capability_app_extension.h" +#include "application_manager/message_helper.h" +#include namespace sdl_rpc_plugin { using namespace application_manager; @@ -128,10 +131,48 @@ void GetSystemCapabilityRequest::Run() { return; } break; + case mobile_apis::SystemCapabilityType::APP_SERVICES: { + smart_objects::SmartObject app_service_capabilities( + smart_objects::SmartType_Map); + smart_objects::SmartObject app_services(smart_objects::SmartType_Array); + + std::vector service_records = + application_manager_.GetAppServiceManager().GetAllServices(); + + for (auto& record : service_records) { + smart_objects::SmartObject app_services_capabilities( + smart_objects::SmartType_Map); + app_services_capabilities[strings::updated_app_service_record] = record; + app_services.asArray()->push_back(app_services_capabilities); + } + + app_service_capabilities[strings::app_services] = app_services; + response_params[strings::system_capability] + [strings::app_services_capabilities] = + app_service_capabilities; + + break; + } default: // Return unsupported resource SendResponse(false, mobile_apis::Result::UNSUPPORTED_RESOURCE); return; } + + if ((*message_)[app_mngr::strings::msg_params].keyExists( + strings::subscribe)) { + auto& ext = SystemCapabilityAppExtension::ExtractExtension(*app); + if ((*message_)[app_mngr::strings::msg_params][strings::subscribe] + .asBool() == true) { + LOG4CXX_DEBUG(logger_, + "Subscribe to system capability: " << response_type); + ext.SubscribeTo(response_type); + } else { + LOG4CXX_DEBUG(logger_, + "Unsubscribe from system capability: " << response_type); + ext.UnsubscribeFrom(response_type); + } + } + SendResponse(true, mobile_apis::Result::SUCCESS, NULL, &response_params); } diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_system_capability_updated_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_system_capability_updated_notification.cc new file mode 100644 index 0000000000..6a1f0844d9 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_system_capability_updated_notification.cc @@ -0,0 +1,70 @@ +#include "sdl_rpc_plugin/commands/mobile/on_system_capability_updated_notification.h" +#include "application_manager/application_manager.h" +#include "application_manager/helpers/application_helper.h" +#include "application_manager/message_helper.h" +#include "sdl_rpc_plugin/extensions/system_capability_app_extension.h" +#include "smart_objects/enum_schema_item.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; +namespace commands { +namespace mobile { + +OnSystemCapabilityUpdatedNotification::OnSystemCapabilityUpdatedNotification( + const app_mngr::commands::MessageSharedPtr& message, + app_mngr::ApplicationManager& application_manager, + app_mngr::rpc_service::RPCService& rpc_service, + app_mngr::HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handler) + : CommandNotificationImpl(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handler) {} + +OnSystemCapabilityUpdatedNotification:: + ~OnSystemCapabilityUpdatedNotification() {} + +void OnSystemCapabilityUpdatedNotification::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + mobile_apis::SystemCapabilityType::eType system_capability_type = + static_cast( + (*message_)[strings::msg_params][strings::system_capability] + [strings::system_capability_type].asInt()); + + const char* capability_type_string; + ns_smart_device_link::ns_smart_objects::EnumConversionHelper< + mobile_apis::SystemCapabilityType::eType>:: + EnumToCString(system_capability_type, &capability_type_string); + + auto subscribed_to_capability_predicate = + [&system_capability_type](const ApplicationSharedPtr app) { + DCHECK_OR_RETURN(app, false); + auto& ext = SystemCapabilityAppExtension::ExtractExtension(*app); + return ext.IsSubscribedTo(system_capability_type); + }; + + const std::vector& applications = FindAllApps( + application_manager_.applications(), subscribed_to_capability_predicate); + + LOG4CXX_DEBUG(logger_, + "Number of Notifications to be sent: " << applications.size()); + + std::vector::const_iterator app_it = + applications.begin(); + + for (; applications.end() != app_it; ++app_it) { + const ApplicationSharedPtr app = *app_it; + LOG4CXX_INFO(logger_, + "Sending OnSystemCapabilityUpdated " << capability_type_string + << " application id " + << app->app_id()); + (*message_)[strings::params][strings::connection_key] = app->app_id(); + SendNotification(); + } +} + +} // namespace mobile +} // namespace commands +} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/extensions/system_capability_app_extension.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/extensions/system_capability_app_extension.cc new file mode 100644 index 0000000000..130585a927 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/extensions/system_capability_app_extension.cc @@ -0,0 +1,98 @@ +#include "sdl_rpc_plugin/extensions/system_capability_app_extension.h" + +namespace sdl_rpc_plugin { +CREATE_LOGGERPTR_GLOBAL(logger_, "GetSystemCapabilitiesAppExtension") + +namespace app_mngr_ = application_manager; +const app_mngr_::AppExtensionUID + SystemCapabilityAppExtension::SystemCapabilityAppExtensionUID = 200; + +SystemCapabilityAppExtension::SystemCapabilityAppExtension( + sdl_rpc_plugin::SDLRPCPlugin& plugin, app_mngr_::Application& app) + : app_mngr_::AppExtension( + SystemCapabilityAppExtension::SystemCapabilityAppExtensionUID) + , plugin_(plugin) + , app_(app) {} + +SystemCapabilityAppExtension::~SystemCapabilityAppExtension() {} + +bool SystemCapabilityAppExtension::SubscribeTo( + const SystemCapabilityType system_capability_type) { + LOG4CXX_INFO(logger_, + "Subscribing to System Capability " << system_capability_type); + return subscribed_data_.insert(system_capability_type).second; +} + +bool SystemCapabilityAppExtension::UnsubscribeFrom( + const SystemCapabilityType system_capability_type) { + LOG4CXX_INFO(logger_, + "Unsubscribing from System Capability " + << system_capability_type); + auto it = subscribed_data_.find(system_capability_type); + if (it != subscribed_data_.end()) { + subscribed_data_.erase(it); + return true; + } + return false; +} + +void SystemCapabilityAppExtension::UnsubscribeFromAll() { + LOG4CXX_INFO(logger_, "Unsubscribing from ALL System Capabilities"); + subscribed_data_.clear(); +} + +bool SystemCapabilityAppExtension::IsSubscribedTo( + const SystemCapabilityType system_capability_type) const { + LOG4CXX_DEBUG(logger_, system_capability_type); + return subscribed_data_.find(system_capability_type) != + subscribed_data_.end(); +} + +SystemCapabilitySubscriptions SystemCapabilityAppExtension::Subscriptions() { + return subscribed_data_; +} + +void SystemCapabilityAppExtension::SaveResumptionData( + ns_smart_device_link::ns_smart_objects::SmartObject& resumption_data) { + LOG4CXX_AUTO_TRACE(logger_); + const char* application_system_capability = "systemCapability"; + + resumption_data[application_system_capability] = + smart_objects::SmartObject(smart_objects::SmartType_Array); + + int i = 0; + for (const auto& subscription : subscribed_data_) { + resumption_data[application_system_capability][i] = subscription; + i++; + } +} + +void SystemCapabilityAppExtension::ProcessResumption( + const smart_objects::SmartObject& resumption_data) { + LOG4CXX_AUTO_TRACE(logger_); + + const char* application_system_capability = "systemCapability"; + if (resumption_data.keyExists(application_system_capability)) { + const smart_objects::SmartObject& subscriptions = + resumption_data[application_system_capability]; + for (size_t i = 0; i < subscriptions.length(); ++i) { + SystemCapabilityType capability_type = + static_cast((resumption_data[i]).asInt()); + SubscribeTo(capability_type); + } + } +} + +SystemCapabilityAppExtension& SystemCapabilityAppExtension::ExtractExtension( + app_mngr_::Application& app) { + LOG4CXX_AUTO_TRACE(logger_); + auto ext_ptr = app.QueryInterface( + SystemCapabilityAppExtension::SystemCapabilityAppExtensionUID); + DCHECK(ext_ptr); + DCHECK(dynamic_cast(ext_ptr.get())); + auto app_extension = + std::static_pointer_cast(ext_ptr); + DCHECK(app_extension); + return *app_extension; +} +} \ No newline at end of file diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/hmi_command_factory.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/hmi_command_factory.cc index 7065c7cf7d..dc94474b9d 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/hmi_command_factory.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/hmi_command_factory.cc @@ -241,6 +241,8 @@ #include "sdl_rpc_plugin/commands/hmi/rc_get_capabilities_request.h" #include "sdl_rpc_plugin/commands/hmi/rc_get_capabilities_response.h" +#include "sdl_rpc_plugin/commands/hmi/on_bc_system_capability_updated_notification.h" + namespace sdl_rpc_plugin { using namespace application_manager; @@ -840,6 +842,10 @@ CommandCreator& HMICommandFactory::get_creator_factory( ? factory.GetCreator() : factory.GetCreator(); } + case hmi_apis::FunctionID::BasicCommunication_OnSystemCapabilityUpdated: { + return factory + .GetCreator(); + } default: { return factory.GetCreator(); } } } diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/mobile_command_factory.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/mobile_command_factory.cc index 8eab054be3..77be545e0b 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/mobile_command_factory.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/mobile_command_factory.cc @@ -73,6 +73,7 @@ #include "sdl_rpc_plugin/commands/mobile/on_tbt_client_state_notification.h" #include "sdl_rpc_plugin/commands/mobile/on_hash_change_notification.h" #include "sdl_rpc_plugin/commands/mobile/on_way_point_change_notification.h" +#include "sdl_rpc_plugin/commands/mobile/on_system_capability_updated_notification.h" #include "sdl_rpc_plugin/commands/mobile/perform_audio_pass_thru_request.h" #include "sdl_rpc_plugin/commands/mobile/perform_audio_pass_thru_response.h" #include "sdl_rpc_plugin/commands/mobile/perform_interaction_request.h" @@ -388,6 +389,10 @@ CommandCreator& MobileCommandFactory::get_creator_factory( case mobile_apis::FunctionID::OnTouchEventID: { return factory.GetCreator(); } + case mobile_apis::FunctionID::OnSystemCapabilityUpdatedID: { + return factory.GetCreator< + commands::mobile::OnSystemCapabilityUpdatedNotification>(); + } case mobile_apis::FunctionID::OnSystemRequestID: { return factory .GetCreator(); diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/sdl_rpc_plugin.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/sdl_rpc_plugin.cc index 22b818f5e0..aa82c74098 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/sdl_rpc_plugin.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/sdl_rpc_plugin.cc @@ -32,15 +32,18 @@ #include "sdl_rpc_plugin/sdl_rpc_plugin.h" #include "sdl_rpc_plugin/sdl_command_factory.h" +#include "sdl_rpc_plugin/extensions/system_capability_app_extension.h" namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; namespace plugins = application_manager::plugin_manager; -bool SDLRPCPlugin::Init( - application_manager::ApplicationManager& app_manager, - application_manager::rpc_service::RPCService& rpc_service, - application_manager::HMICapabilities& hmi_capabilities, - policy::PolicyHandlerInterface& policy_handler) { +CREATE_LOGGERPTR_GLOBAL(logger_, "SdlRPCPlugin") + +bool SDLRPCPlugin::Init(app_mngr::ApplicationManager& app_manager, + app_mngr::rpc_service::RPCService& rpc_service, + app_mngr::HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handler) { command_factory_.reset(new sdl_rpc_plugin::SDLCommandFactory( app_manager, rpc_service, hmi_capabilities, policy_handler)); return true; @@ -48,8 +51,7 @@ bool SDLRPCPlugin::Init( bool SDLRPCPlugin::IsAbleToProcess( const int32_t function_id, - const application_manager::commands::Command::CommandSource - message_source) { + const app_mngr::commands::Command::CommandSource message_source) { return command_factory_->IsAbleToProcess(function_id, message_source); } @@ -57,16 +59,27 @@ std::string SDLRPCPlugin::PluginName() { return "SDL RPC Plugin"; } -application_manager::CommandFactory& SDLRPCPlugin::GetCommandFactory() { +app_mngr::CommandFactory& SDLRPCPlugin::GetCommandFactory() { return *command_factory_; } -void SDLRPCPlugin::OnPolicyEvent( - application_manager::plugin_manager::PolicyEvent event) {} +void SDLRPCPlugin::OnPolicyEvent(plugins::PolicyEvent event) {} void SDLRPCPlugin::OnApplicationEvent( - application_manager::plugin_manager::ApplicationEvent event, - application_manager::ApplicationSharedPtr application) {} + plugins::ApplicationEvent event, + app_mngr::ApplicationSharedPtr application) { + if (plugins::ApplicationEvent::kApplicationRegistered == event) { + application->AddExtension( + std::make_shared(*this, *application)); + } else if (plugins::ApplicationEvent::kDeleteApplicationData == event) { + ClearSubscriptions(application); + } +} + +void SDLRPCPlugin::ClearSubscriptions(app_mngr::ApplicationSharedPtr app) { + auto& ext = SystemCapabilityAppExtension::ExtractExtension(*app); + ext.UnsubscribeFromAll(); +} } // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/src/app_service_manager.cc b/src/components/application_manager/src/app_service_manager.cc index 8fea64b228..57b319c680 100644 --- a/src/components/application_manager/src/app_service_manager.cc +++ b/src/components/application_manager/src/app_service_manager.cc @@ -37,6 +37,7 @@ #include "application_manager/app_service_manager.h" #include "application_manager/application.h" +#include "application_manager/app_service_manager.h" #include "application_manager/application_manager.h" #include "application_manager/commands/command_impl.h" #include "application_manager/message_helper.h" @@ -78,19 +79,73 @@ smart_objects::SmartObject AppServiceManager::PublishAppService( service_record[strings::service_id] = service_id; service_record[strings::service_published] = true; service_record[strings::service_active] = true; - app_service.record = service_record; published_services_.insert( std::pair(service_id, app_service)); + auto all_services = GetAllServices(); + smart_objects::SmartObjectSPtr notification = + std::make_shared( + MessageHelper::CreateMobileSystemCapabilityNotification( + all_services, + service_id, + mobile_apis::ServiceUpdateReason::PUBLISHED)); + app_manager_.GetRPCService().ManageMobileCommand( + notification, commands::Command::CommandSource::SOURCE_SDL); + smart_objects::SmartObjectSPtr hmi_notification = + std::make_shared( + MessageHelper::CreateHMISystemCapabilityNotification( + all_services, + service_id, + mobile_apis::ServiceUpdateReason::PUBLISHED)); + app_manager_.GetRPCService().ManageHMICommand(hmi_notification); return service_record; } bool AppServiceManager::UnpublishAppService(const std::string service_id) { LOG4CXX_AUTO_TRACE(logger_); - // TODO - return false; + + auto it = published_services_.find(service_id); + if (it == published_services_.end()) { + LOG4CXX_ERROR(logger_, "Service id does not exist in published services"); + return false; + } + LOG4CXX_DEBUG(logger_, "Unpublishing app service: " << service_id); + + SetServicePublished(service_id, false); + + auto all_services = GetAllServices(); + smart_objects::SmartObjectSPtr notification = + std::make_shared( + MessageHelper::CreateMobileSystemCapabilityNotification( + all_services, + service_id, + mobile_apis::ServiceUpdateReason::REMOVED)); + app_manager_.GetRPCService().ManageMobileCommand( + notification, commands::Command::CommandSource::SOURCE_SDL); + smart_objects::SmartObjectSPtr hmi_notification = + std::make_shared( + MessageHelper::CreateHMISystemCapabilityNotification( + all_services, + service_id, + mobile_apis::ServiceUpdateReason::REMOVED)); + app_manager_.GetRPCService().ManageHMICommand(hmi_notification); + + published_services_.erase(it); + + return true; +} + +void AppServiceManager::UnpublishServices(const uint32_t connection_key) { + LOG4CXX_AUTO_TRACE(logger_); + LOG4CXX_DEBUG(logger_, "Unpublishing all app services: " << connection_key); + for (auto it = published_services_.begin(); it != published_services_.end(); + ++it) { + if (it->second.connection_key == connection_key) { + UnpublishAppService(it->first); + } + } } std::vector AppServiceManager::GetAllServices() { @@ -103,6 +158,15 @@ std::vector AppServiceManager::GetAllServices() { return services; } +void AppServiceManager::SetServicePublished(const std::string service_id, + bool service_published) { + auto it = published_services_.find(service_id); + if (it == published_services_.end()) { + LOG4CXX_ERROR(logger_, "Service id does not exist in published services"); + return; + } + it->second.record[strings::service_published] = service_published; +} std::pair AppServiceManager::ActiveServiceByType( std::string service_type) { diff --git a/src/components/application_manager/src/application_manager_impl.cc b/src/components/application_manager/src/application_manager_impl.cc index d82eeb776c..6ee221f56f 100644 --- a/src/components/application_manager/src/application_manager_impl.cc +++ b/src/components/application_manager/src/application_manager_impl.cc @@ -2619,6 +2619,8 @@ void ApplicationManagerImpl::UnregisterApplication( << is_unexpected_disconnect); size_t subscribed_for_way_points_app_count = 0; + GetAppServiceManager().UnpublishServices(app_id); + // SDL sends UnsubscribeWayPoints only for last application { sync_primitives::AutoLock lock(subscribed_way_points_apps_lock_); diff --git a/src/components/application_manager/src/message_helper/message_helper.cc b/src/components/application_manager/src/message_helper/message_helper.cc index 58d5171f84..1d3a553711 100644 --- a/src/components/application_manager/src/message_helper/message_helper.cc +++ b/src/components/application_manager/src/message_helper/message_helper.cc @@ -327,6 +327,57 @@ smart_objects::SmartObjectSPtr MessageHelper::CreateMessageForHMI( return message; } +smart_objects::SmartObject +MessageHelper::CreateMobileSystemCapabilityNotification( + std::vector& all_services, + const std::string service_id, + mobile_apis::ServiceUpdateReason::eType update_reason) { + smart_objects::SmartObject message(smart_objects::SmartType_Map); + + message[strings::params][strings::message_type] = MessageType::kNotification; + message[strings::params][strings::function_id] = + mobile_apis::FunctionID::OnSystemCapabilityUpdatedID; + + smart_objects::SmartObject system_capability = + smart_objects::SmartObject(smart_objects::SmartType_Map); + system_capability[strings::system_capability_type] = + mobile_apis::SystemCapabilityType::APP_SERVICES; + + smart_objects::SmartObject app_service_capabilities( + smart_objects::SmartType_Map); + smart_objects::SmartObject app_services(smart_objects::SmartType_Array); + + std::vector service_records = all_services; + + for (auto& record : service_records) { + smart_objects::SmartObject app_services_capabilities( + smart_objects::SmartType_Map); + app_services_capabilities[strings::updated_app_service_record] = record; + if (record[strings::service_id].asString() == service_id) { + app_services_capabilities[strings::update_reason] = update_reason; + } + app_services.asArray()->push_back(app_services_capabilities); + } + + app_service_capabilities[strings::app_services] = app_services; + system_capability[strings::app_services_capabilities] = + app_service_capabilities; + + message[strings::msg_params][strings::system_capability] = system_capability; + return message; +} + +smart_objects::SmartObject MessageHelper::CreateHMISystemCapabilityNotification( + std::vector& all_services, + const std::string service_id, + mobile_apis::ServiceUpdateReason::eType update_reason) { + auto message = CreateMobileSystemCapabilityNotification( + all_services, service_id, update_reason); + message[strings::params][strings::function_id] = + hmi_apis::FunctionID::BasicCommunication_OnSystemCapabilityUpdated; + return message; +} + smart_objects::SmartObjectSPtr MessageHelper::CreateHashUpdateNotification( const uint32_t app_id) { LOG4CXX_AUTO_TRACE(logger_); diff --git a/src/components/application_manager/src/smart_object_keys.cc b/src/components/application_manager/src/smart_object_keys.cc index 1b6dfe2b8b..4900726d48 100644 --- a/src/components/application_manager/src/smart_object_keys.cc +++ b/src/components/application_manager/src/smart_object_keys.cc @@ -27,6 +27,7 @@ const char* app_launch_last_session = "app_launch_last_session"; const char* policy_app_id = "policyAppID"; const char* hmi_app_id = "hmiAppID"; const char* device_id = "deviceID"; +const char* subscribe = "subscribe"; const char* subscribed_for_way_points = "subscribed_for_way_points"; const char* url = "url"; const char* urlScheme = "urlScheme"; @@ -145,6 +146,7 @@ const char* navigation_capability = "navigationCapability"; const char* phone_capability = "phoneCapability"; const char* video_streaming_capability = "videoStreamingCapability"; const char* rc_capability = "remoteControlCapability"; +const char* app_services_capabilities = "appServicesCapabilities"; const char* day_color_scheme = "dayColorScheme"; const char* night_color_scheme = "nightColorScheme"; const char* primary_color = "primaryColor"; @@ -283,6 +285,9 @@ const char* service_id = "serviceID"; const char* service_manifest = "serviceManifest"; const char* service_published = "servicePublished"; const char* service_active = "serviceActive"; +const char* app_services = "appServices"; +const char* update_reason = "updateReason"; +const char* updated_app_service_record = "updatedAppServiceRecord"; // resuming const char* application_commands = "applicationCommands"; diff --git a/src/components/application_manager/test/application_manager_impl_test.cc b/src/components/application_manager/test/application_manager_impl_test.cc index 4ea44e5aca..0b24fa8032 100644 --- a/src/components/application_manager/test/application_manager_impl_test.cc +++ b/src/components/application_manager/test/application_manager_impl_test.cc @@ -138,6 +138,9 @@ class ApplicationManagerImplTest : public ::testing::Test { app_manager_impl_->resume_controller().set_resumption_storage( mock_storage_); app_manager_impl_->set_connection_handler(&mock_connection_handler_); + std::unique_ptr app_service_manager_ptr( + new AppServiceManager(*app_manager_impl_)); + app_manager_impl_->SetAppServiceManager(app_service_manager_ptr); } void CreateAppManager() { diff --git a/src/components/application_manager/test/include/application_manager/mock_message_helper.h b/src/components/application_manager/test/include/application_manager/mock_message_helper.h index 84a3b6bc87..878d3e7dd7 100644 --- a/src/components/application_manager/test/include/application_manager/mock_message_helper.h +++ b/src/components/application_manager/test/include/application_manager/mock_message_helper.h @@ -308,6 +308,16 @@ class MockMessageHelper { void(mobile_apis::ButtonName::eType button, ApplicationSharedPtr application, ApplicationManager& app_mngr)); + MOCK_METHOD3(CreateMobileSystemCapabilityNotification, + smart_objects::SmartObject( + std::vector& all_services, + const std::string service_id, + mobile_apis::ServiceUpdateReason::eType update_reason)); + MOCK_METHOD3(CreateHMISystemCapabilityNotification, + smart_objects::SmartObject( + std::vector& all_services, + const std::string service_id, + mobile_apis::ServiceUpdateReason::eType update_reason)); static MockMessageHelper* message_helper_mock(); }; diff --git a/src/components/application_manager/test/mock_message_helper.cc b/src/components/application_manager/test/mock_message_helper.cc index f091e183dc..6bd42a44a1 100644 --- a/src/components/application_manager/test/mock_message_helper.cc +++ b/src/components/application_manager/test/mock_message_helper.cc @@ -572,4 +572,22 @@ void MessageHelper::SendUnsubscribeButtonNotification( ->SendUnsubscribeButtonNotification(button, application, app_mngr); } +smart_objects::SmartObject +MessageHelper::CreateMobileSystemCapabilityNotification( + std::vector& all_services, + const std::string service_id, + mobile_apis::ServiceUpdateReason::eType update_reason) { + return MockMessageHelper::message_helper_mock() + ->CreateMobileSystemCapabilityNotification( + all_services, service_id, update_reason); +} + +smart_objects::SmartObject MessageHelper::CreateHMISystemCapabilityNotification( + std::vector& all_services, + const std::string service_id, + mobile_apis::ServiceUpdateReason::eType update_reason) { + return MockMessageHelper::message_helper_mock() + ->CreateHMISystemCapabilityNotification( + all_services, service_id, update_reason); +} } // namespace application_manager diff --git a/src/components/hmi_message_handler/src/messagebroker_adapter.cc b/src/components/hmi_message_handler/src/messagebroker_adapter.cc index d400cca335..8e45d4ecd9 100644 --- a/src/components/hmi_message_handler/src/messagebroker_adapter.cc +++ b/src/components/hmi_message_handler/src/messagebroker_adapter.cc @@ -138,6 +138,8 @@ void MessageBrokerAdapter::SubscribeTo() { MessageBrokerController::subscribeTo("BasicCommunication.OnEventChanged"); MessageBrokerController::subscribeTo("RC.OnInteriorVehicleData"); MessageBrokerController::subscribeTo("RC.OnRemoteControlSettings"); + MessageBrokerController::subscribeTo( + "SystemCapability.OnSystemCapabilityUpdated"); LOG4CXX_INFO(logger_, "Subscribed to notifications."); } diff --git a/src/components/interfaces/HMI_API.xml b/src/components/interfaces/HMI_API.xml index adef6a87cc..0ad932fe82 100644 --- a/src/components/interfaces/HMI_API.xml +++ b/src/components/interfaces/HMI_API.xml @@ -3298,15 +3298,6 @@ - - - - - - - - - If included, the platform supports RC climate controls. For this baseline version, maxsize=1. i.e. only one climate control module is supported. @@ -3634,8 +3625,73 @@ + + + The service has just been published with the module and once activated to the primary service of its type, it will be ready for possible consumption. + + + The service has just been unpublished with the module and is no longer accessible + + + The service is activated as the primary service of this type. All requests dealing with this service type will be handled by this service. + + + The service has been deactivated as the primary service of its type + + + The service has updated its manifest. This could imply updated capabilities + + + + + + Only included in OnSystemCapabilityUpdated. Update reason for service record. + + + Service record for a specific app service provider + + + + + Capabilities of app services including what service types are supported and the current state of services. + + An array of currently available services. If this is an update to the capability the affected services will include an update reason in that item + + + + + Enumerations of all available system capability types + + + + + + + + + The systemCapabilityType identifies which data object exists in this struct. For example, if the SystemCapability Type is NAVIGATION then a "navigationCapability" should exist + + Used as a descriptor of what data to expect in this struct. The corresponding param to this enum should be included and the only other para included. + + + Describes extended capabilities for onboard navigation system + + + Describes extended capabilities of the module's phone feature + + + Describes extended capabilities of the module's phone feature + + + Describes extended capabilities of the module's phone feature + + + An array of currently available services. If this is an update to the capability the affected services will include an update reason in that item + + + @@ -4065,6 +4121,12 @@ Must be 'true' - when the event is started on HMI. Must be 'false' when the event is ended on HMI + + A notification to inform the connected device that a specific system capability has changed. + + The system capability that has been updated + + diff --git a/src/components/interfaces/MOBILE_API.xml b/src/components/interfaces/MOBILE_API.xml index 4d9bfbf09d..01f0485323 100644 --- a/src/components/interfaces/MOBILE_API.xml +++ b/src/components/interfaces/MOBILE_API.xml @@ -2643,6 +2643,7 @@ + - - The systemCapabilityType indicates which type of data should be changed and identifies which data object exists in this struct. For example, if the SystemCapability Type is NAVIGATION then a "navigationCapability" should exist - - Used as a descriptor of what data to expect in this struct. The corresponding param to this enum should be included and the only other para included. - - - Describes extended capabilities for onboard navigation system - - - Describes extended capabilities of the module's phone feature - - - Describes extended capabilities of the module's phone feature - - - Describes extended capabilities of the module's phone feature - - @@ -3973,8 +3957,64 @@ + + + The service has just been published with the module and once activated to the primary service of its type, it will be ready for possible consumption. + + + The service has just been unpublished with the module and is no longer accessible + + + The service is activated as the primary service of this type. All requests dealing with this service type will be handled by this service. + + + The service has been deactivated as the primary service of its type + + + The service has updated its manifest. This could imply updated capabilities + + + + + + Only included in OnSystemCapabilityUpdated. Update reason for service record. + + + Service record for a specific app service provider + + + + + Capabilities of app services including what service types are supported and the current state of services. + + An array of currently available services. If this is an update to the capability the affected services will include an update reason in that item + + + + + The systemCapabilityType identifies which data object exists in this struct. For example, if the SystemCapability Type is NAVIGATION then a "navigationCapability" should exist + + Used as a descriptor of what data to expect in this struct. The corresponding param to this enum should be included and the only other para included. + + + Describes extended capabilities for onboard navigation system + + + Describes extended capabilities of the module's phone feature + + + Describes extended capabilities of the module's phone feature + + + Describes extended capabilities of the module's phone feature + + + An array of currently available services. If this is an update to the capability the affected services will include an update reason in that item + + + @@ -6847,6 +6887,9 @@ The type of system capability to get more information on + + Flag to subscribe to updates of the supplied service capability type. If true, then requester will be subscribed + @@ -7280,6 +7323,13 @@ + + A notification to inform the connected device that a specific system capability has changed. + + The system capability that has been updated + + + diff --git a/src/components/policy/policy_external/include/policy/policy_table/enums.h b/src/components/policy/policy_external/include/policy/policy_table/enums.h index 094e5cc7c6..32277f2dcf 100644 --- a/src/components/policy/policy_external/include/policy/policy_table/enums.h +++ b/src/components/policy/policy_external/include/policy/policy_table/enums.h @@ -545,6 +545,11 @@ enum FunctionID { */ OnAppServiceDataID = 32786, + /** + * @brief OnSystemCapabilityUpdatedID + */ + OnSystemCapabilityUpdatedID = 32787, + /** * @brief EncodedSyncPDataID. */ diff --git a/src/components/policy/policy_external/src/policy_table/enums.cc b/src/components/policy/policy_external/src/policy_table/enums.cc index 2260d7e320..2d21715194 100644 --- a/src/components/policy/policy_external/src/policy_table/enums.cc +++ b/src/components/policy/policy_external/src/policy_table/enums.cc @@ -1226,6 +1226,11 @@ bool EnumFromJsonString(const std::string& literal, FunctionID* result) { return true; } + if ("OnSystemCapabilityUpdated" == literal) { + *result = OnSystemCapabilityUpdatedID; + return true; + } + if ("EncodedSyncPData" == literal) { *result = EncodedSyncPDataID; return true; diff --git a/src/components/policy/policy_regular/include/policy/policy_table/enums.h b/src/components/policy/policy_regular/include/policy/policy_table/enums.h index a62a60f2e9..1600c718f1 100644 --- a/src/components/policy/policy_regular/include/policy/policy_table/enums.h +++ b/src/components/policy/policy_regular/include/policy/policy_table/enums.h @@ -531,6 +531,11 @@ enum FunctionID { */ OnAppServiceDataID = 32786, + /** + * @brief OnSystemCapabilityUpdatedID + */ + OnSystemCapabilityUpdatedID = 32787, + /** * @brief EncodedSyncPDataID. */ diff --git a/src/components/policy/policy_regular/src/policy_table/enums.cc b/src/components/policy/policy_regular/src/policy_table/enums.cc index 5c011fbfa0..47ad1e98ab 100644 --- a/src/components/policy/policy_regular/src/policy_table/enums.cc +++ b/src/components/policy/policy_regular/src/policy_table/enums.cc @@ -897,6 +897,8 @@ bool IsValidEnum(FunctionID val) { return true; case OnSyncPDataID: return true; + case OnSystemCapabilityUpdatedID: + return true; default: return false; } @@ -1050,6 +1052,8 @@ const char* EnumToJsonString(FunctionID val) { return "OnEncodedSyncPData"; case OnSyncPDataID: return "OnSyncPData"; + case OnSystemCapabilityUpdatedID: + return "OnSystemCapabilityUpdated"; default: return ""; } @@ -1401,6 +1405,11 @@ bool EnumFromJsonString(const std::string& literal, FunctionID* result) { return true; } + if ("OnSystemCapabilityUpdated" == literal) { + *result = OnSystemCapabilityUpdatedID; + return true; + } + if ("EncodedSyncPData" == literal) { *result = EncodedSyncPDataID; return true; -- cgit v1.2.1 From ef8116cef0eec0e972fd8fc4ffd437711a7508a2 Mon Sep 17 00:00:00 2001 From: Shobhit Adlakha Date: Fri, 22 Feb 2019 09:43:22 -0500 Subject: Update src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/publish_app_service_request.cc Add info for DISALLOWED Co-Authored-By: JackLivio --- .../src/commands/mobile/publish_app_service_request.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/publish_app_service_request.cc b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/publish_app_service_request.cc index 6ef63aa1b8..123a4d4def 100644 --- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/publish_app_service_request.cc +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/publish_app_service_request.cc @@ -123,7 +123,7 @@ void PublishAppServiceRequest::Run() { requested_handled_rpcs); if (!result) { - SendResponse(false, mobile_apis::Result::DISALLOWED, NULL, NULL); + SendResponse(false, mobile_apis::Result::DISALLOWED, "Service disallowed by policies", NULL); } response_params[strings::app_service_record] = service_record; -- cgit v1.2.1 From 8080ac0ded578a25107fe1d532419056fa9819f7 Mon Sep 17 00:00:00 2001 From: Jacob Keeler Date: Fri, 22 Feb 2019 11:30:08 -0500 Subject: Update src/appMain/smartDeviceLink.ini Co-Authored-By: JackLivio --- src/appMain/smartDeviceLink.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/appMain/smartDeviceLink.ini b/src/appMain/smartDeviceLink.ini index 954381afeb..90c2d94bf3 100644 --- a/src/appMain/smartDeviceLink.ini +++ b/src/appMain/smartDeviceLink.ini @@ -371,7 +371,7 @@ EnableAppLaunchIOS = true ;VideoServiceTransports = TCP_WIFI, IAP_CARPLAY, IAP_USB_HOST_MODE, IAP_USB_DEVICE_MODE, IAP_USB, AOA_USB [AppServices] -; The ID to pass to app service publishers when sending a PerformAppServiceInteraction request +; The ID used to fill the originApp field when the HMI sends a PerformAppServiceInteraction request HMIOriginID = "HMI_ID" ; Services that exist on the module. Values are of AppServiceType in RPC Spec. These services will be used as default and app services will only become primary service publisher with direct user interaction. These services will also be a fallback if no app service publisher is registered with the system of that type. -- cgit v1.2.1 From 9e0d02fa6f5d81233815ee2507014ff928457a17 Mon Sep 17 00:00:00 2001 From: JackLivio Date: Fri, 22 Feb 2019 12:38:58 -0500 Subject: Remove todos --- src/components/policy/policy_external/src/policy_table/validation.cc | 4 ++-- src/components/policy/policy_regular/src/policy_table/validation.cc | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/components/policy/policy_external/src/policy_table/validation.cc b/src/components/policy/policy_external/src/policy_table/validation.cc index 77056e0d43..fad8509711 100644 --- a/src/components/policy/policy_external/src/policy_table/validation.cc +++ b/src/components/policy/policy_external/src/policy_table/validation.cc @@ -195,11 +195,11 @@ bool ApplicationParams::ValidateModuleTypes() const { } bool AppServiceHandledRpc::Validate() const { - return true; // todo add validation + return true; } bool AppServiceInfo::Validate() const { - return true; // todo add validation + return true; } bool ApplicationParams::Validate() const { diff --git a/src/components/policy/policy_regular/src/policy_table/validation.cc b/src/components/policy/policy_regular/src/policy_table/validation.cc index 6c15d958f5..4db84e06ff 100644 --- a/src/components/policy/policy_regular/src/policy_table/validation.cc +++ b/src/components/policy/policy_regular/src/policy_table/validation.cc @@ -178,11 +178,11 @@ bool ApplicationParams::ValidateModuleTypes() const { } bool AppServiceHandledRpc::Validate() const { - return true; // todo add validation + return true; } bool AppServiceInfo::Validate() const { - return true; // todo add validation + return true; } bool ApplicationParams::Validate() const { -- cgit v1.2.1 From 5a0d510affcc77ddf240fc2b3465da6b570b1da1 Mon Sep 17 00:00:00 2001 From: JackLivio Date: Fri, 22 Feb 2019 12:47:44 -0500 Subject: style --- .../src/commands/mobile/publish_app_service_request.cc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/publish_app_service_request.cc b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/publish_app_service_request.cc index bdbf8d0983..7ccbe9fecd 100644 --- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/publish_app_service_request.cc +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/publish_app_service_request.cc @@ -130,7 +130,10 @@ void PublishAppServiceRequest::Run() { requested_handled_rpcs); if (!result) { - SendResponse(false, mobile_apis::Result::DISALLOWED, "Service disallowed by policies", NULL); + SendResponse(false, + mobile_apis::Result::DISALLOWED, + "Service disallowed by policies", + NULL); } response_params[strings::app_service_record] = service_record; -- cgit v1.2.1 From 2a26de5bc0f3a357e28e6a83c9a7d439d2673431 Mon Sep 17 00:00:00 2001 From: Jacob Keeler Date: Sat, 23 Feb 2019 12:35:11 -0500 Subject: App Service Activation Logic (#2809) * Add AS.AppServiceActivation and AS.GetAppServiceRecords RPCs * Initialize AppServiceManager in Application manager tests * Moved create notification functions to message helper class * Fix style * Removed setServiceActive function * Add OnSystemCapabilityUpdated triggers to AppServiceManager Includes refactoring of OnSystemCapabilityUpdated notification classes. * Remove servicesSupported parameter * Update SystemCapability structs with new revisions * Include additional cases for activation 1. Services are activated if their publishing app is in the foreground. 2. If a service is deactivated without another being activated, the embedded service becomes active if available. * Fixed error from previous commit and addressed style comments * Addressed review comments * Address review comments * Fix LastState usage in app service manager * Addressed review comments and removed extra debug statements * Fix style --- .../application_manager/app_service_manager.h | 21 +- .../include/application_manager/message_helper.h | 11 +- .../application_manager/smart_object_keys.h | 3 + .../hmi/as_app_service_activation_request.h | 80 ++++++ .../hmi/as_app_service_activation_response.h | 80 ++++++ .../hmi/as_get_app_service_records_request.h | 80 ++++++ .../hmi/as_get_app_service_records_response.h | 80 ++++++ .../src/app_service_hmi_command_factory.cc | 14 + .../hmi/as_app_service_activation_request.cc | 87 +++++++ .../hmi/as_app_service_activation_response.cc | 59 +++++ .../hmi/as_get_app_service_records_request.cc | 88 +++++++ .../hmi/as_get_app_service_records_response.cc | 59 +++++ .../commands/mobile/publish_app_service_request.cc | 5 + ...on_bc_system_capability_updated_notification.cc | 80 ++++++ .../mobile/get_system_capability_request.cc | 22 +- .../on_system_capability_updated_notification.cc | 95 ++++++- .../application_manager/src/app_service_manager.cc | 285 ++++++++++++++++++--- .../src/application_manager_impl.cc | 5 +- .../src/message_helper/message_helper.cc | 46 +--- .../application_manager/src/smart_object_keys.cc | 3 + .../test/application_manager_impl_test.cc | 12 +- .../application_manager/mock_message_helper.h | 11 +- .../test/mock_message_helper.cc | 21 +- src/components/interfaces/HMI_API.xml | 36 +++ 24 files changed, 1142 insertions(+), 141 deletions(-) create mode 100644 src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/hmi/as_app_service_activation_request.h create mode 100644 src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/hmi/as_app_service_activation_response.h create mode 100644 src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/hmi/as_get_app_service_records_request.h create mode 100644 src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/hmi/as_get_app_service_records_response.h create mode 100644 src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_app_service_activation_request.cc create mode 100644 src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_app_service_activation_response.cc create mode 100644 src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_get_app_service_records_request.cc create mode 100644 src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_get_app_service_records_response.cc diff --git a/src/components/application_manager/include/application_manager/app_service_manager.h b/src/components/application_manager/include/application_manager/app_service_manager.h index c1f8a52370..253ed2a439 100644 --- a/src/components/application_manager/include/application_manager/app_service_manager.h +++ b/src/components/application_manager/include/application_manager/app_service_manager.h @@ -33,8 +33,14 @@ #ifndef SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_APP_SERVICE_MANAGER_H_ #define SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_APP_SERVICE_MANAGER_H_ +#include "application_manager/application.h" +#include "interfaces/MOBILE_API.h" #include "smart_objects/smart_object.h" +namespace resumption { +class LastState; +} + namespace application_manager { struct AppService { @@ -55,7 +61,8 @@ class AppServiceManager { * @brief Class constructor * @param app_manager */ - AppServiceManager(ApplicationManager& app_manager); + AppServiceManager(ApplicationManager& app_manager, + resumption::LastState& last_state); /** * @brief Class destructor @@ -77,6 +84,8 @@ class AppServiceManager { */ bool UnpublishAppService(const std::string service_id); + void OnAppActivated(ApplicationConstSharedPtr app); + /** * @brief TODO * @param connection_key @@ -124,13 +133,23 @@ class AppServiceManager { std::pair ActiveServiceByType( std::string service_type); + std::pair EmbeddedServiceForType( + std::string service_type); + std::pair FindServiceByName(std::string name); std::string DefaultServiceByType(std::string service_type); private: ApplicationManager& app_manager_; + resumption::LastState& last_state_; std::map published_services_; + + void BroadcastAppServiceUpdate(smart_objects::SmartObject& msg_params); + void AppServiceUpdated( + const smart_objects::SmartObject& service_record, + const mobile_apis::ServiceUpdateReason::eType update_reason, + smart_objects::SmartObject& msg_params); }; } // namespace application_manager diff --git a/src/components/application_manager/include/application_manager/message_helper.h b/src/components/application_manager/include/application_manager/message_helper.h index 0487355056..fd16d57740 100644 --- a/src/components/application_manager/include/application_manager/message_helper.h +++ b/src/components/application_manager/include/application_manager/message_helper.h @@ -878,15 +878,8 @@ class MessageHelper { static smart_objects::SmartObjectSPtr CreateMessageForHMI( hmi_apis::messageType::eType message_type, const uint32_t correlation_id); - static smart_objects::SmartObject CreateMobileSystemCapabilityNotification( - std::vector& all_services, - const std::string service_id, - mobile_apis::ServiceUpdateReason::eType update_reason); - - static smart_objects::SmartObject CreateHMISystemCapabilityNotification( - std::vector& all_services, - const std::string service_id, - mobile_apis::ServiceUpdateReason::eType update_reason); + static smart_objects::SmartObject CreateAppServiceCapabilities( + std::vector& all_services); private: /** 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 af334d5e97..615b8ab767 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 @@ -321,6 +321,9 @@ extern const char* service_active; extern const char* app_services; extern const char* update_reason; extern const char* updated_app_service_record; +extern const char* service_records; +extern const char* activate; +extern const char* set_as_default; // resuming extern const char* application_commands; diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/hmi/as_app_service_activation_request.h b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/hmi/as_app_service_activation_request.h new file mode 100644 index 0000000000..c98979da0f --- /dev/null +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/hmi/as_app_service_activation_request.h @@ -0,0 +1,80 @@ +/* + Copyright (c) 2019, Ford Motor Company, Livio + 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 the copyright holders nor the names of their + 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. + */ + +#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_APP_SERVICE_RPC_PLUGIN_INCLUDE_APP_SERVICE_RPC_PLUGIN_COMMANDS_HMI_AS_APP_SERVICE_ACTIVATION_REQUEST_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_APP_SERVICE_RPC_PLUGIN_INCLUDE_APP_SERVICE_RPC_PLUGIN_COMMANDS_HMI_AS_APP_SERVICE_ACTIVATION_REQUEST_H_ + +#include "app_service_rpc_plugin/app_service_rpc_plugin.h" +#include "application_manager/commands/request_from_hmi.h" + +namespace app_service_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief ASAppServiceActivationRequest command class + **/ +class ASAppServiceActivationRequest + : public app_mngr::commands::RequestFromHMI { + public: + /** + * @brief ASAppServiceActivationRequest class constructor + * + * @param message Incoming SmartObject message + **/ + ASAppServiceActivationRequest( + const app_mngr::commands::MessageSharedPtr& message, + app_mngr::ApplicationManager& application_manager, + app_mngr::rpc_service::RPCService& rpc_service, + app_mngr::HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle); + + /** + * @brief ASAppServiceActivationRequest class destructor + **/ + virtual ~ASAppServiceActivationRequest(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(ASAppServiceActivationRequest); +}; + +} // namespace commands + +} // namespace app_service_rpc_plugin + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_APP_SERVICE_RPC_PLUGIN_INCLUDE_APP_SERVICE_RPC_PLUGIN_COMMANDS_HMI_AS_APP_SERVICE_ACTIVATION_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/hmi/as_app_service_activation_response.h b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/hmi/as_app_service_activation_response.h new file mode 100644 index 0000000000..68b77cb7e3 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/hmi/as_app_service_activation_response.h @@ -0,0 +1,80 @@ +/* + Copyright (c) 2019, Ford Motor Company, Livio + 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 the copyright holders nor the names of their + 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. + */ + +#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_APP_SERVICE_RPC_PLUGIN_INCLUDE_APP_SERVICE_RPC_PLUGIN_COMMANDS_HMI_AS_APP_SERVICE_ACTIVATION_RESPONSE_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_APP_SERVICE_RPC_PLUGIN_INCLUDE_APP_SERVICE_RPC_PLUGIN_COMMANDS_HMI_AS_APP_SERVICE_ACTIVATION_RESPONSE_H_ + +#include "app_service_rpc_plugin/app_service_rpc_plugin.h" +#include "application_manager/commands/response_to_hmi.h" + +namespace app_service_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief ASAppServiceActivationResponse command class + **/ +class ASAppServiceActivationResponse + : public app_mngr::commands::ResponseToHMI { + public: + /** + * @brief ASAppServiceActivationResponse class constructor + * + * @param message Incoming SmartObject message + **/ + ASAppServiceActivationResponse( + const app_mngr::commands::MessageSharedPtr& message, + app_mngr::ApplicationManager& application_manager, + app_mngr::rpc_service::RPCService& rpc_service, + app_mngr::HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle); + + /** + * @brief ASAppServiceActivationResponse class destructor + **/ + virtual ~ASAppServiceActivationResponse(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(ASAppServiceActivationResponse); +}; + +} // namespace commands + +} // namespace app_service_rpc_plugin + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_APP_SERVICE_RPC_PLUGIN_INCLUDE_APP_SERVICE_RPC_PLUGIN_COMMANDS_HMI_AS_APP_SERVICE_ACTIVATION_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/hmi/as_get_app_service_records_request.h b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/hmi/as_get_app_service_records_request.h new file mode 100644 index 0000000000..79ea0922a8 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/hmi/as_get_app_service_records_request.h @@ -0,0 +1,80 @@ +/* + Copyright (c) 2019, Ford Motor Company, Livio + 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 the copyright holders nor the names of their + 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. + */ + +#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_APP_SERVICE_RPC_PLUGIN_INCLUDE_APP_SERVICE_RPC_PLUGIN_COMMANDS_HMI_AS_GET_APP_SERVICE_RECORDS_REQUEST_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_APP_SERVICE_RPC_PLUGIN_INCLUDE_APP_SERVICE_RPC_PLUGIN_COMMANDS_HMI_AS_GET_APP_SERVICE_RECORDS_REQUEST_H_ + +#include "app_service_rpc_plugin/app_service_rpc_plugin.h" +#include "application_manager/commands/request_from_hmi.h" + +namespace app_service_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief ASGetAppServiceRecordsRequest command class + **/ +class ASGetAppServiceRecordsRequest + : public app_mngr::commands::RequestFromHMI { + public: + /** + * @brief ASGetAppServiceRecordsRequest class constructor + * + * @param message Incoming SmartObject message + **/ + ASGetAppServiceRecordsRequest( + const app_mngr::commands::MessageSharedPtr& message, + app_mngr::ApplicationManager& application_manager, + app_mngr::rpc_service::RPCService& rpc_service, + app_mngr::HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle); + + /** + * @brief ASGetAppServiceRecordsRequest class destructor + **/ + virtual ~ASGetAppServiceRecordsRequest(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(ASGetAppServiceRecordsRequest); +}; + +} // namespace commands + +} // namespace app_service_rpc_plugin + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_APP_SERVICE_RPC_PLUGIN_INCLUDE_APP_SERVICE_RPC_PLUGIN_COMMANDS_HMI_AS_GET_APP_SERVICE_RECORDS_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/hmi/as_get_app_service_records_response.h b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/hmi/as_get_app_service_records_response.h new file mode 100644 index 0000000000..6db24132af --- /dev/null +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/hmi/as_get_app_service_records_response.h @@ -0,0 +1,80 @@ +/* + Copyright (c) 2019, Ford Motor Company, Livio + 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 the copyright holders nor the names of their + 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. + */ + +#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_APP_SERVICE_RPC_PLUGIN_INCLUDE_APP_SERVICE_RPC_PLUGIN_COMMANDS_HMI_AS_GET_APP_SERVICE_RECORDS_RESPONSE_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_APP_SERVICE_RPC_PLUGIN_INCLUDE_APP_SERVICE_RPC_PLUGIN_COMMANDS_HMI_AS_GET_APP_SERVICE_RECORDS_RESPONSE_H_ + +#include "app_service_rpc_plugin/app_service_rpc_plugin.h" +#include "application_manager/commands/response_to_hmi.h" + +namespace app_service_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief ASGetAppServiceRecordsResponse command class + **/ +class ASGetAppServiceRecordsResponse + : public app_mngr::commands::ResponseToHMI { + public: + /** + * @brief ASGetAppServiceRecordsResponse class constructor + * + * @param message Incoming SmartObject message + **/ + ASGetAppServiceRecordsResponse( + const app_mngr::commands::MessageSharedPtr& message, + app_mngr::ApplicationManager& application_manager, + app_mngr::rpc_service::RPCService& rpc_service, + app_mngr::HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle); + + /** + * @brief ASGetAppServiceRecordsResponse class destructor + **/ + virtual ~ASGetAppServiceRecordsResponse(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(ASGetAppServiceRecordsResponse); +}; + +} // namespace commands + +} // namespace app_service_rpc_plugin + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_APP_SERVICE_RPC_PLUGIN_INCLUDE_APP_SERVICE_RPC_PLUGIN_COMMANDS_HMI_AS_GET_APP_SERVICE_RECORDS_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/app_service_hmi_command_factory.cc b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/app_service_hmi_command_factory.cc index e741d7bfd4..7afc04c8e9 100644 --- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/app_service_hmi_command_factory.cc +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/app_service_hmi_command_factory.cc @@ -34,6 +34,10 @@ #include "application_manager/message.h" #include "interfaces/HMI_API.h" +#include "app_service_rpc_plugin/commands/hmi/as_app_service_activation_request.h" +#include "app_service_rpc_plugin/commands/hmi/as_app_service_activation_response.h" +#include "app_service_rpc_plugin/commands/hmi/as_get_app_service_records_request.h" +#include "app_service_rpc_plugin/commands/hmi/as_get_app_service_records_response.h" #include "app_service_rpc_plugin/commands/hmi/as_publish_app_service_request.h" #include "app_service_rpc_plugin/commands/hmi/as_publish_app_service_response.h" #include "app_service_rpc_plugin/commands/hmi/on_as_app_service_data_notification.h" @@ -111,6 +115,16 @@ app_mngr::CommandCreator& AppServiceHmiCommandFactory::buildCommandCreator( commands::OnASAppServiceDataNotificationFromHMI>() : factory .GetCreator(); + case hmi_apis::FunctionID::AppService_GetAppServiceRecords: + return hmi_apis::messageType::request == message_type + ? factory.GetCreator() + : factory + .GetCreator(); + case hmi_apis::FunctionID::AppService_AppServiceActivation: + return hmi_apis::messageType::request == message_type + ? factory.GetCreator() + : factory + .GetCreator(); default: LOG4CXX_WARN(logger_, "Unsupported function_id: " << function_id); return factory.GetCreator(); diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_app_service_activation_request.cc b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_app_service_activation_request.cc new file mode 100644 index 0000000000..7c32d9bbe1 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_app_service_activation_request.cc @@ -0,0 +1,87 @@ +/* + Copyright (c) 2019, Ford Motor Company, Livio + 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 the copyright holders nor the names of their + 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 "app_service_rpc_plugin/commands/hmi/as_app_service_activation_request.h" + +namespace app_service_rpc_plugin { +using namespace application_manager; +namespace commands { + +ASAppServiceActivationRequest::ASAppServiceActivationRequest( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + app_mngr::rpc_service::RPCService& rpc_service, + app_mngr::HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handler) + : RequestFromHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handler) {} + +ASAppServiceActivationRequest::~ASAppServiceActivationRequest() {} + +void ASAppServiceActivationRequest::Run() { + LOG4CXX_AUTO_TRACE(logger_); + AppServiceManager& service_manager = + application_manager_.GetAppServiceManager(); + smart_objects::SmartObject params = (*message_)[strings::msg_params]; + smart_objects::SmartObject response_params(smart_objects::SmartType_Map); + std::string service_id = params[strings::service_id].asString(); + response_params[strings::service_id] = service_id; + if (params[strings::activate].asBool()) { + response_params[strings::activate] = + service_manager.ActivateAppService(service_id); + } else { + service_manager.DeactivateAppService(service_id); + response_params[strings::activate] = false; + } + + if (params.keyExists(strings::set_as_default)) { + if (params[strings::set_as_default].asBool()) { + response_params[strings::set_as_default] = + service_manager.SetDefaultService(service_id); + } else { + service_manager.RemoveDefaultService(service_id); + response_params[strings::set_as_default] = false; + } + } + + SendResponse(true, + (*message_)[strings::params][strings::correlation_id].asUInt(), + hmi_apis::FunctionID::AppService_AppServiceActivation, + hmi_apis::Common_Result::SUCCESS, + &response_params); +} + +} // namespace commands +} // namespace app_service_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_app_service_activation_response.cc b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_app_service_activation_response.cc new file mode 100644 index 0000000000..c77d3ed381 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_app_service_activation_response.cc @@ -0,0 +1,59 @@ +/* + Copyright (c) 2019, Ford Motor Company, Livio + 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 the copyright holders nor the names of their + 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 "app_service_rpc_plugin/commands/hmi/as_app_service_activation_response.h" + +namespace app_service_rpc_plugin { +using namespace application_manager; +namespace commands { + +ASAppServiceActivationResponse::ASAppServiceActivationResponse( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + app_mngr::rpc_service::RPCService& rpc_service, + app_mngr::HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handler) + : ResponseToHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handler) {} + +ASAppServiceActivationResponse::~ASAppServiceActivationResponse() {} + +void ASAppServiceActivationResponse::Run() { + LOG4CXX_AUTO_TRACE(logger_); + rpc_service_.SendMessageToHMI(message_); +} + +} // namespace commands +} // namespace app_service_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_get_app_service_records_request.cc b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_get_app_service_records_request.cc new file mode 100644 index 0000000000..1131448d2f --- /dev/null +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_get_app_service_records_request.cc @@ -0,0 +1,88 @@ +/* + Copyright (c) 2019, Ford Motor Company, Livio + 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 the copyright holders nor the names of their + 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 "app_service_rpc_plugin/commands/hmi/as_get_app_service_records_request.h" + +namespace app_service_rpc_plugin { +using namespace application_manager; +namespace commands { + +ASGetAppServiceRecordsRequest::ASGetAppServiceRecordsRequest( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + app_mngr::rpc_service::RPCService& rpc_service, + app_mngr::HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handler) + : RequestFromHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handler) {} + +ASGetAppServiceRecordsRequest::~ASGetAppServiceRecordsRequest() {} + +void ASGetAppServiceRecordsRequest::Run() { + LOG4CXX_AUTO_TRACE(logger_); + std::string type; + if ((*message_)[strings::msg_params].keyExists(strings::service_type)) { + type = (*message_)[strings::msg_params][strings::service_type].asString(); + } + smart_objects::SmartObject response_params = + smart_objects::SmartObject(smart_objects::SmartType_Map); + smart_objects::SmartObject records = + smart_objects::SmartObject(smart_objects::SmartType_Array); + std::vector service_records = + application_manager_.GetAppServiceManager().GetAllServices(); + + int index = 0; + for (auto& record : service_records) { + if (!type.empty() && + record[strings::service_manifest][strings::service_type].asString() != + type) { + continue; + } + records[index] = record; + index++; + } + + if (!records.empty()) { + response_params[strings::service_records] = records; + } + SendResponse(true, + (*message_)[strings::params][strings::correlation_id].asUInt(), + hmi_apis::FunctionID::AppService_GetAppServiceRecords, + hmi_apis::Common_Result::SUCCESS, + &response_params); +} + +} // namespace commands +} // namespace app_service_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_get_app_service_records_response.cc b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_get_app_service_records_response.cc new file mode 100644 index 0000000000..0479aa8d31 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_get_app_service_records_response.cc @@ -0,0 +1,59 @@ +/* + Copyright (c) 2019, Ford Motor Company, Livio + 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 the copyright holders nor the names of their + 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 "app_service_rpc_plugin/commands/hmi/as_get_app_service_records_response.h" + +namespace app_service_rpc_plugin { +using namespace application_manager; +namespace commands { + +ASGetAppServiceRecordsResponse::ASGetAppServiceRecordsResponse( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + app_mngr::rpc_service::RPCService& rpc_service, + app_mngr::HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handler) + : ResponseToHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handler) {} + +ASGetAppServiceRecordsResponse::~ASGetAppServiceRecordsResponse() {} + +void ASGetAppServiceRecordsResponse::Run() { + LOG4CXX_AUTO_TRACE(logger_); + rpc_service_.SendMessageToHMI(message_); +} + +} // namespace commands +} // namespace app_service_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/publish_app_service_request.cc b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/publish_app_service_request.cc index 96f17f732a..ab82bf77dd 100644 --- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/publish_app_service_request.cc +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/publish_app_service_request.cc @@ -99,6 +99,11 @@ void PublishAppServiceRequest::Run() { smart_objects::SmartObject service_record = application_manager_.GetAppServiceManager().PublishAppService( manifest, true, connection_key()); + if (app->is_foreground()) { + // Service should be activated if app is in the foreground + application_manager_.GetAppServiceManager().ActivateAppService( + service_record[strings::service_id].asString()); + } response_params[strings::app_service_record] = service_record; diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_bc_system_capability_updated_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_bc_system_capability_updated_notification.cc index 3f8dcf08f6..d0c33e76d9 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_bc_system_capability_updated_notification.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_bc_system_capability_updated_notification.cc @@ -32,6 +32,7 @@ #include "sdl_rpc_plugin/commands/hmi/on_bc_system_capability_updated_notification.h" #include "application_manager/application_impl.h" +#include "application_manager/message_helper.h" #include "application_manager/rpc_service.h" #include "interfaces/HMI_API.h" @@ -60,6 +61,85 @@ void OnBCSystemCapabilityUpdatedNotification::Run() { LOG4CXX_DEBUG(logger_, "Sending BasicCommunication.OnSystemCapabilityUpdated " "Notification to HMI"); + + smart_objects::SmartObject& msg_params = (*message_)[strings::msg_params]; + + hmi_apis::Common_SystemCapabilityType::eType system_capability_type = + static_cast( + msg_params[strings::system_capability] + [strings::system_capability_type].asInt()); + switch (system_capability_type) { + case hmi_apis::Common_SystemCapabilityType::NAVIGATION: { + if (hmi_capabilities_.navigation_capability()) { + msg_params[strings::system_capability][strings::navigation_capability] = + *hmi_capabilities_.navigation_capability(); + } + break; + } + case hmi_apis::Common_SystemCapabilityType::PHONE_CALL: { + if (hmi_capabilities_.phone_capability()) { + msg_params[strings::system_capability][strings::phone_capability] = + *hmi_capabilities_.phone_capability(); + } + break; + } + case hmi_apis::Common_SystemCapabilityType::REMOTE_CONTROL: { + if (!hmi_capabilities_.is_rc_cooperating()) { + return; + } + if (hmi_capabilities_.rc_capability()) { + msg_params[strings::system_capability][strings::rc_capability] = + *hmi_capabilities_.rc_capability(); + } + break; + } + case hmi_apis::Common_SystemCapabilityType::VIDEO_STREAMING: + if (hmi_capabilities_.video_streaming_capability()) { + msg_params[strings::system_capability] + [strings::video_streaming_capability] = + *hmi_capabilities_.video_streaming_capability(); + } + break; + case hmi_apis::Common_SystemCapabilityType::APP_SERVICES: { + auto all_services = + application_manager_.GetAppServiceManager().GetAllServices(); + auto app_service_caps = + MessageHelper::CreateAppServiceCapabilities(all_services); + + smart_objects::SmartArray* app_services = + app_service_caps[strings::app_services].asArray(); + smart_objects::SmartObject& updated_capabilities = + msg_params[strings::system_capability] + [strings::app_services_capabilities][strings::app_services]; + for (size_t i = 0; i < updated_capabilities.length(); i++) { + std::string service_id = + updated_capabilities[i][strings::updated_app_service_record] + [strings::service_id].asString(); + auto matching_service_predicate = [&service_id]( + const smart_objects::SmartObject& app_service_capability) { + return service_id == + app_service_capability[strings::updated_app_service_record] + [strings::service_id].asString(); + }; + + auto it = std::find_if(app_services->begin(), + app_services->end(), + matching_service_predicate); + if (it != app_services->end()) { + LOG4CXX_DEBUG(logger_, + "Replacing updated record with service_id " + << service_id); + app_services->erase(it); + } + app_services->push_back(updated_capabilities[i]); + } + msg_params[strings::system_capability] + [strings::app_services_capabilities] = app_service_caps; + break; + } + default: + return; + } SendNotification(); } 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 1449f0e061..b551db0008 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 @@ -132,25 +132,11 @@ void GetSystemCapabilityRequest::Run() { } break; case mobile_apis::SystemCapabilityType::APP_SERVICES: { - smart_objects::SmartObject app_service_capabilities( - smart_objects::SmartType_Map); - smart_objects::SmartObject app_services(smart_objects::SmartType_Array); - - std::vector service_records = + auto all_services = application_manager_.GetAppServiceManager().GetAllServices(); - - for (auto& record : service_records) { - smart_objects::SmartObject app_services_capabilities( - smart_objects::SmartType_Map); - app_services_capabilities[strings::updated_app_service_record] = record; - app_services.asArray()->push_back(app_services_capabilities); - } - - app_service_capabilities[strings::app_services] = app_services; - response_params[strings::system_capability] - [strings::app_services_capabilities] = - app_service_capabilities; - + response_params + [strings::system_capability][strings::app_services_capabilities] = + MessageHelper::CreateAppServiceCapabilities(all_services); break; } default: // Return unsupported resource diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_system_capability_updated_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_system_capability_updated_notification.cc index 6a1f0844d9..0745bc08dc 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_system_capability_updated_notification.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_system_capability_updated_notification.cc @@ -28,10 +28,84 @@ OnSystemCapabilityUpdatedNotification:: void OnSystemCapabilityUpdatedNotification::Run() { LOG4CXX_AUTO_TRACE(logger_); - mobile_apis::SystemCapabilityType::eType system_capability_type = - static_cast( - (*message_)[strings::msg_params][strings::system_capability] - [strings::system_capability_type].asInt()); + smart_objects::SmartObject& msg_params = (*message_)[strings::msg_params]; + mobile_apis::SystemCapabilityType::eType system_capability_type = static_cast< + mobile_apis::SystemCapabilityType::eType>( + msg_params[strings::system_capability][strings::system_capability_type] + .asInt()); + + switch (system_capability_type) { + case mobile_apis::SystemCapabilityType::NAVIGATION: { + if (hmi_capabilities_.navigation_capability()) { + msg_params[strings::system_capability][strings::navigation_capability] = + *hmi_capabilities_.navigation_capability(); + } + break; + } + case mobile_apis::SystemCapabilityType::PHONE_CALL: { + if (hmi_capabilities_.phone_capability()) { + msg_params[strings::system_capability][strings::phone_capability] = + *hmi_capabilities_.phone_capability(); + } + break; + } + case mobile_apis::SystemCapabilityType::REMOTE_CONTROL: { + if (!hmi_capabilities_.is_rc_cooperating()) { + return; + } + if (hmi_capabilities_.rc_capability()) { + msg_params[strings::system_capability][strings::rc_capability] = + *hmi_capabilities_.rc_capability(); + } + break; + } + case mobile_apis::SystemCapabilityType::VIDEO_STREAMING: + if (hmi_capabilities_.video_streaming_capability()) { + msg_params[strings::system_capability] + [strings::video_streaming_capability] = + *hmi_capabilities_.video_streaming_capability(); + } + break; + case mobile_apis::SystemCapabilityType::APP_SERVICES: { + auto all_services = + application_manager_.GetAppServiceManager().GetAllServices(); + auto app_service_caps = + MessageHelper::CreateAppServiceCapabilities(all_services); + + smart_objects::SmartArray* app_services = + app_service_caps[strings::app_services].asArray(); + smart_objects::SmartObject& updated_capabilities = + msg_params[strings::system_capability] + [strings::app_services_capabilities][strings::app_services]; + for (size_t i = 0; i < updated_capabilities.length(); i++) { + std::string service_id = + updated_capabilities[i][strings::updated_app_service_record] + [strings::service_id].asString(); + auto matching_service_predicate = [&service_id]( + const smart_objects::SmartObject& app_service_capability) { + return service_id == + app_service_capability[strings::updated_app_service_record] + [strings::service_id].asString(); + }; + + auto it = std::find_if(app_services->begin(), + app_services->end(), + matching_service_predicate); + if (it != app_services->end()) { + LOG4CXX_DEBUG(logger_, + "Replacing updated record with service_id " + << service_id); + app_services->erase(it); + } + app_services->push_back(updated_capabilities[i]); + } + msg_params[strings::system_capability] + [strings::app_services_capabilities] = app_service_caps; + break; + } + default: + return; + } const char* capability_type_string; ns_smart_device_link::ns_smart_objects::EnumConversionHelper< @@ -56,6 +130,19 @@ void OnSystemCapabilityUpdatedNotification::Run() { for (; applications.end() != app_it; ++app_it) { const ApplicationSharedPtr app = *app_it; + if (system_capability_type == + mobile_apis::SystemCapabilityType::REMOTE_CONTROL && + !app->is_remote_control_supported()) { + LOG4CXX_WARN( + logger_, + "App with connection key: " + << app->app_id() + << " was subcribed to REMOTE_CONTROL system capabilities, but " + "does not have RC permissions. Unsubscribing"); + auto& ext = SystemCapabilityAppExtension::ExtractExtension(*app); + ext.UnsubscribeFrom(system_capability_type); + continue; + } LOG4CXX_INFO(logger_, "Sending OnSystemCapabilityUpdated " << capability_type_string << " application id " diff --git a/src/components/application_manager/src/app_service_manager.cc b/src/components/application_manager/src/app_service_manager.cc index 57b319c680..bc9d363839 100644 --- a/src/components/application_manager/src/app_service_manager.cc +++ b/src/components/application_manager/src/app_service_manager.cc @@ -43,14 +43,19 @@ #include "application_manager/message_helper.h" #include "application_manager/smart_object_keys.h" #include "encryption/hashing.h" +#include "resumption/last_state.h" #include "utils/logger.h" CREATE_LOGGERPTR_GLOBAL(logger_, "AppServiceManager") namespace application_manager { -AppServiceManager::AppServiceManager(ApplicationManager& app_manager) - : app_manager_(app_manager) {} +const char* kAppServiceSection = "AppServices"; +const char* kDefaults = "defaults"; + +AppServiceManager::AppServiceManager(ApplicationManager& app_manager, + resumption::LastState& last_state) + : app_manager_(app_manager), last_state_(last_state) {} AppServiceManager::~AppServiceManager() { LOG4CXX_AUTO_TRACE(logger_); @@ -78,28 +83,31 @@ smart_objects::SmartObject AppServiceManager::PublishAppService( service_record[strings::service_manifest] = manifest; service_record[strings::service_id] = service_id; service_record[strings::service_published] = true; - service_record[strings::service_active] = true; + service_record[strings::service_active] = false; app_service.record = service_record; + std::string service_type = manifest[strings::service_type].asString(); + Json::Value& dictionary = last_state_.get_dictionary(); + app_service.default_service = + (dictionary[kAppServiceSection][kDefaults][service_type].asString() == + manifest[strings::service_name].asString()); + published_services_.insert( std::pair(service_id, app_service)); - auto all_services = GetAllServices(); - smart_objects::SmartObjectSPtr notification = - std::make_shared( - MessageHelper::CreateMobileSystemCapabilityNotification( - all_services, - service_id, - mobile_apis::ServiceUpdateReason::PUBLISHED)); - app_manager_.GetRPCService().ManageMobileCommand( - notification, commands::Command::CommandSource::SOURCE_SDL); - smart_objects::SmartObjectSPtr hmi_notification = - std::make_shared( - MessageHelper::CreateHMISystemCapabilityNotification( - all_services, - service_id, - mobile_apis::ServiceUpdateReason::PUBLISHED)); - app_manager_.GetRPCService().ManageHMICommand(hmi_notification); + smart_objects::SmartObject msg_params; + AppServiceUpdated( + service_record, mobile_apis::ServiceUpdateReason::PUBLISHED, msg_params); + BroadcastAppServiceUpdate(msg_params); + + // Activate the new service if it is the default for its service type, or if + // no service is active of its service type + std::pair active_service = + ActiveServiceByType(service_type); + if (active_service.first.empty() || app_service.default_service) { + ActivateAppService(service_id); + } + return service_record; } @@ -114,24 +122,25 @@ bool AppServiceManager::UnpublishAppService(const std::string service_id) { LOG4CXX_DEBUG(logger_, "Unpublishing app service: " << service_id); SetServicePublished(service_id, false); + smart_objects::SmartObject msg_params; - auto all_services = GetAllServices(); - smart_objects::SmartObjectSPtr notification = - std::make_shared( - MessageHelper::CreateMobileSystemCapabilityNotification( - all_services, - service_id, - mobile_apis::ServiceUpdateReason::REMOVED)); - app_manager_.GetRPCService().ManageMobileCommand( - notification, commands::Command::CommandSource::SOURCE_SDL); - smart_objects::SmartObjectSPtr hmi_notification = - std::make_shared( - MessageHelper::CreateHMISystemCapabilityNotification( - all_services, - service_id, - mobile_apis::ServiceUpdateReason::REMOVED)); - app_manager_.GetRPCService().ManageHMICommand(hmi_notification); + auto record = it->second.record; + if (record[strings::service_active].asBool()) { + record[strings::service_active] = false; + // Activate embedded service, if available + auto embedded_service = EmbeddedServiceForType( + record[strings::service_manifest][strings::service_type].asString()); + if (!embedded_service.first.empty()) { + embedded_service.second.record[strings::service_active] = true; + AppServiceUpdated(embedded_service.second.record, + mobile_apis::ServiceUpdateReason::ACTIVATED, + msg_params); + } + } + AppServiceUpdated( + it->second.record, mobile_apis::ServiceUpdateReason::REMOVED, msg_params); + BroadcastAppServiceUpdate(msg_params); published_services_.erase(it); return true; @@ -148,6 +157,17 @@ void AppServiceManager::UnpublishServices(const uint32_t connection_key) { } } +void AppServiceManager::OnAppActivated(ApplicationConstSharedPtr app) { + LOG4CXX_AUTO_TRACE(logger_); + auto it = published_services_.begin(); + // Activate all services published by the app + for (; it != published_services_.end(); ++it) { + if (it->second.connection_key == app->app_id()) { + ActivateAppService(it->first); + } + } +} + std::vector AppServiceManager::GetAllServices() { LOG4CXX_AUTO_TRACE(logger_); std::vector services; @@ -158,14 +178,123 @@ std::vector AppServiceManager::GetAllServices() { return services; } -void AppServiceManager::SetServicePublished(const std::string service_id, - bool service_published) { +bool AppServiceManager::SetDefaultService(const std::string service_id) { + LOG4CXX_AUTO_TRACE(logger_); auto it = published_services_.find(service_id); if (it == published_services_.end()) { - LOG4CXX_ERROR(logger_, "Service id does not exist in published services"); - return; + LOG4CXX_ERROR(logger_, "Unable to find published service " << service_id); + return false; } - it->second.record[strings::service_published] = service_published; + AppService& service = it->second; + + std::string service_type = + service.record[strings::service_manifest][strings::service_type] + .asString(); + std::string default_service_name = DefaultServiceByType(service_type); + if (!default_service_name.empty()) { + auto default_service = FindServiceByName(default_service_name); + if (!default_service.first.empty()) { + default_service.second.default_service = false; + } + } + service.default_service = true; + + Json::Value& dictionary = last_state_.get_dictionary(); + dictionary[kAppServiceSection][kDefaults][service_type] = + service.record[strings::service_manifest][strings::service_name] + .asString(); + return true; +} + +bool AppServiceManager::RemoveDefaultService(const std::string service_id) { + LOG4CXX_AUTO_TRACE(logger_); + auto it = published_services_.find(service_id); + if (it == published_services_.end()) { + LOG4CXX_ERROR(logger_, "Unable to find published service " << service_id); + return false; + } + + AppService& service = it->second; + if (!service.default_service) { + LOG4CXX_ERROR(logger_, "Service was not default " << service_id); + return false; + } + service.default_service = false; + + std::string service_type = + service.record[strings::service_manifest][strings::service_type] + .asString(); + Json::Value& dictionary = last_state_.get_dictionary(); + dictionary[kAppServiceSection][kDefaults].removeMember(service_type); + return true; +} + +bool AppServiceManager::ActivateAppService(const std::string service_id) { + LOG4CXX_AUTO_TRACE(logger_); + auto it = published_services_.find(service_id); + if (it == published_services_.end()) { + LOG4CXX_ERROR(logger_, "Unable to find published service " << service_id); + return false; + } + + smart_objects::SmartObject& service = it->second.record; + if (service[strings::service_active].asBool()) { + LOG4CXX_DEBUG(logger_, "Service was already active " << service_id); + return true; + } + + smart_objects::SmartObject msg_params; + + const std::string service_type = + service[strings::service_manifest][strings::service_type].asString(); + auto active_service = ActiveServiceByType(service_type); + if (!active_service.first.empty()) { + active_service.second.record[strings::service_active] = false; + AppServiceUpdated(active_service.second.record, + mobile_apis::ServiceUpdateReason::DEACTIVATED, + msg_params); + } + service[strings::service_active] = true; + AppServiceUpdated( + service, mobile_apis::ServiceUpdateReason::ACTIVATED, msg_params); + + BroadcastAppServiceUpdate(msg_params); + return true; +} + +bool AppServiceManager::DeactivateAppService(const std::string service_id) { + LOG4CXX_AUTO_TRACE(logger_); + auto it = published_services_.find(service_id); + if (it == published_services_.end()) { + LOG4CXX_ERROR(logger_, "Unable to find published service " << service_id); + return false; + } + smart_objects::SmartObject& service = it->second.record; + smart_objects::SmartObject msg_params; + bool send_update = false; + + if (service[strings::service_active].asBool()) { + service[strings::service_active] = false; + AppServiceUpdated( + service, mobile_apis::ServiceUpdateReason::DEACTIVATED, msg_params); + + // Activate embedded service, if available + const std::string service_type = + service[strings::service_manifest][strings::service_type].asString(); + auto embedded_service = EmbeddedServiceForType(service_type); + if (!embedded_service.first.empty()) { + embedded_service.second.record[strings::service_active] = true; + AppServiceUpdated(embedded_service.second.record, + mobile_apis::ServiceUpdateReason::ACTIVATED, + msg_params); + } + send_update = true; + } + + if (send_update) { + BroadcastAppServiceUpdate(msg_params); + } + return true; } std::pair AppServiceManager::ActiveServiceByType( @@ -184,6 +313,21 @@ std::pair AppServiceManager::ActiveServiceByType( return std::make_pair(std::string(), empty); } +std::pair AppServiceManager::EmbeddedServiceForType( + std::string service_type) { + LOG4CXX_AUTO_TRACE(logger_); + for (auto it = published_services_.begin(); it != published_services_.end(); + ++it) { + if (it->second.record[strings::service_manifest][strings::service_type] + .asString() == service_type && + !it->second.mobile_service) { + return *it; + } + } + AppService empty; + return std::make_pair(std::string(), empty); +} + std::pair AppServiceManager::FindServiceByName( std::string name) { LOG4CXX_AUTO_TRACE(logger_); @@ -197,4 +341,65 @@ std::pair AppServiceManager::FindServiceByName( AppService empty; return std::make_pair(std::string(), empty); } + +std::string AppServiceManager::DefaultServiceByType(std::string service_type) { + LOG4CXX_AUTO_TRACE(logger_); + Json::Value& dictionary = last_state_.get_dictionary(); + if (dictionary[kAppServiceSection][kDefaults].isMember(service_type)) { + return dictionary[kAppServiceSection][kDefaults][service_type].asString(); + } + return std::string(); +} + +void AppServiceManager::SetServicePublished(const std::string service_id, + bool service_published) { + LOG4CXX_AUTO_TRACE(logger_); + auto it = published_services_.find(service_id); + if (it == published_services_.end()) { + LOG4CXX_ERROR(logger_, "Service id does not exist in published services"); + return; + } + it->second.record[strings::service_published] = service_published; +} + +void AppServiceManager::BroadcastAppServiceUpdate( + smart_objects::SmartObject& msg_params) { + LOG4CXX_AUTO_TRACE(logger_); + smart_objects::SmartObject message(smart_objects::SmartType_Map); + + msg_params[strings::system_capability][strings::system_capability_type] = + mobile_apis::SystemCapabilityType::APP_SERVICES; + message[strings::params][strings::message_type] = MessageType::kNotification; + message[strings::msg_params] = msg_params; + + // Construct and send mobile notification + message[strings::params][strings::function_id] = + mobile_apis::FunctionID::OnSystemCapabilityUpdatedID; + smart_objects::SmartObjectSPtr notification = + std::make_shared(message); + app_manager_.GetRPCService().ManageMobileCommand( + notification, commands::Command::CommandSource::SOURCE_SDL); + + // Construct and send HMI notification + message[strings::params][strings::function_id] = + hmi_apis::FunctionID::BasicCommunication_OnSystemCapabilityUpdated; + smart_objects::SmartObjectSPtr hmi_notification = + std::make_shared(message); + app_manager_.GetRPCService().ManageHMICommand(hmi_notification); +} + +void AppServiceManager::AppServiceUpdated( + const smart_objects::SmartObject& service_record, + const mobile_apis::ServiceUpdateReason::eType update_reason, + smart_objects::SmartObject& msg_params) { + LOG4CXX_AUTO_TRACE(logger_); + smart_objects::SmartObject& services = + msg_params[strings::system_capability][strings::app_services_capabilities] + [strings::app_services]; + smart_objects::SmartObject service(smart_objects::SmartType_Map); + service[strings::update_reason] = update_reason; + service[strings::updated_app_service_record] = service_record; + services[-1] = service; +} + } // namespace application_manager diff --git a/src/components/application_manager/src/application_manager_impl.cc b/src/components/application_manager/src/application_manager_impl.cc index 6ee221f56f..6298d547d7 100644 --- a/src/components/application_manager/src/application_manager_impl.cc +++ b/src/components/application_manager/src/application_manager_impl.cc @@ -699,6 +699,8 @@ bool ApplicationManagerImpl::ActivateApplication(ApplicationSharedPtr app) { // remove from resumption if app was activated by user resume_controller().OnAppActivated(app); + // Activate any app services published by the app + GetAppServiceManager().OnAppActivated(app); const HMILevel::eType hmi_level = HMILevel::HMI_FULL; const AudioStreamingState::eType audio_state = app->IsAudioApplication() ? AudioStreamingState::AUDIBLE @@ -2010,7 +2012,8 @@ bool ApplicationManagerImpl::Init(resumption::LastState& last_state, app_launch_ctrl_.reset(new app_launch::AppLaunchCtrlImpl( *app_launch_dto_.get(), *this, settings_)); - app_service_manager_.reset(new application_manager::AppServiceManager(*this)); + app_service_manager_.reset( + new application_manager::AppServiceManager(*this, last_state)); return true; } diff --git a/src/components/application_manager/src/message_helper/message_helper.cc b/src/components/application_manager/src/message_helper/message_helper.cc index 1d3a553711..124ec80312 100644 --- a/src/components/application_manager/src/message_helper/message_helper.cc +++ b/src/components/application_manager/src/message_helper/message_helper.cc @@ -327,55 +327,25 @@ smart_objects::SmartObjectSPtr MessageHelper::CreateMessageForHMI( return message; } -smart_objects::SmartObject -MessageHelper::CreateMobileSystemCapabilityNotification( - std::vector& all_services, - const std::string service_id, - mobile_apis::ServiceUpdateReason::eType update_reason) { - smart_objects::SmartObject message(smart_objects::SmartType_Map); - - message[strings::params][strings::message_type] = MessageType::kNotification; - message[strings::params][strings::function_id] = - mobile_apis::FunctionID::OnSystemCapabilityUpdatedID; - - smart_objects::SmartObject system_capability = - smart_objects::SmartObject(smart_objects::SmartType_Map); - system_capability[strings::system_capability_type] = - mobile_apis::SystemCapabilityType::APP_SERVICES; - +smart_objects::SmartObject MessageHelper::CreateAppServiceCapabilities( + std::vector& all_services) { smart_objects::SmartObject app_service_capabilities( smart_objects::SmartType_Map); smart_objects::SmartObject app_services(smart_objects::SmartType_Array); std::vector service_records = all_services; + int i = 0; for (auto& record : service_records) { - smart_objects::SmartObject app_services_capabilities( + smart_objects::SmartObject app_service_capability( smart_objects::SmartType_Map); - app_services_capabilities[strings::updated_app_service_record] = record; - if (record[strings::service_id].asString() == service_id) { - app_services_capabilities[strings::update_reason] = update_reason; - } - app_services.asArray()->push_back(app_services_capabilities); + app_service_capability[strings::updated_app_service_record] = record; + app_services[i] = app_service_capability; + i++; } app_service_capabilities[strings::app_services] = app_services; - system_capability[strings::app_services_capabilities] = - app_service_capabilities; - - message[strings::msg_params][strings::system_capability] = system_capability; - return message; -} - -smart_objects::SmartObject MessageHelper::CreateHMISystemCapabilityNotification( - std::vector& all_services, - const std::string service_id, - mobile_apis::ServiceUpdateReason::eType update_reason) { - auto message = CreateMobileSystemCapabilityNotification( - all_services, service_id, update_reason); - message[strings::params][strings::function_id] = - hmi_apis::FunctionID::BasicCommunication_OnSystemCapabilityUpdated; - return message; + return app_service_capabilities; } smart_objects::SmartObjectSPtr MessageHelper::CreateHashUpdateNotification( diff --git a/src/components/application_manager/src/smart_object_keys.cc b/src/components/application_manager/src/smart_object_keys.cc index 4900726d48..59499818d3 100644 --- a/src/components/application_manager/src/smart_object_keys.cc +++ b/src/components/application_manager/src/smart_object_keys.cc @@ -288,6 +288,9 @@ const char* service_active = "serviceActive"; const char* app_services = "appServices"; const char* update_reason = "updateReason"; const char* updated_app_service_record = "updatedAppServiceRecord"; +const char* service_records = "serviceRecords"; +const char* activate = "activate"; +const char* set_as_default = "setAsDefault"; // resuming const char* application_commands = "applicationCommands"; diff --git a/src/components/application_manager/test/application_manager_impl_test.cc b/src/components/application_manager/test/application_manager_impl_test.cc index 0b24fa8032..389f092e50 100644 --- a/src/components/application_manager/test/application_manager_impl_test.cc +++ b/src/components/application_manager/test/application_manager_impl_test.cc @@ -36,25 +36,26 @@ #include #include -#include "gtest/gtest.h" #include "application_manager/application.h" #include "application_manager/application_impl.h" #include "application_manager/application_manager_impl.h" #include "application_manager/mock_application.h" #include "application_manager/mock_application_manager_settings.h" #include "application_manager/mock_resumption_data.h" -#include "application_manager/mock_rpc_service.h" #include "application_manager/mock_rpc_plugin_manager.h" +#include "application_manager/mock_rpc_service.h" #include "application_manager/resumption/resume_ctrl_impl.h" #include "application_manager/test/include/application_manager/mock_message_helper.h" #include "connection_handler/mock_connection_handler.h" +#include "gtest/gtest.h" #include "hmi_message_handler/mock_hmi_message_handler.h" #include "media_manager/mock_media_manager.h" #include "policy/mock_policy_settings.h" #include "policy/usage_statistics/mock_statistics_manager.h" #include "protocol/bson_object_keys.h" -#include "protocol_handler/mock_session_observer.h" #include "protocol_handler/mock_protocol_handler.h" +#include "protocol_handler/mock_session_observer.h" +#include "resumption/mock_last_state.h" #include "utils/custom_string.h" #include "utils/file_system.h" #include "utils/lock.h" @@ -138,8 +139,10 @@ class ApplicationManagerImplTest : public ::testing::Test { app_manager_impl_->resume_controller().set_resumption_storage( mock_storage_); app_manager_impl_->set_connection_handler(&mock_connection_handler_); + Json::Value empty; + ON_CALL(mock_last_state_, get_dictionary()).WillByDefault(ReturnRef(empty)); std::unique_ptr app_service_manager_ptr( - new AppServiceManager(*app_manager_impl_)); + new AppServiceManager(*app_manager_impl_, mock_last_state_)); app_manager_impl_->SetAppServiceManager(app_service_manager_ptr); } @@ -212,6 +215,7 @@ class ApplicationManagerImplTest : public ::testing::Test { std::shared_ptr > mock_storage_; MockRPCService* mock_rpc_service_; + resumption_test::MockLastState mock_last_state_; NiceMock mock_connection_handler_; NiceMock mock_session_observer_; NiceMock mock_application_manager_settings_; diff --git a/src/components/application_manager/test/include/application_manager/mock_message_helper.h b/src/components/application_manager/test/include/application_manager/mock_message_helper.h index 878d3e7dd7..8d9cf9d7ef 100644 --- a/src/components/application_manager/test/include/application_manager/mock_message_helper.h +++ b/src/components/application_manager/test/include/application_manager/mock_message_helper.h @@ -308,16 +308,9 @@ class MockMessageHelper { void(mobile_apis::ButtonName::eType button, ApplicationSharedPtr application, ApplicationManager& app_mngr)); - MOCK_METHOD3(CreateMobileSystemCapabilityNotification, + MOCK_METHOD1(CreateAppServiceCapabilities, smart_objects::SmartObject( - std::vector& all_services, - const std::string service_id, - mobile_apis::ServiceUpdateReason::eType update_reason)); - MOCK_METHOD3(CreateHMISystemCapabilityNotification, - smart_objects::SmartObject( - std::vector& all_services, - const std::string service_id, - mobile_apis::ServiceUpdateReason::eType update_reason)); + std::vector& all_services)); static MockMessageHelper* message_helper_mock(); }; diff --git a/src/components/application_manager/test/mock_message_helper.cc b/src/components/application_manager/test/mock_message_helper.cc index 6bd42a44a1..0fe82e0dfb 100644 --- a/src/components/application_manager/test/mock_message_helper.cc +++ b/src/components/application_manager/test/mock_message_helper.cc @@ -572,22 +572,9 @@ void MessageHelper::SendUnsubscribeButtonNotification( ->SendUnsubscribeButtonNotification(button, application, app_mngr); } -smart_objects::SmartObject -MessageHelper::CreateMobileSystemCapabilityNotification( - std::vector& all_services, - const std::string service_id, - mobile_apis::ServiceUpdateReason::eType update_reason) { - return MockMessageHelper::message_helper_mock() - ->CreateMobileSystemCapabilityNotification( - all_services, service_id, update_reason); -} - -smart_objects::SmartObject MessageHelper::CreateHMISystemCapabilityNotification( - std::vector& all_services, - const std::string service_id, - mobile_apis::ServiceUpdateReason::eType update_reason) { - return MockMessageHelper::message_helper_mock() - ->CreateHMISystemCapabilityNotification( - all_services, service_id, update_reason); +smart_objects::SmartObject MessageHelper::CreateAppServiceCapabilities( + std::vector& all_services) { + return MockMessageHelper::message_helper_mock()->CreateAppServiceCapabilities( + all_services); } } // namespace application_manager diff --git a/src/components/interfaces/HMI_API.xml b/src/components/interfaces/HMI_API.xml index 0ad932fe82..2875323550 100644 --- a/src/components/interfaces/HMI_API.xml +++ b/src/components/interfaces/HMI_API.xml @@ -6201,5 +6201,41 @@ + + + + If included, only service records of supplied type will be returned in response. If not included, all service records for all types will be returned. See Common.AppServiceType. + + + + + + All app service records of requested type. + + + + + + The ID of the service that should have an activation event take place on + + + True if the service is to be activated. False if the app is to be deactivated + + + True if the service is to be the default service of this type. False if the app is not to be the default + + + + + + The ID of the service that was requested to have an activation event take place + + + True if the service was activated. False if the app was deactivated or unable to be activated + + + True if the service was set to the default service of this type. False if the app was not to be the default + + -- cgit v1.2.1 From 7d7af1bc71540dcfefbf669fc27e07f7996c586a Mon Sep 17 00:00:00 2001 From: JackLivio Date: Sat, 23 Feb 2019 13:49:50 -0500 Subject: Set behavior for omitted and missing service_names and handled_rpcs --- .../commands/mobile/publish_app_service_request.cc | 4 +-- .../src/policies/policy_handler.cc | 15 ++++++++--- .../include/policy/policy_table/types.h | 2 +- .../policy_external/src/sql_pt_representation.cc | 30 ++++++++++++++++------ .../include/policy/policy_table/types.h | 2 +- .../policy_regular/src/sql_pt_representation.cc | 30 ++++++++++++++++------ 6 files changed, 58 insertions(+), 25 deletions(-) diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/publish_app_service_request.cc b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/publish_app_service_request.cc index 7ccbe9fecd..81f369a6d8 100644 --- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/publish_app_service_request.cc +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/publish_app_service_request.cc @@ -113,7 +113,7 @@ void PublishAppServiceRequest::Run() { (*message_)[strings::msg_params][strings::app_service_manifest] [strings::service_type].asString(); - smart_objects::SmartArray* requested_handled_rpcs; + smart_objects::SmartArray* requested_handled_rpcs = NULL; if ((*message_)[strings::msg_params][strings::app_service_manifest].keyExists( strings::handled_rpcs)) { requested_handled_rpcs = @@ -121,8 +121,6 @@ void PublishAppServiceRequest::Run() { [strings::handled_rpcs].asArray(); } - ApplicationSharedPtr app = application_manager_.application(connection_key()); - bool result = policy_handler_.CheckAppServiceParameters(app->policy_app_id(), requested_service_name, diff --git a/src/components/application_manager/src/policies/policy_handler.cc b/src/components/application_manager/src/policies/policy_handler.cc index 9382a8580b..c267ac5de9 100644 --- a/src/components/application_manager/src/policies/policy_handler.cc +++ b/src/components/application_manager/src/policies/policy_handler.cc @@ -1965,21 +1965,26 @@ bool PolicyHandler::CheckAppServiceParameters( return false; } - if (!requested_service_name.empty()) { - auto service_names = - *(app_service_parameters[requested_service_type].service_names); + auto service_names = + *(app_service_parameters[requested_service_type].service_names); + if (!service_names.is_initialized()) { + LOG4CXX_DEBUG(logger_, + "Pt Service Name is Null, All service names accepted"); + } else if (!requested_service_name.empty()) { auto find_name_result = std::find(service_names.begin(), service_names.end(), rpc::String<0, 255>(requested_service_name)); if (find_name_result == service_names.end()) { + LOG4CXX_DEBUG(logger_, + "Disallowed service name: " << requested_service_name); return false; } } if (requested_handled_rpcs) { auto temp_rpcs = - *(app_service_parameters[requested_service_type].handled_rpcs); + app_service_parameters[requested_service_type].handled_rpcs; for (auto handled_it = temp_rpcs.begin(); handled_it != temp_rpcs.end(); ++handled_it) { handled_rpcs.push_back(handled_it->function_id); @@ -1991,6 +1996,8 @@ bool PolicyHandler::CheckAppServiceParameters( auto find_result = std::find( handled_rpcs.begin(), handled_rpcs.end(), requested_it->asInt()); if (find_result == handled_rpcs.end()) { + LOG4CXX_DEBUG(logger_, + "Disallowed by handled rpc: " << requested_it->asInt()); return false; } } diff --git a/src/components/policy/policy_external/include/policy/policy_table/types.h b/src/components/policy/policy_external/include/policy/policy_table/types.h index f3d154dd9f..0edfa55ab8 100644 --- a/src/components/policy/policy_external/include/policy/policy_table/types.h +++ b/src/components/policy/policy_external/include/policy/policy_table/types.h @@ -142,7 +142,7 @@ struct AppServiceHandledRpc : CompositeType { struct AppServiceInfo : CompositeType { public: Optional service_names; - Optional handled_rpcs; + AppServiceHandledRpcs handled_rpcs; public: AppServiceInfo(); diff --git a/src/components/policy/policy_external/src/sql_pt_representation.cc b/src/components/policy/policy_external/src/sql_pt_representation.cc index 435638ddb7..0b60daa0e1 100644 --- a/src/components/policy/policy_external/src/sql_pt_representation.cc +++ b/src/components/policy/policy_external/src/sql_pt_representation.cc @@ -1325,16 +1325,28 @@ bool SQLPTRepresentation::SaveAppServiceParameters( } auto app_service_names = it->second.service_names; - policy_table::AppServiceNames::const_iterator names_it; - for (names_it = app_service_names->begin(); - names_it != app_service_names->end(); - ++names_it) { + + if (app_service_names.is_initialized() && app_service_names->empty()) { + // App service names is an empty array + LOG4CXX_DEBUG(logger_, "App Service Names is Empty Array"); service_name_query.Bind(0, static_cast(id)); - service_name_query.Bind(1, *names_it); + service_name_query.Bind(1); if (!service_name_query.Exec() || !service_name_query.Reset()) { - LOG4CXX_WARN(logger_, "Incorrect insert into app service names"); + LOG4CXX_WARN(logger_, "Incorrect insert into empty app service names"); return false; } + } else { + policy_table::AppServiceNames::const_iterator names_it; + for (names_it = app_service_names->begin(); + names_it != app_service_names->end(); + ++names_it) { + service_name_query.Bind(0, static_cast(id)); + service_name_query.Bind(1, *names_it); + if (!service_name_query.Exec() || !service_name_query.Reset()) { + LOG4CXX_WARN(logger_, "Incorrect insert into app service names"); + return false; + } + } } // Insert handled rpcs array into db @@ -1347,7 +1359,7 @@ bool SQLPTRepresentation::SaveAppServiceParameters( auto handled_rpcs = it->second.handled_rpcs; policy_table::AppServiceHandledRpcs::const_iterator rpc_it; - for (rpc_it = handled_rpcs->begin(); rpc_it != handled_rpcs->end(); + for (rpc_it = handled_rpcs.begin(); rpc_it != handled_rpcs.end(); ++rpc_it) { handled_rpcs_query.Bind(0, static_cast(id)); handled_rpcs_query.Bind(1, static_cast(rpc_it->function_id)); @@ -1816,15 +1828,17 @@ bool SQLPTRepresentation::GatherAppServiceParameters( service_name_query.Bind(0, service_type_id); while (service_name_query.Next()) { + LOG4CXX_DEBUG(logger_, "Loading service name"); (*app_service_parameters)[service_type].service_names->push_back( service_name_query.GetString(0)); + (*app_service_parameters)[service_type].service_names->mark_initialized(); } handled_rpcs_query.Bind(0, service_type_id); while (handled_rpcs_query.Next()) { policy_table::AppServiceHandledRpc handled_rpc; handled_rpc.function_id = handled_rpcs_query.GetInteger(0); - (*app_service_parameters)[service_type].handled_rpcs->push_back( + (*app_service_parameters)[service_type].handled_rpcs.push_back( handled_rpc); } diff --git a/src/components/policy/policy_regular/include/policy/policy_table/types.h b/src/components/policy/policy_regular/include/policy/policy_table/types.h index b7522065bd..118f98677a 100644 --- a/src/components/policy/policy_regular/include/policy/policy_table/types.h +++ b/src/components/policy/policy_regular/include/policy/policy_table/types.h @@ -136,7 +136,7 @@ struct AppServiceHandledRpc : CompositeType { struct AppServiceInfo : CompositeType { public: Optional service_names; - Optional handled_rpcs; + AppServiceHandledRpcs handled_rpcs; public: AppServiceInfo(); diff --git a/src/components/policy/policy_regular/src/sql_pt_representation.cc b/src/components/policy/policy_regular/src/sql_pt_representation.cc index b2981759ab..661be436f0 100644 --- a/src/components/policy/policy_regular/src/sql_pt_representation.cc +++ b/src/components/policy/policy_regular/src/sql_pt_representation.cc @@ -1266,16 +1266,28 @@ bool SQLPTRepresentation::SaveAppServiceParameters( } auto app_service_names = it->second.service_names; - policy_table::AppServiceNames::const_iterator names_it; - for (names_it = app_service_names->begin(); - names_it != app_service_names->end(); - ++names_it) { + + if (app_service_names.is_initialized() && app_service_names->empty()) { + // App service names is an empty array + LOG4CXX_DEBUG(logger_, "App Service Names is Empty Array"); service_name_query.Bind(0, static_cast(id)); - service_name_query.Bind(1, *names_it); + service_name_query.Bind(1); if (!service_name_query.Exec() || !service_name_query.Reset()) { - LOG4CXX_WARN(logger_, "Incorrect insert into app service names"); + LOG4CXX_WARN(logger_, "Incorrect insert into empty app service names"); return false; } + } else { + policy_table::AppServiceNames::const_iterator names_it; + for (names_it = app_service_names->begin(); + names_it != app_service_names->end(); + ++names_it) { + service_name_query.Bind(0, static_cast(id)); + service_name_query.Bind(1, *names_it); + if (!service_name_query.Exec() || !service_name_query.Reset()) { + LOG4CXX_WARN(logger_, "Incorrect insert into app service names"); + return false; + } + } } // Insert handled rpcs array into db @@ -1288,7 +1300,7 @@ bool SQLPTRepresentation::SaveAppServiceParameters( auto handled_rpcs = it->second.handled_rpcs; policy_table::AppServiceHandledRpcs::const_iterator rpc_it; - for (rpc_it = handled_rpcs->begin(); rpc_it != handled_rpcs->end(); + for (rpc_it = handled_rpcs.begin(); rpc_it != handled_rpcs.end(); ++rpc_it) { handled_rpcs_query.Bind(0, static_cast(id)); handled_rpcs_query.Bind(1, static_cast(rpc_it->function_id)); @@ -1770,15 +1782,17 @@ bool SQLPTRepresentation::GatherAppServiceParameters( service_name_query.Bind(0, service_type_id); while (service_name_query.Next()) { + LOG4CXX_DEBUG(logger_, "Loading service name"); (*app_service_parameters)[service_type].service_names->push_back( service_name_query.GetString(0)); + (*app_service_parameters)[service_type].service_names->mark_initialized(); } handled_rpcs_query.Bind(0, service_type_id); while (handled_rpcs_query.Next()) { policy_table::AppServiceHandledRpc handled_rpc; handled_rpc.function_id = handled_rpcs_query.GetInteger(0); - (*app_service_parameters)[service_type].handled_rpcs->push_back( + (*app_service_parameters)[service_type].handled_rpcs.push_back( handled_rpc); } -- cgit v1.2.1 From da17adca89fa2cc7429230aae5c179cd3b1f4832 Mon Sep 17 00:00:00 2001 From: JackLivio Date: Sat, 23 Feb 2019 13:55:03 -0500 Subject: Move publish app service & subscribe after policy check --- .../src/commands/mobile/publish_app_service_request.cc | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/publish_app_service_request.cc b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/publish_app_service_request.cc index 81f369a6d8..953cc56b67 100644 --- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/publish_app_service_request.cc +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/publish_app_service_request.cc @@ -92,13 +92,6 @@ void PublishAppServiceRequest::Run() { } ApplicationSharedPtr app = application_manager_.application(connection_key()); - auto& ext = - sdl_rpc_plugin::SystemCapabilityAppExtension::ExtractExtension(*app); - ext.SubscribeTo(mobile_apis::SystemCapabilityType::APP_SERVICES); - - smart_objects::SmartObject service_record = - application_manager_.GetAppServiceManager().PublishAppService( - manifest, true, connection_key()); std::string requested_service_name = ""; @@ -134,6 +127,14 @@ void PublishAppServiceRequest::Run() { NULL); } + auto& ext = + sdl_rpc_plugin::SystemCapabilityAppExtension::ExtractExtension(*app); + ext.SubscribeTo(mobile_apis::SystemCapabilityType::APP_SERVICES); + + smart_objects::SmartObject service_record = + application_manager_.GetAppServiceManager().PublishAppService( + manifest, true, connection_key()); + response_params[strings::app_service_record] = service_record; SendResponse(true, mobile_apis::Result::SUCCESS, NULL, &response_params); -- cgit v1.2.1 From c3f3360bebde3f1c6a52234c94749434cfa69693 Mon Sep 17 00:00:00 2001 From: jacobkeeler Date: Sat, 23 Feb 2019 13:30:31 -0500 Subject: Fix API typo and style Also remove unused member variable in App Service messages --- .../commands/hmi/as_publish_app_service_request.h | 1 - .../commands/hmi/as_publish_app_service_response.h | 1 - .../commands/hmi/on_as_app_service_data_notification.h | 1 - .../hmi/on_as_app_service_data_notification_from_hmi.h | 1 - .../commands/mobile/on_app_service_data_notification.h | 1 - .../mobile/on_app_service_data_notification_from_mobile.h | 1 - .../commands/mobile/publish_app_service_request.h | 1 - .../commands/mobile/publish_app_service_response.h | 1 - .../src/commands/hmi/as_publish_app_service_request.cc | 10 +--------- .../src/commands/hmi/as_publish_app_service_response.cc | 10 +--------- .../commands/hmi/on_as_app_service_data_notification.cc | 10 +--------- .../hmi/on_as_app_service_data_notification_from_hmi.cc | 10 +--------- .../commands/mobile/on_app_service_data_notification.cc | 10 +--------- .../mobile/on_app_service_data_notification_from_mobile.cc | 10 +--------- .../src/commands/mobile/publish_app_service_request.cc | 10 +--------- .../src/commands/mobile/publish_app_service_response.cc | 10 +--------- src/components/interfaces/HMI_API.xml | 14 +++++++------- src/components/interfaces/MOBILE_API.xml | 14 +++++++------- 18 files changed, 22 insertions(+), 94 deletions(-) diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/hmi/as_publish_app_service_request.h b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/hmi/as_publish_app_service_request.h index 0c7f222c1d..ec2c00a714 100644 --- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/hmi/as_publish_app_service_request.h +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/hmi/as_publish_app_service_request.h @@ -71,7 +71,6 @@ class ASPublishAppServiceRequest : public app_mngr::commands::RequestFromHMI { private: bool ValidateManifest(smart_objects::SmartObject& manifest); - AppServiceRpcPlugin* plugin_; DISALLOW_COPY_AND_ASSIGN(ASPublishAppServiceRequest); }; diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/hmi/as_publish_app_service_response.h b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/hmi/as_publish_app_service_response.h index c532225632..519d57c609 100644 --- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/hmi/as_publish_app_service_response.h +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/hmi/as_publish_app_service_response.h @@ -69,7 +69,6 @@ class ASPublishAppServiceResponse : public app_mngr::commands::ResponseToHMI { virtual void Run(); private: - AppServiceRpcPlugin* plugin_; DISALLOW_COPY_AND_ASSIGN(ASPublishAppServiceResponse); }; diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/hmi/on_as_app_service_data_notification.h b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/hmi/on_as_app_service_data_notification.h index 44d6d09fd3..30af13038a 100644 --- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/hmi/on_as_app_service_data_notification.h +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/hmi/on_as_app_service_data_notification.h @@ -70,7 +70,6 @@ class OnASAppServiceDataNotification virtual void Run(); private: - AppServiceRpcPlugin* plugin_; DISALLOW_COPY_AND_ASSIGN(OnASAppServiceDataNotification); }; diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/hmi/on_as_app_service_data_notification_from_hmi.h b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/hmi/on_as_app_service_data_notification_from_hmi.h index 7ca20d692a..5a23e35df0 100644 --- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/hmi/on_as_app_service_data_notification_from_hmi.h +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/hmi/on_as_app_service_data_notification_from_hmi.h @@ -70,7 +70,6 @@ class OnASAppServiceDataNotificationFromHMI virtual void Run(); private: - AppServiceRpcPlugin* plugin_; DISALLOW_COPY_AND_ASSIGN(OnASAppServiceDataNotificationFromHMI); }; diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/mobile/on_app_service_data_notification.h b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/mobile/on_app_service_data_notification.h index 4bc818f9be..719f5ebf5b 100644 --- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/mobile/on_app_service_data_notification.h +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/mobile/on_app_service_data_notification.h @@ -70,7 +70,6 @@ class OnAppServiceDataNotification virtual void Run(); private: - AppServiceRpcPlugin* plugin_; DISALLOW_COPY_AND_ASSIGN(OnAppServiceDataNotification); }; diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/mobile/on_app_service_data_notification_from_mobile.h b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/mobile/on_app_service_data_notification_from_mobile.h index f163e5848b..c41fabf7b1 100644 --- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/mobile/on_app_service_data_notification_from_mobile.h +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/mobile/on_app_service_data_notification_from_mobile.h @@ -70,7 +70,6 @@ class OnAppServiceDataNotificationFromMobile virtual void Run(); private: - AppServiceRpcPlugin* plugin_; DISALLOW_COPY_AND_ASSIGN(OnAppServiceDataNotificationFromMobile); }; diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/mobile/publish_app_service_request.h b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/mobile/publish_app_service_request.h index 459fa0457e..72e4f1c629 100644 --- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/mobile/publish_app_service_request.h +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/mobile/publish_app_service_request.h @@ -70,7 +70,6 @@ class PublishAppServiceRequest : public app_mngr::commands::CommandRequestImpl { private: bool ValidateManifest(smart_objects::SmartObject& manifest); - AppServiceRpcPlugin* plugin_; DISALLOW_COPY_AND_ASSIGN(PublishAppServiceRequest); }; diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/mobile/publish_app_service_response.h b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/mobile/publish_app_service_response.h index a11399c9e1..9275f9e468 100644 --- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/mobile/publish_app_service_response.h +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/mobile/publish_app_service_response.h @@ -69,7 +69,6 @@ class PublishAppServiceResponse virtual void Run(); private: - AppServiceRpcPlugin* plugin_; DISALLOW_COPY_AND_ASSIGN(PublishAppServiceResponse); }; diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_publish_app_service_request.cc b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_publish_app_service_request.cc index a3e6bfed2a..5e20ca20d1 100644 --- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_publish_app_service_request.cc +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_publish_app_service_request.cc @@ -47,15 +47,7 @@ ASPublishAppServiceRequest::ASPublishAppServiceRequest( application_manager, rpc_service, hmi_capabilities, - policy_handler) - , plugin_(NULL) { - auto plugin = application_manager.GetPluginManager().FindPluginToProcess( - hmi_apis::FunctionID::AppService_PublishAppService, - app_mngr::commands::Command::CommandSource::SOURCE_HMI); - if (plugin) { - plugin_ = dynamic_cast(&(*plugin)); - } -} + policy_handler) {} ASPublishAppServiceRequest::~ASPublishAppServiceRequest() {} diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_publish_app_service_response.cc b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_publish_app_service_response.cc index 1191b07abe..c143315b8c 100644 --- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_publish_app_service_response.cc +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_publish_app_service_response.cc @@ -47,15 +47,7 @@ ASPublishAppServiceResponse::ASPublishAppServiceResponse( application_manager, rpc_service, hmi_capabilities, - policy_handler) - , plugin_(NULL) { - auto plugin = application_manager.GetPluginManager().FindPluginToProcess( - hmi_apis::FunctionID::AppService_PublishAppService, - app_mngr::commands::Command::CommandSource::SOURCE_HMI); - if (plugin) { - plugin_ = dynamic_cast(&(*plugin)); - } -} + policy_handler) {} ASPublishAppServiceResponse::~ASPublishAppServiceResponse() {} diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/on_as_app_service_data_notification.cc b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/on_as_app_service_data_notification.cc index 29562d3086..899cc44f94 100644 --- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/on_as_app_service_data_notification.cc +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/on_as_app_service_data_notification.cc @@ -47,15 +47,7 @@ OnASAppServiceDataNotification::OnASAppServiceDataNotification( application_manager, rpc_service, hmi_capabilities, - policy_handler) - , plugin_(NULL) { - auto plugin = application_manager.GetPluginManager().FindPluginToProcess( - hmi_apis::FunctionID::AppService_OnAppServiceData, - app_mngr::commands::Command::CommandSource::SOURCE_HMI); - if (plugin) { - plugin_ = dynamic_cast(&(*plugin)); - } -} + policy_handler) {} OnASAppServiceDataNotification::~OnASAppServiceDataNotification() {} diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/on_as_app_service_data_notification_from_hmi.cc b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/on_as_app_service_data_notification_from_hmi.cc index ce68192d13..c89b52a683 100644 --- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/on_as_app_service_data_notification_from_hmi.cc +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/on_as_app_service_data_notification_from_hmi.cc @@ -47,15 +47,7 @@ OnASAppServiceDataNotificationFromHMI::OnASAppServiceDataNotificationFromHMI( application_manager, rpc_service, hmi_capabilities, - policy_handler) - , plugin_(NULL) { - auto plugin = application_manager.GetPluginManager().FindPluginToProcess( - hmi_apis::FunctionID::AppService_OnAppServiceData, - app_mngr::commands::Command::CommandSource::SOURCE_HMI); - if (plugin) { - plugin_ = dynamic_cast(&(*plugin)); - } -} + policy_handler) {} OnASAppServiceDataNotificationFromHMI:: ~OnASAppServiceDataNotificationFromHMI() {} diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/on_app_service_data_notification.cc b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/on_app_service_data_notification.cc index ef2ab7a4ab..6a6a50dc86 100644 --- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/on_app_service_data_notification.cc +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/on_app_service_data_notification.cc @@ -50,15 +50,7 @@ OnAppServiceDataNotification::OnAppServiceDataNotification( application_manager, rpc_service, hmi_capabilities, - policy_handler) - , plugin_(NULL) { - auto plugin = application_manager.GetPluginManager().FindPluginToProcess( - mobile_apis::FunctionID::OnAppServiceDataID, - app_mngr::commands::Command::CommandSource::SOURCE_MOBILE); - if (plugin) { - plugin_ = dynamic_cast(&(*plugin)); - } -} + policy_handler) {} OnAppServiceDataNotification::~OnAppServiceDataNotification() {} diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/on_app_service_data_notification_from_mobile.cc b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/on_app_service_data_notification_from_mobile.cc index 0b0ac0b68c..b46bc7934e 100644 --- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/on_app_service_data_notification_from_mobile.cc +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/on_app_service_data_notification_from_mobile.cc @@ -50,15 +50,7 @@ OnAppServiceDataNotificationFromMobile::OnAppServiceDataNotificationFromMobile( application_manager, rpc_service, hmi_capabilities, - policy_handler) - , plugin_(NULL) { - auto plugin = application_manager.GetPluginManager().FindPluginToProcess( - mobile_apis::FunctionID::OnAppServiceDataID, - app_mngr::commands::Command::CommandSource::SOURCE_MOBILE); - if (plugin) { - plugin_ = dynamic_cast(&(*plugin)); - } -} + policy_handler) {} OnAppServiceDataNotificationFromMobile:: ~OnAppServiceDataNotificationFromMobile() {} diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/publish_app_service_request.cc b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/publish_app_service_request.cc index ab82bf77dd..ed60bb14df 100644 --- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/publish_app_service_request.cc +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/publish_app_service_request.cc @@ -51,15 +51,7 @@ PublishAppServiceRequest::PublishAppServiceRequest( application_manager, rpc_service, hmi_capabilities, - policy_handler) - , plugin_(NULL) { - auto plugin = application_manager.GetPluginManager().FindPluginToProcess( - mobile_apis::FunctionID::PublishAppServiceID, - app_mngr::commands::Command::CommandSource::SOURCE_MOBILE); - if (plugin) { - plugin_ = dynamic_cast(&(*plugin)); - } -} + policy_handler) {} PublishAppServiceRequest::~PublishAppServiceRequest() {} diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/publish_app_service_response.cc b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/publish_app_service_response.cc index b302189ef7..b1136c79d0 100644 --- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/publish_app_service_response.cc +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/publish_app_service_response.cc @@ -50,15 +50,7 @@ PublishAppServiceResponse::PublishAppServiceResponse( application_manager, rpc_service, hmi_capabilities, - policy_handler) - , plugin_(NULL) { - auto plugin = application_manager.GetPluginManager().FindPluginToProcess( - mobile_apis::FunctionID::PublishAppServiceID, - app_mngr::commands::Command::CommandSource::SOURCE_MOBILE); - if (plugin) { - plugin_ = dynamic_cast(&(*plugin)); - } -} + policy_handler) {} PublishAppServiceResponse::~PublishAppServiceResponse() {} diff --git a/src/components/interfaces/HMI_API.xml b/src/components/interfaces/HMI_API.xml index 2875323550..a253e5fa0a 100644 --- a/src/components/interfaces/HMI_API.xml +++ b/src/components/interfaces/HMI_API.xml @@ -3439,7 +3439,7 @@ - + Music: The current progress of the playback queue in seconds Podcast: The current progress of the playback queue in seconds @@ -3472,7 +3472,7 @@ - + @@ -3480,7 +3480,7 @@ - + @@ -3489,7 +3489,7 @@ - + @@ -3544,7 +3544,7 @@ - + This data is related to what a weather service would provide @@ -3643,7 +3643,7 @@ - + Only included in OnSystemCapabilityUpdated. Update reason for service record. @@ -3652,7 +3652,7 @@ - + Capabilities of app services including what service types are supported and the current state of services. An array of currently available services. If this is an update to the capability the affected services will include an update reason in that item diff --git a/src/components/interfaces/MOBILE_API.xml b/src/components/interfaces/MOBILE_API.xml index 01f0485323..a631759bff 100644 --- a/src/components/interfaces/MOBILE_API.xml +++ b/src/components/interfaces/MOBILE_API.xml @@ -3771,7 +3771,7 @@ - + Music: The current progress of the playback queue in seconds Podcast: The current progress of the playback queue in seconds @@ -3889,26 +3889,26 @@ - This manifest contains all the information necessary for the service to be published, activated, and consumers able to interact with it + This manifest contains all the information necessary for the service to be published, activated, and consumers able to interact with it - Unique name of this service + Unique name of this service - The type of service that is to be offered by this app + The type of service that is to be offered by this app - The file name of the icon to be associated with this service. Most likely the same as the appIcon. + The file name of the icon to be associated with this service. Most likely the same as the appIcon. - If true, app service consumers beyond the IVI system will be able to access this service. If false, only the IVI system will be able consume the service. If not provided, it is assumed to be false. + If true, app service consumers beyond the IVI system will be able to access this service. If false, only the IVI system will be able consume the service. If not provided, it is assumed to be false. - The URI prefix for this service. If provided, all PerformAppServiceInteraction requests must start with it. + The URI prefix for this service. If provided, all PerformAppServiceInteraction requests must start with it. -- cgit v1.2.1 From 24e80d4604096911f2da09df4badf6db97a78a39 Mon Sep 17 00:00:00 2001 From: jacobkeeler Date: Sat, 23 Feb 2019 15:12:05 -0500 Subject: Add NAVIGATION AppServiceType --- src/components/interfaces/HMI_API.xml | 107 +++++++++++++++++++++++++++++++ src/components/interfaces/MOBILE_API.xml | 107 +++++++++++++++++++++++++++++++ 2 files changed, 214 insertions(+) diff --git a/src/components/interfaces/HMI_API.xml b/src/components/interfaces/HMI_API.xml index a253e5fa0a..1976f7c742 100644 --- a/src/components/interfaces/HMI_API.xml +++ b/src/components/interfaces/HMI_API.xml @@ -3368,6 +3368,7 @@ + @@ -3556,6 +3557,110 @@ + + + Informs the subscriber if this service can actually accept way points. + + + + + + Using this action plus a supplied direction can give the type of turn. + + + + + + + + + + + + A junction that represents a standard intersection with a single road crossing another. + + + A junction where the road splits off into two paths; a fork in the road. + + + A junction that has multiple intersections and paths. + + + A junction where traffic moves in a single direction around a central, non-traversable point to reach one of the connecting roads. + + + Similar to a roundabout, however the center of the roundabout is fully traversable. Also known as a mini-roundabout. + + + A junction where lefts diverge to the right, then curve to the left, converting a left turn to a crossing maneuver. + + + Multiple way intersection that allows traffic to flow based on priority; most commonly right of way and first in, first out. + + + A junction designated for traffic turn arounds. + + + + + + + + + + + + + + + + + The angle at which this instruction takes place. For example, 0 would mean straight, less than 45 is bearing right, greater than 135 is sharp right, between 45 and 135 is a regular right, and 180 is a U-Turn, etc. + + + + + + Used to infer which side of the road this instruction takes place. For a U-Turn (Action=Turn, direction=180) this will determine which direction the turn should take place. + + + + This is a string representation of this instruction, used to display instructions to the users. This is not intended to be read aloud to the users, see the param prompt in NavigationServiceData for that. + + + + An image representation of this instruction. + + + + + This data is related to what a navigation service would provide. + + + This is the timestamp of when the data was generated. This is to ensure any time or distance given in the data can accurately be adjusted if necessary. + + + + + + + + This array should be ordered with all remaining instructions. The start of this array should always contain the next instruction. + + + + + The distance to this instruction from current location. This should only be updated ever .1 unit of distance. For more accuracy the consumer can use the GPS location of itself and the next instruction. + + + Distance till next maneuver (starting from) from previous maneuver. + + + + This is a prompt message that should be conveyed to the user through either display or voice (TTS). This param will change often as it should represent the following: approaching instruction, post instruction, alerts that affect the current navigation session, etc. + + + This manifest contains all the information necessary for the service to be published, activated, and consumers able to interact with it @@ -3593,6 +3698,7 @@ + @@ -3623,6 +3729,7 @@ + diff --git a/src/components/interfaces/MOBILE_API.xml b/src/components/interfaces/MOBILE_API.xml index a631759bff..8a3766c5fa 100644 --- a/src/components/interfaces/MOBILE_API.xml +++ b/src/components/interfaces/MOBILE_API.xml @@ -3700,6 +3700,7 @@ + @@ -3888,6 +3889,110 @@ + + + Informs the subscriber if this service can actually accept way points. + + + + + + Using this action plus a supplied direction can give the type of turn. + + + + + + + + + + + + A junction that represents a standard intersection with a single road crossing another. + + + A junction where the road splits off into two paths; a fork in the road. + + + A junction that has multiple intersections and paths. + + + A junction where traffic moves in a single direction around a central, non-traversable point to reach one of the connecting roads. + + + Similar to a roundabout, however the center of the roundabout is fully traversable. Also known as a mini-roundabout. + + + A junction where lefts diverge to the right, then curve to the left, converting a left turn to a crossing maneuver. + + + Multiple way intersection that allows traffic to flow based on priority; most commonly right of way and first in, first out. + + + A junction designated for traffic turn arounds. + + + + + + + + + + + + + + + + + The angle at which this instruction takes place. For example, 0 would mean straight, less than 45 is bearing right, greater than 135 is sharp right, between 45 and 135 is a regular right, and 180 is a U-Turn, etc. + + + + + + Used to infer which side of the road this instruction takes place. For a U-Turn (Action=Turn, direction=180) this will determine which direction the turn should take place. + + + + This is a string representation of this instruction, used to display instructions to the users. This is not intended to be read aloud to the users, see the param prompt in NavigationServiceData for that. + + + + An image representation of this instruction. + + + + + This data is related to what a navigation service would provide. + + + This is the timestamp of when the data was generated. This is to ensure any time or distance given in the data can accurately be adjusted if necessary. + + + + + + + + This array should be ordered with all remaining instructions. The start of this array should always contain the next instruction. + + + + + The distance to this instruction from current location. This should only be updated ever .1 unit of distance. For more accuracy the consumer can use the GPS location of itself and the next instruction. + + + Distance till next maneuver (starting from) from previous maneuver. + + + + This is a prompt message that should be conveyed to the user through either display or voice (TTS). This param will change often as it should represent the following: approaching instruction, post instruction, alerts that affect the current navigation session, etc. + + + This manifest contains all the information necessary for the service to be published, activated, and consumers able to interact with it @@ -3925,6 +4030,7 @@ + @@ -3955,6 +4061,7 @@ + -- cgit v1.2.1 From aa8ad39cc936c7de63818d4307d8ac6a4dff5530 Mon Sep 17 00:00:00 2001 From: JackLivio Date: Sun, 24 Feb 2019 14:28:12 -0500 Subject: Get App Service Data With Subscribe (#2812) * Initial app service app extension * Add GetAppServiceData rpc templates. * Add request to mobile, and fix HMI GASD naming * Add Core->Mobile Requests and Responses * HMI GetAppService Request/Response to hmi and from hmi. * Add mobile on event handling * Fix GASD Response From Mobile * Fixes for GetAppServiceData subscribe, and OnAppServiceData Fixes allow for multiple consumers on a single app service type. Consumer/provider can be any combination of an ios app(s), android app(s), or an ivi HMI app(s). * Update AppServicetype to string and fix unit tests * Address review comments * Address comments * Address comments * Pass info from provider in GASD response --- .../application_manager/app_service_manager.h | 4 + .../application_manager/application_manager_impl.h | 8 + .../include/application_manager/commands/command.h | 7 +- .../command_notification_from_mobile_impl.h | 5 + .../commands/command_request_impl.h | 20 +++ .../commands/command_request_to_mobile.h | 73 +++++++++ .../commands/command_response_from_mobile.h | 73 +++++++++ .../commands/notification_from_hmi.h | 6 + .../commands/request_from_hmi.h | 38 ++++- .../application_manager/event_engine/event.h | 99 +++++++++++++ .../event_engine/event_dispatcher.h | 36 +++++ .../event_engine/event_dispatcher_impl.h | 51 +++++++ .../event_engine/event_observer.h | 35 ++++- .../include/application_manager/hmi_interfaces.h | 3 +- .../policies/external/policy_event_observer.h | 1 + .../policies/regular/policy_event_observer.h | 1 + .../include/application_manager/rpc_service_impl.h | 4 +- .../application_manager/smart_object_keys.h | 2 + .../application_manager/state_controller_impl.h | 1 + .../app_service_app_extension.h | 131 ++++++++++++++++ .../app_service_rpc_plugin.h | 18 +-- .../hmi/as_get_app_service_data_request_from_hmi.h | 93 ++++++++++++ .../hmi/as_get_app_service_data_request_to_hmi.h | 79 ++++++++++ .../as_get_app_service_data_response_from_hmi.h | 79 ++++++++++ .../hmi/as_get_app_service_data_response_to_hmi.h | 79 ++++++++++ .../commands/mobile/get_app_service_data_request.h | 88 +++++++++++ .../get_app_service_data_request_to_mobile.h | 79 ++++++++++ .../mobile/get_app_service_data_response.h | 78 ++++++++++ .../get_app_service_data_response_from_mobile.h | 81 ++++++++++ .../src/app_service_app_extension.cc | 122 +++++++++++++++ .../src/app_service_command_factory.cc | 9 +- .../src/app_service_hmi_command_factory.cc | 29 +++- .../src/app_service_mobile_command_factory.cc | 17 +++ .../src/app_service_rpc_plugin.cc | 25 +++- .../as_get_app_service_data_request_from_hmi.cc | 114 ++++++++++++++ .../hmi/as_get_app_service_data_request_to_hmi.cc | 62 ++++++++ .../as_get_app_service_data_response_from_hmi.cc | 67 +++++++++ .../hmi/as_get_app_service_data_response_to_hmi.cc | 62 ++++++++ .../hmi/on_as_app_service_data_notification.cc | 5 +- ...on_as_app_service_data_notification_from_hmi.cc | 4 +- .../mobile/get_app_service_data_request.cc | 130 ++++++++++++++++ .../get_app_service_data_request_to_mobile.cc | 62 ++++++++ .../mobile/get_app_service_data_response.cc | 62 ++++++++ .../get_app_service_data_response_from_mobile.cc | 74 +++++++++ .../mobile/on_app_service_data_notification.cc | 37 ++++- ...on_app_service_data_notification_from_mobile.cc | 3 + .../commands/mobile/publish_app_service_request.cc | 1 + .../rc_rpc_plugin/src/rc_command_factory.cc | 6 +- .../test/commands/button_press_request_test.cc | 9 +- .../get_interior_vehicle_data_request_test.cc | 61 ++++---- .../sdl_rpc_plugin/src/sdl_command_factory.cc | 6 +- .../test/commands/hmi/get_urls_test.cc | 12 +- .../test/commands/hmi/hmi_notifications_test.cc | 4 +- .../test/commands/hmi/rc_is_ready_request_test.cc | 2 +- .../test/commands/hmi/response_from_hmi_test.cc | 4 +- .../commands/hmi/sdl_activate_app_request_test.cc | 8 +- .../commands/hmi/simple_request_from_hmi_test.cc | 2 +- .../commands/hmi/simple_response_from_hmi_test.cc | 2 +- .../test/commands/hmi/ui_is_ready_request_test.cc | 6 +- .../test/commands/hmi/vr_is_ready_request_test.cc | 6 +- .../commands/mobile/add_command_request_test.cc | 140 ++++++++--------- .../test/commands/mobile/alert_request_test.cc | 64 ++++---- .../mobile/create_interaction_choice_set_test.cc | 2 +- .../mobile/delete_interaction_choice_set_test.cc | 2 +- .../test/commands/mobile/delete_sub_menu_test.cc | 22 +-- .../commands/mobile/dial_number_request_test.cc | 8 +- .../commands/mobile/get_way_points_request_test.cc | 2 +- .../mobile/perform_audio_pass_thru_test.cc | 38 ++--- .../test/commands/mobile/put_file_test.cc | 9 +- .../mobile/register_app_interface_request_test.cc | 89 ++++++----- .../mobile/reset_global_properties_test.cc | 79 +++++----- .../test/commands/mobile/send_haptic_data_test.cc | 2 +- .../commands/mobile/send_location_request_test.cc | 9 +- .../commands/mobile/set_display_layout_test.cc | 2 +- .../commands/mobile/set_global_properties_test.cc | 13 +- .../commands/mobile/set_media_clock_timer_test.cc | 4 +- .../test/commands/mobile/show_test.cc | 38 ++--- .../test/commands/mobile/slider_test.cc | 2 +- .../test/commands/mobile/speak_request_test.cc | 4 +- .../mobile/subscribe_button_request_test.cc | 4 +- .../test/commands/mobile/system_request_test.cc | 6 +- .../mobile/unsubscribe_button_request_test.cc | 16 +- .../mobile/unsubscribe_way_points_request_test.cc | 6 +- .../src/vehicle_info_command_factory.cc | 6 +- .../test/commands/hmi/vi_is_ready_request_test.cc | 2 +- .../mobile/diagnostic_message_request_test.cc | 8 +- .../test/commands/mobile/get_dtcs_request_test.cc | 7 +- .../mobile/get_vehicle_data_request_test.cc | 8 +- .../mobile/unsubscribe_vehicle_request_test.cc | 7 +- .../application_manager/src/app_service_manager.cc | 35 +++++ .../src/application_manager_impl.cc | 11 ++ .../command_notification_from_mobile_impl.cc | 24 +++ .../src/commands/command_request_impl.cc | 95 +++++++++++- .../src/commands/command_request_to_mobile.cc | 72 +++++++++ .../src/commands/command_response_from_mobile.cc | 71 +++++++++ .../src/commands/notification_from_hmi.cc | 20 +++ .../src/commands/request_from_hmi.cc | 165 ++++++++++++++++++++- .../application_manager/src/event_engine/event.cc | 12 ++ .../src/event_engine/event_dispatcher_impl.cc | 72 +++++++++ .../src/event_engine/event_observer.cc | 23 ++- .../application_manager/src/hmi_interfaces_impl.cc | 6 + .../src/hmi_language_handler.cc | 4 +- .../src/policies/policy_event_observer.cc | 2 + .../application_manager/src/rpc_handler_impl.cc | 1 + .../application_manager/src/rpc_service_impl.cc | 24 ++- .../application_manager/src/smart_object_keys.cc | 1 + .../src/state_controller_impl.cc | 1 + .../src/system_time/system_time_handler_impl.cc | 2 +- .../test/command_holder_test.cc | 14 +- .../test/commands/command_request_impl_test.cc | 6 +- .../test/hmi_capabilities_test.cc | 2 +- .../commands/command_request_test.h | 2 +- .../application_manager/mock_event_dispatcher.h | 20 +++ .../test/message_helper/message_helper_test.cc | 6 +- .../test/state_controller/state_controller_test.cc | 4 +- .../application_manager/application_manager.h | 1 + .../include/application_manager/rpc_service.h | 4 +- .../application_manager/mock_application_manager.h | 1 + .../test/application_manager/mock_rpc_service.h | 5 +- src/components/interfaces/HMI_API.xml | 15 ++ src/components/interfaces/MOBILE_API.xml | 40 +++++ .../include/policy/policy_table/enums.h | 5 + .../policy_external/src/policy_table/enums.cc | 5 + .../include/policy/policy_table/enums.h | 5 + .../policy_regular/src/policy_table/enums.cc | 9 ++ 125 files changed, 3254 insertions(+), 415 deletions(-) create mode 100644 src/components/application_manager/include/application_manager/commands/command_request_to_mobile.h create mode 100644 src/components/application_manager/include/application_manager/commands/command_response_from_mobile.h create mode 100644 src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/app_service_app_extension.h create mode 100644 src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/hmi/as_get_app_service_data_request_from_hmi.h create mode 100644 src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/hmi/as_get_app_service_data_request_to_hmi.h create mode 100644 src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/hmi/as_get_app_service_data_response_from_hmi.h create mode 100644 src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/hmi/as_get_app_service_data_response_to_hmi.h create mode 100644 src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/mobile/get_app_service_data_request.h create mode 100644 src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/mobile/get_app_service_data_request_to_mobile.h create mode 100644 src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/mobile/get_app_service_data_response.h create mode 100644 src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/mobile/get_app_service_data_response_from_mobile.h create mode 100644 src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/app_service_app_extension.cc create mode 100644 src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_get_app_service_data_request_from_hmi.cc create mode 100644 src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_get_app_service_data_request_to_hmi.cc create mode 100644 src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_get_app_service_data_response_from_hmi.cc create mode 100644 src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_get_app_service_data_response_to_hmi.cc create mode 100644 src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/get_app_service_data_request.cc create mode 100644 src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/get_app_service_data_request_to_mobile.cc create mode 100644 src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/get_app_service_data_response.cc create mode 100644 src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/get_app_service_data_response_from_mobile.cc create mode 100644 src/components/application_manager/src/commands/command_request_to_mobile.cc create mode 100644 src/components/application_manager/src/commands/command_response_from_mobile.cc diff --git a/src/components/application_manager/include/application_manager/app_service_manager.h b/src/components/application_manager/include/application_manager/app_service_manager.h index 253ed2a439..b910118942 100644 --- a/src/components/application_manager/include/application_manager/app_service_manager.h +++ b/src/components/application_manager/include/application_manager/app_service_manager.h @@ -36,6 +36,7 @@ #include "application_manager/application.h" #include "interfaces/MOBILE_API.h" #include "smart_objects/smart_object.h" +#include "application_manager/application.h" namespace resumption { class LastState; @@ -130,6 +131,9 @@ class AppServiceManager { */ std::vector GetAllServices(); + void GetProvider(const std::string& service_type, + ApplicationSharedPtr& app, + bool& hmi_service); std::pair ActiveServiceByType( std::string service_type); diff --git a/src/components/application_manager/include/application_manager/application_manager_impl.h b/src/components/application_manager/include/application_manager/application_manager_impl.h index 16bfb9e7de..07f11eddaa 100644 --- a/src/components/application_manager/include/application_manager/application_manager_impl.h +++ b/src/components/application_manager/include/application_manager/application_manager_impl.h @@ -387,6 +387,13 @@ class ApplicationManagerImpl hmi_apis::Common_CloudConnectionStatus::eType GetCloudAppConnectionStatus( ApplicationConstSharedPtr app) const; + /* + * @brief Returns unique correlation ID for to mobile request + * + * @return Unique correlation ID + */ + uint32_t GetNextMobileCorrelationID() OVERRIDE; + /* * @brief Returns unique correlation ID for HMI request * @@ -1429,6 +1436,7 @@ class ApplicationManagerImpl hmi_apis::HMI_API* hmi_so_factory_; mobile_apis::MOBILE_API* mobile_so_factory_; + static uint32_t mobile_corelation_id_; static uint32_t corelation_id_; static const uint32_t max_corelation_id_; diff --git a/src/components/application_manager/include/application_manager/commands/command.h b/src/components/application_manager/include/application_manager/commands/command.h index f8ea7db24d..d832995b8d 100644 --- a/src/components/application_manager/include/application_manager/commands/command.h +++ b/src/components/application_manager/include/application_manager/commands/command.h @@ -112,7 +112,12 @@ class Command { */ virtual void SetAllowedToTerminate(const bool allowed) = 0; - enum CommandSource { SOURCE_SDL, SOURCE_MOBILE, SOURCE_HMI }; + enum CommandSource { + SOURCE_SDL, + SOURCE_MOBILE, + SOURCE_HMI, + SOURCE_SDL_TO_HMI + }; }; typedef smart_objects::SmartObjectSPtr MessageSharedPtr; diff --git a/src/components/application_manager/include/application_manager/commands/command_notification_from_mobile_impl.h b/src/components/application_manager/include/application_manager/commands/command_notification_from_mobile_impl.h index 8741dae540..e8485a3abc 100644 --- a/src/components/application_manager/include/application_manager/commands/command_notification_from_mobile_impl.h +++ b/src/components/application_manager/include/application_manager/commands/command_notification_from_mobile_impl.h @@ -53,6 +53,11 @@ class CommandNotificationFromMobileImpl : public CommandImpl { virtual bool CleanUp(); virtual void Run(); void SendNotification(); + void SendNotificationToMobile(); + void SendNotificationToHMI( + const hmi_apis::FunctionID::eType& hmi_function_id); + void SendNotificationToConsumers( + const hmi_apis::FunctionID::eType& hmi_function_id); private: DISALLOW_COPY_AND_ASSIGN(CommandNotificationFromMobileImpl); diff --git a/src/components/application_manager/include/application_manager/commands/command_request_impl.h b/src/components/application_manager/include/application_manager/commands/command_request_impl.h index 27aa93d1d8..a5ecd7274b 100644 --- a/src/components/application_manager/include/application_manager/commands/command_request_impl.h +++ b/src/components/application_manager/include/application_manager/commands/command_request_impl.h @@ -149,6 +149,8 @@ class CommandRequestImpl : public CommandImpl, */ virtual void on_event(const event_engine::Event& event); + virtual void on_event(const event_engine::MobileEvent& event); + /* * @brief Creates Mobile response * @@ -170,6 +172,16 @@ class CommandRequestImpl : public CommandImpl, */ bool CheckSyntax(const std::string& str, bool allow_empty_line = false); + void SendProviderRequest( + const mobile_apis::FunctionID::eType& mobile_function_id, + const hmi_apis::FunctionID::eType& hmi_function_id, + const smart_objects::SmartObject* msg, + bool use_events = false); + + void SendMobileRequest(const mobile_apis::FunctionID::eType& function_id, + smart_objects::SmartObjectSPtr msg, + bool use_events = false); + /* * @brief Sends HMI request * @@ -234,6 +246,14 @@ class CommandRequestImpl : public CommandImpl, */ bool HasDisallowedParams() const; + /** + * @brief Checks result code from Mobile for single RPC + * @param result_code contains result code from Mobile response + * @return true if result code complies successful result codes, + * false otherwise. + */ + bool IsMobileResultSuccess(mobile_apis::Result::eType result_code) const; + /** * @brief Checks result code from HMI for single RPC * and returns parameter for sending to mobile app. diff --git a/src/components/application_manager/include/application_manager/commands/command_request_to_mobile.h b/src/components/application_manager/include/application_manager/commands/command_request_to_mobile.h new file mode 100644 index 0000000000..a1e63561bf --- /dev/null +++ b/src/components/application_manager/include/application_manager/commands/command_request_to_mobile.h @@ -0,0 +1,73 @@ +/* + Copyright (c) 2018, 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. + */ + +#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_COMMANDS_COMMAND_REQUEST_TO_MOBILE_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_COMMANDS_COMMAND_REQUEST_TO_MOBILE_H_ + +#include "application_manager/commands/command_impl.h" +#include "application_manager/application_manager.h" +#include "interfaces/MOBILE_API.h" +#include "smart_objects/smart_object.h" + +namespace application_manager { + +namespace commands { + +class CommandRequestToMobile : public CommandImpl { + public: + CommandRequestToMobile(const MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handler); + ~CommandRequestToMobile(); + bool Init() OVERRIDE; + bool CleanUp() OVERRIDE; + void Run() OVERRIDE; + void SendRequest(); + + /* + * @brief Retrieves application ID + */ + inline uint32_t application_id() const { + return (*message_)[strings::msg_params][strings::app_id].asUInt(); + } + + private: + DISALLOW_COPY_AND_ASSIGN(CommandRequestToMobile); +}; + +} // namespace commands + +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_COMMANDS_COMMAND_REQUEST_TO_MOBILE_H_ diff --git a/src/components/application_manager/include/application_manager/commands/command_response_from_mobile.h b/src/components/application_manager/include/application_manager/commands/command_response_from_mobile.h new file mode 100644 index 0000000000..65983d82f8 --- /dev/null +++ b/src/components/application_manager/include/application_manager/commands/command_response_from_mobile.h @@ -0,0 +1,73 @@ +/* + Copyright (c) 2018, 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. + */ + +#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_COMMANDS_COMMAND_RESPONSE_TO_MOBILE_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_COMMANDS_COMMAND_RESPONSE_TO_MOBILE_H_ + +#include "application_manager/commands/command_impl.h" +#include "application_manager/application_manager.h" +#include "interfaces/MOBILE_API.h" +#include "smart_objects/smart_object.h" + +namespace application_manager { + +namespace commands { + +class CommandResponseFromMobile : public CommandImpl { + public: + CommandResponseFromMobile(const MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handler); + ~CommandResponseFromMobile(); + bool Init() OVERRIDE; + bool CleanUp() OVERRIDE; + void Run() OVERRIDE; + void SendResponse(); + + /* + * @brief Retrieves application ID + */ + inline uint32_t application_id() const { + return (*message_)[strings::msg_params][strings::app_id].asUInt(); + } + + private: + DISALLOW_COPY_AND_ASSIGN(CommandResponseFromMobile); +}; + +} // namespace commands + +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_COMMANDS_COMMAND_RESPONSE_TO_MOBILE_H_ diff --git a/src/components/application_manager/include/application_manager/commands/notification_from_hmi.h b/src/components/application_manager/include/application_manager/commands/notification_from_hmi.h index 8bbbd0e3de..25cfd7b207 100644 --- a/src/components/application_manager/include/application_manager/commands/notification_from_hmi.h +++ b/src/components/application_manager/include/application_manager/commands/notification_from_hmi.h @@ -53,8 +53,14 @@ class NotificationFromHMI : public CommandImpl { virtual bool CleanUp(); virtual void Run(); void SendNotificationToMobile(const MessageSharedPtr& message); + void SendNotificationToMobile( + const MessageSharedPtr& message, + const mobile_apis::FunctionID::eType& mobile_function_id); + void SendNotificationToHMI(MessageSharedPtr& message); void CreateHMIRequest(const hmi_apis::FunctionID::eType& function_id, const smart_objects::SmartObject& msg_params) const; + void SendNotificationToConsumers( + const mobile_apis::FunctionID::eType& mobile_function_id); private: DISALLOW_COPY_AND_ASSIGN(NotificationFromHMI); diff --git a/src/components/application_manager/include/application_manager/commands/request_from_hmi.h b/src/components/application_manager/include/application_manager/commands/request_from_hmi.h index d980e98576..0a5f5d7eee 100644 --- a/src/components/application_manager/include/application_manager/commands/request_from_hmi.h +++ b/src/components/application_manager/include/application_manager/commands/request_from_hmi.h @@ -55,17 +55,20 @@ class RequestFromHMI : public CommandImpl, public event_engine::EventObserver { virtual bool CleanUp(); virtual void Run(); virtual void on_event(const event_engine::Event& event); + void on_event(const event_engine::MobileEvent& event) OVERRIDE; /** * @brief SendResponse allows to send response to hmi * @param correlation_id the correlation id for the rfesponse. * @param function_id the function id for which response will be sent * @param result_code the result code. */ - void SendResponse(const bool success, - const uint32_t correlation_id, - const hmi_apis::FunctionID::eType function_id, - const hmi_apis::Common_Result::eType result_code, - const smart_objects::SmartObject* response_params = NULL); + void SendResponse( + const bool success, + const uint32_t correlation_id, + const hmi_apis::FunctionID::eType function_id, + const hmi_apis::Common_Result::eType result_code, + const smart_objects::SmartObject* response_params = NULL, + commands::Command::CommandSource source = commands::Command::SOURCE_HMI); /** * @brief SendResponse allows to send error response to hmi @@ -79,6 +82,25 @@ class RequestFromHMI : public CommandImpl, public event_engine::EventObserver { const hmi_apis::Common_Result::eType result_code, const std::string error_message); + void SendProviderRequest( + const mobile_apis::FunctionID::eType& mobile_function_id, + const hmi_apis::FunctionID::eType& hmi_function_id, + const smart_objects::SmartObject* msg, + bool use_events = false); + + void SendMobileRequest(const mobile_apis::FunctionID::eType& function_id, + const ApplicationSharedPtr app, + const smart_objects::SmartObject* msg_params, + bool use_events); + + void SendHMIRequest(const hmi_apis::FunctionID::eType& function_id, + const smart_objects::SmartObject* msg_params, + bool use_events); + + bool ProcessHMIInterfacesAvailability( + const uint32_t hmi_correlation_id, + const hmi_apis::FunctionID::eType& function_id); + private: /** * @brief Fills common parameters for SO @@ -91,6 +113,12 @@ class RequestFromHMI : public CommandImpl, public event_engine::EventObserver { const uint32_t correlation_id, const hmi_apis::FunctionID::eType function_id); + protected: + bool IsMobileResultSuccess(mobile_apis::Result::eType result_code) const; + + bool IsHMIResultSuccess(hmi_apis::Common_Result::eType result_code, + HmiInterfaces::InterfaceID interface) const; + private: DISALLOW_COPY_AND_ASSIGN(RequestFromHMI); }; diff --git a/src/components/application_manager/include/application_manager/event_engine/event.h b/src/components/application_manager/include/application_manager/event_engine/event.h index 68ee508a9b..cfd6e95693 100644 --- a/src/components/application_manager/include/application_manager/event_engine/event.h +++ b/src/components/application_manager/include/application_manager/event_engine/event.h @@ -34,6 +34,7 @@ #define SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_EVENT_ENGINE_EVENT_H_ #include +#include #include "smart_objects/smart_object.h" #include "application_manager/smart_object_keys.h" @@ -141,6 +142,104 @@ int32_t Event::smart_object_type() const { .asInt(); } +class MobileEvent { + public: + // Typedef for possible Event ID's from mobile_apis functionID enum + typedef mobile_apis::FunctionID::eType MobileEventID; + + /* + * @brief Constructor with parameters + * + * @param id Event ID. Please see mobile_apis::FunctionID for possible ID's + */ + explicit MobileEvent(const MobileEventID& id); + + /* + * @brief Destructor + */ + virtual ~MobileEvent(); + + /* + * @brief Sends synchronously event to all subscribers. + * + */ + void raise(EventDispatcher& event_dispatcher); + + /* + * @brief Provides event ID + */ + inline const MobileEventID& id() const; + + /* + * @brief Sets event smart object + * + * @param so The smart_object received in Mobile response + */ + void set_smart_object(const smart_objects::SmartObject& so); + + /* + * @brief Retrieves event smart object + * + * @return The smart_object received in Mobile response + */ + inline const smart_objects::SmartObject& smart_object() const; + + /* + * @brief Retrieves smart object request ID + */ + inline int32_t smart_object_function_id() const; + + /* + * @brief Retrieves smart object correlation ID + */ + inline int32_t smart_object_correlation_id() const; + + /* + * @brief Retrieves smart_object response type + */ + inline int32_t smart_object_type() const; + + protected: + private: + MobileEventID id_; + smart_objects::SmartObject response_so_; + + /* + * @brief Default constructor + * + * Unimplemented to avoid misusing + */ + MobileEvent(); + + DISALLOW_COPY_AND_ASSIGN(MobileEvent); +}; + +const MobileEvent::MobileEventID& MobileEvent::id() const { + return id_; +} + +const smart_objects::SmartObject& MobileEvent::smart_object() const { + return response_so_; +} + +int32_t MobileEvent::smart_object_function_id() const { + return response_so_.getElement(strings::params) + .getElement(strings::function_id) + .asInt(); +} + +int32_t MobileEvent::smart_object_correlation_id() const { + return response_so_.getElement(strings::params) + .getElement(strings::correlation_id) + .asInt(); +} + +int32_t MobileEvent::smart_object_type() const { + return response_so_.getElement(strings::params) + .getElement(strings::message_type) + .asInt(); +} + } // namespace event_engine } // namespace application_manager diff --git a/src/components/application_manager/include/application_manager/event_engine/event_dispatcher.h b/src/components/application_manager/include/application_manager/event_engine/event_dispatcher.h index 813dda0295..0656372f47 100644 --- a/src/components/application_manager/include/application_manager/event_engine/event_dispatcher.h +++ b/src/components/application_manager/include/application_manager/event_engine/event_dispatcher.h @@ -77,6 +77,42 @@ class EventDispatcher { */ virtual void remove_observer(EventObserver& observer) = 0; + // Mobile Events + + /* + * @brief Delivers the event to all subscribers + * + * @param event Received event + */ + virtual void raise_mobile_event(const MobileEvent& event) = 0; + + /* + * @brief Subscribe the observer to event + * + * @param event_id The event ID to subscribe for + * @param hmi_correlation_id The event HMI correlation ID + * @param observer The observer to subscribe for event + */ + virtual void add_mobile_observer(const MobileEvent::MobileEventID& event_id, + int32_t mobile_correlation_id, + EventObserver& observer) = 0; + + /* + * @brief Unsubscribes the observer from specific event + * + * @param event_id The event ID to unsubscribe from + * @param observer The observer to be unsubscribed + */ + virtual void remove_mobile_observer( + const MobileEvent::MobileEventID& event_id, EventObserver& observer) = 0; + + /* + * @brief Unsubscribes the observer from all events + * + * @param observer The observer to be unsubscribed + */ + virtual void remove_mobile_observer(EventObserver& observer) = 0; + /* * @brief Destructor */ diff --git a/src/components/application_manager/include/application_manager/event_engine/event_dispatcher_impl.h b/src/components/application_manager/include/application_manager/event_engine/event_dispatcher_impl.h index ed923369ac..75e77e603c 100644 --- a/src/components/application_manager/include/application_manager/event_engine/event_dispatcher_impl.h +++ b/src/components/application_manager/include/application_manager/event_engine/event_dispatcher_impl.h @@ -52,6 +52,8 @@ class EventDispatcherImpl : public EventDispatcher { typedef std::vector ObserverVector; typedef std::map ObserversMap; typedef std::map EventObserverMap; + typedef std::map + MobileEventObserverMap; /* * @brief Destructor */ @@ -66,6 +68,9 @@ class EventDispatcherImpl : public EventDispatcher { EventObserverMap get_observers() const { return observers_event_; } + MobileEventObserverMap get_mobile_observers() const { + return mobile_observers_event_; + } ObserverVector get_observers_list() const { return observers_; } @@ -105,6 +110,41 @@ class EventDispatcherImpl : public EventDispatcher { */ void remove_observer(EventObserver& observer) OVERRIDE; + // Mobile requests + /* + * @brief Delivers the event to all subscribers + * + * @param event Received event + */ + void raise_mobile_event(const MobileEvent& event) OVERRIDE; + + /* + * @brief Subscribe the observer to event + * + * @param event_id The event ID to subscribe for + * @param hmi_correlation_id The event HMI correlation ID + * @param observer The observer to subscribe for event + */ + void add_mobile_observer(const MobileEvent::MobileEventID& event_id, + int32_t mobile_correlation_id, + EventObserver& observer) OVERRIDE; + + /* + * @brief Unsubscribes the observer from specific event + * + * @param event_id The event ID to unsubscribe from + * @param observer The observer to be unsubscribed + */ + void remove_mobile_observer(const MobileEvent::MobileEventID& event_id, + EventObserver& observer) OVERRIDE; + + /* + * @brief Unsubscribes the observer from all events + * + * @param observer The observer to be unsubscribed + */ + void remove_mobile_observer(EventObserver& observer) OVERRIDE; + private: /* * @brief removes observer @@ -113,14 +153,25 @@ class EventDispatcherImpl : public EventDispatcher { */ void remove_observer_from_vector(EventObserver& observer); + /* + * @brief removes observer + * when occurs unsubscribe from event + * @param observer to be removed + */ + void remove_mobile_observer_from_vector(EventObserver& observer); + DISALLOW_COPY_AND_ASSIGN(EventDispatcherImpl); private: // Members section sync_primitives::Lock state_lock_; + sync_primitives::Lock mobile_state_lock_; sync_primitives::RecursiveLock observer_lock_; + sync_primitives::RecursiveLock mobile_observer_lock_; EventObserverMap observers_event_; + MobileEventObserverMap mobile_observers_event_; ObserverVector observers_; + ObserverVector mobile_observers_; }; } // namespace event_engine diff --git a/src/components/application_manager/include/application_manager/event_engine/event_observer.h b/src/components/application_manager/include/application_manager/event_engine/event_observer.h index 593f1df657..7a7fe7c2ec 100644 --- a/src/components/application_manager/include/application_manager/event_engine/event_observer.h +++ b/src/components/application_manager/include/application_manager/event_engine/event_observer.h @@ -72,6 +72,8 @@ class EventObserver { */ virtual void on_event(const Event& event) = 0; + virtual void on_event(const MobileEvent& event); + protected: /* * @brief Subscribe to an event @@ -94,7 +96,38 @@ class EventObserver { * @brief Unsubscribes the observer from all events * */ - void unsubscribe_from_all_events(); + DEPRECATED void unsubscribe_from_all_events(); + + /* + * @brief Unsubscribes the observer from all events + * + */ + void unsubscribe_from_all_hmi_events(); + + // Mobile Events + + /* + * @brief Subscribe to an event + * + * @param event_id The event ID to subscribe for + * @param mobile_correlation_id The event mobile correlation ID. + * If param is omitted, it means subscription for mobile notification + */ + void subscribe_on_event(const MobileEvent::MobileEventID& event_id, + int32_t mobile_correlation_id = 0); + + /* + * @brief Unsubscribes the observer from specific event + * + * @param event_id The event ID to unsubscribe from + */ + void unsubscribe_from_event(const MobileEvent::MobileEventID& event_id); + + /* + * @brief Unsubscribes the observer from all events + * + */ + void unsubscribe_from_all_mobile_events(); private: ObserverID id_; diff --git a/src/components/application_manager/include/application_manager/hmi_interfaces.h b/src/components/application_manager/include/application_manager/hmi_interfaces.h index 59ec32694a..5f172b415d 100644 --- a/src/components/application_manager/include/application_manager/hmi_interfaces.h +++ b/src/components/application_manager/include/application_manager/hmi_interfaces.h @@ -60,7 +60,8 @@ class HmiInterfaces { HMI_INTERFACE_Navigation, HMI_INTERFACE_VehicleInfo, HMI_INTERFACE_SDL, - HMI_INTERFACE_RC + HMI_INTERFACE_RC, + HMI_INTERFACE_AppService }; /** diff --git a/src/components/application_manager/include/application_manager/policies/external/policy_event_observer.h b/src/components/application_manager/include/application_manager/policies/external/policy_event_observer.h index 8c904bf513..3168b80b5a 100644 --- a/src/components/application_manager/include/application_manager/policies/external/policy_event_observer.h +++ b/src/components/application_manager/include/application_manager/policies/external/policy_event_observer.h @@ -48,6 +48,7 @@ class PolicyEventObserver application_manager::event_engine::EventDispatcher& event_dispatcher); void set_policy_handler(policy::PolicyHandlerInterface* const policy_handler); void on_event(const application_manager::event_engine::Event& event); + void on_event(const application_manager::event_engine::MobileEvent& event); void subscribe_on_event( const application_manager::event_engine::Event::EventID& event_id, int32_t hmi_correlation_id = 0); diff --git a/src/components/application_manager/include/application_manager/policies/regular/policy_event_observer.h b/src/components/application_manager/include/application_manager/policies/regular/policy_event_observer.h index f4924111b3..4a104812a4 100644 --- a/src/components/application_manager/include/application_manager/policies/regular/policy_event_observer.h +++ b/src/components/application_manager/include/application_manager/policies/regular/policy_event_observer.h @@ -48,6 +48,7 @@ class PolicyEventObserver application_manager::event_engine::EventDispatcher& event_dispatcher); void set_policy_handler(policy::PolicyHandlerInterface* const policy_handler); void on_event(const application_manager::event_engine::Event& event); + void on_event(const application_manager::event_engine::MobileEvent& event); void subscribe_on_event( const application_manager::event_engine::Event::EventID& event_id, int32_t hmi_correlation_id = 0); diff --git a/src/components/application_manager/include/application_manager/rpc_service_impl.h b/src/components/application_manager/include/application_manager/rpc_service_impl.h index 1eaeb46255..98767672ca 100644 --- a/src/components/application_manager/include/application_manager/rpc_service_impl.h +++ b/src/components/application_manager/include/application_manager/rpc_service_impl.h @@ -108,7 +108,9 @@ class RPCServiceImpl : public RPCService, bool ManageMobileCommand(const commands::MessageSharedPtr message, commands::Command::CommandSource source) OVERRIDE; - bool ManageHMICommand(const commands::MessageSharedPtr message) OVERRIDE; + bool ManageHMICommand(const commands::MessageSharedPtr message, + commands::Command::CommandSource source = + commands::Command::SOURCE_HMI) OVERRIDE; // CALLED ON messages_to_hmi_ thread! void Handle(const impl::MessageToHmi message) OVERRIDE; 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 615b8ab767..d6c5f165da 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 @@ -318,6 +318,8 @@ extern const char* service_id; extern const char* service_manifest; extern const char* service_published; extern const char* service_active; +extern const char* service_data; +extern const char* subscribe; extern const char* app_services; extern const char* update_reason; extern const char* updated_app_service_record; diff --git a/src/components/application_manager/include/application_manager/state_controller_impl.h b/src/components/application_manager/include/application_manager/state_controller_impl.h index 99113d6d00..8270e9b807 100644 --- a/src/components/application_manager/include/application_manager/state_controller_impl.h +++ b/src/components/application_manager/include/application_manager/state_controller_impl.h @@ -144,6 +144,7 @@ class StateControllerImpl : public event_engine::EventObserver, // EventObserver interface void on_event(const event_engine::Event& event); + void on_event(const event_engine::MobileEvent& event); /** * @brief Sets default application state and apply currently active HMI states diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/app_service_app_extension.h b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/app_service_app_extension.h new file mode 100644 index 0000000000..9be93f5c9e --- /dev/null +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/app_service_app_extension.h @@ -0,0 +1,131 @@ +/* + Copyright (c) 2018, Livio + 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. + */ + +#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_APP_SERVICE_RPC_PLUGIN_INCLUDE_APP_SERVICE_RPC_PLUGIN_APP_SERVICE_APP_EXTENSION_H +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_APP_SERVICE_RPC_PLUGIN_INCLUDE_APP_SERVICE_RPC_PLUGIN_APP_SERVICE_APP_EXTENSION_H + +#include +#include "application_manager/app_extension.h" + +#include +#include + +namespace app_service_rpc_plugin { +class AppServiceRpcPlugin; + +namespace app_mngr = application_manager; + +typedef int AppExtensionUID; +typedef mobile_apis::VehicleDataType::eType VehicleDataType; +/** + * @brief Defines set of app service types + */ +typedef std::set AppServiceSubscriptions; + +class AppServiceAppExtension : public app_mngr::AppExtension { + public: + /** + * @brief AppServiceAppExtension constructor + * @param plugin app service plugin + * @param app application that contains this plugin + */ + AppServiceAppExtension(AppServiceRpcPlugin& plugin, + app_mngr::Application& app); + virtual ~AppServiceAppExtension(); + + /** + * @brief subscribeToAppService add vehicle_data to list of subscriptions of + * application extension + * @param vehicle_data data to subscribe + * @return true in case if subscription is successful + */ + bool SubscribeToAppService(const std::string app_service_type); + + /** + * @brief unsubscribeFromAppService remove vehicle_data from list of + * subscriptions of application extension + * @param vehicle_data data to unsubscribe + * @return true in case if unsubscription is successful + */ + bool UnsubscribeFromAppService(const std::string app_service_type); + /** + * @brief unsubscribeFromAppService unsubscribe from all app service types + */ + void UnsubscribeFromAppService(); + + /** + * @brief isSubscribedToAppService checks if extension is subscribed to + * app service type + * @param app_service_type data type to check subscription + * @return true if extension is subscribed this app_service_type, otherwise + * return false + */ + bool IsSubscribedToAppService(const std::string app_service_type) const; + + /** + * @brief Subscriptions get list of subscriptions for application extension + * @return list of subscriptions for application extension + */ + AppServiceSubscriptions Subscriptions(); + + /** + * @brief SaveResumptionData saves vehicle info data + * @param resumption_data plase to store resumption data + */ + void SaveResumptionData(ns_smart_device_link::ns_smart_objects::SmartObject& + resumption_data) OVERRIDE; + + /** + * @brief ProcessResumption load resumtion data back to plugin during + * resumption + * @param resumption_data resumption data + */ + void ProcessResumption( + const smart_objects::SmartObject& resumption_data) OVERRIDE; + + /** + * @brief ExtractVIExtension utility function to extract application extension + * from application + * @param app : applicaiton that contains vehicle info app_extension + * @return application extension extracted from application + */ + static AppServiceAppExtension& ExtractASExtension( + application_manager::Application& app); + + private: + AppServiceSubscriptions subscribed_data_; + AppServiceRpcPlugin& plugin_; + app_mngr::Application& app_; +}; +} + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_APP_SERVICE_PLUGIN_INCLUDE_APP_SERVICE_PLUGIN_APP_SERVICE_APP_EXTENSION_H diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/app_service_rpc_plugin.h b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/app_service_rpc_plugin.h index 1113911a22..c9cb98cdfb 100644 --- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/app_service_rpc_plugin.h +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/app_service_rpc_plugin.h @@ -30,8 +30,8 @@ POSSIBILITY OF SUCH DAMAGE. */ -#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_app_service_PLUGIN_INCLUDE_app_service_PLUGIN_app_service_PLUGIN_H -#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_app_service_PLUGIN_INCLUDE_app_service_PLUGIN_app_service_PLUGIN_H +#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_APP_SERVICE_PLUGIN_INCLUDE_APP_SERVICE_PLUGIN_APP_SERVICE_RPC_PLUGIN_H +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_APP_SERVICE_PLUGIN_INCLUDE_APP_SERVICE_PLUGIN_APP_SERVICE_RPC_PLUGIN_H #include "application_manager/command_factory.h" @@ -60,17 +60,9 @@ class AppServiceRpcPlugin : public plugins::RPCPlugin { void OnApplicationEvent(plugins::ApplicationEvent event, app_mngr::ApplicationSharedPtr application) OVERRIDE; - /** - * @brief ProcessResumptionSubscription send Subscribe vehicle data requests - * to HMI - * @param app application for subscription - * @param ext application extension - */ - // TODO - // void ProcessResumptionSubscription(app_mngr::Application& app, - // AppServiceAppExtension& ext); - private: + void DeleteSubscriptions(app_mngr::ApplicationSharedPtr app); + std::unique_ptr command_factory_; app_mngr::ApplicationManager* application_manager_; }; @@ -78,4 +70,4 @@ class AppServiceRpcPlugin : public plugins::RPCPlugin { extern "C" application_manager::plugin_manager::RPCPlugin* Create(); -#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_app_service_PLUGIN_INCLUDE_app_service_PLUGIN_app_service_PLUGIN_H +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_APP_SERVICE_PLUGIN_INCLUDE_APP_SERVICE_PLUGIN_APP_SERVICE_PLUGIN_H diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/hmi/as_get_app_service_data_request_from_hmi.h b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/hmi/as_get_app_service_data_request_from_hmi.h new file mode 100644 index 0000000000..847b921502 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/hmi/as_get_app_service_data_request_from_hmi.h @@ -0,0 +1,93 @@ +/* + Copyright (c) 2019, Ford Motor Company, Livio + 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 the copyright holders nor the names of their + 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. + */ + +#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_APP_SERVICE_RPC_PLUGIN_INCLUDE_APP_SERVICE_RPC_PLUGIN_COMMANDS_HMI_AS_GET_APP_SERVICE_DATA_REQUEST_FROM_HMI_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_APP_SERVICE_RPC_PLUGIN_INCLUDE_APP_SERVICE_RPC_PLUGIN_COMMANDS_HMI_AS_GET_APP_SERVICE_DATA_REQUEST_FROM_HMI_H_ + +#include "application_manager/commands/request_from_hmi.h" + +namespace app_service_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief ASGetAppServiceDataRequestFromHMI command class + **/ +class ASGetAppServiceDataRequestFromHMI + : public app_mngr::commands::RequestFromHMI { + public: + /** + * @brief ASGetAppServiceDataRequestFromHMI class constructor + * + * @param message Incoming SmartObject message + **/ + ASGetAppServiceDataRequestFromHMI( + const app_mngr::commands::MessageSharedPtr& message, + app_mngr::ApplicationManager& application_manager, + app_mngr::rpc_service::RPCService& rpc_service, + app_mngr::HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle); + + /** + * @brief ASGetAppServiceDataRequestFromHMI class destructor + **/ + virtual ~ASGetAppServiceDataRequestFromHMI(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + /** + * @brief on_event allows to handle events + * + * @param event event type that current request subscribed on. + */ + void on_event(const app_mngr::event_engine::Event& event) OVERRIDE; + + /** + * @brief on_event allows to handle events + * + * @param event event type that current request subscribed on. + */ + void on_event(const app_mngr::event_engine::MobileEvent& event) OVERRIDE; + + private: + DISALLOW_COPY_AND_ASSIGN(ASGetAppServiceDataRequestFromHMI); +}; + +} // namespace commands + +} // namespace app_service_rpc_plugin + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_APP_SERVICE_RPC_PLUGIN_INCLUDE_APP_SERVICE_RPC_PLUGIN_COMMANDS_HMI_AS_GET_APP_SERVICE_DATA_REQUEST_FROM_HMI_H_ diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/hmi/as_get_app_service_data_request_to_hmi.h b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/hmi/as_get_app_service_data_request_to_hmi.h new file mode 100644 index 0000000000..c4b3026176 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/hmi/as_get_app_service_data_request_to_hmi.h @@ -0,0 +1,79 @@ +/* + Copyright (c) 2019, Ford Motor Company, Livio + 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 the copyright holders nor the names of their + 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. + */ + +#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_APP_SERVICE_RPC_PLUGIN_INCLUDE_APP_SERVICE_RPC_PLUGIN_COMMANDS_HMI_AS_GET_APP_SERVICE_DATA_REQUEST_TO_HMI_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_APP_SERVICE_RPC_PLUGIN_INCLUDE_APP_SERVICE_RPC_PLUGIN_COMMANDS_HMI_AS_GET_APP_SERVICE_DATA_REQUEST_TO_HMI_H_ + +#include "application_manager/commands/request_to_hmi.h" + +namespace app_service_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief ASGetAppServiceDataRequestToHMI command class + **/ +class ASGetAppServiceDataRequestToHMI + : public app_mngr::commands::RequestToHMI { + public: + /** + * @brief ASGetAppServiceDataRequestToHMI class constructor + * + * @param message Incoming SmartObject message + **/ + ASGetAppServiceDataRequestToHMI( + const app_mngr::commands::MessageSharedPtr& message, + app_mngr::ApplicationManager& application_manager, + app_mngr::rpc_service::RPCService& rpc_service, + app_mngr::HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle); + + /** + * @brief ASGetAppServiceDataRequestToHMI class destructor + **/ + virtual ~ASGetAppServiceDataRequestToHMI(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(ASGetAppServiceDataRequestToHMI); +}; + +} // namespace commands + +} // namespace app_service_rpc_plugin + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_APP_SERVICE_RPC_PLUGIN_INCLUDE_APP_SERVICE_RPC_PLUGIN_COMMANDS_HMI_AS_GET_APP_SERVICE_DATA_TO_HMI_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/hmi/as_get_app_service_data_response_from_hmi.h b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/hmi/as_get_app_service_data_response_from_hmi.h new file mode 100644 index 0000000000..b46626a56b --- /dev/null +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/hmi/as_get_app_service_data_response_from_hmi.h @@ -0,0 +1,79 @@ +/* + Copyright (c) 2019, Ford Motor Company, Livio + 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 the copyright holders nor the names of their + 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. + */ + +#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_APP_SERVICE_RPC_PLUGIN_INCLUDE_APP_SERVICE_RPC_PLUGIN_COMMANDS_HMI_AS_GET_APP_SERVICE_DATA_RESPONSE_FROM_HMI_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_APP_SERVICE_RPC_PLUGIN_INCLUDE_APP_SERVICE_RPC_PLUGIN_COMMANDS_HMI_AS_GET_APP_SERVICE_DATA_RESPONSE_FROM_HMI_H_ + +#include "application_manager/commands/response_from_hmi.h" + +namespace app_service_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief ASGetAppServiceDataResponseFromHMI command class + **/ +class ASGetAppServiceDataResponseFromHMI + : public app_mngr::commands::ResponseFromHMI { + public: + /** + * @brief ASGetAppServiceDataResponseFromHMI class constructor + * + * @param message Incoming SmartObject message + **/ + ASGetAppServiceDataResponseFromHMI( + const app_mngr::commands::MessageSharedPtr& message, + app_mngr::ApplicationManager& application_manager, + app_mngr::rpc_service::RPCService& rpc_service, + app_mngr::HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle); + + /** + * @brief ASGetAppServiceDataResponseFromHMI class destructor + **/ + virtual ~ASGetAppServiceDataResponseFromHMI(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(ASGetAppServiceDataResponseFromHMI); +}; + +} // namespace commands + +} // namespace app_service_rpc_plugin + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_APP_SERVICE_RPC_PLUGIN_INCLUDE_APP_SERVICE_RPC_PLUGIN_COMMANDS_HMI_AS_GET_APP_SERVICE_DATA_RESPONSE_FROM_HMI_H_ diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/hmi/as_get_app_service_data_response_to_hmi.h b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/hmi/as_get_app_service_data_response_to_hmi.h new file mode 100644 index 0000000000..e48a9d1429 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/hmi/as_get_app_service_data_response_to_hmi.h @@ -0,0 +1,79 @@ +/* + Copyright (c) 2019, Ford Motor Company, Livio + 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 the copyright holders nor the names of their + 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. + */ + +#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_APP_SERVICE_RPC_PLUGIN_INCLUDE_APP_SERVICE_RPC_PLUGIN_COMMANDS_HMI_AS_GET_APP_SERVICE_DATA_RESPONSE_TO_HMI_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_APP_SERVICE_RPC_PLUGIN_INCLUDE_APP_SERVICE_RPC_PLUGIN_COMMANDS_HMI_AS_GET_APP_SERVICE_DATA_RESPONSE_TO_HMI_H_ + +#include "application_manager/commands/response_to_hmi.h" + +namespace app_service_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief ASGetAppServiceDataResponseToHMI command class + **/ +class ASGetAppServiceDataResponseToHMI + : public app_mngr::commands::ResponseToHMI { + public: + /** + * @brief ASGetAppServiceDataResponseToHMI class constructor + * + * @param message Incoming SmartObject message + **/ + ASGetAppServiceDataResponseToHMI( + const app_mngr::commands::MessageSharedPtr& message, + app_mngr::ApplicationManager& application_manager, + app_mngr::rpc_service::RPCService& rpc_service, + app_mngr::HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle); + + /** + * @brief ASGetAppServiceDataResponseToHMI class destructor + **/ + virtual ~ASGetAppServiceDataResponseToHMI(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(ASGetAppServiceDataResponseToHMI); +}; + +} // namespace commands + +} // namespace app_service_rpc_plugin + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_APP_SERVICE_RPC_PLUGIN_INCLUDE_APP_SERVICE_RPC_PLUGIN_COMMANDS_HMI_AS_GET_APP_SERVICE_DATA_RESPONSE_TO_HMI_H_ diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/mobile/get_app_service_data_request.h b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/mobile/get_app_service_data_request.h new file mode 100644 index 0000000000..8295e855fa --- /dev/null +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/mobile/get_app_service_data_request.h @@ -0,0 +1,88 @@ +/* + Copyright (c) 2019, Ford Motor Company, Livio + 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 the copyright holders nor the names of their + 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. + */ + +#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_APP_SERVICE_RPC_PLUGIN_INCLUDE_APP_SERVICE_RPC_PLUGIN_COMMANDS_MOBILE_GET_APP_SERVICE_DATA_REQUEST_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_APP_SERVICE_RPC_PLUGIN_INCLUDE_APP_SERVICE_RPC_PLUGIN_COMMANDS_MOBILE_GET_APP_SERVICE_DATA_REQUEST_H_ + +#include "app_service_rpc_plugin/app_service_rpc_plugin.h" +#include "application_manager/commands/command_request_impl.h" + +namespace app_service_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief GetAppServiceDataRequest command class + **/ +class GetAppServiceDataRequest : public app_mngr::commands::CommandRequestImpl { + public: + /** + * @brief GetAppServiceDataRequest class constructor + * + * @param message Incoming SmartObject message + **/ + GetAppServiceDataRequest(const app_mngr::commands::MessageSharedPtr& message, + app_mngr::ApplicationManager& application_manager, + app_mngr::rpc_service::RPCService& rpc_service, + app_mngr::HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle); + + /** + * @brief GetAppServiceDataRequest class destructor + **/ + virtual ~GetAppServiceDataRequest(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + /** + * @brief Interface method that is called whenever new event received + * + * @param event The received event + */ + virtual void on_event(const app_mngr::event_engine::Event& event); + + virtual void on_event(const app_mngr::event_engine::MobileEvent& event); + + private: + AppServiceRpcPlugin* plugin_; + DISALLOW_COPY_AND_ASSIGN(GetAppServiceDataRequest); +}; + +} // namespace commands + +} // namespace app_service_rpc_plugin + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_APP_SERVICE_RPC_PLUGIN_INCLUDE_APP_SERVICE_RPC_PLUGIN_COMMANDS_MOBILE_GET_APP_SERVICE_DATA_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/mobile/get_app_service_data_request_to_mobile.h b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/mobile/get_app_service_data_request_to_mobile.h new file mode 100644 index 0000000000..279cf15055 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/mobile/get_app_service_data_request_to_mobile.h @@ -0,0 +1,79 @@ +/* + Copyright (c) 2019, Ford Motor Company, Livio + 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 the copyright holders nor the names of their + 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. + */ + +#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_APP_SERVICE_RPC_PLUGIN_INCLUDE_APP_SERVICE_RPC_PLUGIN_COMMANDS_MOBILE_GET_APP_SERVICE_DATA_REQUEST_TO_MOBILE_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_APP_SERVICE_RPC_PLUGIN_INCLUDE_APP_SERVICE_RPC_PLUGIN_COMMANDS_MOBILE_GET_APP_SERVICE_DATA_REQUEST_TO_MOBILE_H_ + +#include "application_manager/commands/command_request_to_mobile.h" + +namespace app_service_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief GetAppServiceDataRequestToMobile command class + **/ +class GetAppServiceDataRequestToMobile + : public app_mngr::commands::CommandRequestToMobile { + public: + /** + * @brief GetAppServiceDataRequestToMobile class constructor + * + * @param message Incoming SmartObject message + **/ + GetAppServiceDataRequestToMobile( + const app_mngr::commands::MessageSharedPtr& message, + app_mngr::ApplicationManager& application_manager, + app_mngr::rpc_service::RPCService& rpc_service, + app_mngr::HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle); + + /** + * @brief GetAppServiceDataRequestToMobile class destructor + **/ + virtual ~GetAppServiceDataRequestToMobile(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(GetAppServiceDataRequestToMobile); +}; + +} // namespace commands + +} // namespace app_service_rpc_plugin + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_APP_SERVICE_RPC_PLUGIN_INCLUDE_APP_SERVICE_RPC_PLUGIN_COMMANDS_MOBILE_GET_APP_SERVICE_DATA_REQUEST_TO_MOBILE_H_ diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/mobile/get_app_service_data_response.h b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/mobile/get_app_service_data_response.h new file mode 100644 index 0000000000..f5758e1c39 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/mobile/get_app_service_data_response.h @@ -0,0 +1,78 @@ +/* + Copyright (c) 2019, Ford Motor Company, Livio + 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 the copyright holders nor the names of their + 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. + */ + +#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_APP_SERVICE_RPC_PLUGIN_INCLUDE_APP_SERVICE_RPC_PLUGIN_COMMANDS_MOBILE_GET_APP_SERVICE_DATA_RESPONSE_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_APP_SERVICE_RPC_PLUGIN_INCLUDE_APP_SERVICE_RPC_PLUGIN_COMMANDS_MOBILE_GET_APP_SERVICE_DATA_RESPONSE_H_ + +#include "application_manager/commands/command_response_impl.h" + +namespace app_service_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief GetAppServiceDataResponse command class + **/ +class GetAppServiceDataResponse + : public app_mngr::commands::CommandResponseImpl { + public: + /** + * @brief GetAppServiceDataResponse class constructor + * + * @param message Incoming SmartObject message + **/ + GetAppServiceDataResponse(const app_mngr::commands::MessageSharedPtr& message, + app_mngr::ApplicationManager& application_manager, + app_mngr::rpc_service::RPCService& rpc_service, + app_mngr::HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle); + + /** + * @brief GetAppServiceDataResponse class destructor + **/ + virtual ~GetAppServiceDataResponse(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(GetAppServiceDataResponse); +}; + +} // namespace commands + +} // namespace app_service_rpc_plugin + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_APP_SERVICE_RPC_PLUGIN_INCLUDE_APP_SERVICE_RPC_PLUGIN_COMMANDS_MOBILE_GET_APP_SERVICE_DATA_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/mobile/get_app_service_data_response_from_mobile.h b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/mobile/get_app_service_data_response_from_mobile.h new file mode 100644 index 0000000000..1411b23e5a --- /dev/null +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/mobile/get_app_service_data_response_from_mobile.h @@ -0,0 +1,81 @@ +/* + Copyright (c) 2019, Ford Motor Company, Livio + 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 the copyright holders nor the names of their + 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. + */ + +#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_APP_SERVICE_RPC_PLUGIN_INCLUDE_APP_SERVICE_RPC_PLUGIN_COMMANDS_MOBILE_GET_APP_SERVICE_DATA_RESPONSE_FROM_MOBILE_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_APP_SERVICE_RPC_PLUGIN_INCLUDE_APP_SERVICE_RPC_PLUGIN_COMMANDS_MOBILE_GET_APP_SERVICE_DATA_RESPONSE_FROM_MOBILE_H_ + +#include "app_service_rpc_plugin/app_service_rpc_plugin.h" +#include "application_manager/commands/command_response_from_mobile.h" + +namespace app_service_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief GetAppServiceDataResponseFromMobile command class + **/ +class GetAppServiceDataResponseFromMobile + : public app_mngr::commands::CommandResponseFromMobile { + public: + /** + * @brief GetAppServiceDataResponseFromMobile class constructor + * + * @param message Incoming SmartObject message + **/ + GetAppServiceDataResponseFromMobile( + const app_mngr::commands::MessageSharedPtr& message, + app_mngr::ApplicationManager& application_manager, + app_mngr::rpc_service::RPCService& rpc_service, + app_mngr::HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle); + + /** + * @brief GetAppServiceDataResponseFromMobile class destructor + **/ + virtual ~GetAppServiceDataResponseFromMobile(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + AppServiceRpcPlugin* plugin_; + DISALLOW_COPY_AND_ASSIGN(GetAppServiceDataResponseFromMobile); +}; + +} // namespace commands + +} // namespace app_service_rpc_plugin + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_APP_SERVICE_RPC_PLUGIN_INCLUDE_APP_SERVICE_RPC_PLUGIN_COMMANDS_MOBILE_GET_APP_SERVICE_DATA_RESPONSE_FROM_MOBILE_H_ diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/app_service_app_extension.cc b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/app_service_app_extension.cc new file mode 100644 index 0000000000..63812056f1 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/app_service_app_extension.cc @@ -0,0 +1,122 @@ +/* + Copyright (c) 2018, 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 "app_service_rpc_plugin/app_service_app_extension.h" +#include "app_service_rpc_plugin/app_service_rpc_plugin.h" + +CREATE_LOGGERPTR_GLOBAL(logger_, "AppServiceRpcPlugin") + +namespace app_service_rpc_plugin { + +const AppExtensionUID AppServiceAppExtensionUID = 455; + +AppServiceAppExtension::AppServiceAppExtension( + AppServiceRpcPlugin& plugin, application_manager::Application& app) + : app_mngr::AppExtension(AppServiceAppExtensionUID) + , plugin_(plugin) + , app_(app) { + LOG4CXX_AUTO_TRACE(logger_); +} + +AppServiceAppExtension::~AppServiceAppExtension() { + LOG4CXX_AUTO_TRACE(logger_); +} + +bool AppServiceAppExtension::SubscribeToAppService( + const std::string app_service_type) { + LOG4CXX_DEBUG(logger_, "Subscribe to app service: " << app_service_type); + return subscribed_data_.insert(app_service_type).second; +} + +bool AppServiceAppExtension::UnsubscribeFromAppService( + const std::string app_service_type) { + LOG4CXX_DEBUG(logger_, app_service_type); + auto it = subscribed_data_.find(app_service_type); + if (it != subscribed_data_.end()) { + subscribed_data_.erase(it); + return true; + } + return false; +} + +void AppServiceAppExtension::UnsubscribeFromAppService() { + LOG4CXX_AUTO_TRACE(logger_); + subscribed_data_.clear(); +} + +bool AppServiceAppExtension::IsSubscribedToAppService( + const std::string app_service_type) const { + LOG4CXX_DEBUG(logger_, + "isSubscribedToAppService for type: " << app_service_type); + return subscribed_data_.find(app_service_type) != subscribed_data_.end(); +} + +AppServiceSubscriptions AppServiceAppExtension::Subscriptions() { + return subscribed_data_; +} + +void AppServiceAppExtension::SaveResumptionData( + smart_objects::SmartObject& resumption_data) { + const char* app_service_info = "appService"; + resumption_data[app_service_info] = + smart_objects::SmartObject(smart_objects::SmartType_Array); + int i = 0; + for (const auto& subscription : subscribed_data_) { + resumption_data[app_service_info][i] = subscription; + i++; + } +} + +void AppServiceAppExtension::ProcessResumption( + const smart_objects::SmartObject& resumption_data) { + const char* app_service_info = "appService"; + if (resumption_data.keyExists(app_service_info)) { + const smart_objects::SmartObject& subscriptions_app_services = + resumption_data[app_service_info]; + for (size_t i = 0; i < subscriptions_app_services.length(); ++i) { + std::string service_type = resumption_data[i].asString(); + SubscribeToAppService(service_type); + } + } +} + +AppServiceAppExtension& AppServiceAppExtension::ExtractASExtension( + application_manager::Application& app) { + auto ext_ptr = app.QueryInterface(AppServiceAppExtensionUID); + DCHECK(ext_ptr); + DCHECK(dynamic_cast(ext_ptr.get())); + auto vi_app_extension = + std::static_pointer_cast(ext_ptr); + DCHECK(vi_app_extension); + return *vi_app_extension; +} +} diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/app_service_command_factory.cc b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/app_service_command_factory.cc index 0405bb3e7c..f0a0698bb7 100644 --- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/app_service_command_factory.cc +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/app_service_command_factory.cc @@ -55,7 +55,8 @@ AppServiceCommandFactory::~AppServiceCommandFactory() { app_mngr::CommandSharedPtr AppServiceCommandFactory::CreateCommand( const app_mngr::commands::MessageSharedPtr& message, app_mngr::commands::Command::CommandSource source) { - if (app_mngr::commands::Command::SOURCE_HMI == source) { + if (app_mngr::commands::Command::SOURCE_HMI == source || + app_mngr::commands::Command::SOURCE_SDL_TO_HMI == source) { return hmi_command_factory_->CreateCommand(message, source); } else { return mobile_command_factory_->CreateCommand(message, source); @@ -65,7 +66,11 @@ app_mngr::CommandSharedPtr AppServiceCommandFactory::CreateCommand( bool AppServiceCommandFactory::IsAbleToProcess( const int32_t function_id, const commands::Command::CommandSource source) const { - return commands::Command::SOURCE_HMI == source + LOG4CXX_DEBUG(logger_, + "AppServiceCommandFactory::IsAbleToProcess" << function_id + << " " << source); + return (commands::Command::SOURCE_HMI == source || + commands::Command::SOURCE_SDL_TO_HMI == source) ? hmi_command_factory_->IsAbleToProcess(function_id, source) : mobile_command_factory_->IsAbleToProcess(function_id, source); } diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/app_service_hmi_command_factory.cc b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/app_service_hmi_command_factory.cc index 7afc04c8e9..b2b5ec7974 100644 --- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/app_service_hmi_command_factory.cc +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/app_service_hmi_command_factory.cc @@ -42,6 +42,10 @@ #include "app_service_rpc_plugin/commands/hmi/as_publish_app_service_response.h" #include "app_service_rpc_plugin/commands/hmi/on_as_app_service_data_notification.h" #include "app_service_rpc_plugin/commands/hmi/on_as_app_service_data_notification_from_hmi.h" +#include "app_service_rpc_plugin/commands/hmi/as_get_app_service_data_request_from_hmi.h" +#include "app_service_rpc_plugin/commands/hmi/as_get_app_service_data_response_from_hmi.h" +#include "app_service_rpc_plugin/commands/hmi/as_get_app_service_data_request_to_hmi.h" +#include "app_service_rpc_plugin/commands/hmi/as_get_app_service_data_response_to_hmi.h" CREATE_LOGGERPTR_GLOBAL(logger_, "AppServiceRpcPlugin") @@ -78,6 +82,8 @@ app_mngr::CommandSharedPtr AppServiceHmiCommandFactory::CreateCommand( message_type_str = "response"; } else if (hmi_apis::messageType::error_response == message_type) { message_type_str = "error response"; + } else if (hmi_apis::messageType::notification == message_type) { + message_type_str = "notification"; } UNUSED(message_type_str); @@ -91,6 +97,8 @@ app_mngr::CommandSharedPtr AppServiceHmiCommandFactory::CreateCommand( bool AppServiceHmiCommandFactory::IsAbleToProcess( const int32_t function_id, const app_mngr::commands::Command::CommandSource source) const { + LOG4CXX_DEBUG(logger_, + "HMI App Service Plugin IsAbleToProcess: " << function_id); UNUSED(source); return buildCommandCreator(function_id, hmi_apis::messageType::INVALID_ENUM, @@ -104,6 +112,9 @@ app_mngr::CommandCreator& AppServiceHmiCommandFactory::buildCommandCreator( auto factory = app_mngr::CommandCreatorFactory( application_manager_, rpc_service_, hmi_capabilities_, policy_handler_); + LOG4CXX_DEBUG(logger_, + "buildCommandCreator: " << function_id << " " << source); + switch (function_id) { case hmi_apis::FunctionID::AppService_PublishAppService: return hmi_apis::messageType::request == message_type @@ -115,6 +126,22 @@ app_mngr::CommandCreator& AppServiceHmiCommandFactory::buildCommandCreator( commands::OnASAppServiceDataNotificationFromHMI>() : factory .GetCreator(); + case hmi_apis::FunctionID::AppService_GetAppServiceData: + if (app_mngr::commands::Command::CommandSource::SOURCE_HMI == source) { + return hmi_apis::messageType::request == message_type + ? factory.GetCreator< + commands::ASGetAppServiceDataRequestFromHMI>() + : factory.GetCreator< + commands::ASGetAppServiceDataResponseFromHMI>(); + } else if (app_mngr::commands::Command::CommandSource:: + SOURCE_SDL_TO_HMI == source) { + return hmi_apis::messageType::request == message_type + ? factory.GetCreator< + commands::ASGetAppServiceDataRequestToHMI>() + : factory.GetCreator< + commands::ASGetAppServiceDataResponseToHMI>(); + } + case hmi_apis::FunctionID::AppService_GetAppServiceRecords: return hmi_apis::messageType::request == message_type ? factory.GetCreator() @@ -126,7 +153,7 @@ app_mngr::CommandCreator& AppServiceHmiCommandFactory::buildCommandCreator( : factory .GetCreator(); default: - LOG4CXX_WARN(logger_, "Unsupported function_id: " << function_id); + LOG4CXX_WARN(logger_, "Unsupported HMI function_id: " << function_id); return factory.GetCreator(); } } diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/app_service_mobile_command_factory.cc b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/app_service_mobile_command_factory.cc index e0e667e975..3e00408a91 100644 --- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/app_service_mobile_command_factory.cc +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/app_service_mobile_command_factory.cc @@ -39,6 +39,10 @@ #include "app_service_rpc_plugin/commands/mobile/on_app_service_data_notification_from_mobile.h" #include "app_service_rpc_plugin/commands/mobile/publish_app_service_request.h" #include "app_service_rpc_plugin/commands/mobile/publish_app_service_response.h" +#include "app_service_rpc_plugin/commands/mobile/get_app_service_data_request.h" +#include "app_service_rpc_plugin/commands/mobile/get_app_service_data_response.h" +#include "app_service_rpc_plugin/commands/mobile/get_app_service_data_request_to_mobile.h" +#include "app_service_rpc_plugin/commands/mobile/get_app_service_data_response_from_mobile.h" CREATE_LOGGERPTR_GLOBAL(logger_, "AppServiceRpcPlugin") @@ -111,6 +115,19 @@ app_mngr::CommandCreator& AppServiceMobileCommandFactory::buildCommandCreator( ? factory.GetCreator< commands::OnAppServiceDataNotificationFromMobile>() : factory.GetCreator(); + case mobile_apis::FunctionID::GetAppServiceDataID: + if (app_mngr::commands::Command::CommandSource::SOURCE_MOBILE == source) { + return mobile_apis::messageType::request == message_type + ? factory.GetCreator() + : factory.GetCreator< + commands::GetAppServiceDataResponseFromMobile>(); + } else if (app_mngr::commands::Command::CommandSource::SOURCE_SDL == + source) { + return mobile_apis::messageType::request == message_type + ? factory.GetCreator< + commands::GetAppServiceDataRequestToMobile>() + : factory.GetCreator(); + } default: LOG4CXX_WARN(logger_, "Unsupported function_id: " << function_id); return factory.GetCreator(); diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/app_service_rpc_plugin.cc b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/app_service_rpc_plugin.cc index 739d8bb0e2..971e3cc5e0 100644 --- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/app_service_rpc_plugin.cc +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/app_service_rpc_plugin.cc @@ -32,7 +32,7 @@ #include "application_manager/message_helper.h" #include "application_manager/smart_object_keys.h" -//#include "app_service_rpc_plugin/app_service_app_extension.h" +#include "app_service_rpc_plugin/app_service_app_extension.h" #include "app_service_rpc_plugin/app_service_command_factory.h" #include "app_service_rpc_plugin/app_service_rpc_plugin.h" @@ -71,13 +71,24 @@ void AppServiceRpcPlugin::OnPolicyEvent(plugins::PolicyEvent event) {} void AppServiceRpcPlugin::OnApplicationEvent( plugins::ApplicationEvent event, - app_mngr::ApplicationSharedPtr application) {} + app_mngr::ApplicationSharedPtr application) { + if (plugins::ApplicationEvent::kApplicationRegistered == event) { + application->AddExtension( + std::make_shared(*this, *application)); + } else if (plugins::ApplicationEvent::kDeleteApplicationData == event) { + DeleteSubscriptions(application); + } +} + +void AppServiceRpcPlugin::DeleteSubscriptions( + application_manager::ApplicationSharedPtr app) { + auto& ext = AppServiceAppExtension::ExtractASExtension(*app); + auto subscriptions = ext.Subscriptions(); + for (auto& service_type : subscriptions) { + ext.UnsubscribeFromAppService(service_type); + } +} -/*void AppServiceRpcPlugin::ProcessResumptionSubscription( - application_manager::Application& app, AppServiceAppExtension& ext) { - LOG4CXX_AUTO_TRACE(logger_); - // TODO -}*/ } // namespace app_service_rpc_plugin extern "C" application_manager::plugin_manager::RPCPlugin* Create() { diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_get_app_service_data_request_from_hmi.cc b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_get_app_service_data_request_from_hmi.cc new file mode 100644 index 0000000000..5cdbbfc012 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_get_app_service_data_request_from_hmi.cc @@ -0,0 +1,114 @@ +/* + Copyright (c) 2019, Ford Motor Company, Livio + 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 the copyright holders nor the names of their + 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 "app_service_rpc_plugin/commands/hmi/as_get_app_service_data_request_from_hmi.h" +#include "application_manager/application_impl.h" +#include "application_manager/rpc_service.h" +#include "interfaces/MOBILE_API.h" +#include "smart_objects/enum_schema_item.h" + +#include "application_manager/message_helper.h" + +namespace app_service_rpc_plugin { +using namespace application_manager; +namespace commands { + +ASGetAppServiceDataRequestFromHMI::ASGetAppServiceDataRequestFromHMI( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + app_mngr::rpc_service::RPCService& rpc_service, + app_mngr::HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handler) + : RequestFromHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handler) {} + +ASGetAppServiceDataRequestFromHMI::~ASGetAppServiceDataRequestFromHMI() {} + +void ASGetAppServiceDataRequestFromHMI::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + std::string service_type = + (*message_)[strings::msg_params][strings::service_type].asString(); + + LOG4CXX_DEBUG(logger_, "Get Service Type: " << service_type); + + SendProviderRequest(mobile_apis::FunctionID::GetAppServiceDataID, + hmi_apis::FunctionID::AppService_GetAppServiceData, + &(*message_), + true); +} + +void ASGetAppServiceDataRequestFromHMI::on_event( + const event_engine::Event& event) { + const smart_objects::SmartObject& event_message = event.smart_object(); + + auto msg_params = event_message[strings::msg_params]; + + hmi_apis::Common_Result::eType result = + static_cast( + event_message[strings::params][hmi_response::code].asInt()); + bool success = + IsHMIResultSuccess(result, HmiInterfaces::HMI_INTERFACE_AppService); + SendResponse(success, + correlation_id(), + hmi_apis::FunctionID::AppService_GetAppServiceData, + result, + &msg_params, + application_manager::commands::Command::SOURCE_SDL_TO_HMI); +} + +void ASGetAppServiceDataRequestFromHMI::on_event( + const event_engine::MobileEvent& event) { + const smart_objects::SmartObject& event_message = event.smart_object(); + + auto msg_params = event_message[strings::msg_params]; + + mobile_apis::Result::eType mobile_result = + static_cast( + msg_params[strings::result_code].asInt()); + hmi_apis::Common_Result::eType result = + MessageHelper::MobileToHMIResult(mobile_result); + bool success = IsMobileResultSuccess(mobile_result); + + SendResponse(success, + correlation_id(), + hmi_apis::FunctionID::AppService_GetAppServiceData, + result, + &msg_params, + application_manager::commands::Command::SOURCE_SDL_TO_HMI); +} + +} // namespace commands +} // namespace app_service_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_get_app_service_data_request_to_hmi.cc b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_get_app_service_data_request_to_hmi.cc new file mode 100644 index 0000000000..822cd0a29b --- /dev/null +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_get_app_service_data_request_to_hmi.cc @@ -0,0 +1,62 @@ +/* + Copyright (c) 2019, Ford Motor Company, Livio + 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 the copyright holders nor the names of their + 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 "app_service_rpc_plugin/commands/hmi/as_get_app_service_data_request_to_hmi.h" +#include "application_manager/application_impl.h" +#include "application_manager/rpc_service.h" +#include "interfaces/MOBILE_API.h" + +namespace app_service_rpc_plugin { +using namespace application_manager; +namespace commands { + +ASGetAppServiceDataRequestToHMI::ASGetAppServiceDataRequestToHMI( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + app_mngr::rpc_service::RPCService& rpc_service, + app_mngr::HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handler) + : RequestToHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handler) {} + +ASGetAppServiceDataRequestToHMI::~ASGetAppServiceDataRequestToHMI() {} + +void ASGetAppServiceDataRequestToHMI::Run() { + LOG4CXX_AUTO_TRACE(logger_); + SendRequest(); +} + +} // namespace commands +} // namespace app_service_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_get_app_service_data_response_from_hmi.cc b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_get_app_service_data_response_from_hmi.cc new file mode 100644 index 0000000000..9ce6ffdb50 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_get_app_service_data_response_from_hmi.cc @@ -0,0 +1,67 @@ +/* + Copyright (c) 2019, Ford Motor Company, Livio + 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 the copyright holders nor the names of their + 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 "app_service_rpc_plugin/commands/hmi/as_get_app_service_data_response_from_hmi.h" +#include "application_manager/application_impl.h" +#include "application_manager/rpc_service.h" +#include "interfaces/MOBILE_API.h" + +#include "application_manager/message_helper.h" + +namespace app_service_rpc_plugin { +using namespace application_manager; +namespace commands { + +ASGetAppServiceDataResponseFromHMI::ASGetAppServiceDataResponseFromHMI( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + app_mngr::rpc_service::RPCService& rpc_service, + app_mngr::HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handler) + : ResponseFromHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handler) {} + +ASGetAppServiceDataResponseFromHMI::~ASGetAppServiceDataResponseFromHMI() {} + +void ASGetAppServiceDataResponseFromHMI::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + event_engine::Event event(hmi_apis::FunctionID::AppService_GetAppServiceData); + event.set_smart_object(*message_); + event.raise(application_manager_.event_dispatcher()); +} + +} // namespace commands +} // namespace app_service_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_get_app_service_data_response_to_hmi.cc b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_get_app_service_data_response_to_hmi.cc new file mode 100644 index 0000000000..9e2289d39e --- /dev/null +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_get_app_service_data_response_to_hmi.cc @@ -0,0 +1,62 @@ +/* + Copyright (c) 2019, Ford Motor Company, Livio + 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 the copyright holders nor the names of their + 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 "app_service_rpc_plugin/commands/hmi/as_get_app_service_data_response_to_hmi.h" +#include "application_manager/application_impl.h" +#include "application_manager/rpc_service.h" +#include "interfaces/MOBILE_API.h" + +namespace app_service_rpc_plugin { +using namespace application_manager; +namespace commands { + +ASGetAppServiceDataResponseToHMI::ASGetAppServiceDataResponseToHMI( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + app_mngr::rpc_service::RPCService& rpc_service, + app_mngr::HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handler) + : ResponseToHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handler) {} + +ASGetAppServiceDataResponseToHMI::~ASGetAppServiceDataResponseToHMI() {} + +void ASGetAppServiceDataResponseToHMI::Run() { + LOG4CXX_AUTO_TRACE(logger_); + rpc_service_.SendMessageToHMI(message_); +} + +} // namespace commands +} // namespace app_service_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/on_as_app_service_data_notification.cc b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/on_as_app_service_data_notification.cc index 899cc44f94..80dd88c15f 100644 --- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/on_as_app_service_data_notification.cc +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/on_as_app_service_data_notification.cc @@ -31,7 +31,6 @@ */ #include "app_service_rpc_plugin/commands/hmi/on_as_app_service_data_notification.h" -#include "application_manager/message_helper.h" namespace app_service_rpc_plugin { using namespace application_manager; @@ -53,8 +52,8 @@ OnASAppServiceDataNotification::~OnASAppServiceDataNotification() {} void OnASAppServiceDataNotification::Run() { LOG4CXX_AUTO_TRACE(logger_); - LOG4CXX_DEBUG(logger_, "Received an OnAppServiceData from HMI"); - MessageHelper::PrintSmartObject(*message_); + LOG4CXX_DEBUG(logger_, "Sending AS data to HMI"); + SendNotification(); } } // namespace commands diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/on_as_app_service_data_notification_from_hmi.cc b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/on_as_app_service_data_notification_from_hmi.cc index c89b52a683..05266f834b 100644 --- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/on_as_app_service_data_notification_from_hmi.cc +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/on_as_app_service_data_notification_from_hmi.cc @@ -31,7 +31,6 @@ */ #include "app_service_rpc_plugin/commands/hmi/on_as_app_service_data_notification_from_hmi.h" -#include "application_manager/message_helper.h" namespace app_service_rpc_plugin { using namespace application_manager; @@ -55,7 +54,8 @@ OnASAppServiceDataNotificationFromHMI:: void OnASAppServiceDataNotificationFromHMI::Run() { LOG4CXX_AUTO_TRACE(logger_); LOG4CXX_DEBUG(logger_, "Received an OnAppServiceData from HMI"); - MessageHelper::PrintSmartObject(*message_); + SendNotificationToConsumers( + mobile_apis::FunctionID::eType::OnAppServiceDataID); } } // namespace commands diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/get_app_service_data_request.cc b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/get_app_service_data_request.cc new file mode 100644 index 0000000000..b54071068f --- /dev/null +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/get_app_service_data_request.cc @@ -0,0 +1,130 @@ +/* + Copyright (c) 2019, Ford Motor Company, Livio + 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 the copyright holders nor the names of their + 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 "app_service_rpc_plugin/commands/mobile/get_app_service_data_request.h" +#include "app_service_rpc_plugin/app_service_app_extension.h" +#include "application_manager/application_impl.h" +#include "application_manager/message_helper.h" +#include "application_manager/rpc_service.h" +#include "interfaces/MOBILE_API.h" +#include "smart_objects/enum_schema_item.h" + +namespace app_service_rpc_plugin { +using namespace application_manager; +namespace commands { + +GetAppServiceDataRequest::GetAppServiceDataRequest( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + app_mngr::rpc_service::RPCService& rpc_service, + app_mngr::HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handler) + : CommandRequestImpl(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handler) + , plugin_(NULL) { + auto plugin = (application_manager.GetPluginManager().FindPluginToProcess( + mobile_apis::FunctionID::GetAppServiceDataID, + app_mngr::commands::Command::CommandSource::SOURCE_MOBILE)); + if (plugin) { + plugin_ = dynamic_cast(&(*plugin)); + } +} + +GetAppServiceDataRequest::~GetAppServiceDataRequest() {} + +void GetAppServiceDataRequest::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + std::string service_type = + (*message_)[strings::msg_params][strings::service_type].asString(); + + bool subscribe = false; + if ((*message_)[strings::msg_params].keyExists(strings::subscribe)) { + subscribe = (*message_)[strings::msg_params][strings::subscribe].asBool(); + } + + ApplicationSharedPtr app = application_manager_.application(connection_key()); + + if (subscribe) { + auto& ext = AppServiceAppExtension::ExtractASExtension(*app); + ext.SubscribeToAppService(service_type); + } + + SendProviderRequest(mobile_apis::FunctionID::GetAppServiceDataID, + hmi_apis::FunctionID::AppService_GetAppServiceData, + &(*message_), + true); +} + +void GetAppServiceDataRequest::on_event( + const event_engine::MobileEvent& event) { + const smart_objects::SmartObject& event_message = event.smart_object(); + + auto msg_params = event_message[strings::msg_params]; + + mobile_apis::Result::eType result = static_cast( + msg_params[strings::result_code].asInt()); + bool success = IsMobileResultSuccess(result); + + const char* info = msg_params.keyExists(strings::info) + ? msg_params[strings::info].asCharArray() + : NULL; + + SendResponse(success, result, info, &msg_params); +} + +void GetAppServiceDataRequest::on_event(const event_engine::Event& event) { + const smart_objects::SmartObject& event_message = event.smart_object(); + + auto msg_params = event_message[strings::msg_params]; + + hmi_apis::Common_Result::eType hmi_result = + static_cast( + event_message[strings::params][hmi_response::code].asInt()); + + mobile_apis::Result::eType result = + MessageHelper::HMIToMobileResult(hmi_result); + bool success = PrepareResultForMobileResponse( + hmi_result, HmiInterfaces::HMI_INTERFACE_AppService); + + const char* info = msg_params.keyExists(strings::info) + ? msg_params[strings::info].asCharArray() + : NULL; + + SendResponse(success, result, info, &msg_params); +} + +} // namespace commands +} // namespace app_service_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/get_app_service_data_request_to_mobile.cc b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/get_app_service_data_request_to_mobile.cc new file mode 100644 index 0000000000..2bf81b3a2d --- /dev/null +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/get_app_service_data_request_to_mobile.cc @@ -0,0 +1,62 @@ +/* + Copyright (c) 2019, Ford Motor Company, Livio + 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 the copyright holders nor the names of their + 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 "app_service_rpc_plugin/commands/mobile/get_app_service_data_request_to_mobile.h" +#include "application_manager/application_impl.h" +#include "application_manager/rpc_service.h" +#include "interfaces/MOBILE_API.h" + +namespace app_service_rpc_plugin { +using namespace application_manager; +namespace commands { + +GetAppServiceDataRequestToMobile::GetAppServiceDataRequestToMobile( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + app_mngr::rpc_service::RPCService& rpc_service, + app_mngr::HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handler) + : CommandRequestToMobile(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handler) {} + +GetAppServiceDataRequestToMobile::~GetAppServiceDataRequestToMobile() {} + +void GetAppServiceDataRequestToMobile::Run() { + LOG4CXX_AUTO_TRACE(logger_); + SendRequest(); +} + +} // namespace commands +} // namespace app_service_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/get_app_service_data_response.cc b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/get_app_service_data_response.cc new file mode 100644 index 0000000000..df7bbba2f7 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/get_app_service_data_response.cc @@ -0,0 +1,62 @@ +/* + Copyright (c) 2019, Ford Motor Company, Livio + 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 the copyright holders nor the names of their + 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 "app_service_rpc_plugin/commands/mobile/get_app_service_data_response.h" +#include "application_manager/application_impl.h" +#include "application_manager/rpc_service.h" +#include "interfaces/MOBILE_API.h" + +namespace app_service_rpc_plugin { +using namespace application_manager; +namespace commands { + +GetAppServiceDataResponse::GetAppServiceDataResponse( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + app_mngr::rpc_service::RPCService& rpc_service, + app_mngr::HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handler) + : CommandResponseImpl(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handler) {} + +GetAppServiceDataResponse::~GetAppServiceDataResponse() {} + +void GetAppServiceDataResponse::Run() { + LOG4CXX_AUTO_TRACE(logger_); + rpc_service_.SendMessageToMobile(message_); +} + +} // namespace commands +} // namespace app_service_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/get_app_service_data_response_from_mobile.cc b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/get_app_service_data_response_from_mobile.cc new file mode 100644 index 0000000000..f8c1f3892d --- /dev/null +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/get_app_service_data_response_from_mobile.cc @@ -0,0 +1,74 @@ +/* + Copyright (c) 2019, Ford Motor Company, Livio + 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 the copyright holders nor the names of their + 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 "app_service_rpc_plugin/commands/mobile/get_app_service_data_response_from_mobile.h" +#include "application_manager/application_impl.h" +#include "application_manager/message_helper.h" +#include "application_manager/rpc_service.h" +#include "interfaces/MOBILE_API.h" + +namespace app_service_rpc_plugin { +using namespace application_manager; +namespace commands { + +GetAppServiceDataResponseFromMobile::GetAppServiceDataResponseFromMobile( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + app_mngr::rpc_service::RPCService& rpc_service, + app_mngr::HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handler) + : CommandResponseFromMobile(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handler) + , plugin_(NULL) { + auto plugin = (application_manager.GetPluginManager().FindPluginToProcess( + mobile_apis::FunctionID::PublishAppServiceID, + app_mngr::commands::Command::CommandSource::SOURCE_MOBILE)); + if (plugin) { + plugin_ = dynamic_cast(&(*plugin)); + } +} + +GetAppServiceDataResponseFromMobile::~GetAppServiceDataResponseFromMobile() {} + +void GetAppServiceDataResponseFromMobile::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + event_engine::MobileEvent event(mobile_apis::FunctionID::GetAppServiceDataID); + event.set_smart_object(*message_); + event.raise(application_manager_.event_dispatcher()); +} + +} // namespace commands +} // namespace app_service_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/on_app_service_data_notification.cc b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/on_app_service_data_notification.cc index 6a6a50dc86..a016d1fe16 100644 --- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/on_app_service_data_notification.cc +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/on_app_service_data_notification.cc @@ -31,11 +31,15 @@ */ #include "app_service_rpc_plugin/commands/mobile/on_app_service_data_notification.h" +#include "app_service_rpc_plugin/app_service_app_extension.h" #include "application_manager/application_impl.h" +#include "application_manager/helpers/application_helper.h" #include "application_manager/message_helper.h" #include "application_manager/rpc_service.h" #include "interfaces/MOBILE_API.h" +#include "smart_objects/enum_schema_item.h" + namespace app_service_rpc_plugin { using namespace application_manager; namespace commands { @@ -58,7 +62,38 @@ void OnAppServiceDataNotification::Run() { LOG4CXX_AUTO_TRACE(logger_); LOG4CXX_DEBUG(logger_, "Sending OnAppServiceData to consumer"); MessageHelper::PrintSmartObject(*message_); - SendNotification(); + + std::string service_type = + (*message_)[strings::msg_params][strings::service_type].asString(); + + auto subscribed_to_app_service_predicate = + [service_type](const ApplicationSharedPtr app) { + DCHECK_OR_RETURN(app, false); + auto& ext = AppServiceAppExtension::ExtractASExtension(*app); + LOG4CXX_DEBUG(logger_, "Check subscription for type: " << service_type); + return ext.IsSubscribedToAppService(service_type); + }; + + const std::vector& applications = + application_manager::FindAllApps(application_manager_.applications(), + subscribed_to_app_service_predicate); + + std::vector::const_iterator app_it = + applications.begin(); + + for (; applications.end() != app_it; ++app_it) { + const ApplicationSharedPtr app = *app_it; + if (!app) { + LOG4CXX_ERROR(logger_, "NULL pointer"); + continue; + } + LOG4CXX_DEBUG(logger_, + "Sending OnAppServiceDataNotification to mobile connection: " + << app->app_id()); + (*message_)[app_mngr::strings::params][app_mngr::strings::connection_key] = + app->app_id(); + SendNotification(); + } } } // namespace commands diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/on_app_service_data_notification_from_mobile.cc b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/on_app_service_data_notification_from_mobile.cc index 1aa8504ff9..1328e128d4 100644 --- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/on_app_service_data_notification_from_mobile.cc +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/on_app_service_data_notification_from_mobile.cc @@ -75,6 +75,9 @@ void OnAppServiceDataNotificationFromMobile::Run() { "OnAppServiceDataNotificationFromMobile"); return; } + + SendNotificationToConsumers( + hmi_apis::FunctionID::eType::AppService_OnAppServiceData); } } // namespace commands diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/publish_app_service_request.cc b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/publish_app_service_request.cc index f951d2b126..05210208ca 100644 --- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/publish_app_service_request.cc +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/publish_app_service_request.cc @@ -117,6 +117,7 @@ void PublishAppServiceRequest::Run() { mobile_apis::Result::DISALLOWED, "Service disallowed by policies", NULL); + return; } auto& ext = diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/rc_command_factory.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/rc_command_factory.cc index ecfc1dcda4..d49f3e9e36 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/rc_command_factory.cc +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/rc_command_factory.cc @@ -124,7 +124,8 @@ RCCommandFactory::RCCommandFactory(const RCCommandParams& params) CommandSharedPtr RCCommandFactory::CreateCommand( const app_mngr::commands::MessageSharedPtr& message, app_mngr::commands::Command::CommandSource source) { - if (app_mngr::commands::Command::SOURCE_HMI == source) { + if (app_mngr::commands::Command::SOURCE_HMI == source || + app_mngr::commands::Command::SOURCE_SDL_TO_HMI == source) { hmi_apis::messageType::eType message_type = static_cast( (*message)[strings::params][strings::message_type].asInt()); @@ -153,7 +154,8 @@ bool RCCommandFactory::IsAbleToProcess( const application_manager::commands::Command::CommandSource message_source) const { using app_mngr::commands::Command; - if (Command::SOURCE_HMI == message_source) { + if (Command::SOURCE_HMI == message_source || + Command::SOURCE_SDL_TO_HMI == message_source) { return get_hmi_creator_factory( static_cast(function_id), hmi_apis::messageType::INVALID_ENUM).CanBeCreated(); diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/commands/button_press_request_test.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/commands/button_press_request_test.cc index 59d038a790..e9d1063648 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/commands/button_press_request_test.cc +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/commands/button_press_request_test.cc @@ -196,8 +196,8 @@ TEST_F(ButtonPressRequestTest, SetResourceState(resource, kAppId, rc_rpc_plugin::ResourceState::BUSY)); EXPECT_CALL(mock_rpc_service_, ManageHMICommand( - HMIResultCodeIs(hmi_apis::FunctionID::Buttons_ButtonPress))) - .WillOnce(Return(true)); + HMIResultCodeIs(hmi_apis::FunctionID::Buttons_ButtonPress), + _)).WillOnce(Return(true)); // Act std::shared_ptr command = @@ -230,8 +230,9 @@ TEST_F( .Times(2); EXPECT_CALL(mock_rpc_service_, - ManageHMICommand(HMIResultCodeIs( - hmi_apis::FunctionID::Buttons_ButtonPress))).Times(0); + ManageHMICommand( + HMIResultCodeIs(hmi_apis::FunctionID::Buttons_ButtonPress), + _)).Times(0); MessageSharedPtr command_result; EXPECT_CALL(mock_rpc_service_, ManageMobileCommand( 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 25dad2dc04..4e74e74ef8 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 @@ -199,9 +199,10 @@ TEST_F(GetInteriorVehicleDataRequestTest, mobile_message); // Expectations - EXPECT_CALL(mock_rpc_service_, - ManageHMICommand(HMIResultCodeIs( - hmi_apis::FunctionID::RC_GetInteriorVehicleData))) + EXPECT_CALL( + mock_rpc_service_, + ManageHMICommand( + HMIResultCodeIs(hmi_apis::FunctionID::RC_GetInteriorVehicleData), _)) .WillOnce(Return(true)); // Act command->Run(); @@ -225,9 +226,10 @@ TEST_F(GetInteriorVehicleDataRequestTest, mobile_message); // Expectations - EXPECT_CALL(mock_rpc_service_, - ManageHMICommand(HMIResultCodeIs( - hmi_apis::FunctionID::RC_GetInteriorVehicleData))) + EXPECT_CALL( + mock_rpc_service_, + ManageHMICommand( + HMIResultCodeIs(hmi_apis::FunctionID::RC_GetInteriorVehicleData), _)) .WillOnce(Return(true)); // Act command->Run(); @@ -253,7 +255,7 @@ TEST_F( .WillOnce(Return(true)); EXPECT_CALL(mock_interior_data_cache_, Retrieve(enums_value::kRadio)) .WillOnce(Return(radio_data)); - EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_)).Times(0); + EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_, _)).Times(0); MessageSharedPtr command_result; EXPECT_CALL( mock_rpc_service_, @@ -295,9 +297,10 @@ TEST_F( .WillByDefault(Return(true)); // Expectations - EXPECT_CALL(mock_rpc_service_, - ManageHMICommand(HMIResultCodeIs( - hmi_apis::FunctionID::RC_GetInteriorVehicleData))) + EXPECT_CALL( + mock_rpc_service_, + ManageHMICommand( + HMIResultCodeIs(hmi_apis::FunctionID::RC_GetInteriorVehicleData), _)) .WillOnce(Return(true)); EXPECT_CALL( mock_rpc_service_, @@ -347,7 +350,7 @@ TEST_F(GetInteriorVehicleDataRequestTest, EXPECT_CALL(mock_interior_data_cache_, Retrieve(enums_value::kRadio)) .WillOnce(Return(radio_data)); - EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_)).Times(0); + EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_, _)).Times(0); MessageSharedPtr command_result; EXPECT_CALL( mock_rpc_service_, @@ -383,7 +386,7 @@ TEST_F( .WillByDefault(Return(&rc_capabilities)); // Expectations - EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_)).Times(0); + EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_, _)).Times(0); EXPECT_CALL(mock_rpc_service_, ManageMobileCommand( MobileResultCodeIs(mobile_apis::Result::UNSUPPORTED_RESOURCE), @@ -407,7 +410,7 @@ TEST_F( ON_CALL(mock_policy_handler_, CheckModule(_, _)).WillByDefault(Return(false)); // Expectations - EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_)).Times(0); + EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_, _)).Times(0); EXPECT_CALL(mock_rpc_service_, ManageMobileCommand( MobileResultCodeIs(mobile_apis::Result::DISALLOWED), _)) @@ -443,9 +446,10 @@ TEST_F(GetInteriorVehicleDataRequestTest, ManageMobileCommand(MobileResultCodeIs(mobile_apis::Result::SUCCESS), _)) .WillOnce(Return(true)); - EXPECT_CALL(mock_rpc_service_, - ManageHMICommand(HMIResultCodeIs( - hmi_apis::FunctionID::RC_GetInteriorVehicleData))) + EXPECT_CALL( + mock_rpc_service_, + ManageHMICommand( + HMIResultCodeIs(hmi_apis::FunctionID::RC_GetInteriorVehicleData), _)) .WillOnce(Return(true)); // Act @@ -478,9 +482,10 @@ TEST_F(GetInteriorVehicleDataRequestTest, .WillByDefault(Return(true)); // Expectations - EXPECT_CALL(mock_rpc_service_, - ManageHMICommand(HMIResultCodeIs( - hmi_apis::FunctionID::RC_GetInteriorVehicleData))) + EXPECT_CALL( + mock_rpc_service_, + ManageHMICommand( + HMIResultCodeIs(hmi_apis::FunctionID::RC_GetInteriorVehicleData), _)) .WillOnce(Return(true)); EXPECT_CALL(mock_rpc_service_, ManageMobileCommand( @@ -519,9 +524,10 @@ TEST_F(GetInteriorVehicleDataRequestTest, .WillByDefault(Return(true)); // Expectations - EXPECT_CALL(mock_rpc_service_, - ManageHMICommand(HMIResultCodeIs( - hmi_apis::FunctionID::RC_GetInteriorVehicleData))) + EXPECT_CALL( + mock_rpc_service_, + ManageHMICommand( + HMIResultCodeIs(hmi_apis::FunctionID::RC_GetInteriorVehicleData), _)) .WillOnce(Return(true)); EXPECT_CALL(mock_rpc_service_, ManageMobileCommand( @@ -569,10 +575,11 @@ TEST_F(GetInteriorVehicleDataRequestTest, StoreRequestToHMITime(enums_value::kRadio)); EXPECT_CALL(mock_interior_data_cache_, Contains(enums_value::kRadio)) .WillRepeatedly(Return(false)); - EXPECT_CALL(mock_rpc_service_, - ManageHMICommand(HMIResultCodeIs( - hmi_apis::FunctionID::RC_GetInteriorVehicleData))) - .WillRepeatedly(Return(true)); + EXPECT_CALL( + mock_rpc_service_, + ManageHMICommand( + HMIResultCodeIs(hmi_apis::FunctionID::RC_GetInteriorVehicleData), + _)).WillRepeatedly(Return(true)); // Act command->Run(); } @@ -585,7 +592,7 @@ TEST_F(GetInteriorVehicleDataRequestTest, mock_rpc_service_, ManageMobileCommand(MobileResultCodeIs(mobile_apis::Result::REJECTED), _)) .WillOnce(Return(false)); - EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_)).Times(0); + EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_, _)).Times(0); // Act command->Run(); diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/sdl_command_factory.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/sdl_command_factory.cc index efdcde7526..d745cd8f44 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/sdl_command_factory.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/sdl_command_factory.cc @@ -55,7 +55,8 @@ SDLCommandFactory::SDLCommandFactory( app_mngr::CommandSharedPtr SDLCommandFactory::CreateCommand( const app_mngr::commands::MessageSharedPtr& message, app_mngr::commands::Command::CommandSource source) { - if (app_mngr::commands::Command::SOURCE_HMI == source) { + if (app_mngr::commands::Command::SOURCE_HMI == source || + app_mngr::commands::Command::SOURCE_SDL_TO_HMI == source) { return hmi_command_factory_->CreateCommand(message, source); } else { return mobile_command_factory_->CreateCommand(message, source); @@ -70,7 +71,8 @@ bool SDLCommandFactory::IsAbleToProcess( bool is_mobile_command_factory_able_to_process = mobile_command_factory_->IsAbleToProcess(FunctionID, source); - return app_mngr::commands::Command::SOURCE_HMI == source + return (app_mngr::commands::Command::SOURCE_HMI == source || + app_mngr::commands::Command::SOURCE_SDL_TO_HMI == source) ? is_hmi_command_factory_able_to_process : is_mobile_command_factory_able_to_process; } diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/get_urls_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/get_urls_test.cc index 2191900750..20a05d8601 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/get_urls_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/get_urls_test.cc @@ -110,7 +110,7 @@ TEST_F(GetUrlsTest, RUN_SUCCESS) { TEST_F(GetUrlsTest, RUN_PolicyNotEnabled_UNSUCCESS) { EXPECT_CALL(mock_policy_handler_, PolicyEnabled()).WillOnce(Return(false)); - EXPECT_CALL(mock_rpc_service_, ManageHMICommand(command_msg_)) + EXPECT_CALL(mock_rpc_service_, ManageHMICommand(command_msg_, _)) .WillOnce(Return(true)); request_command_->Run(); @@ -127,7 +127,7 @@ TEST_F(GetUrlsTest, RUN_EmptyEndpoints_UNSUCCESS) { .WillOnce(SetArgReferee<1>(endpoints_)); EXPECT_CALL(mock_policy_handler_, PolicyEnabled()).WillOnce(Return(true)); - EXPECT_CALL(mock_rpc_service_, ManageHMICommand(command_msg_)) + EXPECT_CALL(mock_rpc_service_, ManageHMICommand(command_msg_, _)) .WillOnce(Return(true)); request_command_->Run(); @@ -160,7 +160,7 @@ TEST_F(GetUrlsTest, ProcessPolicyServiceURLs_SUCCESS) { EXPECT_CALL(app_mngr_, application(kAppIdForSending)) .WillOnce(Return(mock_app)); EXPECT_CALL(*mock_app, app_id()).WillOnce(Return(kAppIdForSending)); - EXPECT_CALL(mock_rpc_service_, ManageHMICommand(command_msg_)) + EXPECT_CALL(mock_rpc_service_, ManageHMICommand(command_msg_, _)) .WillOnce(Return(true)); request_command_->Run(); @@ -197,7 +197,7 @@ TEST_F(GetUrlsTest, ProcessPolicyServiceURLs_IncorrectIdForSending_UNSUCCESS) { EXPECT_CALL(mock_policy_handler_, GetAppIdForSending()) .WillOnce(Return(kInvalidAppId_)); - EXPECT_CALL(mock_rpc_service_, ManageHMICommand(command_msg_)) + EXPECT_CALL(mock_rpc_service_, ManageHMICommand(command_msg_, _)) .WillOnce(Return(true)); EXPECT_CALL(app_mngr_, application(kInvalidAppId_)).Times(0); @@ -226,7 +226,7 @@ TEST_F(GetUrlsTest, ProcessPolicyServiceURLs_ApplicationIsNotValid_UNSUCCESS) { EXPECT_CALL(app_mngr_, application(kAppIdForSending)) .WillOnce(Return(invalid_mock_app)); - EXPECT_CALL(mock_rpc_service_, ManageHMICommand(command_msg_)) + EXPECT_CALL(mock_rpc_service_, ManageHMICommand(command_msg_, _)) .WillOnce(Return(true)); request_command_->Run(); @@ -261,7 +261,7 @@ TEST_F(GetUrlsTest, ProcessPolicyServiceURLs_FoundURLForApplication_SUCCESS) { EXPECT_CALL(*mock_app, policy_app_id()).WillOnce(Return(kPolicyAppId)); - EXPECT_CALL(mock_rpc_service_, ManageHMICommand(command_msg_)) + EXPECT_CALL(mock_rpc_service_, ManageHMICommand(command_msg_, _)) .WillOnce(Return(true)); request_command_->Run(); diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/hmi_notifications_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/hmi_notifications_test.cc index fe82b16f3f..ca322ea425 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/hmi_notifications_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/hmi_notifications_test.cc @@ -945,7 +945,7 @@ TEST_F(HMICommandsNotificationsTest, EXPECT_CALL(app_mngr_, GetNextHMICorrelationID()) .WillOnce(Return(kCorrelationId_)); - EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_)) + EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_, _)) .WillOnce(GetMessage(temp_message)); command->Run(); @@ -973,7 +973,7 @@ TEST_F(HMICommandsNotificationsTest, EXPECT_CALL(app_mngr_, SetUnregisterAllApplicationsReason(_)).Times(0); EXPECT_CALL(app_mngr_, HeadUnitReset(_)).Times(0); EXPECT_CALL(app_mngr_, GetNextHMICorrelationID()).Times(0); - EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_)).Times(0); + EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_, _)).Times(0); command->Run(); } diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/rc_is_ready_request_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/rc_is_ready_request_test.cc index 030db2f424..c7fbdb663b 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/rc_is_ready_request_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/rc_is_ready_request_test.cc @@ -99,7 +99,7 @@ class RCIsReadyRequestTest EXPECT_CALL(mock_message_helper_, CreateModuleInfoSO(hmi_apis::FunctionID::RC_GetCapabilities, _)) .WillOnce(Return(capabilities)); - EXPECT_CALL(mock_rpc_service_, ManageHMICommand(capabilities)); + EXPECT_CALL(mock_rpc_service_, ManageHMICommand(capabilities, _)); } void PrepareEvent(bool is_message_contain_param, diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/response_from_hmi_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/response_from_hmi_test.cc index 0b1f2df491..25abefb010 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/response_from_hmi_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/response_from_hmi_test.cc @@ -86,7 +86,7 @@ TEST_F(ResponseFromHMITest, CreateHMIRequest_SUCCESS) { ResponseFromHMIPtr command(CreateCommand()); MessageSharedPtr result_msg; - EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_)) + EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_, _)) .WillOnce(DoAll(SaveArg<0>(&result_msg), Return(true))); const hmi_apis::FunctionID::eType posted_function_id = @@ -115,7 +115,7 @@ TEST_F(ResponseFromHMITest, CreateHMIRequest_CantManageCommand_Covering) { MessageSharedPtr result_msg; ON_CALL(app_mngr_, GetNextHMICorrelationID()).WillByDefault(Return(1u)); - EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_)) + EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_, _)) .WillOnce(DoAll(SaveArg<0>(&result_msg), Return(false))); const hmi_apis::FunctionID::eType posted_function_id = diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/sdl_activate_app_request_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/sdl_activate_app_request_test.cc index 8543a201bf..a90c0c70fc 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/sdl_activate_app_request_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/sdl_activate_app_request_test.cc @@ -166,9 +166,9 @@ TEST_F(SDLActivateAppRequestTest, DISABLED_Run_DeactivateApp_REJECTED) { IsStateActive(am::HmiState::StateID::STATE_ID_DEACTIVATE_HMI)) .WillOnce(Return(true)); - EXPECT_CALL( - mock_rpc_service_, - ManageHMICommand(HMIResultCodeIs(hmi_apis::FunctionID::SDL_ActivateApp))) + EXPECT_CALL(mock_rpc_service_, + ManageHMICommand( + HMIResultCodeIs(hmi_apis::FunctionID::SDL_ActivateApp), _)) .WillOnce(Return(true)); command->Run(); @@ -487,7 +487,7 @@ TEST_F(SDLActivateAppRequestTest, OnTimeout_SUCCESS) { std::shared_ptr command( CreateCommand(msg)); ON_CALL(mock_event_dispatcher_, remove_observer(_, _)); - EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_)).WillOnce(Return(true)); + EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_, _)).WillOnce(Return(true)); command->onTimeOut(); } diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/simple_request_from_hmi_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/simple_request_from_hmi_test.cc index 5c42d265c7..a69f6c71fc 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/simple_request_from_hmi_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/simple_request_from_hmi_test.cc @@ -81,7 +81,7 @@ TEST_F(RequestFromHMITest, SendResponse_SUCCESS) { const bool success = false; const uint32_t correlation_id = 1u; - EXPECT_CALL(mock_rpc_service_, ManageHMICommand(NotNull())); + EXPECT_CALL(mock_rpc_service_, ManageHMICommand(NotNull(), _)); command->SendResponse(success, correlation_id, diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/simple_response_from_hmi_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/simple_response_from_hmi_test.cc index 4a86fa9458..4f415975ba 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/simple_response_from_hmi_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/simple_response_from_hmi_test.cc @@ -310,7 +310,7 @@ TEST_F(NotificationFromHMITest, CreateHMIRequest_UNSUCCESS) { EXPECT_CALL(app_mngr_, GetNextHMICorrelationID()) .WillOnce(Return(correlation_id)); EXPECT_CALL(mock_rpc_service_, - ManageHMICommand(CheckMsgType(am::MessageType::kRequest))) + ManageHMICommand(CheckMsgType(am::MessageType::kRequest), _)) .WillOnce(Return(false)); command->CreateHMIRequest(hmi_apis::FunctionID::INVALID_ENUM, diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/ui_is_ready_request_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/ui_is_ready_request_test.cc index fe0d8a8470..70fc80bbd1 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/ui_is_ready_request_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/ui_is_ready_request_test.cc @@ -125,9 +125,9 @@ class UIIsReadyRequestTest .WillOnce(Return(get_capabilities)); EXPECT_CALL(mock_hmi_capabilities_, set_handle_response_for(*get_language)); - EXPECT_CALL(mock_rpc_service_, ManageHMICommand(get_language)); - EXPECT_CALL(mock_rpc_service_, ManageHMICommand(get_all_language)); - EXPECT_CALL(mock_rpc_service_, ManageHMICommand(get_capabilities)); + EXPECT_CALL(mock_rpc_service_, ManageHMICommand(get_language, _)); + EXPECT_CALL(mock_rpc_service_, ManageHMICommand(get_all_language, _)); + EXPECT_CALL(mock_rpc_service_, ManageHMICommand(get_capabilities, _)); } void PrepareEvent(bool is_message_contain_param, diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/vr_is_ready_request_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/vr_is_ready_request_test.cc index 5aa00e0264..259fd0b92b 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/vr_is_ready_request_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/vr_is_ready_request_test.cc @@ -98,7 +98,7 @@ class VRIsReadyRequestTest CreateModuleInfoSO(hmi_apis::FunctionID::VR_GetLanguage, _)) .WillOnce(Return(language)); EXPECT_CALL(mock_hmi_capabilities_, set_handle_response_for(*language)); - EXPECT_CALL(mock_rpc_service_, ManageHMICommand(language)); + EXPECT_CALL(mock_rpc_service_, ManageHMICommand(language, _)); smart_objects::SmartObjectSPtr support_language( new smart_objects::SmartObject(smart_objects::SmartType_Map)); @@ -106,14 +106,14 @@ class VRIsReadyRequestTest mock_message_helper_, CreateModuleInfoSO(hmi_apis::FunctionID::VR_GetSupportedLanguages, _)) .WillOnce(Return(support_language)); - EXPECT_CALL(mock_rpc_service_, ManageHMICommand(support_language)); + EXPECT_CALL(mock_rpc_service_, ManageHMICommand(support_language, _)); smart_objects::SmartObjectSPtr capabilities( new smart_objects::SmartObject(smart_objects::SmartType_Map)); EXPECT_CALL(mock_message_helper_, CreateModuleInfoSO(hmi_apis::FunctionID::VR_GetCapabilities, _)) .WillOnce(Return(capabilities)); - EXPECT_CALL(mock_rpc_service_, ManageHMICommand(capabilities)); + EXPECT_CALL(mock_rpc_service_, ManageHMICommand(capabilities, _)); } void PrepareEvent(bool is_message_contain_param, diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/add_command_request_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/add_command_request_test.cc index 7c99b5f2b8..0023368b5a 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/add_command_request_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/add_command_request_test.cc @@ -190,11 +190,11 @@ class AddCommandRequestTest EXPECT_CALL(mock_rpc_service_, ManageHMICommand( - HMIResultCodeIs(hmi_apis::FunctionID::UI_AddCommand))) + HMIResultCodeIs(hmi_apis::FunctionID::UI_AddCommand), _)) .WillOnce(Return(true)); EXPECT_CALL(mock_rpc_service_, ManageHMICommand( - HMIResultCodeIs(hmi_apis::FunctionID::VR_AddCommand))) + HMIResultCodeIs(hmi_apis::FunctionID::VR_AddCommand), _)) .WillOnce(Return(true)); } EXPECT_CALL(mock_rpc_service_, ManageMobileCommand(_, _)).Times(0); @@ -207,7 +207,7 @@ class AddCommandRequestTest EXPECT_CALL(*mock_app_, RemoveCommand(kCmdId)); EXPECT_CALL(mock_rpc_service_, - ManageHMICommand(HMIResultCodeIs(cmd_to_delete))) + ManageHMICommand(HMIResultCodeIs(cmd_to_delete), _)) .WillOnce(Return(true)); SmartObjectSPtr response = std::make_shared(SmartType_Map); @@ -276,7 +276,7 @@ TEST_F(AddCommandRequestTest, Run_ImageVerificationFailed_EXPECT_WARNINGS) { commands_map, lock_ptr_))); EXPECT_CALL( mock_rpc_service_, - ManageHMICommand(HMIResultCodeIs(hmi_apis::FunctionID::UI_AddCommand))) + ManageHMICommand(HMIResultCodeIs(hmi_apis::FunctionID::UI_AddCommand), _)) .WillOnce(Return(true)); std::shared_ptr request_ptr = CreateCommand(msg_); @@ -492,13 +492,13 @@ TEST_F(AddCommandRequestTest, { InSequence dummy; - EXPECT_CALL( - mock_rpc_service_, - ManageHMICommand(HMIResultCodeIs(hmi_apis::FunctionID::UI_AddCommand))) + EXPECT_CALL(mock_rpc_service_, + ManageHMICommand( + HMIResultCodeIs(hmi_apis::FunctionID::UI_AddCommand), _)) .WillOnce(Return(true)); - EXPECT_CALL( - mock_rpc_service_, - ManageHMICommand(HMIResultCodeIs(hmi_apis::FunctionID::VR_AddCommand))) + EXPECT_CALL(mock_rpc_service_, + ManageHMICommand( + HMIResultCodeIs(hmi_apis::FunctionID::VR_AddCommand), _)) .WillOnce(Return(true)); } EXPECT_CALL(mock_rpc_service_, ManageMobileCommand(_, _)).Times(0); @@ -522,7 +522,7 @@ TEST_F(AddCommandRequestTest, GetRunMethods_SUCCESS) { EXPECT_CALL( mock_rpc_service_, - ManageHMICommand(HMIResultCodeIs(hmi_apis::FunctionID::UI_AddCommand))) + ManageHMICommand(HMIResultCodeIs(hmi_apis::FunctionID::UI_AddCommand), _)) .WillOnce(Return(true)); std::shared_ptr request_ptr = CreateCommand(msg_); @@ -547,7 +547,7 @@ TEST_F(AddCommandRequestTest, OnEvent_UI_SUCCESS) { EXPECT_CALL( mock_rpc_service_, - ManageHMICommand(HMIResultCodeIs(hmi_apis::FunctionID::UI_AddCommand))) + ManageHMICommand(HMIResultCodeIs(hmi_apis::FunctionID::UI_AddCommand), _)) .WillOnce(Return(true)); EXPECT_CALL(*mock_app_, help_prompt_manager()) @@ -578,7 +578,7 @@ TEST_F(AddCommandRequestTest, OnEvent_VR_SUCCESS) { EXPECT_CALL( mock_rpc_service_, - ManageHMICommand(HMIResultCodeIs(hmi_apis::FunctionID::VR_AddCommand))) + ManageHMICommand(HMIResultCodeIs(hmi_apis::FunctionID::VR_AddCommand), _)) .WillOnce(Return(true)); EXPECT_CALL(*mock_app_, help_prompt_manager()) @@ -659,7 +659,7 @@ TEST_F(AddCommandRequestTest, EXPECT_CALL( mock_rpc_service_, - ManageHMICommand(HMIResultCodeIs(hmi_apis::FunctionID::UI_AddCommand))) + ManageHMICommand(HMIResultCodeIs(hmi_apis::FunctionID::UI_AddCommand), _)) .WillOnce(Return(true)); std::shared_ptr request_ptr = CreateCommand(msg_); @@ -690,13 +690,13 @@ TEST_F(AddCommandRequestTest, { InSequence dummy; - EXPECT_CALL( - mock_rpc_service_, - ManageHMICommand(HMIResultCodeIs(hmi_apis::FunctionID::UI_AddCommand))) + EXPECT_CALL(mock_rpc_service_, + ManageHMICommand( + HMIResultCodeIs(hmi_apis::FunctionID::UI_AddCommand), _)) .WillOnce(Return(true)); - EXPECT_CALL( - mock_rpc_service_, - ManageHMICommand(HMIResultCodeIs(hmi_apis::FunctionID::VR_AddCommand))) + EXPECT_CALL(mock_rpc_service_, + ManageHMICommand( + HMIResultCodeIs(hmi_apis::FunctionID::VR_AddCommand), _)) .WillOnce(Return(true)); } EXPECT_CALL(mock_rpc_service_, @@ -734,13 +734,13 @@ TEST_F( commands_map, lock_ptr_))); { InSequence dummy; - EXPECT_CALL( - mock_rpc_service_, - ManageHMICommand(HMIResultCodeIs(hmi_apis::FunctionID::UI_AddCommand))) + EXPECT_CALL(mock_rpc_service_, + ManageHMICommand( + HMIResultCodeIs(hmi_apis::FunctionID::UI_AddCommand), _)) .WillOnce(Return(true)); - EXPECT_CALL( - mock_rpc_service_, - ManageHMICommand(HMIResultCodeIs(hmi_apis::FunctionID::VR_AddCommand))) + EXPECT_CALL(mock_rpc_service_, + ManageHMICommand( + HMIResultCodeIs(hmi_apis::FunctionID::VR_AddCommand), _)) .WillOnce(Return(true)); } @@ -779,13 +779,13 @@ TEST_F( { InSequence dummy; - EXPECT_CALL( - mock_rpc_service_, - ManageHMICommand(HMIResultCodeIs(hmi_apis::FunctionID::UI_AddCommand))) + EXPECT_CALL(mock_rpc_service_, + ManageHMICommand( + HMIResultCodeIs(hmi_apis::FunctionID::UI_AddCommand), _)) .WillOnce(Return(true)); - EXPECT_CALL( - mock_rpc_service_, - ManageHMICommand(HMIResultCodeIs(hmi_apis::FunctionID::VR_AddCommand))) + EXPECT_CALL(mock_rpc_service_, + ManageHMICommand( + HMIResultCodeIs(hmi_apis::FunctionID::VR_AddCommand), _)) .WillOnce(Return(true)); } @@ -824,13 +824,13 @@ TEST_F( { InSequence dummy; - EXPECT_CALL( - mock_rpc_service_, - ManageHMICommand(HMIResultCodeIs(hmi_apis::FunctionID::UI_AddCommand))) + EXPECT_CALL(mock_rpc_service_, + ManageHMICommand( + HMIResultCodeIs(hmi_apis::FunctionID::UI_AddCommand), _)) .WillOnce(Return(true)); - EXPECT_CALL( - mock_rpc_service_, - ManageHMICommand(HMIResultCodeIs(hmi_apis::FunctionID::VR_AddCommand))) + EXPECT_CALL(mock_rpc_service_, + ManageHMICommand( + HMIResultCodeIs(hmi_apis::FunctionID::VR_AddCommand), _)) .WillOnce(Return(true)); } std::shared_ptr request_ptr = @@ -873,13 +873,13 @@ TEST_F( commands_map, lock_ptr_))); { InSequence dummy; - EXPECT_CALL( - mock_rpc_service_, - ManageHMICommand(HMIResultCodeIs(hmi_apis::FunctionID::UI_AddCommand))) + EXPECT_CALL(mock_rpc_service_, + ManageHMICommand( + HMIResultCodeIs(hmi_apis::FunctionID::UI_AddCommand), _)) .WillOnce(Return(true)); - EXPECT_CALL( - mock_rpc_service_, - ManageHMICommand(HMIResultCodeIs(hmi_apis::FunctionID::VR_AddCommand))) + EXPECT_CALL(mock_rpc_service_, + ManageHMICommand( + HMIResultCodeIs(hmi_apis::FunctionID::VR_AddCommand), _)) .WillOnce(Return(true)); } std::shared_ptr request_ptr = @@ -921,7 +921,7 @@ TEST_F( commands_map, lock_ptr_))); EXPECT_CALL( mock_rpc_service_, - ManageHMICommand(HMIResultCodeIs(hmi_apis::FunctionID::UI_AddCommand))) + ManageHMICommand(HMIResultCodeIs(hmi_apis::FunctionID::UI_AddCommand), _)) .WillOnce(Return(true)); std::shared_ptr request_ptr = CreateCommand(msg_); @@ -958,7 +958,7 @@ TEST_F( EXPECT_CALL( mock_rpc_service_, - ManageHMICommand(HMIResultCodeIs(hmi_apis::FunctionID::VR_AddCommand))) + ManageHMICommand(HMIResultCodeIs(hmi_apis::FunctionID::VR_AddCommand), _)) .WillOnce(Return(true)); std::shared_ptr request_ptr = CreateCommand(msg_); @@ -996,13 +996,13 @@ TEST_F(AddCommandRequestTest, commands_map, lock_ptr_))); { InSequence dummy; - EXPECT_CALL( - mock_rpc_service_, - ManageHMICommand(HMIResultCodeIs(hmi_apis::FunctionID::UI_AddCommand))) + EXPECT_CALL(mock_rpc_service_, + ManageHMICommand( + HMIResultCodeIs(hmi_apis::FunctionID::UI_AddCommand), _)) .WillOnce(Return(true)); - EXPECT_CALL( - mock_rpc_service_, - ManageHMICommand(HMIResultCodeIs(hmi_apis::FunctionID::VR_AddCommand))) + EXPECT_CALL(mock_rpc_service_, + ManageHMICommand( + HMIResultCodeIs(hmi_apis::FunctionID::VR_AddCommand), _)) .WillOnce(Return(true)); } EXPECT_CALL(mock_rpc_service_, @@ -1020,9 +1020,9 @@ TEST_F(AddCommandRequestTest, event_ui.set_smart_object(*msg_ui); Event event_vr(hmi_apis::FunctionID::VR_AddCommand); event_vr.set_smart_object(*msg_); - EXPECT_CALL( - mock_rpc_service_, - ManageHMICommand(HMIResultCodeIs(hmi_apis::FunctionID::VR_DeleteCommand))) + EXPECT_CALL(mock_rpc_service_, + ManageHMICommand( + HMIResultCodeIs(hmi_apis::FunctionID::VR_DeleteCommand), _)) .WillOnce(Return(true)); EXPECT_CALL(*mock_app_, RemoveCommand(kCmdId)).Times(2); request_ptr->on_event(event_ui); @@ -1044,13 +1044,13 @@ TEST_F(AddCommandRequestTest, commands_map, lock_ptr_))); { InSequence dummy; - EXPECT_CALL( - mock_rpc_service_, - ManageHMICommand(HMIResultCodeIs(hmi_apis::FunctionID::UI_AddCommand))) + EXPECT_CALL(mock_rpc_service_, + ManageHMICommand( + HMIResultCodeIs(hmi_apis::FunctionID::UI_AddCommand), _)) .WillOnce(Return(true)); - EXPECT_CALL( - mock_rpc_service_, - ManageHMICommand(HMIResultCodeIs(hmi_apis::FunctionID::VR_AddCommand))) + EXPECT_CALL(mock_rpc_service_, + ManageHMICommand( + HMIResultCodeIs(hmi_apis::FunctionID::VR_AddCommand), _)) .WillOnce(Return(true)); } EXPECT_CALL(mock_rpc_service_, @@ -1063,9 +1063,9 @@ TEST_F(AddCommandRequestTest, Event event_ui(hmi_apis::FunctionID::UI_AddCommand); event_ui.set_smart_object(*msg_); request_ptr->on_event(event_ui); - EXPECT_CALL( - mock_rpc_service_, - ManageHMICommand(HMIResultCodeIs(hmi_apis::FunctionID::UI_DeleteCommand))) + EXPECT_CALL(mock_rpc_service_, + ManageHMICommand( + HMIResultCodeIs(hmi_apis::FunctionID::UI_DeleteCommand), _)) .WillOnce(Return(true)); EXPECT_CALL(*mock_app_, RemoveCommand(kCmdId)).Times(2); Event event_vr(hmi_apis::FunctionID::VR_AddCommand); @@ -1119,13 +1119,13 @@ TEST_F(AddCommandRequestTest, OnTimeOut_AppRemoveCommandCalled) { .WillOnce(Return(so_ptr_.get())); { InSequence dummy; - EXPECT_CALL( - mock_rpc_service_, - ManageHMICommand(HMIResultCodeIs(hmi_apis::FunctionID::UI_AddCommand))) + EXPECT_CALL(mock_rpc_service_, + ManageHMICommand( + HMIResultCodeIs(hmi_apis::FunctionID::UI_AddCommand), _)) .WillOnce(Return(true)); - EXPECT_CALL( - mock_rpc_service_, - ManageHMICommand(HMIResultCodeIs(hmi_apis::FunctionID::VR_AddCommand))) + EXPECT_CALL(mock_rpc_service_, + ManageHMICommand( + HMIResultCodeIs(hmi_apis::FunctionID::VR_AddCommand), _)) .WillOnce(Return(true)); } EXPECT_CALL(mock_rpc_service_, ManageMobileCommand(_, _)).Times(0); diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/alert_request_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/alert_request_test.cc index e32cc2b335..a66d0d557f 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/alert_request_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/alert_request_test.cc @@ -169,11 +169,11 @@ class AlertRequestTest : public CommandRequestTest { void ExpectManageHmiCommandTTSAndUI() { EXPECT_CALL( mock_rpc_service_, - ManageHMICommand(HMIResultCodeIs(hmi_apis::FunctionID::UI_Alert))) + ManageHMICommand(HMIResultCodeIs(hmi_apis::FunctionID::UI_Alert), _)) .WillOnce(Return(true)); EXPECT_CALL( mock_rpc_service_, - ManageHMICommand(HMIResultCodeIs(hmi_apis::FunctionID::TTS_Speak))) + ManageHMICommand(HMIResultCodeIs(hmi_apis::FunctionID::TTS_Speak), _)) .WillOnce(Return(true)); } sync_primitives::Lock lock_; @@ -452,7 +452,7 @@ TEST_F(AlertRequestTest, OnEvent_UIAlertHasHmiResponsesToWait_UNSUCCESS) { EXPECT_CALL(mock_rpc_service_, ManageHMICommand( - HMIResultCodeIs(hmi_apis::FunctionID::TTS_StopSpeaking))); + HMIResultCodeIs(hmi_apis::FunctionID::TTS_StopSpeaking), _)); command->on_event(event); } @@ -477,10 +477,9 @@ TEST_F(AlertRequestTest, DISABLED_OnEvent_TTSWarnings_SUCCESS) { (*msg_)[am::strings::msg_params][am::strings::tts_chunks], _, _)) .WillOnce(Return(mobile_apis::Result::SUCCESS)); - EXPECT_CALL( - mock_rpc_service_, - ManageHMICommand(HMIResultCodeIs(hmi_apis::FunctionID::TTS_Speak))) - .WillOnce(Return(true)); + EXPECT_CALL(mock_rpc_service_, + ManageHMICommand(HMIResultCodeIs(hmi_apis::FunctionID::TTS_Speak), + _)).WillOnce(Return(true)); CommandPtr command(CreateCommand(msg_)); command->Run(); @@ -509,10 +508,9 @@ TEST_F(AlertRequestTest, DISABLED_OnEvent_TTSUnsupportedResource_SUCCESS) { VerifyTtsFiles( (*msg_)[am::strings::msg_params][am::strings::tts_chunks], _, _)) .WillOnce(Return(mobile_apis::Result::SUCCESS)); - EXPECT_CALL( - mock_rpc_service_, - ManageHMICommand(HMIResultCodeIs(hmi_apis::FunctionID::TTS_Speak))) - .WillOnce(Return(true)); + EXPECT_CALL(mock_rpc_service_, + ManageHMICommand(HMIResultCodeIs(hmi_apis::FunctionID::TTS_Speak), + _)).WillOnce(Return(true)); CommandPtr command(CreateCommand(msg_)); command->Run(); @@ -556,9 +554,9 @@ TEST_F(AlertRequestTest, CommandPtr command(CreateCommand(msg_)); command->Run(); - EXPECT_CALL( - mock_rpc_service_, - ManageHMICommand(HMIResultCodeIs(hmi_apis::FunctionID::TTS_StopSpeaking))) + EXPECT_CALL(mock_rpc_service_, + ManageHMICommand( + HMIResultCodeIs(hmi_apis::FunctionID::TTS_StopSpeaking), _)) .WillOnce(Return(true)); Event ui_event(hmi_apis::FunctionID::UI_Alert); @@ -605,9 +603,9 @@ TEST_F(AlertRequestTest, OnEvent_TTSUnsupportedResourceUiAlertSuccess_SUCCESS) { (*msg_)[am::strings::params][am::hmi_response::code] = hmi_apis::Common_Result::SUCCESS; - EXPECT_CALL( - mock_rpc_service_, - ManageHMICommand(HMIResultCodeIs(hmi_apis::FunctionID::TTS_StopSpeaking))) + EXPECT_CALL(mock_rpc_service_, + ManageHMICommand( + HMIResultCodeIs(hmi_apis::FunctionID::TTS_StopSpeaking), _)) .WillOnce(Return(true)); Event ui_event(hmi_apis::FunctionID::UI_Alert); @@ -643,10 +641,9 @@ TEST_F(AlertRequestTest, OnEvent_TTSSuccesUiAlertInvalidEnum_SUCCESS) { VerifyTtsFiles( (*msg_)[am::strings::msg_params][am::strings::tts_chunks], _, _)) .WillOnce(Return(mobile_apis::Result::SUCCESS)); - EXPECT_CALL( - mock_rpc_service_, - ManageHMICommand(HMIResultCodeIs(hmi_apis::FunctionID::TTS_Speak))) - .WillOnce(Return(true)); + EXPECT_CALL(mock_rpc_service_, + ManageHMICommand(HMIResultCodeIs(hmi_apis::FunctionID::TTS_Speak), + _)).WillOnce(Return(true)); CommandPtr command(CreateCommand(msg_)); command->Run(); @@ -654,9 +651,9 @@ TEST_F(AlertRequestTest, OnEvent_TTSSuccesUiAlertInvalidEnum_SUCCESS) { (*msg_)[am::strings::params][am::hmi_response::code] = hmi_apis::Common_Result::INVALID_ENUM; - EXPECT_CALL( - mock_rpc_service_, - ManageHMICommand(HMIResultCodeIs(hmi_apis::FunctionID::TTS_StopSpeaking))) + EXPECT_CALL(mock_rpc_service_, + ManageHMICommand( + HMIResultCodeIs(hmi_apis::FunctionID::TTS_StopSpeaking), _)) .WillOnce(Return(true)); Event ui_event(hmi_apis::FunctionID::UI_Alert); @@ -693,10 +690,9 @@ TEST_F(AlertRequestTest, DISABLED_OnEvent_TTSAbortedUiAlertNotSent_SUCCESS) { VerifyTtsFiles( (*msg_)[am::strings::msg_params][am::strings::tts_chunks], _, _)) .WillOnce(Return(mobile_apis::Result::SUCCESS)); - EXPECT_CALL( - mock_rpc_service_, - ManageHMICommand(HMIResultCodeIs(hmi_apis::FunctionID::TTS_Speak))) - .WillOnce(Return(true)); + EXPECT_CALL(mock_rpc_service_, + ManageHMICommand(HMIResultCodeIs(hmi_apis::FunctionID::TTS_Speak), + _)).WillOnce(Return(true)); CommandPtr command(CreateCommand(msg_)); command->Run(); @@ -704,9 +700,9 @@ TEST_F(AlertRequestTest, DISABLED_OnEvent_TTSAbortedUiAlertNotSent_SUCCESS) { (*msg_)[am::strings::params][am::hmi_response::code] = hmi_apis::Common_Result::INVALID_ENUM; - EXPECT_CALL( - mock_rpc_service_, - ManageHMICommand(HMIResultCodeIs(hmi_apis::FunctionID::TTS_StopSpeaking))) + EXPECT_CALL(mock_rpc_service_, + ManageHMICommand( + HMIResultCodeIs(hmi_apis::FunctionID::TTS_StopSpeaking), _)) .WillOnce(Return(true)); Event ui_event(hmi_apis::FunctionID::UI_Alert); @@ -743,9 +739,9 @@ TEST_F(AlertRequestTest, DISABLED_OnEvent_TTSWarningUiAlertWarning_SUCCESS) { CommandPtr command(CreateCommand(msg_)); command->Run(); - EXPECT_CALL( - mock_rpc_service_, - ManageHMICommand(HMIResultCodeIs(hmi_apis::FunctionID::TTS_StopSpeaking))) + EXPECT_CALL(mock_rpc_service_, + ManageHMICommand( + HMIResultCodeIs(hmi_apis::FunctionID::TTS_StopSpeaking), _)) .WillOnce(Return(true)); Event ui_event(hmi_apis::FunctionID::UI_Alert); diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/create_interaction_choice_set_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/create_interaction_choice_set_test.cc index c42be48e57..3abda89234 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/create_interaction_choice_set_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/create_interaction_choice_set_test.cc @@ -232,7 +232,7 @@ TEST_F(CreateInteractionChoiceSetRequestTest, OnEvent_VR_UNSUPPORTED_RESOURCE) { .WillByDefault( Return(am::HmiInterfaces::HMI_INTERFACE_BasicCommunication)); - EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_)).WillOnce(Return(true)); + EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_, _)).WillOnce(Return(true)); ON_CALL(mock_message_helper_, CheckChoiceSetVRCommands(_)) .WillByDefault(Return(am::MessageHelper::ChoiceSetVRCommandsStatus::ALL)); req_vr->Run(); diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/delete_interaction_choice_set_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/delete_interaction_choice_set_test.cc index 43c30809e5..c209c4fea2 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/delete_interaction_choice_set_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/delete_interaction_choice_set_test.cc @@ -252,7 +252,7 @@ TEST_F(DeleteInteractionChoiceSetRequestTest, Run_SendVrDeleteCommand_SUCCESS) { EXPECT_CALL(*app_, UpdateHash()); } - EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_)).WillOnce(Return(true)); + EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_, _)).WillOnce(Return(true)); EXPECT_CALL(mock_rpc_service_, ManageMobileCommand(_, _)); DeleteInteractionChoiceSetRequestPtr command = diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/delete_sub_menu_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/delete_sub_menu_test.cc index f1c44f86ac..ff9e29c872 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/delete_sub_menu_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/delete_sub_menu_test.cc @@ -224,9 +224,9 @@ TEST_F(DeleteSubMenuRequestTest, Run_SendHMIRequest_SUCCESS) { EXPECT_CALL(app_mngr_, GetNextHMICorrelationID()) .WillOnce(Return(kCorrelationId)); - EXPECT_CALL( - mock_rpc_service_, - ManageHMICommand(HMIResultCodeIs(hmi_apis::FunctionID::UI_DeleteSubMenu))) + EXPECT_CALL(mock_rpc_service_, + ManageHMICommand( + HMIResultCodeIs(hmi_apis::FunctionID::UI_DeleteSubMenu), _)) .WillOnce(Return(true)); command_->Run(); } @@ -273,9 +273,9 @@ TEST_F(DeleteSubMenuRequestTest, OnEvent_DeleteSubmenu_SUCCESS) { EXPECT_CALL(*app_, app_id()).WillOnce(Return(kConnectionKey)); EXPECT_CALL(*app_, get_grammar_id()).WillOnce(Return(kGrammarId)); - EXPECT_CALL( - mock_rpc_service_, - ManageHMICommand(HMIResultCodeIs(hmi_apis::FunctionID::VR_DeleteCommand))) + EXPECT_CALL(mock_rpc_service_, + ManageHMICommand( + HMIResultCodeIs(hmi_apis::FunctionID::VR_DeleteCommand), _)) .WillOnce(Return(true)); EXPECT_CALL(*app_, commands_map()).WillOnce(Return(accessor_)); @@ -284,9 +284,9 @@ TEST_F(DeleteSubMenuRequestTest, OnEvent_DeleteSubmenu_SUCCESS) { EXPECT_CALL(*app_, help_prompt_manager()) .WillOnce(ReturnRef(*mock_help_prompt_manager_)); EXPECT_CALL(*mock_help_prompt_manager_, OnVrCommandDeleted(kCmdId, false)); - EXPECT_CALL( - mock_rpc_service_, - ManageHMICommand(HMIResultCodeIs(hmi_apis::FunctionID::UI_DeleteCommand))) + EXPECT_CALL(mock_rpc_service_, + ManageHMICommand( + HMIResultCodeIs(hmi_apis::FunctionID::UI_DeleteCommand), _)) .WillOnce(Return(true)); EXPECT_CALL(*app_, RemoveSubMenu(_)); @@ -330,7 +330,7 @@ TEST_F(DeleteSubMenuRequestTest, std::make_pair(0, &((*message_)[am::strings::msg_params]))); EXPECT_CALL(app_mngr_, application(_)).WillRepeatedly(Return(app_)); - EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_)).Times(0); + EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_, _)).Times(0); EXPECT_CALL(*app_, commands_map()).Times(2).WillRepeatedly(Return(accessor_)); EXPECT_CALL(*app_, RemoveCommand(_)).Times(0); @@ -357,7 +357,7 @@ TEST_F(DeleteSubMenuRequestTest, std::make_pair(0, &((*message_)[am::strings::msg_params]))); EXPECT_CALL(app_mngr_, application(_)).WillRepeatedly(Return(app_)); - EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_)).Times(0); + EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_, _)).Times(0); EXPECT_CALL(*app_, commands_map()).Times(2).WillRepeatedly(Return(accessor_)); EXPECT_CALL(*app_, RemoveCommand(_)).Times(0); diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/dial_number_request_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/dial_number_request_test.cc index 5d6c6dc89e..ffa1b833be 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/dial_number_request_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/dial_number_request_test.cc @@ -131,9 +131,11 @@ TEST_F(DialNumberRequestTest, Run_SUCCESS) { MockAppPtr app(CreateMockApp()); EXPECT_CALL(app_mngr_, application(kConnectionKey)).WillOnce(Return(app)); - EXPECT_CALL(mock_rpc_service_, - ManageHMICommand(HMIResultCodeIs( - hmi_apis::FunctionID::BasicCommunication_DialNumber))); + EXPECT_CALL( + mock_rpc_service_, + ManageHMICommand( + HMIResultCodeIs(hmi_apis::FunctionID::BasicCommunication_DialNumber), + _)); command->Run(); } diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/get_way_points_request_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/get_way_points_request_test.cc index 09a3336a10..f450d4b671 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/get_way_points_request_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/get_way_points_request_test.cc @@ -205,7 +205,7 @@ TEST_F(GetWayPointsRequestTest, OnEvent_DefaultCase) { EXPECT_CALL(app_mngr_, updateRequestTimeout(_, _, _)).Times(0); - EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_)).Times(0); + EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_, _)).Times(0); CallOnEvent caller(*command_sptr_, event); caller(); diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/perform_audio_pass_thru_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/perform_audio_pass_thru_test.cc index f51f1aa655..acda9b9fc7 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/perform_audio_pass_thru_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/perform_audio_pass_thru_test.cc @@ -239,7 +239,7 @@ TEST_F(PerformAudioPassThruRequestTest, MessageSharedPtr response_to_mobile; uint32_t app_id = kConnectionKey; EXPECT_CALL(app_mngr_, EndAudioPassThru(app_id)).WillOnce(Return(false)); - EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_)) + EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_, _)) .WillRepeatedly(Return(true)); EXPECT_CALL( mock_rpc_service_, @@ -342,7 +342,7 @@ TEST_F(PerformAudioPassThruRequestTest, ON_CALL(mock_hmi_interfaces_, GetInterfaceState(_)) .WillByDefault(Return(am::HmiInterfaces::STATE_AVAILABLE)); - EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_)) + EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_, _)) .WillOnce(DoAll(SaveArg<0>(&speak_reqeust_result_msg), Return(true))); // Perform audio path thru request sending @@ -355,7 +355,7 @@ TEST_F(PerformAudioPassThruRequestTest, ON_CALL(mock_hmi_interfaces_, GetInterfaceState(_)) .WillByDefault(Return(am::HmiInterfaces::STATE_AVAILABLE)); - EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_)) + EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_, _)) .WillOnce(DoAll(SaveArg<0>(&perform_result_msg), Return(true))); } CallRun run_caller(*command_sptr_); @@ -431,7 +431,7 @@ TEST_F(PerformAudioPassThruRequestTest, ON_CALL(mock_hmi_interfaces_, GetInterfaceState(_)) .WillByDefault(Return(am::HmiInterfaces::STATE_AVAILABLE)); - EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_)) + EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_, _)) .WillOnce(DoAll(SaveArg<0>(&speak_reqeust_result_msg), Return(true))); // Perform audio path thru request sending @@ -444,7 +444,7 @@ TEST_F(PerformAudioPassThruRequestTest, ON_CALL(mock_hmi_interfaces_, GetInterfaceState(_)) .WillByDefault(Return(am::HmiInterfaces::STATE_AVAILABLE)); - EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_)) + EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_, _)) .WillOnce(DoAll(SaveArg<0>(&perform_result_msg), Return(true))); } CallRun caller(*command_sptr_); @@ -505,7 +505,7 @@ TEST_F(PerformAudioPassThruRequestTest, ON_CALL(mock_hmi_interfaces_, GetInterfaceState(_)) .WillByDefault(Return(am::HmiInterfaces::STATE_AVAILABLE)); - EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_)) + EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_, _)) .WillOnce(DoAll(SaveArg<0>(&speak_reqeust_result_msg), Return(true))); // Perform audio path thru request sending @@ -518,7 +518,7 @@ TEST_F(PerformAudioPassThruRequestTest, ON_CALL(mock_hmi_interfaces_, GetInterfaceState(_)) .WillByDefault(Return(am::HmiInterfaces::STATE_AVAILABLE)); - EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_)) + EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_, _)) .WillOnce(DoAll(SaveArg<0>(&perform_result_msg), Return(true))); } CallRun caller(*command_sptr_); @@ -551,7 +551,7 @@ TEST_F( .WillByDefault(Return(am::HmiInterfaces::STATE_AVAILABLE)); // Perform audio path thru request sending - EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_)) + EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_, _)) .WillOnce(DoAll(SaveArg<0>(&perform_result_msg), Return(true))); // Perform audio path thru request sending @@ -564,7 +564,7 @@ TEST_F( .WillByDefault(Return(am::HmiInterfaces::STATE_AVAILABLE)); // Start recording notification sending - EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_)) + EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_, _)) .WillOnce(DoAll(SaveArg<0>(&start_record_result_msg), Return(true))); } @@ -613,7 +613,7 @@ TEST_F(PerformAudioPassThruRequestTest, // Start recording notification sending - EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_)).WillOnce(Return(true)); + EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_, _)).WillOnce(Return(true)); // Start microphone recording cals uint32_t app_id = kConnectionKey; @@ -676,7 +676,7 @@ TEST_F(PerformAudioPassThruRequestTest, msg_params_[am::strings::function_id] = kFunctionId; msg_params_[am::strings::correlation_id] = kCorrelationId; - EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_)).WillOnce(Return(true)); + EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_, _)).WillOnce(Return(true)); uint32_t app_id = kConnectionKey; EXPECT_CALL(app_mngr_, BeginAudioPassThru(app_id)).WillOnce(Return(true)); @@ -703,7 +703,7 @@ TEST_F(PerformAudioPassThruRequestTest, msg_params_[am::strings::function_id] = kFunctionId; uint32_t app_id = kConnectionKey; - EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_)).WillOnce(Return(true)); + EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_, _)).WillOnce(Return(true)); EXPECT_CALL(app_mngr_, BeginAudioPassThru(app_id)).WillOnce(Return(true)); EXPECT_CALL( @@ -751,7 +751,7 @@ TEST_F(PerformAudioPassThruRequestTest, EXPECT_CALL(mock_rpc_service_, ManageMobileCommand(_, _)); command_sptr_->SendResponse(true, am::mobile_api::Result::SUCCESS); - EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_)).Times(0); + EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_, _)).Times(0); command_sptr_->onTimeOut(); } @@ -783,7 +783,7 @@ TEST_F(PerformAudioPassThruRequestTest, ON_CALL(mock_hmi_interfaces_, GetInterfaceState(_)) .WillByDefault(Return(am::HmiInterfaces::STATE_AVAILABLE)); - EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_)) + EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_, _)) .WillOnce(DoAll(SaveArg<0>(&speak_reqeust_result_msg), Return(true))); // Perform audio path thru request sending @@ -796,7 +796,7 @@ TEST_F(PerformAudioPassThruRequestTest, ON_CALL(mock_hmi_interfaces_, GetInterfaceState(_)) .WillByDefault(Return(am::HmiInterfaces::STATE_AVAILABLE)); - EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_)) + EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_, _)) .WillOnce(DoAll(SaveArg<0>(&perform_result_msg), Return(true))); MessageSharedPtr msg = CreateMessage(smart_objects::SmartType_Map); @@ -807,7 +807,7 @@ TEST_F(PerformAudioPassThruRequestTest, // For setting is_active_tts_speak -> true - EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_)) + EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_, _)) .Times(2) .WillRepeatedly(Return(false)); CallRun caller(*command_sptr_); @@ -819,9 +819,9 @@ TEST_F(PerformAudioPassThruRequestTest, ManageMobileCommand(_, am::commands::Command::SOURCE_SDL)); command_sptr_->SendResponse(true, am::mobile_api::Result::SUCCESS); - EXPECT_CALL( - mock_rpc_service_, - ManageHMICommand(HMIResultCodeIs(hmi_apis::FunctionID::TTS_StopSpeaking))) + EXPECT_CALL(mock_rpc_service_, + ManageHMICommand( + HMIResultCodeIs(hmi_apis::FunctionID::TTS_StopSpeaking), _)) .WillOnce(Return(false)); command_sptr_->onTimeOut(); diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/put_file_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/put_file_test.cc index df4f69f0d0..415b559f82 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/put_file_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/put_file_test.cc @@ -315,10 +315,11 @@ TEST_F(PutFileRequestTest, Run_SendOnPutFileNotification_SUCCESS) { EXPECT_CALL(app_mngr_, SaveBinary(binary_data_, kStorageFolder, kFileName, kZeroOffset)) .WillOnce(Return(mobile_apis::Result::SUCCESS)); - EXPECT_CALL(mock_rpc_service_, - ManageHMICommand(HMIResultCodeIs( - hmi_apis::FunctionID::BasicCommunication_OnPutFile))) - .WillOnce(Return(true)); + EXPECT_CALL( + mock_rpc_service_, + ManageHMICommand( + HMIResultCodeIs(hmi_apis::FunctionID::BasicCommunication_OnPutFile), + _)).WillOnce(Return(true)); ExpectManageMobileCommandWithResultCode(mobile_apis::Result::SUCCESS); PutFileRequestPtr command(CreateCommand(msg_)); diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/register_app_interface_request_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/register_app_interface_request_test.cc index 7dab16fe35..868d353a85 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/register_app_interface_request_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/register_app_interface_request_test.cc @@ -207,27 +207,36 @@ class RegisterAppInterfaceRequestTest mock_rpc_service_, ManageMobileCommand(MobileResultCodeIs(response_result_code), _)); - EXPECT_CALL(mock_rpc_service_, - ManageHMICommand(HMIResultCodeIs( - hmi_apis::FunctionID::BasicCommunication_OnAppRegistered))) - .Times(0); + EXPECT_CALL( + mock_rpc_service_, + ManageHMICommand( + HMIResultCodeIs( + hmi_apis::FunctionID::BasicCommunication_OnAppRegistered), + _)).Times(0); - EXPECT_CALL(mock_rpc_service_, - ManageHMICommand(HMIResultCodeIs( - hmi_apis::FunctionID::Buttons_OnButtonSubscription))) - .Times(0); + EXPECT_CALL( + mock_rpc_service_, + ManageHMICommand( + HMIResultCodeIs(hmi_apis::FunctionID::Buttons_OnButtonSubscription), + _)).Times(0); - EXPECT_CALL(mock_rpc_service_, - ManageHMICommand(HMIResultCodeIs( - hmi_apis::FunctionID::UI_ChangeRegistration))).Times(0); + EXPECT_CALL( + mock_rpc_service_, + ManageHMICommand( + HMIResultCodeIs(hmi_apis::FunctionID::UI_ChangeRegistration), _)) + .Times(0); - EXPECT_CALL(mock_rpc_service_, - ManageHMICommand(HMIResultCodeIs( - hmi_apis::FunctionID::TTS_ChangeRegistration))).Times(0); + EXPECT_CALL( + mock_rpc_service_, + ManageHMICommand( + HMIResultCodeIs(hmi_apis::FunctionID::TTS_ChangeRegistration), _)) + .Times(0); - EXPECT_CALL(mock_rpc_service_, - ManageHMICommand(HMIResultCodeIs( - hmi_apis::FunctionID::VR_ChangeRegistration))).Times(0); + EXPECT_CALL( + mock_rpc_service_, + ManageHMICommand( + HMIResultCodeIs(hmi_apis::FunctionID::VR_ChangeRegistration), _)) + .Times(0); EXPECT_CALL(app_mngr_, OnApplicationSwitched( @@ -297,13 +306,15 @@ TEST_F(RegisterAppInterfaceRequestTest, Run_MinimalData_SUCCESS) { EXPECT_CALL(app_mngr_, RegisterApplication(msg_)).WillOnce(Return(mock_app)); EXPECT_CALL(mock_rpc_service_, - ManageHMICommand(HMIResultCodeIs( - hmi_apis::FunctionID::BasicCommunication_OnAppRegistered))) - .WillOnce(Return(true)); - EXPECT_CALL(mock_rpc_service_, - ManageHMICommand(HMIResultCodeIs( - hmi_apis::FunctionID::Buttons_OnButtonSubscription))) - .WillOnce(Return(true)); + ManageHMICommand( + HMIResultCodeIs( + hmi_apis::FunctionID::BasicCommunication_OnAppRegistered), + _)).WillOnce(Return(true)); + EXPECT_CALL( + mock_rpc_service_, + ManageHMICommand( + HMIResultCodeIs(hmi_apis::FunctionID::Buttons_OnButtonSubscription), + _)).WillOnce(Return(true)); EXPECT_CALL(mock_rpc_service_, ManageMobileCommand(_, am::commands::Command::SOURCE_SDL)) .Times(2); @@ -399,25 +410,27 @@ TEST_F(RegisterAppInterfaceRequestTest, .WillRepeatedly(Return(am::HmiInterfaces::STATE_AVAILABLE)); EXPECT_CALL(mock_rpc_service_, - ManageHMICommand(HMIResultCodeIs( - hmi_apis::FunctionID::BasicCommunication_OnAppRegistered))) - .WillOnce(Return(true)); - EXPECT_CALL(mock_rpc_service_, - ManageHMICommand(HMIResultCodeIs( - hmi_apis::FunctionID::Buttons_OnButtonSubscription))) - .WillOnce(Return(true)); + ManageHMICommand( + HMIResultCodeIs( + hmi_apis::FunctionID::BasicCommunication_OnAppRegistered), + _)).WillOnce(Return(true)); + EXPECT_CALL( + mock_rpc_service_, + ManageHMICommand( + HMIResultCodeIs(hmi_apis::FunctionID::Buttons_OnButtonSubscription), + _)).WillOnce(Return(true)); EXPECT_CALL(mock_rpc_service_, ManageHMICommand( - HMIResultCodeIs(hmi_apis::FunctionID::VR_ChangeRegistration))) - .WillOnce(Return(true)); + HMIResultCodeIs(hmi_apis::FunctionID::VR_ChangeRegistration), + _)).WillOnce(Return(true)); EXPECT_CALL(mock_rpc_service_, - ManageHMICommand(HMIResultCodeIs( - hmi_apis::FunctionID::TTS_ChangeRegistration))) - .WillOnce(Return(true)); + ManageHMICommand( + HMIResultCodeIs(hmi_apis::FunctionID::TTS_ChangeRegistration), + _)).WillOnce(Return(true)); EXPECT_CALL(mock_rpc_service_, ManageHMICommand( - HMIResultCodeIs(hmi_apis::FunctionID::UI_ChangeRegistration))) - .WillOnce(Return(true)); + HMIResultCodeIs(hmi_apis::FunctionID::UI_ChangeRegistration), + _)).WillOnce(Return(true)); EXPECT_CALL(mock_rpc_service_, ManageMobileCommand(_, am::commands::Command::SOURCE_SDL)) .Times(2); diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/reset_global_properties_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/reset_global_properties_test.cc index 0e3cd685fa..38585319e4 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/reset_global_properties_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/reset_global_properties_test.cc @@ -170,7 +170,7 @@ TEST_F(ResetGlobalPropertiesRequestTest, Run_InvalidVrHelp_UNSUCCESS) { EXPECT_CALL(mock_message_helper_, CreateAppVrHelp(_)) .WillOnce(Return(vr_help)); - EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_)).Times(0); + EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_, _)).Times(0); command_->Run(); } @@ -238,12 +238,13 @@ TEST_F(ResetGlobalPropertiesRequestTest, Run_SUCCESS) { .WillOnce(Return(so_help_prompt.get())); EXPECT_CALL(mock_rpc_service_, - ManageHMICommand(HMIResultCodeIs( - hmi_apis::FunctionID::UI_SetGlobalProperties))) - .WillOnce(Return(true)); - EXPECT_CALL(mock_rpc_service_, - ManageHMICommand(HMIResultCodeIs( - hmi_apis::FunctionID::TTS_SetGlobalProperties))) + ManageHMICommand( + HMIResultCodeIs(hmi_apis::FunctionID::UI_SetGlobalProperties), + _)).WillOnce(Return(true)); + EXPECT_CALL( + mock_rpc_service_, + ManageHMICommand( + HMIResultCodeIs(hmi_apis::FunctionID::TTS_SetGlobalProperties), _)) .WillOnce(Return(true)); command_->Run(); @@ -275,9 +276,9 @@ TEST_F(ResetGlobalPropertiesRequestTest, EXPECT_CALL(mock_message_helper_, CreateAppVrHelp(_)) .WillOnce(Return(vr_help)); EXPECT_CALL(mock_rpc_service_, - ManageHMICommand(HMIResultCodeIs( - hmi_apis::FunctionID::UI_SetGlobalProperties))) - .WillOnce(Return(true)); + ManageHMICommand( + HMIResultCodeIs(hmi_apis::FunctionID::UI_SetGlobalProperties), + _)).WillOnce(Return(true)); command_->Run(); @@ -321,12 +322,13 @@ TEST_F(ResetGlobalPropertiesRequestTest, (*ui_msg)[am::strings::params][am::hmi_response::code] = hmi_apis::Common_Result::eType::SUCCESS; EXPECT_CALL(mock_rpc_service_, - ManageHMICommand(HMIResultCodeIs( - hmi_apis::FunctionID::UI_SetGlobalProperties))) - .WillOnce(Return(true)); - EXPECT_CALL(mock_rpc_service_, - ManageHMICommand(HMIResultCodeIs( - hmi_apis::FunctionID::TTS_SetGlobalProperties))) + ManageHMICommand( + HMIResultCodeIs(hmi_apis::FunctionID::UI_SetGlobalProperties), + _)).WillOnce(Return(true)); + EXPECT_CALL( + mock_rpc_service_, + ManageHMICommand( + HMIResultCodeIs(hmi_apis::FunctionID::TTS_SetGlobalProperties), _)) .WillOnce(Return(true)); Event ui_event(hmi_apis::FunctionID::UI_SetGlobalProperties); ui_event.set_smart_object(*ui_msg); @@ -363,9 +365,9 @@ TEST_F(ResetGlobalPropertiesRequestTest, OnEvent_InvalidApp_NoHashUpdate) { EXPECT_CALL(*mock_app_, set_reset_global_properties_active(true)); EXPECT_CALL(mock_rpc_service_, - ManageHMICommand(HMIResultCodeIs( - hmi_apis::FunctionID::UI_SetGlobalProperties))) - .WillOnce(Return(true)); + ManageHMICommand( + HMIResultCodeIs(hmi_apis::FunctionID::UI_SetGlobalProperties), + _)).WillOnce(Return(true)); smart_objects::SmartObjectSPtr vr_help = std::make_shared( smart_objects::SmartType_Map); @@ -413,12 +415,13 @@ TEST_F(ResetGlobalPropertiesRequestTest, EXPECT_CALL(*mock_app_, set_reset_global_properties_active(true)); EXPECT_CALL(mock_rpc_service_, - ManageHMICommand(HMIResultCodeIs( - hmi_apis::FunctionID::UI_SetGlobalProperties))) - .WillOnce(Return(true)); - EXPECT_CALL(mock_rpc_service_, - ManageHMICommand(HMIResultCodeIs( - hmi_apis::FunctionID::TTS_SetGlobalProperties))) + ManageHMICommand( + HMIResultCodeIs(hmi_apis::FunctionID::UI_SetGlobalProperties), + _)).WillOnce(Return(true)); + EXPECT_CALL( + mock_rpc_service_, + ManageHMICommand( + HMIResultCodeIs(hmi_apis::FunctionID::TTS_SetGlobalProperties), _)) .WillOnce(Return(true)); ResetGlobalPropertiesRequestPtr command = @@ -478,12 +481,13 @@ TEST_F(ResetGlobalPropertiesRequestTest, EXPECT_CALL(*mock_app_, set_reset_global_properties_active(true)); EXPECT_CALL(mock_rpc_service_, - ManageHMICommand(HMIResultCodeIs( - hmi_apis::FunctionID::UI_SetGlobalProperties))) - .WillOnce(Return(true)); - EXPECT_CALL(mock_rpc_service_, - ManageHMICommand(HMIResultCodeIs( - hmi_apis::FunctionID::TTS_SetGlobalProperties))) + ManageHMICommand( + HMIResultCodeIs(hmi_apis::FunctionID::UI_SetGlobalProperties), + _)).WillOnce(Return(true)); + EXPECT_CALL( + mock_rpc_service_, + ManageHMICommand( + HMIResultCodeIs(hmi_apis::FunctionID::TTS_SetGlobalProperties), _)) .WillOnce(Return(true)); command_->Run(); @@ -542,12 +546,13 @@ TEST_F(ResetGlobalPropertiesRequestTest, EXPECT_CALL(*mock_app_, set_reset_global_properties_active(true)); EXPECT_CALL(mock_rpc_service_, - ManageHMICommand(HMIResultCodeIs( - hmi_apis::FunctionID::UI_SetGlobalProperties))) - .WillOnce(Return(true)); - EXPECT_CALL(mock_rpc_service_, - ManageHMICommand(HMIResultCodeIs( - hmi_apis::FunctionID::TTS_SetGlobalProperties))) + ManageHMICommand( + HMIResultCodeIs(hmi_apis::FunctionID::UI_SetGlobalProperties), + _)).WillOnce(Return(true)); + EXPECT_CALL( + mock_rpc_service_, + ManageHMICommand( + HMIResultCodeIs(hmi_apis::FunctionID::TTS_SetGlobalProperties), _)) .WillOnce(Return(true)); command_->Run(); diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/send_haptic_data_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/send_haptic_data_test.cc index 6c7127e48c..19f799448a 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/send_haptic_data_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/send_haptic_data_test.cc @@ -102,7 +102,7 @@ TEST_F(SendHapticDataRequestTest, Run_SUCCESS) { EXPECT_CALL(mock_rpc_service_, ManageHMICommand( - HMIResultCodeIs(hmi_apis::FunctionID::UI_SendHapticData))) + HMIResultCodeIs(hmi_apis::FunctionID::UI_SendHapticData), _)) .WillOnce(Return(true)); SendHapticDataRequestPtr command(CreateCommand(msg_)); diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/send_location_request_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/send_location_request_test.cc index 4f44293fc9..4cab3db2a3 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/send_location_request_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/send_location_request_test.cc @@ -137,15 +137,16 @@ class SendLocationRequestTest void FinishSetup() { EXPECT_CALL(*mock_app_, hmi_app_id()).WillOnce(Return(kAppID)); - EXPECT_CALL(mock_rpc_service_, - ManageHMICommand(HMIResultCodeIs( - hmi_apis::FunctionID::Navigation_SendLocation))); + EXPECT_CALL( + mock_rpc_service_, + ManageHMICommand( + HMIResultCodeIs(hmi_apis::FunctionID::Navigation_SendLocation), _)); } void FinishSetupCancelled(mobile_apis::Result::eType result) { EXPECT_CALL(*mock_app_, hmi_app_id()).Times(0); - EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_)).Times(0); + EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_, _)).Times(0); EXPECT_CALL(mock_rpc_service_, ManageMobileCommand(MobileResultCodeIs(result), _)); } diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/set_display_layout_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/set_display_layout_test.cc index cd6af1512d..10ca925739 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/set_display_layout_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/set_display_layout_test.cc @@ -201,7 +201,7 @@ TEST_F(SetDisplayLayoutRequestTest, Run_SUCCESS) { GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_UI)) .WillRepeatedly(Return(am::HmiInterfaces::STATE_AVAILABLE)); EXPECT_CALL(mock_rpc_service_, - ManageHMICommand(CheckMshCorrId(kCorrelationKey))) + ManageHMICommand(CheckMshCorrId(kCorrelationKey), _)) .WillOnce(Return(true)); command->Run(); diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/set_global_properties_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/set_global_properties_test.cc index 03aa5d85a1..94dbbc8b44 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/set_global_properties_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/set_global_properties_test.cc @@ -322,12 +322,13 @@ TEST_F(SetGlobalPropertiesRequestTest, (*msg_vr)[am::strings::msg_params][am::strings::help_prompt], _, _)) .WillOnce(Return(mobile_apis::Result::SUCCESS)); EXPECT_CALL(mock_rpc_service_, - ManageHMICommand(HMIResultCodeIs( - hmi_apis::FunctionID::UI_SetGlobalProperties))) - .WillOnce(Return(true)); - EXPECT_CALL(mock_rpc_service_, - ManageHMICommand(HMIResultCodeIs( - hmi_apis::FunctionID::TTS_SetGlobalProperties))) + ManageHMICommand( + HMIResultCodeIs(hmi_apis::FunctionID::UI_SetGlobalProperties), + _)).WillOnce(Return(true)); + EXPECT_CALL( + mock_rpc_service_, + ManageHMICommand( + HMIResultCodeIs(hmi_apis::FunctionID::TTS_SetGlobalProperties), _)) .WillOnce(Return(true)); (*msg_vr)[am::strings::params][am::hmi_response::code] = hmi_apis::Common_Result::SUCCESS; diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/set_media_clock_timer_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/set_media_clock_timer_test.cc index a69d3d741b..04a7da60cf 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/set_media_clock_timer_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/set_media_clock_timer_test.cc @@ -179,7 +179,7 @@ TEST_F(SetMediaClockRequestTest, Run_UpdateCountUp_SUCCESS) { GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_UI)) .WillByDefault(Return(am::HmiInterfaces::STATE_AVAILABLE)); - EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_)).WillOnce(Return(true)); + EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_, _)).WillOnce(Return(true)); command->Run(); } @@ -217,7 +217,7 @@ TEST_F(SetMediaClockRequestTest, Run_UpdateCountDown_SUCCESS) { GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_UI)) .WillByDefault(Return(am::HmiInterfaces::STATE_AVAILABLE)); - EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_)).WillOnce(Return(true)); + EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_, _)).WillOnce(Return(true)); command->Run(); } diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/show_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/show_test.cc index 4725af4671..4540980b9e 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/show_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/show_test.cc @@ -125,7 +125,7 @@ class ShowRequestTest : public CommandRequestTest { static_cast(field_name); msg_params[am::hmi_request::show_strings][0][am::hmi_request::field_text] = text_field_; - EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_)); + EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_, _)); EXPECT_CALL(*mock_app_, set_show_command(msg_params)); } @@ -143,7 +143,7 @@ class ShowRequestTest : public CommandRequestTest { EXPECT_CALL(mock_rpc_service_, ManageMobileCommand(_, _)); EXPECT_CALL(*mock_app_, app_id()).Times(0); - EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_)).Times(0); + EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_, _)).Times(0); EXPECT_CALL(*mock_app_, set_show_command(_)).Times(0); } @@ -196,7 +196,7 @@ class ShowRequestTest : public CommandRequestTest { } } - EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_)); + EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_, _)); EXPECT_CALL(*mock_app_, set_show_command(msg_params)); } @@ -272,7 +272,7 @@ TEST_F(ShowRequestTest, Run_SoftButtonExists_SUCCESS) { EXPECT_CALL( mock_message_helper_, SubscribeApplicationToSoftButton(creation_msg_params, _, kFunctionID)); - EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_)); + EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_, _)); EXPECT_CALL(*mock_app_, set_show_command(msg_params)); command->Run(); @@ -296,7 +296,7 @@ TEST_F(ShowRequestTest, Run_SoftButtonNotExists_SUCCESS) { smart_objects::SmartObject(smart_objects::SmartType_Array); EXPECT_CALL(*mock_app_, UnsubscribeFromSoftButtons(kFunctionID)); - EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_)); + EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_, _)); EXPECT_CALL(*mock_app_, set_show_command(msg_params)); command->Run(); @@ -321,7 +321,7 @@ TEST_F(ShowRequestTest, Run_SoftButtonExists_Canceled) { EXPECT_CALL(mock_message_helper_, SubscribeApplicationToSoftButton(_, _, _)) .Times(0); - EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_)).Times(0); + EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_, _)).Times(0); EXPECT_CALL(*mock_app_, set_show_command(_)).Times(0); command->Run(); @@ -348,7 +348,7 @@ TEST_F(ShowRequestTest, Run_Graphic_SUCCESS) { msg_params[am::hmi_request::show_strings] = smart_objects::SmartObject(smart_objects::SmartType_Array); - EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_)); + EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_, _)); EXPECT_CALL(*mock_app_, set_show_command(msg_params)); command->Run(); @@ -375,7 +375,7 @@ TEST_F(ShowRequestTest, Run_Graphic_WARNINGS) { msg_params[am::hmi_request::show_strings] = smart_objects::SmartObject(smart_objects::SmartType_Array); - EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_)); + EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_, _)); EXPECT_CALL(*mock_app_, set_show_command(msg_params)); command->Run(); @@ -398,7 +398,7 @@ TEST_F(ShowRequestTest, Run_Graphic_Canceled) { .WillOnce(Return(mobile_apis::Result::INVALID_DATA)); EXPECT_CALL(mock_rpc_service_, ManageMobileCommand(_, _)); EXPECT_CALL(*mock_app_, app_id()).Times(0); - EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_)).Times(0); + EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_, _)).Times(0); EXPECT_CALL(*mock_app_, set_show_command(msg_params)).Times(0); command->Run(); @@ -421,7 +421,7 @@ TEST_F(ShowRequestTest, Run_Graphic_WrongSyntax) { EXPECT_CALL(mock_rpc_service_, ManageMobileCommand(_, _)); EXPECT_CALL(*mock_app_, app_id()).Times(0); - EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_)).Times(0); + EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_, _)).Times(0); EXPECT_CALL(*mock_app_, set_show_command(msg_params)).Times(0); command->Run(); @@ -447,7 +447,7 @@ TEST_F(ShowRequestTest, Run_SecondaryGraphic_SUCCESS) { msg_params[am::strings::app_id] = kAppId; msg_params[am::hmi_request::show_strings] = smart_objects::SmartObject(smart_objects::SmartType_Array); - EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_)); + EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_, _)); EXPECT_CALL(*mock_app_, set_show_command(msg_params)); command->Run(); @@ -473,7 +473,7 @@ TEST_F(ShowRequestTest, Run_SecondaryGraphic_WARNINGS) { msg_params[am::strings::app_id] = kAppId; msg_params[am::hmi_request::show_strings] = smart_objects::SmartObject(smart_objects::SmartType_Array); - EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_)); + EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_, _)); EXPECT_CALL(*mock_app_, set_show_command(msg_params)); command->Run(); @@ -497,7 +497,7 @@ TEST_F(ShowRequestTest, Run_SecondaryGraphic_Canceled) { EXPECT_CALL(mock_rpc_service_, ManageMobileCommand(_, _)); EXPECT_CALL(*mock_app_, app_id()).Times(0); - EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_)).Times(0); + EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_, _)).Times(0); EXPECT_CALL(*mock_app_, set_show_command(msg_params)).Times(0); command->Run(); @@ -520,7 +520,7 @@ TEST_F(ShowRequestTest, Run_SecondaryGraphic_WrongSyntax) { EXPECT_CALL(mock_rpc_service_, ManageMobileCommand(_, _)); EXPECT_CALL(*mock_app_, app_id()).Times(0); - EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_)).Times(0); + EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_, _)).Times(0); EXPECT_CALL(*mock_app_, set_show_command(msg_params)).Times(0); command->Run(); @@ -836,7 +836,7 @@ TEST_F(ShowRequestTest, Run_Alignment_SUCCESS) { msg_params[am::hmi_request::show_strings] = smart_objects::SmartObject(smart_objects::SmartType_Array); - EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_)); + EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_, _)); EXPECT_CALL(*mock_app_, set_show_command(msg_params)); command->Run(); @@ -859,7 +859,7 @@ TEST_F(ShowRequestTest, Run_CustomPresets_SUCCESS) { msg_params[am::strings::app_id] = kAppId; msg_params[am::hmi_request::show_strings] = smart_objects::SmartObject(smart_objects::SmartType_Array); - EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_)); + EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_, _)); EXPECT_CALL(*mock_app_, set_show_command(msg_params)); command->Run(); @@ -880,7 +880,7 @@ TEST_F(ShowRequestTest, Run_CustomPresets_WrongSyntax) { EXPECT_CALL(mock_rpc_service_, ManageMobileCommand(_, _)); EXPECT_CALL(*mock_app_, app_id()).Times(0); - EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_)).Times(0); + EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_, _)).Times(0); EXPECT_CALL(*mock_app_, set_show_command(_)).Times(0); command->Run(); @@ -895,7 +895,7 @@ TEST_F(ShowRequestTest, Run_InvalidApp_Canceled) { .WillOnce(Return(MockAppPtr())); EXPECT_CALL(mock_rpc_service_, ManageMobileCommand(_, _)); EXPECT_CALL(*mock_app_, app_id()).Times(0); - EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_)).Times(0); + EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_, _)).Times(0); EXPECT_CALL(*mock_app_, set_show_command(_)).Times(0); command->Run(); @@ -910,7 +910,7 @@ TEST_F(ShowRequestTest, Run_EmptyParams_Canceled) { .WillOnce(Return(mock_app_)); EXPECT_CALL(mock_rpc_service_, ManageMobileCommand(_, _)); EXPECT_CALL(*mock_app_, app_id()).Times(0); - EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_)).Times(0); + EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_, _)).Times(0); EXPECT_CALL(*mock_app_, set_show_command(_)).Times(0); command->Run(); diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/slider_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/slider_test.cc index be14aebc8f..14e670a387 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/slider_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/slider_test.cc @@ -268,7 +268,7 @@ TEST_F(SliderRequestTest, Run_SUCCESS) { EXPECT_CALL( mock_rpc_service_, - ManageHMICommand(HMIResultCodeIs(hmi_apis::FunctionID::UI_Slider))); + ManageHMICommand(HMIResultCodeIs(hmi_apis::FunctionID::UI_Slider), _)); CommandPtr command(CreateCommand(msg_)); command->Run(); diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/speak_request_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/speak_request_test.cc index 9eb23eeee3..5dcbd7e6b9 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/speak_request_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/speak_request_test.cc @@ -295,7 +295,7 @@ TEST_F(SpeakRequestTest, Run_MsgWithEmptyString_Success) { EXPECT_CALL( mock_rpc_service_, - ManageHMICommand(HMIResultCodeIs(hmi_apis::FunctionID::TTS_Speak))); + ManageHMICommand(HMIResultCodeIs(hmi_apis::FunctionID::TTS_Speak), _)); command->Run(); } @@ -315,7 +315,7 @@ TEST_F(SpeakRequestTest, Run_MsgCorrect_Success) { EXPECT_CALL( mock_rpc_service_, - ManageHMICommand(HMIResultCodeIs(hmi_apis::FunctionID::TTS_Speak))); + ManageHMICommand(HMIResultCodeIs(hmi_apis::FunctionID::TTS_Speak), _)); command->Run(); } diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/subscribe_button_request_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/subscribe_button_request_test.cc index caca56e297..df3e778ee6 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/subscribe_button_request_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/subscribe_button_request_test.cc @@ -182,7 +182,7 @@ TEST_F(SubscribeButtonRequestTest, Run_SUCCESS) { MessageSharedPtr hmi_result_msg; - EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_)) + EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_, _)) .WillOnce(DoAll(SaveArg<0>(&hmi_result_msg), Return(true))); MessageSharedPtr mobile_result_msg; @@ -230,7 +230,7 @@ TEST_F(SubscribeButtonRequestTest, Run_SUCCESS_App_Base_RPC_Version) { MessageSharedPtr hmi_result_msg; - EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_)) + EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_, _)) .WillOnce(DoAll(SaveArg<0>(&hmi_result_msg), Return(true))); MessageSharedPtr mobile_result_msg; diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/system_request_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/system_request_test.cc index 9e6bc8f505..298661dc74 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/system_request_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/system_request_test.cc @@ -160,7 +160,7 @@ TEST_F(SystemRequestTest, .WillOnce(Return(mobile_apis::Result::SUCCESS)); smart_objects::SmartObjectSPtr result; - EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_)) + EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_, _)) .WillOnce(DoAll(SaveArg<0>(&result), Return(true))); std::shared_ptr command(CreateCommand(msg)); @@ -201,7 +201,7 @@ TEST_F( .WillOnce(Return(false)); ExpectManageMobileCommandWithResultCode(mobile_apis::Result::DISALLOWED); - EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_)).Times(0); + EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_, _)).Times(0); std::shared_ptr command(CreateCommand(msg)); ASSERT_TRUE(command->Init()); @@ -222,7 +222,7 @@ TEST_F(SystemRequestTest, Run_RequestTypeDisallowed_SendDisallowedResponse) { .WillOnce(Return(false)); ExpectManageMobileCommandWithResultCode(mobile_apis::Result::DISALLOWED); - EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_)).Times(0); + EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_, _)).Times(0); std::shared_ptr command(CreateCommand(msg)); ASSERT_TRUE(command->Init()); diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/unsubscribe_button_request_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/unsubscribe_button_request_test.cc index a848fff2b2..22893b771c 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/unsubscribe_button_request_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/unsubscribe_button_request_test.cc @@ -139,9 +139,11 @@ TEST_F(UnsubscribeButtonRequestTest, Run_SUCCESS) { EXPECT_CALL(*mock_app, UnsubscribeFromButton(kButtonId)) .WillOnce(Return(true)); - EXPECT_CALL(mock_rpc_service_, - ManageHMICommand(HMIResultCodeIs( - hmi_apis::FunctionID::Buttons_OnButtonSubscription))); + EXPECT_CALL( + mock_rpc_service_, + ManageHMICommand( + HMIResultCodeIs(hmi_apis::FunctionID::Buttons_OnButtonSubscription), + _)); EXPECT_CALL( mock_rpc_service_, ManageMobileCommand(MobileResultCodeIs(mobile_result::SUCCESS), _)); @@ -182,9 +184,11 @@ TEST_F(UnsubscribeButtonRequestTest, Run_SUCCESS_Base_RPC_Version) { EXPECT_CALL(*mock_app, UnsubscribeFromButton(mobile_apis::ButtonName::PLAY_PAUSE)) .WillOnce(Return(true)); - EXPECT_CALL(mock_rpc_service_, - ManageHMICommand(HMIResultCodeIs( - hmi_apis::FunctionID::Buttons_OnButtonSubscription))); + EXPECT_CALL( + mock_rpc_service_, + ManageHMICommand( + HMIResultCodeIs(hmi_apis::FunctionID::Buttons_OnButtonSubscription), + _)); EXPECT_CALL( mock_rpc_service_, ManageMobileCommand(MobileResultCodeIs(mobile_result::SUCCESS), _)); diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/unsubscribe_way_points_request_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/unsubscribe_way_points_request_test.cc index f345d719c6..818ee06e96 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/unsubscribe_way_points_request_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/unsubscribe_way_points_request_test.cc @@ -123,8 +123,10 @@ TEST_F(UnsubscribeWayPointsRequestTest, Run_AppSubscribedForWayPoints_SUCCESS) { .WillOnce(Return(true)); EXPECT_CALL(mock_rpc_service_, - ManageHMICommand(HMIResultCodeIs( - hmi_apis::FunctionID::Navigation_UnsubscribeWayPoints))); + ManageHMICommand( + HMIResultCodeIs( + hmi_apis::FunctionID::Navigation_UnsubscribeWayPoints), + _)); command_->Run(); } diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/vehicle_info_command_factory.cc b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/vehicle_info_command_factory.cc index 32959174da..0c6e0a07b1 100644 --- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/vehicle_info_command_factory.cc +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/vehicle_info_command_factory.cc @@ -53,7 +53,8 @@ VehicleInfoCommandFactory::~VehicleInfoCommandFactory() {} app_mngr::CommandSharedPtr VehicleInfoCommandFactory::CreateCommand( const app_mngr::commands::MessageSharedPtr& message, app_mngr::commands::Command::CommandSource source) { - if (app_mngr::commands::Command::SOURCE_HMI == source) { + if (app_mngr::commands::Command::SOURCE_HMI == source || + app_mngr::commands::Command::SOURCE_SDL_TO_HMI == source) { return hmi_command_factory_->CreateCommand(message, source); } else { return mob_command_factory_->CreateCommand(message, source); @@ -63,7 +64,8 @@ app_mngr::CommandSharedPtr VehicleInfoCommandFactory::CreateCommand( bool VehicleInfoCommandFactory::IsAbleToProcess( const int32_t function_id, const commands::Command::CommandSource source) const { - return commands::Command::SOURCE_HMI == source + return (commands::Command::SOURCE_HMI == source || + app_mngr::commands::Command::SOURCE_SDL_TO_HMI == source) ? hmi_command_factory_->IsAbleToProcess(function_id, source) : mob_command_factory_->IsAbleToProcess(function_id, source); } diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/commands/hmi/vi_is_ready_request_test.cc b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/commands/hmi/vi_is_ready_request_test.cc index d4477d5d5f..679d9d0e58 100644 --- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/commands/hmi/vi_is_ready_request_test.cc +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/commands/hmi/vi_is_ready_request_test.cc @@ -101,7 +101,7 @@ class VIIsReadyRequestTest mock_message_helper_, CreateModuleInfoSO(hmi_apis::FunctionID::VehicleInfo_GetVehicleType, _)) .WillOnce(Return(ivi_type)); - EXPECT_CALL(mock_rpc_service_, ManageHMICommand(ivi_type)); + EXPECT_CALL(mock_rpc_service_, ManageHMICommand(ivi_type, _)); } void PrepareEvent(bool is_message_contain_param, diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/commands/mobile/diagnostic_message_request_test.cc b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/commands/mobile/diagnostic_message_request_test.cc index 9cdf60b1ea..b27a306a5c 100644 --- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/commands/mobile/diagnostic_message_request_test.cc +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/commands/mobile/diagnostic_message_request_test.cc @@ -141,9 +141,11 @@ TEST_F(DiagnosticMessageRequestTest, Run_SUCCESS) { EXPECT_CALL(app_mngr_settings_, supported_diag_modes()) .WillOnce(ReturnRef(supported_diag_modes)); - EXPECT_CALL(mock_rpc_service_, - ManageHMICommand(HMIResultCodeIs( - hmi_apis::FunctionID::VehicleInfo_DiagnosticMessage))); + EXPECT_CALL( + mock_rpc_service_, + ManageHMICommand( + HMIResultCodeIs(hmi_apis::FunctionID::VehicleInfo_DiagnosticMessage), + _)); command->Run(); } diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/commands/mobile/get_dtcs_request_test.cc b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/commands/mobile/get_dtcs_request_test.cc index 4473a36c63..981d649a94 100644 --- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/commands/mobile/get_dtcs_request_test.cc +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/commands/mobile/get_dtcs_request_test.cc @@ -98,9 +98,10 @@ TEST_F(GetDTCsRequestTest, Run_SUCCESS) { MockAppPtr app(CreateMockApp()); EXPECT_CALL(app_mngr_, application(kConnectionKey)).WillOnce(Return(app)); - EXPECT_CALL(mock_rpc_service_, - ManageHMICommand( - HMIResultCodeIs(hmi_apis::FunctionID::VehicleInfo_GetDTCs))); + EXPECT_CALL( + mock_rpc_service_, + ManageHMICommand( + HMIResultCodeIs(hmi_apis::FunctionID::VehicleInfo_GetDTCs), _)); command->Run(); } diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/commands/mobile/get_vehicle_data_request_test.cc b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/commands/mobile/get_vehicle_data_request_test.cc index a88d362968..cb78e44904 100644 --- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/commands/mobile/get_vehicle_data_request_test.cc +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/commands/mobile/get_vehicle_data_request_test.cc @@ -200,9 +200,11 @@ TEST_F(GetVehicleDataRequestTest, Run_SUCCESS) { MockAppPtr app(CreateMockApp()); EXPECT_CALL(app_mngr_, application(kConnectionKey)).WillOnce(Return(app)); - EXPECT_CALL(mock_rpc_service_, - ManageHMICommand(HMIResultCodeIs( - hmi_apis::FunctionID::VehicleInfo_GetVehicleData))); + EXPECT_CALL( + mock_rpc_service_, + ManageHMICommand( + HMIResultCodeIs(hmi_apis::FunctionID::VehicleInfo_GetVehicleData), + _)); command->Run(); } diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/commands/mobile/unsubscribe_vehicle_request_test.cc b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/commands/mobile/unsubscribe_vehicle_request_test.cc index 323334de2d..165c7694b1 100644 --- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/commands/mobile/unsubscribe_vehicle_request_test.cc +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/commands/mobile/unsubscribe_vehicle_request_test.cc @@ -149,9 +149,10 @@ TEST_F(UnsubscribeVehicleRequestTest, .WillOnce(Return(mock_app_)); EXPECT_CALL(mock_rpc_service_, - ManageHMICommand(HMIResultCodeIs( - hmi_apis::FunctionID::VehicleInfo_UnsubscribeVehicleData))) - .WillOnce(Return(true)); + ManageHMICommand( + HMIResultCodeIs( + hmi_apis::FunctionID::VehicleInfo_UnsubscribeVehicleData), + _)).WillOnce(Return(true)); vehicle_info_plugin::VehicleInfoAppExtension* vi_app_extension = dynamic_cast( vi_app_extension_ptr_.get()); diff --git a/src/components/application_manager/src/app_service_manager.cc b/src/components/application_manager/src/app_service_manager.cc index bc9d363839..8250109023 100644 --- a/src/components/application_manager/src/app_service_manager.cc +++ b/src/components/application_manager/src/app_service_manager.cc @@ -46,6 +46,8 @@ #include "resumption/last_state.h" #include "utils/logger.h" +#include "smart_objects/enum_schema_item.h" + CREATE_LOGGERPTR_GLOBAL(logger_, "AppServiceManager") namespace application_manager { @@ -178,6 +180,39 @@ std::vector AppServiceManager::GetAllServices() { return services; } +void AppServiceManager::GetProvider(const std::string& service_type, + ApplicationSharedPtr& app, + bool& hmi_service) { + LOG4CXX_AUTO_TRACE(logger_); + auto service_it = published_services_.begin(); + auto end = published_services_.end(); + + for (; service_it != end; ++service_it) { + auto service = service_it->second; + auto record = service_it->second.record; + if (record[strings::service_published].asBool() == false || + record[strings::service_active].asBool() == false) { + continue; + } + + std::string record_service_type = + record[strings::service_manifest][strings::service_type].asString(); + + if (record_service_type == service_type) { + LOG4CXX_DEBUG(logger_, + "Found provider for service type: " << service_type); + bool mobile_service = service.mobile_service; + if (mobile_service) { + app = app_manager_.application(service.connection_key); + hmi_service = false; + return; + } + hmi_service = true; + return; + } + } +} + bool AppServiceManager::SetDefaultService(const std::string service_id) { LOG4CXX_AUTO_TRACE(logger_); auto it = published_services_.find(service_id); diff --git a/src/components/application_manager/src/application_manager_impl.cc b/src/components/application_manager/src/application_manager_impl.cc index 6298d547d7..7fd2bd1995 100644 --- a/src/components/application_manager/src/application_manager_impl.cc +++ b/src/components/application_manager/src/application_manager_impl.cc @@ -132,6 +132,7 @@ bool policy_app_id_comparator(const std::string& policy_app_id, return app->policy_app_id() == policy_app_id; } +uint32_t ApplicationManagerImpl::mobile_corelation_id_ = 0; uint32_t ApplicationManagerImpl::corelation_id_ = 0; const uint32_t ApplicationManagerImpl::max_corelation_id_ = UINT_MAX; @@ -1013,6 +1014,16 @@ ApplicationManagerImpl::GetCloudAppConnectionStatus( } } +uint32_t ApplicationManagerImpl::GetNextMobileCorrelationID() { + if (mobile_corelation_id_ < max_corelation_id_) { + mobile_corelation_id_++; + } else { + mobile_corelation_id_ = 0; + } + + return mobile_corelation_id_; +} + uint32_t ApplicationManagerImpl::GetNextHMICorrelationID() { if (corelation_id_ < max_corelation_id_) { corelation_id_++; diff --git a/src/components/application_manager/src/commands/command_notification_from_mobile_impl.cc b/src/components/application_manager/src/commands/command_notification_from_mobile_impl.cc index 4e9a2556de..f9b084323a 100644 --- a/src/components/application_manager/src/commands/command_notification_from_mobile_impl.cc +++ b/src/components/application_manager/src/commands/command_notification_from_mobile_impl.cc @@ -75,6 +75,30 @@ void CommandNotificationFromMobileImpl::SendNotification() { rpc_service_.SendMessageToMobile(message_); } +void CommandNotificationFromMobileImpl::SendNotificationToMobile() { + auto app = application_manager_.application(connection_key()); + (*message_)[strings::params][strings::protocol_type] = mobile_protocol_type_; + (*message_)[strings::params][strings::protocol_version] = + app->protocol_version(); + (*message_)[strings::params][strings::message_type] = + static_cast(application_manager::MessageType::kNotification); + + rpc_service_.ManageMobileCommand(message_, SOURCE_SDL); +} + +void CommandNotificationFromMobileImpl::SendNotificationToHMI( + const hmi_apis::FunctionID::eType& hmi_function_id) { + (*message_)[strings::params][strings::protocol_type] = hmi_protocol_type_; + (*message_)[strings::params][strings::function_id] = hmi_function_id; + rpc_service_.SendMessageToHMI(message_); +} + +void CommandNotificationFromMobileImpl::SendNotificationToConsumers( + const hmi_apis::FunctionID::eType& hmi_function_id) { + SendNotificationToMobile(); + SendNotificationToHMI(hmi_function_id); +} + } // namespace commands } // namespace application_manager diff --git a/src/components/application_manager/src/commands/command_request_impl.cc b/src/components/application_manager/src/commands/command_request_impl.cc index 68e8cfe6b4..cc956df019 100644 --- a/src/components/application_manager/src/commands/command_request_impl.cc +++ b/src/components/application_manager/src/commands/command_request_impl.cc @@ -41,6 +41,8 @@ #include "application_manager/message_helper.h" #include "smart_objects/smart_object.h" +#include "smart_objects/enum_schema_item.h" + namespace application_manager { namespace commands { @@ -233,7 +235,7 @@ void CommandRequestImpl::Run() {} void CommandRequestImpl::onTimeOut() { LOG4CXX_AUTO_TRACE(logger_); - unsubscribe_from_all_events(); + unsubscribe_from_all_hmi_events(); { // FIXME (dchmerev@luxoft.com): atomic_xchg fits better sync_primitives::AutoLock auto_lock(state_lock_); @@ -257,6 +259,8 @@ void CommandRequestImpl::onTimeOut() { void CommandRequestImpl::on_event(const event_engine::Event& event) {} +void CommandRequestImpl::on_event(const event_engine::MobileEvent& event) {} + void CommandRequestImpl::SendResponse( const bool success, const mobile_apis::Result::eType& result_code, @@ -414,6 +418,74 @@ void CommandRequestImpl::UpdateHash() { application->UpdateHash(); } +void CommandRequestImpl::SendProviderRequest( + const mobile_apis::FunctionID::eType& mobile_function_id, + const hmi_apis::FunctionID::eType& hmi_function_id, + const smart_objects::SmartObject* msg, + bool use_events) { + std::string service_type = + (*msg)[strings::msg_params][strings::service_type].asString(); + + bool hmi_destination = false; + ApplicationSharedPtr app; + application_manager_.GetAppServiceManager().GetProvider( + service_type, app, hmi_destination); + + if (hmi_destination) { + LOG4CXX_DEBUG(logger_, "Sending Request to HMI Provider"); + SendHMIRequest(hmi_function_id, &(*msg)[strings::msg_params], use_events); + return; + } + + if (!app) { + LOG4CXX_DEBUG(logger_, "Invalid App Provider pointer"); + SendResponse(false, + mobile_apis::Result::DATA_NOT_AVAILABLE, + "No app service provider available"); + return; + } + + if (connection_key() == app->app_id()) { + SendResponse(false, + mobile_apis::Result::IGNORED, + "Consumer app is same as producer app"); + return; + } + + smart_objects::SmartObjectSPtr new_msg = + std::make_shared(); + smart_objects::SmartObject& request = *new_msg; + + request[strings::params] = (*msg)[strings::params]; + request[strings::msg_params] = (*msg)[strings::msg_params]; + request[strings::params][strings::connection_key] = app->app_id(); + + SendMobileRequest(mobile_function_id, new_msg, use_events); +} + +void CommandRequestImpl::SendMobileRequest( + const mobile_apis::FunctionID::eType& function_id, + smart_objects::SmartObjectSPtr msg, + bool use_events) { + smart_objects::SmartObject& request = *msg; + + const uint32_t mobile_correlation_id = + application_manager_.GetNextMobileCorrelationID(); + + request[strings::params][strings::correlation_id] = mobile_correlation_id; + request[strings::params][strings::message_type] = MessageType::kRequest; + if (use_events) { + LOG4CXX_DEBUG(logger_, + "SendMobileRequest subscribe_on_event " + << function_id << " " << mobile_correlation_id); + subscribe_on_event(function_id, mobile_correlation_id); + } + + if (!rpc_service_.ManageMobileCommand(msg, SOURCE_SDL)) { + LOG4CXX_ERROR(logger_, "Unable to send request to mobile"); + } +} + uint32_t CommandRequestImpl::SendHMIRequest( const hmi_apis::FunctionID::eType& function_id, const smart_objects::SmartObject* msg_params, @@ -439,12 +511,12 @@ uint32_t CommandRequestImpl::SendHMIRequest( if (use_events) { LOG4CXX_DEBUG(logger_, - "subscribe_on_event " << function_id << " " - << hmi_correlation_id); + "SendHMIRequest subscribe_on_event " << function_id << " " + << hmi_correlation_id); subscribe_on_event(function_id, hmi_correlation_id); } if (ProcessHMIInterfacesAvailability(hmi_correlation_id, function_id)) { - if (!rpc_service_.ManageHMICommand(result)) { + if (!rpc_service_.ManageHMICommand(result, SOURCE_SDL_TO_HMI)) { LOG4CXX_ERROR(logger_, "Unable to send request"); SendResponse(false, mobile_apis::Result::OUT_OF_MEMORY); } @@ -474,7 +546,7 @@ void CommandRequestImpl::CreateHMINotification( notify[strings::params][strings::function_id] = function_id; notify[strings::msg_params] = msg_params; - if (!rpc_service_.ManageHMICommand(result)) { + if (!rpc_service_.ManageHMICommand(result, SOURCE_SDL_TO_HMI)) { LOG4CXX_ERROR(logger_, "Unable to send HMI notification"); } } @@ -811,6 +883,19 @@ bool CommandRequestImpl::HasDisallowedParams() const { (!removed_parameters_permissions_.undefined_params.empty())); } +bool CommandRequestImpl::IsMobileResultSuccess( + mobile_apis::Result::eType result_code) const { + LOG4CXX_AUTO_TRACE(logger_); + using namespace helpers; + return Compare( + result_code, + mobile_apis::Result::SUCCESS, + mobile_apis::Result::WARNINGS, + mobile_apis::Result::WRONG_LANGUAGE, + mobile_apis::Result::RETRY, + mobile_apis::Result::SAVED); +} + bool CommandRequestImpl::PrepareResultForMobileResponse( hmi_apis::Common_Result::eType result_code, HmiInterfaces::InterfaceID interface) const { diff --git a/src/components/application_manager/src/commands/command_request_to_mobile.cc b/src/components/application_manager/src/commands/command_request_to_mobile.cc new file mode 100644 index 0000000000..e1ed06e887 --- /dev/null +++ b/src/components/application_manager/src/commands/command_request_to_mobile.cc @@ -0,0 +1,72 @@ +/* + Copyright (c) 2014, 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 "application_manager/commands/command_request_to_mobile.h" +#include "application_manager/rpc_service.h" + +namespace application_manager { + +namespace commands { + +CommandRequestToMobile::CommandRequestToMobile( + const MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handler) + : CommandImpl(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handler) {} + +CommandRequestToMobile::~CommandRequestToMobile() {} + +bool CommandRequestToMobile::Init() { + return true; +} + +bool CommandRequestToMobile::CleanUp() { + return true; +} + +void CommandRequestToMobile::Run() { + SendRequest(); +} + +void CommandRequestToMobile::SendRequest() { + rpc_service_.SendMessageToMobile(message_); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/src/commands/command_response_from_mobile.cc b/src/components/application_manager/src/commands/command_response_from_mobile.cc new file mode 100644 index 0000000000..dfed65b134 --- /dev/null +++ b/src/components/application_manager/src/commands/command_response_from_mobile.cc @@ -0,0 +1,71 @@ +/* + Copyright (c) 2013, 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 "application_manager/commands/command_response_from_mobile.h" +#include "application_manager/rpc_service.h" +#include "smart_objects/smart_object.h" + +namespace application_manager { + +namespace commands { + +CommandResponseFromMobile::CommandResponseFromMobile( + const MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle) + : CommandImpl(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handle) {} + +CommandResponseFromMobile::~CommandResponseFromMobile() {} + +bool CommandResponseFromMobile::Init() { + return true; +} + +bool CommandResponseFromMobile::CleanUp() { + return true; +} + +void CommandResponseFromMobile::Run() {} + +void CommandResponseFromMobile::SendResponse() { + rpc_service_.ManageMobileCommand(message_, SOURCE_SDL); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/src/commands/notification_from_hmi.cc b/src/components/application_manager/src/commands/notification_from_hmi.cc index 75e49b180e..b6bb8d4e3c 100644 --- a/src/components/application_manager/src/commands/notification_from_hmi.cc +++ b/src/components/application_manager/src/commands/notification_from_hmi.cc @@ -73,6 +73,20 @@ void NotificationFromHMI::SendNotificationToMobile( rpc_service_.ManageMobileCommand(message, SOURCE_SDL); } +void NotificationFromHMI::SendNotificationToMobile( + const MessageSharedPtr& message, + const mobile_apis::FunctionID::eType& mobile_function_id) { + (*message)[strings::params][strings::message_type] = + static_cast(application_manager::MessageType::kNotification); + (*message)[strings::params][strings::function_id] = mobile_function_id; + rpc_service_.ManageMobileCommand(message, SOURCE_SDL); +} + +void NotificationFromHMI::SendNotificationToHMI(MessageSharedPtr& message) { + (*message)[strings::params][strings::protocol_type] = hmi_protocol_type_; + rpc_service_.SendMessageToHMI(message); +} + void NotificationFromHMI::CreateHMIRequest( const hmi_apis::FunctionID::eType& function_id, const smart_objects::SmartObject& msg_params) const { @@ -106,6 +120,12 @@ void NotificationFromHMI::CreateHMIRequest( } } +void NotificationFromHMI::SendNotificationToConsumers( + const mobile_apis::FunctionID::eType& mobile_function_id) { + SendNotificationToHMI(message_); + SendNotificationToMobile(message_, mobile_function_id); +} + } // namespace commands } // namespace application_manager diff --git a/src/components/application_manager/src/commands/request_from_hmi.cc b/src/components/application_manager/src/commands/request_from_hmi.cc index 0a6865457e..d97694276e 100644 --- a/src/components/application_manager/src/commands/request_from_hmi.cc +++ b/src/components/application_manager/src/commands/request_from_hmi.cc @@ -34,6 +34,8 @@ #include "application_manager/application_manager.h" #include "application_manager/rpc_service.h" +#include "smart_objects/enum_schema_item.h" + namespace application_manager { namespace commands { @@ -67,12 +69,15 @@ void RequestFromHMI::Run() {} void RequestFromHMI::on_event(const event_engine::Event& event) {} +void RequestFromHMI::on_event(const event_engine::MobileEvent& event) {} + void RequestFromHMI::SendResponse( const bool success, const uint32_t correlation_id, const hmi_apis::FunctionID::eType function_id, const hmi_apis::Common_Result::eType result_code, - const smart_objects::SmartObject* response_params) { + const smart_objects::SmartObject* response_params, + commands::Command::CommandSource source) { smart_objects::SmartObjectSPtr message = std::make_shared( smart_objects::SmartType_Map); @@ -86,7 +91,7 @@ void RequestFromHMI::SendResponse( (*message)[strings::msg_params] = *response_params; } - rpc_service_.ManageHMICommand(message); + rpc_service_.ManageHMICommand(message, source); } void RequestFromHMI::SendErrorResponse( @@ -116,5 +121,161 @@ void RequestFromHMI::FillCommonParametersOfSO( (message)[strings::params][strings::correlation_id] = correlation_id; } +bool RequestFromHMI::IsMobileResultSuccess( + mobile_apis::Result::eType result_code) const { + LOG4CXX_AUTO_TRACE(logger_); + using namespace helpers; + return Compare( + result_code, + mobile_apis::Result::SUCCESS, + mobile_apis::Result::WARNINGS, + mobile_apis::Result::WRONG_LANGUAGE, + mobile_apis::Result::RETRY, + mobile_apis::Result::SAVED); +} + +bool RequestFromHMI::IsHMIResultSuccess( + hmi_apis::Common_Result::eType result_code, + HmiInterfaces::InterfaceID interface) const { + LOG4CXX_AUTO_TRACE(logger_); + using namespace helpers; + if (Compare( + result_code, + hmi_apis::Common_Result::SUCCESS, + hmi_apis::Common_Result::WARNINGS, + hmi_apis::Common_Result::WRONG_LANGUAGE, + hmi_apis::Common_Result::RETRY, + hmi_apis::Common_Result::SAVED)) { + return true; + } + + const HmiInterfaces::InterfaceState state = + application_manager_.hmi_interfaces().GetInterfaceState(interface); + if ((hmi_apis::Common_Result::UNSUPPORTED_RESOURCE == result_code) && + (HmiInterfaces::STATE_NOT_AVAILABLE != state)) { + return true; + } + return false; +} + +void RequestFromHMI::SendProviderRequest( + const mobile_apis::FunctionID::eType& mobile_function_id, + const hmi_apis::FunctionID::eType& hmi_function_id, + const smart_objects::SmartObject* msg, + bool use_events) { + std::string service_type = + (*msg)[strings::msg_params][strings::service_type].asString(); + + bool hmi_destination = false; + ApplicationSharedPtr app; + application_manager_.GetAppServiceManager().GetProvider( + service_type, app, hmi_destination); + + if (hmi_destination) { + LOG4CXX_DEBUG(logger_, "Sending Request to HMI Provider"); + SendHMIRequest(hmi_function_id, &(*msg)[strings::msg_params], use_events); + return; + } + + if (!app) { + LOG4CXX_DEBUG(logger_, "Invalid App Provider pointer"); + return; + } + LOG4CXX_DEBUG(logger_, "Sending Request to Mobile Provider"); + SendMobileRequest( + mobile_function_id, app, &(*msg)[strings::msg_params], use_events); +} + +void RequestFromHMI::SendMobileRequest( + const mobile_apis::FunctionID::eType& function_id, + const ApplicationSharedPtr app, + const smart_objects::SmartObject* msg_params, + bool use_events) { + smart_objects::SmartObjectSPtr result = + std::make_shared(); + + const uint32_t mobile_correlation_id = + application_manager_.GetNextMobileCorrelationID(); + + smart_objects::SmartObject& request = *result; + + request[strings::params][strings::message_type] = MessageType::kRequest; + request[strings::params][strings::function_id] = function_id; + request[strings::params][strings::correlation_id] = mobile_correlation_id; + request[strings::params][strings::protocol_version] = app->protocol_version(); + request[strings::params][strings::protocol_type] = + CommandImpl::mobile_protocol_type_; + + request[strings::params][strings::connection_key] = app->app_id(); + + if (msg_params) { + request[strings::msg_params] = *msg_params; + } + + if (use_events) { + LOG4CXX_DEBUG(logger_, + "RequestFromHMI subscribe_on_event " + << function_id << " " << mobile_correlation_id); + subscribe_on_event(function_id, mobile_correlation_id); + } + if (!rpc_service_.ManageMobileCommand( + result, commands::Command::CommandSource::SOURCE_SDL)) { + LOG4CXX_ERROR(logger_, "Unable to send request to mobile"); + } +} + +void RequestFromHMI::SendHMIRequest( + const hmi_apis::FunctionID::eType& function_id, + const smart_objects::SmartObject* msg_params, + bool use_events) { + smart_objects::SmartObjectSPtr result = + std::make_shared(); + + const uint32_t hmi_correlation_id = + application_manager_.GetNextHMICorrelationID(); + + smart_objects::SmartObject& request = *result; + request[strings::params][strings::message_type] = MessageType::kRequest; + request[strings::params][strings::function_id] = function_id; + request[strings::params][strings::correlation_id] = hmi_correlation_id; + request[strings::params][strings::protocol_type] = + CommandImpl::hmi_protocol_type_; + + if (msg_params) { + request[strings::msg_params] = *msg_params; + } + + if (use_events) { + LOG4CXX_DEBUG(logger_, + "RequestFromHMI subscribe_on_event " << function_id << " " + << hmi_correlation_id); + subscribe_on_event(function_id, hmi_correlation_id); + } + if (ProcessHMIInterfacesAvailability(hmi_correlation_id, function_id)) { + if (!rpc_service_.ManageHMICommand( + result, commands::Command::CommandSource::SOURCE_SDL_TO_HMI)) { + LOG4CXX_ERROR(logger_, "Unable to send request"); + } + } else { + LOG4CXX_DEBUG(logger_, "Interface is not available"); + } +} + +bool RequestFromHMI::ProcessHMIInterfacesAvailability( + const uint32_t hmi_correlation_id, + const hmi_apis::FunctionID::eType& function_id) { + LOG4CXX_AUTO_TRACE(logger_); + HmiInterfaces& hmi_interfaces = application_manager_.hmi_interfaces(); + HmiInterfaces::InterfaceID interface = + hmi_interfaces.GetInterfaceFromFunction(function_id); + DCHECK(interface != HmiInterfaces::HMI_INTERFACE_INVALID_ENUM); + const HmiInterfaces::InterfaceState state = + hmi_interfaces.GetInterfaceState(interface); + if (HmiInterfaces::STATE_NOT_AVAILABLE == state) { + return false; + } + return true; +} + } // namespace commands } // namespace application_manager diff --git a/src/components/application_manager/src/event_engine/event.cc b/src/components/application_manager/src/event_engine/event.cc index cc180ca950..ecdeb41a2e 100644 --- a/src/components/application_manager/src/event_engine/event.cc +++ b/src/components/application_manager/src/event_engine/event.cc @@ -48,5 +48,17 @@ void Event::set_smart_object(const smart_objects::SmartObject& so) { response_so_ = so; } +MobileEvent::MobileEvent(const MobileEventID& id) : id_(id), response_so_() {} + +MobileEvent::~MobileEvent() {} + +void MobileEvent::raise(EventDispatcher& event_dispatcher) { + event_dispatcher.raise_mobile_event(*this); +} + +void MobileEvent::set_smart_object(const smart_objects::SmartObject& so) { + response_so_ = so; +} + } // namespace event_engine } // namespace application_manager diff --git a/src/components/application_manager/src/event_engine/event_dispatcher_impl.cc b/src/components/application_manager/src/event_engine/event_dispatcher_impl.cc index f1e5bf9735..3f3cfae1d3 100644 --- a/src/components/application_manager/src/event_engine/event_dispatcher_impl.cc +++ b/src/components/application_manager/src/event_engine/event_dispatcher_impl.cc @@ -122,5 +122,77 @@ void EventDispatcherImpl::remove_observer_from_vector(EventObserver& observer) { observers_.end()); } +// Mobile Events + +void EventDispatcherImpl::raise_mobile_event(const MobileEvent& event) { + AutoLock observer_lock(mobile_observer_lock_); + { + AutoLock state_lock(mobile_state_lock_); + + // check if event is notification + if (mobile_apis::messageType::notification == event.smart_object_type()) { + const uint32_t notification_correlation_id = 0; + mobile_observers_ = + mobile_observers_event_[event.id()][notification_correlation_id]; + } + + if (mobile_apis::messageType::response == event.smart_object_type()) { + mobile_observers_ = mobile_observers_event_ + [event.id()][event.smart_object_correlation_id()]; + } + } + + // Call observers + while (!mobile_observers_.empty()) { + EventObserver* temp = *mobile_observers_.begin(); + mobile_observers_.erase(mobile_observers_.begin()); + AutoUnlock unlock_observer(observer_lock); + temp->on_event(event); + } +} + +void EventDispatcherImpl::add_mobile_observer( + const MobileEvent::MobileEventID& event_id, + int32_t mobile_correlation_id, + EventObserver& observer) { + AutoLock auto_lock(mobile_state_lock_); + mobile_observers_event_[event_id][mobile_correlation_id].push_back(&observer); +} + +void EventDispatcherImpl::remove_mobile_observer( + const MobileEvent::MobileEventID& event_id, EventObserver& observer) { + remove_mobile_observer_from_vector(observer); + AutoLock auto_lock(mobile_state_lock_); + ObserversMap::iterator it = mobile_observers_event_[event_id].begin(); + + for (; mobile_observers_event_[event_id].end() != it; ++it) { + ObserverVector& obs_vec = it->second; + const ObserverVector::iterator obs_vec_it = obs_vec.end(); + obs_vec.erase( + std::remove_if( + obs_vec.begin(), obs_vec_it, IdCheckFunctor(observer.id())), + obs_vec_it); + } +} + +void EventDispatcherImpl::remove_mobile_observer(EventObserver& observer) { + remove_mobile_observer_from_vector(observer); + MobileEventObserverMap::iterator event_map = mobile_observers_event_.begin(); + + for (; mobile_observers_event_.end() != event_map; ++event_map) { + remove_mobile_observer(event_map->first, observer); + } +} + +void EventDispatcherImpl::remove_mobile_observer_from_vector( + EventObserver& observer) { + AutoLock auto_lock(mobile_observer_lock_); + + mobile_observers_.erase( + std::remove_if( + observers_.begin(), observers_.end(), IdCheckFunctor(observer.id())), + observers_.end()); +} + } // namespace event_engine } // namespace application_manager diff --git a/src/components/application_manager/src/event_engine/event_observer.cc b/src/components/application_manager/src/event_engine/event_observer.cc index f89f6649b1..fc252d3125 100644 --- a/src/components/application_manager/src/event_engine/event_observer.cc +++ b/src/components/application_manager/src/event_engine/event_observer.cc @@ -44,7 +44,8 @@ EventObserver::EventObserver(EventDispatcher& event_dispatcher) } EventObserver::~EventObserver() { - unsubscribe_from_all_events(); + unsubscribe_from_all_hmi_events(); + unsubscribe_from_all_mobile_events(); } void EventObserver::subscribe_on_event(const Event::EventID& event_id, @@ -60,5 +61,25 @@ void EventObserver::unsubscribe_from_all_events() { event_dispatcher_.remove_observer(*this); } +void EventObserver::unsubscribe_from_all_hmi_events() { + event_dispatcher_.remove_observer(*this); +} + +void EventObserver::subscribe_on_event( + const MobileEvent::MobileEventID& event_id, int32_t mobile_correlation_id) { + event_dispatcher_.add_mobile_observer(event_id, mobile_correlation_id, *this); +} + +void EventObserver::unsubscribe_from_event( + const MobileEvent::MobileEventID& event_id) { + event_dispatcher_.remove_mobile_observer(event_id, *this); +} + +void EventObserver::unsubscribe_from_all_mobile_events() { + event_dispatcher_.remove_mobile_observer(*this); +} + +void EventObserver::on_event(const event_engine::MobileEvent& event) {} + } // namespace event_engine } // namespace application_manager diff --git a/src/components/application_manager/src/hmi_interfaces_impl.cc b/src/components/application_manager/src/hmi_interfaces_impl.cc index 452b5ab79d..e31257bcad 100644 --- a/src/components/application_manager/src/hmi_interfaces_impl.cc +++ b/src/components/application_manager/src/hmi_interfaces_impl.cc @@ -227,6 +227,10 @@ generate_function_to_interface_convert_map() { HmiInterfaces::HMI_INTERFACE_RC; convert_map[RC_OnInteriorVehicleData] = HmiInterfaces::HMI_INTERFACE_RC; convert_map[RC_OnRemoteControlSettings] = HmiInterfaces::HMI_INTERFACE_RC; + convert_map[AppService_PublishAppService] = + HmiInterfaces::HMI_INTERFACE_AppService; + convert_map[AppService_GetAppServiceData] = + HmiInterfaces::HMI_INTERFACE_AppService; return convert_map; } @@ -250,6 +254,8 @@ HmiInterfacesImpl::HmiInterfacesImpl() { HmiInterfaces::STATE_NOT_RESPONSE; interfaces_states_[HmiInterfaces::HMI_INTERFACE_RC] = HmiInterfaces::STATE_NOT_RESPONSE; + interfaces_states_[HmiInterfaces::HMI_INTERFACE_AppService] = + HmiInterfaces::STATE_NOT_RESPONSE; } HmiInterfaces::InterfaceState HmiInterfacesImpl::GetInterfaceState( diff --git a/src/components/application_manager/src/hmi_language_handler.cc b/src/components/application_manager/src/hmi_language_handler.cc index 6e89b2419c..647df242df 100644 --- a/src/components/application_manager/src/hmi_language_handler.cc +++ b/src/components/application_manager/src/hmi_language_handler.cc @@ -284,7 +284,7 @@ void HMILanguageHandler::VerifyWithPersistedLanguages() { LOG4CXX_DEBUG(logger_, "No registered apps found. HMILanguageHandler unsubscribed " "from all events."); - unsubscribe_from_all_events(); + unsubscribe_from_all_hmi_events(); } } @@ -304,7 +304,7 @@ void HMILanguageHandler::HandleWrongLanguageApp(const Apps::value_type& app) { if (0 == apps_.size()) { LOG4CXX_DEBUG(logger_, "HMILanguageHandler unsubscribed from all events."); - unsubscribe_from_all_events(); + unsubscribe_from_all_hmi_events(); } } SendOnLanguageChangeToMobile(app.first); diff --git a/src/components/application_manager/src/policies/policy_event_observer.cc b/src/components/application_manager/src/policies/policy_event_observer.cc index f397814005..ea8935c8c5 100644 --- a/src/components/application_manager/src/policies/policy_event_observer.cc +++ b/src/components/application_manager/src/policies/policy_event_observer.cc @@ -55,6 +55,8 @@ void PolicyEventObserver::set_policy_handler( policy_handler_ = policy_handler; } +void PolicyEventObserver::on_event(const event_engine::MobileEvent& event) {} + void PolicyEventObserver::on_event(const event_engine::Event& event) { sync_primitives::AutoLock auto_lock(policy_handler_lock_); if (!policy_handler_) { diff --git a/src/components/application_manager/src/rpc_handler_impl.cc b/src/components/application_manager/src/rpc_handler_impl.cc index 939b3d1ce6..40f2e90115 100644 --- a/src/components/application_manager/src/rpc_handler_impl.cc +++ b/src/components/application_manager/src/rpc_handler_impl.cc @@ -269,6 +269,7 @@ bool RPCHandlerImpl::ConvertMessageToSO( "Failed to parse string to smart object with API version " << msg_version.toString() << " : " << message.json_message()); + std::shared_ptr response( MessageHelper::CreateNegativeResponse( message.connection_key(), diff --git a/src/components/application_manager/src/rpc_service_impl.cc b/src/components/application_manager/src/rpc_service_impl.cc index 7a68ae5779..99d0bf0cfe 100644 --- a/src/components/application_manager/src/rpc_service_impl.cc +++ b/src/components/application_manager/src/rpc_service_impl.cc @@ -154,7 +154,19 @@ bool RPCServiceImpl::ManageMobileCommand( return true; } - if (message_type == mobile_apis::messageType::request) { + if (message_type == mobile_apis::messageType::request && + source == commands::Command::CommandSource::SOURCE_SDL) { + if (command->Init()) { + command->Run(); + command->CleanUp(); + return true; + } else { + return false; + } + } + + if (message_type == mobile_apis::messageType::request && + source == commands::Command::CommandSource::SOURCE_MOBILE) { // commands will be launched from requesr_ctrl mobile_apis::HMILevel::eType app_hmi_level = mobile_apis::HMILevel::INVALID_ENUM; @@ -241,8 +253,8 @@ bool RPCServiceImpl::ManageMobileCommand( return false; } -bool RPCServiceImpl::ManageHMICommand( - const commands::MessageSharedPtr message) { +bool RPCServiceImpl::ManageHMICommand(const commands::MessageSharedPtr message, + commands::Command::CommandSource source) { LOG4CXX_AUTO_TRACE(logger_); if (!message) { @@ -258,15 +270,15 @@ bool RPCServiceImpl::ManageHMICommand( MessageHelper::PrintSmartObject(*message); const int32_t function_id = (*(message.get()))[strings::params][strings::function_id].asInt(); - auto plugin = app_manager_.GetPluginManager().FindPluginToProcess( - function_id, commands::Command::SOURCE_HMI); + auto plugin = + app_manager_.GetPluginManager().FindPluginToProcess(function_id, source); if (!plugin) { LOG4CXX_WARN(logger_, "Filed to find plugin : " << plugin.error()); return false; } application_manager::CommandFactory& factory = (*plugin).GetCommandFactory(); - auto command = factory.CreateCommand(message, commands::Command::SOURCE_HMI); + auto command = factory.CreateCommand(message, source); if (!command) { LOG4CXX_WARN(logger_, "Failed to create command from smart object"); diff --git a/src/components/application_manager/src/smart_object_keys.cc b/src/components/application_manager/src/smart_object_keys.cc index 59499818d3..b7778d339e 100644 --- a/src/components/application_manager/src/smart_object_keys.cc +++ b/src/components/application_manager/src/smart_object_keys.cc @@ -285,6 +285,7 @@ const char* service_id = "serviceID"; const char* service_manifest = "serviceManifest"; const char* service_published = "servicePublished"; const char* service_active = "serviceActive"; +const char* service_data = "serviceData"; const char* app_services = "appServices"; const char* update_reason = "updateReason"; const char* updated_app_service_record = "updatedAppServiceRecord"; diff --git a/src/components/application_manager/src/state_controller_impl.cc b/src/components/application_manager/src/state_controller_impl.cc index 5e912ca3be..f4852c532c 100644 --- a/src/components/application_manager/src/state_controller_impl.cc +++ b/src/components/application_manager/src/state_controller_impl.cc @@ -624,6 +624,7 @@ void StateControllerImpl::ApplyRegularState(ApplicationSharedPtr app, "Resolving HMI level conflicts for app " << app->app_id()); ForEachApplication(HmiLevelConflictResolver(app, state, this)); } +void StateControllerImpl::on_event(const event_engine::MobileEvent& event) {} void StateControllerImpl::on_event(const event_engine::Event& event) { using smart_objects::SmartObject; diff --git a/src/components/application_manager/src/system_time/system_time_handler_impl.cc b/src/components/application_manager/src/system_time/system_time_handler_impl.cc index 27f0972c01..06343af5a3 100644 --- a/src/components/application_manager/src/system_time/system_time_handler_impl.cc +++ b/src/components/application_manager/src/system_time/system_time_handler_impl.cc @@ -56,7 +56,7 @@ SystemTimeHandlerImpl::SystemTimeHandlerImpl( SystemTimeHandlerImpl::~SystemTimeHandlerImpl() { LOG4CXX_AUTO_TRACE(logger_); - unsubscribe_from_all_events(); + unsubscribe_from_all_hmi_events(); } void SystemTimeHandlerImpl::DoSystemTimeQuery() { diff --git a/src/components/application_manager/test/command_holder_test.cc b/src/components/application_manager/test/command_holder_test.cc index 56e24b8d29..9496e37924 100644 --- a/src/components/application_manager/test/command_holder_test.cc +++ b/src/components/application_manager/test/command_holder_test.cc @@ -84,7 +84,7 @@ TEST_F(CommandHolderImplTest, HoldOne_ExpectReleaseOne) { mock_app_ptr_, am::CommandHolder::CommandType::kHmiCommand, cmd_ptr_); // Act - EXPECT_CALL(mock_rpc_service_, ManageHMICommand(cmd_ptr_)); + EXPECT_CALL(mock_rpc_service_, ManageHMICommand(cmd_ptr_, _)); cmd_holder.Resume(mock_app_ptr_, am::CommandHolder::CommandType::kHmiCommand); } @@ -99,7 +99,8 @@ TEST_F(CommandHolderImplTest, HoldMany_ExpectReleaseSame) { } while (iterations < 5); // Act - EXPECT_CALL(mock_rpc_service_, ManageHMICommand(cmd_ptr_)).Times(iterations); + EXPECT_CALL(mock_rpc_service_, ManageHMICommand(cmd_ptr_, _)) + .Times(iterations); cmd_holder.Resume(mock_app_ptr_, am::CommandHolder::CommandType::kHmiCommand); } @@ -112,7 +113,7 @@ TEST_F(CommandHolderImplTest, Hold_Drop_ExpectNoReleased) { // Act cmd_holder.Clear(mock_app_ptr_); - EXPECT_CALL(mock_rpc_service_, ManageHMICommand(cmd_ptr_)).Times(0); + EXPECT_CALL(mock_rpc_service_, ManageHMICommand(cmd_ptr_, _)).Times(0); cmd_holder.Resume(mock_app_ptr_, am::CommandHolder::CommandType::kHmiCommand); } @@ -127,7 +128,7 @@ TEST_F(CommandHolderImplTest, Hold_ReleaseAnotherId_ExpectNoReleased) { std::shared_ptr another_app = std::make_shared(); - EXPECT_CALL(mock_rpc_service_, ManageHMICommand(cmd_ptr_)).Times(0); + EXPECT_CALL(mock_rpc_service_, ManageHMICommand(cmd_ptr_, _)).Times(0); cmd_holder.Resume(another_app, am::CommandHolder::CommandType::kHmiCommand); } @@ -146,7 +147,8 @@ TEST_F(CommandHolderImplTest, Hold_DropAnotherId_ExpectReleased) { std::make_shared(); cmd_holder.Clear(another_app); - EXPECT_CALL(mock_rpc_service_, ManageHMICommand(cmd_ptr_)).Times(iterations); + EXPECT_CALL(mock_rpc_service_, ManageHMICommand(cmd_ptr_, _)) + .Times(iterations); cmd_holder.Resume(mock_app_ptr_, am::CommandHolder::CommandType::kHmiCommand); } @@ -160,7 +162,7 @@ TEST_F(CommandHolderImplTest, Hold_Mobile_and_HMI_commands_ExpectReleased) { mock_app_ptr_, am::CommandHolder::CommandType::kMobileCommand, cmd_ptr_); // Act - EXPECT_CALL(mock_rpc_service_, ManageHMICommand(cmd_ptr_)); + EXPECT_CALL(mock_rpc_service_, ManageHMICommand(cmd_ptr_, _)); cmd_holder.Resume(mock_app_ptr_, am::CommandHolder::CommandType::kHmiCommand); EXPECT_CALL( diff --git a/src/components/application_manager/test/commands/command_request_impl_test.cc b/src/components/application_manager/test/commands/command_request_impl_test.cc index c70dd14852..d4a62d069f 100644 --- a/src/components/application_manager/test/commands/command_request_impl_test.cc +++ b/src/components/application_manager/test/commands/command_request_impl_test.cc @@ -258,7 +258,7 @@ TEST_F(CommandRequestImplTest, CreateHMINotification_SUCCESS) { MessageSharedPtr result; - EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_)) + EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_, _)) .WillOnce(DoAll(SaveArg<0>(&result), Return(true))); command->CreateHMINotification(kInvalidFunctionId, *msg_params); @@ -280,7 +280,7 @@ TEST_F(CommandRequestImplTest, SendHMIRequest_NoUseEvent_SUCCESS) { .WillRepeatedly(Return(am::HmiInterfaces::STATE_AVAILABLE)); // Return `true` prevents call of `SendResponse` method; - EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_)).WillOnce(Return(true)); + EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_, _)).WillOnce(Return(true)); EXPECT_EQ(kCorrelationId, command->SendHMIRequest(kInvalidFunctionId, NULL, false)); @@ -298,7 +298,7 @@ TEST_F(CommandRequestImplTest, SendHMIRequest_UseEvent_SUCCESS) { .WillRepeatedly(Return(am::HmiInterfaces::STATE_AVAILABLE)); // Return `true` prevents call of `SendResponse` method; - EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_)).WillOnce(Return(true)); + EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_, _)).WillOnce(Return(true)); EXPECT_CALL(event_dispatcher_, add_observer(_, _, _)); EXPECT_EQ(kCorrelationId, diff --git a/src/components/application_manager/test/hmi_capabilities_test.cc b/src/components/application_manager/test/hmi_capabilities_test.cc index ae95fca35f..d67dfebaa5 100644 --- a/src/components/application_manager/test/hmi_capabilities_test.cc +++ b/src/components/application_manager/test/hmi_capabilities_test.cc @@ -583,7 +583,7 @@ void HMICapabilitiesTest::SetCooperating() { smart_objects::SmartObjectSPtr test_so; EXPECT_CALL(*(MockMessageHelper::message_helper_mock()), CreateModuleInfoSO(_, _)).WillRepeatedly(Return(test_so)); - EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_)) + EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_, _)) .WillRepeatedly(Return(true)); } diff --git a/src/components/application_manager/test/include/application_manager/commands/command_request_test.h b/src/components/application_manager/test/include/application_manager/commands/command_request_test.h index 1980ffa100..8dd29ce244 100644 --- a/src/components/application_manager/test/include/application_manager/commands/command_request_test.h +++ b/src/components/application_manager/test/include/application_manager/commands/command_request_test.h @@ -105,7 +105,7 @@ class CommandRequestTest : public CommandsTest { MessageSharedPtr CatchHMICommandResult(CallableT delegate, bool call_return = true) { MessageSharedPtr result_msg; - EXPECT_CALL(this->mock_rpc_service_, ManageHMICommand(_)) + EXPECT_CALL(this->mock_rpc_service_, ManageHMICommand(_, _)) .WillOnce(DoAll(SaveArg<0>(&result_msg), Return(call_return))); delegate(); return result_msg; diff --git a/src/components/application_manager/test/include/application_manager/mock_event_dispatcher.h b/src/components/application_manager/test/include/application_manager/mock_event_dispatcher.h index 916f4a69f0..c5aedba029 100644 --- a/src/components/application_manager/test/include/application_manager/mock_event_dispatcher.h +++ b/src/components/application_manager/test/include/application_manager/mock_event_dispatcher.h @@ -59,6 +59,26 @@ class MockEventDispatcher MOCK_METHOD1( remove_observer, void(::application_manager::event_engine::EventObserver& observer)); + + MOCK_METHOD1( + raise_mobile_event, + void(const ::application_manager::event_engine::MobileEvent& event)); + MOCK_METHOD3( + add_mobile_observer, + void( + const ::application_manager::event_engine::MobileEvent::MobileEventID& + event_id, + int32_t mobile_correlation_id, + ::application_manager::event_engine::EventObserver& observer)); + MOCK_METHOD2( + remove_mobile_observer, + void( + const ::application_manager::event_engine::MobileEvent::MobileEventID& + event_id, + ::application_manager::event_engine::EventObserver& observer)); + MOCK_METHOD1( + remove_mobile_observer, + void(::application_manager::event_engine::EventObserver& observer)); }; } // namespace event_engine_test diff --git a/src/components/application_manager/test/message_helper/message_helper_test.cc b/src/components/application_manager/test/message_helper/message_helper_test.cc index b813c36bb4..f43062dc53 100644 --- a/src/components/application_manager/test/message_helper/message_helper_test.cc +++ b/src/components/application_manager/test/message_helper/message_helper_test.cc @@ -967,7 +967,7 @@ TEST_F(MessageHelperTest, SendGetListOfPermissionsResponse_SUCCESS) { ON_CALL(mock_application_manager, GetRPCService()) .WillByDefault(ReturnRef(mock_rpc_service_)); - EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_)) + EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_, _)) .WillOnce(DoAll(SaveArg<0>(&result), Return(true))); const uint32_t correlation_id = 0u; @@ -1007,7 +1007,7 @@ TEST_F(MessageHelperTest, ON_CALL(mock_application_manager, GetRPCService()) .WillByDefault(ReturnRef(mock_rpc_service_)); - EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_)) + EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_, _)) .WillOnce(DoAll(SaveArg<0>(&result), Return(true))); const uint32_t correlation_id = 0u; @@ -1053,7 +1053,7 @@ TEST_F(MessageHelperTest, SendNaviSetVideoConfigRequest) { smart_objects::SmartObjectSPtr result; ON_CALL(mock_application_manager, GetRPCService()) .WillByDefault(ReturnRef(mock_rpc_service_)); - EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_)) + EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_, _)) .WillOnce(DoAll(SaveArg<0>(&result), Return(true))); int32_t app_id = 123; diff --git a/src/components/application_manager/test/state_controller/state_controller_test.cc b/src/components/application_manager/test/state_controller/state_controller_test.cc index 1d4cead52b..58fea00f82 100644 --- a/src/components/application_manager/test/state_controller/state_controller_test.cc +++ b/src/components/application_manager/test/state_controller/state_controller_test.cc @@ -992,7 +992,7 @@ class StateControllerImplTest : public ::testing::Test { .WillByDefault(Return(bc_activate_app_request)); ON_CALL(app_manager_mock_, GetRPCService()) .WillByDefault(ReturnRef(mock_rpc_service_)); - ON_CALL(mock_rpc_service_, ManageHMICommand(bc_activate_app_request)) + ON_CALL(mock_rpc_service_, ManageHMICommand(bc_activate_app_request, _)) .WillByDefault(Return(true)); } @@ -1941,7 +1941,7 @@ TEST_F(StateControllerImplTest, DISABLED_ActivateAppSuccessReceivedFromHMI) { SetBCActivateAppRequestToHMI(hmi_level, corr_id); ON_CALL(app_manager_mock_, GetRPCService()) .WillByDefault(ReturnRef(mock_rpc_service_)); - ON_CALL(mock_rpc_service_, ManageHMICommand(bc_activate_app_request)) + ON_CALL(mock_rpc_service_, ManageHMICommand(bc_activate_app_request, _)) .WillByDefault(Return(true)); EXPECT_CALL(app_manager_mock_, application_id(corr_id)) diff --git a/src/components/include/application_manager/application_manager.h b/src/components/include/application_manager/application_manager.h index b542a66b83..f1b17a8225 100644 --- a/src/components/include/application_manager/application_manager.h +++ b/src/components/include/application_manager/application_manager.h @@ -397,6 +397,7 @@ class ApplicationManager { virtual bool is_stopping() const = 0; virtual bool is_audio_pass_thru_active() const = 0; + virtual uint32_t GetNextMobileCorrelationID() = 0; virtual uint32_t GetNextHMICorrelationID() = 0; virtual uint32_t GenerateNewHMIAppID() = 0; diff --git a/src/components/include/application_manager/rpc_service.h b/src/components/include/application_manager/rpc_service.h index 79b4007f71..d892b12422 100644 --- a/src/components/include/application_manager/rpc_service.h +++ b/src/components/include/application_manager/rpc_service.h @@ -58,7 +58,9 @@ class RPCService { * @param message pointer to received message * @return true if command is executed, otherwise return false */ - virtual bool ManageHMICommand(const commands::MessageSharedPtr message) = 0; + virtual bool ManageHMICommand(const commands::MessageSharedPtr message, + commands::Command::CommandSource + source = commands::Command::SOURCE_HMI) = 0; /** * @brief SendMessageToMobile Put message to the queue to be sent to mobile. diff --git a/src/components/include/test/application_manager/mock_application_manager.h b/src/components/include/test/application_manager/mock_application_manager.h index 04029adda3..46b2118249 100644 --- a/src/components/include/test/application_manager/mock_application_manager.h +++ b/src/components/include/test/application_manager/mock_application_manager.h @@ -162,6 +162,7 @@ class MockApplicationManager : public application_manager::ApplicationManager { MOCK_CONST_METHOD0(is_stopping, bool()); MOCK_CONST_METHOD0(is_audio_pass_thru_active, bool()); MOCK_METHOD0(GetNextHMICorrelationID, uint32_t()); + MOCK_METHOD0(GetNextMobileCorrelationID, uint32_t()); MOCK_METHOD0(GenerateNewHMIAppID, uint32_t()); MOCK_METHOD1(EndNaviServices, void(uint32_t app_id)); MOCK_METHOD1(BeginAudioPassThru, bool(uint32_t app_id)); diff --git a/src/components/include/test/application_manager/mock_rpc_service.h b/src/components/include/test/application_manager/mock_rpc_service.h index 4eddbbe257..3503f8bad1 100644 --- a/src/components/include/test/application_manager/mock_rpc_service.h +++ b/src/components/include/test/application_manager/mock_rpc_service.h @@ -10,9 +10,10 @@ namespace application_manager_test { class MockRPCService : public application_manager::rpc_service::RPCService { public: - MOCK_METHOD1( + MOCK_METHOD2( ManageHMICommand, - bool(const application_manager::commands::MessageSharedPtr message)); + bool(const application_manager::commands::MessageSharedPtr message, + application_manager::commands::Command::CommandSource source)); MOCK_METHOD2( ManageMobileCommand, bool(const application_manager::commands::MessageSharedPtr message, diff --git a/src/components/interfaces/HMI_API.xml b/src/components/interfaces/HMI_API.xml index a253e5fa0a..6aeb08c3cc 100644 --- a/src/components/interfaces/HMI_API.xml +++ b/src/components/interfaces/HMI_API.xml @@ -6202,6 +6202,21 @@ + + This request asks the module for current data related to the specific service. It also includes an option to subscribe to that service for future updates + + + + + If true, the consumer is requesting to subscribe to all future updates from the service publisher. If false, the consumer doesn't wish to subscribe and should be unsubscribed if it was previously subscribed. + + + + + This response includes the data that is requested from the specific service + + + If included, only service records of supplied type will be returned in response. If not included, all service records for all types will be returned. See Common.AppServiceType. diff --git a/src/components/interfaces/MOBILE_API.xml b/src/components/interfaces/MOBILE_API.xml index a631759bff..b3cf9df8f0 100644 --- a/src/components/interfaces/MOBILE_API.xml +++ b/src/components/interfaces/MOBILE_API.xml @@ -2618,6 +2618,7 @@ + + + diff --git a/src/components/policy/policy_external/include/policy/policy_table/enums.h b/src/components/policy/policy_external/include/policy/policy_table/enums.h index 32277f2dcf..932fb9b801 100644 --- a/src/components/policy/policy_external/include/policy/policy_table/enums.h +++ b/src/components/policy/policy_external/include/policy/policy_table/enums.h @@ -450,6 +450,11 @@ enum FunctionID { */ PublishAppServiceID = 52, + /** + * @brief GetAppServiceDataID. + */ + GetAppServiceDataID = 53, + /** * @brief OnHMIStatusID. */ diff --git a/src/components/policy/policy_external/src/policy_table/enums.cc b/src/components/policy/policy_external/src/policy_table/enums.cc index 2d21715194..f99a7e69de 100644 --- a/src/components/policy/policy_external/src/policy_table/enums.cc +++ b/src/components/policy/policy_external/src/policy_table/enums.cc @@ -1131,6 +1131,11 @@ bool EnumFromJsonString(const std::string& literal, FunctionID* result) { return true; } + if ("GetAppServiceData" == literal) { + *result = GetAppServiceDataID; + return true; + } + if ("OnHMIStatus" == literal) { *result = OnHMIStatusID; return true; diff --git a/src/components/policy/policy_regular/include/policy/policy_table/enums.h b/src/components/policy/policy_regular/include/policy/policy_table/enums.h index 1600c718f1..69840c71ba 100644 --- a/src/components/policy/policy_regular/include/policy/policy_table/enums.h +++ b/src/components/policy/policy_regular/include/policy/policy_table/enums.h @@ -436,6 +436,11 @@ enum FunctionID { */ PublishAppServiceID = 52, + /** + * @brief GetAppServiceDataID. + */ + GetAppServiceDataID = 53, + /** * @brief OnHMIStatusID. */ diff --git a/src/components/policy/policy_regular/src/policy_table/enums.cc b/src/components/policy/policy_regular/src/policy_table/enums.cc index 47ad1e98ab..2f84c68c66 100644 --- a/src/components/policy/policy_regular/src/policy_table/enums.cc +++ b/src/components/policy/policy_regular/src/policy_table/enums.cc @@ -851,6 +851,8 @@ bool IsValidEnum(FunctionID val) { return true; case PublishAppServiceID: return true; + case GetAppServiceDataID: + return true; case OnHMIStatusID: return true; case OnAppInterfaceUnregisteredID: @@ -1006,6 +1008,8 @@ const char* EnumToJsonString(FunctionID val) { return "SetCloudAppProperties"; case PublishAppServiceID: return "PublishAppService"; + case GetAppServiceDataID: + return "GetAppServiceData"; case OnHMIStatusID: return "OnHMIStatus"; case OnAppInterfaceUnregisteredID: @@ -1310,6 +1314,11 @@ bool EnumFromJsonString(const std::string& literal, FunctionID* result) { return true; } + if ("GetAppServiceData" == literal) { + *result = GetAppServiceDataID; + return true; + } + if ("OnHMIStatus" == literal) { *result = OnHMIStatusID; return true; -- cgit v1.2.1 From 1f4a99fa5c7f8ad10645dc4c1a76469b83d53011 Mon Sep 17 00:00:00 2001 From: jacobkeeler Date: Sun, 24 Feb 2019 18:42:37 -0500 Subject: Revert "Update based on comments" This reverts commit d67a37a5dedfe696dd4308fd0eb53ee48e15daf8. # Conflicts: # src/components/application_manager/src/application_manager_impl.cc # src/components/connection_handler/src/connection_handler_impl.cc --- src/components/application_manager/src/application_manager_impl.cc | 3 ++- .../include/connection_handler/connection_handler_impl.h | 3 ++- src/components/connection_handler/src/connection_handler_impl.cc | 4 +++- src/components/include/connection_handler/connection_handler.h | 3 ++- .../include/test/connection_handler/mock_connection_handler.h | 5 +++-- 5 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/components/application_manager/src/application_manager_impl.cc b/src/components/application_manager/src/application_manager_impl.cc index 7b2475a4e0..b4381f4ba9 100644 --- a/src/components/application_manager/src/application_manager_impl.cc +++ b/src/components/application_manager/src/application_manager_impl.cc @@ -845,7 +845,8 @@ void ApplicationManagerImpl::RefreshCloudAppInformation() { } // If the device was disconnected, this will reinitialize the device - connection_handler().AddCloudAppDevice(endpoint, cloud_transport_type); + connection_handler().AddCloudAppDevice( + *enabled_it, endpoint, cloud_transport_type); } pending_device_map_lock_ptr_->Release(); diff --git a/src/components/connection_handler/include/connection_handler/connection_handler_impl.h b/src/components/connection_handler/include/connection_handler/connection_handler_impl.h index 96cb9f600d..e9e7ba47a3 100644 --- a/src/components/connection_handler/include/connection_handler/connection_handler_impl.h +++ b/src/components/connection_handler/include/connection_handler/connection_handler_impl.h @@ -130,7 +130,8 @@ class ConnectionHandlerImpl void ConnectToAllDevices() OVERRIDE; - void AddCloudAppDevice(const std::string& endpoint, + void AddCloudAppDevice(const std::string& policy_app_id, + const std::string& endpoint, const std::string& cloud_transport_type) OVERRIDE; void RemoveCloudAppDevice(const DeviceHandle device_id) OVERRIDE; diff --git a/src/components/connection_handler/src/connection_handler_impl.cc b/src/components/connection_handler/src/connection_handler_impl.cc index b58700834f..41d6e1dd54 100644 --- a/src/components/connection_handler/src/connection_handler_impl.cc +++ b/src/components/connection_handler/src/connection_handler_impl.cc @@ -1327,7 +1327,9 @@ void ConnectionHandlerImpl::ConnectToAllDevices() { } void ConnectionHandlerImpl::AddCloudAppDevice( - const std::string& endpoint, const std::string& cloud_transport_type) { + const std::string& policy_app_id, + const std::string& endpoint, + const std::string& cloud_transport_type) { transport_manager_.AddCloudDevice(endpoint, cloud_transport_type); } diff --git a/src/components/include/connection_handler/connection_handler.h b/src/components/include/connection_handler/connection_handler.h index e409460a96..a4058c7078 100644 --- a/src/components/include/connection_handler/connection_handler.h +++ b/src/components/include/connection_handler/connection_handler.h @@ -103,7 +103,8 @@ class ConnectionHandler { virtual void ConnectToAllDevices() = 0; - virtual void AddCloudAppDevice(const std::string& endpoint, + virtual void AddCloudAppDevice(const std::string& policy_app_id, + const std::string& endpoint, const std::string& cloud_transport_type) = 0; virtual void RemoveCloudAppDevice(const DeviceHandle device_id) = 0; diff --git a/src/components/include/test/connection_handler/mock_connection_handler.h b/src/components/include/test/connection_handler/mock_connection_handler.h index 5aed5da58c..219ee7b561 100644 --- a/src/components/include/test/connection_handler/mock_connection_handler.h +++ b/src/components/include/test/connection_handler/mock_connection_handler.h @@ -66,8 +66,9 @@ class MockConnectionHandler : public connection_handler::ConnectionHandler { MOCK_CONST_METHOD2(RunAppOnDevice, void(const std::string&, const std::string&)); MOCK_METHOD0(ConnectToAllDevices, void()); - MOCK_METHOD2(AddCloudAppDevice, - void(const std::string& endpoint, + MOCK_METHOD3(AddCloudAppDevice, + void(const std::string& policy_app_id, + const std::string& endpoint, const std::string& cloud_transport_type)); MOCK_METHOD1(RemoveCloudAppDevice, void(const DeviceHandle device_id)); MOCK_METHOD1(CloseRevokedConnection, void(uint32_t connection_key)); -- cgit v1.2.1 From 146aa7a46a540cfd85a30f82bcec2783c9801ba7 Mon Sep 17 00:00:00 2001 From: jacobkeeler Date: Mon, 25 Feb 2019 11:33:34 -0500 Subject: Add auth_token to StartServiceACK for cloud apps --- src/appMain/life_cycle_impl.cc | 2 +- .../application_manager/policies/policy_handler.h | 3 ++ .../policies/regular/policy_handler_observer.h | 3 ++ .../src/policies/policy_handler.cc | 34 ++++++++++++--- .../connection_handler/connection_handler_impl.h | 15 +++++++ .../src/connection_handler_impl.cc | 26 +++++++++++ .../policies/policy_handler_observer.h | 3 ++ .../connection_handler/connection_handler.h | 9 ++++ .../policy_external/policy/policy_listener.h | 10 +++++ .../policy/policy_regular/policy/policy_listener.h | 10 +++++ src/components/include/protocol/bson_object_keys.h | 1 + .../connection_handler/mock_connection_handler.h | 3 ++ .../policy_external/policy/mock_policy_listener.h | 3 ++ .../policy_regular/policy/mock_policy_listener.h | 3 ++ .../include/policy/policy_manager_impl.h | 6 +++ .../policy_external/src/policy_manager_impl.cc | 20 +++++++++ .../include/policy/policy_manager_impl.h | 6 +++ .../policy_regular/src/policy_manager_impl.cc | 20 +++++++++ src/components/protocol/src/bson_object_keys.cc | 1 + .../protocol_handler/protocol_handler_impl.h | 7 +++ .../protocol_handler/src/protocol_handler_impl.cc | 50 ++++++++++++++++------ 21 files changed, 216 insertions(+), 19 deletions(-) diff --git a/src/appMain/life_cycle_impl.cc b/src/appMain/life_cycle_impl.cc index b87191d937..efc627f33a 100644 --- a/src/appMain/life_cycle_impl.cc +++ b/src/appMain/life_cycle_impl.cc @@ -111,6 +111,7 @@ bool LifeCycleImpl::StartComponents() { media_manager_ = new media_manager::MediaManagerImpl(*app_manager_, profile_); app_manager_->set_connection_handler(connection_handler_); + app_manager_->AddPolicyObserver(protocol_handler_); if (!app_manager_->Init(*last_state_, media_manager_)) { LOG4CXX_ERROR(logger_, "Application manager init failed."); return false; @@ -134,7 +135,6 @@ bool LifeCycleImpl::StartComponents() { security_manager_->AddListener(app_manager_); app_manager_->AddPolicyObserver(security_manager_); - app_manager_->AddPolicyObserver(protocol_handler_); if (!crypto_manager_->Init()) { LOG4CXX_ERROR(logger_, "CryptoManager initialization fail."); return false; diff --git a/src/components/application_manager/include/application_manager/policies/policy_handler.h b/src/components/application_manager/include/application_manager/policies/policy_handler.h index 8ee5ff64f6..1cc5fc0156 100644 --- a/src/components/application_manager/include/application_manager/policies/policy_handler.h +++ b/src/components/application_manager/include/application_manager/policies/policy_handler.h @@ -455,6 +455,9 @@ class PolicyHandler : public PolicyHandlerInterface, #ifdef EXTERNAL_PROPRIETARY_MODE void OnCertificateDecrypted(bool is_succeeded) OVERRIDE; #endif // EXTERNAL_PROPRIETARY_MODE + void OnAuthTokenUpdated(const std::string& policy_app_id, + const std::string& auth_token); + virtual bool CanUpdate() OVERRIDE; virtual void OnDeviceConsentChanged(const std::string& device_id, diff --git a/src/components/application_manager/include/application_manager/policies/regular/policy_handler_observer.h b/src/components/application_manager/include/application_manager/policies/regular/policy_handler_observer.h index 07d234f036..68e7511b43 100644 --- a/src/components/application_manager/include/application_manager/policies/regular/policy_handler_observer.h +++ b/src/components/application_manager/include/application_manager/policies/regular/policy_handler_observer.h @@ -48,6 +48,9 @@ class PolicyHandlerObserver { return false; } + virtual void OnAuthTokenUpdated(const std::string& policy_app_id, + const std::string& auth_token) {} + virtual void OnPTUFinished(const bool ptu_result) {} virtual ~PolicyHandlerObserver() {} diff --git a/src/components/application_manager/src/policies/policy_handler.cc b/src/components/application_manager/src/policies/policy_handler.cc index 3be3ef0da7..02b848d9c6 100644 --- a/src/components/application_manager/src/policies/policy_handler.cc +++ b/src/components/application_manager/src/policies/policy_handler.cc @@ -1771,6 +1771,17 @@ void PolicyHandler::OnCertificateUpdated(const std::string& certificate_data) { } #endif // EXTERNAL_PROPRIETARY_MODE +void PolicyHandler::OnAuthTokenUpdated(const std::string& policy_app_id, + const std::string& auth_token) { + LOG4CXX_AUTO_TRACE(logger_); + sync_primitives::AutoLock lock(listeners_lock_); + HandlersCollection::const_iterator it = listeners_.begin(); + for (; it != listeners_.end(); ++it) { + PolicyHandlerObserver* observer = *it; + observer->OnAuthTokenUpdated(policy_app_id, auth_token); + } +} + void PolicyHandler::OnPTUFinished(const bool ptu_result) { LOG4CXX_AUTO_TRACE(logger_); sync_primitives::AutoLock lock(listeners_lock_); @@ -1909,15 +1920,18 @@ void PolicyHandler::OnSetCloudAppProperties( policy_manager_->InitCloudApp(policy_app_id); + bool auth_token_update = false; if (msg_params.keyExists(strings::enabled)) { - policy_manager_->SetCloudAppEnabled(policy_app_id, - msg_params[strings::enabled].asBool()); - + bool enabled = msg_params[strings::enabled].asBool(); + policy_manager_->SetCloudAppEnabled(policy_app_id, enabled); + auth_token_update = enabled; application_manager_.RefreshCloudAppInformation(); } if (msg_params.keyExists(strings::cloud_app_auth_token)) { - policy_manager_->SetAppAuthToken( - policy_app_id, msg_params[strings::cloud_app_auth_token].asString()); + std::string auth_token = + msg_params[strings::cloud_app_auth_token].asString(); + policy_manager_->SetAppAuthToken(policy_app_id, auth_token); + auth_token_update = true; } if (msg_params.keyExists(strings::cloud_transport_type)) { policy_manager_->SetAppCloudTransportType( @@ -1935,6 +1949,16 @@ void PolicyHandler::OnSetCloudAppProperties( policy_manager_->SetHybridAppPreference(policy_app_id, hybrid_app_preference); } + + if (auth_token_update) { + bool enabled; + std::string end, cert, ctt, hap; + std::string auth_token; + + policy_manager_->GetCloudAppParameters( + policy_app_id, enabled, end, cert, auth_token, ctt, hap); + OnAuthTokenUpdated(policy_app_id, auth_token); + } } uint32_t PolicyHandler::HeartBeatTimeout(const std::string& app_id) const { diff --git a/src/components/connection_handler/include/connection_handler/connection_handler_impl.h b/src/components/connection_handler/include/connection_handler/connection_handler_impl.h index e9e7ba47a3..16a3190315 100644 --- a/src/components/connection_handler/include/connection_handler/connection_handler_impl.h +++ b/src/components/connection_handler/include/connection_handler/connection_handler_impl.h @@ -377,6 +377,15 @@ class ConnectionHandlerImpl const uint32_t connection_key, const protocol_handler::ServiceType& service_type) const OVERRIDE; + /** + * @brief Get cloud app id by connection id + * @param connection_id unique connection id + * @return the policy app id of the cloud app if the connection is tied to a + * cloud app, an empty string otherwise. + */ + std::string GetCloudAppID( + const transport_manager::ConnectionUID connection_id) const OVERRIDE; + /** * \brief Get device handle by mac address * \param mac_address uniq address @@ -655,6 +664,12 @@ class ConnectionHandlerImpl std::map start_service_context_map_; + // Map app id -> (cloud_app_endpoint, connection_uid) + mutable sync_primitives::Lock cloud_app_id_map_lock_; + std::map > + cloud_app_id_map_; + /** * @brief connection object as it's being closed */ diff --git a/src/components/connection_handler/src/connection_handler_impl.cc b/src/components/connection_handler/src/connection_handler_impl.cc index 41d6e1dd54..8afc3e885f 100644 --- a/src/components/connection_handler/src/connection_handler_impl.cc +++ b/src/components/connection_handler/src/connection_handler_impl.cc @@ -270,6 +270,17 @@ void ConnectionHandlerImpl::OnConnectionPending( LOG4CXX_DEBUG(logger_, "Add Pending Connection #" << connection_id << " to the list."); + std::string endpoint = device_info.mac_address(); + cloud_app_id_map_lock_.Acquire(); + for (auto it = cloud_app_id_map_.begin(); it != cloud_app_id_map_.end(); + ++it) { + if (endpoint == it->second.first) { + it->second.second = connection_id; + break; + } + } + cloud_app_id_map_lock_.Release(); + sync_primitives::AutoWriteLock lock(connection_list_lock_); if (connection_list_.find(connection_id) == connection_list_.end()) { Connection* connection = @@ -1111,6 +1122,18 @@ const uint8_t ConnectionHandlerImpl::GetSessionIdFromSecondaryTransport( return 0; } +std::string ConnectionHandlerImpl::GetCloudAppID( + const transport_manager::ConnectionUID connection_id) const { + sync_primitives::AutoLock auto_lock(cloud_app_id_map_lock_); + for (auto it = cloud_app_id_map_.begin(); it != cloud_app_id_map_.end(); + ++it) { + if (connection_id == it->second.second) { + return it->first; + } + } + return std::string(); +} + struct CompareMAC { explicit CompareMAC(const std::string& mac) : mac_(mac) {} bool operator()(const DeviceMap::value_type& device) { @@ -1330,6 +1353,9 @@ void ConnectionHandlerImpl::AddCloudAppDevice( const std::string& policy_app_id, const std::string& endpoint, const std::string& cloud_transport_type) { + cloud_app_id_map_lock_.Acquire(); + cloud_app_id_map_[policy_app_id] = std::make_pair(endpoint, 0); + cloud_app_id_map_lock_.Release(); transport_manager_.AddCloudDevice(endpoint, cloud_transport_type); } diff --git a/src/components/include/application_manager/policies/policy_handler_observer.h b/src/components/include/application_manager/policies/policy_handler_observer.h index 1c32102184..c13846dff2 100644 --- a/src/components/include/application_manager/policies/policy_handler_observer.h +++ b/src/components/include/application_manager/policies/policy_handler_observer.h @@ -48,6 +48,9 @@ class PolicyHandlerObserver { return false; } + virtual void OnAuthTokenUpdated(const std::string& policy_app_id, + const std::string& auth_token) {} + virtual void OnPTUFinished(const bool ptu_result) {} virtual ~PolicyHandlerObserver() {} diff --git a/src/components/include/connection_handler/connection_handler.h b/src/components/include/connection_handler/connection_handler.h index a4058c7078..234a7c1b76 100644 --- a/src/components/include/connection_handler/connection_handler.h +++ b/src/components/include/connection_handler/connection_handler.h @@ -127,6 +127,15 @@ class ConnectionHandler { */ virtual uint32_t GetConnectionSessionsCount(uint32_t connection_key) = 0; + /** + * @brief Get cloud app id by connection id + * @param connection_id unique connection id + * @return the policy app id of the cloud app if the connection is tied to a + * cloud app, an empty string otherwise. + */ + virtual std::string GetCloudAppID( + const transport_manager::ConnectionUID connection_id) const = 0; + /** * Gets device id by mac address * @param mac_address diff --git a/src/components/include/policy/policy_external/policy/policy_listener.h b/src/components/include/policy/policy_external/policy/policy_listener.h index c446c87d1b..8299d019f5 100644 --- a/src/components/include/policy/policy_external/policy/policy_listener.h +++ b/src/components/include/policy/policy_external/policy/policy_listener.h @@ -114,6 +114,16 @@ class PolicyListener { */ virtual void OnCertificateUpdated(const std::string& certificate_data) = 0; + /** + * @brief OnAuthTokenUpdated the callback which signals if an app's auth token + * field has been updated during a PTU + * + * @param policy_app_id the policy app id tied to the updated field. + * @param auth_token the value of the updated field. + */ + virtual void OnAuthTokenUpdated(const std::string& policy_app_id, + const std::string& auth_token) = 0; + /** * @brief OnPTUFinishedd the callback which signals PTU has finished * diff --git a/src/components/include/policy/policy_regular/policy/policy_listener.h b/src/components/include/policy/policy_regular/policy/policy_listener.h index 3f6f555bcc..56e674e81b 100644 --- a/src/components/include/policy/policy_regular/policy/policy_listener.h +++ b/src/components/include/policy/policy_regular/policy/policy_listener.h @@ -112,6 +112,16 @@ class PolicyListener { */ virtual void OnCertificateUpdated(const std::string& certificate_data) = 0; + /** + * @brief OnAuthTokenUpdated the callback which signals if an app's auth token + * field has been updated during a PTU + * + * @param policy_app_id the policy app id tied to the updated field. + * @param auth_token the value of the updated field. + */ + virtual void OnAuthTokenUpdated(const std::string& policy_app_id, + const std::string& auth_token) = 0; + /** * Gets devices ids by policy application id * @param policy_app_id diff --git a/src/components/include/protocol/bson_object_keys.h b/src/components/include/protocol/bson_object_keys.h index 56bd5cebd6..f81de4cc81 100644 --- a/src/components/include/protocol/bson_object_keys.h +++ b/src/components/include/protocol/bson_object_keys.h @@ -48,6 +48,7 @@ extern const char* video_service_transports; extern const char* tcp_ip_address; extern const char* tcp_port; extern const char* reason; +extern const char* auth_token; } // namespace strings diff --git a/src/components/include/test/connection_handler/mock_connection_handler.h b/src/components/include/test/connection_handler/mock_connection_handler.h index 219ee7b561..3027fd5cb4 100644 --- a/src/components/include/test/connection_handler/mock_connection_handler.h +++ b/src/components/include/test/connection_handler/mock_connection_handler.h @@ -74,6 +74,9 @@ class MockConnectionHandler : public connection_handler::ConnectionHandler { MOCK_METHOD1(CloseRevokedConnection, void(uint32_t connection_key)); MOCK_METHOD1(CloseConnection, void(ConnectionHandle connection_handle)); MOCK_METHOD1(GetConnectionSessionsCount, uint32_t(uint32_t connection_key)); + MOCK_CONST_METHOD1( + GetCloudAppID, + std::string(const transport_manager::ConnectionUID connection_id)); MOCK_METHOD2(GetDeviceID, bool(const std::string& mac_address, DeviceHandle* device_handle)); diff --git a/src/components/include/test/policy/policy_external/policy/mock_policy_listener.h b/src/components/include/test/policy/policy_external/policy/mock_policy_listener.h index 1f570d8699..720a81862a 100644 --- a/src/components/include/test/policy/policy_external/policy/mock_policy_listener.h +++ b/src/components/include/test/policy/policy_external/policy/mock_policy_listener.h @@ -81,6 +81,9 @@ class MockPolicyListener : public ::policy::PolicyListener { uint32_t timeout_exceed)); MOCK_METHOD0(CanUpdate, bool()); MOCK_METHOD1(OnCertificateUpdated, void(const std::string&)); + MOCK_METHOD2(OnAuthTokenUpdated, + void(const std::string& policy_app_id, + const std::string& auth_token)); MOCK_METHOD1(OnPTUFinished, void(const bool ptu_result)); MOCK_CONST_METHOD2(SendOnAppPermissionsChanged, void(const policy::AppPermissions&, const std::string&)); diff --git a/src/components/include/test/policy/policy_regular/policy/mock_policy_listener.h b/src/components/include/test/policy/policy_regular/policy/mock_policy_listener.h index 3b0c1a925e..045d4f4e4f 100644 --- a/src/components/include/test/policy/policy_regular/policy/mock_policy_listener.h +++ b/src/components/include/test/policy/policy_regular/policy/mock_policy_listener.h @@ -75,6 +75,9 @@ class MockPolicyListener : public ::policy::PolicyListener { MOCK_METHOD1(OnSnapshotCreated, void(const policy::BinaryMessage& pt_string)); MOCK_METHOD0(CanUpdate, bool()); MOCK_METHOD1(OnCertificateUpdated, void(const std::string&)); + MOCK_METHOD2(OnAuthTokenUpdated, + void(const std::string& policy_app_id, + const std::string& auth_token)); MOCK_CONST_METHOD2(SendOnAppPermissionsChanged, void(const policy::AppPermissions&, const std::string&)); MOCK_METHOD3(OnUpdateHMILevel, diff --git a/src/components/policy/policy_external/include/policy/policy_manager_impl.h b/src/components/policy/policy_external/include/policy/policy_manager_impl.h index 399c95170d..2802af1706 100644 --- a/src/components/policy/policy_external/include/policy/policy_manager_impl.h +++ b/src/components/policy/policy_external/include/policy/policy_manager_impl.h @@ -960,6 +960,12 @@ class PolicyManagerImpl : public PolicyManager { void SendAppPermissionsChanged(const std::string& device_id, const std::string& application_id) OVERRIDE; + /** + * @brief notify listener of updated auth token for a given policy id + * @param policy_app_id the app id that has an updated auth token + */ + void SendAuthTokenUpdated(const std::string policy_app_id); + /** * @brief Gets all allowed module types * @param policy_app_id unique identifier of application diff --git a/src/components/policy/policy_external/src/policy_manager_impl.cc b/src/components/policy/policy_external/src/policy_manager_impl.cc index 0844edd8eb..bd7746d720 100644 --- a/src/components/policy/policy_external/src/policy_manager_impl.cc +++ b/src/components/policy/policy_external/src/policy_manager_impl.cc @@ -497,6 +497,12 @@ bool PolicyManagerImpl::LoadPT(const std::string& file, } else { LOG4CXX_INFO(logger_, "app_hmi_types empty"); } + + std::vector enabled_apps; + cache_->GetEnabledCloudApps(enabled_apps); + for (auto it = enabled_apps.begin(); it != enabled_apps.end(); ++it) { + SendAuthTokenUpdated(*it); + } } // If there was a user request for policy table update, it should be started @@ -2080,6 +2086,11 @@ bool PolicyManagerImpl::InitPT(const std::string& file_name, const bool ret = cache_->Init(file_name, settings); if (ret) { RefreshRetrySequence(); + std::vector enabled_apps; + cache_->GetEnabledCloudApps(enabled_apps); + for (auto it = enabled_apps.begin(); it != enabled_apps.end(); ++it) { + SendAuthTokenUpdated(*it); + } } return ret; } @@ -2188,6 +2199,15 @@ void PolicyManagerImpl::SendAppPermissionsChanged( listener()->OnPermissionsUpdated(application_id, notification_data); } +void PolicyManagerImpl::SendAuthTokenUpdated(const std::string policy_app_id) { + bool enabled = false; + std::string end, cert, ctt, hap; + std::string auth_token; + cache_->GetCloudAppParameters( + policy_app_id, enabled, end, cert, auth_token, ctt, hap); + listener_->OnAuthTokenUpdated(policy_app_id, auth_token); +} + void PolicyManagerImpl::OnPrimaryGroupsChanged( const std::string& application_id) { const std::vector devices = diff --git a/src/components/policy/policy_regular/include/policy/policy_manager_impl.h b/src/components/policy/policy_regular/include/policy/policy_manager_impl.h index 20a37717a7..fea8bbe0b3 100644 --- a/src/components/policy/policy_regular/include/policy/policy_manager_impl.h +++ b/src/components/policy/policy_regular/include/policy/policy_manager_impl.h @@ -909,6 +909,12 @@ class PolicyManagerImpl : public PolicyManager { void SendAppPermissionsChanged(const std::string& device_id, const std::string& application_id) OVERRIDE; + /** + * @brief notify listener of updated auth token for a given policy id + * @param policy_app_id the app id that has an updated auth token + */ + void SendAuthTokenUpdated(const std::string policy_app_id); + /** * @brief Gets all allowed module types * @param policy_app_id unique identifier of application diff --git a/src/components/policy/policy_regular/src/policy_manager_impl.cc b/src/components/policy/policy_regular/src/policy_manager_impl.cc index 9b2392a015..a7e206b51b 100644 --- a/src/components/policy/policy_regular/src/policy_manager_impl.cc +++ b/src/components/policy/policy_regular/src/policy_manager_impl.cc @@ -368,6 +368,12 @@ bool PolicyManagerImpl::LoadPT(const std::string& file, } else { LOG4CXX_INFO(logger_, "app_hmi_types empty" << pt_content.size()); } + + std::vector enabled_apps; + cache_->GetEnabledCloudApps(enabled_apps); + for (auto it = enabled_apps.begin(); it != enabled_apps.end(); ++it) { + SendAuthTokenUpdated(*it); + } } // If there was a user request for policy table update, it should be started @@ -1341,6 +1347,11 @@ bool PolicyManagerImpl::InitPT(const std::string& file_name, if (!certificate_data.empty()) { listener_->OnCertificateUpdated(certificate_data); } + std::vector enabled_apps; + cache_->GetEnabledCloudApps(enabled_apps); + for (auto it = enabled_apps.begin(); it != enabled_apps.end(); ++it) { + SendAuthTokenUpdated(*it); + } } return ret; } @@ -1456,6 +1467,15 @@ void PolicyManagerImpl::SendAppPermissionsChanged( listener()->OnPermissionsUpdated(application_id, notification_data); } +void PolicyManagerImpl::SendAuthTokenUpdated(const std::string policy_app_id) { + bool enabled = false; + std::string end, cert, ctt, hap; + std::string auth_token; + cache_->GetCloudAppParameters( + policy_app_id, enabled, end, cert, auth_token, ctt, hap); + listener_->OnAuthTokenUpdated(policy_app_id, auth_token); +} + void PolicyManagerImpl::OnPrimaryGroupsChanged( const std::string& application_id) { const std::vector devices = diff --git a/src/components/protocol/src/bson_object_keys.cc b/src/components/protocol/src/bson_object_keys.cc index 11160d7082..acafd3dbd2 100644 --- a/src/components/protocol/src/bson_object_keys.cc +++ b/src/components/protocol/src/bson_object_keys.cc @@ -18,6 +18,7 @@ const char* video_service_transports = "videoServiceTransports"; const char* tcp_ip_address = "tcpIpAddress"; const char* tcp_port = "tcpPort"; const char* reason = "reason"; +const char* auth_token = "authToken"; } // namespace strings diff --git a/src/components/protocol_handler/include/protocol_handler/protocol_handler_impl.h b/src/components/protocol_handler/include/protocol_handler/protocol_handler_impl.h index ccf6082a18..89800037b5 100644 --- a/src/components/protocol_handler/include/protocol_handler/protocol_handler_impl.h +++ b/src/components/protocol_handler/include/protocol_handler/protocol_handler_impl.h @@ -428,6 +428,9 @@ class ProtocolHandlerImpl void NotifySessionStarted(const SessionContext& context, std::vector& rejected_params) OVERRIDE; + void OnAuthTokenUpdated(const std::string& policy_app_id, + const std::string& auth_token) OVERRIDE; + #ifdef BUILD_TESTS const impl::FromMobileQueue& get_from_mobile_queue() const { return raw_ford_messages_from_mobile_; @@ -777,6 +780,10 @@ class ProtocolHandlerImpl sync_primitives::Lock start_session_frame_map_lock_; StartSessionFrameMap start_session_frame_map_; + // Map policy app id -> auth token + sync_primitives::Lock auth_token_map_lock_; + std::map auth_token_map_; + bool tcp_enabled_; std::string tcp_port_; std::string tcp_ip_address_; diff --git a/src/components/protocol_handler/src/protocol_handler_impl.cc b/src/components/protocol_handler/src/protocol_handler_impl.cc index ee2dc73780..c09fbfe0d8 100644 --- a/src/components/protocol_handler/src/protocol_handler_impl.cc +++ b/src/components/protocol_handler/src/protocol_handler_impl.cc @@ -61,8 +61,9 @@ std::string ConvertPacketDataToString(const uint8_t* data, const size_t kStackSize = 65536; -utils::SemanticVersion defaultProtocolVersion(5, 1, 0); -utils::SemanticVersion minMultipleTransportsVersion(5, 1, 0); +utils::SemanticVersion default_protocol_version(5, 2, 0); +utils::SemanticVersion min_multiple_transports_version(5, 1, 0); +utils::SemanticVersion min_cloud_app_version(5, 2, 0); ProtocolHandlerImpl::ProtocolHandlerImpl( const ProtocolHandlerSettings& settings, @@ -309,16 +310,16 @@ void ProtocolHandlerImpl::SendStartSessionAck( ¶ms, strings::hash_id))); // Minimum protocol version supported by both - utils::SemanticVersion* minVersion = + utils::SemanticVersion* min_version = (full_version.major_version_ < PROTOCOL_VERSION_5) - ? &defaultProtocolVersion + ? &default_protocol_version : utils::SemanticVersion::min(full_version, - defaultProtocolVersion); - char protocolVersionString[256]; - strncpy(protocolVersionString, (*minVersion).toString().c_str(), 255); + default_protocol_version); + char protocol_version_string[256]; + strncpy(protocol_version_string, (*min_version).toString().c_str(), 255); const bool protocol_ver_written = bson_object_put_string( - ¶ms, strings::protocol_version, protocolVersionString); + ¶ms, strings::protocol_version, protocol_version_string); UNUSED(protocol_ver_written); LOG4CXX_DEBUG( logger_, @@ -327,12 +328,12 @@ void ProtocolHandlerImpl::SendStartSessionAck( << bson_object_get_string(¶ms, strings::protocol_version)); LOG4CXX_INFO(logger_, - "Protocol Version String " << protocolVersionString); + "Protocol Version String " << protocol_version_string); std::vector secondaryTransports; std::vector audioServiceTransports; std::vector videoServiceTransports; - if (*minVersion >= minMultipleTransportsVersion) { + if (*min_version >= min_multiple_transports_version) { if (ParseSecondaryTransportConfiguration(connection_id, secondaryTransports, audioServiceTransports, @@ -410,10 +411,22 @@ void ProtocolHandlerImpl::SendStartSessionAck( connection_handler_.SetSecondaryTransportID(session_id, kDisabledSecondary); } + + std::string policy_app_id = + connection_handler_.GetCloudAppID(connection_id); + if (*min_version >= min_cloud_app_version && !policy_app_id.empty()) { + sync_primitives::AutoLock lock(auth_token_map_lock_); + auto it = auth_token_map_.find(policy_app_id); + if (it != auth_token_map_.end()) { + char auth_token[256]; + strncpy(auth_token, it->second.c_str(), 255); + bson_object_put_string(¶ms, strings::auth_token, auth_token); + } + } } - uint8_t* payloadBytes = bson_object_to_bytes(¶ms); - ptr->set_data(payloadBytes, bson_object_size(¶ms)); - free(payloadBytes); + uint8_t* payload_bytes = bson_object_to_bytes(¶ms); + ptr->set_data(payload_bytes, bson_object_size(¶ms)); + free(payload_bytes); } else { set_hash_id(hash_id, *ptr); } @@ -1185,6 +1198,17 @@ void ProtocolHandlerImpl::OnTransportConfigUpdated( } } +void ProtocolHandlerImpl::OnAuthTokenUpdated(const std::string& policy_app_id, + const std::string& auth_token) { + LOG4CXX_AUTO_TRACE(logger_); + sync_primitives::AutoLock lock(auth_token_map_lock_); + if (auth_token.empty()) { + auth_token_map_.erase(policy_app_id); + } else { + auth_token_map_[policy_app_id] = auth_token; + } +} + RESULT_CODE ProtocolHandlerImpl::SendFrame(const ProtocolFramePtr packet) { LOG4CXX_AUTO_TRACE(logger_); if (!packet) { -- cgit v1.2.1 From 45b9c2e8d109ed124c604c4b690b1847bc93c9c6 Mon Sep 17 00:00:00 2001 From: Jacob Keeler Date: Tue, 26 Feb 2019 12:53:56 -0500 Subject: PerformAppServiceInteraction RPC (#2815) * Add PerformAppServiceInteraction RPC * Add handling for `requestServiceActive` parameter * Fix style * Change PerformAppServiceInteraction class naming Clarify direction in class name --- src/appMain/sdl_preloaded_pt.json | 14 +- .../application_manager/app_service_manager.h | 16 +- .../commands/request_from_hmi.h | 12 +- .../application_manager/smart_object_keys.h | 2 +- .../hmi/as_get_active_service_consent_request.h | 80 ++++++++++ .../hmi/as_get_active_service_consent_response.h | 80 ++++++++++ ...form_app_service_interaction_request_from_hmi.h | 94 +++++++++++ ...erform_app_service_interaction_request_to_hmi.h | 80 ++++++++++ ...orm_app_service_interaction_response_from_hmi.h | 80 ++++++++++ ...rform_app_service_interaction_response_to_hmi.h | 80 ++++++++++ .../perform_app_service_interaction_request.h | 89 +++++++++++ ...orm_app_service_interaction_request_to_mobile.h | 80 ++++++++++ .../perform_app_service_interaction_response.h | 80 ++++++++++ ..._app_service_interaction_response_from_mobile.h | 80 ++++++++++ .../src/app_service_hmi_command_factory.cc | 43 ++++- .../src/app_service_mobile_command_factory.cc | 29 +++- .../hmi/as_get_active_service_consent_request.cc | 59 +++++++ .../hmi/as_get_active_service_consent_response.cc | 62 ++++++++ ...orm_app_service_interaction_request_from_hmi.cc | 137 ++++++++++++++++ ...rform_app_service_interaction_request_to_hmi.cc | 61 +++++++ ...rm_app_service_interaction_response_from_hmi.cc | 64 ++++++++ ...form_app_service_interaction_response_to_hmi.cc | 61 +++++++ .../perform_app_service_interaction_request.cc | 176 +++++++++++++++++++++ ...rm_app_service_interaction_request_to_mobile.cc | 63 ++++++++ .../perform_app_service_interaction_response.cc | 61 +++++++ ...app_service_interaction_response_from_mobile.cc | 66 ++++++++ .../application_manager/src/app_service_manager.cc | 81 ++++++---- .../src/commands/command_request_impl.cc | 18 ++- .../src/commands/request_from_hmi.cc | 21 ++- .../application_manager/src/hmi_interfaces_impl.cc | 4 + .../application_manager/src/smart_object_keys.cc | 1 + src/components/interfaces/HMI_API.xml | 42 +++++ src/components/interfaces/MOBILE_API.xml | 39 ++++- .../include/policy/policy_table/enums.h | 5 + .../policy_external/src/policy_table/enums.cc | 5 + .../include/policy/policy_table/enums.h | 5 + .../policy_regular/src/policy_table/enums.cc | 9 ++ 37 files changed, 1920 insertions(+), 59 deletions(-) create mode 100644 src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/hmi/as_get_active_service_consent_request.h create mode 100644 src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/hmi/as_get_active_service_consent_response.h create mode 100644 src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/hmi/as_perform_app_service_interaction_request_from_hmi.h create mode 100644 src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/hmi/as_perform_app_service_interaction_request_to_hmi.h create mode 100644 src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/hmi/as_perform_app_service_interaction_response_from_hmi.h create mode 100644 src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/hmi/as_perform_app_service_interaction_response_to_hmi.h create mode 100644 src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/mobile/perform_app_service_interaction_request.h create mode 100644 src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/mobile/perform_app_service_interaction_request_to_mobile.h create mode 100644 src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/mobile/perform_app_service_interaction_response.h create mode 100644 src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/mobile/perform_app_service_interaction_response_from_mobile.h create mode 100644 src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_get_active_service_consent_request.cc create mode 100644 src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_get_active_service_consent_response.cc create mode 100644 src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_perform_app_service_interaction_request_from_hmi.cc create mode 100644 src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_perform_app_service_interaction_request_to_hmi.cc create mode 100644 src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_perform_app_service_interaction_response_from_hmi.cc create mode 100644 src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_perform_app_service_interaction_response_to_hmi.cc create mode 100644 src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/perform_app_service_interaction_request.cc create mode 100644 src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/perform_app_service_interaction_request_to_mobile.cc create mode 100644 src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/perform_app_service_interaction_response.cc create mode 100644 src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/perform_app_service_interaction_response_from_mobile.cc diff --git a/src/appMain/sdl_preloaded_pt.json b/src/appMain/sdl_preloaded_pt.json index 57f7587542..8041a0d4e9 100644 --- a/src/appMain/sdl_preloaded_pt.json +++ b/src/appMain/sdl_preloaded_pt.json @@ -583,10 +583,20 @@ "AppService":{ "rpcs":{ "PublishAppService":{ - "hmi_levels":["BACKGROUND", + "hmi_levels": [ + "BACKGROUND", + "FULL", + "LIMITED", + "NONE" + ] + }, + "PerformAppServiceInteraction": { + "hmi_levels": [ + "BACKGROUND", "FULL", "LIMITED", - "NONE"] + "NONE" + ] } } }, diff --git a/src/components/application_manager/include/application_manager/app_service_manager.h b/src/components/application_manager/include/application_manager/app_service_manager.h index b910118942..386b473f3d 100644 --- a/src/components/application_manager/include/application_manager/app_service_manager.h +++ b/src/components/application_manager/include/application_manager/app_service_manager.h @@ -131,9 +131,14 @@ class AppServiceManager { */ std::vector GetAllServices(); - void GetProvider(const std::string& service_type, - ApplicationSharedPtr& app, - bool& hmi_service); + void GetProviderByType(const std::string& service_type, + ApplicationSharedPtr& app, + bool& hmi_service); + + void GetProviderByID(const std::string& service_id, + ApplicationSharedPtr& app, + bool& hmi_service); + std::pair ActiveServiceByType( std::string service_type); @@ -142,9 +147,14 @@ class AppServiceManager { std::pair FindServiceByName(std::string name); + std::pair FindServiceByID(std::string service_id); + std::string DefaultServiceByType(std::string service_type); private: + void GetProviderFromService(const AppService& service, + ApplicationSharedPtr& app, + bool& hmi_service); ApplicationManager& app_manager_; resumption::LastState& last_state_; std::map published_services_; diff --git a/src/components/application_manager/include/application_manager/commands/request_from_hmi.h b/src/components/application_manager/include/application_manager/commands/request_from_hmi.h index 0a5f5d7eee..a37e0a289e 100644 --- a/src/components/application_manager/include/application_manager/commands/request_from_hmi.h +++ b/src/components/application_manager/include/application_manager/commands/request_from_hmi.h @@ -101,6 +101,12 @@ class RequestFromHMI : public CommandImpl, public event_engine::EventObserver { const uint32_t hmi_correlation_id, const hmi_apis::FunctionID::eType& function_id); + protected: + bool IsMobileResultSuccess(mobile_apis::Result::eType result_code) const; + + bool IsHMIResultSuccess(hmi_apis::Common_Result::eType result_code, + HmiInterfaces::InterfaceID interface) const; + private: /** * @brief Fills common parameters for SO @@ -113,12 +119,6 @@ class RequestFromHMI : public CommandImpl, public event_engine::EventObserver { const uint32_t correlation_id, const hmi_apis::FunctionID::eType function_id); - protected: - bool IsMobileResultSuccess(mobile_apis::Result::eType result_code) const; - - bool IsHMIResultSuccess(hmi_apis::Common_Result::eType result_code, - HmiInterfaces::InterfaceID interface) const; - private: DISALLOW_COPY_AND_ASSIGN(RequestFromHMI); }; 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 d6c5f165da..33fc3bd7d5 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 @@ -319,7 +319,7 @@ extern const char* service_manifest; extern const char* service_published; extern const char* service_active; extern const char* service_data; -extern const char* subscribe; +extern const char* request_service_active; extern const char* app_services; extern const char* update_reason; extern const char* updated_app_service_record; diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/hmi/as_get_active_service_consent_request.h b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/hmi/as_get_active_service_consent_request.h new file mode 100644 index 0000000000..2286d4c67c --- /dev/null +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/hmi/as_get_active_service_consent_request.h @@ -0,0 +1,80 @@ +/* + Copyright (c) 2019, Ford Motor Company, Livio + 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 the copyright holders nor the names of their + 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. + */ + +#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_APP_SERVICE_RPC_PLUGIN_INCLUDE_APP_SERVICE_RPC_PLUGIN_COMMANDS_HMI_AS_GET_ACTIVE_SERVICE_CONSENT_REQUEST_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_APP_SERVICE_RPC_PLUGIN_INCLUDE_APP_SERVICE_RPC_PLUGIN_COMMANDS_HMI_AS_GET_ACTIVE_SERVICE_CONSENT_REQUEST_H_ + +#include "app_service_rpc_plugin/app_service_rpc_plugin.h" +#include "application_manager/commands/request_to_hmi.h" + +namespace app_service_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief ASGetActiveServiceConsentRequest command class + **/ +class ASGetActiveServiceConsentRequest + : public app_mngr::commands::RequestToHMI { + public: + /** + * @brief ASGetActiveServiceConsentRequest class constructor + * + * @param message Incoming SmartObject message + **/ + ASGetActiveServiceConsentRequest( + const app_mngr::commands::MessageSharedPtr& message, + app_mngr::ApplicationManager& application_manager, + app_mngr::rpc_service::RPCService& rpc_service, + app_mngr::HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle); + + /** + * @brief ASGetActiveServiceConsentRequest class destructor + **/ + virtual ~ASGetActiveServiceConsentRequest(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(ASGetActiveServiceConsentRequest); +}; + +} // namespace commands + +} // namespace app_service_rpc_plugin + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_APP_SERVICE_RPC_PLUGIN_INCLUDE_APP_SERVICE_RPC_PLUGIN_COMMANDS_HMI_AS_GET_ACTIVE_SERVICE_CONSENT_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/hmi/as_get_active_service_consent_response.h b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/hmi/as_get_active_service_consent_response.h new file mode 100644 index 0000000000..f69152208c --- /dev/null +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/hmi/as_get_active_service_consent_response.h @@ -0,0 +1,80 @@ +/* + Copyright (c) 2019, Ford Motor Company, Livio + 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 the copyright holders nor the names of their + 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. + */ + +#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_APP_SERVICE_RPC_PLUGIN_INCLUDE_APP_SERVICE_RPC_PLUGIN_COMMANDS_HMI_AS_GET_ACTIVE_SERVICE_CONSENT_RESPONSE_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_APP_SERVICE_RPC_PLUGIN_INCLUDE_APP_SERVICE_RPC_PLUGIN_COMMANDS_HMI_AS_GET_ACTIVE_SERVICE_CONSENT_RESPONSE_H_ + +#include "app_service_rpc_plugin/app_service_rpc_plugin.h" +#include "application_manager/commands/response_from_hmi.h" + +namespace app_service_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief ASGetActiveServiceConsentResponse command class + **/ +class ASGetActiveServiceConsentResponse + : public app_mngr::commands::ResponseFromHMI { + public: + /** + * @brief ASGetActiveServiceConsentResponse class constructor + * + * @param message Incoming SmartObject message + **/ + ASGetActiveServiceConsentResponse( + const app_mngr::commands::MessageSharedPtr& message, + app_mngr::ApplicationManager& application_manager, + app_mngr::rpc_service::RPCService& rpc_service, + app_mngr::HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle); + + /** + * @brief ASGetActiveServiceConsentResponse class destructor + **/ + virtual ~ASGetActiveServiceConsentResponse(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(ASGetActiveServiceConsentResponse); +}; + +} // namespace commands + +} // namespace app_service_rpc_plugin + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_APP_SERVICE_RPC_PLUGIN_INCLUDE_APP_SERVICE_RPC_PLUGIN_COMMANDS_HMI_AS_GET_ACTIVE_SERVICE_CONSENT_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/hmi/as_perform_app_service_interaction_request_from_hmi.h b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/hmi/as_perform_app_service_interaction_request_from_hmi.h new file mode 100644 index 0000000000..775bb9f812 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/hmi/as_perform_app_service_interaction_request_from_hmi.h @@ -0,0 +1,94 @@ +/* + Copyright (c) 2019, Ford Motor Company, Livio + 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 the copyright holders nor the names of their + 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. + */ + +#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_APP_SERVICE_RPC_PLUGIN_INCLUDE_APP_SERVICE_RPC_PLUGIN_COMMANDS_HMI_AS_PERFORM_APP_SERVICE_INTERACTION_REQUEST_FROM_HMI_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_APP_SERVICE_RPC_PLUGIN_INCLUDE_APP_SERVICE_RPC_PLUGIN_COMMANDS_HMI_AS_PERFORM_APP_SERVICE_INTERACTION_REQUEST_FROM_HMI_H_ + +#include "app_service_rpc_plugin/app_service_rpc_plugin.h" +#include "application_manager/commands/request_from_hmi.h" + +namespace app_service_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief ASPerformAppServiceInteractionRequestFromHMI command class + **/ +class ASPerformAppServiceInteractionRequestFromHMI + : public app_mngr::commands::RequestFromHMI { + public: + /** + * @brief ASPerformAppServiceInteractionRequestFromHMI class constructor + * + * @param message Incoming SmartObject message + **/ + ASPerformAppServiceInteractionRequestFromHMI( + const app_mngr::commands::MessageSharedPtr& message, + app_mngr::ApplicationManager& application_manager, + app_mngr::rpc_service::RPCService& rpc_service, + app_mngr::HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle); + + /** + * @brief ASPerformAppServiceInteractionRequestFromHMI class destructor + **/ + virtual ~ASPerformAppServiceInteractionRequestFromHMI(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + /** + * @brief on_event allows to handle events + * + * @param event event type that current request subscribed on. + */ + void on_event(const app_mngr::event_engine::Event& event) OVERRIDE; + + /** + * @brief on_event allows to handle events + * + * @param event event type that current request subscribed on. + */ + void on_event(const app_mngr::event_engine::MobileEvent& event) OVERRIDE; + + private: + DISALLOW_COPY_AND_ASSIGN(ASPerformAppServiceInteractionRequestFromHMI); +}; + +} // namespace commands + +} // namespace app_service_rpc_plugin + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_APP_SERVICE_RPC_PLUGIN_INCLUDE_APP_SERVICE_RPC_PLUGIN_COMMANDS_HMI_AS_PERFORM_APP_SERVICE_INTERACTION_REQUEST_FROM_HMI_H_ diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/hmi/as_perform_app_service_interaction_request_to_hmi.h b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/hmi/as_perform_app_service_interaction_request_to_hmi.h new file mode 100644 index 0000000000..0b67dd5624 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/hmi/as_perform_app_service_interaction_request_to_hmi.h @@ -0,0 +1,80 @@ +/* + Copyright (c) 2019, Ford Motor Company, Livio + 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 the copyright holders nor the names of their + 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. + */ + +#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_APP_SERVICE_RPC_PLUGIN_INCLUDE_APP_SERVICE_RPC_PLUGIN_COMMANDS_HMI_AS_PERFORM_APP_SERVICE_INTERACTION_REQUEST_TO_HMI_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_APP_SERVICE_RPC_PLUGIN_INCLUDE_APP_SERVICE_RPC_PLUGIN_COMMANDS_HMI_AS_PERFORM_APP_SERVICE_INTERACTION_REQUEST_TO_HMI_H_ + +#include "app_service_rpc_plugin/app_service_rpc_plugin.h" +#include "application_manager/commands/request_to_hmi.h" + +namespace app_service_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief ASPerformAppServiceInteractionRequestToHMI command class + **/ +class ASPerformAppServiceInteractionRequestToHMI + : public app_mngr::commands::RequestToHMI { + public: + /** + * @brief ASPerformAppServiceInteractionRequestToHMI class constructor + * + * @param message Incoming SmartObject message + **/ + ASPerformAppServiceInteractionRequestToHMI( + const app_mngr::commands::MessageSharedPtr& message, + app_mngr::ApplicationManager& application_manager, + app_mngr::rpc_service::RPCService& rpc_service, + app_mngr::HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle); + + /** + * @brief ASPerformAppServiceInteractionRequestToHMI class destructor + **/ + virtual ~ASPerformAppServiceInteractionRequestToHMI(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(ASPerformAppServiceInteractionRequestToHMI); +}; + +} // namespace commands + +} // namespace app_service_rpc_plugin + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_APP_SERVICE_RPC_PLUGIN_INCLUDE_APP_SERVICE_RPC_PLUGIN_COMMANDS_HMI_AS_PERFORM_APP_SERVICE_INTERACTION_REQUEST_TO_HMI_H_ diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/hmi/as_perform_app_service_interaction_response_from_hmi.h b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/hmi/as_perform_app_service_interaction_response_from_hmi.h new file mode 100644 index 0000000000..f807348833 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/hmi/as_perform_app_service_interaction_response_from_hmi.h @@ -0,0 +1,80 @@ +/* + Copyright (c) 2019, Ford Motor Company, Livio + 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 the copyright holders nor the names of their + 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. + */ + +#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_APP_SERVICE_RPC_PLUGIN_INCLUDE_APP_SERVICE_RPC_PLUGIN_COMMANDS_HMI_AS_PERFORM_APP_SERVICE_INTERACTION_RESPONSE_FROM_HMI_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_APP_SERVICE_RPC_PLUGIN_INCLUDE_APP_SERVICE_RPC_PLUGIN_COMMANDS_HMI_AS_PERFORM_APP_SERVICE_INTERACTION_RESPONSE_FROM_HMI_H_ + +#include "app_service_rpc_plugin/app_service_rpc_plugin.h" +#include "application_manager/commands/response_from_hmi.h" + +namespace app_service_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief ASPerformAppServiceInteractionResponseFromHMI command class + **/ +class ASPerformAppServiceInteractionResponseFromHMI + : public app_mngr::commands::ResponseFromHMI { + public: + /** + * @brief ASPerformAppServiceInteractionResponseFromHMI class constructor + * + * @param message Incoming SmartObject message + **/ + ASPerformAppServiceInteractionResponseFromHMI( + const app_mngr::commands::MessageSharedPtr& message, + app_mngr::ApplicationManager& application_manager, + app_mngr::rpc_service::RPCService& rpc_service, + app_mngr::HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle); + + /** + * @brief ASPerformAppServiceInteractionResponseFromHMI class destructor + **/ + virtual ~ASPerformAppServiceInteractionResponseFromHMI(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(ASPerformAppServiceInteractionResponseFromHMI); +}; + +} // namespace commands + +} // namespace app_service_rpc_plugin + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_APP_SERVICE_RPC_PLUGIN_INCLUDE_APP_SERVICE_RPC_PLUGIN_COMMANDS_HMI_AS_PERFORM_APP_SERVICE_INTERACTION_RESPONSE_FROM_HMI_H_ diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/hmi/as_perform_app_service_interaction_response_to_hmi.h b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/hmi/as_perform_app_service_interaction_response_to_hmi.h new file mode 100644 index 0000000000..7ce05bdba1 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/hmi/as_perform_app_service_interaction_response_to_hmi.h @@ -0,0 +1,80 @@ +/* + Copyright (c) 2019, Ford Motor Company, Livio + 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 the copyright holders nor the names of their + 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. + */ + +#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_APP_SERVICE_RPC_PLUGIN_INCLUDE_APP_SERVICE_RPC_PLUGIN_COMMANDS_HMI_AS_PERFORM_APP_SERVICE_INTERACTION_RESPONSE_TO_HMI_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_APP_SERVICE_RPC_PLUGIN_INCLUDE_APP_SERVICE_RPC_PLUGIN_COMMANDS_HMI_AS_PERFORM_APP_SERVICE_INTERACTION_RESPONSE_TO_HMI_H_ + +#include "app_service_rpc_plugin/app_service_rpc_plugin.h" +#include "application_manager/commands/response_to_hmi.h" + +namespace app_service_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief ASPerformAppServiceInteractionResponseToHMI command class + **/ +class ASPerformAppServiceInteractionResponseToHMI + : public app_mngr::commands::ResponseToHMI { + public: + /** + * @brief ASPerformAppServiceInteractionResponseToHMI class constructor + * + * @param message Incoming SmartObject message + **/ + ASPerformAppServiceInteractionResponseToHMI( + const app_mngr::commands::MessageSharedPtr& message, + app_mngr::ApplicationManager& application_manager, + app_mngr::rpc_service::RPCService& rpc_service, + app_mngr::HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle); + + /** + * @brief ASPerformAppServiceInteractionResponseToHMI class destructor + **/ + virtual ~ASPerformAppServiceInteractionResponseToHMI(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(ASPerformAppServiceInteractionResponseToHMI); +}; + +} // namespace commands + +} // namespace app_service_rpc_plugin + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_APP_SERVICE_RPC_PLUGIN_INCLUDE_APP_SERVICE_RPC_PLUGIN_COMMANDS_HMI_AS_PERFORM_APP_SERVICE_INTERACTION_RESPONSE_TO_HMI_H_ diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/mobile/perform_app_service_interaction_request.h b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/mobile/perform_app_service_interaction_request.h new file mode 100644 index 0000000000..854ed3c6aa --- /dev/null +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/mobile/perform_app_service_interaction_request.h @@ -0,0 +1,89 @@ +/* + Copyright (c) 2019, Ford Motor Company, Livio + 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 the copyright holders nor the names of their + 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. + */ + +#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_APP_SERVICE_RPC_PLUGIN_INCLUDE_APP_SERVICE_RPC_PLUGIN_COMMANDS_MOBILE_PERFORM_APP_SERVICE_INTERACTION_REQUEST_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_APP_SERVICE_RPC_PLUGIN_INCLUDE_APP_SERVICE_RPC_PLUGIN_COMMANDS_MOBILE_PERFORM_APP_SERVICE_INTERACTION_REQUEST_H_ + +#include "app_service_rpc_plugin/app_service_rpc_plugin.h" +#include "application_manager/commands/command_request_impl.h" + +namespace app_service_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief PerformAppServiceInteractionRequest command class + **/ +class PerformAppServiceInteractionRequest + : public app_mngr::commands::CommandRequestImpl { + public: + /** + * @brief PerformAppServiceInteractionRequest class constructor + * + * @param message Incoming SmartObject message + **/ + PerformAppServiceInteractionRequest( + const app_mngr::commands::MessageSharedPtr& message, + app_mngr::ApplicationManager& application_manager, + app_mngr::rpc_service::RPCService& rpc_service, + app_mngr::HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle); + + /** + * @brief PerformAppServiceInteractionRequest class destructor + **/ + virtual ~PerformAppServiceInteractionRequest(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + /** + * @brief Interface method that is called whenever new event received + * + * @param event The received event + */ + virtual void on_event(const app_mngr::event_engine::Event& event); + + virtual void on_event(const app_mngr::event_engine::MobileEvent& event); + + private: + DISALLOW_COPY_AND_ASSIGN(PerformAppServiceInteractionRequest); +}; + +} // namespace commands + +} // namespace app_service_rpc_plugin + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_APP_SERVICE_RPC_PLUGIN_INCLUDE_APP_SERVICE_RPC_PLUGIN_COMMANDS_MOBILE_PERFORM_APP_SERVICE_INTERACTION_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/mobile/perform_app_service_interaction_request_to_mobile.h b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/mobile/perform_app_service_interaction_request_to_mobile.h new file mode 100644 index 0000000000..5c38e6a71e --- /dev/null +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/mobile/perform_app_service_interaction_request_to_mobile.h @@ -0,0 +1,80 @@ +/* + Copyright (c) 2019, Ford Motor Company, Livio + 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 the copyright holders nor the names of their + 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. + */ + +#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_APP_SERVICE_RPC_PLUGIN_INCLUDE_APP_SERVICE_RPC_PLUGIN_COMMANDS_MOBILE_PERFORM_APP_SERVICE_INTERACTION_REQUEST_TO_MOBILE_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_APP_SERVICE_RPC_PLUGIN_INCLUDE_APP_SERVICE_RPC_PLUGIN_COMMANDS_MOBILE_PERFORM_APP_SERVICE_INTERACTION_REQUEST_TO_MOBILE_H_ + +#include "app_service_rpc_plugin/app_service_rpc_plugin.h" +#include "application_manager/commands/command_request_to_mobile.h" + +namespace app_service_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief PerformAppServiceInteractionRequestToMobile command class + **/ +class PerformAppServiceInteractionRequestToMobile + : public app_mngr::commands::CommandRequestToMobile { + public: + /** + * @brief PerformAppServiceInteractionRequestToMobile class constructor + * + * @param message Incoming SmartObject message + **/ + PerformAppServiceInteractionRequestToMobile( + const app_mngr::commands::MessageSharedPtr& message, + app_mngr::ApplicationManager& application_manager, + app_mngr::rpc_service::RPCService& rpc_service, + app_mngr::HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle); + + /** + * @brief PerformAppServiceInteractionRequestToMobile class destructor + **/ + virtual ~PerformAppServiceInteractionRequestToMobile(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(PerformAppServiceInteractionRequestToMobile); +}; + +} // namespace commands + +} // namespace app_service_rpc_plugin + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_APP_SERVICE_RPC_PLUGIN_INCLUDE_APP_SERVICE_RPC_PLUGIN_COMMANDS_MOBILE_PERFORM_APP_SERVICE_INTERACTION_REQUEST_TO_MOBILE_H_ diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/mobile/perform_app_service_interaction_response.h b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/mobile/perform_app_service_interaction_response.h new file mode 100644 index 0000000000..b4c422fac6 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/mobile/perform_app_service_interaction_response.h @@ -0,0 +1,80 @@ +/* + Copyright (c) 2019, Ford Motor Company, Livio + 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 the copyright holders nor the names of their + 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. + */ + +#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_APP_SERVICE_RPC_PLUGIN_INCLUDE_APP_SERVICE_RPC_PLUGIN_COMMANDS_MOBILE_PERFORM_APP_SERVICE_INTERACTION_RESPONSE_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_APP_SERVICE_RPC_PLUGIN_INCLUDE_APP_SERVICE_RPC_PLUGIN_COMMANDS_MOBILE_PERFORM_APP_SERVICE_INTERACTION_RESPONSE_H_ + +#include "app_service_rpc_plugin/app_service_rpc_plugin.h" +#include "application_manager/commands/command_response_impl.h" + +namespace app_service_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief PerformAppServiceInteractionResponse command class + **/ +class PerformAppServiceInteractionResponse + : public app_mngr::commands::CommandResponseImpl { + public: + /** + * @brief PerformAppServiceInteractionResponse class constructor + * + * @param message Incoming SmartObject message + **/ + PerformAppServiceInteractionResponse( + const app_mngr::commands::MessageSharedPtr& message, + app_mngr::ApplicationManager& application_manager, + app_mngr::rpc_service::RPCService& rpc_service, + app_mngr::HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle); + + /** + * @brief PerformAppServiceInteractionResponse class destructor + **/ + virtual ~PerformAppServiceInteractionResponse(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(PerformAppServiceInteractionResponse); +}; + +} // namespace commands + +} // namespace app_service_rpc_plugin + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_APP_SERVICE_RPC_PLUGIN_INCLUDE_APP_SERVICE_RPC_PLUGIN_COMMANDS_MOBILE_PERFORM_APP_SERVICE_INTERACTION_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/mobile/perform_app_service_interaction_response_from_mobile.h b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/mobile/perform_app_service_interaction_response_from_mobile.h new file mode 100644 index 0000000000..4530cb2dfd --- /dev/null +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/mobile/perform_app_service_interaction_response_from_mobile.h @@ -0,0 +1,80 @@ +/* + Copyright (c) 2019, Ford Motor Company, Livio + 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 the copyright holders nor the names of their + 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. + */ + +#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_APP_SERVICE_RPC_PLUGIN_INCLUDE_APP_SERVICE_RPC_PLUGIN_COMMANDS_MOBILE_PERFORM_APP_SERVICE_INTERACTION_RESPONSE_FROM_MOBILE_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_APP_SERVICE_RPC_PLUGIN_INCLUDE_APP_SERVICE_RPC_PLUGIN_COMMANDS_MOBILE_PERFORM_APP_SERVICE_INTERACTION_RESPONSE_FROM_MOBILE_H_ + +#include "app_service_rpc_plugin/app_service_rpc_plugin.h" +#include "application_manager/commands/command_response_from_mobile.h" + +namespace app_service_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief PerformAppServiceInteractionResponseFromMobile command class + **/ +class PerformAppServiceInteractionResponseFromMobile + : public app_mngr::commands::CommandResponseFromMobile { + public: + /** + * @brief PerformAppServiceInteractionResponseFromMobile class constructor + * + * @param message Incoming SmartObject message + **/ + PerformAppServiceInteractionResponseFromMobile( + const app_mngr::commands::MessageSharedPtr& message, + app_mngr::ApplicationManager& application_manager, + app_mngr::rpc_service::RPCService& rpc_service, + app_mngr::HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle); + + /** + * @brief PerformAppServiceInteractionResponseFromMobile class destructor + **/ + virtual ~PerformAppServiceInteractionResponseFromMobile(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(PerformAppServiceInteractionResponseFromMobile); +}; + +} // namespace commands + +} // namespace app_service_rpc_plugin + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_APP_SERVICE_RPC_PLUGIN_INCLUDE_APP_SERVICE_RPC_PLUGIN_COMMANDS_MOBILE_PERFORM_APP_SERVICE_INTERACTION_RESPONSE_FROM_MOBILE_H_ diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/app_service_hmi_command_factory.cc b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/app_service_hmi_command_factory.cc index b2b5ec7974..7cfbdd22d0 100644 --- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/app_service_hmi_command_factory.cc +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/app_service_hmi_command_factory.cc @@ -36,16 +36,22 @@ #include "app_service_rpc_plugin/commands/hmi/as_app_service_activation_request.h" #include "app_service_rpc_plugin/commands/hmi/as_app_service_activation_response.h" +#include "app_service_rpc_plugin/commands/hmi/as_get_active_service_consent_request.h" +#include "app_service_rpc_plugin/commands/hmi/as_get_active_service_consent_response.h" +#include "app_service_rpc_plugin/commands/hmi/as_get_app_service_data_request_from_hmi.h" +#include "app_service_rpc_plugin/commands/hmi/as_get_app_service_data_request_to_hmi.h" +#include "app_service_rpc_plugin/commands/hmi/as_get_app_service_data_response_from_hmi.h" +#include "app_service_rpc_plugin/commands/hmi/as_get_app_service_data_response_to_hmi.h" #include "app_service_rpc_plugin/commands/hmi/as_get_app_service_records_request.h" #include "app_service_rpc_plugin/commands/hmi/as_get_app_service_records_response.h" +#include "app_service_rpc_plugin/commands/hmi/as_perform_app_service_interaction_request_from_hmi.h" +#include "app_service_rpc_plugin/commands/hmi/as_perform_app_service_interaction_request_to_hmi.h" +#include "app_service_rpc_plugin/commands/hmi/as_perform_app_service_interaction_response_from_hmi.h" +#include "app_service_rpc_plugin/commands/hmi/as_perform_app_service_interaction_response_to_hmi.h" #include "app_service_rpc_plugin/commands/hmi/as_publish_app_service_request.h" #include "app_service_rpc_plugin/commands/hmi/as_publish_app_service_response.h" #include "app_service_rpc_plugin/commands/hmi/on_as_app_service_data_notification.h" #include "app_service_rpc_plugin/commands/hmi/on_as_app_service_data_notification_from_hmi.h" -#include "app_service_rpc_plugin/commands/hmi/as_get_app_service_data_request_from_hmi.h" -#include "app_service_rpc_plugin/commands/hmi/as_get_app_service_data_response_from_hmi.h" -#include "app_service_rpc_plugin/commands/hmi/as_get_app_service_data_request_to_hmi.h" -#include "app_service_rpc_plugin/commands/hmi/as_get_app_service_data_response_to_hmi.h" CREATE_LOGGERPTR_GLOBAL(logger_, "AppServiceRpcPlugin") @@ -141,7 +147,7 @@ app_mngr::CommandCreator& AppServiceHmiCommandFactory::buildCommandCreator( : factory.GetCreator< commands::ASGetAppServiceDataResponseToHMI>(); } - + break; case hmi_apis::FunctionID::AppService_GetAppServiceRecords: return hmi_apis::messageType::request == message_type ? factory.GetCreator() @@ -152,9 +158,34 @@ app_mngr::CommandCreator& AppServiceHmiCommandFactory::buildCommandCreator( ? factory.GetCreator() : factory .GetCreator(); + case hmi_apis::FunctionID::AppService_PerformAppServiceInteraction: + if (app_mngr::commands::Command::CommandSource::SOURCE_HMI == source) { + return hmi_apis::messageType::request == message_type + ? factory.GetCreator< + commands:: + ASPerformAppServiceInteractionRequestFromHMI>() + : factory.GetCreator< + commands:: + ASPerformAppServiceInteractionResponseFromHMI>(); + } else if (app_mngr::commands::Command::CommandSource:: + SOURCE_SDL_TO_HMI == source) { + return hmi_apis::messageType::request == message_type + ? factory.GetCreator< + commands::ASPerformAppServiceInteractionRequestToHMI>() + : factory.GetCreator< + commands:: + ASPerformAppServiceInteractionResponseToHMI>(); + } + break; + case hmi_apis::FunctionID::AppService_GetActiveServiceConsent: + return hmi_apis::messageType::request == message_type + ? factory + .GetCreator() + : factory.GetCreator< + commands::ASGetActiveServiceConsentResponse>(); default: LOG4CXX_WARN(logger_, "Unsupported HMI function_id: " << function_id); - return factory.GetCreator(); } + return factory.GetCreator(); } } diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/app_service_mobile_command_factory.cc b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/app_service_mobile_command_factory.cc index 3e00408a91..572e637108 100644 --- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/app_service_mobile_command_factory.cc +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/app_service_mobile_command_factory.cc @@ -35,8 +35,16 @@ #include "application_manager/message.h" #include "interfaces/MOBILE_API.h" +#include "app_service_rpc_plugin/commands/mobile/get_app_service_data_request.h" +#include "app_service_rpc_plugin/commands/mobile/get_app_service_data_request_to_mobile.h" +#include "app_service_rpc_plugin/commands/mobile/get_app_service_data_response.h" +#include "app_service_rpc_plugin/commands/mobile/get_app_service_data_response_from_mobile.h" #include "app_service_rpc_plugin/commands/mobile/on_app_service_data_notification.h" #include "app_service_rpc_plugin/commands/mobile/on_app_service_data_notification_from_mobile.h" +#include "app_service_rpc_plugin/commands/mobile/perform_app_service_interaction_request.h" +#include "app_service_rpc_plugin/commands/mobile/perform_app_service_interaction_request_to_mobile.h" +#include "app_service_rpc_plugin/commands/mobile/perform_app_service_interaction_response.h" +#include "app_service_rpc_plugin/commands/mobile/perform_app_service_interaction_response_from_mobile.h" #include "app_service_rpc_plugin/commands/mobile/publish_app_service_request.h" #include "app_service_rpc_plugin/commands/mobile/publish_app_service_response.h" #include "app_service_rpc_plugin/commands/mobile/get_app_service_data_request.h" @@ -128,9 +136,28 @@ app_mngr::CommandCreator& AppServiceMobileCommandFactory::buildCommandCreator( commands::GetAppServiceDataRequestToMobile>() : factory.GetCreator(); } + break; + case mobile_apis::FunctionID::PerformAppServiceInteractionID: + if (app_mngr::commands::Command::CommandSource::SOURCE_MOBILE == source) { + return mobile_apis::messageType::request == message_type + ? factory.GetCreator< + commands::PerformAppServiceInteractionRequest>() + : factory.GetCreator< + commands:: + PerformAppServiceInteractionResponseFromMobile>(); + } else if (app_mngr::commands::Command::CommandSource::SOURCE_SDL == + source) { + return mobile_apis::messageType::request == message_type + ? factory.GetCreator< + commands:: + PerformAppServiceInteractionRequestToMobile>() + : factory.GetCreator< + commands::PerformAppServiceInteractionResponse>(); + } + break; default: LOG4CXX_WARN(logger_, "Unsupported function_id: " << function_id); - return factory.GetCreator(); } + return factory.GetCreator(); } } // namespace vehicle_info_plugin diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_get_active_service_consent_request.cc b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_get_active_service_consent_request.cc new file mode 100644 index 0000000000..b1f3d6fdbf --- /dev/null +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_get_active_service_consent_request.cc @@ -0,0 +1,59 @@ +/* + Copyright (c) 2019, Ford Motor Company, Livio + 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 the copyright holders nor the names of their + 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 "app_service_rpc_plugin/commands/hmi/as_get_active_service_consent_request.h" + +namespace app_service_rpc_plugin { +using namespace application_manager; +namespace commands { + +ASGetActiveServiceConsentRequest::ASGetActiveServiceConsentRequest( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + app_mngr::rpc_service::RPCService& rpc_service, + app_mngr::HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handler) + : RequestToHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handler) {} + +ASGetActiveServiceConsentRequest::~ASGetActiveServiceConsentRequest() {} + +void ASGetActiveServiceConsentRequest::Run() { + LOG4CXX_AUTO_TRACE(logger_); + SendRequest(); +} + +} // namespace commands +} // namespace app_service_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_get_active_service_consent_response.cc b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_get_active_service_consent_response.cc new file mode 100644 index 0000000000..038c2922ad --- /dev/null +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_get_active_service_consent_response.cc @@ -0,0 +1,62 @@ +/* + Copyright (c) 2019, Ford Motor Company, Livio + 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 the copyright holders nor the names of their + 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 "app_service_rpc_plugin/commands/hmi/as_get_active_service_consent_response.h" + +namespace app_service_rpc_plugin { +using namespace application_manager; +namespace commands { + +ASGetActiveServiceConsentResponse::ASGetActiveServiceConsentResponse( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + app_mngr::rpc_service::RPCService& rpc_service, + app_mngr::HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handler) + : ResponseFromHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handler) {} + +ASGetActiveServiceConsentResponse::~ASGetActiveServiceConsentResponse() {} + +void ASGetActiveServiceConsentResponse::Run() { + LOG4CXX_AUTO_TRACE(logger_); + event_engine::Event event( + hmi_apis::FunctionID::AppService_GetActiveServiceConsent); + event.set_smart_object(*message_); + event.raise(application_manager_.event_dispatcher()); +} + +} // namespace commands +} // namespace app_service_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_perform_app_service_interaction_request_from_hmi.cc b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_perform_app_service_interaction_request_from_hmi.cc new file mode 100644 index 0000000000..8f52268f19 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_perform_app_service_interaction_request_from_hmi.cc @@ -0,0 +1,137 @@ +/* + Copyright (c) 2019, Ford Motor Company, Livio + 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 the copyright holders nor the names of their + 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 "app_service_rpc_plugin/commands/hmi/as_perform_app_service_interaction_request_from_hmi.h" +#include "application_manager/message_helper.h" + +namespace app_service_rpc_plugin { +using namespace application_manager; +namespace commands { + +ASPerformAppServiceInteractionRequestFromHMI:: + ASPerformAppServiceInteractionRequestFromHMI( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + app_mngr::rpc_service::RPCService& rpc_service, + app_mngr::HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handler) + : RequestFromHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handler) {} + +ASPerformAppServiceInteractionRequestFromHMI:: + ~ASPerformAppServiceInteractionRequestFromHMI() {} + +void ASPerformAppServiceInteractionRequestFromHMI::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + smart_objects::SmartObject& msg_params = (*message_)[strings::msg_params]; + std::string service_id = msg_params[strings::service_id].asString(); + auto service = + application_manager_.GetAppServiceManager().FindServiceByID(service_id); + if (service.first.empty()) { + smart_objects::SmartObject response_params; + response_params[strings::info] = "The requested service ID does not exist"; + SendResponse(false, + correlation_id(), + hmi_apis::FunctionID::AppService_PerformAppServiceInteraction, + hmi_apis::Common_Result::INVALID_ID, + &response_params, + application_manager::commands::Command::SOURCE_SDL_TO_HMI); + return; + } + + bool request_service_active = false; + if (msg_params.keyExists(strings::request_service_active)) { + request_service_active = + msg_params[strings::request_service_active].asBool(); + msg_params.erase(strings::request_service_active); + } + + // Only activate service if it is not already active + bool activate_service = + request_service_active && + !service.second.record[strings::service_active].asBool(); + if (activate_service) { + application_manager_.GetAppServiceManager().ActivateAppService(service_id); + } + + SendProviderRequest( + mobile_apis::FunctionID::PerformAppServiceInteractionID, + hmi_apis::FunctionID::AppService_PerformAppServiceInteraction, + &(*message_), + true); +} + +void ASPerformAppServiceInteractionRequestFromHMI::on_event( + const event_engine::Event& event) { + const smart_objects::SmartObject& event_message = event.smart_object(); + + auto msg_params = event_message[strings::msg_params]; + + hmi_apis::Common_Result::eType result = + static_cast( + event_message[strings::params][hmi_response::code].asInt()); + bool success = + IsHMIResultSuccess(result, HmiInterfaces::HMI_INTERFACE_AppService); + SendResponse(success, + correlation_id(), + hmi_apis::FunctionID::AppService_PerformAppServiceInteraction, + result, + &msg_params, + application_manager::commands::Command::SOURCE_SDL_TO_HMI); +} + +void ASPerformAppServiceInteractionRequestFromHMI::on_event( + const event_engine::MobileEvent& event) { + const smart_objects::SmartObject& event_message = event.smart_object(); + + auto msg_params = event_message[strings::msg_params]; + + mobile_apis::Result::eType mobile_result = + static_cast( + msg_params[strings::result_code].asInt()); + hmi_apis::Common_Result::eType result = + MessageHelper::MobileToHMIResult(mobile_result); + bool success = IsMobileResultSuccess(mobile_result); + SendResponse(success, + correlation_id(), + hmi_apis::FunctionID::AppService_PerformAppServiceInteraction, + result, + &msg_params, + application_manager::commands::Command::SOURCE_SDL_TO_HMI); +} + +} // namespace commands +} // namespace app_service_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_perform_app_service_interaction_request_to_hmi.cc b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_perform_app_service_interaction_request_to_hmi.cc new file mode 100644 index 0000000000..22876328de --- /dev/null +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_perform_app_service_interaction_request_to_hmi.cc @@ -0,0 +1,61 @@ +/* + Copyright (c) 2019, Ford Motor Company, Livio + 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 the copyright holders nor the names of their + 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 "app_service_rpc_plugin/commands/hmi/as_perform_app_service_interaction_request_to_hmi.h" + +namespace app_service_rpc_plugin { +using namespace application_manager; +namespace commands { + +ASPerformAppServiceInteractionRequestToHMI:: + ASPerformAppServiceInteractionRequestToHMI( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + app_mngr::rpc_service::RPCService& rpc_service, + app_mngr::HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handler) + : RequestToHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handler) {} + +ASPerformAppServiceInteractionRequestToHMI:: + ~ASPerformAppServiceInteractionRequestToHMI() {} + +void ASPerformAppServiceInteractionRequestToHMI::Run() { + LOG4CXX_AUTO_TRACE(logger_); + SendRequest(); +} + +} // namespace commands +} // namespace app_service_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_perform_app_service_interaction_response_from_hmi.cc b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_perform_app_service_interaction_response_from_hmi.cc new file mode 100644 index 0000000000..a2ffa65a73 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_perform_app_service_interaction_response_from_hmi.cc @@ -0,0 +1,64 @@ +/* + Copyright (c) 2019, Ford Motor Company, Livio + 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 the copyright holders nor the names of their + 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 "app_service_rpc_plugin/commands/hmi/as_perform_app_service_interaction_response_from_hmi.h" + +namespace app_service_rpc_plugin { +using namespace application_manager; +namespace commands { + +ASPerformAppServiceInteractionResponseFromHMI:: + ASPerformAppServiceInteractionResponseFromHMI( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + app_mngr::rpc_service::RPCService& rpc_service, + app_mngr::HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handler) + : ResponseFromHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handler) {} + +ASPerformAppServiceInteractionResponseFromHMI:: + ~ASPerformAppServiceInteractionResponseFromHMI() {} + +void ASPerformAppServiceInteractionResponseFromHMI::Run() { + LOG4CXX_AUTO_TRACE(logger_); + event_engine::Event event( + hmi_apis::FunctionID::AppService_PerformAppServiceInteraction); + event.set_smart_object(*message_); + event.raise(application_manager_.event_dispatcher()); +} + +} // namespace commands +} // namespace app_service_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_perform_app_service_interaction_response_to_hmi.cc b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_perform_app_service_interaction_response_to_hmi.cc new file mode 100644 index 0000000000..5ddef55c2a --- /dev/null +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_perform_app_service_interaction_response_to_hmi.cc @@ -0,0 +1,61 @@ +/* + Copyright (c) 2019, Ford Motor Company, Livio + 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 the copyright holders nor the names of their + 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 "app_service_rpc_plugin/commands/hmi/as_perform_app_service_interaction_response_to_hmi.h" + +namespace app_service_rpc_plugin { +using namespace application_manager; +namespace commands { + +ASPerformAppServiceInteractionResponseToHMI:: + ASPerformAppServiceInteractionResponseToHMI( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + app_mngr::rpc_service::RPCService& rpc_service, + app_mngr::HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handler) + : ResponseToHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handler) {} + +ASPerformAppServiceInteractionResponseToHMI:: + ~ASPerformAppServiceInteractionResponseToHMI() {} + +void ASPerformAppServiceInteractionResponseToHMI::Run() { + LOG4CXX_AUTO_TRACE(logger_); + rpc_service_.SendMessageToHMI(message_); +} + +} // namespace commands +} // namespace app_service_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/perform_app_service_interaction_request.cc b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/perform_app_service_interaction_request.cc new file mode 100644 index 0000000000..d21c413b29 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/perform_app_service_interaction_request.cc @@ -0,0 +1,176 @@ +/* + Copyright (c) 2019, Ford Motor Company, Livio + 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 the copyright holders nor the names of their + 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 "app_service_rpc_plugin/commands/mobile/perform_app_service_interaction_request.h" +#include "application_manager/application_impl.h" +#include "application_manager/message_helper.h" +#include "interfaces/MOBILE_API.h" + +namespace app_service_rpc_plugin { +using namespace application_manager; +namespace commands { + +PerformAppServiceInteractionRequest::PerformAppServiceInteractionRequest( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + app_mngr::rpc_service::RPCService& rpc_service, + app_mngr::HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handler) + : CommandRequestImpl(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handler) {} + +PerformAppServiceInteractionRequest::~PerformAppServiceInteractionRequest() {} + +void PerformAppServiceInteractionRequest::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + auto app = application_manager_.application(connection_key()); + if (!app) { + SendResponse(false, mobile_apis::Result::APPLICATION_NOT_REGISTERED); + return; + } + + smart_objects::SmartObject& msg_params = (*message_)[strings::msg_params]; + std::string service_id = msg_params[strings::service_id].asString(); + auto service = + application_manager_.GetAppServiceManager().FindServiceByID(service_id); + if (service.first.empty()) { + SendResponse(false, + mobile_apis::Result::INVALID_ID, + "The requested service ID does not exist"); + return; + } + + bool request_service_active = false; + if (msg_params.keyExists(strings::request_service_active)) { + request_service_active = + msg_params[strings::request_service_active].asBool(); + msg_params.erase(strings::request_service_active); + } + + // Only activate service if it is not already active + bool activate_service = + request_service_active && + !service.second.record[strings::service_active].asBool(); + if (activate_service) { + if (app->is_foreground()) { + // App is in foreground, we can just activate the service + application_manager_.GetAppServiceManager().ActivateAppService( + service_id); + } else { + // App is not in foreground, we need to prompt the user to activate the + // service + smart_objects::SmartObject request_params; + request_params[strings::service_id] = service_id; + SendHMIRequest(hmi_apis::FunctionID::AppService_GetActiveServiceConsent, + &request_params, + true); + return; + } + } + + SendProviderRequest( + mobile_apis::FunctionID::PerformAppServiceInteractionID, + hmi_apis::FunctionID::AppService_PerformAppServiceInteraction, + &(*message_), + true); +} + +void PerformAppServiceInteractionRequest::on_event( + const event_engine::Event& event) { + LOG4CXX_DEBUG(logger_, "HMI PerformAppServiceInteraction on_event"); + const smart_objects::SmartObject& event_message = event.smart_object(); + + auto msg_params = event_message[strings::msg_params]; + + const char* info = msg_params.keyExists(strings::info) + ? msg_params[strings::info].asCharArray() + : NULL; + hmi_apis::Common_Result::eType hmi_result = + static_cast( + event_message[strings::params][hmi_response::code].asInt()); + mobile_apis::Result::eType result = + MessageHelper::HMIToMobileResult(hmi_result); + bool success = PrepareResultForMobileResponse( + hmi_result, HmiInterfaces::HMI_INTERFACE_AppService); + + switch (event.id()) { + case hmi_apis::FunctionID::AppService_PerformAppServiceInteraction: + SendResponse(success, result, info, &msg_params); + break; + case hmi_apis::FunctionID::AppService_GetActiveServiceConsent: + if (msg_params[strings::activate].asBool()) { + // User agreed to activate service, we can now send the provider request + application_manager_.GetAppServiceManager().ActivateAppService( + (*message_)[strings::msg_params][strings::service_id].asString()); + SendProviderRequest( + mobile_apis::FunctionID::PerformAppServiceInteractionID, + hmi_apis::FunctionID::AppService_PerformAppServiceInteraction, + &(*message_), + true); + } else if (mobile_apis::Result::SUCCESS == result) { + // Request was successful, but user denied the request to activate the + // service + SendResponse(false, + mobile_apis::Result::USER_DISALLOWED, + "Request to activate service was denied by driver"); + } else { + SendResponse(success, result, info); + } + break; + default: + break; + } +} + +void PerformAppServiceInteractionRequest::on_event( + const event_engine::MobileEvent& event) { + LOG4CXX_DEBUG(logger_, "Mobile PerformAppServiceInteraction on_event"); + const smart_objects::SmartObject& event_message = event.smart_object(); + + auto msg_params = event_message[strings::msg_params]; + + const char* info = msg_params.keyExists(strings::info) + ? msg_params[strings::info].asCharArray() + : NULL; + mobile_apis::Result::eType result = static_cast( + msg_params[strings::result_code].asInt()); + bool success = IsMobileResultSuccess(result); + + SendResponse(success, result, info, &msg_params); +} + +} // namespace commands +} // namespace app_service_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/perform_app_service_interaction_request_to_mobile.cc b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/perform_app_service_interaction_request_to_mobile.cc new file mode 100644 index 0000000000..8d71174c8d --- /dev/null +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/perform_app_service_interaction_request_to_mobile.cc @@ -0,0 +1,63 @@ +/* + Copyright (c) 2019, Ford Motor Company, Livio + 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 the copyright holders nor the names of their + 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 "app_service_rpc_plugin/commands/mobile/perform_app_service_interaction_request_to_mobile.h" +#include "application_manager/application_impl.h" +#include "interfaces/MOBILE_API.h" + +namespace app_service_rpc_plugin { +using namespace application_manager; +namespace commands { + +PerformAppServiceInteractionRequestToMobile:: + PerformAppServiceInteractionRequestToMobile( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + app_mngr::rpc_service::RPCService& rpc_service, + app_mngr::HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handler) + : CommandRequestToMobile(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handler) {} + +PerformAppServiceInteractionRequestToMobile:: + ~PerformAppServiceInteractionRequestToMobile() {} + +void PerformAppServiceInteractionRequestToMobile::Run() { + LOG4CXX_AUTO_TRACE(logger_); + SendRequest(); +} + +} // namespace commands +} // namespace app_service_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/perform_app_service_interaction_response.cc b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/perform_app_service_interaction_response.cc new file mode 100644 index 0000000000..774ec93720 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/perform_app_service_interaction_response.cc @@ -0,0 +1,61 @@ +/* + Copyright (c) 2019, Ford Motor Company, Livio + 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 the copyright holders nor the names of their + 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 "app_service_rpc_plugin/commands/mobile/perform_app_service_interaction_response.h" +#include "application_manager/application_impl.h" +#include "interfaces/MOBILE_API.h" + +namespace app_service_rpc_plugin { +using namespace application_manager; +namespace commands { + +PerformAppServiceInteractionResponse::PerformAppServiceInteractionResponse( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + app_mngr::rpc_service::RPCService& rpc_service, + app_mngr::HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handler) + : CommandResponseImpl(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handler) {} + +PerformAppServiceInteractionResponse::~PerformAppServiceInteractionResponse() {} + +void PerformAppServiceInteractionResponse::Run() { + LOG4CXX_AUTO_TRACE(logger_); + rpc_service_.SendMessageToMobile(message_); +} + +} // namespace commands +} // namespace app_service_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/perform_app_service_interaction_response_from_mobile.cc b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/perform_app_service_interaction_response_from_mobile.cc new file mode 100644 index 0000000000..9912df84ce --- /dev/null +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/perform_app_service_interaction_response_from_mobile.cc @@ -0,0 +1,66 @@ +/* + Copyright (c) 2019, Ford Motor Company, Livio + 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 the copyright holders nor the names of their + 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 "app_service_rpc_plugin/commands/mobile/perform_app_service_interaction_response_from_mobile.h" +#include "application_manager/application_impl.h" +#include "interfaces/MOBILE_API.h" + +namespace app_service_rpc_plugin { +using namespace application_manager; +namespace commands { + +PerformAppServiceInteractionResponseFromMobile:: + PerformAppServiceInteractionResponseFromMobile( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + app_mngr::rpc_service::RPCService& rpc_service, + app_mngr::HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handler) + : CommandResponseFromMobile(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handler) {} + +PerformAppServiceInteractionResponseFromMobile:: + ~PerformAppServiceInteractionResponseFromMobile() {} + +void PerformAppServiceInteractionResponseFromMobile::Run() { + LOG4CXX_AUTO_TRACE(logger_); + event_engine::MobileEvent event( + mobile_apis::FunctionID::PerformAppServiceInteractionID); + event.set_smart_object(*message_); + event.raise(application_manager_.event_dispatcher()); +} + +} // namespace commands +} // namespace app_service_rpc_plugin diff --git a/src/components/application_manager/src/app_service_manager.cc b/src/components/application_manager/src/app_service_manager.cc index 8250109023..f26bcaf01f 100644 --- a/src/components/application_manager/src/app_service_manager.cc +++ b/src/components/application_manager/src/app_service_manager.cc @@ -35,7 +35,6 @@ #include #include -#include "application_manager/app_service_manager.h" #include "application_manager/application.h" #include "application_manager/app_service_manager.h" #include "application_manager/application_manager.h" @@ -180,37 +179,47 @@ std::vector AppServiceManager::GetAllServices() { return services; } -void AppServiceManager::GetProvider(const std::string& service_type, - ApplicationSharedPtr& app, - bool& hmi_service) { +void AppServiceManager::GetProviderByType(const std::string& service_type, + ApplicationSharedPtr& app, + bool& hmi_service) { LOG4CXX_AUTO_TRACE(logger_); - auto service_it = published_services_.begin(); - auto end = published_services_.end(); - - for (; service_it != end; ++service_it) { - auto service = service_it->second; - auto record = service_it->second.record; - if (record[strings::service_published].asBool() == false || - record[strings::service_active].asBool() == false) { - continue; - } + auto active_service = ActiveServiceByType(service_type); + if (active_service.first.empty()) { + LOG4CXX_ERROR(logger_, + "There is no active service for the given service type: " + << service_type); + return; + } - std::string record_service_type = - record[strings::service_manifest][strings::service_type].asString(); - - if (record_service_type == service_type) { - LOG4CXX_DEBUG(logger_, - "Found provider for service type: " << service_type); - bool mobile_service = service.mobile_service; - if (mobile_service) { - app = app_manager_.application(service.connection_key); - hmi_service = false; - return; - } - hmi_service = true; - return; - } + LOG4CXX_DEBUG(logger_, "Found provider for service type: " << service_type); + GetProviderFromService(active_service.second, app, hmi_service); +} + +void AppServiceManager::GetProviderByID(const std::string& service_id, + ApplicationSharedPtr& app, + bool& hmi_service) { + LOG4CXX_AUTO_TRACE(logger_); + auto it = published_services_.find(service_id); + if (it == published_services_.end()) { + LOG4CXX_ERROR(logger_, "Service id does not exist in published services"); + return; + } + + LOG4CXX_DEBUG(logger_, "Found provider with service ID: " << service_id); + GetProviderFromService(it->second, app, hmi_service); +} + +void AppServiceManager::GetProviderFromService(const AppService& service, + ApplicationSharedPtr& app, + bool& hmi_service) { + LOG4CXX_AUTO_TRACE(logger_); + bool mobile_service = service.mobile_service; + if (mobile_service) { + app = app_manager_.application(service.connection_key); + hmi_service = false; + return; } + hmi_service = true; } bool AppServiceManager::SetDefaultService(const std::string service_id) { @@ -377,6 +386,20 @@ std::pair AppServiceManager::FindServiceByName( return std::make_pair(std::string(), empty); } +std::pair AppServiceManager::FindServiceByID( + std::string service_id) { + LOG4CXX_AUTO_TRACE(logger_); + + auto it = published_services_.find(service_id); + if (it == published_services_.end()) { + LOG4CXX_ERROR(logger_, "Service id does not exist in published services"); + AppService empty; + return std::make_pair(std::string(), empty); + } + + return *it; +} + std::string AppServiceManager::DefaultServiceByType(std::string service_type) { LOG4CXX_AUTO_TRACE(logger_); Json::Value& dictionary = last_state_.get_dictionary(); diff --git a/src/components/application_manager/src/commands/command_request_impl.cc b/src/components/application_manager/src/commands/command_request_impl.cc index cc956df019..c6dbe6972f 100644 --- a/src/components/application_manager/src/commands/command_request_impl.cc +++ b/src/components/application_manager/src/commands/command_request_impl.cc @@ -236,6 +236,7 @@ void CommandRequestImpl::onTimeOut() { LOG4CXX_AUTO_TRACE(logger_); unsubscribe_from_all_hmi_events(); + unsubscribe_from_all_mobile_events(); { // FIXME (dchmerev@luxoft.com): atomic_xchg fits better sync_primitives::AutoLock auto_lock(state_lock_); @@ -423,13 +424,20 @@ void CommandRequestImpl::SendProviderRequest( const hmi_apis::FunctionID::eType& hmi_function_id, const smart_objects::SmartObject* msg, bool use_events) { - std::string service_type = - (*msg)[strings::msg_params][strings::service_type].asString(); - + LOG4CXX_AUTO_TRACE(logger_); bool hmi_destination = false; ApplicationSharedPtr app; - application_manager_.GetAppServiceManager().GetProvider( - service_type, app, hmi_destination); + if ((*msg)[strings::msg_params].keyExists(strings::service_type)) { + std::string service_type = + (*msg)[strings::msg_params][strings::service_type].asString(); + application_manager_.GetAppServiceManager().GetProviderByType( + service_type, app, hmi_destination); + } else if ((*msg)[strings::msg_params].keyExists(strings::service_id)) { + std::string service_id = + (*msg)[strings::msg_params][strings::service_id].asString(); + application_manager_.GetAppServiceManager().GetProviderByID( + service_id, app, hmi_destination); + } if (hmi_destination) { LOG4CXX_DEBUG(logger_, "Sending Request to HMI Provider"); diff --git a/src/components/application_manager/src/commands/request_from_hmi.cc b/src/components/application_manager/src/commands/request_from_hmi.cc index d97694276e..823e93cb5e 100644 --- a/src/components/application_manager/src/commands/request_from_hmi.cc +++ b/src/components/application_manager/src/commands/request_from_hmi.cc @@ -33,6 +33,9 @@ #include "application_manager/commands/request_from_hmi.h" #include "application_manager/application_manager.h" #include "application_manager/rpc_service.h" +#include "utils/helpers.h" + +#include "smart_objects/enum_schema_item.h" #include "smart_objects/enum_schema_item.h" @@ -163,13 +166,20 @@ void RequestFromHMI::SendProviderRequest( const hmi_apis::FunctionID::eType& hmi_function_id, const smart_objects::SmartObject* msg, bool use_events) { - std::string service_type = - (*msg)[strings::msg_params][strings::service_type].asString(); - + LOG4CXX_AUTO_TRACE(logger_); bool hmi_destination = false; ApplicationSharedPtr app; - application_manager_.GetAppServiceManager().GetProvider( - service_type, app, hmi_destination); + if ((*msg)[strings::msg_params].keyExists(strings::service_type)) { + std::string service_type = + (*msg)[strings::msg_params][strings::service_type].asString(); + application_manager_.GetAppServiceManager().GetProviderByType( + service_type, app, hmi_destination); + } else if ((*msg)[strings::msg_params].keyExists(strings::service_id)) { + std::string service_id = + (*msg)[strings::msg_params][strings::service_id].asString(); + application_manager_.GetAppServiceManager().GetProviderByID( + service_id, app, hmi_destination); + } if (hmi_destination) { LOG4CXX_DEBUG(logger_, "Sending Request to HMI Provider"); @@ -181,6 +191,7 @@ void RequestFromHMI::SendProviderRequest( LOG4CXX_DEBUG(logger_, "Invalid App Provider pointer"); return; } + LOG4CXX_DEBUG(logger_, "Sending Request to Mobile Provider"); SendMobileRequest( mobile_function_id, app, &(*msg)[strings::msg_params], use_events); diff --git a/src/components/application_manager/src/hmi_interfaces_impl.cc b/src/components/application_manager/src/hmi_interfaces_impl.cc index e31257bcad..1d1dbe6996 100644 --- a/src/components/application_manager/src/hmi_interfaces_impl.cc +++ b/src/components/application_manager/src/hmi_interfaces_impl.cc @@ -231,6 +231,10 @@ generate_function_to_interface_convert_map() { HmiInterfaces::HMI_INTERFACE_AppService; convert_map[AppService_GetAppServiceData] = HmiInterfaces::HMI_INTERFACE_AppService; + convert_map[AppService_PerformAppServiceInteraction] = + HmiInterfaces::HMI_INTERFACE_AppService; + convert_map[AppService_GetActiveServiceConsent] = + HmiInterfaces::HMI_INTERFACE_AppService; return convert_map; } diff --git a/src/components/application_manager/src/smart_object_keys.cc b/src/components/application_manager/src/smart_object_keys.cc index b7778d339e..8df9a5cfbd 100644 --- a/src/components/application_manager/src/smart_object_keys.cc +++ b/src/components/application_manager/src/smart_object_keys.cc @@ -286,6 +286,7 @@ const char* service_manifest = "serviceManifest"; const char* service_published = "servicePublished"; const char* service_active = "serviceActive"; const char* service_data = "serviceData"; +const char* request_service_active = "requestServiceActive"; const char* app_services = "appServices"; const char* update_reason = "updateReason"; const char* updated_app_service_record = "updatedAppServiceRecord"; diff --git a/src/components/interfaces/HMI_API.xml b/src/components/interfaces/HMI_API.xml index 6aeb08c3cc..7eead66618 100644 --- a/src/components/interfaces/HMI_API.xml +++ b/src/components/interfaces/HMI_API.xml @@ -6252,5 +6252,47 @@ True if the service was set to the default service of this type. False if the app was not to be the default + + + + Fully qualified URI based on the URI prefix and URI scheme the app service provided. SDL makes no gurantee that this URI is correct. + + + + The service ID that the app consumer wishes to send this URI. + + + + This string is the appID of the app requesting the app service provider take the specific action. This will automatically be set by SDL Core in requests originating from the HMI + + + + This flag signals the requesting consumer would like this service to become the active primary service of the destination's type. + + + + + + The service can provide specific result strings to the consumer through this param. These results should be described in the URI schema set in the Service Manifest + + + + + + SDL->HMI. HMI is expected to prompt the user for permission for the app service to take over as the active service. + + + The ID of the service to be activated + + + + + + + "true" - If the driver grants permission for the app service to take over as the active service. + "false" - If the driver denies permission for the app service to take over as the active service. + + + diff --git a/src/components/interfaces/MOBILE_API.xml b/src/components/interfaces/MOBILE_API.xml index b3cf9df8f0..185b9d8773 100644 --- a/src/components/interfaces/MOBILE_API.xml +++ b/src/components/interfaces/MOBILE_API.xml @@ -2619,6 +2619,7 @@ + - + + + + Fully qualified URI based on the URI prefix and URI scheme the app service provided. SDL makes no gurantee that this URI is correct. + + + + The service ID that the app consumer wishes to send this URI. + + + + This string is the appID of the app requesting the app service provider take the specific action. + + + + This flag signals the requesting consumer would like this service to become the active primary service of the destination's type. + + + + + + true, if successful; false, if failed + + + + See Result. All results will be available for this response. + + + + Provides additional human readable info regarding the result. + + + + The service can provide specific result strings to the consumer through this param. These results should be described in the URI schema set in the Service Manifest + + + diff --git a/src/components/policy/policy_external/include/policy/policy_table/enums.h b/src/components/policy/policy_external/include/policy/policy_table/enums.h index 932fb9b801..d795721863 100644 --- a/src/components/policy/policy_external/include/policy/policy_table/enums.h +++ b/src/components/policy/policy_external/include/policy/policy_table/enums.h @@ -455,6 +455,11 @@ enum FunctionID { */ GetAppServiceDataID = 53, + /** + * @brief PerformAppServiceInteractionID. + */ + PerformAppServiceInteractionID = 55, + /** * @brief OnHMIStatusID. */ diff --git a/src/components/policy/policy_external/src/policy_table/enums.cc b/src/components/policy/policy_external/src/policy_table/enums.cc index f99a7e69de..718bafa905 100644 --- a/src/components/policy/policy_external/src/policy_table/enums.cc +++ b/src/components/policy/policy_external/src/policy_table/enums.cc @@ -1136,6 +1136,11 @@ bool EnumFromJsonString(const std::string& literal, FunctionID* result) { return true; } + if ("PerformAppServiceInteraction" == literal) { + *result = PerformAppServiceInteractionID; + return true; + } + if ("OnHMIStatus" == literal) { *result = OnHMIStatusID; return true; diff --git a/src/components/policy/policy_regular/include/policy/policy_table/enums.h b/src/components/policy/policy_regular/include/policy/policy_table/enums.h index 69840c71ba..16f0ef3d67 100644 --- a/src/components/policy/policy_regular/include/policy/policy_table/enums.h +++ b/src/components/policy/policy_regular/include/policy/policy_table/enums.h @@ -441,6 +441,11 @@ enum FunctionID { */ GetAppServiceDataID = 53, + /** + * @brief PerformAppServiceInteractionID. + */ + PerformAppServiceInteractionID = 55, + /** * @brief OnHMIStatusID. */ diff --git a/src/components/policy/policy_regular/src/policy_table/enums.cc b/src/components/policy/policy_regular/src/policy_table/enums.cc index 2f84c68c66..25f6d778fc 100644 --- a/src/components/policy/policy_regular/src/policy_table/enums.cc +++ b/src/components/policy/policy_regular/src/policy_table/enums.cc @@ -853,6 +853,8 @@ bool IsValidEnum(FunctionID val) { return true; case GetAppServiceDataID: return true; + case PerformAppServiceInteractionID: + return true; case OnHMIStatusID: return true; case OnAppInterfaceUnregisteredID: @@ -1010,6 +1012,8 @@ const char* EnumToJsonString(FunctionID val) { return "PublishAppService"; case GetAppServiceDataID: return "GetAppServiceData"; + case PerformAppServiceInteractionID: + return "PerformAppServiceInteraction"; case OnHMIStatusID: return "OnHMIStatus"; case OnAppInterfaceUnregisteredID: @@ -1319,6 +1323,11 @@ bool EnumFromJsonString(const std::string& literal, FunctionID* result) { return true; } + if ("PerformAppServiceInteraction" == literal) { + *result = PerformAppServiceInteractionID; + return true; + } + if ("OnHMIStatus" == literal) { *result = OnHMIStatusID; return true; -- cgit v1.2.1 From 97806312bc0df88d74fadc0c9c620599545b0887 Mon Sep 17 00:00:00 2001 From: jacobkeeler Date: Tue, 26 Feb 2019 15:45:55 -0500 Subject: Add capability updates for NAVIGATION service type Also revise name of `timeStamp` parameter in NavigationServiceData --- .../application_manager/app_service_manager.h | 23 +++--- .../include/application_manager/message_helper.h | 3 + .../application_manager/smart_object_keys.h | 2 + ...on_bc_system_capability_updated_notification.cc | 20 ++++- .../mobile/get_system_capability_request.cc | 14 +++- .../on_system_capability_updated_notification.cc | 20 ++++- .../application_manager/src/app_service_manager.cc | 85 +++++++++++++++------- .../src/message_helper/message_helper.cc | 24 ++++++ .../application_manager/src/smart_object_keys.cc | 2 + .../application_manager/mock_message_helper.h | 3 + .../test/mock_message_helper.cc | 6 ++ src/components/interfaces/HMI_API.xml | 2 +- src/components/interfaces/MOBILE_API.xml | 2 +- 13 files changed, 164 insertions(+), 42 deletions(-) diff --git a/src/components/application_manager/include/application_manager/app_service_manager.h b/src/components/application_manager/include/application_manager/app_service_manager.h index 253ed2a439..8510c78fee 100644 --- a/src/components/application_manager/include/application_manager/app_service_manager.h +++ b/src/components/application_manager/include/application_manager/app_service_manager.h @@ -92,14 +92,6 @@ class AppServiceManager { */ void UnpublishServices(const uint32_t connection_key); - /** - * @brief TODO - * @param service_id - * @param service_published - */ - void SetServicePublished(const std::string service_id, - bool service_published); - /** * @brief TODO * @param service_id @@ -140,12 +132,25 @@ class AppServiceManager { std::string DefaultServiceByType(std::string service_type); + /** + * @brief TODO + * @param service_id + * @param service_published + */ + void SetServicePublished(const std::string service_id, + bool service_published); + + /** + * @brief TODO + * @param out_params + */ + bool UpdateNavigationCapabilities(smart_objects::SmartObject& out_params); + private: ApplicationManager& app_manager_; resumption::LastState& last_state_; std::map published_services_; - void BroadcastAppServiceUpdate(smart_objects::SmartObject& msg_params); void AppServiceUpdated( const smart_objects::SmartObject& service_record, const mobile_apis::ServiceUpdateReason::eType update_reason, diff --git a/src/components/application_manager/include/application_manager/message_helper.h b/src/components/application_manager/include/application_manager/message_helper.h index fd16d57740..8a8e50bf1c 100644 --- a/src/components/application_manager/include/application_manager/message_helper.h +++ b/src/components/application_manager/include/application_manager/message_helper.h @@ -881,6 +881,9 @@ class MessageHelper { static smart_objects::SmartObject CreateAppServiceCapabilities( std::vector& all_services); + static void BroadcastCapabilityUpdate(smart_objects::SmartObject& msg_params, + ApplicationManager& app_mngr); + private: /** * @brief Allows to fill SO according to the current permissions. 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 615b8ab767..f67d5ff121 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 @@ -391,6 +391,8 @@ extern const char* const keyboard_layout_supported; extern const char* const keypress_mode_supported; extern const char* const limited_characters_list_supported; extern const char* const auto_complete_text_supported; +extern const char* const send_location_enabled; +extern const char* const get_way_points_enabled; extern const char* const entity_type; extern const char* const entity_id; extern const char* const status; diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_bc_system_capability_updated_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_bc_system_capability_updated_notification.cc index d0c33e76d9..73ec1137a8 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_bc_system_capability_updated_notification.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_bc_system_capability_updated_notification.cc @@ -70,9 +70,21 @@ void OnBCSystemCapabilityUpdatedNotification::Run() { [strings::system_capability_type].asInt()); switch (system_capability_type) { case hmi_apis::Common_SystemCapabilityType::NAVIGATION: { + smart_objects::SmartObject nav_capability(smart_objects::SmartType_Map); + bool has_nav_capability = false; if (hmi_capabilities_.navigation_capability()) { + has_nav_capability = true; + nav_capability = *hmi_capabilities_.navigation_capability(); + } + has_nav_capability = application_manager_.GetAppServiceManager() + .UpdateNavigationCapabilities(nav_capability) || + has_nav_capability; + + if (has_nav_capability) { msg_params[strings::system_capability][strings::navigation_capability] = - *hmi_capabilities_.navigation_capability(); + nav_capability; + } else { + return; } break; } @@ -80,6 +92,8 @@ void OnBCSystemCapabilityUpdatedNotification::Run() { if (hmi_capabilities_.phone_capability()) { msg_params[strings::system_capability][strings::phone_capability] = *hmi_capabilities_.phone_capability(); + } else { + return; } break; } @@ -90,6 +104,8 @@ void OnBCSystemCapabilityUpdatedNotification::Run() { if (hmi_capabilities_.rc_capability()) { msg_params[strings::system_capability][strings::rc_capability] = *hmi_capabilities_.rc_capability(); + } else { + return; } break; } @@ -98,6 +114,8 @@ void OnBCSystemCapabilityUpdatedNotification::Run() { msg_params[strings::system_capability] [strings::video_streaming_capability] = *hmi_capabilities_.video_streaming_capability(); + } else { + return; } break; case hmi_apis::Common_SystemCapabilityType::APP_SERVICES: { 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 b551db0008..63a4416139 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 @@ -83,10 +83,20 @@ void GetSystemCapabilityRequest::Run() { switch (response_type) { case mobile_apis::SystemCapabilityType::NAVIGATION: { + smart_objects::SmartObject nav_capability(smart_objects::SmartType_Map); + bool has_nav_capability = false; if (hmi_capabilities.navigation_capability()) { + has_nav_capability = true; + auto nav_capability = *hmi_capabilities.navigation_capability(); + } + + has_nav_capability = application_manager_.GetAppServiceManager() + .UpdateNavigationCapabilities(nav_capability) || + has_nav_capability; + + if (has_nav_capability) { response_params[strings::system_capability] - [strings::navigation_capability] = - *hmi_capabilities.navigation_capability(); + [strings::navigation_capability] = nav_capability; } else { SendResponse(false, mobile_apis::Result::DATA_NOT_AVAILABLE); return; diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_system_capability_updated_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_system_capability_updated_notification.cc index 0745bc08dc..b5e3a73ee4 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_system_capability_updated_notification.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_system_capability_updated_notification.cc @@ -36,9 +36,21 @@ void OnSystemCapabilityUpdatedNotification::Run() { switch (system_capability_type) { case mobile_apis::SystemCapabilityType::NAVIGATION: { + smart_objects::SmartObject nav_capability(smart_objects::SmartType_Map); + bool has_nav_capability = false; if (hmi_capabilities_.navigation_capability()) { + has_nav_capability = true; + nav_capability = *hmi_capabilities_.navigation_capability(); + } + has_nav_capability = application_manager_.GetAppServiceManager() + .UpdateNavigationCapabilities(nav_capability) || + has_nav_capability; + + if (has_nav_capability) { msg_params[strings::system_capability][strings::navigation_capability] = - *hmi_capabilities_.navigation_capability(); + nav_capability; + } else { + return; } break; } @@ -46,6 +58,8 @@ void OnSystemCapabilityUpdatedNotification::Run() { if (hmi_capabilities_.phone_capability()) { msg_params[strings::system_capability][strings::phone_capability] = *hmi_capabilities_.phone_capability(); + } else { + return; } break; } @@ -56,6 +70,8 @@ void OnSystemCapabilityUpdatedNotification::Run() { if (hmi_capabilities_.rc_capability()) { msg_params[strings::system_capability][strings::rc_capability] = *hmi_capabilities_.rc_capability(); + } else { + return; } break; } @@ -64,6 +80,8 @@ void OnSystemCapabilityUpdatedNotification::Run() { msg_params[strings::system_capability] [strings::video_streaming_capability] = *hmi_capabilities_.video_streaming_capability(); + } else { + return; } break; case mobile_apis::SystemCapabilityType::APP_SERVICES: { diff --git a/src/components/application_manager/src/app_service_manager.cc b/src/components/application_manager/src/app_service_manager.cc index bc9d363839..e2a9f41deb 100644 --- a/src/components/application_manager/src/app_service_manager.cc +++ b/src/components/application_manager/src/app_service_manager.cc @@ -37,13 +37,13 @@ #include "application_manager/app_service_manager.h" #include "application_manager/application.h" -#include "application_manager/app_service_manager.h" #include "application_manager/application_manager.h" #include "application_manager/commands/command_impl.h" #include "application_manager/message_helper.h" #include "application_manager/smart_object_keys.h" #include "encryption/hashing.h" #include "resumption/last_state.h" +#include "smart_objects/enum_schema_item.h" #include "utils/logger.h" CREATE_LOGGERPTR_GLOBAL(logger_, "AppServiceManager") @@ -96,9 +96,12 @@ smart_objects::SmartObject AppServiceManager::PublishAppService( std::pair(service_id, app_service)); smart_objects::SmartObject msg_params; + msg_params[strings::system_capability][strings::system_capability_type] = + mobile_apis::SystemCapabilityType::APP_SERVICES; AppServiceUpdated( service_record, mobile_apis::ServiceUpdateReason::PUBLISHED, msg_params); - BroadcastAppServiceUpdate(msg_params); + + MessageHelper::BroadcastCapabilityUpdate(msg_params, app_manager_); // Activate the new service if it is the default for its service type, or if // no service is active of its service type @@ -123,6 +126,8 @@ bool AppServiceManager::UnpublishAppService(const std::string service_id) { SetServicePublished(service_id, false); smart_objects::SmartObject msg_params; + msg_params[strings::system_capability][strings::system_capability_type] = + mobile_apis::SystemCapabilityType::APP_SERVICES; auto record = it->second.record; if (record[strings::service_active].asBool()) { @@ -140,7 +145,7 @@ bool AppServiceManager::UnpublishAppService(const std::string service_id) { } AppServiceUpdated( it->second.record, mobile_apis::ServiceUpdateReason::REMOVED, msg_params); - BroadcastAppServiceUpdate(msg_params); + MessageHelper::BroadcastCapabilityUpdate(msg_params, app_manager_); published_services_.erase(it); return true; @@ -244,6 +249,8 @@ bool AppServiceManager::ActivateAppService(const std::string service_id) { } smart_objects::SmartObject msg_params; + msg_params[strings::system_capability][strings::system_capability_type] = + mobile_apis::SystemCapabilityType::APP_SERVICES; const std::string service_type = service[strings::service_manifest][strings::service_type].asString(); @@ -258,7 +265,18 @@ bool AppServiceManager::ActivateAppService(const std::string service_id) { AppServiceUpdated( service, mobile_apis::ServiceUpdateReason::ACTIVATED, msg_params); - BroadcastAppServiceUpdate(msg_params); + MessageHelper::BroadcastCapabilityUpdate(msg_params, app_manager_); + + std::string navi_service_type; + ns_smart_device_link::ns_smart_objects:: + EnumConversionHelper::EnumToString( + mobile_apis::AppServiceType::NAVIGATION, &navi_service_type); + if (service_type == navi_service_type) { + smart_objects::SmartObject msg_params; + msg_params[strings::system_capability][strings::system_capability_type] = + mobile_apis::SystemCapabilityType::NAVIGATION; + MessageHelper::BroadcastCapabilityUpdate(msg_params, app_manager_); + } return true; } @@ -292,7 +310,9 @@ bool AppServiceManager::DeactivateAppService(const std::string service_id) { } if (send_update) { - BroadcastAppServiceUpdate(msg_params); + msg_params[strings::system_capability][strings::system_capability_type] = + mobile_apis::SystemCapabilityType::APP_SERVICES; + MessageHelper::BroadcastCapabilityUpdate(msg_params, app_manager_); } return true; } @@ -362,30 +382,41 @@ void AppServiceManager::SetServicePublished(const std::string service_id, it->second.record[strings::service_published] = service_published; } -void AppServiceManager::BroadcastAppServiceUpdate( - smart_objects::SmartObject& msg_params) { +bool AppServiceManager::UpdateNavigationCapabilities( + smart_objects::SmartObject& out_params) { LOG4CXX_AUTO_TRACE(logger_); - smart_objects::SmartObject message(smart_objects::SmartType_Map); + std::string navi_service_type; + ns_smart_device_link::ns_smart_objects:: + EnumConversionHelper::EnumToString( + mobile_apis::AppServiceType::NAVIGATION, &navi_service_type); + auto service = ActiveServiceByType(navi_service_type); + if (service.first.empty()) { + return false; + } - msg_params[strings::system_capability][strings::system_capability_type] = - mobile_apis::SystemCapabilityType::APP_SERVICES; - message[strings::params][strings::message_type] = MessageType::kNotification; - message[strings::msg_params] = msg_params; - - // Construct and send mobile notification - message[strings::params][strings::function_id] = - mobile_apis::FunctionID::OnSystemCapabilityUpdatedID; - smart_objects::SmartObjectSPtr notification = - std::make_shared(message); - app_manager_.GetRPCService().ManageMobileCommand( - notification, commands::Command::CommandSource::SOURCE_SDL); - - // Construct and send HMI notification - message[strings::params][strings::function_id] = - hmi_apis::FunctionID::BasicCommunication_OnSystemCapabilityUpdated; - smart_objects::SmartObjectSPtr hmi_notification = - std::make_shared(message); - app_manager_.GetRPCService().ManageHMICommand(hmi_notification); + if (!out_params.keyExists(strings::send_location_enabled)) { + out_params[strings::send_location_enabled] = false; + } + if (!out_params.keyExists(strings::get_way_points_enabled)) { + out_params[strings::get_way_points_enabled] = false; + } + + if (!service.second.record[strings::service_manifest].keyExists( + strings::handled_rpcs)) { + return true; + } + + smart_objects::SmartObject& handled_rpcs = + service.second.record[strings::service_manifest][strings::handled_rpcs]; + for (size_t i = 0; i < handled_rpcs.length(); ++i) { + if (handled_rpcs[i].asInt() == mobile_apis::FunctionID::SendLocationID) { + out_params[strings::send_location_enabled] = true; + } else if (handled_rpcs[i].asInt() == + mobile_apis::FunctionID::GetWayPointsID) { + out_params[strings::get_way_points_enabled] = true; + } + } + return true; } void AppServiceManager::AppServiceUpdated( diff --git a/src/components/application_manager/src/message_helper/message_helper.cc b/src/components/application_manager/src/message_helper/message_helper.cc index 124ec80312..7db2308c2c 100644 --- a/src/components/application_manager/src/message_helper/message_helper.cc +++ b/src/components/application_manager/src/message_helper/message_helper.cc @@ -327,6 +327,30 @@ smart_objects::SmartObjectSPtr MessageHelper::CreateMessageForHMI( return message; } +void MessageHelper::BroadcastCapabilityUpdate( + smart_objects::SmartObject& msg_params, ApplicationManager& app_mngr) { + LOG4CXX_AUTO_TRACE(logger_); + smart_objects::SmartObject message(smart_objects::SmartType_Map); + + message[strings::params][strings::message_type] = MessageType::kNotification; + message[strings::msg_params] = msg_params; + + // Construct and send mobile notification + message[strings::params][strings::function_id] = + mobile_apis::FunctionID::OnSystemCapabilityUpdatedID; + smart_objects::SmartObjectSPtr notification = + std::make_shared(message); + app_mngr.GetRPCService().ManageMobileCommand( + notification, commands::Command::CommandSource::SOURCE_SDL); + + // Construct and send HMI notification + message[strings::params][strings::function_id] = + hmi_apis::FunctionID::BasicCommunication_OnSystemCapabilityUpdated; + smart_objects::SmartObjectSPtr hmi_notification = + std::make_shared(message); + app_mngr.GetRPCService().ManageHMICommand(hmi_notification); +} + smart_objects::SmartObject MessageHelper::CreateAppServiceCapabilities( std::vector& all_services) { smart_objects::SmartObject app_service_capabilities( diff --git a/src/components/application_manager/src/smart_object_keys.cc b/src/components/application_manager/src/smart_object_keys.cc index 59499818d3..e07f9732e4 100644 --- a/src/components/application_manager/src/smart_object_keys.cc +++ b/src/components/application_manager/src/smart_object_keys.cc @@ -351,6 +351,8 @@ const char* const keypress_mode_supported = "keypressModeSupported"; const char* const limited_characters_list_supported = "limitedCharactersListSupported"; const char* const auto_complete_text_supported = "autoCompleteTextSupported"; +const char* const send_location_enabled = "sendLocationEnabled"; +const char* const get_way_points_enabled = "getWayPointsEnabled"; const char* const entity_type = "entityType"; const char* const entity_id = "entityID"; const char* const status = "status"; diff --git a/src/components/application_manager/test/include/application_manager/mock_message_helper.h b/src/components/application_manager/test/include/application_manager/mock_message_helper.h index 8d9cf9d7ef..7889774fae 100644 --- a/src/components/application_manager/test/include/application_manager/mock_message_helper.h +++ b/src/components/application_manager/test/include/application_manager/mock_message_helper.h @@ -311,6 +311,9 @@ class MockMessageHelper { MOCK_METHOD1(CreateAppServiceCapabilities, smart_objects::SmartObject( std::vector& all_services)); + MOCK_METHOD2(BroadcastCapabilityUpdate, + void(smart_objects::SmartObject& msg_params, + ApplicationManager& app_mngr)); static MockMessageHelper* message_helper_mock(); }; diff --git a/src/components/application_manager/test/mock_message_helper.cc b/src/components/application_manager/test/mock_message_helper.cc index 0fe82e0dfb..b3b3327ca9 100644 --- a/src/components/application_manager/test/mock_message_helper.cc +++ b/src/components/application_manager/test/mock_message_helper.cc @@ -577,4 +577,10 @@ smart_objects::SmartObject MessageHelper::CreateAppServiceCapabilities( return MockMessageHelper::message_helper_mock()->CreateAppServiceCapabilities( all_services); } + +void MessageHelper::BroadcastCapabilityUpdate( + smart_objects::SmartObject& msg_params, ApplicationManager& app_mngr) { + MockMessageHelper::message_helper_mock()->BroadcastCapabilityUpdate( + msg_params, app_mngr); +} } // namespace application_manager diff --git a/src/components/interfaces/HMI_API.xml b/src/components/interfaces/HMI_API.xml index 1976f7c742..2f299d4026 100644 --- a/src/components/interfaces/HMI_API.xml +++ b/src/components/interfaces/HMI_API.xml @@ -3636,7 +3636,7 @@ This data is related to what a navigation service would provide. - + This is the timestamp of when the data was generated. This is to ensure any time or distance given in the data can accurately be adjusted if necessary. diff --git a/src/components/interfaces/MOBILE_API.xml b/src/components/interfaces/MOBILE_API.xml index 8a3766c5fa..a516e03542 100644 --- a/src/components/interfaces/MOBILE_API.xml +++ b/src/components/interfaces/MOBILE_API.xml @@ -3968,7 +3968,7 @@ This data is related to what a navigation service would provide. - + This is the timestamp of when the data was generated. This is to ensure any time or distance given in the data can accurately be adjusted if necessary. -- cgit v1.2.1 From 994cdb9b31aaac4d688014cdd1bdf5ff2b1970e1 Mon Sep 17 00:00:00 2001 From: jacobkeeler Date: Tue, 26 Feb 2019 16:11:53 -0500 Subject: Increase auth_token size according to spec --- src/components/protocol_handler/src/protocol_handler_impl.cc | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/components/protocol_handler/src/protocol_handler_impl.cc b/src/components/protocol_handler/src/protocol_handler_impl.cc index c09fbfe0d8..083e204ac3 100644 --- a/src/components/protocol_handler/src/protocol_handler_impl.cc +++ b/src/components/protocol_handler/src/protocol_handler_impl.cc @@ -418,8 +418,9 @@ void ProtocolHandlerImpl::SendStartSessionAck( sync_primitives::AutoLock lock(auth_token_map_lock_); auto it = auth_token_map_.find(policy_app_id); if (it != auth_token_map_.end()) { - char auth_token[256]; - strncpy(auth_token, it->second.c_str(), 255); + char auth_token[65536]; + strncpy(auth_token, it->second.c_str(), 65535); + auth_token[sizeof(auth_token) - 1] = '\0'; bson_object_put_string(¶ms, strings::auth_token, auth_token); } } -- cgit v1.2.1 From 046adeb0ed718b54a847fb831e4b0c09e718fa62 Mon Sep 17 00:00:00 2001 From: Sho Amano Date: Wed, 27 Feb 2019 06:53:16 +0900 Subject: fix: remove shared pointer of Application from HmiState (#2225) * fix: remove shared pointer of Application from HmiState This is to fix memory leak issue of ApplicationImpl instances caused by cyclic reference of shared pointers. Implementation in HmiState class is reverted to use app_id instead of shared pointer. * Reflect review comments - store hmi_app_id rather than app_id - use app_mngr_.application_by_hmi_app() to retrieve the shared pointer Also, the old methods with app_id argument are marked as deprecated again. * Update mock functions in state controller test This is to align the changes in hmi_state.cc. * fix: application_manager_test crashes on Ubuntu 14.04 This only affects unit tests. * Add hmi app id in the HmiState output Reflecting review comment. * fix: taking care ApplicationSharedPtr being null in hmi_state.cc * fix: help_prompt_manager_test failures - Remove outdated, unnecessary state creation - Fix the order of destructions of member instances * fix: state_controller_test failures The test code was not correct. Actually RegularHmiState() method of the mock class was never called, but because the instance wasn't properly disposed the expectation was never verified. The solution is to simply remove the inappropriate expectations. --- .../include/application_manager/hmi_state.h | 2 +- .../application_manager/src/hmi_state.cc | 36 ++++-- .../test/application_impl_test.cc | 8 +- .../test/help_prompt_manager_test.cc | 9 +- .../test/state_controller/state_controller_test.cc | 137 +++++++++++++-------- 5 files changed, 125 insertions(+), 67 deletions(-) diff --git a/src/components/application_manager/include/application_manager/hmi_state.h b/src/components/application_manager/include/application_manager/hmi_state.h index 07d9c8dc23..774376b249 100644 --- a/src/components/application_manager/include/application_manager/hmi_state.h +++ b/src/components/application_manager/include/application_manager/hmi_state.h @@ -207,7 +207,7 @@ class HmiState { } protected: - std::shared_ptr app_; + uint32_t hmi_app_id_; StateID state_id_; const ApplicationManager& app_mngr_; HmiStatePtr parent_; diff --git a/src/components/application_manager/src/hmi_state.cc b/src/components/application_manager/src/hmi_state.cc index 7be9668543..e220988f0e 100644 --- a/src/components/application_manager/src/hmi_state.cc +++ b/src/components/application_manager/src/hmi_state.cc @@ -45,7 +45,7 @@ CREATE_LOGGERPTR_GLOBAL(logger_, "HmiState") HmiState::HmiState(std::shared_ptr app, const ApplicationManager& app_mngr, StateID state_id) - : app_(app) + : hmi_app_id_(app->hmi_app_id()) , state_id_(state_id) , app_mngr_(app_mngr) , hmi_level_(mobile_apis::HMILevel::INVALID_ENUM) @@ -57,7 +57,7 @@ HmiState::HmiState(std::shared_ptr app, HmiState::HmiState(std::shared_ptr app, const ApplicationManager& app_mngr) - : app_(app) + : hmi_app_id_(app->hmi_app_id()) , state_id_(STATE_ID_REGULAR) , app_mngr_(app_mngr) , hmi_level_(mobile_apis::HMILevel::INVALID_ENUM) @@ -73,19 +73,27 @@ void HmiState::set_parent(HmiStatePtr parent) { } bool HmiState::is_navi_app() const { - return app_->is_navi(); + const ApplicationSharedPtr app = + app_mngr_.application_by_hmi_app(hmi_app_id_); + return app ? app->is_navi() : false; } bool HmiState::is_media_app() const { - return app_->is_media_application(); + const ApplicationSharedPtr app = + app_mngr_.application_by_hmi_app(hmi_app_id_); + return app ? app->is_media_application() : false; } bool HmiState::is_voice_communication_app() const { - return app_->is_voice_communication_supported(); + const ApplicationSharedPtr app = + app_mngr_.application_by_hmi_app(hmi_app_id_); + return app ? app->is_voice_communication_supported() : false; } bool HmiState::is_mobile_projection_app() const { - return app_->mobile_projection_enabled(); + const ApplicationSharedPtr app = + app_mngr_.application_by_hmi_app(hmi_app_id_); + return app ? app->mobile_projection_enabled() : false; } mobile_apis::AudioStreamingState::eType VRHmiState::audio_streaming_state() @@ -123,7 +131,9 @@ VideoStreamingHmiState::VideoStreamingHmiState( mobile_apis::VideoStreamingState::eType VideoStreamingHmiState::video_streaming_state() const { - if (app_->IsVideoApplication()) { + const ApplicationSharedPtr app = + app_mngr_.application_by_hmi_app(hmi_app_id_); + if (app && app->IsVideoApplication()) { return parent()->video_streaming_state(); } @@ -201,7 +211,7 @@ AudioSource::AudioSource(std::shared_ptr app, const ApplicationManager& app_mngr) : HmiState(app, app_mngr, STATE_ID_AUDIO_SOURCE) , keep_context_(app->keep_context()) { - app_->set_keep_context(false); + app->set_keep_context(false); } mobile_apis::HMILevel::eType AudioSource::hmi_level() const { @@ -260,7 +270,15 @@ std::ostream& operator<<(std::ostream& os, const HmiState::StateID src) { } std::ostream& operator<<(std::ostream& os, const HmiState& src) { - os << "HMIState(app id:" << src.app_->app_id() << ", state:" << src.state_id() + const ApplicationSharedPtr app = + src.app_mngr_.application_by_hmi_app(src.hmi_app_id_); + os << "HMIState(app id:"; + if (app) { + os << app->app_id(); + } else { + os << "(none)"; + } + os << ", hmi app id:" << src.hmi_app_id_ << ", state:" << src.state_id() << ", hmi_level:" << src.hmi_level() << ", audio:" << src.audio_streaming_state() << ", video:" << src.video_streaming_state() diff --git a/src/components/application_manager/test/application_impl_test.cc b/src/components/application_manager/test/application_impl_test.cc index 301ed227b8..437f567538 100644 --- a/src/components/application_manager/test/application_impl_test.cc +++ b/src/components/application_manager/test/application_impl_test.cc @@ -118,6 +118,13 @@ class ApplicationImplTest : public ::testing::Test { AddSet hmi_action); void CheckCurrentHMIState(); + // 'directory_name' has to be declared prior to 'app_impl' so that when + // deleting ApplicationImplTest class, 'directory_name' will be removed + // after 'app_impl' runs its destructor. + // (ApplicationImpl's destructor calls CleanupFiles(), which will call + // application_manager_.get_settings().app_storage_folder() and will + // access 'directory_name'.) + const std::string directory_name = "./test_storage"; MockApplicationManagerSettings mock_application_manager_settings_; MockApplicationManager mock_application_manager_; std::shared_ptr app_impl; @@ -126,7 +133,6 @@ class ApplicationImplTest : public ::testing::Test { std::string mac_address; connection_handler::DeviceHandle device_handle; custom_str::CustomString app_name; - const std::string directory_name = "./test_storage"; HmiState::StateID state_id; HmiStatePtr testHmiState; HMILevel::eType test_lvl; diff --git a/src/components/application_manager/test/help_prompt_manager_test.cc b/src/components/application_manager/test/help_prompt_manager_test.cc index f921eb1dde..dc6635b049 100644 --- a/src/components/application_manager/test/help_prompt_manager_test.cc +++ b/src/components/application_manager/test/help_prompt_manager_test.cc @@ -136,10 +136,12 @@ class HelpPromptManagerTest : public ::testing::Test { typedef CommandsTest::MockAppManager MockAppManager; MockAppManager app_mngr_; + // put this before ApplicationImplTest instance, so that app_mngr_settings_ + // will still exist during app_impl_'s destructor. + NiceMock app_mngr_settings_; std::shared_ptr app_impl_; MockHmiInterfaces mock_hmi_interfaces_; NiceMock mock_event_dispatcher_; - NiceMock app_mngr_settings_; std::shared_ptr mock_app_; sync_primitives::Lock app_lock_; MockRPCService mock_rpc_service_; @@ -175,11 +177,6 @@ void HelpPromptManagerTest::SetUp() { mock_help_prompt_manager_ = std::shared_ptr(new MockHelpPromptManager()); - HmiStatePtr state = std::make_shared( - static_cast >(mock_app_), - app_mngr_, - HmiState::STATE_ID_REGULAR); - std::string path = file_system::CreateDirectory("storage"); file_system::CreateFile(path + "/" + "certificate"); diff --git a/src/components/application_manager/test/state_controller/state_controller_test.cc b/src/components/application_manager/test/state_controller/state_controller_test.cc index 1d4cead52b..76d9a69e74 100644 --- a/src/components/application_manager/test/state_controller/state_controller_test.cc +++ b/src/components/application_manager/test/state_controller/state_controller_test.cc @@ -170,34 +170,42 @@ class StateControllerImplTest : public ::testing::Test { am::ApplicationSharedPtr simple_app_; NiceMock* simple_app_ptr_; uint32_t simple_app_id_ = 1721; + uint32_t simple_hmi_app_id_ = 22770; // random number am::ApplicationSharedPtr navi_app_; NiceMock* navi_app_ptr_; uint32_t navi_app_id_ = 1762; + uint32_t navi_hmi_app_id_ = 17559; am::ApplicationSharedPtr media_app_; NiceMock* media_app_ptr_; uint32_t media_app_id_ = 1801; + uint32_t media_hmi_app_id_ = 12751; am::ApplicationSharedPtr vc_app_; NiceMock* vc_app_ptr_; uint32_t vc_app_id_ = 1825; + uint32_t vc_hmi_app_id_ = 14986; am::ApplicationSharedPtr media_navi_app_; NiceMock* media_navi_app_ptr_; uint32_t media_navi_app_id_ = 1855; + uint32_t media_navi_hmi_app_id_ = 16194; am::ApplicationSharedPtr media_vc_app_; NiceMock* media_vc_app_ptr_; uint32_t media_vc_app_id_ = 1881; + uint32_t media_vc_hmi_app_id_ = 12798; am::ApplicationSharedPtr navi_vc_app_; NiceMock* navi_vc_app_ptr_; uint32_t navi_vc_app_id_ = 1894; + uint32_t navi_vc_hmi_app_id_ = 10807; am::ApplicationSharedPtr media_navi_vc_app_; NiceMock* media_navi_vc_app_ptr_; uint32_t media_navi_vc_app_id_ = 1922; + uint32_t media_navi_vc_hmi_app_id_ = 21419; std::vector valid_states_for_audio_app_; std::vector valid_states_for_not_audio_app_; @@ -661,6 +669,7 @@ class StateControllerImplTest : public ::testing::Test { am::ApplicationSharedPtr ConfigureApp( NiceMock** app_mock, uint32_t app_id, + uint32_t hmi_app_id, bool media, bool navi, bool vc) { @@ -670,6 +679,7 @@ class StateControllerImplTest : public ::testing::Test { am::ApplicationSharedPtr app(*app_mock); ON_CALL(**app_mock, app_id()).WillByDefault(Return(app_id)); + ON_CALL(**app_mock, hmi_app_id()).WillByDefault(Return(hmi_app_id)); ON_CALL(**app_mock, is_media_application()).WillByDefault(Return(media)); ON_CALL(**app_mock, is_navi()).WillByDefault(Return(navi)); ON_CALL(**app_mock, is_voice_communication_supported()) @@ -871,21 +881,50 @@ class StateControllerImplTest : public ::testing::Test { } void ConfigureApps() { - simple_app_ = ConfigureApp( - &simple_app_ptr_, simple_app_id_, NOT_MEDIA, NOT_NAVI, NOT_VC); - media_app_ = - ConfigureApp(&media_app_ptr_, media_app_id_, MEDIA, NOT_NAVI, NOT_VC); - navi_app_ = - ConfigureApp(&navi_app_ptr_, navi_app_id_, NOT_MEDIA, NAVI, NOT_VC); - vc_app_ = ConfigureApp(&vc_app_ptr_, vc_app_id_, NOT_MEDIA, NOT_NAVI, VC); - media_navi_app_ = ConfigureApp( - &media_navi_app_ptr_, media_navi_app_id_, MEDIA, NAVI, NOT_VC); - media_vc_app_ = - ConfigureApp(&media_vc_app_ptr_, media_vc_app_id_, MEDIA, NOT_NAVI, VC); - navi_vc_app_ = - ConfigureApp(&navi_vc_app_ptr_, navi_vc_app_id_, NOT_MEDIA, NAVI, VC); - media_navi_vc_app_ = ConfigureApp( - &media_navi_vc_app_ptr_, media_navi_vc_app_id_, MEDIA, NAVI, VC); + simple_app_ = ConfigureApp(&simple_app_ptr_, + simple_app_id_, + simple_hmi_app_id_, + NOT_MEDIA, + NOT_NAVI, + NOT_VC); + media_app_ = ConfigureApp(&media_app_ptr_, + media_app_id_, + media_hmi_app_id_, + MEDIA, + NOT_NAVI, + NOT_VC); + navi_app_ = ConfigureApp(&navi_app_ptr_, + navi_app_id_, + navi_hmi_app_id_, + NOT_MEDIA, + NAVI, + NOT_VC); + vc_app_ = ConfigureApp( + &vc_app_ptr_, vc_app_id_, vc_hmi_app_id_, NOT_MEDIA, NOT_NAVI, VC); + media_navi_app_ = ConfigureApp(&media_navi_app_ptr_, + media_navi_app_id_, + media_navi_hmi_app_id_, + MEDIA, + NAVI, + NOT_VC); + media_vc_app_ = ConfigureApp(&media_vc_app_ptr_, + media_vc_app_id_, + media_vc_hmi_app_id_, + MEDIA, + NOT_NAVI, + VC); + navi_vc_app_ = ConfigureApp(&navi_vc_app_ptr_, + navi_vc_app_id_, + navi_vc_hmi_app_id_, + NOT_MEDIA, + NAVI, + VC); + media_navi_vc_app_ = ConfigureApp(&media_navi_vc_app_ptr_, + media_navi_vc_app_id_, + media_navi_vc_hmi_app_id_, + MEDIA, + NAVI, + VC); applications_list_.push_back(simple_app_); applications_list_.push_back(media_app_); applications_list_.push_back(navi_app_); @@ -914,6 +953,15 @@ class StateControllerImplTest : public ::testing::Test { ASSERT_EQ(navi_vc_app_->app_id(), navi_vc_app_id_); ASSERT_EQ(media_navi_vc_app_->app_id(), media_navi_vc_app_id_); + ASSERT_EQ(simple_app_->hmi_app_id(), simple_hmi_app_id_); + ASSERT_EQ(media_app_->hmi_app_id(), media_hmi_app_id_); + ASSERT_EQ(navi_app_->hmi_app_id(), navi_hmi_app_id_); + ASSERT_EQ(vc_app_->hmi_app_id(), vc_hmi_app_id_); + ASSERT_EQ(media_navi_app_->hmi_app_id(), media_navi_hmi_app_id_); + ASSERT_EQ(media_vc_app_->hmi_app_id(), media_vc_hmi_app_id_); + ASSERT_EQ(navi_vc_app_->hmi_app_id(), navi_vc_hmi_app_id_); + ASSERT_EQ(media_navi_vc_app_->hmi_app_id(), media_navi_vc_hmi_app_id_); + ASSERT_FALSE(simple_app_->IsAudioApplication()); ASSERT_TRUE(media_app_->IsAudioApplication()); ASSERT_TRUE(navi_app_->IsAudioApplication()); @@ -1040,6 +1088,8 @@ class StateControllerImplTest : public ::testing::Test { application_set_.insert(app); ON_CALL(app_manager_mock_, application(app->app_id())) .WillByDefault(Return(app)); + ON_CALL(app_manager_mock_, application_by_hmi_app(app->hmi_app_id())) + .WillByDefault(Return(app)); } am::HmiStatePtr NoneNotAudibleState() { @@ -1475,9 +1525,9 @@ TEST_F(StateControllerImplTest, NiceMock* app_moved_to_full_mock; app_in_full = - ConfigureApp(&app_in_full_mock, 1761, NOT_MEDIA, NOT_NAVI, NOT_VC); - app_moved_to_full = - ConfigureApp(&app_moved_to_full_mock, 1796, NOT_MEDIA, NOT_NAVI, NOT_VC); + ConfigureApp(&app_in_full_mock, 1761, 15685, NOT_MEDIA, NOT_NAVI, NOT_VC); + app_moved_to_full = ConfigureApp( + &app_moved_to_full_mock, 1796, 30093, NOT_MEDIA, NOT_NAVI, NOT_VC); InsertApplication(app_in_full); InsertApplication(app_moved_to_full); @@ -1549,11 +1599,11 @@ TEST_F(StateControllerImplTest, namespace SystemContext = mobile_apis::SystemContext; NiceMock* app_in_full_mock; am::ApplicationSharedPtr app_in_full = - ConfigureApp(&app_in_full_mock, 1761, MEDIA, NOT_NAVI, NOT_VC); + ConfigureApp(&app_in_full_mock, 1761, 15685, MEDIA, NOT_NAVI, NOT_VC); NiceMock* app_moved_to_full_mock; - am::ApplicationSharedPtr app_moved_to_full = - ConfigureApp(&app_moved_to_full_mock, 1796, MEDIA, NOT_NAVI, NOT_VC); + am::ApplicationSharedPtr app_moved_to_full = ConfigureApp( + &app_moved_to_full_mock, 1796, 30093, MEDIA, NOT_NAVI, NOT_VC); InsertApplication(app_in_full); InsertApplication(app_moved_to_full); @@ -1575,11 +1625,11 @@ TEST_F(StateControllerImplTest, NiceMock* app_in_limited_mock; am::ApplicationSharedPtr app_in_limited = - ConfigureApp(&app_in_limited_mock, 1761, NOT_MEDIA, NAVI, NOT_VC); + ConfigureApp(&app_in_limited_mock, 1761, 15685, NOT_MEDIA, NAVI, NOT_VC); NiceMock* app_moved_to_full_mock; am::ApplicationSharedPtr app_moved_to_full = - ConfigureApp(&app_moved_to_full_mock, 1796, NOT_MEDIA, NAVI, VC); + ConfigureApp(&app_moved_to_full_mock, 1796, 30093, NOT_MEDIA, NAVI, VC); InsertApplication(app_in_limited); InsertApplication(app_moved_to_full); @@ -1600,12 +1650,12 @@ TEST_F(StateControllerImplTest, namespace SystemContext = mobile_apis::SystemContext; NiceMock* app_in_limited_mock; am::ApplicationSharedPtr app_in_limited = - ConfigureApp(&app_in_limited_mock, 1761, NOT_MEDIA, NOT_NAVI, VC); + ConfigureApp(&app_in_limited_mock, 1761, 15685, NOT_MEDIA, NOT_NAVI, VC); NiceMock* app_moved_to_limited_mock; - am::ApplicationSharedPtr app_moved_to_limited = - ConfigureApp(&app_moved_to_limited_mock, 1796, NOT_MEDIA, NOT_NAVI, VC); + am::ApplicationSharedPtr app_moved_to_limited = ConfigureApp( + &app_moved_to_limited_mock, 1796, 30093, NOT_MEDIA, NOT_NAVI, VC); InsertApplication(app_in_limited); InsertApplication(app_moved_to_limited); @@ -1749,8 +1799,8 @@ TEST_F(StateControllerImplTest, namespace SystemContext = mobile_apis::SystemContext; NiceMock* app_moved_to_full_mock; - am::ApplicationSharedPtr app_moved_to_full = - ConfigureApp(&app_moved_to_full_mock, 1761, NOT_MEDIA, NOT_NAVI, NOT_VC); + am::ApplicationSharedPtr app_moved_to_full = ConfigureApp( + &app_moved_to_full_mock, 1761, 15685, NOT_MEDIA, NOT_NAVI, NOT_VC); am::ApplicationSharedPtr limited_app = media_app_; NiceMock* limited_app_mock = @@ -1758,7 +1808,7 @@ TEST_F(StateControllerImplTest, NiceMock* full_app_mock; am::ApplicationSharedPtr full_app = - ConfigureApp(&full_app_mock, 1796, NOT_MEDIA, NOT_NAVI, NOT_VC); + ConfigureApp(&full_app_mock, 1796, 30093, NOT_MEDIA, NOT_NAVI, NOT_VC); InsertApplication(app_moved_to_full); InsertApplication(limited_app); @@ -1786,16 +1836,16 @@ TEST_F( namespace SystemContext = mobile_apis::SystemContext; NiceMock* app_moved_to_full_mock; - am::ApplicationSharedPtr app_moved_to_full = - ConfigureApp(&app_moved_to_full_mock, 1761, MEDIA, NOT_NAVI, NOT_VC); + am::ApplicationSharedPtr app_moved_to_full = ConfigureApp( + &app_moved_to_full_mock, 1761, 15685, MEDIA, NOT_NAVI, NOT_VC); NiceMock* limited_app_mock; am::ApplicationSharedPtr limited_app = - ConfigureApp(&limited_app_mock, 1762, MEDIA, NOT_NAVI, NOT_VC); + ConfigureApp(&limited_app_mock, 1762, 17559, MEDIA, NOT_NAVI, NOT_VC); NiceMock* full_app_mock; am::ApplicationSharedPtr full_app = - ConfigureApp(&full_app_mock, 1796, NOT_MEDIA, NOT_NAVI, NOT_VC); + ConfigureApp(&full_app_mock, 1796, 30093, NOT_MEDIA, NOT_NAVI, NOT_VC); InsertApplication(app_moved_to_full); InsertApplication(limited_app); @@ -1823,16 +1873,16 @@ TEST_F( namespace SystemContext = mobile_apis::SystemContext; NiceMock* app_moved_to_full_mock; - am::ApplicationSharedPtr app_moved_to_full = - ConfigureApp(&app_moved_to_full_mock, 1761, MEDIA, NOT_NAVI, NOT_VC); + am::ApplicationSharedPtr app_moved_to_full = ConfigureApp( + &app_moved_to_full_mock, 1761, 15685, MEDIA, NOT_NAVI, NOT_VC); NiceMock* limited_app_mock; am::ApplicationSharedPtr limited_app = - ConfigureApp(&limited_app_mock, 1762, MEDIA, NOT_NAVI, NOT_VC); + ConfigureApp(&limited_app_mock, 1762, 17559, MEDIA, NOT_NAVI, NOT_VC); NiceMock* full_app_mock; am::ApplicationSharedPtr full_app = - ConfigureApp(&full_app_mock, 1796, NOT_MEDIA, NAVI, NOT_VC); + ConfigureApp(&full_app_mock, 1796, 30093, NOT_MEDIA, NAVI, NOT_VC); InsertApplication(app_moved_to_full); InsertApplication(limited_app); @@ -2845,14 +2895,7 @@ TEST_F(StateControllerImplTest, am::event_engine::Event event(event_id); event.set_smart_object(msg); - const HmiStatePtr state = - createHmiState(mobile_apis::HMILevel::HMI_FULL, - mobile_apis::AudioStreamingState::AUDIBLE, - mobile_apis::VideoStreamingState::NOT_STREAMABLE, - mobile_apis::SystemContext::SYSCTXT_MAIN); - EXPECT_CALL(*simple_app_ptr_, keep_context()).WillOnce(Return(true)); - EXPECT_CALL(*simple_app_ptr_, RegularHmiState()).WillOnce(Return(state)); EXPECT_CALL(*simple_app_ptr_, IsAudioApplication()) .WillRepeatedly(Return(true)); EXPECT_CALL(*simple_app_ptr_, CurrentHmiState()) @@ -2884,12 +2927,6 @@ TEST_F(StateControllerImplTest, OnEventChangedAudioSourceAppToBackground) { am::event_engine::Event event(event_id); event.set_smart_object(msg); - const HmiStatePtr state = - createHmiState(mobile_apis::HMILevel::HMI_LIMITED, - mobile_apis::AudioStreamingState::AUDIBLE, - mobile_apis::VideoStreamingState::NOT_STREAMABLE, - mobile_apis::SystemContext::SYSCTXT_MAIN); - EXPECT_CALL(*simple_app_ptr_, RegularHmiState()).WillOnce(Return(state)); EXPECT_CALL(*simple_app_ptr_, IsAudioApplication()) .WillRepeatedly(Return(true)); EXPECT_CALL(*simple_app_ptr_, CurrentHmiState()) -- cgit v1.2.1 From 0c3ff46e28386f59b530a08c1df8de67372dce77 Mon Sep 17 00:00:00 2001 From: jacobkeeler Date: Tue, 26 Feb 2019 19:08:27 -0500 Subject: Add logic for `HMIOriginID` and `EmbeddedServices` --- .../application_manager/app_service_manager.h | 11 +++-- .../application_manager/smart_object_keys.h | 1 + ...orm_app_service_interaction_request_from_hmi.cc | 19 ++++++++ .../application_manager/src/app_service_manager.cc | 54 ++++++++++++++++++---- .../application_manager/src/smart_object_keys.cc | 1 + 5 files changed, 74 insertions(+), 12 deletions(-) diff --git a/src/components/application_manager/include/application_manager/app_service_manager.h b/src/components/application_manager/include/application_manager/app_service_manager.h index 386b473f3d..621eeb18a7 100644 --- a/src/components/application_manager/include/application_manager/app_service_manager.h +++ b/src/components/application_manager/include/application_manager/app_service_manager.h @@ -58,6 +58,8 @@ class ApplicationManager; */ class AppServiceManager { public: + const std::string kEmbeddedService = "EMBEDDED_SERVICE"; + /** * @brief Class constructor * @param app_manager @@ -152,9 +154,6 @@ class AppServiceManager { std::string DefaultServiceByType(std::string service_type); private: - void GetProviderFromService(const AppService& service, - ApplicationSharedPtr& app, - bool& hmi_service); ApplicationManager& app_manager_; resumption::LastState& last_state_; std::map published_services_; @@ -164,6 +163,12 @@ class AppServiceManager { const smart_objects::SmartObject& service_record, const mobile_apis::ServiceUpdateReason::eType update_reason, smart_objects::SmartObject& msg_params); + void GetProviderFromService(const AppService& service, + ApplicationSharedPtr& app, + bool& hmi_service); + std::pair FindServiceByAppID(std::string name, + std::string type); + std::string GetServiceAppID(AppService service); }; } // namespace application_manager 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 33fc3bd7d5..5bafdaf4d0 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 @@ -326,6 +326,7 @@ extern const char* updated_app_service_record; extern const char* service_records; extern const char* activate; extern const char* set_as_default; +extern const char* origin_app; // resuming extern const char* application_commands; diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_perform_app_service_interaction_request_from_hmi.cc b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_perform_app_service_interaction_request_from_hmi.cc index 8f52268f19..c384e73d33 100644 --- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_perform_app_service_interaction_request_from_hmi.cc +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_perform_app_service_interaction_request_from_hmi.cc @@ -57,6 +57,25 @@ void ASPerformAppServiceInteractionRequestFromHMI::Run() { LOG4CXX_AUTO_TRACE(logger_); smart_objects::SmartObject& msg_params = (*message_)[strings::msg_params]; + std::string hmi_origin_id = + application_manager_.get_settings().hmi_origin_id(); + if (!msg_params.keyExists(strings::origin_app)) { + if (hmi_origin_id.empty()) { + smart_objects::SmartObject response_params; + response_params[strings::info] = + "No HMI origin ID to use for interaction passthrough"; + SendResponse( + false, + correlation_id(), + hmi_apis::FunctionID::AppService_PerformAppServiceInteraction, + hmi_apis::Common_Result::INVALID_DATA, + &response_params, + application_manager::commands::Command::SOURCE_SDL_TO_HMI); + return; + } + msg_params[strings::origin_app] = hmi_origin_id; + } + std::string service_id = msg_params[strings::service_id].asString(); auto service = application_manager_.GetAppServiceManager().FindServiceByID(service_id); diff --git a/src/components/application_manager/src/app_service_manager.cc b/src/components/application_manager/src/app_service_manager.cc index f26bcaf01f..bccfcfb368 100644 --- a/src/components/application_manager/src/app_service_manager.cc +++ b/src/components/application_manager/src/app_service_manager.cc @@ -88,10 +88,21 @@ smart_objects::SmartObject AppServiceManager::PublishAppService( app_service.record = service_record; std::string service_type = manifest[strings::service_type].asString(); - Json::Value& dictionary = last_state_.get_dictionary(); - app_service.default_service = - (dictionary[kAppServiceSection][kDefaults][service_type].asString() == - manifest[strings::service_name].asString()); + + std::string default_app_id = DefaultServiceByType(service_type); + if (default_app_id.empty() && !mobile_service) { + auto embedded_services = app_manager_.get_settings().embedded_services(); + for (auto it = embedded_services.begin(); it != embedded_services.end(); + ++it) { + if (*it == service_type) { + Json::Value& dictionary = last_state_.get_dictionary(); + dictionary[kAppServiceSection][kDefaults][service_type] = + kEmbeddedService; + default_app_id = kEmbeddedService; + } + } + } + app_service.default_service = GetServiceAppID(app_service) == default_app_id; published_services_.insert( std::pair(service_id, app_service)); @@ -234,9 +245,9 @@ bool AppServiceManager::SetDefaultService(const std::string service_id) { std::string service_type = service.record[strings::service_manifest][strings::service_type] .asString(); - std::string default_service_name = DefaultServiceByType(service_type); - if (!default_service_name.empty()) { - auto default_service = FindServiceByName(default_service_name); + std::string default_app_id = DefaultServiceByType(service_type); + if (!default_app_id.empty()) { + auto default_service = FindServiceByAppID(default_app_id, service_type); if (!default_service.first.empty()) { default_service.second.default_service = false; } @@ -245,8 +256,7 @@ bool AppServiceManager::SetDefaultService(const std::string service_id) { Json::Value& dictionary = last_state_.get_dictionary(); dictionary[kAppServiceSection][kDefaults][service_type] = - service.record[strings::service_manifest][strings::service_name] - .asString(); + GetServiceAppID(service); return true; } @@ -386,6 +396,24 @@ std::pair AppServiceManager::FindServiceByName( return std::make_pair(std::string(), empty); } +std::pair AppServiceManager::FindServiceByAppID( + std::string name, std::string type) { + LOG4CXX_AUTO_TRACE(logger_); + for (auto it = published_services_.begin(); it != published_services_.end(); + ++it) { + if (it->second.record[strings::service_manifest][strings::service_type] + .asString() != type) { + continue; + } + + if (name == GetServiceAppID(it->second)) { + return *it; + } + } + AppService empty; + return std::make_pair(std::string(), empty); +} + std::pair AppServiceManager::FindServiceByID( std::string service_id) { LOG4CXX_AUTO_TRACE(logger_); @@ -420,6 +448,14 @@ void AppServiceManager::SetServicePublished(const std::string service_id, it->second.record[strings::service_published] = service_published; } +std::string AppServiceManager::GetServiceAppID(AppService service) { + if (service.mobile_service) { + auto app = app_manager_.application(service.connection_key); + return app ? app->policy_app_id() : std::string(); + } + return kEmbeddedService; +} + void AppServiceManager::BroadcastAppServiceUpdate( smart_objects::SmartObject& msg_params) { LOG4CXX_AUTO_TRACE(logger_); diff --git a/src/components/application_manager/src/smart_object_keys.cc b/src/components/application_manager/src/smart_object_keys.cc index 8df9a5cfbd..b59cfb8778 100644 --- a/src/components/application_manager/src/smart_object_keys.cc +++ b/src/components/application_manager/src/smart_object_keys.cc @@ -293,6 +293,7 @@ const char* updated_app_service_record = "updatedAppServiceRecord"; const char* service_records = "serviceRecords"; const char* activate = "activate"; const char* set_as_default = "setAsDefault"; +const char* origin_app = "originApp"; // resuming const char* application_commands = "applicationCommands"; -- cgit v1.2.1 From 601ab1906f58442a4353957f438a68dcf2648b30 Mon Sep 17 00:00:00 2001 From: jacobkeeler Date: Wed, 27 Feb 2019 13:47:23 -0500 Subject: Address comments --- .../include/application_manager/app_service_manager.h | 6 +++--- .../application_manager/src/app_service_manager.cc | 15 ++++++++------- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/src/components/application_manager/include/application_manager/app_service_manager.h b/src/components/application_manager/include/application_manager/app_service_manager.h index 621eeb18a7..9920b63bd7 100644 --- a/src/components/application_manager/include/application_manager/app_service_manager.h +++ b/src/components/application_manager/include/application_manager/app_service_manager.h @@ -166,9 +166,9 @@ class AppServiceManager { void GetProviderFromService(const AppService& service, ApplicationSharedPtr& app, bool& hmi_service); - std::pair FindServiceByAppID(std::string name, - std::string type); - std::string GetServiceAppID(AppService service); + std::pair FindServiceByPolicyAppID( + std::string policy_app_id, std::string type); + std::string GetPolicyAppID(AppService service); }; } // namespace application_manager diff --git a/src/components/application_manager/src/app_service_manager.cc b/src/components/application_manager/src/app_service_manager.cc index bccfcfb368..11740f13a6 100644 --- a/src/components/application_manager/src/app_service_manager.cc +++ b/src/components/application_manager/src/app_service_manager.cc @@ -102,7 +102,7 @@ smart_objects::SmartObject AppServiceManager::PublishAppService( } } } - app_service.default_service = GetServiceAppID(app_service) == default_app_id; + app_service.default_service = GetPolicyAppID(app_service) == default_app_id; published_services_.insert( std::pair(service_id, app_service)); @@ -247,7 +247,8 @@ bool AppServiceManager::SetDefaultService(const std::string service_id) { .asString(); std::string default_app_id = DefaultServiceByType(service_type); if (!default_app_id.empty()) { - auto default_service = FindServiceByAppID(default_app_id, service_type); + auto default_service = + FindServiceByPolicyAppID(default_app_id, service_type); if (!default_service.first.empty()) { default_service.second.default_service = false; } @@ -256,7 +257,7 @@ bool AppServiceManager::SetDefaultService(const std::string service_id) { Json::Value& dictionary = last_state_.get_dictionary(); dictionary[kAppServiceSection][kDefaults][service_type] = - GetServiceAppID(service); + GetPolicyAppID(service); return true; } @@ -396,8 +397,8 @@ std::pair AppServiceManager::FindServiceByName( return std::make_pair(std::string(), empty); } -std::pair AppServiceManager::FindServiceByAppID( - std::string name, std::string type) { +std::pair AppServiceManager::FindServiceByPolicyAppID( + std::string policy_app_id, std::string type) { LOG4CXX_AUTO_TRACE(logger_); for (auto it = published_services_.begin(); it != published_services_.end(); ++it) { @@ -406,7 +407,7 @@ std::pair AppServiceManager::FindServiceByAppID( continue; } - if (name == GetServiceAppID(it->second)) { + if (policy_app_id == GetPolicyAppID(it->second)) { return *it; } } @@ -448,7 +449,7 @@ void AppServiceManager::SetServicePublished(const std::string service_id, it->second.record[strings::service_published] = service_published; } -std::string AppServiceManager::GetServiceAppID(AppService service) { +std::string AppServiceManager::GetPolicyAppID(AppService service) { if (service.mobile_service) { auto app = app_manager_.application(service.connection_key); return app ? app->policy_app_id() : std::string(); -- cgit v1.2.1 From 1501c34acdbf40ab603a3ba74b0e280db29c0506 Mon Sep 17 00:00:00 2001 From: JackLivio Date: Wed, 27 Feb 2019 17:31:46 -0500 Subject: Increase stack size to fix segault --- src/components/protocol_handler/src/protocol_handler_impl.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/protocol_handler/src/protocol_handler_impl.cc b/src/components/protocol_handler/src/protocol_handler_impl.cc index 083e204ac3..27b06af424 100644 --- a/src/components/protocol_handler/src/protocol_handler_impl.cc +++ b/src/components/protocol_handler/src/protocol_handler_impl.cc @@ -59,7 +59,7 @@ CREATE_LOGGERPTR_GLOBAL(logger_, "ProtocolHandler") std::string ConvertPacketDataToString(const uint8_t* data, const size_t data_size); -const size_t kStackSize = 65536; +const size_t kStackSize = 131072; utils::SemanticVersion default_protocol_version(5, 2, 0); utils::SemanticVersion min_multiple_transports_version(5, 1, 0); -- cgit v1.2.1 From 090ebab24ddb3c761386f20e873b0142fb42db51 Mon Sep 17 00:00:00 2001 From: jacobkeeler Date: Wed, 27 Feb 2019 17:49:02 -0500 Subject: Add lock for `published_services` map Also modify getter functions for services --- .../application_manager/app_service_manager.h | 16 ++-- ...orm_app_service_interaction_request_from_hmi.cc | 7 +- .../perform_app_service_interaction_request.cc | 7 +- .../application_manager/src/app_service_manager.cc | 106 +++++++++++---------- 4 files changed, 71 insertions(+), 65 deletions(-) diff --git a/src/components/application_manager/include/application_manager/app_service_manager.h b/src/components/application_manager/include/application_manager/app_service_manager.h index 5a345e60fb..80e6b5521f 100644 --- a/src/components/application_manager/include/application_manager/app_service_manager.h +++ b/src/components/application_manager/include/application_manager/app_service_manager.h @@ -133,15 +133,13 @@ class AppServiceManager { ApplicationSharedPtr& app, bool& hmi_service); - std::pair ActiveServiceByType( - std::string service_type); + AppService* ActiveServiceByType(std::string service_type); - std::pair EmbeddedServiceForType( - std::string service_type); + AppService* EmbeddedServiceForType(std::string service_type); - std::pair FindServiceByName(std::string name); + AppService* FindServiceByName(std::string name); - std::pair FindServiceByID(std::string service_id); + AppService* FindServiceByID(std::string service_id); std::string DefaultServiceByType(std::string service_type); @@ -162,6 +160,8 @@ class AppServiceManager { private: ApplicationManager& app_manager_; resumption::LastState& last_state_; + + sync_primitives::RecursiveLock published_services_lock_; std::map published_services_; void AppServiceUpdated( @@ -171,8 +171,8 @@ class AppServiceManager { void GetProviderFromService(const AppService& service, ApplicationSharedPtr& app, bool& hmi_service); - std::pair FindServiceByPolicyAppID( - std::string policy_app_id, std::string type); + AppService* FindServiceByPolicyAppID(std::string policy_app_id, + std::string type); std::string GetPolicyAppID(AppService service); }; diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_perform_app_service_interaction_request_from_hmi.cc b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_perform_app_service_interaction_request_from_hmi.cc index c384e73d33..2b66993d8f 100644 --- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_perform_app_service_interaction_request_from_hmi.cc +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_perform_app_service_interaction_request_from_hmi.cc @@ -79,7 +79,7 @@ void ASPerformAppServiceInteractionRequestFromHMI::Run() { std::string service_id = msg_params[strings::service_id].asString(); auto service = application_manager_.GetAppServiceManager().FindServiceByID(service_id); - if (service.first.empty()) { + if (!service) { smart_objects::SmartObject response_params; response_params[strings::info] = "The requested service ID does not exist"; SendResponse(false, @@ -99,9 +99,8 @@ void ASPerformAppServiceInteractionRequestFromHMI::Run() { } // Only activate service if it is not already active - bool activate_service = - request_service_active && - !service.second.record[strings::service_active].asBool(); + bool activate_service = request_service_active && + !service->record[strings::service_active].asBool(); if (activate_service) { application_manager_.GetAppServiceManager().ActivateAppService(service_id); } diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/perform_app_service_interaction_request.cc b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/perform_app_service_interaction_request.cc index d21c413b29..952d1834fb 100644 --- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/perform_app_service_interaction_request.cc +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/perform_app_service_interaction_request.cc @@ -66,7 +66,7 @@ void PerformAppServiceInteractionRequest::Run() { std::string service_id = msg_params[strings::service_id].asString(); auto service = application_manager_.GetAppServiceManager().FindServiceByID(service_id); - if (service.first.empty()) { + if (!service) { SendResponse(false, mobile_apis::Result::INVALID_ID, "The requested service ID does not exist"); @@ -81,9 +81,8 @@ void PerformAppServiceInteractionRequest::Run() { } // Only activate service if it is not already active - bool activate_service = - request_service_active && - !service.second.record[strings::service_active].asBool(); + bool activate_service = request_service_active && + !service->record[strings::service_active].asBool(); if (activate_service) { if (app->is_foreground()) { // App is in foreground, we can just activate the service diff --git a/src/components/application_manager/src/app_service_manager.cc b/src/components/application_manager/src/app_service_manager.cc index ed9120ad19..73219df456 100644 --- a/src/components/application_manager/src/app_service_manager.cc +++ b/src/components/application_manager/src/app_service_manager.cc @@ -70,11 +70,13 @@ smart_objects::SmartObject AppServiceManager::PublishAppService( std::string str_to_hash = ""; std::string service_id = ""; + published_services_lock_.Acquire(); do { str_to_hash = manifest[strings::service_type].asString() + std::to_string(std::rand()); service_id = encryption::MakeHash(str_to_hash); } while (published_services_.find(service_id) != published_services_.end()); + published_services_lock_.Release(); AppService app_service; app_service.connection_key = connection_key; @@ -104,9 +106,11 @@ smart_objects::SmartObject AppServiceManager::PublishAppService( } app_service.default_service = GetPolicyAppID(app_service) == default_app_id; - published_services_.insert( - std::pair(service_id, app_service)); - + { + sync_primitives::AutoLock lock(published_services_lock_); + published_services_.insert( + std::pair(service_id, app_service)); + } smart_objects::SmartObject msg_params; msg_params[strings::system_capability][strings::system_capability_type] = mobile_apis::SystemCapabilityType::APP_SERVICES; @@ -117,9 +121,8 @@ smart_objects::SmartObject AppServiceManager::PublishAppService( // Activate the new service if it is the default for its service type, or if // no service is active of its service type - std::pair active_service = - ActiveServiceByType(service_type); - if (active_service.first.empty() || app_service.default_service) { + AppService* active_service = ActiveServiceByType(service_type); + if (!active_service || app_service.default_service) { ActivateAppService(service_id); } @@ -128,7 +131,7 @@ smart_objects::SmartObject AppServiceManager::PublishAppService( bool AppServiceManager::UnpublishAppService(const std::string service_id) { LOG4CXX_AUTO_TRACE(logger_); - + sync_primitives::AutoLock lock(published_services_lock_); auto it = published_services_.find(service_id); if (it == published_services_.end()) { LOG4CXX_ERROR(logger_, "Service id does not exist in published services"); @@ -141,22 +144,22 @@ bool AppServiceManager::UnpublishAppService(const std::string service_id) { msg_params[strings::system_capability][strings::system_capability_type] = mobile_apis::SystemCapabilityType::APP_SERVICES; - auto record = it->second.record; + auto& record = it->second.record; if (record[strings::service_active].asBool()) { record[strings::service_active] = false; // Activate embedded service, if available auto embedded_service = EmbeddedServiceForType( record[strings::service_manifest][strings::service_type].asString()); - if (!embedded_service.first.empty()) { - embedded_service.second.record[strings::service_active] = true; - AppServiceUpdated(embedded_service.second.record, + if (embedded_service) { + embedded_service->record[strings::service_active] = true; + AppServiceUpdated(embedded_service->record, mobile_apis::ServiceUpdateReason::ACTIVATED, msg_params); } } AppServiceUpdated( - it->second.record, mobile_apis::ServiceUpdateReason::REMOVED, msg_params); + record, mobile_apis::ServiceUpdateReason::REMOVED, msg_params); MessageHelper::BroadcastCapabilityUpdate(msg_params, app_manager_); published_services_.erase(it); @@ -166,6 +169,7 @@ bool AppServiceManager::UnpublishAppService(const std::string service_id) { void AppServiceManager::UnpublishServices(const uint32_t connection_key) { LOG4CXX_AUTO_TRACE(logger_); LOG4CXX_DEBUG(logger_, "Unpublishing all app services: " << connection_key); + sync_primitives::AutoLock lock(published_services_lock_); for (auto it = published_services_.begin(); it != published_services_.end(); ++it) { if (it->second.connection_key == connection_key) { @@ -176,6 +180,7 @@ void AppServiceManager::UnpublishServices(const uint32_t connection_key) { void AppServiceManager::OnAppActivated(ApplicationConstSharedPtr app) { LOG4CXX_AUTO_TRACE(logger_); + sync_primitives::AutoLock lock(published_services_lock_); auto it = published_services_.begin(); // Activate all services published by the app for (; it != published_services_.end(); ++it) { @@ -188,6 +193,7 @@ void AppServiceManager::OnAppActivated(ApplicationConstSharedPtr app) { std::vector AppServiceManager::GetAllServices() { LOG4CXX_AUTO_TRACE(logger_); std::vector services; + sync_primitives::AutoLock lock(published_services_lock_); for (auto it = published_services_.begin(); it != published_services_.end(); ++it) { services.push_back(it->second.record); @@ -200,7 +206,7 @@ void AppServiceManager::GetProviderByType(const std::string& service_type, bool& hmi_service) { LOG4CXX_AUTO_TRACE(logger_); auto active_service = ActiveServiceByType(service_type); - if (active_service.first.empty()) { + if (!active_service) { LOG4CXX_ERROR(logger_, "There is no active service for the given service type: " << service_type); @@ -208,13 +214,14 @@ void AppServiceManager::GetProviderByType(const std::string& service_type, } LOG4CXX_DEBUG(logger_, "Found provider for service type: " << service_type); - GetProviderFromService(active_service.second, app, hmi_service); + GetProviderFromService(*active_service, app, hmi_service); } void AppServiceManager::GetProviderByID(const std::string& service_id, ApplicationSharedPtr& app, bool& hmi_service) { LOG4CXX_AUTO_TRACE(logger_); + sync_primitives::AutoLock lock(published_services_lock_); auto it = published_services_.find(service_id); if (it == published_services_.end()) { LOG4CXX_ERROR(logger_, "Service id does not exist in published services"); @@ -240,6 +247,7 @@ void AppServiceManager::GetProviderFromService(const AppService& service, bool AppServiceManager::SetDefaultService(const std::string service_id) { LOG4CXX_AUTO_TRACE(logger_); + sync_primitives::AutoLock lock(published_services_lock_); auto it = published_services_.find(service_id); if (it == published_services_.end()) { LOG4CXX_ERROR(logger_, "Unable to find published service " << service_id); @@ -254,8 +262,8 @@ bool AppServiceManager::SetDefaultService(const std::string service_id) { if (!default_app_id.empty()) { auto default_service = FindServiceByPolicyAppID(default_app_id, service_type); - if (!default_service.first.empty()) { - default_service.second.default_service = false; + if (default_service) { + default_service->default_service = false; } } service.default_service = true; @@ -268,6 +276,7 @@ bool AppServiceManager::SetDefaultService(const std::string service_id) { bool AppServiceManager::RemoveDefaultService(const std::string service_id) { LOG4CXX_AUTO_TRACE(logger_); + sync_primitives::AutoLock lock(published_services_lock_); auto it = published_services_.find(service_id); if (it == published_services_.end()) { LOG4CXX_ERROR(logger_, "Unable to find published service " << service_id); @@ -291,6 +300,7 @@ bool AppServiceManager::RemoveDefaultService(const std::string service_id) { bool AppServiceManager::ActivateAppService(const std::string service_id) { LOG4CXX_AUTO_TRACE(logger_); + sync_primitives::AutoLock lock(published_services_lock_); auto it = published_services_.find(service_id); if (it == published_services_.end()) { LOG4CXX_ERROR(logger_, "Unable to find published service " << service_id); @@ -310,9 +320,9 @@ bool AppServiceManager::ActivateAppService(const std::string service_id) { const std::string service_type = service[strings::service_manifest][strings::service_type].asString(); auto active_service = ActiveServiceByType(service_type); - if (!active_service.first.empty()) { - active_service.second.record[strings::service_active] = false; - AppServiceUpdated(active_service.second.record, + if (active_service) { + active_service->record[strings::service_active] = false; + AppServiceUpdated(active_service->record, mobile_apis::ServiceUpdateReason::DEACTIVATED, msg_params); } @@ -337,6 +347,7 @@ bool AppServiceManager::ActivateAppService(const std::string service_id) { bool AppServiceManager::DeactivateAppService(const std::string service_id) { LOG4CXX_AUTO_TRACE(logger_); + sync_primitives::AutoLock lock(published_services_lock_); auto it = published_services_.find(service_id); if (it == published_services_.end()) { LOG4CXX_ERROR(logger_, "Unable to find published service " << service_id); @@ -355,9 +366,9 @@ bool AppServiceManager::DeactivateAppService(const std::string service_id) { const std::string service_type = service[strings::service_manifest][strings::service_type].asString(); auto embedded_service = EmbeddedServiceForType(service_type); - if (!embedded_service.first.empty()) { - embedded_service.second.record[strings::service_active] = true; - AppServiceUpdated(embedded_service.second.record, + if (embedded_service) { + embedded_service->record[strings::service_active] = true; + AppServiceUpdated(embedded_service->record, mobile_apis::ServiceUpdateReason::ACTIVATED, msg_params); } @@ -372,54 +383,53 @@ bool AppServiceManager::DeactivateAppService(const std::string service_id) { return true; } -std::pair AppServiceManager::ActiveServiceByType( - std::string service_type) { +AppService* AppServiceManager::ActiveServiceByType(std::string service_type) { LOG4CXX_AUTO_TRACE(logger_); + sync_primitives::AutoLock lock(published_services_lock_); for (auto it = published_services_.begin(); it != published_services_.end(); ++it) { if (it->second.record[strings::service_manifest][strings::service_type] .asString() == service_type && it->second.record[strings::service_published].asBool() && it->second.record[strings::service_active].asBool()) { - return *it; + return &(it->second); } } - AppService empty; - return std::make_pair(std::string(), empty); + return NULL; } -std::pair AppServiceManager::EmbeddedServiceForType( +AppService* AppServiceManager::EmbeddedServiceForType( std::string service_type) { LOG4CXX_AUTO_TRACE(logger_); + sync_primitives::AutoLock lock(published_services_lock_); for (auto it = published_services_.begin(); it != published_services_.end(); ++it) { if (it->second.record[strings::service_manifest][strings::service_type] .asString() == service_type && !it->second.mobile_service) { - return *it; + return &(it->second); } } - AppService empty; - return std::make_pair(std::string(), empty); + return NULL; } -std::pair AppServiceManager::FindServiceByName( - std::string name) { +AppService* AppServiceManager::FindServiceByName(std::string name) { LOG4CXX_AUTO_TRACE(logger_); + sync_primitives::AutoLock lock(published_services_lock_); for (auto it = published_services_.begin(); it != published_services_.end(); ++it) { if (it->second.record[strings::service_manifest][strings::service_name] .asString() == name) { - return *it; + return &(it->second); } } - AppService empty; - return std::make_pair(std::string(), empty); + return NULL; } -std::pair AppServiceManager::FindServiceByPolicyAppID( +AppService* AppServiceManager::FindServiceByPolicyAppID( std::string policy_app_id, std::string type) { LOG4CXX_AUTO_TRACE(logger_); + sync_primitives::AutoLock lock(published_services_lock_); for (auto it = published_services_.begin(); it != published_services_.end(); ++it) { if (it->second.record[strings::service_manifest][strings::service_type] @@ -428,25 +438,22 @@ std::pair AppServiceManager::FindServiceByPolicyAppID( } if (policy_app_id == GetPolicyAppID(it->second)) { - return *it; + return &(it->second); } } - AppService empty; - return std::make_pair(std::string(), empty); + return NULL; } -std::pair AppServiceManager::FindServiceByID( - std::string service_id) { +AppService* AppServiceManager::FindServiceByID(std::string service_id) { LOG4CXX_AUTO_TRACE(logger_); + sync_primitives::AutoLock lock(published_services_lock_); auto it = published_services_.find(service_id); if (it == published_services_.end()) { LOG4CXX_ERROR(logger_, "Service id does not exist in published services"); - AppService empty; - return std::make_pair(std::string(), empty); + return NULL; } - - return *it; + return &(it->second); } std::string AppServiceManager::DefaultServiceByType(std::string service_type) { @@ -461,6 +468,7 @@ std::string AppServiceManager::DefaultServiceByType(std::string service_type) { void AppServiceManager::SetServicePublished(const std::string service_id, bool service_published) { LOG4CXX_AUTO_TRACE(logger_); + sync_primitives::AutoLock lock(published_services_lock_); auto it = published_services_.find(service_id); if (it == published_services_.end()) { LOG4CXX_ERROR(logger_, "Service id does not exist in published services"); @@ -485,7 +493,7 @@ bool AppServiceManager::UpdateNavigationCapabilities( EnumConversionHelper::EnumToString( mobile_apis::AppServiceType::NAVIGATION, &navi_service_type); auto service = ActiveServiceByType(navi_service_type); - if (service.first.empty()) { + if (!service) { return false; } @@ -496,13 +504,13 @@ bool AppServiceManager::UpdateNavigationCapabilities( out_params[strings::get_way_points_enabled] = false; } - if (!service.second.record[strings::service_manifest].keyExists( + if (!service->record[strings::service_manifest].keyExists( strings::handled_rpcs)) { return true; } smart_objects::SmartObject& handled_rpcs = - service.second.record[strings::service_manifest][strings::handled_rpcs]; + service->record[strings::service_manifest][strings::handled_rpcs]; for (size_t i = 0; i < handled_rpcs.length(); ++i) { if (handled_rpcs[i].asInt() == mobile_apis::FunctionID::SendLocationID) { out_params[strings::send_location_enabled] = true; -- cgit v1.2.1 From bc6cec5d29ff36b7092112dc1ea69ccd4d92acc3 Mon Sep 17 00:00:00 2001 From: JackLivio Date: Thu, 28 Feb 2019 09:55:21 -0500 Subject: Close Cloud Connection (#2825) * Close Cloud Connection * Address Comments * Update based on merge --- .../application_manager/application_manager_impl.h | 2 ++ .../hmi/on_exit_application_notification.cc | 4 +++ .../src/application_manager_impl.cc | 34 ++++++++++++++++++++++ .../application_manager/application_manager.h | 2 ++ .../application_manager/mock_application_manager.h | 2 ++ src/components/interfaces/HMI_API.xml | 3 ++ .../transport_adapter/transport_adapter_impl.cc | 6 ++-- 7 files changed, 51 insertions(+), 2 deletions(-) diff --git a/src/components/application_manager/include/application_manager/application_manager_impl.h b/src/components/application_manager/include/application_manager/application_manager_impl.h index 5989605281..1f3f0c327c 100644 --- a/src/components/application_manager/include/application_manager/application_manager_impl.h +++ b/src/components/application_manager/include/application_manager/application_manager_impl.h @@ -360,6 +360,8 @@ class ApplicationManagerImpl void ConnectToDevice(const std::string& device_mac) OVERRIDE; void OnHMIStartedCooperation() OVERRIDE; + void DisconnectCloudApp(ApplicationSharedPtr app) OVERRIDE; + void RefreshCloudAppInformation() OVERRIDE; void CreatePendingApplication( diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_exit_application_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_exit_application_notification.cc index 681390fbf4..b6d44a4511 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_exit_application_notification.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_exit_application_notification.cc @@ -106,6 +106,10 @@ void OnExitApplicationNotification::Run() { application_manager_.UnregisterApplication(app_id, Result::SUCCESS); return; } + case Common_ApplicationExitReason::CLOSE_CLOUD_CONNECTION: { + application_manager_.DisconnectCloudApp(app_impl); + break; + } default: { LOG4CXX_WARN(logger_, "Unhandled reason"); return; diff --git a/src/components/application_manager/src/application_manager_impl.cc b/src/components/application_manager/src/application_manager_impl.cc index b4381f4ba9..9903342ae1 100644 --- a/src/components/application_manager/src/application_manager_impl.cc +++ b/src/components/application_manager/src/application_manager_impl.cc @@ -808,6 +808,40 @@ void ApplicationManagerImpl::OnHMIStartedCooperation() { RefreshCloudAppInformation(); } +void ApplicationManagerImpl::DisconnectCloudApp(ApplicationSharedPtr app) { + std::string endpoint; + std::string certificate; + std::string auth_token; + std::string cloud_transport_type; + std::string hybrid_app_preference; + bool enabled = true; + std::string policy_app_id = app->policy_app_id(); + GetPolicyHandler().GetCloudAppParameters(policy_app_id, + enabled, + endpoint, + certificate, + auth_token, + cloud_transport_type, + hybrid_app_preference); + if (app->IsRegistered() && app->is_cloud_app()) { + LOG4CXX_DEBUG(logger_, "Disabled app is registered, unregistering now"); + GetRPCService().ManageMobileCommand( + MessageHelper::GetOnAppInterfaceUnregisteredNotificationToMobile( + app->app_id(), + mobile_api::AppInterfaceUnregisteredReason::APP_UNAUTHORIZED), + commands::Command::SOURCE_SDL); + + OnAppUnauthorized(app->app_id()); + } + // Delete the cloud device + connection_handler().RemoveCloudAppDevice(app->device()); + + // Create device in pending state + LOG4CXX_DEBUG(logger_, "Re-adding the cloud app device"); + connection_handler().AddCloudAppDevice( + policy_app_id, endpoint, cloud_transport_type); +} + void ApplicationManagerImpl::RefreshCloudAppInformation() { LOG4CXX_AUTO_TRACE(logger_); std::vector enabled_apps; diff --git a/src/components/include/application_manager/application_manager.h b/src/components/include/application_manager/application_manager.h index 47b6bcbc9d..f9b302be06 100644 --- a/src/components/include/application_manager/application_manager.h +++ b/src/components/include/application_manager/application_manager.h @@ -427,6 +427,8 @@ class ApplicationManager { virtual void OnHMIStartedCooperation() = 0; + virtual void DisconnectCloudApp(ApplicationSharedPtr app) = 0; + virtual void RefreshCloudAppInformation() = 0; /** diff --git a/src/components/include/test/application_manager/mock_application_manager.h b/src/components/include/test/application_manager/mock_application_manager.h index 30a24ad9ce..ca03864dfa 100644 --- a/src/components/include/test/application_manager/mock_application_manager.h +++ b/src/components/include/test/application_manager/mock_application_manager.h @@ -166,6 +166,8 @@ class MockApplicationManager : public application_manager::ApplicationManager { MOCK_METHOD1(EndAudioPassThru, bool(uint32_t app_id)); MOCK_METHOD1(ConnectToDevice, void(const std::string& device_mac)); MOCK_METHOD0(OnHMIStartedCooperation, void()); + MOCK_METHOD1(DisconnectCloudApp, + void(application_manager::ApplicationSharedPtr app)); MOCK_METHOD0(RefreshCloudAppInformation, void()); MOCK_CONST_METHOD1(GetCloudAppConnectionStatus, hmi_apis::Common_CloudConnectionStatus::eType( diff --git a/src/components/interfaces/HMI_API.xml b/src/components/interfaces/HMI_API.xml index 7adb5fb51e..24b1858d3b 100644 --- a/src/components/interfaces/HMI_API.xml +++ b/src/components/interfaces/HMI_API.xml @@ -487,6 +487,9 @@ By getting this value, SDL unregisters the named application + + By getting this value, SDL puts the named app to NONE HMILevel. Used by the HMI to close a cloud app connection. + diff --git a/src/components/transport_manager/src/transport_adapter/transport_adapter_impl.cc b/src/components/transport_manager/src/transport_adapter/transport_adapter_impl.cc index 335770bea7..865e8d6aa8 100644 --- a/src/components/transport_manager/src/transport_adapter/transport_adapter_impl.cc +++ b/src/components/transport_manager/src/transport_adapter/transport_adapter_impl.cc @@ -872,6 +872,7 @@ void TransportAdapterImpl::ConnectPending(const DeviceUID& device_id, if (device.use_count() == 0) { LOG4CXX_ERROR( logger_, "Unable to find device, cannot set connection pending status"); + return; } else { device->set_connection_status(ConnectionStatus::PENDING); } @@ -1176,12 +1177,13 @@ void TransportAdapterImpl::RunAppOnDevice(const DeviceUID& device_uid, void TransportAdapterImpl::RemoveDevice(const DeviceUID& device_handle) { LOG4CXX_AUTO_TRACE(logger_); - LOG4CXX_DEBUG(logger_, "Device_handle: " << &device_handle); + LOG4CXX_DEBUG(logger_, "Remove Device_handle: " << &device_handle); sync_primitives::AutoLock locker(devices_mutex_); DeviceMap::iterator i = devices_.find(device_handle); if (i != devices_.end()) { DeviceSptr device = i->second; - if (!device->keep_on_disconnect()) { + bool is_cloud_device = (GetDeviceType() == DeviceType::CLOUD_WEBSOCKET); + if (!device->keep_on_disconnect() || is_cloud_device) { devices_.erase(i); for (TransportAdapterListenerList::iterator it = listeners_.begin(); it != listeners_.end(); -- cgit v1.2.1 From fc9f7d13c0e03caee9e196a636815e791213ad66 Mon Sep 17 00:00:00 2001 From: JackLivio Date: Fri, 1 Mar 2019 15:00:38 -0500 Subject: Get Icon URL Request (#2823) * Fix regex command for reading paths post port number * Add Icon URL to policies * Create Icon Request and save to icon folder. * Fixes for get icon url * Fix unit tests * Send Icon_url request after PTU * Address comments * Address Comments --- .../application_manager/application_manager_impl.h | 24 ++- .../helpers/application_helper.h | 12 ++ .../application_manager/policies/policy_handler.h | 2 + .../mobile/register_app_interface_request.cc | 3 + .../src/commands/mobile/system_request.cc | 26 +++- .../src/application_manager_impl.cc | 162 ++++++++++++++++++++- .../src/message_helper/message_helper.cc | 1 + .../src/policies/policy_handler.cc | 8 +- .../application_manager/application_manager.h | 12 ++ .../policies/policy_handler_interface.h | 1 + .../policy/policy_external/policy/policy_manager.h | 11 +- .../policy/policy_regular/policy/policy_manager.h | 11 +- .../application_manager/mock_application_manager.h | 11 ++ .../policies/mock_policy_handler_interface.h | 1 + .../policy_external/policy/mock_cache_manager.h | 1 + .../policy_external/policy/mock_policy_manager.h | 1 + .../policy_regular/policy/mock_cache_manager.h | 1 + .../policy_regular/policy/mock_policy_manager.h | 1 + src/components/interfaces/HMI_API.xml | 1 + src/components/interfaces/MOBILE_API.xml | 1 + .../policy_external/include/policy/cache_manager.h | 9 ++ .../include/policy/cache_manager_interface.h | 9 ++ .../include/policy/policy_manager_impl.h | 9 ++ .../include/policy/policy_table/enums.h | 1 + .../include/policy/policy_table/types.h | 1 + .../include/policy/policy_table_interface_ext.xml | 2 + .../policy/policy_external/src/cache_manager.cc | 15 ++ .../policy_external/src/policy_manager_impl.cc | 5 + .../policy_external/src/policy_table/enums.cc | 8 + .../policy_external/src/policy_table/types.cc | 15 +- .../policy_external/src/sql_pt_ext_queries.cc | 6 +- .../src/sql_pt_ext_representation.cc | 4 + .../policy/policy_external/src/sql_pt_queries.cc | 14 +- .../policy_external/src/sql_pt_representation.cc | 6 + .../policy_regular/include/policy/cache_manager.h | 9 ++ .../include/policy/cache_manager_interface.h | 9 ++ .../include/policy/policy_manager_impl.h | 9 ++ .../include/policy/policy_table/types.h | 1 + .../policy/policy_regular/src/cache_manager.cc | 15 ++ .../policy_regular/src/policy_manager_impl.cc | 5 + .../policy_regular/src/policy_table/types.cc | 15 +- .../policy/policy_regular/src/sql_pt_queries.cc | 14 +- .../policy_regular/src/sql_pt_representation.cc | 6 + .../src/cloud/cloud_websocket_transport_adapter.cc | 3 +- 44 files changed, 449 insertions(+), 32 deletions(-) diff --git a/src/components/application_manager/include/application_manager/application_manager_impl.h b/src/components/application_manager/include/application_manager/application_manager_impl.h index 1f3f0c327c..ae00108591 100644 --- a/src/components/application_manager/include/application_manager/application_manager_impl.h +++ b/src/components/application_manager/include/application_manager/application_manager_impl.h @@ -117,6 +117,14 @@ struct CommandParametersPermissions; typedef std::map DeviceTypes; +struct AppIconInfo { + std::string endpoint; + bool pending_request; + AppIconInfo(); + AppIconInfo(std::string ws_endpoint, bool pending) + : endpoint(ws_endpoint), pending_request(pending) {} +}; + CREATE_LOGGERPTR_GLOBAL(logger_, "ApplicationManager") typedef std::shared_ptr TimerSPtr; @@ -156,6 +164,7 @@ class ApplicationManagerImpl bool Stop() OVERRIDE; DataAccessor applications() const OVERRIDE; + DataAccessor pending_applications() const OVERRIDE; ApplicationSharedPtr application(uint32_t app_id) const OVERRIDE; ApplicationSharedPtr active_application() const OVERRIDE; @@ -164,6 +173,8 @@ class ApplicationManagerImpl uint32_t hmi_app_id) const OVERRIDE; ApplicationSharedPtr application_by_policy_id( const std::string& policy_app_id) const OVERRIDE; + ApplicationSharedPtr pending_application_by_policy_id( + const std::string& policy_app_id) const OVERRIDE; std::vector applications_by_button( uint32_t button) OVERRIDE; @@ -194,6 +205,9 @@ class ApplicationManagerImpl void SendDriverDistractionState(ApplicationSharedPtr application); + void SendGetIconUrlNotifications(const uint32_t connection_key, + ApplicationSharedPtr application); + ApplicationSharedPtr application( const std::string& device_id, const std::string& policy_app_id) const OVERRIDE; @@ -373,6 +387,10 @@ class ApplicationManagerImpl const transport_manager::ConnectionUID connection_id, const transport_manager::DeviceInfo& device_info); + std::string PolicyIDByIconUrl(const std::string url) OVERRIDE; + + void SetIconFileFromSystemRequest(const std::string policy_id) OVERRIDE; + /** * @brief Notifies the applicaiton manager that a cloud connection status has * updated and should trigger an UpdateAppList RPC to the HMI @@ -504,9 +522,6 @@ class ApplicationManagerImpl // typedef for Applications list typedef std::set ApplictionSet; - typedef std::set - AppsWaitRegistrationSet; - // typedef for Applications list iterator typedef ApplictionSet::iterator ApplictionSetIt; @@ -1478,6 +1493,9 @@ class ApplicationManagerImpl pending_device_map_lock_ptr_; std::map pending_device_map_; + sync_primitives::Lock app_icon_map_lock_ptr_; + std::map app_icon_map_; + #ifdef TELEMETRY_MONITOR AMTelemetryObserver* metric_observer_; #endif // TELEMETRY_MONITOR diff --git a/src/components/application_manager/include/application_manager/helpers/application_helper.h b/src/components/application_manager/include/application_manager/helpers/application_helper.h index 145bef659e..18267c9e7f 100644 --- a/src/components/application_manager/include/application_manager/helpers/application_helper.h +++ b/src/components/application_manager/include/application_manager/helpers/application_helper.h @@ -57,6 +57,18 @@ ApplicationSharedPtr FindApp(DataAccessor accessor, return app; } +template +ApplicationSharedPtr FindPendingApp( + DataAccessor accessor, UnaryPredicate finder) { + AppsWaitRegistrationSet::iterator it = std::find_if( + accessor.GetData().begin(), accessor.GetData().end(), finder); + if (accessor.GetData().end() == it) { + return ApplicationSharedPtr(); + } + ApplicationSharedPtr app = *it; + return app; +} + /** * Helper function for lookup through applications list and returning all * applications satisfying predicate logic diff --git a/src/components/application_manager/include/application_manager/policies/policy_handler.h b/src/components/application_manager/include/application_manager/policies/policy_handler.h index 1cc5fc0156..b912c489e4 100644 --- a/src/components/application_manager/include/application_manager/policies/policy_handler.h +++ b/src/components/application_manager/include/application_manager/policies/policy_handler.h @@ -187,6 +187,8 @@ class PolicyHandler : public PolicyHandlerInterface, void GetUpdateUrls(const uint32_t service_type, EndpointUrls& out_end_points) OVERRIDE; virtual std::string GetLockScreenIconUrl() const OVERRIDE; + virtual std::string GetIconUrl( + const std::string& policy_app_id) const OVERRIDE; uint32_t NextRetryTimeout() OVERRIDE; /** 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 b346ee5798..6317d9b068 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 @@ -447,6 +447,9 @@ void RegisterAppInterfaceRequest::Run() { GetLockScreenIconUrlNotification(connection_key(), application); rpc_service_.ManageMobileCommand(so, SOURCE_SDL); application_manager_.SendDriverDistractionState(application); + // Create onSystemRequest to mobile to obtain cloud app icons + application_manager_.SendGetIconUrlNotifications(connection_key(), + application); } smart_objects::SmartObjectSPtr diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/system_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/system_request.cc index cea00a9d5e..da39aefd6a 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/system_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/system_request.cc @@ -511,7 +511,8 @@ void SystemRequest::Run() { return; } - if (!file_system::IsFileNameValid(file_name)) { + if (!file_system::IsFileNameValid(file_name) && + mobile_apis::RequestType::ICON_URL != request_type) { const std::string err_msg = "Sync file name contains forbidden symbols."; LOG4CXX_ERROR(logger_, err_msg); SendResponse(false, mobile_apis::Result::INVALID_DATA, err_msg.c_str()); @@ -533,8 +534,21 @@ void SystemRequest::Run() { std::string binary_data_folder; if ((*message_)[strings::params].keyExists(strings::binary_data)) { binary_data = (*message_)[strings::params][strings::binary_data].asBinary(); - binary_data_folder = - application_manager_.get_settings().system_files_path(); + if (mobile_apis::RequestType::ICON_URL == request_type) { + binary_data_folder = + application_manager_.get_settings().app_icons_folder(); + // Use the URL file name to identify the policy id. + // Save the icon file with the policy id as the name. + file_name = application_manager_.PolicyIDByIconUrl(file_name); + if (file_name.empty()) { + const std::string err_msg = "Invalid file name"; + SendResponse(false, mobile_apis::Result::INVALID_DATA, err_msg.c_str()); + } + LOG4CXX_DEBUG(logger_, "Got ICON_URL Request. File name: " << file_name); + } else { + binary_data_folder = + application_manager_.get_settings().system_files_path(); + } } else { binary_data_folder = application_manager_.get_settings().app_storage_folder(); @@ -581,6 +595,12 @@ void SystemRequest::Run() { LOG4CXX_DEBUG(logger_, "Binary data ok."); + if (mobile_apis::RequestType::ICON_URL == request_type) { + application_manager_.SetIconFileFromSystemRequest(file_name); + SendResponse(true, mobile_apis::Result::SUCCESS); + return; + } + if (mobile_apis::RequestType::HTTP == request_type && (*message_)[strings::msg_params].keyExists(strings::file_name)) { const std::string& file = diff --git a/src/components/application_manager/src/application_manager_impl.cc b/src/components/application_manager/src/application_manager_impl.cc index 9903342ae1..a9ae2e5ca7 100644 --- a/src/components/application_manager/src/application_manager_impl.cc +++ b/src/components/application_manager/src/application_manager_impl.cc @@ -73,6 +73,7 @@ #include "policy/usage_statistics/counter.h" #include "utils/custom_string.h" #include +#include namespace { int get_rand_from_range(uint32_t from = 0, int to = RAND_MAX) { @@ -240,6 +241,13 @@ DataAccessor ApplicationManagerImpl::applications() const { return accessor; } +DataAccessor +ApplicationManagerImpl::pending_applications() const { + DataAccessor accessor( + apps_to_register_, apps_to_register_list_lock_ptr_); + return accessor; +} + ApplicationSharedPtr ApplicationManagerImpl::application( uint32_t app_id) const { AppIdPredicate finder(app_id); @@ -261,6 +269,13 @@ ApplicationSharedPtr ApplicationManagerImpl::application_by_policy_id( return FindApp(accessor, finder); } +ApplicationSharedPtr ApplicationManagerImpl::pending_application_by_policy_id( + const std::string& policy_app_id) const { + PolicyAppIdPredicate finder(policy_app_id); + DataAccessor accessor = pending_applications(); + return FindPendingApp(accessor, finder); +} + bool ActiveAppPredicate(const ApplicationSharedPtr app) { return app ? app->IsFullscreen() : false; } @@ -808,6 +823,60 @@ void ApplicationManagerImpl::OnHMIStartedCooperation() { RefreshCloudAppInformation(); } +std::string ApplicationManagerImpl::PolicyIDByIconUrl(const std::string url) { + sync_primitives::AutoLock lock(app_icon_map_lock_ptr_); + for (auto& x : app_icon_map_) { + auto policy_id = x.first; + std::string icon_url = GetPolicyHandler().GetIconUrl(policy_id); + if (icon_url == url) { + LOG4CXX_DEBUG(logger_, "Matched icon url: " << url); + x.second.pending_request = false; + return policy_id; + } + } + return std::string(""); +} + +void ApplicationManagerImpl::SetIconFileFromSystemRequest( + const std::string policy_id) { + app_icon_map_lock_ptr_.Acquire(); + auto app_icon_it = app_icon_map_.find(policy_id); + if (app_icon_it != app_icon_map_.end()) { + app_icon_map_.erase(app_icon_it); + } + app_icon_map_lock_ptr_.Release(); + + // Find pending application and set icon path + auto app = pending_application_by_policy_id(policy_id); + if (!app) { + return; + } + const std::string app_icon_dir(settings_.app_icons_folder()); + const std::string full_icon_path(app_icon_dir + "/" + policy_id); + if (file_system::FileExists(full_icon_path)) { + LOG4CXX_DEBUG(logger_, "Set Icon Path: " << full_icon_path); + AppFile file; + file.is_persistent = true; + file.is_download_complete = true; + file.file_name = full_icon_path; + + std::string icon_url = GetPolicyHandler().GetIconUrl(policy_id); + std::string extension = boost::filesystem::extension(icon_url); + if (extension == "bmp" || extension == "BMP") { + file.file_type = mobile_apis::FileType::GRAPHIC_BMP; + } else if (extension == "JPEG" || extension == "jpeg" || + extension == "JPG" || extension == "jpg") { + file.file_type = mobile_apis::FileType::GRAPHIC_JPEG; + } else { + file.file_type = mobile_apis::FileType::GRAPHIC_PNG; + } + + app->AddFile(file); + app->set_app_icon_path(full_icon_path); + } + SendUpdateAppList(); +} + void ApplicationManagerImpl::DisconnectCloudApp(ApplicationSharedPtr app) { std::string endpoint; std::string certificate; @@ -857,6 +926,7 @@ void ApplicationManagerImpl::RefreshCloudAppInformation() { // Store old device map and clear the current map pending_device_map_lock_ptr_->Acquire(); + app_icon_map_lock_ptr_.Acquire(); std::map old_device_map = pending_device_map_; pending_device_map_ = std::map(); // Create a device for each newly enabled cloud app @@ -868,9 +938,9 @@ void ApplicationManagerImpl::RefreshCloudAppInformation() { auth_token, cloud_transport_type, hybrid_app_preference); - + auto policy_id = *enabled_it; pending_device_map_.insert( - std::pair(endpoint, *enabled_it)); + std::pair(endpoint, policy_id)); // Determine which endpoints were disabled by erasing all enabled apps from // the old device list auto old_device_it = old_device_map.find(endpoint); @@ -880,8 +950,34 @@ void ApplicationManagerImpl::RefreshCloudAppInformation() { // If the device was disconnected, this will reinitialize the device connection_handler().AddCloudAppDevice( - *enabled_it, endpoint, cloud_transport_type); + policy_id, endpoint, cloud_transport_type); + + // Look for app icon url data and add to app_icon_url_map + std::string url = GetPolicyHandler().GetIconUrl(policy_id); + + if (url.empty()) { + LOG4CXX_DEBUG(logger_, "No Icon Url for cloud app"); + continue; + } + + auto app_icon_it = app_icon_map_.find(policy_id); + if (app_icon_it != app_icon_map_.end()) { + LOG4CXX_DEBUG(logger_, "Cloud App Already Exists in Icon Map"); + continue; + } + + const std::string app_icon_dir(settings_.app_icons_folder()); + const std::string full_icon_path(app_icon_dir + "/" + policy_id); + if (!file_system::FileExists(full_icon_path)) { + int icon_map_size = app_icon_map_.size(); + AppIconInfo icon_info(endpoint, false); + LOG4CXX_DEBUG(logger_, + "Inserting cloud app into icon map: " << icon_map_size); + app_icon_map_.insert( + std::pair(policy_id, icon_info)); + } } + app_icon_map_lock_ptr_.Release(); pending_device_map_lock_ptr_->Release(); int removed_app_count = 0; @@ -3660,7 +3756,15 @@ void ApplicationManagerImpl::OnPTUFinished(const bool ptu_result) { if (!ptu_result) { return; } + RefreshCloudAppInformation(); + + auto app_id = policy_handler_->GetAppIdForSending(); + auto app = application(app_id); + if (app) { + SendGetIconUrlNotifications(app->app_id(), app); + } + auto on_app_policy_updated = [](plugin_manager::RPCPlugin& plugin) { plugin.OnPolicyEvent(plugin_manager::kApplicationPolicyUpdated); }; @@ -3703,6 +3807,58 @@ void ApplicationManagerImpl::SendDriverDistractionState( } } +void ApplicationManagerImpl::SendGetIconUrlNotifications( + const uint32_t connection_key, ApplicationSharedPtr application) { + LOG4CXX_AUTO_TRACE(logger_); + std::vector enabled_apps; + GetPolicyHandler().GetEnabledCloudApps(enabled_apps); + std::vector::iterator enabled_it = enabled_apps.begin(); + std::vector::iterator enabled_end = enabled_apps.end(); + sync_primitives::AutoLock lock(app_icon_map_lock_ptr_); + for (; enabled_it != enabled_end; ++enabled_it) { + auto app_icon_it = app_icon_map_.find(*enabled_it); + if (app_icon_it == app_icon_map_.end()) { + LOG4CXX_WARN(logger_, "Could not find cloud app in icon map"); + continue; + } + + std::string endpoint = app_icon_it->second.endpoint; + bool pending_request = app_icon_it->second.pending_request; + + if (pending_request) { + LOG4CXX_DEBUG(logger_, "Cloud app has already sent request"); + continue; + } + + std::string url = GetPolicyHandler().GetIconUrl(*enabled_it); + + if (url.empty()) { + LOG4CXX_DEBUG(logger_, "No Icon Url for cloud app"); + continue; + } + + LOG4CXX_DEBUG(logger_, "Creating Get Icon Request"); + + smart_objects::SmartObjectSPtr message = + std::make_shared( + smart_objects::SmartType_Map); + (*message)[strings::params][strings::function_id] = + mobile_apis::FunctionID::OnSystemRequestID; + (*message)[strings::params][strings::connection_key] = connection_key; + (*message)[strings::params][strings::message_type] = + mobile_apis::messageType::notification; + (*message)[strings::params][strings::protocol_version] = + application->protocol_version(); + (*message)[strings::msg_params][strings::request_type] = + mobile_apis::RequestType::ICON_URL; + (*message)[strings::msg_params][strings::url] = url; + + app_icon_it->second.pending_request = true; + + rpc_service_->ManageMobileCommand(message, commands::Command::SOURCE_SDL); + } +} + protocol_handler::MajorProtocolVersion ApplicationManagerImpl::SupportedSDLVersion() const { LOG4CXX_AUTO_TRACE(logger_); diff --git a/src/components/application_manager/src/message_helper/message_helper.cc b/src/components/application_manager/src/message_helper/message_helper.cc index 58d5171f84..cc162b03ea 100644 --- a/src/components/application_manager/src/message_helper/message_helper.cc +++ b/src/components/application_manager/src/message_helper/message_helper.cc @@ -1547,6 +1547,7 @@ bool MessageHelper::CreateHMIApplicationStruct( message[hmi_response::policy_app_id] = policy_app_id; const std::string icon_path = app->app_icon_path(); + if (file_system::FileExists(app->app_icon_path())) { message[strings::icon] = icon_path; } diff --git a/src/components/application_manager/src/policies/policy_handler.cc b/src/components/application_manager/src/policies/policy_handler.cc index 02b848d9c6..05aa9154ea 100644 --- a/src/components/application_manager/src/policies/policy_handler.cc +++ b/src/components/application_manager/src/policies/policy_handler.cc @@ -91,7 +91,8 @@ RequestTypeMap TypeToString = { {mobile_apis::RequestType::EMERGENCY, "EMERGENCY"}, {mobile_apis::RequestType::MEDIA, "MEDIA"}, {mobile_apis::RequestType::FOTA, "FOTA"}, - {mobile_apis::RequestType::OEM_SPECIFIC, "OEM_SPECIFIC"}}; + {mobile_apis::RequestType::OEM_SPECIFIC, "OEM_SPECIFIC"}, + {mobile_apis::RequestType::ICON_URL, "ICON_URL"}}; const std::string RequestTypeToString(mobile_apis::RequestType::eType type) { RequestTypeMap::const_iterator it = TypeToString.find(type); @@ -1576,6 +1577,11 @@ std::string PolicyHandler::GetLockScreenIconUrl() const { return policy_manager_->GetLockScreenIconUrl(); } +std::string PolicyHandler::GetIconUrl(const std::string& policy_app_id) const { + POLICY_LIB_CHECK(std::string("")); + return policy_manager_->GetIconUrl(policy_app_id); +} + uint32_t PolicyHandler::NextRetryTimeout() { POLICY_LIB_CHECK(0); LOG4CXX_AUTO_TRACE(logger_); diff --git a/src/components/include/application_manager/application_manager.h b/src/components/include/application_manager/application_manager.h index f9b302be06..cfd6cbe61c 100644 --- a/src/components/include/application_manager/application_manager.h +++ b/src/components/include/application_manager/application_manager.h @@ -152,6 +152,8 @@ class ApplicationManager { connection_handler::ConnectionHandler* handler) = 0; virtual DataAccessor applications() const = 0; + virtual DataAccessor pending_applications() + const = 0; virtual ApplicationSharedPtr application(uint32_t app_id) const = 0; virtual ApplicationSharedPtr active_application() const = 0; @@ -167,6 +169,9 @@ class ApplicationManager { virtual ApplicationSharedPtr application_by_policy_id( const std::string& policy_app_id) const = 0; + virtual ApplicationSharedPtr pending_application_by_policy_id( + const std::string& policy_app_id) const = 0; + virtual AppSharedPtrs applications_by_button(uint32_t button) = 0; virtual AppSharedPtrs applications_with_navi() = 0; @@ -283,6 +288,9 @@ class ApplicationManager { */ virtual void SendDriverDistractionState(ApplicationSharedPtr application) = 0; + virtual void SendGetIconUrlNotifications( + const uint32_t connection_key, ApplicationSharedPtr application) = 0; + /** * @brief Checks if Application is subscribed for way points * @param Application pointer @@ -431,6 +439,10 @@ class ApplicationManager { virtual void RefreshCloudAppInformation() = 0; + virtual std::string PolicyIDByIconUrl(const std::string url) = 0; + + virtual void SetIconFileFromSystemRequest(const std::string policy_id) = 0; + /** * @brief Retrieve the current connection status of a cloud app * @param app A cloud application diff --git a/src/components/include/application_manager/policies/policy_handler_interface.h b/src/components/include/application_manager/policies/policy_handler_interface.h index 8c8a12ced3..c9feacabd4 100644 --- a/src/components/include/application_manager/policies/policy_handler_interface.h +++ b/src/components/include/application_manager/policies/policy_handler_interface.h @@ -105,6 +105,7 @@ class PolicyHandlerInterface { virtual void GetUpdateUrls(const uint32_t service_type, EndpointUrls& out_end_points) = 0; virtual std::string GetLockScreenIconUrl() const = 0; + virtual std::string GetIconUrl(const std::string& policy_app_id) const = 0; virtual uint32_t NextRetryTimeout() = 0; /** diff --git a/src/components/include/policy/policy_external/policy/policy_manager.h b/src/components/include/policy/policy_external/policy/policy_manager.h index 92c0305279..f342c2a07a 100644 --- a/src/components/include/policy/policy_external/policy/policy_manager.h +++ b/src/components/include/policy/policy_external/policy/policy_manager.h @@ -109,11 +109,20 @@ class PolicyManager : public usage_statistics::StatisticsManager { /** * @brief GetLockScreenIcon allows to obtain lock screen icon url; - * @return url which point to the resourse where lock screen icon could be + * @return url which point to the resource where lock screen icon could be *obtained. */ virtual std::string GetLockScreenIconUrl() const = 0; + /** + * @brief Get Icon Url used for showing a cloud apps icon before the initial + *registration + * + * @return url which point to the resource where icon could be + *obtained. + */ + virtual std::string GetIconUrl(const std::string& policy_app_id) const = 0; + /** * @brief PTU is needed, for this PTS has to be formed and sent. */ diff --git a/src/components/include/policy/policy_regular/policy/policy_manager.h b/src/components/include/policy/policy_regular/policy/policy_manager.h index b2d48585f4..6876611b3f 100644 --- a/src/components/include/policy/policy_regular/policy/policy_manager.h +++ b/src/components/include/policy/policy_regular/policy/policy_manager.h @@ -87,11 +87,20 @@ class PolicyManager : public usage_statistics::StatisticsManager { /** * @brief GetLockScreenIcon allows to obtain lock screen icon url; - * @return url which point to the resourse where lock screen icon could be + * @return url which point to the resource where lock screen icon could be *obtained. */ virtual std::string GetLockScreenIconUrl() const = 0; + /** + * @brief Get Icon Url used for showing a cloud apps icon before the initial + *registration + * + * @return url which point to the resource where icon could be + *obtained. + */ + virtual std::string GetIconUrl(const std::string& policy_app_id) const = 0; + /** * @brief Gets all URLs for sending PTS to from PT itself. * @param service_type Service specifies user of URL diff --git a/src/components/include/test/application_manager/mock_application_manager.h b/src/components/include/test/application_manager/mock_application_manager.h index ca03864dfa..7cae217371 100644 --- a/src/components/include/test/application_manager/mock_application_manager.h +++ b/src/components/include/test/application_manager/mock_application_manager.h @@ -74,6 +74,9 @@ class MockApplicationManager : public application_manager::ApplicationManager { void(connection_handler::ConnectionHandler* handler)); MOCK_CONST_METHOD0(applications, DataAccessor()); + MOCK_CONST_METHOD0( + pending_applications, + DataAccessor()); MOCK_CONST_METHOD1( application, application_manager::ApplicationSharedPtr(uint32_t app_id)); MOCK_CONST_METHOD0(active_application, @@ -97,6 +100,9 @@ class MockApplicationManager : public application_manager::ApplicationManager { MOCK_CONST_METHOD1(application_by_policy_id, application_manager::ApplicationSharedPtr( const std::string& policy_app_id)); + MOCK_CONST_METHOD1(pending_application_by_policy_id, + application_manager::ApplicationSharedPtr( + const std::string& policy_app_id)); MOCK_METHOD1( applications_by_button, std::vector(uint32_t button)); @@ -124,6 +130,9 @@ class MockApplicationManager : public application_manager::ApplicationManager { void(const std::shared_ptr app)); MOCK_METHOD1(SendDriverDistractionState, void(application_manager::ApplicationSharedPtr app)); + MOCK_METHOD2(SendGetIconUrlNotifications, + void(const uint32_t connection_key, + application_manager::ApplicationSharedPtr application)); MOCK_METHOD2(RemoveHMIFakeParameters, void(application_manager::commands::MessageSharedPtr& message, const hmi_apis::FunctionID::eType& function_id)); @@ -172,6 +181,8 @@ class MockApplicationManager : public application_manager::ApplicationManager { MOCK_CONST_METHOD1(GetCloudAppConnectionStatus, hmi_apis::Common_CloudConnectionStatus::eType( application_manager::ApplicationConstSharedPtr app)); + MOCK_METHOD1(PolicyIDByIconUrl, std::string(const std::string url)); + MOCK_METHOD1(SetIconFileFromSystemRequest, void(const std::string policy_id)); MOCK_CONST_METHOD0(IsHMICooperating, bool()); MOCK_METHOD2(IviInfoUpdated, void(mobile_apis::VehicleDataType::eType vehicle_info, diff --git a/src/components/include/test/application_manager/policies/mock_policy_handler_interface.h b/src/components/include/test/application_manager/policies/mock_policy_handler_interface.h index 02a0d73086..3d3fb31af7 100644 --- a/src/components/include/test/application_manager/policies/mock_policy_handler_interface.h +++ b/src/components/include/test/application_manager/policies/mock_policy_handler_interface.h @@ -102,6 +102,7 @@ class MockPolicyHandlerInterface : public policy::PolicyHandlerInterface { void(const uint32_t service_type, policy::EndpointUrls& end_points)); MOCK_CONST_METHOD0(GetLockScreenIconUrl, std::string()); + MOCK_CONST_METHOD1(GetIconUrl, std::string(const std::string& policy_app_id)); MOCK_METHOD0(ResetRetrySequence, void()); MOCK_METHOD0(NextRetryTimeout, uint32_t()); MOCK_CONST_METHOD0(TimeoutExchangeSec, uint32_t()); diff --git a/src/components/include/test/policy/policy_external/policy/mock_cache_manager.h b/src/components/include/test/policy/policy_external/policy/mock_cache_manager.h index da2b4cc2a1..82d4a866c4 100644 --- a/src/components/include/test/policy/policy_external/policy/mock_cache_manager.h +++ b/src/components/include/test/policy/policy_external/policy/mock_cache_manager.h @@ -119,6 +119,7 @@ class MockCacheManagerInterface : public ::policy::CacheManagerInterface { MOCK_METHOD2(GetUpdateUrls, void(const uint32_t service_type, EndpointUrls& out_end_points)); MOCK_CONST_METHOD0(GetLockScreenIconUrl, std::string()); + MOCK_CONST_METHOD1(GetIconUrl, std::string(const std::string& policy_app_id)); MOCK_METHOD1( GetNotificationsNumber, policy_table::NumberOfNotificationsType(const std::string& priority)); diff --git a/src/components/include/test/policy/policy_external/policy/mock_policy_manager.h b/src/components/include/test/policy/policy_external/policy/mock_policy_manager.h index 72dcb147e3..9fe96e1544 100644 --- a/src/components/include/test/policy/policy_external/policy/mock_policy_manager.h +++ b/src/components/include/test/policy/policy_external/policy/mock_policy_manager.h @@ -180,6 +180,7 @@ class MockPolicyManager : public PolicyManager { MOCK_METHOD1(OnAppRegisteredOnMobile, void(const std::string& application_id)); MOCK_CONST_METHOD0(GetLockScreenIconUrl, std::string()); + MOCK_CONST_METHOD1(GetIconUrl, std::string(const std::string& policy_app_id)); MOCK_CONST_METHOD1( GetAppRequestTypes, const std::vector(const std::string policy_app_id)); diff --git a/src/components/include/test/policy/policy_regular/policy/mock_cache_manager.h b/src/components/include/test/policy/policy_regular/policy/mock_cache_manager.h index 24fe9b2393..e7c9502db9 100644 --- a/src/components/include/test/policy/policy_regular/policy/mock_cache_manager.h +++ b/src/components/include/test/policy/policy_regular/policy/mock_cache_manager.h @@ -103,6 +103,7 @@ class MockCacheManagerInterface : public CacheManagerInterface { MOCK_METHOD2(GetUpdateUrls, void(const uint32_t service_type, EndpointUrls& out_end_points)); MOCK_CONST_METHOD0(GetLockScreenIconUrl, std::string()); + MOCK_CONST_METHOD1(GetIconUrl, std::string(const std::string& policy_app_id)); MOCK_METHOD2(Init, bool(const std::string& file_name, const PolicySettings* settings)); diff --git a/src/components/include/test/policy/policy_regular/policy/mock_policy_manager.h b/src/components/include/test/policy/policy_regular/policy/mock_policy_manager.h index a5ce488e1a..7283397187 100644 --- a/src/components/include/test/policy/policy_regular/policy/mock_policy_manager.h +++ b/src/components/include/test/policy/policy_regular/policy/mock_policy_manager.h @@ -226,6 +226,7 @@ class MockPolicyManager : public PolicyManager { MOCK_CONST_METHOD0(get_settings, const PolicySettings&()); MOCK_METHOD1(set_settings, void(const PolicySettings* get_settings)); MOCK_CONST_METHOD0(GetLockScreenIconUrl, std::string()); + MOCK_CONST_METHOD1(GetIconUrl, std::string(const std::string& policy_app_id)); MOCK_METHOD1(GetNextUpdateUrl, AppIdURL(const EndpointUrls& urls)); MOCK_CONST_METHOD2(RetrySequenceUrl, AppIdURL(const struct RetrySequenceURL&, diff --git a/src/components/interfaces/HMI_API.xml b/src/components/interfaces/HMI_API.xml index 24b1858d3b..b056ae3910 100644 --- a/src/components/interfaces/HMI_API.xml +++ b/src/components/interfaces/HMI_API.xml @@ -1271,6 +1271,7 @@ + diff --git a/src/components/interfaces/MOBILE_API.xml b/src/components/interfaces/MOBILE_API.xml index 714399bce6..66f5a19208 100644 --- a/src/components/interfaces/MOBILE_API.xml +++ b/src/components/interfaces/MOBILE_API.xml @@ -2419,6 +2419,7 @@ + diff --git a/src/components/policy/policy_external/include/policy/cache_manager.h b/src/components/policy/policy_external/include/policy/cache_manager.h index 3344b149e4..90783b7a46 100644 --- a/src/components/policy/policy_external/include/policy/cache_manager.h +++ b/src/components/policy/policy_external/include/policy/cache_manager.h @@ -261,6 +261,15 @@ class CacheManager : public CacheManagerInterface { */ virtual std::string GetLockScreenIconUrl() const; + /** + * @brief Get Icon Url used for showing a cloud apps icon before the intial + *registration + * + * @return url which point to the resourse where icon could be + *obtained. + */ + virtual std::string GetIconUrl(const std::string& policy_app_id) const; + /** * @brief Gets list of URL to send PTS to * @param service_type If URLs for specific service are preset, diff --git a/src/components/policy/policy_external/include/policy/cache_manager_interface.h b/src/components/policy/policy_external/include/policy/cache_manager_interface.h index 6a172e6f4b..58baf5ce99 100644 --- a/src/components/policy/policy_external/include/policy/cache_manager_interface.h +++ b/src/components/policy/policy_external/include/policy/cache_manager_interface.h @@ -279,6 +279,15 @@ class CacheManagerInterface { */ virtual std::string GetLockScreenIconUrl() const = 0; + /** + * @brief Get Icon Url used for showing a cloud apps icon before the intial + *registration + * + * @return url which point to the resourse where icon could be + *obtained. + */ + virtual std::string GetIconUrl(const std::string& policy_app_id) const = 0; + /** * @brief Get allowed number of notifications * depending on application priority. diff --git a/src/components/policy/policy_external/include/policy/policy_manager_impl.h b/src/components/policy/policy_external/include/policy/policy_manager_impl.h index 2802af1706..caa1b0dc95 100644 --- a/src/components/policy/policy_external/include/policy/policy_manager_impl.h +++ b/src/components/policy/policy_external/include/policy/policy_manager_impl.h @@ -208,6 +208,15 @@ class PolicyManagerImpl : public PolicyManager { */ std::string GetLockScreenIconUrl() const OVERRIDE; + /** + * @brief Get Icon Url used for showing a cloud apps icon before the intial + *registration + * + * @return url which point to the resourse where icon could be + *obtained. + */ + std::string GetIconUrl(const std::string& policy_app_id) const OVERRIDE; + /** * @brief Handler of PTS sending out */ diff --git a/src/components/policy/policy_external/include/policy/policy_table/enums.h b/src/components/policy/policy_external/include/policy/policy_table/enums.h index 5b494629bb..2477d7eb04 100644 --- a/src/components/policy/policy_external/include/policy/policy_table/enums.h +++ b/src/components/policy/policy_external/include/policy/policy_table/enums.h @@ -154,6 +154,7 @@ enum RequestType { RT_MEDIA, RT_FOTA, RT_OEM_SPECIFIC, + RT_ICON_URL, RT_EMPTY // Added to allow empty Request Types handling }; diff --git a/src/components/policy/policy_external/include/policy/policy_table/types.h b/src/components/policy/policy_external/include/policy/policy_table/types.h index f37531eb63..e844381707 100644 --- a/src/components/policy/policy_external/include/policy/policy_table/types.h +++ b/src/components/policy/policy_external/include/policy/policy_table/types.h @@ -184,6 +184,7 @@ struct ApplicationParams : PolicyBase { Optional enabled; Optional > auth_token; Optional > cloud_transport_type; + Optional > icon_url; public: ApplicationParams(); diff --git a/src/components/policy/policy_external/include/policy/policy_table_interface_ext.xml b/src/components/policy/policy_external/include/policy/policy_table_interface_ext.xml index 5ed852cf45..f90edca8aa 100644 --- a/src/components/policy/policy_external/include/policy/policy_table_interface_ext.xml +++ b/src/components/policy/policy_external/include/policy/policy_table_interface_ext.xml @@ -108,6 +108,8 @@ + policy_table.app_policies_section.apps; + policy_table::ApplicationPolicies::const_iterator policy_iter = + policies.find(policy_app_id); + if (policies.end() != policy_iter) { + auto app_policy = (*policy_iter).second; + url = app_policy.icon_url.is_initialized() ? *app_policy.icon_url + : std::string(); + } + return url; +} + rpc::policy_table_interface_base::NumberOfNotificationsType CacheManager::GetNotificationsNumber(const std::string& priority) { CACHE_MANAGER_CHECK(0); diff --git a/src/components/policy/policy_external/src/policy_manager_impl.cc b/src/components/policy/policy_external/src/policy_manager_impl.cc index bd7746d720..23101438cb 100644 --- a/src/components/policy/policy_external/src/policy_manager_impl.cc +++ b/src/components/policy/policy_external/src/policy_manager_impl.cc @@ -271,6 +271,11 @@ std::string PolicyManagerImpl::GetLockScreenIconUrl() const { return cache_->GetLockScreenIconUrl(); } +std::string PolicyManagerImpl::GetIconUrl( + const std::string& policy_app_id) const { + return cache_->GetIconUrl(policy_app_id); +} + /** * @brief FilterInvalidFunctions filter functions that are absent in schema * @param rpcs list of functions to filter diff --git a/src/components/policy/policy_external/src/policy_table/enums.cc b/src/components/policy/policy_external/src/policy_table/enums.cc index d7d5a241de..9cc838bd82 100644 --- a/src/components/policy/policy_external/src/policy_table/enums.cc +++ b/src/components/policy/policy_external/src/policy_table/enums.cc @@ -629,6 +629,8 @@ bool IsValidEnum(RequestType val) { return true; case RT_OEM_SPECIFIC: return true; + case RT_ICON_URL: + return true; case RT_EMPTY: return true; default: @@ -680,6 +682,8 @@ const char* EnumToJsonString(RequestType val) { return "FOTA"; case RT_OEM_SPECIFIC: return "OEM_SPECIFIC"; + case RT_ICON_URL: + return "ICON_URL"; case RT_EMPTY: return "EMPTY"; default: @@ -772,6 +776,10 @@ bool EnumFromJsonString(const std::string& literal, RequestType* result) { *result = RT_OEM_SPECIFIC; return true; } + if ("ICON_URL" == literal) { + *result = RT_ICON_URL; + return true; + } if ("EMPTY" == literal) { *result = RT_EMPTY; return true; diff --git a/src/components/policy/policy_external/src/policy_table/types.cc b/src/components/policy/policy_external/src/policy_table/types.cc index 0fe54a683d..12de0cc62b 100644 --- a/src/components/policy/policy_external/src/policy_table/types.cc +++ b/src/components/policy/policy_external/src/policy_table/types.cc @@ -247,8 +247,8 @@ ApplicationParams::ApplicationParams(const Json::Value* value__) , endpoint(impl::ValueMember(value__, "endpoint")) , enabled(impl::ValueMember(value__, "enabled")) , auth_token(impl::ValueMember(value__, "auth_token")) - , cloud_transport_type(impl::ValueMember(value__, "cloud_transport_type")) { -} + , cloud_transport_type(impl::ValueMember(value__, "cloud_transport_type")) + , icon_url(impl::ValueMember(value__, "icon_url")) {} Json::Value ApplicationParams::ToJsonValue() const { Json::Value result__(PolicyBase::ToJsonValue()); @@ -267,6 +267,7 @@ Json::Value ApplicationParams::ToJsonValue() const { impl::WriteJsonField("enabled", enabled, &result__); impl::WriteJsonField("auth_token", auth_token, &result__); impl::WriteJsonField("cloud_transport_type", cloud_transport_type, &result__); + impl::WriteJsonField("icon_url", auth_token, &result__); return result__; } @@ -309,6 +310,9 @@ bool ApplicationParams::is_valid() const { if (!hybrid_app_preference.is_valid()) { return false; } + if (!icon_url.is_valid()) { + return false; + } return Validate(); } @@ -359,6 +363,9 @@ bool ApplicationParams::struct_empty() const { if (hybrid_app_preference.is_initialized()) { return false; } + if (icon_url.is_initialized()) { + return false; + } return true; } @@ -426,6 +433,9 @@ void ApplicationParams::ReportErrors(rpc::ValidationReport* report__) const { moduleType.ReportErrors( &report__->ReportSubobject("hybrid_app_preference")); } + if (!icon_url.is_valid()) { + moduleType.ReportErrors(&report__->ReportSubobject("icon_url")); + } } void ApplicationParams::SetPolicyTableType(PolicyTableType pt_type) { @@ -441,6 +451,7 @@ void ApplicationParams::SetPolicyTableType(PolicyTableType pt_type) { enabled.SetPolicyTableType(pt_type); cloud_transport_type.SetPolicyTableType(pt_type); hybrid_app_preference.SetPolicyTableType(pt_type); + icon_url.SetPolicyTableType(pt_type); } // RpcParameters methods diff --git a/src/components/policy/policy_external/src/sql_pt_ext_queries.cc b/src/components/policy/policy_external/src/sql_pt_ext_queries.cc index 32320b6d6c..58206e2c69 100644 --- a/src/components/policy/policy_external/src/sql_pt_ext_queries.cc +++ b/src/components/policy/policy_external/src/sql_pt_ext_queries.cc @@ -207,8 +207,8 @@ const std::string kInsertApplication = " `default_hmi`, `priority_value`, `is_revoked`, `memory_kb`, " " `heart_beat_timeout_ms`, `certificate`, `hybrid_app_preference_value`, " " `endpoint`, `enabled`, `auth_token`, " - " `cloud_transport_type`) VALUES " - "(?,?,?,?,?,?,?,?,?,?,?,?,?,?)"; + " `cloud_transport_type`, `icon_url`) VALUES " + "(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)"; const std::string kCollectFriendlyMsg = "SELECT * FROM `message`"; @@ -237,7 +237,7 @@ const std::string kSelectAppPolicies = "SELECT `id`, `priority_value`, `default_hmi`, `keep_context`, " " `steal_focus`, `memory_kb`, `heart_beat_timeout_ms`, `certificate`, " " `hybrid_app_preference_value`, `endpoint`, `enabled`, `auth_token` " - " `cloud_transport_type` FROM `application`"; + " `cloud_transport_type`, `icon_url` FROM `application`"; const std::string kSelectFunctionalGroupNames = "SELECT `id`, `user_consent_prompt`, `name`" diff --git a/src/components/policy/policy_external/src/sql_pt_ext_representation.cc b/src/components/policy/policy_external/src/sql_pt_ext_representation.cc index 43961815d6..c0214f087f 100644 --- a/src/components/policy/policy_external/src/sql_pt_ext_representation.cc +++ b/src/components/policy/policy_external/src/sql_pt_ext_representation.cc @@ -771,6 +771,9 @@ bool SQLPTExtRepresentation::SaveSpecificAppPolicy( app.second.cloud_transport_type.is_initialized() ? app_query.Bind(13, *app.second.cloud_transport_type) : app_query.Bind(13); + app.second.icon_url.is_initialized() + ? app_query.Bind(14, *app.second.icon_url) + : app_query.Bind(14); if (!app_query.Exec() || !app_query.Reset()) { LOG4CXX_WARN(logger_, "Incorrect insert into application."); @@ -908,6 +911,7 @@ bool SQLPTExtRepresentation::GatherApplicationPoliciesSection( } *params.auth_token = query.GetString(11); *params.cloud_transport_type = query.GetString(12); + *params.icon_url = query.GetString(13); const auto& gather_app_id = ((*policies).apps[app_id].is_string()) ? (*policies).apps[app_id].get_string() diff --git a/src/components/policy/policy_external/src/sql_pt_queries.cc b/src/components/policy/policy_external/src/sql_pt_queries.cc index 162d6957e7..66f7ef65be 100644 --- a/src/components/policy/policy_external/src/sql_pt_queries.cc +++ b/src/components/policy/policy_external/src/sql_pt_queries.cc @@ -156,6 +156,7 @@ const std::string kCreateSchema = " `enabled` BOOLEAN, " " `auth_token` VARCHAR(65535), " " `cloud_transport_type` VARCHAR(255), " + " `icon_url` VARCHAR(65535), " " `remote_control_denied` BOOLEAN NOT NULL DEFAULT 0, " " CONSTRAINT `fk_application_hmi_level1` " " FOREIGN KEY(`default_hmi`) " @@ -649,8 +650,8 @@ const std::string kInsertApplication = "INSERT OR IGNORE INTO `application` (`id`, `priority_value`, " "`is_revoked`, `memory_kb`, `heart_beat_timeout_ms`, `certificate`, " "`hybrid_app_preference_value`, `endpoint`, `enabled`, `auth_token`, " - "`cloud_transport_type`) VALUES " - "(?,?,?,?,?,?,?,?,?,?,?)"; + "`cloud_transport_type`, `icon_url`) VALUES " + "(?,?,?,?,?,?,?,?,?,?,?,?)"; const std::string kInsertAppGroup = "INSERT INTO `app_group` (`application_id`, `functional_group_id`)" @@ -774,7 +775,8 @@ const std::string kSelectUserMsgsVersion = const std::string kSelectAppPolicies = "SELECT `id`, `priority_value`, `memory_kb`, " " `heart_beat_timeout_ms`, `certificate`, `hybrid_app_preference_value`, " - " `endpoint`, `enabled`, `auth_token`, `cloud_transport_type` FROM " + " `endpoint`, `enabled`, `auth_token`, `cloud_transport_type`, `icon_url` " + "FROM " " `application`"; const std::string kCollectFriendlyMsg = "SELECT * FROM `message`"; @@ -875,14 +877,14 @@ const std::string kInsertApplicationFull = " `default_hmi`, `priority_value`, `is_revoked`, `is_default`, " " `is_predata`, `memory_kb`, `heart_beat_timeout_ms`, " " `certificate`, `hybrid_app_preference_value`, `endpoint`, `enabled`, " - " `auth_token`, `cloud_transport_type`) " - " VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"; + " `auth_token`, `cloud_transport_type`, `icon_url`) " + " VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"; const std::string kSelectApplicationFull = "SELECT `keep_context`, `steal_focus`, `default_hmi`, `priority_value`, " " `is_revoked`, `is_default`, `is_predata`, `memory_kb`," " `heart_beat_timeout_ms`, `certificate`, `hybrid_app_preference_value`, " - " `endpoint`, `enabled`, `auth_token`, `cloud_transport_type` " + " `endpoint`, `enabled`, `auth_token`, `cloud_transport_type`, `icon_url` " "FROM `application` " "WHERE `id` = ?"; diff --git a/src/components/policy/policy_external/src/sql_pt_representation.cc b/src/components/policy/policy_external/src/sql_pt_representation.cc index b794d4c3a6..885a59ba36 100644 --- a/src/components/policy/policy_external/src/sql_pt_representation.cc +++ b/src/components/policy/policy_external/src/sql_pt_representation.cc @@ -777,6 +777,7 @@ bool SQLPTRepresentation::GatherApplicationPoliciesSection( } *params.auth_token = query.GetString(8); *params.cloud_transport_type = query.GetString(9); + *params.icon_url = query.GetString(10); const auto& gather_app_id = ((*policies).apps[app_id].is_string()) ? (*policies).apps[app_id].get_string() @@ -1070,6 +1071,9 @@ bool SQLPTRepresentation::SaveSpecificAppPolicy( app.second.cloud_transport_type.is_initialized() ? app_query.Bind(10, *app.second.cloud_transport_type) : app_query.Bind(10); + app.second.icon_url.is_initialized() + ? app_query.Bind(11, *app.second.icon_url) + : app_query.Bind(11); if (!app_query.Exec() || !app_query.Reset()) { LOG4CXX_WARN(logger_, "Incorrect insert into application."); @@ -2172,6 +2176,8 @@ bool SQLPTRepresentation::CopyApplication(const std::string& source, : query.Bind(14, source_app.GetString(13)); source_app.IsNull(14) ? query.Bind(15) : query.Bind(15, source_app.GetString(14)); + source_app.IsNull(15) ? query.Bind(16) + : query.Bind(16, source_app.GetString(15)); if (!query.Exec()) { LOG4CXX_WARN(logger_, "Failed inserting into application."); diff --git a/src/components/policy/policy_regular/include/policy/cache_manager.h b/src/components/policy/policy_regular/include/policy/cache_manager.h index 8c8f0c55c6..d23145994a 100644 --- a/src/components/policy/policy_regular/include/policy/cache_manager.h +++ b/src/components/policy/policy_regular/include/policy/cache_manager.h @@ -255,6 +255,15 @@ class CacheManager : public CacheManagerInterface { */ virtual std::string GetLockScreenIconUrl() const; + /** + * @brief Get Icon Url used for showing a cloud apps icon before the intial + *registration + * + * @return url which point to the resourse where icon could be + *obtained. + */ + virtual std::string GetIconUrl(const std::string& policy_app_id) const; + /** * @brief Get allowed number of notifications * depending on application priority. diff --git a/src/components/policy/policy_regular/include/policy/cache_manager_interface.h b/src/components/policy/policy_regular/include/policy/cache_manager_interface.h index 50b546ecc5..ea59a4ef62 100644 --- a/src/components/policy/policy_regular/include/policy/cache_manager_interface.h +++ b/src/components/policy/policy_regular/include/policy/cache_manager_interface.h @@ -263,6 +263,15 @@ class CacheManagerInterface { */ virtual std::string GetLockScreenIconUrl() const = 0; + /** + * @brief Get Icon Url used for showing a cloud apps icon before the intial + *registration + * + * @return url which point to the resourse where icon could be + *obtained. + */ + virtual std::string GetIconUrl(const std::string& policy_app_id) const = 0; + /** * @brief Get allowed number of notifications * depending on application priority. diff --git a/src/components/policy/policy_regular/include/policy/policy_manager_impl.h b/src/components/policy/policy_regular/include/policy/policy_manager_impl.h index fea8bbe0b3..779bea729d 100644 --- a/src/components/policy/policy_regular/include/policy/policy_manager_impl.h +++ b/src/components/policy/policy_regular/include/policy/policy_manager_impl.h @@ -116,6 +116,15 @@ class PolicyManagerImpl : public PolicyManager { */ std::string GetLockScreenIconUrl() const OVERRIDE; + /** + * @brief Get Icon Url used for showing a cloud apps icon before the intial + *registration + * + * @return url which point to the resourse where icon could be + *obtained. + */ + std::string GetIconUrl(const std::string& policy_app_id) const OVERRIDE; + /** * @brief PTU is needed, for this PTS has to be formed and sent. */ diff --git a/src/components/policy/policy_regular/include/policy/policy_table/types.h b/src/components/policy/policy_regular/include/policy/policy_table/types.h index 18f909bb99..63058dee26 100644 --- a/src/components/policy/policy_regular/include/policy/policy_table/types.h +++ b/src/components/policy/policy_regular/include/policy/policy_table/types.h @@ -150,6 +150,7 @@ struct ApplicationParams : PolicyBase { Optional enabled; Optional > auth_token; Optional > cloud_transport_type; + Optional > icon_url; public: ApplicationParams(); diff --git a/src/components/policy/policy_regular/src/cache_manager.cc b/src/components/policy/policy_regular/src/cache_manager.cc index ca61a338f1..677ea66454 100644 --- a/src/components/policy/policy_regular/src/cache_manager.cc +++ b/src/components/policy/policy_regular/src/cache_manager.cc @@ -892,6 +892,21 @@ std::string CacheManager::GetLockScreenIconUrl() const { return std::string(""); } +std::string CacheManager::GetIconUrl(const std::string& policy_app_id) const { + CACHE_MANAGER_CHECK(std::string()); + std::string url; + const policy_table::ApplicationPolicies& policies = + pt_->policy_table.app_policies_section.apps; + policy_table::ApplicationPolicies::const_iterator policy_iter = + policies.find(policy_app_id); + if (policies.end() != policy_iter) { + auto app_policy = (*policy_iter).second; + url = app_policy.icon_url.is_initialized() ? *app_policy.icon_url + : std::string(); + } + return url; +} + rpc::policy_table_interface_base::NumberOfNotificationsType CacheManager::GetNotificationsNumber(const std::string& priority) { CACHE_MANAGER_CHECK(0); diff --git a/src/components/policy/policy_regular/src/policy_manager_impl.cc b/src/components/policy/policy_regular/src/policy_manager_impl.cc index a7e206b51b..b09478bba1 100644 --- a/src/components/policy/policy_regular/src/policy_manager_impl.cc +++ b/src/components/policy/policy_regular/src/policy_manager_impl.cc @@ -449,6 +449,11 @@ std::string PolicyManagerImpl::GetLockScreenIconUrl() const { return cache_->GetLockScreenIconUrl(); } +std::string PolicyManagerImpl::GetIconUrl( + const std::string& policy_app_id) const { + return cache_->GetIconUrl(policy_app_id); +} + void PolicyManagerImpl::StartPTExchange() { LOG4CXX_AUTO_TRACE(logger_); diff --git a/src/components/policy/policy_regular/src/policy_table/types.cc b/src/components/policy/policy_regular/src/policy_table/types.cc index 5faf96a232..2ee8bf1b21 100644 --- a/src/components/policy/policy_regular/src/policy_table/types.cc +++ b/src/components/policy/policy_regular/src/policy_table/types.cc @@ -173,8 +173,8 @@ ApplicationParams::ApplicationParams(const Json::Value* value__) , endpoint(impl::ValueMember(value__, "endpoint")) , enabled(impl::ValueMember(value__, "enabled")) , auth_token(impl::ValueMember(value__, "auth_token")) - , cloud_transport_type(impl::ValueMember(value__, "cloud_transport_type")) { -} + , cloud_transport_type(impl::ValueMember(value__, "cloud_transport_type")) + , icon_url(impl::ValueMember(value__, "icon_url")) {} Json::Value ApplicationParams::ToJsonValue() const { Json::Value result__(PolicyBase::ToJsonValue()); @@ -194,6 +194,7 @@ Json::Value ApplicationParams::ToJsonValue() const { impl::WriteJsonField("enabled", enabled, &result__); impl::WriteJsonField("auth_token", auth_token, &result__); impl::WriteJsonField("cloud_transport_type", cloud_transport_type, &result__); + impl::WriteJsonField("icon_url", auth_token, &result__); return result__; } @@ -240,6 +241,9 @@ bool ApplicationParams::is_valid() const { if (!hybrid_app_preference.is_valid()) { return false; } + if (!icon_url.is_valid()) { + return false; + } return Validate(); } @@ -293,6 +297,9 @@ bool ApplicationParams::struct_empty() const { if (hybrid_app_preference.is_initialized()) { return false; } + if (icon_url.is_initialized()) { + return false; + } return true; } @@ -347,6 +354,9 @@ void ApplicationParams::ReportErrors(rpc::ValidationReport* report__) const { moduleType.ReportErrors( &report__->ReportSubobject("hybrid_app_preference")); } + if (!icon_url.is_valid()) { + moduleType.ReportErrors(&report__->ReportSubobject("icon_url")); + } } void ApplicationParams::SetPolicyTableType(PolicyTableType pt_type) { @@ -363,6 +373,7 @@ void ApplicationParams::SetPolicyTableType(PolicyTableType pt_type) { enabled.SetPolicyTableType(pt_type); cloud_transport_type.SetPolicyTableType(pt_type); hybrid_app_preference.SetPolicyTableType(pt_type); + icon_url.SetPolicyTableType(pt_type); } // RpcParameters methods diff --git a/src/components/policy/policy_regular/src/sql_pt_queries.cc b/src/components/policy/policy_regular/src/sql_pt_queries.cc index 297031d4c0..8d2576866b 100644 --- a/src/components/policy/policy_regular/src/sql_pt_queries.cc +++ b/src/components/policy/policy_regular/src/sql_pt_queries.cc @@ -142,6 +142,7 @@ const std::string kCreateSchema = " `enabled` BOOLEAN, " " `auth_token` VARCHAR(65535), " " `cloud_transport_type` VARCHAR(255), " + " `icon_url` VARCHAR(65535), " " `remote_control_denied` BOOLEAN NOT NULL DEFAULT 0, " " CONSTRAINT `fk_application_hmi_level1` " " FOREIGN KEY(`default_hmi`) " @@ -598,8 +599,8 @@ const std::string kInsertApplication = "INSERT OR IGNORE INTO `application` (`id`, `priority_value`, " "`is_revoked`, `memory_kb`, `heart_beat_timeout_ms`, `certificate`, " "`hybrid_app_preference_value`, `endpoint`, `enabled`, `auth_token`, " - "`cloud_transport_type`) VALUES " - "(?,?,?,?,?,?,?,?,?,?,?)"; + "`cloud_transport_type`, `icon_url`) VALUES " + "(?,?,?,?,?,?,?,?,?,?,?,?)"; const std::string kInsertAppGroup = "INSERT INTO `app_group` (`application_id`, `functional_group_id`)" @@ -709,7 +710,8 @@ const std::string kSelectUserMsgsVersion = const std::string kSelectAppPolicies = "SELECT `id`, `priority_value`, `memory_kb`, " " `heart_beat_timeout_ms`, `certificate`, `hybrid_app_preference_value`, " - " `endpoint`, `enabled`, `auth_token`, `cloud_transport_type` FROM " + " `endpoint`, `enabled`, `auth_token`, `cloud_transport_type`, `icon_url` " + "FROM " " `application`"; const std::string kCollectFriendlyMsg = "SELECT * FROM `message`"; @@ -810,14 +812,14 @@ const std::string kInsertApplicationFull = " `default_hmi`, `priority_value`, `is_revoked`, `is_default`, " " `is_predata`, `memory_kb`, `heart_beat_timeout_ms`, " " `certificate`, `hybrid_app_preference_value`, `endpoint`, `enabled`, " - " `auth_token`, `cloud_transport_type`) " - " VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"; + " `auth_token`, `cloud_transport_type`, `icon_url`) " + " VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"; const std::string kSelectApplicationFull = "SELECT `keep_context`, `steal_focus`, `default_hmi`, `priority_value`, " " `is_revoked`, `is_default`, `is_predata`, `memory_kb`," " `heart_beat_timeout_ms`, `certificate`, `hybrid_app_preference_value`, " - " `endpoint`, `enabled`, `auth_token`, `cloud_transport_type` " + " `endpoint`, `enabled`, `auth_token`, `cloud_transport_type`, `icon_url` " "FROM `application` " "WHERE `id` = " "?"; diff --git a/src/components/policy/policy_regular/src/sql_pt_representation.cc b/src/components/policy/policy_regular/src/sql_pt_representation.cc index 9282caf535..49aeec2642 100644 --- a/src/components/policy/policy_regular/src/sql_pt_representation.cc +++ b/src/components/policy/policy_regular/src/sql_pt_representation.cc @@ -733,6 +733,7 @@ bool SQLPTRepresentation::GatherApplicationPoliciesSection( } *params.auth_token = query.GetString(8); *params.cloud_transport_type = query.GetString(9); + *params.icon_url = query.GetString(10); const auto& gather_app_id = ((*policies).apps[app_id].is_string()) ? (*policies).apps[app_id].get_string() @@ -1011,6 +1012,9 @@ bool SQLPTRepresentation::SaveSpecificAppPolicy( app.second.cloud_transport_type.is_initialized() ? app_query.Bind(10, *app.second.cloud_transport_type) : app_query.Bind(10); + app.second.icon_url.is_initialized() + ? app_query.Bind(11, *app.second.icon_url) + : app_query.Bind(11); if (!app_query.Exec() || !app_query.Reset()) { LOG4CXX_WARN(logger_, "Incorrect insert into application."); @@ -2122,6 +2126,8 @@ bool SQLPTRepresentation::CopyApplication(const std::string& source, : query.Bind(14, source_app.GetString(13)); source_app.IsNull(14) ? query.Bind(15) : query.Bind(15, source_app.GetString(14)); + source_app.IsNull(15) ? query.Bind(16) + : query.Bind(16, source_app.GetString(15)); if (!query.Exec()) { LOG4CXX_WARN(logger_, "Failed inserting into application."); diff --git a/src/components/transport_manager/src/cloud/cloud_websocket_transport_adapter.cc b/src/components/transport_manager/src/cloud/cloud_websocket_transport_adapter.cc index 9f2b8e6ade..a41c4ea30f 100644 --- a/src/components/transport_manager/src/cloud/cloud_websocket_transport_adapter.cc +++ b/src/components/transport_manager/src/cloud/cloud_websocket_transport_adapter.cc @@ -87,7 +87,8 @@ void CloudWebsocketTransportAdapter::CreateDevice(const std::string& uid) { // Extract host and port from endpoint string boost::regex group_pattern( - "(wss?:\\/\\/)([A-Z\\d\\.-]{2,}\\.?([A-Z]{2,})?)(:)(\\d{2,4})(\\/)"); + "(wss?:\\/\\/)([A-Z\\d\\.-]{2,}\\.?([A-Z]{2,})?)(:)(\\d{2,4})(\\/" + ")(((([A-Z\\d\\.-]{1,})(\\/)?){1,})?){1,}"); boost::smatch results; std::string host = ""; -- cgit v1.2.1 From 9ef245688d5f4c16e44c1980483cf78506a227c9 Mon Sep 17 00:00:00 2001 From: JackLivio Date: Fri, 1 Mar 2019 16:19:45 -0500 Subject: GetCloudAppProperties (#2824) * GetCloudAppProperties * Update setCloudAppProperties to use properties param * Address comments * Add set endpoint and app name * Remove setAppName * Address comment * Address Comments * Add return value to GetCloudAppParameters * Add return --- src/appMain/sdl_preloaded_pt.json | 5 + .../include/application_manager/application.h | 4 +- .../include/application_manager/application_impl.h | 4 +- .../application_manager/policies/policy_handler.h | 2 +- .../application_manager/smart_object_keys.h | 3 +- .../mobile/get_cloud_app_properties_request.h | 31 ++++++ .../mobile/get_cloud_app_properties_response.h | 31 ++++++ .../mobile/get_cloud_app_properties_request.cc | 110 +++++++++++++++++++++ .../mobile/get_cloud_app_properties_response.cc | 31 ++++++ .../sdl_rpc_plugin/src/mobile_command_factory.cc | 8 ++ .../application_manager/src/application_impl.cc | 4 +- .../src/application_manager_impl.cc | 4 +- .../src/policies/policy_handler.cc | 53 ++++++---- .../application_manager/src/smart_object_keys.cc | 3 +- .../test/application_manager_impl_test.cc | 5 +- .../include/application_manager/mock_application.h | 4 +- .../policies/policy_handler_interface.h | 2 +- .../policy/policy_external/policy/policy_manager.h | 9 +- .../policy/policy_regular/policy/policy_manager.h | 9 +- .../policies/mock_policy_handler_interface.h | 2 +- .../policy_external/policy/mock_cache_manager.h | 5 +- .../policy_external/policy/mock_policy_manager.h | 3 + .../policy_regular/policy/mock_cache_manager.h | 5 +- .../policy_regular/policy/mock_policy_manager.h | 5 +- src/components/interfaces/MOBILE_API.xml | 68 ++++++++++--- .../policy_external/include/policy/cache_manager.h | 9 +- .../include/policy/cache_manager_interface.h | 9 +- .../include/policy/policy_manager_impl.h | 9 +- .../include/policy/policy_table/enums.h | 5 + .../policy/policy_external/src/cache_manager.cc | 15 ++- .../policy_external/src/policy_manager_impl.cc | 21 ++-- .../policy_external/src/policy_table/enums.cc | 5 + .../policy_regular/include/policy/cache_manager.h | 9 +- .../include/policy/cache_manager_interface.h | 9 +- .../include/policy/policy_manager_impl.h | 9 +- .../include/policy/policy_table/enums.h | 5 + .../policy/policy_regular/src/cache_manager.cc | 15 ++- .../policy_regular/src/policy_manager_impl.cc | 21 ++-- .../policy_regular/src/policy_table/enums.cc | 10 ++ 39 files changed, 480 insertions(+), 81 deletions(-) create mode 100644 src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/get_cloud_app_properties_request.h create mode 100644 src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/get_cloud_app_properties_response.h create mode 100644 src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/get_cloud_app_properties_request.cc create mode 100644 src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/get_cloud_app_properties_response.cc diff --git a/src/appMain/sdl_preloaded_pt.json b/src/appMain/sdl_preloaded_pt.json index 3c84fc96bd..a2fdb7740a 100644 --- a/src/appMain/sdl_preloaded_pt.json +++ b/src/appMain/sdl_preloaded_pt.json @@ -540,6 +540,11 @@ "FULL", "LIMITED"] }, + "GetCloudAppProperties":{ + "hmi_levels":["BACKGROUND", + "FULL", + "LIMITED"] + }, "GetVehicleData": { "hmi_levels": ["BACKGROUND", "FULL", diff --git a/src/components/application_manager/include/application_manager/application.h b/src/components/application_manager/include/application_manager/application.h index 7a59263299..15a79388c1 100644 --- a/src/components/application_manager/include/application_manager/application.h +++ b/src/components/application_manager/include/application_manager/application.h @@ -957,7 +957,7 @@ class Application : public virtual InitialApplicationData, * websocket open. * @return cloud app auth token */ - virtual const std::string& cloud_app_auth_token() const = 0; + virtual const std::string& auth_token() const = 0; /** * @brief Get cloud app tranpsport type. Defines the type of websocket @@ -994,7 +994,7 @@ class Application : public virtual InitialApplicationData, /** * @brief Set cloud app auth token */ - virtual void set_cloud_app_auth_token(const std::string& auth_token) = 0; + virtual void set_auth_token(const std::string& auth_token) = 0; /** * @brief Set cloud app transport type diff --git a/src/components/application_manager/include/application_manager/application_impl.h b/src/components/application_manager/include/application_manager/application_impl.h index 6d627d0c67..aedb973b31 100644 --- a/src/components/application_manager/include/application_manager/application_impl.h +++ b/src/components/application_manager/include/application_manager/application_impl.h @@ -420,7 +420,7 @@ class ApplicationImpl : public virtual Application, * websocket open. * @return cloud app auth token */ - const std::string& cloud_app_auth_token() const OVERRIDE; + const std::string& auth_token() const OVERRIDE; /** * @brief Get cloud app tranpsport type. Defines the type of websocket @@ -457,7 +457,7 @@ class ApplicationImpl : public virtual Application, /** * @brief Set cloud app auth token */ - void set_cloud_app_auth_token(const std::string& auth_token) OVERRIDE; + void set_auth_token(const std::string& auth_token) OVERRIDE; /** * @brief Set cloud app transport type diff --git a/src/components/application_manager/include/application_manager/policies/policy_handler.h b/src/components/application_manager/include/application_manager/policies/policy_handler.h index b912c489e4..2b6919eac0 100644 --- a/src/components/application_manager/include/application_manager/policies/policy_handler.h +++ b/src/components/application_manager/include/application_manager/policies/policy_handler.h @@ -433,7 +433,7 @@ class PolicyHandler : public PolicyHandlerInterface, * @param hybrid_app_preference Filled with the hybrid app preference for the * cloud application set by the user */ - void GetCloudAppParameters(const std::string& policy_app_id, + bool GetCloudAppParameters(const std::string& policy_app_id, bool& enabled, std::string& endpoint, std::string& certificate, 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 5e6a3bb377..aaca228eda 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 @@ -189,11 +189,12 @@ extern const char* blue; extern const char* display_layout; extern const char* icon_resumed; extern const char* enabled; -extern const char* cloud_app_auth_token; +extern const char* auth_token; extern const char* cloud_transport_type; extern const char* hybrid_app_preference; extern const char* is_cloud_application; extern const char* cloud_connection_status; +extern const char* endpoint; // PutFile extern const char* sync_file_name; diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/get_cloud_app_properties_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/get_cloud_app_properties_request.h new file mode 100644 index 0000000000..3d74a80dc2 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/get_cloud_app_properties_request.h @@ -0,0 +1,31 @@ +#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_GET_CLOUD_APP_PROPERTIES_REQUEST_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_GET_CLOUD_APP_PROPERTIES_REQUEST_H_ + +#include "application_manager/commands/command_request_impl.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +class GetCloudAppPropertiesRequest + : public app_mngr::commands::CommandRequestImpl { + public: + GetCloudAppPropertiesRequest( + const app_mngr::commands::MessageSharedPtr& message, + app_mngr::ApplicationManager& application_manager, + app_mngr::rpc_service::RPCService& rpc_service, + app_mngr::HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handler); + virtual ~GetCloudAppPropertiesRequest(); + virtual void Run(); + virtual void on_event(const app_mngr::event_engine::Event& event); + + private: + DISALLOW_COPY_AND_ASSIGN(GetCloudAppPropertiesRequest); +}; // GetCloudAppPropertiesRequest + +} // namespace commands +} // namespace sdl_rpc_plugin + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_GET_CLOUD_APP_PROPERTIES_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/get_cloud_app_properties_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/get_cloud_app_properties_response.h new file mode 100644 index 0000000000..f716c7dcb5 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/get_cloud_app_properties_response.h @@ -0,0 +1,31 @@ +#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_GET_CLOUD_APP_PROPERTIES_RESPONSE_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_GET_CLOUD_APP_PROPERTIES_RESPONSE_H_ + +#include "application_manager/commands/command_response_impl.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +class GetCloudAppPropertiesResponse + : public app_mngr::commands::CommandResponseImpl { + public: + GetCloudAppPropertiesResponse( + const app_mngr::commands::MessageSharedPtr& message, + app_mngr::ApplicationManager& application_manager, + app_mngr::rpc_service::RPCService& rpc_service, + app_mngr::HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handler); + virtual ~GetCloudAppPropertiesResponse(); + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(GetCloudAppPropertiesResponse); + +}; // GetCloudAppPropertiesResponse + +} // namespace commands +} // namespace sdl_rpc_plugin + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_GET_CLOUD_APP_PROPERTIES_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/get_cloud_app_properties_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/get_cloud_app_properties_request.cc new file mode 100644 index 0000000000..62c91ff3d5 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/get_cloud_app_properties_request.cc @@ -0,0 +1,110 @@ +#include "sdl_rpc_plugin/commands/mobile/get_cloud_app_properties_request.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +GetCloudAppPropertiesRequest::GetCloudAppPropertiesRequest( + const app_mngr::commands::MessageSharedPtr& message, + app_mngr::ApplicationManager& application_manager, + app_mngr::rpc_service::RPCService& rpc_service, + app_mngr::HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handler) + : CommandRequestImpl(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handler) {} + +GetCloudAppPropertiesRequest::~GetCloudAppPropertiesRequest() {} + +void GetCloudAppPropertiesRequest::Run() { + LOG4CXX_AUTO_TRACE(logger_); + ApplicationSharedPtr app = application_manager_.application(connection_key()); + + if (!app) { + LOG4CXX_ERROR(logger_, "Application is not registered"); + SendResponse(false, mobile_apis::Result::APPLICATION_NOT_REGISTERED); + return; + } + + std::string policy_app_id = + (*message_)[strings::msg_params][strings::app_id].asString(); + + bool enabled = true; + std::string endpoint; + std::string auth_token; + std::string certificate; + std::string cloud_transport_type; + std::string hybrid_app_preference; + + bool result = policy_handler_.GetCloudAppParameters(policy_app_id, + enabled, + endpoint, + certificate, + auth_token, + cloud_transport_type, + hybrid_app_preference); + + if (!result) { + SendResponse(false, + mobile_apis::Result::DATA_NOT_AVAILABLE, + "Cloud app does not exist on module"); + return; + } + + ApplicationSharedPtr cloud_app = + application_manager_.application_by_policy_id(policy_app_id); + std::string cloud_name; + if (cloud_app) { + cloud_name = cloud_app->name().AsMBString(); + } else { + policy::StringArray nicknames; + policy::StringArray app_hmi_types; + + policy_handler_.GetInitialAppData( + policy_app_id, &nicknames, &app_hmi_types); + + if (!nicknames.size()) { + LOG4CXX_ERROR(logger_, "Cloud App missing nickname"); + SendResponse(false, + mobile_apis::Result::DATA_NOT_AVAILABLE, + "No available nick names for the requested app"); + return; + } + cloud_name = nicknames[0]; + } + + smart_objects::SmartObject response_params(smart_objects::SmartType_Map); + smart_objects::SmartObject properties(smart_objects::SmartType_Map); + + properties[strings::app_name] = cloud_name; + properties[strings::app_id] = policy_app_id; + properties[strings::enabled] = enabled; + + if (!auth_token.empty()) { + properties[strings::auth_token] = auth_token; + } + if (!cloud_transport_type.empty()) { + properties[strings::cloud_transport_type] = cloud_transport_type; + } + if (!hybrid_app_preference.empty()) { + properties[strings::hybrid_app_preference] = hybrid_app_preference; + } + if (!endpoint.empty()) { + properties[strings::endpoint] = endpoint; + } + + response_params[strings::properties] = properties; + + SendResponse(true, mobile_apis::Result::SUCCESS, NULL, &response_params); +} + +void GetCloudAppPropertiesRequest::on_event( + const app_mngr::event_engine::Event& event) { + LOG4CXX_INFO(logger_, "GetCloudAppPropertiesRequest on_event"); +} + +} // namespace commands +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/get_cloud_app_properties_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/get_cloud_app_properties_response.cc new file mode 100644 index 0000000000..813a9e7006 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/get_cloud_app_properties_response.cc @@ -0,0 +1,31 @@ +#include "application_manager/application_manager.h" +#include "application_manager/rpc_service.h" +#include "sdl_rpc_plugin/commands/mobile/get_cloud_app_properties_response.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +GetCloudAppPropertiesResponse::GetCloudAppPropertiesResponse( + const app_mngr::commands::MessageSharedPtr& message, + app_mngr::ApplicationManager& application_manager, + app_mngr::rpc_service::RPCService& rpc_service, + app_mngr::HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handler) + : CommandResponseImpl(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handler) {} + +GetCloudAppPropertiesResponse::~GetCloudAppPropertiesResponse() {} + +void GetCloudAppPropertiesResponse::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + rpc_service_.SendMessageToMobile(message_); +} + +} // namespace commands +} // namespace sdl_rpc_plugins diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/mobile_command_factory.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/mobile_command_factory.cc index 8eab054be3..5ef76b59ef 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/mobile_command_factory.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/mobile_command_factory.cc @@ -126,6 +126,8 @@ #include "sdl_rpc_plugin/commands/mobile/send_haptic_data_response.h" #include "sdl_rpc_plugin/commands/mobile/set_cloud_app_properties_request.h" #include "sdl_rpc_plugin/commands/mobile/set_cloud_app_properties_response.h" +#include "sdl_rpc_plugin/commands/mobile/get_cloud_app_properties_request.h" +#include "sdl_rpc_plugin/commands/mobile/get_cloud_app_properties_response.h" #include "interfaces/MOBILE_API.h" CREATE_LOGGERPTR_GLOBAL(logger_, "ApplicationManager") @@ -345,6 +347,12 @@ CommandCreator& MobileCommandFactory::get_creator_factory( : factory .GetCreator(); } + case mobile_apis::FunctionID::GetCloudAppPropertiesID: { + return mobile_api::messageType::request == message_type + ? factory.GetCreator() + : factory + .GetCreator(); + } case mobile_apis::FunctionID::OnButtonEventID: { return factory.GetCreator(); } diff --git a/src/components/application_manager/src/application_impl.cc b/src/components/application_manager/src/application_impl.cc index 02bf5b49fe..63bc9be8c6 100644 --- a/src/components/application_manager/src/application_impl.cc +++ b/src/components/application_manager/src/application_impl.cc @@ -1167,7 +1167,7 @@ const std::string& ApplicationImpl::cloud_app_endpoint() const { return endpoint_; } -const std::string& ApplicationImpl::cloud_app_auth_token() const { +const std::string& ApplicationImpl::auth_token() const { return auth_token_; } @@ -1193,7 +1193,7 @@ void ApplicationImpl::set_cloud_app_endpoint(const std::string& endpoint) { endpoint_ = endpoint; } -void ApplicationImpl::set_cloud_app_auth_token(const std::string& auth_token) { +void ApplicationImpl::set_auth_token(const std::string& auth_token) { auth_token_ = auth_token; } diff --git a/src/components/application_manager/src/application_manager_impl.cc b/src/components/application_manager/src/application_manager_impl.cc index a9ae2e5ca7..364887ad3f 100644 --- a/src/components/application_manager/src/application_manager_impl.cc +++ b/src/components/application_manager/src/application_manager_impl.cc @@ -632,7 +632,7 @@ ApplicationSharedPtr ApplicationManagerImpl::RegisterApplication( // Set cloud app parameters application->set_cloud_app_endpoint((*it)->cloud_app_endpoint()); application->set_cloud_app_certificate((*it)->cloud_app_certificate()); - application->set_cloud_app_auth_token((*it)->cloud_app_auth_token()); + application->set_auth_token((*it)->auth_token()); application->set_cloud_app_transport_type( (*it)->cloud_app_transport_type()); application->set_hybrid_app_preference((*it)->hybrid_app_preference()); @@ -1105,7 +1105,7 @@ void ApplicationManagerImpl::CreatePendingApplication( application->set_hmi_application_id(GenerateNewHMIAppID()); application->set_cloud_app_endpoint(endpoint); - application->set_cloud_app_auth_token(auth_token); + application->set_auth_token(auth_token); application->set_cloud_app_transport_type(cloud_transport_type); application->set_hybrid_app_preference(hybrid_app_preference_enum); application->set_cloud_app_certificate(certificate); diff --git a/src/components/application_manager/src/policies/policy_handler.cc b/src/components/application_manager/src/policies/policy_handler.cc index 05aa9154ea..7d94e19b12 100644 --- a/src/components/application_manager/src/policies/policy_handler.cc +++ b/src/components/application_manager/src/policies/policy_handler.cc @@ -1869,7 +1869,7 @@ void PolicyHandler::GetEnabledCloudApps( policy_manager_->GetEnabledCloudApps(enabled_apps); } -void PolicyHandler::GetCloudAppParameters( +bool PolicyHandler::GetCloudAppParameters( const std::string& policy_app_id, bool& enabled, std::string& endpoint, @@ -1877,14 +1877,14 @@ void PolicyHandler::GetCloudAppParameters( std::string& auth_token, std::string& cloud_transport_type, std::string& hybrid_app_preference) const { - POLICY_LIB_CHECK_VOID(); - policy_manager_->GetCloudAppParameters(policy_app_id, - enabled, - endpoint, - certificate, - auth_token, - cloud_transport_type, - hybrid_app_preference); + POLICY_LIB_CHECK(false); + return policy_manager_->GetCloudAppParameters(policy_app_id, + enabled, + endpoint, + certificate, + auth_token, + cloud_transport_type, + hybrid_app_preference); } const bool PolicyHandler::CheckCloudAppEnabled( @@ -1915,40 +1915,51 @@ void PolicyHandler::OnSetCloudAppProperties( << strings::msg_params); return; } - const smart_objects::SmartObject& msg_params = message[strings::msg_params]; - if (!msg_params.keyExists(strings::app_id)) { + if (!message[strings::msg_params].keyExists(strings::properties)) { + LOG4CXX_ERROR(logger_, + "Message does not contain app properties " + << strings::msg_params); + return; + } + + const smart_objects::SmartObject& properties = + message[strings::msg_params][strings::properties]; + if (!properties.keyExists(strings::app_id)) { LOG4CXX_ERROR(logger_, "Message does not contain mandatory parameter " << strings::app_id); return; } - std::string policy_app_id(msg_params[strings::app_id].asString()); + std::string policy_app_id(properties[strings::app_id].asString()); policy_manager_->InitCloudApp(policy_app_id); bool auth_token_update = false; - if (msg_params.keyExists(strings::enabled)) { - bool enabled = msg_params[strings::enabled].asBool(); + if (properties.keyExists(strings::enabled)) { + bool enabled = properties[strings::enabled].asBool(); policy_manager_->SetCloudAppEnabled(policy_app_id, enabled); auth_token_update = enabled; application_manager_.RefreshCloudAppInformation(); } - if (msg_params.keyExists(strings::cloud_app_auth_token)) { - std::string auth_token = - msg_params[strings::cloud_app_auth_token].asString(); + if (properties.keyExists(strings::auth_token)) { + std::string auth_token = properties[strings::auth_token].asString(); policy_manager_->SetAppAuthToken(policy_app_id, auth_token); auth_token_update = true; } - if (msg_params.keyExists(strings::cloud_transport_type)) { + if (properties.keyExists(strings::cloud_transport_type)) { policy_manager_->SetAppCloudTransportType( - policy_app_id, msg_params[strings::cloud_transport_type].asString()); + policy_app_id, properties[strings::cloud_transport_type].asString()); + } + if (properties.keyExists(strings::endpoint)) { + policy_manager_->SetAppEndpoint(policy_app_id, + properties[strings::endpoint].asString()); } - if (msg_params.keyExists(strings::hybrid_app_preference)) { + if (properties.keyExists(strings::hybrid_app_preference)) { std::string hybrid_app_preference; mobile_apis::HybridAppPreference::eType value = static_cast( - msg_params[strings::hybrid_app_preference].asUInt()); + properties[strings::hybrid_app_preference].asUInt()); smart_objects::EnumConversionHelper< mobile_apis::HybridAppPreference::eType>:: EnumToString(value, &hybrid_app_preference); diff --git a/src/components/application_manager/src/smart_object_keys.cc b/src/components/application_manager/src/smart_object_keys.cc index 70581466eb..109739c359 100644 --- a/src/components/application_manager/src/smart_object_keys.cc +++ b/src/components/application_manager/src/smart_object_keys.cc @@ -156,11 +156,12 @@ const char* blue = "blue"; const char* display_layout = "displayLayout"; const char* icon_resumed = "iconResumed"; const char* enabled = "enabled"; -const char* cloud_app_auth_token = "cloudAppAuthToken"; +const char* auth_token = "authToken"; const char* cloud_transport_type = "cloudTransportType"; const char* hybrid_app_preference = "hybridAppPreference"; const char* is_cloud_application = "isCloudApplication"; const char* cloud_connection_status = "cloudConnectionStatus"; +const char* endpoint = "endpoint"; // PutFile const char* sync_file_name = "syncFileName"; diff --git a/src/components/application_manager/test/application_manager_impl_test.cc b/src/components/application_manager/test/application_manager_impl_test.cc index 4ea44e5aca..d4e73ef492 100644 --- a/src/components/application_manager/test/application_manager_impl_test.cc +++ b/src/components/application_manager/test/application_manager_impl_test.cc @@ -1428,8 +1428,7 @@ TEST_F(ApplicationManagerImplTest, ON_CALL(*waiting_app, device()).WillByDefault(Return(kDeviceId)); EXPECT_CALL(*waiting_app, cloud_app_endpoint()) .WillOnce(ReturnRef(kEndpoint)); - EXPECT_CALL(*waiting_app, cloud_app_auth_token()) - .WillOnce(ReturnRef(kAuthToken)); + EXPECT_CALL(*waiting_app, auth_token()).WillOnce(ReturnRef(kAuthToken)); EXPECT_CALL(*waiting_app, cloud_app_certificate()) .WillOnce(ReturnRef(kCertificate)); EXPECT_CALL(*waiting_app, cloud_app_transport_type()) @@ -1482,7 +1481,7 @@ TEST_F(ApplicationManagerImplTest, EXPECT_EQ(APIVersion::kAPIV3, application->version().max_supported_api_version); EXPECT_EQ(kEndpoint, application->cloud_app_endpoint()); - EXPECT_EQ(kAuthToken, application->cloud_app_auth_token()); + EXPECT_EQ(kAuthToken, application->auth_token()); EXPECT_EQ(kCertificate, application->cloud_app_certificate()); EXPECT_EQ(kTransportType, application->cloud_app_transport_type()); EXPECT_EQ(kHybridAppPreference, application->hybrid_app_preference()); 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 d5b3752936..36d20f227d 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 @@ -343,14 +343,14 @@ class MockApplication : public ::application_manager::Application { MOCK_CONST_METHOD0(is_remote_control_supported, bool()); MOCK_METHOD1(set_remote_control_supported, void(const bool allow)); MOCK_CONST_METHOD0(cloud_app_endpoint, const std::string&()); - MOCK_CONST_METHOD0(cloud_app_auth_token, const std::string&()); + MOCK_CONST_METHOD0(auth_token, const std::string&()); MOCK_CONST_METHOD0(cloud_app_transport_type, const std::string&()); MOCK_CONST_METHOD0(hybrid_app_preference, const mobile_apis::HybridAppPreference::eType&()); MOCK_CONST_METHOD0(cloud_app_certificate, const std::string&()); MOCK_CONST_METHOD0(is_cloud_app, bool()); MOCK_METHOD1(set_cloud_app_endpoint, void(const std::string& endpoint)); - MOCK_METHOD1(set_cloud_app_auth_token, void(const std::string& auth_token)); + MOCK_METHOD1(set_auth_token, void(const std::string& auth_token)); MOCK_METHOD1(set_cloud_app_transport_type, void(const std::string& transport_type)); MOCK_METHOD1(set_hybrid_app_preference, diff --git a/src/components/include/application_manager/policies/policy_handler_interface.h b/src/components/include/application_manager/policies/policy_handler_interface.h index c9feacabd4..8dfa1b133a 100644 --- a/src/components/include/application_manager/policies/policy_handler_interface.h +++ b/src/components/include/application_manager/policies/policy_handler_interface.h @@ -472,7 +472,7 @@ class PolicyHandlerInterface { * @param hybrid_app_preference Filled with the hybrid app preference for the * cloud application set by the user */ - virtual void GetCloudAppParameters( + virtual bool GetCloudAppParameters( const std::string& policy_app_id, bool& enabled, std::string& endpoint, diff --git a/src/components/include/policy/policy_external/policy/policy_manager.h b/src/components/include/policy/policy_external/policy/policy_manager.h index f342c2a07a..61ad6b9a91 100644 --- a/src/components/include/policy/policy_external/policy/policy_manager.h +++ b/src/components/include/policy/policy_external/policy/policy_manager.h @@ -555,7 +555,7 @@ class PolicyManager : public usage_statistics::StatisticsManager { * @param hybrid_app_preference Filled with the hybrid app preference for the * cloud application set by the user */ - virtual void GetCloudAppParameters( + virtual bool GetCloudAppParameters( const std::string& policy_app_id, bool& enabled, std::string& endpoint, @@ -592,6 +592,13 @@ class PolicyManager : public usage_statistics::StatisticsManager { const std::string& policy_app_id, const std::string& cloud_transport_type) = 0; + /** + * @brief Set a cloud app's endpoint url + * @param endpoint URL for websocket connection + */ + virtual void SetAppEndpoint(const std::string& policy_app_id, + const std::string& endpoint) = 0; + /** * @brief Set the user preference for how a hybrid (cloud and mobile) app * should be used diff --git a/src/components/include/policy/policy_regular/policy/policy_manager.h b/src/components/include/policy/policy_regular/policy/policy_manager.h index 6876611b3f..898c9ff2c6 100644 --- a/src/components/include/policy/policy_regular/policy/policy_manager.h +++ b/src/components/include/policy/policy_regular/policy/policy_manager.h @@ -535,7 +535,7 @@ class PolicyManager : public usage_statistics::StatisticsManager { * @param hybrid_app_preference Filled with the hybrid app preference for the * cloud application set by the user */ - virtual void GetCloudAppParameters( + virtual bool GetCloudAppParameters( const std::string& policy_app_id, bool& enabled, std::string& endpoint, @@ -573,6 +573,13 @@ class PolicyManager : public usage_statistics::StatisticsManager { const std::string& policy_app_id, const std::string& cloud_transport_type) = 0; + /** + * @brief Set a cloud app's endpoint url + * @param endpoint URL for websocket connection + */ + virtual void SetAppEndpoint(const std::string& policy_app_id, + const std::string& endpoint) = 0; + /** * @brief Set the user preference for how a hybrid (cloud and mobile) app * should be used diff --git a/src/components/include/test/application_manager/policies/mock_policy_handler_interface.h b/src/components/include/test/application_manager/policies/mock_policy_handler_interface.h index 3d3fb31af7..0983e8eedb 100644 --- a/src/components/include/test/application_manager/policies/mock_policy_handler_interface.h +++ b/src/components/include/test/application_manager/policies/mock_policy_handler_interface.h @@ -219,7 +219,7 @@ class MockPolicyHandlerInterface : public policy::PolicyHandlerInterface { MOCK_CONST_METHOD1(CheckCloudAppEnabled, const bool(const std::string& policy_app_id)); MOCK_CONST_METHOD7(GetCloudAppParameters, - void(const std::string& policy_app_id, + bool(const std::string& policy_app_id, bool& enabled, std::string& endpoint, std::string& certificate, diff --git a/src/components/include/test/policy/policy_external/policy/mock_cache_manager.h b/src/components/include/test/policy/policy_external/policy/mock_cache_manager.h index 82d4a866c4..d47a88fe54 100644 --- a/src/components/include/test/policy/policy_external/policy/mock_cache_manager.h +++ b/src/components/include/test/policy/policy_external/policy/mock_cache_manager.h @@ -79,7 +79,7 @@ class MockCacheManagerInterface : public ::policy::CacheManagerInterface { MOCK_CONST_METHOD1(GetEnabledCloudApps, void(std::vector& enabled_apps)); MOCK_CONST_METHOD7(GetCloudAppParameters, - void(const std::string& policy_app_id, + bool(const std::string& policy_app_id, bool& enabled, std::string& endpoint, std::string& certificate, @@ -95,6 +95,9 @@ class MockCacheManagerInterface : public ::policy::CacheManagerInterface { MOCK_METHOD2(SetAppCloudTransportType, void(const std::string& policy_app_id, const std::string& cloud_transport_type)); + MOCK_METHOD2(SetAppEndpoint, + void(const std::string& policy_app_id, + const std::string& endpoint)); MOCK_METHOD2(SetHybridAppPreference, void(const std::string& policy_app_id, const std::string& hybrid_app_preference)); diff --git a/src/components/include/test/policy/policy_external/policy/mock_policy_manager.h b/src/components/include/test/policy/policy_external/policy/mock_policy_manager.h index 9fe96e1544..9b21d95f1b 100644 --- a/src/components/include/test/policy/policy_external/policy/mock_policy_manager.h +++ b/src/components/include/test/policy/policy_external/policy/mock_policy_manager.h @@ -204,6 +204,9 @@ class MockPolicyManager : public PolicyManager { MOCK_METHOD2(SetAppCloudTransportType, void(const std::string& policy_app_id, const std::string& cloud_transport_type)); + MOCK_METHOD2(SetAppEndpoint, + void(const std::string& policy_app_id, + const std::string& endpoint)); MOCK_METHOD2(SetHybridAppPreference, void(const std::string& policy_app_id, const std::string& hybrid_app_preference)); diff --git a/src/components/include/test/policy/policy_regular/policy/mock_cache_manager.h b/src/components/include/test/policy/policy_regular/policy/mock_cache_manager.h index e7c9502db9..83774ab7cd 100644 --- a/src/components/include/test/policy/policy_regular/policy/mock_cache_manager.h +++ b/src/components/include/test/policy/policy_regular/policy/mock_cache_manager.h @@ -66,7 +66,7 @@ class MockCacheManagerInterface : public CacheManagerInterface { MOCK_CONST_METHOD1(GetEnabledCloudApps, void(std::vector& enabled_apps)); MOCK_CONST_METHOD7(GetCloudAppParameters, - void(const std::string& policy_app_id, + bool(const std::string& policy_app_id, bool& enabled, std::string& endpoint, std::string& certificate, @@ -82,6 +82,9 @@ class MockCacheManagerInterface : public CacheManagerInterface { MOCK_METHOD2(SetAppCloudTransportType, void(const std::string& policy_app_id, const std::string& cloud_transport_type)); + MOCK_METHOD2(SetAppEndpoint, + void(const std::string& policy_app_id, + const std::string& endpoint)); MOCK_METHOD2(SetHybridAppPreference, void(const std::string& policy_app_id, const std::string& hybrid_app_preference)); diff --git a/src/components/include/test/policy/policy_regular/policy/mock_policy_manager.h b/src/components/include/test/policy/policy_regular/policy/mock_policy_manager.h index 7283397187..401db5586f 100644 --- a/src/components/include/test/policy/policy_regular/policy/mock_policy_manager.h +++ b/src/components/include/test/policy/policy_regular/policy/mock_policy_manager.h @@ -184,7 +184,7 @@ class MockPolicyManager : public PolicyManager { MOCK_CONST_METHOD1(GetEnabledCloudApps, void(std::vector& enabled_apps)); MOCK_CONST_METHOD7(GetCloudAppParameters, - void(const std::string& policy_app_id, + bool(const std::string& policy_app_id, bool& enabled, std::string& endpoint, std::string& certificate, @@ -200,6 +200,9 @@ class MockPolicyManager : public PolicyManager { MOCK_METHOD2(SetAppCloudTransportType, void(const std::string& policy_app_id, const std::string& cloud_transport_type)); + MOCK_METHOD2(SetAppEndpoint, + void(const std::string& policy_app_id, + const std::string& endpoint)); MOCK_METHOD2(SetHybridAppPreference, void(const std::string& policy_app_id, const std::string& hybrid_app_preference)); diff --git a/src/components/interfaces/MOBILE_API.xml b/src/components/interfaces/MOBILE_API.xml index 66f5a19208..33613d2eca 100644 --- a/src/components/interfaces/MOBILE_API.xml +++ b/src/components/interfaces/MOBILE_API.xml @@ -552,6 +552,24 @@ + + + + + If true, cloud app will be included in HMI RPC UpdateAppList + + + Used to authenticate websocket connection on app activation + + + Specifies the connection type Core should use + + + Specifies the user preference to use the cloud app version or mobile app version when both are available + + + + Defines the hard (physical) and soft (touchscreen) buttons available from the module @@ -2618,6 +2636,7 @@ + diff --git a/src/components/policy/policy_external/include/policy/cache_manager.h b/src/components/policy/policy_external/include/policy/cache_manager.h index 90783b7a46..25adbe19f7 100644 --- a/src/components/policy/policy_external/include/policy/cache_manager.h +++ b/src/components/policy/policy_external/include/policy/cache_manager.h @@ -182,7 +182,7 @@ class CacheManager : public CacheManagerInterface { * @param hybrid_app_preference Filled with the hybrid app preference for the * cloud application set by the user */ - virtual void GetCloudAppParameters(const std::string& policy_app_id, + virtual bool GetCloudAppParameters(const std::string& policy_app_id, bool& enabled, std::string& endpoint, std::string& certificate, @@ -220,6 +220,13 @@ class CacheManager : public CacheManagerInterface { const std::string& policy_app_id, const std::string& cloud_transport_type); + /** + * @brief Set a cloud app's endpoint url + * @param endpoint URL for websocket connection + */ + virtual void SetAppEndpoint(const std::string& policy_app_id, + const std::string& endpoint); + /** * @brief Set the user preference for how a hybrid (cloud and mobile) app * should be used diff --git a/src/components/policy/policy_external/include/policy/cache_manager_interface.h b/src/components/policy/policy_external/include/policy/cache_manager_interface.h index 58baf5ce99..86b4373650 100644 --- a/src/components/policy/policy_external/include/policy/cache_manager_interface.h +++ b/src/components/policy/policy_external/include/policy/cache_manager_interface.h @@ -189,7 +189,7 @@ class CacheManagerInterface { * @param hybrid_app_preference Filled with the hybrid app preference for the * cloud application set by the user */ - virtual void GetCloudAppParameters( + virtual bool GetCloudAppParameters( const std::string& policy_app_id, bool& enabled, std::string& endpoint, @@ -228,6 +228,13 @@ class CacheManagerInterface { const std::string& policy_app_id, const std::string& cloud_transport_type) = 0; + /** + * @brief Set a cloud app's endpoint url + * @param endpoint URL for websocket connection + */ + virtual void SetAppEndpoint(const std::string& policy_app_id, + const std::string& endpoint) = 0; + /** * @brief Set the user preference for how a hybrid (cloud and mobile) app * should be used diff --git a/src/components/policy/policy_external/include/policy/policy_manager_impl.h b/src/components/policy/policy_external/include/policy/policy_manager_impl.h index caa1b0dc95..35fd3a1a7e 100644 --- a/src/components/policy/policy_external/include/policy/policy_manager_impl.h +++ b/src/components/policy/policy_external/include/policy/policy_manager_impl.h @@ -603,7 +603,7 @@ class PolicyManagerImpl : public PolicyManager { * @param hybrid_app_preference Filled with the hybrid app preference for the * cloud application set by the user */ - void GetCloudAppParameters(const std::string& policy_app_id, + bool GetCloudAppParameters(const std::string& policy_app_id, bool& enabled, std::string& endpoint, std::string& certificate, @@ -639,6 +639,13 @@ class PolicyManagerImpl : public PolicyManager { const std::string& policy_app_id, const std::string& cloud_transport_type) OVERRIDE; + /** + * @brief Set a cloud app's endpoint url + * @param endpoint URL for websocket connection + */ + void SetAppEndpoint(const std::string& policy_app_id, + const std::string& endpoint) OVERRIDE; + /** * @brief Set the user preference for how a hybrid (cloud and mobile) app * should be used diff --git a/src/components/policy/policy_external/include/policy/policy_table/enums.h b/src/components/policy/policy_external/include/policy/policy_table/enums.h index 2477d7eb04..a37a9d6b5e 100644 --- a/src/components/policy/policy_external/include/policy/policy_table/enums.h +++ b/src/components/policy/policy_external/include/policy/policy_table/enums.h @@ -446,6 +446,11 @@ enum FunctionID { */ SetCloudAppPropertiesID = 50, + /** + * @brief GetCloudAppPropertiesID. + */ + GetCloudAppPropertiesID = 51, + /** * @brief OnHMIStatusID. */ diff --git a/src/components/policy/policy_external/src/cache_manager.cc b/src/components/policy/policy_external/src/cache_manager.cc index 0220d38b07..b0ff7f12d2 100644 --- a/src/components/policy/policy_external/src/cache_manager.cc +++ b/src/components/policy/policy_external/src/cache_manager.cc @@ -1403,7 +1403,7 @@ void CacheManager::GetEnabledCloudApps( } } -void CacheManager::GetCloudAppParameters( +bool CacheManager::GetCloudAppParameters( const std::string& policy_app_id, bool& enabled, std::string& endpoint, @@ -1432,7 +1432,9 @@ void CacheManager::GetCloudAppParameters( ? EnumToJsonString(*app_policy.hybrid_app_preference) : std::string(); enabled = app_policy.enabled.is_initialized() && *app_policy.enabled; + return true; } + return false; } void CacheManager::InitCloudApp(const std::string& policy_app_id) { @@ -1487,6 +1489,17 @@ void CacheManager::SetAppCloudTransportType( } } +void CacheManager::SetAppEndpoint(const std::string& policy_app_id, + const std::string& endpoint) { + policy_table::ApplicationPolicies& policies = + pt_->policy_table.app_policies_section.apps; + policy_table::ApplicationPolicies::iterator policy_iter = + policies.find(policy_app_id); + if (policies.end() != policy_iter) { + *(*policy_iter).second.endpoint = endpoint; + } +} + void CacheManager::SetHybridAppPreference( const std::string& policy_app_id, const std::string& hybrid_app_preference) { diff --git a/src/components/policy/policy_external/src/policy_manager_impl.cc b/src/components/policy/policy_external/src/policy_manager_impl.cc index 23101438cb..37f5ab666f 100644 --- a/src/components/policy/policy_external/src/policy_manager_impl.cc +++ b/src/components/policy/policy_external/src/policy_manager_impl.cc @@ -741,7 +741,7 @@ void PolicyManagerImpl::GetEnabledCloudApps( cache_->GetEnabledCloudApps(enabled_apps); } -void PolicyManagerImpl::GetCloudAppParameters( +bool PolicyManagerImpl::GetCloudAppParameters( const std::string& policy_app_id, bool& enabled, std::string& endpoint, @@ -749,13 +749,13 @@ void PolicyManagerImpl::GetCloudAppParameters( std::string& auth_token, std::string& cloud_transport_type, std::string& hybrid_app_preference) const { - cache_->GetCloudAppParameters(policy_app_id, - enabled, - endpoint, - certificate, - auth_token, - cloud_transport_type, - hybrid_app_preference); + return cache_->GetCloudAppParameters(policy_app_id, + enabled, + endpoint, + certificate, + auth_token, + cloud_transport_type, + hybrid_app_preference); } void PolicyManagerImpl::InitCloudApp(const std::string& policy_app_id) { @@ -777,6 +777,11 @@ void PolicyManagerImpl::SetAppCloudTransportType( cache_->SetAppCloudTransportType(policy_app_id, cloud_transport_type); } +void PolicyManagerImpl::SetAppEndpoint(const std::string& policy_app_id, + const std::string& endpoint) { + cache_->SetAppEndpoint(policy_app_id, endpoint); +} + void PolicyManagerImpl::SetHybridAppPreference( const std::string& policy_app_id, const std::string& hybrid_app_preference) { diff --git a/src/components/policy/policy_external/src/policy_table/enums.cc b/src/components/policy/policy_external/src/policy_table/enums.cc index 9cc838bd82..aa4b8e55d1 100644 --- a/src/components/policy/policy_external/src/policy_table/enums.cc +++ b/src/components/policy/policy_external/src/policy_table/enums.cc @@ -1134,6 +1134,11 @@ bool EnumFromJsonString(const std::string& literal, FunctionID* result) { return true; } + if ("GetCloudAppProperties" == literal) { + *result = GetCloudAppPropertiesID; + return true; + } + if ("OnHMIStatus" == literal) { *result = OnHMIStatusID; return true; diff --git a/src/components/policy/policy_regular/include/policy/cache_manager.h b/src/components/policy/policy_regular/include/policy/cache_manager.h index d23145994a..3b3c941b20 100644 --- a/src/components/policy/policy_regular/include/policy/cache_manager.h +++ b/src/components/policy/policy_regular/include/policy/cache_manager.h @@ -170,7 +170,7 @@ class CacheManager : public CacheManagerInterface { * @param hybrid_app_preference Filled with the hybrid app preference for the * cloud application set by the user */ - virtual void GetCloudAppParameters(const std::string& policy_app_id, + virtual bool GetCloudAppParameters(const std::string& policy_app_id, bool& enabled, std::string& endpoint, std::string& certificate, @@ -208,6 +208,13 @@ class CacheManager : public CacheManagerInterface { const std::string& policy_app_id, const std::string& cloud_transport_type); + /** + * @brief Set a cloud app's endpoint url + * @param endpoint URL for websocket connection + */ + virtual void SetAppEndpoint(const std::string& policy_app_id, + const std::string& endpoint); + /** * @brief Set the user preference for how a hybrid (cloud and mobile) app * should be used diff --git a/src/components/policy/policy_regular/include/policy/cache_manager_interface.h b/src/components/policy/policy_regular/include/policy/cache_manager_interface.h index ea59a4ef62..a50127d141 100644 --- a/src/components/policy/policy_regular/include/policy/cache_manager_interface.h +++ b/src/components/policy/policy_regular/include/policy/cache_manager_interface.h @@ -175,7 +175,7 @@ class CacheManagerInterface { * @param hybrid_app_preference Filled with the hybrid app preference for the * cloud application set by the user */ - virtual void GetCloudAppParameters( + virtual bool GetCloudAppParameters( const std::string& policy_app_id, bool& enabled, std::string& endpoint, @@ -214,6 +214,13 @@ class CacheManagerInterface { const std::string& policy_app_id, const std::string& cloud_transport_type) = 0; + /** + * @brief Set a cloud app's endpoint url + * @param endpoint URL for websocket connection + */ + virtual void SetAppEndpoint(const std::string& policy_app_id, + const std::string& endpoint) = 0; + /** * @brief Set the user preference for how a hybrid (cloud and mobile) app * should be used diff --git a/src/components/policy/policy_regular/include/policy/policy_manager_impl.h b/src/components/policy/policy_regular/include/policy/policy_manager_impl.h index 779bea729d..357d3f1c87 100644 --- a/src/components/policy/policy_regular/include/policy/policy_manager_impl.h +++ b/src/components/policy/policy_regular/include/policy/policy_manager_impl.h @@ -597,7 +597,7 @@ class PolicyManagerImpl : public PolicyManager { * @param hybrid_app_preference Filled with the hybrid app preference for the * cloud application set by the user */ - void GetCloudAppParameters(const std::string& policy_app_id, + bool GetCloudAppParameters(const std::string& policy_app_id, bool& enabled, std::string& endpoint, std::string& certificate, @@ -634,6 +634,13 @@ class PolicyManagerImpl : public PolicyManager { const std::string& policy_app_id, const std::string& cloud_transport_type) OVERRIDE; + /** + * @brief Set a cloud app's endpoint url + * @param endpoint URL for websocket connection + */ + void SetAppEndpoint(const std::string& policy_app_id, + const std::string& endpoint) OVERRIDE; + /** * @brief Set the user preference for how a hybrid (cloud and mobile) app * should be used diff --git a/src/components/policy/policy_regular/include/policy/policy_table/enums.h b/src/components/policy/policy_regular/include/policy/policy_table/enums.h index 563e822a36..a32060d9bc 100644 --- a/src/components/policy/policy_regular/include/policy/policy_table/enums.h +++ b/src/components/policy/policy_regular/include/policy/policy_table/enums.h @@ -431,6 +431,11 @@ enum FunctionID { */ SetCloudAppPropertiesID = 50, + /** + * @brief GetCloudAppPropertiesID. + */ + GetCloudAppPropertiesID = 51, + /** * @brief OnHMIStatusID. */ diff --git a/src/components/policy/policy_regular/src/cache_manager.cc b/src/components/policy/policy_regular/src/cache_manager.cc index 677ea66454..1a0a908f5d 100644 --- a/src/components/policy/policy_regular/src/cache_manager.cc +++ b/src/components/policy/policy_regular/src/cache_manager.cc @@ -696,7 +696,7 @@ void CacheManager::GetEnabledCloudApps( } } -void CacheManager::GetCloudAppParameters( +bool CacheManager::GetCloudAppParameters( const std::string& policy_app_id, bool& enabled, std::string& endpoint, @@ -725,7 +725,9 @@ void CacheManager::GetCloudAppParameters( ? EnumToJsonString(*app_policy.hybrid_app_preference) : std::string(); enabled = app_policy.enabled.is_initialized() && *app_policy.enabled; + return true; } + return false; } void CacheManager::InitCloudApp(const std::string& policy_app_id) { @@ -782,6 +784,17 @@ void CacheManager::SetAppCloudTransportType( } } +void CacheManager::SetAppEndpoint(const std::string& policy_app_id, + const std::string& endpoint) { + policy_table::ApplicationPolicies& policies = + pt_->policy_table.app_policies_section.apps; + policy_table::ApplicationPolicies::iterator policy_iter = + policies.find(policy_app_id); + if (policies.end() != policy_iter) { + *(*policy_iter).second.endpoint = endpoint; + } +} + void CacheManager::SetHybridAppPreference( const std::string& policy_app_id, const std::string& hybrid_app_preference) { diff --git a/src/components/policy/policy_regular/src/policy_manager_impl.cc b/src/components/policy/policy_regular/src/policy_manager_impl.cc index b09478bba1..ae07b5529c 100644 --- a/src/components/policy/policy_regular/src/policy_manager_impl.cc +++ b/src/components/policy/policy_regular/src/policy_manager_impl.cc @@ -560,7 +560,7 @@ void PolicyManagerImpl::GetEnabledCloudApps( cache_->GetEnabledCloudApps(enabled_apps); } -void PolicyManagerImpl::GetCloudAppParameters( +bool PolicyManagerImpl::GetCloudAppParameters( const std::string& policy_app_id, bool& enabled, std::string& endpoint, @@ -568,13 +568,13 @@ void PolicyManagerImpl::GetCloudAppParameters( std::string& auth_token, std::string& cloud_transport_type, std::string& hybrid_app_preference) const { - cache_->GetCloudAppParameters(policy_app_id, - enabled, - endpoint, - certificate, - auth_token, - cloud_transport_type, - hybrid_app_preference); + return cache_->GetCloudAppParameters(policy_app_id, + enabled, + endpoint, + certificate, + auth_token, + cloud_transport_type, + hybrid_app_preference); } void PolicyManagerImpl::InitCloudApp(const std::string& policy_app_id) { @@ -596,6 +596,11 @@ void PolicyManagerImpl::SetAppCloudTransportType( cache_->SetAppCloudTransportType(policy_app_id, cloud_transport_type); } +void PolicyManagerImpl::SetAppEndpoint(const std::string& policy_app_id, + const std::string& endpoint) { + cache_->SetAppEndpoint(policy_app_id, endpoint); +} + void PolicyManagerImpl::SetHybridAppPreference( const std::string& policy_app_id, const std::string& hybrid_app_preference) { diff --git a/src/components/policy/policy_regular/src/policy_table/enums.cc b/src/components/policy/policy_regular/src/policy_table/enums.cc index 91d0a6990f..195213f844 100644 --- a/src/components/policy/policy_regular/src/policy_table/enums.cc +++ b/src/components/policy/policy_regular/src/policy_table/enums.cc @@ -849,6 +849,8 @@ bool IsValidEnum(FunctionID val) { return true; case SetCloudAppPropertiesID: return true; + case GetCloudAppPropertiesID: + return true; case OnHMIStatusID: return true; case OnAppInterfaceUnregisteredID: @@ -998,6 +1000,8 @@ const char* EnumToJsonString(FunctionID val) { return "SendHapticData"; case SetCloudAppPropertiesID: return "SetCloudAppProperties"; + case GetCloudAppPropertiesID: + return "GetCloudAppProperties"; case OnHMIStatusID: return "OnHMIStatus"; case OnAppInterfaceUnregisteredID: @@ -1287,11 +1291,17 @@ bool EnumFromJsonString(const std::string& literal, FunctionID* result) { *result = SendHapticDataID; return true; } + if ("SetCloudAppProperties" == literal) { *result = SetCloudAppPropertiesID; return true; } + if ("GetCloudAppProperties" == literal) { + *result = GetCloudAppPropertiesID; + return true; + } + if ("OnHMIStatus" == literal) { *result = OnHMIStatusID; return true; -- cgit v1.2.1 From 62f9332802915a096e2bdd8dbeb2d507840e9c85 Mon Sep 17 00:00:00 2001 From: JackLivio Date: Fri, 1 Mar 2019 16:26:27 -0500 Subject: update regex --- .../transport_manager/src/cloud/cloud_websocket_transport_adapter.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/transport_manager/src/cloud/cloud_websocket_transport_adapter.cc b/src/components/transport_manager/src/cloud/cloud_websocket_transport_adapter.cc index 8a7acaa5f7..410d54a407 100644 --- a/src/components/transport_manager/src/cloud/cloud_websocket_transport_adapter.cc +++ b/src/components/transport_manager/src/cloud/cloud_websocket_transport_adapter.cc @@ -87,7 +87,7 @@ void CloudWebsocketTransportAdapter::CreateDevice(const std::string& uid) { // Extract host and port from endpoint string boost::regex group_pattern( - "(wss?:\\/\\/)([A-Z\\d\\.-]{2,}\\.?([A-Z]{2,})?)(:)(\\d{2,4})(\\/)(((([A-Z\\d\\.-]{1,})(\\/)?){1,})?){1,}"); + "(wss?:\\/\\/)([A-Z\\d\\.-]{2,}\\.?([A-Z]{2,})?)(:)(\\d{2,5})(\\/[A-Z\\d\\.-]+)*\\/?"); boost::smatch results; std::string host = ""; -- cgit v1.2.1 From ba7bd475d6099d8a1f3d4c9b2de9317070c84718 Mon Sep 17 00:00:00 2001 From: JackLivio Date: Fri, 1 Mar 2019 16:28:38 -0500 Subject: Remove URI Scheme and URI Prefix (#2828) * Remove URI Scheme and URI Prefix * Remove ValidateManifest() * Style --- .../include/application_manager/smart_object_keys.h | 2 -- .../commands/hmi/as_publish_app_service_request.h | 2 -- .../commands/mobile/publish_app_service_request.h | 2 -- .../commands/hmi/as_publish_app_service_request.cc | 20 -------------------- .../commands/mobile/publish_app_service_request.cc | 18 ------------------ .../application_manager/src/smart_object_keys.cc | 2 -- src/components/interfaces/HMI_API.xml | 8 -------- src/components/interfaces/MOBILE_API.xml | 8 -------- 8 files changed, 62 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 78f336fb64..5054536883 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 @@ -308,8 +308,6 @@ extern const char* service_name; extern const char* service_type; extern const char* service_icon; extern const char* allow_app_consumers; -extern const char* uri_prefix; -extern const char* uri_scheme; extern const char* rpc_spec_version; extern const char* handled_rpcs; extern const char* media_service_manifest; diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/hmi/as_publish_app_service_request.h b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/hmi/as_publish_app_service_request.h index ec2c00a714..4433444602 100644 --- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/hmi/as_publish_app_service_request.h +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/hmi/as_publish_app_service_request.h @@ -69,8 +69,6 @@ class ASPublishAppServiceRequest : public app_mngr::commands::RequestFromHMI { virtual void Run(); private: - bool ValidateManifest(smart_objects::SmartObject& manifest); - DISALLOW_COPY_AND_ASSIGN(ASPublishAppServiceRequest); }; diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/mobile/publish_app_service_request.h b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/mobile/publish_app_service_request.h index 72e4f1c629..d70f279658 100644 --- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/mobile/publish_app_service_request.h +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/mobile/publish_app_service_request.h @@ -68,8 +68,6 @@ class PublishAppServiceRequest : public app_mngr::commands::CommandRequestImpl { virtual void Run(); private: - bool ValidateManifest(smart_objects::SmartObject& manifest); - DISALLOW_COPY_AND_ASSIGN(PublishAppServiceRequest); }; diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_publish_app_service_request.cc b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_publish_app_service_request.cc index 5e20ca20d1..b816016fa7 100644 --- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_publish_app_service_request.cc +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_publish_app_service_request.cc @@ -51,23 +51,6 @@ ASPublishAppServiceRequest::ASPublishAppServiceRequest( ASPublishAppServiceRequest::~ASPublishAppServiceRequest() {} -bool ASPublishAppServiceRequest::ValidateManifest( - smart_objects::SmartObject& manifest) { - if (manifest.keyExists(strings::uri_scheme)) { - Json::Value value; - Json::Reader reader; - if (!reader.parse(manifest[strings::uri_scheme].asString(), value)) { - SendResponse( - false, - (*message_)[strings::params][strings::correlation_id].asUInt(), - hmi_apis::FunctionID::AppService_PublishAppService, - hmi_apis::Common_Result::INVALID_DATA); - return false; - } - } - return true; -} - void ASPublishAppServiceRequest::Run() { LOG4CXX_AUTO_TRACE(logger_); LOG4CXX_DEBUG(logger_, "Received a PublishAppService request from HMI"); @@ -75,9 +58,6 @@ void ASPublishAppServiceRequest::Run() { smart_objects::SmartObject(smart_objects::SmartType_Map); smart_objects::SmartObject manifest = (*message_)[strings::msg_params][strings::app_service_manifest]; - if (!ValidateManifest(manifest)) { - return; - } smart_objects::SmartObject service_record = application_manager_.GetAppServiceManager().PublishAppService( manifest, false, UINT32_MAX); diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/publish_app_service_request.cc b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/publish_app_service_request.cc index 05210208ca..22d8e50c3a 100644 --- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/publish_app_service_request.cc +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/publish_app_service_request.cc @@ -55,21 +55,6 @@ PublishAppServiceRequest::PublishAppServiceRequest( PublishAppServiceRequest::~PublishAppServiceRequest() {} -bool PublishAppServiceRequest::ValidateManifest( - smart_objects::SmartObject& manifest) { - if (manifest.keyExists(strings::uri_scheme)) { - Json::Value value; - Json::Reader reader; - if (!reader.parse(manifest[strings::uri_scheme].asString(), value)) { - SendResponse(false, - mobile_apis::Result::INVALID_DATA, - "Provided uriScheme was not valid JSON"); - return false; - } - } - return true; -} - void PublishAppServiceRequest::Run() { LOG4CXX_AUTO_TRACE(logger_); LOG4CXX_DEBUG(logger_, "Received a PublishAppService " << connection_key()); @@ -79,9 +64,6 @@ void PublishAppServiceRequest::Run() { smart_objects::SmartObject(smart_objects::SmartType_Map); smart_objects::SmartObject manifest = (*message_)[strings::msg_params][strings::app_service_manifest]; - if (!ValidateManifest(manifest)) { - return; - } ApplicationSharedPtr app = application_manager_.application(connection_key()); diff --git a/src/components/application_manager/src/smart_object_keys.cc b/src/components/application_manager/src/smart_object_keys.cc index 45829a4d2a..09e0ccf38b 100644 --- a/src/components/application_manager/src/smart_object_keys.cc +++ b/src/components/application_manager/src/smart_object_keys.cc @@ -275,8 +275,6 @@ const char* service_name = "serviceName"; const char* service_type = "serviceType"; const char* service_icon = "serviceIcon"; const char* allow_app_consumers = "allowAppConsumers"; -const char* uri_prefix = "uriPrefix"; -const char* uri_scheme = "uriScheme"; const char* rpc_spec_version = "rpcSpecVersion"; const char* handled_rpcs = "handledRPCs"; const char* media_service_manifest = "mediaServiceManifest"; diff --git a/src/components/interfaces/HMI_API.xml b/src/components/interfaces/HMI_API.xml index 5cd755ccef..6a7cb8c3d4 100644 --- a/src/components/interfaces/HMI_API.xml +++ b/src/components/interfaces/HMI_API.xml @@ -3680,14 +3680,6 @@ If true, app service consumers beyond the IVI system will be able to access this service. If false, only the IVI system will be able consume the service. If not provided, it is assumed to be false. - - The URI prefix for this service. If provided, all PerformAppServiceInteraction requests must start with it. - - - - This is a custom schema for this service. SDL will not do any verification on this param past that it has a correctly formated JSON Object as its base. The uriScheme should contain all available actions to be taken through a PerformAppServiceInteraction request from an app service consumer. - - This is the max RPC Spec version the app service understands. This is important during the RPC passthrough functionality. If not included, it is assumed the max version of the module is acceptable. diff --git a/src/components/interfaces/MOBILE_API.xml b/src/components/interfaces/MOBILE_API.xml index 39796f4e72..5a4b8c5482 100644 --- a/src/components/interfaces/MOBILE_API.xml +++ b/src/components/interfaces/MOBILE_API.xml @@ -4014,14 +4014,6 @@ If true, app service consumers beyond the IVI system will be able to access this service. If false, only the IVI system will be able consume the service. If not provided, it is assumed to be false. - - The URI prefix for this service. If provided, all PerformAppServiceInteraction requests must start with it. - - - - This is a custom schema for this service. SDL will not do any verification on this param past that it has a correctly formated JSON Object as its base. The uriScheme should contain all available actions to be taken through a PerformAppServiceInteraction request from an app service consumer. - - This is the max RPC Spec version the app service understands. This is important during the RPC passthrough functionality. If not included, it is assumed the max version of the module is acceptable. -- cgit v1.2.1 From 1ef6876b34f46e3b0a4c35bc1119f0057c919dff Mon Sep 17 00:00:00 2001 From: jacobkeeler Date: Mon, 4 Mar 2019 15:51:26 -0500 Subject: Fix style --- .../transport_manager/src/cloud/cloud_websocket_transport_adapter.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/components/transport_manager/src/cloud/cloud_websocket_transport_adapter.cc b/src/components/transport_manager/src/cloud/cloud_websocket_transport_adapter.cc index 410d54a407..ecef25f4f7 100644 --- a/src/components/transport_manager/src/cloud/cloud_websocket_transport_adapter.cc +++ b/src/components/transport_manager/src/cloud/cloud_websocket_transport_adapter.cc @@ -87,7 +87,8 @@ void CloudWebsocketTransportAdapter::CreateDevice(const std::string& uid) { // Extract host and port from endpoint string boost::regex group_pattern( - "(wss?:\\/\\/)([A-Z\\d\\.-]{2,}\\.?([A-Z]{2,})?)(:)(\\d{2,5})(\\/[A-Z\\d\\.-]+)*\\/?"); + "(wss?:\\/\\/)([A-Z\\d\\.-]{2,}\\.?([A-Z]{2,})?)(:)(\\d{2,5})(\\/" + "[A-Z\\d\\.-]+)*\\/?"); boost::smatch results; std::string host = ""; -- cgit v1.2.1 From c2f835cffa63fe1c5ac37c28a8c3e89acb30e086 Mon Sep 17 00:00:00 2001 From: jacobkeeler Date: Tue, 5 Mar 2019 09:57:14 -0500 Subject: Fix lock usage --- .../application_manager/src/app_service_manager.cc | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/components/application_manager/src/app_service_manager.cc b/src/components/application_manager/src/app_service_manager.cc index 73219df456..dcdcd0e66f 100644 --- a/src/components/application_manager/src/app_service_manager.cc +++ b/src/components/application_manager/src/app_service_manager.cc @@ -76,7 +76,6 @@ smart_objects::SmartObject AppServiceManager::PublishAppService( std::to_string(std::rand()); service_id = encryption::MakeHash(str_to_hash); } while (published_services_.find(service_id) != published_services_.end()); - published_services_lock_.Release(); AppService app_service; app_service.connection_key = connection_key; @@ -106,11 +105,11 @@ smart_objects::SmartObject AppServiceManager::PublishAppService( } app_service.default_service = GetPolicyAppID(app_service) == default_app_id; - { - sync_primitives::AutoLock lock(published_services_lock_); - published_services_.insert( - std::pair(service_id, app_service)); - } + auto ret = published_services_.insert( + std::pair(service_id, app_service)); + smart_objects::SmartObject& published_record = ret.first->second.record; + published_services_lock_.Release(); + smart_objects::SmartObject msg_params; msg_params[strings::system_capability][strings::system_capability_type] = mobile_apis::SystemCapabilityType::APP_SERVICES; @@ -126,7 +125,7 @@ smart_objects::SmartObject AppServiceManager::PublishAppService( ActivateAppService(service_id); } - return service_record; + return published_record; } bool AppServiceManager::UnpublishAppService(const std::string service_id) { -- cgit v1.2.1 From 3d3178c0d78dc2c0c1f515bb955eadff78a83e59 Mon Sep 17 00:00:00 2001 From: jacobkeeler Date: Tue, 5 Mar 2019 14:32:47 -0500 Subject: Handle hybrid app preference If both a cloud app and mobile app attempt to register with the same name, the hybrid app preference of the cloud app is used to determine which app should be registered --- .../application_manager/application_manager_impl.h | 10 ++++ .../mobile/register_app_interface_request.h | 3 +- .../mobile/register_app_interface_request.cc | 56 +++++++++++++++---- .../application_manager/src/application_impl.cc | 3 +- .../src/application_manager_impl.cc | 63 +++++++++++++++++----- .../application_manager/application_manager.h | 3 ++ .../application_manager/mock_application_manager.h | 3 ++ 7 files changed, 116 insertions(+), 25 deletions(-) diff --git a/src/components/application_manager/include/application_manager/application_manager_impl.h b/src/components/application_manager/include/application_manager/application_manager_impl.h index ae00108591..32d3a521e3 100644 --- a/src/components/application_manager/include/application_manager/application_manager_impl.h +++ b/src/components/application_manager/include/application_manager/application_manager_impl.h @@ -173,6 +173,8 @@ class ApplicationManagerImpl uint32_t hmi_app_id) const OVERRIDE; ApplicationSharedPtr application_by_policy_id( const std::string& policy_app_id) const OVERRIDE; + ApplicationSharedPtr application_by_name( + const std::string& app_name) const OVERRIDE; ApplicationSharedPtr pending_application_by_policy_id( const std::string& policy_app_id) const OVERRIDE; @@ -1002,6 +1004,14 @@ class ApplicationManagerImpl } }; + struct AppNamePredicate { + std::string app_name_; + AppNamePredicate(const std::string& app_name) : app_name_(app_name) {} + bool operator()(const ApplicationSharedPtr app) const { + return app ? app->name() == app_name_ : false; + } + }; + /** * @brief Sends UpdateAppList notification to HMI */ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/register_app_interface_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/register_app_interface_request.h index f8be896996..a6bfdec209 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/register_app_interface_request.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/register_app_interface_request.h @@ -148,7 +148,8 @@ class RegisterAppInterfaceRequest * return SUCCESS if there is no coincidence of app.name/TTS/VR synonyms, * otherwise appropriate error code returns */ - mobile_apis::Result::eType CheckCoincidence(); + mobile_apis::Result::eType CheckCoincidence( + app_mngr::ApplicationSharedPtr& app); /* * @brief Predicate for using with CheckCoincidence method to compare with VR 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 6317d9b068..e4540fe888 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 @@ -281,17 +281,49 @@ void RegisterAppInterfaceRequest::Run() { return; } - mobile_apis::Result::eType coincidence_result = CheckCoincidence(); + ApplicationSharedPtr duplicate_app; + mobile_apis::Result::eType coincidence_result = + CheckCoincidence(duplicate_app); + + if (mobile_apis::Result::DUPLICATE_NAME == coincidence_result) { + bool error_response = true; + if (duplicate_app->is_cloud_app()) { + if (duplicate_app->hybrid_app_preference() == + mobile_apis::HybridAppPreference::MOBILE) { + // Unregister cloud application and allow mobile application to register + // in it's place + application_manager_.UnregisterApplication( + duplicate_app->app_id(), mobile_apis::Result::USER_DISALLOWED); + error_response = false; + } + } else { + ApplicationSharedPtr cloud_app = + application_manager_.pending_application_by_policy_id(policy_app_id); + // If the duplicate name was not because of a mobile/cloud app pair, go + // through the normal process for handling duplicate names + if (cloud_app.use_count() == 0 || !cloud_app->is_cloud_app()) { + usage_statistics::AppCounter count_of_rejections_duplicate_name( + GetPolicyHandler().GetStatisticManager(), + policy_app_id, + usage_statistics::REJECTIONS_DUPLICATE_NAME); + ++count_of_rejections_duplicate_name; + } else if (cloud_app->hybrid_app_preference() == + mobile_apis::HybridAppPreference::CLOUD) { + // Unregister mobile application and allow cloud application to + // register in it's place + application_manager_.UnregisterApplication( + duplicate_app->app_id(), mobile_apis::Result::USER_DISALLOWED); + error_response = false; + } + } - if (mobile_apis::Result::SUCCESS != coincidence_result) { - LOG4CXX_ERROR(logger_, "Coincidence check failed."); - if (mobile_apis::Result::DUPLICATE_NAME == coincidence_result) { - usage_statistics::AppCounter count_of_rejections_duplicate_name( - GetPolicyHandler().GetStatisticManager(), - policy_app_id, - usage_statistics::REJECTIONS_DUPLICATE_NAME); - ++count_of_rejections_duplicate_name; + if (error_response) { + LOG4CXX_ERROR(logger_, "Coincidence check failed."); + SendResponse(false, coincidence_result); + return; } + } else if (mobile_apis::Result::SUCCESS != coincidence_result) { + LOG4CXX_ERROR(logger_, "Coincidence check failed."); SendResponse(false, coincidence_result); return; } @@ -922,7 +954,8 @@ void RegisterAppInterfaceRequest::SendOnAppRegisteredNotificationToHMI( DCHECK(rpc_service_.ManageHMICommand(notification)); } -mobile_apis::Result::eType RegisterAppInterfaceRequest::CheckCoincidence() { +mobile_apis::Result::eType RegisterAppInterfaceRequest::CheckCoincidence( + ApplicationSharedPtr& out_app) { LOG4CXX_AUTO_TRACE(logger_); const smart_objects::SmartObject& msg_params = (*message_)[strings::msg_params]; @@ -938,6 +971,7 @@ mobile_apis::Result::eType RegisterAppInterfaceRequest::CheckCoincidence() { const custom_str::CustomString& cur_name = (*it)->name(); if (app_name.CompareIgnoreCase(cur_name)) { LOG4CXX_ERROR(logger_, "Application name is known already."); + out_app = *it; return mobile_apis::Result::DUPLICATE_NAME; } @@ -949,6 +983,7 @@ mobile_apis::Result::eType RegisterAppInterfaceRequest::CheckCoincidence() { if (0 != std::count_if(curr_vr->begin(), curr_vr->end(), v)) { LOG4CXX_ERROR(logger_, "Application name is known already."); + out_app = *it; return mobile_apis::Result::DUPLICATE_NAME; } } @@ -961,6 +996,7 @@ mobile_apis::Result::eType RegisterAppInterfaceRequest::CheckCoincidence() { CoincidencePredicateVR v(cur_name); if (0 != std::count_if(new_vr->begin(), new_vr->end(), v)) { LOG4CXX_ERROR(logger_, "vr_synonyms duplicated with app_name ."); + out_app = *it; return mobile_apis::Result::DUPLICATE_NAME; } } // end vr check diff --git a/src/components/application_manager/src/application_impl.cc b/src/components/application_manager/src/application_impl.cc index 63bc9be8c6..3d17da51ce 100644 --- a/src/components/application_manager/src/application_impl.cc +++ b/src/components/application_manager/src/application_impl.cc @@ -1185,8 +1185,7 @@ const std::string& ApplicationImpl::cloud_app_certificate() const { } bool ApplicationImpl::is_cloud_app() const { - return !endpoint_.empty() && - hybrid_app_preference_ != mobile_apis::HybridAppPreference::MOBILE; + return !endpoint_.empty(); } void ApplicationImpl::set_cloud_app_endpoint(const std::string& endpoint) { diff --git a/src/components/application_manager/src/application_manager_impl.cc b/src/components/application_manager/src/application_manager_impl.cc index 364887ad3f..5dd9291c0d 100644 --- a/src/components/application_manager/src/application_manager_impl.cc +++ b/src/components/application_manager/src/application_manager_impl.cc @@ -269,6 +269,13 @@ ApplicationSharedPtr ApplicationManagerImpl::application_by_policy_id( return FindApp(accessor, finder); } +ApplicationSharedPtr ApplicationManagerImpl::application_by_name( + const std::string& app_name) const { + AppNamePredicate finder(app_name); + DataAccessor accessor = applications(); + return FindApp(accessor, finder); +} + ApplicationSharedPtr ApplicationManagerImpl::pending_application_by_policy_id( const std::string& policy_app_id) const { PolicyAppIdPredicate finder(policy_app_id); @@ -690,6 +697,10 @@ ApplicationSharedPtr ApplicationManagerImpl::RegisterApplication( apps_size_ = applications_.size(); applications_list_lock_ptr_->Release(); + // Update cloud app information, in case any pending apps are unable to be + // registered due to a mobile app taking precedence + RefreshCloudAppInformation(); + // It is possible that secondary transport of this app has been already // established. Make sure that the information is reflected to application // instance. @@ -917,11 +928,11 @@ void ApplicationManagerImpl::RefreshCloudAppInformation() { GetPolicyHandler().GetEnabledCloudApps(enabled_apps); std::vector::iterator enabled_it = enabled_apps.begin(); std::vector::iterator enabled_end = enabled_apps.end(); - std::string endpoint = ""; - std::string certificate = ""; - std::string auth_token = ""; - std::string cloud_transport_type = ""; - std::string hybrid_app_preference = ""; + std::string endpoint; + std::string certificate; + std::string auth_token; + std::string cloud_transport_type; + std::string hybrid_app_preference_str; bool enabled = true; // Store old device map and clear the current map @@ -937,8 +948,36 @@ void ApplicationManagerImpl::RefreshCloudAppInformation() { certificate, auth_token, cloud_transport_type, - hybrid_app_preference); + hybrid_app_preference_str); + + mobile_apis::HybridAppPreference::eType hybrid_app_preference = + mobile_apis::HybridAppPreference::INVALID_ENUM; + smart_objects::EnumConversionHelper< + mobile_apis::HybridAppPreference::eType>:: + StringToEnum(hybrid_app_preference_str, &hybrid_app_preference); + auto policy_id = *enabled_it; + policy::StringArray nicknames; + policy::StringArray app_hmi_types; + GetPolicyHandler().GetInitialAppData(policy_id, &nicknames, &app_hmi_types); + + if (nicknames.empty()) { + LOG4CXX_ERROR(logger_, "Cloud App missing nickname"); + continue; + } else if (mobile_apis::HybridAppPreference::MOBILE == + hybrid_app_preference) { + auto nickname_it = nicknames.begin(); + for (; nickname_it != nicknames.end(); ++nickname_it) { + auto app = application_by_name(*nickname_it); + if (app.use_count() != 0) { + LOG4CXX_ERROR( + logger_, + "Mobile app already registered for cloud app: " << *nickname_it); + continue; + } + } + } + pending_device_map_.insert( std::pair(endpoint, policy_id)); // Determine which endpoints were disabled by erasing all enabled apps from @@ -1032,11 +1071,11 @@ void ApplicationManagerImpl::CreatePendingApplication( connection_handler::DeviceHandle device_id) { LOG4CXX_AUTO_TRACE(logger_); - std::string endpoint = ""; - std::string certificate = ""; - std::string auth_token = ""; - std::string cloud_transport_type = ""; - std::string hybrid_app_preference_str = ""; + std::string endpoint; + std::string certificate; + std::string auth_token; + std::string cloud_transport_type; + std::string hybrid_app_preference_str; bool enabled = true; std::string name = device_info.name(); pending_device_map_lock_ptr_->Acquire(); @@ -1055,7 +1094,7 @@ void ApplicationManagerImpl::CreatePendingApplication( GetPolicyHandler().GetInitialAppData( policy_app_id, &nicknames, &app_hmi_types); - if (!nicknames.size()) { + if (nicknames.empty()) { LOG4CXX_ERROR(logger_, "Cloud App missing nickname"); return; } diff --git a/src/components/include/application_manager/application_manager.h b/src/components/include/application_manager/application_manager.h index cfd6cbe61c..67be49a224 100644 --- a/src/components/include/application_manager/application_manager.h +++ b/src/components/include/application_manager/application_manager.h @@ -169,6 +169,9 @@ class ApplicationManager { virtual ApplicationSharedPtr application_by_policy_id( const std::string& policy_app_id) const = 0; + virtual ApplicationSharedPtr application_by_name( + const std::string& app_name) const = 0; + virtual ApplicationSharedPtr pending_application_by_policy_id( const std::string& policy_app_id) const = 0; diff --git a/src/components/include/test/application_manager/mock_application_manager.h b/src/components/include/test/application_manager/mock_application_manager.h index 7cae217371..daf4a23925 100644 --- a/src/components/include/test/application_manager/mock_application_manager.h +++ b/src/components/include/test/application_manager/mock_application_manager.h @@ -100,6 +100,9 @@ class MockApplicationManager : public application_manager::ApplicationManager { MOCK_CONST_METHOD1(application_by_policy_id, application_manager::ApplicationSharedPtr( const std::string& policy_app_id)); + MOCK_CONST_METHOD1( + application_by_name, + application_manager::ApplicationSharedPtr(const std::string& app_name)); MOCK_CONST_METHOD1(pending_application_by_policy_id, application_manager::ApplicationSharedPtr( const std::string& policy_app_id)); -- cgit v1.2.1 From 00a12837cc8f2b334eeeed1fd033826fe772c362 Mon Sep 17 00:00:00 2001 From: jacobkeeler Date: Tue, 5 Mar 2019 18:45:53 -0500 Subject: Add logic for handling `allowAppConsumers` --- .../application_manager/app_service_manager.h | 3 +++ .../mobile/on_app_service_data_notification.cc | 24 ++++++++++++++++++++-- .../application_manager/src/app_service_manager.cc | 13 ++++++++++-- .../src/commands/command_request_impl.cc | 4 ++-- .../src/commands/request_from_hmi.cc | 4 ++-- 5 files changed, 40 insertions(+), 8 deletions(-) diff --git a/src/components/application_manager/include/application_manager/app_service_manager.h b/src/components/application_manager/include/application_manager/app_service_manager.h index 80e6b5521f..d6d13a209a 100644 --- a/src/components/application_manager/include/application_manager/app_service_manager.h +++ b/src/components/application_manager/include/application_manager/app_service_manager.h @@ -126,10 +126,12 @@ class AppServiceManager { std::vector GetAllServices(); void GetProviderByType(const std::string& service_type, + bool mobile_consumer, ApplicationSharedPtr& app, bool& hmi_service); void GetProviderByID(const std::string& service_id, + bool mobile_consumer, ApplicationSharedPtr& app, bool& hmi_service); @@ -169,6 +171,7 @@ class AppServiceManager { const mobile_apis::ServiceUpdateReason::eType update_reason, smart_objects::SmartObject& msg_params); void GetProviderFromService(const AppService& service, + bool mobile_consumer, ApplicationSharedPtr& app, bool& hmi_service); AppService* FindServiceByPolicyAppID(std::string policy_app_id, diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/on_app_service_data_notification.cc b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/on_app_service_data_notification.cc index a016d1fe16..e198cc0fcd 100644 --- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/on_app_service_data_notification.cc +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/on_app_service_data_notification.cc @@ -61,10 +61,30 @@ OnAppServiceDataNotification::~OnAppServiceDataNotification() {} void OnAppServiceDataNotification::Run() { LOG4CXX_AUTO_TRACE(logger_); LOG4CXX_DEBUG(logger_, "Sending OnAppServiceData to consumer"); - MessageHelper::PrintSmartObject(*message_); + + std::string service_id = + (*message_)[strings::msg_params][strings::service_data] + [strings::service_id] + .asString(); + auto service = application_manager_.GetAppServiceManager().FindServiceByID(service_id); + + if (!service) { + LOG4CXX_ERROR(logger_, "Service sending OnAppServiceData is not published"); + return; + } else if (!service + ->record[strings::service_manifest] + [strings::allow_app_consumers] + .asBool()) { + LOG4CXX_ERROR(logger_, + "Service does not allow for app consumers, skipping mobile " + "OnAppServiceData notification"); + return; + } std::string service_type = - (*message_)[strings::msg_params][strings::service_type].asString(); + (*message_)[strings::msg_params][strings::service_data] + [strings::service_type] + .asString(); auto subscribed_to_app_service_predicate = [service_type](const ApplicationSharedPtr app) { diff --git a/src/components/application_manager/src/app_service_manager.cc b/src/components/application_manager/src/app_service_manager.cc index dcdcd0e66f..494d3d61bf 100644 --- a/src/components/application_manager/src/app_service_manager.cc +++ b/src/components/application_manager/src/app_service_manager.cc @@ -201,6 +201,7 @@ std::vector AppServiceManager::GetAllServices() { } void AppServiceManager::GetProviderByType(const std::string& service_type, + bool mobile_consumer, ApplicationSharedPtr& app, bool& hmi_service) { LOG4CXX_AUTO_TRACE(logger_); @@ -213,10 +214,11 @@ void AppServiceManager::GetProviderByType(const std::string& service_type, } LOG4CXX_DEBUG(logger_, "Found provider for service type: " << service_type); - GetProviderFromService(*active_service, app, hmi_service); + GetProviderFromService(*active_service, mobile_consumer, app, hmi_service); } void AppServiceManager::GetProviderByID(const std::string& service_id, + bool mobile_consumer, ApplicationSharedPtr& app, bool& hmi_service) { LOG4CXX_AUTO_TRACE(logger_); @@ -228,13 +230,20 @@ void AppServiceManager::GetProviderByID(const std::string& service_id, } LOG4CXX_DEBUG(logger_, "Found provider with service ID: " << service_id); - GetProviderFromService(it->second, app, hmi_service); + GetProviderFromService(it->second, mobile_consumer, app, hmi_service); } void AppServiceManager::GetProviderFromService(const AppService& service, + bool mobile_consumer, ApplicationSharedPtr& app, bool& hmi_service) { LOG4CXX_AUTO_TRACE(logger_); + if (mobile_consumer && + !service.record[strings::service_manifest][strings::allow_app_consumers] + .asBool()) { + LOG4CXX_ERROR(logger_, "Service does not support app consumers"); + return; + } bool mobile_service = service.mobile_service; if (mobile_service) { app = app_manager_.application(service.connection_key); diff --git a/src/components/application_manager/src/commands/command_request_impl.cc b/src/components/application_manager/src/commands/command_request_impl.cc index c6dbe6972f..8d339d4d14 100644 --- a/src/components/application_manager/src/commands/command_request_impl.cc +++ b/src/components/application_manager/src/commands/command_request_impl.cc @@ -431,12 +431,12 @@ void CommandRequestImpl::SendProviderRequest( std::string service_type = (*msg)[strings::msg_params][strings::service_type].asString(); application_manager_.GetAppServiceManager().GetProviderByType( - service_type, app, hmi_destination); + service_type, true, app, hmi_destination); } else if ((*msg)[strings::msg_params].keyExists(strings::service_id)) { std::string service_id = (*msg)[strings::msg_params][strings::service_id].asString(); application_manager_.GetAppServiceManager().GetProviderByID( - service_id, app, hmi_destination); + service_id, true, app, hmi_destination); } if (hmi_destination) { diff --git a/src/components/application_manager/src/commands/request_from_hmi.cc b/src/components/application_manager/src/commands/request_from_hmi.cc index 823e93cb5e..3c8e75141a 100644 --- a/src/components/application_manager/src/commands/request_from_hmi.cc +++ b/src/components/application_manager/src/commands/request_from_hmi.cc @@ -173,12 +173,12 @@ void RequestFromHMI::SendProviderRequest( std::string service_type = (*msg)[strings::msg_params][strings::service_type].asString(); application_manager_.GetAppServiceManager().GetProviderByType( - service_type, app, hmi_destination); + service_type, false, app, hmi_destination); } else if ((*msg)[strings::msg_params].keyExists(strings::service_id)) { std::string service_id = (*msg)[strings::msg_params][strings::service_id].asString(); application_manager_.GetAppServiceManager().GetProviderByID( - service_id, app, hmi_destination); + service_id, false, app, hmi_destination); } if (hmi_destination) { -- cgit v1.2.1 From f9e39400db6458d4a3199913b33279149d0ce70c Mon Sep 17 00:00:00 2001 From: jacobkeeler Date: Tue, 5 Mar 2019 18:47:12 -0500 Subject: Fix usage of `subscribe` parameter in GetAppServiceData --- .../src/commands/mobile/get_app_service_data_request.cc | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/get_app_service_data_request.cc b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/get_app_service_data_request.cc index b54071068f..0d387785ee 100644 --- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/get_app_service_data_request.cc +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/get_app_service_data_request.cc @@ -70,16 +70,16 @@ void GetAppServiceDataRequest::Run() { std::string service_type = (*message_)[strings::msg_params][strings::service_type].asString(); - bool subscribe = false; - if ((*message_)[strings::msg_params].keyExists(strings::subscribe)) { - subscribe = (*message_)[strings::msg_params][strings::subscribe].asBool(); - } - ApplicationSharedPtr app = application_manager_.application(connection_key()); - - if (subscribe) { + if ((*message_)[strings::msg_params].keyExists(strings::subscribe)) { + bool subscribe = + (*message_)[strings::msg_params][strings::subscribe].asBool(); auto& ext = AppServiceAppExtension::ExtractASExtension(*app); - ext.SubscribeToAppService(service_type); + if (subscribe) { + ext.SubscribeToAppService(service_type); + } else { + ext.UnsubscribeFromAppService(service_type); + } } SendProviderRequest(mobile_apis::FunctionID::GetAppServiceDataID, -- cgit v1.2.1 From 25850f0eaab20ef8166ad851343b2d9de5b26127 Mon Sep 17 00:00:00 2001 From: jacobkeeler Date: Tue, 5 Mar 2019 18:47:26 -0500 Subject: Fix HMI API types --- src/components/interfaces/HMI_API.xml | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/components/interfaces/HMI_API.xml b/src/components/interfaces/HMI_API.xml index 5cd755ccef..d4f2cdaab0 100644 --- a/src/components/interfaces/HMI_API.xml +++ b/src/components/interfaces/HMI_API.xml @@ -3751,17 +3751,17 @@ - + Only included in OnSystemCapabilityUpdated. Update reason for service record. - + Service record for a specific app service provider Capabilities of app services including what service types are supported and the current state of services. - + An array of currently available services. If this is an update to the capability the affected services will include an update reason in that item @@ -3779,22 +3779,22 @@ The systemCapabilityType identifies which data object exists in this struct. For example, if the SystemCapability Type is NAVIGATION then a "navigationCapability" should exist - + Used as a descriptor of what data to expect in this struct. The corresponding param to this enum should be included and the only other para included. - + Describes extended capabilities for onboard navigation system - + Describes extended capabilities of the module's phone feature - + Describes extended capabilities of the module's phone feature - + Describes extended capabilities of the module's phone feature - + An array of currently available services. If this is an update to the capability the affected services will include an update reason in that item -- cgit v1.2.1 From 0849c4b4de0fa54408a2d353afb4d4de242ef544 Mon Sep 17 00:00:00 2001 From: jacobkeeler Date: Tue, 5 Mar 2019 18:48:49 -0500 Subject: Fix style --- .../include/application_manager/application_manager_impl.h | 1 - 1 file changed, 1 deletion(-) diff --git a/src/components/application_manager/include/application_manager/application_manager_impl.h b/src/components/application_manager/include/application_manager/application_manager_impl.h index 32d3a521e3..d72d03fa53 100644 --- a/src/components/application_manager/include/application_manager/application_manager_impl.h +++ b/src/components/application_manager/include/application_manager/application_manager_impl.h @@ -404,7 +404,6 @@ class ApplicationManagerImpl * @param app A cloud application * @return The current CloudConnectionStatus of app */ - hmi_apis::Common_CloudConnectionStatus::eType GetCloudAppConnectionStatus( ApplicationConstSharedPtr app) const; -- cgit v1.2.1 From 24be2c57bb2965d29c86f6891346b6491bcf08e6 Mon Sep 17 00:00:00 2001 From: jacobkeeler Date: Tue, 5 Mar 2019 18:50:50 -0500 Subject: Fix style --- .../commands/mobile/on_app_service_data_notification.cc | 17 +++++++---------- .../application_manager/src/app_service_manager.cc | 2 +- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/on_app_service_data_notification.cc b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/on_app_service_data_notification.cc index e198cc0fcd..2c6ba414e0 100644 --- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/on_app_service_data_notification.cc +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/on_app_service_data_notification.cc @@ -64,17 +64,15 @@ void OnAppServiceDataNotification::Run() { std::string service_id = (*message_)[strings::msg_params][strings::service_data] - [strings::service_id] - .asString(); - auto service = application_manager_.GetAppServiceManager().FindServiceByID(service_id); - + [strings::service_id].asString(); + auto service = + application_manager_.GetAppServiceManager().FindServiceByID(service_id); + if (!service) { LOG4CXX_ERROR(logger_, "Service sending OnAppServiceData is not published"); return; - } else if (!service - ->record[strings::service_manifest] - [strings::allow_app_consumers] - .asBool()) { + } else if (!service->record[strings::service_manifest] + [strings::allow_app_consumers].asBool()) { LOG4CXX_ERROR(logger_, "Service does not allow for app consumers, skipping mobile " "OnAppServiceData notification"); @@ -83,8 +81,7 @@ void OnAppServiceDataNotification::Run() { std::string service_type = (*message_)[strings::msg_params][strings::service_data] - [strings::service_type] - .asString(); + [strings::service_type].asString(); auto subscribed_to_app_service_predicate = [service_type](const ApplicationSharedPtr app) { diff --git a/src/components/application_manager/src/app_service_manager.cc b/src/components/application_manager/src/app_service_manager.cc index 494d3d61bf..24c21dc201 100644 --- a/src/components/application_manager/src/app_service_manager.cc +++ b/src/components/application_manager/src/app_service_manager.cc @@ -109,7 +109,7 @@ smart_objects::SmartObject AppServiceManager::PublishAppService( std::pair(service_id, app_service)); smart_objects::SmartObject& published_record = ret.first->second.record; published_services_lock_.Release(); - + smart_objects::SmartObject msg_params; msg_params[strings::system_capability][strings::system_capability_type] = mobile_apis::SystemCapabilityType::APP_SERVICES; -- cgit v1.2.1 From 799220d37076e9da4900e97fe634ee5343a095ae Mon Sep 17 00:00:00 2001 From: jacobkeeler Date: Tue, 5 Mar 2019 21:31:13 -0500 Subject: Fix issues after merge --- .../src/application_manager_impl.cc | 10 ++++- .../src/connection_handler_impl.cc | 3 +- .../cloud/websocket_client_connection.h | 4 +- .../src/cloud/websocket_client_connection.cc | 52 +++++++++++----------- 4 files changed, 38 insertions(+), 31 deletions(-) diff --git a/src/components/application_manager/src/application_manager_impl.cc b/src/components/application_manager/src/application_manager_impl.cc index fd30c4ee03..36309fa2f9 100644 --- a/src/components/application_manager/src/application_manager_impl.cc +++ b/src/components/application_manager/src/application_manager_impl.cc @@ -905,10 +905,16 @@ void ApplicationManagerImpl::DisconnectCloudApp(ApplicationSharedPtr app) { // Delete the cloud device connection_handler().RemoveCloudAppDevice(app->device()); + transport_manager::transport_adapter::CloudAppProperties properties{ + endpoint, + certificate, + enabled, + auth_token, + cloud_transport_type, + hybrid_app_preference}; // Create device in pending state LOG4CXX_DEBUG(logger_, "Re-adding the cloud app device"); - connection_handler().AddCloudAppDevice( - policy_app_id, endpoint, cloud_transport_type); + connection_handler().AddCloudAppDevice(policy_app_id, properties); } void ApplicationManagerImpl::RefreshCloudAppInformation() { diff --git a/src/components/connection_handler/src/connection_handler_impl.cc b/src/components/connection_handler/src/connection_handler_impl.cc index ed8880d066..7e93e04047 100644 --- a/src/components/connection_handler/src/connection_handler_impl.cc +++ b/src/components/connection_handler/src/connection_handler_impl.cc @@ -1354,7 +1354,8 @@ void ConnectionHandlerImpl::AddCloudAppDevice( const transport_manager::transport_adapter::CloudAppProperties& cloud_properties) { cloud_app_id_map_lock_.Acquire(); - cloud_app_id_map_[policy_app_id] = std::make_pair(endpoint, 0); + cloud_app_id_map_[policy_app_id] = + std::make_pair(cloud_properties.endpoint, 0); cloud_app_id_map_lock_.Release(); transport_manager_.AddCloudDevice(cloud_properties); } diff --git a/src/components/transport_manager/include/transport_manager/cloud/websocket_client_connection.h b/src/components/transport_manager/include/transport_manager/cloud/websocket_client_connection.h index cb7731bcce..aa608312a0 100644 --- a/src/components/transport_manager/include/transport_manager/cloud/websocket_client_connection.h +++ b/src/components/transport_manager/include/transport_manager/cloud/websocket_client_connection.h @@ -142,8 +142,8 @@ class WebsocketClientConnection boost::beast::flat_buffer buffer_; std::string host_; std::string text_; - std::shared_ptr ws_; - std::shared_ptr wss_; + WS ws_; + WSS wss_; std::atomic_bool shutdown_; diff --git a/src/components/transport_manager/src/cloud/websocket_client_connection.cc b/src/components/transport_manager/src/cloud/websocket_client_connection.cc index dd25c74de6..5c9553a970 100644 --- a/src/components/transport_manager/src/cloud/websocket_client_connection.cc +++ b/src/components/transport_manager/src/cloud/websocket_client_connection.cc @@ -49,6 +49,8 @@ WebsocketClientConnection::WebsocketClientConnection( : controller_(controller) , ctx_(ssl::context::sslv23_client) , resolver_(ioc_) + , ws_(ioc_) + , wss_(ioc_, ctx_) , shutdown_(false) , thread_delegate_(new LoopThreadDelegate(&message_queue_, this)) , write_thread_(threads::CreateThread("WS Async Send", thread_delegate_)) @@ -69,7 +71,7 @@ void WebsocketClientConnection::AddCertificateAuthority( return; } - wss_->next_layer().set_verify_mode(ssl::verify_peer); + wss_.next_layer().set_verify_mode(ssl::verify_peer); } TransportAdapter::Error WebsocketClientConnection::Start() { @@ -105,12 +107,10 @@ TransportAdapter::Error WebsocketClientConnection::Start() { // Make Connection to host IP Address over TCP if (cloud_properties.cloud_transport_type == "WSS") { - wss_ = std::make_shared(ioc_, ctx_); boost::asio::connect( - wss_->next_layer().next_layer(), results.begin(), results.end(), ec); + wss_.next_layer().next_layer(), results.begin(), results.end(), ec); } else { - ws_ = std::make_shared(ioc_); - boost::asio::connect(ws_->next_layer(), results.begin(), results.end(), ec); + boost::asio::connect(ws_.next_layer(), results.begin(), results.end(), ec); } if (ec) { std::string str_err = "ErrorMessage: " + ec.message(); @@ -134,7 +134,7 @@ TransportAdapter::Error WebsocketClientConnection::Start() { } // Perform SSL Handshake - wss_->next_layer().handshake(ssl::stream_base::client, ec); + wss_.next_layer().handshake(ssl::stream_base::client, ec); if (ec) { std::string str_err = "ErrorMessage: " + ec.message(); @@ -149,9 +149,9 @@ TransportAdapter::Error WebsocketClientConnection::Start() { // Perform websocket handshake if (cloud_properties.cloud_transport_type == "WSS") { - wss_->handshake(host, "/", ec); + wss_.handshake(host, "/", ec); } else { - ws_->handshake(host, "/", ec); + ws_.handshake(host, "/", ec); } if (ec) { std::string str_err = "ErrorMessage: " + ec.message(); @@ -164,26 +164,26 @@ TransportAdapter::Error WebsocketClientConnection::Start() { // Set the binary message write option if (cloud_properties.cloud_transport_type == "WSS") { - wss_->binary(true); + wss_.binary(true); } else { - ws_->binary(true); + ws_.binary(true); } write_thread_->start(threads::ThreadOptions()); controller_->ConnectDone(device_uid_, app_handle_); // Start async read if (cloud_properties.cloud_transport_type == "WSS") { - wss_->async_read(buffer_, - std::bind(&WebsocketClientConnection::OnRead, - this, - std::placeholders::_1, - std::placeholders::_2)); - } else { - ws_->async_read(buffer_, + wss_.async_read(buffer_, std::bind(&WebsocketClientConnection::OnRead, this, std::placeholders::_1, std::placeholders::_2)); + } else { + ws_.async_read(buffer_, + std::bind(&WebsocketClientConnection::OnRead, + this, + std::placeholders::_1, + std::placeholders::_2)); } boost::asio::post(io_pool_, [&]() { ioc_.run(); }); @@ -206,17 +206,17 @@ void WebsocketClientConnection::Recv(boost::system::error_code ec) { return; } if (cloud_properties.cloud_transport_type == "WSS") { - wss_->async_read(buffer_, - std::bind(&WebsocketClientConnection::OnRead, - this, - std::placeholders::_1, - std::placeholders::_2)); - } else { - ws_->async_read(buffer_, + wss_.async_read(buffer_, std::bind(&WebsocketClientConnection::OnRead, this, std::placeholders::_1, std::placeholders::_2)); + } else { + ws_.async_read(buffer_, + std::bind(&WebsocketClientConnection::OnRead, + this, + std::placeholders::_1, + std::placeholders::_2)); } } @@ -301,10 +301,10 @@ void WebsocketClientConnection::LoopThreadDelegate::DrainQueue() { if (!shutdown_) { boost::system::error_code ec; if (handler_.cloud_properties.cloud_transport_type == "WSS") { - handler_.wss_->write( + handler_.wss_.write( boost::asio::buffer(message_ptr->data(), message_ptr->data_size())); } else { - handler_.ws_->write( + handler_.ws_.write( boost::asio::buffer(message_ptr->data(), message_ptr->data_size())); } if (ec) { -- cgit v1.2.1 From 7a08eafdfe80eab35ac56d3694ddc993d73b871a Mon Sep 17 00:00:00 2001 From: jacobkeeler Date: Tue, 5 Mar 2019 23:37:25 -0500 Subject: Remove todos and fix typos --- .../application_manager/include/application_manager/application.h | 2 +- .../include/application_manager/application_impl.h | 2 +- src/components/transport_manager/src/transport_manager_default.cc | 5 ++--- src/components/transport_manager/src/transport_manager_impl.cc | 2 -- 4 files changed, 4 insertions(+), 7 deletions(-) diff --git a/src/components/application_manager/include/application_manager/application.h b/src/components/application_manager/include/application_manager/application.h index 15a79388c1..b4d8ca857e 100644 --- a/src/components/application_manager/include/application_manager/application.h +++ b/src/components/application_manager/include/application_manager/application.h @@ -960,7 +960,7 @@ class Application : public virtual InitialApplicationData, virtual const std::string& auth_token() const = 0; /** - * @brief Get cloud app tranpsport type. Defines the type of websocket + * @brief Get cloud app transport type. Defines the type of websocket * connection used. * @return cloud app transport type */ diff --git a/src/components/application_manager/include/application_manager/application_impl.h b/src/components/application_manager/include/application_manager/application_impl.h index aedb973b31..ff34d2a96a 100644 --- a/src/components/application_manager/include/application_manager/application_impl.h +++ b/src/components/application_manager/include/application_manager/application_impl.h @@ -423,7 +423,7 @@ class ApplicationImpl : public virtual Application, const std::string& auth_token() const OVERRIDE; /** - * @brief Get cloud app tranpsport type. Defines the type of websocket + * @brief Get cloud app transport type. Defines the type of websocket * connection used. * @return cloud app transport type */ diff --git a/src/components/transport_manager/src/transport_manager_default.cc b/src/components/transport_manager/src/transport_manager_default.cc index bf692de24c..41487b054b 100644 --- a/src/components/transport_manager/src/transport_manager_default.cc +++ b/src/components/transport_manager/src/transport_manager_default.cc @@ -107,9 +107,8 @@ int TransportManagerDefault::Init(resumption::LastState& last_state) { #if defined CLOUD_APP_WEBSOCKET_TRANSPORT_SUPPORT transport_adapter::TransportAdapterImpl* ta_cloud = - new transport_adapter::CloudWebsocketTransportAdapter( - last_state, get_settings()); // Todo add retry connection logic from - // ini to initializer. + new transport_adapter::CloudWebsocketTransportAdapter(last_state, + get_settings()); #ifdef TELEMETRY_MONITOR if (metric_observer_) { ta_cloud->SetTelemetryObserver(metric_observer_); diff --git a/src/components/transport_manager/src/transport_manager_impl.cc b/src/components/transport_manager/src/transport_manager_impl.cc index 0c74602f6b..d197882120 100644 --- a/src/components/transport_manager/src/transport_manager_impl.cc +++ b/src/components/transport_manager/src/transport_manager_impl.cc @@ -133,8 +133,6 @@ void TransportManagerImpl::ReconnectionTimeout() { void TransportManagerImpl::AddCloudDevice( const transport_manager::transport_adapter::CloudAppProperties cloud_properties) { - // todo put conversion into own function - transport_adapter::DeviceType type = transport_adapter::DeviceType::UNKNOWN; if ((cloud_properties.cloud_transport_type == "WS") || (cloud_properties.cloud_transport_type == "WSS")) { -- cgit v1.2.1 From 7b2af762ed58252c2d01a6a3bc1dc4a8ec13f5da Mon Sep 17 00:00:00 2001 From: jacobkeeler Date: Wed, 6 Mar 2019 10:50:46 -0500 Subject: Revert "Remove setAppName" This reverts commit e258587fad7340ff25e503e7beef3ee51e290f45. --- .../application_manager/src/policies/policy_handler.cc | 4 ++++ .../include/policy/policy_external/policy/policy_manager.h | 7 +++++++ .../include/policy/policy_regular/policy/policy_manager.h | 7 +++++++ .../test/policy/policy_external/policy/mock_cache_manager.h | 3 +++ .../test/policy/policy_external/policy/mock_policy_manager.h | 3 +++ .../test/policy/policy_regular/policy/mock_cache_manager.h | 3 +++ .../test/policy/policy_regular/policy/mock_policy_manager.h | 3 +++ .../policy/policy_external/include/policy/cache_manager.h | 7 +++++++ .../policy_external/include/policy/cache_manager_interface.h | 7 +++++++ .../policy_external/include/policy/policy_manager_impl.h | 7 +++++++ src/components/policy/policy_external/src/cache_manager.cc | 11 +++++++++++ .../policy/policy_external/src/policy_manager_impl.cc | 5 +++++ .../policy/policy_regular/include/policy/cache_manager.h | 7 +++++++ .../policy_regular/include/policy/cache_manager_interface.h | 6 ++++++ .../policy_regular/include/policy/policy_manager_impl.h | 7 +++++++ src/components/policy/policy_regular/src/cache_manager.cc | 11 +++++++++++ .../policy/policy_regular/src/policy_manager_impl.cc | 5 +++++ 17 files changed, 103 insertions(+) diff --git a/src/components/application_manager/src/policies/policy_handler.cc b/src/components/application_manager/src/policies/policy_handler.cc index 7d94e19b12..2dc9f73373 100644 --- a/src/components/application_manager/src/policies/policy_handler.cc +++ b/src/components/application_manager/src/policies/policy_handler.cc @@ -1954,6 +1954,10 @@ void PolicyHandler::OnSetCloudAppProperties( policy_manager_->SetAppEndpoint(policy_app_id, properties[strings::endpoint].asString()); } + if (properties.keyExists(strings::app_name)) { + policy_manager_->SetAppName(policy_app_id, + properties[strings::app_name].asString()); + } if (properties.keyExists(strings::hybrid_app_preference)) { std::string hybrid_app_preference; diff --git a/src/components/include/policy/policy_external/policy/policy_manager.h b/src/components/include/policy/policy_external/policy/policy_manager.h index 61ad6b9a91..c1c2b419a1 100644 --- a/src/components/include/policy/policy_external/policy/policy_manager.h +++ b/src/components/include/policy/policy_external/policy/policy_manager.h @@ -599,6 +599,13 @@ class PolicyManager : public usage_statistics::StatisticsManager { virtual void SetAppEndpoint(const std::string& policy_app_id, const std::string& endpoint) = 0; + /** + * @brief Set a cloud app's name + * @param app_name Nickname for cloud app + */ + virtual void SetAppName(const std::string& policy_app_id, + const std::string& app_name) = 0; + /** * @brief Set the user preference for how a hybrid (cloud and mobile) app * should be used diff --git a/src/components/include/policy/policy_regular/policy/policy_manager.h b/src/components/include/policy/policy_regular/policy/policy_manager.h index 898c9ff2c6..2a5a6c2239 100644 --- a/src/components/include/policy/policy_regular/policy/policy_manager.h +++ b/src/components/include/policy/policy_regular/policy/policy_manager.h @@ -580,6 +580,13 @@ class PolicyManager : public usage_statistics::StatisticsManager { virtual void SetAppEndpoint(const std::string& policy_app_id, const std::string& endpoint) = 0; + /** + * @brief Set a cloud app's name + * @param app_name Nickname for cloud app + */ + virtual void SetAppName(const std::string& policy_app_id, + const std::string& app_name) = 0; + /** * @brief Set the user preference for how a hybrid (cloud and mobile) app * should be used diff --git a/src/components/include/test/policy/policy_external/policy/mock_cache_manager.h b/src/components/include/test/policy/policy_external/policy/mock_cache_manager.h index d47a88fe54..04cc0347c3 100644 --- a/src/components/include/test/policy/policy_external/policy/mock_cache_manager.h +++ b/src/components/include/test/policy/policy_external/policy/mock_cache_manager.h @@ -98,6 +98,9 @@ class MockCacheManagerInterface : public ::policy::CacheManagerInterface { MOCK_METHOD2(SetAppEndpoint, void(const std::string& policy_app_id, const std::string& endpoint)); + MOCK_METHOD2(SetAppName, + void(const std::string& policy_app_id, + const std::string& app_name)); MOCK_METHOD2(SetHybridAppPreference, void(const std::string& policy_app_id, const std::string& hybrid_app_preference)); diff --git a/src/components/include/test/policy/policy_external/policy/mock_policy_manager.h b/src/components/include/test/policy/policy_external/policy/mock_policy_manager.h index 9b21d95f1b..f1abdc496e 100644 --- a/src/components/include/test/policy/policy_external/policy/mock_policy_manager.h +++ b/src/components/include/test/policy/policy_external/policy/mock_policy_manager.h @@ -207,6 +207,9 @@ class MockPolicyManager : public PolicyManager { MOCK_METHOD2(SetAppEndpoint, void(const std::string& policy_app_id, const std::string& endpoint)); + MOCK_METHOD2(SetAppName, + void(const std::string& policy_app_id, + const std::string& app_name)); MOCK_METHOD2(SetHybridAppPreference, void(const std::string& policy_app_id, const std::string& hybrid_app_preference)); diff --git a/src/components/include/test/policy/policy_regular/policy/mock_cache_manager.h b/src/components/include/test/policy/policy_regular/policy/mock_cache_manager.h index 83774ab7cd..0b6af6fd6f 100644 --- a/src/components/include/test/policy/policy_regular/policy/mock_cache_manager.h +++ b/src/components/include/test/policy/policy_regular/policy/mock_cache_manager.h @@ -85,6 +85,9 @@ class MockCacheManagerInterface : public CacheManagerInterface { MOCK_METHOD2(SetAppEndpoint, void(const std::string& policy_app_id, const std::string& endpoint)); + MOCK_METHOD2(SetAppName, + void(const std::string& policy_app_id, + const std::string& app_name)); MOCK_METHOD2(SetHybridAppPreference, void(const std::string& policy_app_id, const std::string& hybrid_app_preference)); diff --git a/src/components/include/test/policy/policy_regular/policy/mock_policy_manager.h b/src/components/include/test/policy/policy_regular/policy/mock_policy_manager.h index 401db5586f..de24b8b949 100644 --- a/src/components/include/test/policy/policy_regular/policy/mock_policy_manager.h +++ b/src/components/include/test/policy/policy_regular/policy/mock_policy_manager.h @@ -203,6 +203,9 @@ class MockPolicyManager : public PolicyManager { MOCK_METHOD2(SetAppEndpoint, void(const std::string& policy_app_id, const std::string& endpoint)); + MOCK_METHOD2(SetAppName, + void(const std::string& policy_app_id, + const std::string& app_name)); MOCK_METHOD2(SetHybridAppPreference, void(const std::string& policy_app_id, const std::string& hybrid_app_preference)); diff --git a/src/components/policy/policy_external/include/policy/cache_manager.h b/src/components/policy/policy_external/include/policy/cache_manager.h index 25adbe19f7..943bf1e743 100644 --- a/src/components/policy/policy_external/include/policy/cache_manager.h +++ b/src/components/policy/policy_external/include/policy/cache_manager.h @@ -227,6 +227,13 @@ class CacheManager : public CacheManagerInterface { virtual void SetAppEndpoint(const std::string& policy_app_id, const std::string& endpoint); + /** + * @brief Set a cloud app's name + * @param app_name Nickname for cloud app + */ + virtual void SetAppName(const std::string& policy_app_id, + const std::string& app_name); + /** * @brief Set the user preference for how a hybrid (cloud and mobile) app * should be used diff --git a/src/components/policy/policy_external/include/policy/cache_manager_interface.h b/src/components/policy/policy_external/include/policy/cache_manager_interface.h index 86b4373650..bafc65e208 100644 --- a/src/components/policy/policy_external/include/policy/cache_manager_interface.h +++ b/src/components/policy/policy_external/include/policy/cache_manager_interface.h @@ -235,6 +235,13 @@ class CacheManagerInterface { virtual void SetAppEndpoint(const std::string& policy_app_id, const std::string& endpoint) = 0; + /** + * @brief Set a cloud app's name + * @param app_name Nickname for cloud app + */ + virtual void SetAppName(const std::string& policy_app_id, + const std::string& app_name) = 0; + /** * @brief Set the user preference for how a hybrid (cloud and mobile) app * should be used diff --git a/src/components/policy/policy_external/include/policy/policy_manager_impl.h b/src/components/policy/policy_external/include/policy/policy_manager_impl.h index 35fd3a1a7e..d73409ec17 100644 --- a/src/components/policy/policy_external/include/policy/policy_manager_impl.h +++ b/src/components/policy/policy_external/include/policy/policy_manager_impl.h @@ -646,6 +646,13 @@ class PolicyManagerImpl : public PolicyManager { void SetAppEndpoint(const std::string& policy_app_id, const std::string& endpoint) OVERRIDE; + /** + * @brief Set a cloud app's name + * @param app_name Nickname for cloud app + */ + void SetAppName(const std::string& policy_app_id, + const std::string& app_name) OVERRIDE; + /** * @brief Set the user preference for how a hybrid (cloud and mobile) app * should be used diff --git a/src/components/policy/policy_external/src/cache_manager.cc b/src/components/policy/policy_external/src/cache_manager.cc index b0ff7f12d2..23bca24476 100644 --- a/src/components/policy/policy_external/src/cache_manager.cc +++ b/src/components/policy/policy_external/src/cache_manager.cc @@ -1500,6 +1500,17 @@ void CacheManager::SetAppEndpoint(const std::string& policy_app_id, } } +void CacheManager::SetAppName(const std::string& policy_app_id, + const std::string& app_name) { + policy_table::ApplicationPolicies& policies = + pt_->policy_table.app_policies_section.apps; + policy_table::ApplicationPolicies::iterator policy_iter = + policies.find(policy_app_id); + if (policies.end() != policy_iter) { + (*policy_iter).second.nicknames->push_back(app_name); + } +} + void CacheManager::SetHybridAppPreference( const std::string& policy_app_id, const std::string& hybrid_app_preference) { diff --git a/src/components/policy/policy_external/src/policy_manager_impl.cc b/src/components/policy/policy_external/src/policy_manager_impl.cc index 37f5ab666f..6931ec87b8 100644 --- a/src/components/policy/policy_external/src/policy_manager_impl.cc +++ b/src/components/policy/policy_external/src/policy_manager_impl.cc @@ -782,6 +782,11 @@ void PolicyManagerImpl::SetAppEndpoint(const std::string& policy_app_id, cache_->SetAppEndpoint(policy_app_id, endpoint); } +void PolicyManagerImpl::SetAppName(const std::string& policy_app_id, + const std::string& app_name) { + cache_->SetAppName(policy_app_id, app_name); +} + void PolicyManagerImpl::SetHybridAppPreference( const std::string& policy_app_id, const std::string& hybrid_app_preference) { diff --git a/src/components/policy/policy_regular/include/policy/cache_manager.h b/src/components/policy/policy_regular/include/policy/cache_manager.h index 3b3c941b20..b6b6691985 100644 --- a/src/components/policy/policy_regular/include/policy/cache_manager.h +++ b/src/components/policy/policy_regular/include/policy/cache_manager.h @@ -215,6 +215,13 @@ class CacheManager : public CacheManagerInterface { virtual void SetAppEndpoint(const std::string& policy_app_id, const std::string& endpoint); + /** + * @brief Set a cloud app's name + * @param app_name Nickname for cloud app + */ + virtual void SetAppName(const std::string& policy_app_id, + const std::string& app_name); + /** * @brief Set the user preference for how a hybrid (cloud and mobile) app * should be used diff --git a/src/components/policy/policy_regular/include/policy/cache_manager_interface.h b/src/components/policy/policy_regular/include/policy/cache_manager_interface.h index a50127d141..13479f7595 100644 --- a/src/components/policy/policy_regular/include/policy/cache_manager_interface.h +++ b/src/components/policy/policy_regular/include/policy/cache_manager_interface.h @@ -221,6 +221,12 @@ class CacheManagerInterface { virtual void SetAppEndpoint(const std::string& policy_app_id, const std::string& endpoint) = 0; + /** + * @brief Set a cloud app's name + * @param app_name Nickname for cloud app + */ + virtual void SetAppName(const std::string& policy_app_id, + const std::string& app_name) = 0; /** * @brief Set the user preference for how a hybrid (cloud and mobile) app * should be used diff --git a/src/components/policy/policy_regular/include/policy/policy_manager_impl.h b/src/components/policy/policy_regular/include/policy/policy_manager_impl.h index 357d3f1c87..5e46ff9fa1 100644 --- a/src/components/policy/policy_regular/include/policy/policy_manager_impl.h +++ b/src/components/policy/policy_regular/include/policy/policy_manager_impl.h @@ -641,6 +641,13 @@ class PolicyManagerImpl : public PolicyManager { void SetAppEndpoint(const std::string& policy_app_id, const std::string& endpoint) OVERRIDE; + /** + * @brief Set a cloud app's name + * @param app_name Nickname for cloud app + */ + void SetAppName(const std::string& policy_app_id, + const std::string& app_name) OVERRIDE; + /** * @brief Set the user preference for how a hybrid (cloud and mobile) app * should be used diff --git a/src/components/policy/policy_regular/src/cache_manager.cc b/src/components/policy/policy_regular/src/cache_manager.cc index 1a0a908f5d..9407f28132 100644 --- a/src/components/policy/policy_regular/src/cache_manager.cc +++ b/src/components/policy/policy_regular/src/cache_manager.cc @@ -795,6 +795,17 @@ void CacheManager::SetAppEndpoint(const std::string& policy_app_id, } } +void CacheManager::SetAppName(const std::string& policy_app_id, + const std::string& app_name) { + policy_table::ApplicationPolicies& policies = + pt_->policy_table.app_policies_section.apps; + policy_table::ApplicationPolicies::iterator policy_iter = + policies.find(policy_app_id); + if (policies.end() != policy_iter) { + (*policy_iter).second.nicknames->push_back(app_name); + } +} + void CacheManager::SetHybridAppPreference( const std::string& policy_app_id, const std::string& hybrid_app_preference) { diff --git a/src/components/policy/policy_regular/src/policy_manager_impl.cc b/src/components/policy/policy_regular/src/policy_manager_impl.cc index ae07b5529c..12502bc6d4 100644 --- a/src/components/policy/policy_regular/src/policy_manager_impl.cc +++ b/src/components/policy/policy_regular/src/policy_manager_impl.cc @@ -601,6 +601,11 @@ void PolicyManagerImpl::SetAppEndpoint(const std::string& policy_app_id, cache_->SetAppEndpoint(policy_app_id, endpoint); } +void PolicyManagerImpl::SetAppName(const std::string& policy_app_id, + const std::string& app_name) { + cache_->SetAppName(policy_app_id, app_name); +} + void PolicyManagerImpl::SetHybridAppPreference( const std::string& policy_app_id, const std::string& hybrid_app_preference) { -- cgit v1.2.1 From bcd314658814edf6b822b9a23267c0694865e06c Mon Sep 17 00:00:00 2001 From: jacobkeeler Date: Wed, 6 Mar 2019 13:20:21 -0500 Subject: Implement cloud app properties revision --- .../application_manager/smart_object_keys.h | 1 + .../mobile/get_cloud_app_properties_request.cc | 34 +++++++--------------- .../mobile/set_cloud_app_properties_request.cc | 6 ---- .../src/policies/policy_handler.cc | 11 +++++-- .../application_manager/src/smart_object_keys.cc | 1 + .../policy/policy_external/policy/policy_manager.h | 8 ++--- .../policy/policy_regular/policy/policy_manager.h | 8 ++--- .../policy_external/policy/mock_cache_manager.h | 4 +-- .../policy_external/policy/mock_policy_manager.h | 4 +-- .../policy_regular/policy/mock_cache_manager.h | 4 +-- .../policy_regular/policy/mock_policy_manager.h | 4 +-- src/components/interfaces/MOBILE_API.xml | 6 ++-- .../policy_external/include/policy/cache_manager.h | 8 ++--- .../include/policy/cache_manager_interface.h | 8 ++--- .../include/policy/policy_manager_impl.h | 8 ++--- .../policy/policy_external/src/cache_manager.cc | 6 ++-- .../policy_external/src/policy_manager_impl.cc | 6 ++-- .../policy_regular/include/policy/cache_manager.h | 8 ++--- .../include/policy/cache_manager_interface.h | 8 ++--- .../include/policy/policy_manager_impl.h | 8 ++--- .../policy/policy_regular/src/cache_manager.cc | 6 ++-- .../policy_regular/src/policy_manager_impl.cc | 6 ++-- 22 files changed, 77 insertions(+), 86 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 aaca228eda..2e8b02d06b 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 @@ -188,6 +188,7 @@ extern const char* green; extern const char* blue; extern const char* display_layout; extern const char* icon_resumed; +extern const char* nicknames; extern const char* enabled; extern const char* auth_token; extern const char* cloud_transport_type; diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/get_cloud_app_properties_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/get_cloud_app_properties_request.cc index 62c91ff3d5..34ed30c243 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/get_cloud_app_properties_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/get_cloud_app_properties_request.cc @@ -54,32 +54,20 @@ void GetCloudAppPropertiesRequest::Run() { return; } - ApplicationSharedPtr cloud_app = - application_manager_.application_by_policy_id(policy_app_id); - std::string cloud_name; - if (cloud_app) { - cloud_name = cloud_app->name().AsMBString(); - } else { - policy::StringArray nicknames; - policy::StringArray app_hmi_types; - - policy_handler_.GetInitialAppData( - policy_app_id, &nicknames, &app_hmi_types); - - if (!nicknames.size()) { - LOG4CXX_ERROR(logger_, "Cloud App missing nickname"); - SendResponse(false, - mobile_apis::Result::DATA_NOT_AVAILABLE, - "No available nick names for the requested app"); - return; - } - cloud_name = nicknames[0]; - } + policy::StringArray nicknames; + policy::StringArray app_hmi_types; + + policy_handler_.GetInitialAppData(policy_app_id, &nicknames, &app_hmi_types); smart_objects::SmartObject response_params(smart_objects::SmartType_Map); smart_objects::SmartObject properties(smart_objects::SmartType_Map); - - properties[strings::app_name] = cloud_name; + smart_objects::SmartObject nicknames_array(smart_objects::SmartType_Array); + size_t i = 0; + for (std::string nickname : nicknames) { + nicknames_array[i] = nickname; + ++i; + } + properties[strings::nicknames] = nicknames_array; properties[strings::app_id] = policy_app_id; properties[strings::enabled] = enabled; diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/set_cloud_app_properties_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/set_cloud_app_properties_request.cc index 663881a2ea..5173be56d6 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/set_cloud_app_properties_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/set_cloud_app_properties_request.cc @@ -29,12 +29,6 @@ void SetCloudAppPropertiesRequest::Run() { return; } - if ((*message_)[strings::msg_params].empty()) { - LOG4CXX_ERROR(logger_, strings::msg_params << " is empty."); - SendResponse(false, mobile_apis::Result::INVALID_DATA); - return; - } - policy_handler_.OnSetCloudAppProperties(*message_); SendResponse(true, mobile_apis::Result::SUCCESS); diff --git a/src/components/application_manager/src/policies/policy_handler.cc b/src/components/application_manager/src/policies/policy_handler.cc index 2dc9f73373..691ac21040 100644 --- a/src/components/application_manager/src/policies/policy_handler.cc +++ b/src/components/application_manager/src/policies/policy_handler.cc @@ -1954,9 +1954,14 @@ void PolicyHandler::OnSetCloudAppProperties( policy_manager_->SetAppEndpoint(policy_app_id, properties[strings::endpoint].asString()); } - if (properties.keyExists(strings::app_name)) { - policy_manager_->SetAppName(policy_app_id, - properties[strings::app_name].asString()); + if (properties.keyExists(strings::nicknames)) { + StringArray nicknames; + const smart_objects::SmartObject& nicknames_array = + properties[strings::nicknames]; + for (size_t i = 0; i < nicknames_array.length(); ++i) { + nicknames.push_back(nicknames_array[i].asString()); + } + policy_manager_->SetAppNicknames(policy_app_id, nicknames); } if (properties.keyExists(strings::hybrid_app_preference)) { std::string hybrid_app_preference; diff --git a/src/components/application_manager/src/smart_object_keys.cc b/src/components/application_manager/src/smart_object_keys.cc index 109739c359..485b59c520 100644 --- a/src/components/application_manager/src/smart_object_keys.cc +++ b/src/components/application_manager/src/smart_object_keys.cc @@ -155,6 +155,7 @@ const char* green = "green"; const char* blue = "blue"; const char* display_layout = "displayLayout"; const char* icon_resumed = "iconResumed"; +const char* nicknames = "nicknames"; const char* enabled = "enabled"; const char* auth_token = "authToken"; const char* cloud_transport_type = "cloudTransportType"; diff --git a/src/components/include/policy/policy_external/policy/policy_manager.h b/src/components/include/policy/policy_external/policy/policy_manager.h index c1c2b419a1..64306d7e0a 100644 --- a/src/components/include/policy/policy_external/policy/policy_manager.h +++ b/src/components/include/policy/policy_external/policy/policy_manager.h @@ -600,11 +600,11 @@ class PolicyManager : public usage_statistics::StatisticsManager { const std::string& endpoint) = 0; /** - * @brief Set a cloud app's name - * @param app_name Nickname for cloud app + * @brief Set a cloud app's nicknames + * @param nicknames Nicknames for cloud app */ - virtual void SetAppName(const std::string& policy_app_id, - const std::string& app_name) = 0; + virtual void SetAppNicknames(const std::string& policy_app_id, + const StringArray& nicknames) = 0; /** * @brief Set the user preference for how a hybrid (cloud and mobile) app diff --git a/src/components/include/policy/policy_regular/policy/policy_manager.h b/src/components/include/policy/policy_regular/policy/policy_manager.h index 2a5a6c2239..0528dc9f36 100644 --- a/src/components/include/policy/policy_regular/policy/policy_manager.h +++ b/src/components/include/policy/policy_regular/policy/policy_manager.h @@ -581,11 +581,11 @@ class PolicyManager : public usage_statistics::StatisticsManager { const std::string& endpoint) = 0; /** - * @brief Set a cloud app's name - * @param app_name Nickname for cloud app + * @brief Set a cloud app's nicknames + * @param nicknames Nicknames for cloud app */ - virtual void SetAppName(const std::string& policy_app_id, - const std::string& app_name) = 0; + virtual void SetAppNicknames(const std::string& policy_app_id, + const StringArray& nicknames) = 0; /** * @brief Set the user preference for how a hybrid (cloud and mobile) app diff --git a/src/components/include/test/policy/policy_external/policy/mock_cache_manager.h b/src/components/include/test/policy/policy_external/policy/mock_cache_manager.h index 04cc0347c3..2885126fd1 100644 --- a/src/components/include/test/policy/policy_external/policy/mock_cache_manager.h +++ b/src/components/include/test/policy/policy_external/policy/mock_cache_manager.h @@ -98,9 +98,9 @@ class MockCacheManagerInterface : public ::policy::CacheManagerInterface { MOCK_METHOD2(SetAppEndpoint, void(const std::string& policy_app_id, const std::string& endpoint)); - MOCK_METHOD2(SetAppName, + MOCK_METHOD2(SetAppNicknames, void(const std::string& policy_app_id, - const std::string& app_name)); + const StringArray& nicknames)); MOCK_METHOD2(SetHybridAppPreference, void(const std::string& policy_app_id, const std::string& hybrid_app_preference)); diff --git a/src/components/include/test/policy/policy_external/policy/mock_policy_manager.h b/src/components/include/test/policy/policy_external/policy/mock_policy_manager.h index f1abdc496e..d7d81b3476 100644 --- a/src/components/include/test/policy/policy_external/policy/mock_policy_manager.h +++ b/src/components/include/test/policy/policy_external/policy/mock_policy_manager.h @@ -207,9 +207,9 @@ class MockPolicyManager : public PolicyManager { MOCK_METHOD2(SetAppEndpoint, void(const std::string& policy_app_id, const std::string& endpoint)); - MOCK_METHOD2(SetAppName, + MOCK_METHOD2(SetAppNicknames, void(const std::string& policy_app_id, - const std::string& app_name)); + const StringArray& nicknames)); MOCK_METHOD2(SetHybridAppPreference, void(const std::string& policy_app_id, const std::string& hybrid_app_preference)); diff --git a/src/components/include/test/policy/policy_regular/policy/mock_cache_manager.h b/src/components/include/test/policy/policy_regular/policy/mock_cache_manager.h index 0b6af6fd6f..ff186b5ab4 100644 --- a/src/components/include/test/policy/policy_regular/policy/mock_cache_manager.h +++ b/src/components/include/test/policy/policy_regular/policy/mock_cache_manager.h @@ -85,9 +85,9 @@ class MockCacheManagerInterface : public CacheManagerInterface { MOCK_METHOD2(SetAppEndpoint, void(const std::string& policy_app_id, const std::string& endpoint)); - MOCK_METHOD2(SetAppName, + MOCK_METHOD2(SetAppNicknames, void(const std::string& policy_app_id, - const std::string& app_name)); + const StringArray& nicknames)); MOCK_METHOD2(SetHybridAppPreference, void(const std::string& policy_app_id, const std::string& hybrid_app_preference)); diff --git a/src/components/include/test/policy/policy_regular/policy/mock_policy_manager.h b/src/components/include/test/policy/policy_regular/policy/mock_policy_manager.h index de24b8b949..4e3121397f 100644 --- a/src/components/include/test/policy/policy_regular/policy/mock_policy_manager.h +++ b/src/components/include/test/policy/policy_regular/policy/mock_policy_manager.h @@ -203,9 +203,9 @@ class MockPolicyManager : public PolicyManager { MOCK_METHOD2(SetAppEndpoint, void(const std::string& policy_app_id, const std::string& endpoint)); - MOCK_METHOD2(SetAppName, + MOCK_METHOD2(SetAppNicknames, void(const std::string& policy_app_id, - const std::string& app_name)); + const StringArray& nicknames)); MOCK_METHOD2(SetHybridAppPreference, void(const std::string& policy_app_id, const std::string& hybrid_app_preference)); diff --git a/src/components/interfaces/MOBILE_API.xml b/src/components/interfaces/MOBILE_API.xml index 33613d2eca..e7dbc1e089 100644 --- a/src/components/interfaces/MOBILE_API.xml +++ b/src/components/interfaces/MOBILE_API.xml @@ -553,7 +553,9 @@ - + + An array of app names a cloud app is allowed to register with. If included in a SetCloudAppProperties request, this value will overwrite the existing "nicknames" field in the app policies section of the policy table. + If true, cloud app will be included in HMI RPC UpdateAppList @@ -963,7 +965,7 @@ Similar to VP8, but VP9 is customized for video resolutions beyond high-definition video (UHD) and also enables lossless compression. - + diff --git a/src/components/policy/policy_external/include/policy/cache_manager.h b/src/components/policy/policy_external/include/policy/cache_manager.h index 943bf1e743..a1db3536c2 100644 --- a/src/components/policy/policy_external/include/policy/cache_manager.h +++ b/src/components/policy/policy_external/include/policy/cache_manager.h @@ -228,11 +228,11 @@ class CacheManager : public CacheManagerInterface { const std::string& endpoint); /** - * @brief Set a cloud app's name - * @param app_name Nickname for cloud app + * @brief Set a cloud app's nicknames + * @param nicknames Nicknames for cloud app */ - virtual void SetAppName(const std::string& policy_app_id, - const std::string& app_name); + virtual void SetAppNicknames(const std::string& policy_app_id, + const StringArray& nicknames); /** * @brief Set the user preference for how a hybrid (cloud and mobile) app diff --git a/src/components/policy/policy_external/include/policy/cache_manager_interface.h b/src/components/policy/policy_external/include/policy/cache_manager_interface.h index bafc65e208..78546823c4 100644 --- a/src/components/policy/policy_external/include/policy/cache_manager_interface.h +++ b/src/components/policy/policy_external/include/policy/cache_manager_interface.h @@ -236,11 +236,11 @@ class CacheManagerInterface { const std::string& endpoint) = 0; /** - * @brief Set a cloud app's name - * @param app_name Nickname for cloud app + * @brief Set a cloud app's nicknames + * @param nicknames Nicknames for cloud app */ - virtual void SetAppName(const std::string& policy_app_id, - const std::string& app_name) = 0; + virtual void SetAppNicknames(const std::string& policy_app_id, + const StringArray& nicknames) = 0; /** * @brief Set the user preference for how a hybrid (cloud and mobile) app diff --git a/src/components/policy/policy_external/include/policy/policy_manager_impl.h b/src/components/policy/policy_external/include/policy/policy_manager_impl.h index d73409ec17..8ba0aafacc 100644 --- a/src/components/policy/policy_external/include/policy/policy_manager_impl.h +++ b/src/components/policy/policy_external/include/policy/policy_manager_impl.h @@ -647,11 +647,11 @@ class PolicyManagerImpl : public PolicyManager { const std::string& endpoint) OVERRIDE; /** - * @brief Set a cloud app's name - * @param app_name Nickname for cloud app + * @brief Set a cloud app's nicknames + * @param nicknames Nicknames for cloud app */ - void SetAppName(const std::string& policy_app_id, - const std::string& app_name) OVERRIDE; + void SetAppNicknames(const std::string& policy_app_id, + const StringArray& nicknames) OVERRIDE; /** * @brief Set the user preference for how a hybrid (cloud and mobile) app diff --git a/src/components/policy/policy_external/src/cache_manager.cc b/src/components/policy/policy_external/src/cache_manager.cc index 23bca24476..c105a9161d 100644 --- a/src/components/policy/policy_external/src/cache_manager.cc +++ b/src/components/policy/policy_external/src/cache_manager.cc @@ -1500,14 +1500,14 @@ void CacheManager::SetAppEndpoint(const std::string& policy_app_id, } } -void CacheManager::SetAppName(const std::string& policy_app_id, - const std::string& app_name) { +void CacheManager::SetAppNicknames(const std::string& policy_app_id, + const StringArray& nicknames) { policy_table::ApplicationPolicies& policies = pt_->policy_table.app_policies_section.apps; policy_table::ApplicationPolicies::iterator policy_iter = policies.find(policy_app_id); if (policies.end() != policy_iter) { - (*policy_iter).second.nicknames->push_back(app_name); + (*(*policy_iter).second.nicknames) = nicknames; } } diff --git a/src/components/policy/policy_external/src/policy_manager_impl.cc b/src/components/policy/policy_external/src/policy_manager_impl.cc index 6931ec87b8..28e493c115 100644 --- a/src/components/policy/policy_external/src/policy_manager_impl.cc +++ b/src/components/policy/policy_external/src/policy_manager_impl.cc @@ -782,9 +782,9 @@ void PolicyManagerImpl::SetAppEndpoint(const std::string& policy_app_id, cache_->SetAppEndpoint(policy_app_id, endpoint); } -void PolicyManagerImpl::SetAppName(const std::string& policy_app_id, - const std::string& app_name) { - cache_->SetAppName(policy_app_id, app_name); +void PolicyManagerImpl::SetAppNicknames(const std::string& policy_app_id, + const StringArray& nicknames) { + cache_->SetAppNicknames(policy_app_id, nicknames); } void PolicyManagerImpl::SetHybridAppPreference( diff --git a/src/components/policy/policy_regular/include/policy/cache_manager.h b/src/components/policy/policy_regular/include/policy/cache_manager.h index b6b6691985..b789c7252c 100644 --- a/src/components/policy/policy_regular/include/policy/cache_manager.h +++ b/src/components/policy/policy_regular/include/policy/cache_manager.h @@ -216,11 +216,11 @@ class CacheManager : public CacheManagerInterface { const std::string& endpoint); /** - * @brief Set a cloud app's name - * @param app_name Nickname for cloud app + * @brief Set a cloud app's nicknames + * @param nicknames Nicknames for cloud app */ - virtual void SetAppName(const std::string& policy_app_id, - const std::string& app_name); + virtual void SetAppNicknames(const std::string& policy_app_id, + const StringArray& nicknames); /** * @brief Set the user preference for how a hybrid (cloud and mobile) app diff --git a/src/components/policy/policy_regular/include/policy/cache_manager_interface.h b/src/components/policy/policy_regular/include/policy/cache_manager_interface.h index 13479f7595..4a59bfb8a9 100644 --- a/src/components/policy/policy_regular/include/policy/cache_manager_interface.h +++ b/src/components/policy/policy_regular/include/policy/cache_manager_interface.h @@ -222,11 +222,11 @@ class CacheManagerInterface { const std::string& endpoint) = 0; /** - * @brief Set a cloud app's name - * @param app_name Nickname for cloud app + * @brief Set a cloud app's nicknames + * @param nicknames Nicknames for cloud app */ - virtual void SetAppName(const std::string& policy_app_id, - const std::string& app_name) = 0; + virtual void SetAppNicknames(const std::string& policy_app_id, + const StringArray& nicknames) = 0; /** * @brief Set the user preference for how a hybrid (cloud and mobile) app * should be used diff --git a/src/components/policy/policy_regular/include/policy/policy_manager_impl.h b/src/components/policy/policy_regular/include/policy/policy_manager_impl.h index 5e46ff9fa1..1b5a78ed00 100644 --- a/src/components/policy/policy_regular/include/policy/policy_manager_impl.h +++ b/src/components/policy/policy_regular/include/policy/policy_manager_impl.h @@ -642,11 +642,11 @@ class PolicyManagerImpl : public PolicyManager { const std::string& endpoint) OVERRIDE; /** - * @brief Set a cloud app's name - * @param app_name Nickname for cloud app + * @brief Set a cloud app's nicknames + * @param nicknames Nicknames for cloud app */ - void SetAppName(const std::string& policy_app_id, - const std::string& app_name) OVERRIDE; + void SetAppNicknames(const std::string& policy_app_id, + const StringArray& nicknames) OVERRIDE; /** * @brief Set the user preference for how a hybrid (cloud and mobile) app diff --git a/src/components/policy/policy_regular/src/cache_manager.cc b/src/components/policy/policy_regular/src/cache_manager.cc index 9407f28132..a8e033d505 100644 --- a/src/components/policy/policy_regular/src/cache_manager.cc +++ b/src/components/policy/policy_regular/src/cache_manager.cc @@ -795,14 +795,14 @@ void CacheManager::SetAppEndpoint(const std::string& policy_app_id, } } -void CacheManager::SetAppName(const std::string& policy_app_id, - const std::string& app_name) { +void CacheManager::SetAppNicknames(const std::string& policy_app_id, + const StringArray& nicknames) { policy_table::ApplicationPolicies& policies = pt_->policy_table.app_policies_section.apps; policy_table::ApplicationPolicies::iterator policy_iter = policies.find(policy_app_id); if (policies.end() != policy_iter) { - (*policy_iter).second.nicknames->push_back(app_name); + (*(*policy_iter).second.nicknames) = nicknames; } } diff --git a/src/components/policy/policy_regular/src/policy_manager_impl.cc b/src/components/policy/policy_regular/src/policy_manager_impl.cc index 12502bc6d4..bbd843b7c2 100644 --- a/src/components/policy/policy_regular/src/policy_manager_impl.cc +++ b/src/components/policy/policy_regular/src/policy_manager_impl.cc @@ -601,9 +601,9 @@ void PolicyManagerImpl::SetAppEndpoint(const std::string& policy_app_id, cache_->SetAppEndpoint(policy_app_id, endpoint); } -void PolicyManagerImpl::SetAppName(const std::string& policy_app_id, - const std::string& app_name) { - cache_->SetAppName(policy_app_id, app_name); +void PolicyManagerImpl::SetAppNicknames(const std::string& policy_app_id, + const StringArray& nicknames) { + cache_->SetAppNicknames(policy_app_id, nicknames); } void PolicyManagerImpl::SetHybridAppPreference( -- cgit v1.2.1 From 222ec0566594288744d73ef30174e714bd6f29ce Mon Sep 17 00:00:00 2001 From: Shobhit Adlakha Date: Wed, 6 Mar 2019 13:36:58 -0500 Subject: GetFile RPC (#2811) * Implemented GetFile rpc in MOBILE API * Initial implementation of GetFile rpc * Implemented GetFile RPC * Fixed binary data param in GetFile response * Added case for handling SmartType UInteger in SmartObject::duplicate function * Implemented offset and length params * Implemented GetFile for services published by the HMI * Switched to events to handle forwarding GetFile request to HMI * Addressed review comments * Addressed review comments * Addressed review comments * Implemented length parameter * Changed RPC name from GetFileFromHMI to GetFilePath * Fix MOBILE_API formatting * Fix HMI_API formatting * Addressed review comments * Checking success rather than result code for hmi response --- src/appMain/sdl_preloaded_pt.json | 6 + .../commands/command_request_impl.h | 10 +- .../application_manager/smart_object_keys.h | 2 + .../commands/hmi/bc_get_file_path_request.h | 77 +++++ .../commands/hmi/bc_get_file_path_response.h | 77 +++++ .../commands/mobile/get_file_request.h | 87 +++++ .../commands/mobile/get_file_response.h | 77 +++++ .../src/commands/hmi/bc_get_file_path_request.cc | 62 ++++ .../src/commands/hmi/bc_get_file_path_response.cc | 66 ++++ .../src/commands/mobile/get_file_request.cc | 353 +++++++++++++++++++++ .../src/commands/mobile/get_file_response.cc | 63 ++++ .../sdl_rpc_plugin/src/hmi_command_factory.cc | 7 + .../sdl_rpc_plugin/src/mobile_command_factory.cc | 7 + .../src/commands/command_request_impl.cc | 7 +- .../application_manager/src/hmi_interfaces_impl.cc | 2 + .../application_manager/src/smart_object_keys.cc | 2 + src/components/interfaces/HMI_API.xml | 23 ++ src/components/interfaces/MOBILE_API.xml | 59 ++++ .../include/policy/policy_table/enums.h | 5 + .../policy_external/src/policy_table/enums.cc | 5 + .../include/policy/policy_table/enums.h | 5 + .../policy_regular/src/policy_table/enums.cc | 9 + src/components/smart_objects/src/smart_object.cc | 3 + src/components/utils/include/utils/file_system.h | 13 + src/components/utils/src/file_system.cc | 20 ++ 25 files changed, 1041 insertions(+), 6 deletions(-) create mode 100644 src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/bc_get_file_path_request.h create mode 100644 src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/bc_get_file_path_response.h create mode 100644 src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/get_file_request.h create mode 100644 src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/get_file_response.h create mode 100644 src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/bc_get_file_path_request.cc create mode 100644 src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/bc_get_file_path_response.cc create mode 100644 src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/get_file_request.cc create mode 100644 src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/get_file_response.cc diff --git a/src/appMain/sdl_preloaded_pt.json b/src/appMain/sdl_preloaded_pt.json index 8041a0d4e9..fcd92e6df5 100644 --- a/src/appMain/sdl_preloaded_pt.json +++ b/src/appMain/sdl_preloaded_pt.json @@ -200,6 +200,12 @@ "LIMITED", "NONE"] }, + "GetFile": { + "hmi_levels": ["BACKGROUND", + "FULL", + "LIMITED", + "NONE"] + }, "RegisterAppInterface": { "hmi_levels": ["BACKGROUND", "FULL", diff --git a/src/components/application_manager/include/application_manager/commands/command_request_impl.h b/src/components/application_manager/include/application_manager/commands/command_request_impl.h index a5ecd7274b..e12c6de3ab 100644 --- a/src/components/application_manager/include/application_manager/commands/command_request_impl.h +++ b/src/components/application_manager/include/application_manager/commands/command_request_impl.h @@ -159,10 +159,12 @@ class CommandRequestImpl : public CommandImpl, * @param info Provides additional human readable info regarding the result * @param response_params Additional params in response */ - void SendResponse(const bool success, - const mobile_apis::Result::eType& result_code, - const char* info = NULL, - const smart_objects::SmartObject* response_params = NULL); + void SendResponse( + const bool success, + const mobile_apis::Result::eType& result_code, + const char* info = NULL, + const smart_objects::SmartObject* response_params = NULL, + const std::vector binary_data = std::vector()); /** * @brief Check syntax of string from mobile 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 5054536883..5d030dace6 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 @@ -200,6 +200,7 @@ extern const char* cloud_connection_status; // PutFile extern const char* sync_file_name; extern const char* file_name; +extern const char* file_path; extern const char* file_type; extern const char* file_size; extern const char* crc32_check_sum; @@ -316,6 +317,7 @@ extern const char* service_id; extern const char* service_manifest; extern const char* service_published; extern const char* service_active; +extern const char* app_service_id; extern const char* service_data; extern const char* request_service_active; extern const char* app_services; diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/bc_get_file_path_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/bc_get_file_path_request.h new file mode 100644 index 0000000000..fd241da3c4 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/bc_get_file_path_request.h @@ -0,0 +1,77 @@ +/* + Copyright (c) 2019, Ford Motor Company, Livio + 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 the copyright holders nor the names of their + 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. + */ + +#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_BC_GET_FILE_PATH_REQUEST_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_BC_GET_FILE_PATH_REQUEST_H_ + +#include "application_manager/commands/request_to_hmi.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief BCGetFilePathRequest command class + **/ +class BCGetFilePathRequest : public app_mngr::commands::RequestToHMI { + public: + /** + * @brief BCGetFilePathRequest class constructor + * + * @param message Incoming SmartObject message + **/ + BCGetFilePathRequest(const app_mngr::commands::MessageSharedPtr& message, + app_mngr::ApplicationManager& application_manager, + app_mngr::rpc_service::RPCService& rpc_service, + app_mngr::HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handler); + + /** + * @brief BCGetFilePathRequest class destructor + **/ + virtual ~BCGetFilePathRequest(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(BCGetFilePathRequest); +}; + +} // namespace commands + +} // namespace sdl_rpc_plugin + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_sdl_RPC_PLUGIN_INCLUDE_sdl_RPC_PLUGIN_COMMANDS_HMI_BC_GET_FILE_PATH_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/bc_get_file_path_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/bc_get_file_path_response.h new file mode 100644 index 0000000000..2a6025cbdf --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/bc_get_file_path_response.h @@ -0,0 +1,77 @@ +/* + Copyright (c) 2019, Ford Motor Company, Livio + 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 the copyright holders nor the names of their + 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. + */ + +#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_BC_GET_FILE_PATH_RESPONSE_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_BC_GET_FILE_PATH_RESPONSE_H_ + +#include "application_manager/commands/response_from_hmi.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief BCGetFilePathResponse command class + **/ +class BCGetFilePathResponse : public app_mngr::commands::ResponseFromHMI { + public: + /** + * @brief BCGetFilePathResponse class constructor + * + * @param message Incoming SmartObject message + **/ + BCGetFilePathResponse(const app_mngr::commands::MessageSharedPtr& message, + app_mngr::ApplicationManager& application_manager, + app_mngr::rpc_service::RPCService& rpc_service, + app_mngr::HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handler); + + /** + * @brief BCGetFilePathResponse class destructor + **/ + virtual ~BCGetFilePathResponse(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(BCGetFilePathResponse); +}; + +} // namespace commands + +} // namespace sdl_rpc_plugin + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_BC_GET_FILE_PATH_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/get_file_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/get_file_request.h new file mode 100644 index 0000000000..d4182ea004 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/get_file_request.h @@ -0,0 +1,87 @@ +/* + Copyright (c) 2019, Ford Motor Company, Livio + 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 the copyright holders nor the names of their + 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. + */ + +#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_GET_FILE_REQUEST_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_GET_FILE_REQUEST_H_ + +#include "application_manager/commands/command_request_impl.h" +#include "application_manager/event_engine/event.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief GetFileRequest command class + **/ +class GetFileRequest : public app_mngr::commands::CommandRequestImpl { + public: + /** + * @brief GetFileRequest class constructor + * + * @param message Incoming SmartObject message + **/ + GetFileRequest(const app_mngr::commands::MessageSharedPtr& message, + app_mngr::ApplicationManager& application_manager, + app_mngr::rpc_service::RPCService& rpc_service, + app_mngr::HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle); + + /** + * @brief GetFileRequest class destructor + **/ + virtual ~GetFileRequest(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + bool GetFilePath(std::string& file_path, bool& forward_to_hmi); + + void on_event(const app_mngr::event_engine::Event& event) FINAL; + + private: + std::string file_name_; + mobile_apis::FileType::eType file_type_; + uint32_t length_; + uint32_t offset_; + + DISALLOW_COPY_AND_ASSIGN(GetFileRequest); +}; + +} // namespace commands + +} // namespace sdl_rpc_plugin + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_GET_FILE_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/get_file_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/get_file_response.h new file mode 100644 index 0000000000..bc191d224c --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/get_file_response.h @@ -0,0 +1,77 @@ +/* + Copyright (c) 2019, Ford Motor Company, Livio + 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 the copyright holders nor the names of their + 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. + */ + +#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_GET_FILE_RESPONSE_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_GET_FILE_RESPONSE_H_ + +#include "application_manager/commands/command_response_impl.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief GetFileResponse command class + **/ +class GetFileResponse : public app_mngr::commands::CommandResponseImpl { + public: + /** + * @brief GetFileResponse class constructor + * + * @param message Incoming SmartObject message + **/ + GetFileResponse(const app_mngr::commands::MessageSharedPtr& message, + app_mngr::ApplicationManager& application_manager, + app_mngr::rpc_service::RPCService& rpc_service, + app_mngr::HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle); + + /** + * @brief GetFileResponse class destructor + **/ + virtual ~GetFileResponse(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(GetFileResponse); +}; + +} // namespace commands + +} // namespace sdl_rpc_plugin + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_GET_FILE_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/bc_get_file_path_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/bc_get_file_path_request.cc new file mode 100644 index 0000000000..b735cd9bdf --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/bc_get_file_path_request.cc @@ -0,0 +1,62 @@ +/* + Copyright (c) 2019, Ford Motor Company, Livio + 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 the copyright holders nor the names of their + 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 "sdl_rpc_plugin/commands/hmi/bc_get_file_path_request.h" +#include "application_manager/application_impl.h" +#include "application_manager/rpc_service.h" +#include "interfaces/MOBILE_API.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; +namespace commands { + +BCGetFilePathRequest::BCGetFilePathRequest( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + app_mngr::rpc_service::RPCService& rpc_service, + app_mngr::HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handler) + : RequestToHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handler) {} + +BCGetFilePathRequest::~BCGetFilePathRequest() {} + +void BCGetFilePathRequest::Run() { + LOG4CXX_AUTO_TRACE(logger_); + SendRequest(); +} + +} // namespace commands +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/bc_get_file_path_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/bc_get_file_path_response.cc new file mode 100644 index 0000000000..b86ab6a2b8 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/bc_get_file_path_response.cc @@ -0,0 +1,66 @@ +/* + Copyright (c) 2019, Ford Motor Company, Livio + 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 the copyright holders nor the names of their + 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 "sdl_rpc_plugin/commands/hmi/bc_get_file_path_response.h" +#include "application_manager/application_impl.h" +#include "application_manager/rpc_service.h" +#include "interfaces/MOBILE_API.h" +#include "application_manager/event_engine/event.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; +namespace commands { + +BCGetFilePathResponse::BCGetFilePathResponse( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + app_mngr::rpc_service::RPCService& rpc_service, + app_mngr::HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handler) + : ResponseFromHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handler) {} + +BCGetFilePathResponse::~BCGetFilePathResponse() {} + +void BCGetFilePathResponse::Run() { + LOG4CXX_AUTO_TRACE(logger_); + application_manager::event_engine::Event event( + hmi_apis::FunctionID::BasicCommunication_GetFilePath); + event.set_smart_object(*message_); + event.raise(application_manager_.event_dispatcher()); +} + +} // namespace commands +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/get_file_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/get_file_request.cc new file mode 100644 index 0000000000..c0fbcee146 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/get_file_request.cc @@ -0,0 +1,353 @@ +/* + Copyright (c) 2019, Ford Motor Company, Livio + 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 the copyright holders nor the names of their + 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 "sdl_rpc_plugin/commands/mobile/get_file_request.h" +#include "application_manager/application_impl.h" +#include "application_manager/rpc_service.h" +#include "interfaces/MOBILE_API.h" +#include "application_manager/message_helper.h" +#include "application_manager/app_service_manager.h" +#include "utils/file_system.h" +#include + +namespace { +/** +* Calculates CRC32 checksum +* @param binary_data - input data for which CRC32 should be calculated +* @return calculated CRC32 checksum +*/ +uint32_t GetCrc32CheckSum(const std::vector& binary_data) { + const std::size_t file_size = binary_data.size(); + boost::crc_32_type result; + result.process_bytes(&binary_data[0], file_size); + return result.checksum(); +} + +} // namespace + +namespace sdl_rpc_plugin { +using namespace application_manager; +namespace commands { + +GetFileRequest::GetFileRequest( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + app_mngr::rpc_service::RPCService& rpc_service, + app_mngr::HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handler) + : CommandRequestImpl(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handler) + , file_name_("") + , file_type_(mobile_apis::FileType::INVALID_ENUM) + , length_(0) + , offset_(0) {} + +GetFileRequest::~GetFileRequest() {} + +bool GetFileRequest::GetFilePath(std::string& file_path, bool& forward_to_hmi) { + std::string path = application_manager_.get_settings().app_storage_folder(); + auto connect_key = connection_key(); + forward_to_hmi = false; + + if ((*message_)[strings::msg_params].keyExists(strings::app_service_id)) { + std::string service_id = + (*message_)[strings::msg_params][strings::app_service_id].asString(); + LOG4CXX_DEBUG(logger_, + "Finding storage directory for service id: " << service_id); + + AppService* app_service_info = + application_manager_.GetAppServiceManager().FindServiceByID(service_id); + if (app_service_info) { + if (app_service_info->mobile_service) { + connect_key = app_service_info->connection_key; + } else { + forward_to_hmi = true; + return true; + } + } else { + return false; + } + } else { + LOG4CXX_DEBUG(logger_, "Using current storage directory"); + } + + ApplicationSharedPtr app = application_manager_.application(connect_key); + file_path = path + "/" + app->folder_name(); + return true; +} + +void GetFileRequest::Run() { + LOG4CXX_AUTO_TRACE(logger_); + LOG4CXX_INFO(logger_, "Received GetFile request"); + + ApplicationSharedPtr app = application_manager_.application(connection_key()); + smart_objects::SmartObject response_params = + smart_objects::SmartObject(smart_objects::SmartType_Map); + + if (!app) { + LOG4CXX_ERROR(logger_, "Application is not registered"); + SendResponse(false, mobile_apis::Result::APPLICATION_NOT_REGISTERED); + return; + } + + file_name_ = (*message_)[strings::msg_params][strings::file_name].asString(); + + if (!file_system::IsFileNameValid(file_name_)) { + LOG4CXX_ERROR(logger_, + "File name " << file_name_ << " contains forbidden symbols."); + SendResponse(false, + mobile_apis::Result::INVALID_DATA, + "File name contains forbidden symbols", + &response_params); + return; + } + + // Initialize other params with default values. If exists overwrite the values + LOG4CXX_DEBUG(logger_, "Intialize non manadatory params with default values"); + + if ((*message_)[strings::msg_params].keyExists(strings::file_type)) { + file_type_ = static_cast( + (*message_)[strings::msg_params][strings::file_type].asInt()); + } + + // Check if file exists on system (may have to use app service id to get the + // correct app folder) + LOG4CXX_DEBUG(logger_, "Check if file exists on system"); + std::string file_path; + bool forward_to_hmi; + + if (GetFilePath(file_path, forward_to_hmi)) { + if (forward_to_hmi) { + LOG4CXX_DEBUG(logger_, "Forwarding GetFile request to HMI"); + SendHMIRequest(hmi_apis::FunctionID::BasicCommunication_GetFilePath, + &(*message_)[strings::msg_params], + true); + return; + } + } else { + LOG4CXX_ERROR(logger_, "Could not get file path"); + SendResponse(false, + mobile_apis::Result::INVALID_DATA, + "Could not get file path", + &response_params); + return; + } + + const std::string full_path = file_path + "/" + file_name_; + if (!file_system::FileExists(full_path)) { + LOG4CXX_ERROR(logger_, "File " << full_path << " does not exist"); + SendResponse(false, + mobile_apis::Result::FILE_NOT_FOUND, + "File does not exist", + &response_params); + return; + } + + // Handle offset + LOG4CXX_DEBUG(logger_, "Handle offset and length parameters"); + const uint64_t file_size = file_system::FileSize(full_path); + + if ((*message_)[strings::msg_params].keyExists(strings::offset)) { + offset_ = (*message_)[strings::msg_params][strings::offset].asUInt(); + } + + length_ = file_size - offset_; + if ((*message_)[strings::msg_params].keyExists(strings::length)) { + length_ = std::min( + static_cast( + (*message_)[strings::msg_params][strings::length].asUInt()), + length_); + } + + if (offset_ > file_size) { + LOG4CXX_ERROR(logger_, + "Offset " << offset_ << " greater than file size " + << file_size); + SendResponse(false, + mobile_apis::Result::INVALID_DATA, + "Offset greater than file size", + &response_params); + return; + } + if (length_ > file_size - offset_) { + LOG4CXX_ERROR(logger_, + "Length " << length_ << " greater than file size - offset" + << file_size); + SendResponse(false, + mobile_apis::Result::INVALID_DATA, + "Length greater than file size - offset", + &response_params); + return; + } + + // Load data from file as binary data + LOG4CXX_DEBUG(logger_, "Load binary data from file"); + std::vector bin_data; + if (!file_system::ReadBinaryFile(full_path, bin_data, offset_, length_)) { + LOG4CXX_ERROR(logger_, "Failed to read from file: " << full_path); + SendResponse(false, + mobile_apis::Result::GENERIC_ERROR, + "Unable to read from file", + &response_params); + return; + } + + // Construct response message + if ((*message_)[strings::msg_params].keyExists(strings::offset)) { + response_params[strings::offset] = offset_; + } + if ((*message_)[strings::msg_params].keyExists(strings::length)) { + response_params[strings::length] = length_; + } + if ((*message_)[strings::msg_params].keyExists(strings::file_type)) { + response_params[strings::file_type] = file_type_; + } + const uint32_t crc_calculated = GetCrc32CheckSum(bin_data); + response_params[strings::crc32_check_sum] = crc_calculated; + + SendResponse(true, + mobile_apis::Result::SUCCESS, + "File uploaded", + &response_params, + bin_data); +} + +void GetFileRequest::on_event(const app_mngr::event_engine::Event& event) { + LOG4CXX_AUTO_TRACE(logger_); + + if (hmi_apis::FunctionID::BasicCommunication_GetFilePath != event.id()) { + return; + } + const smart_objects::SmartObject& event_message = event.smart_object(); + + hmi_apis::Common_Result::eType hmi_result = + static_cast( + event_message[strings::params][hmi_response::code].asInt()); + + mobile_apis::Result::eType result = + MessageHelper::HMIToMobileResult(hmi_result); + bool success = PrepareResultForMobileResponse( + hmi_result, HmiInterfaces::HMI_INTERFACE_AppService); + + if (!success) { + auto msg_params = event_message[strings::msg_params]; + const char* info = msg_params.keyExists(strings::info) + ? msg_params[strings::info].asCharArray() + : NULL; + + SendResponse(false, result, info, &msg_params); + return; + } + smart_objects::SmartObject response_params = + smart_objects::SmartObject(smart_objects::SmartType_Map); + std::vector bin_data; + + if (event_message[strings::msg_params].keyExists(strings::file_type)) { + response_params[strings::file_type] = + event_message[strings::msg_params][strings::file_type]; + } + + if (event_message[strings::msg_params].keyExists(strings::file_path)) { + std::string full_path = + event_message[strings::msg_params][strings::file_path].asString(); + + if (!file_system::FileExists(full_path)) { + LOG4CXX_ERROR(logger_, "File " << full_path << " does not exist"); + SendResponse(false, + mobile_apis::Result::FILE_NOT_FOUND, + "File does not exist", + &response_params); + return; + } + + const uint64_t file_size = file_system::FileSize(full_path); + if ((*message_)[strings::msg_params].keyExists(strings::offset)) { + offset_ = (*message_)[strings::msg_params][strings::offset].asUInt(); + } + + length_ = file_size - offset_; + if ((*message_)[strings::msg_params].keyExists(strings::length)) { + length_ = std::min( + static_cast( + (*message_)[strings::msg_params][strings::length].asUInt()), + length_); + } + + if (offset_ > file_size) { + LOG4CXX_ERROR(logger_, + "Offset " << offset_ << " greater than file size " + << file_size); + SendResponse(false, + mobile_apis::Result::INVALID_DATA, + "Offset greater than file size", + &response_params); + return; + } + if (length_ > file_size - offset_) { + LOG4CXX_ERROR(logger_, + "Length " << length_ << " greater than file size - offset" + << file_size); + SendResponse(false, + mobile_apis::Result::INVALID_DATA, + "Length greater than file size - offset", + &response_params); + return; + } + if (!file_system::ReadBinaryFile(full_path, bin_data, offset_, length_)) { + LOG4CXX_ERROR(logger_, "Failed to read from file: " << full_path); + SendResponse(false, + mobile_apis::Result::GENERIC_ERROR, + "Failed to read from file", + &response_params); + return; + } + + const uint32_t crc_calculated = GetCrc32CheckSum(bin_data); + response_params[strings::crc32_check_sum] = crc_calculated; + + } else { + LOG4CXX_ERROR(logger_, "HMI did not return a file path: "); + SendResponse(false, + mobile_apis::Result::INVALID_DATA, + "HMI did not return a file path", + &response_params); + return; + } + + SendResponse(true, result, "File uploaded", &response_params, bin_data); +} + +} // namespace commands +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/get_file_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/get_file_response.cc new file mode 100644 index 0000000000..2ea8dde02a --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/get_file_response.cc @@ -0,0 +1,63 @@ +/* + Copyright (c) 2019, Ford Motor Company, Livio + 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 the copyright holders nor the names of their + 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 "sdl_rpc_plugin/commands/mobile/get_file_response.h" +#include "application_manager/application_impl.h" +#include "application_manager/rpc_service.h" +#include "interfaces/MOBILE_API.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; +namespace commands { + +GetFileResponse::GetFileResponse( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + app_mngr::rpc_service::RPCService& rpc_service, + app_mngr::HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handler) + : CommandResponseImpl(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handler) {} + +GetFileResponse::~GetFileResponse() {} + +void GetFileResponse::Run() { + LOG4CXX_AUTO_TRACE(logger_); + LOG4CXX_INFO(logger_, "Sending GetFile response"); + rpc_service_.SendMessageToMobile(message_); +} + +} // namespace commands +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/hmi_command_factory.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/hmi_command_factory.cc index dc94474b9d..3cfe4d7118 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/hmi_command_factory.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/hmi_command_factory.cc @@ -240,6 +240,8 @@ #include "sdl_rpc_plugin/commands/hmi/rc_is_ready_response.h" #include "sdl_rpc_plugin/commands/hmi/rc_get_capabilities_request.h" #include "sdl_rpc_plugin/commands/hmi/rc_get_capabilities_response.h" +#include "sdl_rpc_plugin/commands/hmi/bc_get_file_path_request.h" +#include "sdl_rpc_plugin/commands/hmi/bc_get_file_path_response.h" #include "sdl_rpc_plugin/commands/hmi/on_bc_system_capability_updated_notification.h" @@ -842,6 +844,11 @@ CommandCreator& HMICommandFactory::get_creator_factory( ? factory.GetCreator() : factory.GetCreator(); } + case hmi_apis::FunctionID::BasicCommunication_GetFilePath: { + return hmi_apis::messageType::request == message_type + ? factory.GetCreator() + : factory.GetCreator(); + } case hmi_apis::FunctionID::BasicCommunication_OnSystemCapabilityUpdated: { return factory .GetCreator(); diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/mobile_command_factory.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/mobile_command_factory.cc index 77be545e0b..f12dcbb485 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/mobile_command_factory.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/mobile_command_factory.cc @@ -127,6 +127,8 @@ #include "sdl_rpc_plugin/commands/mobile/send_haptic_data_response.h" #include "sdl_rpc_plugin/commands/mobile/set_cloud_app_properties_request.h" #include "sdl_rpc_plugin/commands/mobile/set_cloud_app_properties_response.h" +#include "sdl_rpc_plugin/commands/mobile/get_file_request.h" +#include "sdl_rpc_plugin/commands/mobile/get_file_response.h" #include "interfaces/MOBILE_API.h" CREATE_LOGGERPTR_GLOBAL(logger_, "ApplicationManager") @@ -234,6 +236,11 @@ CommandCreator& MobileCommandFactory::get_creator_factory( ? factory.GetCreator() : factory.GetCreator(); } + case mobile_apis::FunctionID::GetFileID: { + return mobile_api::messageType::request == message_type + ? factory.GetCreator() + : factory.GetCreator(); + } case mobile_apis::FunctionID::DeleteFileID: { return mobile_api::messageType::request == message_type ? factory.GetCreator() diff --git a/src/components/application_manager/src/commands/command_request_impl.cc b/src/components/application_manager/src/commands/command_request_impl.cc index 8d339d4d14..970f8802c0 100644 --- a/src/components/application_manager/src/commands/command_request_impl.cc +++ b/src/components/application_manager/src/commands/command_request_impl.cc @@ -266,7 +266,8 @@ void CommandRequestImpl::SendResponse( const bool success, const mobile_apis::Result::eType& result_code, const char* info, - const smart_objects::SmartObject* response_params) { + const smart_objects::SmartObject* response_params, + const std::vector binary_data) { LOG4CXX_AUTO_TRACE(logger_); { sync_primitives::AutoLock auto_lock(state_lock_); @@ -291,7 +292,9 @@ void CommandRequestImpl::SendResponse( CommandImpl::protocol_version_; response[strings::params][strings::connection_key] = connection_key(); response[strings::params][strings::function_id] = function_id(); - + if (!binary_data.empty()) { + response[strings::params][strings::binary_data] = binary_data; + } if (response_params) { response[strings::msg_params] = *response_params; } diff --git a/src/components/application_manager/src/hmi_interfaces_impl.cc b/src/components/application_manager/src/hmi_interfaces_impl.cc index 1d1dbe6996..9aff403e09 100644 --- a/src/components/application_manager/src/hmi_interfaces_impl.cc +++ b/src/components/application_manager/src/hmi_interfaces_impl.cc @@ -103,6 +103,8 @@ generate_function_to_interface_convert_map() { HmiInterfaces::HMI_INTERFACE_BasicCommunication; convert_map[BasicCommunication_OnEventChanged] = HmiInterfaces::HMI_INTERFACE_BasicCommunication; + convert_map[BasicCommunication_GetFilePath] = + HmiInterfaces::HMI_INTERFACE_BasicCommunication; convert_map[VR_IsReady] = HmiInterfaces::HMI_INTERFACE_VR; convert_map[VR_Started] = HmiInterfaces::HMI_INTERFACE_VR; convert_map[VR_Stopped] = HmiInterfaces::HMI_INTERFACE_VR; diff --git a/src/components/application_manager/src/smart_object_keys.cc b/src/components/application_manager/src/smart_object_keys.cc index 09e0ccf38b..402a15ae60 100644 --- a/src/components/application_manager/src/smart_object_keys.cc +++ b/src/components/application_manager/src/smart_object_keys.cc @@ -167,6 +167,7 @@ const char* cloud_connection_status = "cloudConnectionStatus"; // PutFile const char* sync_file_name = "syncFileName"; const char* file_name = "fileName"; +const char* file_path = "filePath"; const char* file_type = "fileType"; const char* file_size = "fileSize"; const char* crc32_check_sum = "crc"; @@ -283,6 +284,7 @@ const char* service_id = "serviceID"; const char* service_manifest = "serviceManifest"; const char* service_published = "servicePublished"; const char* service_active = "serviceActive"; +const char* app_service_id = "appServiceId"; const char* service_data = "serviceData"; const char* request_service_active = "requestServiceActive"; const char* app_services = "appServices"; diff --git a/src/components/interfaces/HMI_API.xml b/src/components/interfaces/HMI_API.xml index 3968ef20fb..e927280718 100644 --- a/src/components/interfaces/HMI_API.xml +++ b/src/components/interfaces/HMI_API.xml @@ -4179,6 +4179,29 @@ + + This request is sent to retrieve a file path from the HMI. + + File name that should be retrieved. + + + Selected file type. + + + ID of the service that should have uploaded the requested file. + + + + + HMI handles the request internally and returns the file path with the response. + + Path to file in hmi + + + Selected file type. + + + Request from SDL to HMI to obtain information about head unit system. diff --git a/src/components/interfaces/MOBILE_API.xml b/src/components/interfaces/MOBILE_API.xml index 5a4b8c5482..f1ec069882 100644 --- a/src/components/interfaces/MOBILE_API.xml +++ b/src/components/interfaces/MOBILE_API.xml @@ -2620,6 +2620,7 @@ + + + Optional offset in bytes for resuming partial data chunks + + + + Optional length in bytes for resuming partial data chunks if offset is set to 0, then length is the total length of the file to be downloaded + + + + File type that is being sent in response. + + + + Additional CRC32 checksum to protect data integrity up to 512 Mbits + + + Used to delete a file resident on the module in the app's local cache. diff --git a/src/components/policy/policy_external/include/policy/policy_table/enums.h b/src/components/policy/policy_external/include/policy/policy_table/enums.h index d795721863..d2cf995e95 100644 --- a/src/components/policy/policy_external/include/policy/policy_table/enums.h +++ b/src/components/policy/policy_external/include/policy/policy_table/enums.h @@ -455,6 +455,11 @@ enum FunctionID { */ GetAppServiceDataID = 53, + /** + * @brief GetFileID + */ + GetFileID = 54, + /** * @brief PerformAppServiceInteractionID. */ diff --git a/src/components/policy/policy_external/src/policy_table/enums.cc b/src/components/policy/policy_external/src/policy_table/enums.cc index 718bafa905..2a3d944f33 100644 --- a/src/components/policy/policy_external/src/policy_table/enums.cc +++ b/src/components/policy/policy_external/src/policy_table/enums.cc @@ -1131,6 +1131,11 @@ bool EnumFromJsonString(const std::string& literal, FunctionID* result) { return true; } + if ("GetFile" == literal) { + *result = GetFileID; + return true; + } + if ("GetAppServiceData" == literal) { *result = GetAppServiceDataID; return true; diff --git a/src/components/policy/policy_regular/include/policy/policy_table/enums.h b/src/components/policy/policy_regular/include/policy/policy_table/enums.h index 16f0ef3d67..5b496a4fbd 100644 --- a/src/components/policy/policy_regular/include/policy/policy_table/enums.h +++ b/src/components/policy/policy_regular/include/policy/policy_table/enums.h @@ -441,6 +441,11 @@ enum FunctionID { */ GetAppServiceDataID = 53, + /** + * @brief GetFileID + */ + GetFileID = 54, + /** * @brief PerformAppServiceInteractionID. */ diff --git a/src/components/policy/policy_regular/src/policy_table/enums.cc b/src/components/policy/policy_regular/src/policy_table/enums.cc index 25f6d778fc..113ba8c527 100644 --- a/src/components/policy/policy_regular/src/policy_table/enums.cc +++ b/src/components/policy/policy_regular/src/policy_table/enums.cc @@ -851,6 +851,8 @@ bool IsValidEnum(FunctionID val) { return true; case PublishAppServiceID: return true; + case GetFileID: + return true; case GetAppServiceDataID: return true; case PerformAppServiceInteractionID: @@ -1010,6 +1012,8 @@ const char* EnumToJsonString(FunctionID val) { return "SetCloudAppProperties"; case PublishAppServiceID: return "PublishAppService"; + case GetFileID: + return "GetFile"; case GetAppServiceDataID: return "GetAppServiceData"; case PerformAppServiceInteractionID: @@ -1318,6 +1322,11 @@ bool EnumFromJsonString(const std::string& literal, FunctionID* result) { return true; } + if ("GetFile" == literal) { + *result = GetFileID; + return true; + } + if ("GetAppServiceData" == literal) { *result = GetAppServiceDataID; return true; diff --git a/src/components/smart_objects/src/smart_object.cc b/src/components/smart_objects/src/smart_object.cc index 1322757ab1..3235dd619e 100644 --- a/src/components/smart_objects/src/smart_object.cc +++ b/src/components/smart_objects/src/smart_object.cc @@ -701,6 +701,9 @@ void SmartObject::duplicate(const SmartObject& OtherObject) { case SmartType_Integer: newData.int_value = OtherObject.m_data.int_value; break; + case SmartType_UInteger: + newData.int_value = OtherObject.m_data.int_value; + break; case SmartType_Double: newData.double_value = OtherObject.m_data.double_value; break; diff --git a/src/components/utils/include/utils/file_system.h b/src/components/utils/include/utils/file_system.h index e26fef34bb..e6e5fdc0d4 100644 --- a/src/components/utils/include/utils/file_system.h +++ b/src/components/utils/include/utils/file_system.h @@ -241,6 +241,19 @@ bool WriteBinaryFile(const std::string& name, */ bool ReadBinaryFile(const std::string& name, std::vector& result); +/** + * @brief Reads from file + * + * @param name path to file + * @param result read data + * @param offset number of bytes to be ignored from begining of file + * @return returns true if the operation is successfully. + */ +bool ReadBinaryFile(const std::string& name, + std::vector& result, + uint32_t offset, + uint32_t length); + bool ReadFile(const std::string& name, std::string& result); /** diff --git a/src/components/utils/src/file_system.cc b/src/components/utils/src/file_system.cc index f98aeda056..430cf40da0 100644 --- a/src/components/utils/src/file_system.cc +++ b/src/components/utils/src/file_system.cc @@ -316,6 +316,26 @@ bool file_system::ReadBinaryFile(const std::string& name, return true; } +bool file_system::ReadBinaryFile(const std::string& name, + std::vector& result, + uint32_t offset, + uint32_t length) { + if (!FileExists(name) || !IsAccessible(name, R_OK)) { + return false; + } + + std::ifstream file(name.c_str(), std::ios_base::binary); + file.ignore(offset); + std::ostringstream ss; + std::string s; + s.resize(length); + file.read(&s[0], length); + + result.resize(s.length()); + std::copy(s.begin(), s.end(), result.begin()); + return true; +} + bool file_system::ReadFile(const std::string& name, std::string& result) { if (!FileExists(name) || !IsAccessible(name, R_OK)) { return false; -- cgit v1.2.1 From 82f77e91d31a8a5507c8cdd2388e24642e1c846f Mon Sep 17 00:00:00 2001 From: jacobkeeler Date: Wed, 6 Mar 2019 14:56:36 -0500 Subject: Add passthrough timeout to provider requests --- src/appMain/smartDeviceLink.ini | 15 ++++----------- .../mobile/perform_app_service_interaction_request.cc | 2 ++ .../src/commands/command_request_impl.cc | 4 ++++ .../application_manager/src/commands/request_from_hmi.cc | 7 +++++++ 4 files changed, 17 insertions(+), 11 deletions(-) diff --git a/src/appMain/smartDeviceLink.ini b/src/appMain/smartDeviceLink.ini index ee67e6f018..54c2395c47 100644 --- a/src/appMain/smartDeviceLink.ini +++ b/src/appMain/smartDeviceLink.ini @@ -359,16 +359,6 @@ EnableAppLaunchIOS = true ;SecondaryTransportForUSB = ;SecondaryTransportForWiFi = -[AppServices] -; The ID to pass to app service publishers when sending a PerformAppServiceInteraction request -;CoresOriginId = "sdl_core" - -; Services that exist on the module. Values are of AppServiceType in RPC Spec. These services will be used as default and app services will only become primary service publisher with direct user interaction. These services will also be a fallback if no app service publisher is registered with the system of that type. -;EmbeddedServices = MEDIA, WEATHER, NAVIGATION, VOICE_ASSISTANT, COMMUNICATION_VOIP, MESSAGING, TTS - -; Additional time added to RPC timeout when passing through to App service -RpcPassThroughTimeout = 10000 - [ServicesMap] ; A matrix to specify which service is allowed on which transports. The transports are listed ; in preferred order. If a transport is not listed, then the service is not allowed @@ -385,4 +375,7 @@ RpcPassThroughTimeout = 10000 HMIOriginID = "HMI_ID" ; Services that exist on the module. Values are of AppServiceType in RPC Spec. These services will be used as default and app services will only become primary service publisher with direct user interaction. These services will also be a fallback if no app service publisher is registered with the system of that type. -EmbeddedServices = MEDIA, WEATHER, NAVIGATION, VOICE_ASSISTANT +EmbeddedServices = MEDIA, WEATHER, NAVIGATION + +; Additional time added to RPC timeout when passing through to App service +RpcPassThroughTimeout = 10000 \ No newline at end of file diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/perform_app_service_interaction_request.cc b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/perform_app_service_interaction_request.cc index d21c413b29..9623cffd36 100644 --- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/perform_app_service_interaction_request.cc +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/perform_app_service_interaction_request.cc @@ -94,6 +94,8 @@ void PerformAppServiceInteractionRequest::Run() { // service smart_objects::SmartObject request_params; request_params[strings::service_id] = service_id; + application_manager_.IncreaseForwardedRequestTimeout(connection_key(), + correlation_id()); SendHMIRequest(hmi_apis::FunctionID::AppService_GetActiveServiceConsent, &request_params, true); diff --git a/src/components/application_manager/src/commands/command_request_impl.cc b/src/components/application_manager/src/commands/command_request_impl.cc index c6dbe6972f..fcca87b235 100644 --- a/src/components/application_manager/src/commands/command_request_impl.cc +++ b/src/components/application_manager/src/commands/command_request_impl.cc @@ -441,6 +441,8 @@ void CommandRequestImpl::SendProviderRequest( if (hmi_destination) { LOG4CXX_DEBUG(logger_, "Sending Request to HMI Provider"); + application_manager_.IncreaseForwardedRequestTimeout(connection_key(), + correlation_id()); SendHMIRequest(hmi_function_id, &(*msg)[strings::msg_params], use_events); return; } @@ -468,6 +470,8 @@ void CommandRequestImpl::SendProviderRequest( request[strings::msg_params] = (*msg)[strings::msg_params]; request[strings::params][strings::connection_key] = app->app_id(); + application_manager_.IncreaseForwardedRequestTimeout(connection_key(), + correlation_id()); SendMobileRequest(mobile_function_id, new_msg, use_events); } diff --git a/src/components/application_manager/src/commands/request_from_hmi.cc b/src/components/application_manager/src/commands/request_from_hmi.cc index 823e93cb5e..86473f5fca 100644 --- a/src/components/application_manager/src/commands/request_from_hmi.cc +++ b/src/components/application_manager/src/commands/request_from_hmi.cc @@ -32,6 +32,7 @@ #include "application_manager/commands/request_from_hmi.h" #include "application_manager/application_manager.h" +#include "application_manager/request_info.h" #include "application_manager/rpc_service.h" #include "utils/helpers.h" @@ -183,6 +184,9 @@ void RequestFromHMI::SendProviderRequest( if (hmi_destination) { LOG4CXX_DEBUG(logger_, "Sending Request to HMI Provider"); + application_manager_.IncreaseForwardedRequestTimeout( + application_manager::request_controller::RequestInfo::HmiConnectoinKey, + correlation_id()); SendHMIRequest(hmi_function_id, &(*msg)[strings::msg_params], use_events); return; } @@ -193,6 +197,9 @@ void RequestFromHMI::SendProviderRequest( } LOG4CXX_DEBUG(logger_, "Sending Request to Mobile Provider"); + application_manager_.IncreaseForwardedRequestTimeout( + application_manager::request_controller::RequestInfo::HmiConnectoinKey, + correlation_id()); SendMobileRequest( mobile_function_id, app, &(*msg)[strings::msg_params], use_events); } -- cgit v1.2.1 From 969c77262efd0db36a51eaaa665e091a076efebf Mon Sep 17 00:00:00 2001 From: jacobkeeler Date: Wed, 6 Mar 2019 15:30:13 -0500 Subject: Add forwarding timeout for GetFile --- .../rpc_plugins/sdl_rpc_plugin/src/commands/mobile/get_file_request.cc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/get_file_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/get_file_request.cc index c0fbcee146..2b3611fece 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/get_file_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/get_file_request.cc @@ -151,6 +151,8 @@ void GetFileRequest::Run() { if (GetFilePath(file_path, forward_to_hmi)) { if (forward_to_hmi) { LOG4CXX_DEBUG(logger_, "Forwarding GetFile request to HMI"); + application_manager_.IncreaseForwardedRequestTimeout(connection_key(), + correlation_id()); SendHMIRequest(hmi_apis::FunctionID::BasicCommunication_GetFilePath, &(*message_)[strings::msg_params], true); -- cgit v1.2.1 From 5cc1ad073dd9a05a3bd65499acf0c6b079287a29 Mon Sep 17 00:00:00 2001 From: jacobkeeler Date: Thu, 7 Mar 2019 15:48:37 -0500 Subject: Fix serviceIcon type --- src/components/interfaces/MOBILE_API.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/interfaces/MOBILE_API.xml b/src/components/interfaces/MOBILE_API.xml index f1ec069882..1d910e29bf 100644 --- a/src/components/interfaces/MOBILE_API.xml +++ b/src/components/interfaces/MOBILE_API.xml @@ -4007,7 +4007,7 @@ The type of service that is to be offered by this app - + The file name of the icon to be associated with this service. Most likely the same as the appIcon. -- cgit v1.2.1 From b49f662b54b5be8a67140fca1e8f55f87bef13d2 Mon Sep 17 00:00:00 2001 From: jacobkeeler Date: Thu, 7 Mar 2019 17:20:16 -0500 Subject: Address review comments Also fix bug where an app name could coincide with several apps vr synonyms --- .../mobile/register_app_interface_request.h | 6 ++++-- .../mobile/register_app_interface_request.cc | 25 +++++++++++++--------- 2 files changed, 19 insertions(+), 12 deletions(-) diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/register_app_interface_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/register_app_interface_request.h index a6bfdec209..91ee8ea813 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/register_app_interface_request.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/register_app_interface_request.h @@ -144,12 +144,14 @@ class RegisterAppInterfaceRequest /* * @brief Check new application parameters (name, tts, vr) for * coincidence with already known parameters of registered applications + * @param out_duplicate_apps In the case other apps was found with duplicate + * names, this field will be filled with a list of said apps * * return SUCCESS if there is no coincidence of app.name/TTS/VR synonyms, * otherwise appropriate error code returns - */ + */ mobile_apis::Result::eType CheckCoincidence( - app_mngr::ApplicationSharedPtr& app); + std::vector& out_duplicate_apps); /* * @brief Predicate for using with CheckCoincidence method to compare with VR 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 e4540fe888..924705f82b 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 @@ -281,11 +281,13 @@ void RegisterAppInterfaceRequest::Run() { return; } - ApplicationSharedPtr duplicate_app; + std::vector duplicate_apps; mobile_apis::Result::eType coincidence_result = - CheckCoincidence(duplicate_app); + CheckCoincidence(duplicate_apps); - if (mobile_apis::Result::DUPLICATE_NAME == coincidence_result) { + if (mobile_apis::Result::DUPLICATE_NAME == coincidence_result && + duplicate_apps.size() == 1) { + ApplicationSharedPtr duplicate_app = duplicate_apps.front(); bool error_response = true; if (duplicate_app->is_cloud_app()) { if (duplicate_app->hybrid_app_preference() == @@ -955,7 +957,7 @@ void RegisterAppInterfaceRequest::SendOnAppRegisteredNotificationToHMI( } mobile_apis::Result::eType RegisterAppInterfaceRequest::CheckCoincidence( - ApplicationSharedPtr& out_app) { + std::vector& out_duplicate_apps) { LOG4CXX_AUTO_TRACE(logger_); const smart_objects::SmartObject& msg_params = (*message_)[strings::msg_params]; @@ -971,8 +973,8 @@ mobile_apis::Result::eType RegisterAppInterfaceRequest::CheckCoincidence( const custom_str::CustomString& cur_name = (*it)->name(); if (app_name.CompareIgnoreCase(cur_name)) { LOG4CXX_ERROR(logger_, "Application name is known already."); - out_app = *it; - return mobile_apis::Result::DUPLICATE_NAME; + out_duplicate_apps.push_back(*it); + continue; } const smart_objects::SmartObject* vr = (*it)->vr_synonyms(); @@ -983,8 +985,8 @@ mobile_apis::Result::eType RegisterAppInterfaceRequest::CheckCoincidence( if (0 != std::count_if(curr_vr->begin(), curr_vr->end(), v)) { LOG4CXX_ERROR(logger_, "Application name is known already."); - out_app = *it; - return mobile_apis::Result::DUPLICATE_NAME; + out_duplicate_apps.push_back(*it); + continue; } } @@ -996,13 +998,16 @@ mobile_apis::Result::eType RegisterAppInterfaceRequest::CheckCoincidence( CoincidencePredicateVR v(cur_name); if (0 != std::count_if(new_vr->begin(), new_vr->end(), v)) { LOG4CXX_ERROR(logger_, "vr_synonyms duplicated with app_name ."); - out_app = *it; - return mobile_apis::Result::DUPLICATE_NAME; + out_duplicate_apps.push_back(*it); + continue; } } // end vr check } // application for end + if (!out_duplicate_apps.empty()) { + return mobile_apis::Result::DUPLICATE_NAME; + } return mobile_apis::Result::SUCCESS; } // method end -- cgit v1.2.1 From 3be4d6a8384f5422a040121c11b448a7dd6901fc Mon Sep 17 00:00:00 2001 From: Shobhit Adlakha Date: Thu, 7 Mar 2019 21:43:31 -0500 Subject: RPC Passing and Handling unknown RPC parameters (#2821) * Initial app service app extension * Add GetAppServiceData rpc templates. * Add request to mobile, and fix HMI GASD naming * Add Core->Mobile Requests and Responses * HMI GetAppService Request/Response to hmi and from hmi. * Add mobile on event handling * Fix GASD Response From Mobile * Add PerformAppServiceInteraction RPC * Fixes for GetAppServiceData subscribe, and OnAppServiceData Fixes allow for multiple consumers on a single app service type. Consumer/provider can be any combination of an ios app(s), android app(s), or an ivi HMI app(s). * Update AppServicetype to string and fix unit tests * Implemented RpcPassThroughTimeout param and IncreaseForwardedRequestTimeout function * Address review comments * Fixed build tests * Fix style * Address comments * Address comments * Pass info from provider in GASD response * Implemented boolean paramter to keep/remove unknown RPC paramaters * Added plugin keys * Implemented allowing unknown rpc params if function is handled by AS plugin or is related to SystemCapability * Implemented handling unknown params for OSCU notifications * Fixed build tests * Implemented handling unknown params for RPC Passing * Initial implementation of RPC Passing * fixed UNSUPPORTED_REQUEST case * Moved RPCPassing implementation into seperate class * Implemented passthrough request timeout * Addressed style and formatting comments * Put RPCPassingHandler in seperate file * Removed unused request/response file (based on review comment r263121367) * Fixed timeout implementation * Created functions for handling forwarding requests/responses to core and mobile * Moved Populating request queue functionality to seperate function * Changed implementation to use one map with the original request and a queue of app service information * Fixed timeout implementation * Seperated RPCPassing checks from IsAppServiceRPC checks * Added locks for request and timeout queues * Addressed review comments * Fixed rpc_passing_handler_ initializer and added comments * Reduced scope of locks for rpc_passing_queue --- src/appMain/smartDeviceLink.ini | 10 + .../application_manager/app_service_manager.h | 6 +- .../application_manager/application_manager_impl.h | 3 +- .../plugin_manager/plugin_keys.h | 48 +++ .../include/application_manager/rpc_handler_impl.h | 3 +- .../application_manager/rpc_passing_handler.h | 113 +++++++ .../include/application_manager/rpc_service_impl.h | 6 +- .../src/app_service_rpc_plugin.cc | 4 +- .../rpc_plugins/rc_rpc_plugin/src/rc_rpc_plugin.cc | 4 +- .../sdl_rpc_plugin/src/sdl_rpc_plugin.cc | 3 +- .../vehicle_info_plugin/src/vehicle_info_plugin.cc | 4 +- .../application_manager/src/app_service_manager.cc | 22 +- .../src/application_manager_impl.cc | 15 +- .../src/plugin_manager/plugin_keys.cc | 14 + .../application_manager/src/rpc_handler_impl.cc | 71 ++++- .../application_manager/src/rpc_passing_handler.cc | 331 +++++++++++++++++++++ .../application_manager/src/rpc_service_impl.cc | 94 +++++- .../include/formatters/CFormatterJsonSDLRPCv1.h | 10 +- .../include/formatters/CFormatterJsonSDLRPCv2.h | 10 +- .../formatters/include/formatters/CSmartFactory.h | 8 +- .../include/formatters/formatter_json_rpc.h | 6 +- .../formatters/src/CFormatterJsonSDLRPCv1.cc | 12 +- .../formatters/src/CFormatterJsonSDLRPCv2.cc | 12 +- .../formatters/src/formatter_json_rpc.cc | 6 +- .../include/application_manager/rpc_service.h | 11 + .../test/application_manager/mock_rpc_service.h | 4 + .../include/smart_objects/array_schema_item.h | 11 +- .../include/smart_objects/enum_schema_item.h | 15 +- .../include/smart_objects/object_schema_item.h | 10 +- .../include/smart_objects/schema_item.h | 10 +- .../include/smart_objects/smart_schema.h | 10 +- .../smart_objects/src/array_schema_item.cc | 9 +- .../smart_objects/src/object_schema_item.cc | 15 +- src/components/smart_objects/src/schema_item.cc | 5 +- src/components/smart_objects/src/smart_schema.cc | 9 +- 35 files changed, 835 insertions(+), 89 deletions(-) create mode 100644 src/components/application_manager/include/application_manager/plugin_manager/plugin_keys.h create mode 100644 src/components/application_manager/include/application_manager/rpc_passing_handler.h create mode 100644 src/components/application_manager/src/plugin_manager/plugin_keys.cc create mode 100644 src/components/application_manager/src/rpc_passing_handler.cc diff --git a/src/appMain/smartDeviceLink.ini b/src/appMain/smartDeviceLink.ini index 54c2395c47..2b2c784746 100644 --- a/src/appMain/smartDeviceLink.ini +++ b/src/appMain/smartDeviceLink.ini @@ -359,6 +359,16 @@ EnableAppLaunchIOS = true ;SecondaryTransportForUSB = ;SecondaryTransportForWiFi = +[AppServices] +; The ID to pass to app service publishers when sending a PerformAppServiceInteraction request +;CoresOriginId = "sdl_core" + +; Services that exist on the module. Values are of AppServiceType in RPC Spec. These services will be used as default and app services will only become primary service publisher with direct user interaction. These services will also be a fallback if no app service publisher is registered with the system of that type. +;EmbeddedServices = MEDIA, WEATHER, NAVIGATION, VOICE_ASSISTANT, COMMUNICATION_VOIP, MESSAGING, TTS + +; Additional time added to RPC timeout when passing through to App service +RpcPassThroughTimeout = 10000 + [ServicesMap] ; A matrix to specify which service is allowed on which transports. The transports are listed ; in preferred order. If a transport is not listed, then the service is not allowed diff --git a/src/components/application_manager/include/application_manager/app_service_manager.h b/src/components/application_manager/include/application_manager/app_service_manager.h index d6d13a209a..f7c46178c5 100644 --- a/src/components/application_manager/include/application_manager/app_service_manager.h +++ b/src/components/application_manager/include/application_manager/app_service_manager.h @@ -37,6 +37,7 @@ #include "interfaces/MOBILE_API.h" #include "smart_objects/smart_object.h" #include "application_manager/application.h" +#include "application_manager/rpc_passing_handler.h" namespace resumption { class LastState; @@ -52,7 +53,6 @@ struct AppService { }; class ApplicationManager; - /** * @brief The AppServiceManager is TODO. */ @@ -124,6 +124,7 @@ class AppServiceManager { * @param manifest */ std::vector GetAllServices(); + std::vector > GetActiveServices(); void GetProviderByType(const std::string& service_type, bool mobile_consumer, @@ -159,12 +160,15 @@ class AppServiceManager { */ bool UpdateNavigationCapabilities(smart_objects::SmartObject& out_params); + RPCPassingHandler& GetRPCPassingHandler(); + private: ApplicationManager& app_manager_; resumption::LastState& last_state_; sync_primitives::RecursiveLock published_services_lock_; std::map published_services_; + RPCPassingHandler rpc_passing_handler_; void AppServiceUpdated( const smart_objects::SmartObject& service_record, diff --git a/src/components/application_manager/include/application_manager/application_manager_impl.h b/src/components/application_manager/include/application_manager/application_manager_impl.h index 6161d6bbbf..12f2310d36 100644 --- a/src/components/application_manager/include/application_manager/application_manager_impl.h +++ b/src/components/application_manager/include/application_manager/application_manager_impl.h @@ -1118,7 +1118,8 @@ class ApplicationManagerImpl mobile_apis::MOBILE_API& mobile_so_factory(); bool ConvertSOtoMessage(const smart_objects::SmartObject& message, - Message& output); + Message& output, + const bool remove_unknown_parameters = true); template void PrepareApplicationListSO(ApplicationList app_list, diff --git a/src/components/application_manager/include/application_manager/plugin_manager/plugin_keys.h b/src/components/application_manager/include/application_manager/plugin_manager/plugin_keys.h new file mode 100644 index 0000000000..11a7d353f6 --- /dev/null +++ b/src/components/application_manager/include/application_manager/plugin_manager/plugin_keys.h @@ -0,0 +1,48 @@ +/* + Copyright (c) 2019, Ford Motor Company, Livio + 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 the copyright holders nor the names of their + 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. + */ + +#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_PLUGIN_MANAGER_PLUGIN_KEYS_H +#define SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_PLUGIN_MANAGER_PLUGIN_KEYS_H + +namespace application_manager { +namespace plugin_manager { + +namespace plugin_names { +extern const char* vehicle_info_rpc_plugin; +extern const char* app_service_rpc_plugin; +extern const char* rc_rpc_plugin; +extern const char* sdl_rpc_plugin; +} + +} // namespace plugin_manager +} // namespace application_manager +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_PLUGIN_MANAGER_PLUGIN_KEYS_H diff --git a/src/components/application_manager/include/application_manager/rpc_handler_impl.h b/src/components/application_manager/include/application_manager/rpc_handler_impl.h index cc93e4213c..b7e74c5ab3 100644 --- a/src/components/application_manager/include/application_manager/rpc_handler_impl.h +++ b/src/components/application_manager/include/application_manager/rpc_handler_impl.h @@ -158,7 +158,8 @@ class RPCHandlerImpl : public RPCHandler, void ProcessMessageFromMobile(const std::shared_ptr message); void ProcessMessageFromHMI(const std::shared_ptr message); bool ConvertMessageToSO(const Message& message, - smart_objects::SmartObject& output); + smart_objects::SmartObject& output, + const bool remove_unknown_parameters = true); std::shared_ptr ConvertRawMsgToMessage( const ::protocol_handler::RawMessagePtr message); hmi_apis::HMI_API& hmi_so_factory(); diff --git a/src/components/application_manager/include/application_manager/rpc_passing_handler.h b/src/components/application_manager/include/application_manager/rpc_passing_handler.h new file mode 100644 index 0000000000..3ed10ff1e6 --- /dev/null +++ b/src/components/application_manager/include/application_manager/rpc_passing_handler.h @@ -0,0 +1,113 @@ +/* + * Copyright (c) 2018, 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. + */ + +#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_RPC_PASSING_HANDLER_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_RPC_PASSING_HANDLER_H_ + +#include "application_manager/application.h" +#include "interfaces/MOBILE_API.h" +#include "smart_objects/smart_object.h" +#include "application_manager/app_service_manager.h" +#include +#include "utils/timer.h" + +namespace application_manager { + +struct ServiceInfo { + std::string service_id; + uint32_t connection_key; +}; + +typedef std::shared_ptr TimerSPtr; + +class AppServiceManager; + +class RPCPassingHandler { + public: + RPCPassingHandler(AppServiceManager& asm_ref, ApplicationManager& am_ref); + + /** + * @brief Class destructor + */ + ~RPCPassingHandler(); + + /** + * @brief Check if function id is in the handled_rpcs list of an active app + * service + * @param function_id RPC function id + * @return true if function id exists in handled_rpcs list of an active app + * service + */ + bool CanHandleFunctionID(int32_t function_id); + + /** + * @brief Check if app services or core is being used to handle the RPC + * @param correlation_id correlation id of RPC response + * @return true if an app service was used to handle the RPC + */ + bool IsPassThroughMessage(uint32_t correlation_id, + commands::Command::CommandSource source, + int32_t message_type); + + /** + * @brief Function to handle sending and receiving RPC Passing + * requests/responses + * @param rpc_message RPC message SmartObject + * @return true if the request was forwarded, false otherwise + */ + bool RPCPassThrough(smart_objects::SmartObject rpc_message); + + private: + bool PerformNextRequest(uint32_t correlation_id); + void OnPassThroughRequestTimeout(); + void AddRequestTimer(uint32_t correlation_id); + void RemoveRequestTimer(uint32_t correlation_id); + void ClearCompletedTimers(); + void ForwardRequestToMobile(uint32_t correlation_id); + void ForwardRequestToCore(uint32_t correlation_id); + void ForwardResponseToMobile(uint32_t correlation_id, + smart_objects::SmartObject response_message); + void PopulateRPCRequestQueue(smart_objects::SmartObject request_message); + + AppServiceManager& app_service_manager_; + ApplicationManager& app_manager_; + sync_primitives::RecursiveLock rpc_request_queue_lock_; + std::map > > + rpc_request_queue; + sync_primitives::RecursiveLock timeout_queue_lock_; + std::vector > timeout_queue_; +}; + +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_RPC_PASSING_HANDLER_H_ diff --git a/src/components/application_manager/include/application_manager/rpc_service_impl.h b/src/components/application_manager/include/application_manager/rpc_service_impl.h index 98767672ca..848e9645e7 100644 --- a/src/components/application_manager/include/application_manager/rpc_service_impl.h +++ b/src/components/application_manager/include/application_manager/rpc_service_impl.h @@ -121,6 +121,9 @@ class RPCServiceImpl : public RPCService, bool final_message = false) OVERRIDE; void SendMessageToHMI(const commands::MessageSharedPtr message) OVERRIDE; + bool IsAppServiceRPC(int32_t function_id, + commands::Command::CommandSource source); + void set_protocol_handler( protocol_handler::ProtocolHandler* handler) OVERRIDE; void set_hmi_message_handler( @@ -128,7 +131,8 @@ class RPCServiceImpl : public RPCService, private: bool ConvertSOtoMessage(const smart_objects::SmartObject& message, - Message& output); + Message& output, + const bool remove_unknown_parameters = true); hmi_apis::HMI_API& hmi_so_factory(); mobile_apis::MOBILE_API& mobile_so_factory(); diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/app_service_rpc_plugin.cc b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/app_service_rpc_plugin.cc index 971e3cc5e0..b96e5c199d 100644 --- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/app_service_rpc_plugin.cc +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/app_service_rpc_plugin.cc @@ -35,11 +35,13 @@ #include "app_service_rpc_plugin/app_service_app_extension.h" #include "app_service_rpc_plugin/app_service_command_factory.h" #include "app_service_rpc_plugin/app_service_rpc_plugin.h" +#include "application_manager/plugin_manager/plugin_keys.h" namespace app_service_rpc_plugin { CREATE_LOGGERPTR_GLOBAL(logger_, "AppServiceRpcPlugin") namespace strings = application_manager::strings; +namespace plugins = application_manager::plugin_manager; AppServiceRpcPlugin::AppServiceRpcPlugin() : application_manager_(nullptr) {} @@ -60,7 +62,7 @@ bool AppServiceRpcPlugin::IsAbleToProcess( } std::string AppServiceRpcPlugin::PluginName() { - return "App Service RPC Plugin"; + return plugins::plugin_names::app_service_rpc_plugin; } app_mngr::CommandFactory& AppServiceRpcPlugin::GetCommandFactory() { diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/rc_rpc_plugin.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/rc_rpc_plugin.cc index fd6b4e86ac..3bc1106573 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/rc_rpc_plugin.cc +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/rc_rpc_plugin.cc @@ -29,7 +29,7 @@ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ - +#include "application_manager/plugin_manager/plugin_keys.h" #include "rc_rpc_plugin/rc_rpc_plugin.h" #include "rc_rpc_plugin/rc_command_factory.h" #include "rc_rpc_plugin/rc_app_extension.h" @@ -77,7 +77,7 @@ bool RCRPCPlugin::IsAbleToProcess( } std::string RCRPCPlugin::PluginName() { - return "RC RPC Plugin"; + return plugins::plugin_names::rc_rpc_plugin; } application_manager::CommandFactory& RCRPCPlugin::GetCommandFactory() { diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/sdl_rpc_plugin.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/sdl_rpc_plugin.cc index aa82c74098..c448b41ff1 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/sdl_rpc_plugin.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/sdl_rpc_plugin.cc @@ -30,6 +30,7 @@ POSSIBILITY OF SUCH DAMAGE. */ +#include "application_manager/plugin_manager/plugin_keys.h" #include "sdl_rpc_plugin/sdl_rpc_plugin.h" #include "sdl_rpc_plugin/sdl_command_factory.h" #include "sdl_rpc_plugin/extensions/system_capability_app_extension.h" @@ -56,7 +57,7 @@ bool SDLRPCPlugin::IsAbleToProcess( } std::string SDLRPCPlugin::PluginName() { - return "SDL RPC Plugin"; + return plugins::plugin_names::sdl_rpc_plugin; } app_mngr::CommandFactory& SDLRPCPlugin::GetCommandFactory() { diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/vehicle_info_plugin.cc b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/vehicle_info_plugin.cc index d0bcc36ab4..c9e9839929 100644 --- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/vehicle_info_plugin.cc +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/vehicle_info_plugin.cc @@ -33,6 +33,7 @@ #include "vehicle_info_plugin/vehicle_info_plugin.h" #include "vehicle_info_plugin/vehicle_info_command_factory.h" #include "vehicle_info_plugin/vehicle_info_app_extension.h" +#include "application_manager/plugin_manager/plugin_keys.h" #include "application_manager/smart_object_keys.h" #include "application_manager/message_helper.h" #include "application_manager/message_helper.h" @@ -41,6 +42,7 @@ namespace vehicle_info_plugin { CREATE_LOGGERPTR_GLOBAL(logger_, "VehicleInfoPlugin") namespace strings = application_manager::strings; +namespace plugins = application_manager::plugin_manager; VehicleInfoPlugin::VehicleInfoPlugin() : application_manager_(nullptr) {} @@ -61,7 +63,7 @@ bool VehicleInfoPlugin::IsAbleToProcess( } std::string VehicleInfoPlugin::PluginName() { - return "Vehicle Info Plugin"; + return plugins::plugin_names::vehicle_info_rpc_plugin; } app_mngr::CommandFactory& VehicleInfoPlugin::GetCommandFactory() { diff --git a/src/components/application_manager/src/app_service_manager.cc b/src/components/application_manager/src/app_service_manager.cc index 24c21dc201..d148e4ef61 100644 --- a/src/components/application_manager/src/app_service_manager.cc +++ b/src/components/application_manager/src/app_service_manager.cc @@ -45,8 +45,6 @@ #include "smart_objects/enum_schema_item.h" #include "utils/logger.h" -#include "smart_objects/enum_schema_item.h" - CREATE_LOGGERPTR_GLOBAL(logger_, "AppServiceManager") namespace application_manager { @@ -56,7 +54,9 @@ const char* kDefaults = "defaults"; AppServiceManager::AppServiceManager(ApplicationManager& app_manager, resumption::LastState& last_state) - : app_manager_(app_manager), last_state_(last_state) {} + : app_manager_(app_manager) + , last_state_(last_state) + , rpc_passing_handler_(*this, app_manager_) {} AppServiceManager::~AppServiceManager() { LOG4CXX_AUTO_TRACE(logger_); @@ -544,4 +544,20 @@ void AppServiceManager::AppServiceUpdated( services[-1] = service; } +std::vector > +AppServiceManager::GetActiveServices() { + std::vector > active_services; + for (auto it = published_services_.begin(); it != published_services_.end(); + ++it) { + if (it->second.record[strings::service_active].asBool()) { + active_services.push_back(*it); + } + } + return active_services; +} + +RPCPassingHandler& AppServiceManager::GetRPCPassingHandler() { + return rpc_passing_handler_; +} + } // namespace application_manager diff --git a/src/components/application_manager/src/application_manager_impl.cc b/src/components/application_manager/src/application_manager_impl.cc index 2c8f5e06b2..f9da143720 100644 --- a/src/components/application_manager/src/application_manager_impl.cc +++ b/src/components/application_manager/src/application_manager_impl.cc @@ -2052,7 +2052,9 @@ bool ApplicationManagerImpl::Stop() { } bool ApplicationManagerImpl::ConvertSOtoMessage( - const smart_objects::SmartObject& message, Message& output) { + const smart_objects::SmartObject& message, + Message& output, + const bool remove_unknown_parameters) { LOG4CXX_AUTO_TRACE(logger_); if (smart_objects::SmartType_Null == message.getType() || @@ -2077,16 +2079,16 @@ bool ApplicationManagerImpl::ConvertSOtoMessage( switch (protocol_type) { case 0: { if (protocol_version == 1) { - if (!formatters::CFormatterJsonSDLRPCv1::toString(message, - output_string)) { + if (!formatters::CFormatterJsonSDLRPCv1::toString( + message, output_string, remove_unknown_parameters)) { LOG4CXX_WARN(logger_, "Failed to serialize smart object"); return false; } output.set_protocol_version( protocol_handler::MajorProtocolVersion::PROTOCOL_VERSION_1); } else { - if (!formatters::CFormatterJsonSDLRPCv2::toString(message, - output_string)) { + if (!formatters::CFormatterJsonSDLRPCv2::toString( + message, output_string, remove_unknown_parameters)) { LOG4CXX_WARN(logger_, "Failed to serialize smart object"); return false; } @@ -2098,7 +2100,8 @@ bool ApplicationManagerImpl::ConvertSOtoMessage( break; } case 1: { - if (!formatters::FormatterJsonRpc::ToString(message, output_string)) { + if (!formatters::FormatterJsonRpc::ToString( + message, output_string, remove_unknown_parameters)) { LOG4CXX_WARN(logger_, "Failed to serialize smart object"); return false; } diff --git a/src/components/application_manager/src/plugin_manager/plugin_keys.cc b/src/components/application_manager/src/plugin_manager/plugin_keys.cc new file mode 100644 index 0000000000..9eabc67c09 --- /dev/null +++ b/src/components/application_manager/src/plugin_manager/plugin_keys.cc @@ -0,0 +1,14 @@ +#include "application_manager/plugin_manager/plugin_keys.h" + +namespace application_manager { +namespace plugin_manager { + +namespace plugin_names { +const char* vehicle_info_rpc_plugin = "Vehicle Info RPC Plugin"; +const char* app_service_rpc_plugin = "App Service RPC Plugin"; +const char* rc_rpc_plugin = "RC RPC Plugin"; +const char* sdl_rpc_plugin = "SDL RPC Plugin"; +} + +} // namespace plugin_manager +} // namespace application_manager \ No newline at end of file diff --git a/src/components/application_manager/src/rpc_handler_impl.cc b/src/components/application_manager/src/rpc_handler_impl.cc index 40f2e90115..6374e2a955 100644 --- a/src/components/application_manager/src/rpc_handler_impl.cc +++ b/src/components/application_manager/src/rpc_handler_impl.cc @@ -31,6 +31,7 @@ */ #include "application_manager/rpc_handler_impl.h" +#include "application_manager/plugin_manager/plugin_keys.h" namespace application_manager { namespace rpc_handler { @@ -38,6 +39,7 @@ namespace rpc_handler { CREATE_LOGGERPTR_LOCAL(logger_, "RPCHandlerImpl") namespace formatters = ns_smart_device_link::ns_json_handler::formatters; namespace jhs = ns_smart_device_link::ns_json_handler::strings; +namespace plugin_names = application_manager::plugin_manager::plugin_names; RPCHandlerImpl::RPCHandlerImpl(ApplicationManager& app_manager) : app_manager_(app_manager) @@ -63,17 +65,54 @@ void RPCHandlerImpl::ProcessMessageFromMobile( #endif // TELEMETRY_MONITOR smart_objects::SmartObjectSPtr so_from_mobile = std::make_shared(); - + bool remove_unknown_parameters = true; DCHECK_OR_RETURN_VOID(so_from_mobile); if (!so_from_mobile) { LOG4CXX_ERROR(logger_, "Null pointer"); return; } - if (!ConvertMessageToSO(*message, *so_from_mobile)) { + bool rpc_passing = app_manager_.GetAppServiceManager() + .GetRPCPassingHandler() + .CanHandleFunctionID(message->function_id()); + if (app_manager_.GetRPCService().IsAppServiceRPC( + message->function_id(), commands::Command::SOURCE_MOBILE) || + rpc_passing) { + LOG4CXX_DEBUG(logger_, + "Allowing unknown parameters for request function " + << message->function_id()); + remove_unknown_parameters = false; + } + + if (!ConvertMessageToSO( + *message, *so_from_mobile, remove_unknown_parameters)) { LOG4CXX_ERROR(logger_, "Cannot create smart object from message"); return; } + + if (rpc_passing) { + uint32_t correlation_id = + (*so_from_mobile)[strings::params][strings::correlation_id].asUInt(); + int32_t message_type = + (*so_from_mobile)[strings::params][strings::message_type].asInt(); + if (app_manager_.GetAppServiceManager() + .GetRPCPassingHandler() + .RPCPassThrough(*so_from_mobile)) { + // RPC was forwarded. Skip handling by Core + return; + } else if (!app_manager_.GetAppServiceManager() + .GetRPCPassingHandler() + .IsPassThroughMessage(correlation_id, + commands::Command::SOURCE_MOBILE, + message_type)) { + // Since PassThrough failed, refiltering the message + if (!ConvertMessageToSO(*message, *so_from_mobile, true)) { + LOG4CXX_ERROR(logger_, "Cannot create smart object from message"); + return; + } + } + } + #ifdef TELEMETRY_MONITOR metric->message = so_from_mobile; #endif // TELEMETRY_MONITOR @@ -95,13 +134,28 @@ void RPCHandlerImpl::ProcessMessageFromHMI( LOG4CXX_AUTO_TRACE(logger_); smart_objects::SmartObjectSPtr smart_object = std::make_shared(); - + bool remove_unknown_parameters = true; if (!smart_object) { LOG4CXX_ERROR(logger_, "Null pointer"); return; } - if (!ConvertMessageToSO(*message, *smart_object)) { + smart_objects::SmartObject converted_result; + formatters::FormatterJsonRpc::FromString( + message->json_message(), converted_result); + + if (app_manager_.GetRPCService().IsAppServiceRPC( + converted_result[jhs::S_PARAMS][jhs::S_FUNCTION_ID].asInt(), + commands::Command::SOURCE_HMI)) { + LOG4CXX_DEBUG( + logger_, + "Allowing unknown parameters for request function " + << converted_result[jhs::S_PARAMS][jhs::S_FUNCTION_ID].asInt()); + remove_unknown_parameters = false; + } + + if (!ConvertMessageToSO(*message, *smart_object, remove_unknown_parameters)) { if (application_manager::MessageType::kResponse == (*smart_object)[strings::params][strings::message_type].asInt()) { (*smart_object).erase(strings::msg_params); @@ -228,7 +282,8 @@ void RPCHandlerImpl::GetMessageVersion( bool RPCHandlerImpl::ConvertMessageToSO( const Message& message, - ns_smart_device_link::ns_smart_objects::SmartObject& output) { + ns_smart_device_link::ns_smart_objects::SmartObject& output, + const bool remove_unknown_parameters) { LOG4CXX_AUTO_TRACE(logger_); LOG4CXX_DEBUG(logger_, "\t\t\tMessage to convert: protocol " @@ -262,9 +317,11 @@ bool RPCHandlerImpl::ConvertMessageToSO( } if (!conversion_result || - !mobile_so_factory().attachSchema(output, true, msg_version) || + !mobile_so_factory().attachSchema( + output, remove_unknown_parameters, msg_version) || ((output.validate(&report, msg_version) != - smart_objects::errors::OK))) { + smart_objects::errors::OK && + remove_unknown_parameters))) { LOG4CXX_WARN(logger_, "Failed to parse string to smart object with API version " << msg_version.toString() << " : " diff --git a/src/components/application_manager/src/rpc_passing_handler.cc b/src/components/application_manager/src/rpc_passing_handler.cc new file mode 100644 index 0000000000..560418e910 --- /dev/null +++ b/src/components/application_manager/src/rpc_passing_handler.cc @@ -0,0 +1,331 @@ +/* + * Copyright (c) 2018, 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 "application_manager/help_prompt_manager_impl.h" + +#include +#include + +#include "application_manager/application.h" +#include "application_manager/application_manager.h" +#include "application_manager/rpc_passing_handler.h" +#include "application_manager/commands/command_impl.h" +#include "application_manager/message_helper.h" +#include "application_manager/smart_object_keys.h" +#include "encryption/hashing.h" +#include "resumption/last_state.h" +#include "smart_objects/enum_schema_item.h" +#include "utils/logger.h" + +#include "smart_objects/enum_schema_item.h" +#include "utils/timer_task_impl.h" + +CREATE_LOGGERPTR_GLOBAL(logger_, "RPCPassingHandler") + +namespace application_manager { + +RPCPassingHandler::RPCPassingHandler(AppServiceManager& asm_ref, + ApplicationManager& am_ref) + : app_service_manager_(asm_ref), app_manager_(am_ref) {} + +RPCPassingHandler::~RPCPassingHandler() {} + +bool RPCPassingHandler::IsPassThroughMessage( + uint32_t correlation_id, + commands::Command::CommandSource source, + int32_t message_type) { + sync_primitives::AutoLock lock(rpc_request_queue_lock_); + + if (rpc_request_queue.find(correlation_id) != rpc_request_queue.end()) { + if (message_type == MessageType::kResponse && + source == commands::Command::CommandSource::SOURCE_SDL) { + // Checks if response is being sent to mobile then removes the correlation + // id from the map + rpc_request_queue.erase(correlation_id); + } + return true; + } + return false; +} + +bool RPCPassingHandler::CanHandleFunctionID(int32_t function_id) { + auto services = app_service_manager_.GetActiveServices(); + for (auto it = services.begin(); it != services.end(); ++it) { + auto handled_rpcs = + it->second.record[strings::service_manifest][strings::handled_rpcs]; + for (size_t i = 0; i < handled_rpcs.length(); i++) { + if (handled_rpcs[i].asInt() == function_id) { + return true; + } + } + } + return false; +} + +bool RPCPassingHandler::RPCPassThrough(smart_objects::SmartObject rpc_message) { + LOG4CXX_AUTO_TRACE(logger_); + + uint32_t correlation_id = + rpc_message[strings::params][strings::correlation_id].asUInt(); + int32_t message_type = + rpc_message[strings::params][strings::message_type].asInt(); + + LOG4CXX_DEBUG(logger_, "RPC_PASSING: "); + MessageHelper::PrintSmartObject(rpc_message); + + // Clear timers for timed out requests + ClearCompletedTimers(); + switch (message_type) { + case MessageType::kRequest: { + LOG4CXX_DEBUG(logger_, "Handle request"); + rpc_request_queue_lock_.Acquire(); + if (rpc_request_queue.find(correlation_id) == rpc_request_queue.end()) { + rpc_request_queue_lock_.Release(); + LOG4CXX_DEBUG( + logger_, + "Correlation id DOES NOT exist in map. Constructing request queue"); + PopulateRPCRequestQueue(rpc_message); + } else { + rpc_request_queue_lock_.Release(); + LOG4CXX_DEBUG(logger_, "Correlation id DOES exist in map. Continuing"); + return false; + } + + rpc_request_queue_lock_.Acquire(); + if (rpc_request_queue[correlation_id].second.empty()) { + LOG4CXX_DEBUG(logger_, + "No services left in map. Using core to handle request"); + rpc_request_queue.erase(correlation_id); + rpc_request_queue_lock_.Release(); + return false; + } else { + rpc_request_queue_lock_.Release(); + ForwardRequestToMobile(correlation_id); + return true; + } + + break; + } + + case MessageType::kResponse: { + LOG4CXX_DEBUG(logger_, "Handle response"); + rpc_request_queue_lock_.Acquire(); + if (rpc_request_queue.find(correlation_id) == rpc_request_queue.end()) { + rpc_request_queue_lock_.Release(); + return false; + } + rpc_request_queue_lock_.Release(); + RemoveRequestTimer(correlation_id); + auto result_code = static_cast( + rpc_message[strings::msg_params][strings::result_code].asInt()); + + if (result_code == mobile_apis::Result::UNSUPPORTED_REQUEST) { + LOG4CXX_DEBUG(logger_, "Service sent UNSUPPORTED_REQUEST"); + PerformNextRequest(correlation_id); + return true; + } else { + LOG4CXX_DEBUG(logger_, "Valid RPC passing response"); + ForwardResponseToMobile(correlation_id, rpc_message); + return true; + } + + break; + } + } + + return false; +} + +void RPCPassingHandler::PopulateRPCRequestQueue( + smart_objects::SmartObject request_message) { + uint32_t origin_connection_key = + request_message[strings::params][strings::connection_key].asUInt(); + uint32_t correlation_id = + request_message[strings::params][strings::correlation_id].asUInt(); + int32_t function_id = + request_message[strings::params][strings::function_id].asInt(); + + // Construct list of pass through services + auto entry = std::make_pair(request_message, std::deque()); + auto services = app_service_manager_.GetActiveServices(); + + for (auto services_it = services.begin(); services_it != services.end(); + ++services_it) { + auto handled_rpcs = + services_it->second + .record[strings::service_manifest][strings::handled_rpcs]; + for (size_t i = 0; i < handled_rpcs.length(); i++) { + if (handled_rpcs[i].asInt() == function_id) { + // Add requests to queue + ServiceInfo service_info{services_it->first, + services_it->second.connection_key}; + entry.second.push_back(service_info); + app_manager_.IncreaseForwardedRequestTimeout(origin_connection_key, + correlation_id); + break; + } + } + } + + sync_primitives::AutoLock lock(rpc_request_queue_lock_); + rpc_request_queue[correlation_id] = entry; + + LOG4CXX_DEBUG(logger_, + "Added " << rpc_request_queue[correlation_id].second.size() + << " requests to the queue"); +} +void RPCPassingHandler::ForwardRequestToMobile(uint32_t correlation_id) { + rpc_request_queue_lock_.Acquire(); + uint32_t connection_key = + rpc_request_queue[correlation_id].second.front().connection_key; + LOG4CXX_DEBUG(logger_, + "Forwarding request to service with app id " << connection_key); + + smart_objects::SmartObject message(rpc_request_queue[correlation_id].first); + message[strings::params][strings::connection_key] = connection_key; + smart_objects::SmartObjectSPtr result = + std::make_shared(message); + rpc_request_queue_lock_.Release(); + AddRequestTimer(correlation_id); + app_manager_.GetRPCService().SendMessageToMobile(result); +} + +void RPCPassingHandler::ForwardRequestToCore(uint32_t correlation_id) { + LOG4CXX_DEBUG(logger_, + "No services left in map. using core to handle request"); + rpc_request_queue_lock_.Acquire(); + smart_objects::SmartObject message(rpc_request_queue[correlation_id].first); + smart_objects::SmartObjectSPtr result = + std::make_shared(message); + rpc_request_queue.erase(correlation_id); + rpc_request_queue_lock_.Release(); + app_manager_.GetRPCService().ManageMobileCommand( + result, commands::Command::SOURCE_MOBILE); +} + +void RPCPassingHandler::ForwardResponseToMobile( + uint32_t correlation_id, smart_objects::SmartObject response_message) { + rpc_request_queue_lock_.Acquire(); + uint32_t origin_connection_key = + rpc_request_queue[correlation_id] + .first[strings::params][strings::connection_key] + .asUInt(); + rpc_request_queue_lock_.Release(); + + LOG4CXX_DEBUG(logger_, + "Forwarding response to mobile app " << origin_connection_key); + smart_objects::SmartObject message(response_message); + message[strings::params][strings::connection_key] = origin_connection_key; + smart_objects::SmartObjectSPtr result = + std::make_shared(message); + app_manager_.GetRPCService().SendMessageToMobile(result); +} + +bool RPCPassingHandler::PerformNextRequest(uint32_t correlation_id) { + LOG4CXX_DEBUG(logger_, "Performing next request in queue"); + rpc_request_queue_lock_.Acquire(); + if (rpc_request_queue.find(correlation_id) == rpc_request_queue.end()) { + LOG4CXX_ERROR(logger_, "Correlation id does NOT exist in map"); + rpc_request_queue_lock_.Release(); + return false; + } + rpc_request_queue[correlation_id].second.pop_front(); + bool empty = rpc_request_queue[correlation_id].second.empty(); + rpc_request_queue_lock_.Release(); + + if (empty) { + ForwardRequestToCore(correlation_id); + } else { + ForwardRequestToMobile(correlation_id); + } + + return true; +} + +void RPCPassingHandler::OnPassThroughRequestTimeout() { + timeout_queue_lock_.Acquire(); + LOG4CXX_DEBUG(logger_, "Request Timed out"); + auto timeout_entry = timeout_queue_.front(); + uint32_t correlation_id = timeout_entry.second; + timeout_queue_lock_.Release(); + PerformNextRequest(correlation_id); +} + +void RPCPassingHandler::ClearCompletedTimers() { + sync_primitives::AutoLock lock(timeout_queue_lock_); + + LOG4CXX_DEBUG(logger_, "Clearing Completed Timers"); + for (auto it = timeout_queue_.begin(); it != timeout_queue_.end();) { + TimerSPtr timer = it->first; + uint32_t cid = it->second; + if (timer->is_completed()) { + LOG4CXX_DEBUG(logger_, + "Removing completed timer for correlation id " << cid); + it = timeout_queue_.erase(it); + } else { + ++it; + } + } +} + +void RPCPassingHandler::AddRequestTimer(uint32_t correlation_id) { + TimerSPtr rpc_passing_timer(std::make_shared( + "RPCPassingTimeoutTimer_" + std::to_string(correlation_id), + new timer::TimerTaskImpl( + this, &RPCPassingHandler::OnPassThroughRequestTimeout))); + const uint32_t timeout_ms = + app_manager_.get_settings().rpc_pass_through_timeout(); + rpc_passing_timer->Start(timeout_ms, timer::kSingleShot); + LOG4CXX_DEBUG(logger_, + "Adding and starting timer for correlation id " + << correlation_id); + sync_primitives::AutoLock lock(timeout_queue_lock_); + timeout_queue_.push_back(std::make_pair(rpc_passing_timer, correlation_id)); +} + +void RPCPassingHandler::RemoveRequestTimer(uint32_t correlation_id) { + sync_primitives::AutoLock lock(timeout_queue_lock_); + + for (auto it = timeout_queue_.begin(); it != timeout_queue_.end();) { + TimerSPtr timer = it->first; + uint32_t cid = it->second; + if (cid == correlation_id) { + LOG4CXX_DEBUG(logger_, + "Removing timer for correlation id " << correlation_id); + it = timeout_queue_.erase(it); + } else { + ++it; + } + } +} + +} // namespace application_manager diff --git a/src/components/application_manager/src/rpc_service_impl.cc b/src/components/application_manager/src/rpc_service_impl.cc index 99d0bf0cfe..d8329ba8cf 100644 --- a/src/components/application_manager/src/rpc_service_impl.cc +++ b/src/components/application_manager/src/rpc_service_impl.cc @@ -31,6 +31,7 @@ */ #include "application_manager/rpc_service_impl.h" +#include "application_manager/plugin_manager/plugin_keys.h" namespace application_manager { namespace rpc_service { @@ -38,6 +39,7 @@ namespace rpc_service { CREATE_LOGGERPTR_LOCAL(logger_, "RPCServiceImpl") namespace formatters = ns_smart_device_link::ns_json_handler::formatters; namespace jhs = ns_smart_device_link::ns_json_handler::strings; +namespace plugin_names = application_manager::plugin_manager::plugin_names; RPCServiceImpl::RPCServiceImpl( ApplicationManager& app_manager, @@ -386,6 +388,7 @@ void RPCServiceImpl::SendMessageToMobile( const bool is_result_code_exists = (*message)[strings::msg_params].keyExists(strings::result_code); + bool remove_unknown_parameters = true; if (!app) { LOG4CXX_ERROR(logger_, "No application associated with connection key"); @@ -417,7 +420,31 @@ void RPCServiceImpl::SendMessageToMobile( // Messages to mobile are not yet prioritized so use default priority value std::shared_ptr message_to_send( new Message(protocol_handler::MessagePriority::kDefault)); - if (!ConvertSOtoMessage((*message), (*message_to_send))) { + + int32_t function_id = (*message)[jhs::S_PARAMS][jhs::S_FUNCTION_ID].asInt(); + bool rpc_passing = app_manager_.GetAppServiceManager() + .GetRPCPassingHandler() + .CanHandleFunctionID(function_id); + if (IsAppServiceRPC(function_id, + commands::Command::CommandSource::SOURCE_SDL) || + rpc_passing) { + LOG4CXX_DEBUG(logger_, + "Allowing unknown parameters for response function " + << function_id); + remove_unknown_parameters = false; + } + + if (rpc_passing && + !app_manager_.GetAppServiceManager() + .GetRPCPassingHandler() + .IsPassThroughMessage( + (*message)[jhs::S_PARAMS][jhs::S_CORRELATION_ID].asUInt(), + commands::Command::CommandSource::SOURCE_SDL, + (*message)[jhs::S_PARAMS][jhs::S_MESSAGE_TYPE].asInt())) { + remove_unknown_parameters = true; + } + if (!ConvertSOtoMessage( + (*message), (*message_to_send), remove_unknown_parameters)) { LOG4CXX_WARN(logger_, "Can't send msg to Mobile: failed to create string"); return; } @@ -496,6 +523,7 @@ void RPCServiceImpl::SendMessageToHMI( return; } + bool remove_unknown_parameters = true; // SmartObject |message| has no way to declare priority for now std::shared_ptr message_to_send( new Message(protocol_handler::MessagePriority::kDefault)); @@ -509,7 +537,17 @@ void RPCServiceImpl::SendMessageToHMI( logger_, "Attached schema to message, result if valid: " << message->isValid()); - if (!ConvertSOtoMessage(*message, *message_to_send)) { + if (IsAppServiceRPC((*message)[jhs::S_PARAMS][jhs::S_FUNCTION_ID].asInt(), + commands::Command::CommandSource::SOURCE_SDL_TO_HMI)) { + LOG4CXX_DEBUG(logger_, + "Allowing unknown parameters for response function " + << (*message)[jhs::S_PARAMS][jhs::S_FUNCTION_ID].asInt()); + + remove_unknown_parameters = false; + } + + if (!ConvertSOtoMessage( + *message, *message_to_send, remove_unknown_parameters)) { LOG4CXX_WARN(logger_, "Cannot send message to HMI: failed to create string"); return; @@ -518,6 +556,42 @@ void RPCServiceImpl::SendMessageToHMI( messages_to_hmi_.PostMessage(impl::MessageToHmi(message_to_send)); } +bool RPCServiceImpl::IsAppServiceRPC(int32_t function_id, + commands::Command::CommandSource source) { + // General RPCs related to App Services + if ((source == commands::Command::CommandSource::SOURCE_MOBILE) || + (source == + commands::Command::CommandSource::SOURCE_SDL)) { // MOBILE COMMANDS + switch (function_id) { + case mobile_apis::FunctionID::GetSystemCapabilityID: + case mobile_apis::FunctionID::OnSystemCapabilityUpdatedID: + return true; + break; + } + } else if ((source == commands::Command::CommandSource::SOURCE_HMI) || + (source == commands::Command::CommandSource:: + SOURCE_SDL_TO_HMI)) { // HMI COMMANDS + switch (function_id) { + case hmi_apis::FunctionID::BasicCommunication_OnSystemCapabilityUpdated: + return true; + break; + } + } + + // RPCs handled by app services plugin + auto plugin = + app_manager_.GetPluginManager().FindPluginToProcess(function_id, source); + if (!plugin) { + return false; + } + if ((*plugin).PluginName() != plugin_names::app_service_rpc_plugin) { + return false; + } + application_manager::CommandFactory& factory = (*plugin).GetCommandFactory(); + + return factory.IsAbleToProcess(function_id, source); +} + void RPCServiceImpl::set_protocol_handler( protocol_handler::ProtocolHandler* handler) { protocol_handler_ = handler; @@ -530,7 +604,8 @@ void RPCServiceImpl::set_hmi_message_handler( bool RPCServiceImpl::ConvertSOtoMessage( const ns_smart_device_link::ns_smart_objects::SmartObject& message, - Message& output) { + Message& output, + const bool remove_unknown_parameters) { LOG4CXX_AUTO_TRACE(logger_); if (smart_objects::SmartType_Null == message.getType() || @@ -555,16 +630,16 @@ bool RPCServiceImpl::ConvertSOtoMessage( switch (protocol_type) { case 0: { if (protocol_version == 1) { - if (!formatters::CFormatterJsonSDLRPCv1::toString(message, - output_string)) { + if (!formatters::CFormatterJsonSDLRPCv1::toString( + message, output_string, remove_unknown_parameters)) { LOG4CXX_WARN(logger_, "Failed to serialize smart object"); return false; } output.set_protocol_version( protocol_handler::MajorProtocolVersion::PROTOCOL_VERSION_1); } else { - if (!formatters::CFormatterJsonSDLRPCv2::toString(message, - output_string)) { + if (!formatters::CFormatterJsonSDLRPCv2::toString( + message, output_string, remove_unknown_parameters)) { LOG4CXX_WARN(logger_, "Failed to serialize smart object"); return false; } @@ -576,7 +651,8 @@ bool RPCServiceImpl::ConvertSOtoMessage( break; } case 1: { - if (!formatters::FormatterJsonRpc::ToString(message, output_string)) { + if (!formatters::FormatterJsonRpc::ToString( + message, output_string, remove_unknown_parameters)) { LOG4CXX_WARN(logger_, "Failed to serialize smart object"); return false; } @@ -589,7 +665,7 @@ bool RPCServiceImpl::ConvertSOtoMessage( return false; } - LOG4CXX_DEBUG(logger_, "Convertion result: " << output_string); + LOG4CXX_DEBUG(logger_, "Conversion result: " << output_string); output.set_connection_key(message.getElement(jhs::S_PARAMS) .getElement(strings::connection_key) diff --git a/src/components/formatters/include/formatters/CFormatterJsonSDLRPCv1.h b/src/components/formatters/include/formatters/CFormatterJsonSDLRPCv1.h index d2fdf87957..cd3e50212a 100644 --- a/src/components/formatters/include/formatters/CFormatterJsonSDLRPCv1.h +++ b/src/components/formatters/include/formatters/CFormatterJsonSDLRPCv1.h @@ -126,11 +126,14 @@ class CFormatterJsonSDLRPCv1 : public CFormatterJsonBase { * * @param obj input SmartObject * @param outStr resulting JSON string + * @param remove_unknown_parameters contains true if need to remove unknown + *parameters * @return true if success, false otherwise */ static bool toString( const ns_smart_device_link::ns_smart_objects::SmartObject& obj, - std::string& outStr); + std::string& outStr, + const bool remove_unknown_parameters = true); /** * @brief Creates a SmartObject from a JSON string. @@ -151,12 +154,15 @@ class CFormatterJsonSDLRPCv1 : public CFormatterJsonBase { * @param schema Smart schema which describes 'fake' smart object to be *formatted * @param outStr Resulting JSON string + * @param remove_unknown_parameters contains true if need to remove unknown + *parameters * @return formatting error code */ static tMetaFormatterErrorCode MetaFormatToString( const ns_smart_device_link::ns_smart_objects::SmartObject& object, const ns_smart_device_link::ns_smart_objects::CSmartSchema& schema, - std::string& outStr); + std::string& outStr, + const bool remove_unknown_parameters = true); }; // ---------------------------------------------------------------------------- diff --git a/src/components/formatters/include/formatters/CFormatterJsonSDLRPCv2.h b/src/components/formatters/include/formatters/CFormatterJsonSDLRPCv2.h index e248954552..f86e4e51cb 100644 --- a/src/components/formatters/include/formatters/CFormatterJsonSDLRPCv2.h +++ b/src/components/formatters/include/formatters/CFormatterJsonSDLRPCv2.h @@ -73,11 +73,14 @@ class CFormatterJsonSDLRPCv2 : public CFormatterJsonBase { * * @param obj input SmartObject * @param outStr resulting JSON string + * @param remove_unknown_parameters contains true if need to remove unknown + *parameters * @return true if success, false otherwise */ static bool toString( const ns_smart_device_link::ns_smart_objects::SmartObject& obj, - std::string& outStr); + std::string& outStr, + const bool remove_unknown_parameters = true); /** * @brief Creates a SmartObject from a JSON string. @@ -128,12 +131,15 @@ class CFormatterJsonSDLRPCv2 : public CFormatterJsonBase { * @param schema Smart schema which describes 'fake' smart object to be *formatted * @param outStr Resulting JSON string + * @param remove_unknown_parameters contains true if need to remove unknown + *parameters * @return formatting error code */ static tMetaFormatterErrorCode MetaFormatToString( const ns_smart_device_link::ns_smart_objects::SmartObject& object, const ns_smart_device_link::ns_smart_objects::CSmartSchema& schema, - std::string& outStr); + std::string& outStr, + const bool remove_unknown_parameters = true); }; template diff --git a/src/components/formatters/include/formatters/CSmartFactory.h b/src/components/formatters/include/formatters/CSmartFactory.h index a48eab2a6b..f3c3fbe207 100644 --- a/src/components/formatters/include/formatters/CSmartFactory.h +++ b/src/components/formatters/include/formatters/CSmartFactory.h @@ -148,14 +148,14 @@ class CSmartFactory { * * @param object SmartObject to attach schema for. * - * @param RemoveFakeParameters contains true if need + * @param remove_unknown_parameters contains true if need * to remove fake parameters from smart object otherwise contains false. * * @return True if operation was successful or false otherwise. */ bool attachSchema( ns_smart_device_link::ns_smart_objects::SmartObject& object, - const bool RemoveFakeParameters, + const bool remove_unknown_parameters, const utils::SemanticVersion& MessageVersion = utils::SemanticVersion()); /** @@ -276,7 +276,7 @@ CSmartFactory::CSmartFactory( template bool CSmartFactory::attachSchema( ns_smart_device_link::ns_smart_objects::SmartObject& object, - const bool RemoveFakeParameters, + const bool remove_unknown_parameters, const utils::SemanticVersion& MessageVersion) { if (false == object.keyExists(strings::S_PARAMS)) return false; @@ -305,7 +305,7 @@ bool CSmartFactory::attachSchema( object.setSchema(schemaIterator->second); schemaIterator->second.applySchema( - object, RemoveFakeParameters, MessageVersion); + object, remove_unknown_parameters, MessageVersion); return true; } diff --git a/src/components/formatters/include/formatters/formatter_json_rpc.h b/src/components/formatters/include/formatters/formatter_json_rpc.h index 842e176976..3503767988 100644 --- a/src/components/formatters/include/formatters/formatter_json_rpc.h +++ b/src/components/formatters/include/formatters/formatter_json_rpc.h @@ -105,11 +105,13 @@ class FormatterJsonRpc : public CFormatterJsonBase { * * @param obj Input SmartObject. * @param out_str Resulting JSON string. - * + * @param remove_unknown_parameters contains true if need to remove unknown + *parameters * @return true if success, false otherwise. */ static bool ToString(const ns_smart_objects::SmartObject& obj, - std::string& out_str); + std::string& out_str, + const bool remove_unknown_parameters = true); /** * @brief Creates a SmartObject from a JSON string. diff --git a/src/components/formatters/src/CFormatterJsonSDLRPCv1.cc b/src/components/formatters/src/CFormatterJsonSDLRPCv1.cc index 121fd43131..a5c3d1a103 100644 --- a/src/components/formatters/src/CFormatterJsonSDLRPCv1.cc +++ b/src/components/formatters/src/CFormatterJsonSDLRPCv1.cc @@ -85,7 +85,8 @@ const std::string CFormatterJsonSDLRPCv1::getMessageType( // ---------------------------------------------------------------------------- bool CFormatterJsonSDLRPCv1::toString(const smart_objects_ns::SmartObject& obj, - std::string& outStr) { + std::string& outStr, + const bool remove_unknown_parameters) { bool result = false; try { Json::Value root(Json::objectValue); @@ -93,7 +94,8 @@ bool CFormatterJsonSDLRPCv1::toString(const smart_objects_ns::SmartObject& obj, smart_objects_ns::SmartObject formattedObj(obj); formattedObj.getSchema().unapplySchema( - formattedObj); // converts enums(as int32_t) to strings + formattedObj, + remove_unknown_parameters); // converts enums(as int32_t) to strings objToJsonValue(formattedObj.getElement(strings::S_MSG_PARAMS), params); @@ -125,7 +127,8 @@ CFormatterJsonSDLRPCv1::tMetaFormatterErrorCode CFormatterJsonSDLRPCv1::MetaFormatToString( const smart_objects_ns::SmartObject& object, const smart_objects_ns::CSmartSchema& schema, - std::string& outStr) { + std::string& outStr, + const bool remove_unknown_parameters) { meta_formatter_error_code::tMetaFormatterErrorCode result_code = meta_formatter_error_code::kErrorOk; @@ -156,7 +159,8 @@ CFormatterJsonSDLRPCv1::MetaFormatToString( result_code |= meta_formatter_error_code::kErrorSchemaIsNotFunction; } - CFormatterJsonSDLRPCv1::toString(tmp_object, outStr); + CFormatterJsonSDLRPCv1::toString( + tmp_object, outStr, remove_unknown_parameters); return result_code; } diff --git a/src/components/formatters/src/CFormatterJsonSDLRPCv2.cc b/src/components/formatters/src/CFormatterJsonSDLRPCv2.cc index ffbb644cc6..a582b52462 100644 --- a/src/components/formatters/src/CFormatterJsonSDLRPCv2.cc +++ b/src/components/formatters/src/CFormatterJsonSDLRPCv2.cc @@ -41,14 +41,16 @@ namespace formatters { // ---------------------------------------------------------------------------- bool CFormatterJsonSDLRPCv2::toString(const smart_objects_ns::SmartObject& obj, - std::string& outStr) { + std::string& outStr, + const bool remove_unknown_parameters) { bool result = true; try { Json::Value root(Json::objectValue); smart_objects_ns::SmartObject formattedObj(obj); formattedObj.getSchema().unapplySchema( - formattedObj); // converts enums(as int32_t) to strings + formattedObj, + remove_unknown_parameters); // converts enums(as int32_t) to strings objToJsonValue(formattedObj.getElement(strings::S_MSG_PARAMS), root); @@ -68,7 +70,8 @@ CFormatterJsonSDLRPCv2::tMetaFormatterErrorCode CFormatterJsonSDLRPCv2::MetaFormatToString( const smart_objects_ns::SmartObject& object, const smart_objects_ns::CSmartSchema& schema, - std::string& outStr) { + std::string& outStr, + const bool remove_unknown_parameters) { meta_formatter_error_code::tMetaFormatterErrorCode result_code = meta_formatter_error_code::kErrorOk; @@ -99,7 +102,8 @@ CFormatterJsonSDLRPCv2::MetaFormatToString( result_code |= meta_formatter_error_code::kErrorSchemaIsNotFunction; } - CFormatterJsonSDLRPCv2::toString(tmp_object, outStr); + CFormatterJsonSDLRPCv2::toString( + tmp_object, outStr, remove_unknown_parameters); return result_code; } diff --git a/src/components/formatters/src/formatter_json_rpc.cc b/src/components/formatters/src/formatter_json_rpc.cc index d50d04d0e9..07d45d5855 100644 --- a/src/components/formatters/src/formatter_json_rpc.cc +++ b/src/components/formatters/src/formatter_json_rpc.cc @@ -57,7 +57,8 @@ const char* FormatterJsonRpc::kData = "data"; const char* FormatterJsonRpc::kMessage = "message"; bool FormatterJsonRpc::ToString(const ns_smart_objects::SmartObject& obj, - std::string& out_str) { + std::string& out_str, + const bool remove_unknown_parameters) { bool result = true; try { Json::Value root(Json::objectValue); @@ -66,7 +67,8 @@ bool FormatterJsonRpc::ToString(const ns_smart_objects::SmartObject& obj, ns_smart_objects::SmartObject formatted_object(obj); Json::Value msg_params_json(Json::objectValue); - formatted_object.getSchema().unapplySchema(formatted_object); + formatted_object.getSchema().unapplySchema(formatted_object, + remove_unknown_parameters); bool is_message_params = formatted_object.keyExists(strings::S_MSG_PARAMS); bool empty_message_params = true; diff --git a/src/components/include/application_manager/rpc_service.h b/src/components/include/application_manager/rpc_service.h index d892b12422..e0127eac80 100644 --- a/src/components/include/application_manager/rpc_service.h +++ b/src/components/include/application_manager/rpc_service.h @@ -76,6 +76,17 @@ class RPCService { */ virtual void SendMessageToHMI(const commands::MessageSharedPtr message) = 0; + /** + * @brief Check if RPC with function_id can be handled by app services(related + * to app services or handled by app services plugin) + * @param function_id RPC function id + * @param source RPC command source + * @param rpc_passing Reference to bool. Set to true to enable rpc pasing + * @return true if App Services can handle RPC + */ + virtual bool IsAppServiceRPC(int32_t function_id, + commands::Command::CommandSource source) = 0; + /** * @brief set_protocol_handler * @param handler diff --git a/src/components/include/test/application_manager/mock_rpc_service.h b/src/components/include/test/application_manager/mock_rpc_service.h index 3503f8bad1..aacb48a5ab 100644 --- a/src/components/include/test/application_manager/mock_rpc_service.h +++ b/src/components/include/test/application_manager/mock_rpc_service.h @@ -27,6 +27,10 @@ class MockRPCService : public application_manager::rpc_service::RPCService { void(protocol_handler::ProtocolHandler* handler)); MOCK_METHOD1(set_hmi_message_handler, void(hmi_message_handler::HMIMessageHandler* handler)); + MOCK_METHOD2( + IsAppServiceRPC, + bool(int32_t function_id, + application_manager::commands::Command::CommandSource source)); }; } } diff --git a/src/components/smart_objects/include/smart_objects/array_schema_item.h b/src/components/smart_objects/include/smart_objects/array_schema_item.h index a81fdd637e..b365a48638 100644 --- a/src/components/smart_objects/include/smart_objects/array_schema_item.h +++ b/src/components/smart_objects/include/smart_objects/array_schema_item.h @@ -79,12 +79,12 @@ class CArraySchemaItem : public ISchemaItem { * @brief Apply schema. * * @param Object Object to apply schema. - * - * @param RemoveFakeParameters contains true if need to remove fake parameters + * @param remove_unknown_parameters contains true if need to remove unknown + *parameters * from smart object otherwise contains false. **/ void applySchema(SmartObject& Object, - const bool RemoveFakeParameters, + const bool remove_unknown_parameters, const utils::SemanticVersion& MessageVersion = utils::SemanticVersion()) OVERRIDE; @@ -92,8 +92,11 @@ class CArraySchemaItem : public ISchemaItem { * @brief Unapply schema. * * @param Object Object to unapply schema. + * @param remove_unknown_parameters contains true if need to remove unknown + *parameters **/ - void unapplySchema(SmartObject& Object) OVERRIDE; + void unapplySchema(SmartObject& Object, + const bool remove_unknown_parameters) OVERRIDE; /** * @brief Build smart object by smart schema having copied matched diff --git a/src/components/smart_objects/include/smart_objects/enum_schema_item.h b/src/components/smart_objects/include/smart_objects/enum_schema_item.h index 942b491927..dfa0a4baeb 100644 --- a/src/components/smart_objects/include/smart_objects/enum_schema_item.h +++ b/src/components/smart_objects/include/smart_objects/enum_schema_item.h @@ -129,18 +129,22 @@ class TEnumSchemaItem : public CDefaultSchemaItem { * and tries to convert it to integer according to element-to-string * map. * @param Object Object to apply schema. - * @param RemoveFakeParameters contains true if need to remove fake parameters + * @param remove_unknown_parameters contains true if need to remove unknown + *parameters * from smart object otherwise contains false. **/ void applySchema(SmartObject& Object, - const bool RemoveFakeParameters, + const bool remove_unknown_parameters, const utils::SemanticVersion& MessageVersion = utils::SemanticVersion()) OVERRIDE; /** * @brief Unapply schema. * @param Object Object to unapply schema. + * @param remove_unknown_parameters contains true if need to remove unknown + *parameters **/ - void unapplySchema(SmartObject& Object) OVERRIDE; + void unapplySchema(SmartObject& Object, + const bool remove_unknown_parameters) OVERRIDE; private: /** @@ -365,7 +369,7 @@ errors::eType TEnumSchemaItem::validate( template void TEnumSchemaItem::applySchema( SmartObject& Object, - const bool RemoveFakeParameters, + const bool remove_unknown_parameters, const utils::SemanticVersion& MessageVersion) { if (SmartType_String == Object.getType()) { EnumType enum_val = static_cast(-1); @@ -376,7 +380,8 @@ void TEnumSchemaItem::applySchema( } template -void TEnumSchemaItem::unapplySchema(SmartObject& Object) { +void TEnumSchemaItem::unapplySchema( + SmartObject& Object, const bool remove_unknown_parameters) { if (SmartType_Integer == Object.getType()) { const char* str; if (ConversionHelper::EnumToCString(static_cast(Object.asInt()), diff --git a/src/components/smart_objects/include/smart_objects/object_schema_item.h b/src/components/smart_objects/include/smart_objects/object_schema_item.h index 45d161320b..27937ee17c 100644 --- a/src/components/smart_objects/include/smart_objects/object_schema_item.h +++ b/src/components/smart_objects/include/smart_objects/object_schema_item.h @@ -118,18 +118,22 @@ class CObjectSchemaItem : public ISchemaItem { /** * @brief Apply schema. * @param Object Object to apply schema. - * @param RemoveFakeParameters contains true if need to remove fake parameters + * @param remove_unknown_parameters contains true if need to remove unknown + *parameters * from smart object otherwise contains false. **/ void applySchema(SmartObject& Object, - const bool RemoveFakeParameters, + const bool remove_unknown_parameters, const utils::SemanticVersion& MessageVersion = utils::SemanticVersion()) OVERRIDE; /** * @brief Unapply schema. * @param Object Object to unapply schema. + * @param remove_unknown_parameters contains true if need to remove unknown + *parameters **/ - void unapplySchema(SmartObject& Object) OVERRIDE; + void unapplySchema(SmartObject& Object, + const bool remove_unknown_parameters) OVERRIDE; /** * @brief Build smart object by smart schema having copied matched * parameters from pattern smart object diff --git a/src/components/smart_objects/include/smart_objects/schema_item.h b/src/components/smart_objects/include/smart_objects/schema_item.h index 24c642c0ba..0c1b3f75b8 100644 --- a/src/components/smart_objects/include/smart_objects/schema_item.h +++ b/src/components/smart_objects/include/smart_objects/schema_item.h @@ -88,21 +88,25 @@ class ISchemaItem { * @brief Apply schema. * * @param Object Object to apply schema. - * @param RemoveFakeParameters contains true if need to remove fake parameters + * @param remove_unknown_parameters contains true if need to remove unknown + *parameters * from smart object otherwise contains false. **/ virtual void applySchema( ns_smart_device_link::ns_smart_objects::SmartObject& Object, - const bool RemoveFakeParameters, + const bool remove_unknown_parameters, const utils::SemanticVersion& MessageVersion = utils::SemanticVersion()); /** * @brief Unapply schema. * * @param Object Object to unapply schema. + * @param remove_unknown_parameters contains true if need to remove unknown + *parameters **/ virtual void unapplySchema( - ns_smart_device_link::ns_smart_objects::SmartObject& Object); + ns_smart_device_link::ns_smart_objects::SmartObject& Object, + const bool remove_unknown_parameters = true); /** * @brief Build smart object by smart schema having copied matched diff --git a/src/components/smart_objects/include/smart_objects/smart_schema.h b/src/components/smart_objects/include/smart_objects/smart_schema.h index 5e1497fdde..41737fed25 100644 --- a/src/components/smart_objects/include/smart_objects/smart_schema.h +++ b/src/components/smart_objects/include/smart_objects/smart_schema.h @@ -85,22 +85,26 @@ class CSmartSchema FINAL { * * @param Object Object to apply schema. * - * @param RemoveFakeParameters contains true if need to remove fake parameters + * @param remove_unknown_parameters contains true if need to remove unknown + *parameters * from smart object otherwise contains false. **/ void applySchema( SmartObject& Object, - const bool RemoveFakeParameters, + const bool remove_unknown_parameters, const utils::SemanticVersion& MessageVersion = utils::SemanticVersion()); /** * @brief The reverse SmartObject conversion using schema. * * @param object Object to convert. + * @param remove_unknown_parameters contains true if need to remove unknown + *parameters */ // TODO(cpplint): Is this a non-const reference? // If so, make const or use a pointer. - void unapplySchema(SmartObject& object); + void unapplySchema(SmartObject& object, + const bool remove_unknown_parameters = true); /** * @brief Build smart object by smart schema having copied matched diff --git a/src/components/smart_objects/src/array_schema_item.cc b/src/components/smart_objects/src/array_schema_item.cc index 7d5f8bcf84..be5fc2b83a 100644 --- a/src/components/smart_objects/src/array_schema_item.cc +++ b/src/components/smart_objects/src/array_schema_item.cc @@ -90,20 +90,21 @@ errors::eType CArraySchemaItem::validate( void CArraySchemaItem::applySchema( SmartObject& Object, - const bool RemoveFakeParameters, + const bool remove_unknown_parameters, const utils::SemanticVersion& MessageVersion) { if (SmartType_Array == Object.getType()) { for (size_t i = 0U; i < Object.length(); ++i) { mElementSchemaItem->applySchema( - Object[i], RemoveFakeParameters, MessageVersion); + Object[i], remove_unknown_parameters, MessageVersion); } } } -void CArraySchemaItem::unapplySchema(SmartObject& Object) { +void CArraySchemaItem::unapplySchema(SmartObject& Object, + const bool remove_unknown_parameters) { if (SmartType_Array == Object.getType()) { for (size_t i = 0U; i < Object.length(); ++i) { - mElementSchemaItem->unapplySchema(Object[i]); + mElementSchemaItem->unapplySchema(Object[i], remove_unknown_parameters); } } } diff --git a/src/components/smart_objects/src/object_schema_item.cc b/src/components/smart_objects/src/object_schema_item.cc index 742c2ec353..b32757db7a 100644 --- a/src/components/smart_objects/src/object_schema_item.cc +++ b/src/components/smart_objects/src/object_schema_item.cc @@ -154,13 +154,13 @@ errors::eType CObjectSchemaItem::validate( void CObjectSchemaItem::applySchema( SmartObject& Object, - const bool RemoveFakeParameters, + const bool remove_unknown_parameters, const utils::SemanticVersion& MessageVersion) { if (SmartType_Map != Object.getType()) { return; } - if (RemoveFakeParameters) { + if (remove_unknown_parameters) { RemoveFakeParams(Object, MessageVersion); } @@ -173,16 +173,17 @@ void CObjectSchemaItem::applySchema( if (member.mSchemaItem->setDefaultValue(default_value)) { Object[key] = default_value; member.mSchemaItem->applySchema( - Object[key], RemoveFakeParameters, MessageVersion); + Object[key], remove_unknown_parameters, MessageVersion); } } else { member.mSchemaItem->applySchema( - Object[key], RemoveFakeParameters, MessageVersion); + Object[key], remove_unknown_parameters, MessageVersion); } } } -void CObjectSchemaItem::unapplySchema(SmartObject& Object) { +void CObjectSchemaItem::unapplySchema(SmartObject& Object, + const bool remove_unknown_parameters) { if (SmartType_Map != Object.getType()) { return; } @@ -191,7 +192,7 @@ void CObjectSchemaItem::unapplySchema(SmartObject& Object) { const std::string& key = it->first; // move next to avoid wrong iterator on erase ++it; - if (mMembers.end() == mMembers.find(key)) { + if (mMembers.end() == mMembers.find(key) && remove_unknown_parameters) { // remove fake params Object.erase(key); } @@ -202,7 +203,7 @@ void CObjectSchemaItem::unapplySchema(SmartObject& Object) { const std::string& key = it->first; const SMember& member = it->second; if (Object.keyExists(key)) { - member.mSchemaItem->unapplySchema(Object[key]); + member.mSchemaItem->unapplySchema(Object[key], remove_unknown_parameters); } } } diff --git a/src/components/smart_objects/src/schema_item.cc b/src/components/smart_objects/src/schema_item.cc index 5e9358092a..fbab17f32d 100644 --- a/src/components/smart_objects/src/schema_item.cc +++ b/src/components/smart_objects/src/schema_item.cc @@ -51,10 +51,11 @@ bool ISchemaItem::hasDefaultValue(SmartObject& Object) { } void ISchemaItem::applySchema(SmartObject& Object, - const bool RemoveFakeParameters, + const bool remove_unknown_parameters, const utils::SemanticVersion& MessageVersion) {} -void ISchemaItem::unapplySchema(SmartObject& Object) {} +void ISchemaItem::unapplySchema(SmartObject& Object, + const bool remove_unknown_parameters) {} void ISchemaItem::BuildObjectBySchema(const SmartObject& pattern_object, SmartObject& result_object) {} diff --git a/src/components/smart_objects/src/smart_schema.cc b/src/components/smart_objects/src/smart_schema.cc index f7cd22c4bc..dc0f1cbe31 100644 --- a/src/components/smart_objects/src/smart_schema.cc +++ b/src/components/smart_objects/src/smart_schema.cc @@ -52,13 +52,14 @@ void CSmartSchema::setSchemaItem(const ISchemaItemPtr schemaItem) { } void CSmartSchema::applySchema(SmartObject& Object, - const bool RemoveFakeParameters, + const bool remove_unknown_parameters, const utils::SemanticVersion& MessageVersion) { - mSchemaItem->applySchema(Object, RemoveFakeParameters, MessageVersion); + mSchemaItem->applySchema(Object, remove_unknown_parameters, MessageVersion); } -void CSmartSchema::unapplySchema(SmartObject& Object) { - mSchemaItem->unapplySchema(Object); +void CSmartSchema::unapplySchema(SmartObject& Object, + const bool remove_unknown_parameters) { + mSchemaItem->unapplySchema(Object, remove_unknown_parameters); } void CSmartSchema::BuildObjectBySchema(const SmartObject& pattern_object, -- cgit v1.2.1 From 0fdfd32ff5ebeae5d6eb8f92131b235de5441236 Mon Sep 17 00:00:00 2001 From: jacobkeeler Date: Thu, 7 Mar 2019 23:26:35 -0500 Subject: Update preloaded PT and fix merge issues --- src/appMain/sdl_preloaded_pt.json | 62 +++++++++++++++++++--- src/appMain/smartDeviceLink.ini | 10 ---- .../src/app_service_mobile_command_factory.cc | 4 -- 3 files changed, 54 insertions(+), 22 deletions(-) diff --git a/src/appMain/sdl_preloaded_pt.json b/src/appMain/sdl_preloaded_pt.json index f70fdfdf10..06b9c3caa4 100644 --- a/src/appMain/sdl_preloaded_pt.json +++ b/src/appMain/sdl_preloaded_pt.json @@ -199,12 +199,6 @@ "FULL", "LIMITED", "NONE"] - }, - "GetFile": { - "hmi_levels": ["BACKGROUND", - "FULL", - "LIMITED", - "NONE"] }, "RegisterAppInterface": { "hmi_levels": ["BACKGROUND", @@ -591,21 +585,73 @@ } } }, - "AppService":{ + "AppServiceProducer":{ "rpcs":{ "PublishAppService":{ "hmi_levels": [ + "FULL", + "LIMITED", "BACKGROUND", + "NONE" + ] + }, + "GetAppServiceData": { + "hmi_levels": [ "FULL", "LIMITED", + "BACKGROUND", + "NONE" + ] + }, + "OnAppServiceData": { + "hmi_levels": [ + "FULL", + "LIMITED", + "BACKGROUND", "NONE" ] }, "PerformAppServiceInteraction": { "hmi_levels": [ + "FULL", + "LIMITED", "BACKGROUND", + "NONE" + ] + } + } + }, + "AppServiceConsumer": { + "rpcs": { + "GetFile": { + "hmi_levels": [ + "FULL", + "LIMITED", + "BACKGROUND", + "NONE" + ] + }, + "GetAppServiceData": { + "hmi_levels": [ + "FULL", + "LIMITED", + "BACKGROUND", + "NONE" + ] + }, + "OnAppServiceData": { + "hmi_levels": [ "FULL", "LIMITED", + "BACKGROUND", + "NONE" + ] + }, + "PerformAppServiceInteraction": { + "hmi_levels": [ + "FULL", + "LIMITED", + "BACKGROUND", "NONE" ] } @@ -2451,7 +2497,7 @@ "steal_focus": false, "priority": "NONE", "default_hmi": "NONE", - "groups": ["Base-4", "AppService"], + "groups": ["Base-4"], "RequestType": [], "RequestSubType": [] }, diff --git a/src/appMain/smartDeviceLink.ini b/src/appMain/smartDeviceLink.ini index 2b2c784746..54c2395c47 100644 --- a/src/appMain/smartDeviceLink.ini +++ b/src/appMain/smartDeviceLink.ini @@ -359,16 +359,6 @@ EnableAppLaunchIOS = true ;SecondaryTransportForUSB = ;SecondaryTransportForWiFi = -[AppServices] -; The ID to pass to app service publishers when sending a PerformAppServiceInteraction request -;CoresOriginId = "sdl_core" - -; Services that exist on the module. Values are of AppServiceType in RPC Spec. These services will be used as default and app services will only become primary service publisher with direct user interaction. These services will also be a fallback if no app service publisher is registered with the system of that type. -;EmbeddedServices = MEDIA, WEATHER, NAVIGATION, VOICE_ASSISTANT, COMMUNICATION_VOIP, MESSAGING, TTS - -; Additional time added to RPC timeout when passing through to App service -RpcPassThroughTimeout = 10000 - [ServicesMap] ; A matrix to specify which service is allowed on which transports. The transports are listed ; in preferred order. If a transport is not listed, then the service is not allowed diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/app_service_mobile_command_factory.cc b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/app_service_mobile_command_factory.cc index 572e637108..4b4da5e3e9 100644 --- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/app_service_mobile_command_factory.cc +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/app_service_mobile_command_factory.cc @@ -47,10 +47,6 @@ #include "app_service_rpc_plugin/commands/mobile/perform_app_service_interaction_response_from_mobile.h" #include "app_service_rpc_plugin/commands/mobile/publish_app_service_request.h" #include "app_service_rpc_plugin/commands/mobile/publish_app_service_response.h" -#include "app_service_rpc_plugin/commands/mobile/get_app_service_data_request.h" -#include "app_service_rpc_plugin/commands/mobile/get_app_service_data_response.h" -#include "app_service_rpc_plugin/commands/mobile/get_app_service_data_request_to_mobile.h" -#include "app_service_rpc_plugin/commands/mobile/get_app_service_data_response_from_mobile.h" CREATE_LOGGERPTR_GLOBAL(logger_, "AppServiceRpcPlugin") -- cgit v1.2.1 From dbd96397d3c0ab94571868b084c0f66e3e4a3d7e Mon Sep 17 00:00:00 2001 From: jacobkeeler Date: Fri, 8 Mar 2019 19:20:04 -0500 Subject: Allow for unknown enum values when validating messages --- .../application_manager/src/rpc_handler_impl.cc | 12 ++++++------ .../include/smart_objects/always_false_schema_item.h | 9 +++++---- .../include/smart_objects/always_true_schema_item.h | 9 +++++---- .../include/smart_objects/array_schema_item.h | 9 +++++---- .../include/smart_objects/default_shema_item.h | 12 +++++++----- .../include/smart_objects/enum_schema_item.h | 15 ++++++++++----- .../include/smart_objects/number_schema_item.h | 12 +++++++----- .../include/smart_objects/object_schema_item.h | 9 +++++---- .../smart_objects/include/smart_objects/schema_item.h | 3 ++- .../smart_objects/include/smart_objects/smart_object.h | 3 ++- .../smart_objects/include/smart_objects/smart_schema.h | 9 +++++---- .../include/smart_objects/string_schema_item.h | 9 +++++---- .../smart_objects/src/always_false_schema_item.cc | 3 ++- .../smart_objects/src/always_true_schema_item.cc | 3 ++- src/components/smart_objects/src/array_schema_item.cc | 6 ++++-- src/components/smart_objects/src/object_schema_item.cc | 10 +++++++--- src/components/smart_objects/src/schema_item.cc | 3 ++- src/components/smart_objects/src/smart_object.cc | 6 ++++-- src/components/smart_objects/src/smart_schema.cc | 6 ++++-- src/components/smart_objects/src/string_schema_item.cc | 3 ++- 20 files changed, 91 insertions(+), 60 deletions(-) diff --git a/src/components/application_manager/src/rpc_handler_impl.cc b/src/components/application_manager/src/rpc_handler_impl.cc index 6374e2a955..449ff0eceb 100644 --- a/src/components/application_manager/src/rpc_handler_impl.cc +++ b/src/components/application_manager/src/rpc_handler_impl.cc @@ -319,9 +319,8 @@ bool RPCHandlerImpl::ConvertMessageToSO( if (!conversion_result || !mobile_so_factory().attachSchema( output, remove_unknown_parameters, msg_version) || - ((output.validate(&report, msg_version) != - smart_objects::errors::OK && - remove_unknown_parameters))) { + output.validate(&report, msg_version, !remove_unknown_parameters) != + smart_objects::errors::OK) { LOG4CXX_WARN(logger_, "Failed to parse string to smart object with API version " << msg_version.toString() << " : " @@ -387,10 +386,11 @@ bool RPCHandlerImpl::ConvertMessageToSO( } rpc::ValidationReport report("RPC"); - - if (output.validate(&report) != smart_objects::errors::OK) { + utils::SemanticVersion empty_version; + if (output.validate(&report, empty_version, !remove_unknown_parameters) != + smart_objects::errors::OK) { LOG4CXX_ERROR(logger_, - "Incorrect parameter from HMI" + "Incorrect parameter from HMI - " << rpc::PrettyFormat(report)); output.erase(strings::msg_params); diff --git a/src/components/smart_objects/include/smart_objects/always_false_schema_item.h b/src/components/smart_objects/include/smart_objects/always_false_schema_item.h index bfa39af10a..5e635d049b 100644 --- a/src/components/smart_objects/include/smart_objects/always_false_schema_item.h +++ b/src/components/smart_objects/include/smart_objects/always_false_schema_item.h @@ -55,10 +55,11 @@ class CAlwaysFalseSchemaItem : public ISchemaItem { * @param MessageVersion to check mobile RPC version against RPC Spec History * @return ns_smart_objects::errors::eType **/ - errors::eType validate(const SmartObject& Object, - rpc::ValidationReport* report__, - const utils::SemanticVersion& MessageVersion = - utils::SemanticVersion()) OVERRIDE; + errors::eType validate( + const SmartObject& Object, + rpc::ValidationReport* report__, + const utils::SemanticVersion& MessageVersion = utils::SemanticVersion(), + const bool allow_unknown_parameters = false) OVERRIDE; private: CAlwaysFalseSchemaItem(); diff --git a/src/components/smart_objects/include/smart_objects/always_true_schema_item.h b/src/components/smart_objects/include/smart_objects/always_true_schema_item.h index 4750c280e5..efa208833a 100644 --- a/src/components/smart_objects/include/smart_objects/always_true_schema_item.h +++ b/src/components/smart_objects/include/smart_objects/always_true_schema_item.h @@ -55,10 +55,11 @@ class CAlwaysTrueSchemaItem : public ISchemaItem { * @param MessageVersion to check mobile RPC version against RPC Spec History * @return ns_smart_objects::errors::eType **/ - errors::eType validate(const SmartObject& Object, - rpc::ValidationReport* report__, - const utils::SemanticVersion& MessageVersion = - utils::SemanticVersion()) OVERRIDE; + errors::eType validate( + const SmartObject& Object, + rpc::ValidationReport* report__, + const utils::SemanticVersion& MessageVersion = utils::SemanticVersion(), + const bool allow_unknown_parameters = false) OVERRIDE; private: CAlwaysTrueSchemaItem(); diff --git a/src/components/smart_objects/include/smart_objects/array_schema_item.h b/src/components/smart_objects/include/smart_objects/array_schema_item.h index b365a48638..3f2e22849d 100644 --- a/src/components/smart_objects/include/smart_objects/array_schema_item.h +++ b/src/components/smart_objects/include/smart_objects/array_schema_item.h @@ -70,10 +70,11 @@ class CArraySchemaItem : public ISchemaItem { * @param MessageVersion to check mobile RPC version against RPC Spec History * @return ns_smart_objects::errors::eType **/ - errors::eType validate(const SmartObject& Object, - rpc::ValidationReport* report__, - const utils::SemanticVersion& MessageVersion = - utils::SemanticVersion()) OVERRIDE; + errors::eType validate( + const SmartObject& Object, + rpc::ValidationReport* report__, + const utils::SemanticVersion& MessageVersion = utils::SemanticVersion(), + const bool allow_unknown_parameters = false) OVERRIDE; /** * @brief Apply schema. diff --git a/src/components/smart_objects/include/smart_objects/default_shema_item.h b/src/components/smart_objects/include/smart_objects/default_shema_item.h index 5978fcb282..f86bd81f71 100644 --- a/src/components/smart_objects/include/smart_objects/default_shema_item.h +++ b/src/components/smart_objects/include/smart_objects/default_shema_item.h @@ -55,10 +55,11 @@ class CDefaultSchemaItem : public ISchemaItem { * @param MessageVersion to check mobile RPC version against RPC Spec History * @return ns_smart_objects::errors::eType **/ - errors::eType validate(const SmartObject& Object, - rpc::ValidationReport* report__, - const utils::SemanticVersion& MessageVersion = - utils::SemanticVersion()) OVERRIDE; + errors::eType validate( + const SmartObject& Object, + rpc::ValidationReport* report__, + const utils::SemanticVersion& MessageVersion = utils::SemanticVersion(), + const bool allow_unknown_parameters = false) OVERRIDE; /** * @brief Set default value to an object. @@ -105,7 +106,8 @@ template errors::eType CDefaultSchemaItem::validate( const SmartObject& Object, rpc::ValidationReport* report__, - const utils::SemanticVersion& MessageVersion) { + const utils::SemanticVersion& MessageVersion, + const bool allow_unknown_parameters) { if (getSmartType() != Object.getType()) { std::string validation_info = "Incorrect type, expected: " + SmartObject::typeToString(getSmartType()) + diff --git a/src/components/smart_objects/include/smart_objects/enum_schema_item.h b/src/components/smart_objects/include/smart_objects/enum_schema_item.h index dfa0a4baeb..2067859d88 100644 --- a/src/components/smart_objects/include/smart_objects/enum_schema_item.h +++ b/src/components/smart_objects/include/smart_objects/enum_schema_item.h @@ -110,10 +110,11 @@ class TEnumSchemaItem : public CDefaultSchemaItem { * @param MessageVersion to check mobile RPC version against RPC Spec History * @return ns_smart_objects::errors::eType **/ - errors::eType validate(const SmartObject& Object, - rpc::ValidationReport* report__, - const utils::SemanticVersion& MessageVersion = - utils::SemanticVersion()) OVERRIDE; + errors::eType validate( + const SmartObject& Object, + rpc::ValidationReport* report__, + const utils::SemanticVersion& MessageVersion = utils::SemanticVersion(), + const bool allow_unknown_parameters = false) OVERRIDE; /** * @brief Return the correct history signature based on message version. * @param signatures Vector reference of enums history items. @@ -310,10 +311,14 @@ template errors::eType TEnumSchemaItem::validate( const SmartObject& Object, rpc::ValidationReport* report__, - const utils::SemanticVersion& MessageVersion) { + const utils::SemanticVersion& MessageVersion, + const bool allow_unknown_parameters) { if (SmartType_Integer != Object.getType()) { std::string validation_info; if (SmartType_String == Object.getType()) { + if (allow_unknown_parameters) { + return errors::OK; + } validation_info = "Invalid enum value: " + Object.asString(); } else { validation_info = "Incorrect type, expected: " + diff --git a/src/components/smart_objects/include/smart_objects/number_schema_item.h b/src/components/smart_objects/include/smart_objects/number_schema_item.h index 6481605daf..0c6c657026 100644 --- a/src/components/smart_objects/include/smart_objects/number_schema_item.h +++ b/src/components/smart_objects/include/smart_objects/number_schema_item.h @@ -72,10 +72,11 @@ class TNumberSchemaItem : public CDefaultSchemaItem { * @param MessageVersion to check mobile RPC version against RPC Spec History * @return ns_smart_objects::errors::eType **/ - errors::eType validate(const SmartObject& Object, - rpc::ValidationReport* report__, - const utils::SemanticVersion& MessageVersion = - utils::SemanticVersion()) OVERRIDE; + errors::eType validate( + const SmartObject& Object, + rpc::ValidationReport* report__, + const utils::SemanticVersion& MessageVersion = utils::SemanticVersion(), + const bool allow_unknown_parameters = false) OVERRIDE; private: /** @@ -137,7 +138,8 @@ template errors::eType TNumberSchemaItem::validate( const SmartObject& Object, rpc::ValidationReport* report__, - const utils::SemanticVersion& MessageVersion) { + const utils::SemanticVersion& MessageVersion, + const bool allow_unknown_parameters) { if (!isValidNumberType(Object.getType())) { SmartType expectedType = (typeid(double) == typeid(Object.getType())) ? SmartType_Double diff --git a/src/components/smart_objects/include/smart_objects/object_schema_item.h b/src/components/smart_objects/include/smart_objects/object_schema_item.h index 27937ee17c..3f452c08cc 100644 --- a/src/components/smart_objects/include/smart_objects/object_schema_item.h +++ b/src/components/smart_objects/include/smart_objects/object_schema_item.h @@ -111,10 +111,11 @@ class CObjectSchemaItem : public ISchemaItem { * @param MessageVersion to check mobile RPC version against RPC Spec History * @return ns_smart_objects::errors::eType **/ - errors::eType validate(const SmartObject& Object, - rpc::ValidationReport* report__, - const utils::SemanticVersion& MessageVersion = - utils::SemanticVersion()) OVERRIDE; + errors::eType validate( + const SmartObject& Object, + rpc::ValidationReport* report__, + const utils::SemanticVersion& MessageVersion = utils::SemanticVersion(), + const bool allow_unknown_parameters = false) OVERRIDE; /** * @brief Apply schema. * @param Object Object to apply schema. diff --git a/src/components/smart_objects/include/smart_objects/schema_item.h b/src/components/smart_objects/include/smart_objects/schema_item.h index 0c1b3f75b8..644d03728f 100644 --- a/src/components/smart_objects/include/smart_objects/schema_item.h +++ b/src/components/smart_objects/include/smart_objects/schema_item.h @@ -64,7 +64,8 @@ class ISchemaItem { virtual errors::eType validate( const SmartObject& Object, rpc::ValidationReport* report__, - const utils::SemanticVersion& MessageVersion = utils::SemanticVersion()); + const utils::SemanticVersion& MessageVersion = utils::SemanticVersion(), + const bool allow_unknown_parameters = false); /** * @brief Set default value to an object. diff --git a/src/components/smart_objects/include/smart_objects/smart_object.h b/src/components/smart_objects/include/smart_objects/smart_object.h index 2abc221972..c1c1983e81 100644 --- a/src/components/smart_objects/include/smart_objects/smart_object.h +++ b/src/components/smart_objects/include/smart_objects/smart_object.h @@ -680,7 +680,8 @@ class SmartObject FINAL { */ errors::eType validate( rpc::ValidationReport* report__, - const utils::SemanticVersion& MessageVersion = utils::SemanticVersion()); + const utils::SemanticVersion& MessageVersion = utils::SemanticVersion(), + const bool allow_unknown_parameters = false); /** * @brief Sets new schema diff --git a/src/components/smart_objects/include/smart_objects/smart_schema.h b/src/components/smart_objects/include/smart_objects/smart_schema.h index 41737fed25..d9ef7ae418 100644 --- a/src/components/smart_objects/include/smart_objects/smart_schema.h +++ b/src/components/smart_objects/include/smart_objects/smart_schema.h @@ -68,10 +68,11 @@ class CSmartSchema FINAL { * @param MessageVersion to check mobile RPC version against RPC Spec History * @return ns_smart_objects::errors::eType **/ - errors::eType validate(const SmartObject& Object, - rpc::ValidationReport* report__, - const utils::SemanticVersion& messageVersion = - utils::SemanticVersion()) const; + errors::eType validate( + const SmartObject& Object, + rpc::ValidationReport* report__, + const utils::SemanticVersion& messageVersion = utils::SemanticVersion(), + const bool allow_unknown_parameters = false) const; /** * @brief Set new root schema item. diff --git a/src/components/smart_objects/include/smart_objects/string_schema_item.h b/src/components/smart_objects/include/smart_objects/string_schema_item.h index 5b37db584d..678097b838 100644 --- a/src/components/smart_objects/include/smart_objects/string_schema_item.h +++ b/src/components/smart_objects/include/smart_objects/string_schema_item.h @@ -67,10 +67,11 @@ class CStringSchemaItem : public CDefaultSchemaItem { * @param MessageVersion to check mobile RPC version against RPC Spec History * @return ns_smart_objects::errors::eType **/ - errors::eType validate(const SmartObject& Object, - rpc::ValidationReport* report__, - const utils::SemanticVersion& MessageVersion = - utils::SemanticVersion()) OVERRIDE; + errors::eType validate( + const SmartObject& Object, + rpc::ValidationReport* report__, + const utils::SemanticVersion& MessageVersion = utils::SemanticVersion(), + const bool allow_unknown_parameters = false) OVERRIDE; private: /** diff --git a/src/components/smart_objects/src/always_false_schema_item.cc b/src/components/smart_objects/src/always_false_schema_item.cc index ca247eed09..62ae6549b9 100644 --- a/src/components/smart_objects/src/always_false_schema_item.cc +++ b/src/components/smart_objects/src/always_false_schema_item.cc @@ -44,7 +44,8 @@ std::shared_ptr CAlwaysFalseSchemaItem::create() { errors::eType CAlwaysFalseSchemaItem::validate( const SmartObject& Object, rpc::ValidationReport* report__, - const utils::SemanticVersion& MessageVersion) { + const utils::SemanticVersion& MessageVersion, + const bool allow_unknown_parameters) { report__->set_validation_info("Generic error"); return errors::ERROR; } diff --git a/src/components/smart_objects/src/always_true_schema_item.cc b/src/components/smart_objects/src/always_true_schema_item.cc index 983733165c..9421654900 100644 --- a/src/components/smart_objects/src/always_true_schema_item.cc +++ b/src/components/smart_objects/src/always_true_schema_item.cc @@ -42,7 +42,8 @@ std::shared_ptr CAlwaysTrueSchemaItem::create() { errors::eType CAlwaysTrueSchemaItem::validate( const SmartObject& Object, rpc::ValidationReport* report__, - const utils::SemanticVersion& MessageVersion) { + const utils::SemanticVersion& MessageVersion, + const bool allow_unknown_parameters) { return errors::OK; } diff --git a/src/components/smart_objects/src/array_schema_item.cc b/src/components/smart_objects/src/array_schema_item.cc index be5fc2b83a..0b616db692 100644 --- a/src/components/smart_objects/src/array_schema_item.cc +++ b/src/components/smart_objects/src/array_schema_item.cc @@ -45,7 +45,8 @@ std::shared_ptr CArraySchemaItem::create( errors::eType CArraySchemaItem::validate( const SmartObject& Object, rpc::ValidationReport* report__, - const utils::SemanticVersion& MessageVersion) { + const utils::SemanticVersion& MessageVersion, + const bool allow_unknown_parameters) { if (SmartType_Array != Object.getType()) { std::string validation_info = "Incorrect type, expected: " + SmartObject::typeToString(SmartType_Array) + @@ -80,7 +81,8 @@ errors::eType CArraySchemaItem::validate( const errors::eType result = mElementSchemaItem->validate(Object.getElement(i), &report__->ReportSubobject(strVal.str()), - MessageVersion); + MessageVersion, + allow_unknown_parameters); if (errors::OK != result) { return result; } diff --git a/src/components/smart_objects/src/object_schema_item.cc b/src/components/smart_objects/src/object_schema_item.cc index b32757db7a..382ae93e6d 100644 --- a/src/components/smart_objects/src/object_schema_item.cc +++ b/src/components/smart_objects/src/object_schema_item.cc @@ -110,7 +110,8 @@ std::shared_ptr CObjectSchemaItem::create( errors::eType CObjectSchemaItem::validate( const SmartObject& object, rpc::ValidationReport* report__, - const utils::SemanticVersion& MessageVersion) { + const utils::SemanticVersion& MessageVersion, + const bool allow_unknown_parameters) { if (SmartType_Map != object.getType()) { std::string validation_info = "Incorrect type, expected: " + SmartObject::typeToString(SmartType_Map) + @@ -142,8 +143,11 @@ errors::eType CObjectSchemaItem::validate( errors::eType result = errors::OK; // Check if MessageVersion matches schema version - result = correct_member.mSchemaItem->validate( - field, &report__->ReportSubobject(key), MessageVersion); + result = + correct_member.mSchemaItem->validate(field, + &report__->ReportSubobject(key), + MessageVersion, + allow_unknown_parameters); if (errors::OK != result) { return result; } diff --git a/src/components/smart_objects/src/schema_item.cc b/src/components/smart_objects/src/schema_item.cc index fbab17f32d..f116cae708 100644 --- a/src/components/smart_objects/src/schema_item.cc +++ b/src/components/smart_objects/src/schema_item.cc @@ -38,7 +38,8 @@ namespace ns_smart_objects { errors::eType ISchemaItem::validate( const SmartObject& object, rpc::ValidationReport* report__, - const utils::SemanticVersion& MessageVersion) { + const utils::SemanticVersion& MessageVersion, + const bool allow_unknown_parameters) { return errors::ERROR; } diff --git a/src/components/smart_objects/src/smart_object.cc b/src/components/smart_objects/src/smart_object.cc index 3235dd619e..d58310ec95 100644 --- a/src/components/smart_objects/src/smart_object.cc +++ b/src/components/smart_objects/src/smart_object.cc @@ -878,8 +878,10 @@ bool SmartObject::isValid() const { errors::eType SmartObject::validate( rpc::ValidationReport* report__, - const utils::SemanticVersion& MessageVersion) { - return m_schema.validate(*this, report__, MessageVersion); + const utils::SemanticVersion& MessageVersion, + const bool allow_unknown_parameters) { + return m_schema.validate( + *this, report__, MessageVersion, allow_unknown_parameters); } void SmartObject::setSchema(const CSmartSchema& schema) { diff --git a/src/components/smart_objects/src/smart_schema.cc b/src/components/smart_objects/src/smart_schema.cc index dc0f1cbe31..062bb18c8c 100644 --- a/src/components/smart_objects/src/smart_schema.cc +++ b/src/components/smart_objects/src/smart_schema.cc @@ -43,8 +43,10 @@ CSmartSchema::CSmartSchema(const ISchemaItemPtr SchemaItem) errors::eType CSmartSchema::validate( const SmartObject& object, rpc::ValidationReport* report__, - const utils::SemanticVersion& MessageVersion) const { - return mSchemaItem->validate(object, report__, MessageVersion); + const utils::SemanticVersion& MessageVersion, + const bool allow_unknown_parameters) const { + return mSchemaItem->validate( + object, report__, MessageVersion, allow_unknown_parameters); } void CSmartSchema::setSchemaItem(const ISchemaItemPtr schemaItem) { diff --git a/src/components/smart_objects/src/string_schema_item.cc b/src/components/smart_objects/src/string_schema_item.cc index 0288ad85e8..7331dd1340 100644 --- a/src/components/smart_objects/src/string_schema_item.cc +++ b/src/components/smart_objects/src/string_schema_item.cc @@ -49,7 +49,8 @@ std::shared_ptr CStringSchemaItem::create( errors::eType CStringSchemaItem::validate( const SmartObject& Object, rpc::ValidationReport* report__, - const utils::SemanticVersion& MessageVersion) { + const utils::SemanticVersion& MessageVersion, + const bool allow_unknown_parameters) { if (SmartType_String != Object.getType()) { std::string validation_info = "Incorrect type, expected: " + SmartObject::typeToString(SmartType_String) + -- cgit v1.2.1 From 91175fc0304866eb788c34080e66e71ea8409e16 Mon Sep 17 00:00:00 2001 From: jacobkeeler Date: Mon, 11 Mar 2019 11:05:58 -0400 Subject: Fix SystemCapabilities redefinition in HMI API --- src/components/interfaces/HMI_API.xml | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/components/interfaces/HMI_API.xml b/src/components/interfaces/HMI_API.xml index 004e0301c7..bbb173044a 100644 --- a/src/components/interfaces/HMI_API.xml +++ b/src/components/interfaces/HMI_API.xml @@ -3302,6 +3302,15 @@ + + + + + + + + + If included, the platform supports RC climate controls. For this baseline version, maxsize=1. i.e. only one climate control module is supported. @@ -3773,7 +3782,7 @@ - + The systemCapabilityType identifies which data object exists in this struct. For example, if the SystemCapability Type is NAVIGATION then a "navigationCapability" should exist Used as a descriptor of what data to expect in this struct. The corresponding param to this enum should be included and the only other para included. @@ -4249,7 +4258,7 @@ A notification to inform the connected device that a specific system capability has changed. - + The system capability that has been updated -- cgit v1.2.1 From db9199e556ef01e3dc86b414c223c7fea5383877 Mon Sep 17 00:00:00 2001 From: jacobkeeler Date: Mon, 11 Mar 2019 15:21:29 -0400 Subject: Remove unused code and headers --- .../include/application_manager/app_service_manager.h | 2 -- .../commands/mobile/get_app_service_data_request.h | 1 - .../mobile/get_app_service_data_response_from_mobile.h | 1 - .../commands/hmi/as_get_app_service_data_request_to_hmi.cc | 1 - .../hmi/as_get_app_service_data_response_from_hmi.cc | 2 +- .../commands/hmi/as_get_app_service_data_response_to_hmi.cc | 1 - .../src/commands/mobile/get_app_service_data_request.cc | 10 +--------- .../mobile/get_app_service_data_request_to_mobile.cc | 1 - .../src/commands/mobile/get_app_service_data_response.cc | 1 - .../mobile/get_app_service_data_response_from_mobile.cc | 10 +--------- .../perform_app_service_interaction_request_to_mobile.cc | 1 - .../mobile/perform_app_service_interaction_response.cc | 1 - .../src/commands/mobile/publish_app_service_response.cc | 1 - .../application_manager/src/app_service_manager.cc | 13 ------------- 14 files changed, 3 insertions(+), 43 deletions(-) diff --git a/src/components/application_manager/include/application_manager/app_service_manager.h b/src/components/application_manager/include/application_manager/app_service_manager.h index f7c46178c5..4c0877a456 100644 --- a/src/components/application_manager/include/application_manager/app_service_manager.h +++ b/src/components/application_manager/include/application_manager/app_service_manager.h @@ -140,8 +140,6 @@ class AppServiceManager { AppService* EmbeddedServiceForType(std::string service_type); - AppService* FindServiceByName(std::string name); - AppService* FindServiceByID(std::string service_id); std::string DefaultServiceByType(std::string service_type); diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/mobile/get_app_service_data_request.h b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/mobile/get_app_service_data_request.h index 8295e855fa..70cf0dc6b9 100644 --- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/mobile/get_app_service_data_request.h +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/mobile/get_app_service_data_request.h @@ -77,7 +77,6 @@ class GetAppServiceDataRequest : public app_mngr::commands::CommandRequestImpl { virtual void on_event(const app_mngr::event_engine::MobileEvent& event); private: - AppServiceRpcPlugin* plugin_; DISALLOW_COPY_AND_ASSIGN(GetAppServiceDataRequest); }; diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/mobile/get_app_service_data_response_from_mobile.h b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/mobile/get_app_service_data_response_from_mobile.h index 1411b23e5a..7e2b26d8fb 100644 --- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/mobile/get_app_service_data_response_from_mobile.h +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/mobile/get_app_service_data_response_from_mobile.h @@ -70,7 +70,6 @@ class GetAppServiceDataResponseFromMobile virtual void Run(); private: - AppServiceRpcPlugin* plugin_; DISALLOW_COPY_AND_ASSIGN(GetAppServiceDataResponseFromMobile); }; diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_get_app_service_data_request_to_hmi.cc b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_get_app_service_data_request_to_hmi.cc index 822cd0a29b..635cd7319a 100644 --- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_get_app_service_data_request_to_hmi.cc +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_get_app_service_data_request_to_hmi.cc @@ -33,7 +33,6 @@ #include "app_service_rpc_plugin/commands/hmi/as_get_app_service_data_request_to_hmi.h" #include "application_manager/application_impl.h" #include "application_manager/rpc_service.h" -#include "interfaces/MOBILE_API.h" namespace app_service_rpc_plugin { using namespace application_manager; diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_get_app_service_data_response_from_hmi.cc b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_get_app_service_data_response_from_hmi.cc index 9ce6ffdb50..c0b1b274fb 100644 --- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_get_app_service_data_response_from_hmi.cc +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_get_app_service_data_response_from_hmi.cc @@ -33,7 +33,7 @@ #include "app_service_rpc_plugin/commands/hmi/as_get_app_service_data_response_from_hmi.h" #include "application_manager/application_impl.h" #include "application_manager/rpc_service.h" -#include "interfaces/MOBILE_API.h" +#include "interfaces/HMI_API.h" #include "application_manager/message_helper.h" diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_get_app_service_data_response_to_hmi.cc b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_get_app_service_data_response_to_hmi.cc index 9e2289d39e..b489ec4765 100644 --- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_get_app_service_data_response_to_hmi.cc +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_get_app_service_data_response_to_hmi.cc @@ -33,7 +33,6 @@ #include "app_service_rpc_plugin/commands/hmi/as_get_app_service_data_response_to_hmi.h" #include "application_manager/application_impl.h" #include "application_manager/rpc_service.h" -#include "interfaces/MOBILE_API.h" namespace app_service_rpc_plugin { using namespace application_manager; diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/get_app_service_data_request.cc b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/get_app_service_data_request.cc index 0d387785ee..d8ff1d8040 100644 --- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/get_app_service_data_request.cc +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/get_app_service_data_request.cc @@ -52,15 +52,7 @@ GetAppServiceDataRequest::GetAppServiceDataRequest( application_manager, rpc_service, hmi_capabilities, - policy_handler) - , plugin_(NULL) { - auto plugin = (application_manager.GetPluginManager().FindPluginToProcess( - mobile_apis::FunctionID::GetAppServiceDataID, - app_mngr::commands::Command::CommandSource::SOURCE_MOBILE)); - if (plugin) { - plugin_ = dynamic_cast(&(*plugin)); - } -} + policy_handler) {} GetAppServiceDataRequest::~GetAppServiceDataRequest() {} diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/get_app_service_data_request_to_mobile.cc b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/get_app_service_data_request_to_mobile.cc index 2bf81b3a2d..0af1a5436b 100644 --- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/get_app_service_data_request_to_mobile.cc +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/get_app_service_data_request_to_mobile.cc @@ -33,7 +33,6 @@ #include "app_service_rpc_plugin/commands/mobile/get_app_service_data_request_to_mobile.h" #include "application_manager/application_impl.h" #include "application_manager/rpc_service.h" -#include "interfaces/MOBILE_API.h" namespace app_service_rpc_plugin { using namespace application_manager; diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/get_app_service_data_response.cc b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/get_app_service_data_response.cc index df7bbba2f7..32ad8e014d 100644 --- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/get_app_service_data_response.cc +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/get_app_service_data_response.cc @@ -33,7 +33,6 @@ #include "app_service_rpc_plugin/commands/mobile/get_app_service_data_response.h" #include "application_manager/application_impl.h" #include "application_manager/rpc_service.h" -#include "interfaces/MOBILE_API.h" namespace app_service_rpc_plugin { using namespace application_manager; diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/get_app_service_data_response_from_mobile.cc b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/get_app_service_data_response_from_mobile.cc index f8c1f3892d..90fca04eb2 100644 --- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/get_app_service_data_response_from_mobile.cc +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/get_app_service_data_response_from_mobile.cc @@ -50,15 +50,7 @@ GetAppServiceDataResponseFromMobile::GetAppServiceDataResponseFromMobile( application_manager, rpc_service, hmi_capabilities, - policy_handler) - , plugin_(NULL) { - auto plugin = (application_manager.GetPluginManager().FindPluginToProcess( - mobile_apis::FunctionID::PublishAppServiceID, - app_mngr::commands::Command::CommandSource::SOURCE_MOBILE)); - if (plugin) { - plugin_ = dynamic_cast(&(*plugin)); - } -} + policy_handler) {} GetAppServiceDataResponseFromMobile::~GetAppServiceDataResponseFromMobile() {} diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/perform_app_service_interaction_request_to_mobile.cc b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/perform_app_service_interaction_request_to_mobile.cc index 8d71174c8d..2a7b644cb3 100644 --- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/perform_app_service_interaction_request_to_mobile.cc +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/perform_app_service_interaction_request_to_mobile.cc @@ -32,7 +32,6 @@ #include "app_service_rpc_plugin/commands/mobile/perform_app_service_interaction_request_to_mobile.h" #include "application_manager/application_impl.h" -#include "interfaces/MOBILE_API.h" namespace app_service_rpc_plugin { using namespace application_manager; diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/perform_app_service_interaction_response.cc b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/perform_app_service_interaction_response.cc index 774ec93720..5e84f42c34 100644 --- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/perform_app_service_interaction_response.cc +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/perform_app_service_interaction_response.cc @@ -32,7 +32,6 @@ #include "app_service_rpc_plugin/commands/mobile/perform_app_service_interaction_response.h" #include "application_manager/application_impl.h" -#include "interfaces/MOBILE_API.h" namespace app_service_rpc_plugin { using namespace application_manager; diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/publish_app_service_response.cc b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/publish_app_service_response.cc index b1136c79d0..d1bfc6e154 100644 --- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/publish_app_service_response.cc +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/publish_app_service_response.cc @@ -34,7 +34,6 @@ #include "application_manager/application_impl.h" #include "application_manager/message_helper.h" #include "application_manager/rpc_service.h" -#include "interfaces/MOBILE_API.h" namespace app_service_rpc_plugin { using namespace application_manager; diff --git a/src/components/application_manager/src/app_service_manager.cc b/src/components/application_manager/src/app_service_manager.cc index d148e4ef61..e1464f08e0 100644 --- a/src/components/application_manager/src/app_service_manager.cc +++ b/src/components/application_manager/src/app_service_manager.cc @@ -421,19 +421,6 @@ AppService* AppServiceManager::EmbeddedServiceForType( return NULL; } -AppService* AppServiceManager::FindServiceByName(std::string name) { - LOG4CXX_AUTO_TRACE(logger_); - sync_primitives::AutoLock lock(published_services_lock_); - for (auto it = published_services_.begin(); it != published_services_.end(); - ++it) { - if (it->second.record[strings::service_manifest][strings::service_name] - .asString() == name) { - return &(it->second); - } - } - return NULL; -} - AppService* AppServiceManager::FindServiceByPolicyAppID( std::string policy_app_id, std::string type) { LOG4CXX_AUTO_TRACE(logger_); -- cgit v1.2.1 From 5a9cc6ecf0eaa069b1295e0e408edd6a226c4b9d Mon Sep 17 00:00:00 2001 From: jacobkeeler Date: Mon, 11 Mar 2019 15:23:52 -0400 Subject: Add protocol test for auth_token --- .../src/connection_handler_impl.cc | 2 + .../protocol_handler/protocol_handler_impl.h | 3 +- .../protocol_handler/src/protocol_handler_impl.cc | 5 +- .../test/protocol_handler_tm_test.cc | 222 ++++++++++++++++----- 4 files changed, 183 insertions(+), 49 deletions(-) diff --git a/src/components/connection_handler/src/connection_handler_impl.cc b/src/components/connection_handler/src/connection_handler_impl.cc index 7e93e04047..c412c9c637 100644 --- a/src/components/connection_handler/src/connection_handler_impl.cc +++ b/src/components/connection_handler/src/connection_handler_impl.cc @@ -888,6 +888,8 @@ ConnectionHandlerImpl::TransportTypeProfileStringFromDeviceHandle( return std::string("IAP_USB_DEVICE_MODE"); } else if (connection_type == "CARPLAY_WIRELESS_IOS") { return std::string("IAP_CARPLAY"); + } else if (connection_type == "CLOUD_WEBSOCKET") { + return std::string("WEBSOCKET"); #ifdef BUILD_TESTS } else if (connection_type == "BTMAC") { return std::string("BTMAC"); diff --git a/src/components/protocol_handler/include/protocol_handler/protocol_handler_impl.h b/src/components/protocol_handler/include/protocol_handler/protocol_handler_impl.h index 89800037b5..7c2b411dcb 100644 --- a/src/components/protocol_handler/include/protocol_handler/protocol_handler_impl.h +++ b/src/components/protocol_handler/include/protocol_handler/protocol_handler_impl.h @@ -141,7 +141,8 @@ typedef enum { TT_NONE = -1, TT_USB = 0, TT_BLUETOOTH = 1, - TT_WIFI = 2 + TT_WIFI = 2, + TT_WEBSOCKET = 3 } TransportType; struct TransportDescription { diff --git a/src/components/protocol_handler/src/protocol_handler_impl.cc b/src/components/protocol_handler/src/protocol_handler_impl.cc index 27b06af424..d5837a0470 100644 --- a/src/components/protocol_handler/src/protocol_handler_impl.cc +++ b/src/components/protocol_handler/src/protocol_handler_impl.cc @@ -2274,7 +2274,10 @@ const impl::TransportTypes transportTypes = { impl::TransportDescription(impl::TransportType::TT_USB, true, false)), std::make_pair( std::string("IAP_CARPLAY"), - impl::TransportDescription(impl::TransportType::TT_WIFI, true, false))}; + impl::TransportDescription(impl::TransportType::TT_WIFI, true, false)), + std::make_pair(std::string("WEBSOCKET"), + impl::TransportDescription( + impl::TransportType::TT_WEBSOCKET, false, false))}; const impl::TransportDescription ProtocolHandlerImpl::GetTransportTypeFromConnectionType( diff --git a/src/components/protocol_handler/test/protocol_handler_tm_test.cc b/src/components/protocol_handler/test/protocol_handler_tm_test.cc index 51284dfcda..e1149fefb2 100644 --- a/src/components/protocol_handler/test/protocol_handler_tm_test.cc +++ b/src/components/protocol_handler/test/protocol_handler_tm_test.cc @@ -29,19 +29,19 @@ * 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 -#include "protocol_handler/protocol_handler.h" -#include "protocol_handler/protocol_handler_impl.h" +#include "connection_handler/connection_handler_impl.h" +#include "connection_handler/mock_connection_handler.h" +#include "gtest/gtest.h" #include "protocol/bson_object_keys.h" #include "protocol/common.h" #include "protocol_handler/control_message_matcher.h" #include "protocol_handler/mock_protocol_handler.h" -#include "protocol_handler/mock_protocol_observer.h" #include "protocol_handler/mock_protocol_handler_settings.h" +#include "protocol_handler/mock_protocol_observer.h" #include "protocol_handler/mock_session_observer.h" -#include "connection_handler/mock_connection_handler.h" -#include "connection_handler/connection_handler_impl.h" +#include "protocol_handler/protocol_handler.h" +#include "protocol_handler/protocol_handler_impl.h" #ifdef ENABLE_SECURITY #include "security_manager/mock_security_manager.h" #include "security_manager/mock_ssl_context.h" @@ -50,8 +50,8 @@ #include "utils/mock_system_time_handler.h" #include "utils/semantic_version.h" -#include "utils/test_async_waiter.h" #include +#include "utils/test_async_waiter.h" namespace transport_manager { namespace transport_adapter { @@ -59,8 +59,8 @@ namespace transport_adapter { const char* tc_enabled = "enabled"; const char* tc_tcp_port = "tcp_port"; const char* tc_tcp_ip_address = "tcp_ip_address"; -} -} +} // namespace transport_adapter +} // namespace transport_manager namespace test { namespace components { @@ -70,50 +70,50 @@ namespace protocol_handler_test { #define NEW_SESSION_ID 0u #define SESSION_START_REJECT 0u // Protocol Handler Entities -using protocol_handler::ProtocolHandlerImpl; -using protocol_handler::ServiceType; -using protocol_handler::RawMessage; -using protocol_handler::RawMessagePtr; -using protocol_handler::PROTECTION_ON; -using protocol_handler::PROTECTION_OFF; -using protocol_handler::PROTOCOL_VERSION_1; -using protocol_handler::PROTOCOL_VERSION_2; -using protocol_handler::PROTOCOL_VERSION_3; -using protocol_handler::PROTOCOL_VERSION_4; -using protocol_handler::PROTOCOL_VERSION_5; -using protocol_handler::PROTOCOL_VERSION_MAX; -using protocol_handler::FRAME_TYPE_CONTROL; -using protocol_handler::FRAME_TYPE_SINGLE; -using protocol_handler::FRAME_TYPE_FIRST; -using protocol_handler::FRAME_TYPE_CONSECUTIVE; -using protocol_handler::FRAME_TYPE_MAX_VALUE; -using protocol_handler::MAXIMUM_FRAME_DATA_V2_SIZE; -using protocol_handler::FRAME_DATA_START_SERVICE; -using protocol_handler::FRAME_DATA_START_SERVICE_ACK; -using protocol_handler::FRAME_DATA_END_SERVICE_NACK; -using protocol_handler::FRAME_DATA_END_SERVICE_ACK; using protocol_handler::FRAME_DATA_END_SERVICE; +using protocol_handler::FRAME_DATA_END_SERVICE_ACK; +using protocol_handler::FRAME_DATA_END_SERVICE_NACK; +using protocol_handler::FRAME_DATA_FIRST; using protocol_handler::FRAME_DATA_HEART_BEAT; using protocol_handler::FRAME_DATA_HEART_BEAT_ACK; -using protocol_handler::FRAME_DATA_SERVICE_DATA_ACK; -using protocol_handler::FRAME_DATA_SINGLE; -using protocol_handler::FRAME_DATA_FIRST; using protocol_handler::FRAME_DATA_LAST_CONSECUTIVE; using protocol_handler::FRAME_DATA_REGISTER_SECONDARY_TRANSPORT; using protocol_handler::FRAME_DATA_REGISTER_SECONDARY_TRANSPORT_ACK; using protocol_handler::FRAME_DATA_REGISTER_SECONDARY_TRANSPORT_NACK; +using protocol_handler::FRAME_DATA_SERVICE_DATA_ACK; +using protocol_handler::FRAME_DATA_SINGLE; +using protocol_handler::FRAME_DATA_START_SERVICE; +using protocol_handler::FRAME_DATA_START_SERVICE_ACK; using protocol_handler::FRAME_DATA_TRANSPORT_EVENT_UPDATE; -using protocol_handler::kRpc; -using protocol_handler::kControl; +using protocol_handler::FRAME_TYPE_CONSECUTIVE; +using protocol_handler::FRAME_TYPE_CONTROL; +using protocol_handler::FRAME_TYPE_FIRST; +using protocol_handler::FRAME_TYPE_MAX_VALUE; +using protocol_handler::FRAME_TYPE_SINGLE; using protocol_handler::kAudio; -using protocol_handler::kMobileNav; using protocol_handler::kBulk; +using protocol_handler::kControl; using protocol_handler::kInvalidServiceType; +using protocol_handler::kMobileNav; +using protocol_handler::kRpc; +using protocol_handler::MAXIMUM_FRAME_DATA_V2_SIZE; +using protocol_handler::PROTECTION_OFF; +using protocol_handler::PROTECTION_ON; +using protocol_handler::PROTOCOL_VERSION_1; +using protocol_handler::PROTOCOL_VERSION_2; +using protocol_handler::PROTOCOL_VERSION_3; +using protocol_handler::PROTOCOL_VERSION_4; +using protocol_handler::PROTOCOL_VERSION_5; +using protocol_handler::PROTOCOL_VERSION_MAX; +using protocol_handler::ProtocolHandlerImpl; +using protocol_handler::RawMessage; +using protocol_handler::RawMessagePtr; +using protocol_handler::ServiceType; // For TM states -using transport_manager::TransportManagerListener; using test::components::security_manager_test::MockSystemTimeHandler; -using transport_manager::E_SUCCESS; using transport_manager::DeviceInfo; +using transport_manager::E_SUCCESS; +using transport_manager::TransportManagerListener; #ifdef ENABLE_SECURITY // For security using ContextCreationStrategy = @@ -122,21 +122,21 @@ using ContextCreationStrategy = // For CH entities using connection_handler::DeviceHandle; // Google Testing Framework Entities -using ::testing::Return; -using ::testing::ReturnRef; -using ::testing::ReturnRefOfCopy; -using ::testing::ReturnNull; +using ::testing::_; using ::testing::An; using ::testing::AnyOf; using ::testing::AtLeast; using ::testing::ByRef; using ::testing::DoAll; -using ::testing::SaveArg; using ::testing::Eq; -using ::testing::_; using ::testing::Invoke; -using ::testing::SetArgReferee; +using ::testing::Return; +using ::testing::ReturnNull; +using ::testing::ReturnRef; +using ::testing::ReturnRefOfCopy; +using ::testing::SaveArg; using ::testing::SetArgPointee; +using ::testing::SetArgReferee; typedef std::vector UCharDataVector; @@ -149,7 +149,7 @@ namespace { const uint32_t kAsyncExpectationsTimeout = 10000u; const uint32_t kMicrosecondsInMillisecond = 1000u; const uint32_t kAddSessionWaitTimeMs = 100u; -} +} // namespace class ProtocolHandlerImplTest : public ::testing::Test { protected: @@ -383,6 +383,9 @@ class ProtocolHandlerImplTest : public ::testing::Test { const std::vector& expected_audio_service_transports, const std::vector& expected_video_service_transports); + void VerifyCloudAppParamsInStartSessionAck(const std::string& policy_app_id, + char* auth_token); + testing::NiceMock protocol_handler_settings_mock; std::shared_ptr protocol_handler_impl; TransportManagerListener* tm_listener; @@ -1920,6 +1923,117 @@ void ProtocolHandlerImplTest::VerifySecondaryTransportParamsInStartSessionAck( bson_object_deinitialize(&expected_obj); + EXPECT_CALL( + transport_manager_mock, + SendMessageToDevice(ControlMessage( + FRAME_DATA_START_SERVICE_ACK, PROTECTION_OFF, connection_id, _))) + .WillOnce(DoAll(NotifyTestAsyncWaiter(&waiter), Return(E_SUCCESS))); + times++; + +#ifdef ENABLE_SECURITY + AddSecurityManager(); + + EXPECT_CALL(session_observer_mock, KeyFromPair(connection_id, session_id)) + .WillOnce(Return(connection_key)); + + EXPECT_CALL(session_observer_mock, GetSSLContext(connection_key, kRpc)) + .WillOnce(ReturnNull()); +#endif // ENABLE_SECURITY + + protocol_handler_impl->SendStartSessionAck(connection_id, + session_id, + input_protocol_version, + hash_id, + protocol_handler::SERVICE_TYPE_RPC, + false /* protection */, + full_version); + + EXPECT_TRUE(waiter.WaitFor(times, kAsyncExpectationsTimeout)); +} + +void ProtocolHandlerImplTest::VerifyCloudAppParamsInStartSessionAck( + const std::string& policy_app_id, char* auth_token) { + const size_t maximum_rpc_payload_size = 1500; + EXPECT_CALL(protocol_handler_settings_mock, maximum_rpc_payload_size()) + .WillRepeatedly(Return(maximum_rpc_payload_size)); + InitProtocolHandlerImpl(0u, 0u); + + TestAsyncWaiter waiter; + uint32_t times = 0; + + const uint8_t input_protocol_version = 5; + const uint32_t hash_id = 123456; + utils::SemanticVersion full_version(5, 2, 0); + char full_version_string[] = "5.2.0"; + + // configuration setup + EXPECT_CALL(protocol_handler_settings_mock, max_supported_protocol_version()) + .WillRepeatedly(Return(PROTOCOL_VERSION_5)); + EXPECT_CALL(connection_handler_mock, GetCloudAppID(connection_id)) + .WillOnce(Return(policy_app_id)); + connection_handler::SessionTransports dummy_st = {0, 0}; + EXPECT_CALL(connection_handler_mock, + SetSecondaryTransportID(_, kDisabledSecondary)) + .WillOnce(Return(dummy_st)); + EXPECT_CALL(protocol_handler_settings_mock, multiple_transports_enabled()) + .WillRepeatedly(Return(false)); + std::vector empty_vec; + EXPECT_CALL(protocol_handler_settings_mock, audio_service_transports()) + .WillRepeatedly(ReturnRef(empty_vec)); + EXPECT_CALL(protocol_handler_settings_mock, video_service_transports()) + .WillRepeatedly(ReturnRef(empty_vec)); + EXPECT_CALL(session_observer_mock, + TransportTypeProfileStringFromConnHandle(connection_id)) + .WillRepeatedly(Return("WEBSOCKET")); + + // Prepare expected BSON parameters. When we add another param in Start + // Service ACK frame in future, it should be also added here. + BsonObject expected_obj; + bson_object_initialize_default(&expected_obj); + + // mtu + bson_object_put_int64(&expected_obj, + protocol_handler::strings::mtu, + static_cast(maximum_rpc_payload_size)); + // hashId + bson_object_put_int32(&expected_obj, + protocol_handler::strings::hash_id, + static_cast(hash_id)); + // protocolVersion + bson_object_put_string(&expected_obj, + protocol_handler::strings::protocol_version, + full_version_string); + + // secondaryTransports + BsonArray secondary_transports; + bson_array_initialize(&secondary_transports, 0); + bson_object_put_array(&expected_obj, + protocol_handler::strings::secondary_transports, + &secondary_transports); + + BsonArray audio_service_transports; + bson_array_initialize(&audio_service_transports, 1); + bson_array_add_int32(&audio_service_transports, 1); + bson_object_put_array(&expected_obj, + protocol_handler::strings::audio_service_transports, + &audio_service_transports); + + BsonArray video_service_transports; + bson_array_initialize(&video_service_transports, 1); + bson_array_add_int32(&video_service_transports, 1); + bson_object_put_array(&expected_obj, + protocol_handler::strings::video_service_transports, + &video_service_transports); + + // authToken + bson_object_put_string( + &expected_obj, protocol_handler::strings::auth_token, auth_token); + + std::vector expected_param = + CreateVectorFromBsonObject(&expected_obj); + + bson_object_deinitialize(&expected_obj); + EXPECT_CALL(transport_manager_mock, SendMessageToDevice(ControlMessage(FRAME_DATA_START_SERVICE_ACK, PROTECTION_OFF, @@ -1938,6 +2052,8 @@ void ProtocolHandlerImplTest::VerifySecondaryTransportParamsInStartSessionAck( .WillOnce(ReturnNull()); #endif // ENABLE_SECURITY + protocol_handler_impl->OnAuthTokenUpdated(policy_app_id, + std::string(auth_token)); protocol_handler_impl->SendStartSessionAck(connection_id, session_id, input_protocol_version, @@ -2468,6 +2584,18 @@ TEST_F(ProtocolHandlerImplTest, StartSessionAck_PrimaryTransportUSBHostMode) { expected_video_service_transports); } +TEST_F(ProtocolHandlerImplTest, StartSessionAck_CloudAppAuthTokenAvailable) { + std::string policy_id = "policy_id"; + char auth_token[] = "Sample auth token"; + + // A TransportUpdateEvent is also issued after Start Service ACK. We don't + // check it in this test case. + EXPECT_CALL(session_observer_mock, ProtocolVersionUsed(_, _, _)) + .WillRepeatedly(Return(false)); + + VerifyCloudAppParamsInStartSessionAck(policy_id, auth_token); +} + TEST_F(ProtocolHandlerImplTest, TransportEventUpdate_afterVersionNegotiation_TCPEnabled) { TestAsyncWaiter waiter; -- cgit v1.2.1 From 2210d7af870b8dbb53943e52765436cdc858c2f6 Mon Sep 17 00:00:00 2001 From: JackLivio Date: Mon, 11 Mar 2019 15:49:09 -0400 Subject: App service policies unit tests --- .../test/policy_handler_test.cc | 51 ++++++++++++++++++++++ .../application_manager/test/sdl_pt_update.json | 8 +++- .../test/json/valid_sdl_pt_update.json | 8 +++- .../test/policy_manager_impl_test.cc | 33 ++++++++++++++ .../test/policy_manager_impl_test.cc | 33 ++++++++++++++ .../test/sql_pt_representation_test.cc | 32 ++++++++++++++ .../policy_regular/test/valid_sdl_pt_update.json | 8 +++- 7 files changed, 170 insertions(+), 3 deletions(-) diff --git a/src/components/application_manager/test/policy_handler_test.cc b/src/components/application_manager/test/policy_handler_test.cc index a1471eff36..553c804e35 100644 --- a/src/components/application_manager/test/policy_handler_test.cc +++ b/src/components/application_manager/test/policy_handler_test.cc @@ -380,6 +380,57 @@ TEST_F(PolicyHandlerTest, ClearUserConsent) { policy_handler_.ClearUserConsent(); } +TEST_F(PolicyHandlerTest, AppServiceUpdate_CheckAppService) { + // Arrange + EnablePolicy(); + EXPECT_TRUE(policy_handler_.LoadPolicyLibrary()); + // Check + EXPECT_TRUE(policy_handler_.InitPolicyTable()); + ChangePolicyManagerToMock(); + std::string file_name("sdl_pt_update.json"); + std::ifstream ifile(file_name); + Json::Reader reader; + std::string json; + Json::Value root(Json::objectValue); + if (ifile.is_open() && reader.parse(ifile, root, true)) { + json = root.toStyledString(); + } + ifile.close(); + BinaryMessage msg(json.begin(), json.end()); + // Checks + EXPECT_CALL(*mock_policy_manager_, LoadPT("", msg)).WillOnce(Return(true)); + policy_handler_.ReceiveMessageFromSDK("", msg); + + policy_table::AppServiceParameters app_service_params = policy_table::AppServiceParameters(); + (app_service_params)["MEDIA"] = policy_table::AppServiceInfo(); + (app_service_params)["MEDIA"].service_names->push_back("SDL App"); + (app_service_params)["MEDIA"].service_names->push_back("SDL Music"); + (app_service_params)["MEDIA"].service_names->mark_initialized(); + policy_table::AppServiceHandledRpc handled_rpc; + handled_rpc.function_id = 41; + (app_service_params)["MEDIA"].handled_rpcs.push_back(handled_rpc); + EXPECT_CALL(*mock_policy_manager_, GetAppServiceParameters(_,_)).WillRepeatedly(SetArgPointee<1>(app_service_params)); + + ns_smart_device_link::ns_smart_objects::SmartArray requested_handled_rpcs; + ns_smart_device_link::ns_smart_objects::SmartObject rpc_id(41); + requested_handled_rpcs.push_back(rpc_id); + + ns_smart_device_link::ns_smart_objects::SmartArray fake_handled_rpcs; + ns_smart_device_link::ns_smart_objects::SmartObject fake_rpc_id(40); + fake_handled_rpcs.push_back(fake_rpc_id); + + ASSERT_TRUE(policy_handler_.CheckAppServiceParameters("1010101010", "SDL Music", "MEDIA", &requested_handled_rpcs)); + ASSERT_TRUE(policy_handler_.CheckAppServiceParameters("1010101010", "SDL App", "MEDIA", &requested_handled_rpcs)); + ASSERT_TRUE(policy_handler_.CheckAppServiceParameters("1010101010", "SDL App", "MEDIA", NULL)); + ASSERT_TRUE(policy_handler_.CheckAppServiceParameters("1010101010", "", "MEDIA", NULL)); + + ASSERT_FALSE(policy_handler_.CheckAppServiceParameters("1010101010", "", "", NULL)); + ASSERT_FALSE(policy_handler_.CheckAppServiceParameters("1010101010", "SDL App", "NAVIGATION", &requested_handled_rpcs)); + ASSERT_FALSE(policy_handler_.CheckAppServiceParameters("1010101010", "MUSIC", "MEDIA", &requested_handled_rpcs)); + ASSERT_FALSE(policy_handler_.CheckAppServiceParameters("1010101010", "SDL App", "MEDIA", &fake_handled_rpcs)); + +} + TEST_F(PolicyHandlerTest, ReceiveMessageFromSDK) { // Arrange EnablePolicy(); diff --git a/src/components/application_manager/test/sdl_pt_update.json b/src/components/application_manager/test/sdl_pt_update.json index 17b07f797f..aea3f7700b 100644 --- a/src/components/application_manager/test/sdl_pt_update.json +++ b/src/components/application_manager/test/sdl_pt_update.json @@ -20,7 +20,13 @@ "nicknames" : [ "SyncProxyTester" ], "priority" : "EMERGENCY", "steal_focus" : true, - "watchdog_timer_ms" : 20000 + "watchdog_timer_ms" : 20000, + "app_services": { + "MEDIA": { + "service_names" : ["SDL App", "SDL Music"], + "handled_rpcs" : [{"function_id": 41}] + } + } }, "default" : { "default_hmi" : "NONE", diff --git a/src/components/policy/policy_external/test/json/valid_sdl_pt_update.json b/src/components/policy/policy_external/test/json/valid_sdl_pt_update.json index 35e6b1d1a6..acf18c5706 100644 --- a/src/components/policy/policy_external/test/json/valid_sdl_pt_update.json +++ b/src/components/policy/policy_external/test/json/valid_sdl_pt_update.json @@ -20,7 +20,13 @@ "nicknames" : [ "SyncProxyTester" ], "priority" : "EMERGENCY", "steal_focus" : true, - "heart_beat_timeout_ms": 5000 + "heart_beat_timeout_ms": 5000, + "app_services": { + "MEDIA": { + "service_names" : ["SDL App", "SDL Music"], + "handled_rpcs" : [{"function_id": 41}] + } + } }, "default" : { "default_hmi" : "NONE", diff --git a/src/components/policy/policy_external/test/policy_manager_impl_test.cc b/src/components/policy/policy_external/test/policy_manager_impl_test.cc index 6521db7c36..72c9e1a2bd 100644 --- a/src/components/policy/policy_external/test/policy_manager_impl_test.cc +++ b/src/components/policy/policy_external/test/policy_manager_impl_test.cc @@ -345,6 +345,39 @@ TEST_F(PolicyManagerImplTest2, GetCurrentDeviceId) { EXPECT_EQ("", policy_manager_->GetCurrentDeviceId(app_id_2_)); } +TEST_F( + PolicyManagerImplTest2, + UpdateApplication_AppServices) { + // Arrange + CreateLocalPT(preloaded_pt_filename_); + EXPECT_EQ("UP_TO_DATE", policy_manager_->GetPolicyTableStatus()); + GetPTU("json/valid_sdl_pt_update.json"); + EXPECT_EQ("UP_TO_DATE", policy_manager_->GetPolicyTableStatus()); + // Try to add existing app + policy_table::AppServiceParameters app_service_parameters = + policy_table::AppServiceParameters(); + policy_manager_->GetAppServiceParameters(app_id_2_, &app_service_parameters); + + ASSERT_FALSE(app_service_parameters.find("MEDIA") == + app_service_parameters.end()); + + auto service_names = + *(app_service_parameters["MEDIA"].service_names); + + EXPECT_TRUE(service_names.is_initialized()); + EXPECT_EQ(static_cast(service_names[0]), "SDL App"); + EXPECT_EQ(static_cast(service_names[1]), "SDL Music"); + + auto handled_rpcs = + app_service_parameters["MEDIA"].handled_rpcs; + + EXPECT_TRUE(handled_rpcs.is_initialized()); + EXPECT_EQ(handled_rpcs[0].function_id, 41); + + // Check no update required + EXPECT_EQ("UP_TO_DATE", policy_manager_->GetPolicyTableStatus()); +} + TEST_F( PolicyManagerImplTest_ExternalConsent, ExternalConsent_SetExternalConsentStatusWhileAppExists_ExpectUserConsentsUpdateForApp) { diff --git a/src/components/policy/policy_regular/test/policy_manager_impl_test.cc b/src/components/policy/policy_regular/test/policy_manager_impl_test.cc index ff054b3cc4..1fb72cb0f9 100644 --- a/src/components/policy/policy_regular/test/policy_manager_impl_test.cc +++ b/src/components/policy/policy_regular/test/policy_manager_impl_test.cc @@ -834,6 +834,39 @@ TEST_F( EXPECT_EQ("UP_TO_DATE", manager->GetPolicyTableStatus()); } +TEST_F( + PolicyManagerImplTest2, + UpdateApplication_AppServices) { + // Arrange + CreateLocalPT("sdl_preloaded_pt.json"); + EXPECT_EQ("UP_TO_DATE", manager->GetPolicyTableStatus()); + GetPTU("valid_sdl_pt_update.json"); + EXPECT_EQ("UP_TO_DATE", manager->GetPolicyTableStatus()); + // Try to add existing app + policy_table::AppServiceParameters app_service_parameters = + policy_table::AppServiceParameters(); + manager->GetAppServiceParameters(app_id2, &app_service_parameters); + + ASSERT_FALSE(app_service_parameters.find("MEDIA") == + app_service_parameters.end()); + + auto service_names = + *(app_service_parameters["MEDIA"].service_names); + + EXPECT_TRUE(service_names.is_initialized()); + EXPECT_EQ(static_cast(service_names[0]), "SDL App"); + EXPECT_EQ(static_cast(service_names[1]), "SDL Music"); + + auto handled_rpcs = + app_service_parameters["MEDIA"].handled_rpcs; + + EXPECT_TRUE(handled_rpcs.is_initialized()); + EXPECT_EQ(handled_rpcs[0].function_id, 41); + + // Check no update required + EXPECT_EQ("UP_TO_DATE", manager->GetPolicyTableStatus()); +} + TEST_F(PolicyManagerImplTest2, PTUpdatedAt_DaysNotExceedLimit_ExpectNoUpdateRequired) { // Arrange diff --git a/src/components/policy/policy_regular/test/sql_pt_representation_test.cc b/src/components/policy/policy_regular/test/sql_pt_representation_test.cc index 6448a47b42..2fa5156362 100644 --- a/src/components/policy/policy_regular/test/sql_pt_representation_test.cc +++ b/src/components/policy/policy_regular/test/sql_pt_representation_test.cc @@ -124,6 +124,12 @@ class SQLPTRepresentationTest : public SQLPTRepresentation, policy_table::ApplicationPoliciesSection* policies) const { return ::SQLPTRepresentation::GatherApplicationPoliciesSection(policies); } + + bool GatherAppServiceParameters(const std::string& app_id, + policy_table::AppServiceParameters* policies) const { + return ::SQLPTRepresentation::GatherAppServiceParameters(app_id, policies); + } + virtual void GatherDeviceData(policy_table::DeviceData* data) const { ::SQLPTRepresentation::GatherDeviceData(data); } @@ -314,6 +320,15 @@ class SQLPTRepresentationTest : public SQLPTRepresentation, app_policies["1234"]["keep_context"] = Json::Value(false); app_policies["1234"]["steal_focus"] = Json::Value(false); app_policies["1234"]["RequestType"] = Json::Value(Json::arrayValue); + app_policies["1234"]["app_services"] = Json::Value(Json::objectValue); + app_policies["1234"]["app_services"]["MEDIA"] = Json::Value(Json::objectValue); + app_policies["1234"]["app_services"]["MEDIA"]["service_names"] = Json::Value(Json::arrayValue); + app_policies["1234"]["app_services"]["MEDIA"]["service_names"][0] = Json::Value("SDL App"); + app_policies["1234"]["app_services"]["MEDIA"]["service_names"][1] = Json::Value("SDL Music"); + app_policies["1234"]["app_services"]["MEDIA"]["handled_rpcs"] = Json::Value(Json::arrayValue); + app_policies["1234"]["app_services"]["MEDIA"]["handled_rpcs"][0] = Json::Value(Json::objectValue); + app_policies["1234"]["app_services"]["MEDIA"]["handled_rpcs"][0]["function_id"] = Json::Value(41); + app_policies["device"] = Json::Value(Json::objectValue); app_policies["device"]["groups"] = Json::Value(Json::arrayValue); @@ -1706,6 +1721,23 @@ TEST_F(SQLPTRepresentationTest, Save_SetPolicyTableThenSave_ExpectSavedToPT) { GatherDeviceData(&devices); EXPECT_EQ(3u, devices.size()); + + const std::string kAppId = "1234"; + policy_table::AppServiceParameters app_service_parameters; + GatherAppServiceParameters(kAppId , &app_service_parameters); + ASSERT_FALSE(app_service_parameters.find("MEDIA") == + app_service_parameters.end()); + auto service_names = + *(app_service_parameters["MEDIA"].service_names); + EXPECT_TRUE(service_names.is_initialized()); + EXPECT_EQ(static_cast(service_names[0]), "SDL App"); + EXPECT_EQ(static_cast(service_names[1]), "SDL Music"); + + auto handled_rpcs = + app_service_parameters["MEDIA"].handled_rpcs; + + EXPECT_TRUE(handled_rpcs.is_initialized()); + EXPECT_EQ(handled_rpcs[0].function_id, 41); } } // namespace policy_test diff --git a/src/components/policy/policy_regular/test/valid_sdl_pt_update.json b/src/components/policy/policy_regular/test/valid_sdl_pt_update.json index 35e6b1d1a6..acf18c5706 100644 --- a/src/components/policy/policy_regular/test/valid_sdl_pt_update.json +++ b/src/components/policy/policy_regular/test/valid_sdl_pt_update.json @@ -20,7 +20,13 @@ "nicknames" : [ "SyncProxyTester" ], "priority" : "EMERGENCY", "steal_focus" : true, - "heart_beat_timeout_ms": 5000 + "heart_beat_timeout_ms": 5000, + "app_services": { + "MEDIA": { + "service_names" : ["SDL App", "SDL Music"], + "handled_rpcs" : [{"function_id": 41}] + } + } }, "default" : { "default_hmi" : "NONE", -- cgit v1.2.1 From 30c31d0b35961079e7b84cec74e1418a9af8451a Mon Sep 17 00:00:00 2001 From: JackLivio Date: Mon, 11 Mar 2019 16:20:12 -0400 Subject: Fix onAppServiceData from mobile --- .../src/commands/mobile/on_app_service_data_notification_from_mobile.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/on_app_service_data_notification_from_mobile.cc b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/on_app_service_data_notification_from_mobile.cc index 1328e128d4..7bb62d298d 100644 --- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/on_app_service_data_notification_from_mobile.cc +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/on_app_service_data_notification_from_mobile.cc @@ -61,7 +61,7 @@ void OnAppServiceDataNotificationFromMobile::Run() { MessageHelper::PrintSmartObject(*message_); std::string service_type = - (*message_)[strings::msg_params][strings::app_service_manifest] + (*message_)[strings::msg_params][strings::service_data] [strings::service_type].asString(); ApplicationSharedPtr app = application_manager_.application(connection_key()); -- cgit v1.2.1 From baf16b9012ed2478d7b84cd64adbd6779224899d Mon Sep 17 00:00:00 2001 From: JackLivio Date: Mon, 11 Mar 2019 16:24:44 -0400 Subject: Fix style --- .../test/policy_handler_test.cc | 35 ++++++++++++++-------- .../test/policy_manager_impl_test.cc | 14 ++++----- .../test/policy_manager_impl_test.cc | 14 ++++----- .../test/sql_pt_representation_test.cc | 35 ++++++++++++---------- 4 files changed, 52 insertions(+), 46 deletions(-) diff --git a/src/components/application_manager/test/policy_handler_test.cc b/src/components/application_manager/test/policy_handler_test.cc index 553c804e35..da6e45162a 100644 --- a/src/components/application_manager/test/policy_handler_test.cc +++ b/src/components/application_manager/test/policy_handler_test.cc @@ -401,7 +401,8 @@ TEST_F(PolicyHandlerTest, AppServiceUpdate_CheckAppService) { EXPECT_CALL(*mock_policy_manager_, LoadPT("", msg)).WillOnce(Return(true)); policy_handler_.ReceiveMessageFromSDK("", msg); - policy_table::AppServiceParameters app_service_params = policy_table::AppServiceParameters(); + policy_table::AppServiceParameters app_service_params = + policy_table::AppServiceParameters(); (app_service_params)["MEDIA"] = policy_table::AppServiceInfo(); (app_service_params)["MEDIA"].service_names->push_back("SDL App"); (app_service_params)["MEDIA"].service_names->push_back("SDL Music"); @@ -409,8 +410,9 @@ TEST_F(PolicyHandlerTest, AppServiceUpdate_CheckAppService) { policy_table::AppServiceHandledRpc handled_rpc; handled_rpc.function_id = 41; (app_service_params)["MEDIA"].handled_rpcs.push_back(handled_rpc); - EXPECT_CALL(*mock_policy_manager_, GetAppServiceParameters(_,_)).WillRepeatedly(SetArgPointee<1>(app_service_params)); - + EXPECT_CALL(*mock_policy_manager_, GetAppServiceParameters(_, _)) + .WillRepeatedly(SetArgPointee<1>(app_service_params)); + ns_smart_device_link::ns_smart_objects::SmartArray requested_handled_rpcs; ns_smart_device_link::ns_smart_objects::SmartObject rpc_id(41); requested_handled_rpcs.push_back(rpc_id); @@ -419,16 +421,23 @@ TEST_F(PolicyHandlerTest, AppServiceUpdate_CheckAppService) { ns_smart_device_link::ns_smart_objects::SmartObject fake_rpc_id(40); fake_handled_rpcs.push_back(fake_rpc_id); - ASSERT_TRUE(policy_handler_.CheckAppServiceParameters("1010101010", "SDL Music", "MEDIA", &requested_handled_rpcs)); - ASSERT_TRUE(policy_handler_.CheckAppServiceParameters("1010101010", "SDL App", "MEDIA", &requested_handled_rpcs)); - ASSERT_TRUE(policy_handler_.CheckAppServiceParameters("1010101010", "SDL App", "MEDIA", NULL)); - ASSERT_TRUE(policy_handler_.CheckAppServiceParameters("1010101010", "", "MEDIA", NULL)); - - ASSERT_FALSE(policy_handler_.CheckAppServiceParameters("1010101010", "", "", NULL)); - ASSERT_FALSE(policy_handler_.CheckAppServiceParameters("1010101010", "SDL App", "NAVIGATION", &requested_handled_rpcs)); - ASSERT_FALSE(policy_handler_.CheckAppServiceParameters("1010101010", "MUSIC", "MEDIA", &requested_handled_rpcs)); - ASSERT_FALSE(policy_handler_.CheckAppServiceParameters("1010101010", "SDL App", "MEDIA", &fake_handled_rpcs)); - + ASSERT_TRUE(policy_handler_.CheckAppServiceParameters( + "1010101010", "SDL Music", "MEDIA", &requested_handled_rpcs)); + ASSERT_TRUE(policy_handler_.CheckAppServiceParameters( + "1010101010", "SDL App", "MEDIA", &requested_handled_rpcs)); + ASSERT_TRUE(policy_handler_.CheckAppServiceParameters( + "1010101010", "SDL App", "MEDIA", NULL)); + ASSERT_TRUE(policy_handler_.CheckAppServiceParameters( + "1010101010", "", "MEDIA", NULL)); + + ASSERT_FALSE( + policy_handler_.CheckAppServiceParameters("1010101010", "", "", NULL)); + ASSERT_FALSE(policy_handler_.CheckAppServiceParameters( + "1010101010", "SDL App", "NAVIGATION", &requested_handled_rpcs)); + ASSERT_FALSE(policy_handler_.CheckAppServiceParameters( + "1010101010", "MUSIC", "MEDIA", &requested_handled_rpcs)); + ASSERT_FALSE(policy_handler_.CheckAppServiceParameters( + "1010101010", "SDL App", "MEDIA", &fake_handled_rpcs)); } TEST_F(PolicyHandlerTest, ReceiveMessageFromSDK) { diff --git a/src/components/policy/policy_external/test/policy_manager_impl_test.cc b/src/components/policy/policy_external/test/policy_manager_impl_test.cc index 72c9e1a2bd..5af345eb7c 100644 --- a/src/components/policy/policy_external/test/policy_manager_impl_test.cc +++ b/src/components/policy/policy_external/test/policy_manager_impl_test.cc @@ -345,9 +345,7 @@ TEST_F(PolicyManagerImplTest2, GetCurrentDeviceId) { EXPECT_EQ("", policy_manager_->GetCurrentDeviceId(app_id_2_)); } -TEST_F( - PolicyManagerImplTest2, - UpdateApplication_AppServices) { +TEST_F(PolicyManagerImplTest2, UpdateApplication_AppServices) { // Arrange CreateLocalPT(preloaded_pt_filename_); EXPECT_EQ("UP_TO_DATE", policy_manager_->GetPolicyTableStatus()); @@ -359,21 +357,19 @@ TEST_F( policy_manager_->GetAppServiceParameters(app_id_2_, &app_service_parameters); ASSERT_FALSE(app_service_parameters.find("MEDIA") == - app_service_parameters.end()); + app_service_parameters.end()); - auto service_names = - *(app_service_parameters["MEDIA"].service_names); + auto service_names = *(app_service_parameters["MEDIA"].service_names); EXPECT_TRUE(service_names.is_initialized()); EXPECT_EQ(static_cast(service_names[0]), "SDL App"); EXPECT_EQ(static_cast(service_names[1]), "SDL Music"); - auto handled_rpcs = - app_service_parameters["MEDIA"].handled_rpcs; + auto handled_rpcs = app_service_parameters["MEDIA"].handled_rpcs; EXPECT_TRUE(handled_rpcs.is_initialized()); EXPECT_EQ(handled_rpcs[0].function_id, 41); - + // Check no update required EXPECT_EQ("UP_TO_DATE", policy_manager_->GetPolicyTableStatus()); } diff --git a/src/components/policy/policy_regular/test/policy_manager_impl_test.cc b/src/components/policy/policy_regular/test/policy_manager_impl_test.cc index 1fb72cb0f9..5f3e81232e 100644 --- a/src/components/policy/policy_regular/test/policy_manager_impl_test.cc +++ b/src/components/policy/policy_regular/test/policy_manager_impl_test.cc @@ -834,9 +834,7 @@ TEST_F( EXPECT_EQ("UP_TO_DATE", manager->GetPolicyTableStatus()); } -TEST_F( - PolicyManagerImplTest2, - UpdateApplication_AppServices) { +TEST_F(PolicyManagerImplTest2, UpdateApplication_AppServices) { // Arrange CreateLocalPT("sdl_preloaded_pt.json"); EXPECT_EQ("UP_TO_DATE", manager->GetPolicyTableStatus()); @@ -848,21 +846,19 @@ TEST_F( manager->GetAppServiceParameters(app_id2, &app_service_parameters); ASSERT_FALSE(app_service_parameters.find("MEDIA") == - app_service_parameters.end()); + app_service_parameters.end()); - auto service_names = - *(app_service_parameters["MEDIA"].service_names); + auto service_names = *(app_service_parameters["MEDIA"].service_names); EXPECT_TRUE(service_names.is_initialized()); EXPECT_EQ(static_cast(service_names[0]), "SDL App"); EXPECT_EQ(static_cast(service_names[1]), "SDL Music"); - auto handled_rpcs = - app_service_parameters["MEDIA"].handled_rpcs; + auto handled_rpcs = app_service_parameters["MEDIA"].handled_rpcs; EXPECT_TRUE(handled_rpcs.is_initialized()); EXPECT_EQ(handled_rpcs[0].function_id, 41); - + // Check no update required EXPECT_EQ("UP_TO_DATE", manager->GetPolicyTableStatus()); } diff --git a/src/components/policy/policy_regular/test/sql_pt_representation_test.cc b/src/components/policy/policy_regular/test/sql_pt_representation_test.cc index 2fa5156362..9063c280bd 100644 --- a/src/components/policy/policy_regular/test/sql_pt_representation_test.cc +++ b/src/components/policy/policy_regular/test/sql_pt_representation_test.cc @@ -125,7 +125,8 @@ class SQLPTRepresentationTest : public SQLPTRepresentation, return ::SQLPTRepresentation::GatherApplicationPoliciesSection(policies); } - bool GatherAppServiceParameters(const std::string& app_id, + bool GatherAppServiceParameters( + const std::string& app_id, policy_table::AppServiceParameters* policies) const { return ::SQLPTRepresentation::GatherAppServiceParameters(app_id, policies); } @@ -321,14 +322,20 @@ class SQLPTRepresentationTest : public SQLPTRepresentation, app_policies["1234"]["steal_focus"] = Json::Value(false); app_policies["1234"]["RequestType"] = Json::Value(Json::arrayValue); app_policies["1234"]["app_services"] = Json::Value(Json::objectValue); - app_policies["1234"]["app_services"]["MEDIA"] = Json::Value(Json::objectValue); - app_policies["1234"]["app_services"]["MEDIA"]["service_names"] = Json::Value(Json::arrayValue); - app_policies["1234"]["app_services"]["MEDIA"]["service_names"][0] = Json::Value("SDL App"); - app_policies["1234"]["app_services"]["MEDIA"]["service_names"][1] = Json::Value("SDL Music"); - app_policies["1234"]["app_services"]["MEDIA"]["handled_rpcs"] = Json::Value(Json::arrayValue); - app_policies["1234"]["app_services"]["MEDIA"]["handled_rpcs"][0] = Json::Value(Json::objectValue); - app_policies["1234"]["app_services"]["MEDIA"]["handled_rpcs"][0]["function_id"] = Json::Value(41); - + app_policies["1234"]["app_services"]["MEDIA"] = + Json::Value(Json::objectValue); + app_policies["1234"]["app_services"]["MEDIA"]["service_names"] = + Json::Value(Json::arrayValue); + app_policies["1234"]["app_services"]["MEDIA"]["service_names"][0] = + Json::Value("SDL App"); + app_policies["1234"]["app_services"]["MEDIA"]["service_names"][1] = + Json::Value("SDL Music"); + app_policies["1234"]["app_services"]["MEDIA"]["handled_rpcs"] = + Json::Value(Json::arrayValue); + app_policies["1234"]["app_services"]["MEDIA"]["handled_rpcs"][0] = + Json::Value(Json::objectValue); + app_policies["1234"]["app_services"]["MEDIA"]["handled_rpcs"][0] + ["function_id"] = Json::Value(41); app_policies["device"] = Json::Value(Json::objectValue); app_policies["device"]["groups"] = Json::Value(Json::arrayValue); @@ -1724,17 +1731,15 @@ TEST_F(SQLPTRepresentationTest, Save_SetPolicyTableThenSave_ExpectSavedToPT) { const std::string kAppId = "1234"; policy_table::AppServiceParameters app_service_parameters; - GatherAppServiceParameters(kAppId , &app_service_parameters); + GatherAppServiceParameters(kAppId, &app_service_parameters); ASSERT_FALSE(app_service_parameters.find("MEDIA") == - app_service_parameters.end()); - auto service_names = - *(app_service_parameters["MEDIA"].service_names); + app_service_parameters.end()); + auto service_names = *(app_service_parameters["MEDIA"].service_names); EXPECT_TRUE(service_names.is_initialized()); EXPECT_EQ(static_cast(service_names[0]), "SDL App"); EXPECT_EQ(static_cast(service_names[1]), "SDL Music"); - auto handled_rpcs = - app_service_parameters["MEDIA"].handled_rpcs; + auto handled_rpcs = app_service_parameters["MEDIA"].handled_rpcs; EXPECT_TRUE(handled_rpcs.is_initialized()); EXPECT_EQ(handled_rpcs[0].function_id, 41); -- cgit v1.2.1 From a3084a207c4593d38502e57531105846267057a1 Mon Sep 17 00:00:00 2001 From: Shobhit Adlakha Date: Tue, 12 Mar 2019 14:19:58 -0400 Subject: Validating forwarded and App Service RPC requests (#2837) * Created validate param and seperate function for Validating RPC SmartObject * Moved validate rpc smart object function to rpc handler interface * Addressed review comments * Addressed review comments --- .../include/application_manager/rpc_handler_impl.h | 8 ++++- .../application_manager/src/rpc_handler_impl.cc | 37 ++++++++++++++++------ .../application_manager/src/rpc_passing_handler.cc | 36 +++++++++++++++++++-- .../include/application_manager/rpc_handler.h | 5 +++ 4 files changed, 73 insertions(+), 13 deletions(-) diff --git a/src/components/application_manager/include/application_manager/rpc_handler_impl.h b/src/components/application_manager/include/application_manager/rpc_handler_impl.h index b7e74c5ab3..489bcd21fd 100644 --- a/src/components/application_manager/include/application_manager/rpc_handler_impl.h +++ b/src/components/application_manager/include/application_manager/rpc_handler_impl.h @@ -154,12 +154,18 @@ class RPCHandlerImpl : public RPCHandler, ns_smart_device_link::ns_smart_objects::SmartObject& output, utils::SemanticVersion& message_version); + bool ValidateRpcSO(smart_objects::SmartObject* message, + utils::SemanticVersion& msg_version, + rpc::ValidationReport& report_out, + bool remove_unknown_params) OVERRIDE; + private: void ProcessMessageFromMobile(const std::shared_ptr message); void ProcessMessageFromHMI(const std::shared_ptr message); bool ConvertMessageToSO(const Message& message, smart_objects::SmartObject& output, - const bool remove_unknown_parameters = true); + const bool remove_unknown_parameters = true, + const bool validate_params = true); std::shared_ptr ConvertRawMsgToMessage( const ::protocol_handler::RawMessagePtr message); hmi_apis::HMI_API& hmi_so_factory(); diff --git a/src/components/application_manager/src/rpc_handler_impl.cc b/src/components/application_manager/src/rpc_handler_impl.cc index 6374e2a955..65d5d713e8 100644 --- a/src/components/application_manager/src/rpc_handler_impl.cc +++ b/src/components/application_manager/src/rpc_handler_impl.cc @@ -85,7 +85,7 @@ void RPCHandlerImpl::ProcessMessageFromMobile( } if (!ConvertMessageToSO( - *message, *so_from_mobile, remove_unknown_parameters)) { + *message, *so_from_mobile, remove_unknown_parameters, !rpc_passing)) { LOG4CXX_ERROR(logger_, "Cannot create smart object from message"); return; } @@ -106,7 +106,7 @@ void RPCHandlerImpl::ProcessMessageFromMobile( commands::Command::SOURCE_MOBILE, message_type)) { // Since PassThrough failed, refiltering the message - if (!ConvertMessageToSO(*message, *so_from_mobile, true)) { + if (!ConvertMessageToSO(*message, *so_from_mobile, true, true)) { LOG4CXX_ERROR(logger_, "Cannot create smart object from message"); return; } @@ -283,7 +283,8 @@ void RPCHandlerImpl::GetMessageVersion( bool RPCHandlerImpl::ConvertMessageToSO( const Message& message, ns_smart_device_link::ns_smart_objects::SmartObject& output, - const bool remove_unknown_parameters) { + const bool remove_unknown_parameters, + const bool validate_params) { LOG4CXX_AUTO_TRACE(logger_); LOG4CXX_DEBUG(logger_, "\t\t\tMessage to convert: protocol " @@ -303,6 +304,7 @@ bool RPCHandlerImpl::ConvertMessageToSO( message.type(), message.correlation_id()); + smart_objects::SmartObject* so_ptr = (conversion_result) ? &output : NULL; rpc::ValidationReport report("RPC"); // Attach RPC version to SmartObject if it does not exist yet. @@ -316,12 +318,9 @@ bool RPCHandlerImpl::ConvertMessageToSO( GetMessageVersion(output, msg_version); } - if (!conversion_result || - !mobile_so_factory().attachSchema( - output, remove_unknown_parameters, msg_version) || - ((output.validate(&report, msg_version) != - smart_objects::errors::OK && - remove_unknown_parameters))) { + if (validate_params && + !ValidateRpcSO( + so_ptr, msg_version, report, remove_unknown_parameters)) { LOG4CXX_WARN(logger_, "Failed to parse string to smart object with API version " << msg_version.toString() << " : " @@ -338,8 +337,10 @@ bool RPCHandlerImpl::ConvertMessageToSO( rpc::PrettyFormat(report); app_manager_.GetRPCService().ManageMobileCommand( response, commands::Command::SOURCE_SDL); + return false; } + LOG4CXX_DEBUG(logger_, "Convertion result for sdl object is true function_id " << output[jhs::S_PARAMS][jhs::S_FUNCTION_ID].asInt()); @@ -388,7 +389,8 @@ bool RPCHandlerImpl::ConvertMessageToSO( rpc::ValidationReport report("RPC"); - if (output.validate(&report) != smart_objects::errors::OK) { + if (validate_params && + output.validate(&report) != smart_objects::errors::OK) { LOG4CXX_ERROR(logger_, "Incorrect parameter from HMI" << rpc::PrettyFormat(report)); @@ -449,6 +451,21 @@ bool RPCHandlerImpl::ConvertMessageToSO( return true; } +bool RPCHandlerImpl::ValidateRpcSO(smart_objects::SmartObject* message, + utils::SemanticVersion& msg_version, + rpc::ValidationReport& report_out, + bool remove_unknown_params) { + if (!message || + !mobile_so_factory().attachSchema( + *message, remove_unknown_params, msg_version) || + (message->validate(&report_out, msg_version) != + smart_objects::errors::OK)) { + LOG4CXX_WARN(logger_, "Failed to parse string to smart object"); + return false; + } + return true; +} + std::shared_ptr RPCHandlerImpl::ConvertRawMsgToMessage( const protocol_handler::RawMessagePtr message) { LOG4CXX_AUTO_TRACE(logger_); diff --git a/src/components/application_manager/src/rpc_passing_handler.cc b/src/components/application_manager/src/rpc_passing_handler.cc index 560418e910..165b1f43ba 100644 --- a/src/components/application_manager/src/rpc_passing_handler.cc +++ b/src/components/application_manager/src/rpc_passing_handler.cc @@ -38,6 +38,7 @@ #include "application_manager/application.h" #include "application_manager/application_manager.h" #include "application_manager/rpc_passing_handler.h" +#include "application_manager/rpc_handler.h" #include "application_manager/commands/command_impl.h" #include "application_manager/message_helper.h" #include "application_manager/smart_object_keys.h" @@ -145,8 +146,12 @@ bool RPCPassingHandler::RPCPassThrough(smart_objects::SmartObject rpc_message) { } rpc_request_queue_lock_.Release(); RemoveRequestTimer(correlation_id); - auto result_code = static_cast( - rpc_message[strings::msg_params][strings::result_code].asInt()); + + mobile_apis::Result::eType result_code; + smart_objects::EnumConversionHelper:: + StringToEnum( + rpc_message[strings::msg_params][strings::result_code].asString(), + &result_code); if (result_code == mobile_apis::Result::UNSUPPORTED_REQUEST) { LOG4CXX_DEBUG(logger_, "Service sent UNSUPPORTED_REQUEST"); @@ -228,6 +233,33 @@ void RPCPassingHandler::ForwardRequestToCore(uint32_t correlation_id) { std::make_shared(message); rpc_request_queue.erase(correlation_id); rpc_request_queue_lock_.Release(); + + // Validate rpc message before forwarding to core + rpc::ValidationReport report("RPC"); + uint32_t connection_key = + message[strings::params][strings::connection_key].asUInt(); + int32_t function_id = message[strings::params][strings::function_id].asInt(); + auto app_ptr = app_manager_.application(connection_key); + utils::SemanticVersion msg_version(0, 0, 0); + if (app_ptr) { + msg_version = app_ptr->msg_version(); + } + + if (!app_manager_.GetRPCHandler().ValidateRpcSO( + &message, msg_version, report, true)) { + std::shared_ptr response( + MessageHelper::CreateNegativeResponse( + connection_key, + function_id, + correlation_id, + mobile_apis::Result::INVALID_DATA)); + + (*response)[strings::msg_params][strings::info] = rpc::PrettyFormat(report); + app_manager_.GetRPCService().ManageMobileCommand( + response, commands::Command::SOURCE_SDL); + return; + } + app_manager_.GetRPCService().ManageMobileCommand( result, commands::Command::SOURCE_MOBILE); } diff --git a/src/components/include/application_manager/rpc_handler.h b/src/components/include/application_manager/rpc_handler.h index 9b6428f32d..a64ef44dfb 100644 --- a/src/components/include/application_manager/rpc_handler.h +++ b/src/components/include/application_manager/rpc_handler.h @@ -52,6 +52,11 @@ class RPCHandler #endif // TELEMETRY_MONITOR { public: + virtual bool ValidateRpcSO(smart_objects::SmartObject* message, + utils::SemanticVersion& msg_version, + rpc::ValidationReport& report_out, + bool remove_unknown_params) = 0; + virtual ~RPCHandler() {} }; -- cgit v1.2.1 From f94e7c768ce4fede9f02d63a8f24efaec255bc32 Mon Sep 17 00:00:00 2001 From: jacobkeeler Date: Tue, 12 Mar 2019 15:36:48 -0400 Subject: Rename `allow_unknown_parameters` in SO files --- .../smart_objects/include/smart_objects/always_false_schema_item.h | 2 +- .../smart_objects/include/smart_objects/always_true_schema_item.h | 2 +- .../smart_objects/include/smart_objects/array_schema_item.h | 2 +- .../smart_objects/include/smart_objects/default_shema_item.h | 4 ++-- .../smart_objects/include/smart_objects/enum_schema_item.h | 6 +++--- .../smart_objects/include/smart_objects/number_schema_item.h | 4 ++-- .../smart_objects/include/smart_objects/object_schema_item.h | 2 +- src/components/smart_objects/include/smart_objects/schema_item.h | 2 +- src/components/smart_objects/include/smart_objects/smart_object.h | 2 +- src/components/smart_objects/include/smart_objects/smart_schema.h | 2 +- .../smart_objects/include/smart_objects/string_schema_item.h | 2 +- src/components/smart_objects/src/always_false_schema_item.cc | 2 +- src/components/smart_objects/src/always_true_schema_item.cc | 2 +- src/components/smart_objects/src/array_schema_item.cc | 4 ++-- src/components/smart_objects/src/object_schema_item.cc | 4 ++-- src/components/smart_objects/src/schema_item.cc | 2 +- src/components/smart_objects/src/smart_object.cc | 4 ++-- src/components/smart_objects/src/smart_schema.cc | 4 ++-- src/components/smart_objects/src/string_schema_item.cc | 2 +- 19 files changed, 27 insertions(+), 27 deletions(-) diff --git a/src/components/smart_objects/include/smart_objects/always_false_schema_item.h b/src/components/smart_objects/include/smart_objects/always_false_schema_item.h index 5e635d049b..c88c4e697a 100644 --- a/src/components/smart_objects/include/smart_objects/always_false_schema_item.h +++ b/src/components/smart_objects/include/smart_objects/always_false_schema_item.h @@ -59,7 +59,7 @@ class CAlwaysFalseSchemaItem : public ISchemaItem { const SmartObject& Object, rpc::ValidationReport* report__, const utils::SemanticVersion& MessageVersion = utils::SemanticVersion(), - const bool allow_unknown_parameters = false) OVERRIDE; + const bool allow_unknown_enums = false) OVERRIDE; private: CAlwaysFalseSchemaItem(); diff --git a/src/components/smart_objects/include/smart_objects/always_true_schema_item.h b/src/components/smart_objects/include/smart_objects/always_true_schema_item.h index efa208833a..0cd3d15452 100644 --- a/src/components/smart_objects/include/smart_objects/always_true_schema_item.h +++ b/src/components/smart_objects/include/smart_objects/always_true_schema_item.h @@ -59,7 +59,7 @@ class CAlwaysTrueSchemaItem : public ISchemaItem { const SmartObject& Object, rpc::ValidationReport* report__, const utils::SemanticVersion& MessageVersion = utils::SemanticVersion(), - const bool allow_unknown_parameters = false) OVERRIDE; + const bool allow_unknown_enums = false) OVERRIDE; private: CAlwaysTrueSchemaItem(); diff --git a/src/components/smart_objects/include/smart_objects/array_schema_item.h b/src/components/smart_objects/include/smart_objects/array_schema_item.h index 3f2e22849d..427d209020 100644 --- a/src/components/smart_objects/include/smart_objects/array_schema_item.h +++ b/src/components/smart_objects/include/smart_objects/array_schema_item.h @@ -74,7 +74,7 @@ class CArraySchemaItem : public ISchemaItem { const SmartObject& Object, rpc::ValidationReport* report__, const utils::SemanticVersion& MessageVersion = utils::SemanticVersion(), - const bool allow_unknown_parameters = false) OVERRIDE; + const bool allow_unknown_enums = false) OVERRIDE; /** * @brief Apply schema. diff --git a/src/components/smart_objects/include/smart_objects/default_shema_item.h b/src/components/smart_objects/include/smart_objects/default_shema_item.h index f86bd81f71..b07c668e97 100644 --- a/src/components/smart_objects/include/smart_objects/default_shema_item.h +++ b/src/components/smart_objects/include/smart_objects/default_shema_item.h @@ -59,7 +59,7 @@ class CDefaultSchemaItem : public ISchemaItem { const SmartObject& Object, rpc::ValidationReport* report__, const utils::SemanticVersion& MessageVersion = utils::SemanticVersion(), - const bool allow_unknown_parameters = false) OVERRIDE; + const bool allow_unknown_enums = false) OVERRIDE; /** * @brief Set default value to an object. @@ -107,7 +107,7 @@ errors::eType CDefaultSchemaItem::validate( const SmartObject& Object, rpc::ValidationReport* report__, const utils::SemanticVersion& MessageVersion, - const bool allow_unknown_parameters) { + const bool allow_unknown_enums) { if (getSmartType() != Object.getType()) { std::string validation_info = "Incorrect type, expected: " + SmartObject::typeToString(getSmartType()) + diff --git a/src/components/smart_objects/include/smart_objects/enum_schema_item.h b/src/components/smart_objects/include/smart_objects/enum_schema_item.h index 2067859d88..02e10b5603 100644 --- a/src/components/smart_objects/include/smart_objects/enum_schema_item.h +++ b/src/components/smart_objects/include/smart_objects/enum_schema_item.h @@ -114,7 +114,7 @@ class TEnumSchemaItem : public CDefaultSchemaItem { const SmartObject& Object, rpc::ValidationReport* report__, const utils::SemanticVersion& MessageVersion = utils::SemanticVersion(), - const bool allow_unknown_parameters = false) OVERRIDE; + const bool allow_unknown_enums = false) OVERRIDE; /** * @brief Return the correct history signature based on message version. * @param signatures Vector reference of enums history items. @@ -312,11 +312,11 @@ errors::eType TEnumSchemaItem::validate( const SmartObject& Object, rpc::ValidationReport* report__, const utils::SemanticVersion& MessageVersion, - const bool allow_unknown_parameters) { + const bool allow_unknown_enums) { if (SmartType_Integer != Object.getType()) { std::string validation_info; if (SmartType_String == Object.getType()) { - if (allow_unknown_parameters) { + if (allow_unknown_enums) { return errors::OK; } validation_info = "Invalid enum value: " + Object.asString(); diff --git a/src/components/smart_objects/include/smart_objects/number_schema_item.h b/src/components/smart_objects/include/smart_objects/number_schema_item.h index 0c6c657026..041f7ecd52 100644 --- a/src/components/smart_objects/include/smart_objects/number_schema_item.h +++ b/src/components/smart_objects/include/smart_objects/number_schema_item.h @@ -76,7 +76,7 @@ class TNumberSchemaItem : public CDefaultSchemaItem { const SmartObject& Object, rpc::ValidationReport* report__, const utils::SemanticVersion& MessageVersion = utils::SemanticVersion(), - const bool allow_unknown_parameters = false) OVERRIDE; + const bool allow_unknown_enums = false) OVERRIDE; private: /** @@ -139,7 +139,7 @@ errors::eType TNumberSchemaItem::validate( const SmartObject& Object, rpc::ValidationReport* report__, const utils::SemanticVersion& MessageVersion, - const bool allow_unknown_parameters) { + const bool allow_unknown_enums) { if (!isValidNumberType(Object.getType())) { SmartType expectedType = (typeid(double) == typeid(Object.getType())) ? SmartType_Double diff --git a/src/components/smart_objects/include/smart_objects/object_schema_item.h b/src/components/smart_objects/include/smart_objects/object_schema_item.h index 3f452c08cc..cacda792bf 100644 --- a/src/components/smart_objects/include/smart_objects/object_schema_item.h +++ b/src/components/smart_objects/include/smart_objects/object_schema_item.h @@ -115,7 +115,7 @@ class CObjectSchemaItem : public ISchemaItem { const SmartObject& Object, rpc::ValidationReport* report__, const utils::SemanticVersion& MessageVersion = utils::SemanticVersion(), - const bool allow_unknown_parameters = false) OVERRIDE; + const bool allow_unknown_enums = false) OVERRIDE; /** * @brief Apply schema. * @param Object Object to apply schema. diff --git a/src/components/smart_objects/include/smart_objects/schema_item.h b/src/components/smart_objects/include/smart_objects/schema_item.h index 644d03728f..585e312c1a 100644 --- a/src/components/smart_objects/include/smart_objects/schema_item.h +++ b/src/components/smart_objects/include/smart_objects/schema_item.h @@ -65,7 +65,7 @@ class ISchemaItem { const SmartObject& Object, rpc::ValidationReport* report__, const utils::SemanticVersion& MessageVersion = utils::SemanticVersion(), - const bool allow_unknown_parameters = false); + const bool allow_unknown_enums = false); /** * @brief Set default value to an object. diff --git a/src/components/smart_objects/include/smart_objects/smart_object.h b/src/components/smart_objects/include/smart_objects/smart_object.h index c1c1983e81..d4db14d33f 100644 --- a/src/components/smart_objects/include/smart_objects/smart_object.h +++ b/src/components/smart_objects/include/smart_objects/smart_object.h @@ -681,7 +681,7 @@ class SmartObject FINAL { errors::eType validate( rpc::ValidationReport* report__, const utils::SemanticVersion& MessageVersion = utils::SemanticVersion(), - const bool allow_unknown_parameters = false); + const bool allow_unknown_enums = false); /** * @brief Sets new schema diff --git a/src/components/smart_objects/include/smart_objects/smart_schema.h b/src/components/smart_objects/include/smart_objects/smart_schema.h index d9ef7ae418..072b3c0b7e 100644 --- a/src/components/smart_objects/include/smart_objects/smart_schema.h +++ b/src/components/smart_objects/include/smart_objects/smart_schema.h @@ -72,7 +72,7 @@ class CSmartSchema FINAL { const SmartObject& Object, rpc::ValidationReport* report__, const utils::SemanticVersion& messageVersion = utils::SemanticVersion(), - const bool allow_unknown_parameters = false) const; + const bool allow_unknown_enums = false) const; /** * @brief Set new root schema item. diff --git a/src/components/smart_objects/include/smart_objects/string_schema_item.h b/src/components/smart_objects/include/smart_objects/string_schema_item.h index 678097b838..5f95ca0389 100644 --- a/src/components/smart_objects/include/smart_objects/string_schema_item.h +++ b/src/components/smart_objects/include/smart_objects/string_schema_item.h @@ -71,7 +71,7 @@ class CStringSchemaItem : public CDefaultSchemaItem { const SmartObject& Object, rpc::ValidationReport* report__, const utils::SemanticVersion& MessageVersion = utils::SemanticVersion(), - const bool allow_unknown_parameters = false) OVERRIDE; + const bool allow_unknown_enums = false) OVERRIDE; private: /** diff --git a/src/components/smart_objects/src/always_false_schema_item.cc b/src/components/smart_objects/src/always_false_schema_item.cc index 62ae6549b9..4f8f4584af 100644 --- a/src/components/smart_objects/src/always_false_schema_item.cc +++ b/src/components/smart_objects/src/always_false_schema_item.cc @@ -45,7 +45,7 @@ errors::eType CAlwaysFalseSchemaItem::validate( const SmartObject& Object, rpc::ValidationReport* report__, const utils::SemanticVersion& MessageVersion, - const bool allow_unknown_parameters) { + const bool allow_unknown_enums) { report__->set_validation_info("Generic error"); return errors::ERROR; } diff --git a/src/components/smart_objects/src/always_true_schema_item.cc b/src/components/smart_objects/src/always_true_schema_item.cc index 9421654900..855bfef2a0 100644 --- a/src/components/smart_objects/src/always_true_schema_item.cc +++ b/src/components/smart_objects/src/always_true_schema_item.cc @@ -43,7 +43,7 @@ errors::eType CAlwaysTrueSchemaItem::validate( const SmartObject& Object, rpc::ValidationReport* report__, const utils::SemanticVersion& MessageVersion, - const bool allow_unknown_parameters) { + const bool allow_unknown_enums) { return errors::OK; } diff --git a/src/components/smart_objects/src/array_schema_item.cc b/src/components/smart_objects/src/array_schema_item.cc index 0b616db692..1671a97644 100644 --- a/src/components/smart_objects/src/array_schema_item.cc +++ b/src/components/smart_objects/src/array_schema_item.cc @@ -46,7 +46,7 @@ errors::eType CArraySchemaItem::validate( const SmartObject& Object, rpc::ValidationReport* report__, const utils::SemanticVersion& MessageVersion, - const bool allow_unknown_parameters) { + const bool allow_unknown_enums) { if (SmartType_Array != Object.getType()) { std::string validation_info = "Incorrect type, expected: " + SmartObject::typeToString(SmartType_Array) + @@ -82,7 +82,7 @@ errors::eType CArraySchemaItem::validate( mElementSchemaItem->validate(Object.getElement(i), &report__->ReportSubobject(strVal.str()), MessageVersion, - allow_unknown_parameters); + allow_unknown_enums); if (errors::OK != result) { return result; } diff --git a/src/components/smart_objects/src/object_schema_item.cc b/src/components/smart_objects/src/object_schema_item.cc index 382ae93e6d..21d2316e48 100644 --- a/src/components/smart_objects/src/object_schema_item.cc +++ b/src/components/smart_objects/src/object_schema_item.cc @@ -111,7 +111,7 @@ errors::eType CObjectSchemaItem::validate( const SmartObject& object, rpc::ValidationReport* report__, const utils::SemanticVersion& MessageVersion, - const bool allow_unknown_parameters) { + const bool allow_unknown_enums) { if (SmartType_Map != object.getType()) { std::string validation_info = "Incorrect type, expected: " + SmartObject::typeToString(SmartType_Map) + @@ -147,7 +147,7 @@ errors::eType CObjectSchemaItem::validate( correct_member.mSchemaItem->validate(field, &report__->ReportSubobject(key), MessageVersion, - allow_unknown_parameters); + allow_unknown_enums); if (errors::OK != result) { return result; } diff --git a/src/components/smart_objects/src/schema_item.cc b/src/components/smart_objects/src/schema_item.cc index f116cae708..8c40e2c7bd 100644 --- a/src/components/smart_objects/src/schema_item.cc +++ b/src/components/smart_objects/src/schema_item.cc @@ -39,7 +39,7 @@ errors::eType ISchemaItem::validate( const SmartObject& object, rpc::ValidationReport* report__, const utils::SemanticVersion& MessageVersion, - const bool allow_unknown_parameters) { + const bool allow_unknown_enums) { return errors::ERROR; } diff --git a/src/components/smart_objects/src/smart_object.cc b/src/components/smart_objects/src/smart_object.cc index d58310ec95..ef5dc787be 100644 --- a/src/components/smart_objects/src/smart_object.cc +++ b/src/components/smart_objects/src/smart_object.cc @@ -879,9 +879,9 @@ bool SmartObject::isValid() const { errors::eType SmartObject::validate( rpc::ValidationReport* report__, const utils::SemanticVersion& MessageVersion, - const bool allow_unknown_parameters) { + const bool allow_unknown_enums) { return m_schema.validate( - *this, report__, MessageVersion, allow_unknown_parameters); + *this, report__, MessageVersion, allow_unknown_enums); } void SmartObject::setSchema(const CSmartSchema& schema) { diff --git a/src/components/smart_objects/src/smart_schema.cc b/src/components/smart_objects/src/smart_schema.cc index 062bb18c8c..4ab5e5ff23 100644 --- a/src/components/smart_objects/src/smart_schema.cc +++ b/src/components/smart_objects/src/smart_schema.cc @@ -44,9 +44,9 @@ errors::eType CSmartSchema::validate( const SmartObject& object, rpc::ValidationReport* report__, const utils::SemanticVersion& MessageVersion, - const bool allow_unknown_parameters) const { + const bool allow_unknown_enums) const { return mSchemaItem->validate( - object, report__, MessageVersion, allow_unknown_parameters); + object, report__, MessageVersion, allow_unknown_enums); } void CSmartSchema::setSchemaItem(const ISchemaItemPtr schemaItem) { diff --git a/src/components/smart_objects/src/string_schema_item.cc b/src/components/smart_objects/src/string_schema_item.cc index 7331dd1340..e2ebde1861 100644 --- a/src/components/smart_objects/src/string_schema_item.cc +++ b/src/components/smart_objects/src/string_schema_item.cc @@ -50,7 +50,7 @@ errors::eType CStringSchemaItem::validate( const SmartObject& Object, rpc::ValidationReport* report__, const utils::SemanticVersion& MessageVersion, - const bool allow_unknown_parameters) { + const bool allow_unknown_enums) { if (SmartType_String != Object.getType()) { std::string validation_info = "Incorrect type, expected: " + SmartObject::typeToString(SmartType_String) + -- cgit v1.2.1 From a83aac5c4e094e02e0aa777bb2ae097a2b0b6de9 Mon Sep 17 00:00:00 2001 From: jacobkeeler Date: Tue, 12 Mar 2019 15:45:09 -0400 Subject: Rename `remove_unknown_parameters` to `allow_unknown_parameters` --- .../application_manager/application_manager_impl.h | 2 +- .../include/application_manager/rpc_handler_impl.h | 4 +-- .../include/application_manager/rpc_service_impl.h | 2 +- .../src/application_manager_impl.cc | 2 +- .../application_manager/src/rpc_handler_impl.cc | 29 +++++++++++----------- .../application_manager/src/rpc_passing_handler.cc | 2 +- .../application_manager/src/rpc_service_impl.cc | 22 ++++++++-------- .../include/application_manager/rpc_handler.h | 2 +- 8 files changed, 33 insertions(+), 32 deletions(-) diff --git a/src/components/application_manager/include/application_manager/application_manager_impl.h b/src/components/application_manager/include/application_manager/application_manager_impl.h index 27be913cd5..007b3433f0 100644 --- a/src/components/application_manager/include/application_manager/application_manager_impl.h +++ b/src/components/application_manager/include/application_manager/application_manager_impl.h @@ -1149,7 +1149,7 @@ class ApplicationManagerImpl bool ConvertSOtoMessage(const smart_objects::SmartObject& message, Message& output, - const bool remove_unknown_parameters = true); + const bool allow_unknown_parameters = false); template void PrepareApplicationListSO(ApplicationList app_list, diff --git a/src/components/application_manager/include/application_manager/rpc_handler_impl.h b/src/components/application_manager/include/application_manager/rpc_handler_impl.h index 489bcd21fd..0f2cb46cae 100644 --- a/src/components/application_manager/include/application_manager/rpc_handler_impl.h +++ b/src/components/application_manager/include/application_manager/rpc_handler_impl.h @@ -157,14 +157,14 @@ class RPCHandlerImpl : public RPCHandler, bool ValidateRpcSO(smart_objects::SmartObject* message, utils::SemanticVersion& msg_version, rpc::ValidationReport& report_out, - bool remove_unknown_params) OVERRIDE; + bool allow_unknown_parameters) OVERRIDE; private: void ProcessMessageFromMobile(const std::shared_ptr message); void ProcessMessageFromHMI(const std::shared_ptr message); bool ConvertMessageToSO(const Message& message, smart_objects::SmartObject& output, - const bool remove_unknown_parameters = true, + const bool allow_unknown_parameters = false, const bool validate_params = true); std::shared_ptr ConvertRawMsgToMessage( const ::protocol_handler::RawMessagePtr message); diff --git a/src/components/application_manager/include/application_manager/rpc_service_impl.h b/src/components/application_manager/include/application_manager/rpc_service_impl.h index 848e9645e7..516b8abb8b 100644 --- a/src/components/application_manager/include/application_manager/rpc_service_impl.h +++ b/src/components/application_manager/include/application_manager/rpc_service_impl.h @@ -132,7 +132,7 @@ class RPCServiceImpl : public RPCService, private: bool ConvertSOtoMessage(const smart_objects::SmartObject& message, Message& output, - const bool remove_unknown_parameters = true); + const bool allow_unknown_parameters = false); hmi_apis::HMI_API& hmi_so_factory(); mobile_apis::MOBILE_API& mobile_so_factory(); diff --git a/src/components/application_manager/src/application_manager_impl.cc b/src/components/application_manager/src/application_manager_impl.cc index 9d16c366d5..581551c3ac 100644 --- a/src/components/application_manager/src/application_manager_impl.cc +++ b/src/components/application_manager/src/application_manager_impl.cc @@ -2268,7 +2268,7 @@ bool ApplicationManagerImpl::Stop() { bool ApplicationManagerImpl::ConvertSOtoMessage( const smart_objects::SmartObject& message, Message& output, - const bool remove_unknown_parameters) { + const bool allow_unknown_parameters) { LOG4CXX_AUTO_TRACE(logger_); if (smart_objects::SmartType_Null == message.getType() || diff --git a/src/components/application_manager/src/rpc_handler_impl.cc b/src/components/application_manager/src/rpc_handler_impl.cc index 8911e746a6..9063728d66 100644 --- a/src/components/application_manager/src/rpc_handler_impl.cc +++ b/src/components/application_manager/src/rpc_handler_impl.cc @@ -65,7 +65,7 @@ void RPCHandlerImpl::ProcessMessageFromMobile( #endif // TELEMETRY_MONITOR smart_objects::SmartObjectSPtr so_from_mobile = std::make_shared(); - bool remove_unknown_parameters = true; + bool allow_unknown_parameters = false; DCHECK_OR_RETURN_VOID(so_from_mobile); if (!so_from_mobile) { LOG4CXX_ERROR(logger_, "Null pointer"); @@ -81,11 +81,11 @@ void RPCHandlerImpl::ProcessMessageFromMobile( LOG4CXX_DEBUG(logger_, "Allowing unknown parameters for request function " << message->function_id()); - remove_unknown_parameters = false; + allow_unknown_parameters = true; } if (!ConvertMessageToSO( - *message, *so_from_mobile, remove_unknown_parameters, !rpc_passing)) { + *message, *so_from_mobile, allow_unknown_parameters, !rpc_passing)) { LOG4CXX_ERROR(logger_, "Cannot create smart object from message"); return; } @@ -106,7 +106,7 @@ void RPCHandlerImpl::ProcessMessageFromMobile( commands::Command::SOURCE_MOBILE, message_type)) { // Since PassThrough failed, refiltering the message - if (!ConvertMessageToSO(*message, *so_from_mobile, true, true)) { + if (!ConvertMessageToSO(*message, *so_from_mobile)) { LOG4CXX_ERROR(logger_, "Cannot create smart object from message"); return; } @@ -134,7 +134,7 @@ void RPCHandlerImpl::ProcessMessageFromHMI( LOG4CXX_AUTO_TRACE(logger_); smart_objects::SmartObjectSPtr smart_object = std::make_shared(); - bool remove_unknown_parameters = true; + bool allow_unknown_parameters = false; if (!smart_object) { LOG4CXX_ERROR(logger_, "Null pointer"); return; @@ -152,10 +152,10 @@ void RPCHandlerImpl::ProcessMessageFromHMI( logger_, "Allowing unknown parameters for request function " << converted_result[jhs::S_PARAMS][jhs::S_FUNCTION_ID].asInt()); - remove_unknown_parameters = false; + allow_unknown_parameters = true; } - if (!ConvertMessageToSO(*message, *smart_object, remove_unknown_parameters)) { + if (!ConvertMessageToSO(*message, *smart_object, allow_unknown_parameters)) { if (application_manager::MessageType::kResponse == (*smart_object)[strings::params][strings::message_type].asInt()) { (*smart_object).erase(strings::msg_params); @@ -283,7 +283,7 @@ void RPCHandlerImpl::GetMessageVersion( bool RPCHandlerImpl::ConvertMessageToSO( const Message& message, ns_smart_device_link::ns_smart_objects::SmartObject& output, - const bool remove_unknown_parameters, + const bool allow_unknown_parameters, const bool validate_params) { LOG4CXX_AUTO_TRACE(logger_); LOG4CXX_DEBUG(logger_, @@ -320,7 +320,7 @@ bool RPCHandlerImpl::ConvertMessageToSO( if (validate_params && !ValidateRpcSO( - so_ptr, msg_version, report, remove_unknown_parameters)) { + so_ptr, msg_version, report, allow_unknown_parameters))) { LOG4CXX_WARN(logger_, "Failed to parse string to smart object with API version " << msg_version.toString() << " : " @@ -388,10 +388,11 @@ bool RPCHandlerImpl::ConvertMessageToSO( } rpc::ValidationReport report("RPC"); + utils::SemanticVersion empty_version; if (validate_params && - output.validate(&report, empty_version, !remove_unknown_parameters) != - smart_objects::errors::OK) { + output.validate(&report, empty_version, allow_unknown_parameters) != + smart_objects::errors::OK) { LOG4CXX_ERROR(logger_, "Incorrect parameter from HMI - " << rpc::PrettyFormat(report)); @@ -455,11 +456,11 @@ bool RPCHandlerImpl::ConvertMessageToSO( bool RPCHandlerImpl::ValidateRpcSO(smart_objects::SmartObject* message, utils::SemanticVersion& msg_version, rpc::ValidationReport& report_out, - bool remove_unknown_params) { + bool allow_unknown_parameters) { if (!message || !mobile_so_factory().attachSchema( - *message, remove_unknown_params, msg_version) || - output.validate(&report_out, msg_version, !remove_unknown_parameters) != + *message, !allow_unknown_parameters, msg_version) || + message->validate(&report_out, msg_version, allow_unknown_parameters) != smart_objects::errors::OK) { LOG4CXX_WARN(logger_, "Failed to parse string to smart object"); return false; diff --git a/src/components/application_manager/src/rpc_passing_handler.cc b/src/components/application_manager/src/rpc_passing_handler.cc index 165b1f43ba..f3db361de3 100644 --- a/src/components/application_manager/src/rpc_passing_handler.cc +++ b/src/components/application_manager/src/rpc_passing_handler.cc @@ -246,7 +246,7 @@ void RPCPassingHandler::ForwardRequestToCore(uint32_t correlation_id) { } if (!app_manager_.GetRPCHandler().ValidateRpcSO( - &message, msg_version, report, true)) { + &message, msg_version, report, false)) { std::shared_ptr response( MessageHelper::CreateNegativeResponse( connection_key, diff --git a/src/components/application_manager/src/rpc_service_impl.cc b/src/components/application_manager/src/rpc_service_impl.cc index d8329ba8cf..dfb5839764 100644 --- a/src/components/application_manager/src/rpc_service_impl.cc +++ b/src/components/application_manager/src/rpc_service_impl.cc @@ -388,7 +388,7 @@ void RPCServiceImpl::SendMessageToMobile( const bool is_result_code_exists = (*message)[strings::msg_params].keyExists(strings::result_code); - bool remove_unknown_parameters = true; + bool allow_unknown_parameters = false; if (!app) { LOG4CXX_ERROR(logger_, "No application associated with connection key"); @@ -431,7 +431,7 @@ void RPCServiceImpl::SendMessageToMobile( LOG4CXX_DEBUG(logger_, "Allowing unknown parameters for response function " << function_id); - remove_unknown_parameters = false; + allow_unknown_parameters = true; } if (rpc_passing && @@ -441,10 +441,10 @@ void RPCServiceImpl::SendMessageToMobile( (*message)[jhs::S_PARAMS][jhs::S_CORRELATION_ID].asUInt(), commands::Command::CommandSource::SOURCE_SDL, (*message)[jhs::S_PARAMS][jhs::S_MESSAGE_TYPE].asInt())) { - remove_unknown_parameters = true; + allow_unknown_parameters = false; } if (!ConvertSOtoMessage( - (*message), (*message_to_send), remove_unknown_parameters)) { + (*message), (*message_to_send), allow_unknown_parameters)) { LOG4CXX_WARN(logger_, "Can't send msg to Mobile: failed to create string"); return; } @@ -523,7 +523,7 @@ void RPCServiceImpl::SendMessageToHMI( return; } - bool remove_unknown_parameters = true; + bool allow_unknown_parameters = false; // SmartObject |message| has no way to declare priority for now std::shared_ptr message_to_send( new Message(protocol_handler::MessagePriority::kDefault)); @@ -543,11 +543,11 @@ void RPCServiceImpl::SendMessageToHMI( "Allowing unknown parameters for response function " << (*message)[jhs::S_PARAMS][jhs::S_FUNCTION_ID].asInt()); - remove_unknown_parameters = false; + allow_unknown_parameters = true; } if (!ConvertSOtoMessage( - *message, *message_to_send, remove_unknown_parameters)) { + *message, *message_to_send, allow_unknown_parameters)) { LOG4CXX_WARN(logger_, "Cannot send message to HMI: failed to create string"); return; @@ -605,7 +605,7 @@ void RPCServiceImpl::set_hmi_message_handler( bool RPCServiceImpl::ConvertSOtoMessage( const ns_smart_device_link::ns_smart_objects::SmartObject& message, Message& output, - const bool remove_unknown_parameters) { + const bool allow_unknown_parameters) { LOG4CXX_AUTO_TRACE(logger_); if (smart_objects::SmartType_Null == message.getType() || @@ -631,7 +631,7 @@ bool RPCServiceImpl::ConvertSOtoMessage( case 0: { if (protocol_version == 1) { if (!formatters::CFormatterJsonSDLRPCv1::toString( - message, output_string, remove_unknown_parameters)) { + message, output_string, !allow_unknown_parameters)) { LOG4CXX_WARN(logger_, "Failed to serialize smart object"); return false; } @@ -639,7 +639,7 @@ bool RPCServiceImpl::ConvertSOtoMessage( protocol_handler::MajorProtocolVersion::PROTOCOL_VERSION_1); } else { if (!formatters::CFormatterJsonSDLRPCv2::toString( - message, output_string, remove_unknown_parameters)) { + message, output_string, !allow_unknown_parameters)) { LOG4CXX_WARN(logger_, "Failed to serialize smart object"); return false; } @@ -652,7 +652,7 @@ bool RPCServiceImpl::ConvertSOtoMessage( } case 1: { if (!formatters::FormatterJsonRpc::ToString( - message, output_string, remove_unknown_parameters)) { + message, output_string, !allow_unknown_parameters)) { LOG4CXX_WARN(logger_, "Failed to serialize smart object"); return false; } diff --git a/src/components/include/application_manager/rpc_handler.h b/src/components/include/application_manager/rpc_handler.h index a64ef44dfb..3652c77342 100644 --- a/src/components/include/application_manager/rpc_handler.h +++ b/src/components/include/application_manager/rpc_handler.h @@ -55,7 +55,7 @@ class RPCHandler virtual bool ValidateRpcSO(smart_objects::SmartObject* message, utils::SemanticVersion& msg_version, rpc::ValidationReport& report_out, - bool remove_unknown_params) = 0; + bool allow_unknown_parameters) = 0; virtual ~RPCHandler() {} }; -- cgit v1.2.1 From e64899c5733f64b154ea42ebbd8f33585c55c704 Mon Sep 17 00:00:00 2001 From: jacobkeeler Date: Tue, 12 Mar 2019 15:50:15 -0400 Subject: Change `message` in ValidateRpcSO to reference --- .../include/application_manager/rpc_handler_impl.h | 2 +- .../application_manager/src/application_manager_impl.cc | 6 +++--- .../application_manager/src/rpc_handler_impl.cc | 17 ++++++++--------- .../application_manager/src/rpc_passing_handler.cc | 2 +- .../include/application_manager/rpc_handler.h | 2 +- 5 files changed, 14 insertions(+), 15 deletions(-) diff --git a/src/components/application_manager/include/application_manager/rpc_handler_impl.h b/src/components/application_manager/include/application_manager/rpc_handler_impl.h index 0f2cb46cae..e1dc9e6c5d 100644 --- a/src/components/application_manager/include/application_manager/rpc_handler_impl.h +++ b/src/components/application_manager/include/application_manager/rpc_handler_impl.h @@ -154,7 +154,7 @@ class RPCHandlerImpl : public RPCHandler, ns_smart_device_link::ns_smart_objects::SmartObject& output, utils::SemanticVersion& message_version); - bool ValidateRpcSO(smart_objects::SmartObject* message, + bool ValidateRpcSO(smart_objects::SmartObject& message, utils::SemanticVersion& msg_version, rpc::ValidationReport& report_out, bool allow_unknown_parameters) OVERRIDE; diff --git a/src/components/application_manager/src/application_manager_impl.cc b/src/components/application_manager/src/application_manager_impl.cc index 581551c3ac..701bb339a1 100644 --- a/src/components/application_manager/src/application_manager_impl.cc +++ b/src/components/application_manager/src/application_manager_impl.cc @@ -2294,7 +2294,7 @@ bool ApplicationManagerImpl::ConvertSOtoMessage( case 0: { if (protocol_version == 1) { if (!formatters::CFormatterJsonSDLRPCv1::toString( - message, output_string, remove_unknown_parameters)) { + message, output_string, !allow_unknown_parameters)) { LOG4CXX_WARN(logger_, "Failed to serialize smart object"); return false; } @@ -2302,7 +2302,7 @@ bool ApplicationManagerImpl::ConvertSOtoMessage( protocol_handler::MajorProtocolVersion::PROTOCOL_VERSION_1); } else { if (!formatters::CFormatterJsonSDLRPCv2::toString( - message, output_string, remove_unknown_parameters)) { + message, output_string, !allow_unknown_parameters)) { LOG4CXX_WARN(logger_, "Failed to serialize smart object"); return false; } @@ -2315,7 +2315,7 @@ bool ApplicationManagerImpl::ConvertSOtoMessage( } case 1: { if (!formatters::FormatterJsonRpc::ToString( - message, output_string, remove_unknown_parameters)) { + message, output_string, !allow_unknown_parameters)) { LOG4CXX_WARN(logger_, "Failed to serialize smart object"); return false; } diff --git a/src/components/application_manager/src/rpc_handler_impl.cc b/src/components/application_manager/src/rpc_handler_impl.cc index 9063728d66..2574da5fb5 100644 --- a/src/components/application_manager/src/rpc_handler_impl.cc +++ b/src/components/application_manager/src/rpc_handler_impl.cc @@ -304,7 +304,6 @@ bool RPCHandlerImpl::ConvertMessageToSO( message.type(), message.correlation_id()); - smart_objects::SmartObject* so_ptr = (conversion_result) ? &output : NULL; rpc::ValidationReport report("RPC"); // Attach RPC version to SmartObject if it does not exist yet. @@ -318,9 +317,10 @@ bool RPCHandlerImpl::ConvertMessageToSO( GetMessageVersion(output, msg_version); } - if (validate_params && - !ValidateRpcSO( - so_ptr, msg_version, report, allow_unknown_parameters))) { + if (!conversion_result || + (validate_params && + !ValidateRpcSO( + output, msg_version, report, allow_unknown_parameters))) { LOG4CXX_WARN(logger_, "Failed to parse string to smart object with API version " << msg_version.toString() << " : " @@ -453,14 +453,13 @@ bool RPCHandlerImpl::ConvertMessageToSO( return true; } -bool RPCHandlerImpl::ValidateRpcSO(smart_objects::SmartObject* message, +bool RPCHandlerImpl::ValidateRpcSO(smart_objects::SmartObject& message, utils::SemanticVersion& msg_version, rpc::ValidationReport& report_out, bool allow_unknown_parameters) { - if (!message || - !mobile_so_factory().attachSchema( - *message, !allow_unknown_parameters, msg_version) || - message->validate(&report_out, msg_version, allow_unknown_parameters) != + if (!mobile_so_factory().attachSchema( + message, !allow_unknown_parameters, msg_version) || + message.validate(&report_out, msg_version, allow_unknown_parameters) != smart_objects::errors::OK) { LOG4CXX_WARN(logger_, "Failed to parse string to smart object"); return false; diff --git a/src/components/application_manager/src/rpc_passing_handler.cc b/src/components/application_manager/src/rpc_passing_handler.cc index f3db361de3..8d93659a27 100644 --- a/src/components/application_manager/src/rpc_passing_handler.cc +++ b/src/components/application_manager/src/rpc_passing_handler.cc @@ -246,7 +246,7 @@ void RPCPassingHandler::ForwardRequestToCore(uint32_t correlation_id) { } if (!app_manager_.GetRPCHandler().ValidateRpcSO( - &message, msg_version, report, false)) { + message, msg_version, report, false)) { std::shared_ptr response( MessageHelper::CreateNegativeResponse( connection_key, diff --git a/src/components/include/application_manager/rpc_handler.h b/src/components/include/application_manager/rpc_handler.h index 3652c77342..2ada9e7901 100644 --- a/src/components/include/application_manager/rpc_handler.h +++ b/src/components/include/application_manager/rpc_handler.h @@ -52,7 +52,7 @@ class RPCHandler #endif // TELEMETRY_MONITOR { public: - virtual bool ValidateRpcSO(smart_objects::SmartObject* message, + virtual bool ValidateRpcSO(smart_objects::SmartObject& message, utils::SemanticVersion& msg_version, rpc::ValidationReport& report_out, bool allow_unknown_parameters) = 0; -- cgit v1.2.1 From 1eb4ec400d357987bcab8628c017f78372363c5b Mon Sep 17 00:00:00 2001 From: jacobkeeler Date: Tue, 12 Mar 2019 16:56:13 -0400 Subject: Add description to allow_unknown_enums --- .../smart_objects/include/smart_objects/always_false_schema_item.h | 4 ++++ .../smart_objects/include/smart_objects/always_true_schema_item.h | 4 ++++ .../smart_objects/include/smart_objects/array_schema_item.h | 4 ++++ .../smart_objects/include/smart_objects/default_shema_item.h | 4 ++++ .../smart_objects/include/smart_objects/enum_schema_item.h | 4 ++++ .../smart_objects/include/smart_objects/number_schema_item.h | 4 ++++ .../smart_objects/include/smart_objects/object_schema_item.h | 4 ++++ src/components/smart_objects/include/smart_objects/schema_item.h | 6 +++++- src/components/smart_objects/include/smart_objects/smart_object.h | 4 ++++ src/components/smart_objects/include/smart_objects/smart_schema.h | 4 ++++ .../smart_objects/include/smart_objects/string_schema_item.h | 4 ++++ 11 files changed, 45 insertions(+), 1 deletion(-) diff --git a/src/components/smart_objects/include/smart_objects/always_false_schema_item.h b/src/components/smart_objects/include/smart_objects/always_false_schema_item.h index c88c4e697a..05c53ec582 100644 --- a/src/components/smart_objects/include/smart_objects/always_false_schema_item.h +++ b/src/components/smart_objects/include/smart_objects/always_false_schema_item.h @@ -53,6 +53,10 @@ class CAlwaysFalseSchemaItem : public ISchemaItem { * @param Object Object to validate. * @param report__ object for reporting errors during validation * @param MessageVersion to check mobile RPC version against RPC Spec History + * @param allow_unknown_enums + * false - unknown enum values (left as string values after applySchema) + * will be considered invalid. + * true - such values will be considered valid. * @return ns_smart_objects::errors::eType **/ errors::eType validate( diff --git a/src/components/smart_objects/include/smart_objects/always_true_schema_item.h b/src/components/smart_objects/include/smart_objects/always_true_schema_item.h index 0cd3d15452..a2d305d0f9 100644 --- a/src/components/smart_objects/include/smart_objects/always_true_schema_item.h +++ b/src/components/smart_objects/include/smart_objects/always_true_schema_item.h @@ -53,6 +53,10 @@ class CAlwaysTrueSchemaItem : public ISchemaItem { * @param Object Object to validate. * @param report__ object for reporting errors during validation * @param MessageVersion to check mobile RPC version against RPC Spec History + * @param allow_unknown_enums + * false - unknown enum values (left as string values after applySchema) + * will be considered invalid. + * true - such values will be considered valid. * @return ns_smart_objects::errors::eType **/ errors::eType validate( diff --git a/src/components/smart_objects/include/smart_objects/array_schema_item.h b/src/components/smart_objects/include/smart_objects/array_schema_item.h index 427d209020..7706b6e091 100644 --- a/src/components/smart_objects/include/smart_objects/array_schema_item.h +++ b/src/components/smart_objects/include/smart_objects/array_schema_item.h @@ -68,6 +68,10 @@ class CArraySchemaItem : public ISchemaItem { * @param Object Object to validate. * @param report__ object for reporting errors during validation * @param MessageVersion to check mobile RPC version against RPC Spec History + * @param allow_unknown_enums + * false - unknown enum values (left as string values after applySchema) + * will be considered invalid. + * true - such values will be considered valid. * @return ns_smart_objects::errors::eType **/ errors::eType validate( diff --git a/src/components/smart_objects/include/smart_objects/default_shema_item.h b/src/components/smart_objects/include/smart_objects/default_shema_item.h index b07c668e97..beeeaac81f 100644 --- a/src/components/smart_objects/include/smart_objects/default_shema_item.h +++ b/src/components/smart_objects/include/smart_objects/default_shema_item.h @@ -53,6 +53,10 @@ class CDefaultSchemaItem : public ISchemaItem { * @param Object Object to validate. * @param report__ object for reporting errors during validation * @param MessageVersion to check mobile RPC version against RPC Spec History + * @param allow_unknown_enums + * false - unknown enum values (left as string values after applySchema) + * will be considered invalid. + * true - such values will be considered valid. * @return ns_smart_objects::errors::eType **/ errors::eType validate( diff --git a/src/components/smart_objects/include/smart_objects/enum_schema_item.h b/src/components/smart_objects/include/smart_objects/enum_schema_item.h index 02e10b5603..2a27f765d2 100644 --- a/src/components/smart_objects/include/smart_objects/enum_schema_item.h +++ b/src/components/smart_objects/include/smart_objects/enum_schema_item.h @@ -108,6 +108,10 @@ class TEnumSchemaItem : public CDefaultSchemaItem { * @param Object Object to validate. * @param report__ object for reporting errors during validation * @param MessageVersion to check mobile RPC version against RPC Spec History + * @param allow_unknown_enums + * false - unknown enum values (left as string values after applySchema) + * will be considered invalid. + * true - such values will be considered valid. * @return ns_smart_objects::errors::eType **/ errors::eType validate( diff --git a/src/components/smart_objects/include/smart_objects/number_schema_item.h b/src/components/smart_objects/include/smart_objects/number_schema_item.h index 041f7ecd52..b3e227e0f1 100644 --- a/src/components/smart_objects/include/smart_objects/number_schema_item.h +++ b/src/components/smart_objects/include/smart_objects/number_schema_item.h @@ -70,6 +70,10 @@ class TNumberSchemaItem : public CDefaultSchemaItem { * @param Object Object to validate. * @param report__ object for reporting errors during validation * @param MessageVersion to check mobile RPC version against RPC Spec History + * @param allow_unknown_enums + * false - unknown enum values (left as string values after applySchema) + * will be considered invalid. + * true - such values will be considered valid. * @return ns_smart_objects::errors::eType **/ errors::eType validate( diff --git a/src/components/smart_objects/include/smart_objects/object_schema_item.h b/src/components/smart_objects/include/smart_objects/object_schema_item.h index cacda792bf..7b57792c1e 100644 --- a/src/components/smart_objects/include/smart_objects/object_schema_item.h +++ b/src/components/smart_objects/include/smart_objects/object_schema_item.h @@ -109,6 +109,10 @@ class CObjectSchemaItem : public ISchemaItem { * @param Object Object to validate. * @param report__ object for reporting errors during validation * @param MessageVersion to check mobile RPC version against RPC Spec History + * @param allow_unknown_enums + * false - unknown enum values (left as string values after applySchema) + * will be considered invalid. + * true - such values will be considered valid. * @return ns_smart_objects::errors::eType **/ errors::eType validate( diff --git a/src/components/smart_objects/include/smart_objects/schema_item.h b/src/components/smart_objects/include/smart_objects/schema_item.h index 585e312c1a..fa5f6d3adc 100644 --- a/src/components/smart_objects/include/smart_objects/schema_item.h +++ b/src/components/smart_objects/include/smart_objects/schema_item.h @@ -58,7 +58,11 @@ class ISchemaItem { * @param Object Object to validate. * @param report__ object for reporting errors during validation * message if an error occurs - * @param MessageVersion to check mobile RPC version against RPC Spec Histor + * @param MessageVersion to check mobile RPC version against RPC Spec History + * @param allow_unknown_enums + * false - unknown enum values (left as string values after applySchema) + * will be considered invalid. + * true - such values will be considered valid. * @return ns_smart_objects::errors::eType **/ virtual errors::eType validate( diff --git a/src/components/smart_objects/include/smart_objects/smart_object.h b/src/components/smart_objects/include/smart_objects/smart_object.h index d4db14d33f..b862d25a17 100644 --- a/src/components/smart_objects/include/smart_objects/smart_object.h +++ b/src/components/smart_objects/include/smart_objects/smart_object.h @@ -676,6 +676,10 @@ class SmartObject FINAL { * * @param report__ object for reporting errors during validation * @param messageVersion of the mobile app to check against RPC Spec Schema + * @param allow_unknown_enums + * false - unknown enum values (left as string values after applySchema) + * will be considered invalid. + * true - such values will be considered valid. * @return Result of validation. */ errors::eType validate( diff --git a/src/components/smart_objects/include/smart_objects/smart_schema.h b/src/components/smart_objects/include/smart_objects/smart_schema.h index 072b3c0b7e..ece2696539 100644 --- a/src/components/smart_objects/include/smart_objects/smart_schema.h +++ b/src/components/smart_objects/include/smart_objects/smart_schema.h @@ -66,6 +66,10 @@ class CSmartSchema FINAL { * @param Object Object to validate. * @param report__ object for reporting errors during validation * @param MessageVersion to check mobile RPC version against RPC Spec History + * @param allow_unknown_enums + * false - unknown enum values (left as string values after applySchema) + * will be considered invalid. + * true - such values will be considered valid. * @return ns_smart_objects::errors::eType **/ errors::eType validate( diff --git a/src/components/smart_objects/include/smart_objects/string_schema_item.h b/src/components/smart_objects/include/smart_objects/string_schema_item.h index 5f95ca0389..7104ff47a9 100644 --- a/src/components/smart_objects/include/smart_objects/string_schema_item.h +++ b/src/components/smart_objects/include/smart_objects/string_schema_item.h @@ -65,6 +65,10 @@ class CStringSchemaItem : public CDefaultSchemaItem { * @param Object Object to validate. * @param report__ object for reporting errors during validation * @param MessageVersion to check mobile RPC version against RPC Spec History + * @param allow_unknown_enums + * false - unknown enum values (left as string values after applySchema) + * will be considered invalid. + * true - such values will be considered valid. * @return ns_smart_objects::errors::eType **/ errors::eType validate( -- cgit v1.2.1 From 1e5581872dc14ebcdde71cbcb9cd7eee9b98338a Mon Sep 17 00:00:00 2001 From: jacobkeeler Date: Wed, 13 Mar 2019 10:35:33 -0400 Subject: Add unit tests for cloud policy handler additions --- .../test/policy_handler_test.cc | 104 ++++++++++++++++++++- .../policies/mock_policy_handler_observer.h | 3 + .../policy_external/policy/mock_policy_manager.h | 2 +- 3 files changed, 104 insertions(+), 5 deletions(-) diff --git a/src/components/application_manager/test/policy_handler_test.cc b/src/components/application_manager/test/policy_handler_test.cc index a1471eff36..25024ff50d 100644 --- a/src/components/application_manager/test/policy_handler_test.cc +++ b/src/components/application_manager/test/policy_handler_test.cc @@ -81,15 +81,13 @@ using namespace application_manager; using namespace policy; using namespace utils::custom_string; using testing::_; +using ::testing::DoAll; using ::testing::Mock; +using ::testing::NiceMock; using ::testing::Return; using ::testing::ReturnRef; -using ::testing::NiceMock; -using ::testing::SetArgReferee; using ::testing::SetArgPointee; -using ::testing::DoAll; using ::testing::SetArgReferee; -using ::testing::Mock; typedef NiceMock MockRPCService; @@ -2536,6 +2534,104 @@ TEST_F(PolicyHandlerTest, RemoteAppsUrl_SUCCESS) { EXPECT_EQ(url, policy_handler_.RemoteAppsUrl()); } +TEST_F(PolicyHandlerTest, OnSetCloudAppProperties_AllProperties_SUCCESS) { + EnablePolicyAndPolicyManagerMock(); + + bool enabled = true; + std::string app_name = "anAppName"; + std::string auth_token = "anAuthToken"; + std::string cloud_transport_type = "aTransportType"; + mobile_apis::HybridAppPreference::eType hybrid_app_preference = + mobile_apis::HybridAppPreference::CLOUD; + std::string hybrid_app_preference_str = "CLOUD"; + std::string endpoint = "anEndpoint"; + + StringArray nicknames_vec; + nicknames_vec.push_back(app_name); + + smart_objects::SmartObject message(smart_objects::SmartType_Map); + smart_objects::SmartObject properties(smart_objects::SmartType_Map); + smart_objects::SmartObject nicknames(smart_objects::SmartType_Array); + + properties[strings::app_id] = kPolicyAppId_; + nicknames[0] = app_name; + properties[strings::nicknames] = nicknames; + properties[strings::enabled] = enabled; + properties[strings::auth_token] = auth_token; + properties[strings::cloud_transport_type] = cloud_transport_type; + properties[strings::hybrid_app_preference] = hybrid_app_preference; + properties[strings::endpoint] = endpoint; + message[strings::msg_params][strings::properties] = properties; + + application_manager_test::MockPolicyHandlerObserver policy_handler_observer; + policy_handler_.add_listener(&policy_handler_observer); + + EXPECT_CALL(*mock_policy_manager_, InitCloudApp(kPolicyAppId_)); + EXPECT_CALL(*mock_policy_manager_, + SetCloudAppEnabled(kPolicyAppId_, enabled)); + EXPECT_CALL(*mock_policy_manager_, + SetAppNicknames(kPolicyAppId_, nicknames_vec)); + EXPECT_CALL(*mock_policy_manager_, + SetAppAuthToken(kPolicyAppId_, auth_token)); + EXPECT_CALL(*mock_policy_manager_, + SetAppCloudTransportType(kPolicyAppId_, cloud_transport_type)); + EXPECT_CALL(*mock_policy_manager_, + SetHybridAppPreference(kPolicyAppId_, hybrid_app_preference_str)); + EXPECT_CALL(*mock_policy_manager_, SetAppEndpoint(kPolicyAppId_, endpoint)); + EXPECT_CALL(*mock_policy_manager_, + GetCloudAppParameters(kPolicyAppId_, _, _, _, _, _, _)) + .WillOnce(DoAll(SetArgReferee<4>(auth_token), Return(true))); + EXPECT_CALL(app_manager_, RefreshCloudAppInformation()); + EXPECT_CALL(policy_handler_observer, + OnAuthTokenUpdated(kPolicyAppId_, auth_token)); + + policy_handler_.OnSetCloudAppProperties(message); +} + +TEST_F(PolicyHandlerTest, GetCloudAppParameters_AllProperties_SUCCESS) { + EnablePolicyAndPolicyManagerMock(); + + bool enabled = true; + std::string certificate = "aCertificate"; + std::string auth_token = "anAuthToken"; + std::string cloud_transport_type = "aTransportType"; + std::string hybrid_app_preference_str = "CLOUD"; + std::string endpoint = "anEndpoint"; + + application_manager_test::MockPolicyHandlerObserver policy_handler_observer; + policy_handler_.add_listener(&policy_handler_observer); + + EXPECT_CALL(*mock_policy_manager_, + GetCloudAppParameters(kPolicyAppId_, _, _, _, _, _, _)) + .WillOnce(DoAll(SetArgReferee<1>(enabled), + SetArgReferee<2>(endpoint), + SetArgReferee<3>(certificate), + SetArgReferee<4>(auth_token), + SetArgReferee<5>(cloud_transport_type), + SetArgReferee<6>(hybrid_app_preference_str), + Return(true))); + + bool enabled_out; + std::string endpoint_out; + std::string cert_out; + std::string auth_token_out; + std::string ctt_out; + std::string hap_out; + EXPECT_TRUE(policy_handler_.GetCloudAppParameters(kPolicyAppId_, + enabled_out, + endpoint_out, + cert_out, + auth_token_out, + ctt_out, + hap_out)); + EXPECT_EQ(enabled, enabled_out); + EXPECT_EQ(endpoint, endpoint_out); + EXPECT_EQ(certificate, cert_out); + EXPECT_EQ(auth_token, auth_token_out); + EXPECT_EQ(cloud_transport_type, ctt_out); + EXPECT_EQ(hybrid_app_preference_str, hap_out); +} + } // namespace policy_handler_test } // namespace components } // namespace test diff --git a/src/components/include/test/application_manager/policies/mock_policy_handler_observer.h b/src/components/include/test/application_manager/policies/mock_policy_handler_observer.h index e8ed0e90e2..bd8c83d897 100644 --- a/src/components/include/test/application_manager/policies/mock_policy_handler_observer.h +++ b/src/components/include/test/application_manager/policies/mock_policy_handler_observer.h @@ -49,6 +49,9 @@ class MockPolicyHandlerObserver : public ::policy::PolicyHandlerObserver { MOCK_METHOD1(OnUpdateHMIAppType, void(std::map >)); MOCK_METHOD1(OnCertificateUpdated, bool(const std::string&)); + MOCK_METHOD2(OnAuthTokenUpdated, + void(const std::string& policy_app_id, + const std::string& auth_token)); MOCK_METHOD1(OnPTUFinished, void(const bool ptu_result)); }; } // namespace application_manager_test diff --git a/src/components/include/test/policy/policy_external/policy/mock_policy_manager.h b/src/components/include/test/policy/policy_external/policy/mock_policy_manager.h index 3f594ff6df..0ec4883448 100644 --- a/src/components/include/test/policy/policy_external/policy/mock_policy_manager.h +++ b/src/components/include/test/policy/policy_external/policy/mock_policy_manager.h @@ -188,7 +188,7 @@ class MockPolicyManager : public PolicyManager { MOCK_CONST_METHOD1(GetEnabledCloudApps, void(std::vector& enabled_apps)); MOCK_CONST_METHOD7(GetCloudAppParameters, - void(const std::string& policy_app_id, + bool(const std::string& policy_app_id, bool& enabled, std::string& endpoint, std::string& certificate, -- cgit v1.2.1 From c86f4a10067bf31e96dd82bec6aa776aed846f6a Mon Sep 17 00:00:00 2001 From: jacobkeeler Date: Wed, 13 Mar 2019 10:36:18 -0400 Subject: Fix SDL.ActivateApp unit tests for EXTERNAL_PROPRIETARY build --- .../sdl_rpc_plugin/test/commands/hmi/sdl_activate_app_request_test.cc | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/sdl_activate_app_request_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/sdl_activate_app_request_test.cc index a90c0c70fc..917de81fb3 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/sdl_activate_app_request_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/sdl_activate_app_request_test.cc @@ -140,6 +140,8 @@ TEST_F(SDLActivateAppRequestTest, Run_ActivateApp_SUCCESS) { std::shared_ptr command( CreateCommand(msg)); + EXPECT_CALL(app_mngr_, WaitingApplicationByID(kAppID)) + .WillOnce(Return(ApplicationSharedPtr())); EXPECT_CALL(app_mngr_, state_controller()) .WillOnce(ReturnRef(mock_state_controller_)); EXPECT_CALL(mock_state_controller_, @@ -446,8 +448,10 @@ TEST_F(SDLActivateAppRequestTest, WaitingCloudApplication_ConnectDevice) { EXPECT_CALL(*mock_app, IsRegistered()).WillOnce(Return(false)); EXPECT_CALL(*mock_app, is_cloud_app()).WillOnce(Return(true)); +#ifndef EXTERNAL_PROPRIETARY_MODE EXPECT_CALL(app_mngr_, application(kAppID)) .WillOnce(Return(ApplicationSharedPtr())); +#endif EXPECT_CALL(app_mngr_, WaitingApplicationByID(kAppID)) .WillOnce(Return(mock_app)); -- cgit v1.2.1 From 1c32db10769c284450346b5e2de829bb437bff7e Mon Sep 17 00:00:00 2001 From: JackLivio Date: Wed, 13 Mar 2019 13:07:49 -0400 Subject: Cloud app disconnect tests + fix --- .../application_manager/application_manager_impl.h | 9 ++ .../src/application_manager_impl.cc | 10 +- .../test/application_manager_impl_test.cc | 136 ++++++++++++++++++++- .../test/transport_adapter_test.cc | 131 ++++++++++++++++++++ .../test/transport_manager_impl_test.cc | 44 +++++++ 5 files changed, 321 insertions(+), 9 deletions(-) diff --git a/src/components/application_manager/include/application_manager/application_manager_impl.h b/src/components/application_manager/include/application_manager/application_manager_impl.h index 27be913cd5..90af5afebf 100644 --- a/src/components/application_manager/include/application_manager/application_manager_impl.h +++ b/src/components/application_manager/include/application_manager/application_manager_impl.h @@ -1580,6 +1580,15 @@ class ApplicationManagerImpl rpc_service_.reset(rpc_service); } + /** + * @brief set a mock rpc service directly. Only for unit + * testing. + * @param mock_app the mock rpc service to be assigned + */ + void SetMockPolicyHandler(policy::PolicyHandlerInterface* policy_handler) { + policy_handler_.reset(policy_handler); + } + virtual void SetPluginManager( std::unique_ptr& plugin_manager) OVERRIDE { diff --git a/src/components/application_manager/src/application_manager_impl.cc b/src/components/application_manager/src/application_manager_impl.cc index 9d16c366d5..1eeaa8f739 100644 --- a/src/components/application_manager/src/application_manager_impl.cc +++ b/src/components/application_manager/src/application_manager_impl.cc @@ -1195,14 +1195,15 @@ void ApplicationManagerImpl::SetPendingApplicationState( } LOG4CXX_DEBUG(logger_, "Unregister application and move into apps_to_register"); - { - sync_primitives::AutoLock lock(apps_to_register_list_lock_ptr_); - apps_to_register_.insert(app); - } UnregisterApplication( app->app_id(), mobile_apis::Result::INVALID_ENUM, true, true); app->MarkUnregistered(); + + { + sync_primitives::AutoLock lock(apps_to_register_list_lock_ptr_); + apps_to_register_.insert(app); + } } void ApplicationManagerImpl::OnConnectionStatusUpdated() { @@ -2923,6 +2924,7 @@ void ApplicationManagerImpl::UnregisterApplication( auto it_app = applications_.begin(); while (applications_.end() != it_app) { if (app_id == (*it_app)->app_id()) { + connection_handler().GetDeviceID((*it_app)->mac_address(), &handle); app_to_remove = *it_app; applications_.erase(it_app++); } else { diff --git a/src/components/application_manager/test/application_manager_impl_test.cc b/src/components/application_manager/test/application_manager_impl_test.cc index f27e252142..c606a37ff2 100644 --- a/src/components/application_manager/test/application_manager_impl_test.cc +++ b/src/components/application_manager/test/application_manager_impl_test.cc @@ -29,12 +29,12 @@ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ +#include #include #include #include #include #include -#include #include "application_manager/application.h" #include "application_manager/application_impl.h" @@ -44,6 +44,7 @@ #include "application_manager/mock_resumption_data.h" #include "application_manager/mock_rpc_plugin_manager.h" #include "application_manager/mock_rpc_service.h" +#include "application_manager/policies/mock_policy_handler_interface.h" #include "application_manager/resumption/resume_ctrl_impl.h" #include "application_manager/test/include/application_manager/mock_message_helper.h" #include "connection_handler/mock_connection_handler.h" @@ -60,8 +61,8 @@ #include "utils/file_system.h" #include "utils/lock.h" -#include "utils/push_log.h" #include "encryption/hashing.h" +#include "utils/push_log.h" namespace test { namespace components { @@ -73,15 +74,16 @@ namespace con_test = connection_handler_test; using testing::_; using ::testing::An; -using ::testing::Matcher; using ::testing::ByRef; using ::testing::DoAll; +using ::testing::Matcher; using ::testing::Mock; +using ::testing::NiceMock; using ::testing::Return; using ::testing::ReturnRef; -using ::testing::NiceMock; using ::testing::SaveArg; using ::testing::SetArgPointee; +using ::testing::SetArgReferee; using namespace application_manager; @@ -115,6 +117,8 @@ class ApplicationManagerImplTest : public ::testing::Test { std::make_shared >( mock_app_mngr_)) , mock_rpc_service_(new MockRPCService) + , mock_policy_handler_( + new test::components::policy_test::MockPolicyHandlerInterface) , mock_message_helper_( application_manager::MockMessageHelper::message_helper_mock()) @@ -141,6 +145,7 @@ class ApplicationManagerImplTest : public ::testing::Test { app_manager_impl_->set_connection_handler(&mock_connection_handler_); Json::Value empty; ON_CALL(mock_last_state_, get_dictionary()).WillByDefault(ReturnRef(empty)); + // app_manager_impl_->SetMockPolicyHandler(mock_policy_handler_); std::unique_ptr app_service_manager_ptr( new AppServiceManager(*app_manager_impl_, mock_last_state_)); app_manager_impl_->SetAppServiceManager(app_service_manager_ptr); @@ -210,6 +215,8 @@ class ApplicationManagerImplTest : public ::testing::Test { connection_handler::DeviceHandle secondary_device_handle, std::string secondary_transport_device_string); + void AddCloudAppToPendingDeviceMap(); + uint32_t app_id_; NiceMock mock_policy_settings_; std::shared_ptr > mock_storage_; @@ -219,6 +226,8 @@ class ApplicationManagerImplTest : public ::testing::Test { NiceMock mock_connection_handler_; NiceMock mock_session_observer_; NiceMock mock_application_manager_settings_; + test::components::policy_test::MockPolicyHandlerInterface* + mock_policy_handler_; application_manager_test::MockApplicationManager mock_app_mngr_; std::unique_ptr app_manager_impl_; application_manager::MockMessageHelper* mock_message_helper_; @@ -1428,6 +1437,123 @@ TEST_F(ApplicationManagerImplTest, EXPECT_TRUE(file_system::RemoveDirectory(kDirectoryName, true)); } +void ApplicationManagerImplTest::AddCloudAppToPendingDeviceMap() { + app_manager_impl_->SetMockPolicyHandler(mock_policy_handler_); + std::vector enabled_apps{"1234"}; + std::string endpoint = "https://fakesdlcloudapptesting.com:8080"; + std::string certificate = "cert"; + std::string auth_token = "auth_token"; + std::string cloud_transport_type = "WS"; + std::string hybrid_app_preference_str = "CLOUD"; + bool enabled = true; + EXPECT_CALL(*mock_policy_handler_, GetEnabledCloudApps(_)) + .WillOnce(SetArgReferee<0>(enabled_apps)); + EXPECT_CALL(*mock_policy_handler_, GetCloudAppParameters(_, _, _, _, _, _, _)) + .WillOnce(DoAll(SetArgReferee<1>(enabled), + SetArgReferee<2>(endpoint), + SetArgReferee<3>(certificate), + SetArgReferee<4>(auth_token), + SetArgReferee<5>(cloud_transport_type), + SetArgReferee<6>(hybrid_app_preference_str), + Return(true))); + + std::vector nicknames{"CloudApp"}; + EXPECT_CALL(*mock_policy_handler_, GetInitialAppData(_, _, _)) + .WillOnce(DoAll(SetArgPointee<1>(nicknames), Return(true))); + + EXPECT_CALL(*mock_policy_handler_, GetIconUrl(_)).WillOnce(Return("")); + + app_manager_impl_->RefreshCloudAppInformation(); +} + +TEST_F(ApplicationManagerImplTest, CreatePendingApplication) { + // Add to pending device map. Calls refresh cloud app + AddCloudAppToPendingDeviceMap(); + + // CreatePendingApplication + transport_manager::DeviceInfo device_info( + 1, "mac", "https://fakesdlcloudapptesting.com:8080", "CLOUD_WEBSOCKET"); + std::vector nicknames{"CloudApp"}; + EXPECT_CALL(*mock_policy_handler_, GetInitialAppData(_, _, _)) + .WillOnce(DoAll(SetArgPointee<1>(nicknames), Return(true))); + std::vector enabled_apps{"1234"}; + std::string endpoint = "https://fakesdlcloudapptesting.com:8080"; + std::string certificate = "cert"; + std::string auth_token = "auth_token"; + std::string cloud_transport_type = "WS"; + std::string hybrid_app_preference_str = "CLOUD"; + bool enabled = true; + + EXPECT_CALL(*mock_policy_handler_, GetStatisticManager()) + .WillOnce(Return(std::shared_ptr( + new usage_statistics_test::MockStatisticsManager()))); + EXPECT_CALL(*mock_policy_handler_, GetCloudAppParameters(_, _, _, _, _, _, _)) + .WillOnce(DoAll(SetArgReferee<1>(enabled), + SetArgReferee<2>(endpoint), + SetArgReferee<3>(certificate), + SetArgReferee<4>(auth_token), + SetArgReferee<5>(cloud_transport_type), + SetArgReferee<6>(hybrid_app_preference_str), + Return(true))); + // Expect Update app list + EXPECT_CALL(*mock_rpc_service_, ManageHMICommand(_, _)).Times(1); + app_manager_impl_->CreatePendingApplication(1, device_info, 1); + AppsWaitRegistrationSet app_list = + app_manager_impl_->AppsWaitingForRegistration().GetData(); + EXPECT_EQ(1u, app_list.size()); +} + +TEST_F(ApplicationManagerImplTest, SetPendingState) { + AddCloudAppToPendingDeviceMap(); + AddMockApplication(); + AppsWaitRegistrationSet app_list = + app_manager_impl_->AppsWaitingForRegistration().GetData(); + EXPECT_EQ(0u, app_list.size()); + EXPECT_CALL(*mock_app_ptr_, policy_app_id()).WillRepeatedly(Return("1234")); + EXPECT_CALL(*mock_app_ptr_, app_id()).WillRepeatedly(Return(123)); + std::string mac = "MAC_ADDRESS"; + EXPECT_CALL(*mock_app_ptr_, mac_address()).WillRepeatedly(ReturnRef(mac)); + transport_manager::DeviceInfo device_info( + 1, "mac", "https://fakesdlcloudapptesting.com:8080", "CLOUD_WEBSOCKET"); + + std::vector enabled_apps{"1234"}; + std::string endpoint = "https://fakesdlcloudapptesting.com:8080"; + std::string certificate = "cert"; + std::string auth_token = "auth_token"; + std::string cloud_transport_type = "WS"; + std::string hybrid_app_preference_str = "CLOUD"; + bool enabled = true; + + EXPECT_CALL(*mock_policy_handler_, GetEnabledCloudApps(_)) + .WillOnce(SetArgReferee<0>(enabled_apps)); + EXPECT_CALL(*mock_policy_handler_, GetCloudAppParameters(_, _, _, _, _, _, _)) + .WillOnce(DoAll(SetArgReferee<1>(enabled), + SetArgReferee<2>(endpoint), + SetArgReferee<3>(certificate), + SetArgReferee<4>(auth_token), + SetArgReferee<5>(cloud_transport_type), + SetArgReferee<6>(hybrid_app_preference_str), + Return(true))); + + std::vector nicknames{"CloudApp"}; + EXPECT_CALL(*mock_policy_handler_, GetInitialAppData(_, _, _)) + .WillOnce(DoAll(SetArgPointee<1>(nicknames), Return(true))); + + EXPECT_CALL(*mock_policy_handler_, GetIconUrl(_)).WillOnce(Return("")); + + plugin_manager::MockRPCPluginManager* mock_rpc_plugin_manager = + new plugin_manager::MockRPCPluginManager; + std::unique_ptr mock_rpc_plugin_manager_ptr( + mock_rpc_plugin_manager); + app_manager_impl_->SetPluginManager(mock_rpc_plugin_manager_ptr); + + EXPECT_CALL(mock_connection_handler_, GetDeviceID(_, _)) + .WillOnce(DoAll(SetArgPointee<1>(0), Return(true))); + app_manager_impl_->SetPendingApplicationState(1, device_info); + app_list = app_manager_impl_->AppsWaitingForRegistration().GetData(); + EXPECT_EQ(1u, app_list.size()); +} + TEST_F(ApplicationManagerImplTest, RegisterApplication_CloudAppRegisterSuccess) { std::shared_ptr waiting_app = @@ -1542,6 +1668,6 @@ TEST_F(ApplicationManagerImplTest, EXPECT_EQ(0, application.use_count()); } -} // application_manager_test +} // namespace application_manager_test } // namespace components } // namespace test diff --git a/src/components/transport_manager/test/transport_adapter_test.cc b/src/components/transport_manager/test/transport_adapter_test.cc index dafabf4504..5abfa4dfdd 100644 --- a/src/components/transport_manager/test/transport_adapter_test.cc +++ b/src/components/transport_manager/test/transport_adapter_test.cc @@ -478,6 +478,137 @@ TEST_F(TransportAdapterTest, Disconnect_ConnectDoneSuccess) { EXPECT_CALL(*serverMock, Terminate()); } +TEST_F(TransportAdapterTest, FindPending) { + MockServerConnectionFactory* serverMock = new MockServerConnectionFactory(); + MockTransportAdapterImpl transport_adapter( + NULL, serverMock, NULL, last_state_, transport_manager_settings); + SetDefaultExpectations(transport_adapter); + + EXPECT_CALL(*serverMock, Init()).WillOnce(Return(TransportAdapter::OK)); + EXPECT_CALL(transport_adapter, Restore()).WillOnce(Return(true)); + transport_adapter.Init(); + + MockTransportAdapterListener mock_listener; + transport_adapter.AddListener(&mock_listener); + + std::shared_ptr mockdev = + std::make_shared(dev_id, uniq_id); + DeviceVector devices{mockdev}; + transport_adapter.SearchDeviceDone(devices); + + // Create cloud app device with connection in pending state + std::shared_ptr connection = + std::make_shared(); + EXPECT_CALL(transport_adapter, FindDevice(uniq_id)).WillOnce(Return(mockdev)); + transport_adapter.ConnectionCreated(connection, uniq_id, 0); + transport_adapter.ConnectPending(uniq_id, 0); + + std::vector dev_list = transport_adapter.GetDeviceList(); + ASSERT_EQ(1u, dev_list.size()); + EXPECT_EQ(uniq_id, dev_list[0]); + EXPECT_EQ(ConnectionStatus::PENDING, mockdev->connection_status()); + + ConnectionSPtr mock_connection = + transport_adapter.FindPendingConnection(uniq_id, 0); + ASSERT_TRUE(mock_connection.use_count() != 0); + + ConnectionSPtr mock_connection_fake = + transport_adapter.FindPendingConnection(uniq_id, 1); + ASSERT_TRUE(mock_connection_fake.use_count() == 0); +} + +TEST_F(TransportAdapterTest, + Pending_Connect_Disconnect_ConnectDoneSuccess_PendingDeviceAdded) { + MockServerConnectionFactory* serverMock = new MockServerConnectionFactory(); + MockTransportAdapterImpl transport_adapter( + NULL, serverMock, NULL, last_state_, transport_manager_settings); + SetDefaultExpectations(transport_adapter); + + EXPECT_CALL(*serverMock, Init()).WillOnce(Return(TransportAdapter::OK)); + EXPECT_CALL(transport_adapter, Restore()).WillOnce(Return(true)); + transport_adapter.Init(); + + MockTransportAdapterListener mock_listener; + transport_adapter.AddListener(&mock_listener); + + std::shared_ptr mockdev = + std::make_shared(dev_id, uniq_id); + DeviceVector devices{mockdev}; + transport_adapter.SearchDeviceDone(devices); + + // Create cloud app device with connection in pending state + std::shared_ptr connection = + std::make_shared(); + EXPECT_CALL(transport_adapter, FindDevice(uniq_id)).WillOnce(Return(mockdev)); + transport_adapter.ConnectionCreated(connection, uniq_id, 0); + transport_adapter.ConnectPending(uniq_id, 0); + + std::vector dev_list = transport_adapter.GetDeviceList(); + ASSERT_EQ(1u, dev_list.size()); + EXPECT_EQ(uniq_id, dev_list[0]); + EXPECT_EQ(ConnectionStatus::PENDING, mockdev->connection_status()); + + // Connect cloud app + int app_handle = 0; + std::vector int_list = {app_handle}; + EXPECT_CALL(*mockdev, GetApplicationList()).WillOnce(Return(int_list)); + + EXPECT_CALL(*serverMock, IsInitialised()).WillOnce(Return(true)); + EXPECT_CALL(*serverMock, CreateConnection(uniq_id, app_handle)) + .WillOnce(Return(TransportAdapter::OK)); + EXPECT_CALL(transport_adapter, FindDevice(uniq_id)).WillOnce(Return(mockdev)); + + TransportAdapter::Error res = transport_adapter.ConnectDevice(uniq_id); + + EXPECT_EQ(TransportAdapter::OK, res); + EXPECT_EQ(ConnectionStatus::CONNECTED, mockdev->connection_status()); + + auto mock_connection = std::make_shared(); + transport_adapter.ConnectionCreated(mock_connection, dev_id, app_handle); + + EXPECT_CALL(transport_adapter, Store()); + transport_adapter.ConnectDone(dev_id, app_handle); + + // Disconnect cloud app + EXPECT_CALL(*mock_connection, Disconnect()) + .WillOnce(Return(TransportAdapter::OK)); + TransportAdapter::Error new_res = + transport_adapter.Disconnect(dev_id, app_handle); + EXPECT_EQ(TransportAdapter::OK, new_res); + + EXPECT_CALL(transport_adapter, FindDevice(uniq_id)).WillOnce(Return(mockdev)); + EXPECT_CALL(transport_adapter, GetDeviceType()) + .WillOnce(Return(DeviceType::CLOUD_WEBSOCKET)); + EXPECT_CALL(mock_listener, + OnDisconnectDeviceDone(&transport_adapter, uniq_id)); + EXPECT_CALL(mock_listener, OnDeviceListUpdated(&transport_adapter)).Times(2); + EXPECT_CALL(transport_adapter, Store()); + transport_adapter.DisconnectDone(uniq_id, 0); + + dev_list = transport_adapter.GetDeviceList(); + ASSERT_EQ(0u, dev_list.size()); + + // Recreate device and put cloud app back into pending state + std::shared_ptr mockdev2 = + std::make_shared(dev_id, uniq_id); + DeviceVector devices2{mockdev2}; + transport_adapter.SearchDeviceDone(devices2); + + std::shared_ptr connection2 = + std::make_shared(); + EXPECT_CALL(transport_adapter, FindDevice(uniq_id)) + .WillOnce(Return(mockdev2)); + transport_adapter.ConnectionCreated(connection2, uniq_id, 0); + transport_adapter.ConnectPending(uniq_id, 0); + + dev_list = transport_adapter.GetDeviceList(); + ASSERT_EQ(1u, dev_list.size()); + EXPECT_EQ(uniq_id, dev_list[0]); + EXPECT_EQ(ConnectionStatus::PENDING, mockdev2->connection_status()); + + EXPECT_CALL(*serverMock, Terminate()); +} + TEST_F(TransportAdapterTest, DisconnectDevice_DeviceAddedConnectionCreated) { MockServerConnectionFactory* serverMock = new MockServerConnectionFactory(); MockTransportAdapterImpl transport_adapter( diff --git a/src/components/transport_manager/test/transport_manager_impl_test.cc b/src/components/transport_manager/test/transport_manager_impl_test.cc index 5f13adcd44..dbf0899a1b 100644 --- a/src/components/transport_manager/test/transport_manager_impl_test.cc +++ b/src/components/transport_manager/test/transport_manager_impl_test.cc @@ -190,6 +190,24 @@ class TransportManagerImplTest : public ::testing::Test { tm_.TestHandle(test_event); } + void HandlePending() { + TransportAdapterEvent test_event(EventTypeEnum::ON_CONNECT_PENDING, + mock_adapter_, + dev_info_.mac_address(), + application_id_, + test_message_, + error_); + + EXPECT_CALL(*mock_adapter_, DeviceName(dev_info_.mac_address())) + .WillOnce(Return(dev_info_.name())); + EXPECT_CALL(*mock_adapter_, GetConnectionType()) + .WillRepeatedly(Return(dev_info_.connection_type())); + + EXPECT_CALL(*tm_listener_, OnConnectionPending(dev_info_, connection_key_)); + + tm_.TestHandle(test_event); + } + void HandleConnectionFailed() { TransportAdapterEvent test_event(EventTypeEnum::ON_CONNECT_FAIL, mock_adapter_, @@ -405,6 +423,32 @@ TEST_F(TransportManagerImplTest, DisconnectDevice_DeviceNotConnected) { EXPECT_EQ(E_INVALID_HANDLE, tm_.DisconnectDevice(device_handle_)); } +TEST_F(TransportManagerImplTest, Pending) { + // Calling HandlePending twice verifies the connection_id stays the same if + // the connection exists. + HandlePending(); + HandlePending(); + + // Now create pending event for new app id and verify connection_id is + // incremented + TransportAdapterEvent test_event(EventTypeEnum::ON_CONNECT_PENDING, + mock_adapter_, + dev_info_.mac_address(), + application_id_ + 1, + test_message_, + error_); + + EXPECT_CALL(*mock_adapter_, DeviceName(dev_info_.mac_address())) + .WillOnce(Return(dev_info_.name())); + EXPECT_CALL(*mock_adapter_, GetConnectionType()) + .WillRepeatedly(Return(dev_info_.connection_type())); + + EXPECT_CALL(*tm_listener_, + OnConnectionPending(dev_info_, connection_key_ + 1)); + + tm_.TestHandle(test_event); +} + TEST_F(TransportManagerImplTest, Disconnect) { // Arrange HandleConnection(); -- cgit v1.2.1 From b84c348facd194ec0f94348af1621534549320b0 Mon Sep 17 00:00:00 2001 From: jacobkeeler Date: Thu, 14 Mar 2019 11:11:44 -0400 Subject: Add mock app service manager --- .../application_manager/app_service_manager.h | 22 ++--- .../application_manager/application_manager_impl.h | 4 +- .../src/app_service_app_extension.cc | 8 +- .../hmi/as_get_app_service_records_request.cc | 2 +- ...on_bc_system_capability_updated_notification.cc | 2 +- .../mobile/get_system_capability_request.cc | 2 +- .../on_system_capability_updated_notification.cc | 2 +- .../application_manager/src/app_service_manager.cc | 32 ++++---- .../test/application_manager_impl_test.cc | 12 ++- .../application_manager/mock_app_service_manager.h | 95 ++++++++++++++++++++++ 10 files changed, 142 insertions(+), 39 deletions(-) create mode 100644 src/components/application_manager/test/include/application_manager/mock_app_service_manager.h diff --git a/src/components/application_manager/include/application_manager/app_service_manager.h b/src/components/application_manager/include/application_manager/app_service_manager.h index f7c46178c5..7f8d305edd 100644 --- a/src/components/application_manager/include/application_manager/app_service_manager.h +++ b/src/components/application_manager/include/application_manager/app_service_manager.h @@ -123,28 +123,28 @@ class AppServiceManager { * @brief TODO * @param manifest */ - std::vector GetAllServices(); + std::vector GetAllServiceRecords(); std::vector > GetActiveServices(); void GetProviderByType(const std::string& service_type, - bool mobile_consumer, + const bool mobile_consumer, ApplicationSharedPtr& app, bool& hmi_service); void GetProviderByID(const std::string& service_id, - bool mobile_consumer, + const bool mobile_consumer, ApplicationSharedPtr& app, bool& hmi_service); - AppService* ActiveServiceByType(std::string service_type); + AppService* ActiveServiceForType(const std::string service_type); - AppService* EmbeddedServiceForType(std::string service_type); + AppService* EmbeddedServiceForType(const std::string service_type); - AppService* FindServiceByName(std::string name); + AppService* FindServiceByName(const std::string name); - AppService* FindServiceByID(std::string service_id); + AppService* FindServiceByID(const std::string service_id); - std::string DefaultServiceByType(std::string service_type); + std::string DefaultServiceByType(const std::string service_type); /** * @brief TODO @@ -175,11 +175,11 @@ class AppServiceManager { const mobile_apis::ServiceUpdateReason::eType update_reason, smart_objects::SmartObject& msg_params); void GetProviderFromService(const AppService& service, - bool mobile_consumer, + const bool mobile_consumer, ApplicationSharedPtr& app, bool& hmi_service); - AppService* FindServiceByPolicyAppID(std::string policy_app_id, - std::string type); + AppService* FindServiceByPolicyAppID(const std::string policy_app_id, + const std::string type); std::string GetPolicyAppID(AppService service); }; diff --git a/src/components/application_manager/include/application_manager/application_manager_impl.h b/src/components/application_manager/include/application_manager/application_manager_impl.h index 007b3433f0..2d2eff7bd3 100644 --- a/src/components/application_manager/include/application_manager/application_manager_impl.h +++ b/src/components/application_manager/include/application_manager/application_manager_impl.h @@ -1587,8 +1587,8 @@ class ApplicationManagerImpl } virtual void SetAppServiceManager( - std::unique_ptr& app_service_manager) { - app_service_manager_.reset(app_service_manager.release()); + AppServiceManager* app_service_manager) { + app_service_manager_.reset(app_service_manager); } private: diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/app_service_app_extension.cc b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/app_service_app_extension.cc index 63812056f1..6d8b0c08cc 100644 --- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/app_service_app_extension.cc +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/app_service_app_extension.cc @@ -1,5 +1,5 @@ /* - Copyright (c) 2018, Ford Motor Company + Copyright (c) 2019, Ford Motor Company, Livio All rights reserved. Redistribution and use in source and binary forms, with or without @@ -13,9 +13,9 @@ 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. + Neither the name of the the copyright holders nor the names of their + 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 diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_get_app_service_records_request.cc b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_get_app_service_records_request.cc index 1131448d2f..6123843704 100644 --- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_get_app_service_records_request.cc +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_get_app_service_records_request.cc @@ -61,7 +61,7 @@ void ASGetAppServiceRecordsRequest::Run() { smart_objects::SmartObject records = smart_objects::SmartObject(smart_objects::SmartType_Array); std::vector service_records = - application_manager_.GetAppServiceManager().GetAllServices(); + application_manager_.GetAppServiceManager().GetAllServiceRecords(); int index = 0; for (auto& record : service_records) { diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_bc_system_capability_updated_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_bc_system_capability_updated_notification.cc index 73ec1137a8..494651379f 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_bc_system_capability_updated_notification.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_bc_system_capability_updated_notification.cc @@ -120,7 +120,7 @@ void OnBCSystemCapabilityUpdatedNotification::Run() { break; case hmi_apis::Common_SystemCapabilityType::APP_SERVICES: { auto all_services = - application_manager_.GetAppServiceManager().GetAllServices(); + application_manager_.GetAppServiceManager().GetAllServiceRecords(); auto app_service_caps = MessageHelper::CreateAppServiceCapabilities(all_services); 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 63a4416139..a90c51f48a 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 @@ -143,7 +143,7 @@ void GetSystemCapabilityRequest::Run() { break; case mobile_apis::SystemCapabilityType::APP_SERVICES: { auto all_services = - application_manager_.GetAppServiceManager().GetAllServices(); + application_manager_.GetAppServiceManager().GetAllServiceRecords(); response_params [strings::system_capability][strings::app_services_capabilities] = MessageHelper::CreateAppServiceCapabilities(all_services); diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_system_capability_updated_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_system_capability_updated_notification.cc index b5e3a73ee4..6ab560f56c 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_system_capability_updated_notification.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_system_capability_updated_notification.cc @@ -86,7 +86,7 @@ void OnSystemCapabilityUpdatedNotification::Run() { break; case mobile_apis::SystemCapabilityType::APP_SERVICES: { auto all_services = - application_manager_.GetAppServiceManager().GetAllServices(); + application_manager_.GetAppServiceManager().GetAllServiceRecords(); auto app_service_caps = MessageHelper::CreateAppServiceCapabilities(all_services); diff --git a/src/components/application_manager/src/app_service_manager.cc b/src/components/application_manager/src/app_service_manager.cc index d148e4ef61..c2f647f567 100644 --- a/src/components/application_manager/src/app_service_manager.cc +++ b/src/components/application_manager/src/app_service_manager.cc @@ -120,7 +120,7 @@ smart_objects::SmartObject AppServiceManager::PublishAppService( // Activate the new service if it is the default for its service type, or if // no service is active of its service type - AppService* active_service = ActiveServiceByType(service_type); + AppService* active_service = ActiveServiceForType(service_type); if (!active_service || app_service.default_service) { ActivateAppService(service_id); } @@ -189,7 +189,7 @@ void AppServiceManager::OnAppActivated(ApplicationConstSharedPtr app) { } } -std::vector AppServiceManager::GetAllServices() { +std::vector AppServiceManager::GetAllServiceRecords() { LOG4CXX_AUTO_TRACE(logger_); std::vector services; sync_primitives::AutoLock lock(published_services_lock_); @@ -201,11 +201,11 @@ std::vector AppServiceManager::GetAllServices() { } void AppServiceManager::GetProviderByType(const std::string& service_type, - bool mobile_consumer, + const bool mobile_consumer, ApplicationSharedPtr& app, bool& hmi_service) { LOG4CXX_AUTO_TRACE(logger_); - auto active_service = ActiveServiceByType(service_type); + auto active_service = ActiveServiceForType(service_type); if (!active_service) { LOG4CXX_ERROR(logger_, "There is no active service for the given service type: " @@ -218,7 +218,7 @@ void AppServiceManager::GetProviderByType(const std::string& service_type, } void AppServiceManager::GetProviderByID(const std::string& service_id, - bool mobile_consumer, + const bool mobile_consumer, ApplicationSharedPtr& app, bool& hmi_service) { LOG4CXX_AUTO_TRACE(logger_); @@ -234,7 +234,7 @@ void AppServiceManager::GetProviderByID(const std::string& service_id, } void AppServiceManager::GetProviderFromService(const AppService& service, - bool mobile_consumer, + const bool mobile_consumer, ApplicationSharedPtr& app, bool& hmi_service) { LOG4CXX_AUTO_TRACE(logger_); @@ -327,7 +327,7 @@ bool AppServiceManager::ActivateAppService(const std::string service_id) { const std::string service_type = service[strings::service_manifest][strings::service_type].asString(); - auto active_service = ActiveServiceByType(service_type); + auto active_service = ActiveServiceForType(service_type); if (active_service) { active_service->record[strings::service_active] = false; AppServiceUpdated(active_service->record, @@ -391,7 +391,8 @@ bool AppServiceManager::DeactivateAppService(const std::string service_id) { return true; } -AppService* AppServiceManager::ActiveServiceByType(std::string service_type) { +AppService* AppServiceManager::ActiveServiceForType( + const std::string service_type) { LOG4CXX_AUTO_TRACE(logger_); sync_primitives::AutoLock lock(published_services_lock_); for (auto it = published_services_.begin(); it != published_services_.end(); @@ -407,7 +408,7 @@ AppService* AppServiceManager::ActiveServiceByType(std::string service_type) { } AppService* AppServiceManager::EmbeddedServiceForType( - std::string service_type) { + const std::string service_type) { LOG4CXX_AUTO_TRACE(logger_); sync_primitives::AutoLock lock(published_services_lock_); for (auto it = published_services_.begin(); it != published_services_.end(); @@ -421,7 +422,7 @@ AppService* AppServiceManager::EmbeddedServiceForType( return NULL; } -AppService* AppServiceManager::FindServiceByName(std::string name) { +AppService* AppServiceManager::FindServiceByName(const std::string name) { LOG4CXX_AUTO_TRACE(logger_); sync_primitives::AutoLock lock(published_services_lock_); for (auto it = published_services_.begin(); it != published_services_.end(); @@ -435,7 +436,7 @@ AppService* AppServiceManager::FindServiceByName(std::string name) { } AppService* AppServiceManager::FindServiceByPolicyAppID( - std::string policy_app_id, std::string type) { + const std::string policy_app_id, const std::string type) { LOG4CXX_AUTO_TRACE(logger_); sync_primitives::AutoLock lock(published_services_lock_); for (auto it = published_services_.begin(); it != published_services_.end(); @@ -452,7 +453,7 @@ AppService* AppServiceManager::FindServiceByPolicyAppID( return NULL; } -AppService* AppServiceManager::FindServiceByID(std::string service_id) { +AppService* AppServiceManager::FindServiceByID(const std::string service_id) { LOG4CXX_AUTO_TRACE(logger_); sync_primitives::AutoLock lock(published_services_lock_); @@ -464,7 +465,8 @@ AppService* AppServiceManager::FindServiceByID(std::string service_id) { return &(it->second); } -std::string AppServiceManager::DefaultServiceByType(std::string service_type) { +std::string AppServiceManager::DefaultServiceByType( + const std::string service_type) { LOG4CXX_AUTO_TRACE(logger_); Json::Value& dictionary = last_state_.get_dictionary(); if (dictionary[kAppServiceSection][kDefaults].isMember(service_type)) { @@ -474,7 +476,7 @@ std::string AppServiceManager::DefaultServiceByType(std::string service_type) { } void AppServiceManager::SetServicePublished(const std::string service_id, - bool service_published) { + const bool service_published) { LOG4CXX_AUTO_TRACE(logger_); sync_primitives::AutoLock lock(published_services_lock_); auto it = published_services_.find(service_id); @@ -500,7 +502,7 @@ bool AppServiceManager::UpdateNavigationCapabilities( ns_smart_device_link::ns_smart_objects:: EnumConversionHelper::EnumToString( mobile_apis::AppServiceType::NAVIGATION, &navi_service_type); - auto service = ActiveServiceByType(navi_service_type); + auto service = ActiveServiceForType(navi_service_type); if (!service) { return false; } diff --git a/src/components/application_manager/test/application_manager_impl_test.cc b/src/components/application_manager/test/application_manager_impl_test.cc index f27e252142..e88d10d3e0 100644 --- a/src/components/application_manager/test/application_manager_impl_test.cc +++ b/src/components/application_manager/test/application_manager_impl_test.cc @@ -42,6 +42,7 @@ #include "application_manager/mock_application.h" #include "application_manager/mock_application_manager_settings.h" #include "application_manager/mock_resumption_data.h" +#include "application_manager/mock_app_service_manager.h" #include "application_manager/mock_rpc_plugin_manager.h" #include "application_manager/mock_rpc_service.h" #include "application_manager/resumption/resume_ctrl_impl.h" @@ -115,6 +116,8 @@ class ApplicationManagerImplTest : public ::testing::Test { std::make_shared >( mock_app_mngr_)) , mock_rpc_service_(new MockRPCService) + , mock_app_service_manager_( + new MockAppServiceManager(mock_app_mngr_, mock_last_state_)) , mock_message_helper_( application_manager::MockMessageHelper::message_helper_mock()) @@ -139,11 +142,13 @@ class ApplicationManagerImplTest : public ::testing::Test { app_manager_impl_->resume_controller().set_resumption_storage( mock_storage_); app_manager_impl_->set_connection_handler(&mock_connection_handler_); + ON_CALL(*mock_app_service_manager_, UnpublishServices(_)) + .WillByDefault(Return()); + ON_CALL(*mock_app_service_manager_, OnAppActivated(_)) + .WillByDefault(Return()); + app_manager_impl_->SetAppServiceManager(mock_app_service_manager_); Json::Value empty; ON_CALL(mock_last_state_, get_dictionary()).WillByDefault(ReturnRef(empty)); - std::unique_ptr app_service_manager_ptr( - new AppServiceManager(*app_manager_impl_, mock_last_state_)); - app_manager_impl_->SetAppServiceManager(app_service_manager_ptr); } void CreateAppManager() { @@ -221,6 +226,7 @@ class ApplicationManagerImplTest : public ::testing::Test { NiceMock mock_application_manager_settings_; application_manager_test::MockApplicationManager mock_app_mngr_; std::unique_ptr app_manager_impl_; + MockAppServiceManager* mock_app_service_manager_; application_manager::MockMessageHelper* mock_message_helper_; std::shared_ptr mock_app_ptr_; diff --git a/src/components/application_manager/test/include/application_manager/mock_app_service_manager.h b/src/components/application_manager/test/include/application_manager/mock_app_service_manager.h new file mode 100644 index 0000000000..030c130cbc --- /dev/null +++ b/src/components/application_manager/test/include/application_manager/mock_app_service_manager.h @@ -0,0 +1,95 @@ +/* + Copyright (c) 2019, Ford Motor Company, Livio + 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 the copyright holders nor the names of their + 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. + */ + +#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_TEST_INCLUDE_APPLICATION_MANAGER_MOCK_APP_SERVICE_MANAGER_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_TEST_INCLUDE_APPLICATION_MANAGER_MOCK_APP_SERVICE_MANAGER_H_ + +#include +#include "application_manager/app_service_manager.h" + +namespace test { +namespace components { +namespace application_manager_test { + +class MockAppServiceManager : public application_manager::AppServiceManager { + public: + MockAppServiceManager(application_manager::ApplicationManager& app_manager, + resumption::LastState& last_state) + : application_manager::AppServiceManager(app_manager, last_state) {} + MOCK_METHOD3(PublishAppService, smart_objects::SmartObject( + const smart_objects::SmartObject& manifest, + const bool mobile_service, + const uint32_t connection_key)); + MOCK_METHOD1(UnpublishAppService, bool(const std::string service_id)); + MOCK_METHOD1(UnpublishServices, void(const uint32_t connection_key)); + MOCK_METHOD1(OnAppActivated, + void(application_manager::ApplicationConstSharedPtr app)); + MOCK_METHOD1(SetDefaultService, bool(const std::string service_id)); + MOCK_METHOD1(RemoveDefaultService, bool(const std::string service_id)); + MOCK_METHOD1(ActivateAppService, bool(const std::string service_id)); + MOCK_METHOD1(DeactivateAppService, bool(const std::string service_id)); + MOCK_METHOD0(GetAllServiceRecords, std::vector()); + MOCK_METHOD0( + GetActiveServices, + std::vector >()); + MOCK_METHOD4(GetProviderByType, + void(const std::string& service_type, + const bool mobile_consumer, + application_manager::ApplicationSharedPtr& app, + bool& hmi_service)); + MOCK_METHOD4(GetProviderByID, + void(const std::string& service_id, + const bool mobile_consumer, + application_manager::ApplicationSharedPtr& app, + bool& hmi_service)); + MOCK_METHOD1( + ActiveServiceForType, + application_manager::AppService*(const std::string service_type)); + MOCK_METHOD1( + EmbeddedServiceForType, + application_manager::AppService*(const std::string service_type)); + MOCK_METHOD1(FindServiceByID, + application_manager::AppService*(const std::string service_id)); + MOCK_METHOD1(DefaultServiceByType, + std::string(const std::string service_type)); + MOCK_METHOD2(SetServicePublished, + void(const std::string service_id, + const bool service_published)); + MOCK_METHOD1(UpdateNavigationCapabilities, + bool(smart_objects::SmartObject& out_params)); +}; + +} // namespace application_manager_test +} // namespace components +} // namespace test + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_TEST_INCLUDE_APPLICATION_MANAGER_MOCK_APP_SERVICE_MANAGER_H_ -- cgit v1.2.1 From 2209cb392b84215398a929f0f4be5cb7d470684d Mon Sep 17 00:00:00 2001 From: JackLivio Date: Thu, 14 Mar 2019 17:00:52 -0400 Subject: OnAppServiceDataTests --- .../application_manager/app_service_manager.h | 2 +- .../application_manager/application_manager_impl.h | 3 +- .../application_manager/commands/command_impl.h | 1 + .../application_manager/rpc_passing_handler.h | 1 + .../app_service_rpc_plugin/CMakeLists.txt | 2 +- .../app_service_rpc_plugin/test/CMakeLists.txt | 72 +++++++ .../on_app_service_data_notification_test.cc | 217 +++++++++++++++++++++ .../application_manager/src/app_service_manager.cc | 3 +- .../application_manager/mock_app_service_manager.h | 11 +- 9 files changed, 303 insertions(+), 9 deletions(-) create mode 100644 src/components/application_manager/rpc_plugins/app_service_rpc_plugin/test/CMakeLists.txt create mode 100644 src/components/application_manager/rpc_plugins/app_service_rpc_plugin/test/commands/mobile/on_app_service_data_notification_test.cc diff --git a/src/components/application_manager/include/application_manager/app_service_manager.h b/src/components/application_manager/include/application_manager/app_service_manager.h index 7f8d305edd..973c5054b4 100644 --- a/src/components/application_manager/include/application_manager/app_service_manager.h +++ b/src/components/application_manager/include/application_manager/app_service_manager.h @@ -142,7 +142,7 @@ class AppServiceManager { AppService* FindServiceByName(const std::string name); - AppService* FindServiceByID(const std::string service_id); + virtual AppService* FindServiceByID(const std::string service_id); std::string DefaultServiceByType(const std::string service_type); diff --git a/src/components/application_manager/include/application_manager/application_manager_impl.h b/src/components/application_manager/include/application_manager/application_manager_impl.h index 2d2eff7bd3..f20ed982e9 100644 --- a/src/components/application_manager/include/application_manager/application_manager_impl.h +++ b/src/components/application_manager/include/application_manager/application_manager_impl.h @@ -1586,8 +1586,7 @@ class ApplicationManagerImpl plugin_manager_.reset(plugin_manager.release()); } - virtual void SetAppServiceManager( - AppServiceManager* app_service_manager) { + virtual void SetAppServiceManager(AppServiceManager* app_service_manager) { app_service_manager_.reset(app_service_manager); } diff --git a/src/components/application_manager/include/application_manager/commands/command_impl.h b/src/components/application_manager/include/application_manager/commands/command_impl.h index 4859f73a55..dd1592c4aa 100644 --- a/src/components/application_manager/include/application_manager/commands/command_impl.h +++ b/src/components/application_manager/include/application_manager/commands/command_impl.h @@ -37,6 +37,7 @@ #include "application_manager/event_engine/event_observer.h" #include "application_manager/application_manager.h" #include "application_manager/smart_object_keys.h" +#include "policy/policy_types.h" #include "utils/logger.h" namespace application_manager { diff --git a/src/components/application_manager/include/application_manager/rpc_passing_handler.h b/src/components/application_manager/include/application_manager/rpc_passing_handler.h index 3ed10ff1e6..ce41b5a597 100644 --- a/src/components/application_manager/include/application_manager/rpc_passing_handler.h +++ b/src/components/application_manager/include/application_manager/rpc_passing_handler.h @@ -39,6 +39,7 @@ #include "application_manager/app_service_manager.h" #include #include "utils/timer.h" +#include "application_manager/commands/command.h" namespace application_manager { diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/CMakeLists.txt b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/CMakeLists.txt index 2bdc150906..1e23aac8ee 100644 --- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/CMakeLists.txt +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/CMakeLists.txt @@ -80,5 +80,5 @@ install(TARGETS app_service_rpc_plugin ) if(BUILD_TESTS) - # add_subdirectory(test) + add_subdirectory(test) endif() diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/test/CMakeLists.txt b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/test/CMakeLists.txt new file mode 100644 index 0000000000..02fb4fe4ec --- /dev/null +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/test/CMakeLists.txt @@ -0,0 +1,72 @@ +# Copyright (c) 2019, Livio +# 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 copyright holders nor the names of their 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(${CMAKE_SOURCE_DIR}/tools/cmake/helpers/sources.cmake) + +include_directories ( + ${GMOCK_INCLUDE_DIRECTORY} + ${CMAKE_CURRENT_SOURCE_DIR}/include + ${COMPONENTS_DIR}/application_manager/test/include + ${COMPONENTS_DIR}/include/test/application_manager/ + ${COMPONENTS_DIR}/resumption/include + ) + +set(APP_SERVICE_COMMANDS_TEST_DIR ${CMAKE_CURRENT_SOURCE_DIR}/commands) + +file(GLOB SOURCES + ${COMPONENTS_DIR}/application_manager/test/mock_message_helper.cc + ${APP_SERVICE_COMMANDS_TEST_DIR}/* + ${APP_SERVICE_COMMANDS_TEST_DIR}/mobile/* +) + +set(LIBRARIES + AppServiceRpcPluginStaticLib + ApplicationManager + connectionHandler + SmartObjects + ProtocolHandler + MessageHelper + connectionHandler + Utils + jsoncpp + gmock_main + dl + Resumption +) + +if(ENABLE_LOG) + list(APPEND LIBRARIES log4cxx -L${LOG4CXX_LIBS_DIRECTORY}) + list(APPEND LIBRARIES apr-1 -L${APR_LIBS_DIRECTORY}) + list(APPEND LIBRARIES aprutil-1 -L${APR_UTIL_LIBS_DIRECTORY}) + list(APPEND LIBRARIES expat -L${EXPAT_LIBS_DIRECTORY}) +endif() + +create_test("app_service_commands_test" "${SOURCES}" "${LIBRARIES}" ) + diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/test/commands/mobile/on_app_service_data_notification_test.cc b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/test/commands/mobile/on_app_service_data_notification_test.cc new file mode 100644 index 0000000000..d501ea08ea --- /dev/null +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/test/commands/mobile/on_app_service_data_notification_test.cc @@ -0,0 +1,217 @@ +/* + * Copyright (c) 2018, 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 "application_manager/application.h" +#include "application_manager/mock_application.h" +#include "application_manager/mock_app_service_manager.h" +#include "application_manager/commands/commands_test.h" +#include "app_service_rpc_plugin/commands/mobile/on_app_service_data_notification.h" +#include "app_service_rpc_plugin/app_service_rpc_plugin.h" +#include "app_service_rpc_plugin/app_service_app_extension.h" +#include "gtest/gtest.h" +#include "interfaces/MOBILE_API.h" +#include "application_manager/commands/command_impl.h" +#include "resumption/last_state_impl.h" + +namespace am = application_manager; +using ::testing::_; +using ::testing::Return; +using ::testing::ReturnRef; +using ::testing::ReturnNull; +using ::testing::NiceMock; +using ::testing::SaveArg; +using ::testing::Mock; +using am::ApplicationSet; +using am::commands::MessageSharedPtr; +using test::components::application_manager_test::MockApplication; +using test::components::application_manager_test::MockApplicationManager; +using test::components::application_manager_test::MockAppServiceManager; +using test::components::commands_test::CommandsTest; +using test::components::commands_test::CommandsTestMocks; +using app_service_rpc_plugin::commands::OnAppServiceDataNotification; + +namespace { +const uint32_t kAppId = 0u; +const uint32_t kConnectionKey = 1u; +const std::string kPolicyAppId = "Test"; +const int kModuleId = 153u; +} + +namespace app_service_plugin_test { +using namespace app_service_rpc_plugin; +using application_manager::ApplicationSet; + +class OnAppServiceDatanotificationTest + : public CommandsTest { + public: + OnAppServiceDatanotificationTest() + : mock_app_(std::make_shared >()) + , app_service_app_extension_( + std::make_shared( + app_service_plugin_, *mock_app_)) + , apps_lock_(std::make_shared()) + , apps_da_(apps_, apps_lock_) + , last_state_("app_storage_folder", "app_info_storage") + , app_service_manager_(app_mngr_, last_state_) { + ON_CALL(*mock_app_, app_id()).WillByDefault(Return(kAppId)); + ON_CALL(*mock_app_, is_remote_control_supported()) + .WillByDefault(Return(true)); + ON_CALL(*mock_app_, QueryInterface(_)) + .WillByDefault(Return(app_service_app_extension_)); + } + + MessageSharedPtr CreateBasicMessage() { + MessageSharedPtr message = CreateMessage(); + (*message)[application_manager::strings::params] + [application_manager::strings::function_id] = + mobile_apis::FunctionID::OnAppServiceDataID; + (*message)[application_manager::strings::params] + [application_manager::strings::connection_key] = kConnectionKey; + (*message)[application_manager::strings::params] + [application_manager::strings::app_id] = kAppId; + + return message; + } + + protected: + std::shared_ptr mock_app_; + std::shared_ptr app_service_app_extension_; + app_service_rpc_plugin::AppServiceRpcPlugin app_service_plugin_; + application_manager::ApplicationSet apps_; + const std::shared_ptr apps_lock_; + DataAccessor apps_da_; + resumption::LastStateImpl last_state_; + MockAppServiceManager app_service_manager_; +}; + +TEST_F(OnAppServiceDatanotificationTest, Run_SendMessageToMobile_Notification) { + MessageSharedPtr mobile_message = CreateBasicMessage(); + + (*mobile_message)[am::strings::msg_params][am::strings::service_data] + [am::strings::service_type] = "MEDIA"; + (*mobile_message)[am::strings::msg_params][am::strings::service_data] + [am::strings::service_id] = "mediaid1234"; + (*mobile_message)[am::strings::msg_params][am::strings::service_data] + ["mediaServiceData"]["mediaTitle"] = "media title"; + + apps_.insert(mock_app_); + app_service_app_extension_->SubscribeToAppService("MEDIA"); + ON_CALL(app_mngr_, applications()).WillByDefault(Return(apps_da_)); + + am::AppService service; + service.connection_key = 1; + service.mobile_service = true; + service + .record[am::strings::service_manifest][am::strings::allow_app_consumers] = + true; + EXPECT_CALL(app_service_manager_, FindServiceByID(_)) + .WillOnce(Return(&service)); + + EXPECT_CALL(app_mngr_, GetAppServiceManager()) + .WillRepeatedly(ReturnRef(app_service_manager_)); + + std::shared_ptr command = + CreateCommand(mobile_message); + + EXPECT_CALL(mock_rpc_service_, SendMessageToMobile(_, false)) + .WillOnce(SaveArg<0>(&mobile_message)); + // Act + command->Run(); + + // Assertions + ASSERT_TRUE(mobile_message.get()); + Mock::VerifyAndClearExpectations(&app_mngr_); +} + +TEST_F(OnAppServiceDatanotificationTest, Run_NoService) { + MessageSharedPtr mobile_message = CreateBasicMessage(); + + (*mobile_message)[am::strings::msg_params][am::strings::service_data] + [am::strings::service_type] = "MEDIA"; + (*mobile_message)[am::strings::msg_params][am::strings::service_data] + [am::strings::service_id] = "mediaid1234"; + (*mobile_message)[am::strings::msg_params][am::strings::service_data] + ["mediaServiceData"]["mediaTitle"] = "media title"; + + apps_.insert(mock_app_); + app_service_app_extension_->SubscribeToAppService("MEDIA"); + ON_CALL(app_mngr_, applications()).WillByDefault(Return(apps_da_)); + + EXPECT_CALL(app_service_manager_, FindServiceByID(_)).WillOnce(ReturnNull()); + + EXPECT_CALL(app_mngr_, GetAppServiceManager()) + .WillRepeatedly(ReturnRef(app_service_manager_)); + + std::shared_ptr command = + CreateCommand(mobile_message); + + EXPECT_CALL(mock_rpc_service_, SendMessageToMobile(_, false)).Times(0); + command->Run(); + + Mock::VerifyAndClearExpectations(&app_mngr_); +} + +TEST_F(OnAppServiceDatanotificationTest, Run_NoSubscribedApps) { + MessageSharedPtr mobile_message = CreateBasicMessage(); + + (*mobile_message)[am::strings::msg_params][am::strings::service_data] + [am::strings::service_type] = "MEDIA"; + (*mobile_message)[am::strings::msg_params][am::strings::service_data] + [am::strings::service_id] = "mediaid1234"; + (*mobile_message)[am::strings::msg_params][am::strings::service_data] + ["mediaServiceData"]["mediaTitle"] = "media title"; + + apps_.insert(mock_app_); + ON_CALL(app_mngr_, applications()).WillByDefault(Return(apps_da_)); + + am::AppService service; + service.connection_key = 1; + service.mobile_service = true; + service + .record[am::strings::service_manifest][am::strings::allow_app_consumers] = + true; + EXPECT_CALL(app_service_manager_, FindServiceByID(_)) + .WillOnce(Return(&service)); + + EXPECT_CALL(app_mngr_, GetAppServiceManager()) + .WillRepeatedly(ReturnRef(app_service_manager_)); + + std::shared_ptr command = + CreateCommand(mobile_message); + + EXPECT_CALL(mock_rpc_service_, SendMessageToMobile(_, false)).Times(0); + command->Run(); + + Mock::VerifyAndClearExpectations(&app_mngr_); +} + +} // namespace rc_rpc_plugin_test diff --git a/src/components/application_manager/src/app_service_manager.cc b/src/components/application_manager/src/app_service_manager.cc index c2f647f567..36d5307a41 100644 --- a/src/components/application_manager/src/app_service_manager.cc +++ b/src/components/application_manager/src/app_service_manager.cc @@ -189,7 +189,8 @@ void AppServiceManager::OnAppActivated(ApplicationConstSharedPtr app) { } } -std::vector AppServiceManager::GetAllServiceRecords() { +std::vector +AppServiceManager::GetAllServiceRecords() { LOG4CXX_AUTO_TRACE(logger_); std::vector services; sync_primitives::AutoLock lock(published_services_lock_); diff --git a/src/components/application_manager/test/include/application_manager/mock_app_service_manager.h b/src/components/application_manager/test/include/application_manager/mock_app_service_manager.h index 030c130cbc..cad71f98ab 100644 --- a/src/components/application_manager/test/include/application_manager/mock_app_service_manager.h +++ b/src/components/application_manager/test/include/application_manager/mock_app_service_manager.h @@ -35,6 +35,8 @@ #include #include "application_manager/app_service_manager.h" +#include "application_manager/commands/command.h" +#include "application_manager/commands/command_impl.h" namespace test { namespace components { @@ -45,10 +47,11 @@ class MockAppServiceManager : public application_manager::AppServiceManager { MockAppServiceManager(application_manager::ApplicationManager& app_manager, resumption::LastState& last_state) : application_manager::AppServiceManager(app_manager, last_state) {} - MOCK_METHOD3(PublishAppService, smart_objects::SmartObject( - const smart_objects::SmartObject& manifest, - const bool mobile_service, - const uint32_t connection_key)); + MOCK_METHOD3( + PublishAppService, + smart_objects::SmartObject(const smart_objects::SmartObject& manifest, + const bool mobile_service, + const uint32_t connection_key)); MOCK_METHOD1(UnpublishAppService, bool(const std::string service_id)); MOCK_METHOD1(UnpublishServices, void(const uint32_t connection_key)); MOCK_METHOD1(OnAppActivated, -- cgit v1.2.1 From 2ff8225f536a1595d6a409ddeb7e46c3ec9ebb95 Mon Sep 17 00:00:00 2001 From: jacobkeeler Date: Fri, 15 Mar 2019 09:40:24 -0400 Subject: Rearrange includes and make AppServiceManager methods virtual --- .../application_manager/app_service_manager.h | 59 +++++++++++----------- .../application_manager/application_manager_impl.h | 1 + .../application_manager/rpc_passing_handler.h | 4 +- .../hmi/as_app_service_activation_request.cc | 2 + .../hmi/as_get_app_service_records_request.cc | 2 + ...orm_app_service_interaction_request_from_hmi.cc | 2 + .../commands/hmi/as_publish_app_service_request.cc | 2 + .../mobile/on_app_service_data_notification.cc | 2 + .../perform_app_service_interaction_request.cc | 2 + .../commands/mobile/publish_app_service_request.cc | 2 + ...on_bc_system_capability_updated_notification.cc | 2 + .../src/commands/mobile/get_file_request.cc | 2 + .../mobile/get_system_capability_request.cc | 2 + .../on_system_capability_updated_notification.cc | 2 + .../application_manager/src/app_service_manager.cc | 3 +- .../src/commands/command_request_impl.cc | 4 +- .../src/commands/request_from_hmi.cc | 2 + .../application_manager/src/rpc_handler_impl.cc | 2 + .../application_manager/src/rpc_passing_handler.cc | 5 +- .../application_manager/src/rpc_service_impl.cc | 2 + .../application_manager/application_manager.h | 3 +- 21 files changed, 71 insertions(+), 36 deletions(-) diff --git a/src/components/application_manager/include/application_manager/app_service_manager.h b/src/components/application_manager/include/application_manager/app_service_manager.h index 7f8d305edd..47a60780bc 100644 --- a/src/components/application_manager/include/application_manager/app_service_manager.h +++ b/src/components/application_manager/include/application_manager/app_service_manager.h @@ -34,10 +34,9 @@ #define SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_APP_SERVICE_MANAGER_H_ #include "application_manager/application.h" +#include "application_manager/rpc_passing_handler.h" #include "interfaces/MOBILE_API.h" #include "smart_objects/smart_object.h" -#include "application_manager/application.h" -#include "application_manager/rpc_passing_handler.h" namespace resumption { class LastState; @@ -52,6 +51,7 @@ struct AppService { smart_objects::SmartObject record; }; +class RPCPassingHandler; class ApplicationManager; /** * @brief The AppServiceManager is TODO. @@ -70,13 +70,13 @@ class AppServiceManager { /** * @brief Class destructor */ - ~AppServiceManager(); + virtual ~AppServiceManager(); /** * @brief TODO * @param manifest */ - smart_objects::SmartObject PublishAppService( + virtual smart_objects::SmartObject PublishAppService( const smart_objects::SmartObject& manifest, const bool mobile_service, const uint32_t connection_key); @@ -85,82 +85,83 @@ class AppServiceManager { * @brief TODO * @param service_id */ - bool UnpublishAppService(const std::string service_id); + virtual bool UnpublishAppService(const std::string service_id); - void OnAppActivated(ApplicationConstSharedPtr app); + virtual void OnAppActivated(ApplicationConstSharedPtr app); /** * @brief TODO * @param connection_key */ - void UnpublishServices(const uint32_t connection_key); + virtual void UnpublishServices(const uint32_t connection_key); /** * @brief TODO * @param service_id */ - bool SetDefaultService(const std::string service_id); + virtual bool SetDefaultService(const std::string service_id); /** * @brief TODO * @param service_id */ - bool RemoveDefaultService(const std::string service_id); + virtual bool RemoveDefaultService(const std::string service_id); /** * @brief TODO * @param service_id */ - bool ActivateAppService(const std::string service_id); + virtual bool ActivateAppService(const std::string service_id); /** * @brief TODO * @param service_id */ - bool DeactivateAppService(const std::string service_id); + virtual bool DeactivateAppService(const std::string service_id); /** * @brief TODO * @param manifest */ - std::vector GetAllServiceRecords(); - std::vector > GetActiveServices(); + virtual std::vector GetAllServiceRecords(); + virtual std::vector > GetActiveServices(); - void GetProviderByType(const std::string& service_type, - const bool mobile_consumer, - ApplicationSharedPtr& app, - bool& hmi_service); + virtual void GetProviderByType(const std::string& service_type, + const bool mobile_consumer, + ApplicationSharedPtr& app, + bool& hmi_service); - void GetProviderByID(const std::string& service_id, - const bool mobile_consumer, - ApplicationSharedPtr& app, - bool& hmi_service); + virtual void GetProviderByID(const std::string& service_id, + const bool mobile_consumer, + ApplicationSharedPtr& app, + bool& hmi_service); - AppService* ActiveServiceForType(const std::string service_type); + virtual AppService* ActiveServiceForType(const std::string service_type); - AppService* EmbeddedServiceForType(const std::string service_type); + virtual AppService* EmbeddedServiceForType(const std::string service_type); AppService* FindServiceByName(const std::string name); - AppService* FindServiceByID(const std::string service_id); + virtual AppService* FindServiceByID(const std::string service_id); - std::string DefaultServiceByType(const std::string service_type); + virtual std::string DefaultServiceByType(const std::string service_type); /** * @brief TODO * @param service_id * @param service_published */ - void SetServicePublished(const std::string service_id, - bool service_published); + virtual void SetServicePublished(const std::string service_id, + bool service_published); /** * @brief TODO * @param out_params */ - bool UpdateNavigationCapabilities(smart_objects::SmartObject& out_params); + virtual bool UpdateNavigationCapabilities( + smart_objects::SmartObject& out_params); - RPCPassingHandler& GetRPCPassingHandler(); + virtual RPCPassingHandler& GetRPCPassingHandler(); private: ApplicationManager& app_manager_; diff --git a/src/components/application_manager/include/application_manager/application_manager_impl.h b/src/components/application_manager/include/application_manager/application_manager_impl.h index 2d2eff7bd3..fc40624e4d 100644 --- a/src/components/application_manager/include/application_manager/application_manager_impl.h +++ b/src/components/application_manager/include/application_manager/application_manager_impl.h @@ -42,6 +42,7 @@ #include #include "application_manager/application_manager.h" +#include "application_manager/app_service_manager.h" #include "application_manager/hmi_capabilities.h" #include "application_manager/message.h" #include "application_manager/message_helper.h" diff --git a/src/components/application_manager/include/application_manager/rpc_passing_handler.h b/src/components/application_manager/include/application_manager/rpc_passing_handler.h index 3ed10ff1e6..ab85b1374f 100644 --- a/src/components/application_manager/include/application_manager/rpc_passing_handler.h +++ b/src/components/application_manager/include/application_manager/rpc_passing_handler.h @@ -33,11 +33,11 @@ #ifndef SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_RPC_PASSING_HANDLER_H_ #define SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_RPC_PASSING_HANDLER_H_ +#include #include "application_manager/application.h" +#include "application_manager/commands/command.h" #include "interfaces/MOBILE_API.h" #include "smart_objects/smart_object.h" -#include "application_manager/app_service_manager.h" -#include #include "utils/timer.h" namespace application_manager { diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_app_service_activation_request.cc b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_app_service_activation_request.cc index 7c32d9bbe1..fd7312ca98 100644 --- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_app_service_activation_request.cc +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_app_service_activation_request.cc @@ -32,6 +32,8 @@ #include "app_service_rpc_plugin/commands/hmi/as_app_service_activation_request.h" +#include "application_manager/app_service_manager.h" + namespace app_service_rpc_plugin { using namespace application_manager; namespace commands { diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_get_app_service_records_request.cc b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_get_app_service_records_request.cc index 6123843704..fa704c1995 100644 --- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_get_app_service_records_request.cc +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_get_app_service_records_request.cc @@ -32,6 +32,8 @@ #include "app_service_rpc_plugin/commands/hmi/as_get_app_service_records_request.h" +#include "application_manager/app_service_manager.h" + namespace app_service_rpc_plugin { using namespace application_manager; namespace commands { diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_perform_app_service_interaction_request_from_hmi.cc b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_perform_app_service_interaction_request_from_hmi.cc index 2b66993d8f..70a5a10be0 100644 --- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_perform_app_service_interaction_request_from_hmi.cc +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_perform_app_service_interaction_request_from_hmi.cc @@ -31,6 +31,8 @@ */ #include "app_service_rpc_plugin/commands/hmi/as_perform_app_service_interaction_request_from_hmi.h" + +#include "application_manager/app_service_manager.h" #include "application_manager/message_helper.h" namespace app_service_rpc_plugin { diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_publish_app_service_request.cc b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_publish_app_service_request.cc index b816016fa7..c9466ff52d 100644 --- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_publish_app_service_request.cc +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_publish_app_service_request.cc @@ -31,6 +31,8 @@ */ #include "app_service_rpc_plugin/commands/hmi/as_publish_app_service_request.h" + +#include "application_manager/app_service_manager.h" #include "application_manager/message_helper.h" namespace app_service_rpc_plugin { diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/on_app_service_data_notification.cc b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/on_app_service_data_notification.cc index 2c6ba414e0..fd3891e0e8 100644 --- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/on_app_service_data_notification.cc +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/on_app_service_data_notification.cc @@ -31,7 +31,9 @@ */ #include "app_service_rpc_plugin/commands/mobile/on_app_service_data_notification.h" + #include "app_service_rpc_plugin/app_service_app_extension.h" +#include "application_manager/app_service_manager.h" #include "application_manager/application_impl.h" #include "application_manager/helpers/application_helper.h" #include "application_manager/message_helper.h" diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/perform_app_service_interaction_request.cc b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/perform_app_service_interaction_request.cc index 9e262f0ca3..989b57ca12 100644 --- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/perform_app_service_interaction_request.cc +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/perform_app_service_interaction_request.cc @@ -31,6 +31,8 @@ */ #include "app_service_rpc_plugin/commands/mobile/perform_app_service_interaction_request.h" + +#include "application_manager/app_service_manager.h" #include "application_manager/application_impl.h" #include "application_manager/message_helper.h" #include "interfaces/MOBILE_API.h" diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/publish_app_service_request.cc b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/publish_app_service_request.cc index 22d8e50c3a..171c10913e 100644 --- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/publish_app_service_request.cc +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/publish_app_service_request.cc @@ -31,6 +31,8 @@ */ #include "app_service_rpc_plugin/commands/mobile/publish_app_service_request.h" + +#include "application_manager/app_service_manager.h" #include "application_manager/application_impl.h" #include "application_manager/message_helper.h" #include "application_manager/rpc_service.h" diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_bc_system_capability_updated_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_bc_system_capability_updated_notification.cc index 494651379f..0677c97db8 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_bc_system_capability_updated_notification.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_bc_system_capability_updated_notification.cc @@ -31,6 +31,8 @@ */ #include "sdl_rpc_plugin/commands/hmi/on_bc_system_capability_updated_notification.h" + +#include "application_manager/app_service_manager.h" #include "application_manager/application_impl.h" #include "application_manager/message_helper.h" #include "application_manager/rpc_service.h" diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/get_file_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/get_file_request.cc index 2b3611fece..2c92d74b47 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/get_file_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/get_file_request.cc @@ -31,6 +31,8 @@ */ #include "sdl_rpc_plugin/commands/mobile/get_file_request.h" + +#include "application_manager/app_service_manager.h" #include "application_manager/application_impl.h" #include "application_manager/rpc_service.h" #include "interfaces/MOBILE_API.h" 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 a90c51f48a..2a25928b97 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 @@ -31,7 +31,9 @@ */ #include "sdl_rpc_plugin/commands/mobile/get_system_capability_request.h" + #include "sdl_rpc_plugin/extensions/system_capability_app_extension.h" +#include "application_manager/app_service_manager.h" #include "application_manager/message_helper.h" #include diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_system_capability_updated_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_system_capability_updated_notification.cc index 6ab560f56c..a8544ae643 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_system_capability_updated_notification.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_system_capability_updated_notification.cc @@ -1,4 +1,6 @@ #include "sdl_rpc_plugin/commands/mobile/on_system_capability_updated_notification.h" + +#include "application_manager/app_service_manager.h" #include "application_manager/application_manager.h" #include "application_manager/helpers/application_helper.h" #include "application_manager/message_helper.h" diff --git a/src/components/application_manager/src/app_service_manager.cc b/src/components/application_manager/src/app_service_manager.cc index c2f647f567..83551b1a13 100644 --- a/src/components/application_manager/src/app_service_manager.cc +++ b/src/components/application_manager/src/app_service_manager.cc @@ -30,7 +30,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#include "application_manager/help_prompt_manager_impl.h" +#include "application_manager/app_service_manager.h" #include #include @@ -39,6 +39,7 @@ #include "application_manager/application_manager.h" #include "application_manager/commands/command_impl.h" #include "application_manager/message_helper.h" +#include "application_manager/rpc_passing_handler.h" #include "application_manager/smart_object_keys.h" #include "encryption/hashing.h" #include "resumption/last_state.h" diff --git a/src/components/application_manager/src/commands/command_request_impl.cc b/src/components/application_manager/src/commands/command_request_impl.cc index 344831f882..2d875db387 100644 --- a/src/components/application_manager/src/commands/command_request_impl.cc +++ b/src/components/application_manager/src/commands/command_request_impl.cc @@ -36,9 +36,11 @@ #include "utils/macro.h" #include "application_manager/commands/command_request_impl.h" + +#include "application_manager/app_service_manager.h" #include "application_manager/application_manager.h" -#include "application_manager/rpc_service.h" #include "application_manager/message_helper.h" +#include "application_manager/rpc_service.h" #include "smart_objects/smart_object.h" #include "smart_objects/enum_schema_item.h" diff --git a/src/components/application_manager/src/commands/request_from_hmi.cc b/src/components/application_manager/src/commands/request_from_hmi.cc index 0adb389e76..5581f027c0 100644 --- a/src/components/application_manager/src/commands/request_from_hmi.cc +++ b/src/components/application_manager/src/commands/request_from_hmi.cc @@ -31,6 +31,8 @@ */ #include "application_manager/commands/request_from_hmi.h" + +#include "application_manager/app_service_manager.h" #include "application_manager/application_manager.h" #include "application_manager/request_info.h" #include "application_manager/rpc_service.h" diff --git a/src/components/application_manager/src/rpc_handler_impl.cc b/src/components/application_manager/src/rpc_handler_impl.cc index 2574da5fb5..6205e028d0 100644 --- a/src/components/application_manager/src/rpc_handler_impl.cc +++ b/src/components/application_manager/src/rpc_handler_impl.cc @@ -31,6 +31,8 @@ */ #include "application_manager/rpc_handler_impl.h" + +#include "application_manager/app_service_manager.h" #include "application_manager/plugin_manager/plugin_keys.h" namespace application_manager { diff --git a/src/components/application_manager/src/rpc_passing_handler.cc b/src/components/application_manager/src/rpc_passing_handler.cc index 8d93659a27..7ff01756f7 100644 --- a/src/components/application_manager/src/rpc_passing_handler.cc +++ b/src/components/application_manager/src/rpc_passing_handler.cc @@ -35,12 +35,13 @@ #include #include +#include "application_manager/app_service_manager.h" #include "application_manager/application.h" #include "application_manager/application_manager.h" -#include "application_manager/rpc_passing_handler.h" -#include "application_manager/rpc_handler.h" #include "application_manager/commands/command_impl.h" #include "application_manager/message_helper.h" +#include "application_manager/rpc_handler.h" +#include "application_manager/rpc_passing_handler.h" #include "application_manager/smart_object_keys.h" #include "encryption/hashing.h" #include "resumption/last_state.h" diff --git a/src/components/application_manager/src/rpc_service_impl.cc b/src/components/application_manager/src/rpc_service_impl.cc index dfb5839764..96882d472f 100644 --- a/src/components/application_manager/src/rpc_service_impl.cc +++ b/src/components/application_manager/src/rpc_service_impl.cc @@ -31,6 +31,8 @@ */ #include "application_manager/rpc_service_impl.h" + +#include "application_manager/app_service_manager.h" #include "application_manager/plugin_manager/plugin_keys.h" namespace application_manager { diff --git a/src/components/include/application_manager/application_manager.h b/src/components/include/application_manager/application_manager.h index 97140a18f1..e8f646c1e5 100644 --- a/src/components/include/application_manager/application_manager.h +++ b/src/components/include/application_manager/application_manager.h @@ -51,7 +51,7 @@ #include "application_manager/hmi_interfaces.h" #include "policy/policy_types.h" #include "application_manager/plugin_manager/rpc_plugin_manager.h" -#include "application_manager/app_service_manager.h" + namespace resumption { class LastState; } @@ -90,6 +90,7 @@ class RPCHandler; } class Application; +class AppServiceManager; class StateControllerImpl; struct CommandParametersPermissions; using policy::RPCParams; -- cgit v1.2.1 From cea6922fa666b86dcf71ec95b0f6a28ac73c97d3 Mon Sep 17 00:00:00 2001 From: jacobkeeler Date: Fri, 15 Mar 2019 11:31:58 -0400 Subject: Fix weatherIcon definition --- src/components/interfaces/HMI_API.xml | 2 +- src/components/interfaces/MOBILE_API.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/interfaces/HMI_API.xml b/src/components/interfaces/HMI_API.xml index bbb173044a..e0ca4d6d18 100644 --- a/src/components/interfaces/HMI_API.xml +++ b/src/components/interfaces/HMI_API.xml @@ -3555,7 +3555,7 @@ In km - + diff --git a/src/components/interfaces/MOBILE_API.xml b/src/components/interfaces/MOBILE_API.xml index 3b9614ab76..a0345ada29 100644 --- a/src/components/interfaces/MOBILE_API.xml +++ b/src/components/interfaces/MOBILE_API.xml @@ -3899,7 +3899,7 @@ In km - + -- cgit v1.2.1 From 592876079697e75765ef0ce95ce232d173e4a7c8 Mon Sep 17 00:00:00 2001 From: JackLivio Date: Fri, 15 Mar 2019 14:35:20 -0400 Subject: CommandRequestTest SendProviderRequest Tests --- .../application_manager/app_service_manager.h | 18 ++--- .../test/commands/CMakeLists.txt | 1 + .../test/commands/command_request_impl_test.cc | 86 ++++++++++++++++++++++ 3 files changed, 96 insertions(+), 9 deletions(-) diff --git a/src/components/application_manager/include/application_manager/app_service_manager.h b/src/components/application_manager/include/application_manager/app_service_manager.h index 973c5054b4..e8d7b6a91e 100644 --- a/src/components/application_manager/include/application_manager/app_service_manager.h +++ b/src/components/application_manager/include/application_manager/app_service_manager.h @@ -126,15 +126,15 @@ class AppServiceManager { std::vector GetAllServiceRecords(); std::vector > GetActiveServices(); - void GetProviderByType(const std::string& service_type, - const bool mobile_consumer, - ApplicationSharedPtr& app, - bool& hmi_service); - - void GetProviderByID(const std::string& service_id, - const bool mobile_consumer, - ApplicationSharedPtr& app, - bool& hmi_service); + virtual void GetProviderByType(const std::string& service_type, + const bool mobile_consumer, + ApplicationSharedPtr& app, + bool& hmi_service); + + virtual void GetProviderByID(const std::string& service_id, + const bool mobile_consumer, + ApplicationSharedPtr& app, + bool& hmi_service); AppService* ActiveServiceForType(const std::string service_type); diff --git a/src/components/application_manager/test/commands/CMakeLists.txt b/src/components/application_manager/test/commands/CMakeLists.txt index 33258e60db..556f3a5032 100644 --- a/src/components/application_manager/test/commands/CMakeLists.txt +++ b/src/components/application_manager/test/commands/CMakeLists.txt @@ -59,6 +59,7 @@ set(LIBRARIES ApplicationManager jsoncpp Policy + Resumption ) create_test("commands_test" "${SOURCES}" "${LIBRARIES}") diff --git a/src/components/application_manager/test/commands/command_request_impl_test.cc b/src/components/application_manager/test/commands/command_request_impl_test.cc index d4a62d069f..6d80a11440 100644 --- a/src/components/application_manager/test/commands/command_request_impl_test.cc +++ b/src/components/application_manager/test/commands/command_request_impl_test.cc @@ -51,6 +51,9 @@ #include "application_manager/mock_hmi_interface.h" #include "interfaces/MOBILE_API.h" +#include "application_manager/mock_app_service_manager.h" +#include "resumption/last_state_impl.h" + namespace test { namespace components { namespace commands_test { @@ -64,6 +67,7 @@ using ::testing::_; using ::testing::Return; using ::testing::SaveArg; using ::testing::DoAll; +using ::testing::SetArgReferee; using am::commands::MessageSharedPtr; using am::CommandParametersPermissions; @@ -74,6 +78,7 @@ using am::ApplicationManager; using am::ApplicationSet; using am::RPCParams; using am::MockHmiInterfaces; +using test::components::application_manager_test::MockAppServiceManager; typedef am::commands::CommandRequestImpl::RequestState RequestState; @@ -585,6 +590,87 @@ TEST_F(CommandRequestImplTest, AppNotFound_HashUpdateNotExpected) { command.reset(); } +TEST_F(CommandRequestImplTest, SendProviderRequest_ByServiceType) { + resumption::LastStateImpl last_state("app_storage_folder", + "app_info_storage"); + MockAppServiceManager app_service_manager(app_mngr_, last_state); + MockAppPtr mock_app = CreateMockApp(); + EXPECT_CALL(app_mngr_, GetAppServiceManager()) + .WillRepeatedly(ReturnRef(app_service_manager)); + EXPECT_CALL(app_service_manager, GetProviderByType("MEDIA", _, _, _)) + .WillOnce(DoAll(SetArgReferee<2>(mock_app), SetArgReferee<3>(false))); + + MessageSharedPtr result; + EXPECT_CALL(mock_rpc_service_, ManageMobileCommand(_, _)) + .WillOnce(DoAll(SaveArg<0>(&result), Return(true))); + + MessageSharedPtr msg = CreateMessage(); + (*msg)[strings::params][strings::function_id] = + mobile_apis::FunctionID::GetAppServiceDataID; + (*msg)[strings::msg_params][strings::service_type] = "MEDIA"; + + CommandPtr command = CreateCommand(msg); + command->SendProviderRequest( + mobile_apis::FunctionID::GetAppServiceDataID, + hmi_apis::FunctionID::AppService_GetAppServiceData, + &(*msg), + true); +} + +TEST_F(CommandRequestImplTest, SendProviderRequest_ByProviderID) { + resumption::LastStateImpl last_state("app_storage_folder", + "app_info_storage"); + MockAppServiceManager app_service_manager(app_mngr_, last_state); + MockAppPtr mock_app = CreateMockApp(); + EXPECT_CALL(app_mngr_, GetAppServiceManager()) + .WillRepeatedly(ReturnRef(app_service_manager)); + EXPECT_CALL(app_service_manager, GetProviderByID("serviceid12345", _, _, _)) + .WillOnce(DoAll(SetArgReferee<2>(mock_app), SetArgReferee<3>(false))); + + MessageSharedPtr result; + EXPECT_CALL(mock_rpc_service_, ManageMobileCommand(_, _)) + .WillOnce(DoAll(SaveArg<0>(&result), Return(true))); + + MessageSharedPtr msg = CreateMessage(); + (*msg)[strings::params][strings::function_id] = + mobile_apis::FunctionID::GetAppServiceDataID; + (*msg)[strings::msg_params][strings::service_id] = "serviceid12345"; + + CommandPtr command = CreateCommand(msg); + command->SendProviderRequest( + mobile_apis::FunctionID::GetAppServiceDataID, + hmi_apis::FunctionID::AppService_GetAppServiceData, + &(*msg), + true); +} + +TEST_F(CommandRequestImplTest, SendProviderRequestToHMI_ByProviderID) { + resumption::LastStateImpl last_state("app_storage_folder", + "app_info_storage"); + MockAppServiceManager app_service_manager(app_mngr_, last_state); + MockAppPtr mock_app = CreateMockApp(); + EXPECT_CALL(app_mngr_, GetAppServiceManager()) + .WillRepeatedly(ReturnRef(app_service_manager)); + EXPECT_CALL(app_service_manager, GetProviderByID("serviceid12345", _, _, _)) + .WillOnce(DoAll(SetArgReferee<2>(mock_app), SetArgReferee<3>(true))); + + MessageSharedPtr result; + EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_, _)) + .WillOnce(DoAll(SaveArg<0>(&result), Return(true))); + + MessageSharedPtr msg = CreateMessage(); + (*msg)[strings::params][strings::function_id] = + mobile_apis::FunctionID::GetAppServiceDataID; + (*msg)[strings::msg_params][strings::service_id] = "serviceid12345"; + + CommandPtr command = CreateCommand(msg); + command->SendProviderRequest( + mobile_apis::FunctionID::GetAppServiceDataID, + hmi_apis::FunctionID::AppService_GetAppServiceData, + &(*msg), + true); +} + } // namespace command_request_impl } // namespace commands_test } // namespace components -- cgit v1.2.1 From 02d737241c5024c51d9fef20223b49afff5817f1 Mon Sep 17 00:00:00 2001 From: jacobkeeler Date: Sat, 16 Mar 2019 12:06:30 -0400 Subject: API changes to app service manager --- .../application_manager/app_service_manager.h | 121 ++++++++++++++++----- .../commands/hmi/as_publish_app_service_request.cc | 2 +- .../application_manager/src/app_service_manager.cc | 7 +- .../application_manager/src/rpc_passing_handler.cc | 10 +- .../application_manager/mock_app_service_manager.h | 2 +- 5 files changed, 104 insertions(+), 38 deletions(-) diff --git a/src/components/application_manager/include/application_manager/app_service_manager.h b/src/components/application_manager/include/application_manager/app_service_manager.h index 47a60780bc..b5b8598a0f 100644 --- a/src/components/application_manager/include/application_manager/app_service_manager.h +++ b/src/components/application_manager/include/application_manager/app_service_manager.h @@ -73,94 +73,159 @@ class AppServiceManager { virtual ~AppServiceManager(); /** - * @brief TODO - * @param manifest + * @brief Publish an app service. This service will be activated if it is the + * default service for its type, or if it is the first service to register of + * its type. + * @param manifest - The app service manifest of the service to be published + * @param mobile_service - True, if the service is being published by a mobile + * app. False, if published by the embedded system. + * @param connection_key - If mobile_service is true, the connection key of + * the app publishing this service. + * @return The app service record of the published app service */ virtual smart_objects::SmartObject PublishAppService( const smart_objects::SmartObject& manifest, const bool mobile_service, - const uint32_t connection_key); + const uint32_t connection_key = 0u); /** - * @brief TODO - * @param service_id + * @brief Unpublish an existing app service + * @param service_id - The ID of the app service to be deleted. + * @return True on success, false otherwise */ virtual bool UnpublishAppService(const std::string service_id); + /** + * @brief Callback for when an application is activated. Will activate all + * services which were published by this app. + * @param app - The application that was activated. + */ virtual void OnAppActivated(ApplicationConstSharedPtr app); /** - * @brief TODO - * @param connection_key + * @brief Unpublish any published services for a given mobile application + * @param connection_key - The connection key of the application from which + * all published services should be deleted. */ virtual void UnpublishServices(const uint32_t connection_key); /** - * @brief TODO - * @param service_id + * @brief Sets a service to the default service for its type + * @param service_id - The ID of the service to become the default + * @return True on success, false otherwise */ virtual bool SetDefaultService(const std::string service_id); /** - * @brief TODO - * @param service_id + * @brief Removes a service from the list of default services. + * @param service_id - The ID of the existing default service. + * @return True on success, false otherwise */ virtual bool RemoveDefaultService(const std::string service_id); /** - * @brief TODO - * @param service_id + * @brief Activate an existing service + * @param service_id - The ID of the service to be activated. + * @return True if the service is active, false otherwise */ virtual bool ActivateAppService(const std::string service_id); /** - * @brief TODO - * @param service_id + * @brief Deactivate an existing active service + * @param service_id - The ID of the service to be deactivated. + * @return True if the service was deactivated, false otherwise */ virtual bool DeactivateAppService(const std::string service_id); /** - * @brief TODO - * @param manifest + * @brief Get a list of all published service records. + * @return A list of all all published service records. */ virtual std::vector GetAllServiceRecords(); - virtual std::vector > GetActiveServices(); + + /** + * @brief Get a list of all active app services. + * @return A list of all all active app services. + */ + virtual std::vector GetActiveServices(); + /** + * @brief Retrieve the active service provider for a given service type + * @param service_type - The service type of the provider to be retrieved + * @param mobile_consumer - True, if the consumer trying to communicate with + * the provider is a mobile application + * @param app - Output parameter that will be filled with the application + * providing the requested service on success, unchanged on failure + * @param hmi_service - Output parameter set to true if the service + * provider is the HMI, unchanged on failure + */ virtual void GetProviderByType(const std::string& service_type, const bool mobile_consumer, ApplicationSharedPtr& app, bool& hmi_service); + /** + * @brief Retrieve the service provider with a given service ID + * @param service_type - The service type of the provider to be retrieved + * @param mobile_consumer - True, if the consumer trying to communicate with + * the provider is a mobile application + * @param app - Output parameter that will be filled with the application + * providing the requested service on success, unchanged on failure + * @param hmi_service - Output parameter set to true if the service + * provider is the HMI, unchanged on failure + */ virtual void GetProviderByID(const std::string& service_id, const bool mobile_consumer, ApplicationSharedPtr& app, bool& hmi_service); + /** + * @brief Get the active service for a given service type. + * @param service_type - The service type + * @return A pointer to the active service for the given service type on + * success, NULL on failure + */ virtual AppService* ActiveServiceForType(const std::string service_type); + /** + * @brief Get the embedded service for a given service type. + * @param service_type - The service type + * @return A pointer to the embedded service for the given service type on + * success, NULL on failure + */ virtual AppService* EmbeddedServiceForType(const std::string service_type); AppService* FindServiceByName(const std::string name); + /** + * @brief Get the service with a given service ID. + * @param service_type - The service ID + * @return A pointer to requested service on success, NULL on failure + */ virtual AppService* FindServiceByID(const std::string service_id); - virtual std::string DefaultServiceByType(const std::string service_type); - /** - * @brief TODO - * @param service_id - * @param service_published + * @brief Get the service ID of the default service for a given service type. + * @param service_type - The service type + * @return The service ID of the default service for the given service type on + * success, "" on failure */ - virtual void SetServicePublished(const std::string service_id, - bool service_published); + virtual std::string DefaultServiceByType(const std::string service_type); /** - * @brief TODO - * @param out_params + * @brief Update a navigation system capability struct with the capabilities + * of the active navigation service. + * @param out_params - The struct to be modified + * @return True on success, false otherwise (if there was no active NAVIGATION + * service) */ virtual bool UpdateNavigationCapabilities( smart_objects::SmartObject& out_params); + /** + * @brief Get the RPCPassingHandler tied to this object + * @return The RPCPassingHandler tied to this object + */ virtual RPCPassingHandler& GetRPCPassingHandler(); private: @@ -171,6 +236,8 @@ class AppServiceManager { std::map published_services_; RPCPassingHandler rpc_passing_handler_; + void SetServicePublished(const std::string service_id, + bool service_published); void AppServiceUpdated( const smart_objects::SmartObject& service_record, const mobile_apis::ServiceUpdateReason::eType update_reason, diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_publish_app_service_request.cc b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_publish_app_service_request.cc index c9466ff52d..6d2f516f0f 100644 --- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_publish_app_service_request.cc +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_publish_app_service_request.cc @@ -62,7 +62,7 @@ void ASPublishAppServiceRequest::Run() { (*message_)[strings::msg_params][strings::app_service_manifest]; smart_objects::SmartObject service_record = application_manager_.GetAppServiceManager().PublishAppService( - manifest, false, UINT32_MAX); + manifest, false); response_params[strings::app_service_record] = service_record; SendResponse(true, diff --git a/src/components/application_manager/src/app_service_manager.cc b/src/components/application_manager/src/app_service_manager.cc index 83551b1a13..5643611526 100644 --- a/src/components/application_manager/src/app_service_manager.cc +++ b/src/components/application_manager/src/app_service_manager.cc @@ -547,13 +547,12 @@ void AppServiceManager::AppServiceUpdated( services[-1] = service; } -std::vector > -AppServiceManager::GetActiveServices() { - std::vector > active_services; +std::vector AppServiceManager::GetActiveServices() { + std::vector active_services; for (auto it = published_services_.begin(); it != published_services_.end(); ++it) { if (it->second.record[strings::service_active].asBool()) { - active_services.push_back(*it); + active_services.push_back(it->second); } } return active_services; diff --git a/src/components/application_manager/src/rpc_passing_handler.cc b/src/components/application_manager/src/rpc_passing_handler.cc index 7ff01756f7..37b01a92f6 100644 --- a/src/components/application_manager/src/rpc_passing_handler.cc +++ b/src/components/application_manager/src/rpc_passing_handler.cc @@ -83,7 +83,7 @@ bool RPCPassingHandler::CanHandleFunctionID(int32_t function_id) { auto services = app_service_manager_.GetActiveServices(); for (auto it = services.begin(); it != services.end(); ++it) { auto handled_rpcs = - it->second.record[strings::service_manifest][strings::handled_rpcs]; + it->record[strings::service_manifest][strings::handled_rpcs]; for (size_t i = 0; i < handled_rpcs.length(); i++) { if (handled_rpcs[i].asInt() == function_id) { return true; @@ -187,13 +187,13 @@ void RPCPassingHandler::PopulateRPCRequestQueue( for (auto services_it = services.begin(); services_it != services.end(); ++services_it) { auto handled_rpcs = - services_it->second - .record[strings::service_manifest][strings::handled_rpcs]; + services_it->record[strings::service_manifest][strings::handled_rpcs]; for (size_t i = 0; i < handled_rpcs.length(); i++) { if (handled_rpcs[i].asInt() == function_id) { // Add requests to queue - ServiceInfo service_info{services_it->first, - services_it->second.connection_key}; + ServiceInfo service_info{ + services_it->record[strings::service_id].asString(), + services_it->connection_key}; entry.second.push_back(service_info); app_manager_.IncreaseForwardedRequestTimeout(origin_connection_key, correlation_id); diff --git a/src/components/application_manager/test/include/application_manager/mock_app_service_manager.h b/src/components/application_manager/test/include/application_manager/mock_app_service_manager.h index 030c130cbc..7459e40061 100644 --- a/src/components/application_manager/test/include/application_manager/mock_app_service_manager.h +++ b/src/components/application_manager/test/include/application_manager/mock_app_service_manager.h @@ -60,7 +60,7 @@ class MockAppServiceManager : public application_manager::AppServiceManager { MOCK_METHOD0(GetAllServiceRecords, std::vector()); MOCK_METHOD0( GetActiveServices, - std::vector >()); + std::vector()); MOCK_METHOD4(GetProviderByType, void(const std::string& service_type, const bool mobile_consumer, -- cgit v1.2.1 From 7d7d823228bc69cc449cd55d80f48cc456b39a21 Mon Sep 17 00:00:00 2001 From: jacobkeeler Date: Sat, 16 Mar 2019 12:08:10 -0400 Subject: Add basic AppServiceManager tests Also add minor safety checks in AppServiceManager class --- .../application_manager/src/app_service_manager.cc | 7 +- .../application_manager/test/CMakeLists.txt | 1 + .../test/app_service_manager_test.cc | 382 +++++++++++++++++++++ 3 files changed, 388 insertions(+), 2 deletions(-) create mode 100644 src/components/application_manager/test/app_service_manager_test.cc diff --git a/src/components/application_manager/src/app_service_manager.cc b/src/components/application_manager/src/app_service_manager.cc index 5643611526..f0fd9b30ea 100644 --- a/src/components/application_manager/src/app_service_manager.cc +++ b/src/components/application_manager/src/app_service_manager.cc @@ -104,7 +104,8 @@ smart_objects::SmartObject AppServiceManager::PublishAppService( } } } - app_service.default_service = GetPolicyAppID(app_service) == default_app_id; + app_service.default_service = + !default_app_id.empty() && GetPolicyAppID(app_service) == default_app_id; auto ret = published_services_.insert( std::pair(service_id, app_service)); @@ -375,7 +376,9 @@ bool AppServiceManager::DeactivateAppService(const std::string service_id) { const std::string service_type = service[strings::service_manifest][strings::service_type].asString(); auto embedded_service = EmbeddedServiceForType(service_type); - if (embedded_service) { + if (embedded_service && + embedded_service->record[strings::service_id].asString() != + service[strings::service_id].asString()) { embedded_service->record[strings::service_active] = true; AppServiceUpdated(embedded_service->record, mobile_apis::ServiceUpdateReason::ACTIVATED, diff --git a/src/components/application_manager/test/CMakeLists.txt b/src/components/application_manager/test/CMakeLists.txt index 02cf58485a..4851a6b37e 100755 --- a/src/components/application_manager/test/CMakeLists.txt +++ b/src/components/application_manager/test/CMakeLists.txt @@ -63,6 +63,7 @@ set(testSources ${AM_TEST_DIR}/application_state_test.cc ${AM_TEST_DIR}/usage_statistics_test.cc ${AM_TEST_DIR}/policy_handler_test.cc + ${AM_TEST_DIR}/app_service_manager_test.cc ${AM_TEST_DIR}/application_manager_impl_test.cc ${AM_TEST_DIR}/application_helper_test.cc ${AM_TEST_DIR}/command_holder_test.cc diff --git a/src/components/application_manager/test/app_service_manager_test.cc b/src/components/application_manager/test/app_service_manager_test.cc new file mode 100644 index 0000000000..cb49812f9c --- /dev/null +++ b/src/components/application_manager/test/app_service_manager_test.cc @@ -0,0 +1,382 @@ +/* + * Copyright (c) 2017, 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 + +#include "application_manager/commands/command.h" +#include "application_manager/mock_application.h" +#include "application_manager/mock_application_manager.h" +#include "application_manager/mock_application_manager_settings.h" +#include "application_manager/mock_message_helper.h" +#include "application_manager/smart_object_keys.h" +#include "resumption/mock_last_state.h" +#include "smart_objects/smart_object.h" + +namespace test { +namespace components { +namespace application_manager_test { + +using testing::_; +using ::testing::DoAll; +using ::testing::Mock; +using ::testing::Return; +using ::testing::ReturnRef; +using ::testing::SaveArg; + +namespace am = application_manager; + +const char* kAppServiceSection = "AppServices"; +const char* kDefaults = "defaults"; +const std::string kServiceType = "MEDIA"; +const std::string kServiceName = "service_name"; +const std::string kServiceId = "service_id"; +const std::string kPolicyAppId = "p_app_id"; +const uint32_t kConnectionKey = 43629; + +MATCHER_P(CapabilityUpdateMatcher, reason, "") { + smart_objects::SmartObject& services_updated = + arg[am::strings::system_capability] + [am::strings::app_services_capabilities][am::strings::app_services]; + if (smart_objects::SmartType_Array != services_updated.getType()) { + return false; + } + for (size_t i = 0; i < services_updated.length(); i++) { + smart_objects::SmartObject& service_cap = services_updated[i]; + if (reason == service_cap[am::strings::update_reason].asInt()) { + return true; + } + } + return false; +} + +class AppServiceManagerTest : public testing::Test { + public: + AppServiceManagerTest() + : mock_app_ptr_(new MockApplication) + , app_service_manager_(mock_app_manager_, mock_last_state_) + , mock_message_helper_( + application_manager::MockMessageHelper::message_helper_mock()) { + Mock::VerifyAndClearExpectations(mock_message_helper_); + } + ~AppServiceManagerTest() { + Mock::VerifyAndClearExpectations(mock_message_helper_); + } + + void SetUp() OVERRIDE { + ON_CALL(*mock_message_helper_, BroadcastCapabilityUpdate(_, _)) + .WillByDefault(Return()); + ON_CALL(mock_settings_, embedded_services()) + .WillByDefault(ReturnRef(embedded_services_)); + ON_CALL(mock_app_manager_, get_settings()) + .WillByDefault(ReturnRef(mock_settings_)); + ON_CALL(*mock_app_ptr_, policy_app_id()) + .WillByDefault(Return(kPolicyAppId)); + ON_CALL(mock_last_state_, get_dictionary()) + .WillByDefault(ReturnRef(dict_)); + auto app_ptr = std::static_pointer_cast(mock_app_ptr_); + ON_CALL(mock_app_manager_, application(kConnectionKey)) + .WillByDefault(Return(app_ptr)); + } + + protected: + smart_objects::SmartObject GenerateMediaManifest( + bool allow_app_consumers, std::string app_service_name = kServiceName) { + smart_objects::SmartObject manifest(smart_objects::SmartType_Map); + manifest[am::strings::service_type] = "MEDIA"; + manifest[am::strings::service_name] = app_service_name; + manifest[am::strings::allow_app_consumers] = allow_app_consumers; + manifest[am::strings::media_service_manifest] = + smart_objects::SmartObject(smart_objects::SmartType_Map); + return manifest; + } + + smart_objects::SmartObject PublishMobileService( + uint32_t connection_key = kConnectionKey, bool first_run = true) { + smart_objects::SmartObject manifest = GenerateMediaManifest(true); + + Json::Value empty_json; + EXPECT_CALL(mock_last_state_, get_dictionary()) + .WillOnce(ReturnRef(empty_json)); + + EXPECT_CALL(*mock_message_helper_, + BroadcastCapabilityUpdate( + CapabilityUpdateMatcher( + mobile_apis::ServiceUpdateReason::PUBLISHED), + _)) + .WillOnce(Return()); + if (first_run) { + EXPECT_CALL(*mock_message_helper_, + BroadcastCapabilityUpdate( + CapabilityUpdateMatcher( + mobile_apis::ServiceUpdateReason::ACTIVATED), + _)) + .WillOnce(Return()); + } + + return app_service_manager_.PublishAppService(manifest, true, connection_key); + } + + void CheckCapabilityUpdate(smart_objects::SmartObject& msg_params, + size_t length, + std::string service_id, + mobile_apis::ServiceUpdateReason::eType reason, + bool published, + bool active) { + smart_objects::SmartObject& services_updated = + msg_params[am::strings::system_capability] + [am::strings::app_services_capabilities] + [am::strings::app_services]; + ASSERT_EQ(smart_objects::SmartType_Array, services_updated.getType()); + EXPECT_EQ(length, services_updated.length()); + for (size_t i = 0; i < services_updated.length(); i++) { + smart_objects::SmartObject& service_cap = services_updated[i]; + if (service_id == service_cap[am::strings::updated_app_service_record] + [am::strings::service_id] + .asString()) { + CheckCapability(service_cap, service_id, reason, published, active); + return; + } + } + FAIL() << "Unable to find service in capability update with service_id: " + << service_id; + } + + void CheckCapability(smart_objects::SmartObject& app_service_capability, + std::string service_id, + mobile_apis::ServiceUpdateReason::eType reason, + bool published, + bool active) { + EXPECT_EQ(reason, + app_service_capability[am::strings::update_reason].asInt()); + smart_objects::SmartObject& updated_record = + app_service_capability[am::strings::updated_app_service_record]; + EXPECT_EQ(service_id, updated_record[am::strings::service_id].asString()); + EXPECT_EQ(published, updated_record[am::strings::service_published].asBool()); + EXPECT_EQ(active, updated_record[am::strings::service_active].asBool()); + } + + Json::Value dict_; + std::vector embedded_services_; + std::shared_ptr mock_app_ptr_; + MockApplicationManager mock_app_manager_; + resumption_test::MockLastState mock_last_state_; + MockApplicationManagerSettings mock_settings_; + application_manager::AppServiceManager app_service_manager_; + application_manager::MockMessageHelper* mock_message_helper_; +}; + +TEST_F(AppServiceManagerTest, PublishAppService_Mobile_SUCCESS) { + smart_objects::SmartObject manifest = GenerateMediaManifest(true); + + Json::Value empty_json; + // dict[kAppServiceSection][kDefaults][kServiceType] = kPolicyAppId; + EXPECT_CALL(mock_last_state_, get_dictionary()) + .WillOnce(ReturnRef(empty_json)); + + smart_objects::SmartObject syscap_update_published; + EXPECT_CALL( + *mock_message_helper_, + BroadcastCapabilityUpdate( + CapabilityUpdateMatcher(mobile_apis::ServiceUpdateReason::PUBLISHED), + _)) + .WillOnce(DoAll(SaveArg<0>(&syscap_update_published), Return())); + + smart_objects::SmartObject syscap_update_activated; + EXPECT_CALL( + *mock_message_helper_, + BroadcastCapabilityUpdate( + CapabilityUpdateMatcher(mobile_apis::ServiceUpdateReason::ACTIVATED), + _)) + .WillOnce(DoAll(SaveArg<0>(&syscap_update_activated), Return())); + + auto record = + app_service_manager_.PublishAppService(manifest, true, kConnectionKey); + + // Check final record + std::string service_id = record[am::strings::service_id].asString(); + EXPECT_EQ(manifest, record[am::strings::service_manifest]); + EXPECT_EQ(true, record[am::strings::service_published].asBool()); + EXPECT_EQ(true, record[am::strings::service_active].asBool()); + + // Check first capability update + CheckCapabilityUpdate(syscap_update_published, + 1, + service_id, + mobile_apis::ServiceUpdateReason::PUBLISHED, + true, + false); + + // Check second capability update + CheckCapabilityUpdate(syscap_update_activated, + 1, + service_id, + mobile_apis::ServiceUpdateReason::ACTIVATED, + true, + true); +} + +TEST_F(AppServiceManagerTest, PublishAppService_HMI_SUCCESS) { + smart_objects::SmartObject manifest = GenerateMediaManifest(true); + + Json::Value empty_json; + EXPECT_CALL(mock_last_state_, get_dictionary()) + .WillOnce(ReturnRef(empty_json)); + + smart_objects::SmartObject syscap_update_published; + EXPECT_CALL( + *mock_message_helper_, + BroadcastCapabilityUpdate( + CapabilityUpdateMatcher(mobile_apis::ServiceUpdateReason::PUBLISHED), + _)) + .WillOnce(DoAll(SaveArg<0>(&syscap_update_published), Return())); + + smart_objects::SmartObject syscap_update_activated; + EXPECT_CALL( + *mock_message_helper_, + BroadcastCapabilityUpdate( + CapabilityUpdateMatcher(mobile_apis::ServiceUpdateReason::ACTIVATED), + _)) + .WillOnce(DoAll(SaveArg<0>(&syscap_update_activated), Return())); + + auto record = + app_service_manager_.PublishAppService(manifest, false); + + // Check final record + std::string service_id = record[am::strings::service_id].asString(); + EXPECT_EQ(manifest, record[am::strings::service_manifest]); + EXPECT_EQ(true, record[am::strings::service_published].asBool()); + EXPECT_EQ(true, record[am::strings::service_active].asBool()); + + // Check first capability update + CheckCapabilityUpdate(syscap_update_published, + 1, + service_id, + mobile_apis::ServiceUpdateReason::PUBLISHED, + true, + false); + + // Check second capability update + CheckCapabilityUpdate(syscap_update_activated, + 1, + service_id, + mobile_apis::ServiceUpdateReason::ACTIVATED, + true, + true); +} + +TEST_F(AppServiceManagerTest, ActivateAppService_AlreadyActivated) { + auto record = PublishMobileService(); + + // No capability update + EXPECT_CALL( + *mock_message_helper_, + BroadcastCapabilityUpdate( + CapabilityUpdateMatcher(mobile_apis::ServiceUpdateReason::ACTIVATED), + _)) + .Times(0); + std::string service_id = record[am::strings::service_id].asString(); + + EXPECT_TRUE(app_service_manager_.ActivateAppService(service_id)); +} + +TEST_F(AppServiceManagerTest, ActivateAppService_TwoApps_SUCCESS) { + // Register two services with the same service type, the first is activated + // automatically + auto record = PublishMobileService(); + auto record2 = PublishMobileService(kConnectionKey + 1, false); + + // No capability update + smart_objects::SmartObject syscap_update_activated; + EXPECT_CALL(*mock_message_helper_, + BroadcastCapabilityUpdate( + CapabilityUpdateMatcher( + mobile_apis::ServiceUpdateReason::ACTIVATED), + _)) + .WillOnce(DoAll(SaveArg<0>(&syscap_update_activated), Return())); + std::string service_id = record[am::strings::service_id].asString(); + std::string service_id2 = record2[am::strings::service_id].asString(); + + // Activate the second service + EXPECT_TRUE(app_service_manager_.ActivateAppService(service_id2)); + + // Check that the first service is deactivated + CheckCapabilityUpdate(syscap_update_activated, + 2, + service_id, + mobile_apis::ServiceUpdateReason::DEACTIVATED, + true, + false); + + // Check that the second service is activated + CheckCapabilityUpdate(syscap_update_activated, + 2, + service_id2, + mobile_apis::ServiceUpdateReason::ACTIVATED, + true, + true); +} + +TEST_F(AppServiceManagerTest, DeactivateAppService_SUCCESS) { + auto record = PublishMobileService(); + + smart_objects::SmartObject syscap_update_deactivated; + EXPECT_CALL(*mock_message_helper_, + BroadcastCapabilityUpdate( + CapabilityUpdateMatcher( + mobile_apis::ServiceUpdateReason::DEACTIVATED), + _)) + .WillOnce(DoAll(SaveArg<0>(&syscap_update_deactivated), Return())); + std::string service_id = record[am::strings::service_id].asString(); + + EXPECT_TRUE(app_service_manager_.DeactivateAppService(service_id)); + + // Check deactivated capability updated + CheckCapabilityUpdate(syscap_update_deactivated, + 1, + service_id, + mobile_apis::ServiceUpdateReason::DEACTIVATED, + true, + false); +} + +TEST_F(AppServiceManagerTest, ActiveServiceForType_SUCCESS) { + auto record = PublishMobileService(); + + auto service = app_service_manager_.ActiveServiceForType(kServiceType); + + ASSERT_FALSE(service == NULL); + EXPECT_EQ(service->record, record); +} + +} // namespace application_manager_test +} // namespace components +} // namespace test \ No newline at end of file -- cgit v1.2.1 From 6328bb42cc8699f018be74b15544cfeb6c4100e7 Mon Sep 17 00:00:00 2001 From: JackLivio Date: Sat, 16 Mar 2019 13:12:07 -0400 Subject: Delete write_thread_ --- .../transport_manager/src/cloud/websocket_client_connection.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/src/components/transport_manager/src/cloud/websocket_client_connection.cc b/src/components/transport_manager/src/cloud/websocket_client_connection.cc index 5c9553a970..8944bd74b6 100644 --- a/src/components/transport_manager/src/cloud/websocket_client_connection.cc +++ b/src/components/transport_manager/src/cloud/websocket_client_connection.cc @@ -267,6 +267,7 @@ void WebsocketClientConnection::Shutdown() { thread_delegate_->SetShutdown(); write_thread_->join(); delete thread_delegate_; + threads::DeleteThread(write_thread_); } if (buffer_.size()) { buffer_.consume(buffer_.size()); -- cgit v1.2.1 From 9d408169f2898ecf8935c2bbc7eec227ac3ed120 Mon Sep 17 00:00:00 2001 From: JackLivio Date: Sat, 16 Mar 2019 13:29:48 -0400 Subject: Set deleted pointers to null --- .../transport_manager/src/cloud/websocket_client_connection.cc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/components/transport_manager/src/cloud/websocket_client_connection.cc b/src/components/transport_manager/src/cloud/websocket_client_connection.cc index 8944bd74b6..057e3d7208 100644 --- a/src/components/transport_manager/src/cloud/websocket_client_connection.cc +++ b/src/components/transport_manager/src/cloud/websocket_client_connection.cc @@ -267,7 +267,9 @@ void WebsocketClientConnection::Shutdown() { thread_delegate_->SetShutdown(); write_thread_->join(); delete thread_delegate_; + thread_delegate_ = NULL; threads::DeleteThread(write_thread_); + write_thread_ = NULL; } if (buffer_.size()) { buffer_.consume(buffer_.size()); -- cgit v1.2.1 From a40f522db248338912f4bc702cee8577e8498d27 Mon Sep 17 00:00:00 2001 From: JackLivio Date: Sat, 16 Mar 2019 14:17:41 -0400 Subject: Remove pending cloud apps at shutdown --- .../src/application_manager_impl.cc | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/components/application_manager/src/application_manager_impl.cc b/src/components/application_manager/src/application_manager_impl.cc index 701bb339a1..b4a0d442f0 100644 --- a/src/components/application_manager/src/application_manager_impl.cc +++ b/src/components/application_manager/src/application_manager_impl.cc @@ -933,6 +933,9 @@ void ApplicationManagerImpl::DisconnectCloudApp(ApplicationSharedPtr app) { void ApplicationManagerImpl::RefreshCloudAppInformation() { LOG4CXX_AUTO_TRACE(logger_); + if (is_stopping()) { + return; + } std::vector enabled_apps; GetPolicyHandler().GetEnabledCloudApps(enabled_apps); std::vector::iterator enabled_it = enabled_apps.begin(); @@ -2824,6 +2827,21 @@ void ApplicationManagerImpl::UnregisterAllApplications() { it = accessor.GetData().begin(); } } + + bool send_pending_update_app_list = false; + { + sync_primitives::AutoLock auto_lock(apps_to_register_list_lock_ptr_); + if (!apps_to_register_.empty()) { + send_pending_update_app_list = true; + apps_to_register_.clear(); + } + } + + // Only send update app list if pending apps were removed. + if (send_pending_update_app_list) { + SendUpdateAppList(); + } + if (is_ignition_off) { resume_controller().OnIgnitionOff(); } -- cgit v1.2.1 From 7b3aaabb4543a8a6363761435bb1d43e060b7c19 Mon Sep 17 00:00:00 2001 From: jacobkeeler Date: Sat, 16 Mar 2019 16:46:24 -0400 Subject: Make DefaultServiceByType private Also fix unnecessary `application_manager_impl.h` includes --- .../application_manager/app_service_manager.h | 17 +++++++++-------- .../system_time/system_time_handler_impl.h | 2 +- .../basic_communication_get_system_time_response.h | 2 +- .../hmi/on_system_time_ready_notification.h | 2 +- .../src/commands/mobile/get_file_request.cc | 1 - .../sdl_rpc_plugin/src/hmi_command_factory.cc | 2 ++ .../src/app_launch/app_launch_data_db.cc | 2 +- .../application_manager/src/app_service_manager.cc | 1 - .../src/hmi_capabilities_impl.cc | 4 +++- .../src/resumption/resumption_data_json.cc | 2 +- .../src/system_time/system_time_handler_impl.cc | 2 ++ .../test/commands/command_impl_test.cc | 11 ++++++----- .../application_manager/mock_app_service_manager.h | 2 -- .../test/message_helper/message_helper_test.cc | 2 +- .../application_manager/mock_application_manager.h | 21 ++++++++++++--------- .../include/telemetry_monitor/telemetry_monitor.h | 2 +- 16 files changed, 41 insertions(+), 34 deletions(-) diff --git a/src/components/application_manager/include/application_manager/app_service_manager.h b/src/components/application_manager/include/application_manager/app_service_manager.h index d643d55d1e..c97dd05a70 100644 --- a/src/components/application_manager/include/application_manager/app_service_manager.h +++ b/src/components/application_manager/include/application_manager/app_service_manager.h @@ -202,14 +202,6 @@ class AppServiceManager { */ virtual AppService* FindServiceByID(const std::string service_id); - /** - * @brief Get the service ID of the default service for a given service type. - * @param service_type - The service type - * @return The service ID of the default service for the given service type on - * success, "" on failure - */ - virtual std::string DefaultServiceByType(const std::string service_type); - /** * @brief Update a navigation system capability struct with the capabilities * of the active navigation service. @@ -244,6 +236,15 @@ class AppServiceManager { const bool mobile_consumer, ApplicationSharedPtr& app, bool& hmi_service); + + /** + * @brief Get the policy app ID of the default service provider for a given + * service type. + * @param service_type - The service type + * @return The policy app ID of the default service provider for the given + * service type on success, "" on failure + */ + std::string DefaultServiceByType(const std::string service_type); AppService* FindServiceByPolicyAppID(const std::string policy_app_id, const std::string type); std::string GetPolicyAppID(AppService service); diff --git a/src/components/application_manager/include/application_manager/system_time/system_time_handler_impl.h b/src/components/application_manager/include/application_manager/system_time/system_time_handler_impl.h index add440ad80..05565861f6 100644 --- a/src/components/application_manager/include/application_manager/system_time/system_time_handler_impl.h +++ b/src/components/application_manager/include/application_manager/system_time/system_time_handler_impl.h @@ -39,7 +39,7 @@ #include "utils/lock.h" #include "utils/macro.h" #include "utils/system_time_handler.h" -#include "application_manager/application_manager_impl.h" +#include "application_manager/application_manager.h" #include "application_manager/event_engine/event_observer.h" namespace application_manager { diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/basic_communication_get_system_time_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/basic_communication_get_system_time_response.h index 90160d9953..3a97ebdfb5 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/basic_communication_get_system_time_response.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/basic_communication_get_system_time_response.h @@ -36,7 +36,7 @@ #include "application_manager/commands/response_from_hmi.h" #include "utils/macro.h" -#include "application_manager/application_manager_impl.h" +#include "application_manager/application_manager.h" namespace sdl_rpc_plugin { namespace app_mngr = application_manager; diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_system_time_ready_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_system_time_ready_notification.h index 0beba8dc6b..7cd8410d8e 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_system_time_ready_notification.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_system_time_ready_notification.h @@ -34,7 +34,7 @@ #define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_SYSTEM_TIME_READY_NOTIFICATION_H_ #include "application_manager/commands/notification_from_hmi.h" -#include "application_manager/application_manager_impl.h" +#include "application_manager/application_manager.h" namespace sdl_rpc_plugin { namespace app_mngr = application_manager; diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/get_file_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/get_file_request.cc index 2c92d74b47..a582670426 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/get_file_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/get_file_request.cc @@ -37,7 +37,6 @@ #include "application_manager/rpc_service.h" #include "interfaces/MOBILE_API.h" #include "application_manager/message_helper.h" -#include "application_manager/app_service_manager.h" #include "utils/file_system.h" #include diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/hmi_command_factory.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/hmi_command_factory.cc index 3cfe4d7118..fb809e8834 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/hmi_command_factory.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/hmi_command_factory.cc @@ -248,6 +248,8 @@ namespace sdl_rpc_plugin { using namespace application_manager; +CREATE_LOGGERPTR_GLOBAL(logger_, "HMICommandFactory") + HMICommandFactory::HMICommandFactory( ApplicationManager& application_manager, rpc_service::RPCService& rpc_service, diff --git a/src/components/application_manager/src/app_launch/app_launch_data_db.cc b/src/components/application_manager/src/app_launch/app_launch_data_db.cc index 393b01c952..22d2790183 100644 --- a/src/components/application_manager/src/app_launch/app_launch_data_db.cc +++ b/src/components/application_manager/src/app_launch/app_launch_data_db.cc @@ -33,7 +33,7 @@ #include #include "application_manager/app_launch/app_launch_data_db.h" -#include "application_manager/application_manager_impl.h" +#include "application_manager/application_manager.h" #include "application_manager/app_launch/app_launch_sql_queries.h" #include "application_manager/smart_object_keys.h" #include "application_manager/message_helper.h" diff --git a/src/components/application_manager/src/app_service_manager.cc b/src/components/application_manager/src/app_service_manager.cc index 6a32c875bb..222f1b955e 100644 --- a/src/components/application_manager/src/app_service_manager.cc +++ b/src/components/application_manager/src/app_service_manager.cc @@ -39,7 +39,6 @@ #include "application_manager/application_manager.h" #include "application_manager/commands/command_impl.h" #include "application_manager/message_helper.h" -#include "application_manager/rpc_passing_handler.h" #include "application_manager/smart_object_keys.h" #include "encryption/hashing.h" #include "resumption/last_state.h" diff --git a/src/components/application_manager/src/hmi_capabilities_impl.cc b/src/components/application_manager/src/hmi_capabilities_impl.cc index 6cd6747e99..060eaf011c 100644 --- a/src/components/application_manager/src/hmi_capabilities_impl.cc +++ b/src/components/application_manager/src/hmi_capabilities_impl.cc @@ -34,7 +34,7 @@ #include "utils/logger.h" #include "application_manager/hmi_capabilities_impl.h" -#include "application_manager/application_manager_impl.h" +#include "application_manager/application_manager.h" #include "smart_objects/smart_object.h" #include "application_manager/message_helper.h" #include "application_manager/smart_object_keys.h" @@ -46,6 +46,8 @@ namespace application_manager { namespace formatters = ns_smart_device_link::ns_json_handler::formatters; +CREATE_LOGGERPTR_GLOBAL(logger_, "HMICapabilities") + namespace { std::map vr_enum_capabilities; diff --git a/src/components/application_manager/src/resumption/resumption_data_json.cc b/src/components/application_manager/src/resumption/resumption_data_json.cc index c8e9032dfa..584fb4e697 100644 --- a/src/components/application_manager/src/resumption/resumption_data_json.cc +++ b/src/components/application_manager/src/resumption/resumption_data_json.cc @@ -30,7 +30,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#include "application_manager/application_manager_impl.h" +#include "application_manager/application_manager.h" #include "application_manager/resumption/resumption_data_json.h" #include "smart_objects/smart_object.h" #include "json/json.h" diff --git a/src/components/application_manager/src/system_time/system_time_handler_impl.cc b/src/components/application_manager/src/system_time/system_time_handler_impl.cc index 06343af5a3..f5d08a8ebf 100644 --- a/src/components/application_manager/src/system_time/system_time_handler_impl.cc +++ b/src/components/application_manager/src/system_time/system_time_handler_impl.cc @@ -41,6 +41,8 @@ namespace application_manager { +CREATE_LOGGERPTR_GLOBAL(logger_, "SystemTimeHandler") + SystemTimeHandlerImpl::SystemTimeHandlerImpl( ApplicationManager& application_manager) : event_engine::EventObserver(application_manager.event_dispatcher()) diff --git a/src/components/application_manager/test/commands/command_impl_test.cc b/src/components/application_manager/test/commands/command_impl_test.cc index 222f16ef46..53e8534c2b 100644 --- a/src/components/application_manager/test/commands/command_impl_test.cc +++ b/src/components/application_manager/test/commands/command_impl_test.cc @@ -85,11 +85,12 @@ class CommandImplTest : public CommandsTest { using CommandImpl::ReplaceMobileWithHMIAppId; using CommandImpl::ReplaceHMIWithMobileAppId; - UnwrappedCommandImpl(const MessageSharedPtr& message, - ApplicationManager& application_manager, - app_mngr::rpc_service::RPCService& rpc_service, - app_mngr::HMICapabilities& hmi_capabilities, - policy::PolicyHandlerInterface& policy_handler) + UnwrappedCommandImpl( + const MessageSharedPtr& message, + ApplicationManager& application_manager, + application_manager::rpc_service::RPCService& rpc_service, + application_manager::HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handler) : CommandImpl(message, application_manager, rpc_service, diff --git a/src/components/application_manager/test/include/application_manager/mock_app_service_manager.h b/src/components/application_manager/test/include/application_manager/mock_app_service_manager.h index 7459e40061..87d0755748 100644 --- a/src/components/application_manager/test/include/application_manager/mock_app_service_manager.h +++ b/src/components/application_manager/test/include/application_manager/mock_app_service_manager.h @@ -79,8 +79,6 @@ class MockAppServiceManager : public application_manager::AppServiceManager { application_manager::AppService*(const std::string service_type)); MOCK_METHOD1(FindServiceByID, application_manager::AppService*(const std::string service_id)); - MOCK_METHOD1(DefaultServiceByType, - std::string(const std::string service_type)); MOCK_METHOD2(SetServicePublished, void(const std::string service_id, const bool service_published)); diff --git a/src/components/application_manager/test/message_helper/message_helper_test.cc b/src/components/application_manager/test/message_helper/message_helper_test.cc index f43062dc53..92be221ec9 100644 --- a/src/components/application_manager/test/message_helper/message_helper_test.cc +++ b/src/components/application_manager/test/message_helper/message_helper_test.cc @@ -42,7 +42,7 @@ #include "utils/custom_string.h" #include "utils/lock.h" #include "policy/mock_policy_settings.h" -#include "application_manager/policies/policy_handler.h" +#include "application_manager/commands/command_impl.h" #include "application_manager/mock_application_manager.h" #include "application_manager/mock_rpc_service.h" #include "application_manager/event_engine/event_dispatcher.h" diff --git a/src/components/include/test/application_manager/mock_application_manager.h b/src/components/include/test/application_manager/mock_application_manager.h index 4f09d2c2f9..679e6ccfb3 100644 --- a/src/components/include/test/application_manager/mock_application_manager.h +++ b/src/components/include/test/application_manager/mock_application_manager.h @@ -39,21 +39,24 @@ #include "gmock/gmock.h" -#include "application_manager/application_manager.h" -#include "application_manager/application_manager_impl.h" +#include "application_manager/app_launch/app_launch_ctrl.h" +#include "application_manager/app_service_manager.h" #include "application_manager/application_manager_settings.h" +#include "application_manager/command_factory.h" #include "application_manager/commands/command.h" +#include "application_manager/event_engine/event_dispatcher.h" #include "application_manager/hmi_capabilities.h" -#include "application_manager/state_controller.h" #include "application_manager/message.h" -#include "resumption/last_state.h" -#include "interfaces/MOBILE_API.h" -#include "application_manager/app_launch/app_launch_ctrl.h" -#include "application_manager/event_engine/event_dispatcher.h" +#include "application_manager/message_helper.h" +#include "application_manager/plugin_manager/rpc_plugin_manager.h" +#include "application_manager/resumption/resume_ctrl.h" +#include "application_manager/rpc_handler.h" +#include "application_manager/rpc_service.h" #include "application_manager/state_controller.h" +#include "interfaces/HMI_API.h" +#include "interfaces/MOBILE_API.h" +#include "resumption/last_state.h" #include "smart_objects/smart_object.h" -#include "application_manager/plugin_manager/rpc_plugin_manager.h" -#include "application_manager/command_factory.h" namespace test { namespace components { diff --git a/src/components/telemetry_monitor/include/telemetry_monitor/telemetry_monitor.h b/src/components/telemetry_monitor/include/telemetry_monitor/telemetry_monitor.h index ff7b9da9d6..0d31573d8e 100644 --- a/src/components/telemetry_monitor/include/telemetry_monitor/telemetry_monitor.h +++ b/src/components/telemetry_monitor/include/telemetry_monitor/telemetry_monitor.h @@ -40,7 +40,7 @@ #include "utils/threads/thread_delegate.h" #include "telemetry_monitor/metric_wrapper.h" #include "telemetry_monitor/application_manager_observer.h" -#include "application_manager/application_manager_impl.h" +#include "application_manager/application_manager.h" #include "telemetry_monitor/transport_manager_observer.h" #include "transport_manager/transport_manager_impl.h" #include "protocol_handler_observer.h" -- cgit v1.2.1 From b9d5a91818e253da2fe94e344bb1fb92b4555d3e Mon Sep 17 00:00:00 2001 From: jacobkeeler Date: Sat, 16 Mar 2019 16:48:52 -0400 Subject: Fix style and add more tests --- .../application_manager/app_service_manager.h | 2 +- .../application_manager/application_manager_impl.h | 3 +- .../commands/hmi/as_publish_app_service_request.cc | 4 +- .../application_manager/src/app_service_manager.cc | 3 +- .../test/app_service_manager_test.cc | 146 ++++++++++++++------- .../application_manager/mock_app_service_manager.h | 14 +- 6 files changed, 115 insertions(+), 57 deletions(-) diff --git a/src/components/application_manager/include/application_manager/app_service_manager.h b/src/components/application_manager/include/application_manager/app_service_manager.h index c97dd05a70..9690d7cd46 100644 --- a/src/components/application_manager/include/application_manager/app_service_manager.h +++ b/src/components/application_manager/include/application_manager/app_service_manager.h @@ -142,7 +142,7 @@ class AppServiceManager { * @return A list of all all published service records. */ virtual std::vector GetAllServiceRecords(); - + /** * @brief Get a list of all active app services. * @return A list of all all active app services. diff --git a/src/components/application_manager/include/application_manager/application_manager_impl.h b/src/components/application_manager/include/application_manager/application_manager_impl.h index fc40624e4d..cba9cdfd79 100644 --- a/src/components/application_manager/include/application_manager/application_manager_impl.h +++ b/src/components/application_manager/include/application_manager/application_manager_impl.h @@ -1587,8 +1587,7 @@ class ApplicationManagerImpl plugin_manager_.reset(plugin_manager.release()); } - virtual void SetAppServiceManager( - AppServiceManager* app_service_manager) { + virtual void SetAppServiceManager(AppServiceManager* app_service_manager) { app_service_manager_.reset(app_service_manager); } diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_publish_app_service_request.cc b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_publish_app_service_request.cc index 6d2f516f0f..637240666d 100644 --- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_publish_app_service_request.cc +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_publish_app_service_request.cc @@ -61,8 +61,8 @@ void ASPublishAppServiceRequest::Run() { smart_objects::SmartObject manifest = (*message_)[strings::msg_params][strings::app_service_manifest]; smart_objects::SmartObject service_record = - application_manager_.GetAppServiceManager().PublishAppService( - manifest, false); + application_manager_.GetAppServiceManager().PublishAppService(manifest, + false); response_params[strings::app_service_record] = service_record; SendResponse(true, diff --git a/src/components/application_manager/src/app_service_manager.cc b/src/components/application_manager/src/app_service_manager.cc index 222f1b955e..1711180980 100644 --- a/src/components/application_manager/src/app_service_manager.cc +++ b/src/components/application_manager/src/app_service_manager.cc @@ -190,7 +190,8 @@ void AppServiceManager::OnAppActivated(ApplicationConstSharedPtr app) { } } -std::vector AppServiceManager::GetAllServiceRecords() { +std::vector +AppServiceManager::GetAllServiceRecords() { LOG4CXX_AUTO_TRACE(logger_); std::vector services; sync_primitives::AutoLock lock(published_services_lock_); diff --git a/src/components/application_manager/test/app_service_manager_test.cc b/src/components/application_manager/test/app_service_manager_test.cc index cb49812f9c..406f6fe0ce 100644 --- a/src/components/application_manager/test/app_service_manager_test.cc +++ b/src/components/application_manager/test/app_service_manager_test.cc @@ -61,6 +61,7 @@ const std::string kServiceName = "service_name"; const std::string kServiceId = "service_id"; const std::string kPolicyAppId = "p_app_id"; const uint32_t kConnectionKey = 43629; +const uint32_t kHMIConnectionKey = 0; MATCHER_P(CapabilityUpdateMatcher, reason, "") { smart_objects::SmartObject& services_updated = @@ -100,8 +101,7 @@ class AppServiceManagerTest : public testing::Test { .WillByDefault(ReturnRef(mock_settings_)); ON_CALL(*mock_app_ptr_, policy_app_id()) .WillByDefault(Return(kPolicyAppId)); - ON_CALL(mock_last_state_, get_dictionary()) - .WillByDefault(ReturnRef(dict_)); + ON_CALL(mock_last_state_, get_dictionary()).WillByDefault(ReturnRef(dict_)); auto app_ptr = std::static_pointer_cast(mock_app_ptr_); ON_CALL(mock_app_manager_, application(kConnectionKey)) .WillByDefault(Return(app_ptr)); @@ -119,7 +119,7 @@ class AppServiceManagerTest : public testing::Test { return manifest; } - smart_objects::SmartObject PublishMobileService( + smart_objects::SmartObject PublishService( uint32_t connection_key = kConnectionKey, bool first_run = true) { smart_objects::SmartObject manifest = GenerateMediaManifest(true); @@ -131,18 +131,17 @@ class AppServiceManagerTest : public testing::Test { BroadcastCapabilityUpdate( CapabilityUpdateMatcher( mobile_apis::ServiceUpdateReason::PUBLISHED), - _)) - .WillOnce(Return()); + _)).WillOnce(Return()); if (first_run) { EXPECT_CALL(*mock_message_helper_, BroadcastCapabilityUpdate( CapabilityUpdateMatcher( mobile_apis::ServiceUpdateReason::ACTIVATED), - _)) - .WillOnce(Return()); + _)).WillOnce(Return()); } - - return app_service_manager_.PublishAppService(manifest, true, connection_key); + bool mobile_service = connection_key != kHMIConnectionKey; + return app_service_manager_.PublishAppService( + manifest, mobile_service, connection_key); } void CheckCapabilityUpdate(smart_objects::SmartObject& msg_params, @@ -151,17 +150,16 @@ class AppServiceManagerTest : public testing::Test { mobile_apis::ServiceUpdateReason::eType reason, bool published, bool active) { - smart_objects::SmartObject& services_updated = - msg_params[am::strings::system_capability] - [am::strings::app_services_capabilities] - [am::strings::app_services]; + smart_objects::SmartObject& services_updated = msg_params + [am::strings::system_capability][am::strings::app_services_capabilities] + [am::strings::app_services]; ASSERT_EQ(smart_objects::SmartType_Array, services_updated.getType()); EXPECT_EQ(length, services_updated.length()); for (size_t i = 0; i < services_updated.length(); i++) { smart_objects::SmartObject& service_cap = services_updated[i]; - if (service_id == service_cap[am::strings::updated_app_service_record] - [am::strings::service_id] - .asString()) { + if (service_id == + service_cap[am::strings::updated_app_service_record] + [am::strings::service_id].asString()) { CheckCapability(service_cap, service_id, reason, published, active); return; } @@ -180,7 +178,8 @@ class AppServiceManagerTest : public testing::Test { smart_objects::SmartObject& updated_record = app_service_capability[am::strings::updated_app_service_record]; EXPECT_EQ(service_id, updated_record[am::strings::service_id].asString()); - EXPECT_EQ(published, updated_record[am::strings::service_published].asBool()); + EXPECT_EQ(published, + updated_record[am::strings::service_published].asBool()); EXPECT_EQ(active, updated_record[am::strings::service_active].asBool()); } @@ -207,16 +206,14 @@ TEST_F(AppServiceManagerTest, PublishAppService_Mobile_SUCCESS) { *mock_message_helper_, BroadcastCapabilityUpdate( CapabilityUpdateMatcher(mobile_apis::ServiceUpdateReason::PUBLISHED), - _)) - .WillOnce(DoAll(SaveArg<0>(&syscap_update_published), Return())); - + _)).WillOnce(DoAll(SaveArg<0>(&syscap_update_published), Return())); + smart_objects::SmartObject syscap_update_activated; EXPECT_CALL( *mock_message_helper_, BroadcastCapabilityUpdate( CapabilityUpdateMatcher(mobile_apis::ServiceUpdateReason::ACTIVATED), - _)) - .WillOnce(DoAll(SaveArg<0>(&syscap_update_activated), Return())); + _)).WillOnce(DoAll(SaveArg<0>(&syscap_update_activated), Return())); auto record = app_service_manager_.PublishAppService(manifest, true, kConnectionKey); @@ -256,19 +253,16 @@ TEST_F(AppServiceManagerTest, PublishAppService_HMI_SUCCESS) { *mock_message_helper_, BroadcastCapabilityUpdate( CapabilityUpdateMatcher(mobile_apis::ServiceUpdateReason::PUBLISHED), - _)) - .WillOnce(DoAll(SaveArg<0>(&syscap_update_published), Return())); + _)).WillOnce(DoAll(SaveArg<0>(&syscap_update_published), Return())); smart_objects::SmartObject syscap_update_activated; EXPECT_CALL( *mock_message_helper_, BroadcastCapabilityUpdate( CapabilityUpdateMatcher(mobile_apis::ServiceUpdateReason::ACTIVATED), - _)) - .WillOnce(DoAll(SaveArg<0>(&syscap_update_activated), Return())); + _)).WillOnce(DoAll(SaveArg<0>(&syscap_update_activated), Return())); - auto record = - app_service_manager_.PublishAppService(manifest, false); + auto record = app_service_manager_.PublishAppService(manifest, false); // Check final record std::string service_id = record[am::strings::service_id].asString(); @@ -293,35 +287,55 @@ TEST_F(AppServiceManagerTest, PublishAppService_HMI_SUCCESS) { true); } +TEST_F(AppServiceManagerTest, UnpublishAppService_SUCCESS) { + auto record = PublishService(); + + smart_objects::SmartObject syscap_update_unpublished; + EXPECT_CALL( + *mock_message_helper_, + BroadcastCapabilityUpdate( + CapabilityUpdateMatcher(mobile_apis::ServiceUpdateReason::REMOVED), + _)).WillOnce(DoAll(SaveArg<0>(&syscap_update_unpublished), Return())); + std::string service_id = record[am::strings::service_id].asString(); + + EXPECT_TRUE(app_service_manager_.UnpublishAppService(service_id)); + + // Check removed capability update + CheckCapabilityUpdate(syscap_update_unpublished, + 1, + service_id, + mobile_apis::ServiceUpdateReason::REMOVED, + false, + false); +} + TEST_F(AppServiceManagerTest, ActivateAppService_AlreadyActivated) { - auto record = PublishMobileService(); + auto record = PublishService(); // No capability update EXPECT_CALL( *mock_message_helper_, BroadcastCapabilityUpdate( CapabilityUpdateMatcher(mobile_apis::ServiceUpdateReason::ACTIVATED), - _)) - .Times(0); + _)).Times(0); std::string service_id = record[am::strings::service_id].asString(); - + EXPECT_TRUE(app_service_manager_.ActivateAppService(service_id)); } TEST_F(AppServiceManagerTest, ActivateAppService_TwoApps_SUCCESS) { // Register two services with the same service type, the first is activated // automatically - auto record = PublishMobileService(); - auto record2 = PublishMobileService(kConnectionKey + 1, false); + auto record = PublishService(); + auto record2 = PublishService(kConnectionKey + 1, false); // No capability update smart_objects::SmartObject syscap_update_activated; - EXPECT_CALL(*mock_message_helper_, - BroadcastCapabilityUpdate( - CapabilityUpdateMatcher( - mobile_apis::ServiceUpdateReason::ACTIVATED), - _)) - .WillOnce(DoAll(SaveArg<0>(&syscap_update_activated), Return())); + EXPECT_CALL( + *mock_message_helper_, + BroadcastCapabilityUpdate( + CapabilityUpdateMatcher(mobile_apis::ServiceUpdateReason::ACTIVATED), + _)).WillOnce(DoAll(SaveArg<0>(&syscap_update_activated), Return())); std::string service_id = record[am::strings::service_id].asString(); std::string service_id2 = record2[am::strings::service_id].asString(); @@ -346,7 +360,7 @@ TEST_F(AppServiceManagerTest, ActivateAppService_TwoApps_SUCCESS) { } TEST_F(AppServiceManagerTest, DeactivateAppService_SUCCESS) { - auto record = PublishMobileService(); + auto record = PublishService(); smart_objects::SmartObject syscap_update_deactivated; EXPECT_CALL(*mock_message_helper_, @@ -359,7 +373,7 @@ TEST_F(AppServiceManagerTest, DeactivateAppService_SUCCESS) { EXPECT_TRUE(app_service_manager_.DeactivateAppService(service_id)); - // Check deactivated capability updated + // Check deactivated capability update CheckCapabilityUpdate(syscap_update_deactivated, 1, service_id, @@ -369,12 +383,56 @@ TEST_F(AppServiceManagerTest, DeactivateAppService_SUCCESS) { } TEST_F(AppServiceManagerTest, ActiveServiceForType_SUCCESS) { - auto record = PublishMobileService(); + auto record = PublishService(); auto service = app_service_manager_.ActiveServiceForType(kServiceType); ASSERT_FALSE(service == NULL); - EXPECT_EQ(service->record, record); + EXPECT_EQ(record, service->record); + EXPECT_EQ(kConnectionKey, service->connection_key); + EXPECT_EQ(true, service->mobile_service); +} + +TEST_F(AppServiceManagerTest, EmbeddedServiceForType_SUCCESS) { + auto record = PublishService(kHMIConnectionKey); + + auto service = app_service_manager_.EmbeddedServiceForType(kServiceType); + + ASSERT_FALSE(service == NULL); + EXPECT_EQ(record, service->record); + EXPECT_EQ(false, service->mobile_service); +} + +TEST_F(AppServiceManagerTest, FindServiceByID_SUCCESS) { + auto record = PublishService(); + + std::string service_id = record[am::strings::service_id].asString(); + auto service = app_service_manager_.FindServiceByID(service_id); + + ASSERT_FALSE(service == NULL); + EXPECT_EQ(record, service->record); + EXPECT_EQ(kConnectionKey, service->connection_key); + EXPECT_EQ(true, service->mobile_service); +} + +TEST_F(AppServiceManagerTest, GetAllServiceRecords_OneService_SUCCESS) { + auto record = PublishService(); + + auto records = app_service_manager_.GetAllServiceRecords(); + + ASSERT_EQ(1u, records.size()); + EXPECT_EQ(record, records[0]); +} + +TEST_F(AppServiceManagerTest, GetActiveServices_OneService_SUCCESS) { + auto record = PublishService(); + + auto services = app_service_manager_.GetActiveServices(); + + ASSERT_EQ(1u, services.size()); + EXPECT_EQ(record, services[0].record); + EXPECT_EQ(kConnectionKey, services[0].connection_key); + EXPECT_EQ(true, services[0].mobile_service); } } // namespace application_manager_test diff --git a/src/components/application_manager/test/include/application_manager/mock_app_service_manager.h b/src/components/application_manager/test/include/application_manager/mock_app_service_manager.h index 87d0755748..311268689a 100644 --- a/src/components/application_manager/test/include/application_manager/mock_app_service_manager.h +++ b/src/components/application_manager/test/include/application_manager/mock_app_service_manager.h @@ -45,10 +45,11 @@ class MockAppServiceManager : public application_manager::AppServiceManager { MockAppServiceManager(application_manager::ApplicationManager& app_manager, resumption::LastState& last_state) : application_manager::AppServiceManager(app_manager, last_state) {} - MOCK_METHOD3(PublishAppService, smart_objects::SmartObject( - const smart_objects::SmartObject& manifest, - const bool mobile_service, - const uint32_t connection_key)); + MOCK_METHOD3( + PublishAppService, + smart_objects::SmartObject(const smart_objects::SmartObject& manifest, + const bool mobile_service, + const uint32_t connection_key)); MOCK_METHOD1(UnpublishAppService, bool(const std::string service_id)); MOCK_METHOD1(UnpublishServices, void(const uint32_t connection_key)); MOCK_METHOD1(OnAppActivated, @@ -58,9 +59,8 @@ class MockAppServiceManager : public application_manager::AppServiceManager { MOCK_METHOD1(ActivateAppService, bool(const std::string service_id)); MOCK_METHOD1(DeactivateAppService, bool(const std::string service_id)); MOCK_METHOD0(GetAllServiceRecords, std::vector()); - MOCK_METHOD0( - GetActiveServices, - std::vector()); + MOCK_METHOD0(GetActiveServices, + std::vector()); MOCK_METHOD4(GetProviderByType, void(const std::string& service_type, const bool mobile_consumer, -- cgit v1.2.1 From e169090156eb89a060088df093b254599d4b4c68 Mon Sep 17 00:00:00 2001 From: jacobkeeler Date: Sat, 16 Mar 2019 17:00:27 -0400 Subject: Add safety checks in PerformAppServiceInteraction and GetAppServiceData --- .../commands/mobile/get_app_service_data_request.h | 2 ++ .../mobile/get_app_service_data_request.cc | 22 +++++++++++++++------- .../perform_app_service_interaction_request.cc | 9 +++++++++ 3 files changed, 26 insertions(+), 7 deletions(-) diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/mobile/get_app_service_data_request.h b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/mobile/get_app_service_data_request.h index 70cf0dc6b9..7c80ec5e03 100644 --- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/mobile/get_app_service_data_request.h +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/mobile/get_app_service_data_request.h @@ -77,6 +77,8 @@ class GetAppServiceDataRequest : public app_mngr::commands::CommandRequestImpl { virtual void on_event(const app_mngr::event_engine::MobileEvent& event); private: + void HandleSubscribe(); + DISALLOW_COPY_AND_ASSIGN(GetAppServiceDataRequest); }; diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/get_app_service_data_request.cc b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/get_app_service_data_request.cc index d8ff1d8040..7b29160692 100644 --- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/get_app_service_data_request.cc +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/get_app_service_data_request.cc @@ -59,13 +59,20 @@ GetAppServiceDataRequest::~GetAppServiceDataRequest() {} void GetAppServiceDataRequest::Run() { LOG4CXX_AUTO_TRACE(logger_); + SendProviderRequest(mobile_apis::FunctionID::GetAppServiceDataID, + hmi_apis::FunctionID::AppService_GetAppServiceData, + &(*message_), + true); +} + +void GetAppServiceDataRequest::HandleSubscribe() { std::string service_type = (*message_)[strings::msg_params][strings::service_type].asString(); - - ApplicationSharedPtr app = application_manager_.application(connection_key()); if ((*message_)[strings::msg_params].keyExists(strings::subscribe)) { bool subscribe = (*message_)[strings::msg_params][strings::subscribe].asBool(); + ApplicationSharedPtr app = + application_manager_.application(connection_key()); auto& ext = AppServiceAppExtension::ExtractASExtension(*app); if (subscribe) { ext.SubscribeToAppService(service_type); @@ -73,11 +80,6 @@ void GetAppServiceDataRequest::Run() { ext.UnsubscribeFromAppService(service_type); } } - - SendProviderRequest(mobile_apis::FunctionID::GetAppServiceDataID, - hmi_apis::FunctionID::AppService_GetAppServiceData, - &(*message_), - true); } void GetAppServiceDataRequest::on_event( @@ -89,6 +91,9 @@ void GetAppServiceDataRequest::on_event( mobile_apis::Result::eType result = static_cast( msg_params[strings::result_code].asInt()); bool success = IsMobileResultSuccess(result); + if (success) { + HandleSubscribe(); + } const char* info = msg_params.keyExists(strings::info) ? msg_params[strings::info].asCharArray() @@ -110,6 +115,9 @@ void GetAppServiceDataRequest::on_event(const event_engine::Event& event) { MessageHelper::HMIToMobileResult(hmi_result); bool success = PrepareResultForMobileResponse( hmi_result, HmiInterfaces::HMI_INTERFACE_AppService); + if (success) { + HandleSubscribe(); + } const char* info = msg_params.keyExists(strings::info) ? msg_params[strings::info].asCharArray() diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/perform_app_service_interaction_request.cc b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/perform_app_service_interaction_request.cc index 989b57ca12..4046ac7379 100644 --- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/perform_app_service_interaction_request.cc +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/perform_app_service_interaction_request.cc @@ -75,6 +75,15 @@ void PerformAppServiceInteractionRequest::Run() { return; } + if (!service->record[strings::service_manifest][strings::allow_app_consumers] + .asBool()) { + SendResponse( + false, + mobile_apis::Result::REJECTED, + "The requested service ID does not allow mobile app consumers"); + return; + } + bool request_service_active = false; if (msg_params.keyExists(strings::request_service_active)) { request_service_active = -- cgit v1.2.1 From 04edfb6b21232dffb3598feca80e2f8e2bf7783c Mon Sep 17 00:00:00 2001 From: Shobhit Adlakha Date: Sat, 16 Mar 2019 17:40:17 -0400 Subject: App service mobile and hmi command creation unit tests (#2843) * Created dummy_command_tests for app_service_rpc_plugin and added other App Service related RPCs * Set expectation that shared_ptr for command was succesfully created in dummy_command_tests --- .../app_service_rpc_plugin/CMakeLists.txt | 2 +- .../app_service_rpc_plugin/test/CMakeLists.txt | 37 +++++ .../test/commands/hmi/dummy_hmi_commands_test.cc | 151 +++++++++++++++++++++ .../commands/mobile/dummy_mobile_commands_test.cc | 135 ++++++++++++++++++ .../test/commands/hmi/dummy_hmi_commands_test.cc | 16 ++- .../commands/mobile/dummy_mobile_commands_test.cc | 30 ++-- 6 files changed, 352 insertions(+), 19 deletions(-) create mode 100644 src/components/application_manager/rpc_plugins/app_service_rpc_plugin/test/CMakeLists.txt create mode 100644 src/components/application_manager/rpc_plugins/app_service_rpc_plugin/test/commands/hmi/dummy_hmi_commands_test.cc create mode 100644 src/components/application_manager/rpc_plugins/app_service_rpc_plugin/test/commands/mobile/dummy_mobile_commands_test.cc diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/CMakeLists.txt b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/CMakeLists.txt index 2bdc150906..1e23aac8ee 100644 --- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/CMakeLists.txt +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/CMakeLists.txt @@ -80,5 +80,5 @@ install(TARGETS app_service_rpc_plugin ) if(BUILD_TESTS) - # add_subdirectory(test) + add_subdirectory(test) endif() diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/test/CMakeLists.txt b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/test/CMakeLists.txt new file mode 100644 index 0000000000..63b52da062 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/test/CMakeLists.txt @@ -0,0 +1,37 @@ +include(${CMAKE_SOURCE_DIR}/tools/cmake/helpers/sources.cmake) + +include_directories( + ${GMOCK_INCLUDE_DIRECTORY} + ${COMPONENTS_DIR}/application_manager/rpc_plugins/app_service_rpc_plugin/include + ${COMPONENTS_DIR}/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/ + ${COMPONENTS_DIR}/application_manager/test/include/ + ${POLICY_MOCK_INCLUDE_PATH}/ + ${CMAKE_SOURCE_DIR}/src +) + + +set(COMMANDS_TEST_DIR ${CMAKE_CURRENT_SOURCE_DIR}/commands) + +file(GLOB SOURCES + ${COMPONENTS_DIR}/application_manager/test/mock_message_helper.cc + ${COMPONENTS_DIR}/application_manager/test/mock_application_helper.cc + ${COMPONENTS_DIR}/application_manager/src/smart_object_keys.cc + ${COMMANDS_TEST_DIR}/hmi/* + ${COMMANDS_TEST_DIR}/mobile/* + ${COMPONENTS_DIR}/application_manager/src/message.cc + ${COMPONENTS_DIR}/application_manager/src/event_engine/* +) + +set(LIBRARIES + gmock + Utils + SmartObjects + HMI_API + MOBILE_API + connectionHandler + app_service_rpc_plugin + jsoncpp + Policy +) + +create_cotired_test("app_services_commands_test" "${SOURCES}" "${LIBRARIES}" ) diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/test/commands/hmi/dummy_hmi_commands_test.cc b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/test/commands/hmi/dummy_hmi_commands_test.cc new file mode 100644 index 0000000000..8ef87b6de9 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/test/commands/hmi/dummy_hmi_commands_test.cc @@ -0,0 +1,151 @@ +/* + * Copyright (c) 2018, 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 "application_manager/commands/command_request_test.h" + +#include +#include +#include +#include "gtest/gtest.h" + +#include "hmi/as_app_service_activation_request.h" +#include "hmi/as_app_service_activation_response.h" +#include "hmi/as_get_active_service_consent_request.h" +#include "hmi/as_get_active_service_consent_response.h" +#include "hmi/as_get_app_service_data_request_from_hmi.h" +#include "hmi/as_get_app_service_data_request_to_hmi.h" +#include "hmi/as_get_app_service_data_response_from_hmi.h" +#include "hmi/as_get_app_service_data_response_to_hmi.h" +#include "hmi/as_get_app_service_records_request.h" +#include "hmi/as_get_app_service_records_response.h" +#include "hmi/as_perform_app_service_interaction_request_from_hmi.h" +#include "hmi/as_perform_app_service_interaction_request_to_hmi.h" +#include "hmi/as_perform_app_service_interaction_response_from_hmi.h" +#include "hmi/as_perform_app_service_interaction_response_to_hmi.h" +#include "hmi/as_publish_app_service_request.h" +#include "hmi/as_publish_app_service_response.h" +#include "hmi/on_as_app_service_data_notification.h" +#include "hmi/on_as_app_service_data_notification_from_hmi.h" + +#include "application_manager/commands/commands_test.h" +#include "application_manager/mock_application.h" +#include "application_manager/mock_application_manager.h" +#include "application_manager/mock_application_manager_settings.h" +#include "application_manager/mock_event_dispatcher.h" + +namespace am = application_manager; + +namespace test { +namespace components { +namespace commands_test { +namespace hmi_commands_test { +namespace dummy_hmi_commands_test { + +namespace commands = app_service_rpc_plugin::commands; + +using ::testing::_; +using ::testing::NotNull; +using ::testing::Types; +using application_manager::commands::MessageSharedPtr; +using ::test::components::event_engine_test::MockEventDispatcher; +using ::test::components::application_manager_test::MockApplicationManager; +using ::test::components::application_manager_test:: + MockApplicationManagerSettings; +using ::application_manager::ApplicationSharedPtr; +using ::test::components::application_manager_test::MockApplication; + +template +class HMICommandsTest : public components::commands_test::CommandRequestTest< + CommandsTestMocks::kIsNice> { + public: + typedef Command CommandType; + + void InitCommand(const uint32_t& timeout) OVERRIDE { + stream_retry_.first = 0; + stream_retry_.second = 0; + EXPECT_CALL(app_mngr_settings_, default_timeout()) + .WillOnce(ReturnRef(timeout)); + ON_CALL(app_mngr_, event_dispatcher()) + .WillByDefault(ReturnRef(event_dispatcher_)); + ON_CALL(app_mngr_, get_settings()) + .WillByDefault(ReturnRef(app_mngr_settings_)); + ON_CALL(app_mngr_settings_, start_stream_retry_amount()) + .WillByDefault(ReturnRef(stream_retry_)); + } + + protected: + std::pair stream_retry_; +}; + +template +class HMICommandsTestFirst : public HMICommandsTest { + public: + using typename HMICommandsTest::CommandType; +}; + +/* macro TYPED_TEST_CASE takes max 50 args. That is why there are few + * TYPED_TEST_CASE for HMI and mobile commands + */ + +typedef Types + HMICommandsListFirst; + +TYPED_TEST_CASE(HMICommandsTestFirst, HMICommandsListFirst); + +TYPED_TEST(HMICommandsTestFirst, CtorAndDtorCall) { + std::shared_ptr command = + this->template CreateCommand(); + EXPECT_NE(command.use_count(), 0); +} + +} // namespace dummy_hmi_commands_test +} // namespace hmi_commands_test +} // namespace commands_test +} // namespace components +} // namespace test diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/test/commands/mobile/dummy_mobile_commands_test.cc b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/test/commands/mobile/dummy_mobile_commands_test.cc new file mode 100644 index 0000000000..3c8a780128 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/test/commands/mobile/dummy_mobile_commands_test.cc @@ -0,0 +1,135 @@ +/* + * Copyright (c) 2018, 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 "application_manager/commands/command_request_test.h" + +#include +#include +#include +#include "gtest/gtest.h" + +#include "mobile/get_app_service_data_request.h" +#include "mobile/get_app_service_data_request_to_mobile.h" +#include "mobile/get_app_service_data_response.h" +#include "mobile/get_app_service_data_response_from_mobile.h" +#include "mobile/on_app_service_data_notification.h" +#include "mobile/on_app_service_data_notification_from_mobile.h" +#include "mobile/perform_app_service_interaction_request.h" +#include "mobile/perform_app_service_interaction_request_to_mobile.h" +#include "mobile/perform_app_service_interaction_response.h" +#include "mobile/perform_app_service_interaction_response_from_mobile.h" +#include "mobile/publish_app_service_request.h" +#include "mobile/publish_app_service_response.h" + +#include "application_manager/mock_application.h" +#include "application_manager/mock_application_manager.h" +#include "test/application_manager/mock_application_manager_settings.h" +#include "application_manager/mock_event_dispatcher.h" + +namespace am = application_manager; + +namespace test { +namespace components { +namespace commands_test { +namespace mobile_commands_test { +namespace dummy_mobile_commands_test { + +namespace commands = app_service_rpc_plugin::commands; +using ::testing::_; +using ::testing::NotNull; +using ::testing::Types; +using am::commands::MessageSharedPtr; +using ::test::components::event_engine_test::MockEventDispatcher; +using ::test::components::application_manager_test::MockApplicationManager; +using ::test::components::application_manager_test:: + MockApplicationManagerSettings; +using ::application_manager::ApplicationSharedPtr; +using ::test::components::application_manager_test::MockApplication; + +namespace { +const std::string kEmptyString_ = ""; +} // namespace + +template +class MobileCommandsTest : public components::commands_test::CommandRequestTest< + CommandsTestMocks::kIsNice> { + public: + typedef Command CommandType; + + void InitCommand(const uint32_t& timeout) OVERRIDE { + EXPECT_CALL(app_mngr_settings_, default_timeout()) + .WillOnce(ReturnRef(timeout)); + ON_CALL(app_mngr_, event_dispatcher()) + .WillByDefault(ReturnRef(event_dispatcher_)); + ON_CALL(app_mngr_, get_settings()) + .WillByDefault(ReturnRef(app_mngr_settings_)); + ON_CALL(app_mngr_settings_, app_icons_folder()) + .WillByDefault(ReturnRef(kEmptyString_)); + } +}; + +template +class MobileCommandsTestFirst : public MobileCommandsTest { + public: + using typename MobileCommandsTest::CommandType; +}; + +/* macro TYPED_TEST_CASE takes max 50 args. That is why there are few + * TYPED_TEST_CASE for HMI and mobile commands + */ + +typedef Types MobileCommandsListFirst; + +TYPED_TEST_CASE(MobileCommandsTestFirst, MobileCommandsListFirst); + +TYPED_TEST(MobileCommandsTestFirst, CtorAndDtorCall) { + std::shared_ptr command = + this->template CreateCommand(); + EXPECT_NE(command.use_count(), 0); +} + +} // namespace dummy_mobile_commands_test +} // namespace mobile_commands_test +} // namespace commands_test +} // namespace components +} // namespace test diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/dummy_hmi_commands_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/dummy_hmi_commands_test.cc index a6497ca6e1..874d27b4b0 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/dummy_hmi_commands_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/dummy_hmi_commands_test.cc @@ -223,6 +223,8 @@ #include "hmi/on_tts_reset_timeout_notification.h" #include "hmi/dial_number_request.h" #include "hmi/dial_number_response.h" +#include "hmi/bc_get_file_path_request.h" +#include "hmi/bc_get_file_path_response.h" #include "application_manager/commands/commands_test.h" #include "application_manager/mock_application.h" @@ -496,7 +498,9 @@ typedef Types HMICommandsListFifth; + commands::AllowAppResponse, + commands::BCGetFilePathRequest, + commands::BCGetFilePathResponse> HMICommandsListFifth; TYPED_TEST_CASE(HMICommandsTestFirst, HMICommandsListFirst); TYPED_TEST_CASE(HMICommandsTestSecond, HMICommandsListSecond); @@ -507,30 +511,30 @@ TYPED_TEST_CASE(HMICommandsTestFifth, HMICommandsListFifth); TYPED_TEST(HMICommandsTestFirst, CtorAndDtorCall) { std::shared_ptr command = this->template CreateCommand(); - UNUSED(command); + EXPECT_NE(command.use_count(), 0); } TYPED_TEST(HMICommandsTestSecond, CtorAndDtorCall) { std::shared_ptr command = this->template CreateCommand(); - UNUSED(command); + EXPECT_NE(command.use_count(), 0); } TYPED_TEST(HMICommandsTestThird, CtorAndDtorCall) { std::shared_ptr command = this->template CreateCommand(); - UNUSED(command); + EXPECT_NE(command.use_count(), 0); } TYPED_TEST(HMICommandsTestFourth, CtorAndDtorCall) { std::shared_ptr command = this->template CreateCommand(); - UNUSED(command); + EXPECT_NE(command.use_count(), 0); } TYPED_TEST(HMICommandsTestFifth, CtorAndDtorCall) { std::shared_ptr command = this->template CreateCommand(); - UNUSED(command); + EXPECT_NE(command.use_count(), 0); } } // namespace dummy_hmi_commands_test diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/dummy_mobile_commands_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/dummy_mobile_commands_test.cc index 8589cbb6be..9c20143c39 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/dummy_mobile_commands_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/dummy_mobile_commands_test.cc @@ -62,6 +62,8 @@ #include "mobile/end_audio_pass_thru_request.h" #include "mobile/end_audio_pass_thru_response.h" #include "mobile/generic_response.h" +#include "mobile/get_file_request.h" +#include "mobile/get_file_response.h" #include "mobile/get_way_points_request.h" #include "mobile/get_way_points_response.h" #include "mobile/list_files_request.h" @@ -78,6 +80,7 @@ #include "mobile/on_keyboard_input_notification.h" #include "mobile/on_language_change_notification.h" #include "mobile/on_permissions_change_notification.h" +#include "mobile/on_system_capability_updated_notification.h" #include "mobile/on_system_request_notification.h" #include "mobile/on_tbt_client_state_notification.h" #include "mobile/on_touch_event_notification.h" @@ -220,6 +223,8 @@ typedef Types + commands::mobile::OnSystemCapabilityUpdatedNotification> MobileCommandsListFirst; -typedef Types MobileCommandsListSecond; + commands::UnregisterAppInterfaceRequest> MobileCommandsListSecond; -typedef Types MobileCommandsListThird; @@ -294,18 +300,18 @@ TYPED_TEST_CASE(MobileCommandsTestThird, MobileCommandsListThird); TYPED_TEST(MobileCommandsTestFirst, CtorAndDtorCall) { std::shared_ptr command = this->template CreateCommand(); - UNUSED(command); + EXPECT_NE(command.use_count(), 0); } TYPED_TEST(MobileCommandsTestSecond, CtorAndDtorCall) { std::shared_ptr command = this->template CreateCommand(); - UNUSED(command); + EXPECT_NE(command.use_count(), 0); } TYPED_TEST(MobileCommandsTestThird, CtorAndDtorCall) { std::shared_ptr command = this->template CreateCommand(); - UNUSED(command); + EXPECT_NE(command.use_count(), 0); } } // namespace dummy_mobile_commands_test -- cgit v1.2.1 From 95dc54877f2238c2ad6599204c17fd83ba7d3aa3 Mon Sep 17 00:00:00 2001 From: jacobkeeler Date: Sat, 16 Mar 2019 18:58:07 -0400 Subject: Address comments and fix CI failures --- .../test/app_service_manager_test.cc | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/src/components/application_manager/test/app_service_manager_test.cc b/src/components/application_manager/test/app_service_manager_test.cc index 406f6fe0ce..960e8e31f6 100644 --- a/src/components/application_manager/test/app_service_manager_test.cc +++ b/src/components/application_manager/test/app_service_manager_test.cc @@ -197,7 +197,6 @@ TEST_F(AppServiceManagerTest, PublishAppService_Mobile_SUCCESS) { smart_objects::SmartObject manifest = GenerateMediaManifest(true); Json::Value empty_json; - // dict[kAppServiceSection][kDefaults][kServiceType] = kPolicyAppId; EXPECT_CALL(mock_last_state_, get_dictionary()) .WillOnce(ReturnRef(empty_json)); @@ -221,8 +220,8 @@ TEST_F(AppServiceManagerTest, PublishAppService_Mobile_SUCCESS) { // Check final record std::string service_id = record[am::strings::service_id].asString(); EXPECT_EQ(manifest, record[am::strings::service_manifest]); - EXPECT_EQ(true, record[am::strings::service_published].asBool()); - EXPECT_EQ(true, record[am::strings::service_active].asBool()); + EXPECT_TRUE(record[am::strings::service_published].asBool()); + EXPECT_TRUE(record[am::strings::service_active].asBool()); // Check first capability update CheckCapabilityUpdate(syscap_update_published, @@ -267,8 +266,8 @@ TEST_F(AppServiceManagerTest, PublishAppService_HMI_SUCCESS) { // Check final record std::string service_id = record[am::strings::service_id].asString(); EXPECT_EQ(manifest, record[am::strings::service_manifest]); - EXPECT_EQ(true, record[am::strings::service_published].asBool()); - EXPECT_EQ(true, record[am::strings::service_active].asBool()); + EXPECT_TRUE(record[am::strings::service_published].asBool()); + EXPECT_TRUE(record[am::strings::service_active].asBool()); // Check first capability update CheckCapabilityUpdate(syscap_update_published, @@ -390,7 +389,7 @@ TEST_F(AppServiceManagerTest, ActiveServiceForType_SUCCESS) { ASSERT_FALSE(service == NULL); EXPECT_EQ(record, service->record); EXPECT_EQ(kConnectionKey, service->connection_key); - EXPECT_EQ(true, service->mobile_service); + EXPECT_TRUE(service->mobile_service); } TEST_F(AppServiceManagerTest, EmbeddedServiceForType_SUCCESS) { @@ -400,7 +399,7 @@ TEST_F(AppServiceManagerTest, EmbeddedServiceForType_SUCCESS) { ASSERT_FALSE(service == NULL); EXPECT_EQ(record, service->record); - EXPECT_EQ(false, service->mobile_service); + EXPECT_FALSE(service->mobile_service); } TEST_F(AppServiceManagerTest, FindServiceByID_SUCCESS) { @@ -412,7 +411,7 @@ TEST_F(AppServiceManagerTest, FindServiceByID_SUCCESS) { ASSERT_FALSE(service == NULL); EXPECT_EQ(record, service->record); EXPECT_EQ(kConnectionKey, service->connection_key); - EXPECT_EQ(true, service->mobile_service); + EXPECT_TRUE(service->mobile_service); } TEST_F(AppServiceManagerTest, GetAllServiceRecords_OneService_SUCCESS) { @@ -432,7 +431,7 @@ TEST_F(AppServiceManagerTest, GetActiveServices_OneService_SUCCESS) { ASSERT_EQ(1u, services.size()); EXPECT_EQ(record, services[0].record); EXPECT_EQ(kConnectionKey, services[0].connection_key); - EXPECT_EQ(true, services[0].mobile_service); + EXPECT_TRUE(services[0].mobile_service); } } // namespace application_manager_test -- cgit v1.2.1 From 57c4c45dc343217c25b6fd0985516d35326363af Mon Sep 17 00:00:00 2001 From: jacobkeeler Date: Sun, 17 Mar 2019 09:48:58 -0400 Subject: Fix build failure after merge --- .../rpc_plugins/app_service_rpc_plugin/test/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/test/CMakeLists.txt b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/test/CMakeLists.txt index 63b52da062..97d2efaf07 100644 --- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/test/CMakeLists.txt +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/test/CMakeLists.txt @@ -30,6 +30,7 @@ set(LIBRARIES MOBILE_API connectionHandler app_service_rpc_plugin + sdl_rpc_plugin jsoncpp Policy ) -- cgit v1.2.1 From 14b83db71c0fd4249f5753134a33e4e36f6a775f Mon Sep 17 00:00:00 2001 From: jacobkeeler Date: Sun, 17 Mar 2019 10:50:10 -0400 Subject: Add null check for app in HandleSubscribe --- .../src/commands/mobile/get_app_service_data_request.cc | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/get_app_service_data_request.cc b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/get_app_service_data_request.cc index 7b29160692..7c2e62abe2 100644 --- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/get_app_service_data_request.cc +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/get_app_service_data_request.cc @@ -68,11 +68,10 @@ void GetAppServiceDataRequest::Run() { void GetAppServiceDataRequest::HandleSubscribe() { std::string service_type = (*message_)[strings::msg_params][strings::service_type].asString(); - if ((*message_)[strings::msg_params].keyExists(strings::subscribe)) { + ApplicationSharedPtr app = application_manager_.application(connection_key()); + if (app && (*message_)[strings::msg_params].keyExists(strings::subscribe)) { bool subscribe = (*message_)[strings::msg_params][strings::subscribe].asBool(); - ApplicationSharedPtr app = - application_manager_.application(connection_key()); auto& ext = AppServiceAppExtension::ExtractASExtension(*app); if (subscribe) { ext.SubscribeToAppService(service_type); -- cgit v1.2.1 From c7cfce0fe516b1b5edb231fe65b1e6d57580abd6 Mon Sep 17 00:00:00 2001 From: JackLivio Date: Sun, 17 Mar 2019 13:49:14 -0400 Subject: Address comments --- .../test/policy_handler_test.cc | 48 ++++++++++++---------- .../test/policy_manager_impl_test.cc | 12 +++--- .../test/policy_manager_impl_test.cc | 12 +++--- .../test/sql_pt_representation_test.cc | 8 ++-- 4 files changed, 45 insertions(+), 35 deletions(-) diff --git a/src/components/application_manager/test/policy_handler_test.cc b/src/components/application_manager/test/policy_handler_test.cc index da6e45162a..27e9120661 100644 --- a/src/components/application_manager/test/policy_handler_test.cc +++ b/src/components/application_manager/test/policy_handler_test.cc @@ -403,13 +403,17 @@ TEST_F(PolicyHandlerTest, AppServiceUpdate_CheckAppService) { policy_table::AppServiceParameters app_service_params = policy_table::AppServiceParameters(); - (app_service_params)["MEDIA"] = policy_table::AppServiceInfo(); - (app_service_params)["MEDIA"].service_names->push_back("SDL App"); - (app_service_params)["MEDIA"].service_names->push_back("SDL Music"); - (app_service_params)["MEDIA"].service_names->mark_initialized(); + std::string media_str = "MEDIA"; + std::string as_app_id = "1010101010"; + std::string service_name1 = "SDL Music"; + std::string service_name2 = "SDL App"; + (app_service_params)[media_str] = policy_table::AppServiceInfo(); + (app_service_params)[media_str].service_names->push_back(service_name2); + (app_service_params)[media_str].service_names->push_back(service_name1); + (app_service_params)[media_str].service_names->mark_initialized(); policy_table::AppServiceHandledRpc handled_rpc; handled_rpc.function_id = 41; - (app_service_params)["MEDIA"].handled_rpcs.push_back(handled_rpc); + (app_service_params)[media_str].handled_rpcs.push_back(handled_rpc); EXPECT_CALL(*mock_policy_manager_, GetAppServiceParameters(_, _)) .WillRepeatedly(SetArgPointee<1>(app_service_params)); @@ -421,23 +425,23 @@ TEST_F(PolicyHandlerTest, AppServiceUpdate_CheckAppService) { ns_smart_device_link::ns_smart_objects::SmartObject fake_rpc_id(40); fake_handled_rpcs.push_back(fake_rpc_id); - ASSERT_TRUE(policy_handler_.CheckAppServiceParameters( - "1010101010", "SDL Music", "MEDIA", &requested_handled_rpcs)); - ASSERT_TRUE(policy_handler_.CheckAppServiceParameters( - "1010101010", "SDL App", "MEDIA", &requested_handled_rpcs)); - ASSERT_TRUE(policy_handler_.CheckAppServiceParameters( - "1010101010", "SDL App", "MEDIA", NULL)); - ASSERT_TRUE(policy_handler_.CheckAppServiceParameters( - "1010101010", "", "MEDIA", NULL)); - - ASSERT_FALSE( - policy_handler_.CheckAppServiceParameters("1010101010", "", "", NULL)); - ASSERT_FALSE(policy_handler_.CheckAppServiceParameters( - "1010101010", "SDL App", "NAVIGATION", &requested_handled_rpcs)); - ASSERT_FALSE(policy_handler_.CheckAppServiceParameters( - "1010101010", "MUSIC", "MEDIA", &requested_handled_rpcs)); - ASSERT_FALSE(policy_handler_.CheckAppServiceParameters( - "1010101010", "SDL App", "MEDIA", &fake_handled_rpcs)); + EXPECT_TRUE(policy_handler_.CheckAppServiceParameters( + as_app_id, service_name1, media_str, &requested_handled_rpcs)); + EXPECT_TRUE(policy_handler_.CheckAppServiceParameters( + as_app_id, service_name2, media_str, &requested_handled_rpcs)); + EXPECT_TRUE(policy_handler_.CheckAppServiceParameters( + as_app_id, service_name2, media_str, NULL)); + EXPECT_TRUE(policy_handler_.CheckAppServiceParameters( + as_app_id, "", media_str, NULL)); + + EXPECT_FALSE( + policy_handler_.CheckAppServiceParameters(as_app_id, "", "", NULL)); + EXPECT_FALSE(policy_handler_.CheckAppServiceParameters( + as_app_id, service_name2, "NAVIGATION", &requested_handled_rpcs)); + EXPECT_FALSE(policy_handler_.CheckAppServiceParameters( + as_app_id, "MUSIC", media_str, &requested_handled_rpcs)); + EXPECT_FALSE(policy_handler_.CheckAppServiceParameters( + as_app_id, service_name2, media_str, &fake_handled_rpcs)); } TEST_F(PolicyHandlerTest, ReceiveMessageFromSDK) { diff --git a/src/components/policy/policy_external/test/policy_manager_impl_test.cc b/src/components/policy/policy_external/test/policy_manager_impl_test.cc index 5af345eb7c..0d70f7d198 100644 --- a/src/components/policy/policy_external/test/policy_manager_impl_test.cc +++ b/src/components/policy/policy_external/test/policy_manager_impl_test.cc @@ -347,6 +347,7 @@ TEST_F(PolicyManagerImplTest2, GetCurrentDeviceId) { TEST_F(PolicyManagerImplTest2, UpdateApplication_AppServices) { // Arrange + std::string media_str = "MEDIA"; CreateLocalPT(preloaded_pt_filename_); EXPECT_EQ("UP_TO_DATE", policy_manager_->GetPolicyTableStatus()); GetPTU("json/valid_sdl_pt_update.json"); @@ -356,18 +357,19 @@ TEST_F(PolicyManagerImplTest2, UpdateApplication_AppServices) { policy_table::AppServiceParameters(); policy_manager_->GetAppServiceParameters(app_id_2_, &app_service_parameters); - ASSERT_FALSE(app_service_parameters.find("MEDIA") == + ASSERT_FALSE(app_service_parameters.find(media_str) == app_service_parameters.end()); - auto service_names = *(app_service_parameters["MEDIA"].service_names); + auto service_names = *(app_service_parameters[media_str].service_names); - EXPECT_TRUE(service_names.is_initialized()); + ASSERT_TRUE(service_names.is_initialized()); + ASSERT_EQ(service_names.size(), 2u); EXPECT_EQ(static_cast(service_names[0]), "SDL App"); EXPECT_EQ(static_cast(service_names[1]), "SDL Music"); - auto handled_rpcs = app_service_parameters["MEDIA"].handled_rpcs; + auto handled_rpcs = app_service_parameters[media_str].handled_rpcs; - EXPECT_TRUE(handled_rpcs.is_initialized()); + ASSERT_TRUE(handled_rpcs.is_initialized()); EXPECT_EQ(handled_rpcs[0].function_id, 41); // Check no update required diff --git a/src/components/policy/policy_regular/test/policy_manager_impl_test.cc b/src/components/policy/policy_regular/test/policy_manager_impl_test.cc index 5f3e81232e..da5a677602 100644 --- a/src/components/policy/policy_regular/test/policy_manager_impl_test.cc +++ b/src/components/policy/policy_regular/test/policy_manager_impl_test.cc @@ -835,6 +835,7 @@ TEST_F( } TEST_F(PolicyManagerImplTest2, UpdateApplication_AppServices) { + std::string media_str = "MEDIA"; // Arrange CreateLocalPT("sdl_preloaded_pt.json"); EXPECT_EQ("UP_TO_DATE", manager->GetPolicyTableStatus()); @@ -845,18 +846,19 @@ TEST_F(PolicyManagerImplTest2, UpdateApplication_AppServices) { policy_table::AppServiceParameters(); manager->GetAppServiceParameters(app_id2, &app_service_parameters); - ASSERT_FALSE(app_service_parameters.find("MEDIA") == + ASSERT_FALSE(app_service_parameters.find(media_str) == app_service_parameters.end()); - auto service_names = *(app_service_parameters["MEDIA"].service_names); + auto service_names = *(app_service_parameters[media_str].service_names); - EXPECT_TRUE(service_names.is_initialized()); + ASSERT_TRUE(service_names.is_initialized()); + ASSERT_EQ(service_names.size(), 2u); EXPECT_EQ(static_cast(service_names[0]), "SDL App"); EXPECT_EQ(static_cast(service_names[1]), "SDL Music"); - auto handled_rpcs = app_service_parameters["MEDIA"].handled_rpcs; + auto handled_rpcs = app_service_parameters[media_str].handled_rpcs; - EXPECT_TRUE(handled_rpcs.is_initialized()); + ASSERT_TRUE(handled_rpcs.is_initialized()); EXPECT_EQ(handled_rpcs[0].function_id, 41); // Check no update required diff --git a/src/components/policy/policy_regular/test/sql_pt_representation_test.cc b/src/components/policy/policy_regular/test/sql_pt_representation_test.cc index 9063c280bd..0055ce2ee9 100644 --- a/src/components/policy/policy_regular/test/sql_pt_representation_test.cc +++ b/src/components/policy/policy_regular/test/sql_pt_representation_test.cc @@ -1730,16 +1730,18 @@ TEST_F(SQLPTRepresentationTest, Save_SetPolicyTableThenSave_ExpectSavedToPT) { EXPECT_EQ(3u, devices.size()); const std::string kAppId = "1234"; + const std::string media_str = "MEDIA"; policy_table::AppServiceParameters app_service_parameters; GatherAppServiceParameters(kAppId, &app_service_parameters); - ASSERT_FALSE(app_service_parameters.find("MEDIA") == + ASSERT_FALSE(app_service_parameters.find(media_str) == app_service_parameters.end()); - auto service_names = *(app_service_parameters["MEDIA"].service_names); + auto service_names = *(app_service_parameters[media_str].service_names); EXPECT_TRUE(service_names.is_initialized()); + ASSERT_EQ(service_names.size(), 2u); EXPECT_EQ(static_cast(service_names[0]), "SDL App"); EXPECT_EQ(static_cast(service_names[1]), "SDL Music"); - auto handled_rpcs = app_service_parameters["MEDIA"].handled_rpcs; + auto handled_rpcs = app_service_parameters[media_str].handled_rpcs; EXPECT_TRUE(handled_rpcs.is_initialized()); EXPECT_EQ(handled_rpcs[0].function_id, 41); -- cgit v1.2.1 From a593ff38c4a5a01f1cbb467b955c12d44783e995 Mon Sep 17 00:00:00 2001 From: JackLivio Date: Sun, 17 Mar 2019 14:22:26 -0400 Subject: Address comments --- .../test/application_manager_impl_test.cc | 62 ++++++++-------------- 1 file changed, 23 insertions(+), 39 deletions(-) diff --git a/src/components/application_manager/test/application_manager_impl_test.cc b/src/components/application_manager/test/application_manager_impl_test.cc index c606a37ff2..36ae9b0b48 100644 --- a/src/components/application_manager/test/application_manager_impl_test.cc +++ b/src/components/application_manager/test/application_manager_impl_test.cc @@ -102,11 +102,14 @@ const std::string kAppName = "appName"; // Cloud application params const std::string kEndpoint = "endpoint"; +const std::string kEndpoint2 = "https://fakesdlcloudapptesting.com:8080"; const std::string kAuthToken = "auth_token"; const std::string kCertificate = "cert"; const std::string kTransportType = "WS"; const mobile_api::HybridAppPreference::eType kHybridAppPreference = mobile_api::HybridAppPreference::CLOUD; +const std::string kHybridAppPreferenceStr = "CLOUD"; +const bool kEnabled = true; } // namespace class ApplicationManagerImplTest : public ::testing::Test { @@ -145,7 +148,6 @@ class ApplicationManagerImplTest : public ::testing::Test { app_manager_impl_->set_connection_handler(&mock_connection_handler_); Json::Value empty; ON_CALL(mock_last_state_, get_dictionary()).WillByDefault(ReturnRef(empty)); - // app_manager_impl_->SetMockPolicyHandler(mock_policy_handler_); std::unique_ptr app_service_manager_ptr( new AppServiceManager(*app_manager_impl_, mock_last_state_)); app_manager_impl_->SetAppServiceManager(app_service_manager_ptr); @@ -1440,21 +1442,15 @@ TEST_F(ApplicationManagerImplTest, void ApplicationManagerImplTest::AddCloudAppToPendingDeviceMap() { app_manager_impl_->SetMockPolicyHandler(mock_policy_handler_); std::vector enabled_apps{"1234"}; - std::string endpoint = "https://fakesdlcloudapptesting.com:8080"; - std::string certificate = "cert"; - std::string auth_token = "auth_token"; - std::string cloud_transport_type = "WS"; - std::string hybrid_app_preference_str = "CLOUD"; - bool enabled = true; EXPECT_CALL(*mock_policy_handler_, GetEnabledCloudApps(_)) .WillOnce(SetArgReferee<0>(enabled_apps)); EXPECT_CALL(*mock_policy_handler_, GetCloudAppParameters(_, _, _, _, _, _, _)) - .WillOnce(DoAll(SetArgReferee<1>(enabled), - SetArgReferee<2>(endpoint), - SetArgReferee<3>(certificate), - SetArgReferee<4>(auth_token), - SetArgReferee<5>(cloud_transport_type), - SetArgReferee<6>(hybrid_app_preference_str), + .WillOnce(DoAll(SetArgReferee<1>(kEnabled), + SetArgReferee<2>(kEndpoint2), + SetArgReferee<3>(kCertificate), + SetArgReferee<4>(kAuthToken), + SetArgReferee<5>(kTransportType), + SetArgReferee<6>(kHybridAppPreferenceStr), Return(true))); std::vector nicknames{"CloudApp"}; @@ -1472,28 +1468,22 @@ TEST_F(ApplicationManagerImplTest, CreatePendingApplication) { // CreatePendingApplication transport_manager::DeviceInfo device_info( - 1, "mac", "https://fakesdlcloudapptesting.com:8080", "CLOUD_WEBSOCKET"); + 1, "mac", kEndpoint2, "CLOUD_WEBSOCKET"); std::vector nicknames{"CloudApp"}; EXPECT_CALL(*mock_policy_handler_, GetInitialAppData(_, _, _)) .WillOnce(DoAll(SetArgPointee<1>(nicknames), Return(true))); std::vector enabled_apps{"1234"}; - std::string endpoint = "https://fakesdlcloudapptesting.com:8080"; - std::string certificate = "cert"; - std::string auth_token = "auth_token"; - std::string cloud_transport_type = "WS"; - std::string hybrid_app_preference_str = "CLOUD"; - bool enabled = true; EXPECT_CALL(*mock_policy_handler_, GetStatisticManager()) .WillOnce(Return(std::shared_ptr( new usage_statistics_test::MockStatisticsManager()))); EXPECT_CALL(*mock_policy_handler_, GetCloudAppParameters(_, _, _, _, _, _, _)) - .WillOnce(DoAll(SetArgReferee<1>(enabled), - SetArgReferee<2>(endpoint), - SetArgReferee<3>(certificate), - SetArgReferee<4>(auth_token), - SetArgReferee<5>(cloud_transport_type), - SetArgReferee<6>(hybrid_app_preference_str), + .WillOnce(DoAll(SetArgReferee<1>(kEnabled), + SetArgReferee<2>(kEndpoint2), + SetArgReferee<3>(kCertificate), + SetArgReferee<4>(kAuthToken), + SetArgReferee<5>(kTransportType), + SetArgReferee<6>(kHybridAppPreferenceStr), Return(true))); // Expect Update app list EXPECT_CALL(*mock_rpc_service_, ManageHMICommand(_, _)).Times(1); @@ -1514,25 +1504,19 @@ TEST_F(ApplicationManagerImplTest, SetPendingState) { std::string mac = "MAC_ADDRESS"; EXPECT_CALL(*mock_app_ptr_, mac_address()).WillRepeatedly(ReturnRef(mac)); transport_manager::DeviceInfo device_info( - 1, "mac", "https://fakesdlcloudapptesting.com:8080", "CLOUD_WEBSOCKET"); + 1, "mac", kEndpoint2, "CLOUD_WEBSOCKET"); std::vector enabled_apps{"1234"}; - std::string endpoint = "https://fakesdlcloudapptesting.com:8080"; - std::string certificate = "cert"; - std::string auth_token = "auth_token"; - std::string cloud_transport_type = "WS"; - std::string hybrid_app_preference_str = "CLOUD"; - bool enabled = true; EXPECT_CALL(*mock_policy_handler_, GetEnabledCloudApps(_)) .WillOnce(SetArgReferee<0>(enabled_apps)); EXPECT_CALL(*mock_policy_handler_, GetCloudAppParameters(_, _, _, _, _, _, _)) - .WillOnce(DoAll(SetArgReferee<1>(enabled), - SetArgReferee<2>(endpoint), - SetArgReferee<3>(certificate), - SetArgReferee<4>(auth_token), - SetArgReferee<5>(cloud_transport_type), - SetArgReferee<6>(hybrid_app_preference_str), + .WillOnce(DoAll(SetArgReferee<1>(kEnabled), + SetArgReferee<2>(kEndpoint2), + SetArgReferee<3>(kCertificate), + SetArgReferee<4>(kAuthToken), + SetArgReferee<5>(kTransportType), + SetArgReferee<6>(kHybridAppPreferenceStr), Return(true))); std::vector nicknames{"CloudApp"}; -- cgit v1.2.1 From d309b03fcb3240bea005132682400f4c5444e61b Mon Sep 17 00:00:00 2001 From: JackLivio Date: Sun, 17 Mar 2019 14:26:12 -0400 Subject: Update var name to kServiceType --- .../test/policy_handler_test.cc | 24 +++++++++++----------- .../test/policy_manager_impl_test.cc | 8 ++++---- .../test/policy_manager_impl_test.cc | 8 ++++---- .../test/sql_pt_representation_test.cc | 8 ++++---- 4 files changed, 24 insertions(+), 24 deletions(-) diff --git a/src/components/application_manager/test/policy_handler_test.cc b/src/components/application_manager/test/policy_handler_test.cc index 27e9120661..5b31b8d574 100644 --- a/src/components/application_manager/test/policy_handler_test.cc +++ b/src/components/application_manager/test/policy_handler_test.cc @@ -403,17 +403,17 @@ TEST_F(PolicyHandlerTest, AppServiceUpdate_CheckAppService) { policy_table::AppServiceParameters app_service_params = policy_table::AppServiceParameters(); - std::string media_str = "MEDIA"; + std::string kServiceType = "MEDIA"; std::string as_app_id = "1010101010"; std::string service_name1 = "SDL Music"; std::string service_name2 = "SDL App"; - (app_service_params)[media_str] = policy_table::AppServiceInfo(); - (app_service_params)[media_str].service_names->push_back(service_name2); - (app_service_params)[media_str].service_names->push_back(service_name1); - (app_service_params)[media_str].service_names->mark_initialized(); + (app_service_params)[kServiceType] = policy_table::AppServiceInfo(); + (app_service_params)[kServiceType].service_names->push_back(service_name2); + (app_service_params)[kServiceType].service_names->push_back(service_name1); + (app_service_params)[kServiceType].service_names->mark_initialized(); policy_table::AppServiceHandledRpc handled_rpc; handled_rpc.function_id = 41; - (app_service_params)[media_str].handled_rpcs.push_back(handled_rpc); + (app_service_params)[kServiceType].handled_rpcs.push_back(handled_rpc); EXPECT_CALL(*mock_policy_manager_, GetAppServiceParameters(_, _)) .WillRepeatedly(SetArgPointee<1>(app_service_params)); @@ -426,22 +426,22 @@ TEST_F(PolicyHandlerTest, AppServiceUpdate_CheckAppService) { fake_handled_rpcs.push_back(fake_rpc_id); EXPECT_TRUE(policy_handler_.CheckAppServiceParameters( - as_app_id, service_name1, media_str, &requested_handled_rpcs)); + as_app_id, service_name1, kServiceType, &requested_handled_rpcs)); EXPECT_TRUE(policy_handler_.CheckAppServiceParameters( - as_app_id, service_name2, media_str, &requested_handled_rpcs)); + as_app_id, service_name2, kServiceType, &requested_handled_rpcs)); EXPECT_TRUE(policy_handler_.CheckAppServiceParameters( - as_app_id, service_name2, media_str, NULL)); + as_app_id, service_name2, kServiceType, NULL)); EXPECT_TRUE(policy_handler_.CheckAppServiceParameters( - as_app_id, "", media_str, NULL)); + as_app_id, "", kServiceType, NULL)); EXPECT_FALSE( policy_handler_.CheckAppServiceParameters(as_app_id, "", "", NULL)); EXPECT_FALSE(policy_handler_.CheckAppServiceParameters( as_app_id, service_name2, "NAVIGATION", &requested_handled_rpcs)); EXPECT_FALSE(policy_handler_.CheckAppServiceParameters( - as_app_id, "MUSIC", media_str, &requested_handled_rpcs)); + as_app_id, "MUSIC", kServiceType, &requested_handled_rpcs)); EXPECT_FALSE(policy_handler_.CheckAppServiceParameters( - as_app_id, service_name2, media_str, &fake_handled_rpcs)); + as_app_id, service_name2, kServiceType, &fake_handled_rpcs)); } TEST_F(PolicyHandlerTest, ReceiveMessageFromSDK) { diff --git a/src/components/policy/policy_external/test/policy_manager_impl_test.cc b/src/components/policy/policy_external/test/policy_manager_impl_test.cc index 0d70f7d198..1916e09efc 100644 --- a/src/components/policy/policy_external/test/policy_manager_impl_test.cc +++ b/src/components/policy/policy_external/test/policy_manager_impl_test.cc @@ -347,7 +347,7 @@ TEST_F(PolicyManagerImplTest2, GetCurrentDeviceId) { TEST_F(PolicyManagerImplTest2, UpdateApplication_AppServices) { // Arrange - std::string media_str = "MEDIA"; + std::string kServiceType = "MEDIA"; CreateLocalPT(preloaded_pt_filename_); EXPECT_EQ("UP_TO_DATE", policy_manager_->GetPolicyTableStatus()); GetPTU("json/valid_sdl_pt_update.json"); @@ -357,17 +357,17 @@ TEST_F(PolicyManagerImplTest2, UpdateApplication_AppServices) { policy_table::AppServiceParameters(); policy_manager_->GetAppServiceParameters(app_id_2_, &app_service_parameters); - ASSERT_FALSE(app_service_parameters.find(media_str) == + ASSERT_FALSE(app_service_parameters.find(kServiceType) == app_service_parameters.end()); - auto service_names = *(app_service_parameters[media_str].service_names); + auto service_names = *(app_service_parameters[kServiceType].service_names); ASSERT_TRUE(service_names.is_initialized()); ASSERT_EQ(service_names.size(), 2u); EXPECT_EQ(static_cast(service_names[0]), "SDL App"); EXPECT_EQ(static_cast(service_names[1]), "SDL Music"); - auto handled_rpcs = app_service_parameters[media_str].handled_rpcs; + auto handled_rpcs = app_service_parameters[kServiceType].handled_rpcs; ASSERT_TRUE(handled_rpcs.is_initialized()); EXPECT_EQ(handled_rpcs[0].function_id, 41); diff --git a/src/components/policy/policy_regular/test/policy_manager_impl_test.cc b/src/components/policy/policy_regular/test/policy_manager_impl_test.cc index da5a677602..97b1768666 100644 --- a/src/components/policy/policy_regular/test/policy_manager_impl_test.cc +++ b/src/components/policy/policy_regular/test/policy_manager_impl_test.cc @@ -835,7 +835,7 @@ TEST_F( } TEST_F(PolicyManagerImplTest2, UpdateApplication_AppServices) { - std::string media_str = "MEDIA"; + std::string kServiceType = "MEDIA"; // Arrange CreateLocalPT("sdl_preloaded_pt.json"); EXPECT_EQ("UP_TO_DATE", manager->GetPolicyTableStatus()); @@ -846,17 +846,17 @@ TEST_F(PolicyManagerImplTest2, UpdateApplication_AppServices) { policy_table::AppServiceParameters(); manager->GetAppServiceParameters(app_id2, &app_service_parameters); - ASSERT_FALSE(app_service_parameters.find(media_str) == + ASSERT_FALSE(app_service_parameters.find(kServiceType) == app_service_parameters.end()); - auto service_names = *(app_service_parameters[media_str].service_names); + auto service_names = *(app_service_parameters[kServiceType].service_names); ASSERT_TRUE(service_names.is_initialized()); ASSERT_EQ(service_names.size(), 2u); EXPECT_EQ(static_cast(service_names[0]), "SDL App"); EXPECT_EQ(static_cast(service_names[1]), "SDL Music"); - auto handled_rpcs = app_service_parameters[media_str].handled_rpcs; + auto handled_rpcs = app_service_parameters[kServiceType].handled_rpcs; ASSERT_TRUE(handled_rpcs.is_initialized()); EXPECT_EQ(handled_rpcs[0].function_id, 41); diff --git a/src/components/policy/policy_regular/test/sql_pt_representation_test.cc b/src/components/policy/policy_regular/test/sql_pt_representation_test.cc index 0055ce2ee9..675d708843 100644 --- a/src/components/policy/policy_regular/test/sql_pt_representation_test.cc +++ b/src/components/policy/policy_regular/test/sql_pt_representation_test.cc @@ -1730,18 +1730,18 @@ TEST_F(SQLPTRepresentationTest, Save_SetPolicyTableThenSave_ExpectSavedToPT) { EXPECT_EQ(3u, devices.size()); const std::string kAppId = "1234"; - const std::string media_str = "MEDIA"; + const std::string kServiceType = "MEDIA"; policy_table::AppServiceParameters app_service_parameters; GatherAppServiceParameters(kAppId, &app_service_parameters); - ASSERT_FALSE(app_service_parameters.find(media_str) == + ASSERT_FALSE(app_service_parameters.find(kServiceType) == app_service_parameters.end()); - auto service_names = *(app_service_parameters[media_str].service_names); + auto service_names = *(app_service_parameters[kServiceType].service_names); EXPECT_TRUE(service_names.is_initialized()); ASSERT_EQ(service_names.size(), 2u); EXPECT_EQ(static_cast(service_names[0]), "SDL App"); EXPECT_EQ(static_cast(service_names[1]), "SDL Music"); - auto handled_rpcs = app_service_parameters[media_str].handled_rpcs; + auto handled_rpcs = app_service_parameters[kServiceType].handled_rpcs; EXPECT_TRUE(handled_rpcs.is_initialized()); EXPECT_EQ(handled_rpcs[0].function_id, 41); -- cgit v1.2.1 From 36b383be1c8dd77218d0954e7851389c1de71f08 Mon Sep 17 00:00:00 2001 From: JackLivio Date: Sun, 17 Mar 2019 15:15:16 -0400 Subject: Address comments --- .../include/application_manager/rpc_passing_handler.h | 1 - .../commands/mobile/on_app_service_data_notification_test.cc | 10 +++++----- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/components/application_manager/include/application_manager/rpc_passing_handler.h b/src/components/application_manager/include/application_manager/rpc_passing_handler.h index cc0ac2979a..ab85b1374f 100644 --- a/src/components/application_manager/include/application_manager/rpc_passing_handler.h +++ b/src/components/application_manager/include/application_manager/rpc_passing_handler.h @@ -39,7 +39,6 @@ #include "interfaces/MOBILE_API.h" #include "smart_objects/smart_object.h" #include "utils/timer.h" -#include "application_manager/commands/command.h" namespace application_manager { diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/test/commands/mobile/on_app_service_data_notification_test.cc b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/test/commands/mobile/on_app_service_data_notification_test.cc index d501ea08ea..47358ef631 100644 --- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/test/commands/mobile/on_app_service_data_notification_test.cc +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/test/commands/mobile/on_app_service_data_notification_test.cc @@ -70,10 +70,10 @@ namespace app_service_plugin_test { using namespace app_service_rpc_plugin; using application_manager::ApplicationSet; -class OnAppServiceDatanotificationTest +class OnAppServiceDataNotificationTest : public CommandsTest { public: - OnAppServiceDatanotificationTest() + OnAppServiceDataNotificationTest() : mock_app_(std::make_shared >()) , app_service_app_extension_( std::make_shared( @@ -113,7 +113,7 @@ class OnAppServiceDatanotificationTest MockAppServiceManager app_service_manager_; }; -TEST_F(OnAppServiceDatanotificationTest, Run_SendMessageToMobile_Notification) { +TEST_F(OnAppServiceDataNotificationTest, Run_SendMessageToMobile_Notification) { MessageSharedPtr mobile_message = CreateBasicMessage(); (*mobile_message)[am::strings::msg_params][am::strings::service_data] @@ -152,7 +152,7 @@ TEST_F(OnAppServiceDatanotificationTest, Run_SendMessageToMobile_Notification) { Mock::VerifyAndClearExpectations(&app_mngr_); } -TEST_F(OnAppServiceDatanotificationTest, Run_NoService) { +TEST_F(OnAppServiceDataNotificationTest, Run_NoService) { MessageSharedPtr mobile_message = CreateBasicMessage(); (*mobile_message)[am::strings::msg_params][am::strings::service_data] @@ -180,7 +180,7 @@ TEST_F(OnAppServiceDatanotificationTest, Run_NoService) { Mock::VerifyAndClearExpectations(&app_mngr_); } -TEST_F(OnAppServiceDatanotificationTest, Run_NoSubscribedApps) { +TEST_F(OnAppServiceDataNotificationTest, Run_NoSubscribedApps) { MessageSharedPtr mobile_message = CreateBasicMessage(); (*mobile_message)[am::strings::msg_params][am::strings::service_data] -- cgit v1.2.1 From 4449a193e699ef32a6286e8fac4112e8a9e5fe76 Mon Sep 17 00:00:00 2001 From: jacobkeeler Date: Mon, 18 Mar 2019 10:37:27 -0400 Subject: Align Core's MOBILE_API.xml with the rpc_spec repo --- src/components/interfaces/MOBILE_API.xml | 83 +++++++++++++++++--------------- 1 file changed, 44 insertions(+), 39 deletions(-) diff --git a/src/components/interfaces/MOBILE_API.xml b/src/components/interfaces/MOBILE_API.xml index a0345ada29..f51a4f8201 100644 --- a/src/components/interfaces/MOBILE_API.xml +++ b/src/components/interfaces/MOBILE_API.xml @@ -1,7 +1,7 @@ - + The request succeeded @@ -544,7 +544,7 @@ - + Enumeration for the user's preference of which app type to use when both are available @@ -556,7 +556,7 @@ An array of app names a cloud app is allowed to register with. If included in a SetCloudAppProperties request, this value will overwrite the existing "nicknames" field in the app policies section of the policy table. - + If true, cloud app will be included in HMI RPC UpdateAppList @@ -569,9 +569,11 @@ Specifies the user preference to use the cloud app version or mobile app version when both are available - + + Specifies the endpoint which Core will attempt to connect to when this app is selected + - + Defines the hard (physical) and soft (touchscreen) buttons available from the module @@ -965,7 +967,7 @@ Similar to VP8, but VP9 is customized for video resolutions beyond high-definition video (UHD) and also enables lossless compression. - + @@ -2826,7 +2828,7 @@ - + @@ -3722,7 +3724,7 @@ - + @@ -3978,7 +3980,7 @@ - Used to infer which side of the road this instruction takes place. For a U-Turn (Action=Turn, direction=180) this will determine which direction the turn should take place. + Used to infer which side of the road this instruction takes place. For a U-Turn (action=TURN, bearing=180) this will determine which direction the turn should take place. @@ -4030,7 +4032,7 @@ - The file name of the icon to be associated with this service. Most likely the same as the appIcon. + The icon to be associated with this service. Most likely the same as the appIcon. @@ -4071,9 +4073,11 @@ - Contains all the current data of the app service. The serviceType will link to which of the service data objects are included in this object. (eg if service type equals MEDIA, the mediaServiceData param should be included. + Contains all the current data of the app service. The serviceType will link to which of the service data objects are included in this object (e.g. if the service type is MEDIA, the mediaServiceData param should be included). - + + The type of service that is to be offered by this app. See AppServiceType for known enum equivalent types. Parameter is a string to allow for new service types to be used by apps on older versions of SDL Core. + @@ -4120,7 +4124,7 @@ The systemCapabilityType identifies which data object exists in this struct. For example, if the SystemCapability Type is NAVIGATION then a "navigationCapability" should exist - Used as a descriptor of what data to expect in this struct. The corresponding param to this enum should be included and the only other para included. + Used as a descriptor of what data to expect in this struct. The corresponding param to this enum should be included and the only other param included. Describes extended capabilities for onboard navigation system @@ -5381,7 +5385,7 @@ Parameter used by cloud apps to identify a head unit - + Emergency Call notification and confirmation data @@ -5499,7 +5503,7 @@ Parameter used by cloud apps to identify a head unit - + Emergency Call notification and confirmation data @@ -6470,7 +6474,7 @@ Provides additional human readable info regarding the result. - + This request is sent to the module to retrieve a file @@ -6486,7 +6490,10 @@ Optional offset in bytes for resuming partial data chunks - Optional length in bytes for resuming partial data chunks if offset is set to 0, then length is the total length of the file to be downloaded + + Optional length in bytes for resuming partial data chunks + If offset is set to 0, then length is the total length of the file to be retrieved + @@ -6506,7 +6513,7 @@ - + Provides additional human readable info regarding the result. @@ -6515,20 +6522,20 @@ Optional offset in bytes for resuming partial data chunks - + Optional length in bytes for resuming partial data chunks if offset is set to 0, then length is the total length of the file to be downloaded - + File type that is being sent in response. - + Additional CRC32 checksum to protect data integrity up to 512 Mbits - + Used to delete a file resident on the module in the app's local cache. @@ -6910,8 +6917,8 @@ - If subscribe is true, the head unit will register onInteriorVehicleData notifications for the requested moduleType. - If subscribe is false, the head unit will unregister onInteriorVehicleData notifications for the requested moduleType. + If subscribe is true, the head unit will register OnInteriorVehicleData notifications for the requested moduleType. + If subscribe is false, the head unit will unregister OnInteriorVehicleData notifications for the requested moduleType. If subscribe is not included, the subscription status of the app for the requested moduleType will remain unchanged. @@ -7070,7 +7077,7 @@ The type of system capability to get more information on - Flag to subscribe to updates of the supplied service capability type. If true, then requester will be subscribed + Flag to subscribe to updates of the supplied service capability type. If true, the requester will be subscribed. If false, the requester will not be subscribed and be removed as a subscriber if it was previously subscribed. @@ -7124,20 +7131,18 @@ - + - RPC used to enable/disable a cloud application and set authentication data + RPC used to enable/disable a cloud application and set its cloud-related policy properties - The requested cloud application properties + The new cloud application properties - - The response to registerAppInterface - + The response to SetCloudAppProperties true if successful; false if failed @@ -7220,8 +7225,8 @@ This request asks the module for current data related to the specific service. It also includes an option to subscribe to that service for future updates - See AppServiceType - + The type of service that is to be offered by this app. See AppServiceType for known enum equivalent types. Parameter is a string to allow for new service types to be used by apps on older versions of SDL Core. + If true, the consumer is requesting to subscribe to all future updates from the service publisher. If false, the consumer doesn't wish to subscribe and should be unsubscribed if it was previously subscribed. @@ -7229,7 +7234,7 @@ - This response includes the data that is requested from the specific service + This response includes the data that was requested from the specific service true, if successful; false, if failed @@ -7255,9 +7260,9 @@ - + - Fully qualified URI based on the URI prefix and URI scheme the app service provided. SDL makes no gurantee that this URI is correct. + Fully qualified URI based on a predetermined scheme provided by the app service. SDL makes no guarantee that this URI is correct. @@ -7273,7 +7278,7 @@ - + true, if successful; false, if failed @@ -7287,7 +7292,7 @@ - The service can provide specific result strings to the consumer through this param. These results should be described in the URI schema set in the Service Manifest + The service can provide specific result strings to the consumer through this param. @@ -7419,7 +7424,7 @@ Parameter used by cloud apps to identify a head unit - + Emergency Call notification and confirmation data -- cgit v1.2.1 From a83066f7a9d243e3d7f839f86577b61867ef6e62 Mon Sep 17 00:00:00 2001 From: jacobkeeler Date: Mon, 18 Mar 2019 13:05:03 -0400 Subject: Update HMI API descriptions and interface versions --- src/components/interfaces/HMI_API.xml | 80 ++++++++++++++++++----------------- 1 file changed, 42 insertions(+), 38 deletions(-) diff --git a/src/components/interfaces/HMI_API.xml b/src/components/interfaces/HMI_API.xml index e0ca4d6d18..859e8d4d4a 100644 --- a/src/components/interfaces/HMI_API.xml +++ b/src/components/interfaces/HMI_API.xml @@ -34,7 +34,7 @@ - + @@ -3634,7 +3634,7 @@ - Used to infer which side of the road this instruction takes place. For a U-Turn (Action=Turn, direction=180) this will determine which direction the turn should take place. + Used to infer which side of the road this instruction takes place. For a U-Turn (action=TURN, bearing=180) this will determine which direction the turn should take place. @@ -3685,8 +3685,8 @@ The type of service that is to be offered by this app - - The file name of the icon to be associated with this service. Most likely the same as the appIcon. + + The icon to be associated with this service. Most likely the same as the appIcon. @@ -3727,9 +3727,11 @@ - Contains all the current data of the app service. The serviceType will link to which of the service data objects are included in this object. (eg if service type equals MEDIA, the mediaServiceData param should be included. + Contains all the current data of the app service. The serviceType will link to which of the service data objects are included in this object (e.g. if the service type is MEDIA, the mediaServiceData param should be included). - + + The type of service that is to be offered by this app. See AppServiceType for known enum equivalent types. Parameter is a string to allow for new service types to be used by apps on older versions of SDL Core. + @@ -3785,7 +3787,7 @@ The systemCapabilityType identifies which data object exists in this struct. For example, if the SystemCapability Type is NAVIGATION then a "navigationCapability" should exist - Used as a descriptor of what data to expect in this struct. The corresponding param to this enum should be included and the only other para included. + Used as a descriptor of what data to expect in this struct. The corresponding param to this enum should be included and the only other param included. Describes extended capabilities for onboard navigation system @@ -3890,7 +3892,7 @@ - + Request from SDL to HMI to obtain current UTC time. @@ -5285,7 +5287,7 @@ - + Method is invoked at system startup. Response should provide information about presence of any of vehicle information modules (ECU, GPS, etc) and their readiness to cooperate with SDL. @@ -6251,7 +6253,7 @@ The module data to retrieve from the vehicle for that type - If subscribe is true, the head unit will send onInteriorVehicleData notifications for the module type + If subscribe is true, the head unit will send OnInteriorVehicleData notifications for the module type @@ -6260,7 +6262,7 @@ Is a conditional-mandatory parameter: must be returned in case "subscribe" parameter was present in the related request. - if "true" - the "moduleType" from request is successfully subscribed and the head unit will send onInteriorVehicleData notifications for the moduleDescription. + if "true" - the "moduleType" from request is successfully subscribed and the head unit will send OnInteriorVehicleData notifications for the moduleDescription. if "false" - the "moduleType" from request is either unsubscribed or failed to subscribe. @@ -6313,7 +6315,7 @@ - + Interface used for interacting with app services as a producer or consumer Registers a service offered by this app on the module @@ -6340,7 +6342,9 @@ This request asks the module for current data related to the specific service. It also includes an option to subscribe to that service for future updates - + + The type of service that is to be offered by this app. See AppServiceType for known enum equivalent types. Parameter is a string to allow for new service types to be used by apps on older versions of SDL Core. + If true, the consumer is requesting to subscribe to all future updates from the service publisher. If false, the consumer doesn't wish to subscribe and should be unsubscribed if it was previously subscribed. @@ -6348,10 +6352,34 @@ - This response includes the data that is requested from the specific service + This response includes the data that was requested from the specific service + + + Fully qualified URI based on a predetermined scheme provided by the app service. SDL makes no guarantee that this URI is correct. + + + + The service ID that the app consumer wishes to send this URI. + + + + This string is the appID of the app requesting the app service provider take the specific action. This will automatically be set by SDL Core in requests originating from the HMI + + + + This flag signals the requesting consumer would like this service to become the active primary service of the destination's type. + + + + + + The service can provide specific result strings to the consumer through this param. + + + If included, only service records of supplied type will be returned in response. If not included, all service records for all types will be returned. See Common.AppServiceType. @@ -6388,30 +6416,6 @@ - - - Fully qualified URI based on the URI prefix and URI scheme the app service provided. SDL makes no gurantee that this URI is correct. - - - - The service ID that the app consumer wishes to send this URI. - - - - This string is the appID of the app requesting the app service provider take the specific action. This will automatically be set by SDL Core in requests originating from the HMI - - - - This flag signals the requesting consumer would like this service to become the active primary service of the destination's type. - - - - - - The service can provide specific result strings to the consumer through this param. These results should be described in the URI schema set in the Service Manifest - - - SDL->HMI. HMI is expected to prompt the user for permission for the app service to take over as the active service. -- cgit v1.2.1 From 9765ebf0ce1c2fd5fd841abf98c89d8fca3b7cd8 Mon Sep 17 00:00:00 2001 From: Jacob Keeler Date: Mon, 18 Mar 2019 13:22:07 -0400 Subject: Update after comments --- .github/PULL_REQUEST_TEMPLATE.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index 260d3b55ad..301a22eafe 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -1,4 +1,4 @@ -[Things to note: Pull Requests **must** fix an issue. Discussion about the feature / bug takes place in the issue, discussion of the implementation takes place in the PR. Please also see the [Contributing Guide](https://github.com/smartdevicelink/sdl_core/blob/master/.github/CONTRIBUTING.md) for information on branch naming and the CLA, and the [SmartDeviceLink GitHub Best Practices](https://d83tozu1c8tt6.cloudfront.net/media/resources/SDL_GitHub_BestPractices.pdf) document for more information on how to enter a pull request. Once this PR is ready for review, please request one from @jordynmackool. +[Things to note: Pull Requests **must** fix an issue. Discussion about the feature / bug takes place in the issue, discussion of the implementation takes place in the PR. Please also see the [Contributing Guide](https://github.com/smartdevicelink/sdl_core/blob/master/.github/CONTRIBUTING.md) for information on branch naming and the CLA, and the [SmartDeviceLink GitHub Best Practices](https://d83tozu1c8tt6.cloudfront.net/media/resources/SDL_GitHub_BestPractices.pdf) document for more information on how to enter a pull request. Once this PR is ready for review, please request one from @theresalech. Delete the above section when you've read it.] -- cgit v1.2.1 From 6e909aa9ee9a5590230e3f7350cbf31fcd9c12ca Mon Sep 17 00:00:00 2001 From: jacobkeeler Date: Mon, 18 Mar 2019 13:50:38 -0400 Subject: Fix duplicate regex parsing in cloud adapter --- .../src/cloud/cloud_websocket_transport_adapter.cc | 31 +++++++--------------- 1 file changed, 9 insertions(+), 22 deletions(-) diff --git a/src/components/transport_manager/src/cloud/cloud_websocket_transport_adapter.cc b/src/components/transport_manager/src/cloud/cloud_websocket_transport_adapter.cc index dd575979b2..8298042d41 100644 --- a/src/components/transport_manager/src/cloud/cloud_websocket_transport_adapter.cc +++ b/src/components/transport_manager/src/cloud/cloud_websocket_transport_adapter.cc @@ -80,17 +80,6 @@ void CloudWebsocketTransportAdapter::CreateDevice(const std::string& uid) { return; } - boost::regex pattern( - "(wss?):\\/\\/([A-Z\\d\\.-]{2,})\\.?([A-Z]{2,})?(:\\d{2,4})\\/", - boost::regex::icase); - std::string str = uid; - if (!boost::regex_match(str, pattern)) { - LOG4CXX_DEBUG(logger_, "Invalid Endpoint: " << uid); - return; - } - - LOG4CXX_DEBUG(logger_, "Valid Endpoint: " << uid); - // Port after second colon in valid endpoint string std::size_t pos_port = uid.find(":"); pos_port = uid.find(":", pos_port + 1); @@ -100,22 +89,20 @@ void CloudWebsocketTransportAdapter::CreateDevice(const std::string& uid) { "(wss?:\\/\\/)([A-Z\\d\\.-]{2,}\\.?([A-Z]{2,})?)(:)(\\d{2,5})(\\/" "[A-Z\\d\\.-]+)*\\/?"); boost::smatch results; + std::string str = uid; - std::string host = ""; - std::string port = ""; - if (boost::regex_search(str, results, group_pattern)) { - host = results[2]; - port = results[5]; - - LOG4CXX_DEBUG(logger_, - "Results: " << results[0] << " " << results[1] << " " - << results[2] << " " << results[3] << " " - << results[4] << " " << results[5] << " "); - } else { + if (!boost::regex_search(str, results, group_pattern)) { LOG4CXX_DEBUG(logger_, "Invalid Pattern: " << uid); return; } + std::string host = results[2]; + std::string port = results[5]; + + LOG4CXX_DEBUG(logger_, + "Results: " << results[0] << " " << results[1] << " " + << results[2] << " " << results[3] << " " + << results[4] << " " << results[5] << " "); std::string device_id = uid; LOG4CXX_DEBUG(logger_, -- cgit v1.2.1 From a7596bcecbacbeabfd862b247441e534c64130f7 Mon Sep 17 00:00:00 2001 From: JackLivio Date: Mon, 18 Mar 2019 16:17:23 -0400 Subject: Send Invalid ID on duplicate correlation_id --- .../include/application_manager/rpc_passing_handler.h | 2 +- .../application_manager/src/rpc_passing_handler.cc | 16 ++++++++++++++-- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/components/application_manager/include/application_manager/rpc_passing_handler.h b/src/components/application_manager/include/application_manager/rpc_passing_handler.h index ab85b1374f..675d567820 100644 --- a/src/components/application_manager/include/application_manager/rpc_passing_handler.h +++ b/src/components/application_manager/include/application_manager/rpc_passing_handler.h @@ -82,7 +82,7 @@ class RPCPassingHandler { * @brief Function to handle sending and receiving RPC Passing * requests/responses * @param rpc_message RPC message SmartObject - * @return true if the request was forwarded, false otherwise + * @return true if the request was handled, false otherwise */ bool RPCPassThrough(smart_objects::SmartObject rpc_message); diff --git a/src/components/application_manager/src/rpc_passing_handler.cc b/src/components/application_manager/src/rpc_passing_handler.cc index 37b01a92f6..3e90b86663 100644 --- a/src/components/application_manager/src/rpc_passing_handler.cc +++ b/src/components/application_manager/src/rpc_passing_handler.cc @@ -118,8 +118,20 @@ bool RPCPassingHandler::RPCPassThrough(smart_objects::SmartObject rpc_message) { PopulateRPCRequestQueue(rpc_message); } else { rpc_request_queue_lock_.Release(); - LOG4CXX_DEBUG(logger_, "Correlation id DOES exist in map. Continuing"); - return false; + LOG4CXX_DEBUG(logger_, "Correlation id DOES exist in map. Returning"); + std::shared_ptr response( + MessageHelper::CreateNegativeResponse( + rpc_message[strings::params][strings::connection_key].asInt(), + rpc_message[strings::params][strings::function_id].asInt(), + correlation_id, + mobile_apis::Result::INVALID_ID)); + + (*response)[strings::msg_params][strings::info] = + "Duplicate correlation_id"; + app_manager_.GetRPCService().ManageMobileCommand( + response, commands::Command::SOURCE_SDL); + + return true; } rpc_request_queue_lock_.Acquire(); -- cgit v1.2.1 From 645b370783a3e93361d1bd88069f3a2cc0481ba7 Mon Sep 17 00:00:00 2001 From: jacobkeeler Date: Fri, 22 Mar 2019 15:06:25 -0400 Subject: Change is_foreground() usages to IsFullscreen() --- .../src/commands/mobile/perform_app_service_interaction_request.cc | 2 +- .../src/commands/mobile/publish_app_service_request.cc | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/perform_app_service_interaction_request.cc b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/perform_app_service_interaction_request.cc index 4046ac7379..63b6e47d8e 100644 --- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/perform_app_service_interaction_request.cc +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/perform_app_service_interaction_request.cc @@ -95,7 +95,7 @@ void PerformAppServiceInteractionRequest::Run() { bool activate_service = request_service_active && !service->record[strings::service_active].asBool(); if (activate_service) { - if (app->is_foreground()) { + if (app->IsFullscreen()) { // App is in foreground, we can just activate the service application_manager_.GetAppServiceManager().ActivateAppService( service_id); diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/publish_app_service_request.cc b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/publish_app_service_request.cc index 171c10913e..bb0855d42f 100644 --- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/publish_app_service_request.cc +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/publish_app_service_request.cc @@ -111,7 +111,7 @@ void PublishAppServiceRequest::Run() { smart_objects::SmartObject service_record = application_manager_.GetAppServiceManager().PublishAppService( manifest, true, connection_key()); - if (app->is_foreground()) { + if (app->IsFullscreen()) { // Service should be activated if app is in the foreground application_manager_.GetAppServiceManager().ActivateAppService( service_record[strings::service_id].asString()); -- cgit v1.2.1 From 89a050714709b3a3027273c17383c0506344ddf5 Mon Sep 17 00:00:00 2001 From: jacobkeeler Date: Mon, 25 Mar 2019 15:42:50 -0400 Subject: Fix versioning and descriptions in MOBILE API --- src/components/interfaces/MOBILE_API.xml | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/components/interfaces/MOBILE_API.xml b/src/components/interfaces/MOBILE_API.xml index f51a4f8201..1090050c91 100644 --- a/src/components/interfaces/MOBILE_API.xml +++ b/src/components/interfaces/MOBILE_API.xml @@ -898,7 +898,7 @@ - Enumeration that describes possible states of turn-by-turn client or AppLink app. + Enumeration that describes possible states of turn-by-turn client or SmartDeviceLink app. @@ -2585,7 +2585,7 @@ - Enumeration linking function names with function IDs in AppLink protocol. Assumes enumeration starts at value 0. + Enumeration linking function names with function IDs in SmartDeviceLink protocol. Assumes enumeration starts at value 0.