summaryrefslogtreecommitdiff
path: root/cmds/dumpstate/dumpstate.cpp
diff options
context:
space:
mode:
author Nandana Dutt <nandana@google.com> 2019-01-30 10:55:37 +0000
committer Gerrit Code Review <noreply-gerritcodereview@google.com> 2019-01-30 10:55:37 +0000
commit6b8e52c805f124f8b1d7e511ae68d01d0769c32b (patch)
tree01da11535792f4bb0c16e610bd74e36d6e6f016e /cmds/dumpstate/dumpstate.cpp
parentc4f5492a93eb569afa2ae5452705d05fb2b21207 (diff)
parente78c3d7c62bd904fdf4a05aea482e50a78dbfb87 (diff)
Merge "Use screenshot file descriptor if available"
Diffstat (limited to 'cmds/dumpstate/dumpstate.cpp')
-rw-r--r--cmds/dumpstate/dumpstate.cpp13
1 files changed, 10 insertions, 3 deletions
diff --git a/cmds/dumpstate/dumpstate.cpp b/cmds/dumpstate/dumpstate.cpp
index dfc5b49c6f..15cea833b2 100644
--- a/cmds/dumpstate/dumpstate.cpp
+++ b/cmds/dumpstate/dumpstate.cpp
@@ -2475,6 +2475,13 @@ Dumpstate::RunStatus Dumpstate::RunInternal(int32_t calling_uid,
// bugreport is not shared but made available for manual retrieval.
return status;
}
+ if (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_);
+ }
+ }
}
/* vibrate a few but shortly times to let user know it's finished */
@@ -2560,9 +2567,9 @@ Dumpstate::RunStatus Dumpstate::CopyBugreportIfUserConsented() {
return HandleUserConsentDenied();
}
if (consent_result == UserConsentResult::APPROVED) {
- bool copy_succeeded = android::os::CopyFileToFd(ds.path_, ds.options_->bugreport_fd.get());
- if (copy_succeeded && remove(ds.path_.c_str())) {
- MYLOGE("remove(%s): %s", ds.path_.c_str(), strerror(errno));
+ bool copy_succeeded = android::os::CopyFileToFd(path_, options_->bugreport_fd.get());
+ if (copy_succeeded) {
+ android::os::UnlinkAndLogOnError(path_);
}
return copy_succeeded ? Dumpstate::RunStatus::OK : Dumpstate::RunStatus::ERROR;
} else if (consent_result == UserConsentResult::UNAVAILABLE) {