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

Commit 8f87419d authored by Pankaj Kanwar's avatar Pankaj Kanwar Committed by android-build-merger
Browse files

Merge "Ensure self-managed CS can use any URI scheme." into pi-dev

am: c3d76c90

Change-Id: I07a545c830828427207474a0bcbc96f9c03a7be3
parents b51afe00 c3d76c90
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -1172,6 +1172,12 @@ public class Call implements CreateConnectionResponse, EventManager.Loggable,
            return false;
        }

        if (!PhoneAccount.SCHEME_SIP.equals(getHandle().getScheme()) &&
                !PhoneAccount.SCHEME_TEL.equals(getHandle().getScheme())) {
            // Can't log schemes other than SIP or TEL for now.
            return false;
        }

        return phoneAccount.getExtras() != null && phoneAccount.getExtras().getBoolean(
                PhoneAccount.EXTRA_LOG_SELF_MANAGED_CALLS, false);
    }
+3 −3
Original line number Diff line number Diff line
@@ -101,9 +101,9 @@ public class CallIntentProcessor {
        String scheme = handle.getScheme();
        String uriString = handle.getSchemeSpecificPart();

        if (!PhoneAccount.SCHEME_VOICEMAIL.equals(scheme)) {
            handle = Uri.fromParts(PhoneNumberUtils.isUriNumber(uriString) ?
                    PhoneAccount.SCHEME_SIP : PhoneAccount.SCHEME_TEL, uriString, null);
        // Ensure sip URIs dialed using TEL scheme get converted to SIP scheme.
        if (PhoneAccount.SCHEME_TEL.equals(scheme) && PhoneNumberUtils.isUriNumber(uriString)) {
            handle = Uri.fromParts(PhoneAccount.SCHEME_SIP, uriString, null);
        }

        PhoneAccountHandle phoneAccountHandle = intent.getParcelableExtra(
+67 −49
Original line number Diff line number Diff line
@@ -144,6 +144,9 @@ public class NewOutgoingCallIntentBroadcaster {
                        return;
                    }

                    // TODO: Remove the assumption that phone numbers are either SIP or TEL.
                    // This does not impact self-managed ConnectionServices as they do not use the
                    // NewOutgoingCallIntentBroadcaster.
                    Uri resultHandleUri = Uri.fromParts(
                            mPhoneNumberUtilsAdapter.isUriNumber(resultNumber) ?
                                    PhoneAccount.SCHEME_SIP : PhoneAccount.SCHEME_TEL,
@@ -219,12 +222,36 @@ public class NewOutgoingCallIntentBroadcaster {
            }
        }

        String number = mPhoneNumberUtilsAdapter.getNumberFromIntent(intent, mContext);
        PhoneAccountHandle targetPhoneAccount = mIntent.getParcelableExtra(
                TelecomManager.EXTRA_PHONE_ACCOUNT_HANDLE);
        boolean isSelfManaged = false;
        if (targetPhoneAccount != null) {
            PhoneAccount phoneAccount =
                    mCallsManager.getPhoneAccountRegistrar().getPhoneAccountUnchecked(
                            targetPhoneAccount);
            if (phoneAccount != null) {
                isSelfManaged = phoneAccount.isSelfManaged();
            }
        }

        String number = "";
        // True for certain types of numbers that are not intended to be intercepted or modified
        // by third parties (e.g. emergency numbers).
        boolean callImmediately = false;
        // True for all managed calls, false for self-managed calls.
        boolean sendNewOutgoingCallBroadcast = true;
        Uri callingAddress = handle;

        if (!isSelfManaged) {
            // Placing a managed call
            number = mPhoneNumberUtilsAdapter.getNumberFromIntent(intent, mContext);
            if (TextUtils.isEmpty(number)) {
                Log.w(this, "Empty number obtained from the call intent.");
                return DisconnectCause.NO_PHONE_NUMBER_SUPPLIED;
            }

            // TODO: Cleanup this dialing code; it makes the assumption that we're dialing with a
            // SIP or TEL URI.
            boolean isUriNumber = mPhoneNumberUtilsAdapter.isUriNumber(number);
            if (!isUriNumber) {
                number = mPhoneNumberUtilsAdapter.convertKeypadLettersToDigits(number);
@@ -236,9 +263,6 @@ public class NewOutgoingCallIntentBroadcaster {

            rewriteCallIntentAction(intent, isPotentialEmergencyNumber);
            action = intent.getAction();
        // True for certain types of numbers that are not intended to be intercepted or modified
        // by third parties (e.g. emergency numbers).
        boolean callImmediately = false;

            if (Intent.ACTION_CALL.equals(action)) {
                if (isPotentialEmergencyNumber) {
@@ -263,29 +287,23 @@ public class NewOutgoingCallIntentBroadcaster {
                return DisconnectCause.INVALID_NUMBER;
            }

        // True for all managed calls, false for self-managed calls.
        boolean sendNewOutgoingCallBroadcast = true;
        PhoneAccountHandle targetPhoneAccount = mIntent.getParcelableExtra(
                TelecomManager.EXTRA_PHONE_ACCOUNT_HANDLE);
        if (targetPhoneAccount != null) {
            PhoneAccount phoneAccount =
                    mCallsManager.getPhoneAccountRegistrar().getPhoneAccountUnchecked(
                            targetPhoneAccount);
            if (phoneAccount != null && phoneAccount.isSelfManaged()) {
            // TODO: Support dialing using URIs instead of just assuming SIP or TEL.
            String scheme = isUriNumber ? PhoneAccount.SCHEME_SIP : PhoneAccount.SCHEME_TEL;
            callingAddress = Uri.fromParts(scheme, number, null);
        } else {
            // Self-managed call.
            callImmediately = true;
            sendNewOutgoingCallBroadcast = false;
            Log.i(this, "Skipping NewOutgoingCallBroadcast for self-managed call.");
        }
        }

        if (callImmediately) {
            String scheme = isUriNumber ? PhoneAccount.SCHEME_SIP : PhoneAccount.SCHEME_TEL;
            boolean speakerphoneOn = mIntent.getBooleanExtra(
                    TelecomManager.EXTRA_START_CALL_WITH_SPEAKERPHONE, false);
            int videoState = mIntent.getIntExtra(
                    TelecomManager.EXTRA_START_CALL_WITH_VIDEO_STATE,
                    VideoProfile.STATE_AUDIO_ONLY);
            placeOutgoingCallImmediately(mCall, Uri.fromParts(scheme, number, null), null,
            placeOutgoingCallImmediately(mCall, callingAddress, null,
                    speakerphoneOn, videoState);

            // Don't return but instead continue and send the ACTION_NEW_OUTGOING_CALL broadcast
+3 −3
Original line number Diff line number Diff line
@@ -103,9 +103,9 @@ public class UserCallIntentProcessor {
        String scheme = handle.getScheme();
        String uriString = handle.getSchemeSpecificPart();

        if (!PhoneAccount.SCHEME_VOICEMAIL.equals(scheme)) {
            handle = Uri.fromParts(PhoneNumberUtils.isUriNumber(uriString) ?
                    PhoneAccount.SCHEME_SIP : PhoneAccount.SCHEME_TEL, uriString, null);
        // Ensure sip URIs dialed using TEL scheme get converted to SIP scheme.
        if (PhoneAccount.SCHEME_TEL.equals(scheme) && PhoneNumberUtils.isUriNumber(uriString)) {
            handle = Uri.fromParts(PhoneAccount.SCHEME_SIP, uriString, null);
        }

        // Check DISALLOW_OUTGOING_CALLS restriction. Note: We are skipping this check in a managed
+1 −0
Original line number Diff line number Diff line
@@ -583,6 +583,7 @@ public class MissedCallNotifierImpl extends CallsManagerListenerBase implements
                                    || TextUtils.isEmpty(handleString)) {
                                handle = null;
                            } else {
                                // TODO: Remove the assumption that numbers are SIP or TEL only.
                                handle = Uri.fromParts(PhoneNumberUtils.isUriNumber(handleString) ?
                                        PhoneAccount.SCHEME_SIP : PhoneAccount.SCHEME_TEL,
                                                handleString, null);
Loading