summaryrefslogtreecommitdiff
path: root/cmds/dumpstate/DumpstateService.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'cmds/dumpstate/DumpstateService.cpp')
-rw-r--r--cmds/dumpstate/DumpstateService.cpp57
1 files changed, 11 insertions, 46 deletions
diff --git a/cmds/dumpstate/DumpstateService.cpp b/cmds/dumpstate/DumpstateService.cpp
index 10d3d1756b..bfcc058c1b 100644
--- a/cmds/dumpstate/DumpstateService.cpp
+++ b/cmds/dumpstate/DumpstateService.cpp
@@ -58,8 +58,6 @@ static binder::Status exception(uint32_t code, const std::string& msg) {
exit(0);
}
-class DumpstateToken : public BnDumpstateToken {};
-
} // namespace
DumpstateService::DumpstateService() : ds_(nullptr) {
@@ -81,48 +79,16 @@ status_t DumpstateService::Start() {
return android::OK;
}
-// Note: this method is part of the old flow and is not expected to be used in combination
-// with startBugreport.
-binder::Status DumpstateService::setListener(const std::string& name,
- const sp<IDumpstateListener>& listener,
- bool getSectionDetails,
- sp<IDumpstateToken>* returned_token) {
- *returned_token = nullptr;
- if (name.empty()) {
- MYLOGE("setListener(): name not set\n");
- return binder::Status::ok();
- }
- if (listener == nullptr) {
- MYLOGE("setListener(): listener not set\n");
- return binder::Status::ok();
- }
- std::lock_guard<std::mutex> lock(lock_);
- if (ds_ == nullptr) {
- ds_ = &(Dumpstate::GetInstance());
- }
- if (ds_->listener_ != nullptr) {
- MYLOGE("setListener(%s): already set (%s)\n", name.c_str(), ds_->listener_name_.c_str());
- return binder::Status::ok();
- }
-
- ds_->listener_name_ = name;
- ds_->listener_ = listener;
- ds_->report_section_ = getSectionDetails;
- *returned_token = new DumpstateToken();
-
- return binder::Status::ok();
-}
-
binder::Status DumpstateService::startBugreport(int32_t calling_uid,
const std::string& calling_package,
android::base::unique_fd bugreport_fd,
android::base::unique_fd screenshot_fd,
int bugreport_mode,
- const sp<IDumpstateListener>& listener) {
+ const sp<IDumpstateListener>& listener,
+ bool is_screenshot_requested) {
MYLOGI("startBugreport() with mode: %d\n", bugreport_mode);
- // This is the bugreporting API flow, so ensure there is only one bugreport in progress at a
- // time.
+ // Ensure there is only one bugreport in progress at a time.
std::lock_guard<std::mutex> lock(lock_);
if (ds_ != nullptr) {
MYLOGE("Error! There is already a bugreport in progress. Returning.");
@@ -153,9 +119,9 @@ binder::Status DumpstateService::startBugreport(int32_t calling_uid,
std::unique_ptr<Dumpstate::DumpOptions> options = std::make_unique<Dumpstate::DumpOptions>();
options->Initialize(static_cast<Dumpstate::BugreportMode>(bugreport_mode), bugreport_fd,
- screenshot_fd);
+ screenshot_fd, is_screenshot_requested);
- if (bugreport_fd.get() == -1 || (options->do_fb && screenshot_fd.get() == -1)) {
+ if (bugreport_fd.get() == -1 || (options->do_screenshot && screenshot_fd.get() == -1)) {
MYLOGE("Invalid filedescriptor");
signalErrorAndExit(listener, IDumpstateListener::BUGREPORT_ERROR_INVALID_INPUT);
}
@@ -171,6 +137,8 @@ binder::Status DumpstateService::startBugreport(int32_t calling_uid,
ds_info->calling_package = calling_package;
pthread_t thread;
+ // Initialize dumpstate
+ ds_->Initialize();
status_t err = pthread_create(&thread, nullptr, dumpstate_thread_main, ds_info);
if (err != 0) {
delete ds_info;
@@ -182,14 +150,13 @@ binder::Status DumpstateService::startBugreport(int32_t calling_uid,
}
binder::Status DumpstateService::cancelBugreport() {
- // This is a no-op since the cancellation is done from java side via setting sys properties.
- // See BugreportManagerServiceImpl.
- // TODO(b/111441001): maybe make native and java sides use different binder interface
- // to avoid these annoyances.
+ std::lock_guard<std::mutex> lock(lock_);
+ ds_->Cancel();
return binder::Status::ok();
}
status_t DumpstateService::dump(int fd, const Vector<String16>&) {
+ std::lock_guard<std::mutex> lock(lock_);
if (ds_ == nullptr) {
dprintf(fd, "Bugreport not in progress yet");
return NO_ERROR;
@@ -204,19 +171,17 @@ status_t DumpstateService::dump(int fd, const Vector<String16>&) {
dprintf(fd, "progress:\n");
ds_->progress_->Dump(fd, " ");
dprintf(fd, "args: %s\n", ds_->options_->args.c_str());
- dprintf(fd, "extra_options: %s\n", ds_->options_->extra_options.c_str());
+ dprintf(fd, "bugreport_mode: %s\n", ds_->options_->bugreport_mode.c_str());
dprintf(fd, "version: %s\n", ds_->version_.c_str());
dprintf(fd, "bugreport_dir: %s\n", destination.c_str());
dprintf(fd, "screenshot_path: %s\n", ds_->screenshot_path_.c_str());
dprintf(fd, "log_path: %s\n", ds_->log_path_.c_str());
dprintf(fd, "tmp_path: %s\n", ds_->tmp_path_.c_str());
dprintf(fd, "path: %s\n", ds_->path_.c_str());
- dprintf(fd, "extra_options: %s\n", ds_->options_->extra_options.c_str());
dprintf(fd, "base_name: %s\n", ds_->base_name_.c_str());
dprintf(fd, "name: %s\n", ds_->name_.c_str());
dprintf(fd, "now: %ld\n", ds_->now_);
dprintf(fd, "is_zipping: %s\n", ds_->IsZipping() ? "true" : "false");
- dprintf(fd, "listener: %s\n", ds_->listener_name_.c_str());
dprintf(fd, "notification title: %s\n", ds_->options_->notification_title.c_str());
dprintf(fd, "notification description: %s\n", ds_->options_->notification_description.c_str());