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

Commit 4cbf7184 authored by Hunsuk Choi's avatar Hunsuk Choi
Browse files

Unregister the callback handler on cancelSelection

If a user hangs up a call while changing preferred transport type,
the result callback causes IllegalStateException by sending message to
a Handler on a dead thread.

Bug: 266191727
Test: atest EmergencyCallDomainSelectionConnection
Change-Id: I68c34839d99f552a255edd716ecd1aa1005167e5
parent 8a1b61b8
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -176,6 +176,15 @@ public class EmergencyCallDomainSelectionConnection extends DomainSelectionConne
        }
    }

    /** {@inheritDoc} */
    @Override
    public void cancelSelection() {
        logi("cancelSelection");
        AccessNetworksManager anm = mPhone.getAccessNetworksManager();
        anm.unregisterForQualifiedNetworksChanged(mHandler);
        super.cancelSelection();
    }

    /**
     * Returns the attributes required to determine the domain for a telephony service.
     *
+7 −0
Original line number Diff line number Diff line
@@ -217,4 +217,11 @@ public class EmergencyCallDomainSelectionConnectionTest extends TelephonyTest {

        verify(mConnectionCallback).onSelectionTerminated(eq(ERROR_UNSPECIFIED));
    }

    @Test
    @SmallTest
    public void testCancelSelection() throws Exception {
        mEcDsc.cancelSelection();
        verify(mAnm).unregisterForQualifiedNetworksChanged(any());
    }
}