2 * Copyright (c) 2019 TOYOTA MOTOR CORPORATION
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 #include "hs-apprecover.h"
18 #include "hs-appinfo.h"
20 #include "hs-clientmanager.h"
22 const char _keyArea[] = "area";
25 * starting recover applications
29 * - map : recover app map
35 void HS_AppRecover::startRecovery(afb_api_t api, recover_map &map)
37 HS_AfmMainProxy afm_proxy;
38 for(auto &key : HS_Config::keys_recover_type) {
39 for(auto &m : map[key]){
40 struct app_recover_info recover_info;
41 recover_info.recover_type = key;
42 recover_info.visibility = m.visibility;
43 m_recover_apps_list[m.appid] = std::move(recover_info);
45 // recover application
46 m_recovering_set.insert(m.appid);
47 afm_proxy.start(api, HS_AppInfo::instance()->getAppProperty(m.appid, _keyId));
53 * register started applications
56 * - appid : application id liked "dashboard"
59 * false : not all application recovered
60 * true : all applications recovered
62 bool HS_AppRecover::registerRecoveredApp(std::string &appid)
64 auto it = m_recovering_set.find(appid);
65 if(it != m_recovering_set.end()) {
66 m_recovering_set.erase(appid);
67 auto ip = m_recover_apps_list.find(appid);
68 if(ip != m_recover_apps_list.end()
69 && ip->second.visibility) {
70 HS_ClientManager::instance()->pushEvent("showWindow", nullptr, appid);
74 return m_recovering_set.empty() ? true : false;