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

Commit f1a584a4 authored by Eric Laurent's avatar Eric Laurent Committed by Android (Google) Code Review
Browse files

Merge "media utils: dump audio HAL service before restarting audioserver"

parents a24e36cc 42896a07
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -1392,6 +1392,12 @@ status_t AudioSystem::getMicrophones(std::vector<media::MicrophoneInfo> *microph
    return af->getMicrophones(microphones);
}

status_t AudioSystem::setAudioHalPids(const std::vector<pid_t>& pids) {
  const sp<IAudioFlinger>& af = AudioSystem::get_audio_flinger();
  if (af == nullptr) return PERMISSION_DENIED;
  return af->setAudioHalPids(pids);
}

status_t AudioSystem::getSurroundFormats(unsigned int *numSurroundFormats,
                                         audio_format_t *surroundFormats,
                                         bool *surroundFormatsEnabled,
+43 −1
Original line number Diff line number Diff line
@@ -90,10 +90,12 @@ enum {
    SET_MASTER_BALANCE,
    GET_MASTER_BALANCE,
    SET_EFFECT_SUSPENDED,
    SET_AUDIO_HAL_PIDS
};

#define MAX_ITEMS_PER_LIST 1024


class BpAudioFlinger : public BpInterface<IAudioFlinger>
{
public:
@@ -900,6 +902,20 @@ public:
        status = reply.readParcelableVector(microphones);
        return status;
    }
    virtual status_t setAudioHalPids(const std::vector<pid_t>& pids)
    {
        Parcel data, reply;
        data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
        data.writeInt32(pids.size());
        for (auto pid : pids) {
            data.writeInt32(pid);
        }
        status_t status = remote()->transact(SET_AUDIO_HAL_PIDS, data, &reply);
        if (status != NO_ERROR) {
            return status;
        }
        return static_cast <status_t> (reply.readInt32());
    }
};

IMPLEMENT_META_INTERFACE(AudioFlinger, "android.media.IAudioFlinger");
@@ -955,7 +971,8 @@ status_t BnAudioFlinger::onTransact(
        case SET_MODE:
        case SET_MIC_MUTE:
        case SET_LOW_RAM_DEVICE:
        case SYSTEM_READY: {
        case SYSTEM_READY:
        case SET_AUDIO_HAL_PIDS: {
            if (!isServiceUid(IPCThreadState::self()->getCallingUid())) {
                ALOGW("%s: transaction %d received from PID %d unauthorized UID %d",
                      __func__, code, IPCThreadState::self()->getCallingPid(),
@@ -1544,6 +1561,31 @@ status_t BnAudioFlinger::onTransact(
            }
            return NO_ERROR;
        }
        case SET_AUDIO_HAL_PIDS: {
            CHECK_INTERFACE(IAudioFlinger, data, reply);
            std::vector<pid_t> pids;
            int32_t size;
            status_t status = data.readInt32(&size);
            if (status != NO_ERROR) {
                return status;
            }
            if (size < 0) {
                return BAD_VALUE;
            }
            if (size > MAX_ITEMS_PER_LIST) {
                size = MAX_ITEMS_PER_LIST;
            }
            for (int32_t i = 0; i < size; i++) {
                int32_t pid;
                status =  data.readInt32(&pid);
                if (status != NO_ERROR) {
                    return status;
                }
                pids.push_back(pid);
            }
            reply->writeInt32(setAudioHalPids(pids));
            return NO_ERROR;
        }
        default:
            return BBinder::onTransact(code, data, reply, flags);
    }
+6 −0
Original line number Diff line number Diff line
@@ -399,6 +399,12 @@ public:

    static bool     isCallScreenModeSupported();

     /**
     * Send audio HAL server process pids to native audioserver process for use
     * when generating audio HAL servers tombstones
     */
    static status_t setAudioHalPids(const std::vector<pid_t>& pids);

    // ----------------------------------------------------------------------------

    class AudioVolumeGroupCallback : public RefBase
+2 −0
Original line number Diff line number Diff line
@@ -523,6 +523,8 @@ public:

    /* List available microphones and their characteristics */
    virtual status_t getMicrophones(std::vector<media::MicrophoneInfo> *microphones) = 0;

    virtual status_t setAudioHalPids(const std::vector<pid_t>& pids) = 0;
};


+27 −0
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@
#define LOG_TAG "DevicesFactoryHalHidl"
//#define LOG_NDEBUG 0

#include "android/hidl/manager/1.0/IServiceManager.h"
#include PATH(android/hardware/audio/FILE_VERSION/IDevice.h)
#include <media/audiohal/hidl/HalDeathHandler.h>
#include <utils/Log.h>
@@ -28,6 +29,8 @@
#include "DeviceHalHidl.h"
#include "DevicesFactoryHalHidl.h"

#include <set>

using ::android::hardware::audio::CPP_VERSION::IDevice;
using ::android::hardware::audio::CPP_VERSION::Result;
using ::android::hardware::Return;
@@ -108,5 +111,29 @@ status_t DevicesFactoryHalHidl::openDevice(const char *name, sp<DeviceHalInterfa
    return BAD_VALUE;
}

status_t DevicesFactoryHalHidl::getHalPids(std::vector<pid_t> *pids) {
    std::set<pid_t> pidsSet;

    for (const auto& factory : mDeviceFactories) {
        using ::android::hidl::base::V1_0::DebugInfo;
        using android::hidl::manager::V1_0::IServiceManager;

        DebugInfo debugInfo;
        auto ret = factory->getDebugInfo([&] (const auto &info) {
               debugInfo = info;
            });
        if (!ret.isOk()) {
           return INVALID_OPERATION;
        }
        if (debugInfo.pid == (int)IServiceManager::PidConstant::NO_PID) {
            continue;
        }
        pidsSet.insert(debugInfo.pid);
    }

    *pids = {pidsSet.begin(), pidsSet.end()};
    return NO_ERROR;
}

} // namespace CPP_VERSION
} // namespace android
Loading