APPLNIK-6608. GetSystemInfo request/response implementation.
authorAndrey Oleynik <AOleynik@luxoft.com>
Wed, 9 Apr 2014 15:35:46 +0000 (18:35 +0300)
committerJustin Dickow <jjdickow@gmail.com>
Wed, 9 Jul 2014 18:11:13 +0000 (14:11 -0400)
src/components/application_manager/include/application_manager/policies/policy_handler.h
src/components/application_manager/src/hmi_command_factory.cc
src/components/application_manager/src/message_helper.cc
src/components/application_manager/src/policies/policy_handler.cc
src/components/policy

index 3695c6a..0801c7e 100644 (file)
@@ -179,6 +179,21 @@ class PolicyHandler : public utils::Singleton<PolicyHandler>,
   void OnSystemInfoChanged(const std::string& language);
 
   /**
+   * @brief Save data from GetSystemInfo request to policy table
+   * @param ccpu_version CCPU version
+   * @param wers_country_code WERS country code
+   * @param language System language
+   */
+  void OnGetSystemInfo(const std::string& ccpu_version,
+                       const std::string& wers_country_code,
+                       const std::string& language);
+
+  /**
+   * @brief Send request to HMI to get update on system parameters
+   */
+  virtual void OnSystemInfoUpdateRequired();
+
+  /**
    * Adds statistics info
    * @param type type of info
    */
index 34db1df..51b3e51 100644 (file)
@@ -69,6 +69,8 @@
 #include "application_manager/commands/hmi/on_put_file_notification.h"
 #include "application_manager/commands/hmi/on_ignition_cycle_over_notification.h"
 #include "application_manager/commands/hmi/on_system_info_changed_notification.h"
+#include "application_manager/commands/hmi/get_system_info_request.h"
+#include "application_manager/commands/hmi/get_system_info_response.h"
 #include "application_manager/commands/hmi/close_popup_request.h"
 #include "application_manager/commands/hmi/close_popup_response.h"
 #include "application_manager/commands/hmi/button_get_capabilities_request.h"
@@ -306,6 +308,14 @@ CommandSharedPtr HMICommandFactory::CreateCommand(
       }
       break;
     }
+    case hmi_apis::FunctionID::BasicCommunication_GetSystemInfo: {
+      if (is_response) {
+        command.reset(new commands::GetSystemInfoResponse(message));
+      } else {
+        command.reset(new commands::GetSystemInfoRequest(message));
+      }
+      break;
+    }
     case hmi_apis::FunctionID::SDL_ActivateApp: {
       if (is_response) {
         command.reset(new commands::SDLActivateAppResponse(message));
@@ -1067,15 +1077,7 @@ CommandSharedPtr HMICommandFactory::CreateCommand(
     command.reset(new commands::UpdateSDLRequest(message));
     }
     break;
-    }
-    case hmi_apis::FunctionID::BasicCommunication_OnAppPermissionChanged: {
-    command.reset(new commands::OnAppPermissionChangedNotification(message));
-    break;
-    }
-    case hmi_apis::FunctionID::BasicCommunication_OnAllowApp: {
-    command.reset(new commands::OnAllowAppNotification(message));
-    break;
-    }*/
+    */
     case hmi_apis::FunctionID::BasicCommunication_OnIgnitionCycleOver: {
       command.reset(new commands::OnIgnitionCycleOverNotification(message));
       break;
index 7994cf2..0fb26cb 100644 (file)
@@ -1898,6 +1898,27 @@ void MessageHelper::SendOnStatusUpdate(const std::string& status) {
   ApplicationManagerImpl::instance()->ManageHMICommand(message);
 }
 
+void MessageHelper::SendGetSystemInfoRequest() {
+  smart_objects::SmartObject* message = new smart_objects::SmartObject(
+    smart_objects::SmartType_Map);
+  if (!message) {
+    return;
+  }
+
+  (*message)[strings::params][strings::function_id] =
+    hmi_apis::FunctionID::BasicCommunication_GetSystemInfo;
+  (*message)[strings::params][strings::message_type] =
+    MessageType::kRequest;
+  (*message)[strings::params][strings::correlation_id] =
+    ApplicationManagerImpl::instance()->GetNextHMICorrelationID();
+  (*message)[strings::params][strings::protocol_version] =
+    commands::CommandImpl::protocol_version_;
+  (*message)[strings::params][strings::protocol_type] =
+    commands::CommandImpl::hmi_protocol_type_;
+
+  ApplicationManagerImpl::instance()->ManageHMICommand(message);
+}
+
 mobile_apis::Result::eType MessageHelper::VerifyImageFiles(
   smart_objects::SmartObject& message, ApplicationConstSharedPtr app) {
   if (NsSmartDeviceLink::NsSmartObjects::SmartType_Array == message.getType()) {
index ebb87f1..f20ef96 100644 (file)
@@ -323,6 +323,18 @@ void PolicyHandler::OnSystemInfoChanged(const std::string& language) {
   policy_manager_->SetSystemLanguage(language);
 }
 
+void PolicyHandler::OnGetSystemInfo(const std::string& ccpu_version,
+                                    const std::string& wers_country_code,
+                                    const std::string& language) {
+  LOG4CXX_INFO(logger_, "OnGetSystemInfo");
+  policy_manager_->SetSystemInfo(ccpu_version, wers_country_code, language);
+}
+
+void PolicyHandler::OnSystemInfoUpdateRequired() {
+  LOG4CXX_INFO(logger_, "OnSystemInfoUpdateRequired");
+  application_manager::MessageHelper::SendGetSystemInfoRequest();
+}
+
 void PolicyHandler::OnAppRevoked(const std::string& policy_app_id) {
   LOG4CXX_INFO(logger_, "OnAppRevoked");
   if (!policy_manager_) {
index bb04121..a39fc98 160000 (submodule)
@@ -1 +1 @@
-Subproject commit bb04121e5d947c2cffb395b840d5faf83797d978
+Subproject commit a39fc98a0f29a115834c6acdad7288824e4b2e78