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

Commit da5c71a4 authored by Aaron Okano's avatar Aaron Okano Committed by Android (Google) Code Review
Browse files

Merge "binder: Add method to enable RT inheritance for all Binders in process" into main

parents 79397846 b3395b54
Loading
Loading
Loading
Loading
+10 −3
Original line number Diff line number Diff line
@@ -593,8 +593,9 @@ int BBinder::getMinSchedulerPriority() {

bool BBinder::isInheritRt() {
    Extras* e = mExtras.load(std::memory_order_acquire);

    return e && e->mInheritRt;
    // Return configured default value if it has not been overridden
    if (e == nullptr) return sGlobalInheritRt.load(std::memory_order_acquire);
    return e->mInheritRt;
}

void BBinder::setInheritRt(bool inheritRt) {
@@ -616,6 +617,12 @@ void BBinder::setInheritRt(bool inheritRt) {
    e->mInheritRt = inheritRt;
}

std::atomic<bool> BBinder::sGlobalInheritRt(false);

void BBinder::setGlobalInheritRt(bool enabled) {
    sGlobalInheritRt.store(enabled, std::memory_order_release);
}

pid_t BBinder::getDebugPid() {
#ifdef __linux__
    return getpid();
@@ -744,7 +751,7 @@ BBinder::~BBinder()
        if (isRequestingSid()) {
            ALOGW("Binder %p destroyed when requesting SID before being parceled.", this);
        }
        if (isInheritRt()) {
        if (sGlobalInheritRt.load(std::memory_order_acquire) != isInheritRt()) {
            ALOGW("Binder %p destroyed after setInheritRt before being parceled.", this);
        }
#ifdef __linux__
+7 −0
Original line number Diff line number Diff line
@@ -91,6 +91,11 @@ public:
    // This must be called before the object is sent to another process. Not thread safe.
    LIBBINDER_EXPORTED void setInheritRt(bool inheritRt);

    // Set default, overridden by setInheritRt. You must set this default early.
    // Any binder objects sent out of the process before this is called will
    // not use the updated value.
    LIBBINDER_EXPORTED static void setGlobalInheritRt(bool enabled);

    LIBBINDER_EXPORTED pid_t getDebugPid();

    // Whether this binder has been sent to another process.
@@ -124,6 +129,8 @@ private:
    [[nodiscard]] status_t startRecordingTransactions(const Parcel& data);
    [[nodiscard]] status_t stopRecordingTransactions();

    static std::atomic<bool> sGlobalInheritRt;

    std::atomic<Extras*> mExtras;

    friend ::android::internal::Stability;