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

Commit e7f126d0 authored by Wink Saville's avatar Wink Saville Committed by The Android Automerger
Browse files

Telephony: Ignore events on a destroyed phone

It is possible to receive responses from RIL after phone has released
it's references. Ignore events in such cases, since those events no
longer make sense, and some phone members have been de-initialized.

Make CallTrackers notify UI when ending calls in dispose, since
it has already unregistered, and won't receive the CALL_STATE_CHANGED

Change-Id: I5d8fd9ce3f74b9ae9b5b645565bd24d11be0aebc
CRs-Fixed: 228731, 228005, 415801, 350739
parent a4ac174f
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -341,6 +341,11 @@ public abstract class PhoneBase extends Handler implements Phone {
    public void handleMessage(Message msg) {
        AsyncResult ar;

        if (!mIsTheCurrentActivePhone) {
            Rlog.e(LOG_TAG, "Received message " + msg +
                    "[" + msg.what + "] while being destroyed. Ignoring.");
            return;
        }
        switch(msg.what) {
            case EVENT_CALL_RING:
                Rlog.d(LOG_TAG, "Event EVENT_CALL_RING Received state=" + getState());
+5 −0
Original line number Diff line number Diff line
@@ -1080,6 +1080,11 @@ public class CDMAPhone extends PhoneBase {
        AsyncResult ar;
        Message     onComplete;

        if (!mIsTheCurrentActivePhone) {
            Rlog.e(LOG_TAG, "Received message " + msg +
                    "[" + msg.what + "] while being destroyed. Ignoring.");
            return;
        }
        switch(msg.what) {
            case EVENT_RADIO_AVAILABLE: {
                mCi.getBasebandVersion(obtainMessage(EVENT_GET_BASEBAND_VERSION_DONE));
+18 −4
Original line number Diff line number Diff line
@@ -110,16 +110,26 @@ public final class CdmaCallTracker extends CallTracker {
        mCi.unregisterForCallWaitingInfo(this);
        for(CdmaConnection c : mConnections) {
            try {
                if(c != null) hangup(c);
                if(c != null) {
                    hangup(c);
                    // Since by now we are unregistered, we won't notify
                    // PhoneApp that the call is gone. Do that here
                    Rlog.d(LOG_TAG, "dispose: call connnection onDisconnect, cause LOST_SIGNAL");
                    c.onDisconnect(Connection.DisconnectCause.LOST_SIGNAL);
                }
            } catch (CallStateException ex) {
                Rlog.e(LOG_TAG, "unexpected error on hangup during dispose");
                Rlog.e(LOG_TAG, "dispose: unexpected error on hangup", ex);
            }
        }

        try {
            if(mPendingMO != null) hangup(mPendingMO);
            if(mPendingMO != null) {
                hangup(mPendingMO);
                Rlog.d(LOG_TAG, "dispose: call mPendingMO.onDsiconnect, cause LOST_SIGNAL");
                mPendingMO.onDisconnect(Connection.DisconnectCause.LOST_SIGNAL);
            }
        } catch (CallStateException ex) {
            Rlog.e(LOG_TAG, "unexpected error on hangup during dispose");
            Rlog.e(LOG_TAG, "dispose: unexpected error on hangup", ex);
        }

        clearDisconnected();
@@ -922,6 +932,10 @@ public final class CdmaCallTracker extends CallTracker {
    handleMessage (Message msg) {
        AsyncResult ar;

        if (!mPhone.mIsTheCurrentActivePhone) {
            Rlog.w(LOG_TAG, "Ignoring events received on inactive CdmaPhone");
            return;
        }
        switch (msg.what) {
            case EVENT_POLL_CALLS_RESULT:{
                Rlog.d(LOG_TAG, "Event EVENT_POLL_CALLS_RESULT Received");
+7 −0
Original line number Diff line number Diff line
@@ -66,6 +66,13 @@ public class CdmaLteServiceStateTracker extends CdmaServiceStateTracker {
        AsyncResult ar;
        int[] ints;
        String[] strings;

        if (!mPhone.mIsTheCurrentActivePhone) {
            loge("Received message " + msg + "[" + msg.what + "]" +
                    " while being destroyed. Ignoring.");
            return;
        }

        switch (msg.what) {
        case EVENT_POLL_STATE_GPRS:
            if (DBG) log("handleMessage EVENT_POLL_STATE_GPRS");
+2 −0
Original line number Diff line number Diff line
@@ -203,6 +203,8 @@ public class CdmaServiceStateTracker extends ServiceStateTracker {
    @Override
    public void dispose() {
        checkCorrectThread();
        log("ServiceStateTracker dispose");

        // Unregister for all events.
        mCi.unregisterForRadioStateChanged(this);
        mCi.unregisterForVoiceNetworkStateChanged(this);
Loading