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

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

Merge "Telephony: Use data and voice states for SPN"

am: c6d06861

Change-Id: I857eb99f10a4b24372c058d1174719d6e8600559
parents 6cf3ac82 c6d06861
Loading
Loading
Loading
Loading
+27 −4
Original line number Diff line number Diff line
@@ -2162,6 +2162,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
@@ -2185,8 +2186,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
@@ -2199,7 +2200,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) &&
@@ -2306,6 +2307,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
@@ -3352,7 +3361,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,
@@ -5078,4 +5087,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;
    }
}