X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;f=src%2Fapp.cpp;h=d4c36f9327096720d190b07bb515a7612fb2909e;hb=8f01fbeeca1a6f3d10ea42b312191532a4a830d4;hp=0c8980469168337e83152729c56e2b2ca688edde;hpb=d50bc2311ce07e7e5e60b217cc5d904eaf4f9c59;p=apps%2Fagl-service-windowmanager.git diff --git a/src/app.cpp b/src/app.cpp index 0c89804..d4c36f9 100644 --- a/src/app.cpp +++ b/src/app.cpp @@ -46,7 +46,7 @@ extern "C" namespace wm { -const unsigned kTimeOut = 10000000UL; /* 10s */ +static const unsigned kTimeOut = 3000000UL; /* 3s */ /* DrawingArea name used by "{layout}.{area}" */ const char kNameLayoutNormal[] = "normal"; @@ -133,6 +133,15 @@ void App::removeClient(const std::string &appid) g_app_list.removeClient(appid); } +void App::exeptionProcessForTransition() +{ + unsigned req_num = g_app_list.currentRequestNumber(); + HMI_SEQ_NOTICE(req_num, "Process exeption handling for request. Remove current request %d", req_num); + g_app_list.removeRequest(req_num); + HMI_SEQ_NOTICE(g_app_list.currentRequestNumber(), "Process next request if exists"); + this->processNextRequest(); +} + bool App::subscribeEventForApp(const std::string &appid, afb_req req, const std::string &evname) { if(!g_app_list.contains(appid)){ @@ -319,7 +328,7 @@ int App::init_layers() return 0; } -void App::surface_set_layout(int surface_id, optional sub_surface_id) +void App::surface_set_layout(int surface_id, const std::string& area) { if (!this->controller->surface_exists(surface_id)) { @@ -338,7 +347,9 @@ void App::surface_set_layout(int surface_id, optional sub_surface_id) uint32_t layer_id = *o_layer_id; auto const &layer = this->layers.get_layer(layer_id); - auto rect = layer.value().rect; + auto rect = this->layers.getAreaSize(area); + HMI_SEQ_DEBUG(g_app_list.currentRequestNumber(), "%s : x:%d y:%d w:%d h:%d", area.c_str(), + rect.x, rect.y, rect.w, rect.h); auto &s = this->controller->surfaces[surface_id]; int x = rect.x; @@ -610,6 +621,12 @@ WMError App::checkPolicy(unsigned req_num) /* get new status from Policy Manager */ HMI_SEQ_NOTICE(req_num, "ATM, Policy manager does't exist, then set WMAction as is"); + if(trigger.role == "HomeScreen") + { + // TODO : Remove when Policy Manager completed + HMI_SEQ_NOTICE(req_num, "Hack. This process will be removed. Change HomeScreen code!!"); + req_area = "fullscreen"; + } TaskVisible task_visible = (trigger.task == Task::TASK_ALLOCATE) ? TaskVisible::VISIBLE : TaskVisible::INVISIBLE; ret = g_app_list.setAction(req_num, trigger.appid, trigger.role, req_area, task_visible); @@ -631,12 +648,12 @@ WMError App::startTransition(unsigned req_num) return ret; } - for (const auto &y : actions) + for (const auto &action : actions) { - if (y.visible != TaskVisible::INVISIBLE) + if (action.visible != TaskVisible::INVISIBLE) { sync_draw_happen = true; - this->emit_syncdraw(y.role, y.area); + this->emit_syncdraw(action.role, action.area); /* TODO: emit event for app not subscriber if(g_app_list.contains(y.appid)) g_app_list.lookUpClient(y.appid)->emit_syncdraw(y.role, y.area); */ @@ -651,12 +668,12 @@ WMError App::startTransition(unsigned req_num) { // deactivate only, no syncDraw // Make it deactivate here - for (const auto &z : actions) + for (const auto &x : actions) { - if (g_app_list.contains(z.appid)) + if (g_app_list.contains(x.appid)) { - auto client = g_app_list.lookUpClient(z.appid); - this->deactivate(client->surfaceID(z.role)); + auto client = g_app_list.lookUpClient(x.appid); + this->deactivate(client->surfaceID(x.role)); } } ret = NO_LAYOUT_CHANGE; @@ -666,8 +683,8 @@ WMError App::startTransition(unsigned req_num) WMError App::setInvisibleTask(const std::string &role, bool split) { - unsigned req = g_app_list.currentRequestNumber(); - HMI_SEQ_DEBUG(req, "set current visible app to invisible task"); + unsigned req_num = g_app_list.currentRequestNumber(); + HMI_SEQ_DEBUG(req_num, "set current visible app to invisible task"); // This task is copied from original actiavete surface const char *drawing_name = role.c_str(); auto const &surface_id = this->lookup_id(drawing_name); @@ -687,6 +704,7 @@ WMError App::setInvisibleTask(const std::string &role, bool split) { continue; } + HMI_DEBUG("wm", "debug: main %d , sub : %d", l.second.state.main, l.second.state.sub); if (l.second.state.main != -1) { //this->deactivate(l.second.state.main); @@ -696,9 +714,9 @@ WMError App::setInvisibleTask(const std::string &role, bool split) if(!found){ return WMError::NOT_REGISTERED; } - HMI_SEQ_INFO(req, "Invisible %s", add_name.c_str()); + HMI_SEQ_INFO(req_num, "Invisible %s", add_name.c_str()); WMAction act{add_name, add_role, add_area, task_visible, end_draw_finished}; - g_app_list.setAction(req, act); + g_app_list.setAction(req_num, act); l.second.state.main = -1; } @@ -712,9 +730,9 @@ WMError App::setInvisibleTask(const std::string &role, bool split) { return WMError::NOT_REGISTERED; } - HMI_SEQ_INFO(req, "Invisible %s", add_name.c_str()); + HMI_SEQ_INFO(req_num, "Invisible %s", add_name.c_str()); WMAction act{add_name, add_role, add_area, task_visible, end_draw_finished}; - g_app_list.setAction(req, act); + g_app_list.setAction(req_num, act); l.second.state.sub = -1; } } @@ -754,13 +772,13 @@ WMError App::setInvisibleTask(const std::string &role, bool split) deact_sub.appid = g_app_list.getAppID(state.sub, main, &found); if (!found) { - HMI_SEQ_DEBUG(req, "sub surface ddoesn't exist"); + HMI_SEQ_DEBUG(req_num, "sub surface doesn't exist"); return WMError::NOT_REGISTERED; } deact_sub.visible = task_visible; deact_sub.end_draw_finished = end_draw_finished; - HMI_SEQ_DEBUG(req, "sub surface ddoesn't exist"); - g_app_list.setAction(req, deact_sub); + HMI_SEQ_DEBUG(req_num, "sub surface doesn't exist"); + g_app_list.setAction(req_num, deact_sub); } } //state = LayoutState{state.main, *surface_id}; @@ -780,13 +798,13 @@ WMError App::setInvisibleTask(const std::string &role, bool split) deact_main.appid = g_app_list.getAppID(state.main, deact_main.role, &found); if (!found) { - HMI_SEQ_DEBUG(req, "sub surface ddoesn't exist"); + HMI_SEQ_DEBUG(req_num, "sub surface ddoesn't exist"); return WMError::NOT_REGISTERED; } deact_main.visible = task_visible; deact_main.end_draw_finished = end_draw_finished; - HMI_SEQ_DEBUG(req, "sub surface doesn't exist"); - g_app_list.setAction(req, deact_main); + HMI_SEQ_DEBUG(req_num, "sub surface doesn't exist"); + g_app_list.setAction(req_num, deact_main); } if (state.sub != -1) { @@ -800,13 +818,13 @@ WMError App::setInvisibleTask(const std::string &role, bool split) deact_sub.appid = g_app_list.getAppID(state.sub, deact_sub.role, &found); if (!found) { - HMI_SEQ_DEBUG(req, "sub surface ddoesn't exist"); + HMI_SEQ_DEBUG(req_num, "sub surface ddoesn't exist"); return WMError::NOT_REGISTERED; } deact_sub.visible = task_visible; deact_sub.end_draw_finished = end_draw_finished; - HMI_SEQ_DEBUG(req, "sub surface doesn't exist"); - g_app_list.setAction(req, deact_sub); + HMI_SEQ_DEBUG(req_num, "sub surface doesn't exist"); + g_app_list.setAction(req_num, deact_sub); } } //state = LayoutState{*surface_id}; @@ -874,7 +892,7 @@ WMError App::setRequest(const std::string& appid, const std::string &role, const } WMRequest req = WMRequest(appid, role, area, task); - unsigned new_req = g_app_list.addAllocateRequest(req); + unsigned new_req = g_app_list.addRequest(req); *req_num = new_req; g_app_list.reqDump(); @@ -921,8 +939,7 @@ void App::api_activate_surface(char const *appid, char const *drawing_name, char //this->emit_error() HMI_SEQ_ERROR(req_num, errorDescription(ret)); g_app_list.removeRequest(req_num); - g_app_list.next(); - g_app_list.reqDump(); + this->processNextRequest(); } } @@ -936,51 +953,38 @@ void App::api_deactivate_surface(char const *appid, char const *drawing_name, co std::string id = appid; std::string role = drawing_name; std::string area = ""; //drawing_area; + Task task = Task::TASK_RELEASE; + unsigned req_num = 0; + WMError ret = WMError::UNKNOWN; - if (!g_app_list.contains(id)) - { - reply("app doesn't request 'requestSurface' yet"); - return; - } - auto client = g_app_list.lookUpClient(id); + ret = this->setRequest(id, role, area, task, &req_num); - /* - * Queueing Phase - */ - unsigned current = g_app_list.currentRequestNumber(); - unsigned requested_num = g_app_list.getRequestNumber(id); - if (requested_num != 0) + if (ret != WMError::SUCCESS) { - HMI_SEQ_INFO(requested_num, "%s %s %s request is already queued", id.c_str(), role.c_str(), area.c_str()); - reply("already requested"); + HMI_ERROR("wm", errorDescription(ret)); + reply("Failed to set request"); return; } - WMRequest req = WMRequest(id, role, area, Task::TASK_RELEASE); - unsigned new_req = g_app_list.addAllocateRequest(req); - g_app_list.reqDump(); - - HMI_SEQ_DEBUG(current, "%s start sequence with %s, %s", id.c_str(), role.c_str(), area.c_str()); - reply(nullptr); - if (new_req != current) + if (req_num != g_app_list.currentRequestNumber()) { // Add request, then invoked after the previous task is finished - HMI_SEQ_DEBUG(new_req, "request is accepted"); + HMI_SEQ_DEBUG(req_num, "request is accepted"); return; } /* * Do allocate tasks */ - WMError ret = this->doTransition(new_req); + ret = this->doTransition(req_num); if (ret != WMError::SUCCESS) { - HMI_SEQ_ERROR(new_req, errorDescription(ret)); - g_app_list.removeRequest(new_req); - g_app_list.next(); //this->emit_error() + HMI_SEQ_ERROR(req_num, errorDescription(ret)); + g_app_list.removeRequest(req_num); + this->processNextRequest(); } } @@ -1062,7 +1066,7 @@ WMError App::doEndDraw(unsigned req_num) WMError App::setSurfaceSize(unsigned surface, const std::string &area) { - this->surface_set_layout(surface); + this->surface_set_layout(surface, area); return WMError::SUCCESS; } @@ -1089,6 +1093,10 @@ WMError App::layoutChange(const WMAction &action) WMError App::visibilityChange(const WMAction &action) { + HMI_SEQ_DEBUG(g_app_list.currentRequestNumber(), "Change visibility"); + if(!g_app_list.contains(action.appid)){ + return WMError::NOT_REGISTERED; + } auto client = g_app_list.lookUpClient(action.appid); unsigned surface = client->surfaceID(action.role); if(surface == 0) @@ -1111,47 +1119,69 @@ WMError App::visibilityChange(const WMAction &action) WMError App::changeCurrentState(unsigned req_num) { - HMI_SEQ_DEBUG(req_num, "Change current layout status"); - bool found = false; - auto actions = g_app_list.getActions(req_num, &found); - if(!found) + HMI_SEQ_DEBUG(req_num, "Change current layout state"); + bool trigger_found = false, action_found = false; + auto trigger = g_app_list.getRequest(req_num, &trigger_found); + auto actions = g_app_list.getActions(req_num, &action_found); + if (!trigger_found || !action_found) { HMI_SEQ_ERROR(req_num, "Action not found"); return WMError::LAYOUT_CHANGE_FAIL; } - struct LayoutState state; - std::vector areas; - bool state_change = false; + // Layout state reset + struct LayoutState reset_state{-1, -1}; + HMI_SEQ_DEBUG(req_num,"Reset layout state"); + for (const auto &action : actions) + { + if(!g_app_list.contains(action.appid)){ + return WMError::NOT_REGISTERED; + } + auto client = g_app_list.lookUpClient(action.appid); + auto pCurState = *this->layers.get_layout_state((int)client->surfaceID(action.role)); + if(pCurState == nullptr) + { + HMI_SEQ_ERROR(req_num, "Counldn't find current status"); + continue; + } + pCurState->main = reset_state.main; + pCurState->sub = reset_state.sub; + } - for(const auto &action : actions) + HMI_SEQ_DEBUG(req_num, "Change state"); + for (const auto &action : actions) { - if(action.visible != TaskVisible::INVISIBLE) + auto client = g_app_list.lookUpClient(action.appid); + auto pLayerCurState = *this->layers.get_layout_state((int)client->surfaceID(action.role)); + if (pLayerCurState == nullptr) + { + HMI_SEQ_ERROR(req_num, "Counldn't find current status"); + continue; + } + int surface = -1; + + if (action.visible != TaskVisible::INVISIBLE) { + surface = (int)client->surfaceID(action.role); + HMI_SEQ_INFO(req_num, "Change %s surface : %d, state visible area : %s", + action.role.c_str(), surface, action.area.c_str()); // visible == true -> layout changes - areas.push_back(action.area); - auto client = g_app_list.lookUpClient(action.appid); if(action.area == "normal.full" || action.area == "split.main") { - state.main = (int)client->surfaceID(action.role); + pLayerCurState->main = surface; } - else if(action.role == "split.sub") + else if (action.area == "split.sub") { - state.sub = (int)client->surfaceID(action.role); + pLayerCurState->sub = surface; + } + else + { + // normalfull + pLayerCurState->main = surface; } - state_change = true; } } - if(state_change) - { - auto trigger = g_app_list.getRequest(req_num, &found); - auto client = g_app_list.lookUpClient(trigger.appid); - auto pCurState = *this->layers.get_layout_state((int)client->surfaceID(trigger.role)); - struct LayoutState &curState = *pCurState; - curState = state; - } - return WMError::SUCCESS; }