diff options
-rw-r--r-- | power-libperfmgr/aidl/Power.cpp | 41 | ||||
-rw-r--r-- | power-libperfmgr/aidl/Power.h | 1 |
2 files changed, 42 insertions, 0 deletions
diff --git a/power-libperfmgr/aidl/Power.cpp b/power-libperfmgr/aidl/Power.cpp index e15d985d..4bbbb447 100644 --- a/power-libperfmgr/aidl/Power.cpp +++ b/power-libperfmgr/aidl/Power.cpp @@ -83,6 +83,9 @@ Power::Power(std::shared_ptr<DisplayLowPower> dlpw) LOG(INFO) << "Initialize with EXPENSIVE_RENDERING on"; HintManager::GetInstance()->DoHint("EXPENSIVE_RENDERING"); } + + auto status = this->getInterfaceVersion(&mServiceVersion); + LOG(INFO) << "PowerHAL InterfaceVersion:" << mServiceVersion << " isOK: " << status.isOk(); } ndk::ScopedAStatus Power::setMode(Mode type, bool enabled) { @@ -178,6 +181,27 @@ ndk::ScopedAStatus Power::setMode(Mode type, bool enabled) { } ndk::ScopedAStatus Power::isModeSupported(Mode type, bool *_aidl_return) { + switch (mServiceVersion) { + case 5: + if (static_cast<int32_t>(type) <= static_cast<int32_t>(Mode::AUTOMOTIVE_PROJECTION)) + break; + [[fallthrough]]; + case 4: + [[fallthrough]]; + case 3: + if (static_cast<int32_t>(type) <= static_cast<int32_t>(Mode::GAME_LOADING)) + break; + [[fallthrough]]; + case 2: + [[fallthrough]]; + case 1: + if (static_cast<int32_t>(type) <= static_cast<int32_t>(Mode::CAMERA_STREAMING_HIGH)) + break; + [[fallthrough]]; + default: + *_aidl_return = false; + return ndk::ScopedAStatus::ok(); + } bool supported = HintManager::GetInstance()->IsHintSupported(toString(type)); // LOW_POWER handled insides PowerHAL specifically if (type == Mode::LOW_POWER) { @@ -233,6 +257,23 @@ ndk::ScopedAStatus Power::setBoost(Boost type, int32_t durationMs) { } ndk::ScopedAStatus Power::isBoostSupported(Boost type, bool *_aidl_return) { + switch (mServiceVersion) { + case 5: + [[fallthrough]]; + case 4: + [[fallthrough]]; + case 3: + [[fallthrough]]; + case 2: + [[fallthrough]]; + case 1: + if (static_cast<int32_t>(type) <= static_cast<int32_t>(Boost::CAMERA_SHOT)) + break; + [[fallthrough]]; + default: + *_aidl_return = false; + return ndk::ScopedAStatus::ok(); + } bool supported = HintManager::GetInstance()->IsHintSupported(toString(type)); if (!supported && HintManager::GetInstance()->IsAdpfProfileSupported(toString(type))) { supported = true; diff --git a/power-libperfmgr/aidl/Power.h b/power-libperfmgr/aidl/Power.h index b7fd8f26..e256e34a 100644 --- a/power-libperfmgr/aidl/Power.h +++ b/power-libperfmgr/aidl/Power.h @@ -55,6 +55,7 @@ class Power : public ::aidl::android::hardware::power::BnPower { std::unique_ptr<InteractionHandler> mInteractionHandler; std::atomic<bool> mVRModeOn; std::atomic<bool> mSustainedPerfModeOn; + int32_t mServiceVersion; }; } // namespace pixel |