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

Commit bad055ac authored by Parvathy Shanmugam's avatar Parvathy Shanmugam Committed by Gerrit Code Review
Browse files

Merge "(IMS Threading refactoring) Telephony IMS classes to schedule IMS...

Merge "(IMS Threading refactoring) Telephony IMS classes to schedule IMS callback on the main thread"
parents 5953d078 fc189fcc
Loading
Loading
Loading
Loading
+21 −8
Original line number Original line Diff line number Diff line
@@ -122,6 +122,7 @@ import com.android.internal.telephony.metrics.CallQualityMetrics;
import com.android.internal.telephony.metrics.TelephonyMetrics;
import com.android.internal.telephony.metrics.TelephonyMetrics;
import com.android.internal.telephony.nano.TelephonyProto.TelephonyCallSession;
import com.android.internal.telephony.nano.TelephonyProto.TelephonyCallSession;
import com.android.internal.telephony.nano.TelephonyProto.TelephonyCallSession.Event.ImsCommand;
import com.android.internal.telephony.nano.TelephonyProto.TelephonyCallSession.Event.ImsCommand;
import com.android.internal.telephony.util.TelephonyUtils;
import com.android.internal.util.IndentingPrintWriter;
import com.android.internal.util.IndentingPrintWriter;
import com.android.telephony.Rlog;
import com.android.telephony.Rlog;


@@ -191,8 +192,8 @@ public class ImsPhoneCallTracker extends CallTracker implements ImsPullCall {


    private final MmTelFeatureListener mMmTelFeatureListener = new MmTelFeatureListener();
    private final MmTelFeatureListener mMmTelFeatureListener = new MmTelFeatureListener();
    private class MmTelFeatureListener extends MmTelFeature.Listener {
    private class MmTelFeatureListener extends MmTelFeature.Listener {
        @Override

        public void onIncomingCall(IImsCallSession c, Bundle extras) {
        private void processIncomingCall(IImsCallSession c, Bundle extras) {
            if (DBG) log("onReceive : incoming call intent");
            if (DBG) log("onReceive : incoming call intent");
            mOperationLocalLog.log("onIncomingCall Received");
            mOperationLocalLog.log("onIncomingCall Received");


@@ -292,14 +293,22 @@ public class ImsPhoneCallTracker extends CallTracker implements ImsPullCall {
            }
            }
        }
        }


        @Override
        public void onIncomingCall(IImsCallSession c, Bundle extras) {
            TelephonyUtils.runWithCleanCallingIdentity(()-> processIncomingCall(c, extras),
                    mExecutor);
        }

        @Override
        @Override
        public void onVoiceMessageCountUpdate(int count) {
        public void onVoiceMessageCountUpdate(int count) {
            TelephonyUtils.runWithCleanCallingIdentity(()-> {
                if (mPhone != null && mPhone.mDefaultPhone != null) {
                if (mPhone != null && mPhone.mDefaultPhone != null) {
                    if (DBG) log("onVoiceMessageCountChanged :: count=" + count);
                    if (DBG) log("onVoiceMessageCountChanged :: count=" + count);
                    mPhone.mDefaultPhone.setVoiceMessageCount(count);
                    mPhone.mDefaultPhone.setVoiceMessageCount(count);
                } else {
                } else {
                    loge("onVoiceMessageCountUpdate: null phone");
                    loge("onVoiceMessageCountUpdate: null phone");
                }
                }
            }, mExecutor);
        }
        }
    }
    }


