aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYuta Doi <yuta-d@witz-inc.co.jp>2018-06-15 20:40:22 +0900
committerYuta Doi <yuta-d@witz-inc.co.jp>2018-06-15 20:40:22 +0900
commit36098a64cf5bcac3d721f126e3d809674badc110 (patch)
tree449e95a62f881d82ee55d0de5ffdaed95462e636
parent172c4fb3d449b908baff3111fd171b42935fbb4f (diff)
Modify format of layout information and process for updating layout
and delete unnecessary process Change-Id: I266cbc684c28b49d9855db851a56afbff3588b35 Signed-off-by: Yuta Doi <yuta-d@witz-inc.co.jp>
-rw-r--r--src/app.cpp225
-rw-r--r--src/app.hpp4
-rw-r--r--src/layout_manager/layout.cpp348
-rw-r--r--src/layout_manager/layout.hpp19
-rw-r--r--src/policy_manager/policy_manager.cpp105
-rw-r--r--src/policy_manager/policy_manager.hpp18
-rw-r--r--src/policy_manager/zipc/dummy_stm.c10
7 files changed, 113 insertions, 616 deletions
diff --git a/src/app.cpp b/src/app.cpp
index 769bec3..712ec3b 100644
--- a/src/app.cpp
+++ b/src/app.cpp
@@ -95,16 +95,12 @@ struct result<layer_map> load_layer_map(char const *filename) {
namespace rm {
App *context;
-std::string g_new_role; // TODO: workaround
static void eventHandler(json_object* json_out) {
context->updateWindowResource(json_out);
}
} // namespace rm
-
void App::updateWindowResource(json_object* json_out) {
- HMI_DEBUG("wm", "role:%s", rm::g_new_role.c_str());
-
// Check parking brake state
json_object* json_parking_brake;
if (!json_object_object_get_ex(json_out, "parking_brake", &json_parking_brake)) {
@@ -243,22 +239,84 @@ void App::updateWindowResource(json_object* json_out) {
}
}
- // Get category
- const char* category = nullptr;
- std::string str_category;
- str_category = this->pm_.roleToCategory(rm::g_new_role.c_str());
- category = str_category.c_str();
- HMI_DEBUG("wm", "role:%s category:%s", rm::g_new_role.c_str(), category);
+ // Get displayed roles from current layout
+ json_object* json_layers;
+ if (!json_object_object_get_ex(json_out, "layers", &json_layers)) {
+ HMI_DEBUG("wm", "Not found key \"layers\"");
+ return;
+ }
- // Update layout
- if (this->lm_.updateLayout(json_out, rm::g_new_role.c_str(), category)) {
- HMI_DEBUG("wm", "Layer is changed!!");
+ int len = json_object_array_length(json_layers);
+ HMI_DEBUG("wm", "json_layers len:%d", len);
+ HMI_DEBUG("wm", "json_layers dump:%s", json_object_get_string(json_layers));
- // Allocate surface
- this->allocateSurface();
- }
- else {
- HMI_DEBUG("wm", "All layer is NOT changed!!");
+ for (int i=0; i<len; i++) {
+ json_object* json_tmp = json_object_array_get_idx(json_layers, i);
+
+ std::string layer_name = jh::getStringFromJson(json_tmp, "name");
+ json_bool changed = jh::getBoolFromJson(json_tmp, "changed");
+ HMI_DEBUG("wm", "layer:%s changed:%d", layer_name.c_str(), changed);
+
+ if (changed) {
+ json_object* json_areas;
+ if (!json_object_object_get_ex(json_tmp, "areas", &json_areas)) {
+ HMI_DEBUG("wm", "Not found key \"areas\"");
+ return;
+ }
+
+ int len = json_object_array_length(json_areas);
+ HMI_DEBUG("wm", "json_layers len:%d", len);
+
+ RoleState nxt_roles;
+ RoleState crr_roles = this->crr_layer_state[layer_name];
+ for (int j=0; j<len; j++) {
+ json_object* json_tmp2 = json_object_array_get_idx(json_areas, j);
+
+ std::string area_name = jh::getStringFromJson(json_tmp2, "name");
+ std::string role_name = jh::getStringFromJson(json_tmp2, "role");
+
+ nxt_roles[role_name] = area_name;
+
+ auto i_crr = crr_roles.find(role_name);
+ HMI_DEBUG("wm", "next role:%s area:%s",
+ role_name.c_str(), area_name.c_str());
+
+ // If next role does not exist in current
+ if (crr_roles.end() == i_crr) {
+ HMI_DEBUG("wm", "next role does not exist in current");
+
+ // Set surface size
+ this->setSurfaceSize(role_name.c_str(), area_name.c_str());
+ }
+ else {
+ HMI_DEBUG("wm", "current role:%s area:%s",
+ i_crr->first.c_str(), i_crr->second.c_str());
+
+ // If next role exists in current and area is different with current
+ if (area_name != i_crr->second) {
+ HMI_DEBUG("wm", "next role exists in current and area is different with current");
+
+ // Set surface size
+ this->setSurfaceSize(role_name.c_str(), area_name.c_str());
+ }
+
+ // Remove role which exist in next list from current list
+ crr_roles.erase(i_crr);
+ }
+ }
+
+ // Deactivate roles which remains in current list
+ // because these are not displayed in next layout
+ for (auto i_crr : crr_roles) {
+ HMI_DEBUG("wm", "Deactivate role:%s", i_crr.first.c_str());
+
+ // Deactivate
+ this->deactivate(i_crr.first.c_str());
+ }
+
+ // Update current role list
+ this->crr_layer_state[layer_name] = nxt_roles;
+ }
}
}
@@ -524,14 +582,6 @@ void App::allocateWindowResource(char const *event, char const *drawing_name,
json_object_object_add(json_in, "area", json_object_new_string(new_area));
}
- // TODO: workaround
- if (nullptr != new_role) {
- rm::g_new_role = std::string(new_role);
- }
- else {
- rm::g_new_role = std::string("");
- }
-
this->pm_.inputEvent(json_in);
// Release json_object
@@ -986,129 +1036,6 @@ void controller_hooks::surface_destination_rectangle(uint32_t /*surface_id*/,
uint32_t /*w*/,
uint32_t /*h*/) {}
-int App::allocateSurface() {
- HMI_DEBUG("wm", "Call");
-
- // Get current/previous layers
- LayoutManager::TypeLayers crr_layers = this->lm_.getCurrentLayers();
- LayoutManager::TypeLayers prv_layers = this->lm_.getPreviousLayers();
-
- // Update resource of all layers
- for (auto itr_layers = crr_layers.begin();
- itr_layers != crr_layers.end(); ++itr_layers) {
- // Get layer
- std::string layer = itr_layers->first;
- HMI_DEBUG("wm", "Try to update resource in %s layer", layer.c_str());
-
- // If layout is changed, update resouce
- if (this->lm_.isLayoutChanged(layer.c_str())) {
- // Get current/previous layout
- LayoutManager::TypeLayouts crr_layout = itr_layers->second;
- LayoutManager::TypeLayouts prv_layout = prv_layers[layer];
-
- // Get current/previous layout name
- std::string crr_layout_name = crr_layout.begin()->first;
- std::string prv_layout_name = prv_layout.begin()->first;
- HMI_DEBUG("wm", "layout name crr:%s prv:%s",
- crr_layout_name.c_str(), prv_layout_name.c_str());
-
- // Get current/previous ares
- LayoutManager::TypeAreas crr_areas = crr_layout[crr_layout_name];
- LayoutManager::TypeAreas prv_areas = prv_layout[prv_layout_name];
-
- // Create previous displayed role list
- std::string prv_area_name;
- std::vector<std::string> prv_role_list;
- for (auto itr_areas = prv_areas.begin();
- itr_areas != prv_areas.end(); ++itr_areas) {
- prv_area_name = itr_areas->first;
- prv_role_list.push_back(prv_areas[prv_area_name]["role"]);
- HMI_DEBUG("wm", "previous displayed role:%s",
- prv_areas[prv_area_name]["role"].c_str());
- }
-
- // Allocate surface for each area
- std::string crr_area_name;
- std::string crr_role_name;
- LayoutManager::TypeRolCtg crr_rol_ctg;
- for (auto itr_areas = crr_areas.begin();
- itr_areas != crr_areas.end(); ++itr_areas) {
- crr_area_name = itr_areas->first;
- crr_rol_ctg = itr_areas->second;
-
- // Get role of current area
- if ("category" == crr_rol_ctg.begin()->first) {
- // If current area have category
- // Get category name
- std::string crr_ctg = crr_rol_ctg.begin()->second;
-
- // Serch relevant role from previous displayed role list
- for (auto itr_role = prv_role_list.begin();
- itr_role != prv_role_list.end(); ++itr_role) {
- std::string prv_ctg = this->pm_.roleToCategory((*itr_role).c_str());
- if (crr_ctg == prv_ctg) {
- // First discovered role is set to current role
- crr_role_name = *itr_role;
-
- // Delete used role for other areas
- // which have same category
- prv_role_list.erase(itr_role);
-
- break;
- }
- }
- }
- else {
- crr_role_name = itr_areas->second["role"];
- }
- HMI_DEBUG("wm", "Allocate surface for area:%s role:%s",
- crr_area_name.c_str(), crr_role_name.c_str());
-
- // Deactivate non-displayed role
- std::string prv_role_name;
- if (crr_layout_name == prv_layout_name) {
- HMI_DEBUG("wm", "Current layout is same with previous");
-
- // Deactivate previous role in same area
- // if it is different with current
- prv_role_name = prv_areas[crr_area_name]["role"];
- if (crr_role_name != prv_role_name) {
- this->deactivate(prv_role_name);
- }
- }
- else {
- HMI_DEBUG("wm", "Current layout is different with previous");
-
- if ("none" != prv_layout_name) {
- // Deactivate previous role in all area in previous layout
- // if it is different with current role
- for(auto itr = prv_areas.begin(); itr != prv_areas.end(); ++itr) {
- prv_role_name = itr->second["role"].c_str();
- if (crr_role_name != prv_role_name) {
- this->deactivate(prv_role_name);
- }
- }
- }
- }
-
- // Set surface for displayed role
- if ("none" != crr_layout_name) {
- // If current layout is not "none",
- // set surface for current role
- this->setSurfaceSize(crr_role_name.c_str(), crr_area_name.c_str());
-
- // TODO:
- // This API is workaround.
- // Resource manager should manage each resource infomations
- // according to architecture document.
- this->lm_.updateArea(layer.c_str(), crr_role_name.c_str(), crr_area_name.c_str());
- }
- }
- }
- }
- return 0;
-}
-
void App::setSurfaceSize(const char* role, const char* area) {
HMI_DEBUG("wm", "role:%s area:%s", role, area);
diff --git a/src/app.hpp b/src/app.hpp
index ea5ac36..68214b3 100644
--- a/src/app.hpp
+++ b/src/app.hpp
@@ -251,6 +251,8 @@ struct App {
void updateWindowResource(json_object* json_out);
private:
+ typedef std::map<std::string, std::string> RoleState;
+
PolicyManager pm_;
LayoutManager lm_;
std::unordered_map<std::string, int> role2surfaceid_;
@@ -258,8 +260,8 @@ private:
std::unordered_map<std::string, std::string> role2drawingname_;
std::unordered_map<int, int> appid2role_;
CarInfo crr_car_info_;
+ std::map<std::string, RoleState> crr_layer_state;
- int allocateSurface();
void setSurfaceSize(const char* role, const char* area);
int loadAppDb();
const char* convertDrawingNameToRole(char const *drawing_name);
diff --git a/src/layout_manager/layout.cpp b/src/layout_manager/layout.cpp
index cd81d8f..49381cc 100644
--- a/src/layout_manager/layout.cpp
+++ b/src/layout_manager/layout.cpp
@@ -37,276 +37,13 @@ int LayoutManager::initialize() {
return ret;
}
- TypeLayouts layout;
- TypeAreas area;
- TypeRolCtg rol_ctg;
-
- rol_ctg["none"] = "none";
- area["none"] = rol_ctg;
- layout["none"] = area;
-
- this->prv_layers_["on_screen"] = layout;
- this->prv_layers_["apps"] = layout;
- this->prv_layers_["homescreen"] = layout;
- this->prv_layers_["restriction"] = layout;
-
- this->crr_layers_["on_screen"] = layout;
- this->crr_layers_["apps"] = layout;
- this->crr_layers_["homescreen"] = layout;
- this->crr_layers_["restriction"] = layout;
-
- this->prv_layers_car_stop_["on_screen"] = layout;
- this->prv_layers_car_stop_["apps"] = layout;
- this->prv_layers_car_stop_["homescreen"] = layout;
- this->prv_layers_car_stop_["restriction"] = layout;
-
- return ret;
-}
-
-bool LayoutManager::updateLayout(json_object* obj,
- const char* new_role, const char* category) {
- HMI_DEBUG("wm:lm", "Call");
-
- bool ret = false;
-
- // Check car state change
- json_object* json_car;
- if (!json_object_object_get_ex(obj, "car", &json_car)) {
- HMI_ERROR("wm:lm", "Parse Error!!");
- return -1;
- }
-
- json_bool is_car_state_changed;
- std::string car_state = "";
- is_car_state_changed = jh::getBoolFromJson(json_car, "is_changed");
- if (is_car_state_changed) {
- // If car state is changed, get car state
- car_state = jh::getStringFromJson(json_car, "state");
- }
-
- // Check restriction mode change
- json_object* json_restriction_mode;
- if (!json_object_object_get_ex(obj, "restriction_mode", &json_restriction_mode)) {
- HMI_ERROR("wm:lm", "Parse Error!!");
- return -1;
- }
-
- json_bool is_restriction_mode_changed;
- std::string restriction_mode = "";
- is_restriction_mode_changed = jh::getBoolFromJson(json_restriction_mode, "is_changed");
- if (is_restriction_mode_changed) {
- // If restriction mode is changed, get restriction mode
- restriction_mode = jh::getStringFromJson(json_restriction_mode, "state");
- }
-
- // Update layout of all layers
- json_object* json_layers;
- if (!json_object_object_get_ex(obj, "layers", &json_layers)) {
- HMI_ERROR("wm:lm", "Parse Error!!");
- return -1;
- }
-
- int len = json_object_array_length(json_layers);
- HMI_DEBUG("wm:lm", "json_layers len:%d", len);
- HMI_DEBUG("wm:lm", "json_layers dump:%s", json_object_get_string(json_layers));
-
- for (int i=0; i<len; i++) {
- json_object* json_tmp = json_object_array_get_idx(json_layers, i);
-
- // Get layer name and json_object
- const char* layer;
- json_object* json_layer;
- json_object_object_foreach(json_tmp, key, val) {
- layer = key;
- json_layer = val;
- HMI_DEBUG("wm:lm", "Try to update %s layer state", layer);
- }
-
- // Store previous state
- this->prv_layers_[layer] = this->crr_layers_[layer];
- std::string prv_layout_name = this->prv_layers_[layer].begin()->first;
-
-#if 1
- // If restriction mode is changed off -> on,
- // store current state for state of restriction mode off
- if ((is_restriction_mode_changed) && ("restriction_mode_on" == restriction_mode)) {
- HMI_DEBUG("wm:lm", "Store current state for state of restriction mode off");
- this->prv_layers_car_stop_[layer] = this->crr_layers_[layer];
- }
-#else
- // If car state is changed car_stop -> car_run,
- // store current state for state of car stop
- if ((is_car_state_changed) && ("car_run" == car_state)) {
- HMI_DEBUG("wm:lm", "Store current state for state of car stop");
- this->prv_layers_car_stop_[layer] = this->crr_layers_[layer];
- }
-#endif
-
- json_object* json_is_changed;
- if (!json_object_object_get_ex(json_layer, "is_changed", &json_is_changed)) {
- HMI_ERROR("wm:lm", "Not found key \"is_changed\"");
- return false;
- }
-
- // If layer state is changed
- if (json_object_get_boolean(json_is_changed)) {
- // Set layout changed flag
- this->is_layout_changed_[layer] = true;
-
- json_object* json_state;
- if (!json_object_object_get_ex(json_layer, "state", &json_state)) {
- HMI_ERROR("wm:lm", "Not found key \"state\"");
- return false;
- }
-
- const char* crr_layout_name = json_object_get_string(json_state);
- HMI_DEBUG("wm:lm", "crr state: %s", crr_layout_name);
-
- TypeLayouts crr_layout;
-#if 1
- if ((is_restriction_mode_changed) && ("restriction_mode_off" == restriction_mode)) {
- // If restriction mode is changed on -> off,
- // restore state of restriction mode off
- HMI_DEBUG("wm:lm", "Restriction mode is changed on -> off, so restore state of restriction mode off");
- crr_layout = this->prv_layers_car_stop_[layer];
-#else
- if ((is_car_state_changed) && ("car_stop" == car_state)) {
- // If car state is changed car_run -> car_stop,
- // restore state of car stop
- HMI_DEBUG("wm:lm", "Car state is changed car_run -> car_stop, so restore state of car stop");
- crr_layout = this->prv_layers_car_stop_[layer];
-#endif
- }
- else if ("none" == std::string(crr_layout_name)) {
- // If current layout is "none",
- // current areas is set with "none"
- HMI_DEBUG("wm:lm", "Current layout is \"none\"");
- TypeAreas area;
- TypeRolCtg rol_ctg;
- rol_ctg["none"] = "none";
- area["none"] = rol_ctg;
- crr_layout["none"] = area;
- }
- else {
- if (std::string(crr_layout_name) == prv_layout_name) {
- // If previous layout is same with current,
- // previous areas are copied to current
- HMI_DEBUG("wm:lm", "Previous layout is same with current");
- crr_layout[crr_layout_name] = this->prv_layers_[layer][crr_layout_name];
- }
- else {
- // If previous layout is NOT same with current,
- // current areas is set with default value
- HMI_DEBUG("wm:lm", "Previous layout is NOT same with current");
- crr_layout[crr_layout_name] = this->layout_define_[crr_layout_name];
- }
-
- // Update role in new area
-#if 1
- if (is_restriction_mode_changed) {
- // Updating role is not necessary
- // because new_role is not specified
- // when restriction mode is changed
- HMI_DEBUG("wm:lm", "Updating role is not necessary because new_role is not specified when restriction mode is changed");
-#else
- if (is_car_state_changed) {
- // Updating role is not necessary
- // because new_role is not specified
- // when car state is changed
- HMI_DEBUG("wm:lm", "Updating role is not necessary because new_role is not specified when car state is changed");
-#endif
- }
- else {
- HMI_DEBUG("wm:lm", "Get new_area for new role");
- // Get new_area for new role
- std::string new_area = this->getAreaName(this->layout_define_[crr_layout_name],
- new_role, category);
-
- if ("none" == new_area) {
- HMI_DEBUG("wm:lm", "It is not necessary to update role of areas in this layer, because new_role is not specified for this layer");
- }
- else {
- // Update role in new area
- // because new_role is specified for this layer
- TypeRolCtg crr_role;
- crr_role["role"] = std::string(new_role);
- crr_layout[crr_layout_name][new_area] = crr_role;
- }
- }
- }
-
- // Update layer state
- this->crr_layers_[layer] = crr_layout;
-
- // Check
- for (auto itr_layout = this->crr_layers_[layer].begin();
- itr_layout != this->crr_layers_[layer].end(); ++itr_layout) {
- for (auto itr_area = itr_layout->second.begin();
- itr_area != itr_layout->second.end(); ++itr_area) {
- for (auto itr_role = itr_area->second.begin();
- itr_role != itr_area->second.end(); ++itr_role) {
- HMI_DEBUG("wm:lm", "layout:%s, area:%s, rol_ctg:%s, name:%s",
- itr_layout->first.c_str(), itr_area->first.c_str(),
- itr_role->first.c_str(), itr_role->second.c_str());
- }
- }
- }
-
- ret = true;
- }
- else {
- // Clear layout changed flag
- this->is_layout_changed_[layer] = false;
- }
- }
return ret;
}
-// TODO: This API is for workaround, so this will be removed
-void LayoutManager::updateArea(const char* layer, const char* role, const char* area) {
- this->crr_layers_[layer].begin()->second[area]["role"] = std::string(role);
-}
-
-LayoutManager::TypeLayers LayoutManager::getCurrentLayers() {
- return this->crr_layers_;
-}
-
-LayoutManager::TypeLayers LayoutManager::getPreviousLayers() {
- return this->prv_layers_;
-}
-
compositor::rect LayoutManager::getAreaSize(const char* area) {
return this->area2size_[area];
}
-std::string LayoutManager::getAreaName(TypeAreas areas, const char* role, const char* category) {
- for (auto itr_area = areas.begin(); itr_area != areas.end(); ++itr_area) {
- std::string area_name = itr_area->first;
- TypeRolCtg rol_ctg = itr_area->second;
-
- if ("role" == rol_ctg.begin()->first) {
- if (std::string(role) == rol_ctg.begin()->second) {
- return area_name;
- }
- }
- else if ("category" == rol_ctg.begin()->first) {
- if (std::string(category) == rol_ctg.begin()->second) {
- return area_name;
- }
- }
- else {
- return std::string("none");
- }
- }
- return std::string("none");
-}
-
-
-bool LayoutManager::isLayoutChanged(const char* layer) {
- return this->is_layout_changed_[layer];
-}
-
-
extern const char* kDefaultLayoutDb;
int LayoutManager::loadLayoutDb() {
HMI_DEBUG("wm:lm", "Call");
@@ -332,96 +69,15 @@ int LayoutManager::loadLayoutDb() {
}
HMI_DEBUG("wm:lm", "json_obj dump:%s", json_object_get_string(json_obj));
- // Perse layouts
- HMI_DEBUG("wm:lm", "Perse layouts");
- json_object* json_cfg;
- if (!json_object_object_get_ex(json_obj, "layouts", &json_cfg)) {
- HMI_ERROR("wm:lm", "Parse Error!!");
- return -1;
- }
-
- int len = json_object_array_length(json_cfg);
- HMI_DEBUG("wm:lm", "json_cfg len:%d", len);
- HMI_DEBUG("wm:lm", "json_cfg dump:%s", json_object_get_string(json_cfg));
-
- const char* layout;
- const char* role;
- const char* category;
- for (int i=0; i<len; i++) {
- json_object* json_tmp = json_object_array_get_idx(json_cfg, i);
-
- layout = jh::getStringFromJson(json_tmp, "name");
- if (nullptr == layout) {
- HMI_ERROR("wm:lm", "Parse Error!!");
- return -1;
- }
- HMI_DEBUG("wm:lm", "> layout:%s", layout);
-
- json_object* json_area_array;
- if (!json_object_object_get_ex(json_tmp, "areas", &json_area_array)) {
- HMI_ERROR("wm:lm", "Parse Error!!");
- return -1;
- }
-
- int len_area = json_object_array_length(json_area_array);
- HMI_DEBUG("wm:lm", "json_area_array len:%d", len_area);
- HMI_DEBUG("wm:lm", "json_area_array dump:%s", json_object_get_string(json_area_array));
-
- TypeAreas areas;
- for (int j=0; j<len_area; j++) {
- json_object* json_area = json_object_array_get_idx(json_area_array, j);
-
- const char* area = jh::getStringFromJson(json_area, "name");
- if (nullptr == area) {
- HMI_ERROR("wm:lm", "Parse Error!!");
- return -1;
- }
- HMI_DEBUG("wm:lm", ">> area:%s", area);
-
- TypeRolCtg rol_ctg_name;
- role = jh::getStringFromJson(json_area, "role");
- if (nullptr == role) {
- category = jh::getStringFromJson(json_area, "category");
- if (nullptr == category) {
- HMI_ERROR("wm:lm", "Parse Error!!");
- return -1;
- }
- rol_ctg_name["category"] = std::string(category);
- HMI_DEBUG("wm:lm", ">>> category:%s", category);
- }
- else {
- rol_ctg_name["role"] = std::string(role);
- HMI_DEBUG("wm:lm", ">>> role:%s", role);
- }
-
- areas[area] = rol_ctg_name;
- }
-
- this->layout_define_[layout] = areas;
- }
-
- // Check
- for(auto itr_layout = this->layout_define_.begin();
- itr_layout != this->layout_define_.end(); ++itr_layout) {
- for (auto itr_area = itr_layout->second.begin();
- itr_area != itr_layout->second.end(); ++itr_area) {
- for (auto itr_role = itr_area->second.begin();
- itr_role != itr_area->second.end(); ++itr_role) {
- HMI_DEBUG("wm:lm", "layout:%s, area:%s, rol_ctg:%s, name:%s",
- itr_layout->first.c_str(), itr_area->first.c_str(),
- itr_role->first.c_str(), itr_role->second.c_str());
- }
- }
- }
-
// Perse areas
HMI_DEBUG("wm:lm", "Perse areas");
+ json_object* json_cfg;
if (!json_object_object_get_ex(json_obj, "areas", &json_cfg)) {
HMI_ERROR("wm:lm", "Parse Error!!");
return -1;
}
- len = json_object_array_length(json_cfg);
+ int len = json_object_array_length(json_cfg);
HMI_DEBUG("wm:lm", "json_cfg len:%d", len);
HMI_DEBUG("wm:lm", "json_cfg dump:%s", json_object_get_string(json_cfg));
diff --git a/src/layout_manager/layout.hpp b/src/layout_manager/layout.hpp
index bfa4a6c..648d80e 100644
--- a/src/layout_manager/layout.hpp
+++ b/src/layout_manager/layout.hpp
@@ -45,19 +45,8 @@ public:
explicit LayoutManager();
~LayoutManager() = default;
- typedef std::unordered_map<std::string, std::string> TypeRolCtg;
- typedef std::unordered_map<std::string, TypeRolCtg> TypeAreas;
- typedef std::unordered_map<std::string, TypeAreas> TypeLayouts;
- typedef std::unordered_map<std::string, TypeLayouts> TypeLayers;
-
int initialize();
- bool updateLayout(json_object* obj, const char* new_role, const char* new_area);
- TypeLayers getCurrentLayers();
- TypeLayers getPreviousLayers();
compositor::rect getAreaSize(const char* area);
- bool isLayoutChanged(const char* layer);
-
- void updateArea(const char* layer, const char* role, const char* area);
private:
// Disable copy and move
@@ -66,17 +55,9 @@ private:
LayoutManager(LayoutManager &&) = delete;
LayoutManager &operator=(LayoutManager &&) = delete;
- TypeLayouts layout_define_;
std::unordered_map<std::string, compositor::rect> area2size_;
- TypeLayers crr_layers_, prv_layers_;
- TypeLayers prv_layers_car_stop_;
-
- std::unordered_map<std::string, bool> is_layout_changed_;
-
- std::string getAreaName(TypeAreas area, const char* role, const char* category);
int loadLayoutDb();
- std::string role2App(std::string role, void* ptr);
};
diff --git a/src/policy_manager/policy_manager.cpp b/src/policy_manager/policy_manager.cpp
index 2e4a6f9..23d1e29 100644
--- a/src/policy_manager/policy_manager.cpp
+++ b/src/policy_manager/policy_manager.cpp
@@ -262,7 +262,6 @@ static int checkPolicy(sd_event_source *source, void *data) {
crr_state.layer[stm::gStmLayerNoOnScreen].state,
stm::gStmLayoutNo2Name[crr_state.layer[stm::gStmLayerNoOnScreen].state]);
-#if 1 // @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
// Store previous layers
pm::g_prv_layers = pm::g_crr_layers;
@@ -472,7 +471,6 @@ static int checkPolicy(sd_event_source *source, void *data) {
HMI_DEBUG("wm:pm", ">>> >>> >>> >>> ROLE:%s", as.role.c_str());
}
}
-#endif // @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
json_object* json_out = json_object_new_object();
@@ -532,83 +530,36 @@ static int checkPolicy(sd_event_source *source, void *data) {
stm::gStmRestrictionModeStateNo2Name[crr_state.restriction_mode.state],
&json_out);
+ // Create layout information
+ //
// "layers": [
+ // {
+ // "homescreen": {
+ // "changed": <bool>,
+ // "areas": [
+ // {
+ // "name":<const char*>,
+ // "role":<const char*>
+ // }.
+ // ...
+ // ]
+ // }
+ // },
+ // ...
json_object* json_layer = json_object_new_array();
json_object* json_tmp;
+ for (int layer_no = stm::gStmLayerNoMin;
+ layer_no <= stm::gStmLayerNoMax; layer_no++) {
+ const char* layer_name = stm::gStmLayerName[layer_no];
+ HMI_DEBUG("wm:pm", "LAYER:%s", layer_name);
- // {
- // "homescreen": {
- // "changed": <bool>,
- // "areas": [
- // {
- // "name":<const char*>,
- // "role":<const char*>
- // }.
- // ...
- // ]
- // }
- // },
- json_tmp = json_object_new_object();
- addStateToJson("homescreen",
- crr_state.layer[stm::gStmLayerNoHomescreen].is_changed,
-#if 1
- pm::g_crr_layers["homescreen"].layout_state.name.c_str(),
-#else
- stm::gStmLayoutNo2Name[crr_state.layer[stm::gStmLayerNoHomescreen].state],
-#endif
- &json_tmp);
- json_object_array_add(json_layer, json_tmp);
-
- // {
- // "apps": {
- // "is_changed": <bool>,
- // "state": <const char*>
- // }
- // },
- json_tmp = json_object_new_object();
- addStateToJson("apps",
- crr_state.layer[stm::gStmLayerNoApps].is_changed,
-#if 1
- pm::g_crr_layers["apps"].layout_state.name.c_str(),
-#else
- stm::gStmLayoutNo2Name[crr_state.layer[stm::gStmLayerNoApps].state],
-#endif
- &json_tmp);
- json_object_array_add(json_layer, json_tmp);
-
- // {
- // "restriction": {
- // "is_changed": <bool>,
- // "state": <const char*>
- // }
- // },
- json_tmp = json_object_new_object();
- addStateToJson("restriction",
- crr_state.layer[stm::gStmLayerNoRestriction].is_changed,
-#if 1
- pm::g_crr_layers["restriction"].layout_state.name.c_str(),
-#else
- stm::gStmLayoutNo2Name[crr_state.layer[stm::gStmLayerNoRestriction].state],
-#endif
- &json_tmp);
- json_object_array_add(json_layer, json_tmp);
-
- // {
- // "on_screen": {
- // "is_changed": <bool>,
- // "state": <const char*>
- // }
- // },
- json_tmp = json_object_new_object();
- addStateToJson("on_screen",
- crr_state.layer[stm::gStmLayerNoOnScreen].is_changed,
-#if 1
- pm::g_crr_layers["on_screen"].layout_state.name.c_str(),
-#else
- stm::gStmLayoutNo2Name[crr_state.layer[stm::gStmLayerNoOnScreen].state],
-#endif
- &json_tmp);
- json_object_array_add(json_layer, json_tmp);
+ json_tmp = json_object_new_object();
+ addStateToJson(layer_name,
+ crr_state.layer[layer_no].is_changed,
+ pm::g_crr_layers[layer_name].layout_state.area_list,
+ &json_tmp);
+ json_object_array_add(json_layer, json_tmp);
+ }
// Add json array of layer
json_object_object_add(json_out, "layers", json_layer);
@@ -770,10 +721,6 @@ int PolicyManager::inputEvent(json_object* json_in) {
return 0;
}
-std::string PolicyManager::roleToCategory(const char* role) {
- return this->role2category_[role];
-}
-
extern const char* kDefaultRoleDb;
int PolicyManager::loadRoleDb() {
HMI_DEBUG("wm:pm", "Call");
diff --git a/src/policy_manager/policy_manager.hpp b/src/policy_manager/policy_manager.hpp
index f026edd..0e05cc0 100644
--- a/src/policy_manager/policy_manager.hpp
+++ b/src/policy_manager/policy_manager.hpp
@@ -42,7 +42,6 @@ public:
int initialize();
void registerCallback(CallbackTable callback_table);
int inputEvent(json_object* json_in);
- std::string roleToCategory(const char* role);
private:
// Disable copy and move
@@ -60,23 +59,6 @@ private:
std::unordered_map<std::string, std::string> category2role_;
std::unordered_map<std::string, std::string> role2defaultarea_;
-#if 0
- struct AreaState {
- std::string name;
- std::string role;
- } AreaState;
-
- struct LayoutState {
- std::string name;
- std::vector<AreaState> areas;
- } LayoutState;
-
- struct LayerState {
- std::string name;
- LayoutState layout;
- } LayerState;
-#endif
-
int initializeSdEventLoop();
// Load role.db
diff --git a/src/policy_manager/zipc/dummy_stm.c b/src/policy_manager/zipc/dummy_stm.c
index 71dfbaa..643e11e 100644
--- a/src/policy_manager/zipc/dummy_stm.c
+++ b/src/policy_manager/zipc/dummy_stm.c
@@ -344,13 +344,15 @@ int stmTransitionState(int event, stm_state_t* state) {
if (gStmRestrictionModeStateNoOff == restriction_mode_state) {
switch (category_no) {
case STM_CTG_NO_HOMESCREEN:
- // Apps layer
- g_crr_state.layer[gStmLayerNoApps].state = gStmLayoutNoNone;
- g_crr_state.layer[gStmLayerNoApps].is_changed = STM_TRUE;
-
// Homescreen layer
g_crr_state.layer[gStmLayerNoHomescreen].state = gStmLayoutNoHs;
g_crr_state.layer[gStmLayerNoHomescreen].is_changed = STM_TRUE;
+
+ // Apps layer
+ if (gStmLayoutNoNone != apps_state) {
+ g_crr_state.layer[gStmLayerNoApps].state = gStmLayoutNoNone;
+ g_crr_state.layer[gStmLayerNoApps].is_changed = STM_TRUE;
+ }
break;
case STM_CTG_NO_MAP:
switch (area_no) {