libaudiohal@aidl: Remove non-working code for HAL PIDs retrieval
Since native audio_server does not have "list services" permission,
it is always being denied to get services debug info (which includes
PIDs). Effectively, `DevicesFactoryHalAidl::getHalPids` never works.
The job of retrieval of HAL PIDs is actually done by the Java
AudioService. The code in libaudiohal@aidl triggers an SELinux
denial and thus should be removed.
Bug: 314853580
Test: check kernel log for 'avc: denied { list }'
Test: DeviceBootTest
(cherry picked from commit db666111308159850ae94fd4bcbc1b7c4d091dcd)
Change-Id: I5fb8e0a98a49141ec488e4faa04274eba46f80fa
diff --git a/media/libaudiohal/impl/DevicesFactoryHalAidl.cpp b/media/libaudiohal/impl/DevicesFactoryHalAidl.cpp
index a8f9f7e..96a3e60 100644
--- a/media/libaudiohal/impl/DevicesFactoryHalAidl.cpp
+++ b/media/libaudiohal/impl/DevicesFactoryHalAidl.cpp
@@ -24,7 +24,6 @@
#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>
@@ -119,23 +118,9 @@
if (pids == nullptr) {
return BAD_VALUE;
}
- // 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;
+ // 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;
}
status_t DevicesFactoryHalAidl::setCallbackOnce(sp<DevicesFactoryHalCallback> callback) {