adpf: Use one client token per process for all hint sessions
So it doesn't leak when gc is delayed in service process.
Update HintManagerService to allow multiple sessions tied to the same
token.
Bug: 218129784
Test: chrome no longer gets killed
Change-Id: I67a66041cc67d01e4cfcd3ded303a1bed6050f60
diff --git a/native/android/performance_hint.cpp b/native/android/performance_hint.cpp
index 0c36051..65428de 100644
--- a/native/android/performance_hint.cpp
+++ b/native/android/performance_hint.cpp
@@ -48,6 +48,7 @@
static APerformanceHintManager* create(sp<IHintManager> iHintManager);
sp<IHintManager> mHintManager;
+ const sp<IBinder> mToken = sp<BBinder>::make();
const int64_t mPreferredRateNanos;
};
@@ -119,11 +120,10 @@
APerformanceHintSession* APerformanceHintManager::createSession(
const int32_t* threadIds, size_t size, int64_t initialTargetWorkDurationNanos) {
- sp<IBinder> token = sp<BBinder>::make();
std::vector<int32_t> tids(threadIds, threadIds + size);
sp<IHintSession> session;
binder::Status ret =
- mHintManager->createHintSession(token, tids, initialTargetWorkDurationNanos, &session);
+ mHintManager->createHintSession(mToken, tids, initialTargetWorkDurationNanos, &session);
if (!ret.isOk() || !session) {
return nullptr;
}