From: Jan-Simon Moeller Date: Wed, 27 Dec 2017 20:24:30 +0000 (+0000) Subject: Merge "Fix build error in gcc 7.2" into eel X-Git-Tag: 5.0.0^0 X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=commitdiff_plain;h=12c8934465fd7cebccef4260478b282c1bd18d7f;hp=24876db0da69f40ea3a4ab1c61fb2d1721e8ff87;p=apps%2Fagl-service-windowmanager.git Merge "Fix build error in gcc 7.2" into eel --- diff --git a/layers.json b/layers.json index 7ee3e21..8a04d7b 100644 --- a/layers.json +++ b/layers.json @@ -22,7 +22,7 @@ "comment": "Single layer map for the HomeScreen" }, { - "role": "MediaPlayer|Radio|Phone|Navigation|HVAC|Settings|Dashboard|POI|Mixer", + "role": "Music|Video|WebBrowser|MediaPlayer|Radio|Phone|Navigation|HVAC|Settings|Dashboard|POI|Mixer", "name": "apps", "layer_id": 1001, "area": { "type": "rect", "rect": { "x": 0, "y": 218, "width": -1, "height": -433 } }, diff --git a/src/app.cpp b/src/app.cpp index bf84b22..d218f3e 100644 --- a/src/app.cpp +++ b/src/app.cpp @@ -628,7 +628,7 @@ void App::surface_created(uint32_t surface_id) { this->controller->layers[*layer_id]->add_surface( this->controller->surfaces[surface_id].get()); - + this->layout_commit(); // activate the main_surface right away /*if (surface_id == static_cast(this->layers.main_surface)) { HMI_DEBUG("wm", "Activating main_surface (%d)", surface_id); @@ -735,6 +735,7 @@ char const *App::api_request_surface(char const *drawing_name, this->controller->layers[*lid]->add_surface( this->controller->surfaces[sid].get()); + this->layout_commit(); return nullptr; } @@ -751,6 +752,7 @@ void App::activate(int id) { // FOR CES DEMO >>> if ((0 == strcmp(label, "Radio")) || (0 == strcmp(label, "MediaPlayer")) + || (0 == strcmp(label, "Music")) || (0 == strcmp(label, "Navigation"))) { for (auto i = surface_bg.begin(); i != surface_bg.end(); ++i) { if (id == *i) { @@ -790,6 +792,7 @@ void App::deactivate(int id) { // FOR CES DEMO >>> if ((0 == strcmp(label, "Radio")) || (0 == strcmp(label, "MediaPlayer")) + || (0 == strcmp(label, "Music")) || (0 == strcmp(label, "Navigation"))) { // Store id diff --git a/src/main.cpp b/src/main.cpp index e8ae75a..0197c3c 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -30,6 +30,13 @@ extern "C" { #include } +typedef struct wmClientCtxt{ + std::string name; + wmClientCtxt(const char* appName){ + name = appName; + } +} wmClientCtxt; + struct afb_instance { std::unique_ptr display; wm::App app; @@ -149,6 +156,30 @@ int binding_init() noexcept { return -1; } +static bool checkFirstReq(afb_req req){ + wmClientCtxt* ctxt = (wmClientCtxt*)afb_req_context_get(req); + return (ctxt) ? false : true; +} + +static void cbRemoveClientCtxt(void* data){ + wmClientCtxt* ctxt = (wmClientCtxt*)data; + if(ctxt == nullptr){ + return; + } + HMI_DEBUG("wm","remove app %s", ctxt->name.c_str()); + // Lookup surfaceID and remove it because App is dead. + auto pSid = g_afb_instance->app.id_alloc.lookup(ctxt->name.c_str()); + if(pSid){ + auto sid = *pSid; + g_afb_instance->app.id_alloc.remove_id(sid); + g_afb_instance->app.layers.remove_surface(sid); + g_afb_instance->app.controller->sprops.erase(sid); + g_afb_instance->app.controller->surfaces.erase(sid); + HMI_DEBUG("wm", "delete surfaceID %d", sid); + } + delete ctxt; +} + void windowmanager_requestsurface(afb_req req) noexcept { std::lock_guard guard(binding_m); #ifdef ST @@ -166,7 +197,30 @@ void windowmanager_requestsurface(afb_req req) noexcept { return; } + /* Create Security Context */ + bool isFirstReq = checkFirstReq(req); + if(!isFirstReq){ + wmClientCtxt* ctxt = (wmClientCtxt*)afb_req_context_get(req); + HMI_DEBUG("wm", "You're %s.", ctxt->name.c_str()); + if(ctxt->name != std::string(a_drawing_name)){ + afb_req_fail_f(req, "failed", "Dont request with other name: %s for now", a_drawing_name); + HMI_DEBUG("wm", "Don't request with other name: %s for now", a_drawing_name); + return; + } + } + auto ret = g_afb_instance->app.api_request_surface(a_drawing_name); + + if(isFirstReq){ + wmClientCtxt* ctxt = new wmClientCtxt(a_drawing_name); + HMI_DEBUG("wm", "create session for %s", ctxt->name.c_str()); + afb_req_session_set_LOA(req, 1); + afb_req_context_set(req, ctxt, cbRemoveClientCtxt); + } + else{ + HMI_DEBUG("wm", "session already created for %s", a_drawing_name); + } + if (ret.is_err()) { afb_req_fail(req, "failed", ret.unwrap_err()); return;