Support to let listener know critical dump is finished
BUG: 153809412
Test: atest dumpstate_test
Change-Id: Id4b5c762e335adaa645fabca2b00e378a0c30ce4
diff --git a/cmds/dumpstate/binder/android/os/IDumpstateListener.aidl b/cmds/dumpstate/binder/android/os/IDumpstateListener.aidl
index 8ff4ca6..a5e6c68 100644
--- a/cmds/dumpstate/binder/android/os/IDumpstateListener.aidl
+++ b/cmds/dumpstate/binder/android/os/IDumpstateListener.aidl
@@ -68,4 +68,9 @@
* Called when screenshot is taken.
*/
oneway void onScreenshotTaken(boolean success);
+
+ /**
+ * Called when ui intensive bugreport dumps are finished.
+ */
+ oneway void onUiIntensiveBugreportDumpsFinished(String callingPackage);
}
diff --git a/cmds/dumpstate/dumpstate.cpp b/cmds/dumpstate/dumpstate.cpp
index c85c7cf..1911119 100644
--- a/cmds/dumpstate/dumpstate.cpp
+++ b/cmds/dumpstate/dumpstate.cpp
@@ -2630,11 +2630,13 @@
if (options_->telephony_only) {
MaybeTakeEarlyScreenshot();
+ onUiIntensiveBugreportDumpsFinished(calling_uid, calling_package);
MaybeCheckUserConsent(calling_uid, calling_package);
DumpstateTelephonyOnly(calling_package);
DumpstateBoard();
} else if (options_->wifi_only) {
MaybeTakeEarlyScreenshot();
+ onUiIntensiveBugreportDumpsFinished(calling_uid, calling_package);
MaybeCheckUserConsent(calling_uid, calling_package);
DumpstateWifiOnly();
} else {
@@ -2643,6 +2645,7 @@
// Take screenshot and get consent only after critical dumpsys has finished.
MaybeTakeEarlyScreenshot();
+ onUiIntensiveBugreportDumpsFinished(calling_uid, calling_package);
MaybeCheckUserConsent(calling_uid, calling_package);
// Dump state for the default case. This also drops root.
@@ -2732,6 +2735,19 @@
TakeScreenshot();
}
+void Dumpstate::onUiIntensiveBugreportDumpsFinished(int32_t calling_uid,
+ const std::string& calling_package) {
+ if (calling_uid == AID_SHELL || !CalledByApi()) {
+ return;
+ }
+ if (listener_ != nullptr) {
+ // Let listener know ui intensive bugreport dumps are finished, then it can do event
+ // handling if required.
+ android::String16 package(calling_package.c_str());
+ listener_->onUiIntensiveBugreportDumpsFinished(package);
+ }
+}
+
void Dumpstate::MaybeCheckUserConsent(int32_t calling_uid, const std::string& calling_package) {
if (calling_uid == AID_SHELL || !CalledByApi()) {
// No need to get consent for shell triggered dumpstates, or not through
diff --git a/cmds/dumpstate/dumpstate.h b/cmds/dumpstate/dumpstate.h
index 498f338..28d8936 100644
--- a/cmds/dumpstate/dumpstate.h
+++ b/cmds/dumpstate/dumpstate.h
@@ -509,6 +509,9 @@
void MaybeTakeEarlyScreenshot();
+ void onUiIntensiveBugreportDumpsFinished(int32_t calling_uid,
+ const std::string& calling_package);
+
void MaybeCheckUserConsent(int32_t calling_uid, const std::string& calling_package);
// Removes the in progress files output files (tmp file, zip/txt file, screenshot),
diff --git a/cmds/dumpstate/tests/dumpstate_smoke_test.cpp b/cmds/dumpstate/tests/dumpstate_smoke_test.cpp
index 047a1c3..6f2d754 100644
--- a/cmds/dumpstate/tests/dumpstate_smoke_test.cpp
+++ b/cmds/dumpstate/tests/dumpstate_smoke_test.cpp
@@ -173,6 +173,15 @@
return binder::Status::ok();
}
+ binder::Status onUiIntensiveBugreportDumpsFinished(const android::String16& callingpackage)
+ override {
+ std::lock_guard <std::mutex> lock(lock_);
+ std::string callingpackageUtf8 = std::string(String8(callingpackage).string());
+ dprintf(out_fd_, "\rCalling package of ui intensive bugreport dumps finished: %s",
+ callingpackageUtf8.c_str());
+ return binder::Status::ok();
+ }
+
bool getIsFinished() {
std::lock_guard<std::mutex> lock(lock_);
return is_finished_;
diff --git a/cmds/dumpstate/tests/dumpstate_test.cpp b/cmds/dumpstate/tests/dumpstate_test.cpp
index 2efb130..9871a3b 100644
--- a/cmds/dumpstate/tests/dumpstate_test.cpp
+++ b/cmds/dumpstate/tests/dumpstate_test.cpp
@@ -66,6 +66,8 @@
MOCK_METHOD1(onError, binder::Status(int32_t error_code));
MOCK_METHOD0(onFinished, binder::Status());
MOCK_METHOD1(onScreenshotTaken, binder::Status(bool success));
+ MOCK_METHOD1(onUiIntensiveBugreportDumpsFinished,
+ binder::Status(const android::String16& callingpackage));
protected:
MOCK_METHOD0(onAsBinder, IBinder*());