diff options
| -rw-r--r-- | cmds/dumpstate/binder/android/os/IDumpstateListener.aidl | 5 | ||||
| -rw-r--r-- | cmds/dumpstate/dumpstate.cpp | 16 | ||||
| -rw-r--r-- | cmds/dumpstate/dumpstate.h | 3 | ||||
| -rw-r--r-- | cmds/dumpstate/tests/dumpstate_smoke_test.cpp | 9 | ||||
| -rw-r--r-- | cmds/dumpstate/tests/dumpstate_test.cpp | 2 |
5 files changed, 35 insertions, 0 deletions
diff --git a/cmds/dumpstate/binder/android/os/IDumpstateListener.aidl b/cmds/dumpstate/binder/android/os/IDumpstateListener.aidl index 8ff4ca6474..a5e6c68363 100644 --- a/cmds/dumpstate/binder/android/os/IDumpstateListener.aidl +++ b/cmds/dumpstate/binder/android/os/IDumpstateListener.aidl @@ -68,4 +68,9 @@ interface IDumpstateListener { * 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 c85c7cf048..19111198ab 100644 --- a/cmds/dumpstate/dumpstate.cpp +++ b/cmds/dumpstate/dumpstate.cpp @@ -2630,11 +2630,13 @@ Dumpstate::RunStatus Dumpstate::RunInternal(int32_t calling_uid, 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 @@ Dumpstate::RunStatus Dumpstate::RunInternal(int32_t calling_uid, // 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 @@ void Dumpstate::MaybeTakeEarlyScreenshot() { 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 498f338227..28d8936828 100644 --- a/cmds/dumpstate/dumpstate.h +++ b/cmds/dumpstate/dumpstate.h @@ -509,6 +509,9 @@ class Dumpstate { 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 047a1c38f0..6f2d75403d 100644 --- a/cmds/dumpstate/tests/dumpstate_smoke_test.cpp +++ b/cmds/dumpstate/tests/dumpstate_smoke_test.cpp @@ -173,6 +173,15 @@ class DumpstateListener : public BnDumpstateListener { 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 2efb130776..9871a3bd6c 100644 --- a/cmds/dumpstate/tests/dumpstate_test.cpp +++ b/cmds/dumpstate/tests/dumpstate_test.cpp @@ -66,6 +66,8 @@ class DumpstateListenerMock : public IDumpstateListener { 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*()); |