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

Commit 9f8be83f authored by Steve Statia's avatar Steve Statia Committed by Android (Google) Code Review
Browse files

Merge "Reformat local numbers that are placing calls in Singapore to not show...

Merge "Reformat local numbers that are placing calls in Singapore to not show the country code." into main
parents 89cf895e 4f7428e8
Loading
Loading
Loading
Loading
+12 −1
Original line number Diff line number Diff line
@@ -18,3 +18,14 @@ flag {
  description: "Used in DisconnectCause and TelephonyConnection if a non-emergency call fails on a device with no 2G, to guard whether a user can see an updated error message reminding the 2G is disabled and potentially disrupting their call connectivity"
  bug: "300142897"
}

# OWNER=stevestatia TARGET=24Q4
flag {
    name: "remove_country_code_from_local_singapore_calls"
    namespace: "telephony"
    description: "Fix bug where the country code is being shown when merging in local Singapore numbers to conference calls."
    bug:"284416645"
    metadata {
        purpose: PURPOSE_BUGFIX
    }
}
+60 −0
Original line number Diff line number Diff line
@@ -21,7 +21,10 @@ import static junit.framework.Assert.assertFalse;
import static junit.framework.Assert.assertNull;
import static junit.framework.Assert.assertTrue;

import com.android.internal.telephony.flags.Flags;

import android.net.Uri;
import android.platform.test.flag.junit.SetFlagsRule;
import android.telephony.PhoneNumberUtils;
import android.text.SpannableStringBuilder;
import android.text.style.TtsSpan;
@@ -32,6 +35,7 @@ import androidx.test.filters.SmallTest;
import org.junit.After;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Rule;
import org.junit.Test;

public class PhoneNumberUtilsTest {
@@ -40,6 +44,8 @@ public class PhoneNumberUtilsTest {

    private int mOldMinMatch;

    @Rule public final SetFlagsRule mSetFlagsRule = new SetFlagsRule();

    @Before
    public void setUp() throws Exception {
        mOldMinMatch = PhoneNumberUtils.getMinMatchForTest();
@@ -613,6 +619,60 @@ public class PhoneNumberUtilsTest {
        assertEquals("+1 650-555-1212", PhoneNumberUtils.formatNumber("+16505551212", "jp"));
    }

    /**
     * Test to ensure that when international calls to Singapore are being placed the country
     * code is present with and without the feature flag enabled.
     */
    @SmallTest
    @Test
    public void testFormatSingaporeInternational() {
        // Disable feature flag.
        mSetFlagsRule.disableFlags(Flags.FLAG_REMOVE_COUNTRY_CODE_FROM_LOCAL_SINGAPORE_CALLS);

        // International call from a US iso
        assertEquals("+65 6521 8000", PhoneNumberUtils.formatNumber("+6565218000", "US"));

        // Lowercase country iso
        assertEquals("+65 6521 8000", PhoneNumberUtils.formatNumber("+6565218000", "us"));

        // Enable feature flag
        mSetFlagsRule.enableFlags(Flags.FLAG_REMOVE_COUNTRY_CODE_FROM_LOCAL_SINGAPORE_CALLS);

        // Internal call from a US iso
        assertEquals("+65 6521 8000", PhoneNumberUtils.formatNumber("+6565218000", "US"));

        // Lowercase country iso
        assertEquals("+65 6521 8000", PhoneNumberUtils.formatNumber("+6565218000", "us"));
        mSetFlagsRule.disableFlags(Flags.FLAG_REMOVE_COUNTRY_CODE_FROM_LOCAL_SINGAPORE_CALLS);
    }

    /**
     * Test to ensure that when local calls from Singaporean numbers are being placed to other
     * Singaporean numbers the country code +65 is not being shown.
     */
    @SmallTest
    @Test
    public void testFormatSingaporeNational() {
        // Disable feature flag.
        mSetFlagsRule.disableFlags(Flags.FLAG_REMOVE_COUNTRY_CODE_FROM_LOCAL_SINGAPORE_CALLS);

        // Local call from a Singaporean number to a Singaporean number
        assertEquals("+65 6521 8000", PhoneNumberUtils.formatNumber("+6565218000", "SG"));

        // Lowercase country iso.
        assertEquals("+65 6521 8000", PhoneNumberUtils.formatNumber("+6565218000", "sg"));

        // Enable feature flag.
        mSetFlagsRule.enableFlags(Flags.FLAG_REMOVE_COUNTRY_CODE_FROM_LOCAL_SINGAPORE_CALLS);

        // Local call from a Singaporean number to a Singaporean number.
        assertEquals("6521 8000", PhoneNumberUtils.formatNumber("+6565218000", "SG"));

        // Lowercase country iso.
        assertEquals("6521 8000", PhoneNumberUtils.formatNumber("+6565218000", "sg"));
        mSetFlagsRule.disableFlags(Flags.FLAG_REMOVE_COUNTRY_CODE_FROM_LOCAL_SINGAPORE_CALLS);
    }

    @SmallTest
    @Test
    public void testFormatNumber_LeadingStarAndHash() {