sdm: color-manager: Detect first frame of UI to apply color-mode.

Default color-mode is applied on the first frame of UI screen.
sdm.boot_anim_layer_count property is used to configure the
number of layers in boot animation process. Any commit with
more layers than sdm.boot_anim_layer_count is treated as first frame
of UI and default color-mode is applied at this point.

CRs-Fixed: 939410
Change-Id: Ib5c568819cd045f0de4ee7dcb4accfae9c27f5b2
diff --git a/sdm/include/utils/debug.h b/sdm/include/utils/debug.h
index b4a286a..251e195 100644
--- a/sdm/include/utils/debug.h
+++ b/sdm/include/utils/debug.h
@@ -64,6 +64,7 @@
   static int GetSimulationFlag();
   static int GetHDMIResolution();
   static int GetIdleTimeoutMs();
+  static int GetBootAnimLayerCount();
   static bool IsRotatorDownScaleDisabled();
   static bool IsDecimationDisabled();
   static int GetMaxPipesPerMixer(DisplayType display_type);
diff --git a/sdm/libs/hwc/hwc_display_primary.cpp b/sdm/libs/hwc/hwc_display_primary.cpp
index 5cf1b56..a9c7e67 100755
--- a/sdm/libs/hwc/hwc_display_primary.cpp
+++ b/sdm/libs/hwc/hwc_display_primary.cpp
@@ -97,14 +97,17 @@
   return HWCDisplay::Init();
 }
 
-void HWCDisplayPrimary::ProcessBootAnimCompleted() {
-  char value[PROPERTY_VALUE_MAX];
+void HWCDisplayPrimary::ProcessBootAnimCompleted(hwc_display_contents_1_t *list) {
+  uint32_t numBootUpLayers = 0;
 
-  // Applying default mode after bootanimation is finished
-  property_get("init.svc.bootanim", value, "running");
-  if (!strncmp(value, "stopped", strlen("stopped"))) {
+  numBootUpLayers = static_cast<uint32_t>(Debug::GetBootAnimLayerCount());
+
+  if (numBootUpLayers == 0) {
+    numBootUpLayers = 2;
+  }
+
+  if (list->numHwLayers > numBootUpLayers) {
     boot_animation_completed_ = true;
-
     // one-shot action check if bootanimation completed then apply default display mode.
     if (display_intf_)
       display_intf_->ApplyDefaultDisplayMode();
@@ -116,7 +119,7 @@
   DisplayError error = kErrorNone;
 
   if (!boot_animation_completed_)
-    ProcessBootAnimCompleted();
+    ProcessBootAnimCompleted(content_list);
 
   if (display_paused_) {
     MarkLayersForGPUBypass(content_list);
diff --git a/sdm/libs/hwc/hwc_display_primary.h b/sdm/libs/hwc/hwc_display_primary.h
index e30d200..3773717 100644
--- a/sdm/libs/hwc/hwc_display_primary.h
+++ b/sdm/libs/hwc/hwc_display_primary.h
@@ -55,7 +55,7 @@
   HWCDisplayPrimary(CoreInterface *core_intf, hwc_procs_t const **hwc_procs);
   void SetMetaDataRefreshRateFlag(bool enable);
   virtual DisplayError SetDisplayMode(uint32_t mode);
-  void ProcessBootAnimCompleted();
+  void ProcessBootAnimCompleted(hwc_display_contents_1_t *content_list);
   void SetQDCMSolidFillInfo(bool enable, uint32_t color);
   void ToggleCPUHint(bool set);
   void ForceRefreshRate(uint32_t refresh_rate);
diff --git a/sdm/libs/utils/debug.cpp b/sdm/libs/utils/debug.cpp
index 003be5a..d0d21ee 100644
--- a/sdm/libs/utils/debug.cpp
+++ b/sdm/libs/utils/debug.cpp
@@ -59,6 +59,13 @@
   return value;
 }
 
+int Debug::GetBootAnimLayerCount() {
+  int value = 0;
+  debug_.debug_handler_->GetProperty("sdm.boot_anim_layer_count", &value);
+
+  return value;
+}
+
 bool Debug::IsRotatorDownScaleDisabled() {
   int value = 0;
   debug_.debug_handler_->GetProperty("sdm.debug.rotator_downscale", &value);