Add plumbing for ADPF Power Efficiency hint
These patches introduce a new power efficiency mode for hint sessions
to the public API, and internally expose a new setMode API for hint
sessions that resembles the setMode API for iPower, to control
different session operating modes.
This set of patches:
- Updates the PowerHAL AIDL to version 5, and updates relevant bp files
- Exposes new setPreferPowerEfficiency(bool enabled) method from the
SDK and NDK
- Exposes new setMode(int mode, bool enabled) method from PowerHAL AIDL
and HintManagerService
- Adds support for new setMode call in PowerHAL
Bug: b/288117936
Test: manual
Change-Id: Id006341b5ab0ae6fadd975d740d2fcf89f0636e4
diff --git a/power/aidl/vts/Android.bp b/power/aidl/vts/Android.bp
index 56c98bd..eb98b8b 100644
--- a/power/aidl/vts/Android.bp
+++ b/power/aidl/vts/Android.bp
@@ -26,14 +26,12 @@
defaults: [
"VtsHalTargetTestDefaults",
"use_libaidlvintf_gtest_helper_static",
+ "android.hardware.power-ndk_static",
],
srcs: ["VtsHalPowerTargetTest.cpp"],
shared_libs: [
"libbinder_ndk",
],
- static_libs: [
- "android.hardware.power-V4-ndk",
- ],
test_suites: [
"general-tests",
"vts",
diff --git a/power/aidl/vts/VtsHalPowerTargetTest.cpp b/power/aidl/vts/VtsHalPowerTargetTest.cpp
index 0976d18..96995a0 100644
--- a/power/aidl/vts/VtsHalPowerTargetTest.cpp
+++ b/power/aidl/vts/VtsHalPowerTargetTest.cpp
@@ -34,6 +34,7 @@
using android::hardware::power::IPowerHintSession;
using android::hardware::power::Mode;
using android::hardware::power::SessionHint;
+using android::hardware::power::SessionMode;
using android::hardware::power::WorkDuration;
const std::vector<Boost> kBoosts{ndk::enum_range<Boost>().begin(), ndk::enum_range<Boost>().end()};
@@ -43,6 +44,9 @@
const std::vector<SessionHint> kSessionHints{ndk::enum_range<SessionHint>().begin(),
ndk::enum_range<SessionHint>().end()};
+const std::vector<SessionMode> kSessionModes{ndk::enum_range<SessionMode>().begin(),
+ ndk::enum_range<SessionMode>().end()};
+
const std::vector<Boost> kInvalidBoosts = {
static_cast<Boost>(static_cast<int32_t>(kBoosts.front()) - 1),
static_cast<Boost>(static_cast<int32_t>(kBoosts.back()) + 1),
@@ -58,6 +62,11 @@
static_cast<SessionHint>(static_cast<int32_t>(kSessionHints.back()) + 1),
};
+const std::vector<SessionMode> kInvalidSessionModes = {
+ static_cast<SessionMode>(static_cast<int32_t>(kSessionModes.front()) - 1),
+ static_cast<SessionMode>(static_cast<int32_t>(kSessionModes.back()) + 1),
+};
+
class DurationWrapper : public WorkDuration {
public:
DurationWrapper(int64_t dur, int64_t time) {
@@ -228,6 +237,21 @@
ASSERT_TRUE(mSession->setThreads(kSelfTids).isOk());
}
+TEST_P(HintSessionAidl, setSessionMode) {
+ if (mServiceVersion < 5) {
+ GTEST_SKIP() << "DEVICE not launching with Power V5 and beyond.";
+ }
+
+ for (const auto& sessionMode : kSessionModes) {
+ ASSERT_TRUE(mSession->setMode(sessionMode, true).isOk());
+ ASSERT_TRUE(mSession->setMode(sessionMode, false).isOk());
+ }
+ for (const auto& sessionMode : kInvalidSessionModes) {
+ ASSERT_TRUE(mSession->setMode(sessionMode, true).isOk());
+ ASSERT_TRUE(mSession->setMode(sessionMode, false).isOk());
+ }
+}
+
// FIXED_PERFORMANCE mode is required for all devices which ship on Android 11
// or later
TEST_P(PowerAidl, hasFixedPerformance) {