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

Commit d9689edc authored by Parvathy Shanmugam's avatar Parvathy Shanmugam Committed by Automerger Merge Worker
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" am: bad055ac am: 4a299c8f am: dcd9b81d

Original change: https://android-review.googlesource.com/c/platform/frameworks/opt/telephony/+/1967364

Change-Id: Ib9dd3105dd662a12906384c566dbc63cf70e9cad
parents 79ecf659 dcd9b81d
Loading
Loading
Loading
Loading
+21 −8
Original line number 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.nano.TelephonyProto.TelephonyCallSession;
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.telephony.Rlog;

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

    private final MmTelFeatureListener mMmTelFeatureListener = new MmTelFeatureListener();
    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");
            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
        public void onVoiceMessageCountUpdate(int count) {
            TelephonyUtils.runWithCleanCallingIdentity(()-> {
                if (mPhone != null && mPhone.mDefaultPhone != null) {
                    if (DBG) log("onVoiceMessageCountChanged :: count=" + count);
                    mPhone.mDefaultPhone.setVoiceMessageCount(count);
                } else {
                    loge("onVoiceMessageCountUpdate: null phone");
                }
            }, mExecutor);
        }
    }

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

    private String mLastDialString = 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
@@ -928,6 +938,9 @@ public class ImsPhoneCallTracker extends CallTracker implements ImsPullCall {
    public ImsPhoneCallTracker(ImsPhone phone, ConnectorFactory factory, Executor executor) {
        this.mPhone = phone;
        mConnectorFactory = factory;
        if (executor != null) {
            mExecutor = executor;
        }

        mMetrics = TelephonyMetrics.getInstance();

+12 −1
Original line number 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.assertNotEquals;
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.verify;
import static org.mockito.Mockito.when;
@@ -42,16 +44,25 @@ import org.junit.Before;
import org.junit.Test;
import org.mockito.ArgumentCaptor;

import java.util.concurrent.Executor;

public class ImsCallTest extends TelephonyTest {

    private Bundle mBundle;
    private ImsCallProfile mTestCallProfile;

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

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

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

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

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

@RunWith(AndroidTestingRunner.class)
@TestableLooper.RunWithLooper
@@ -141,6 +142,13 @@ public class ImsPhoneCallTrackerTest extends TelephonyTest {
    @Captor
    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 {

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

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