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

Commit 90f82490 authored by Abhijeet Kaur's avatar Abhijeet Kaur Committed by Rhed Jao
Browse files

Copy Screenshot to fd if and only if user consent approved

Currently the dumpstate screenshot file is copied to the screenshot fd
(provided by the API caller) even when user consent times out.

Bug: 152944488
Test: BugreportManagerTest#normalflow_full
Change-Id: I0ede8bc8cf5333ea586218a37fd6456f782a50c7
Merged-in: I0ede8bc8cf5333ea586218a37fd6456f782a50c7
parent a03e1302
Loading
Loading
Loading
Loading
+7 −7
Original line number Diff line number Diff line
@@ -2717,13 +2717,6 @@ Dumpstate::RunStatus Dumpstate::RunInternal(int32_t calling_uid,
            MYLOGI("User denied consent. Returning\n");
            return status;
        }
        if (options_->do_fb && options_->screenshot_fd.get() != -1) {
            bool copy_succeeded = android::os::CopyFileToFd(screenshot_path_,
                                                            options_->screenshot_fd.get());
            if (copy_succeeded) {
                android::os::UnlinkAndLogOnError(screenshot_path_);
            }
        }
        if (status == Dumpstate::RunStatus::USER_CONSENT_TIMED_OUT) {
            MYLOGI(
                "Did not receive user consent yet."
@@ -2831,6 +2824,13 @@ Dumpstate::RunStatus Dumpstate::CopyBugreportIfUserConsented() {
        bool copy_succeeded = android::os::CopyFileToFd(path_, options_->bugreport_fd.get());
        if (copy_succeeded) {
            android::os::UnlinkAndLogOnError(path_);
            if (options_->do_fb && options_->screenshot_fd.get() != -1) {
                copy_succeeded = android::os::CopyFileToFd(screenshot_path_,
                                                           options_->screenshot_fd.get());
                if (copy_succeeded) {
                    android::os::UnlinkAndLogOnError(screenshot_path_);
                }
            }
        }
        return copy_succeeded ? Dumpstate::RunStatus::OK : Dumpstate::RunStatus::ERROR;
    } else if (consent_result == UserConsentResult::UNAVAILABLE) {