Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 601fe6c8 authored by Nandana Dutt's avatar Nandana Dutt Committed by Gerrit Code Review
Browse files

Merge "Add more methods to dumpstate listener"

parents 61cb76e7 a6a28bd2
Loading
Loading
Loading
Loading
+2 −4
Original line number Diff line number Diff line
@@ -25,8 +25,6 @@ import android.os.DumpstateOptions;
  * {@hide}
  */
interface IDumpstate {


    // TODO: remove method once startBugReport is used by Shell.
    /*
     * Sets the listener for this dumpstate progress.
+39 −9
Original line number Diff line number Diff line
@@ -22,11 +22,41 @@ package android.os;
  * {@hide}
  */
interface IDumpstateListener {
    /**
     * Called when there is a progress update.
     *
     * @param progress the progress in [0, 100]
     */
    oneway void onProgress(int progress);

    /* Options specified are invalid or incompatible */
    const int BUGREPORT_ERROR_INVALID_INPUT = 1;

    /* Bugreport encountered a runtime error */
    const int BUGREPORT_ERROR_RUNTIME_ERROR = 2;

    /**
     * Called on an error condition with one of the error codes listed above.
     */
    oneway void onError(int errorCode);

    /**
     * Called when taking bugreport finishes successfully
     *
     * @param durationMs time capturing bugreport took in milliseconds
     * @param title title for the bugreport; helpful in reminding the user why they took it
     * @param description detailed description for the bugreport
     */
     oneway void onFinished(long durationMs, @utf8InCpp String title,
                            @utf8InCpp String description);

    // TODO(b/111441001): Remove old methods when not used anymore.
    void onProgressUpdated(int progress);
    void onMaxProgressUpdated(int maxProgress);

    /**
     * Called after every section is complete.
     *
     * @param  name          section name
     * @param  status        values from status_t
     *                       {@code OK} section completed successfully
+13 −0
Original line number Diff line number Diff line
@@ -53,6 +53,19 @@ class DumpstateListener : public IDumpstateListener {
    DumpstateListener(int fd, std::shared_ptr<std::vector<SectionInfo>> sections)
        : outFd_(fd), max_progress_(5000), sections_(sections) {
    }
    binder::Status onProgress(int32_t progress) override {
        dprintf(outFd_, "\rIn progress %d", progress);
        return binder::Status::ok();
    }
    binder::Status onError(int32_t error_code) override {
        dprintf(outFd_, "\rError %d", error_code);
        return binder::Status::ok();
    }
    binder::Status onFinished(int64_t duration_ms, const ::std::string&,
                              const ::std::string&) override {
        dprintf(outFd_, "\rFinished in %lld", (long long) duration_ms);
        return binder::Status::ok();
    }
    binder::Status onProgressUpdated(int32_t progress) override {
        dprintf(outFd_, "\rIn progress %d/%d", progress, max_progress_);
        return binder::Status::ok();
+4 −0
Original line number Diff line number Diff line
@@ -59,6 +59,10 @@ using ::testing::internal::GetCapturedStdout;

class DumpstateListenerMock : public IDumpstateListener {
  public:
    MOCK_METHOD1(onProgress, binder::Status(int32_t progress));
    MOCK_METHOD1(onError, binder::Status(int32_t error_code));
    MOCK_METHOD3(onFinished, binder::Status(int64_t duration_ms, const ::std::string& title,
                                            const ::std::string& description));
    MOCK_METHOD1(onProgressUpdated, binder::Status(int32_t progress));
    MOCK_METHOD1(onMaxProgressUpdated, binder::Status(int32_t max_progress));
    MOCK_METHOD4(onSectionComplete, binder::Status(const ::std::string& name, int32_t status,