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

Commit 4518749c authored by Brad Ebinger's avatar Brad Ebinger Committed by Automerger Merge Worker
Browse files

Merge "Silent redial regarding fg and bg call type" am: aab16d41 am: 1be2c56e am: affc9e7d

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

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: Id41525be83fd930a360b1ed4feb46830e80a9977
parents ba25db62 affc9e7d
Loading
Loading
Loading
Loading
+7 −5
Original line number Diff line number Diff line
@@ -1364,9 +1364,15 @@ public class GsmCdmaPhone extends Phone {
        }
        TelephonyManager tm = mContext.getSystemService(TelephonyManager.class);
        boolean isEmergency = tm.isEmergencyNumber(dialString);
        /** Check if the call is Wireless Priority Service call */
        boolean isWpsCall = dialString != null ? (dialString.startsWith(PREFIX_WPS)
                || dialString.startsWith(PREFIX_WPS_CLIR_ACTIVATE)
                || dialString.startsWith(PREFIX_WPS_CLIR_DEACTIVATE)) : false;

        ImsPhone.ImsDialArgs.Builder imsDialArgsBuilder;
        imsDialArgsBuilder = ImsPhone.ImsDialArgs.Builder.from(dialArgs)
                                                 .setIsEmergency(isEmergency);
                                                 .setIsEmergency(isEmergency)
                                                 .setIsWpsCall(isWpsCall);
        mDialArgs = dialArgs = imsDialArgsBuilder.build();

        Phone imsPhone = mImsPhone;
