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
|
|
@ -17,18 +17,19 @@
|
|||
#define LOG_TAG "android.hardware.power-service.realme_sm6375.ext-libperfmgr"
|
||||
|
||||
#include "PowerExt.h"
|
||||
#include "PowerSessionManager.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 "PowerSessionManager.h"
|
||||
|
||||
namespace aidl {
|
||||
namespace google {
|
||||
namespace hardware {
|
||||
|
|
@ -36,13 +37,15 @@ namespace power {
|
|||
namespace impl {
|
||||
namespace pixel {
|
||||
|
||||
using ::android::perfmgr::HintManager;
|
||||
|
||||
ndk::ScopedAStatus PowerExt::setMode(const std::string &mode, bool enabled) {
|
||||
LOG(DEBUG) << "PowerExt setMode: " << mode << " to: " << enabled;
|
||||
|
||||
if (enabled) {
|
||||
mHintManager->DoHint(mode);
|
||||
HintManager::GetInstance()->DoHint(mode);
|
||||
} else {
|
||||
mHintManager->EndHint(mode);
|
||||
HintManager::GetInstance()->EndHint(mode);
|
||||
}
|
||||
PowerSessionManager::getInstance()->updateHintMode(mode, enabled);
|
||||
|
||||
|
|
@ -50,7 +53,7 @@ ndk::ScopedAStatus PowerExt::setMode(const std::string &mode, bool enabled) {
|
|||
}
|
||||
|
||||
ndk::ScopedAStatus PowerExt::isModeSupported(const std::string &mode, bool *_aidl_return) {
|
||||
bool supported = mHintManager->IsHintSupported(mode);
|
||||
bool supported = HintManager::GetInstance()->IsHintSupported(mode);
|
||||
LOG(INFO) << "PowerExt mode " << mode << " isModeSupported: " << supported;
|
||||
*_aidl_return = supported;
|
||||
return ndk::ScopedAStatus::ok();
|
||||
|
|
@ -60,18 +63,18 @@ ndk::ScopedAStatus PowerExt::setBoost(const std::string &boost, int32_t duration
|
|||
LOG(DEBUG) << "PowerExt setBoost: " << boost << " duration: " << durationMs;
|
||||
|
||||
if (durationMs > 0) {
|
||||
mHintManager->DoHint(boost, std::chrono::milliseconds(durationMs));
|
||||
HintManager::GetInstance()->DoHint(boost, std::chrono::milliseconds(durationMs));
|
||||
} else if (durationMs == 0) {
|
||||
mHintManager->DoHint(boost);
|
||||
HintManager::GetInstance()->DoHint(boost);
|
||||
} else {
|
||||
mHintManager->EndHint(boost);
|
||||
HintManager::GetInstance()->EndHint(boost);
|
||||
}
|
||||
|
||||
return ndk::ScopedAStatus::ok();
|
||||
}
|
||||
|
||||
ndk::ScopedAStatus PowerExt::isBoostSupported(const std::string &boost, bool *_aidl_return) {
|
||||
bool supported = mHintManager->IsHintSupported(boost);
|
||||
bool supported = HintManager::GetInstance()->IsHintSupported(boost);
|
||||
LOG(INFO) << "PowerExt boost " << boost << " isBoostSupported: " << supported;
|
||||
*_aidl_return = supported;
|
||||
return ndk::ScopedAStatus::ok();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue