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
diff --git a/cmds/dumpstate/dumpstate.cpp b/cmds/dumpstate/dumpstate.cpp
index 9a11da6..b83d17e 100644
--- a/cmds/dumpstate/dumpstate.cpp
+++ b/cmds/dumpstate/dumpstate.cpp
@@ -1948,6 +1948,8 @@
return "BUGREPORT_TELEPHONY";
case Dumpstate::BugreportMode::BUGREPORT_WIFI:
return "BUGREPORT_WIFI";
+ case Dumpstate::BugreportMode::BUGREPORT_DEFAULT:
+ return "BUGREPORT_DEFAULT";
}
}
@@ -1988,12 +1990,14 @@
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 @@
// 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") {