@@ -1374,10 +1380,6 @@ public class GsmCdmaPhone extends Phone {
        CarrierConfigManager configManager =
                (CarrierConfigManager) mContext.getSystemService(Context.CARRIER_CONFIG_SERVICE);

        /** Check if the call is Wireless Priority Service call */
        boolean isWpsCall = dialString != null ? (dialString.startsWith(PREFIX_WPS)
                || dialString.startsWith(PREFIX_WPS_CLIR_ACTIVATE)
                || dialString.startsWith(PREFIX_WPS_CLIR_DEACTIVATE)) : false;
        boolean allowWpsOverIms = configManager.getConfigForSubId(getSubId())
                .getBoolean(CarrierConfigManager.KEY_SUPPORT_WPS_OVER_IMS_BOOL);

+12 −1
Original line number Diff line number Diff line
@@ -170,6 +170,7 @@ public class ImsPhone extends ImsPhoneBase {
            private android.telecom.Connection.RttTextStream mRttTextStream;
            private int mRetryCallFailCause = ImsReasonInfo.CODE_UNSPECIFIED;
            private int mRetryCallFailNetworkType = TelephonyManager.NETWORK_TYPE_UNKNOWN;
            private boolean mIsWpsCall = false;

            public static ImsDialArgs.Builder from(DialArgs dialArgs) {
                if (dialArgs instanceof ImsDialArgs) {
@@ -182,7 +183,8 @@ public class ImsPhone extends ImsPhoneBase {
                            .setClirMode(dialArgs.clirMode)
                            .setRetryCallFailCause(((ImsDialArgs)dialArgs).retryCallFailCause)
                            .setRetryCallFailNetworkType(
                                    ((ImsDialArgs)dialArgs).retryCallFailNetworkType);
                                    ((ImsDialArgs)dialArgs).retryCallFailNetworkType)
                            .setIsWpsCall(((ImsDialArgs)dialArgs).isWpsCall);
                }
                return new ImsDialArgs.Builder()
                        .setUusInfo(dialArgs.uusInfo)
@@ -208,6 +210,11 @@ public class ImsPhone extends ImsPhoneBase {
                return this;
            }

            public ImsDialArgs.Builder setIsWpsCall(boolean isWpsCall) {
                this.mIsWpsCall = isWpsCall;
                return this;
            }

            public ImsDialArgs build() {
                return new ImsDialArgs(this);
            }
@@ -222,11 +229,15 @@ public class ImsPhone extends ImsPhoneBase {
        public final int retryCallFailCause;
        public final int retryCallFailNetworkType;

        /** Indicates the call is Wireless Priority Service call */
        public final boolean isWpsCall;

        private ImsDialArgs(ImsDialArgs.Builder b) {
            super(b);
            this.rttTextStream = b.mRttTextStream;
            this.retryCallFailCause = b.mRetryCallFailCause;
            this.retryCallFailNetworkType = b.mRetryCallFailNetworkType;
            this.isWpsCall = b.mIsWpsCall;
        }
    }

+43 −6
Original line number Diff line number Diff line
@@ -873,6 +873,8 @@ public class ImsPhoneCallTracker extends CallTracker implements ImsPullCall {
     */
    private boolean mShouldUpdateImsConfigOnDisconnect = false;

    private Pair<Boolean, Integer> mPendingSilentRedialInfo = null;

    /**
     * Default implementation for retrieving shared preferences; uses the actual PreferencesManager.
     */
@@ -1279,6 +1281,7 @@ public class ImsPhoneCallTracker extends CallTracker implements ImsPullCall {
            throws CallStateException {
        boolean isPhoneInEcmMode = isPhoneInEcbMode();
        boolean isEmergencyNumber = dialArgs.isEmergency;
        boolean isWpsCall = dialArgs.isWpsCall;

        if (!shouldNumberBePlacedOnIms(isEmergencyNumber, dialString)) {
            Rlog.i(LOG_TAG, "dial: shouldNumberBePlacedOnIms = false");
@@ -1321,7 +1324,7 @@ public class ImsPhoneCallTracker extends CallTracker implements ImsPullCall {
            mLastDialString = dialString;
            mLastDialArgs = dialArgs;
            mPendingMO = new ImsPhoneConnection(mPhone, dialString, this, mForegroundCall,
                    isEmergencyNumber);
                    isEmergencyNumber, isWpsCall);
            if (isEmergencyNumber && dialArgs != null && dialArgs.intentExtras != null) {
                Rlog.i(LOG_TAG, "dial ims emergency dialer: " + dialArgs.intentExtras.getBoolean(
                        TelecomManager.EXTRA_IS_USER_INTENT_EMERGENCY_CALL));
@@ -2950,15 +2953,27 @@ public class ImsPhoneCallTracker extends CallTracker implements ImsPullCall {
            if (mPendingMO != null) {
                // To initiate dialing circuit-switched call
                if (reasonInfo.getCode() == ImsReasonInfo.CODE_LOCAL_CALL_CS_RETRY_REQUIRED
                        && mBackgroundCall.getState() == ImsPhoneCall.State.IDLE
                        && mRingingCall.getState() == ImsPhoneCall.State.IDLE) {
                        && mRingingCall.getState() == ImsPhoneCall.State.IDLE
                        && isForegroundHigherPriority()) {
                    mForegroundCall.detach(mPendingMO);
                    removeConnection(mPendingMO);
                    mPendingMO.finalize();
                    mPendingMO = null;
                    // if we need to perform CSFB of call, hang up any background call
                    // before redialing if it is a lower priority.
                    if (mBackgroundCall.getState().isAlive()) {
                        try {
                            hangup(mBackgroundCall);
                            mPendingSilentRedialInfo = new Pair<>(reasonInfo.getExtraCode() ==
                                ImsReasonInfo.EXTRA_CODE_CALL_RETRY_EMERGENCY, eccCategory);
                        } catch (CallStateException ex) {
                            mPendingSilentRedialInfo = null;
                        }
                    } else {
                        updatePhoneState();
                        mPhone.initiateSilentRedial(reasonInfo.getExtraCode() ==
                                ImsReasonInfo.EXTRA_CODE_CALL_RETRY_EMERGENCY, eccCategory);
                    }
                    return;
                } else {
                    sendCallStartFailedDisconnect(imsCall, reasonInfo);
@@ -3166,6 +3181,12 @@ public class ImsPhoneCallTracker extends CallTracker implements ImsPullCall {
                }
                mShouldUpdateImsConfigOnDisconnect = false;
            }

            if (mPendingSilentRedialInfo != null) {
                mPhone.initiateSilentRedial(mPendingSilentRedialInfo.first,
                                            mPendingSilentRedialInfo.second);
                mPendingSilentRedialInfo = null;
            }
        }

        @Override
@@ -5100,4 +5121,20 @@ public class ImsPhoneCallTracker extends CallTracker implements ImsPullCall {
        }
        mPhone.notifySuppServiceFailed(Phone.SuppService.CONFERENCE);
    }

    /**
     * Calculate whether CSFB or not with fg call type and bg call type.
     * @return {@code true} if bg call is not alive or fg call has higher score than bg call.
     */
    private boolean isForegroundHigherPriority() {
        if (!mBackgroundCall.getState().isAlive()) {
            return true;
        }
        ImsPhoneConnection fgConnection = mForegroundCall.getFirstConnection();
        ImsPhoneConnection bgConnection = mBackgroundCall.getFirstConnection();
        if (fgConnection.getCallPriority() > bgConnection.getCallPriority()) {
            return true;
        }
        return false;
    }
}
+21 −1
Original line number Diff line number Diff line
@@ -108,6 +108,8 @@ public class ImsPhoneConnection extends Connection implements

    private boolean mIsEmergency = false;

    private boolean mIsWpsCall = false;

    /**
     * Used to indicate that video state changes detected by
     * {@link #updateMediaCapabilities(ImsCall)} should be ignored.  When a video state change from
@@ -231,7 +233,7 @@ public class ImsPhoneConnection extends Connection implements

    /** This is an MO call, created when dialing */
    public ImsPhoneConnection(Phone phone, String dialString, ImsPhoneCallTracker ct,
            ImsPhoneCall parent, boolean isEmergency) {
            ImsPhoneCall parent, boolean isEmergency, boolean isWpsCall) {
        super(PhoneConstants.PHONE_TYPE_IMS);
        createWakeLock(phone.getContext());
        acquireWakeLock();
@@ -261,6 +263,8 @@ public class ImsPhoneConnection extends Connection implements
            setEmergencyCallInfo(mOwner);
        }

        mIsWpsCall = isWpsCall;

        fetchDtmfToneDelay(phone);

        if (phone.getContext().getResources().getBoolean(
@@ -1411,6 +1415,10 @@ public class ImsPhoneConnection extends Connection implements
        return mIsEmergency;
    }

    protected boolean isWpsCall() {
        return mIsWpsCall;
    }

    /**
     * Indicates whether current phone connection is cross sim calling or not
     * @return boolean: true if cross sim calling, false otherwise
@@ -1586,4 +1594,16 @@ public class ImsPhoneConnection extends Connection implements
                return android.telecom.Connection.VERIFICATION_STATUS_NOT_VERIFIED;
        }
    }

    /**
     * The priority of the call to the user. A higher number means higher priority.
     */
    protected int getCallPriority() {
        if (isEmergency()) {
            return 2;
        } else if (isWpsCall()) {
            return 1;
        }
        return 0;
    }
}
+8 −8
Original line number Diff line number Diff line
@@ -127,7 +127,7 @@ public class ImsPhoneConnectionTest extends TelephonyTest {

        logd("Testing initial state of MO ImsPhoneConnection");
        mConnectionUT = new ImsPhoneConnection(mImsPhone, String.format("+1 (700).555-41NN%c1234",
                PhoneNumberUtils.PAUSE), mImsCT, mForeGroundCall, false);
                PhoneNumberUtils.PAUSE), mImsCT, mForeGroundCall, false, false);
        assertEquals(PhoneConstants.PRESENTATION_ALLOWED, mConnectionUT.getNumberPresentation());
        assertEquals(PhoneConstants.PRESENTATION_ALLOWED, mConnectionUT.getCnapNamePresentation());
        assertEquals("+1 (700).555-41NN,1234", mConnectionUT.getOrigDialString());
@@ -140,7 +140,7 @@ public class ImsPhoneConnectionTest extends TelephonyTest {
    public void testImsUpdateStateForeGround() {
        // MO Foreground Connection dailing -> active
        mConnectionUT = new ImsPhoneConnection(mImsPhone, "+1 (700).555-41NN1234", mImsCT,
                mForeGroundCall, false);
                mForeGroundCall, false, false);
        // initially in dialing state
        doReturn(Call.State.DIALING).when(mForeGroundCall).getState();
        assertTrue(mConnectionUT.update(mImsCall, Call.State.ACTIVE));
@@ -155,7 +155,7 @@ public class ImsPhoneConnectionTest extends TelephonyTest {
    public void testUpdateCodec() {
        // MO Foreground Connection dailing -> active
        mConnectionUT = new ImsPhoneConnection(mImsPhone, "+1 (700).555-41NN1234", mImsCT,
                mForeGroundCall, false);
                mForeGroundCall, false, false);
        doReturn(Call.State.ACTIVE).when(mForeGroundCall).getState();
        assertTrue(mConnectionUT.updateMediaCapabilities(mImsCall));
    }
@@ -178,7 +178,7 @@ public class ImsPhoneConnectionTest extends TelephonyTest {
    @SmallTest
    public void testImsUpdateStatePendingHold() {
        mConnectionUT = new ImsPhoneConnection(mImsPhone, "+1 (700).555-41NN1234", mImsCT,
                mForeGroundCall, false);
                mForeGroundCall, false, false);
        doReturn(true).when(mImsCall).isPendingHold();
        assertFalse(mConnectionUT.update(mImsCall, Call.State.ACTIVE));
        verify(mForeGroundCall, times(0)).update(eq(mConnectionUT), eq(mImsCall),
@@ -223,7 +223,7 @@ public class ImsPhoneConnectionTest extends TelephonyTest {
    @SmallTest
    public void testPostDialWait() {
        mConnectionUT = new ImsPhoneConnection(mImsPhone, String.format("+1 (700).555-41NN%c1234",
                PhoneNumberUtils.WAIT), mImsCT, mForeGroundCall, false);
                PhoneNumberUtils.WAIT), mImsCT, mForeGroundCall, false, false);
        doReturn(Call.State.DIALING).when(mForeGroundCall).getState();
        doAnswer(new Answer() {
            @Override
@@ -246,7 +246,7 @@ public class ImsPhoneConnectionTest extends TelephonyTest {
    @MediumTest
    public void testPostDialPause() {
        mConnectionUT = new ImsPhoneConnection(mImsPhone, String.format("+1 (700).555-41NN%c1234",
                PhoneNumberUtils.PAUSE), mImsCT, mForeGroundCall, false);
                PhoneNumberUtils.PAUSE), mImsCT, mForeGroundCall, false, false);
        doReturn(Call.State.DIALING).when(mForeGroundCall).getState();
        doAnswer(new Answer() {
            @Override
@@ -374,7 +374,7 @@ public class ImsPhoneConnectionTest extends TelephonyTest {
                {"12345*00000", "12346", "12346"}};
        for (String[] testAddress : testAddressMappingSet) {
            mConnectionUT = new ImsPhoneConnection(mImsPhone, testAddress[0], mImsCT,
                    mForeGroundCall, false);
                    mForeGroundCall, false, false);
            mConnectionUT.setIsIncoming(true);
            mImsCallProfile.setCallExtra(ImsCallProfile.EXTRA_OI, testAddress[1]);
            mConnectionUT.updateAddressDisplay(mImsCall);
@@ -392,7 +392,7 @@ public class ImsPhoneConnectionTest extends TelephonyTest {
        String updateAddress = "6789";

        mConnectionUT = new ImsPhoneConnection(mImsPhone, inputAddress, mImsCT, mForeGroundCall,
                false);
                false, false);
        mConnectionUT.setIsIncoming(false);
        mImsCallProfile.setCallExtra(ImsCallProfile.EXTRA_OI, updateAddress);
        mConnectionUT.updateAddressDisplay(mImsCall);