resourcemanager: update clientInfo when create DeathNotifier
In ResourceManagerService::addResource(), if Pid and Uid are unTrusted,
the mClientInfo stored in DeathNotifier is not updated. At this time,
if the process where Pid is located is killed (lowmemorykiller),
it triggers:
DeathNotifier::binderDied() -> ResourceManagerService::removeResource()
It cannot correctly find pid from mMap(which stores callingpid & callinguid),
so noteStopVideo() will not be called, resulting in the video resource
not being released.
Change-Id: Id456e0e64e34b558ff54507ce010048d9559775b
Signed-off-by: guochuang <guochuang@xiaomi.corp-partner.google.com>
diff --git a/services/mediaresourcemanager/ResourceManagerService.cpp b/services/mediaresourcemanager/ResourceManagerService.cpp
index 9c2fb7c..f12a5d6 100644
--- a/services/mediaresourcemanager/ResourceManagerService.cpp
+++ b/services/mediaresourcemanager/ResourceManagerService.cpp
@@ -310,6 +310,7 @@
mServiceLog->add(log);
std::scoped_lock lock{mLock};
+ ClientInfoParcel updatedClientInfo = clientInfo;
if (!mProcessInfo->isPidUidTrusted(pid, uid)) {
pid_t callingPid = IPCThreadState::self()->getCallingPid();
uid_t callingUid = IPCThreadState::self()->getCallingUid();
@@ -317,6 +318,8 @@
__FUNCTION__, pid, uid, callingPid, callingUid);
pid = callingPid;
uid = callingUid;
+ updatedClientInfo.pid = callingPid;
+ updatedClientInfo.uid = callingUid;
}
ResourceInfos& infos = getResourceInfosForEdit(pid, mMap);
ResourceInfo& info = getResourceInfoForEdit(clientInfo, client, infos);
@@ -342,7 +345,7 @@
}
if (info.deathNotifier == nullptr && client != nullptr) {
info.deathNotifier = DeathNotifier::Create(
- client, ref<ResourceManagerService>(), clientInfo);
+ client, ref<ResourceManagerService>(), updatedClientInfo);
}
if (mObserverService != nullptr && !resourceAdded.empty()) {
mObserverService->onResourceAdded(uid, pid, resourceAdded);