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

Commit 2db58650 authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge "Fix regression in startBugreport flow"

parents 57928b4f 2bbba946
Loading
Loading
Loading
Loading
+12 −8
Original line number Original line Diff line number Diff line
@@ -18,8 +18,9 @@


#include "DumpstateService.h"
#include "DumpstateService.h"


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


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


#include "DumpstateInternal.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()));
    return binder::Status::fromServiceSpecificError(code, String8(msg.c_str()));
}
}


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


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


    pthread_t thread;
    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) {
    if (err != 0) {
        delete ds_info;
        ds_info = nullptr;
        return error(err, "Could not create a background thread.");
        return error(err, "Could not create a background thread.");
    }
    }
    return binder::Status::ok();
    return binder::Status::ok();