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

Commit 4fd6713f authored by Tyler Gunn's avatar Tyler Gunn Committed by Android (Google) Code Review
Browse files

Merge "Better handling of dialog event package numbers, and call pulling." into nyc-mr1-dev

parents dd9256da 1c23d391
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -170,7 +170,7 @@ public class ImsExternalCallTracker {

        ImsExternalConnection connection = new ImsExternalConnection(mPhone,
                state.getCallId(), /* Dialog event package call id */
                state.getAddress().getSchemeSpecificPart() /* phone number */,
                state.getAddress() /* phone number */,
                state.isCallPullable());
        connection.setVideoState(ImsCallProfile.getVideoStateFromCallType(state.getCallType()));
        connection.addListener(mExternalConnectionListener);
+22 −2
Original line number Diff line number Diff line
@@ -23,6 +23,8 @@ import com.android.internal.telephony.Phone;
import com.android.internal.telephony.PhoneConstants;
import com.android.internal.telephony.UUSInfo;

import android.net.Uri;
import android.telephony.PhoneNumberUtils;
import android.telephony.Rlog;
import android.util.Log;

@@ -65,16 +67,21 @@ public class ImsExternalConnection extends Connection {
     */
    private ImsExternalCall mCall;

    /**
     * The original address as contained in the dialog event package.
     */
    private Uri mOriginalAddress;

    /**
     * Determines if the call is pullable.
     */
    private boolean mIsPullable;

    protected ImsExternalConnection(Phone phone, int callId, String address, boolean isPullable) {
    protected ImsExternalConnection(Phone phone, int callId, Uri address, boolean isPullable) {
        super(phone.getPhoneType());
        mCall = new ImsExternalCall(phone, this);
        mCallId = callId;
        mAddress = address;
        setExternalConnectionAddress(address);
        mNumberPresentation = PhoneConstants.PRESENTATION_ALLOWED;
        mIsPullable = isPullable;

@@ -199,6 +206,19 @@ public class ImsExternalConnection extends Connection {
        rebuildCapabilities();
    }

    /**
     * Sets the address of this external connection.  Ensures that dialog event package SIP
     * {@link Uri}s are converted to a regular telephone number.
     *
     * @param address The address from the dialog event package.
     */
    public void setExternalConnectionAddress(Uri address) {
        mOriginalAddress = address;

        Uri telUri = PhoneNumberUtils.convertSipUriToTelUri(address);
        mAddress = telUri.getSchemeSpecificPart();
    }

    public void addListener(Listener listener) {
        mListeners.add(listener);
    }
+4 −0
Original line number Diff line number Diff line
@@ -1173,6 +1173,10 @@ public class ImsPhoneCallTracker extends CallTracker implements ImsPullCall {

            case ImsReasonInfo.CODE_FDN_BLOCKED:
                return DisconnectCause.FDN_BLOCKED;

            case ImsReasonInfo.CODE_ANSWERED_ELSEWHERE:
            case ImsReasonInfo.CODE_CALL_END_CAUSE_CALL_PULL:
                return DisconnectCause.CALL_PULLED;
            default:
        }

+23 −0
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

package com.android.internal.telephony;

import android.net.Uri;
import android.test.AndroidTestCase;
import android.test.suitebuilder.annotation.SmallTest;
import android.text.SpannableStringBuilder;
@@ -642,4 +643,26 @@ public class PhoneNumberUtilsTest extends AndroidTestCase {
        assertEquals("18004664411", PhoneNumberUtils.convertAndStrip("1-800-GOOG-411"));
        assertEquals("8002223334", PhoneNumberUtils.convertAndStrip("(800) ABC-DEFG"));
    }

    @SmallTest
    public void testConvertSipUriToTelUri1() {
        // Nominal case, a tel Uri came in, so we expect one out.
        Uri source = Uri.fromParts("tel", "+16505551212", null);
        Uri expected = Uri.fromParts("tel", "+16505551212", null);
        Uri converted = PhoneNumberUtils.convertSipUriToTelUri(source);
        assertEquals(expected, converted);

        // Valid cases
        source = Uri.fromParts("sip", "+16505551212@sipinator.com", null);
        converted = PhoneNumberUtils.convertSipUriToTelUri(source);
        assertEquals(expected, converted);

        source = Uri.fromParts("sip", "+16505551212;phone-context=blah.com@host.com", null);
        converted = PhoneNumberUtils.convertSipUriToTelUri(source);
        assertEquals(expected, converted);

        source = Uri.fromParts("sip", "+16505551212@something.com;user=phone", null);
        converted = PhoneNumberUtils.convertSipUriToTelUri(source);
        assertEquals(expected, converted);
    }
}