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
8a20bda9e4
commit
b3ea64c377
@ -90,7 +90,7 @@ Power::Power(std::shared_ptr<HintManager> hm)
|
||||
ndk::ScopedAStatus Power::setMode(Mode type, bool enabled) {
|
||||
LOG(DEBUG) << "Power setMode: " << toString(type) << " to: " << enabled;
|
||||
ATRACE_INT(toString(type).c_str(), enabled);
|
||||
PowerSessionManager::getInstance().updateHintMode(toString(type), enabled);
|
||||
PowerSessionManager::getInstance()->updateHintMode(toString(type), enabled);
|
||||
#ifdef MODE_EXT
|
||||
if (setDeviceSpecificMode(type, enabled)) {
|
||||
return ndk::ScopedAStatus::ok();
|
||||
|
@ -47,7 +47,7 @@ ndk::ScopedAStatus PowerExt::setMode(const std::string &mode, bool enabled) {
|
||||
} else {
|
||||
mHintManager->EndHint(mode);
|
||||
}
|
||||
PowerSessionManager::getInstance().updateHintMode(mode, enabled);
|
||||
PowerSessionManager::getInstance()->updateHintMode(mode, enabled);
|
||||
|
||||
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->duration = std::chrono::nanoseconds(durationNanos);
|
||||
mStaleHandler = sp<StaleHandler>(new StaleHandler(this, sStaleTimeoutMs));
|
||||
mPowerManagerHandler = sp<MessageHandler>(&PowerSessionManager::getInstance());
|
||||
mPowerManagerHandler = PowerSessionManager::getInstance();
|
||||
|
||||
if (ATRACE_ENABLED()) {
|
||||
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);
|
||||
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());
|
||||
}
|
||||
|
||||
@ -180,7 +180,7 @@ PowerHintSession::~PowerHintSession() {
|
||||
}
|
||||
|
||||
void PowerHintSession::updateUniveralBoostMode() {
|
||||
PowerHintMonitor::getInstance().getLooper()->sendMessage(mPowerManagerHandler, NULL);
|
||||
PowerHintMonitor::getInstance()->getLooper()->sendMessage(mPowerManagerHandler, NULL);
|
||||
}
|
||||
|
||||
int PowerHintSession::setUclamp(int32_t min, int32_t max) {
|
||||
@ -247,10 +247,10 @@ ndk::ScopedAStatus PowerHintSession::resume() {
|
||||
}
|
||||
|
||||
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.
|
||||
setUclamp(0, 1024);
|
||||
PowerSessionManager::getInstance().removePowerSession(this);
|
||||
PowerSessionManager::getInstance()->removePowerSession(this);
|
||||
updateUniveralBoostMode();
|
||||
return ndk::ScopedAStatus::ok();
|
||||
}
|
||||
@ -291,7 +291,7 @@ ndk::ScopedAStatus PowerHintSession::reportActualWorkDuration(
|
||||
ALOGE("Error: shouldn't report duration during pause state.");
|
||||
return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_STATE);
|
||||
}
|
||||
if (PowerHintMonitor::getInstance().isRunning() && isStale()) {
|
||||
if (PowerHintMonitor::getInstance()->isRunning() && isStale()) {
|
||||
if (ATRACE_ENABLED()) {
|
||||
std::string sz = StringPrintf("adpf.%" PRId32 "-%" PRId32 "-%" PRIxPTR "-stale",
|
||||
mDescriptor->tgid, mDescriptor->uid,
|
||||
@ -401,7 +401,7 @@ void PowerHintSession::setStale() {
|
||||
|
||||
void PowerHintSession::StaleHandler::updateStaleTimer() {
|
||||
std::lock_guard<std::mutex> guard(mStaleLock);
|
||||
if (PowerHintMonitor::getInstance().isRunning()) {
|
||||
if (PowerHintMonitor::getInstance()->isRunning()) {
|
||||
auto when = getStaleTime();
|
||||
auto now = std::chrono::steady_clock::now();
|
||||
mLastUpdatedTime.store(now);
|
||||
@ -410,7 +410,7 @@ void PowerHintSession::StaleHandler::updateStaleTimer() {
|
||||
}
|
||||
if (!mIsMonitoringStale.load()) {
|
||||
auto next = getStaleTime();
|
||||
PowerHintMonitor::getInstance().getLooper()->sendMessageDelayed(
|
||||
PowerHintMonitor::getInstance()->getLooper()->sendMessageDelayed(
|
||||
duration_cast<nanoseconds>(next - now).count(), this, NULL);
|
||||
mIsMonitoringStale.store(true);
|
||||
}
|
||||
@ -432,7 +432,7 @@ void PowerHintSession::StaleHandler::handleMessage(const Message &) {
|
||||
return;
|
||||
}
|
||||
// Schedule for the next checking time.
|
||||
PowerHintMonitor::getInstance().getLooper()->sendMessageDelayed(
|
||||
PowerHintMonitor::getInstance()->getLooper()->sendMessageDelayed(
|
||||
duration_cast<nanoseconds>(when - now).count(), this, NULL);
|
||||
}
|
||||
|
||||
|
@ -116,7 +116,7 @@ bool PowerHintMonitor::threadLoop() {
|
||||
return true;
|
||||
}
|
||||
|
||||
Looper *PowerHintMonitor::getLooper() {
|
||||
sp<Looper> PowerHintMonitor::getLooper() {
|
||||
return mLooper;
|
||||
}
|
||||
|
||||
|
@ -53,8 +53,8 @@ class PowerSessionManager : public MessageHandler {
|
||||
void setHintManager(std::shared_ptr<HintManager> const &hint_manager);
|
||||
|
||||
// Singleton
|
||||
static PowerSessionManager &getInstance() {
|
||||
static PowerSessionManager instance;
|
||||
static sp<PowerSessionManager> getInstance() {
|
||||
static sp<PowerSessionManager> instance = new PowerSessionManager();
|
||||
return instance;
|
||||
}
|
||||
|
||||
@ -80,17 +80,17 @@ class PowerHintMonitor : public Thread {
|
||||
public:
|
||||
void start();
|
||||
bool threadLoop() override;
|
||||
Looper *getLooper();
|
||||
sp<Looper> getLooper();
|
||||
// Singleton
|
||||
static PowerHintMonitor &getInstance() {
|
||||
static PowerHintMonitor instance;
|
||||
static sp<PowerHintMonitor> getInstance() {
|
||||
static sp<PowerHintMonitor> instance = new PowerHintMonitor();
|
||||
return instance;
|
||||
}
|
||||
PowerHintMonitor(PowerHintMonitor const &) = delete;
|
||||
void operator=(PowerHintMonitor const &) = delete;
|
||||
|
||||
private:
|
||||
Looper *mLooper;
|
||||
sp<Looper> mLooper;
|
||||
// Singleton
|
||||
PowerHintMonitor() : Thread(false), mLooper(new Looper(true)) {}
|
||||
};
|
||||
|
@ -69,8 +69,8 @@ int main() {
|
||||
LOG(INFO) << "Xiaomi Power HAL AIDL Service with Extension is started.";
|
||||
|
||||
if (::android::base::GetIntProperty("vendor.powerhal.adpf.rate", -1) != -1) {
|
||||
PowerHintMonitor::getInstance().start();
|
||||
PowerSessionManager::getInstance().setHintManager(hm);
|
||||
PowerHintMonitor::getInstance()->start();
|
||||
PowerSessionManager::getInstance()->setHintManager(hm);
|
||||
}
|
||||
|
||||
std::thread initThread([&]() {
|
||||
|
Loading…
Reference in New Issue
Block a user