diff options
Diffstat (limited to 'cmds/dumpstate/dumpstate.cpp')
| -rw-r--r-- | cmds/dumpstate/dumpstate.cpp | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/cmds/dumpstate/dumpstate.cpp b/cmds/dumpstate/dumpstate.cpp index c1a4b3bc9a..bce2edb6f8 100644 --- a/cmds/dumpstate/dumpstate.cpp +++ b/cmds/dumpstate/dumpstate.cpp @@ -34,6 +34,7 @@ #include <unistd.h> #include <chrono> +#include <fstream> #include <functional> #include <future> #include <memory> @@ -194,6 +195,15 @@ static bool UnlinkAndLogOnError(const std::string& file) { return true; } +static bool IsFileEmpty(const std::string& file_path) { + std::ifstream file(file_path, std::ios::binary | std::ios::ate); + if(file.bad()) { + MYLOGE("Cannot open file: %s\n", file_path.c_str()); + return true; + } + return file.tellg() <= 0; +} + } // namespace } // namespace os } // namespace android @@ -2143,7 +2153,7 @@ static void SendBugreportFinishedBroadcast() { "--es", "android.intent.extra.DUMPSTATE_LOG", ds.log_path_ }; // clang-format on - if (ds.options_->do_fb) { + if (ds.options_->do_fb && !android::os::IsFileEmpty(ds.screenshot_path_)) { am_args.push_back("--es"); am_args.push_back("android.intent.extra.SCREENSHOT"); am_args.push_back(ds.screenshot_path_); @@ -2219,13 +2229,13 @@ static void SetOptionsFromMode(Dumpstate::BugreportMode mode, Dumpstate::DumpOpt break; case Dumpstate::BugreportMode::BUGREPORT_TELEPHONY: options->telephony_only = true; - options->do_fb = true; + options->do_fb = false; options->do_broadcast = true; break; case Dumpstate::BugreportMode::BUGREPORT_WIFI: options->wifi_only = true; options->do_zip_file = true; - options->do_fb = true; + options->do_fb = false; options->do_broadcast = true; break; case Dumpstate::BugreportMode::BUGREPORT_DEFAULT: |