From 904e0e0f01e18e2b358f61df158a6beb599a4636 Mon Sep 17 00:00:00 2001 From: Abhijeet Kaur Date: Wed, 5 Dec 2018 14:03:01 +0000 Subject: Fix adb bugreport and add bugreport unit tests. Commit 58d72e2 introduced a regression, which made fullbugreport as the default mode. This lead to 'adb bugreport SAMPLE_BR' triggering a progress notification on the device as it inherited do_broadcast from full bugreport. Fix the issue by separating full bugreport from default bugreport. Add unit tests for all the cases of calling bugreport. Bug: 119877616 Test: Verified that 'adb bugreport SAMPLE_BR' does not show any notification on the device. Test: mmm -j frameworks/native/cmds/dumpstate/ && adb push ${OUT}/data/nativetest64/dumpstate_test* /data/nativetest64 && adb shell /data/nativetest64/dumpstate_test/dumpstate_test && printf "\n\n#### ALL TESTS PASSED ####\n" Change-Id: I06e57454a91a3276dd89d47b3b0a04d3d85f32da --- cmds/dumpstate/dumpstate.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'cmds/dumpstate/dumpstate.cpp') diff --git a/cmds/dumpstate/dumpstate.cpp b/cmds/dumpstate/dumpstate.cpp index 9a11da626c..b83d17e1e8 100644 --- a/cmds/dumpstate/dumpstate.cpp +++ b/cmds/dumpstate/dumpstate.cpp @@ -1948,6 +1948,8 @@ static inline const char* ModeToString(Dumpstate::BugreportMode mode) { return "BUGREPORT_TELEPHONY"; case Dumpstate::BugreportMode::BUGREPORT_WIFI: return "BUGREPORT_WIFI"; + case Dumpstate::BugreportMode::BUGREPORT_DEFAULT: + return "BUGREPORT_DEFAULT"; } } @@ -1988,12 +1990,14 @@ static void SetOptionsFromMode(Dumpstate::BugreportMode mode, Dumpstate::DumpOpt options->do_fb = true; options->do_broadcast = true; break; + case Dumpstate::BugreportMode::BUGREPORT_DEFAULT: + break; } } static Dumpstate::BugreportMode getBugreportModeFromProperty() { - // If the system property is not set, it's assumed to be a full bugreport. - Dumpstate::BugreportMode mode = Dumpstate::BugreportMode::BUGREPORT_FULL; + // If the system property is not set, it's assumed to be a default bugreport. + Dumpstate::BugreportMode mode = Dumpstate::BugreportMode::BUGREPORT_DEFAULT; std::string extra_options = android::base::GetProperty(PROPERTY_EXTRA_OPTIONS, ""); if (!extra_options.empty()) { @@ -2001,6 +2005,8 @@ static Dumpstate::BugreportMode getBugreportModeFromProperty() { // Currently, it contains the type of the requested bugreport. if (extra_options == "bugreportplus") { mode = Dumpstate::BugreportMode::BUGREPORT_INTERACTIVE; + } else if (extra_options == "bugreportfull") { + mode = Dumpstate::BugreportMode::BUGREPORT_FULL; } else if (extra_options == "bugreportremote") { mode = Dumpstate::BugreportMode::BUGREPORT_REMOTE; } else if (extra_options == "bugreportwear") { -- cgit v1.2.3-59-g8ed1b