diff options
| author | 2019-01-30 03:22:38 -0800 | |
|---|---|---|
| committer | 2019-01-30 03:22:38 -0800 | |
| commit | 95365b3d39bcc69827d61ae7c95e24b0b02cde9c (patch) | |
| tree | b32150544d8fdf09662e5457d59c62c7abeff19f | |
| parent | 36cd6f415f8cba155b4737e56b93f4396e035497 (diff) | |
| parent | 24591ba9e7608d87e792069924cf9df84bf927ca (diff) | |
Merge "Use screenshot file descriptor if available" am: 6b8e52c805
am: 24591ba9e7
Change-Id: I1d177058b2c1d148f1ed4b6f25319b1af7aafb2d
| -rw-r--r-- | cmds/dumpstate/dumpstate.cpp | 13 | ||||
| -rw-r--r-- | cmds/dumpstate/dumpstate.h | 1 |
2 files changed, 10 insertions, 4 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) { diff --git a/cmds/dumpstate/dumpstate.h b/cmds/dumpstate/dumpstate.h index 4766d82909..7fb2f3b2e9 100644 --- a/cmds/dumpstate/dumpstate.h +++ b/cmds/dumpstate/dumpstate.h @@ -347,7 +347,6 @@ class Dumpstate { // File descriptor to output zip file. android::base::unique_fd bugreport_fd; // File descriptor to screenshot file. - // TODO(b/111441001): Use this fd. android::base::unique_fd screenshot_fd; // TODO: rename to MODE. // Extra options passed as system property. |