Loading cmds/dumpstate/dumpstate.cpp +9 −5 Original line number Diff line number Diff line Loading @@ -1989,12 +1989,12 @@ static void PrepareToWriteToFile() { } if (ds.options_->do_fb) { ds.screenshot_path_ = ds.GetPath(".png"); ds.screenshot_path_ = ds.GetPath(ds.CalledByApi() ? "-tmp.png" : ".png"); } ds.tmp_path_ = ds.GetPath(".tmp"); ds.log_path_ = ds.GetPath("-dumpstate_log-" + std::to_string(ds.pid_) + ".txt"); std::string destination = ds.options_->bugreport_fd.get() != -1 std::string destination = ds.CalledByApi() ? StringPrintf("[fd:%d]", ds.options_->bugreport_fd.get()) : ds.bugreport_internal_dir_.c_str(); MYLOGD( Loading @@ -2008,7 +2008,7 @@ static void PrepareToWriteToFile() { ds.tmp_path_.c_str(), ds.screenshot_path_.c_str()); if (ds.options_->do_zip_file) { ds.path_ = ds.GetPath(".zip"); ds.path_ = ds.GetPath(ds.CalledByApi() ? "-tmp.zip" : ".zip"); MYLOGD("Creating initial .zip file (%s)\n", ds.path_.c_str()); create_parent_dirs(ds.path_.c_str()); ds.zip_file.reset(fopen(ds.path_.c_str(), "wb")); Loading Loading @@ -2043,7 +2043,7 @@ static void FinalizeFile() { MYLOGI("changing suffix from %s to %s\n", ds.name_.c_str(), name.c_str()); ds.name_ = name; if (!ds.screenshot_path_.empty()) { std::string new_screenshot_path = ds.GetPath(".png"); std::string new_screenshot_path = ds.GetPath(ds.CalledByApi() ? "-tmp.png" : ".png"); if (rename(ds.screenshot_path_.c_str(), new_screenshot_path.c_str())) { MYLOGE("rename(%s, %s): %s\n", ds.screenshot_path_.c_str(), new_screenshot_path.c_str(), strerror(errno)); Loading @@ -2061,7 +2061,7 @@ static void FinalizeFile() { } else { do_text_file = false; // If the user has changed the suffix, we need to change the zip file name. std::string new_path = ds.GetPath(".zip"); std::string new_path = ds.GetPath(ds.CalledByApi() ? "-tmp.zip" : ".zip"); if (ds.path_ != new_path) { MYLOGD("Renaming zip file from %s to %s\n", ds.path_.c_str(), new_path.c_str()); if (rename(ds.path_.c_str(), new_path.c_str())) { Loading Loading @@ -2716,6 +2716,10 @@ bool Dumpstate::IsUserConsentDenied() const { ds.consent_callback_->getResult() == UserConsentResult::DENIED; } bool Dumpstate::CalledByApi() const { return ds.options_->bugreport_fd.get() != -1 ? true : false; } void Dumpstate::CleanupFiles() { android::os::UnlinkAndLogOnError(tmp_path_); android::os::UnlinkAndLogOnError(screenshot_path_); Loading cmds/dumpstate/dumpstate.h +5 −0 Original line number Diff line number Diff line Loading @@ -340,6 +340,11 @@ class Dumpstate { */ bool IsUserConsentDenied() const; /* * Returns true if dumpstate is called by bugreporting API */ bool CalledByApi() const; /* * Structure to hold options that determine the behavior of dumpstate. */ Loading Loading
cmds/dumpstate/dumpstate.cpp +9 −5 Original line number Diff line number Diff line Loading @@ -1989,12 +1989,12 @@ static void PrepareToWriteToFile() { } if (ds.options_->do_fb) { ds.screenshot_path_ = ds.GetPath(".png"); ds.screenshot_path_ = ds.GetPath(ds.CalledByApi() ? "-tmp.png" : ".png"); } ds.tmp_path_ = ds.GetPath(".tmp"); ds.log_path_ = ds.GetPath("-dumpstate_log-" + std::to_string(ds.pid_) + ".txt"); std::string destination = ds.options_->bugreport_fd.get() != -1 std::string destination = ds.CalledByApi() ? StringPrintf("[fd:%d]", ds.options_->bugreport_fd.get()) : ds.bugreport_internal_dir_.c_str(); MYLOGD( Loading @@ -2008,7 +2008,7 @@ static void PrepareToWriteToFile() { ds.tmp_path_.c_str(), ds.screenshot_path_.c_str()); if (ds.options_->do_zip_file) { ds.path_ = ds.GetPath(".zip"); ds.path_ = ds.GetPath(ds.CalledByApi() ? "-tmp.zip" : ".zip"); MYLOGD("Creating initial .zip file (%s)\n", ds.path_.c_str()); create_parent_dirs(ds.path_.c_str()); ds.zip_file.reset(fopen(ds.path_.c_str(), "wb")); Loading Loading @@ -2043,7 +2043,7 @@ static void FinalizeFile() { MYLOGI("changing suffix from %s to %s\n", ds.name_.c_str(), name.c_str()); ds.name_ = name; if (!ds.screenshot_path_.empty()) { std::string new_screenshot_path = ds.GetPath(".png"); std::string new_screenshot_path = ds.GetPath(ds.CalledByApi() ? "-tmp.png" : ".png"); if (rename(ds.screenshot_path_.c_str(), new_screenshot_path.c_str())) { MYLOGE("rename(%s, %s): %s\n", ds.screenshot_path_.c_str(), new_screenshot_path.c_str(), strerror(errno)); Loading @@ -2061,7 +2061,7 @@ static void FinalizeFile() { } else { do_text_file = false; // If the user has changed the suffix, we need to change the zip file name. std::string new_path = ds.GetPath(".zip"); std::string new_path = ds.GetPath(ds.CalledByApi() ? "-tmp.zip" : ".zip"); if (ds.path_ != new_path) { MYLOGD("Renaming zip file from %s to %s\n", ds.path_.c_str(), new_path.c_str()); if (rename(ds.path_.c_str(), new_path.c_str())) { Loading Loading @@ -2716,6 +2716,10 @@ bool Dumpstate::IsUserConsentDenied() const { ds.consent_callback_->getResult() == UserConsentResult::DENIED; } bool Dumpstate::CalledByApi() const { return ds.options_->bugreport_fd.get() != -1 ? true : false; } void Dumpstate::CleanupFiles() { android::os::UnlinkAndLogOnError(tmp_path_); android::os::UnlinkAndLogOnError(screenshot_path_); Loading
cmds/dumpstate/dumpstate.h +5 −0 Original line number Diff line number Diff line Loading @@ -340,6 +340,11 @@ class Dumpstate { */ bool IsUserConsentDenied() const; /* * Returns true if dumpstate is called by bugreporting API */ bool CalledByApi() const; /* * Structure to hold options that determine the behavior of dumpstate. */ Loading