X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;f=src%2Fhs-apprecover.cpp;h=025b6fbd3b5959a049d19c14391d23dada371882;hb=fa01549aba442decaf7c6d5b655da2d15d1a32ed;hp=c2464b17df29cb58b918dc6ae39cc620457b6610;hpb=868898485c76ad5b0140e6528ba04c08878ea3ce;p=apps%2Fagl-service-homescreen.git diff --git a/src/hs-apprecover.cpp b/src/hs-apprecover.cpp index c2464b1..025b6fb 100644 --- a/src/hs-apprecover.cpp +++ b/src/hs-apprecover.cpp @@ -90,22 +90,34 @@ int HS_AppRecover::init(afb_api_t api) */ void HS_AppRecover::startRecovery(afb_api_t api, recover_map &map) { - HS_AfmMainProxy afm_proxy; 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; 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()) { m_recovering_set.insert(m.appid); - afm_proxy.start(api, HS_AppInfo::instance()->getAppProperty(m.appid, _keyId)); + std::string &after = m_recover_apps_list[m.appid].after; + if(!after.empty()) { + auto w = m_wait_recover_set.find(m_recover_apps_list[m.appid].after); + if(w != m_wait_recover_set.end()) { + m_wait_recover_set[after].insert(m.appid); + } + else { + std::set new_set; + new_set.insert(m.appid); + m_wait_recover_set[after] = std::move(new_set); + } + continue; // don't immediately start application, wait until after applicaiton started. + } + startApplication(api, m.appid); } } } @@ -122,7 +134,7 @@ void HS_AppRecover::startRecovery(afb_api_t api, recover_map &map) * true : recover app * */ -bool HS_AppRecover::registerRecoveredApp(const std::string &appid) +bool HS_AppRecover::registerRecoveredApp(afb_api_t api, const std::string &appid) { bool ret = false; if(m_recovering_set.empty()) { @@ -140,6 +152,15 @@ bool HS_AppRecover::registerRecoveredApp(const std::string &appid) } ret = true; } + + // check wait recover application + auto w = m_wait_recover_set.find(appid); + if(w != m_wait_recover_set.end()) { + for(auto &ref : m_wait_recover_set[appid]) { + startApplication(api, ref); + } + m_wait_recover_set.erase(appid); + } return ret; } @@ -177,6 +198,23 @@ void HS_AppRecover::screenUpdated(struct json_object *obj) } } +/** + * start application + * + * #### Parameters + * - api : the api + * - appid : application id liked "dashboard" + * + * #### Return + * None + * + */ +void HS_AppRecover::startApplication(afb_api_t api, const std::string &appid) +{ + HS_AfmMainProxy afm_proxy; + afm_proxy.start(api, HS_AppInfo::instance()->getAppProperty(appid, _keyId)); +} + /** * update lastmode file *