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

Commit 67a53cfa authored by yongnamcha's avatar yongnamcha
Browse files

Update IMS call status on network type changes

This commit resolves the issue of missing IMS call status
updates during network type changes.

Bug: 371463767
Test: Testing by equipment, atest ImsCallInfoTrackerTest
Flag: EXEMPT bugfix
Change-Id: Iad916872051f54c08a84babe3e7b2a9776735ec8
parent a6b7d406
Loading
Loading
Loading
Loading
+15 −4
Original line number Diff line number Diff line
@@ -18,7 +18,8 @@ package com.android.internal.telephony.imsphone;

import android.annotation.NonNull;
import android.annotation.Nullable;
import android.telephony.AccessNetworkConstants;
import android.telephony.AccessNetworkConstants.AccessNetworkType;
import android.telephony.AccessNetworkConstants.RadioAccessNetworkType;
import android.telephony.ServiceState;

import com.android.internal.telephony.Call;
@@ -32,6 +33,7 @@ public class ImsCallInfo {
    private @Nullable ImsPhoneConnection mConnection = null;
    private Call.State mState = Call.State.IDLE;
    private boolean mIsHeldByRemote = false;
    private @RadioAccessNetworkType int mCallRadioTech = AccessNetworkType.UNKNOWN;

    public ImsCallInfo(int index) {
        mIndex = index;
@@ -42,6 +44,7 @@ public class ImsCallInfo {
        mConnection = null;
        mState = Call.State.IDLE;
        mIsHeldByRemote = false;
        mCallRadioTech = AccessNetworkType.UNKNOWN;
    }

    /**
@@ -52,6 +55,7 @@ public class ImsCallInfo {
    public void update(@NonNull ImsPhoneConnection c) {
        mConnection = c;
        mState = c.getState();
        mCallRadioTech = getCallRadioTech(c);
    }

    /**
@@ -64,8 +68,10 @@ public class ImsCallInfo {
    public boolean update(@NonNull ImsPhoneConnection c,
            boolean holdReceived, boolean resumeReceived) {
        Call.State state = c.getState();
        boolean changed = mState != state;
        int callRadioTech = getCallRadioTech(c);
        boolean changed = mState != state || mCallRadioTech != callRadioTech;
        mState = state;
        mCallRadioTech = callRadioTech;

        if (holdReceived && !mIsHeldByRemote) {
            changed = true;
@@ -109,13 +115,18 @@ public class ImsCallInfo {
    }

    /** @return the radio technology used for current connection. */
    public @AccessNetworkConstants.RadioAccessNetworkType int getCallRadioTech() {
        return ServiceState.rilRadioTechnologyToAccessNetworkType(mConnection.getCallRadioTech());
    public @RadioAccessNetworkType int getCallRadioTech() {
        return mCallRadioTech;
    }

    @Override
    public String toString() {
        return "[ id=" + mIndex + ", state=" + mState
                + ", callRadioTech=" + AccessNetworkType.toString(mCallRadioTech)
                + ", isMT=" + isIncoming() + ", heldByRemote=" + mIsHeldByRemote + " ]";
    }

    private static @RadioAccessNetworkType int getCallRadioTech(ImsPhoneConnection c) {
        return ServiceState.rilRadioTechnologyToAccessNetworkType(c.getCallRadioTech());
    }
}
+2 −0
Original line number Diff line number Diff line
@@ -3119,6 +3119,8 @@ public class ImsPhoneCallTracker extends CallTracker implements ImsPullCall {
            conn.maybeChangeRingbackState();

            maybeSetVideoCallProvider(conn, imsCall);
            // Update IMS call status if the call attributes are changed - i.e. call network type.
            mImsCallInfoTracker.updateImsCallStatus(conn);
            // IMS call profile might be changed while call state is maintained. In this case, it's
            // required to notify to CallAttributesListener.
            // Since call state is not changed, TelephonyRegistry will not notify to
+26 −0
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@
package com.android.internal.telephony.imsphone;

import static android.telephony.AccessNetworkConstants.AccessNetworkType.EUTRAN;
import static android.telephony.AccessNetworkConstants.AccessNetworkType.IWLAN;

import static junit.framework.Assert.assertNotNull;

@@ -387,6 +388,31 @@ public class ImsCallInfoTrackerTest extends TelephonyTest {
        assertEquals(0, imsCallInfos.size());
    }

    @Test
    public void testNetworkChanged() throws Exception {
        ArgumentCaptor<List<ImsCallInfo>> captor = ArgumentCaptor.forClass(List.class);
        ImsPhoneConnection c = getConnection(Call.State.ACTIVE, false);
        mImsCallInfoTracker.addImsCallStatus(c);

        verify(mImsPhone, times(1)).updateImsCallStatus(captor.capture(), any());

        List<ImsCallInfo> imsCallInfos = captor.getValue();
        assertNotNull(imsCallInfos);
        assertEquals(1, imsCallInfos.size());

        ImsCallInfo info = imsCallInfos.get(0);
        assertNotNull(info);
        assertEquals(1, info.getIndex());
        assertEquals(EUTRAN, info.getCallRadioTech());

        // The network type is changed from EUTRAN to IWLAN.
        doReturn(ServiceState.RIL_RADIO_TECHNOLOGY_IWLAN).when(c).getCallRadioTech();
        mImsCallInfoTracker.updateImsCallStatus(c);

        verify(mImsPhone, times(2)).updateImsCallStatus(captor.capture(), any());
        assertEquals(IWLAN, info.getCallRadioTech());
    }

    @Test
    public void testClearAllOrphanedConnections() throws Exception {
        ArgumentCaptor<List<ImsCallInfo>> captor = ArgumentCaptor.forClass(List.class);