Add Power HAL changes for ADPF Timeline API

Add a number of new AIDL objects to the PowerHAL for the ADPF timeline
API, allowing sessions to map to frame producers and display outputs,
and provide FPS updates when relevant, and frame timestamps information
for abuse detection and automatic timing.

Flag: EXEMPT hal change
Bug: 360908317
Bug: 367803904
Test: atest VtsHalPowerTargetTest
Change-Id: I8b0e68ea08006b02d7b816010b16bcf00a467c0f
diff --git a/power/aidl/vts/VtsHalPowerTargetTest.cpp b/power/aidl/vts/VtsHalPowerTargetTest.cpp
index 5e3ddd5..0df360a 100644
--- a/power/aidl/vts/VtsHalPowerTargetTest.cpp
+++ b/power/aidl/vts/VtsHalPowerTargetTest.cpp
@@ -36,6 +36,8 @@
 namespace aidl::android::hardware::power {
 namespace {
 
+using namespace std::chrono_literals;
+
 using ::aidl::android::hardware::common::fmq::SynchronizedReadWrite;
 using ::android::AidlMessageQueue;
 using ::android::hardware::EventFlag;
@@ -137,7 +139,11 @@
         power = IPower::fromBinder(ndk::SpAIBinder(binder));
         auto status = power->getInterfaceVersion(&mServiceVersion);
         ASSERT_TRUE(status.isOk());
-        if (mServiceVersion >= 2) {
+        if (mServiceVersion >= 6) {
+            mSupportInfo = std::make_optional<SupportInfo>();
+            ASSERT_TRUE(power->getSupportInfo(&(*mSupportInfo)).isOk());
+            mSessionSupport = mSupportInfo->usesSessions;
+        } else if (mServiceVersion >= 2) {
             status = power->createHintSession(getpid(), getuid(), kSelfTids, 16666666L, &mSession);
             mSessionSupport = status.isOk();
         }
@@ -147,6 +153,7 @@
     int32_t mServiceVersion;
     std::shared_ptr<IPowerHintSession> mSession;
     bool mSessionSupport = false;
+    std::optional<SupportInfo> mSupportInfo = std::nullopt;
 };
 
 class HintSessionAidl : public PowerAidl {
@@ -341,20 +348,49 @@
 }
 
 TEST_P(PowerAidl, hasSupportInfo) {
-    SupportInfo config;
-    ASSERT_TRUE(power->getSupportInfo(&config).isOk());
+    if (mServiceVersion < 6) {
+        GTEST_SKIP() << "DEVICE not launching with Power V6 and beyond.";
+    }
+    ASSERT_TRUE(mSupportInfo.has_value());
     for (Mode mode : kModes) {
         bool supported;
         power->isModeSupported(mode, &supported);
-        ASSERT_EQ(supported, supportFromBitset(config.modes, mode));
+        ASSERT_EQ(supported, supportFromBitset(mSupportInfo->modes, mode));
     }
     for (Boost boost : kBoosts) {
         bool supported;
         power->isBoostSupported(boost, &supported);
-        ASSERT_EQ(supported, supportFromBitset(config.boosts, boost));
+        ASSERT_EQ(supported, supportFromBitset(mSupportInfo->boosts, boost));
     }
 }
 
+TEST_P(PowerAidl, receivesCompositionData) {
+    if (mServiceVersion < 6) {
+        GTEST_SKIP() << "DEVICE not launching with Power V6 and beyond.";
+    }
+    if (mSupportInfo->compositionData.isSupported) {
+        GTEST_SKIP() << "Composition data marked as unsupported.";
+    }
+    // Sending an empty object is fine, we just want to confirm it accepts the tx
+    std::vector<CompositionData> out{};
+    out.emplace_back();
+    auto status = power->sendCompositionData(out);
+    ASSERT_TRUE(status.isOk());
+}
+
+TEST_P(PowerAidl, receivesCompositionUpdate) {
+    if (mServiceVersion < 6) {
+        GTEST_SKIP() << "DEVICE not launching with Power V6 and beyond.";
+    }
+    if (mSupportInfo->compositionData.isSupported) {
+        GTEST_SKIP() << "Composition data marked as unsupported.";
+    }
+
+    CompositionUpdate out{};
+    auto status = power->sendCompositionUpdate(out);
+    ASSERT_TRUE(status.isOk());
+}
+
 TEST_P(HintSessionAidl, createAndCloseHintSession) {
     if (!mSessionSupport) {
         GTEST_SKIP() << "DEVICE not support Hint Session.";