Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 06bc2075 authored by Shunkai Yao's avatar Shunkai Yao
Browse files

Revert "libaudiohal@aidl: Remove non-working code for HAL PIDs r..."

Revert submission 2862771-cuttlefish_aidl_audio-2

Reason for revert: b/316027906

Reverted changes: /q/submissionid:2862771-cuttlefish_aidl_audio-2

Change-Id: I9ebf49ba4557e10bf9c559f8c20429b1d7824993
parent a4660478
Loading
Loading
Loading
Loading
+18 −3
Original line number Diff line number Diff line
@@ -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) {