summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Matt Buckley <mattbuckley@google.com> 2024-11-16 19:26:34 -0800
committer Matt Buckley <mattbuckley@google.com> 2024-11-18 16:33:51 -0800
commit8f997cbe9f33e7a2ae52d69ba7f17b83d297c665 (patch)
tree25907f5d95bbd4058c594a2bd65f943d30cd381a
parentfa8eb01f88bfc8ef61ba863d95c31605f563a721 (diff)
Refactor initial support check to use SupportInfo
This change makes the intial support check when APerformanceHintManager starts pass the SupportInfo object instead of just relying on the preferred rate Bug: 367803904 Test: atest PerformanceHintNativeTestCases Test: atest HintManagerServiceTest Flag: EXEMPT refactor Change-Id: Iba93310c58896a2b1d02c6156b4e67eaa766af5b
-rw-r--r--include/powermanager/PowerHalController.h1
-rw-r--r--include/powermanager/PowerHalWrapper.h3
-rw-r--r--services/powermanager/PowerHalController.cpp5
-rw-r--r--services/powermanager/PowerHalWrapper.cpp12
-rw-r--r--services/surfaceflinger/tests/unittests/mock/PowerAdvisor/MockPowerHalController.h2
5 files changed, 23 insertions, 0 deletions
diff --git a/include/powermanager/PowerHalController.h b/include/powermanager/PowerHalController.h
index 7e0bd5bedc..f4f4d5e05c 100644
--- a/include/powermanager/PowerHalController.h
+++ b/include/powermanager/PowerHalController.h
@@ -72,6 +72,7 @@ public:
virtual HalResult<aidl::android::hardware::power::ChannelConfig> getSessionChannel(
int tgid, int uid) override;
virtual HalResult<void> closeSessionChannel(int tgid, int uid) override;
+ virtual HalResult<aidl::android::hardware::power::SupportInfo> getSupportInfo() override;
private:
std::mutex mConnectedHalMutex;
diff --git a/include/powermanager/PowerHalWrapper.h b/include/powermanager/PowerHalWrapper.h
index 6e347a9ce9..42901821bc 100644
--- a/include/powermanager/PowerHalWrapper.h
+++ b/include/powermanager/PowerHalWrapper.h
@@ -63,6 +63,7 @@ public:
virtual HalResult<aidl::android::hardware::power::ChannelConfig> getSessionChannel(int tgid,
int uid) = 0;
virtual HalResult<void> closeSessionChannel(int tgid, int uid) = 0;
+ virtual HalResult<aidl::android::hardware::power::SupportInfo> getSupportInfo() = 0;
};
// Empty Power HAL wrapper that ignores all api calls.
@@ -85,6 +86,7 @@ public:
HalResult<aidl::android::hardware::power::ChannelConfig> getSessionChannel(int tgid,
int uid) override;
HalResult<void> closeSessionChannel(int tgid, int uid) override;
+ HalResult<aidl::android::hardware::power::SupportInfo> getSupportInfo() override;
protected:
virtual const char* getUnsupportedMessage();
@@ -170,6 +172,7 @@ public:
HalResult<aidl::android::hardware::power::ChannelConfig> getSessionChannel(int tgid,
int uid) override;
HalResult<void> closeSessionChannel(int tgid, int uid) override;
+ HalResult<aidl::android::hardware::power::SupportInfo> getSupportInfo() override;
protected:
const char* getUnsupportedMessage() override;
diff --git a/services/powermanager/PowerHalController.cpp b/services/powermanager/PowerHalController.cpp
index 40fd097491..0ba1909a44 100644
--- a/services/powermanager/PowerHalController.cpp
+++ b/services/powermanager/PowerHalController.cpp
@@ -168,6 +168,11 @@ HalResult<void> PowerHalController::closeSessionChannel(int tgid, int uid) {
"closeSessionChannel"));
}
+HalResult<aidl::android::hardware::power::SupportInfo> PowerHalController::getSupportInfo() {
+ std::shared_ptr<HalWrapper> handle = initHal();
+ return CACHE_SUPPORT(6, processHalResult(handle->getSupportInfo(), "getSupportInfo"));
+}
+
} // namespace power
} // namespace android
diff --git a/services/powermanager/PowerHalWrapper.cpp b/services/powermanager/PowerHalWrapper.cpp
index bd6685cbad..068c23f94a 100644
--- a/services/powermanager/PowerHalWrapper.cpp
+++ b/services/powermanager/PowerHalWrapper.cpp
@@ -18,6 +18,7 @@
#include <aidl/android/hardware/power/Boost.h>
#include <aidl/android/hardware/power/IPowerHintSession.h>
#include <aidl/android/hardware/power/Mode.h>
+#include <aidl/android/hardware/power/SupportInfo.h>
#include <powermanager/HalResult.h>
#include <powermanager/PowerHalWrapper.h>
#include <utils/Log.h>
@@ -73,6 +74,11 @@ HalResult<void> EmptyHalWrapper::closeSessionChannel(int, int) {
return HalResult<void>::unsupported();
}
+HalResult<Aidl::SupportInfo> EmptyHalWrapper::getSupportInfo() {
+ ALOGV("Skipped getSupportInfo because %s", getUnsupportedMessage());
+ return HalResult<Aidl::SupportInfo>::unsupported();
+}
+
const char* EmptyHalWrapper::getUnsupportedMessage() {
return "Power HAL is not supported";
}
@@ -280,6 +286,12 @@ HalResult<void> AidlHalWrapper::closeSessionChannel(int tgid, int uid) {
return HalResult<void>::fromStatus(mHandle->closeSessionChannel(tgid, uid));
}
+HalResult<Aidl::SupportInfo> AidlHalWrapper::getSupportInfo() {
+ Aidl::SupportInfo support;
+ auto result = mHandle->getSupportInfo(&support);
+ return HalResult<Aidl::SupportInfo>::fromStatus(result, std::move(support));
+}
+
const char* AidlHalWrapper::getUnsupportedMessage() {
return "Power HAL doesn't support it";
}
diff --git a/services/surfaceflinger/tests/unittests/mock/PowerAdvisor/MockPowerHalController.h b/services/surfaceflinger/tests/unittests/mock/PowerAdvisor/MockPowerHalController.h
index fba4cd82fa..891f507c0c 100644
--- a/services/surfaceflinger/tests/unittests/mock/PowerAdvisor/MockPowerHalController.h
+++ b/services/surfaceflinger/tests/unittests/mock/PowerAdvisor/MockPowerHalController.h
@@ -54,6 +54,8 @@ public:
MOCK_METHOD(HalResult<aidl::android::hardware::power::ChannelConfig>, getSessionChannel,
(int tgid, int uid), (override));
MOCK_METHOD(HalResult<void>, closeSessionChannel, (int tgid, int uid), (override));
+ MOCK_METHOD(HalResult<aidl::android::hardware::power::SupportInfo>, getSupportInfo, (),
+ (override));
};
} // namespace android::adpf::mock \ No newline at end of file