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

Commit aa7cf220 authored by Shiva Kishore Tekale's avatar Shiva Kishore Tekale Committed by Jack Yu
Browse files

Telephony: Use data and voice states for SPN

SPN display text is based on both voice service state
and data service state.
Eg - Voice service state is OOS and data service state
is IN_SERVICE. In such cases, both regStates need to be
considered to determine what to show in UI for SPN.
Fix the wrong CDMA carrier text in expanded status bar.
After updating operator, the expanded status bar will
update SPN
For GSM, SPN is "no service" if service is out of service.
For CDMA, SPN is CDMA carrier. Check current service
state whether out of service, if yes, display "no service"
instead of SPN.

bug: 22640459
Test: manual
Change-Id: Ic46ac0c7e3af51a380bb2db5d71a71bf9595c2ec
parent 0f6e1a01
Loading
Loading
Loading
Loading
+27 −4
Original line number Diff line number Diff line
@@ -2144,6 +2144,7 @@ public class ServiceStateTracker extends Handler {
            wfcDataSpnFormat = wfcSpnFormats[dataIdx];
        }

        int combinedRegState = getCombinedRegState();
        if (mPhone.isPhoneTypeGsm()) {
            // The values of plmn/showPlmn change in different scenarios.
            // 1) No service but emergency call allowed -> expected
@@ -2167,8 +2168,8 @@ public class ServiceStateTracker extends Handler {
            String plmn = null;
            boolean showPlmn = false;
            int rule = (iccRecords != null) ? iccRecords.getDisplayRule(mSS.getOperatorNumeric()) : 0;
            if (mSS.getVoiceRegState() == ServiceState.STATE_OUT_OF_SERVICE
                    || mSS.getVoiceRegState() == ServiceState.STATE_EMERGENCY_ONLY) {
            if (combinedRegState == ServiceState.STATE_OUT_OF_SERVICE
                    || combinedRegState == ServiceState.STATE_EMERGENCY_ONLY) {
                showPlmn = true;
                if (mEmergencyOnly) {
                    // No service but emergency call allowed
@@ -2181,7 +2182,7 @@ public class ServiceStateTracker extends Handler {
                }
                if (DBG) log("updateSpnDisplay: radio is on but out " +
                        "of service, set plmn='" + plmn + "'");
            } else if (mSS.getVoiceRegState() == ServiceState.STATE_IN_SERVICE) {
            } else if (combinedRegState == ServiceState.STATE_IN_SERVICE) {
                // In either home or roaming service
                plmn = mSS.getOperatorAlpha();
                showPlmn = !TextUtils.isEmpty(plmn) &&
@@ -2288,6 +2289,14 @@ public class ServiceStateTracker extends Handler {
                plmn = null;
            }

            if (combinedRegState == ServiceState.STATE_OUT_OF_SERVICE) {
                plmn = Resources.getSystem().getText(com.android.internal.R.string
                        .lockscreen_carrier_default).toString();
                if (DBG) {
                    log("updateSpnDisplay: radio is on but out of svc, set plmn='" + plmn + "'");
                }
            }

            if (mSubId != subId || !TextUtils.equals(plmn, mCurPlmn)) {
                // Allow A blank plmn, "" to set showPlmn to true. Previously, we
                // would set showPlmn to true only if plmn was not empty, i.e. was not
@@ -3312,7 +3321,7 @@ public class ServiceStateTracker extends Handler {
            }

            if (mUiccApplcation != null && mUiccApplcation.getState() == AppState.APPSTATE_READY &&
                    mIccRecords != null && (mSS.getVoiceRegState() == ServiceState.STATE_IN_SERVICE)
                    mIccRecords != null && getCombinedRegState() == ServiceState.STATE_IN_SERVICE
                    && !ServiceState.isLte(mSS.getRilVoiceRadioTechnology())) {
                // SIM is found on the device. If ERI roaming is OFF, and SID/NID matches
                // one configured in SIM, use operator name from CSIM record. Note that ERI, SID,
@@ -5013,4 +5022,18 @@ public class ServiceStateTracker extends Handler {
    public boolean isDeviceShuttingDown() {
        return mDeviceShuttingDown;
    }

    /**
     * Consider dataRegState if voiceRegState is OOS to determine SPN to be displayed
     */
    protected int getCombinedRegState() {
        int regState = mSS.getVoiceRegState();
        int dataRegState = mSS.getDataRegState();
        if ((regState == ServiceState.STATE_OUT_OF_SERVICE)
                && (dataRegState == ServiceState.STATE_IN_SERVICE)) {
            log("getCombinedRegState: return STATE_IN_SERVICE as Data is in service");
            regState = dataRegState;
        }
        return regState;
    }
}