@@ -548,6 +557,7 @@ public class ImsPhoneCallTracker extends CallTracker implements ImsPullCall {


    private String mLastDialString = null;
    private String mLastDialString = null;
    private ImsDialArgs mLastDialArgs = null;
    private ImsDialArgs mLastDialArgs = null;
    private Executor mExecutor = Runnable::run;


    /**
    /**
     * Listeners to changes in the phone state.  Intended for use by other interested IMS components
     * Listeners to changes in the phone state.  Intended for use by other interested IMS components
@@ -928,6 +938,9 @@ public class ImsPhoneCallTracker extends CallTracker implements ImsPullCall {
    public ImsPhoneCallTracker(ImsPhone phone, ConnectorFactory factory, Executor executor) {
    public ImsPhoneCallTracker(ImsPhone phone, ConnectorFactory factory, Executor executor) {
        this.mPhone = phone;
        this.mPhone = phone;
        mConnectorFactory = factory;
        mConnectorFactory = factory;
        if (executor != null) {
            mExecutor = executor;
        }


        mMetrics = TelephonyMetrics.getInstance();
        mMetrics = TelephonyMetrics.getInstance();


+12 −1
Original line number Original line Diff line number Diff line
@@ -22,6 +22,8 @@ import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.assertTrue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import static org.mockito.Mockito.when;
@@ -42,16 +44,25 @@ import org.junit.Before;
import org.junit.Test;
import org.junit.Test;
import org.mockito.ArgumentCaptor;
import org.mockito.ArgumentCaptor;


import java.util.concurrent.Executor;

public class ImsCallTest extends TelephonyTest {
public class ImsCallTest extends TelephonyTest {


    private Bundle mBundle;
    private Bundle mBundle;
    private ImsCallProfile mTestCallProfile;
    private ImsCallProfile mTestCallProfile;


    private Executor mExecutor = new Executor() {
        @Override
        public void execute(Runnable r) {
            r.run();
        }
    };
    @Before
    @Before
    public void setUp() throws Exception {
    public void setUp() throws Exception {
        super.setUp(getClass().getSimpleName());
        super.setUp(getClass().getSimpleName());
        mTestCallProfile = new ImsCallProfile();
        mTestCallProfile = new ImsCallProfile();
        mBundle = mTestCallProfile.mCallExtras;
        mBundle = mTestCallProfile.mCallExtras;
        doReturn(mExecutor).when(mContext).getMainExecutor();
    }
    }


    @After
    @After
@@ -70,7 +81,7 @@ public class ImsCallTest extends TelephonyTest {


        ArgumentCaptor<ImsCallSession.Listener> listenerCaptor =
        ArgumentCaptor<ImsCallSession.Listener> listenerCaptor =
                ArgumentCaptor.forClass(ImsCallSession.Listener.class);
                ArgumentCaptor.forClass(ImsCallSession.Listener.class);
        verify(mockSession).setListener(listenerCaptor.capture());
        verify(mockSession).setListener(listenerCaptor.capture(), any());
        ImsCallSession.Listener listener = listenerCaptor.getValue();
        ImsCallSession.Listener listener = listenerCaptor.getValue();
        assertNotNull(listener);
        assertNotNull(listener);


+9 −0
Original line number Original line Diff line number Diff line
@@ -109,6 +109,7 @@ import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;
import org.mockito.stubbing.Answer;


import java.util.Set;
import java.util.Set;
import java.util.concurrent.Executor;


@RunWith(AndroidTestingRunner.class)
@RunWith(AndroidTestingRunner.class)
@TestableLooper.RunWithLooper
@TestableLooper.RunWithLooper
@@ -141,6 +142,13 @@ public class ImsPhoneCallTrackerTest extends TelephonyTest {
    @Captor
    @Captor
    private ArgumentCaptor<Set<RtpHeaderExtensionType>> mRtpHeaderExtensionTypeCaptor;
    private ArgumentCaptor<Set<RtpHeaderExtensionType>> mRtpHeaderExtensionTypeCaptor;


    private Executor mExecutor = new Executor() {
        @Override
        public void execute(Runnable r) {
            r.run();
        }
    };

    private void imsCallMocking(final ImsCall imsCall) throws Exception {
    private void imsCallMocking(final ImsCall imsCall) throws Exception {


        doAnswer(new Answer<Void>() {
        doAnswer(new Answer<Void>() {
@@ -189,6 +197,7 @@ public class ImsPhoneCallTrackerTest extends TelephonyTest {
            }
            }
        }).when(imsCall).hold();
        }).when(imsCall).hold();


        doReturn(mExecutor).when(mContext).getMainExecutor();
        imsCall.attachSession(mImsCallSession);
        imsCall.attachSession(mImsCallSession);
        doReturn("1").when(mImsCallSession).getCallId();
        doReturn("1").when(mImsCallSession).getCallId();
        doReturn(mImsCallProfile).when(mImsCallSession).getCallProfile();
        doReturn(mImsCallProfile).when(mImsCallSession).getCallProfile();