diff options
author | 2018-05-25 11:53:43 +0900 | |
---|---|---|
committer | 2018-05-25 11:56:22 +0900 | |
commit | 26557a931e330a3ce92d241dcb275a49b66afa10 (patch) | |
tree | 1aa0442defcf1ac0420de8521278ab5352edcb75 | |
parent | 0f4fc9687b78340eb99d9dc0d1890cc063735247 (diff) |
Delete label "role" for the API activateSurface and deactivateSurface
Change-Id: Ia59c0f3ad9d44e0836520abc50419d0be006acdf
Signed-off-by: Yuta Doi <yuta-d@witz-inc.co.jp>
-rw-r--r-- | layers.json | 2 | ||||
-rw-r--r-- | src/app.cpp | 69 | ||||
-rw-r--r-- | src/app.hpp | 6 | ||||
-rw-r--r-- | 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 b168c64..cf10cef 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<int> 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) @@ -958,8 +951,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*){}); } @@ -1200,12 +1193,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 557ea78..f6b809a 100644 --- a/src/app.hpp +++ b/src/app.hpp @@ -234,8 +234,7 @@ struct App { result<int> 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<json_object *> api_get_display_info(); result<json_object *> api_get_area_info(char const *drawing_name); @@ -254,7 +253,7 @@ private: PolicyManager pm_; LayoutManager lm_; std::unordered_map<std::string, int> role2surfaceid_; - std::unordered_map<std::string, std::string> app2role_; + std::unordered_map<std::string, std::string> drawingname2role_; std::unordered_map<std::string, std::string> role2app_; std::unordered_map<int, int> appid2role_; CarInfo crr_car_info_; @@ -262,6 +261,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 d7d731f..e07c2a1 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); @@ -724,7 +714,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) { |