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

Commit a2f92f24 authored by Limon Mia's avatar Limon Mia Committed by Android (Google) Code Review
Browse files

Merge "Added bugreport mode for debugging bluetooth." into main

parents 34f08473 1a6aa9d4
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -147,6 +147,7 @@ binder::Status DumpstateService::startBugreport(int32_t calling_uid,
        bugreport_mode != Dumpstate::BugreportMode::BUGREPORT_TELEPHONY &&
        bugreport_mode != Dumpstate::BugreportMode::BUGREPORT_WIFI &&
        bugreport_mode != Dumpstate::BugreportMode::BUGREPORT_ONBOARDING &&
        bugreport_mode != Dumpstate::BugreportMode::BUGREPORT_BLUETOOTH &&
        bugreport_mode != Dumpstate::BugreportMode::BUGREPORT_DEFAULT) {
        MYLOGE("Invalid input: bad bugreport mode: %d", bugreport_mode);
        signalErrorAndExit(listener, IDumpstateListener::BUGREPORT_ERROR_INVALID_INPUT);
+3 −0
Original line number Diff line number Diff line
@@ -52,6 +52,9 @@ interface IDumpstate {
    // Bugreport taken for onboarding related flows.
    const int BUGREPORT_MODE_ONBOARDING = 7;

    // Bugreport limited to only bluetooth info.
    const int BUGREPORT_MODE_BLUETOOTH = 8;

    // Use pre-dumped data.
    const int BUGREPORT_FLAG_USE_PREDUMPED_UI_DATA = 0x1;

+39 −2
Original line number Diff line number Diff line
@@ -2282,6 +2282,31 @@ static void DumpstateOnboardingOnly() {
    ds.AddDir(LOGPERSIST_DATA_DIR, false);
}

// This method collects log sections for bluetooth debugging only
static void DumpstateBluetoothOnly() {
    DurationReporter duration_reporter("DUMPSTATE");

    printf("========================================================\n");
    printf("== Android Framework Services\n");
    printf("========================================================\n");
    printf("------ DUMPSYS (/system/bin/dumpsys) ------\n");

    const std::vector<std::string> services = {"android.hardware.bluetooth.IBluetoothHci/default",
                                               "bluetooth_manager", "package"};
    for (const std::string& service : services) {
        printf("-------------------------------------------------------------------------------\n");
        printf("DUMP OF SERVICE %s:\n", service.c_str());
        RunDumpsys("DUMPSYS", {service}, CommandOptions::WithTimeout(90).Build(), SEC_TO_MSEC(10));
    }

    printf("========================================================\n");
    printf("== dumpstate: done (id %d)\n", ds.id_);
    printf("========================================================\n");

    /* Dump Bluetooth HCI logs after getting bluetooth_manager dumpsys */
    ds.AddDir("/data/misc/bluetooth/logs", true);
}

static std::string GetTimestamp(const timespec& ts) {
    tm tm;
    localtime_r(&ts.tv_sec, &tm);
@@ -2488,6 +2513,7 @@ static dumpstate_hal_hidl::DumpstateMode GetDumpstateHalModeHidl(
        case Dumpstate::BugreportMode::BUGREPORT_WIFI:
            return dumpstate_hal_hidl::DumpstateMode::WIFI;
        case Dumpstate::BugreportMode::BUGREPORT_ONBOARDING:
        case Dumpstate::BugreportMode::BUGREPORT_BLUETOOTH:
        case Dumpstate::BugreportMode::BUGREPORT_DEFAULT:
            return dumpstate_hal_hidl::DumpstateMode::DEFAULT;
    }
@@ -2510,6 +2536,7 @@ static dumpstate_hal_aidl::IDumpstateDevice::DumpstateMode GetDumpstateHalModeAi
        case Dumpstate::BugreportMode::BUGREPORT_WIFI:
            return dumpstate_hal_aidl::IDumpstateDevice::DumpstateMode::WIFI;
        case Dumpstate::BugreportMode::BUGREPORT_ONBOARDING:
        case Dumpstate::BugreportMode::BUGREPORT_BLUETOOTH:
        case Dumpstate::BugreportMode::BUGREPORT_DEFAULT:
            return dumpstate_hal_aidl::IDumpstateDevice::DumpstateMode::DEFAULT;
    }
@@ -2917,6 +2944,8 @@ static bool PrepareToWriteToFile() {
        ds.base_name_ += "-telephony";
    } else if (ds.options_->wifi_only) {
        ds.base_name_ += "-wifi";
    } else if (ds.options_->bluetooth_only) {
        ds.base_name_ += "-bluetooth";
    }

    if (ds.options_->do_screenshot) {
@@ -3011,6 +3040,8 @@ static inline const char* ModeToString(Dumpstate::BugreportMode mode) {
            return "BUGREPORT_WIFI";
        case Dumpstate::BugreportMode::BUGREPORT_ONBOARDING:
            return "BUGREPORT_ONBOARDING";
        case Dumpstate::BugreportMode::BUGREPORT_BLUETOOTH:
            return "BUGREPORT_BLUETOOTH";
        case Dumpstate::BugreportMode::BUGREPORT_DEFAULT:
            return "BUGREPORT_DEFAULT";
    }
@@ -3060,6 +3091,10 @@ static void SetOptionsFromMode(Dumpstate::BugreportMode mode, Dumpstate::DumpOpt
            options->onboarding_only = true;
            options->do_screenshot = false;
            break;
        case Dumpstate::BugreportMode::BUGREPORT_BLUETOOTH:
            options->bluetooth_only = true;
            options->do_screenshot = false;
            break;
        case Dumpstate::BugreportMode::BUGREPORT_DEFAULT:
            break;
    }
@@ -3481,8 +3516,8 @@ Dumpstate::RunStatus Dumpstate::RunInternal(int32_t calling_uid,

    std::future<std::string> snapshot_system_trace;

    bool is_dumpstate_restricted =
        options_->telephony_only || options_->wifi_only || options_->limited_only;
    bool is_dumpstate_restricted = options_->telephony_only || options_->wifi_only ||
                                   options_->limited_only || options_->bluetooth_only;
    if (!is_dumpstate_restricted) {
        // Snapshot the system trace now (if running) to avoid that dumpstate's
        // own activity pushes out interesting data from the trace ring buffer.
@@ -3510,6 +3545,8 @@ Dumpstate::RunStatus Dumpstate::RunInternal(int32_t calling_uid,
        DumpstateLimitedOnly();
    } else if (options_->onboarding_only) {
        DumpstateOnboardingOnly();
    } else if (options_->bluetooth_only) {
        DumpstateBluetoothOnly();
    } else {
        // Dump state for the default case. This also drops root.
        RunStatus s = DumpstateDefaultAfterCritical();
+2 −0
Original line number Diff line number Diff line
@@ -202,6 +202,7 @@ class Dumpstate {
        BUGREPORT_TELEPHONY = android::os::IDumpstate::BUGREPORT_MODE_TELEPHONY,
        BUGREPORT_WIFI = android::os::IDumpstate::BUGREPORT_MODE_WIFI,
        BUGREPORT_ONBOARDING = android::os::IDumpstate::BUGREPORT_MODE_ONBOARDING,
        BUGREPORT_BLUETOOTH = android::os::IDumpstate::BUGREPORT_MODE_BLUETOOTH,
        BUGREPORT_DEFAULT = android::os::IDumpstate::BUGREPORT_MODE_DEFAULT
    };

@@ -420,6 +421,7 @@ class Dumpstate {
        bool telephony_only = false;
        bool wifi_only = false;
        bool onboarding_only = false;
        bool bluetooth_only = false;
        // Trimmed-down version of dumpstate to only include whitelisted logs.
        bool limited_only = false;
        // Whether progress updates should be published.