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

Commit 41c7350d authored by Shunkai Yao's avatar Shunkai Yao Committed by Gerrit Code Review
Browse files

Merge "Recognize AIDL calls in TimeCheck" into main

parents 6490d84c d4532c8e
Loading
Loading
Loading
Loading
+14 −0
Original line number Diff line number Diff line
@@ -20,6 +20,8 @@ namespace android::mediautils {

// Repository for MethodStatistics Objects

// It's important to have the HAL class name defined with suffix "Hidl/Aidl" because
// TimerThread::isRequestFromHal use this string to match binder call to/from hal.
std::shared_ptr<std::vector<std::string>>
getStatisticsClassesForModule(std::string_view moduleName) {
    static const std::map<std::string, std::shared_ptr<std::vector<std::string>>,
@@ -34,6 +36,15 @@ getStatisticsClassesForModule(std::string_view moduleName) {
                "StreamOutHalHidl",
              })
        },
        {
            METHOD_STATISTICS_MODULE_NAME_AUDIO_AIDL,
            std::shared_ptr<std::vector<std::string>>(
                new std::vector<std::string>{
                "DeviceHalAidl",
                "EffectHalAidl",
                "StreamHalAidl",
              })
        },
    };
    auto it = m.find(moduleName);
    if (it == m.end()) return {};
@@ -61,6 +72,9 @@ getStatisticsForClass(std::string_view className) {
            addClassesToMap(
                    getStatisticsClassesForModule(METHOD_STATISTICS_MODULE_NAME_AUDIO_HIDL),
                    m);
            addClassesToMap(
                    getStatisticsClassesForModule(METHOD_STATISTICS_MODULE_NAME_AUDIO_AIDL),
                    m);
            return m;
        }();

+10 −5
Original line number Diff line number Diff line
@@ -104,11 +104,16 @@ std::string TimerThread::SnapshotAnalysis::toString() const {
//
/* static */
bool TimerThread::isRequestFromHal(const std::shared_ptr<const Request>& request) {
    const size_t hidlPos = request->tag.asStringView().find("Hidl");
    if (hidlPos == std::string::npos) return false;
    // should be a separator afterwards Hidl which indicates the string was in the class.
    const size_t separatorPos = request->tag.asStringView().find("::", hidlPos);
    return separatorPos != std::string::npos;
    for (const auto& s : {"Hidl", "Aidl"}) {
        const auto& tagSV = request->tag.asStringView();
        const size_t halStrPos = tagSV.find(s);
        // should be a separator afterwards Hidl/Aidl which indicates the string was in the class.
        if (halStrPos != std::string::npos && tagSV.find("::", halStrPos) != std::string::npos) {
            return true;
        }
    }

    return false;
}

struct TimerThread::SnapshotAnalysis TimerThread::getSnapshotAnalysis(size_t retiredCount) const {
+1 −0
Original line number Diff line number Diff line
@@ -124,6 +124,7 @@ private:
// Managed Statistics support.
// Supported Modules
#define METHOD_STATISTICS_MODULE_NAME_AUDIO_HIDL "AudioHidl"
#define METHOD_STATISTICS_MODULE_NAME_AUDIO_AIDL "AudioAidl"

// Returns a vector of class names for the module, or a nullptr if module not found.
std::shared_ptr<std::vector<std::string>>
+9 −6
Original line number Diff line number Diff line
@@ -859,12 +859,15 @@ NO_THREAD_SAFETY_ANALYSIS // conditional try lock
            dprintf(fd, "\nIEffect binder call profile:\n");
            write(fd, timeCheckStats.c_str(), timeCheckStats.size());

            // Automatically fetch HIDL statistics.
            std::shared_ptr<std::vector<std::string>> hidlClassNames =
                    mediautils::getStatisticsClassesForModule(
                            METHOD_STATISTICS_MODULE_NAME_AUDIO_HIDL);
            if (hidlClassNames) {
                for (const auto& className : *hidlClassNames) {
            // Automatically fetch HIDL or AIDL statistics.
            const std::string_view halType = (mDevicesFactoryHal->getHalVersion().getType() ==
                                      AudioHalVersionInfo::Type::HIDL)
                                             ? METHOD_STATISTICS_MODULE_NAME_AUDIO_HIDL
                                             : METHOD_STATISTICS_MODULE_NAME_AUDIO_AIDL;
            const std::shared_ptr<std::vector<std::string>> halClassNames =
                    mediautils::getStatisticsClassesForModule(halType);
            if (halClassNames) {
                for (const auto& className : *halClassNames) {
                    auto stats = mediautils::getStatisticsForClass(className);
                    if (stats) {
                        timeCheckStats = stats->dump();