Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d6baced7 authored by Abhijeet Kaur's avatar Abhijeet Kaur Committed by android-build-merger
Browse files

Merge "Lite bugreports(wifi/telephony) don't need screenshots" am: e5e82852 am: e743811c

am: 3b0819bb

Change-Id: Ia79dbfda8c5a74a414e699551c4709efaa359881
parents f94f4244 3b0819bb
Loading
Loading
Loading
Loading
+13 −3
Original line number Diff line number Diff line
@@ -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
@@ -2149,7 +2159,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_);
@@ -2225,13 +2235,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:
+2 −2
Original line number Diff line number Diff line
@@ -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);