Add retrieveBugreport dumpstate implementation
Adds the native logic necessary for handling the
DEFER_CONSENT flag when calling startBugreport, and
handling the retrieveBugreport API.
When calling startBugreport with the DEFER_CONSENT flag
set, the consent flow will not be invoked. Instead, the
bugreport files will be stored in the bugreport internal
directories and will only be passed to the caller's file
descriptors when the same caller invokes retrieveBugreport
at a later time.
Test: atest CtsRootBugreportTestCases
Test: atest dumpstate_test
Bug: 245328405
Change-Id: I3a46482e173c6084ebda96f08ec60a31953d5f94
diff --git a/cmds/dumpstate/dumpstate.h b/cmds/dumpstate/dumpstate.h
index 9f894b5..8a31c31 100644
--- a/cmds/dumpstate/dumpstate.h
+++ b/cmds/dumpstate/dumpstate.h
@@ -207,7 +207,9 @@
// The flags used to customize bugreport requests.
enum BugreportFlag {
BUGREPORT_USE_PREDUMPED_UI_DATA =
- android::os::IDumpstate::BUGREPORT_FLAG_USE_PREDUMPED_UI_DATA
+ android::os::IDumpstate::BUGREPORT_FLAG_USE_PREDUMPED_UI_DATA,
+ BUGREPORT_FLAG_DEFER_CONSENT =
+ android::os::IDumpstate::BUGREPORT_FLAG_DEFER_CONSENT
};
static android::os::dumpstate::CommandOptions DEFAULT_DUMPSYS;
@@ -353,6 +355,15 @@
*/
RunStatus Run(int32_t calling_uid, const std::string& calling_package);
+ /*
+ * Entry point for retrieving a previous-generated bugreport.
+ *
+ * Initialize() dumpstate before calling this method.
+ */
+ RunStatus Retrieve(int32_t calling_uid, const std::string& calling_package);
+
+
+
RunStatus ParseCommandlineAndRun(int argc, char* argv[]);
/* Deletes in-progress files */
@@ -396,6 +407,7 @@
bool progress_updates_to_socket = false;
bool do_screenshot = false;
bool is_screenshot_copied = false;
+ bool is_consent_deferred = false;
bool is_remote_mode = false;
bool show_header_only = false;
bool telephony_only = false;
@@ -548,6 +560,7 @@
private:
RunStatus RunInternal(int32_t calling_uid, const std::string& calling_package);
+ RunStatus RetrieveInternal(int32_t calling_uid, const std::string& calling_package);
RunStatus DumpstateDefaultAfterCritical();
RunStatus dumpstate();
@@ -572,6 +585,8 @@
RunStatus HandleUserConsentDenied();
+ void HandleRunStatus(RunStatus status);
+
// Copies bugreport artifacts over to the caller's directories provided there is user consent or
// called by Shell.
RunStatus CopyBugreportIfUserConsented(int32_t calling_uid);