drm_hwcomposer: Support multiple AIDL versions

As far as I know, there's no way for Soong to support multiple versions
that will change dependencies based on the Android API version.
However, we can still do that if we build with the aospext project,
making it possible for Android-13 and Android-14 to use the latest
drm_hwcomposer.

Change-Id: Ifeee42d3af64ff873b1a149231dc542ee2aee1df
Signed-off-by: Roman Stratiienko <r.stratiienko@gmail.com>
diff --git a/hwc3/ComposerClient.cpp b/hwc3/ComposerClient.cpp
index 2aed2bc..0597712 100644
--- a/hwc3/ComposerClient.cpp
+++ b/hwc3/ComposerClient.cpp
@@ -190,6 +190,28 @@
   }
 }
 
+#if __ANDROID_API__ < 35
+
+class DisplayConfiguration {
+ public:
+  class Dpi {
+   public:
+    float x = 0.000000F;
+    float y = 0.000000F;
+  };
+  // NOLINTNEXTLINE(readability-identifier-naming)
+  int32_t configId = 0;
+  int32_t width = 0;
+  int32_t height = 0;
+  std::optional<Dpi> dpi;
+  // NOLINTNEXTLINE(readability-identifier-naming)
+  int32_t configGroup = 0;
+  // NOLINTNEXTLINE(readability-identifier-naming)
+  int32_t vsyncPeriod = 0;
+};
+
+#endif
+
 DisplayConfiguration HwcDisplayConfigToAidlConfiguration(
     const HwcDisplayConfigs& configs, const HwcDisplayConfig& config) {
   DisplayConfiguration aidl_configuration =
@@ -1173,6 +1195,8 @@
   return ToBinderStatus(hwc3::Error::kUnsupported);
 }
 
+#if __ANDROID_API__ >= 35
+
 ndk::ScopedAStatus ComposerClient::getDisplayConfigurations(
     int64_t display_id, int32_t /*max_frame_interval_ns*/,
     std::vector<DisplayConfiguration>* configurations) {
@@ -1197,6 +1221,8 @@
   return ToBinderStatus(hwc3::Error::kUnsupported);
 }
 
+#endif
+
 std::string ComposerClient::Dump() {
   uint32_t size = 0;
   hwc_->Dump(&size, nullptr);
diff --git a/hwc3/ComposerClient.h b/hwc3/ComposerClient.h
index 5e4949e..b8ab715 100644
--- a/hwc3/ComposerClient.h
+++ b/hwc3/ComposerClient.h
@@ -145,6 +145,9 @@
       common::Hdr* out_hdr) override;
   ndk::ScopedAStatus setRefreshRateChangedCallbackDebugEnabled(
       int64_t display, bool enabled) override;
+
+#if __ANDROID_API__ >= 35
+
   ndk::ScopedAStatus getDisplayConfigurations(
       int64_t display, int32_t max_frame_interval_ns,
       std::vector<DisplayConfiguration>* configurations) override;
@@ -152,6 +155,8 @@
       int64_t display, const ClockMonotonicTimestamp& expected_present_time,
       int32_t frame_interval_ns) override;
 
+#endif
+
  protected:
   ::ndk::SpAIBinder createBinder() override;
 
diff --git a/hwc3/DrmHwcThree.cpp b/hwc3/DrmHwcThree.cpp
index 2ac307c..fb14bc9 100644
--- a/hwc3/DrmHwcThree.cpp
+++ b/hwc3/DrmHwcThree.cpp
@@ -22,7 +22,9 @@
 
 #include "Utils.h"
 #include "aidl/android/hardware/graphics/common/Dataspace.h"
+#if __ANDROID_API__ >= 35
 #include "aidl/android/hardware/graphics/common/DisplayHotplugEvent.h"
+#endif
 
 namespace aidl::android::hardware::graphics::composer3::impl {
 
@@ -61,6 +63,8 @@
                               static_cast<int32_t>(vsync_period));
 }
 
+#if __ANDROID_API__ >= 35
+
 void DrmHwcThree::SendHotplugEventToClient(
     hwc2_display_t display_id, DrmHwc::DisplayStatus display_status) {
   common::DisplayHotplugEvent event = common::DisplayHotplugEvent::DISCONNECTED;
@@ -80,6 +84,17 @@
   composer_callback_->onHotplugEvent(static_cast<int64_t>(display_id), event);
 }
 
+#else
+
+void DrmHwcThree::SendHotplugEventToClient(
+    hwc2_display_t display_id, DrmHwc::DisplayStatus display_status) {
+  bool connected = display_status != DrmHwc::kDisconnected;
+  HandleDisplayHotplugEvent(static_cast<uint64_t>(display_id), connected);
+  composer_callback_->onHotplug(static_cast<int64_t>(display_id), connected);
+}
+
+#endif
+
 void DrmHwcThree::CleanDisplayResources(uint64_t display_id) {
   DEBUG_FUNC();
   HwcDisplay* display = GetDisplay(display_id);