summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAbhijeet Kaur <abkaur@google.com>2020-04-01 17:22:36 +0100
committerRhed Jao <rhedjao@google.com>2020-06-22 11:52:28 +0000
commit90f8249030e02080e937eeed12fc8c8c692bbc64 (patch)
treefe832855e02b8281be9b14b0cb21fb6cb6fac06d
parenta03e1302db3c51be1e453af179e5549468b501ab (diff)
downloadnative-90f8249030e02080e937eeed12fc8c8c692bbc64.tar.gz
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
-rw-r--r--cmds/dumpstate/dumpstate.cpp14
1 files changed, 7 insertions, 7 deletions
diff --git a/cmds/dumpstate/dumpstate.cpp b/cmds/dumpstate/dumpstate.cpp
index 4ac7b689cf..f4d4f9364f 100644
--- a/cmds/dumpstate/dumpstate.cpp
+++ b/cmds/dumpstate/dumpstate.cpp
@@ -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) {