diff options
author | 2023-12-21 20:00:32 +0000 | |
---|---|---|
committer | 2024-01-23 02:23:55 +0000 | |
commit | db4192ada9dee591ec897a51c07c489c84c860c1 (patch) | |
tree | 6ac33f484d7adfa0bc26a9d1d18589e3b8a91d58 /services/powermanager/PowerHalController.cpp | |
parent | a34d58ed8cdb4763576b42b0fa735ff1d92d46d1 (diff) |
Add support for new PowerHAL methods to PowerHalWrapper
This patch adds FMQ support, createHintSessionWithConfig support,
and refactors the class structure slightly to allow wrapper subclasses
to share unsupported method logic with EmptyHalWrapper
Bug: 317387260
Test: atest libpowermanager_test libsurfaceflinger_unittest libcompositionengine_test
Change-Id: I53b67055b3ada4dc8576533a9b961ff5ec3367a5
Diffstat (limited to 'services/powermanager/PowerHalController.cpp')
-rw-r--r-- | services/powermanager/PowerHalController.cpp | 37 |
1 files changed, 28 insertions, 9 deletions
diff --git a/services/powermanager/PowerHalController.cpp b/services/powermanager/PowerHalController.cpp index 9a23c848c9..c049d7d283 100644 --- a/services/powermanager/PowerHalController.cpp +++ b/services/powermanager/PowerHalController.cpp @@ -80,7 +80,7 @@ std::shared_ptr<HalWrapper> PowerHalController::initHal() { // Check if a call to Power HAL function failed; if so, log the failure and // invalidate the current Power HAL handle. template <typename T> -HalResult<T> PowerHalController::processHalResult(HalResult<T> result, const char* fnName) { +HalResult<T> PowerHalController::processHalResult(HalResult<T>&& result, const char* fnName) { if (result.isFailed()) { ALOGE("%s failed: %s", fnName, result.errorMessage()); std::lock_guard<std::mutex> lock(mConnectedHalMutex); @@ -94,15 +94,13 @@ HalResult<T> PowerHalController::processHalResult(HalResult<T> result, const cha HalResult<void> PowerHalController::setBoost(aidl::android::hardware::power::Boost boost, int32_t durationMs) { std::shared_ptr<HalWrapper> handle = initHal(); - auto result = handle->setBoost(boost, durationMs); - return processHalResult(result, "setBoost"); + return processHalResult(handle->setBoost(boost, durationMs), "setBoost"); } HalResult<void> PowerHalController::setMode(aidl::android::hardware::power::Mode mode, bool enabled) { std::shared_ptr<HalWrapper> handle = initHal(); - auto result = handle->setMode(mode, enabled); - return processHalResult(result, "setMode"); + return processHalResult(handle->setMode(mode, enabled), "setMode"); } HalResult<std::shared_ptr<aidl::android::hardware::power::IPowerHintSession>> @@ -110,14 +108,35 @@ PowerHalController::createHintSession(int32_t tgid, int32_t uid, const std::vector<int32_t>& threadIds, int64_t durationNanos) { std::shared_ptr<HalWrapper> handle = initHal(); - auto result = handle->createHintSession(tgid, uid, threadIds, durationNanos); - return processHalResult(result, "createHintSession"); + return processHalResult(handle->createHintSession(tgid, uid, threadIds, durationNanos), + "createHintSession"); +} + +HalResult<std::shared_ptr<aidl::android::hardware::power::IPowerHintSession>> +PowerHalController::createHintSessionWithConfig( + int32_t tgid, int32_t uid, const std::vector<int32_t>& threadIds, int64_t durationNanos, + aidl::android::hardware::power::SessionTag tag, + aidl::android::hardware::power::SessionConfig* config) { + std::shared_ptr<HalWrapper> handle = initHal(); + return processHalResult(handle->createHintSessionWithConfig(tgid, uid, threadIds, durationNanos, + tag, config), + "createHintSessionWithConfig"); } HalResult<int64_t> PowerHalController::getHintSessionPreferredRate() { std::shared_ptr<HalWrapper> handle = initHal(); - auto result = handle->getHintSessionPreferredRate(); - return processHalResult(result, "getHintSessionPreferredRate"); + return processHalResult(handle->getHintSessionPreferredRate(), "getHintSessionPreferredRate"); +} + +HalResult<aidl::android::hardware::power::ChannelConfig> PowerHalController::getSessionChannel( + int tgid, int uid) { + std::shared_ptr<HalWrapper> handle = initHal(); + return processHalResult(handle->getSessionChannel(tgid, uid), "getSessionChannel"); +} + +HalResult<void> PowerHalController::closeSessionChannel(int tgid, int uid) { + std::shared_ptr<HalWrapper> handle = initHal(); + return processHalResult(handle->closeSessionChannel(tgid, uid), "closeSessionChannel"); } } // namespace power |