- // Update role in new area
-#if 1
- if (crr_state.restriction_mode.is_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 (crr_state.car.is_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 {
-
- std::map<std::string, std::vector<pm::AreaState>> ctg_list;
- for (int ctg_no=stm::gStmCategoryNoMin;
- ctg_no<=stm::gStmCategoryNoMax; ctg_no++) {
- const char* ctg = stm::gStmCategoryName[ctg_no];
- HMI_DEBUG("wm:pm", "ctg:%s", ctg);
-
- // Create area list of previous app
- std::vector<pm::AreaState> area_list;
- for (pm::AreaState area_state : prv_layout_state.area_list) {
- if (std::string(ctg) == area_state.category) {
- // If there is the category which is same with new category in previous layout,
- // push it to area list
- HMI_DEBUG("wm:pm", "push area_state to prv list");
- area_list.push_back(area_state);
- }
- }
-
- int prv_ctg_num = prv_layout_state.category_num[ctg];
- int crr_ctg_num = crr_layout_state.category_num[ctg];
- HMI_DEBUG("wm:pm", "crr_ctg_num:%d prv_ctg_num:%d", crr_ctg_num, prv_ctg_num);
-
- // Remove state of area which is used no longer from area list
- if (crr_ctg_num < prv_ctg_num) {
- HMI_DEBUG("wm:pm", "crr_ctg_num < prv_ctg_num");
- if (0 == strcmp(ctg, category.c_str())) {
- for (auto i = area_list.begin(); i != area_list.end(); ++i) {
- if ((role == i->role) && (area == i->name)) {
- HMI_DEBUG("wm:pm", "store removed role:%s", i->role.c_str());
- crr_layout_state.last_invisibled_role[category] = i->role;
-
- HMI_DEBUG("wm:pm", "remove area state which have same role with requested role");
- area_list.erase(i);
-
- prv_ctg_num--;
-
- if (crr_ctg_num == prv_ctg_num) {
- break;
- }
- }
- }
- }
- else {
- HMI_DEBUG("wm:pm", "store removed role:%s", area_list.begin()->role.c_str());
- crr_layout_state.last_invisibled_role[ctg] = area_list.begin()->role;
-
- HMI_DEBUG("wm:pm", "remove the oldest area data");
- area_list.erase(area_list.begin());
- }
- }
- else if (crr_ctg_num >= prv_ctg_num) {
- HMI_DEBUG("wm:pm", "crr_ctg_num >= prv_ctg_num");
- if (0 == strcmp(ctg, category.c_str())) {
- HMI_DEBUG("wm:pm", "category of requested role is same");
- if ((crr_ctg_num == prv_ctg_num) && (0 != prv_ctg_num)) {
- HMI_DEBUG("wm:pm", "store removed role:%s", area_list.begin()->role.c_str());
- crr_layout_state.last_invisibled_role[ctg] = area_list.begin()->role;
-
- HMI_DEBUG("wm:pm", "remove the oldest area data for adding requested role");
- area_list.erase(area_list.begin());
- }
- }
- }
-
- // Check
- for (pm::AreaState area_state : area_list) {
- HMI_DEBUG("wm:pm", "area_list name:%s category:%s role:%s",
- area_state.name.c_str(),
- area_state.category.c_str(),
- area_state.role.c_str());
+ // Create candidate list
+ std::map<std::string, AreaList> cand_list;
+ for (int ctg_no=stm::StmCtgNoMin;
+ ctg_no<=stm::StmCtgNoMax; ctg_no++) {
+ const char* ctg = stm::kStmCategoryName[ctg_no];
+ HMI_DEBUG("wm:pm", "ctg:%s", ctg);
+
+ // Create candidate list for category from the previous displayed categories
+ AreaList tmp_cand_list;
+ for (AreaState area_state : prv_layout_state.area_list) {
+ if (std::string(ctg) == area_state.category) {
+ // If there is the category which is same with new category in previous layout,
+ // push it to list
+ HMI_DEBUG("wm:pm", "Push to candidate list category:%s role:%s",
+ area_state.category.c_str(), area_state.role.c_str());
+ tmp_cand_list.push_back(area_state);