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

Commit 110dd5d3 authored by Tyler Gunn's avatar Tyler Gunn
Browse files

Ensure Telecom ServiceBinder class unlinks death recipient.

Telecom uses a death recipient to track binder failures.  Turns out it
did not actually unlink the death recipient.  Ooops.

Added code so that it unlinks in unbind() and also within the death
recipient itself (after death).

Test: Manual; ensure no longer getting system unlink warnings.
Bug: 78141360
Change-Id: If75b29ed3610af068dd2a8c23db4886a03f809a9
parent b0398e4a
Loading
Loading
Loading
Loading
+17 −0
Original line number Diff line number Diff line
@@ -303,6 +303,7 @@ abstract class ServiceBinder {
            mIsBindingAborted = true;
        } else {
            logServiceDisconnected("unbind");
            unlinkDeathRecipient();
            mContext.unbindService(mServiceConnection);
            mServiceConnection = null;
            setBinder(null);
@@ -371,9 +372,25 @@ abstract class ServiceBinder {
     * Handles a service disconnection.
     */
    private void handleServiceDisconnected() {
        unlinkDeathRecipient();
        setBinder(null);
    }

    /**
     * Handles un-linking the death recipient from the service's binder.
     */
    private void unlinkDeathRecipient() {
        if (mServiceDeathRecipient != null && mBinder != null) {
            boolean unlinked = mBinder.unlinkToDeath(mServiceDeathRecipient, 0);
            if (!unlinked) {
                Log.i(this, "unlinkDeathRecipient: failed to unlink %s", mComponentName);
            }
            mServiceDeathRecipient = null;
        } else {
            Log.w(this, "unlinkDeathRecipient: death recipient is null.");
        }
    }

    private void clearAbort() {
        mIsBindingAborted = false;
    }