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

Commit 12c19181 authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Update FdToString impl behind flag" into main

parents 42e1a5ca 50ffdd14
Loading
Loading
Loading
Loading
+30 −5
Original line number Original line Diff line number Diff line
@@ -31,6 +31,7 @@
#include <afutils/Permission.h>
#include <afutils/Permission.h>
#include <afutils/PropertyUtils.h>
#include <afutils/PropertyUtils.h>
#include <afutils/TypedLogger.h>
#include <afutils/TypedLogger.h>
#include <android-base/errors.h>
#include <android-base/stringprintf.h>
#include <android-base/stringprintf.h>
#include <android/media/IAudioPolicyService.h>
#include <android/media/IAudioPolicyService.h>
#include <audiomanager/IAudioManager.h>
#include <audiomanager/IAudioManager.h>
@@ -38,6 +39,7 @@
#include <binder/IServiceManager.h>
#include <binder/IServiceManager.h>
#include <binder/Parcel.h>
#include <binder/Parcel.h>
#include <cutils/properties.h>
#include <cutils/properties.h>
#include <com_android_media_audioserver.h>
#include <media/AidlConversion.h>
#include <media/AidlConversion.h>
#include <media/AudioParameter.h>
#include <media/AudioParameter.h>
#include <media/AudioValidator.h>
#include <media/AudioValidator.h>
@@ -210,6 +212,20 @@ static auto& getIAudioFlingerStatistics() {
    return methodStatistics;
    return methodStatistics;
}
}


namespace base {
template <typename T>
struct OkOrFail<std::optional<T>> {
    using opt_t = std::optional<T>;
    OkOrFail() = delete;
    OkOrFail(const opt_t&) = delete;

    static bool IsOk(const opt_t& opt) { return opt.has_value(); }
    static T Unwrap(opt_t&& opt) { return std::move(opt.value()); }
    static std::string ErrorMessage(const opt_t&) { return "Empty optional"; }
    static void Fail(opt_t&&) {}
};
}

class DevicesFactoryHalCallbackImpl : public DevicesFactoryHalCallback {
class DevicesFactoryHalCallbackImpl : public DevicesFactoryHalCallback {
  public:
  public:
    void onNewDevicesAvailable() override {
    void onNewDevicesAvailable() override {
@@ -3597,6 +3613,14 @@ std::vector< sp<IAfEffectModule> > AudioFlinger::purgeOrphanEffectChains_l()
void AudioFlinger::dumpToThreadLog_l(const sp<IAfThreadBase> &thread)
void AudioFlinger::dumpToThreadLog_l(const sp<IAfThreadBase> &thread)
{
{
    constexpr int THREAD_DUMP_TIMEOUT_MS = 2;
    constexpr int THREAD_DUMP_TIMEOUT_MS = 2;
    constexpr auto PREFIX = "- ";
    if (com::android::media::audioserver::fdtostring_timeout_fix()) {
        using ::android::audio_utils::FdToString;

        auto writer = OR_RETURN(FdToString::createWriter(PREFIX));
        thread->dump(writer.borrowFdUnsafe(), {} /* args */);
        mThreadLog.logs(-1 /* time */, FdToString::closeWriterAndGetString(std::move(writer)));
    } else {
        audio_utils::FdToStringOldImpl fdToString("- ", THREAD_DUMP_TIMEOUT_MS);
        audio_utils::FdToStringOldImpl fdToString("- ", THREAD_DUMP_TIMEOUT_MS);
        const int fd = fdToString.borrowFdUnsafe();
        const int fd = fdToString.borrowFdUnsafe();
        if (fd >= 0) {
        if (fd >= 0) {
@@ -3604,6 +3628,7 @@ void AudioFlinger::dumpToThreadLog_l(const sp<IAfThreadBase> &thread)
            mThreadLog.logs(-1 /* time */, fdToString.closeAndGetString());
            mThreadLog.logs(-1 /* time */, fdToString.closeAndGetString());
        }
        }
    }
    }
}


// checkThread_l() must be called with AudioFlinger::mutex() held
// checkThread_l() must be called with AudioFlinger::mutex() held
IAfThreadBase* AudioFlinger::checkThread_l(audio_io_handle_t ioHandle) const
IAfThreadBase* AudioFlinger::checkThread_l(audio_io_handle_t ioHandle) const