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:
Jimmy Shiu 2024-07-18 20:16:00 +05:30 committed by Anand S
commit 53f1fc4eee
No known key found for this signature in database
GPG key ID: 3B2983FA448B3D61
9 changed files with 68 additions and 96 deletions

View file

@ -17,12 +17,13 @@
#define LOG_TAG "powerhal-libperfmgr"
#define ATRACE_TAG (ATRACE_TAG_POWER | ATRACE_TAG_HAL)
#include "PowerSessionManager.h"
#include <log/log.h>
#include <perfmgr/HintManager.h>
#include <processgroup/processgroup.h>
#include <utils/Trace.h>
#include "PowerSessionManager.h"
namespace aidl {
namespace google {
namespace hardware {
@ -30,12 +31,7 @@ namespace power {
namespace impl {
namespace pixel {
void PowerSessionManager::setHintManager(std::shared_ptr<HintManager> const &hint_manager) {
// Only initialize hintmanager instance if hint is supported.
if (hint_manager->IsHintSupported(kDisableBoostHintName)) {
mHintManager = hint_manager;
}
}
using ::android::perfmgr::HintManager;
void PowerSessionManager::updateHintMode(const std::string &mode, bool enabled) {
ALOGV("PowerSessionManager::updateHintMode: mode: %s, enabled: %d", mode.c_str(), enabled);
@ -124,16 +120,16 @@ void PowerSessionManager::handleMessage(const Message &) {
}
void PowerSessionManager::enableSystemTopAppBoost() {
if (mHintManager) {
if (HintManager::GetInstance()->IsHintSupported(kDisableBoostHintName)) {
ALOGV("PowerSessionManager::enableSystemTopAppBoost!!");
mHintManager->EndHint(kDisableBoostHintName);
HintManager::GetInstance()->EndHint(kDisableBoostHintName);
}
}
void PowerSessionManager::disableSystemTopAppBoost() {
if (mHintManager) {
if (HintManager::GetInstance()->IsHintSupported(kDisableBoostHintName)) {
ALOGV("PowerSessionManager::disableSystemTopAppBoost!!");
mHintManager->DoHint(kDisableBoostHintName);
HintManager::GetInstance()->DoHint(kDisableBoostHintName);
}
}