VRR: Use appId to replace uid mapping
Uid is combination of user id and app id. Because the allowlist
is recored by pkg for each users. We could ignore the user id part
and it also could solve the issue we didn't update the mapping
when user added case.
Bug: 298722189
Test: atest SmallAreaDetectionAllowMappingsTest
Test: atest SmallAreaDetectionControllerTest
Test: Add new user and open Youtube short to check refresh rate
Change-Id: Ic80be38ebc19938bc061bf6121c68efc4ff9ac4c
diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp
index 38dc435..ec3050c 100644
--- a/services/surfaceflinger/SurfaceFlinger.cpp
+++ b/services/surfaceflinger/SurfaceFlinger.cpp
@@ -8157,13 +8157,13 @@
}
status_t SurfaceFlinger::updateSmallAreaDetection(
- std::vector<std::pair<uid_t, float>>& uidThresholdMappings) {
- mScheduler->updateSmallAreaDetection(uidThresholdMappings);
+ std::vector<std::pair<int32_t, float>>& appIdThresholdMappings) {
+ mScheduler->updateSmallAreaDetection(appIdThresholdMappings);
return NO_ERROR;
}
-status_t SurfaceFlinger::setSmallAreaDetectionThreshold(uid_t uid, float threshold) {
- mScheduler->setSmallAreaDetectionThreshold(uid, threshold);
+status_t SurfaceFlinger::setSmallAreaDetectionThreshold(int32_t appId, float threshold) {
+ mScheduler->setSmallAreaDetectionThreshold(appId, threshold);
return NO_ERROR;
}
@@ -9530,18 +9530,18 @@
return binder::Status::ok();
}
-binder::Status SurfaceComposerAIDL::updateSmallAreaDetection(const std::vector<int32_t>& uids,
+binder::Status SurfaceComposerAIDL::updateSmallAreaDetection(const std::vector<int32_t>& appIds,
const std::vector<float>& thresholds) {
status_t status;
const int c_uid = IPCThreadState::self()->getCallingUid();
if (c_uid == AID_ROOT || c_uid == AID_SYSTEM) {
- if (uids.size() != thresholds.size()) return binderStatusFromStatusT(BAD_VALUE);
+ if (appIds.size() != thresholds.size()) return binderStatusFromStatusT(BAD_VALUE);
- std::vector<std::pair<uid_t, float>> mappings;
- const size_t size = uids.size();
+ std::vector<std::pair<int32_t, float>> mappings;
+ const size_t size = appIds.size();
mappings.reserve(size);
for (int i = 0; i < size; i++) {
- auto row = std::make_pair(static_cast<uid_t>(uids[i]), thresholds[i]);
+ auto row = std::make_pair(appIds[i], thresholds[i]);
mappings.push_back(row);
}
status = mFlinger->updateSmallAreaDetection(mappings);
@@ -9552,11 +9552,11 @@
return binderStatusFromStatusT(status);
}
-binder::Status SurfaceComposerAIDL::setSmallAreaDetectionThreshold(int32_t uid, float threshold) {
+binder::Status SurfaceComposerAIDL::setSmallAreaDetectionThreshold(int32_t appId, float threshold) {
status_t status;
const int c_uid = IPCThreadState::self()->getCallingUid();
if (c_uid == AID_ROOT || c_uid == AID_SYSTEM) {
- status = mFlinger->setSmallAreaDetectionThreshold(uid, threshold);
+ status = mFlinger->setSmallAreaDetectionThreshold(appId, threshold);
} else {
ALOGE("setSmallAreaDetectionThreshold() permission denied for uid: %d", c_uid);
status = PERMISSION_DENIED;