X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;f=src%2Fapplist.cpp;h=473d68751446bbfe1305260f0f351dae04d393d4;hb=refs%2Fheads%2Ficefish;hp=a5ae9f000e56bfaa13632921f04fe85d391dbb8f;hpb=847dde9621cef9b9a44eda95c63c0fe3f528468d;p=apps%2Fagl-service-windowmanager.git diff --git a/src/applist.cpp b/src/applist.cpp index a5ae9f0..473d687 100644 --- a/src/applist.cpp +++ b/src/applist.cpp @@ -16,7 +16,7 @@ #include #include #include "applist.hpp" -#include "../include/hmi-debug.h" +#include "util.hpp" using std::shared_ptr; using std::string; @@ -65,7 +65,7 @@ AppList::~AppList() {} * @attention This function should be called once for the app * Caller should take care not to be called more than once. */ -void AppList::addClient(const std::string &appid, unsigned layer, unsigned surface, const std::string &role) +void AppList::addClient(const string &appid, unsigned layer, unsigned surface, const string &role) { std::lock_guard lock(this->mtx); shared_ptr client = std::make_shared(appid, layer, surface, role); @@ -73,6 +73,35 @@ void AppList::addClient(const std::string &appid, unsigned layer, unsigned surfa this->clientDump(); } +void AppList::addClient(const string &appid, unsigned layer, const string &role) +{ + std::lock_guard lock(this->mtx); + shared_ptr client = std::make_shared(appid, layer, role); + this->app2client[appid] = client; + this->clientDump(); +} + +/** + * Add Client to the list + * + * This function is overload function. + * But this function just register application. + * So an application does not have role, surface, layer. + * Client need to register role and layer afterward. + * + * @param string[in] Application id. This will be the key to withdraw the information. + * @return None + * @attention This function should be called once for the app + * Caller should take care not to be called more than once. + */ +void AppList::addClient(const string &appid) +{ + std::lock_guard lock(this->mtx); + shared_ptr client = std::make_shared(appid, 0, ""); + this->app2client[appid] = client; + this->clientDump(); +} + /** * Remove WMClient from the list * @@ -82,7 +111,7 @@ void AppList::removeClient(const string &appid) { std::lock_guard lock(this->mtx); this->app2client.erase(appid); - HMI_INFO("wm", "Remove client %s", appid.c_str()); + HMI_INFO("Remove client %s", appid.c_str()); } /** @@ -111,7 +140,7 @@ void AppList::removeSurface(unsigned surface){ { ret = x.second->removeSurfaceIfExist(surface); if(ret){ - HMI_DEBUG("wm", "remove surface %d from Client %s finish", + HMI_DEBUG("remove surface %d from Client %s finish", surface, x.second->appID().c_str()); break; } @@ -132,7 +161,14 @@ void AppList::removeSurface(unsigned surface){ */ shared_ptr AppList::lookUpClient(const string &appid) { - return this->app2client.at(appid); + if(this->app2client.count(appid) != 0) + { + return this->app2client.at(appid); + } + else + { + return nullptr; + } } /** @@ -154,17 +190,16 @@ int AppList::countClient() const * Returns AppID if found. * * @param unsigned[in] surfaceID - * @param string[in] role * @param bool[in,out] AppID is found or not * @return AppID * @attention If AppID is not found, param found will be false. */ -string AppList::getAppID(unsigned surface, const string& role, bool* found) const +string AppList::getAppID(unsigned surface, bool* found) const { *found = false; for (const auto &x : this->app2client) { - if(x.second->surfaceID(role) == surface){ + if(x.second->surfaceID() == surface){ *found = true; return x.second->appID(); } @@ -296,6 +331,10 @@ const vector &AppList::getActions(unsigned req_num, bool* found } } HMI_SEQ_ERROR(req_num, "Couldn't get action with the request : %d", req_num); + { + static vector empty; + return empty; + } } /** @@ -351,7 +390,7 @@ WMError AppList::setAction(unsigned req_num, const struct WMAction &action) * otherwise (visible is false) app should be invisible. Then enddraw_finished param is set to true. * This function doesn't support actions for focus yet. */ -WMError AppList::setAction(unsigned req_num, const string &appid, const string &role, const string &area, TaskVisible visible) +WMError AppList::setAction(unsigned req_num, shared_ptr client, const string &role, const string &area, TaskVisible visible) { std::lock_guard lock(this->mtx); WMError result = WMError::FAIL; @@ -363,7 +402,7 @@ WMError AppList::setAction(unsigned req_num, const string &appid, const string & } // If visible task is not invisible, redraw is required -> true bool edraw_f = (visible != TaskVisible::INVISIBLE) ? false : true; - WMAction action{appid, role, area, visible, edraw_f}; + WMAction action{req_num, client, role, area, visible, edraw_f}; x.sync_draw_req.push_back(action); result = WMError::SUCCESS; @@ -399,7 +438,7 @@ bool AppList::setEndDrawFinished(unsigned req_num, const string &appid, const st { for (auto &y : x.sync_draw_req) { - if (y.appid == appid && y.role == role) + if (y.client->appID() == appid && y.role == role) { HMI_SEQ_INFO(req_num, "Role %s finish redraw", y.role.c_str()); y.end_draw_finished = true; @@ -514,7 +553,7 @@ void AppList::reqDump() { DUMP( "Action : (APPID :%s, ROLE :%s, AREA :%s, VISIBLE : %s, END_DRAW_FINISHED: %d)", - y.appid.c_str(), + y.client->appID().c_str(), y.role.c_str(), y.area.c_str(), (y.visible == TaskVisible::INVISIBLE) ? "invisible" : "visible",