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

Commit 328d1b7b authored by Tyler Gunn's avatar Tyler Gunn
Browse files

Fix issue where remotely disconnected calls show up as missed.

A recent change was made in ag/17877166 to correct the fact that missed
and rejected calls were being miscategorized.  The fix made there
made the assumption that if a call was LOCALLY disconected (ie the user
pressed disconnect) that it was rejected, otherwise it was missed.

That change failed to take into account the fact that in multiendpoint
scenarios where a call is rejected on an twinned device,
ImsReasonInfo#CODE_REJECTED_ELSEWHERE or
ImsReasonInfo#CODE_REMOTE_CALL_DECLINE can be raised when the call is
rejected on the remote device.

To fix this, we assume for incoming calls that if the call was locally
disconnected OR is the IMS stack reports an ImsReasonInfo code which
maps to DisconnectCause.INCOMING_REJECTED, we'll treat the resulting
disconnet cause as INCOMING_REJECTED.

Fixes: 235126378
Test: Manual test on Verizon network with number twinned into Verizon
Messages app.  Called test number and verified both DUT and the tablet
Verizon app are ringing.  Rejected the call on the tablet.  Verified that
the call shows as "rejected" in the call log on the phone and that the
Telecom disconnect cause is rejected.
Test: ImsPhoneCallTracker#testRejectedElsewhereIsRejected - verifies that
call disconnect cause is REJECTED when the ImsReasonInfo code is
CODE_REJECTED_ELSEWHERE.
Test: ImsPhoneCallTracker#testRemoteCallDeclineIsRejected- verifies that
call disconnect cause is REJECTED when the ImsReasonInfo code is
CODE_REMOTE_CALL_DECLINE.

Change-Id: I9deebe96e4c1c91e00d12fc5dec62c0e5b89afc7
parent 74a9c32a
Loading
Loading
Loading
Loading
+11 −3
Original line number Diff line number Diff line
@@ -3277,12 +3277,20 @@ public class ImsPhoneCallTracker extends CallTracker implements ImsPullCall {

                } else if (conn.isIncoming() && conn.getConnectTime() == 0
                        && cause != DisconnectCause.ANSWERED_ELSEWHERE) {

                    if (conn.getDisconnectCause() == DisconnectCause.LOCAL) {
                    // Two cases where the call is declared as rejected.
                    // 1. The disconnect was initiated by the user.  I.e. the connection's
                    // disconnect cause is LOCAL at this point.
                    // 2. The network provided disconnect cause is INCOMING_REJECTED.  This will be
                    // the case for ImsReasonInfo.CODE_USER_TERMINATED_BY_REMOTE and
                    // ImsReasonInfo.CODE_REJECTED_ELSEWHERE.
                    if (conn.getDisconnectCause() == DisconnectCause.LOCAL
                            || cause == DisconnectCause.INCOMING_REJECTED) {
                        // If the user initiated a disconnect of this connection, then we will treat
                        // this is a rejected call.
                        // Note; the record the fact that this is a local disconnect in
                        // Note; we record the fact that this is a local disconnect in
                        // ImsPhoneConnection#onHangupLocal
                        // Alternatively, the network can specify INCOMING_REJECTED as a result of
                        // remote reject on another device; we'll still treat as rejected.
                        cause = DisconnectCause.INCOMING_REJECTED;
                    } else {
                        // Otherwise in all other cases consider it missed.
+18 −0
Original line number Diff line number Diff line
@@ -508,6 +508,24 @@ public class ImsPhoneCallTrackerTest extends TelephonyTest {
        assertEquals(DisconnectCause.INCOMING_REJECTED, connection.getDisconnectCause());
    }

    @Test
    @SmallTest
    public void testRejectedElsewhereIsRejected() {
        ImsPhoneConnection connection = setupRingingConnection();
        mImsCallListener.onCallTerminated(connection.getImsCall(),
                new ImsReasonInfo(ImsReasonInfo.CODE_REJECTED_ELSEWHERE, 0));
        assertEquals(DisconnectCause.INCOMING_REJECTED, connection.getDisconnectCause());
    }

    @Test
    @SmallTest
    public void testRemoteCallDeclineIsRejected() {
        ImsPhoneConnection connection = setupRingingConnection();
        mImsCallListener.onCallTerminated(connection.getImsCall(),
                new ImsReasonInfo(ImsReasonInfo.CODE_REMOTE_CALL_DECLINE, 0));
        assertEquals(DisconnectCause.INCOMING_REJECTED, connection.getDisconnectCause());
    }

    private ImsPhoneConnection setupRingingConnection() {
        mImsCallProfile.setCallerNumberVerificationStatus(
                ImsCallProfile.VERIFICATION_STATUS_PASSED);