sm6375-common: power-libperfmgr: Make HintManager a singleton class
HintManager is unique and widely used in many different components.
This is for making it easiler to be reloaded for debugging.
Bug: 172285365
Test: adb push \
out/target/product/raven/data/nativetest64/libperfmgr_test/libperfmgr_test \
/data/nativetest64/libperfmgr_test/libperfmgr_test && \
adb shell /data/nativetest64/libperfmgr_test/libperfmgr_test
Change-Id: I3affdfe780073ebbc50fac7bfbdd1530ee9dc8c2
This commit is contained in:
parent
40a340e68d
commit
53f1fc4eee
9 changed files with 68 additions and 96 deletions
|
|
@ -18,16 +18,16 @@
|
|||
|
||||
#include "Power.h"
|
||||
|
||||
#include <mutex>
|
||||
|
||||
#include <android-base/file.h>
|
||||
#include <android-base/logging.h>
|
||||
#include <android-base/properties.h>
|
||||
#include <android-base/stringprintf.h>
|
||||
#include <android-base/strings.h>
|
||||
|
||||
#include <perfmgr/HintManager.h>
|
||||
#include <utils/Log.h>
|
||||
|
||||
#include <mutex>
|
||||
|
||||
#include "PowerHintSession.h"
|
||||
#include "PowerSessionManager.h"
|
||||
|
||||
|
|
@ -41,6 +41,7 @@ namespace impl {
|
|||
namespace pixel {
|
||||
|
||||
using ::aidl::google::hardware::power::impl::pixel::PowerHintSession;
|
||||
using ::android::perfmgr::HintManager;
|
||||
|
||||
constexpr char kPowerHalStateProp[] = "vendor.powerhal.state";
|
||||
constexpr char kPowerHalAudioProp[] = "vendor.powerhal.audio";
|
||||
|
|
@ -48,19 +49,18 @@ constexpr char kPowerHalRenderingProp[] = "vendor.powerhal.rendering";
|
|||
constexpr char kPowerHalAdpfRateProp[] = "vendor.powerhal.adpf.rate";
|
||||
constexpr int64_t kPowerHalAdpfRateDefault = -1;
|
||||
|
||||
Power::Power(std::shared_ptr<HintManager> hm)
|
||||
: mHintManager(hm),
|
||||
mInteractionHandler(nullptr),
|
||||
Power::Power()
|
||||
: mInteractionHandler(nullptr),
|
||||
mSustainedPerfModeOn(false),
|
||||
mAdpfRateNs(
|
||||
::android::base::GetIntProperty(kPowerHalAdpfRateProp, kPowerHalAdpfRateDefault)) {
|
||||
mInteractionHandler = std::make_unique<InteractionHandler>(mHintManager);
|
||||
mInteractionHandler = std::make_unique<InteractionHandler>();
|
||||
mInteractionHandler->Init();
|
||||
|
||||
std::string state = ::android::base::GetProperty(kPowerHalStateProp, "");
|
||||
if (state == "SUSTAINED_PERFORMANCE") {
|
||||
LOG(INFO) << "Initialize with SUSTAINED_PERFORMANCE on";
|
||||
mHintManager->DoHint("SUSTAINED_PERFORMANCE");
|
||||
HintManager::GetInstance()->DoHint("SUSTAINED_PERFORMANCE");
|
||||
mSustainedPerfModeOn = true;
|
||||
} else {
|
||||
LOG(INFO) << "Initialize PowerHAL";
|
||||
|
|
@ -69,13 +69,13 @@ Power::Power(std::shared_ptr<HintManager> hm)
|
|||
state = ::android::base::GetProperty(kPowerHalAudioProp, "");
|
||||
if (state == "AUDIO_STREAMING_LOW_LATENCY") {
|
||||
LOG(INFO) << "Initialize with AUDIO_LOW_LATENCY on";
|
||||
mHintManager->DoHint(state);
|
||||
HintManager::GetInstance()->DoHint(state);
|
||||
}
|
||||
|
||||
state = ::android::base::GetProperty(kPowerHalRenderingProp, "");
|
||||
if (state == "EXPENSIVE_RENDERING") {
|
||||
LOG(INFO) << "Initialize with EXPENSIVE_RENDERING on";
|
||||
mHintManager->DoHint("EXPENSIVE_RENDERING");
|
||||
HintManager::GetInstance()->DoHint("EXPENSIVE_RENDERING");
|
||||
}
|
||||
|
||||
// Now start to take powerhint
|
||||
|
|
@ -93,7 +93,7 @@ ndk::ScopedAStatus Power::setMode(Mode type, bool enabled) {
|
|||
#endif
|
||||
case Mode::SUSTAINED_PERFORMANCE:
|
||||
if (enabled) {
|
||||
mHintManager->DoHint("SUSTAINED_PERFORMANCE");
|
||||
HintManager::GetInstance()->DoHint("SUSTAINED_PERFORMANCE");
|
||||
}
|
||||
mSustainedPerfModeOn = true;
|
||||
break;
|
||||
|
|
@ -120,9 +120,9 @@ ndk::ScopedAStatus Power::setMode(Mode type, bool enabled) {
|
|||
[[fallthrough]];
|
||||
default:
|
||||
if (enabled) {
|
||||
mHintManager->DoHint(toString(type));
|
||||
HintManager::GetInstance()->DoHint(toString(type));
|
||||
} else {
|
||||
mHintManager->EndHint(toString(type));
|
||||
HintManager::GetInstance()->EndHint(toString(type));
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
|
@ -131,7 +131,7 @@ ndk::ScopedAStatus Power::setMode(Mode type, bool enabled) {
|
|||
}
|
||||
|
||||
ndk::ScopedAStatus Power::isModeSupported(Mode type, bool *_aidl_return) {
|
||||
bool supported = mHintManager->IsHintSupported(toString(type));
|
||||
bool supported = HintManager::GetInstance()->IsHintSupported(toString(type));
|
||||
#ifdef TAP_TO_WAKE_NODE
|
||||
if (type == Mode::DOUBLE_TAP_TO_WAKE) {
|
||||
supported = true;
|
||||
|
|
@ -162,11 +162,12 @@ ndk::ScopedAStatus Power::setBoost(Boost type, int32_t durationMs) {
|
|||
break;
|
||||
}
|
||||
if (durationMs > 0) {
|
||||
mHintManager->DoHint(toString(type), std::chrono::milliseconds(durationMs));
|
||||
HintManager::GetInstance()->DoHint(toString(type),
|
||||
std::chrono::milliseconds(durationMs));
|
||||
} else if (durationMs == 0) {
|
||||
mHintManager->DoHint(toString(type));
|
||||
HintManager::GetInstance()->DoHint(toString(type));
|
||||
} else {
|
||||
mHintManager->EndHint(toString(type));
|
||||
HintManager::GetInstance()->EndHint(toString(type));
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
|
@ -175,7 +176,7 @@ ndk::ScopedAStatus Power::setBoost(Boost type, int32_t durationMs) {
|
|||
}
|
||||
|
||||
ndk::ScopedAStatus Power::isBoostSupported(Boost type, bool *_aidl_return) {
|
||||
bool supported = mHintManager->IsHintSupported(toString(type));
|
||||
bool supported = HintManager::GetInstance()->IsHintSupported(toString(type));
|
||||
LOG(INFO) << "Power boost " << toString(type) << " isBoostSupported: " << supported;
|
||||
*_aidl_return = supported;
|
||||
return ndk::ScopedAStatus::ok();
|
||||
|
|
@ -189,10 +190,10 @@ binder_status_t Power::dump(int fd, const char **, uint32_t) {
|
|||
std::string buf(::android::base::StringPrintf(
|
||||
"HintManager Running: %s\n"
|
||||
"SustainedPerformanceMode: %s\n",
|
||||
boolToString(mHintManager->IsRunning()),
|
||||
boolToString(HintManager::GetInstance()->IsRunning()),
|
||||
boolToString(mSustainedPerfModeOn)));
|
||||
// Dump nodes through libperfmgr
|
||||
mHintManager->DumpToFd(fd);
|
||||
HintManager::GetInstance()->DumpToFd(fd);
|
||||
if (!::android::base::WriteStringToFd(buf, fd)) {
|
||||
PLOG(ERROR) << "Failed to dump state to fd";
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue