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

Commit 1d158357 authored by Hung-ying Tyan's avatar Hung-ying Tyan
Browse files

SipPhone: do not append SIP domain to PSTN number

in the CallerInfo so that only PSTN number is shown in the call log.

http://b/issue?id=2982632

Change-Id: I414f01d16ce64ecb8da7c6943ea7f080bcfd2794
parent afa583e6
Loading
Loading
Loading
Loading
+28 −19
Original line number Diff line number Diff line
@@ -394,25 +394,45 @@ public class SipPhone extends SipPhoneBase {
            }
        }

        private CallerInfo getCallerInfo(String number) {
        private CallerInfo createCallerInfo(String number, SipProfile callee) {
            SipProfile p = callee;
            String name = p.getDisplayName();
            if (TextUtils.isEmpty(name)) name = p.getUserName();
            CallerInfo info = new CallerInfo();
            info.name = name;
            info.phoneNumber = number;
            Log.v(LOG_TAG, "create caller info from scratch:");
            Log.v(LOG_TAG, "     name: " + info.name);
            Log.v(LOG_TAG, "     numb: " + info.phoneNumber);
            return info;
        }

        // from contacts
        private CallerInfo findCallerInfo(String number) {
            CallerInfo info = CallerInfo.getCallerInfo(mContext, number);
            if ((info == null) || (info.name == null)) return null;
            Log.v(LOG_TAG, "++******++ got info from contact:");
            Log.v(LOG_TAG, "got caller info from contact:");
            Log.v(LOG_TAG, "     name: " + info.name);
            Log.v(LOG_TAG, "     numb: " + info.phoneNumber);
            Log.v(LOG_TAG, "     pres: " + info.numberPresentation);
            return info;
        }

        Connection dial(String calleeSipUri) throws SipException {
            CallerInfo info = getCallerInfo(calleeSipUri);
        private CallerInfo getCallerInfo(String number, SipProfile callee) {
            CallerInfo info = findCallerInfo(number);
            if (info == null) info = createCallerInfo(number, callee);
            return info;
        }

        Connection dial(String originalNumber) throws SipException {
            String calleeSipUri = originalNumber;
            if (!calleeSipUri.contains("@")) {
                calleeSipUri += "@" + getSipDomain(mProfile);
                if (info != null) info.phoneNumber = calleeSipUri;
            }
            try {
                SipProfile callee =
                        new SipProfile.Builder(calleeSipUri).build();
                CallerInfo info = getCallerInfo(originalNumber, callee);
                SipConnection c = new SipConnection(this, callee, info);
                connections.add(c);
                c.dial();
@@ -444,9 +464,9 @@ public class SipPhone extends SipPhoneBase {

        void initIncomingCall(SipAudioCall sipAudioCall, boolean makeCallWait) {
            SipProfile callee = sipAudioCall.getPeerProfile();
            CallerInfo info = getCallerInfo(getUriString(callee));
            if (info == null) info = getCallerInfo(callee.getUserName());
            if (info == null) info = getCallerInfo(callee.getDisplayName());
            CallerInfo info = findCallerInfo(getUriString(callee));
            if (info == null) info = findCallerInfo(callee.getUserName());
            if (info == null) info = findCallerInfo(callee.getDisplayName());
            SipConnection c = new SipConnection(this, callee, info);
            connections.add(c);

@@ -654,20 +674,9 @@ public class SipPhone extends SipPhoneBase {
            super(getUriString(callee));
            mOwner = owner;
            mPeer = callee;
            if (info == null) info = createCallerInfo();
            setUserData(info);
        }

        private CallerInfo createCallerInfo() {
            SipProfile p = mPeer;
            String name = p.getDisplayName();
            if (TextUtils.isEmpty(name)) name = p.getUserName();
            CallerInfo info = new CallerInfo();
            info.name = name;
            info.phoneNumber = getUriString(p);
            return info;
        }

        void initIncomingCall(SipAudioCall sipAudioCall, Call.State newState) {
            setState(newState);
            mSipAudioCall = sipAudioCall;