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

Commit 1310e99f authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Update IMS call status on network type changes" into main

parents d6911b14 67a53cfa
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);