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

Commit 855f5c33 authored by Nandana Dutt's avatar Nandana Dutt Committed by android-build-merger
Browse files

Merge "Remove old dumpstate aidl methods" am: 6f65b7f0 am: 64fa943a am: 9a3eb1fc

am: 4b40766c

Change-Id: I211e13dd9fceee276c781c060ff6ecda6982a598
parents 2357369d 4b40766c
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -93,7 +93,6 @@ cc_defaults {
        "libutils",
    ],
    srcs: [
        "DumpstateSectionReporter.cpp",
        "DumpstateService.cpp",
    ],
    static_libs: [
+0 −42
Original line number Diff line number Diff line
/*
 * Copyright (C) 2018 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#define LOG_TAG "dumpstate"

#include "DumpstateSectionReporter.h"

namespace android {
namespace os {
namespace dumpstate {

DumpstateSectionReporter::DumpstateSectionReporter(const std::string& title,
                                                   sp<android::os::IDumpstateListener> listener,
                                                   bool sendReport)
    : title_(title), listener_(listener), sendReport_(sendReport), status_(OK), size_(-1) {
    started_ = std::chrono::steady_clock::now();
}

DumpstateSectionReporter::~DumpstateSectionReporter() {
    if ((listener_ != nullptr) && (sendReport_)) {
        auto elapsed = std::chrono::duration_cast<std::chrono::milliseconds>(
            std::chrono::steady_clock::now() - started_);
        listener_->onSectionComplete(title_, status_, size_, (int32_t)elapsed.count());
    }
}

}  // namespace dumpstate
}  // namespace os
}  // namespace android
+0 −65
Original line number Diff line number Diff line
/*
 * Copyright (C) 2018 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#ifndef ANDROID_OS_DUMPSTATESECTIONREPORTER_H_
#define ANDROID_OS_DUMPSTATESECTIONREPORTER_H_

#include <android/os/IDumpstateListener.h>
#include <utils/StrongPointer.h>

namespace android {
namespace os {
namespace dumpstate {


/*
 * Helper class used to report per section details to a listener.
 *
 * Typical usage:
 *
 *    DumpstateSectionReporter sectionReporter(title, listener, sendReport);
 *    sectionReporter.setSize(5000);
 *
 */
class DumpstateSectionReporter {
  public:
    DumpstateSectionReporter(const std::string& title, sp<android::os::IDumpstateListener> listener,
                             bool sendReport);

    ~DumpstateSectionReporter();

    void setStatus(status_t status) {
        status_ = status;
    }

    void setSize(int size) {
        size_ = size;
    }

  private:
    std::string title_;
    android::sp<android::os::IDumpstateListener> listener_;
    bool sendReport_;
    status_t status_;
    int size_;
    std::chrono::time_point<std::chrono::steady_clock> started_;
};

}  // namespace dumpstate
}  // namespace os
}  // namespace android

#endif  // ANDROID_OS_DUMPSTATESECTIONREPORTER_H_
+1 −2
Original line number Diff line number Diff line
@@ -200,8 +200,7 @@ status_t DumpstateService::dump(int fd, const Vector<String16>&) {
    dprintf(fd, "id: %d\n", ds_->id_);
    dprintf(fd, "pid: %d\n", ds_->pid_);
    dprintf(fd, "update_progress: %s\n", ds_->options_->do_progress_updates ? "true" : "false");
    dprintf(fd, "update_progress_threshold: %d\n", ds_->update_progress_threshold_);
    dprintf(fd, "last_updated_progress: %d\n", ds_->last_updated_progress_);
    dprintf(fd, "last_percent_progress: %d\n", ds_->last_reported_percent_progress_);
    dprintf(fd, "progress:\n");
    ds_->progress_->Dump(fd, "  ");
    dprintf(fd, "args: %s\n", ds_->options_->args.c_str());
+0 −17
Original line number Diff line number Diff line
@@ -61,21 +61,4 @@ interface IDumpstateListener {
     * Called when taking bugreport finishes successfully.
     */
    void onFinished();

    // 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
     *                       {@code TIMEOUT} dump timed out
     *                       {@code != OK} error
     * @param  size          size in bytes, may be invalid if status != OK
     * @param  durationMs    duration in ms
     */
    void onSectionComplete(@utf8InCpp String name, int status, int size, int durationMs);
}
Loading