Call new dumpstate listener methods
The old listener methods are still connected, but will be removed soon.
Also fixed the progress debug logs, which rarely work since the guard
condition is rarely met.
BUG: 111441001
Test: adb shell /data/nativetest64/dumpstate_test/dumpstate_test
Change-Id: I29b95685df89d0bbebde7d95d496500bf51f4aaa
diff --git a/cmds/dumpstate/dumpstate.cpp b/cmds/dumpstate/dumpstate.cpp
index 712f861..a45775a 100644
--- a/cmds/dumpstate/dumpstate.cpp
+++ b/cmds/dumpstate/dumpstate.cpp
@@ -2256,6 +2256,28 @@
options_ = std::move(options);
}
+Dumpstate::RunStatus Dumpstate::Run() {
+ Dumpstate::RunStatus status = RunInternal();
+ if (listener_ != nullptr) {
+ switch (status) {
+ case Dumpstate::RunStatus::OK:
+ // TODO(b/111441001): duration argument does not make sense. Remove.
+ listener_->onFinished(0 /* duration */, options_->notification_title,
+ options_->notification_description);
+ break;
+ case Dumpstate::RunStatus::HELP:
+ break;
+ case Dumpstate::RunStatus::INVALID_INPUT:
+ listener_->onError(android::os::IDumpstateListener::BUGREPORT_ERROR_INVALID_INPUT);
+ break;
+ case Dumpstate::RunStatus::ERROR:
+ listener_->onError(android::os::IDumpstateListener::BUGREPORT_ERROR_RUNTIME_ERROR);
+ break;
+ }
+ }
+ return status;
+}
+
/*
* Dumps relevant information to a bugreport based on the given options.
*
@@ -2277,7 +2299,7 @@
* Bugreports are first generated in a local directory and later copied to the caller's fd or
* directory.
*/
-Dumpstate::RunStatus Dumpstate::Run() {
+Dumpstate::RunStatus Dumpstate::RunInternal() {
LogDumpOptions(*options_);
if (!options_->ValidateOptions()) {
MYLOGE("Invalid options specified\n");
@@ -2482,6 +2504,7 @@
/* tell activity manager we're done */
if (options_->do_broadcast) {
SendBugreportFinishedBroadcast();
+ // Note that listener_ is notified in Run();
}
MYLOGD("Final progress: %d/%d (estimated %d)\n", progress_->Get(), progress_->GetMax(),