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

Commit 8cff1522 authored by Brad Ebinger's avatar Brad Ebinger Committed by android-build-merger
Browse files

Merge "Add ability to use KEY_DIAL_STRING_REPLACE_STRING_ARRAY for VoLTE calls."

am: f7bb6d10

Change-Id: I65659d4b7550a391e0f889350c035832e90424aa
parents 4cb12e77 f7bb6d10
Loading
Loading
Loading
Loading
+23 −1
Original line number Diff line number Diff line
@@ -27,6 +27,7 @@ import android.telephony.ServiceState;
import android.telephony.emergency.EmergencyNumber;
import android.util.Log;

import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.telephony.emergency.EmergencyNumberTracker;

import java.util.ArrayList;
@@ -322,6 +323,15 @@ public abstract class Connection {
        return null;
    }

    /**
     * Get the number, as set by {@link #restoreDialedNumberAfterConversion(String)}.
     * @return The converted number.
     */
    @VisibleForTesting
    public String getConvertedNumber() {
        return mConvertedNumber;
    }

    /**
     * Gets CNAP presentation associated with connection.
     * @return cnap name or null if unavailable
@@ -1120,7 +1130,19 @@ public abstract class Connection {
        }
    }

    public void setConverted(String oriNumber) {
    /**
     * {@link CallTracker#convertNumberIfNecessary(Phone, String)} can be used to convert a dialed
     * number to another number based on carrier config.  This is used where a carrier wishes to
     * redirect certain short codes such as *55 to another number (e.g. a 1-800 service number).
     * The {@link CallTracker} sub-classes call
     * {@link CallTracker#convertNumberIfNecessary(Phone, String)} to retrieve the newly converted
     * number and instantiate the {@link Connection} instance using the converted number so that the
     * system will dial out the substitution number instead of the originally dialed one.  This gem
     * of a method is called after the dialing process to restore the originally dialed number and
     * keep track of the fact that a converted number was used to place the call.
     * @param oriNumber The original number prior to conversion.
     */
    public void restoreDialedNumberAfterConversion(String oriNumber) {
        mNumberConverted = true;
        mConvertedNumber = mAddress;
        mAddress = oriNumber;
+2 −2
Original line number Diff line number Diff line
@@ -351,7 +351,7 @@ public class GsmCdmaCallTracker extends CallTracker {
        }

        if (mNumberConverted) {
            mPendingMO.setConverted(origNumber);
            mPendingMO.restoreDialedNumberAfterConversion(origNumber);
            mNumberConverted = false;
        }

@@ -484,7 +484,7 @@ public class GsmCdmaCallTracker extends CallTracker {
        }

        if (mNumberConverted) {
            mPendingMO.setConverted(origNumber);
            mPendingMO.restoreDialedNumberAfterConversion(origNumber);
            mNumberConverted = false;
        }

+8 −0
Original line number Diff line number Diff line
@@ -769,9 +769,12 @@ public class ImsPhoneCallTracker extends CallTracker implements ImsPullCall {
        int videoState = dialArgs.videoState;

        if (DBG) log("dial clirMode=" + clirMode);
        String origNumber = dialString;
        if (isEmergencyNumber) {
            clirMode = CommandsInterface.CLIR_SUPPRESSION;
            if (DBG) log("dial emergency call, set clirModIe=" + clirMode);
        } else {
            dialString = convertNumberIfNecessary(mPhone, dialString);
        }

        // note that this triggers call state changed notif
@@ -873,6 +876,11 @@ public class ImsPhoneCallTracker extends CallTracker implements ImsPullCall {
            }
        }

        if (mNumberConverted) {
            mPendingMO.restoreDialedNumberAfterConversion(origNumber);
            mNumberConverted = false;
        }

        updatePhoneState();
        mPhone.notifyPreciseCallStateChanged();

+39 −0
Original line number Diff line number Diff line
@@ -708,6 +708,45 @@ public class ImsPhoneCallTrackerTest extends TelephonyTest {
                nullable(MmTelFeature.Listener.class));
    }

    @Test
    @SmallTest
    public void testRewriteOutgoingNumber() {
        try {
            doAnswer(new Answer<ImsCall>() {
                @Override
                public ImsCall answer(InvocationOnMock invocation) throws Throwable {
                    mImsCallListener =
                            (ImsCall.Listener) invocation.getArguments()[2];
                    ImsCall imsCall = spy(new ImsCall(mContext, mImsCallProfile));
                    imsCall.setListener(mImsCallListener);
                    imsCallMocking(imsCall);
                    return imsCall;
                }
            }).when(mImsManager).makeCall(eq(mImsCallProfile), (String[]) any(),
                    (ImsCall.Listener) any());
        } catch (ImsException ie) {
        }

        // Perform a dial string remapping.
        PersistableBundle bundle = mContextFixture.getCarrierConfigBundle();
        bundle.putStringArray(CarrierConfigManager.KEY_DIAL_STRING_REPLACE_STRING_ARRAY,
                new String[] {"*55:6505551212"});

        ImsPhoneConnection connection = null;
        try {
            connection = (ImsPhoneConnection) mCTUT.dial("*55",
                    ImsCallProfile.CALL_TYPE_VOICE, null);
        } catch (Exception ex) {
            ex.printStackTrace();
            Assert.fail("unexpected exception thrown" + ex.getMessage());
        }
        if (connection == null) {
            Assert.fail("connection is null");
        }
        Assert.assertEquals("6505551212", connection.getConvertedNumber());
        Assert.assertEquals("*55", connection.getAddress());
    }

    /**
     * Test notification of handover from LTE to WIFI and WIFI to LTE and ensure that the expected
     * connection events are sent.