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 12:56:42 +05:30 committed by Anand S
commit 473d400819
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,20 +17,20 @@
#define ATRACE_TAG (ATRACE_TAG_POWER | ATRACE_TAG_HAL)
#define LOG_TAG "powerhal-libperfmgr"
#include <array>
#include <memory>
#include "InteractionHandler.h"
#include <android-base/properties.h>
#include <fcntl.h>
#include <perfmgr/HintManager.h>
#include <poll.h>
#include <sys/eventfd.h>
#include <time.h>
#include <unistd.h>
#include <android-base/properties.h>
#include <utils/Log.h>
#include <utils/Trace.h>
#include "InteractionHandler.h"
#include <array>
#include <memory>
#define MAX_LENGTH 64
@ -79,10 +79,10 @@ static int FbIdleOpen(void) {
} // namespace
InteractionHandler::InteractionHandler(std::shared_ptr<HintManager> const &hint_manager)
: mState(INTERACTION_STATE_UNINITIALIZED),
mDurationMs(0),
mHintManager(hint_manager) {}
using ::android::perfmgr::HintManager;
InteractionHandler::InteractionHandler()
: mState(INTERACTION_STATE_UNINITIALIZED), mDurationMs(0) {}
InteractionHandler::~InteractionHandler() {
Exit();
@ -130,14 +130,14 @@ void InteractionHandler::Exit() {
void InteractionHandler::PerfLock() {
ALOGV("%s: acquiring perf lock", __func__);
if (!mHintManager->DoHint("INTERACTION")) {
if (!HintManager::GetInstance()->DoHint("INTERACTION")) {
ALOGE("%s: do hint INTERACTION failed", __func__);
}
}
void InteractionHandler::PerfRel() {
ALOGV("%s: releasing perf lock", __func__);
if (!mHintManager->EndHint("INTERACTION")) {
if (!HintManager::GetInstance()->EndHint("INTERACTION")) {
ALOGE("%s: end hint INTERACTION failed", __func__);
}
}
@ -160,7 +160,7 @@ void InteractionHandler::Acquire(int32_t duration) {
// 1) override property is set OR
// 2) InteractionHandler not initialized
if (!kDisplayIdleSupport || mState == INTERACTION_STATE_UNINITIALIZED) {
mHintManager->DoHint("INTERACTION", std::chrono::milliseconds(finalDuration));
HintManager::GetInstance()->DoHint("INTERACTION", std::chrono::milliseconds(finalDuration));
return;
}