APPLINK-6209 Resumption: core doesn't store submenus data.
authorakutsan <akutsan@akutsan>
Fri, 14 Mar 2014 07:57:17 +0000 (09:57 +0200)
committerJustin Dickow <jjdickow@gmail.com>
Tue, 8 Jul 2014 21:31:13 +0000 (17:31 -0400)
src/components/application_manager/include/application_manager/resume_ctrl.h
src/components/application_manager/include/application_manager/smart_object_keys.h
src/components/application_manager/src/commands/mobile/add_sub_menu_request.cc
src/components/application_manager/src/resume_ctrl.cpp

index 2142d05..2aab430 100644 (file)
@@ -201,6 +201,7 @@ class ResumeCtrl: public event_engine::EventObserver {
     bool ApplicationIsSaved(const uint32_t app_id);
 
     Json::Value GetApplicationCommands(const uint32_t app_id);
+    Json::Value GetApplicationSubMenus(const uint32_t app_id);
     Json::Value GetApplicationInteractionChoiseSets(const uint32_t app_id);
     Json::Value GetApplicationGlobalProperties(const uint32_t app_id);
     Json::Value GetApplicationSubscriptions(const uint32_t app_id);
index e76bbe0..fc810c0 100644 (file)
@@ -214,6 +214,7 @@ const char supported_diag_modes[] = "supportedDiagModes";
 
 //resuming
 const char application_commands[] = "applicationCommands";
+const char application_submenus[] = "applicationSubMenus";
 const char application_choise_sets[] = "applicationChoiceSets";
 const char application_global_properties[] = "globalProperties";
 const char application_vehicle_info[] = "vehicleInfo";
index b3a8b90..af341bf 100644 (file)
@@ -119,8 +119,8 @@ void AddSubMenuRequest::on_event(const event_engine::Event& event) {
                                    [strings::menu_id].asInt(),
                         (*message_)[strings::msg_params]);
        }
-
       SendResponse(result, result_code, NULL, &(message[strings::msg_params]));
+      application->UpdateHash();
       break;
     }
     default: {
index c188dfa..4b8064e 100644 (file)
@@ -57,16 +57,19 @@ void ResumeCtrl::SaveApplication(ApplicationConstSharedPtr application) {
     saved_applications_.push_back(Json::Value());
     json_app = &(saved_applications_.back());
   }
-
+  uint32_t hash = application->curHash();
+  LOG4CXX_INFO(logger_, " Hash = " << hash);
   uint32_t connection_key = application->app_id();
   (*json_app)[strings::app_id] = app_id;
   (*json_app)[strings::connection_key] = connection_key;
   (*json_app)[strings::hmi_level] =
       static_cast<int32_t> (application->hmi_level());
   (*json_app)[strings::ign_off_count] = 0;
-  (*json_app)[strings::hash_id] = application->curHash();
+  (*json_app)[strings::hash_id] = hash;
   (*json_app)[strings::application_commands] =
       GetApplicationCommands(connection_key);
+  (*json_app)[strings::application_submenus] =
+      GetApplicationSubMenus(connection_key);
   (*json_app)[strings::application_choise_sets] =
       GetApplicationInteractionChoiseSets(connection_key);
   (*json_app)[strings::application_global_properties] =
@@ -171,11 +174,28 @@ bool ResumeCtrl::RestoreApplicationData(ApplicationSharedPtr application) {
 
   LOG4CXX_INFO(logger_, saved_app.toStyledString());
   Json::Value& app_commands = saved_app[strings::application_commands];
+  Json::Value& app_submenus = saved_app[strings::application_submenus];
   Json::Value& app_choise_sets = saved_app[strings::application_choise_sets];
   Json::Value& global_properties = saved_app[strings::application_global_properties];
   Json::Value& subscribtions = saved_app[strings::application_subscribtions];
 
 
+  //add submenus
+  for (Json::Value::iterator json_it = app_submenus.begin();
+      json_it != app_submenus.end(); ++json_it)  {
+    Json::Value& json_submenu = *json_it;
+    smart_objects::SmartObject message = smart_objects::SmartObject(
+                                         smart_objects::SmartType::SmartType_Map);
+    Formatters::CFormatterJsonBase::jsonValueToObj(json_submenu, message);
+    application->AddSubMenu(message[strings::menu_id].asUInt(), message);
+  }
+  requests = MessageHelper::CreateAddSubMenuRequestToHMI(application);
+
+  for (MessageHelper::SmartObjectList::iterator it = requests.begin();
+       it != requests.end(); ++it) {
+    ProcessHMIRequest(*it, true);
+  }
+
   //add commands
   for (Json::Value::iterator json_it = app_commands.begin();
       json_it != app_commands.end(); ++json_it)  {
@@ -309,8 +329,11 @@ void ResumeCtrl::SavetoFileSystem() {
 bool ResumeCtrl::StartResumption(ApplicationSharedPtr application,
                                  uint32_t hash) {
 
-  LOG4CXX_INFO(logger_, "ResumeCtrl::StartResumption " << hash);
+  LOG4CXX_INFO(logger_, "ResumeCtrl::StartResumption");
   DCHECK(application.get());
+  LOG4CXX_INFO(logger_, "app_id = " << application->app_id());
+  LOG4CXX_INFO(logger_, "mobile_id = " << application->mobile_app_id());
+
   sync_primitives::AutoLock auto_lock(queue_lock_);
 
   std::vector<Json::Value>::iterator it = saved_applications_.begin();
@@ -320,8 +343,11 @@ bool ResumeCtrl::StartResumption(ApplicationSharedPtr application,
 
       uint32_t saved_hash = (*it)[strings::hash_id].asUInt();
       uint32_t time_stamp= (*it)[strings::time_stamp].asUInt();
+      LOG4CXX_INFO(logger_, "recived hash = " << hash);
+      LOG4CXX_INFO(logger_, "saved hash = " << saved_hash);
       if (hash == saved_hash) {
         RestoreApplicationData(application);
+        application->UpdateHash();
       }
 
       waiting_for_timer_.insert(std::make_pair(application->app_id(),
@@ -390,6 +416,26 @@ Json::Value ResumeCtrl::GetApplicationCommands(const uint32_t app_id) {
   return result;
 }
 
+Json::Value ResumeCtrl::GetApplicationSubMenus(const uint32_t app_id) {
+  LOG4CXX_INFO(logger_, "ResumeCtrl::GetApplicationCommands" << app_id);
+
+  ApplicationConstSharedPtr app =
+      ApplicationManagerImpl::instance()->application(app_id);
+  DCHECK(app.get());
+
+  Json::Value result;
+  const SubMenuMap& sub_menus = app->sub_menu_map();
+  SubMenuMap::const_iterator it = sub_menus.begin();
+  for (;it != sub_menus.end(); ++it) {
+    smart_objects::SmartObject* so = it->second;
+    Json::Value curr;
+    Formatters::CFormatterJsonBase::objToJsonValue(*so, curr);
+    result.append(curr);
+    LOG4CXX_INFO(logger_, "Converted:" << curr.toStyledString());
+  }
+  return result;
+}
+
 Json::Value ResumeCtrl::GetApplicationInteractionChoiseSets(
     const uint32_t app_id) {
   LOG4CXX_INFO(logger_, "ResumeCtrl::GetApplicationInteractionChoiseSets"