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

Commit d75fabf9 authored by Nancy Chen's avatar Nancy Chen
Browse files

Retain "voicemail:" URI for startOutgoingCall and add scheme Constants.

We want the "voicemail:" URI to be passed to InCallUI, so do
not convert to "tel" before startOutgoingCall. Also factor out
"SCHEME_*" constants to a separate file.

Bug: 17363355
Change-Id: I6ee42bb5262d4de8121082681ccd4f2f06b74b95
parent 81283c93
Loading
Loading
Loading
Loading
+8 −3
Original line number Diff line number Diff line
@@ -119,9 +119,14 @@ public class CallActivity extends Activity {
     * @param intent Call intent containing data about the handle to call.
     */
    private void processOutgoingCallIntent(Intent intent) {
        String uriString = intent.getData().getSchemeSpecificPart();
        Uri handle = Uri.fromParts(
                PhoneNumberUtils.isUriNumber(uriString) ? "sip" : "tel", uriString, null);
        Uri handle = intent.getData();
        String scheme = handle.getScheme();
        String uriString = handle.getSchemeSpecificPart();

        if (!Constants.SCHEME_VOICEMAIL.equals(scheme)) {
            handle = Uri.fromParts(PhoneNumberUtils.isUriNumber(uriString) ?
                    Constants.SCHEME_SIP : Constants.SCHEME_TEL, uriString, null);
        }

        UserManager userManager = (UserManager) getSystemService(Context.USER_SERVICE);
        if (userManager.hasUserRestriction(UserManager.DISALLOW_OUTGOING_CALLS)
+35 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2014 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.android.telecomm;

/**
 * App-wide constants for the phone app.
 *
 * Any constants that need to be shared between two or more classes within
 * the com.android.phone package should be defined here.  (Constants that
 * are private to only one class can go in that class's .java file.)
 */
public class Constants {
    //
    // URI schemes
    //

    public static final String SCHEME_SIP = "sip";
    public static final String SCHEME_SMSTO = "smsto";
    public static final String SCHEME_TEL = "tel";
    public static final String SCHEME_VOICEMAIL = "voicemail";
}
 No newline at end of file
+1 −2
Original line number Diff line number Diff line
@@ -53,7 +53,6 @@ class MissedCallNotifier extends CallsManagerListenerBase {
        Calls.TYPE,
    };
    private static final int MISSED_CALL_NOTIFICATION_ID = 1;
    private static final String SCHEME_SMSTO = "smsto";

    private final Context mContext;
    private final NotificationManager mNotificationManager;
@@ -237,7 +236,7 @@ class MissedCallNotifier extends CallsManagerListenerBase {
    private PendingIntent createSendSmsFromNotificationPendingIntent(Uri handle) {
        return createTelecommPendingIntent(
                TelecommBroadcastReceiver.ACTION_SEND_SMS_FROM_NOTIFICATION,
                Uri.fromParts(SCHEME_SMSTO, handle.getSchemeSpecificPart(), null));
                Uri.fromParts(Constants.SCHEME_SMSTO, handle.getSchemeSpecificPart(), null));
    }

    /**
+4 −10
Original line number Diff line number Diff line
@@ -65,10 +65,6 @@ class NewOutgoingCallIntentBroadcaster {
    public static final String EXTRA_GATEWAY_ORIGINAL_URI =
            "com.android.phone.extra.GATEWAY_ORIGINAL_URI";

    private static final String SCHEME_TEL = "tel";
    private static final String SCHEME_SIP = "sip";
    private static final String SCHEME_VOICEMAIL = "voicemail";

    private final CallsManager mCallsManager;
    private final Call mCall;
    private final Intent mIntent;
@@ -117,10 +113,8 @@ class NewOutgoingCallIntentBroadcaster {
                return;
            }

            Uri resultHandleUri = Uri.fromParts(
                    PhoneNumberUtils.isUriNumber(resultNumber) ? SCHEME_SIP : SCHEME_TEL,
                    resultNumber,
                    null);
            Uri resultHandleUri = Uri.fromParts(PhoneNumberUtils.isUriNumber(resultNumber) ?
                    Constants.SCHEME_SIP : Constants.SCHEME_TEL, resultNumber, null);

            Uri originalUri = mIntent.getData();

@@ -169,7 +163,7 @@ class NewOutgoingCallIntentBroadcaster {
            return DisconnectCause.INVALID_NUMBER;
        }

        boolean isVoicemailNumber = SCHEME_VOICEMAIL.equals(handle.getScheme());
        boolean isVoicemailNumber = Constants.SCHEME_VOICEMAIL.equals(handle.getScheme());
        if (isVoicemailNumber) {
            if (Intent.ACTION_CALL.equals(action)) {
                // Voicemail calls will be handled directly by the telephony connection manager
@@ -234,7 +228,7 @@ class NewOutgoingCallIntentBroadcaster {
        if (callImmediately) {
            Log.i(this, "Placing call immediately instead of waiting for "
                    + " OutgoingCallBroadcastReceiver: %s", intent);
            String scheme = isUriNumber ? SCHEME_SIP : SCHEME_TEL;
            String scheme = isUriNumber ? Constants.SCHEME_SIP : Constants.SCHEME_TEL;
            boolean speakerphoneOn = mIntent.getBooleanExtra(
                    TelecommManager.EXTRA_START_CALL_WITH_SPEAKERPHONE, false);
            int videoState = mIntent.getIntExtra(
+1 −3
Original line number Diff line number Diff line
@@ -38,8 +38,6 @@ import java.util.List;
 * Helper class to manage the "Respond via Message" feature for incoming calls.
 */
public class RespondViaSmsManager extends CallsManagerListenerBase {
    private static final String SCHEME_SMSTO = "smsto";

    private static final int MSG_CANNED_TEXT_MESSAGES_READY = 1;
    private static final int MSG_SHOW_SENT_TOAST = 2;

@@ -170,7 +168,7 @@ public class RespondViaSmsManager extends CallsManagerListenerBase {
                            TelecommApp.getInstance(), true /*updateIfNeeded*/);
            if (component != null) {
                // Build and send the intent
                final Uri uri = Uri.fromParts(SCHEME_SMSTO, phoneNumber, null);
                final Uri uri = Uri.fromParts(Constants.SCHEME_SMSTO, phoneNumber, null);
                final Intent intent = new Intent(TelephonyManager.ACTION_RESPOND_VIA_MESSAGE, uri);
                intent.putExtra(Intent.EXTRA_TEXT, textMessage);
                mHandler.obtainMessage(MSG_SHOW_SENT_TOAST, phoneNumber).sendToTarget();