display: Change the place to set color mode

STC needs to pass the metadata of hdr layer, but
the metadata is not ready during the begining of
prepare. Change apply the color mode during the
begining of prepare and postpone passing the
metadata when it avaliable.

Change-Id: Ieea398022e18f6c5dbcd1aa3a29076bbf2e4bc9b
diff --git a/sdm/libs/core/color_manager.cpp b/sdm/libs/core/color_manager.cpp
index 14b455f..f9e353a 100644
--- a/sdm/libs/core/color_manager.cpp
+++ b/sdm/libs/core/color_manager.cpp
@@ -458,17 +458,13 @@
     }
   }
 
-  if (apply_mode_ || updates) {
+  if (apply_mode_) {
     update_mode_Hwassets = true;
-    if (apply_mode_) {
-      apply_mode_ = false;
-      ret = color_intf_->ColorIntfSetDisplayMode(&pp_features_,
-                     static_cast<uint32_t>(display_id_), cur_mode_id_);
-      if (ret != kErrorNone) {
-        DLOGE("ApplyDisplayMode(mode_id = %d) failed, ret = %d.", cur_mode_id_, ret);
-        return kErrorNone;
-      }
-    }
+    apply_mode_ = false;
+  }
+
+  if (updates) {
+    update_mode_Hwassets = true;
   }
 
   if (hdr_present || hdr_plus_present) {
diff --git a/sdm/libs/core/display_base.cpp b/sdm/libs/core/display_base.cpp
index c4761c5..05e8b0e 100644
--- a/sdm/libs/core/display_base.cpp
+++ b/sdm/libs/core/display_base.cpp
@@ -1034,6 +1034,13 @@
   if (!str_render_intent.empty()) {
     render_intent = std::stoi(str_render_intent);
   }
+
+  error = color_mgr_->ColorMgrSetMode(sde_display_mode->id);
+  if (error != kErrorNone) {
+    DLOGE("Failed for mode id = %d", sde_display_mode->id);
+    return error;
+  }
+
   error = color_mgr_->ColorMgrSetModeWithRenderIntent(sde_display_mode->id, pt, render_intent);
   if (error != kErrorNone) {
     DLOGE("Failed for mode id = %d", sde_display_mode->id);