Add a new image codec domain and subdivide codec resource management by domain
This CL also replaces verifyClients, which obfuscates test failure
messages, with explicit expects and updates whitespace and newlines
in method signatures to Android coding conventions.
Bug: 209803992
Test: atest ResourceManagerService_test
Change-Id: I6208d0f1d052334840926e8c2d120013d4aeba7d
diff --git a/media/libmedia/include/media/MediaResource.h b/media/libmedia/include/media/MediaResource.h
index 4712528..68cc25e 100644
--- a/media/libmedia/include/media/MediaResource.h
+++ b/media/libmedia/include/media/MediaResource.h
@@ -62,6 +62,7 @@
case MediaResource::SubType::kUnspecifiedSubType: return "unspecified";
case MediaResource::SubType::kAudioCodec: return "audio-codec";
case MediaResource::SubType::kVideoCodec: return "video-codec";
+ case MediaResource::SubType::kImageCodec: return "image-codec";
default: return def;
}
}
diff --git a/services/mediaresourcemanager/IMediaResourceMonitor.h b/services/mediaresourcemanager/IMediaResourceMonitor.h
index f92d557..4dd87e1 100644
--- a/services/mediaresourcemanager/IMediaResourceMonitor.h
+++ b/services/mediaresourcemanager/IMediaResourceMonitor.h
@@ -32,6 +32,7 @@
enum {
TYPE_VIDEO_CODEC = 0,
TYPE_AUDIO_CODEC = 1,
+ TYPE_IMAGE_CODEC = 2,
};
virtual void notifyResourceGranted(/*in*/ int32_t pid, /*in*/ const int32_t type) = 0;
diff --git a/services/mediaresourcemanager/ResourceManagerService.cpp b/services/mediaresourcemanager/ResourceManagerService.cpp
index 953686b..d50f8d5 100644
--- a/services/mediaresourcemanager/ResourceManagerService.cpp
+++ b/services/mediaresourcemanager/ResourceManagerService.cpp
@@ -51,8 +51,8 @@
class DeathNotifier : public RefBase {
public:
- DeathNotifier(const std::shared_ptr<ResourceManagerService> &service,
- int pid, int64_t clientId);
+ DeathNotifier(const std::shared_ptr<ResourceManagerService> &service, int pid,
+ int64_t clientId);
virtual ~DeathNotifier() {}
@@ -130,27 +130,48 @@
return itemsStr;
}
-static bool hasResourceType(MediaResource::Type type, const ResourceList& resources) {
+static bool hasResourceType(MediaResource::Type type, MediaResource::SubType subType,
+ MediaResourceParcel resource) {
+ if (type != resource.type) {
+ return false;
+ }
+ switch (type) {
+ // Codec subtypes (e.g. video vs. audio) are each considered separate resources, so
+ // compare the subtypes as well.
+ case MediaResource::Type::kSecureCodec:
+ case MediaResource::Type::kNonSecureCodec:
+ if (resource.subType == subType) {
+ return true;
+ }
+ break;
+ // Non-codec resources are not segregated by the subtype (e.g. video vs. audio).
+ default:
+ return true;
+ }
+ return false;
+}
+
+static bool hasResourceType(MediaResource::Type type, MediaResource::SubType subType,
+ const ResourceList& resources) {
for (auto it = resources.begin(); it != resources.end(); it++) {
- if (it->second.type == type) {
+ if (hasResourceType(type, subType, it->second)) {
return true;
}
}
return false;
}
-static bool hasResourceType(MediaResource::Type type, const ResourceInfos& infos) {
+static bool hasResourceType(MediaResource::Type type, MediaResource::SubType subType,
+ const ResourceInfos& infos) {
for (size_t i = 0; i < infos.size(); ++i) {
- if (hasResourceType(type, infos[i].resources)) {
+ if (hasResourceType(type, subType, infos[i].resources)) {
return true;
}
}
return false;
}
-static ResourceInfos& getResourceInfosForEdit(
- int pid,
- PidResourceInfosMap& map) {
+static ResourceInfos& getResourceInfosForEdit(int pid, PidResourceInfosMap& map) {
ssize_t index = map.indexOfKey(pid);
if (index < 0) {
// new pid
@@ -161,11 +182,8 @@
return map.editValueFor(pid);
}
-static ResourceInfo& getResourceInfoForEdit(
- uid_t uid,
- int64_t clientId,
- const std::shared_ptr<IResourceManagerClient>& client,
- ResourceInfos& infos) {
+static ResourceInfo& getResourceInfoForEdit(uid_t uid, int64_t clientId,
+ const std::shared_ptr<IResourceManagerClient>& client, ResourceInfos& infos) {
ssize_t index = infos.indexOfKey(clientId);
if (index < 0) {
@@ -188,17 +206,24 @@
if (binder != NULL) {
sp<IMediaResourceMonitor> service = interface_cast<IMediaResourceMonitor>(binder);
for (size_t i = 0; i < resources.size(); ++i) {
- if (resources[i].subType == MediaResource::SubType::kAudioCodec) {
- service->notifyResourceGranted(pid, IMediaResourceMonitor::TYPE_AUDIO_CODEC);
- } else if (resources[i].subType == MediaResource::SubType::kVideoCodec) {
- service->notifyResourceGranted(pid, IMediaResourceMonitor::TYPE_VIDEO_CODEC);
+ switch (resources[i].subType) {
+ case MediaResource::SubType::kAudioCodec:
+ service->notifyResourceGranted(pid, IMediaResourceMonitor::TYPE_AUDIO_CODEC);
+ break;
+ case MediaResource::SubType::kVideoCodec:
+ service->notifyResourceGranted(pid, IMediaResourceMonitor::TYPE_VIDEO_CODEC);
+ break;
+ case MediaResource::SubType::kImageCodec:
+ service->notifyResourceGranted(pid, IMediaResourceMonitor::TYPE_IMAGE_CODEC);
+ break;
+ case MediaResource::SubType::kUnspecifiedSubType:
+ break;
}
}
}
}
-binder_status_t ResourceManagerService::dump(
- int fd, const char** /*args*/, uint32_t /*numArgs*/) {
+binder_status_t ResourceManagerService::dump(int fd, const char** /*args*/, uint32_t /*numArgs*/) {
String8 result;
if (checkCallingPermission(String16("android.permission.DUMP")) == false) {
@@ -275,8 +300,7 @@
return OK;
}
-struct SystemCallbackImpl :
- public ResourceManagerService::SystemCallbackInterface {
+struct SystemCallbackImpl : public ResourceManagerService::SystemCallbackInterface {
SystemCallbackImpl() : mClientToken(new BBinder()) {}
virtual void noteStartVideo(int uid) override {
@@ -303,8 +327,7 @@
ResourceManagerService::ResourceManagerService()
: ResourceManagerService(new ProcessInfo(), new SystemCallbackImpl()) {}
-ResourceManagerService::ResourceManagerService(
- const sp<ProcessInfoInterface> &processInfo,
+ResourceManagerService::ResourceManagerService(const sp<ProcessInfoInterface> &processInfo,
const sp<SystemCallbackInterface> &systemResource)
: mProcessInfo(processInfo),
mSystemCB(systemResource),
@@ -362,8 +385,8 @@
return Status::ok();
}
-void ResourceManagerService::onFirstAdded(
- const MediaResourceParcel& resource, const ResourceInfo& clientInfo) {
+void ResourceManagerService::onFirstAdded(const MediaResourceParcel& resource,
+ const ResourceInfo& clientInfo) {
// first time added
if (resource.type == MediaResource::Type::kCpuBoost
&& resource.subType == MediaResource::SubType::kUnspecifiedSubType) {
@@ -380,8 +403,8 @@
}
}
-void ResourceManagerService::onLastRemoved(
- const MediaResourceParcel& resource, const ResourceInfo& clientInfo) {
+void ResourceManagerService::onLastRemoved(const MediaResourceParcel& resource,
+ const ResourceInfo& clientInfo) {
if (resource.type == MediaResource::Type::kCpuBoost
&& resource.subType == MediaResource::SubType::kUnspecifiedSubType
&& mCpuBoostCount > 0) {
@@ -394,8 +417,8 @@
}
}
-void ResourceManagerService::mergeResources(
- MediaResourceParcel& r1, const MediaResourceParcel& r2) {
+void ResourceManagerService::mergeResources(MediaResourceParcel& r1,
+ const MediaResourceParcel& r2) {
// The resource entry on record is maintained to be in [0,INT64_MAX].
// Clamp if merging in the new resource value causes it to go out of bound.
// Note that the new resource value could be negative, eg.DrmSession, the
@@ -411,10 +434,7 @@
}
}
-Status ResourceManagerService::addResource(
- int32_t pid,
- int32_t uid,
- int64_t clientId,
+Status ResourceManagerService::addResource(int32_t pid, int32_t uid, int64_t clientId,
const std::shared_ptr<IResourceManagerClient>& client,
const std::vector<MediaResourceParcel>& resources) {
String8 log = String8::format("addResource(pid %d, clientId %lld, resources %s)",
@@ -473,8 +493,7 @@
return Status::ok();
}
-Status ResourceManagerService::removeResource(
- int32_t pid, int64_t clientId,
+Status ResourceManagerService::removeResource(int32_t pid, int64_t clientId,
const std::vector<MediaResourceParcel>& resources) {
String8 log = String8::format("removeResource(pid %d, clientId %lld, resources %s)",
pid, (long long) clientId, getString(resources).string());
@@ -583,22 +602,19 @@
return Status::ok();
}
-void ResourceManagerService::getClientForResource_l(
- int callingPid, const MediaResourceParcel *res,
+void ResourceManagerService::getClientForResource_l(int callingPid, const MediaResourceParcel *res,
Vector<std::shared_ptr<IResourceManagerClient>> *clients) {
if (res == NULL) {
return;
}
std::shared_ptr<IResourceManagerClient> client;
- if (getLowestPriorityBiggestClient_l(callingPid, res->type, &client)) {
+ if (getLowestPriorityBiggestClient_l(callingPid, res->type, res->subType, &client)) {
clients->push_back(client);
}
}
-Status ResourceManagerService::reclaimResource(
- int32_t callingPid,
- const std::vector<MediaResourceParcel>& resources,
- bool* _aidl_return) {
+Status ResourceManagerService::reclaimResource(int32_t callingPid,
+ const std::vector<MediaResourceParcel>& resources, bool* _aidl_return) {
String8 log = String8::format("reclaimResource(callingPid %d, resources %s)",
callingPid, getString(resources).string());
mServiceLog->add(log);
@@ -618,34 +634,43 @@
const MediaResourceParcel *graphicMemory = NULL;
const MediaResourceParcel *drmSession = NULL;
for (size_t i = 0; i < resources.size(); ++i) {
- MediaResource::Type type = resources[i].type;
- if (resources[i].type == MediaResource::Type::kSecureCodec) {
- secureCodec = &resources[i];
- } else if (type == MediaResource::Type::kNonSecureCodec) {
- nonSecureCodec = &resources[i];
- } else if (type == MediaResource::Type::kGraphicMemory) {
- graphicMemory = &resources[i];
- } else if (type == MediaResource::Type::kDrmSession) {
- drmSession = &resources[i];
+ switch (resources[i].type) {
+ case MediaResource::Type::kSecureCodec:
+ secureCodec = &resources[i];
+ break;
+ case MediaResource::Type::kNonSecureCodec:
+ nonSecureCodec = &resources[i];
+ break;
+ case MediaResource::Type::kGraphicMemory:
+ graphicMemory = &resources[i];
+ break;
+ case MediaResource::Type::kDrmSession:
+ drmSession = &resources[i];
+ break;
+ default:
+ break;
}
}
// first pass to handle secure/non-secure codec conflict
if (secureCodec != NULL) {
if (!mSupportsMultipleSecureCodecs) {
- if (!getAllClients_l(callingPid, MediaResource::Type::kSecureCodec, &clients)) {
+ if (!getAllClients_l(callingPid, MediaResource::Type::kSecureCodec,
+ secureCodec->subType, &clients)) {
return Status::ok();
}
}
if (!mSupportsSecureWithNonSecureCodec) {
- if (!getAllClients_l(callingPid, MediaResource::Type::kNonSecureCodec, &clients)) {
+ if (!getAllClients_l(callingPid, MediaResource::Type::kNonSecureCodec,
+ secureCodec->subType, &clients)) {
return Status::ok();
}
}
}
if (nonSecureCodec != NULL) {
if (!mSupportsSecureWithNonSecureCodec) {
- if (!getAllClients_l(callingPid, MediaResource::Type::kSecureCodec, &clients)) {
+ if (!getAllClients_l(callingPid, MediaResource::Type::kSecureCodec,
+ nonSecureCodec->subType, &clients)) {
return Status::ok();
}
}
@@ -681,11 +706,11 @@
}
}
- *_aidl_return = reclaimInternal(clients);
+ *_aidl_return = reclaimUnconditionallyFrom(clients);
return Status::ok();
}
-bool ResourceManagerService::reclaimInternal(
+bool ResourceManagerService::reclaimUnconditionallyFrom(
const Vector<std::shared_ptr<IResourceManagerClient>> &clients) {
if (clients.size() == 0) {
return false;
@@ -732,9 +757,7 @@
return false;
}
-Status ResourceManagerService::overridePid(
- int originalPid,
- int newPid) {
+Status ResourceManagerService::overridePid(int originalPid, int newPid) {
String8 log = String8::format("overridePid(originalPid %d, newPid %d)",
originalPid, newPid);
mServiceLog->add(log);
@@ -763,9 +786,7 @@
}
Status ResourceManagerService::overrideProcessInfo(
- const std::shared_ptr<IResourceManagerClient>& client,
- int pid,
- int procState,
+ const std::shared_ptr<IResourceManagerClient>& client, int pid, int procState,
int oomScore) {
String8 log = String8::format("overrideProcessInfo(pid %d, procState %d, oomScore %d)",
pid, procState, oomScore);
@@ -799,8 +820,8 @@
return Status::ok();
}
-uintptr_t ResourceManagerService::addCookieAndLink_l(
- ::ndk::SpAIBinder binder, const sp<DeathNotifier>& notifier) {
+uintptr_t ResourceManagerService::addCookieAndLink_l(::ndk::SpAIBinder binder,
+ const sp<DeathNotifier>& notifier) {
std::scoped_lock lock{sCookieLock};
uintptr_t cookie;
@@ -813,8 +834,7 @@
return cookie;
}
-void ResourceManagerService::removeCookieAndUnlink_l(
- ::ndk::SpAIBinder binder, uintptr_t cookie) {
+void ResourceManagerService::removeCookieAndUnlink_l(::ndk::SpAIBinder binder, uintptr_t cookie) {
std::scoped_lock lock{sCookieLock};
AIBinder_unlinkToDeath(binder.get(), mDeathRecipient.get(), (void*)cookie);
sCookieToDeathNotifierMap.erase(cookie);
@@ -889,16 +909,34 @@
MediaResource::Type::kNonSecureCodec,
MediaResource::Type::kGraphicMemory,
MediaResource::Type::kDrmSession}) {
- std::shared_ptr<IResourceManagerClient> client;
- if (getBiggestClient_l(pid, type, &client, true /* pendingRemovalOnly */)) {
- clients.add(client);
- break;
+ switch (type) {
+ // Codec resources are segregated by audio, video and image domains.
+ case MediaResource::Type::kSecureCodec:
+ case MediaResource::Type::kNonSecureCodec:
+ for (MediaResource::SubType subType : {MediaResource::SubType::kAudioCodec,
+ MediaResource::SubType::kVideoCodec,
+ MediaResource::SubType::kImageCodec}) {
+ std::shared_ptr<IResourceManagerClient> client;
+ if (getBiggestClientPendingRemoval_l(pid, type, subType, &client)) {
+ clients.add(client);
+ continue;
+ }
+ }
+ break;
+ // Non-codec resources are shared by audio, video and image codecs (no subtype).
+ default:
+ std::shared_ptr<IResourceManagerClient> client;
+ if (getBiggestClientPendingRemoval_l(pid, type,
+ MediaResource::SubType::kUnspecifiedSubType, &client)) {
+ clients.add(client);
+ }
+ break;
}
}
}
if (!clients.empty()) {
- reclaimInternal(clients);
+ reclaimUnconditionallyFrom(clients);
}
return Status::ok();
}
@@ -915,14 +953,13 @@
return mProcessInfo->getPriority(newPid, priority);
}
-bool ResourceManagerService::getAllClients_l(
- int callingPid, MediaResource::Type type,
- Vector<std::shared_ptr<IResourceManagerClient>> *clients) {
+bool ResourceManagerService::getAllClients_l(int callingPid, MediaResource::Type type,
+ MediaResource::SubType subType, Vector<std::shared_ptr<IResourceManagerClient>> *clients) {
Vector<std::shared_ptr<IResourceManagerClient>> temp;
for (size_t i = 0; i < mMap.size(); ++i) {
ResourceInfos &infos = mMap.editValueAt(i);
for (size_t j = 0; j < infos.size(); ++j) {
- if (hasResourceType(type, infos[j].resources)) {
+ if (hasResourceType(type, subType, infos[j].resources)) {
if (!isCallingPriorityHigher_l(callingPid, mMap.keyAt(i))) {
// some higher/equal priority process owns the resource,
// this request can't be fulfilled.
@@ -942,8 +979,8 @@
return true;
}
-bool ResourceManagerService::getLowestPriorityBiggestClient_l(
- int callingPid, MediaResource::Type type,
+bool ResourceManagerService::getLowestPriorityBiggestClient_l(int callingPid,
+ MediaResource::Type type, MediaResource::SubType subType,
std::shared_ptr<IResourceManagerClient> *client) {
int lowestPriorityPid;
int lowestPriority;
@@ -951,7 +988,7 @@
// Before looking into other processes, check if we have clients marked for
// pending removal in the same process.
- if (getBiggestClient_l(callingPid, type, client, true /* pendingRemovalOnly */)) {
+ if (getBiggestClientPendingRemoval_l(callingPid, type, subType, client)) {
return true;
}
if (!getPriority_l(callingPid, &callingPriority)) {
@@ -959,7 +996,7 @@
callingPid);
return false;
}
- if (!getLowestPriorityPid_l(type, &lowestPriorityPid, &lowestPriority)) {
+ if (!getLowestPriorityPid_l(type, subType, &lowestPriorityPid, &lowestPriority)) {
return false;
}
if (lowestPriority <= callingPriority) {
@@ -968,14 +1005,14 @@
return false;
}
- if (!getBiggestClient_l(lowestPriorityPid, type, client)) {
+ if (!getBiggestClient_l(lowestPriorityPid, type, subType, client)) {
return false;
}
return true;
}
-bool ResourceManagerService::getLowestPriorityPid_l(
- MediaResource::Type type, int *lowestPriorityPid, int *lowestPriority) {
+bool ResourceManagerService::getLowestPriorityPid_l(MediaResource::Type type,
+ MediaResource::SubType subType, int *lowestPriorityPid, int *lowestPriority) {
int pid = -1;
int priority = -1;
for (size_t i = 0; i < mMap.size(); ++i) {
@@ -983,7 +1020,7 @@
// no client on this process.
continue;
}
- if (!hasResourceType(type, mMap.valueAt(i))) {
+ if (!hasResourceType(type, subType, mMap.valueAt(i))) {
// doesn't have the requested resource type
continue;
}
@@ -1021,8 +1058,13 @@
return (callingPidPriority < priority);
}
-bool ResourceManagerService::getBiggestClient_l(
- int pid, MediaResource::Type type, std::shared_ptr<IResourceManagerClient> *client,
+bool ResourceManagerService::getBiggestClientPendingRemoval_l(int pid, MediaResource::Type type,
+ MediaResource::SubType subType, std::shared_ptr<IResourceManagerClient> *client) {
+ return getBiggestClient_l(pid, type, subType, client, true /* pendingRemovalOnly */);
+}
+
+bool ResourceManagerService::getBiggestClient_l(int pid, MediaResource::Type type,
+ MediaResource::SubType subType, std::shared_ptr<IResourceManagerClient> *client,
bool pendingRemovalOnly) {
ssize_t index = mMap.indexOfKey(pid);
if (index < 0) {
@@ -1041,7 +1083,7 @@
}
for (auto it = resources.begin(); it != resources.end(); it++) {
const MediaResourceParcel &resource = it->second;
- if (resource.type == type) {
+ if (hasResourceType(type, subType, resource)) {
if (resource.value > largestValue) {
largestValue = resource.value;
clientTemp = infos[i].client;
@@ -1052,8 +1094,8 @@
if (clientTemp == NULL) {
ALOGE_IF(!pendingRemovalOnly,
- "getBiggestClient_l: can't find resource type %s for pid %d",
- asString(type), pid);
+ "getBiggestClient_l: can't find resource type %s and subtype %s for pid %d",
+ asString(type), asString(subType), pid);
return false;
}
diff --git a/services/mediaresourcemanager/ResourceManagerService.h b/services/mediaresourcemanager/ResourceManagerService.h
index 9c2636e..6551371 100644
--- a/services/mediaresourcemanager/ResourceManagerService.h
+++ b/services/mediaresourcemanager/ResourceManagerService.h
@@ -77,26 +77,19 @@
int /*fd*/, const char** /*args*/, uint32_t /*numArgs*/);
ResourceManagerService();
- explicit ResourceManagerService(
- const sp<ProcessInfoInterface> &processInfo,
+ explicit ResourceManagerService(const sp<ProcessInfoInterface> &processInfo,
const sp<SystemCallbackInterface> &systemResource);
virtual ~ResourceManagerService();
- void setObserverService(
- const std::shared_ptr<ResourceObserverService>& observerService);
+ void setObserverService(const std::shared_ptr<ResourceObserverService>& observerService);
// IResourceManagerService interface
Status config(const std::vector<MediaResourcePolicyParcel>& policies) override;
- Status addResource(
- int32_t pid,
- int32_t uid,
- int64_t clientId,
+ Status addResource(int32_t pid, int32_t uid, int64_t clientId,
const std::shared_ptr<IResourceManagerClient>& client,
const std::vector<MediaResourceParcel>& resources) override;
- Status removeResource(
- int32_t pid,
- int64_t clientId,
+ Status removeResource(int32_t pid, int64_t clientId,
const std::vector<MediaResourceParcel>& resources) override;
Status removeClient(int32_t pid, int64_t clientId) override;
@@ -104,20 +97,13 @@
// Tries to reclaim resource from processes with lower priority than the calling process
// according to the requested resources.
// Returns true if any resource has been reclaimed, otherwise returns false.
- Status reclaimResource(
- int32_t callingPid,
- const std::vector<MediaResourceParcel>& resources,
+ Status reclaimResource(int32_t callingPid, const std::vector<MediaResourceParcel>& resources,
bool* _aidl_return) override;
- Status overridePid(
- int originalPid,
- int newPid) override;
+ Status overridePid(int originalPid, int newPid) override;
- Status overrideProcessInfo(
- const std::shared_ptr<IResourceManagerClient>& client,
- int pid,
- int procState,
- int oomScore) override;
+ Status overrideProcessInfo(const std::shared_ptr<IResourceManagerClient>& client, int pid,
+ int procState, int oomScore) override;
Status markClientForPendingRemoval(int32_t pid, int64_t clientId) override;
@@ -132,30 +118,34 @@
// Reclaims resources from |clients|. Returns true if reclaim succeeded
// for all clients.
- bool reclaimInternal(
- const Vector<std::shared_ptr<IResourceManagerClient>> &clients);
+ bool reclaimUnconditionallyFrom(const Vector<std::shared_ptr<IResourceManagerClient>> &clients);
// Gets the list of all the clients who own the specified resource type.
// Returns false if any client belongs to a process with higher priority than the
// calling process. The clients will remain unchanged if returns false.
- bool getAllClients_l(int callingPid, MediaResource::Type type,
+ bool getAllClients_l(int callingPid, MediaResource::Type type, MediaResource::SubType subType,
Vector<std::shared_ptr<IResourceManagerClient>> *clients);
// Gets the client who owns specified resource type from lowest possible priority process.
// Returns false if the calling process priority is not higher than the lowest process
// priority. The client will remain unchanged if returns false.
bool getLowestPriorityBiggestClient_l(int callingPid, MediaResource::Type type,
- std::shared_ptr<IResourceManagerClient> *client);
+ MediaResource::SubType subType, std::shared_ptr<IResourceManagerClient> *client);
// Gets lowest priority process that has the specified resource type.
// Returns false if failed. The output parameters will remain unchanged if failed.
- bool getLowestPriorityPid_l(MediaResource::Type type, int *pid, int *priority);
+ bool getLowestPriorityPid_l(MediaResource::Type type, MediaResource::SubType subType, int *pid,
+ int *priority);
// Gets the client who owns biggest piece of specified resource type from pid.
- // Returns false if failed. The client will remain unchanged if failed.
- bool getBiggestClient_l(int pid, MediaResource::Type type,
+ // Returns false with no change to client if there are no clients holdiing resources of thisi
+ // type.
+ bool getBiggestClient_l(int pid, MediaResource::Type type, MediaResource::SubType subType,
std::shared_ptr<IResourceManagerClient> *client,
bool pendingRemovalOnly = false);
+ // Same method as above, but with pendingRemovalOnly as true.
+ bool getBiggestClientPendingRemoval_l(int pid, MediaResource::Type type,
+ MediaResource::SubType subType, std::shared_ptr<IResourceManagerClient> *client);
bool isCallingPriorityHigher_l(int callingPid, int pid);
diff --git a/services/mediaresourcemanager/aidl/android/media/MediaResourceSubType.aidl b/services/mediaresourcemanager/aidl/android/media/MediaResourceSubType.aidl
index af2ba68..72a0551 100644
--- a/services/mediaresourcemanager/aidl/android/media/MediaResourceSubType.aidl
+++ b/services/mediaresourcemanager/aidl/android/media/MediaResourceSubType.aidl
@@ -26,4 +26,5 @@
kUnspecifiedSubType = 0,
kAudioCodec = 1,
kVideoCodec = 2,
+ kImageCodec = 3,
}
diff --git a/services/mediaresourcemanager/test/ResourceManagerServiceTestUtils.h b/services/mediaresourcemanager/test/ResourceManagerServiceTestUtils.h
index 8e29312..1624477 100644
--- a/services/mediaresourcemanager/test/ResourceManagerServiceTestUtils.h
+++ b/services/mediaresourcemanager/test/ResourceManagerServiceTestUtils.h
@@ -119,11 +119,11 @@
struct TestClient : public BnResourceManagerClient {
TestClient(int pid, const std::shared_ptr<ResourceManagerService> &service)
- : mReclaimed(false), mPid(pid), mService(service) {}
+ : mPid(pid), mService(service) {}
Status reclaimResource(bool* _aidl_return) override {
mService->removeClient(mPid, getId(ref<TestClient>()));
- mReclaimed = true;
+ mWasReclaimResourceCalled = true;
*_aidl_return = true;
return Status::ok();
}
@@ -133,18 +133,16 @@
return Status::ok();
}
- bool reclaimed() const {
- return mReclaimed;
- }
-
- void reset() {
- mReclaimed = false;
+ bool checkIfReclaimedAndReset() {
+ bool wasReclaimResourceCalled = mWasReclaimResourceCalled;
+ mWasReclaimResourceCalled = false;
+ return wasReclaimResourceCalled;
}
virtual ~TestClient() {}
private:
- bool mReclaimed;
+ bool mWasReclaimResourceCalled = false;
int mPid;
std::shared_ptr<ResourceManagerService> mService;
DISALLOW_EVIL_CONSTRUCTORS(TestClient);
@@ -166,14 +164,30 @@
return lhs.type == rhs.type && lhs.arg == rhs.arg;
}
-#define CHECK_STATUS_TRUE(condition) \
- EXPECT_TRUE((condition).isOk() && (result))
+// The condition is expected to return a status but also update the local
+// result variable.
+#define CHECK_STATUS_TRUE(conditionThatUpdatesResult) \
+ do { \
+ bool result = false; \
+ EXPECT_TRUE((conditionThatUpdatesResult).isOk()); \
+ EXPECT_TRUE(result); \
+ } while(false)
-#define CHECK_STATUS_FALSE(condition) \
- EXPECT_TRUE((condition).isOk() && !(result))
+// The condition is expected to return a status but also update the local
+// result variable.
+#define CHECK_STATUS_FALSE(conditionThatUpdatesResult) \
+ do { \
+ bool result = true; \
+ EXPECT_TRUE((conditionThatUpdatesResult).isOk()); \
+ EXPECT_FALSE(result); \
+ } while(false)
class ResourceManagerServiceTestBase : public ::testing::Test {
public:
+ static TestClient* toTestClient(std::shared_ptr<IResourceManagerClient> testClient) {
+ return static_cast<TestClient*>(testClient.get());
+ }
+
ResourceManagerServiceTestBase()
: mSystemCB(new TestSystemCallback()),
mService(::ndk::SharedRefBase::make<ResourceManagerService>(
@@ -183,6 +197,10 @@
mTestClient3(::ndk::SharedRefBase::make<TestClient>(kTestPid2, mService)) {
}
+ std::shared_ptr<IResourceManagerClient> createTestClient(int pid) {
+ return ::ndk::SharedRefBase::make<TestClient>(pid, mService);
+ }
+
sp<TestSystemCallback> mSystemCB;
std::shared_ptr<ResourceManagerService> mService;
std::shared_ptr<IResourceManagerClient> mTestClient1;
diff --git a/services/mediaresourcemanager/test/ResourceManagerService_test.cpp b/services/mediaresourcemanager/test/ResourceManagerService_test.cpp
index a029d45..8739c3b 100644
--- a/services/mediaresourcemanager/test/ResourceManagerService_test.cpp
+++ b/services/mediaresourcemanager/test/ResourceManagerService_test.cpp
@@ -25,22 +25,60 @@
namespace android {
class ResourceManagerServiceTest : public ResourceManagerServiceTestBase {
+private:
+ static MediaResource createSecureVideoCodecResource(int amount = 1) {
+ return MediaResource(MediaResource::Type::kSecureCodec,
+ MediaResource::SubType::kVideoCodec, amount);
+ }
+
+ static MediaResource createNonSecureVideoCodecResource(int amount = 1) {
+ return MediaResource(MediaResource::Type::kNonSecureCodec,
+ MediaResource::SubType::kVideoCodec, amount);
+ }
+
+ static MediaResource createSecureAudioCodecResource(int amount = 1) {
+ return MediaResource(MediaResource::Type::kSecureCodec,
+ MediaResource::SubType::kAudioCodec, amount);
+ }
+
+ static MediaResource createNonSecureAudioCodecResource(int amount = 1) {
+ return MediaResource(MediaResource::Type::kNonSecureCodec,
+ MediaResource::SubType::kAudioCodec, amount);
+ }
+
+ static MediaResource createSecureImageCodecResource(int amount = 1) {
+ return MediaResource(MediaResource::Type::kSecureCodec,
+ MediaResource::SubType::kImageCodec, amount);
+ }
+
+ static MediaResource createNonSecureImageCodecResource(int amount = 1) {
+ return MediaResource(MediaResource::Type::kNonSecureCodec,
+ MediaResource::SubType::kImageCodec, amount);
+ }
+
+ static MediaResource createGraphicMemoryResource(int amount = 1) {
+ return MediaResource(MediaResource::Type::kGraphicMemory,
+ MediaResource::SubType::kUnspecifiedSubType, amount);
+ }
+
+ static MediaResource createDrmSessionResource(int amount = 1) {
+ return MediaResource(MediaResource::Type::kDrmSession,
+ MediaResource::SubType::kUnspecifiedSubType, amount);
+ }
+
+ static MediaResource createBatteryResource() {
+ return MediaResource(MediaResource::Type::kBattery,
+ MediaResource::SubType::kUnspecifiedSubType, 1);
+ }
+
+ static MediaResource createCpuBoostResource() {
+ return MediaResource(MediaResource::Type::kCpuBoost,
+ MediaResource::SubType::kUnspecifiedSubType, 1);
+ }
+
public:
ResourceManagerServiceTest() : ResourceManagerServiceTestBase() {}
- void verifyClients(bool c1, bool c2, bool c3) {
- TestClient *client1 = static_cast<TestClient*>(mTestClient1.get());
- TestClient *client2 = static_cast<TestClient*>(mTestClient2.get());
- TestClient *client3 = static_cast<TestClient*>(mTestClient3.get());
-
- EXPECT_EQ(c1, client1->reclaimed());
- EXPECT_EQ(c2, client2->reclaimed());
- EXPECT_EQ(c3, client3->reclaimed());
-
- client1->reset();
- client2->reset();
- client3->reset();
- }
// test set up
// ---------------------------------------------------------------------------------
@@ -268,7 +306,6 @@
void testOverridePid() {
- bool result;
std::vector<MediaResourceParcel> resources;
resources.push_back(MediaResource(MediaResource::Type::kSecureCodec, 1));
resources.push_back(MediaResource(MediaResource::Type::kGraphicMemory, 150));
@@ -293,8 +330,6 @@
}
void testMarkClientForPendingRemoval() {
- bool result;
-
{
addResource();
mService->mSupportsSecureWithNonSecureCodec = true;
@@ -307,13 +342,17 @@
// no lower priority client
CHECK_STATUS_FALSE(mService->reclaimResource(kTestPid2, resources, &result));
- verifyClients(false /* c1 */, false /* c2 */, false /* c3 */);
+ EXPECT_EQ(false, toTestClient(mTestClient1)->checkIfReclaimedAndReset());
+ EXPECT_EQ(false, toTestClient(mTestClient2)->checkIfReclaimedAndReset());
+ EXPECT_EQ(false, toTestClient(mTestClient3)->checkIfReclaimedAndReset());
mService->markClientForPendingRemoval(kTestPid2, getId(mTestClient2));
// client marked for pending removal from the same process got reclaimed
CHECK_STATUS_TRUE(mService->reclaimResource(kTestPid2, resources, &result));
- verifyClients(false /* c1 */, true /* c2 */, false /* c3 */);
+ EXPECT_EQ(false, toTestClient(mTestClient1)->checkIfReclaimedAndReset());
+ EXPECT_EQ(true, toTestClient(mTestClient2)->checkIfReclaimedAndReset());
+ EXPECT_EQ(false, toTestClient(mTestClient3)->checkIfReclaimedAndReset());
// clean up client 3 which still left
mService->removeClient(kTestPid2, getId(mTestClient3));
@@ -331,11 +370,15 @@
// client marked for pending removal from the same process got reclaimed
// first, even though there are lower priority process
CHECK_STATUS_TRUE(mService->reclaimResource(kTestPid2, resources, &result));
- verifyClients(false /* c1 */, true /* c2 */, false /* c3 */);
+ EXPECT_EQ(false, toTestClient(mTestClient1)->checkIfReclaimedAndReset());
+ EXPECT_EQ(true, toTestClient(mTestClient2)->checkIfReclaimedAndReset());
+ EXPECT_EQ(false, toTestClient(mTestClient3)->checkIfReclaimedAndReset());
// lower priority client got reclaimed
CHECK_STATUS_TRUE(mService->reclaimResource(kTestPid2, resources, &result));
- verifyClients(true /* c1 */, false /* c2 */, false /* c3 */);
+ EXPECT_EQ(true, toTestClient(mTestClient1)->checkIfReclaimedAndReset());
+ EXPECT_EQ(false, toTestClient(mTestClient2)->checkIfReclaimedAndReset());
+ EXPECT_EQ(false, toTestClient(mTestClient3)->checkIfReclaimedAndReset());
// clean up client 3 which still left
mService->removeClient(kTestPid2, getId(mTestClient3));
@@ -349,17 +392,23 @@
// client marked for pending removal got reclaimed
EXPECT_TRUE(mService->reclaimResourcesFromClientsPendingRemoval(kTestPid2).isOk());
- verifyClients(false /* c1 */, true /* c2 */, false /* c3 */);
+ EXPECT_EQ(false, toTestClient(mTestClient1)->checkIfReclaimedAndReset());
+ EXPECT_EQ(true, toTestClient(mTestClient2)->checkIfReclaimedAndReset());
+ EXPECT_EQ(false, toTestClient(mTestClient3)->checkIfReclaimedAndReset());
// No more clients marked for removal
EXPECT_TRUE(mService->reclaimResourcesFromClientsPendingRemoval(kTestPid2).isOk());
- verifyClients(false /* c1 */, false /* c2 */, false /* c3 */);
+ EXPECT_EQ(false, toTestClient(mTestClient1)->checkIfReclaimedAndReset());
+ EXPECT_EQ(false, toTestClient(mTestClient2)->checkIfReclaimedAndReset());
+ EXPECT_EQ(false, toTestClient(mTestClient3)->checkIfReclaimedAndReset());
mService->markClientForPendingRemoval(kTestPid2, getId(mTestClient3));
// client marked for pending removal got reclaimed
EXPECT_TRUE(mService->reclaimResourcesFromClientsPendingRemoval(kTestPid2).isOk());
- verifyClients(false /* c1 */, false /* c2 */, true /* c3 */);
+ EXPECT_EQ(false, toTestClient(mTestClient1)->checkIfReclaimedAndReset());
+ EXPECT_EQ(false, toTestClient(mTestClient2)->checkIfReclaimedAndReset());
+ EXPECT_EQ(true, toTestClient(mTestClient3)->checkIfReclaimedAndReset());
// clean up client 1 which still left
mService->removeClient(kTestPid1, getId(mTestClient1));
@@ -384,14 +433,15 @@
void testGetAllClients() {
addResource();
-
MediaResource::Type type = MediaResource::Type::kSecureCodec;
+ MediaResource::SubType subType = MediaResource::SubType::kUnspecifiedSubType;
+
Vector<std::shared_ptr<IResourceManagerClient> > clients;
- EXPECT_FALSE(mService->getAllClients_l(kLowPriorityPid, type, &clients));
+ EXPECT_FALSE(mService->getAllClients_l(kLowPriorityPid, type, subType, &clients));
// some higher priority process (e.g. kTestPid2) owns the resource, so getAllClients_l
// will fail.
- EXPECT_FALSE(mService->getAllClients_l(kMidPriorityPid, type, &clients));
- EXPECT_TRUE(mService->getAllClients_l(kHighPriorityPid, type, &clients));
+ EXPECT_FALSE(mService->getAllClients_l(kMidPriorityPid, type, subType, &clients));
+ EXPECT_TRUE(mService->getAllClients_l(kHighPriorityPid, type, subType, &clients));
EXPECT_EQ(2u, clients.size());
// (OK to require ordering in clients[], as the pid map is sorted)
@@ -400,7 +450,6 @@
}
void testReclaimResourceSecure() {
- bool result;
std::vector<MediaResourceParcel> resources;
resources.push_back(MediaResource(MediaResource::Type::kSecureCodec, 1));
resources.push_back(MediaResource(MediaResource::Type::kGraphicMemory, 150));
@@ -417,11 +466,15 @@
// reclaim all secure codecs
CHECK_STATUS_TRUE(mService->reclaimResource(kHighPriorityPid, resources, &result));
- verifyClients(true /* c1 */, false /* c2 */, true /* c3 */);
+ EXPECT_TRUE(toTestClient(mTestClient1)->checkIfReclaimedAndReset());
+ EXPECT_FALSE(toTestClient(mTestClient2)->checkIfReclaimedAndReset());
+ EXPECT_TRUE(toTestClient(mTestClient3)->checkIfReclaimedAndReset());
// call again should reclaim one largest graphic memory from lowest process
CHECK_STATUS_TRUE(mService->reclaimResource(kHighPriorityPid, resources, &result));
- verifyClients(false /* c1 */, true /* c2 */, false /* c3 */);
+ EXPECT_FALSE(toTestClient(mTestClient1)->checkIfReclaimedAndReset());
+ EXPECT_TRUE(toTestClient(mTestClient2)->checkIfReclaimedAndReset());
+ EXPECT_FALSE(toTestClient(mTestClient3)->checkIfReclaimedAndReset());
// nothing left
CHECK_STATUS_FALSE(mService->reclaimResource(kHighPriorityPid, resources, &result));
@@ -439,7 +492,9 @@
// reclaim all secure and non-secure codecs
CHECK_STATUS_TRUE(mService->reclaimResource(kHighPriorityPid, resources, &result));
- verifyClients(true /* c1 */, true /* c2 */, true /* c3 */);
+ EXPECT_TRUE(toTestClient(mTestClient1)->checkIfReclaimedAndReset());
+ EXPECT_TRUE(toTestClient(mTestClient2)->checkIfReclaimedAndReset());
+ EXPECT_TRUE(toTestClient(mTestClient3)->checkIfReclaimedAndReset());
// nothing left
CHECK_STATUS_FALSE(mService->reclaimResource(kHighPriorityPid, resources, &result));
@@ -458,15 +513,21 @@
// reclaim all non-secure codecs
CHECK_STATUS_TRUE(mService->reclaimResource(kHighPriorityPid, resources, &result));
- verifyClients(false /* c1 */, true /* c2 */, false /* c3 */);
+ EXPECT_FALSE(toTestClient(mTestClient1)->checkIfReclaimedAndReset());
+ EXPECT_TRUE(toTestClient(mTestClient2)->checkIfReclaimedAndReset());
+ EXPECT_FALSE(toTestClient(mTestClient3)->checkIfReclaimedAndReset());
// call again should reclaim one largest graphic memory from lowest process
CHECK_STATUS_TRUE(mService->reclaimResource(kHighPriorityPid, resources, &result));
- verifyClients(true /* c1 */, false /* c2 */, false /* c3 */);
+ EXPECT_TRUE(toTestClient(mTestClient1)->checkIfReclaimedAndReset());
+ EXPECT_FALSE(toTestClient(mTestClient2)->checkIfReclaimedAndReset());
+ EXPECT_FALSE(toTestClient(mTestClient3)->checkIfReclaimedAndReset());
// call again should reclaim another largest graphic memory from lowest process
CHECK_STATUS_TRUE(mService->reclaimResource(kHighPriorityPid, resources, &result));
- verifyClients(false /* c1 */, false /* c2 */, true /* c3 */);
+ EXPECT_FALSE(toTestClient(mTestClient1)->checkIfReclaimedAndReset());
+ EXPECT_FALSE(toTestClient(mTestClient2)->checkIfReclaimedAndReset());
+ EXPECT_TRUE(toTestClient(mTestClient3)->checkIfReclaimedAndReset());
// nothing left
CHECK_STATUS_FALSE(mService->reclaimResource(kHighPriorityPid, resources, &result));
@@ -483,15 +544,21 @@
CHECK_STATUS_TRUE(mService->reclaimResource(kHighPriorityPid, resources, &result));
// one largest graphic memory from lowest process got reclaimed
- verifyClients(true /* c1 */, false /* c2 */, false /* c3 */);
+ EXPECT_TRUE(toTestClient(mTestClient1)->checkIfReclaimedAndReset());
+ EXPECT_FALSE(toTestClient(mTestClient2)->checkIfReclaimedAndReset());
+ EXPECT_FALSE(toTestClient(mTestClient3)->checkIfReclaimedAndReset());
// call again should reclaim another graphic memory from lowest process
CHECK_STATUS_TRUE(mService->reclaimResource(kHighPriorityPid, resources, &result));
- verifyClients(false /* c1 */, true /* c2 */, false /* c3 */);
+ EXPECT_FALSE(toTestClient(mTestClient1)->checkIfReclaimedAndReset());
+ EXPECT_TRUE(toTestClient(mTestClient2)->checkIfReclaimedAndReset());
+ EXPECT_FALSE(toTestClient(mTestClient3)->checkIfReclaimedAndReset());
// call again should reclaim another graphic memory from lowest process
CHECK_STATUS_TRUE(mService->reclaimResource(kHighPriorityPid, resources, &result));
- verifyClients(false /* c1 */, false /* c2 */, true /* c3 */);
+ EXPECT_FALSE(toTestClient(mTestClient1)->checkIfReclaimedAndReset());
+ EXPECT_FALSE(toTestClient(mTestClient2)->checkIfReclaimedAndReset());
+ EXPECT_TRUE(toTestClient(mTestClient3)->checkIfReclaimedAndReset());
// nothing left
CHECK_STATUS_FALSE(mService->reclaimResource(kHighPriorityPid, resources, &result));
@@ -508,20 +575,25 @@
CHECK_STATUS_TRUE(mService->reclaimResource(kHighPriorityPid, resources, &result));
// secure codec from lowest process got reclaimed
- verifyClients(true /* c1 */, false /* c2 */, false /* c3 */);
+ EXPECT_TRUE(toTestClient(mTestClient1)->checkIfReclaimedAndReset());
+ EXPECT_FALSE(toTestClient(mTestClient2)->checkIfReclaimedAndReset());
+ EXPECT_FALSE(toTestClient(mTestClient3)->checkIfReclaimedAndReset());
// call again should reclaim another secure codec from lowest process
CHECK_STATUS_TRUE(mService->reclaimResource(kHighPriorityPid, resources, &result));
- verifyClients(false /* c1 */, false /* c2 */, true /* c3 */);
+ EXPECT_FALSE(toTestClient(mTestClient1)->checkIfReclaimedAndReset());
+ EXPECT_FALSE(toTestClient(mTestClient2)->checkIfReclaimedAndReset());
+ EXPECT_TRUE(toTestClient(mTestClient3)->checkIfReclaimedAndReset());
// no more secure codec, non-secure codec will be reclaimed.
CHECK_STATUS_TRUE(mService->reclaimResource(kHighPriorityPid, resources, &result));
- verifyClients(false /* c1 */, true /* c2 */, false /* c3 */);
+ EXPECT_FALSE(toTestClient(mTestClient1)->checkIfReclaimedAndReset());
+ EXPECT_TRUE(toTestClient(mTestClient2)->checkIfReclaimedAndReset());
+ EXPECT_FALSE(toTestClient(mTestClient3)->checkIfReclaimedAndReset());
}
}
void testReclaimResourceNonSecure() {
- bool result;
std::vector<MediaResourceParcel> resources;
resources.push_back(MediaResource(MediaResource::Type::kNonSecureCodec, 1));
resources.push_back(MediaResource(MediaResource::Type::kGraphicMemory, 150));
@@ -537,11 +609,15 @@
// reclaim all secure codecs
CHECK_STATUS_TRUE(mService->reclaimResource(kHighPriorityPid, resources, &result));
- verifyClients(true /* c1 */, false /* c2 */, true /* c3 */);
+ EXPECT_TRUE(toTestClient(mTestClient1)->checkIfReclaimedAndReset());
+ EXPECT_FALSE(toTestClient(mTestClient2)->checkIfReclaimedAndReset());
+ EXPECT_TRUE(toTestClient(mTestClient3)->checkIfReclaimedAndReset());
// call again should reclaim one graphic memory from lowest process
CHECK_STATUS_TRUE(mService->reclaimResource(kHighPriorityPid, resources, &result));
- verifyClients(false /* c1 */, true /* c2 */, false /* c3 */);
+ EXPECT_FALSE(toTestClient(mTestClient1)->checkIfReclaimedAndReset());
+ EXPECT_TRUE(toTestClient(mTestClient2)->checkIfReclaimedAndReset());
+ EXPECT_FALSE(toTestClient(mTestClient3)->checkIfReclaimedAndReset());
// nothing left
CHECK_STATUS_FALSE(mService->reclaimResource(kHighPriorityPid, resources, &result));
@@ -558,15 +634,21 @@
CHECK_STATUS_TRUE(mService->reclaimResource(kHighPriorityPid, resources, &result));
// one largest graphic memory from lowest process got reclaimed
- verifyClients(true /* c1 */, false /* c2 */, false /* c3 */);
+ EXPECT_TRUE(toTestClient(mTestClient1)->checkIfReclaimedAndReset());
+ EXPECT_FALSE(toTestClient(mTestClient2)->checkIfReclaimedAndReset());
+ EXPECT_FALSE(toTestClient(mTestClient3)->checkIfReclaimedAndReset());
// call again should reclaim another graphic memory from lowest process
CHECK_STATUS_TRUE(mService->reclaimResource(kHighPriorityPid, resources, &result));
- verifyClients(false /* c1 */, true /* c2 */, false /* c3 */);
+ EXPECT_FALSE(toTestClient(mTestClient1)->checkIfReclaimedAndReset());
+ EXPECT_TRUE(toTestClient(mTestClient2)->checkIfReclaimedAndReset());
+ EXPECT_FALSE(toTestClient(mTestClient3)->checkIfReclaimedAndReset());
// call again should reclaim another graphic memory from lowest process
CHECK_STATUS_TRUE(mService->reclaimResource(kHighPriorityPid, resources, &result));
- verifyClients(false /* c1 */, false /* c2 */, true /* c3 */);
+ EXPECT_FALSE(toTestClient(mTestClient1)->checkIfReclaimedAndReset());
+ EXPECT_FALSE(toTestClient(mTestClient2)->checkIfReclaimedAndReset());
+ EXPECT_TRUE(toTestClient(mTestClient3)->checkIfReclaimedAndReset());
// nothing left
CHECK_STATUS_FALSE(mService->reclaimResource(kHighPriorityPid, resources, &result));
@@ -582,11 +664,15 @@
CHECK_STATUS_TRUE(mService->reclaimResource(kHighPriorityPid, resources, &result));
// one non secure codec from lowest process got reclaimed
- verifyClients(false /* c1 */, true /* c2 */, false /* c3 */);
+ EXPECT_FALSE(toTestClient(mTestClient1)->checkIfReclaimedAndReset());
+ EXPECT_TRUE(toTestClient(mTestClient2)->checkIfReclaimedAndReset());
+ EXPECT_FALSE(toTestClient(mTestClient3)->checkIfReclaimedAndReset());
// no more non-secure codec, secure codec from lowest priority process will be reclaimed
CHECK_STATUS_TRUE(mService->reclaimResource(kHighPriorityPid, resources, &result));
- verifyClients(true /* c1 */, false /* c2 */, false /* c3 */);
+ EXPECT_TRUE(toTestClient(mTestClient1)->checkIfReclaimedAndReset());
+ EXPECT_FALSE(toTestClient(mTestClient2)->checkIfReclaimedAndReset());
+ EXPECT_FALSE(toTestClient(mTestClient3)->checkIfReclaimedAndReset());
// clean up client 3 which still left
mService->removeClient(kTestPid2, getId(mTestClient3));
@@ -595,13 +681,17 @@
void testGetLowestPriorityBiggestClient() {
MediaResource::Type type = MediaResource::Type::kGraphicMemory;
+ MediaResource::SubType subType = MediaResource::SubType::kUnspecifiedSubType;
std::shared_ptr<IResourceManagerClient> client;
- EXPECT_FALSE(mService->getLowestPriorityBiggestClient_l(kHighPriorityPid, type, &client));
+ EXPECT_FALSE(mService->getLowestPriorityBiggestClient_l(kHighPriorityPid, type, subType,
+ &client));
addResource();
- EXPECT_FALSE(mService->getLowestPriorityBiggestClient_l(kLowPriorityPid, type, &client));
- EXPECT_TRUE(mService->getLowestPriorityBiggestClient_l(kHighPriorityPid, type, &client));
+ EXPECT_FALSE(mService->getLowestPriorityBiggestClient_l(kLowPriorityPid, type, subType,
+ &client));
+ EXPECT_TRUE(mService->getLowestPriorityBiggestClient_l(kHighPriorityPid, type, subType,
+ &client));
// kTestPid1 is the lowest priority process with MediaResource::Type::kGraphicMemory.
// mTestClient1 has the largest MediaResource::Type::kGraphicMemory within kTestPid1.
@@ -614,35 +704,25 @@
TestProcessInfo processInfo;
MediaResource::Type type = MediaResource::Type::kGraphicMemory;
- EXPECT_FALSE(mService->getLowestPriorityPid_l(type, &pid, &priority));
+ MediaResource::SubType subType = MediaResource::SubType::kUnspecifiedSubType;
+ EXPECT_FALSE(mService->getLowestPriorityPid_l(type, subType, &pid, &priority));
addResource();
- EXPECT_TRUE(mService->getLowestPriorityPid_l(type, &pid, &priority));
+ EXPECT_TRUE(mService->getLowestPriorityPid_l(type, subType, &pid, &priority));
EXPECT_EQ(kTestPid1, pid);
int priority1;
processInfo.getPriority(kTestPid1, &priority1);
EXPECT_EQ(priority1, priority);
type = MediaResource::Type::kNonSecureCodec;
- EXPECT_TRUE(mService->getLowestPriorityPid_l(type, &pid, &priority));
+ EXPECT_TRUE(mService->getLowestPriorityPid_l(type, subType, &pid, &priority));
EXPECT_EQ(kTestPid2, pid);
int priority2;
processInfo.getPriority(kTestPid2, &priority2);
EXPECT_EQ(priority2, priority);
}
- void testGetBiggestClient() {
- MediaResource::Type type = MediaResource::Type::kGraphicMemory;
- std::shared_ptr<IResourceManagerClient> client;
- EXPECT_FALSE(mService->getBiggestClient_l(kTestPid2, type, &client));
-
- addResource();
-
- EXPECT_TRUE(mService->getBiggestClient_l(kTestPid2, type, &client));
- EXPECT_EQ(mTestClient2, client);
- }
-
void testIsCallingPriorityHigher() {
EXPECT_FALSE(mService->isCallingPriorityHigher_l(101, 100));
EXPECT_FALSE(mService->isCallingPriorityHigher_l(100, 100));
@@ -725,6 +805,361 @@
EXPECT_EQ(4u, mSystemCB->eventCount());
EXPECT_EQ(EventType::CPUSET_DISABLE, mSystemCB->lastEventType());
}
+
+ void testReclaimResources_withVideoCodec_reclaimsOnlyVideoCodec() {
+ const std::shared_ptr<IResourceManagerClient>& audioImageTestClient = mTestClient1;
+ const std::shared_ptr<IResourceManagerClient>& videoTestClient = mTestClient2;
+
+ // Create an audio and image codec resource
+ std::vector<MediaResourceParcel> audioImageResources;
+ audioImageResources.push_back(createNonSecureAudioCodecResource());
+ audioImageResources.push_back(createNonSecureImageCodecResource());
+ mService->addResource(kLowPriorityPid, kTestUid1, getId(audioImageTestClient),
+ audioImageTestClient, audioImageResources);
+
+ // Fail to reclaim a video codec resource
+ std::vector<MediaResourceParcel> reclaimResources;
+ reclaimResources.push_back(createNonSecureVideoCodecResource());
+ CHECK_STATUS_FALSE(mService->reclaimResource(kHighPriorityPid, reclaimResources, &result));
+
+ // Now add a video codec resource
+ std::vector<MediaResourceParcel> videoResources;
+ videoResources.push_back(createNonSecureVideoCodecResource());
+ mService->addResource(kLowPriorityPid, kTestUid1, getId(videoTestClient), videoTestClient,
+ videoResources);
+
+ // Verify that the newly-created video codec resource can be reclaimed
+ CHECK_STATUS_TRUE(mService->reclaimResource(kHighPriorityPid, reclaimResources, &result));
+
+ // Verify that the audio and image resources are untouched
+ EXPECT_FALSE(toTestClient(audioImageTestClient)->checkIfReclaimedAndReset());
+ // But the video resource was reclaimed
+ EXPECT_TRUE(toTestClient(videoTestClient)->checkIfReclaimedAndReset());
+ }
+
+ void testReclaimResources_withAudioCodec_reclaimsOnlyAudioCodec() {
+ const auto & videoImageTestClient = mTestClient1;
+ const auto & audioTestClient = mTestClient2;
+
+ // Create a video and audio codec resource
+ std::vector<MediaResourceParcel> videoImageResources;
+ videoImageResources.push_back(createNonSecureVideoCodecResource());
+ videoImageResources.push_back(createNonSecureImageCodecResource());
+ mService->addResource(kLowPriorityPid, kTestUid1, getId(videoImageTestClient),
+ videoImageTestClient, videoImageResources);
+
+ // Fail to reclaim an audio codec resource
+ std::vector<MediaResourceParcel> reclaimResources;
+ reclaimResources.push_back(createNonSecureAudioCodecResource());
+ CHECK_STATUS_FALSE(mService->reclaimResource(kHighPriorityPid, reclaimResources, &result));
+
+ // Now add an audio codec resource
+ std::vector<MediaResourceParcel> audioResources;
+ audioResources.push_back(createNonSecureAudioCodecResource());
+ mService->addResource(kLowPriorityPid, kTestUid2, getId(audioTestClient), audioTestClient,
+ audioResources);
+
+ // Verify that the newly-created audio codec resource can be reclaimed
+ CHECK_STATUS_TRUE(mService->reclaimResource(kHighPriorityPid, reclaimResources, &result));
+
+ // Verify that the video and image resources are untouched
+ EXPECT_FALSE(toTestClient(videoImageTestClient)->checkIfReclaimedAndReset());
+ // But the audio resource was reclaimed
+ EXPECT_TRUE(toTestClient(audioTestClient)->checkIfReclaimedAndReset());
+ }
+
+ void testReclaimResources_withImageCodec_reclaimsOnlyImageCodec() {
+ const auto & videoAudioTestClient = mTestClient1;
+ const auto & imageTestClient = mTestClient2;
+
+ // Create a video and audio codec resource
+ std::vector<MediaResourceParcel> videoAudioResources;
+ videoAudioResources.push_back(createNonSecureVideoCodecResource());
+ videoAudioResources.push_back(createNonSecureAudioCodecResource());
+ mService->addResource(kLowPriorityPid, kTestUid1, getId(videoAudioTestClient),
+ videoAudioTestClient, videoAudioResources);
+
+ // Fail to reclaim an image codec resource
+ std::vector<MediaResourceParcel> reclaimResources;
+ reclaimResources.push_back(createNonSecureImageCodecResource());
+ CHECK_STATUS_FALSE(mService->reclaimResource(kHighPriorityPid, reclaimResources, &result));
+
+ // Now add an image codec resource
+ std::vector<MediaResourceParcel> imageResources;
+ imageResources.push_back(createNonSecureImageCodecResource());
+ mService->addResource(kLowPriorityPid, kTestUid2, getId(imageTestClient), imageTestClient,
+ imageResources);
+
+ // Verify that the newly-created image codec resource can be reclaimed
+ CHECK_STATUS_TRUE(mService->reclaimResource(kHighPriorityPid, reclaimResources, &result));
+
+ // Verify that the video and audio resources are untouched
+ EXPECT_FALSE(toTestClient(mTestClient1)->checkIfReclaimedAndReset());
+ // But the image resource was reclaimed
+ EXPECT_TRUE(toTestClient(mTestClient2)->checkIfReclaimedAndReset());
+ }
+
+ void testReclaimResources_whenPartialResourceMatch_reclaims() {
+ const int onlyUid = kTestUid1;
+ const auto onlyClient = createTestClient(kLowPriorityPid);
+
+ std::vector<MediaResourceParcel> ownedResources;
+ ownedResources.push_back(createNonSecureVideoCodecResource());
+ ownedResources.push_back(createGraphicMemoryResource(100));
+ mService->addResource(kLowPriorityPid, onlyUid, getId(onlyClient), onlyClient,
+ ownedResources);
+
+ // Reclaim an image codec instead of the video codec that is owned, but also reclaim
+ // graphics memory, which will trigger the reclaim.
+ std::vector<MediaResourceParcel> reclaimResources;
+ reclaimResources.push_back(createNonSecureImageCodecResource());
+ reclaimResources.push_back(createGraphicMemoryResource(100));
+ CHECK_STATUS_TRUE(mService->reclaimResource(kHighPriorityPid, reclaimResources, &result));
+
+ // Verify that the video codec resources (including the needed graphic memory) is reclaimed
+ EXPECT_TRUE(toTestClient(onlyClient)->checkIfReclaimedAndReset());
+ }
+
+ void testReclaimResourcesFromMarkedClients_removesBiggestMarkedClientForSomeResources() {
+ // this test only uses one pid and one uid
+ const int onlyPid = kTestPid1;
+ const int onlyUid = kTestUid1;
+
+ // secure video codec
+ const auto smallSecureVideoMarkedClient = createTestClient(onlyPid);
+ const auto largeSecureVideoMarkedClient = createTestClient(onlyPid);
+ const auto largestSecureVideoActiveClient = createTestClient(onlyPid);
+ {
+ std::vector<MediaResourceParcel> resources;
+ resources.push_back(createSecureVideoCodecResource(1));
+ mService->addResource(onlyPid, onlyUid, getId(smallSecureVideoMarkedClient),
+ smallSecureVideoMarkedClient, resources);
+ resources.clear();
+ resources.push_back(createSecureVideoCodecResource(2));
+ mService->addResource(onlyPid, onlyUid, getId(largeSecureVideoMarkedClient),
+ largeSecureVideoMarkedClient, resources);
+ resources.clear();
+ resources.push_back(createSecureVideoCodecResource(3));
+ mService->addResource(onlyPid, onlyUid, getId(largestSecureVideoActiveClient),
+ largestSecureVideoActiveClient, resources);
+ }
+ mService->markClientForPendingRemoval(onlyPid, getId(smallSecureVideoMarkedClient));
+ mService->markClientForPendingRemoval(onlyPid, getId(largeSecureVideoMarkedClient));
+ // don't mark the largest client
+
+ // non-secure video codec
+ const auto smallNonSecureVideoMarkedClient = createTestClient(onlyPid);
+ const auto largeNonSecureVideoMarkedClient = createTestClient(onlyPid);
+ const auto largestNonSecureVideoActiveClient = createTestClient(onlyPid);
+ {
+ std::vector<MediaResourceParcel> resources;
+ resources.push_back(createNonSecureVideoCodecResource(1));
+ mService->addResource(onlyPid, onlyUid, getId(smallNonSecureVideoMarkedClient),
+ smallNonSecureVideoMarkedClient, resources);
+ resources.clear();
+ resources.push_back(createNonSecureVideoCodecResource(2));
+ mService->addResource(onlyPid, onlyUid, getId(largeNonSecureVideoMarkedClient),
+ largeNonSecureVideoMarkedClient, resources);
+ resources.clear();
+ resources.push_back(createNonSecureVideoCodecResource(3));
+ mService->addResource(onlyPid, onlyUid, getId(largestNonSecureVideoActiveClient),
+ largestNonSecureVideoActiveClient, resources);
+ }
+ mService->markClientForPendingRemoval(onlyPid, getId(smallNonSecureVideoMarkedClient));
+ mService->markClientForPendingRemoval(onlyPid, getId(largeNonSecureVideoMarkedClient));
+ // don't mark the largest client
+
+ // secure audio codec
+ const auto smallSecureAudioMarkedClient = createTestClient(onlyPid);
+ const auto largeSecureAudioMarkedClient = createTestClient(onlyPid);
+ const auto largestSecureAudioActiveClient = createTestClient(onlyPid);
+ {
+ std::vector<MediaResourceParcel> resources;
+ resources.push_back(createSecureAudioCodecResource(1));
+ mService->addResource(onlyPid, onlyUid, getId(smallSecureAudioMarkedClient),
+ smallSecureAudioMarkedClient, resources);
+ resources.clear();
+ resources.push_back(createSecureAudioCodecResource(2));
+ mService->addResource(onlyPid, onlyUid, getId(largeSecureAudioMarkedClient),
+ largeSecureAudioMarkedClient, resources);
+ resources.clear();
+ resources.push_back(createSecureAudioCodecResource(3));
+ mService->addResource(onlyPid, onlyUid, getId(largestSecureVideoActiveClient),
+ largestSecureVideoActiveClient, resources);
+ }
+ mService->markClientForPendingRemoval(onlyPid, getId(smallSecureAudioMarkedClient));
+ mService->markClientForPendingRemoval(onlyPid, getId(largeSecureAudioMarkedClient));
+ // don't mark the largest client
+
+ // non-secure audio codec
+ const auto smallNonSecureAudioMarkedClient = createTestClient(onlyPid);
+ const auto largeNonSecureAudioMarkedClient = createTestClient(onlyPid);
+ const auto largestNonSecureAudioActiveClient = createTestClient(onlyPid);
+ {
+ std::vector<MediaResourceParcel> resources;
+ resources.push_back(createNonSecureAudioCodecResource(1));
+ mService->addResource(onlyPid, onlyUid, getId(smallNonSecureAudioMarkedClient),
+ smallNonSecureAudioMarkedClient, resources);
+ resources.clear();
+ resources.push_back(createNonSecureAudioCodecResource(2));
+ mService->addResource(onlyPid, onlyUid, getId(largeNonSecureAudioMarkedClient),
+ largeNonSecureAudioMarkedClient, resources);
+ resources.clear();
+ resources.push_back(createNonSecureAudioCodecResource(3));
+ mService->addResource(onlyPid, onlyUid, getId(largestNonSecureAudioActiveClient),
+ largestNonSecureAudioActiveClient, resources);
+ }
+ mService->markClientForPendingRemoval(onlyPid, getId(smallNonSecureAudioMarkedClient));
+ mService->markClientForPendingRemoval(onlyPid, getId(largeNonSecureAudioMarkedClient));
+ // don't mark the largest client
+
+ // secure image codec
+ const auto smallSecureImageMarkedClient = createTestClient(onlyPid);
+ const auto largeSecureImageMarkedClient = createTestClient(onlyPid);
+ const auto largestSecureImageActiveClient = createTestClient(onlyPid);
+ {
+ std::vector<MediaResourceParcel> resources;
+ resources.push_back(createSecureImageCodecResource(1));
+ mService->addResource(onlyPid, onlyUid, getId(smallSecureImageMarkedClient),
+ smallSecureImageMarkedClient, resources);
+ resources.clear();
+ resources.push_back(createSecureImageCodecResource(2));
+ mService->addResource(onlyPid, onlyUid, getId(largeSecureImageMarkedClient),
+ largeSecureImageMarkedClient, resources);
+ resources.clear();
+ resources.push_back(createSecureImageCodecResource(3));
+ mService->addResource(onlyPid, onlyUid, getId(largestSecureImageActiveClient),
+ largestSecureImageActiveClient, resources);
+ }
+ mService->markClientForPendingRemoval(onlyPid, getId(smallSecureImageMarkedClient));
+ mService->markClientForPendingRemoval(onlyPid, getId(largeSecureImageMarkedClient));
+ // don't mark the largest client
+
+ // non-secure image codec
+ const auto smallNonSecureImageMarkedClient = createTestClient(onlyPid);
+ const auto largeNonSecureImageMarkedClient = createTestClient(onlyPid);
+ const auto largestNonSecureImageActiveClient = createTestClient(onlyPid);
+ {
+ std::vector<MediaResourceParcel> resources;
+ resources.push_back(createNonSecureImageCodecResource(1));
+ mService->addResource(onlyPid, onlyUid, getId(smallNonSecureImageMarkedClient),
+ smallNonSecureImageMarkedClient, resources);
+ resources.clear();
+ resources.push_back(createNonSecureImageCodecResource(2));
+ mService->addResource(onlyPid, onlyUid, getId(largeNonSecureImageMarkedClient),
+ largeNonSecureImageMarkedClient, resources);
+ resources.clear();
+ resources.push_back(createNonSecureImageCodecResource(3));
+ mService->addResource(onlyPid, onlyUid, getId(largestNonSecureImageActiveClient),
+ largestNonSecureImageActiveClient, resources);
+ }
+ mService->markClientForPendingRemoval(onlyPid, getId(smallNonSecureImageMarkedClient));
+ mService->markClientForPendingRemoval(onlyPid, getId(largeNonSecureImageMarkedClient));
+ // don't mark the largest client
+
+ // graphic memory
+ const auto smallGraphicMemoryMarkedClient = createTestClient(onlyPid);
+ const auto largeGraphicMemoryMarkedClient = createTestClient(onlyPid);
+ const auto largestGraphicMemoryActiveClient = createTestClient(onlyPid);
+ {
+ std::vector<MediaResourceParcel> resources;
+ resources.push_back(createGraphicMemoryResource(100));
+ mService->addResource(onlyPid, onlyUid, getId(smallGraphicMemoryMarkedClient),
+ smallGraphicMemoryMarkedClient, resources);
+ resources.clear();
+ resources.push_back(createGraphicMemoryResource(200));
+ mService->addResource(onlyPid, onlyUid, getId(largeGraphicMemoryMarkedClient),
+ largeGraphicMemoryMarkedClient, resources);
+ resources.clear();
+ resources.push_back(createGraphicMemoryResource(300));
+ mService->addResource(onlyPid, onlyUid, getId(largestGraphicMemoryActiveClient),
+ largestGraphicMemoryActiveClient, resources);
+ }
+ mService->markClientForPendingRemoval(onlyPid, getId(smallGraphicMemoryMarkedClient));
+ mService->markClientForPendingRemoval(onlyPid, getId(largeGraphicMemoryMarkedClient));
+ // don't mark the largest client
+
+ // DRM session
+ const auto smallDrmSessionMarkedClient = createTestClient(onlyPid);
+ const auto largeDrmSessionMarkedClient = createTestClient(onlyPid);
+ const auto largestDrmSessionActiveClient = createTestClient(onlyPid);
+ {
+ std::vector<MediaResourceParcel> resources;
+ resources.push_back(createDrmSessionResource(1));
+ mService->addResource(onlyPid, onlyUid, getId(smallDrmSessionMarkedClient),
+ smallDrmSessionMarkedClient, resources);
+ resources.clear();
+ resources.push_back(createDrmSessionResource(2));
+ mService->addResource(onlyPid, onlyUid, getId(largeDrmSessionMarkedClient),
+ largeDrmSessionMarkedClient, resources);
+ resources.clear();
+ resources.push_back(createDrmSessionResource(3));
+ mService->addResource(onlyPid, onlyUid, getId(largestDrmSessionActiveClient),
+ largestDrmSessionActiveClient, resources);
+ }
+ mService->markClientForPendingRemoval(onlyPid, getId(smallDrmSessionMarkedClient));
+ mService->markClientForPendingRemoval(onlyPid, getId(largeDrmSessionMarkedClient));
+ // don't mark the largest client
+
+ // battery
+ const auto batteryMarkedClient = createTestClient(onlyPid);
+ {
+ std::vector<MediaResourceParcel> resources;
+ resources.push_back(createBatteryResource());
+ mService->addResource(onlyPid, onlyUid, getId(batteryMarkedClient),
+ batteryMarkedClient, resources);
+ }
+ mService->markClientForPendingRemoval(onlyPid, getId(batteryMarkedClient));
+
+ // CPU boost
+ const auto cpuBoostMarkedClient = createTestClient(onlyPid);
+ {
+ std::vector<MediaResourceParcel> resources;
+ resources.push_back(createCpuBoostResource());
+ mService->addResource(onlyPid, onlyUid, getId(cpuBoostMarkedClient),
+ cpuBoostMarkedClient, resources);
+ }
+ mService->markClientForPendingRemoval(onlyPid, getId(cpuBoostMarkedClient));
+
+ // now we expect that we only reclaim resources from the biggest marked client
+ EXPECT_TRUE(mService->reclaimResourcesFromClientsPendingRemoval(onlyPid).isOk());
+ // secure video codec
+ EXPECT_FALSE(toTestClient(smallSecureVideoMarkedClient)->checkIfReclaimedAndReset());
+ EXPECT_TRUE(toTestClient(largeSecureVideoMarkedClient)->checkIfReclaimedAndReset());
+ EXPECT_FALSE(toTestClient(largestSecureVideoActiveClient)->checkIfReclaimedAndReset());
+ // non-secure video codec
+ EXPECT_FALSE(toTestClient(smallNonSecureVideoMarkedClient)->checkIfReclaimedAndReset());
+ EXPECT_TRUE(toTestClient(largeNonSecureVideoMarkedClient)->checkIfReclaimedAndReset());
+ EXPECT_FALSE(toTestClient(largestNonSecureVideoActiveClient)->checkIfReclaimedAndReset());
+ // secure audio codec
+ EXPECT_FALSE(toTestClient(smallSecureAudioMarkedClient)->checkIfReclaimedAndReset());
+ EXPECT_TRUE(toTestClient(largeSecureAudioMarkedClient)->checkIfReclaimedAndReset());
+ EXPECT_FALSE(toTestClient(largestSecureAudioActiveClient)->checkIfReclaimedAndReset());
+ // non-secure audio codec
+ EXPECT_FALSE(toTestClient(smallNonSecureAudioMarkedClient)->checkIfReclaimedAndReset());
+ EXPECT_TRUE(toTestClient(largeNonSecureAudioMarkedClient)->checkIfReclaimedAndReset());
+ EXPECT_FALSE(toTestClient(largestNonSecureAudioActiveClient)->checkIfReclaimedAndReset());
+ // secure image codec
+ EXPECT_FALSE(toTestClient(smallSecureImageMarkedClient)->checkIfReclaimedAndReset());
+ EXPECT_TRUE(toTestClient(largeSecureImageMarkedClient)->checkIfReclaimedAndReset());
+ EXPECT_FALSE(toTestClient(largestSecureImageActiveClient)->checkIfReclaimedAndReset());
+ // non-secure image codec
+ EXPECT_FALSE(toTestClient(smallNonSecureImageMarkedClient)->checkIfReclaimedAndReset());
+ EXPECT_TRUE(toTestClient(largeNonSecureImageMarkedClient)->checkIfReclaimedAndReset());
+ EXPECT_FALSE(toTestClient(largestNonSecureImageActiveClient)->checkIfReclaimedAndReset());
+ // graphic memory
+ EXPECT_FALSE(toTestClient(smallGraphicMemoryMarkedClient)->checkIfReclaimedAndReset());
+ EXPECT_TRUE(toTestClient(largeGraphicMemoryMarkedClient)->checkIfReclaimedAndReset());
+ EXPECT_FALSE(toTestClient(largestGraphicMemoryActiveClient)->checkIfReclaimedAndReset());
+ // DRM session
+ EXPECT_FALSE(toTestClient(smallDrmSessionMarkedClient)->checkIfReclaimedAndReset());
+ EXPECT_TRUE(toTestClient(largeDrmSessionMarkedClient)->checkIfReclaimedAndReset());
+ EXPECT_FALSE(toTestClient(largestDrmSessionActiveClient)->checkIfReclaimedAndReset());
+ // battery is not expected to be reclaimed when marked as pending removal
+ EXPECT_FALSE(toTestClient(batteryMarkedClient)->checkIfReclaimedAndReset());
+ // CPU boost is not expected to be reclaimed when marked as pending removal
+ EXPECT_FALSE(toTestClient(cpuBoostMarkedClient)->checkIfReclaimedAndReset());
+ }
};
TEST_F(ResourceManagerServiceTest, config) {
@@ -768,19 +1203,15 @@
testGetLowestPriorityPid();
}
-TEST_F(ResourceManagerServiceTest, getBiggestClient_l) {
- testGetBiggestClient();
-}
-
TEST_F(ResourceManagerServiceTest, isCallingPriorityHigher_l) {
testIsCallingPriorityHigher();
}
-TEST_F(ResourceManagerServiceTest, testBatteryStats) {
+TEST_F(ResourceManagerServiceTest, batteryStats) {
testBatteryStats();
}
-TEST_F(ResourceManagerServiceTest, testCpusetBoost) {
+TEST_F(ResourceManagerServiceTest, cpusetBoost) {
testCpusetBoost();
}
@@ -792,4 +1223,25 @@
testMarkClientForPendingRemoval();
}
+TEST_F(ResourceManagerServiceTest, reclaimResources_withVideoCodec_reclaimsOnlyVideoCodec) {
+ testReclaimResources_withVideoCodec_reclaimsOnlyVideoCodec();
+}
+
+TEST_F(ResourceManagerServiceTest, reclaimResources_withAudioCodec_reclaimsOnlyAudioCodec) {
+ testReclaimResources_withAudioCodec_reclaimsOnlyAudioCodec();
+}
+
+TEST_F(ResourceManagerServiceTest, reclaimResources_withImageCodec_reclaimsOnlyImageCodec) {
+ testReclaimResources_withImageCodec_reclaimsOnlyImageCodec();
+}
+
+TEST_F(ResourceManagerServiceTest, reclaimResources_whenPartialResourceMatch_reclaims) {
+ testReclaimResources_whenPartialResourceMatch_reclaims();
+}
+
+TEST_F(ResourceManagerServiceTest,
+ reclaimResourcesFromMarkedClients_removesBiggestMarkedClientForSomeResources) {
+ testReclaimResourcesFromMarkedClients_removesBiggestMarkedClientForSomeResources();
+}
+
} // namespace android