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

Commit 5970b0c1 authored by Treehugger Robot's avatar Treehugger Robot Committed by Brad Ebinger
Browse files

Set Binder to null if linkToDeath throws RemoteException

If linkToDeath throws a RemoteException, set the Binder to null in
order to stop unlinkToDeath from causing the phone process to crash.

For further safety, catch NoSuchElementException directly if it
still happens, as it should just result in a no-op.

Bug: 177073719
Bug: 175737956
Test: manual; atest ImsCommonTests
Merged-In: I743d1768720cee6ef264ef3168183563652e50c4
Merged-In: I8e35fccbd1bc72a821b87445ed71ad30157b019b
Change-Id: I1dd468cf180509e57358d8fc3c5bd1fd7aa9d79d
parent 59ded884
Loading
Loading
Loading
Loading
+10 −3
Original line number Diff line number Diff line
@@ -34,6 +34,8 @@ import com.android.internal.telephony.util.HandlerExecutor;

import java.util.concurrent.Executor;

import java.util.NoSuchElementException;

/**
 * Base class of MmTelFeatureConnection and RcsFeatureConnection.
 */
@@ -102,7 +104,8 @@ public abstract class FeatureConnection {
                    mBinder.linkToDeath(mDeathRecipient, 0);
                }
            } catch (RemoteException e) {
                // No need to do anything if the binder is already dead.
                Log.w(TAG, "setBinder: linkToDeath on already dead Binder, setting null");
                mBinder = null;
            }
        }
    }
@@ -127,9 +130,13 @@ public abstract class FeatureConnection {
            if (mIsAvailable) {
                mIsAvailable = false;
                mRegistrationBinder = null;
                try {
                    if (mBinder != null) {
                        mBinder.unlinkToDeath(mDeathRecipient, 0);
                    }
                } catch (NoSuchElementException e) {
                    Log.w(TAG, "onRemovedOrDied: unlinkToDeath called on unlinked Binder.");
                }
                if (mStatusCallback != null) {
                    Log.d(TAG, "onRemovedOrDied: notifyUnavailable");
                    mStatusCallback.notifyUnavailable();