X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;f=src%2Fhs-apprecover.cpp;h=adc8a3a856f22ffcfcb4c773cab3eb5f5378e861;hb=690bef15acbffe7245b8a0b15ee4372f1ccea5d3;hp=025b6fbd3b5959a049d19c14391d23dada371882;hpb=fa01549aba442decaf7c6d5b655da2d15d1a32ed;p=apps%2Fagl-service-homescreen.git diff --git a/src/hs-apprecover.cpp b/src/hs-apprecover.cpp index 025b6fb..adc8a3a 100644 --- a/src/hs-apprecover.cpp +++ b/src/hs-apprecover.cpp @@ -88,18 +88,20 @@ int HS_AppRecover::init(afb_api_t api) * None * */ -void HS_AppRecover::startRecovery(afb_api_t api, recover_map &map) +void HS_AppRecover::startRecovery(afb_api_t api) { + this->addListenAppId(_listen_all); + HS_ClientManager::instance()->addListener(this); + 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; + for(auto &m : recover_app_map[key]){ + 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()) { @@ -121,26 +123,22 @@ void HS_AppRecover::startRecovery(afb_api_t api, recover_map &map) } } } + recover_app_map.clear(); } /** - * register started applications + * notify * * #### Parameters - * - appid : application id liked "dashboard" + * - api : the api + * - appid : application id * * #### Return - * false : not recover app - * true : recover app - * + * None + * */ -bool HS_AppRecover::registerRecoveredApp(afb_api_t api, const std::string &appid) +void HS_AppRecover::notify(afb_api_t api, std::string appid) { - bool ret = false; - if(m_recovering_set.empty()) { - return ret; - } - AFB_INFO("recover appid=[%s].", appid.c_str()); auto it = m_recovering_set.find(appid); if(it != m_recovering_set.end()) { @@ -150,7 +148,6 @@ bool HS_AppRecover::registerRecoveredApp(afb_api_t api, const std::string &appid && ip->second.visibility) { HS_ClientManager::instance()->pushEvent("showWindow", nullptr, appid); } - ret = true; } // check wait recover application @@ -161,7 +158,10 @@ bool HS_AppRecover::registerRecoveredApp(afb_api_t api, const std::string &appid } m_wait_recover_set.erase(appid); } - return ret; + + if(m_recovering_set.empty()) { + HS_ClientManager::instance()->removeListener(this); + } } /** @@ -176,6 +176,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 s_mode; struct json_object *ids_obj; if(json_object_object_get_ex(obj, key_ids.c_str(), &ids_obj)) {