Add thread management API to PowerHintSession.
Previously the list of threads of a PowerHintSession was only determined
when the PowerHintSession was created. This means newly forked threads
from existing threads of the PowerHintSession will not get the benefit
and the clients have to create new PowerHintSession for that.
This patch adds a new method to allow clients to update the threads of
the PowerHintSession.
Additionally, this patch also removes the oneway annotation at the
interface level of IPowerHintSession, all existing methods are converted
to oneway methods and setThreads is a bidirectional method. This also
allows to do meaningful VTS validation.
Bug: b/244216750
Test: atest VtsHalPowerTargetTest
Change-Id: If499d6dad20c9d7f6fbda1b5dc9d528396f1f6c1
diff --git a/power/aidl/vts/VtsHalPowerTargetTest.cpp b/power/aidl/vts/VtsHalPowerTargetTest.cpp
index e51f756..5f5ce56 100644
--- a/power/aidl/vts/VtsHalPowerTargetTest.cpp
+++ b/power/aidl/vts/VtsHalPowerTargetTest.cpp
@@ -100,6 +100,10 @@
// target-level=7 compatibility_matrix file.
const uint64_t kCompatibilityMatrix7ApiLevel = 33;
+// DEVICEs launching with Android 14 MUST meet the requirements for the
+// target-level=8 compatibility_matrix file.
+const uint64_t kCompatibilityMatrix8ApiLevel = 34;
+
inline bool isUnknownOrUnsupported(const ndk::ScopedAStatus& status) {
return status.getStatus() == STATUS_UNKNOWN_TRANSACTION ||
status.getExceptionCode() == EX_UNSUPPORTED_OPERATION;
@@ -242,6 +246,27 @@
}
}
+TEST_P(PowerAidl, setThreads) {
+ std::shared_ptr<IPowerHintSession> session;
+ auto status = power->createHintSession(getpid(), getuid(), kSelfTids, 16666666L, &session);
+ if (mApiLevel < kCompatibilityMatrix7ApiLevel && !status.isOk()) {
+ EXPECT_TRUE(isUnknownOrUnsupported(status));
+ GTEST_SKIP() << "DEVICE not launching with Android 13 and beyond.";
+ }
+ ASSERT_TRUE(status.isOk());
+
+ if (mApiLevel < kCompatibilityMatrix8ApiLevel) {
+ GTEST_SKIP() << "DEVICE not launching with Android 14 and beyond.";
+ }
+
+ status = session->setThreads(kEmptyTids);
+ ASSERT_FALSE(status.isOk());
+ ASSERT_EQ(EX_ILLEGAL_ARGUMENT, status.getExceptionCode());
+
+ status = session->setThreads(kSelfTids);
+ ASSERT_TRUE(status.isOk());
+}
+
// FIXED_PERFORMANCE mode is required for all devices which ship on Android 11
// or later
TEST_P(PowerAidl, hasFixedPerformance) {