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

Commit 3320f824 authored by Tyler Gunn's avatar Tyler Gunn Committed by Gerrit Code Review
Browse files

Merge "Support for detection of international call while on WFC only."

parents f6800ef3 70241c53
Loading
Loading
Loading
Loading
+50 −1
Original line number Diff line number Diff line
@@ -44,6 +44,7 @@ import android.telephony.CarrierConfigManager;
import android.telephony.CellLocation;
import android.telephony.PhoneNumberUtils;
import android.telephony.ServiceState;
import android.telephony.SubscriptionInfo;
import android.telephony.SubscriptionManager;
import android.telephony.TelephonyManager;

@@ -69,7 +70,6 @@ import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.telephony.cdma.CdmaMmiCode;
import com.android.internal.telephony.cdma.CdmaSubscriptionSourceManager;
import com.android.internal.telephony.cdma.EriManager;
import com.android.internal.telephony.dataconnection.DcTracker;
import com.android.internal.telephony.gsm.GsmMmiCode;
import com.android.internal.telephony.gsm.SuppServiceNotification;
import com.android.internal.telephony.test.SimulatedRadioControl;
@@ -1142,6 +1142,42 @@ public class GsmCdmaPhone extends Phone {
        }
    }

    /**
     * @return {@code true} if the user should be informed of an attempt to dial an international
     * number while on WFC only, {@code false} otherwise.
     */
    public boolean isNotificationOfWfcCallRequired(String dialString) {
        CarrierConfigManager configManager =
                (CarrierConfigManager) mContext.getSystemService(Context.CARRIER_CONFIG_SERVICE);
        PersistableBundle config = configManager.getConfigForSubId(getSubId());

        // Determine if carrier config indicates that international calls over WFC should trigger a
        // notification to the user. This is controlled by carrier configuration and is off by
        // default.
        boolean shouldNotifyInternationalCallOnWfc = config != null
                && config.getBoolean(
                        CarrierConfigManager.KEY_NOTIFY_INTERNATIONAL_CALL_ON_WFC_BOOL);

        if (!shouldNotifyInternationalCallOnWfc) {
            return false;
        }

        Phone imsPhone = mImsPhone;
        boolean isEmergency = PhoneNumberUtils.isEmergencyNumber(getSubId(), dialString);
        boolean shouldConfirmCall =
                        // Using IMS
                        isImsUseEnabled()
                        && imsPhone != null
                        // VoLTE not available
                        && !imsPhone.isVolteEnabled()
                        // WFC is available
                        && imsPhone.isWifiCallingEnabled()
                        && !isEmergency
                        // Dialing international number
                        && PhoneNumberUtils.isInternationalNumber(dialString, getCountryIso());
        return shouldConfirmCall;
    }

    @Override
    protected Connection dialInternal(String dialString, UUSInfo uusInfo, int videoState,
                                      Bundle intentExtras)
@@ -3251,6 +3287,19 @@ public class GsmCdmaPhone extends Phone {
        return operatorNumeric;
    }

    /**
     * @return The country ISO for the subscription associated with this phone.
     */
    public String getCountryIso() {
        int subId = getSubId();
        SubscriptionInfo subInfo = SubscriptionManager.from(getContext())
                .getActiveSubscriptionInfo(subId);
        if (subInfo == null) {
            return null;
        }
        return subInfo.getCountryIso().toUpperCase();
    }

    public void notifyEcbmTimerReset(Boolean flag) {
        mEcmTimerResetRegistrants.notifyResult(flag);
    }
+14 −1
Original line number Diff line number Diff line
@@ -19,10 +19,10 @@ package com.android.internal.telephony;
import android.net.Uri;
import android.platform.test.annotations.Postsubmit;
import android.support.test.filters.FlakyTest;
import android.telephony.PhoneNumberUtils;
import android.test.AndroidTestCase;
import android.test.suitebuilder.annotation.SmallTest;
import android.text.SpannableStringBuilder;
import android.telephony.PhoneNumberUtils;

public class PhoneNumberUtilsTest extends AndroidTestCase {

@@ -691,4 +691,17 @@ public class PhoneNumberUtilsTest extends AndroidTestCase {
        converted = PhoneNumberUtils.convertSipUriToTelUri(source);
        assertEquals(expected, converted);
    }

    @SmallTest
    public void testIsInternational() {
        assertFalse(PhoneNumberUtils.isInternationalNumber("+16505551212", "US"));
        assertTrue(PhoneNumberUtils.isInternationalNumber("+16505551212", "UK"));
        assertTrue(PhoneNumberUtils.isInternationalNumber("+16505551212", "JP"));
        assertTrue(PhoneNumberUtils.isInternationalNumber("+86 10 8888 0000", "US"));
        assertTrue(PhoneNumberUtils.isInternationalNumber("001-541-754-3010", "DE"));
        assertFalse(PhoneNumberUtils.isInternationalNumber("001-541-754-3010", "US"));
        assertTrue(PhoneNumberUtils.isInternationalNumber("01161396694916", "US"));
        assertTrue(PhoneNumberUtils.isInternationalNumber("011-613-966-94916", "US"));
        assertFalse(PhoneNumberUtils.isInternationalNumber("011-613-966-94916", "AU"));
    }
}