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

Commit 3fe6c7f5 authored by Sandeep Gutta's avatar Sandeep Gutta Committed by Sooraj Sasindran
Browse files

MSIM: Fix to update display name in subinfo record

Currently display name in subinfo record is updated from
SubscriptionInfoUpdater.java when SIM state moves to LOADED.

For the SIM cards which does not have valid EF_SPN sim file,
by the time SIM state moves to loaded, setSpnFromConfig()
not getting called and due to that default display string
of "CARD 1/2" updated in subinfo record.

To fix update valid spn name from config, call setDisplayName() once again
after SPN name updated by SIMRecords.

Bug: 36497632
Test: manual - tested with SIM does not have EF_SPN
Change-Id: I27a9b34dc35e70c49872622f000ade6764c07c11
parent ee2b0302
Loading
Loading
Loading
Loading
+29 −0
Original line number Diff line number Diff line
@@ -28,11 +28,13 @@ import android.telephony.PhoneNumberUtils;
import android.telephony.Rlog;
import android.telephony.SmsMessage;
import android.telephony.SubscriptionInfo;
import android.telephony.SubscriptionManager;
import android.text.TextUtils;

import com.android.internal.telephony.CommandsInterface;
import com.android.internal.telephony.MccTable;
import com.android.internal.telephony.SmsConstants;
import com.android.internal.telephony.SubscriptionController;
import com.android.internal.telephony.gsm.SimTlv;
import com.android.internal.telephony.uicc.IccCardApplicationStatus.AppState;
import com.android.internal.telephony.uicc.IccCardApplicationStatus.AppType;
@@ -1645,6 +1647,33 @@ public class SIMRecords extends IccRecords {
        } else {
            setSpnFromConfig(getOperatorNumeric());
        }

        /* update display name with carrier override */
        setDisplayName();
    }

    private void setDisplayName() {
        SubscriptionManager subManager = SubscriptionManager.from(mContext);
        int[] subId = subManager.getSubId(mParentApp.getPhoneId());

        if ((subId == null) || subId.length <= 0) {
            log("subId not valid for Phone " + mParentApp.getPhoneId());
            return;
        }

        SubscriptionInfo subInfo = subManager.getActiveSubscriptionInfo(subId[0]);
        if (subInfo != null && subInfo.getNameSource()
                    != SubscriptionManager.NAME_SOURCE_USER_INPUT) {
            CharSequence oldSubName = subInfo.getDisplayName();
            String newCarrierName = mTelephonyManager.getSimOperatorName(subId[0]);

            if (!TextUtils.isEmpty(newCarrierName) && !newCarrierName.equals(oldSubName)) {
                log("sim name[" + mParentApp.getPhoneId() + "] = " + newCarrierName);
                SubscriptionController.getInstance().setDisplayName(newCarrierName, subId[0]);
            }
        } else {
            log("SUB[" + mParentApp.getPhoneId() + "] " + subId[0] + " SubInfo not created yet");
        }
    }

    private void setSpnFromConfig(String carrier) {