aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorwang_zhiqiang <wang_zhiqiang@dl.cn.nexty-ele.com>2019-04-24 19:22:44 +0800
committerwang_zhiqiang <wang_zhiqiang@dl.cn.nexty-ele.com>2019-04-24 19:22:44 +0800
commit4cb1ba39335aa2a2d2e08481acd72a3682adaefe (patch)
tree0652fc574d098cb904db455ae6522e23a354b102 /src
parent95c8f8ac2526acc5f7467704532ea235532b1876 (diff)
send showWindow event when app start over
Change-Id: I2ced5f48f0c377cdc4261b5bb19ac6f9c40760ea
Diffstat (limited to 'src')
-rw-r--r--src/homescreen.cpp2
-rw-r--r--src/hs-apprecover.cpp10
-rw-r--r--src/hs-apprecover.h2
-rw-r--r--src/hs-clientmanager.cpp25
-rw-r--r--src/hs-clientmanager.h3
5 files changed, 37 insertions, 5 deletions
diff --git a/src/homescreen.cpp b/src/homescreen.cpp
index 2a0ee77..142007f 100644
--- a/src/homescreen.cpp
+++ b/src/homescreen.cpp
@@ -305,6 +305,7 @@ static void tap_shortcut (afb_req_t request)
AFB_INFO("request appid = %s.", value);
ret = g_hs_instance->client_manager->handleRequest(request, __FUNCTION__, value);
if(ret == AFB_REQ_NOT_STARTED_APPLICATION) {
+ g_hs_instance->client_manager->setStartupAppid(std::string(value));
std::string id = g_hs_instance->app_info->getAppProperty(value, _keyId);
HS_AfmMainProxy afm_proxy;
afm_proxy.start(request->api, id);
@@ -462,6 +463,7 @@ static void showWindow(afb_req_t request)
if (value) {
ret = g_hs_instance->client_manager->handleRequest(request, __FUNCTION__, value);
if(ret == AFB_REQ_NOT_STARTED_APPLICATION) {
+ g_hs_instance->client_manager->setStartupAppid(std::string(value));
std::string id = g_hs_instance->app_info->getAppProperty(value, _keyId);
HS_AfmMainProxy afm_proxy;
afm_proxy.start(request->api, id);
diff --git a/src/hs-apprecover.cpp b/src/hs-apprecover.cpp
index cedf751..5ccd039 100644
--- a/src/hs-apprecover.cpp
+++ b/src/hs-apprecover.cpp
@@ -115,13 +115,15 @@ void HS_AppRecover::startRecovery(afb_api_t api, recover_map &map)
* - appid : application id liked "dashboard"
*
* #### Return
- * None
+ * false : not recover app
+ * true : recover app
*
*/
-void HS_AppRecover::registerRecoveredApp(const std::string &appid)
+bool HS_AppRecover::registerRecoveredApp(const std::string &appid)
{
+ bool ret = false;
if(m_recovering_set.empty()) {
- return;
+ return ret;
}
auto it = m_recovering_set.find(appid);
@@ -132,7 +134,9 @@ void HS_AppRecover::registerRecoveredApp(const std::string &appid)
&& ip->second.visibility) {
HS_ClientManager::instance()->pushEvent("showWindow", nullptr, appid);
}
+ ret = true;
}
+ return ret;
}
/**
diff --git a/src/hs-apprecover.h b/src/hs-apprecover.h
index 3a0f8d5..701ec5f 100644
--- a/src/hs-apprecover.h
+++ b/src/hs-apprecover.h
@@ -38,7 +38,7 @@ public:
static HS_AppRecover* instance(void);
int init(afb_api_t api);
void startRecovery(afb_api_t api, recover_map &map);
- void registerRecoveredApp(const std::string &appid);
+ bool registerRecoveredApp(const std::string &appid);
void screenUpdated(struct json_object *obj);
private:
diff --git a/src/hs-clientmanager.cpp b/src/hs-clientmanager.cpp
index 1128b01..89b0ae2 100644
--- a/src/hs-clientmanager.cpp
+++ b/src/hs-clientmanager.cpp
@@ -188,7 +188,7 @@ int HS_ClientManager::handleRequest(afb_req_t request, const char *verb, const c
appid2ctxt[appid] = createClientCtxt(request, appid);
HS_Client* client = addClient(request, appid);
ret = client->handleRequest(request, "subscribe");
- HS_AppRecover::instance()->registerRecoveredApp(std::string(appid));
+ checkRegisterApp(std::string(appid));
}
else {
AFB_NOTICE("not exist session");
@@ -233,4 +233,27 @@ int HS_ClientManager::pushEvent(const char *event, struct json_object *param, st
}
return 0;
+}
+
+/**
+ * check register application
+ *
+ * #### Parameters
+ * - appid : register application's id
+ *
+ * #### Return
+ * None
+ *
+ */
+void HS_ClientManager::checkRegisterApp(const std::string &appid)
+{
+ if(HS_AppRecover::instance()->registerRecoveredApp(appid)) {
+ AFB_NOTICE("register recover application.");
+ return;
+ }
+
+ if(startup_appid == appid) {
+ startup_appid.clear();
+ pushEvent("showWindow", nullptr, appid);
+ }
} \ No newline at end of file
diff --git a/src/hs-clientmanager.h b/src/hs-clientmanager.h
index efc36de..54283c2 100644
--- a/src/hs-clientmanager.h
+++ b/src/hs-clientmanager.h
@@ -48,17 +48,20 @@ public:
int handleRequest(afb_req_t request, const char *verb, const char *appid = nullptr);
int pushEvent(const char *event, struct json_object *param, std::string appid = "");
void removeClientCtxt(void *data); // don't use, internal only
+ void setStartupAppid(const std::string &appid) {startup_appid = appid;}
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);
private:
static HS_ClientManager* me;
std::unordered_map<std::string, HS_Client*> client_list;
std::unordered_map<std::string, HS_ClientCtxt*> appid2ctxt;
std::mutex mtx;
+ std::string startup_appid;
};
#endif // HOMESCREEN_CLIENTMANAGER_H \ No newline at end of file