Loading src/java/com/android/internal/telephony/Connection.java +23 −1 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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 Loading Loading @@ -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; Loading src/java/com/android/internal/telephony/GsmCdmaCallTracker.java +2 −2 Original line number Diff line number Diff line Loading @@ -351,7 +351,7 @@ public class GsmCdmaCallTracker extends CallTracker { } if (mNumberConverted) { mPendingMO.setConverted(origNumber); mPendingMO.restoreDialedNumberAfterConversion(origNumber); mNumberConverted = false; } Loading Loading @@ -484,7 +484,7 @@ public class GsmCdmaCallTracker extends CallTracker { } if (mNumberConverted) { mPendingMO.setConverted(origNumber); mPendingMO.restoreDialedNumberAfterConversion(origNumber); mNumberConverted = false; } Loading src/java/com/android/internal/telephony/imsphone/ImsPhoneCallTracker.java +8 −0 Original line number Diff line number Diff line Loading @@ -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 Loading Loading @@ -873,6 +876,11 @@ public class ImsPhoneCallTracker extends CallTracker implements ImsPullCall { } } if (mNumberConverted) { mPendingMO.restoreDialedNumberAfterConversion(origNumber); mNumberConverted = false; } updatePhoneState(); mPhone.notifyPreciseCallStateChanged(); Loading tests/telephonytests/src/com/android/internal/telephony/imsphone/ImsPhoneCallTrackerTest.java +39 −0 Original line number Diff line number Diff line Loading @@ -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. Loading Loading
src/java/com/android/internal/telephony/Connection.java +23 −1 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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 Loading Loading @@ -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; Loading
src/java/com/android/internal/telephony/GsmCdmaCallTracker.java +2 −2 Original line number Diff line number Diff line Loading @@ -351,7 +351,7 @@ public class GsmCdmaCallTracker extends CallTracker { } if (mNumberConverted) { mPendingMO.setConverted(origNumber); mPendingMO.restoreDialedNumberAfterConversion(origNumber); mNumberConverted = false; } Loading Loading @@ -484,7 +484,7 @@ public class GsmCdmaCallTracker extends CallTracker { } if (mNumberConverted) { mPendingMO.setConverted(origNumber); mPendingMO.restoreDialedNumberAfterConversion(origNumber); mNumberConverted = false; } Loading
src/java/com/android/internal/telephony/imsphone/ImsPhoneCallTracker.java +8 −0 Original line number Diff line number Diff line Loading @@ -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 Loading Loading @@ -873,6 +876,11 @@ public class ImsPhoneCallTracker extends CallTracker implements ImsPullCall { } } if (mNumberConverted) { mPendingMO.restoreDialedNumberAfterConversion(origNumber); mNumberConverted = false; } updatePhoneState(); mPhone.notifyPreciseCallStateChanged(); Loading
tests/telephonytests/src/com/android/internal/telephony/imsphone/ImsPhoneCallTrackerTest.java +39 −0 Original line number Diff line number Diff line Loading @@ -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. Loading