diff options
author | 2023-04-21 20:07:49 -0700 | |
---|---|---|
committer | 2023-05-08 16:28:36 +0000 | |
commit | 805d804635d8fecaf81b406b08994869097836c4 (patch) | |
tree | 5025c463c37b5777dd411efe1d59064b128321dd /libs/binder/ActivityManager.cpp | |
parent | c03813b78e59446cefb105933ecf1a64483e9aed (diff) |
Camera / UidObserver: Add the ability to subscribe to specific UIDs
UidObserver sends updates about the state of all packages installed on
the system. In the case of the cameraserver, we only care about a
handful of them. The current status quo is to filter out these callbacks
but there is a significant IPC cost that is not addressed by that
approach.
This patch adds new entrypoints to ActivityManagerService to listen only
to specified UIDs. This set of uids can be updated dynamically.
Change-Id: I669f27b94fb691187bb77942f53ebc02cb90ace4
Bug: 274486653
Test: -- on physical device:
-- testCamera2AccessCallbackInSplitMode x10
-- ActivityManagerServiceTest
-- ActivityManagerProcessStateTest
-- ActivityManagerFgsBgStartTest
-- UidObserverControllerTest
-- Alternate focus in split screen between Camera2 + GCA x20
Ignore-AOSP: Soak time in U
Diffstat (limited to 'libs/binder/ActivityManager.cpp')
-rw-r--r-- | libs/binder/ActivityManager.cpp | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/libs/binder/ActivityManager.cpp b/libs/binder/ActivityManager.cpp index e45a656d29..aca5009148 100644 --- a/libs/binder/ActivityManager.cpp +++ b/libs/binder/ActivityManager.cpp @@ -75,6 +75,20 @@ status_t ActivityManager::registerUidObserver(const sp<IUidObserver>& observer, return DEAD_OBJECT; } +status_t ActivityManager::registerUidObserverForUids(const sp<IUidObserver>& observer, + const int32_t event, const int32_t cutpoint, + const String16& callingPackage, + const int32_t uids[], size_t nUids, + /*out*/ sp<IBinder>& observerToken) { + sp<IActivityManager> service = getService(); + if (service != nullptr) { + return service->registerUidObserverForUids(observer, event, cutpoint, callingPackage, uids, + nUids, observerToken); + } + // ActivityManagerService appears dead. Return usual error code for dead service. + return DEAD_OBJECT; +} + status_t ActivityManager::unregisterUidObserver(const sp<IUidObserver>& observer) { sp<IActivityManager> service = getService(); @@ -85,6 +99,26 @@ status_t ActivityManager::unregisterUidObserver(const sp<IUidObserver>& observer return DEAD_OBJECT; } +status_t ActivityManager::addUidToObserver(const sp<IBinder>& observerToken, + const String16& callingPackage, int32_t uid) { + sp<IActivityManager> service = getService(); + if (service != nullptr) { + return service->addUidToObserver(observerToken, callingPackage, uid); + } + // ActivityManagerService appears dead. Return usual error code for dead service. + return DEAD_OBJECT; +} + +status_t ActivityManager::removeUidFromObserver(const sp<IBinder>& observerToken, + const String16& callingPackage, int32_t uid) { + sp<IActivityManager> service = getService(); + if (service != nullptr) { + return service->removeUidFromObserver(observerToken, callingPackage, uid); + } + // ActivityManagerService appears dead. Return usual error code for dead service. + return DEAD_OBJECT; +} + bool ActivityManager::isUidActive(const uid_t uid, const String16& callingPackage) { sp<IActivityManager> service = getService(); |