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

Commit f02cd78e authored by Nandana Dutt's avatar Nandana Dutt
Browse files

Remove old dumpstate aidl methods

In Q we added new aidl methods for dumpstate to communicate with
SystemServer. The old methods can be removed now.

This change is functionally equivalent to before except for how progress
is reported. Dumpstate loads previous run stats and calculates expected
run time. If the current run exceeds that time, it used to let the
client know via onMaxProgressUpdated().

Given the API world, this CL simplifies this model so that dumpstate
conveys just one piece of information, i.e. final progress precentage,
rather than current, previous_max, and new_max.

Test: atest dumpstate_test
Test: bugreport from power button works as expected
BUG: 128980174

Change-Id: Id9103649b0f7c8e6ea0b79583ea04825cb5b455f
Merged-In: Id9103649b0f7c8e6ea0b79583ea04825cb5b455f
parent 9db13389
Loading
Loading
Loading
Loading
+0 −1
Original line number Original line Diff line number Diff line
@@ -93,7 +93,6 @@ cc_defaults {
        "libutils",
        "libutils",
    ],
    ],
    srcs: [
    srcs: [
        "DumpstateSectionReporter.cpp",
        "DumpstateService.cpp",
        "DumpstateService.cpp",
    ],
    ],
    static_libs: [
    static_libs: [
+0 −42
Original line number Original line 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 Original line 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 Original line 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, "id: %d\n", ds_->id_);
    dprintf(fd, "pid: %d\n", ds_->pid_);
    dprintf(fd, "pid: %d\n", ds_->pid_);
    dprintf(fd, "update_progress: %s\n", ds_->options_->do_progress_updates ? "true" : "false");
    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_percent_progress: %d\n", ds_->last_reported_percent_progress_);
    dprintf(fd, "last_updated_progress: %d\n", ds_->last_updated_progress_);
    dprintf(fd, "progress:\n");
    dprintf(fd, "progress:\n");
    ds_->progress_->Dump(fd, "  ");
    ds_->progress_->Dump(fd, "  ");
    dprintf(fd, "args: %s\n", ds_->options_->args.c_str());
    dprintf(fd, "args: %s\n", ds_->options_->args.c_str());
+0 −17
Original line number Original line Diff line number Diff line
@@ -61,21 +61,4 @@ interface IDumpstateListener {
     * Called when taking bugreport finishes successfully.
     * Called when taking bugreport finishes successfully.
     */
     */
    void onFinished();
    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