improvement
authorwang_zhiqiang <wang_zhiqiang@dl.cn.nexty-ele.com>
Fri, 24 May 2019 06:28:18 +0000 (14:28 +0800)
committerwang_zhiqiang <wang_zhiqiang@dl.cn.nexty-ele.com>
Fri, 24 May 2019 06:28:18 +0000 (14:28 +0800)
Change-Id: I654800d1d467ff1d5b858dc048bb4271485fb46a

src/hs-apprecover.cpp
src/hs-config.cpp

index 025b6fb..bd34eda 100644 (file)
@@ -92,14 +92,13 @@ void HS_AppRecover::startRecovery(afb_api_t api, recover_map &map)
 {
     for(auto &key : HS_Config::keys_recover_type) {
         for(auto &m : map[key]){
-            struct app_recover_info recover_info;
-            recover_info.recover_type = key;
-            recover_info.visibility = m.visibility;
-            recover_info.after = m.after;
+            struct app_recover_info recover_info = {
+                .recover_type = key,
+                .visibility = m.visibility,
+                .after = m.after
+            };
             m_recover_apps_list[m.appid] = std::move(recover_info);
-            if(key == HS_Config::keys_recover_type[1]) {
-                m_lastmode_list.insert(m.appid);
-            }
+
             // recover application
             auto it = m_recovering_set.find(m.appid);
             if(it == m_recovering_set.end()) {
@@ -176,6 +175,11 @@ bool HS_AppRecover::registerRecoveredApp(afb_api_t api, const std::string &appid
  */
 void HS_AppRecover::screenUpdated(struct json_object *obj)
 {
+    if(m_lastmode_list.empty()) {
+        AFB_NOTICE("init lastmode is null, so don't record lastmode.");
+        return;
+    }
+
     std::set<std::string> s_mode;
     struct json_object *ids_obj;
     if(json_object_object_get_ex(obj, key_ids.c_str(), &ids_obj)) {
index a227d30..f043d46 100644 (file)
@@ -49,7 +49,7 @@ int HS_Config::readConfig(void)
 
     path = root_dir + "/etc/" + lastmode_json;
     if(readJsonFile(path.c_str(), &m_lastmode) < 0) {
-        AFB_ERROR("read %s failed.", lastmode_json.c_str());
+        AFB_WARNING("read %s failed.", lastmode_json.c_str());
         m_lastmode = nullptr;
     }