aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--conf/hs-conf.json6
-rw-r--r--conf/lastmode.json9
-rw-r--r--src/homescreen.cpp13
-rw-r--r--src/hs-apprecover.cpp46
-rw-r--r--src/hs-apprecover.h5
-rw-r--r--src/hs-clientmanager.cpp10
-rw-r--r--src/hs-clientmanager.h2
-rw-r--r--src/hs-config.cpp7
-rw-r--r--src/hs-config.h2
9 files changed, 75 insertions, 25 deletions
diff --git a/conf/hs-conf.json b/conf/hs-conf.json
index 35aabf3..0c01ebd 100644
--- a/conf/hs-conf.json
+++ b/conf/hs-conf.json
@@ -11,7 +11,8 @@
},
{
"appid": "launcher",
- "visibility": "invisible"
+ "visibility": "invisible",
+ "after": "homescreen"
},
{
"appid": "onscreenapp",
@@ -25,7 +26,8 @@
"default-lastmode": [
{
"appid": "launcher",
- "visibility": "visible"
+ "visibility": "visible",
+ "after": "homescreen"
}
],
"normal-apps": [
diff --git a/conf/lastmode.json b/conf/lastmode.json
index 12387ad..3d57f46 100644
--- a/conf/lastmode.json
+++ b/conf/lastmode.json
@@ -1,10 +1,7 @@
[
{
- "appid": "navigation",
- "visibility": "visible"
- },
- {
- "appid": "video",
- "visibility": "visible"
+ "appid": "phone",
+ "visibility": "visible",
+ "after": "homescreen"
}
] \ No newline at end of file
diff --git a/src/homescreen.cpp b/src/homescreen.cpp
index 142007f..1caa23d 100644
--- a/src/homescreen.cpp
+++ b/src/homescreen.cpp
@@ -183,12 +183,12 @@ int hs_instance::init(afb_api_t api)
return -1;
}
- const struct handshake_info *h = hs_config.getHandshakeInfo();
- struct hs_handshake handshake(h->times, h->sleep);
- if(handshake.start(api) < 0) {
- AFB_ERROR("handshake with windowmanager failed.");
- return -1;
- }
+ // const struct handshake_info *h = hs_config.getHandshakeInfo();
+ // struct hs_handshake handshake(h->times, h->sleep);
+ // if(handshake.start(api) < 0) {
+ // AFB_ERROR("handshake with windowmanager failed.");
+ // return -1;
+ // }
if(app_recover == nullptr) {
AFB_ERROR("app_recover is nullptr.");
@@ -682,6 +682,7 @@ static int init(afb_api_t api)
AFB_WARNING( "g_hs_instance isn't null.");
delete g_hs_instance->client_manager;
delete g_hs_instance->app_info;
+ delete g_hs_instance->app_recover;
delete g_hs_instance;
g_hs_instance = nullptr;
}
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<std::string> 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;
}
@@ -178,6 +199,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
*
* #### Parameters
diff --git a/src/hs-apprecover.h b/src/hs-apprecover.h
index 701ec5f..b702bd9 100644
--- a/src/hs-apprecover.h
+++ b/src/hs-apprecover.h
@@ -24,6 +24,7 @@
struct app_recover_info {
std::string recover_type;
bool visibility;
+ std::string after;
};
class HS_AppRecover {
@@ -38,10 +39,11 @@ public:
static HS_AppRecover* instance(void);
int init(afb_api_t api);
void startRecovery(afb_api_t api, recover_map &map);
- bool registerRecoveredApp(const std::string &appid);
+ bool registerRecoveredApp(afb_api_t api, const std::string &appid);
void screenUpdated(struct json_object *obj);
private:
+ void startApplication(afb_api_t api, const std::string &appid);
void updateLastmode(std::set<std::string> &set);
bool isHomescreenApp(const std::string &appid) const;
@@ -49,6 +51,7 @@ private:
static HS_AppRecover* me;
std::map<std::string, struct app_recover_info> m_recover_apps_list;
std::set<std::string> m_recovering_set;
+ std::map<std::string, std::set<std::string>> m_wait_recover_set;
std::set<std::string> m_lastmode_list;
};
diff --git a/src/hs-clientmanager.cpp b/src/hs-clientmanager.cpp
index 832c64f..86e1f28 100644
--- a/src/hs-clientmanager.cpp
+++ b/src/hs-clientmanager.cpp
@@ -199,7 +199,7 @@ int HS_ClientManager::handleRequest(afb_req_t request, const char *verb, const c
}
}
if(isRegisterApp) {
- checkRegisterApp(std::string(appid));
+ checkRegisterApp(request->api, std::string(appid));
}
return ret;
}
@@ -245,17 +245,17 @@ int HS_ClientManager::pushEvent(const char *event, struct json_object *param, st
* check register application
*
* #### Parameters
+ * - api : the api
* - appid : register application's id
*
* #### Return
* None
*
*/
-void HS_ClientManager::checkRegisterApp(const std::string &appid)
+void HS_ClientManager::checkRegisterApp(afb_api_t api, const std::string &appid)
{
- AFB_INFO("appid=[%s].", appid.c_str());
- if(HS_AppRecover::instance()->registerRecoveredApp(appid)) {
- AFB_NOTICE("register recover application.");
+ if(HS_AppRecover::instance()->registerRecoveredApp(api, appid)) {
+ AFB_INFO("register recover application.");
return;
}
diff --git a/src/hs-clientmanager.h b/src/hs-clientmanager.h
index 54283c2..366f256 100644
--- a/src/hs-clientmanager.h
+++ b/src/hs-clientmanager.h
@@ -54,7 +54,7 @@ private:
HS_ClientCtxt* createClientCtxt(afb_req_t req, std::string appid);
HS_Client* addClient(afb_req_t req, std::string appid);
void removeClient(std::string appid);
- void checkRegisterApp(const std::string &appid);
+ void checkRegisterApp(afb_api_t api, const std::string &appid);
private:
static HS_ClientManager* me;
diff --git a/src/hs-config.cpp b/src/hs-config.cpp
index c0d6942..df45e42 100644
--- a/src/hs-config.cpp
+++ b/src/hs-config.cpp
@@ -25,6 +25,7 @@ const std::array<std::string, 3> HS_Config::keys_recover_type = { // based on
const std::string HS_Config::lastmode_json = "lastmode.json";
const std::string HS_Config::key_appid = "appid";
const std::string HS_Config::key_visibility = "visibility";
+const std::string HS_Config::key_after = "after";
std::string HS_Config::root_dir = "";
/**
@@ -145,6 +146,12 @@ std::vector<struct recover_app_info> HS_Config::getRecoverAppInfo(struct json_ob
else {
info.visibility = false;
}
+ if(json_object_object_get_ex(info_obj, key_after.c_str(), &value_obj)) {
+ info.after = json_object_get_string(value_obj);
+ }
+ else {
+ info.after.clear();
+ }
v_app_info.push_back(info);
}
diff --git a/src/hs-config.h b/src/hs-config.h
index fda49a7..56a2cfe 100644
--- a/src/hs-config.h
+++ b/src/hs-config.h
@@ -31,6 +31,7 @@ struct handshake_info {
struct recover_app_info {
std::string appid; // application id like "dashboard"
bool visibility; // the visibility when system starting
+ std::string after; // startup after which application
};
using recover_map = std::unordered_map<std::string, std::vector<struct recover_app_info>>;
@@ -51,6 +52,7 @@ public:
static const std::string lastmode_json;
static const std::string key_appid;
static const std::string key_visibility;
+ static const std::string key_after;
static std::string root_dir;
private: