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

Commit 9b795b5f authored by Gavin Corkery's avatar Gavin Corkery Committed by Gerrit Code Review
Browse files

Merge changes from topic "remove-duplicate-br-calls"

* changes:
  Reduce duplicate calls for restricted dump options
  Remove unnecessary code for new BugreportManager
parents adf390d7 6968f552
Loading
Loading
Loading
Loading
+1 −1
Original line number Original line Diff line number Diff line
@@ -72,5 +72,5 @@ interface IDumpstateListener {
    /**
    /**
     * Called when ui intensive bugreport dumps are finished.
     * Called when ui intensive bugreport dumps are finished.
     */
     */
    oneway void onUiIntensiveBugreportDumpsFinished(String callingPackage);
    oneway void onUiIntensiveBugreportDumpsFinished();
}
}
+12 −22
Original line number Original line Diff line number Diff line
@@ -2863,31 +2863,23 @@ Dumpstate::RunStatus Dumpstate::RunInternal(int32_t calling_uid,
    // duration is logged into MYLOG instead.
    // duration is logged into MYLOG instead.
    PrintHeader();
    PrintHeader();


    // TODO(b/158737089) reduce code repetition in if branches
    bool is_dumpstate_restricted = options_->telephony_only
    if (options_->telephony_only) {
                                   || options_->wifi_only
                                   || options_->limited_only;
    if (!is_dumpstate_restricted) {
        // Invoke critical dumpsys first to preserve system state, before doing anything else.
        RunDumpsysCritical();
    }
    MaybeTakeEarlyScreenshot();
    MaybeTakeEarlyScreenshot();
        onUiIntensiveBugreportDumpsFinished(calling_uid, calling_package);
    onUiIntensiveBugreportDumpsFinished(calling_uid);
    MaybeCheckUserConsent(calling_uid, calling_package);
    MaybeCheckUserConsent(calling_uid, calling_package);
    if (options_->telephony_only) {
        DumpstateTelephonyOnly(calling_package);
        DumpstateTelephonyOnly(calling_package);
    } else if (options_->wifi_only) {
    } else if (options_->wifi_only) {
        MaybeTakeEarlyScreenshot();
        onUiIntensiveBugreportDumpsFinished(calling_uid, calling_package);
        MaybeCheckUserConsent(calling_uid, calling_package);
        DumpstateWifiOnly();
        DumpstateWifiOnly();
    } else if (options_->limited_only) {
    } else if (options_->limited_only) {
        MaybeTakeEarlyScreenshot();
        onUiIntensiveBugreportDumpsFinished(calling_uid, calling_package);
        MaybeCheckUserConsent(calling_uid, calling_package);
        DumpstateLimitedOnly();
        DumpstateLimitedOnly();
    } else {
    } else {
        // Invoke critical dumpsys first to preserve system state, before doing anything else.
        RunDumpsysCritical();

        // Take screenshot and get consent only after critical dumpsys has finished.
        MaybeTakeEarlyScreenshot();
        onUiIntensiveBugreportDumpsFinished(calling_uid, calling_package);
        MaybeCheckUserConsent(calling_uid, calling_package);

        // Dump state for the default case. This also drops root.
        // Dump state for the default case. This also drops root.
        RunStatus s = DumpstateDefaultAfterCritical();
        RunStatus s = DumpstateDefaultAfterCritical();
        if (s != RunStatus::OK) {
        if (s != RunStatus::OK) {
@@ -2969,16 +2961,14 @@ void Dumpstate::MaybeTakeEarlyScreenshot() {
    TakeScreenshot();
    TakeScreenshot();
}
}


void Dumpstate::onUiIntensiveBugreportDumpsFinished(int32_t calling_uid,
void Dumpstate::onUiIntensiveBugreportDumpsFinished(int32_t calling_uid) {
                                                    const std::string& calling_package) {
    if (calling_uid == AID_SHELL || !CalledByApi()) {
    if (calling_uid == AID_SHELL || !CalledByApi()) {
        return;
        return;
    }
    }
    if (listener_ != nullptr) {
    if (listener_ != nullptr) {
        // Let listener know ui intensive bugreport dumps are finished, then it can do event
        // Let listener know ui intensive bugreport dumps are finished, then it can do event
        // handling if required.
        // handling if required.
        android::String16 package(calling_package.c_str());
        listener_->onUiIntensiveBugreportDumpsFinished();
        listener_->onUiIntensiveBugreportDumpsFinished(package);
    }
    }
}
}


+1 −2
Original line number Original line Diff line number Diff line
@@ -544,8 +544,7 @@ class Dumpstate {


    void MaybeTakeEarlyScreenshot();
    void MaybeTakeEarlyScreenshot();


    void onUiIntensiveBugreportDumpsFinished(int32_t calling_uid,
    void onUiIntensiveBugreportDumpsFinished(int32_t calling_uid);
                                             const std::string& calling_package);


    void MaybeCheckUserConsent(int32_t calling_uid, const std::string& calling_package);
    void MaybeCheckUserConsent(int32_t calling_uid, const std::string& calling_package);


+2 −5
Original line number Original line Diff line number Diff line
@@ -173,12 +173,9 @@ class DumpstateListener : public BnDumpstateListener {
        return binder::Status::ok();
        return binder::Status::ok();
    }
    }


    binder::Status onUiIntensiveBugreportDumpsFinished(const android::String16& callingpackage)
    binder::Status onUiIntensiveBugreportDumpsFinished() override {
        override {
        std::lock_guard <std::mutex> lock(lock_);
        std::lock_guard <std::mutex> lock(lock_);
        std::string callingpackageUtf8 = std::string(String8(callingpackage).string());
        dprintf(out_fd_, "\rUi intensive bugreport dumps finished");
        dprintf(out_fd_, "\rCalling package of ui intensive bugreport dumps finished: %s",
                callingpackageUtf8.c_str());
        return binder::Status::ok();
        return binder::Status::ok();
    }
    }


+1 −2
Original line number Original line Diff line number Diff line
@@ -70,8 +70,7 @@ class DumpstateListenerMock : public IDumpstateListener {
    MOCK_METHOD1(onError, binder::Status(int32_t error_code));
    MOCK_METHOD1(onError, binder::Status(int32_t error_code));
    MOCK_METHOD0(onFinished, binder::Status());
    MOCK_METHOD0(onFinished, binder::Status());
    MOCK_METHOD1(onScreenshotTaken, binder::Status(bool success));
    MOCK_METHOD1(onScreenshotTaken, binder::Status(bool success));
    MOCK_METHOD1(onUiIntensiveBugreportDumpsFinished,
    MOCK_METHOD0(onUiIntensiveBugreportDumpsFinished, binder::Status());
        binder::Status(const android::String16& callingpackage));


  protected:
  protected:
    MOCK_METHOD0(onAsBinder, IBinder*());
    MOCK_METHOD0(onAsBinder, IBinder*());