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

Commit 2843755d authored by Paul Chang's avatar Paul Chang Committed by Automerger Merge Worker
Browse files

Merge "Support to let listener know critical dump is finished" into rvc-dev...

Merge "Support to let listener know critical dump is finished" into rvc-dev am: dc64a603 am: 6482590e

Change-Id: Ib9bc6cc11f9f4b708fd4147b399e625c0e1313e3
parents 782caa3c 6482590e
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -68,4 +68,9 @@ interface IDumpstateListener {
     * Called when screenshot is taken.
     */
    oneway void onScreenshotTaken(boolean success);

    /**
     * Called when ui intensive bugreport dumps are finished.
     */
    oneway void onUiIntensiveBugreportDumpsFinished(String callingPackage);
}
+16 −0
Original line number Diff line number Diff line
@@ -2630,11 +2630,13 @@ Dumpstate::RunStatus Dumpstate::RunInternal(int32_t calling_uid,

    if (options_->telephony_only) {
        MaybeTakeEarlyScreenshot();
        onUiIntensiveBugreportDumpsFinished(calling_uid, calling_package);
        MaybeCheckUserConsent(calling_uid, calling_package);
        DumpstateTelephonyOnly(calling_package);
        DumpstateBoard();
    } else if (options_->wifi_only) {
        MaybeTakeEarlyScreenshot();
        onUiIntensiveBugreportDumpsFinished(calling_uid, calling_package);
        MaybeCheckUserConsent(calling_uid, calling_package);
        DumpstateWifiOnly();
    } else {
@@ -2643,6 +2645,7 @@ Dumpstate::RunStatus Dumpstate::RunInternal(int32_t calling_uid,

        // 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.
@@ -2732,6 +2735,19 @@ void Dumpstate::MaybeTakeEarlyScreenshot() {
    TakeScreenshot();
}

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

void Dumpstate::MaybeCheckUserConsent(int32_t calling_uid, const std::string& calling_package) {
    if (calling_uid == AID_SHELL || !CalledByApi()) {
        // No need to get consent for shell triggered dumpstates, or not through
+3 −0
Original line number Diff line number Diff line
@@ -509,6 +509,9 @@ class Dumpstate {

    void MaybeTakeEarlyScreenshot();

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

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

    // Removes the in progress files output files (tmp file, zip/txt file, screenshot),
+9 −0
Original line number Diff line number Diff line
@@ -173,6 +173,15 @@ class DumpstateListener : public BnDumpstateListener {
        return binder::Status::ok();
    }

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

    bool getIsFinished() {
        std::lock_guard<std::mutex> lock(lock_);
        return is_finished_;
+2 −0
Original line number Diff line number Diff line
@@ -66,6 +66,8 @@ class DumpstateListenerMock : public IDumpstateListener {
    MOCK_METHOD1(onError, binder::Status(int32_t error_code));
    MOCK_METHOD0(onFinished, binder::Status());
    MOCK_METHOD1(onScreenshotTaken, binder::Status(bool success));
    MOCK_METHOD1(onUiIntensiveBugreportDumpsFinished,
        binder::Status(const android::String16& callingpackage));

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