diff options
Diffstat (limited to 'cmds/dumpstate/dumpstate.h')
| -rw-r--r-- | cmds/dumpstate/dumpstate.h | 42 |
1 files changed, 39 insertions, 3 deletions
diff --git a/cmds/dumpstate/dumpstate.h b/cmds/dumpstate/dumpstate.h index 3dfe4e955f..4766d82909 100644 --- a/cmds/dumpstate/dumpstate.h +++ b/cmds/dumpstate/dumpstate.h @@ -27,6 +27,7 @@ #include <android-base/macros.h> #include <android-base/unique_fd.h> +#include <android/os/BnIncidentAuthListener.h> #include <android/os/IDumpstate.h> #include <android/os/IDumpstateListener.h> #include <utils/StrongPointer.h> @@ -192,7 +193,7 @@ class Dumpstate { friend class DumpstateTest; public: - enum RunStatus { OK, HELP, INVALID_INPUT, ERROR }; + enum RunStatus { OK, HELP, INVALID_INPUT, ERROR, USER_CONSENT_DENIED, USER_CONSENT_TIMED_OUT }; // The mode under which the bugreport should be run. Each mode encapsulates a few options. enum BugreportMode { @@ -319,7 +320,7 @@ class Dumpstate { struct DumpOptions; /* Main entry point for running a complete bugreport. */ - RunStatus Run(); + RunStatus Run(int32_t calling_uid, const std::string& calling_package); /* Sets runtime options. */ void SetOptions(std::unique_ptr<DumpOptions> options); @@ -447,12 +448,47 @@ class Dumpstate { // List of open ANR dump files. std::vector<DumpData> anr_data_; + // A callback to IncidentCompanion service, which checks user consent for sharing the + // bugreport with the calling app. If the user has not responded yet to the dialog it will + // be neither confirmed nor denied. + class ConsentCallback : public android::os::BnIncidentAuthListener { + public: + ConsentCallback(); + android::binder::Status onReportApproved() override; + android::binder::Status onReportDenied() override; + + enum ConsentResult { APPROVED, DENIED, UNAVAILABLE }; + + ConsentResult getResult(); + + // Returns the time since creating this listener + uint64_t getElapsedTimeMs() const; + + private: + ConsentResult result_; + uint64_t start_time_; + std::mutex lock_; + }; + private: - RunStatus RunInternal(); + RunStatus RunInternal(int32_t calling_uid, const std::string& calling_package); + + void CheckUserConsent(int32_t calling_uid, const android::String16& calling_package); + + // Removes the in progress files output files (tmp file, zip/txt file, screenshot), + // but leaves the log file alone. + void CleanupFiles(); + + RunStatus HandleUserConsentDenied(); + + // Copies bugreport artifacts over to the caller's directories provided there is user consent. + RunStatus CopyBugreportIfUserConsented(); // Used by GetInstance() only. explicit Dumpstate(const std::string& version = VERSION_CURRENT); + android::sp<ConsentCallback> consent_callback_; + DISALLOW_COPY_AND_ASSIGN(Dumpstate); }; |