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

Commit e5ef1beb authored by Josh Gao's avatar Josh Gao Committed by Gerrit Code Review
Browse files

Merge changes I799508fa,I4951cca2

* changes:
  Don't attempt to dump vold on user builds.
  Include extra HALs in dump state
parents 08c5dfcd e73b7eed
Loading
Loading
Loading
Loading
+45 −5
Original line number Diff line number Diff line
@@ -16,7 +16,9 @@
#include <set>

#include <android-base/file.h>
#include <android-base/properties.h>
#include <android-base/stringprintf.h>
#include <android-base/strings.h>
#include <android/hidl/manager/1.0/IServiceManager.h>
#include <dumputils/dump_utils.h>
#include <log/log.h>
@@ -32,7 +34,6 @@ static const char* native_processes_to_dump[] = {
        "/system/bin/mediametrics", // media.metrics
        "/system/bin/mediaserver",
        "/system/bin/netd",
        "/system/bin/vold",
        "/system/bin/sdcard",
        "/system/bin/statsd",
        "/system/bin/surfaceflinger",
@@ -42,6 +43,13 @@ static const char* native_processes_to_dump[] = {
        NULL,
};


// Native processes to dump on debuggable builds.
static const char* debuggable_native_processes_to_dump[] = {
        "/system/bin/vold",
        NULL,
};

/* list of hal interface to dump containing process during native dumps */
static const char* hal_interfaces_to_dump[] {
        "android.hardware.audio@2.0::IDevicesFactory",
@@ -65,13 +73,34 @@ static const char* hal_interfaces_to_dump[] {
        NULL,
};

bool should_dump_hal_interface(const char* interface) {
/* list of extra hal interfaces to dump containing process during native dumps */
// This is filled when dumpstate is called.
static std::set<const std::string> extra_hal_interfaces_to_dump;

static void read_extra_hals_to_dump_from_property() {
    // extra hals to dump are already filled
    if (extra_hal_interfaces_to_dump.size() > 0) {
        return;
    }
    std::string value = android::base::GetProperty("ro.dump.hals.extra", "");
    std::vector<std::string> tokens = android::base::Split(value, ",");
    for (const auto &token : tokens) {
        std::string trimmed_token = android::base::Trim(token);
        if (trimmed_token.length() == 0) {
            continue;
        }
        extra_hal_interfaces_to_dump.insert(trimmed_token);
    }
}

// check if interface is included in either default hal list or extra hal list
bool should_dump_hal_interface(const std::string& interface) {
    for (const char** i = hal_interfaces_to_dump; *i; i++) {
        if (!strcmp(*i, interface)) {
        if (interface == *i) {
            return true;
        }
    }
    return false;
    return extra_hal_interfaces_to_dump.find(interface) != extra_hal_interfaces_to_dump.end();
}

bool should_dump_native_traces(const char* path) {
@@ -80,6 +109,15 @@ bool should_dump_native_traces(const char* path) {
            return true;
        }
    }

    if (android::base::GetBoolProperty("ro.debuggable", false)) {
        for (const char** p = debuggable_native_processes_to_dump; *p; p++) {
            if (!strcmp(*p, path)) {
                return true;
            }
        }
    }

    return false;
}

@@ -91,13 +129,15 @@ std::set<int> get_interesting_hal_pids() {
    sp<IServiceManager> manager = IServiceManager::getService();
    std::set<int> pids;

    read_extra_hals_to_dump_from_property();

    Return<void> ret = manager->debugDump([&](auto& hals) {
        for (const auto &info : hals) {
            if (info.pid == static_cast<int>(IServiceManager::PidConstant::NO_PID)) {
                continue;
            }

            if (!should_dump_hal_interface(info.interfaceName.c_str())) {
            if (!should_dump_hal_interface(info.interfaceName)) {
                continue;
            }