start launcher and lastmode after homescreen started
[apps/agl-service-homescreen.git] / src / homescreen.cpp
index cb8a633..1caa23d 100644 (file)
@@ -140,8 +140,9 @@ int hs_handshake::start(afb_api_t api) const
 struct hs_instance {
     HS_ClientManager *client_manager;   // the connection session manager
     HS_AppInfo *app_info;               // application info
+    HS_AppRecover *app_recover;
 
-    hs_instance() : client_manager(HS_ClientManager::instance()), app_info(HS_AppInfo::instance()) {}
+    hs_instance() : client_manager(HS_ClientManager::instance()), app_info(HS_AppInfo::instance()), app_recover(HS_AppRecover::instance()) {}
     int init(afb_api_t api);
     void setEventHook(const char *event, const event_hook_func f);
     void onEvent(afb_api_t api, const char *event, struct json_object *object);
@@ -182,20 +183,19 @@ 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;
+    // }
 
-    HS_AppRecover *app_recover = new HS_AppRecover();
     if(app_recover == nullptr) {
         AFB_ERROR("app_recover is nullptr.");
         return -1;
     }
+    app_recover->init(api);
     app_recover->startRecovery(api, hs_config.getRecoverMap());
-    client_manager->setAppRecover(app_recover);
 
     return 0;
 }
@@ -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);
@@ -680,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;
     }