diff options
author | JackLivio <jack@livio.io> | 2018-11-21 13:30:30 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-11-21 13:30:30 -0500 |
commit | 8c761e3fcaf4a7f052df405f129fedee7930258a (patch) | |
tree | 1ca254e0e6fe7755f6da17e88e73f2487e3af9f9 | |
parent | 1d4f4d3007eae680b425427f3f73d10807f025ce (diff) | |
parent | c72a8402d33f1481799f40ff3715578a274dcf48 (diff) | |
download | sdl_core-8c761e3fcaf4a7f052df405f129fedee7930258a.tar.gz |
Merge pull request #2747 from smartdevicelink/feature/setcloudappproperties_rpc
New RPC SetCloudAppProperties
13 files changed, 280 insertions, 8 deletions
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/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..0c62b248b4 --- /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,31 @@ +#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..9037cb3b73 --- /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,31 @@ +#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..d92f458587 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/set_cloudapp_properties_request.cc @@ -0,0 +1,48 @@ +#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; + } + + 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_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..6acfb2423d --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/set_cloudapp_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_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..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 @@ -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,12 @@ CommandCreator& MobileCommandFactory::get_creator_factory( ? factory.GetCreator<commands::SendHapticDataRequest>() : factory.GetCreator<commands::SendHapticDataResponse>(); } + case mobile_apis::FunctionID::SetCloudAppPropertiesID: { + return mobile_api::messageType::request == message_type + ? factory.GetCreator<commands::SetCloudAppPropertiesRequest>() + : factory + .GetCreator<commands::SetCloudAppPropertiesResponse>(); + } case mobile_apis::FunctionID::OnButtonEventID: { return factory.GetCreator<commands::mobile::OnButtonEventNotification>(); } diff --git a/src/components/application_manager/src/policies/policy_handler.cc b/src/components/application_manager/src/policies/policy_handler.cc index 505f29e13b..8c026c8c75 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,16 @@ 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<HybridAppPreference>::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<mobile_apis::HybridAppPreference::eType>( + 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/interfaces/MOBILE_API.xml b/src/components/interfaces/MOBILE_API.xml index 6ed42c3588..714399bce6 100644 --- a/src/components/interfaces/MOBILE_API.xml +++ b/src/components/interfaces/MOBILE_API.xml @@ -545,6 +545,13 @@ <element name="VEHICLEDATA_CLOUDAPPVEHICLEID" since="5.1"/> </enum> + <enum name="HybridAppPreference" since="5.1"> + <description>Enumeration for the user's preference of which app type to use when both are available</description> + <element name="MOBILE" /> + <element name="CLOUD" /> + <element name="BOTH" /> + </enum> + <enum name="ButtonName" since="1.0"> <description>Defines the hard (physical) and soft (touchscreen) buttons available from the module</description> <element name="OK" /> @@ -2609,6 +2616,7 @@ <element name="UnsubscribeWayPointsID" value="47" hexvalue="2F" since="4.1" /> <element name="GetSystemCapabilityID" value="48" hexvalue="30" since="4.5" /> <element name="SendHapticDataID" value="49" hexvalue="31" since="4.5" /> + <element name="SetCloudAppPropertiesID" value="50" hexvalue="32" since="5.1" /> <!-- Base Notifications @@ -6626,6 +6634,51 @@ </param> </function> + <function name="SetCloudAppProperties" functionID="SetCloudAppPropertiesID" messagetype="request" since="5.1"> + <description> + RPC used to enable/disable a cloud application and set authentication data + </description> + <param name="appName" type="String" maxlength="100" mandatory="true"></param> + <param name="appID" type="String" maxlength="100" mandatory="true"></param> + <param name="enabled" type="Boolean" mandatory="false"> + <description>If true, cloud app will be included in HMI RPC UpdateAppList</description> + </param> + <param name="cloudAppAuthToken" type="String" maxlength="100" mandatory="false"> + <description>Used to authenticate websocket connection on app activation</description> + </param> + <param name="cloudTransportType" type="String" maxlength="100" mandatory="false"> + <description>Specifies the connection type Core should use</description> + </param> + <param name="hybridAppPreference" type="HybridAppPreference" mandatory="false"> + <description>Specifies the user preference to use the cloud app version or mobile app version when both are available</description> + </param> + </function> + + <function name="SetCloudAppProperties" functionID="SetCloudAppPropertiesID" messagetype="response" since="5.1"> + <description> + The response to registerAppInterface + </description> + <param name="success" type="Boolean" platform="documentation" mandatory="true"> + <description> true if successful; false if failed </description> + </param> + <param name="resultCode" type="Result" platform="documentation" mandatory="true"> + <description>See Result</description> + <element name="SUCCESS" /> + <element name="INVALID_DATA" /> + <element name="OUT_OF_MEMORY" /> + <element name="TOO_MANY_PENDING_REQUESTS" /> + <element name="GENERIC_ERROR" /> + <element name="DUPLICATE_NAME" /> + <element name="TOO_MANY_APPLICATIONS" /> + <element name="APPLICATION_REGISTERED_ALREADY" /> + <element name="UNSUPPORTED_VERSION" /> + <element name="WRONG_LANGUAGE" /> + <element name="DISALLOWED" /> + <element name="WARNINGS" /> + <element name="RESUME_FAILED" /> + </param> + </function> + <!-- Notifications --> <function name="OnHMIStatus" functionID="OnHMIStatusID" messagetype="notification" since="1.0"> 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..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 @@ -441,6 +441,11 @@ enum FunctionID { SendHapticDataID = 49, /** + * @brief SetCloudAppPropertiesID. + */ + SetCloudAppPropertiesID = 50, + + /** * @brief OnHMIStatusID. */ OnHMIStatusID = 32768, 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..d7d5a241de 100644 --- a/src/components/policy/policy_external/src/policy_table/enums.cc +++ b/src/components/policy/policy_external/src/policy_table/enums.cc @@ -1121,6 +1121,11 @@ bool EnumFromJsonString(const std::string& literal, FunctionID* result) { return true; } + if ("SetCloudAppProperties" == literal) { + *result = SetCloudAppPropertiesID; + 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 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 @@ -427,6 +427,11 @@ enum FunctionID { SendHapticDataID = 49, /** + * @brief SetCloudAppPropertiesID. + */ + SetCloudAppPropertiesID = 50, + + /** * @brief OnHMIStatusID. */ OnHMIStatusID = 32768, 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..91d0a6990f 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; 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; } |