hwc2: Restore null display mode

Skip SDM Core API calls in null display mode. Fix null-pointer
dereference while booting up in null display mode. This is a
follow-up change to Change-Id Ia274017...

CRs-Fixed: 2356380
Change-Id: I5b8c63cf0f13df6763f1fa078a61109f784e0270
diff --git a/sdm/libs/hwc2/hwc_session.cpp b/sdm/libs/hwc2/hwc_session.cpp
index 397a830..e9ba25d 100644
--- a/sdm/libs/hwc2/hwc_session.cpp
+++ b/sdm/libs/hwc2/hwc_session.cpp
@@ -206,6 +206,27 @@
       return -EINVAL;
     }
 
+    error = core_intf_->GetMaxDisplaysSupported(kPluggable, &max_sde_pluggable_displays_);
+    if (kErrorNone == error) {
+      if (max_sde_pluggable_displays_ && (kPluggable == hw_disp_info.type)) {
+        // If primary is a pluggable display, we have already used one pluggable display interface.
+        max_sde_pluggable_displays_--;
+      }
+    } else {
+      DLOGE("Could not find maximum pluggable displays supported. Error = %d", error);
+    }
+
+    error = core_intf_->GetMaxDisplaysSupported(kBuiltIn, &max_sde_builtin_displays_);
+    if (kErrorNone == error) {
+      if (max_sde_builtin_displays_ && (kBuiltIn == hw_disp_info.type)) {
+        // If primary is not a pluggable display, we have already used one built-in display
+        // interface.
+        max_sde_builtin_displays_--;
+      }
+    } else {
+      DLOGE("Could not find maximum built-in displays supported. Error = %d", error);
+    }
+
     g_hwc_uevent_.Register(this);
   }
 
@@ -219,26 +240,6 @@
 
   is_composer_up_ = true;
 
-  error = core_intf_->GetMaxDisplaysSupported(kPluggable, &max_sde_pluggable_displays_);
-  if (kErrorNone == error) {
-    if (max_sde_pluggable_displays_ && (kPluggable == map_info_primary_.disp_type)) {
-      // If primary is a pluggable display, we have already used one pluggable display interface.
-      max_sde_pluggable_displays_--;
-    }
-  } else {
-    DLOGE("Could not find maximum pluggable displays supported. Error = %d", error);
-  }
-
-  error = core_intf_->GetMaxDisplaysSupported(kBuiltIn, &max_sde_builtin_displays_);
-  if (kErrorNone == error) {
-    if (max_sde_builtin_displays_ && (kBuiltIn == map_info_primary_.disp_type)) {
-      // If primary is not a pluggable display, we have already used one built-in display interface.
-      max_sde_builtin_displays_--;
-    }
-  } else {
-    DLOGE("Could not find maximum built-in displays supported. Error = %d", error);
-  }
-
   return 0;
 }