resourcemanager: importance based resource reclaim
Extend the reclaim policy by implementing codec importance
based resource reclaim.
User (of the codec) will assign codec importance to
distinguish important codecs from less important.
Upon resource conflict, the Resource Manager Service
reclaims a codec with the lowest importance (lower than that of
the requesting codec) from the same process (if there is one).
Bug: 289097671
Test: atest android.media.misc.cts.ResourceManagerTest
atest android.media.misc.cts.ResourceManagerMultiTest
/data/nativetest64/ResourceManagerService_test/ResourceManagerService_test
/data/nativetest64/ResourceObserverService_test/ResourceObserverService_test
Change-Id: I383d88c852edae53d3eca24d7b563f133a63acaa
diff --git a/services/mediaresourcemanager/ResourceManagerService.cpp b/services/mediaresourcemanager/ResourceManagerService.cpp
index 4bdb6e1..2bcfe27 100644
--- a/services/mediaresourcemanager/ResourceManagerService.cpp
+++ b/services/mediaresourcemanager/ResourceManagerService.cpp
@@ -492,9 +492,10 @@
}
bool ResourceManagerService::getTargetClients(
- int32_t callingPid,
+ const ClientInfoParcel& clientInfo,
const std::vector<MediaResourceParcel>& resources,
std::vector<ClientInfo>& targetClients) {
+ int32_t callingPid = clientInfo.pid;
std::scoped_lock lock{mLock};
if (!mProcessInfo->isPidTrusted(callingPid)) {
pid_t actualCallingPid = IPCThreadState::self()->getCallingPid();
@@ -598,10 +599,9 @@
Status ResourceManagerService::reclaimResource(const ClientInfoParcel& clientInfo,
const std::vector<MediaResourceParcel>& resources, bool* _aidl_return) {
- int32_t callingPid = clientInfo.pid;
std::string clientName = clientInfo.name;
String8 log = String8::format("reclaimResource(callingPid %d, uid %d resources %s)",
- callingPid, clientInfo.uid, getString(resources).c_str());
+ clientInfo.pid, clientInfo.uid, getString(resources).c_str());
mServiceLog->add(log);
*_aidl_return = false;
@@ -611,7 +611,7 @@
}
std::vector<ClientInfo> targetClients;
- if (!getTargetClients(callingPid, resources, targetClients)) {
+ if (!getTargetClients(clientInfo, resources, targetClients)) {
// Nothing to reclaim from.
ALOGI("%s: There aren't any clients to reclaim from", __func__);
return Status::ok();