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

Commit b0ccce44 authored by Aishwarya Mallampati's avatar Aishwarya Mallampati Committed by Automerger Merge Worker
Browse files

Merge "Support different formats of SMSC during FDN check." into main am:...

Merge "Support different formats of SMSC during FDN check." into main am: 5c1f43a6 am: f4164bc6 am: a971c599 am: eef7cc5f

Original change: https://android-review.googlesource.com/c/platform/frameworks/opt/telephony/+/2710813



Change-Id: I86fdf53fa3c0d72d43155f9ff3e1a0a85159e3a7
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents 56d40d41 eef7cc5f
Loading
Loading
Loading
Loading
+35 −0
Original line number Original line Diff line number Diff line
@@ -33,6 +33,7 @@ import com.android.internal.telephony.uicc.UiccProfile;
import com.android.telephony.Rlog;
import com.android.telephony.Rlog;


import java.util.ArrayList;
import java.util.ArrayList;
import java.util.regex.PatternSyntaxException;


/**
/**
 * This is a basic utility class for common functions related to Fixed Dialing Numbers
 * This is a basic utility class for common functions related to Fixed Dialing Numbers
@@ -123,6 +124,7 @@ public class FdnUtils {
            dialStrNational = String.valueOf(phoneNumber.getNationalNumber());
            dialStrNational = String.valueOf(phoneNumber.getNationalNumber());
        } catch (NumberParseException ignored) {
        } catch (NumberParseException ignored) {
            Rlog.w(LOG_TAG, "isFDN: could not parse dialStr");
            Rlog.w(LOG_TAG, "isFDN: could not parse dialStr");
            dialStr = extractSMSC(dialStr);
        }
        }


        /**
        /**
@@ -187,4 +189,37 @@ public class FdnUtils {


        return uiccProfile.getApplication(UiccController.APP_FAM_3GPP);
        return uiccProfile.getApplication(UiccController.APP_FAM_3GPP);
    }
    }

    private static String extractSMSC(String dialStr) {
        try {
            String[] dialStrParts = null;
            if (dialStr.contains(",")) {
                // SMSC can be in the format of ""+123456789123",123"
                // Split into two parts using comma as delimiter
                // and first part of the string is used as smsc address
                dialStrParts = dialStr.split(",");
            } else if (dialStr.contains("@")) {
                // SMSC can be in the format of "+123456789123@ims.mnc.org"
                // Split into two parts using @ as delimiter
                // and first part of the string is used as smsc address
                dialStrParts = dialStr.split("@");
            }

            if (dialStrParts != null && dialStrParts.length >= 1) {
                if (dialStrParts[0].contains("\"")) {
                    // If SMSC is in this format: ""+123456789123",123", after performing above
                    // split we get string with double-quotation marks in it
                    // dialStrParts[0] = ""+123456789123"".
                    // Here, we remove double-quotation marks from the string.
                    dialStrParts[0] = dialStrParts[0].replaceAll("\"", "");
                }
                return dialStrParts[0];
            }
        } catch (PatternSyntaxException ex) {
            Rlog.w(LOG_TAG, "extractSMSC: Could not extract number from dialStr " + ex);
        }

        // Return original dialStr if it is not in any of the formats mentions above.
        return dialStr;
    }
}
}
 No newline at end of file
+18 −0
Original line number Original line Diff line number Diff line
@@ -163,4 +163,22 @@ public class FdnUtilsTest {


        assertFalse(FdnUtils.isFDN("6502910000", "", fdnList));
        assertFalse(FdnUtils.isFDN("6502910000", "", fdnList));
    }
    }

    @Test
    public void smscAddrInTwoStringsFormat_returnsTrue() {
        ArrayList<AdnRecord> fdnList = initializeFdnList();
        AdnRecord adnRecord = new AdnRecord(null, "1234560000");
        fdnList.add(7, adnRecord);

        assertTrue(FdnUtils.isFDN("\"1234560000\",124", "US", fdnList));
    }

    @Test
    public void smscAddrInEmailIdFormat_returnsTrue() {
        ArrayList<AdnRecord> fdnList = initializeFdnList();
        AdnRecord adnRecord = new AdnRecord(null, "1234560000");
        fdnList.add(8, adnRecord);

        assertTrue(FdnUtils.isFDN("1234560000@ims.mnc.org", "US", fdnList));
    }
}
}
 No newline at end of file