sm6375-common: power-libperfmgr: Fix objects that are derived from refbase
Fixes: ag/14313466 Bug: 177493042 Bug: 191163855 Test: Build Change-Id: I94812997a8214b77a2e1d0bcf90ef62205c5adf6 Signed-off-by: Wei Wang <wvw@google.com>
This commit is contained in:
parent
4f6e93f30a
commit
7b56c41f2d
6 changed files with 20 additions and 20 deletions
|
@ -87,7 +87,7 @@ Power::Power(std::shared_ptr<HintManager> hm)
|
||||||
ndk::ScopedAStatus Power::setMode(Mode type, bool enabled) {
|
ndk::ScopedAStatus Power::setMode(Mode type, bool enabled) {
|
||||||
LOG(DEBUG) << "Power setMode: " << toString(type) << " to: " << enabled;
|
LOG(DEBUG) << "Power setMode: " << toString(type) << " to: " << enabled;
|
||||||
ATRACE_INT(toString(type).c_str(), enabled);
|
ATRACE_INT(toString(type).c_str(), enabled);
|
||||||
PowerSessionManager::getInstance().updateHintMode(toString(type), enabled);
|
PowerSessionManager::getInstance()->updateHintMode(toString(type), enabled);
|
||||||
switch (type) {
|
switch (type) {
|
||||||
#ifdef TAP_TO_WAKE_NODE
|
#ifdef TAP_TO_WAKE_NODE
|
||||||
case Mode::DOUBLE_TAP_TO_WAKE:
|
case Mode::DOUBLE_TAP_TO_WAKE:
|
||||||
|
|
|
@ -47,7 +47,7 @@ ndk::ScopedAStatus PowerExt::setMode(const std::string &mode, bool enabled) {
|
||||||
} else {
|
} else {
|
||||||
mHintManager->EndHint(mode);
|
mHintManager->EndHint(mode);
|
||||||
}
|
}
|
||||||
PowerSessionManager::getInstance().updateHintMode(mode, enabled);
|
PowerSessionManager::getInstance()->updateHintMode(mode, enabled);
|
||||||
|
|
||||||
return ndk::ScopedAStatus::ok();
|
return ndk::ScopedAStatus::ok();
|
||||||
}
|
}
|
||||||
|
|
|
@ -146,7 +146,7 @@ PowerHintSession::PowerHintSession(int32_t tgid, int32_t uid, const std::vector<
|
||||||
mDescriptor = new AppHintDesc(tgid, uid, threadIds, sUclampCap);
|
mDescriptor = new AppHintDesc(tgid, uid, threadIds, sUclampCap);
|
||||||
mDescriptor->duration = std::chrono::nanoseconds(durationNanos);
|
mDescriptor->duration = std::chrono::nanoseconds(durationNanos);
|
||||||
mStaleHandler = sp<StaleHandler>(new StaleHandler(this, sStaleTimeoutMs));
|
mStaleHandler = sp<StaleHandler>(new StaleHandler(this, sStaleTimeoutMs));
|
||||||
mPowerManagerHandler = sp<MessageHandler>(&PowerSessionManager::getInstance());
|
mPowerManagerHandler = PowerSessionManager::getInstance();
|
||||||
|
|
||||||
if (ATRACE_ENABLED()) {
|
if (ATRACE_ENABLED()) {
|
||||||
std::string sz =
|
std::string sz =
|
||||||
|
@ -157,7 +157,7 @@ PowerHintSession::PowerHintSession(int32_t tgid, int32_t uid, const std::vector<
|
||||||
mDescriptor->uid, reinterpret_cast<uintptr_t>(this) & 0xffff);
|
mDescriptor->uid, reinterpret_cast<uintptr_t>(this) & 0xffff);
|
||||||
ATRACE_INT(sz.c_str(), mDescriptor->is_active.load());
|
ATRACE_INT(sz.c_str(), mDescriptor->is_active.load());
|
||||||
}
|
}
|
||||||
PowerSessionManager::getInstance().addPowerSession(this);
|
PowerSessionManager::getInstance()->addPowerSession(this);
|
||||||
ALOGD("PowerHintSession created: %s", mDescriptor->toString().c_str());
|
ALOGD("PowerHintSession created: %s", mDescriptor->toString().c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -180,7 +180,7 @@ PowerHintSession::~PowerHintSession() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void PowerHintSession::updateUniveralBoostMode() {
|
void PowerHintSession::updateUniveralBoostMode() {
|
||||||
PowerHintMonitor::getInstance().getLooper()->sendMessage(mPowerManagerHandler, NULL);
|
PowerHintMonitor::getInstance()->getLooper()->sendMessage(mPowerManagerHandler, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
int PowerHintSession::setUclamp(int32_t min, int32_t max) {
|
int PowerHintSession::setUclamp(int32_t min, int32_t max) {
|
||||||
|
@ -247,10 +247,10 @@ ndk::ScopedAStatus PowerHintSession::resume() {
|
||||||
}
|
}
|
||||||
|
|
||||||
ndk::ScopedAStatus PowerHintSession::close() {
|
ndk::ScopedAStatus PowerHintSession::close() {
|
||||||
PowerHintMonitor::getInstance().getLooper()->removeMessages(mStaleHandler);
|
PowerHintMonitor::getInstance()->getLooper()->removeMessages(mStaleHandler);
|
||||||
// Reset to (0, 1024) uclamp value -- instead of threads' original setting.
|
// Reset to (0, 1024) uclamp value -- instead of threads' original setting.
|
||||||
setUclamp(0, 1024);
|
setUclamp(0, 1024);
|
||||||
PowerSessionManager::getInstance().removePowerSession(this);
|
PowerSessionManager::getInstance()->removePowerSession(this);
|
||||||
updateUniveralBoostMode();
|
updateUniveralBoostMode();
|
||||||
return ndk::ScopedAStatus::ok();
|
return ndk::ScopedAStatus::ok();
|
||||||
}
|
}
|
||||||
|
@ -291,7 +291,7 @@ ndk::ScopedAStatus PowerHintSession::reportActualWorkDuration(
|
||||||
ALOGE("Error: shouldn't report duration during pause state.");
|
ALOGE("Error: shouldn't report duration during pause state.");
|
||||||
return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_STATE);
|
return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_STATE);
|
||||||
}
|
}
|
||||||
if (PowerHintMonitor::getInstance().isRunning() && isStale()) {
|
if (PowerHintMonitor::getInstance()->isRunning() && isStale()) {
|
||||||
if (ATRACE_ENABLED()) {
|
if (ATRACE_ENABLED()) {
|
||||||
std::string sz = StringPrintf("adpf.%" PRId32 "-%" PRId32 "-%" PRIxPTR "-stale",
|
std::string sz = StringPrintf("adpf.%" PRId32 "-%" PRId32 "-%" PRIxPTR "-stale",
|
||||||
mDescriptor->tgid, mDescriptor->uid,
|
mDescriptor->tgid, mDescriptor->uid,
|
||||||
|
@ -401,7 +401,7 @@ void PowerHintSession::setStale() {
|
||||||
|
|
||||||
void PowerHintSession::StaleHandler::updateStaleTimer() {
|
void PowerHintSession::StaleHandler::updateStaleTimer() {
|
||||||
std::lock_guard<std::mutex> guard(mStaleLock);
|
std::lock_guard<std::mutex> guard(mStaleLock);
|
||||||
if (PowerHintMonitor::getInstance().isRunning()) {
|
if (PowerHintMonitor::getInstance()->isRunning()) {
|
||||||
auto when = getStaleTime();
|
auto when = getStaleTime();
|
||||||
auto now = std::chrono::steady_clock::now();
|
auto now = std::chrono::steady_clock::now();
|
||||||
mLastUpdatedTime.store(now);
|
mLastUpdatedTime.store(now);
|
||||||
|
@ -410,7 +410,7 @@ void PowerHintSession::StaleHandler::updateStaleTimer() {
|
||||||
}
|
}
|
||||||
if (!mIsMonitoringStale.load()) {
|
if (!mIsMonitoringStale.load()) {
|
||||||
auto next = getStaleTime();
|
auto next = getStaleTime();
|
||||||
PowerHintMonitor::getInstance().getLooper()->sendMessageDelayed(
|
PowerHintMonitor::getInstance()->getLooper()->sendMessageDelayed(
|
||||||
duration_cast<nanoseconds>(next - now).count(), this, NULL);
|
duration_cast<nanoseconds>(next - now).count(), this, NULL);
|
||||||
mIsMonitoringStale.store(true);
|
mIsMonitoringStale.store(true);
|
||||||
}
|
}
|
||||||
|
@ -432,7 +432,7 @@ void PowerHintSession::StaleHandler::handleMessage(const Message &) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// Schedule for the next checking time.
|
// Schedule for the next checking time.
|
||||||
PowerHintMonitor::getInstance().getLooper()->sendMessageDelayed(
|
PowerHintMonitor::getInstance()->getLooper()->sendMessageDelayed(
|
||||||
duration_cast<nanoseconds>(when - now).count(), this, NULL);
|
duration_cast<nanoseconds>(when - now).count(), this, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -116,7 +116,7 @@ bool PowerHintMonitor::threadLoop() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
Looper *PowerHintMonitor::getLooper() {
|
sp<Looper> PowerHintMonitor::getLooper() {
|
||||||
return mLooper;
|
return mLooper;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -53,8 +53,8 @@ class PowerSessionManager : public MessageHandler {
|
||||||
void setHintManager(std::shared_ptr<HintManager> const &hint_manager);
|
void setHintManager(std::shared_ptr<HintManager> const &hint_manager);
|
||||||
|
|
||||||
// Singleton
|
// Singleton
|
||||||
static PowerSessionManager &getInstance() {
|
static sp<PowerSessionManager> getInstance() {
|
||||||
static PowerSessionManager instance;
|
static sp<PowerSessionManager> instance = new PowerSessionManager();
|
||||||
return instance;
|
return instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -80,17 +80,17 @@ class PowerHintMonitor : public Thread {
|
||||||
public:
|
public:
|
||||||
void start();
|
void start();
|
||||||
bool threadLoop() override;
|
bool threadLoop() override;
|
||||||
Looper *getLooper();
|
sp<Looper> getLooper();
|
||||||
// Singleton
|
// Singleton
|
||||||
static PowerHintMonitor &getInstance() {
|
static sp<PowerHintMonitor> getInstance() {
|
||||||
static PowerHintMonitor instance;
|
static sp<PowerHintMonitor> instance = new PowerHintMonitor();
|
||||||
return instance;
|
return instance;
|
||||||
}
|
}
|
||||||
PowerHintMonitor(PowerHintMonitor const &) = delete;
|
PowerHintMonitor(PowerHintMonitor const &) = delete;
|
||||||
void operator=(PowerHintMonitor const &) = delete;
|
void operator=(PowerHintMonitor const &) = delete;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Looper *mLooper;
|
sp<Looper> mLooper;
|
||||||
// Singleton
|
// Singleton
|
||||||
PowerHintMonitor() : Thread(false), mLooper(new Looper(true)) {}
|
PowerHintMonitor() : Thread(false), mLooper(new Looper(true)) {}
|
||||||
};
|
};
|
||||||
|
|
|
@ -69,8 +69,8 @@ int main() {
|
||||||
LOG(INFO) << "Power HAL AIDL Service for moto_sm6375 is started.";
|
LOG(INFO) << "Power HAL AIDL Service for moto_sm6375 is started.";
|
||||||
|
|
||||||
if (::android::base::GetIntProperty("vendor.powerhal.adpf.rate", -1) != -1) {
|
if (::android::base::GetIntProperty("vendor.powerhal.adpf.rate", -1) != -1) {
|
||||||
PowerHintMonitor::getInstance().start();
|
PowerHintMonitor::getInstance()->start();
|
||||||
PowerSessionManager::getInstance().setHintManager(hm);
|
PowerSessionManager::getInstance()->setHintManager(hm);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::thread initThread([&]() {
|
std::thread initThread([&]() {
|
||||||
|
|
Loading…
Reference in a new issue