composer: populate doze mode if the panel supports command mode

Change-Id: I09956d011674410ce03cfeba31ca58e727ac12ea
diff --git a/composer/hwc_display.h b/composer/hwc_display.h
index ccece96..c082578 100644
--- a/composer/hwc_display.h
+++ b/composer/hwc_display.h
@@ -229,6 +229,10 @@
     return false;
   }
 
+  virtual bool HasSmartPanelConfig(void) {
+    return false;
+  }
+
   // Display Configurations
   static uint32_t GetThrottlingRefreshRate() { return HWCDisplay::throttling_refresh_rate_; }
   static void SetThrottlingRefreshRate(uint32_t newRefreshRate)
diff --git a/composer/hwc_display_builtin.cpp b/composer/hwc_display_builtin.cpp
index b132572..0fc1cf0 100644
--- a/composer/hwc_display_builtin.cpp
+++ b/composer/hwc_display_builtin.cpp
@@ -1264,6 +1264,16 @@
   return false;
 }
 
+bool HWCDisplayBuiltIn::HasSmartPanelConfig(void) {
+  for (auto &config : variable_config_map_) {
+    if (config.second.smart_panel) {
+      return true;
+    }
+  }
+
+  return false;
+}
+
 int HWCDisplayBuiltIn::Deinit() {
   // Destory color convert instance. This destroys thread and underlying GL resources.
   if (gl_layer_stitch_) {
diff --git a/composer/hwc_display_builtin.h b/composer/hwc_display_builtin.h
index fb7e918..3eff942 100644
--- a/composer/hwc_display_builtin.h
+++ b/composer/hwc_display_builtin.h
@@ -131,6 +131,7 @@
   virtual HWC2::Error SetClientTarget(buffer_handle_t target, shared_ptr<Fence> acquire_fence,
                                       int32_t dataspace, hwc_region_t damage);
   virtual bool IsSmartPanelConfig(uint32_t config_id);
+  virtual bool HasSmartPanelConfig(void);
   virtual int Deinit();
   virtual bool IsQsyncCallbackNeeded(bool *qsync_enabled, int32_t *refresh_rate,
                                      int32_t *qsync_refresh_rate);
diff --git a/composer/hwc_session.cpp b/composer/hwc_session.cpp
index 179a820..3896df4 100644
--- a/composer/hwc_session.cpp
+++ b/composer/hwc_session.cpp
@@ -1128,9 +1128,18 @@
   }
 
   *out_support = 0;
-  uint32_t config = 0;
-  GetActiveConfigIndex(display, &config);
-  *out_support = isSmartPanelConfig(display, config) ? 1 : 0;
+
+  if (display != qdutils::DISPLAY_PRIMARY) {
+    return HWC2_ERROR_NONE;
+  }
+
+  SCOPE_LOCK(locker_[display]);
+  if (!hwc_display_[display]) {
+    DLOGE("Display %d is not created yet.", INT32(display));
+    return HWC2_ERROR_NONE;
+  }
+
+  *out_support = hwc_display_[display]->HasSmartPanelConfig() ? 1 : 0;
 
   return HWC2_ERROR_NONE;
 }