summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShunkai Yao <yaoshunkai@google.com>2023-12-13 00:49:30 +0000
committerAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>2023-12-13 00:49:30 +0000
commit7ca6c8e820cefdde019d3c5c3feef7099f193f4c (patch)
tree3f7d35ce5cab832340d05ec817812d38669bc163
parent2e89a9175a1f954cb6ae21c2165224e61a1e6a1d (diff)
parente947e7f78e55c2c2589452494cdfe3632a462869 (diff)
downloadav-7ca6c8e820cefdde019d3c5c3feef7099f193f4c.tar.gz
Revert "libaudiohal@aidl: Remove non-working code for HAL PIDs r..." am: 06bc20758a am: 04abfc8c30 am: e947e7f78e
Original change: https://android-review.googlesource.com/c/platform/frameworks/av/+/2871090 Change-Id: I3ac81d3577d31ebca7d12c5bb503677e886c0d3d Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
-rw-r--r--media/libaudiohal/impl/DevicesFactoryHalAidl.cpp21
1 files changed, 18 insertions, 3 deletions
diff --git a/media/libaudiohal/impl/DevicesFactoryHalAidl.cpp b/media/libaudiohal/impl/DevicesFactoryHalAidl.cpp
index 96a3e60350..a8f9f7e66e 100644
--- a/media/libaudiohal/impl/DevicesFactoryHalAidl.cpp
+++ b/media/libaudiohal/impl/DevicesFactoryHalAidl.cpp
@@ -24,6 +24,7 @@
#include <aidl/android/hardware/audio/core/IModule.h>
#include <android/binder_manager.h>
+#include <binder/IServiceManager.h>
#include <media/AidlConversionNdkCpp.h>
#include <media/AidlConversionUtil.h>
#include <utils/Log.h>
@@ -118,9 +119,23 @@ status_t DevicesFactoryHalAidl::getHalPids(std::vector<pid_t> *pids) {
if (pids == nullptr) {
return BAD_VALUE;
}
- // Retrieval of HAL pids requires "list services" permission which is not granted
- // to the audio server. This job is performed by AudioService (in Java) instead.
- return PERMISSION_DENIED;
+ // The functionality for retrieving debug infos of services is not exposed via the NDK.
+ sp<IServiceManager> sm = defaultServiceManager();
+ if (sm == nullptr) {
+ return NO_INIT;
+ }
+ std::set<pid_t> pidsSet;
+ const auto moduleServiceName = std::string(IModule::descriptor) + "/";
+ auto debugInfos = sm->getServiceDebugInfo();
+ for (const auto& info : debugInfos) {
+ if (info.pid > 0 &&
+ info.name.size() > moduleServiceName.size() && // '>' as there must be instance name
+ info.name.substr(0, moduleServiceName.size()) == moduleServiceName) {
+ pidsSet.insert(info.pid);
+ }
+ }
+ *pids = {pidsSet.begin(), pidsSet.end()};
+ return NO_ERROR;
}
status_t DevicesFactoryHalAidl::setCallbackOnce(sp<DevicesFactoryHalCallback> callback) {