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

Commit ee2dc27f authored by Jack Yu's avatar Jack Yu Committed by android-build-merger
Browse files

When SPN is empty, use PNN in mobile network settings

am: e96f0b74

Change-Id: Id15bfdc16a3fb21e9095af7a771d9a2c4fd6eae5
parents 82bfffab e96f0b74
Loading
Loading
Loading
Loading
+14 −15
Original line number Diff line number Diff line
@@ -46,6 +46,7 @@ import android.telephony.RadioAccessFamily;
import android.telephony.Rlog;
import android.telephony.SubscriptionInfo;
import android.telephony.SubscriptionManager;
import android.telephony.SubscriptionManager.SimDisplayNameSource;
import android.telephony.TelephonyManager;
import android.telephony.UiccAccessRule;
import android.telephony.UiccSlotInfo;
@@ -1505,30 +1506,28 @@ public class SubscriptionController extends ISub.Stub {
     * @param nameSource Source of display name
     * @return int representing the priority. Higher value means higher priority.
     */
    public static int getNameSourcePriority(int nameSource) {
        switch (nameSource) {
            case SubscriptionManager.NAME_SOURCE_USER_INPUT:
                return 3;
            case SubscriptionManager.NAME_SOURCE_CARRIER:
                return 2;
            case SubscriptionManager.NAME_SOURCE_SIM_SOURCE:
                return 1;
            case SubscriptionManager.NAME_SOURCE_DEFAULT_SOURCE:
            default:
                return 0;
        }
    public static int getNameSourcePriority(@SimDisplayNameSource int nameSource) {
        int index = Arrays.binarySearch(
                new int[] {
                        SubscriptionManager.NAME_SOURCE_DEFAULT_SOURCE,
                        SubscriptionManager.NAME_SOURCE_SIM_PNN,
                        SubscriptionManager.NAME_SOURCE_SIM_SPN,
                        SubscriptionManager.NAME_SOURCE_CARRIER,
                        SubscriptionManager.NAME_SOURCE_USER_INPUT // user has highest priority.
                }, nameSource);
        return (index < 0) ? 0 : index;
    }

    /**
     * Set display name by simInfo index with name source
     * @param displayName the display name of SIM card
     * @param subId the unique SubInfoRecord index in database
     * @param nameSource 0: NAME_SOURCE_DEFAULT_SOURCE, 1: NAME_SOURCE_SIM_SOURCE,
     *                   2: NAME_SOURCE_USER_INPUT, 3: NAME_SOURCE_CARRIER
     * @param nameSource SIM display name source
     * @return the number of records updated
     */
    @Override
    public int setDisplayNameUsingSrc(String displayName, int subId, int nameSource) {
    public int setDisplayNameUsingSrc(String displayName, int subId,
                                      @SimDisplayNameSource int nameSource) {
        if (DBG) {
            logd("[setDisplayName]+  displayName:" + displayName + " subId:" + subId
                + " nameSource:" + nameSource);
+12 −4
Original line number Diff line number Diff line
@@ -372,8 +372,8 @@ public class UiccProfile extends IccCard {
        String ccName = config.getString(CarrierConfigManager.KEY_CARRIER_NAME_STRING);

        String newCarrierName = null;
        String currSpn = getServiceProviderName();
        int nameSource = SubscriptionManager.NAME_SOURCE_SIM_SOURCE;
        String currSpn = getServiceProviderName();  // Get the name from EF_SPN.
        int nameSource = SubscriptionManager.NAME_SOURCE_SIM_SPN;
        // If carrier config is priority, use it regardless - the preference
        // and the name were both set by the carrier, so this is safe;
        // otherwise, if the SPN is priority but we don't have one *and* we have
@@ -382,10 +382,18 @@ public class UiccProfile extends IccCard {
            newCarrierName = ccName;
            nameSource = SubscriptionManager.NAME_SOURCE_CARRIER;
        } else if (TextUtils.isEmpty(currSpn)) {
            // currSpn is empty and could not get name from carrier config; get name from carrier id
            // currSpn is empty and could not get name from carrier config; get name from PNN or
            // carrier id
            Phone phone = PhoneFactory.getPhone(mPhoneId);
            if (phone != null) {
                newCarrierName = phone.getCarrierName();
                String currPnn = phone.getPlmn();   // Get the name from EF_PNN.
                if (!TextUtils.isEmpty(currPnn)) {
                    newCarrierName = currPnn;
                    nameSource = SubscriptionManager.NAME_SOURCE_SIM_PNN;
                } else {
                    newCarrierName = phone.getCarrierName();    // Get the name from carrier id.
                    nameSource = SubscriptionManager.NAME_SOURCE_DEFAULT_SOURCE;
                }
            }
        }

+3 −3
Original line number Diff line number Diff line
@@ -202,7 +202,7 @@ public class SubscriptionControllerTest extends TelephonyTest {

        /* Setting */
        String disName = "TESTING";
        int nameSource = SubscriptionManager.NAME_SOURCE_SIM_SOURCE;
        int nameSource = SubscriptionManager.NAME_SOURCE_SIM_SPN;
        mSubscriptionControllerUT.setDisplayNameUsingSrc(disName, subID, nameSource);
        SubscriptionInfo subInfo = mSubscriptionControllerUT
                .getActiveSubscriptionInfo(subID, mCallingPackage);
@@ -465,12 +465,12 @@ public class SubscriptionControllerTest extends TelephonyTest {

        // Changing non-opportunistic sub1 shouldn't trigger callback.
        mSubscriptionControllerUT.setDisplayNameUsingSrc("DisplayName", 1,
                SubscriptionManager.NAME_SOURCE_SIM_SOURCE);
                SubscriptionManager.NAME_SOURCE_SIM_SPN);
        verify(mTelephonyRegisteryMock, times(1))
                .notifyOpportunisticSubscriptionInfoChanged();

        mSubscriptionControllerUT.setDisplayNameUsingSrc("DisplayName", 2,
                SubscriptionManager.NAME_SOURCE_SIM_SOURCE);
                SubscriptionManager.NAME_SOURCE_SIM_SPN);
        verify(mTelephonyRegisteryMock, times(2))
                .notifyOpportunisticSubscriptionInfoChanged();
    }