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

Commit f93b3102 authored by Devin Moore's avatar Devin Moore
Browse files

Log when AIBinder_linkToDeath is called with the same cookie

Only log this after AIBinder_DeathRecipient_setOnUnlinked was called on
that DeathRecipient.

Ignore-AOSP-First: b/334118276

Test: atest libbinder_ndk_unit_test
Bug: 334118276
Change-Id: Ib6f38933d905014841d868aed545362a0181be58
parent 04f1b648
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -478,6 +478,16 @@ binder_status_t AIBinder_DeathRecipient::linkToDeath(const sp<IBinder>& binder,

    std::lock_guard<std::mutex> l(mDeathRecipientsMutex);

    if (mOnUnlinked && cookie &&
        std::find_if(mDeathRecipients.begin(), mDeathRecipients.end(),
                     [&cookie](android::sp<TransferDeathRecipient> recipient) {
                         return recipient->getCookie() == cookie;
                     }) != mDeathRecipients.end()) {
        ALOGE("Attempting to AIBinder_linkToDeath with the same cookie with an onUnlink callback. "
              "This will cause the onUnlinked callback to be called multiple times with the same "
              "cookie, which is usually not intended.");
    }

    sp<TransferDeathRecipient> recipient =
            new TransferDeathRecipient(binder, cookie, this, mOnDied, mOnUnlinked);