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

Commit 49039cac authored by Nandana Dutt's avatar Nandana Dutt Committed by android-build-merger
Browse files

Merge "Fix regression in startBugreport flow" am: 2db58650

am: fb2ddfd9

Change-Id: I3f81fc92a531aa9931589c6642701fc1e90c0902
parents 770aca8d fb2ddfd9
Loading
Loading
Loading
Loading
+12 −8
Original line number Diff line number Diff line
@@ -18,8 +18,9 @@

#include "DumpstateService.h"

#include <android-base/stringprintf.h>
#include <memory>

#include <android-base/stringprintf.h>
#include "android/os/BnDumpstate.h"

#include "DumpstateInternal.h"
@@ -48,9 +49,10 @@ static binder::Status error(uint32_t code, const std::string& msg) {
    return binder::Status::fromServiceSpecificError(code, String8(msg.c_str()));
}

// Takes ownership of data.
static void* callAndNotify(void* data) {
    DumpstateInfo& ds_info = *static_cast<DumpstateInfo*>(data);
    ds_info.ds->Run(ds_info.calling_uid, ds_info.calling_package);
    std::unique_ptr<DumpstateInfo> ds_info(static_cast<DumpstateInfo*>(data));
    ds_info->ds->Run(ds_info->calling_uid, ds_info->calling_package);
    MYLOGD("Finished Run()\n");
    return nullptr;
}
@@ -150,14 +152,16 @@ binder::Status DumpstateService::startBugreport(int32_t calling_uid,
        ds_->listener_ = listener;
    }

    DumpstateInfo ds_info;
    ds_info.ds = ds_;
    ds_info.calling_uid = calling_uid;
    ds_info.calling_package = calling_package;
    DumpstateInfo* ds_info = new DumpstateInfo();
    ds_info->ds = ds_;
    ds_info->calling_uid = calling_uid;
    ds_info->calling_package = calling_package;

    pthread_t thread;
    status_t err = pthread_create(&thread, nullptr, callAndNotify, &ds_);
    status_t err = pthread_create(&thread, nullptr, callAndNotify, ds_info);
    if (err != 0) {
        delete ds_info;
        ds_info = nullptr;
        return error(err, "Could not create a background thread.");
    }
    return binder::Status::ok();