diff options
author | Erica Chang <echang@cyngn.com> | 2015-04-09 12:37:20 -0700 |
---|---|---|
committer | Erica Chang <echang@cyngn.com> | 2015-04-27 22:31:09 +0000 |
commit | b9bf02b3d651a248b8cd692ce921e78c1bee452b (patch) | |
tree | 56f629191b5677030829a45c926d464958cccc58 | |
parent | d61a1880e506cb7b97864a75c9f906298f9c8902 (diff) | |
download | android_frameworks_opt_telephony-stable/cm-12.1-YOG3C.tar.gz android_frameworks_opt_telephony-stable/cm-12.1-YOG3C.tar.bz2 android_frameworks_opt_telephony-stable/cm-12.1-YOG3C.zip |
Telephony: add CDMA SPN display rulestable/cm-12.1-YOG3C
Change-Id: Ie7c271441f6f7dfaf85f506735c8fd33c88732a4
(cherry picked from commit 92181e5046744bc5afcecad23374a704552005fb)
-rw-r--r-- | src/java/com/android/internal/telephony/cdma/CdmaServiceStateTracker.java | 48 | ||||
-rw-r--r-- | src/java/com/android/internal/telephony/uicc/RuimRecords.java | 48 |
2 files changed, 81 insertions, 15 deletions
diff --git a/src/java/com/android/internal/telephony/cdma/CdmaServiceStateTracker.java b/src/java/com/android/internal/telephony/cdma/CdmaServiceStateTracker.java index dcc5a0145..080a0a9c9 100644 --- a/src/java/com/android/internal/telephony/cdma/CdmaServiceStateTracker.java +++ b/src/java/com/android/internal/telephony/cdma/CdmaServiceStateTracker.java @@ -132,6 +132,9 @@ public class CdmaServiceStateTracker extends ServiceStateTracker { /** Contains the name of the registered network in CDMA (either ONS or ERI text). */ protected String mCurPlmn = null; + protected String mCurSpn = null; + protected boolean mCurShowPlmn = false; + protected boolean mCurShowSpn = false; protected String mMdn; protected int mHomeSystemId[] = null; @@ -593,36 +596,58 @@ public class CdmaServiceStateTracker extends ServiceStateTracker { @Override protected void updateSpnDisplay() { // mOperatorAlphaLong contains the ERI text - String plmn = mSS.getOperatorAlphaLong(); + String plmn = null; + String spn = null; + boolean showPlmn = false; + boolean showSpn = false; + int rule = 0; + int combinedRegState; + + rule = (mIccRecords != null) ? mIccRecords.getDisplayRule(mSS.getOperatorNumeric()) : 0; + combinedRegState = getCombinedRegState(); - int combinedRegState = getCombinedRegState(); if (combinedRegState == ServiceState.STATE_OUT_OF_SERVICE) { + // display out of service + showPlmn = true; plmn = Resources.getSystem().getText(com.android.internal. R.string.lockscreen_carrier_default).toString(); if (DBG) log("updateSpnDisplay: radio is on but out " + "of service, set plmn='" + plmn + "'"); + } else if (combinedRegState == ServiceState.STATE_IN_SERVICE) { + // depends on the rule and whether plmn or spn is null + plmn = mSS.getOperatorAlphaLong(); + showPlmn = ( !TextUtils.isEmpty(plmn)) && + ((rule & RuimRecords.SPN_RULE_SHOW_PLMN) == RuimRecords.SPN_RULE_SHOW_PLMN); + spn = (mIccRecords != null) ? mIccRecords.getServiceProviderName() : ""; + showSpn = (!TextUtils.isEmpty(spn)) && + ((rule & RuimRecords.SPN_RULE_SHOW_SPN) == RuimRecords.SPN_RULE_SHOW_SPN); + } else { + // power off state (airplane mode), show nothing } - if (!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 - // null and not blank. But this would cause us to incorrectly display - // "No Service". Now showPlmn is set to true for any non null string. - boolean showPlmn = plmn != null; + // Update if any value changes + if (showPlmn != mCurShowPlmn + || showSpn != mCurShowSpn + || !TextUtils.equals(spn, mCurSpn) + || !TextUtils.equals(plmn, mCurPlmn)) { + if (DBG) { log(String.format("updateSpnDisplay: changed sending intent" + " showPlmn='%b' plmn='%s'", showPlmn, plmn)); } Intent intent = new Intent(TelephonyIntents.SPN_STRINGS_UPDATED_ACTION); intent.addFlags(Intent.FLAG_RECEIVER_REPLACE_PENDING); - intent.putExtra(TelephonyIntents.EXTRA_SHOW_SPN, false); - intent.putExtra(TelephonyIntents.EXTRA_SPN, ""); + intent.putExtra(TelephonyIntents.EXTRA_SHOW_SPN, showSpn); + intent.putExtra(TelephonyIntents.EXTRA_SPN, spn); intent.putExtra(TelephonyIntents.EXTRA_SHOW_PLMN, showPlmn); intent.putExtra(TelephonyIntents.EXTRA_PLMN, plmn); SubscriptionManager.putPhoneIdAndSubIdExtra(intent, mPhone.getPhoneId()); mPhone.getContext().sendStickyBroadcastAsUser(intent, UserHandle.ALL); } + mCurShowSpn = showSpn; + mCurShowPlmn = showPlmn; + mCurSpn = spn; mCurPlmn = plmn; } @@ -2111,6 +2136,9 @@ public class CdmaServiceStateTracker extends ServiceStateTracker { pw.println(" mSavedAtTime=" + mSavedAtTime); pw.println(" mWakeLock=" + mWakeLock); pw.println(" mCurPlmn=" + mCurPlmn); + pw.println(" mCurShowPmn=" + mCurShowPlmn); + pw.println(" mCurSpn=" + mCurSpn); + pw.println(" mCurShowSpn=" + mCurShowSpn); pw.println(" mMdn=" + mMdn); pw.println(" mHomeSystemId=" + mHomeSystemId); pw.println(" mHomeNetworkId=" + mHomeNetworkId); diff --git a/src/java/com/android/internal/telephony/uicc/RuimRecords.java b/src/java/com/android/internal/telephony/uicc/RuimRecords.java index b7edcec2d..9234d84c0 100644 --- a/src/java/com/android/internal/telephony/uicc/RuimRecords.java +++ b/src/java/com/android/internal/telephony/uicc/RuimRecords.java @@ -1174,13 +1174,51 @@ public final class RuimRecords extends IccRecords { /** * {@inheritDoc} - * - * No Display rule for RUIMs yet. */ @Override - public int getDisplayRule(String plmn) { - // TODO together with spn - return 0; + public int getDisplayRule(String plmnNumeric) { + int rule = 0; + + if ((mContext != null) && mContext.getResources().getBoolean( + com.android.internal.R.bool.def_telephony_spn_spec_enabled)) { + // Always display the SPN only from RUIM + rule = SPN_RULE_SHOW_SPN; + } else if (mParentApp != null && mParentApp.getUiccCard() != null && + mParentApp.getUiccCard().getOperatorBrandOverride() != null) { + // use operator brand override + rule = SPN_RULE_SHOW_PLMN; + } else if (TextUtils.isEmpty(getServiceProviderName())) { + // EF_SPN content not found on this RUIM, or not yet loaded + rule = SPN_RULE_SHOW_PLMN; + } else if (isOnMatchingPlmn(plmnNumeric)) { + // on home network + if (mCsimSpnDisplayCondition && !TextUtils.isEmpty(getServiceProviderName())) { + // check CSIM SPN Display Condition (applicable on home network), + // but only if SPN was found on this RUIM + rule = SPN_RULE_SHOW_SPN; + } else { + // CSIM SPN Display does not require a SPN display, or SPN not found on RUIM, + // then revert to currently registered network + rule = SPN_RULE_SHOW_PLMN; + } + } else { + // roaming, use the currently registered network + rule = SPN_RULE_SHOW_PLMN; + } + + return rule; + } + + /** + * Checks if currently registered PLMN is home PLMN + * (PLMN numeric matches the one reported in CSIM) + */ + private boolean isOnMatchingPlmn(String plmnNumeric) { + if (plmnNumeric == null) return false; + if (plmnNumeric.equals(getOperatorNumeric())) { + return true; + } + return false; } @Override |