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

Commit 9063850a authored by Ladios Jonquil's avatar Ladios Jonquil
Browse files

gsm/statusbar: Correct CarrierLabel display logic

What's wrong:

* "(No service)|SPN" is shown on lockscreen/statusbar.
* The "(No service)" string won't update on locale change.

What's changed:

statusbar:

* As per lockscreen, the "(No service)" string should be shown only when
  showPlmn is true, and plmn is null.

gsm:

* Run updateSpnDisplay() when ServiceState has not changed (equals() is
  true), but has deregistered (getState() values are different).

* When plmn is null (no service):
 - Set the display rule to show plmn only.
 - Allow updateSpnDisplay() to send the intent on locale change.

Change-Id: Ieab5c93a560c7fbe6a69e2db151d840a30fdbeb4
parent 47c83a2e
Loading
Loading
Loading
Loading
+10 −21
Original line number Diff line number Diff line
@@ -23,18 +23,13 @@ import android.content.IntentFilter;
import android.provider.Telephony;
import android.util.AttributeSet;
import android.util.Slog;
import android.view.View;
import android.widget.TextView;

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.TimeZone;

import com.android.internal.R;

/**
 * This widget display an analogic clock with two hands for hours and
 * minutes.
 * This widget display the current network status or registered PLMN, and/or
 * SPN if available.
 */
public class CarrierLabel extends TextView {
    private boolean mAttached;
@@ -92,26 +87,20 @@ public class CarrierLabel extends TextView {
                    + " showPlmn=" + showPlmn + " plmn=" + plmn);
        }
        StringBuilder str = new StringBuilder();
        boolean something = false;
        if (showPlmn && plmn != null) {
        if (showPlmn) {
            if (plmn != null) {
                str.append(plmn);
            something = true;
            } else {
                str.append(mContext.getText(R.string.lockscreen_carrier_default));
            }
        }
        if (showSpn && spn != null) {
            if (something) {
            if (showPlmn) {
                str.append('\n');
            }
            str.append(spn);
            something = true;
        }
        if (something) {
        setText(str.toString());
        } else {
            setText(com.android.internal.R.string.lockscreen_carrier_default);
    }
    }


}

+4 −0
Original line number Diff line number Diff line
@@ -593,6 +593,7 @@ final class GsmServiceStateTracker extends ServiceStateTracker {
        }

        if (rule != curSpnRule
                || plmn == null
                || !TextUtils.equals(spn, curSpn)
                || !TextUtils.equals(plmn, curPlmn)) {
            boolean showSpn = !mEmergencyOnly
@@ -1016,6 +1017,9 @@ final class GsmServiceStateTracker extends ServiceStateTracker {
                ss.getRoaming() ? "true" : "false");

            phone.notifyServiceStateChanged(ss);

        } else if (hasDeregistered) {
            updateSpnDisplay();
        }

        if (hasGprsAttached) {
+10 −4
Original line number Diff line number Diff line
@@ -1352,19 +1352,25 @@ public final class SIMRecords extends IccRecords {
     */
    protected int getDisplayRule(String plmn) {
        int rule;
        if (spn == null || spnDisplayCondition == -1) {
            // EF_SPN was not found on the SIM, or not yet loaded.  Just show ONS.
        if (spn == null || spnDisplayCondition == -1 || plmn == null) {
            // EF_SPN was not found on the SIM, or not yet loaded, or
            // currently not registered to any PLMN. Just show ONS or
            // the "(No service)" string.
            rule = SPN_RULE_SHOW_PLMN;
        } else if (isOnMatchingPlmn(plmn)) {
            // registered PLMN is either HPLMN or a PLMN in the EF_SPDI list.
            rule = SPN_RULE_SHOW_SPN;
            if ((spnDisplayCondition & 0x01) == 0x01) {
                // ONS required when registered to HPLMN or PLMN in EF_SPDI
                // b1=0: ONS is not required
                // b1=1: ONS is required
                rule |= SPN_RULE_SHOW_PLMN;
            }
        } else {
            // registered PLMN is neither HPLMN nor a PLMN in the EF_SPDI list.
            rule = SPN_RULE_SHOW_PLMN;
            if ((spnDisplayCondition & 0x02) == 0x00) {
                // SPN required if not registered to HPLMN or PLMN in EF_SPDI
                // b2=0: SPN is required
                // b2=1: SPN is not required
                rule |= SPN_RULE_SHOW_SPN;
            }
        }