X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;f=src%2Flayout_manager%2Flayout.cpp;h=cd81d8f49eb542842a0a8169a52b0a81d453afbb;hb=d1fbf20ba98bcb935d75c7a13ab5d5b9450a7837;hp=3f4013e1c09e6ce901c580e819299332c71b7087;hpb=273f15d6f5368a0144ea84cfdcf03f9d985106f5;p=apps%2Fagl-service-windowmanager.git diff --git a/src/layout_manager/layout.cpp b/src/layout_manager/layout.cpp index 3f4013e..cd81d8f 100644 --- a/src/layout_manager/layout.cpp +++ b/src/layout_manager/layout.cpp @@ -84,6 +84,21 @@ bool LayoutManager::updateLayout(json_object* obj, 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)) { @@ -104,19 +119,28 @@ bool LayoutManager::updateLayout(json_object* obj, json_object_object_foreach(json_tmp, key, val) { layer = key; json_layer = val; - HMI_DEBUG("wm:lm", "Update %s layer state", layer); + 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)) { @@ -139,46 +163,75 @@ bool LayoutManager::updateLayout(json_object* obj, 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", "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" - TypeAreas area; - TypeRolCtg rol_ctg; - rol_ctg["none"] = "none"; - area["none"] = rol_ctg; - crr_layout["none"] = area; + // 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 + // 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); - // Update role in new area - TypeRolCtg crr_role; - crr_role["role"] = std::string(new_role); - crr_layout[crr_layout_name][new_area] = crr_role; + 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; + } } } @@ -253,6 +306,7 @@ bool LayoutManager::isLayoutChanged(const char* layer) { return this->is_layout_changed_[layer]; } + extern const char* kDefaultLayoutDb; int LayoutManager::loadLayoutDb() { HMI_DEBUG("wm:lm", "Call"); @@ -270,10 +324,10 @@ int LayoutManager::loadLayoutDb() { } // Load layout.db - HMI_DEBUG("wm:lm", "file_name:%s", file_name.c_str()); - json_object* json_obj = json_object_from_file(file_name.c_str()); - if (nullptr == json_obj) { - HMI_ERROR("wm:lm", "Could not open layout.db, so use default role information"); + json_object* json_obj; + int ret = jh::inputJsonFilie(file_name.c_str(), &json_obj); + if (0 > ret) { + HMI_DEBUG("wm:lm", "Could not open layout.db, so use default layout information"); json_obj = json_tokener_parse(kDefaultLayoutDb); } HMI_DEBUG("wm:lm", "json_obj dump:%s", json_object_get_string(json_obj));