diff options
| author | 2019-03-27 07:07:15 -0700 | |
|---|---|---|
| committer | 2019-03-27 07:07:15 -0700 | |
| commit | e743811c0539e2bc91febe2fc76a4830f1e25208 (patch) | |
| tree | e639989d73372af833e11723ba5fefc09e1e993b | |
| parent | 5df11f46ee088533d1558cd5eee0e251495a1702 (diff) | |
| parent | e5e8285246a7807e247f02d2e0460ced47664326 (diff) | |
Merge "Lite bugreports(wifi/telephony) don't need screenshots"
am: e5e8285246
Change-Id: I7d56e7884bb4053beab6c216e970cc84aa65a736
| -rw-r--r-- | cmds/dumpstate/dumpstate.cpp | 16 | ||||
| -rw-r--r-- | cmds/dumpstate/tests/dumpstate_test.cpp | 4 |
2 files changed, 15 insertions, 5 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: diff --git a/cmds/dumpstate/tests/dumpstate_test.cpp b/cmds/dumpstate/tests/dumpstate_test.cpp index eb73d41dc4..e6a7735d60 100644 --- a/cmds/dumpstate/tests/dumpstate_test.cpp +++ b/cmds/dumpstate/tests/dumpstate_test.cpp @@ -373,7 +373,7 @@ TEST_F(DumpOptionsTest, InitializeTelephonyBugReport) { EXPECT_EQ(status, Dumpstate::RunStatus::OK); EXPECT_TRUE(options_.do_add_date); - EXPECT_TRUE(options_.do_fb); + EXPECT_FALSE(options_.do_fb); EXPECT_TRUE(options_.do_broadcast); EXPECT_TRUE(options_.do_zip_file); EXPECT_TRUE(options_.telephony_only); @@ -404,7 +404,7 @@ TEST_F(DumpOptionsTest, InitializeWifiBugReport) { EXPECT_EQ(status, Dumpstate::RunStatus::OK); EXPECT_TRUE(options_.do_add_date); - EXPECT_TRUE(options_.do_fb); + EXPECT_FALSE(options_.do_fb); EXPECT_TRUE(options_.do_broadcast); EXPECT_TRUE(options_.do_zip_file); EXPECT_TRUE(options_.wifi_only); |