cameraservice: re-map oom_adj scores and states of native vendor clients.
Override the oom_adj scores of vendor clients from to PERCEPTIBLE_APP_ADJ.
Override the process state of vendor clients to to PROCESS_STATE_PERSISTENT_UI.
This is in order for app processes to take priority over vendor clients.
For example, this could help in the case of the default camera app and
face auth contending for resources from the lock screen.
Bug: 132117718
Test: manual test on lockscreen, try to double press and open camera app
while a vendor client is connected to a contending camera device.
Change-Id: Ie5fabb59c876cb02eb706f3dda8f748c69e3c063
Signed-off-by: Jayant Chowdhary <jchowdhary@google.com>
diff --git a/services/camera/libcameraservice/CameraService.cpp b/services/camera/libcameraservice/CameraService.cpp
index fc6d6be..a87ebdf 100644
--- a/services/camera/libcameraservice/CameraService.cpp
+++ b/services/camera/libcameraservice/CameraService.cpp
@@ -117,6 +117,11 @@
static const String16 sManageCameraPermission("android.permission.MANAGE_CAMERA");
+// Matches with PERCEPTIBLE_APP_ADJ in ProcessList.java
+static constexpr int32_t kVendorClientScore = 200;
+// Matches with PROCESS_STATE_PERSISTENT_UI in ActivityManager.java
+static constexpr int32_t kVendorClientState = 1;
+
Mutex CameraService::sProxyMutex;
sp<hardware::ICameraServiceProxy> CameraService::sCameraServiceProxy;
@@ -1120,7 +1125,8 @@
std::map<int,resource_policy::ClientPriority> pidToPriorityMap;
for (size_t i = 0; i < ownerPids.size() - 1; i++) {
pidToPriorityMap.emplace(ownerPids[i],
- resource_policy::ClientPriority(priorityScores[i], states[i]));
+ resource_policy::ClientPriority(priorityScores[i], states[i],
+ /* isVendorClient won't get copied over*/ false));
}
mActiveClientManager.updatePriorities(pidToPriorityMap);
@@ -2980,8 +2986,12 @@
const std::set<String8>& conflictingKeys, int32_t score, int32_t ownerId,
int32_t state) {
+ bool isVendorClient = hardware::IPCThreadState::self()->isServingCall();
+ int32_t score_adj = isVendorClient ? kVendorClientScore : score;
+ int32_t state_adj = isVendorClient ? kVendorClientState: state;
+
return std::make_shared<resource_policy::ClientDescriptor<String8, sp<BasicClient>>>(
- key, value, cost, conflictingKeys, score, ownerId, state);
+ key, value, cost, conflictingKeys, score_adj, ownerId, state_adj, isVendorClient);
}
CameraService::DescriptorPtr CameraService::CameraClientManager::makeClientDescriptor(