From 74c30fd86597fb6b5d13a83dea3341b9bb9e903e Mon Sep 17 00:00:00 2001 From: Yuta Doi Date: Fri, 25 May 2018 11:53:43 +0900 Subject: Delete label "role" for the API activateSurface and deactivateSurface Change-Id: Ia59c0f3ad9d44e0836520abc50419d0be006acdf Signed-off-by: Yuta Doi --- layers.json | 2 +- src/app.cpp | 69 +++++++++++++++++++++++++++--------------------------------- src/app.hpp | 6 +++--- src/main.cpp | 20 +++++------------- 4 files changed, 40 insertions(+), 57 deletions(-) diff --git a/layers.json b/layers.json index bab1368..0fb9983 100644 --- a/layers.json +++ b/layers.json @@ -36,7 +36,7 @@ "comment": "NearHomeScreen is the part of HomeScreen, and upper layer of z order for HomeScreen" }, { - "role": "Restriction", + "role": "Restriction|restriction", "name": "Restriction", "layer_id": 1003, "area": { "type": "rect", "rect": { "x": 0, "y": 218, "width": -1, "height": -433 } }, diff --git a/src/app.cpp b/src/app.cpp index 18bc15e..e9af748 100644 --- a/src/app.cpp +++ b/src/app.cpp @@ -269,32 +269,38 @@ void App::layout_commit() { this->display->flush(); } +const char* App::convertDrawingNameToRole(char const *drawing_name) { + const char* role; + + if (this->drawingname2role_.find(drawing_name) != this->drawingname2role_.end()) { + // drawing_name is old role. So convert to new role. + role = this->drawingname2role_[drawing_name].c_str(); + } + else { + // drawing_name is new role. + role = drawing_name; + } + HMI_DEBUG("wm", "drawing_name:%s -> role: %s", drawing_name, role); + + return role; +} + void App::allocateWindowResource(char const *event, char const *drawing_name, - char const *drawing_area, char const *role, - const reply_func &reply) { + char const *drawing_area, const reply_func &reply) { const char* new_role = nullptr; const char* new_area = nullptr; - if (0 == strcmp("activate", event)) { - // TODO: - // This process will be removed - // because the applications will specify role instead of drawing_name - { - if ((nullptr == role) || (0 == strcmp("", role))) { - HMI_DEBUG("wm", "Role is not specified, so get by using app name"); - new_role = this->app2role_[drawing_name].c_str(); - } - else { - new_role = role; - } - HMI_DEBUG("wm", "drawing_name:%s, new_role: %s", drawing_name, new_role); - } + // Convert old role to new role + if ((nullptr != drawing_name) && (0 != strcmp("", drawing_name))) { + new_role = this->convertDrawingNameToRole(drawing_name); + } + if (0 == strcmp("activate", event)) { // TODO: // This process will be removed // because the area "normal.full" and "normalfull" will be prohibited { - if (0 == strcmp("Restriction", drawing_name)) { + if (0 == strcmp("restriction", new_role)) { new_area = drawing_area; } else { @@ -319,19 +325,6 @@ void App::allocateWindowResource(char const *event, char const *drawing_name, } } else if (0 == strcmp("deactivate", event)) { - // TODO: - // This process will be removed - // because the applications will specify role instead of drawing_name - { - if ((nullptr == role) || (0 == strcmp("", role))) { - HMI_DEBUG("wm", "Role is not specified, so get by using app name"); - new_role = this->app2role_[drawing_name].c_str(); - } - else { - new_role = role; - } - HMI_DEBUG("wm", "drawing_name:%s, new_role: %s", drawing_name, new_role); - } new_area = ""; } @@ -641,8 +634,8 @@ void App::surface_removed(uint32_t surface_id) { } else { auto drawing_name = this->lookup_name(surface_id); if (drawing_name) { - this->allocateWindowResource("deactivate", drawing_name->c_str(), - nullptr, nullptr, + this->allocateWindowResource("deactivate", + drawing_name->c_str(), nullptr, [](const char*){}); } } @@ -754,7 +747,7 @@ result App::api_request_surface(char const *drawing_name) { #endif // Set map of (role, surface_id) - std::string role = this->app2role_[std::string(drawing_name)]; + const char* role = this->convertDrawingNameToRole(drawing_name); this->role2surfaceid_[role] = id; // Set map of (role, app) @@ -994,8 +987,8 @@ void App::deactivate(std::string role) { void App::deactivate_main_surface() { this->layers.main_surface = -1; - this->allocateWindowResource("deactivate", this->layers.main_surface_name.c_str(), - nullptr, nullptr, + this->allocateWindowResource("deactivate", + this->layers.main_surface_name.c_str(), nullptr, [](const char*){}); } @@ -1236,12 +1229,12 @@ int App::loadAppDb() { } HMI_DEBUG("wm", "> role:%s", role); - this->app2role_[app] = std::string(role); + this->drawingname2role_[app] = std::string(role); } // Check - for(auto itr = this->app2role_.begin(); - itr != this->app2role_.end(); ++itr) { + for(auto itr = this->drawingname2role_.begin(); + itr != this->drawingname2role_.end(); ++itr) { HMI_DEBUG("wm", "app:%s role:%s", itr->first.c_str(), itr->second.c_str()); } diff --git a/src/app.hpp b/src/app.hpp index 590b23a..2cc6fa8 100644 --- a/src/app.hpp +++ b/src/app.hpp @@ -234,8 +234,7 @@ struct App { result api_request_surface(char const *drawing_name); char const *api_request_surface(char const *drawing_name, char const *ivi_id); void allocateWindowResource(char const *event, char const *drawing_name, - char const *role, char const *drawing_area, - const reply_func &reply); + char const *drawing_area, const reply_func &reply); void api_enddraw(char const *drawing_name); result api_get_display_info(); result api_get_area_info(char const *drawing_name); @@ -255,7 +254,7 @@ private: PolicyManager pm_; LayoutManager lm_; std::unordered_map role2surfaceid_; - std::unordered_map app2role_; + std::unordered_map drawingname2role_; std::unordered_map role2app_; std::unordered_map appid2role_; CarInfo crr_car_info_; @@ -263,6 +262,7 @@ private: int allocateSurface(); void setSurfaceSize(const char* role, const char* area); int loadAppDb(); + const char* convertDrawingNameToRole(char const *drawing_name); #if 0 struct id_allocator app_id_alloc_; diff --git a/src/main.cpp b/src/main.cpp index 07baf2a..52a2ed4 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -304,13 +304,8 @@ void windowmanager_activatesurface(afb_req req) noexcept { return; } - const char* a_role = afb_req_value(req, "role"); - if(!a_role){ - a_role = ""; - } - - g_afb_instance->app.allocateWindowResource("activate", a_drawing_name, - a_drawing_area, a_role, + g_afb_instance->app.allocateWindowResource("activate", + a_drawing_name, a_drawing_area, [&req](const char* errmsg){ if (errmsg != nullptr) { HMI_ERROR("wm", errmsg); @@ -344,13 +339,8 @@ void windowmanager_deactivatesurface(afb_req req) noexcept { return; } - const char* a_role = afb_req_value(req, "role"); - if(!a_role){ - a_role = ""; - } - - g_afb_instance->app.allocateWindowResource("deactivate", a_drawing_name, - nullptr, a_role, + g_afb_instance->app.allocateWindowResource("deactivate", + a_drawing_name, nullptr, [&req](const char* errmsg){ if (errmsg != nullptr) { HMI_ERROR("wm", errmsg); @@ -759,7 +749,7 @@ void on_event(const char *event, struct json_object *object){ // Allocate window resource if (nullptr != can_event) { - g_afb_instance->app.allocateWindowResource(can_event, nullptr, + g_afb_instance->app.allocateWindowResource(can_event, nullptr, nullptr, [](const char* errmsg){ if (errmsg != nullptr) { -- cgit 1.2.3-korg