Waiting for the surface of new app is created before setting the size
[apps/agl-service-windowmanager.git] / src / layout_manager / layout.cpp
index dc73cbf..c888b0e 100644 (file)
@@ -48,14 +48,17 @@ int LayoutManager::initialize() {
     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;
 }
@@ -101,7 +104,7 @@ 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
@@ -139,43 +142,56 @@ bool LayoutManager::updateLayout(json_object* obj,
             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];
             }
             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 (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");
                 }
                 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;
+                    }
                 }
             }
 
@@ -250,6 +266,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");
@@ -267,10 +284,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));