summaryrefslogtreecommitdiffstats
path: root/packages/Keyguard/src/com
diff options
context:
space:
mode:
authorJason Monk <jmonk@google.com>2014-12-02 16:43:17 -0500
committerJason Monk <jmonk@google.com>2014-12-04 17:29:12 -0500
commit9ff69bd8f115e70a16c72c798449908536a173ea (patch)
tree9a9c6fa10e4c9ac142c9409a9c1268460947144c /packages/Keyguard/src/com
parent1fb699360d1b193c5144c7dcf209d8dc8dfbb8b8 (diff)
downloadframeworks_base-9ff69bd8f115e70a16c72c798449908536a173ea.zip
frameworks_base-9ff69bd8f115e70a16c72c798449908536a173ea.tar.gz
frameworks_base-9ff69bd8f115e70a16c72c798449908536a173ea.tar.bz2
Make CarrierText handle multi-sim
To do this need to handle the subscription id that comes with all spn broadcasts and concatenate properly as needed. Bug: 18223317 Change-Id: I2a1cde0a4bf2f50082288cc5cdeb968fa9aa7dd0
Diffstat (limited to 'packages/Keyguard/src/com')
-rw-r--r--packages/Keyguard/src/com/android/keyguard/CarrierText.java106
-rw-r--r--packages/Keyguard/src/com/android/keyguard/KeyguardMessageArea.java3
-rw-r--r--packages/Keyguard/src/com/android/keyguard/KeyguardUpdateMonitor.java66
-rw-r--r--packages/Keyguard/src/com/android/keyguard/KeyguardUpdateMonitorCallback.java6
4 files changed, 72 insertions, 109 deletions
diff --git a/packages/Keyguard/src/com/android/keyguard/CarrierText.java b/packages/Keyguard/src/com/android/keyguard/CarrierText.java
index 55bfe49..7f4ce59 100644
--- a/packages/Keyguard/src/com/android/keyguard/CarrierText.java
+++ b/packages/Keyguard/src/com/android/keyguard/CarrierText.java
@@ -16,11 +16,17 @@
package com.android.keyguard;
+import java.util.List;
+import java.util.Locale;
+
import android.content.Context;
import android.content.res.TypedArray;
-import android.text.method.SingleLineTransformationMethod;
+import android.telephony.SubscriptionInfo;
+import android.telephony.SubscriptionManager;
import android.text.TextUtils;
+import android.text.method.SingleLineTransformationMethod;
import android.util.AttributeSet;
+import android.util.Log;
import android.view.View;
import android.widget.TextView;
@@ -28,29 +34,19 @@ import com.android.internal.telephony.IccCardConstants;
import com.android.internal.telephony.IccCardConstants.State;
import com.android.internal.widget.LockPatternUtils;
-import java.util.Locale;
-
public class CarrierText extends TextView {
+ private static final boolean DEBUG = KeyguardConstants.DEBUG;
+ private static final String TAG = "CarrierText";
+
private static CharSequence mSeparator;
private LockPatternUtils mLockPatternUtils;
+ private KeyguardUpdateMonitor mKeyguardUpdateMonitor;
private KeyguardUpdateMonitorCallback mCallback = new KeyguardUpdateMonitorCallback() {
- private CharSequence mPlmn;
- private CharSequence mSpn;
- private State mSimState;
-
- @Override
- public void onRefreshCarrierInfo(CharSequence plmn, CharSequence spn) {
- mPlmn = plmn;
- mSpn = spn;
- updateCarrierText(mSimState, mPlmn, mSpn);
- }
-
@Override
- public void onSimStateChanged(int subId, int slotId, State simState) {
- mSimState = simState;
- updateCarrierText(mSimState, mPlmn, mSpn);
+ public void onRefreshCarrierInfo() {
+ updateCarrierText();
}
public void onScreenTurnedOff(int why) {
@@ -93,14 +89,50 @@ public class CarrierText extends TextView {
setTransformationMethod(new CarrierTextTransformationMethod(mContext, useAllCaps));
}
- protected void updateCarrierText(State simState, CharSequence plmn, CharSequence spn) {
- setText(getCarrierTextForSimState(simState, plmn, spn));
+ protected void updateCarrierText() {
+ boolean allSimsMissing = true;
+ CharSequence displayText = null;
+
+ List<SubscriptionInfo> subs = mKeyguardUpdateMonitor.getSubscriptionInfo(false);
+ final int N = subs.size();
+ if (DEBUG) Log.d(TAG, "updateCarrierText(): " + N);
+ for (int i = 0; i < N; i++) {
+ State simState = mKeyguardUpdateMonitor.getSimState(subs.get(i).getSubscriptionId());
+ CharSequence carrierName = subs.get(i).getCarrierName();
+ CharSequence carrierTextForSimState = getCarrierTextForSimState(simState, carrierName);
+ if (DEBUG) Log.d(TAG, "Handling " + simState + " " + carrierName);
+ if (carrierTextForSimState != null) {
+ allSimsMissing = false;
+ displayText = concatenate(displayText, carrierTextForSimState);
+ }
+ }
+ if (allSimsMissing) {
+ if (N != 0) {
+ // Shows "No SIM card | Emergency calls only" on devices that are voice-capable.
+ // This depends on mPlmn containing the text "Emergency calls only" when the radio
+ // has some connectivity. Otherwise, it should be null or empty and just show
+ // "No SIM card"
+ // Grab the first subscripton, because they all should contain the emergency text,
+ // described above.
+ displayText = makeCarrierStringOnEmergencyCapable(
+ getContext().getText(R.string.keyguard_missing_sim_message_short),
+ subs.get(0).getCarrierName());
+ } else {
+ // We don't have a SubscriptionInfo to get the emergency calls only from.
+ // Lets just make it ourselves.
+ displayText = makeCarrierStringOnEmergencyCapable(
+ getContext().getText(R.string.keyguard_missing_sim_message_short),
+ getContext().getText(com.android.internal.R.string.emergency_calls_only));
+ }
+ }
+ setText(displayText);
}
@Override
protected void onFinishInflate() {
super.onFinishInflate();
- mSeparator = getResources().getString(R.string.kg_text_message_separator);
+ mSeparator = getResources().getString(
+ com.android.internal.R.string.kg_text_message_separator);
final boolean screenOn = KeyguardUpdateMonitor.getInstance(mContext).isScreenOn();
setSelected(screenOn); // Allow marquee to work.
}
@@ -108,13 +140,14 @@ public class CarrierText extends TextView {
@Override
protected void onAttachedToWindow() {
super.onAttachedToWindow();
- KeyguardUpdateMonitor.getInstance(mContext).registerCallback(mCallback);
+ mKeyguardUpdateMonitor = KeyguardUpdateMonitor.getInstance(mContext);
+ mKeyguardUpdateMonitor.registerCallback(mCallback);
}
@Override
protected void onDetachedFromWindow() {
super.onDetachedFromWindow();
- KeyguardUpdateMonitor.getInstance(mContext).removeCallback(mCallback);
+ mKeyguardUpdateMonitor.removeCallback(mCallback);
}
/**
@@ -122,36 +155,31 @@ public class CarrierText extends TextView {
* and SPN as well as device capabilities, such as being emergency call capable.
*
* @param simState
- * @param plmn
+ * @param text
* @param spn
- * @return
+ * @return Carrier text if not in missing state, null otherwise.
*/
private CharSequence getCarrierTextForSimState(IccCardConstants.State simState,
- CharSequence plmn, CharSequence spn) {
+ CharSequence text) {
CharSequence carrierText = null;
StatusMode status = getStatusForIccState(simState);
switch (status) {
case Normal:
- carrierText = concatenate(plmn, spn);
+ carrierText = text;
break;
case SimNotReady:
- carrierText = null; // nothing to display yet.
+ // Null is reserved for denoting missing, in this case we have nothing to display.
+ carrierText = ""; // nothing to display yet.
break;
case NetworkLocked:
carrierText = makeCarrierStringOnEmergencyCapable(
- mContext.getText(R.string.keyguard_network_locked_message), plmn);
+ mContext.getText(R.string.keyguard_network_locked_message), text);
break;
case SimMissing:
- // Shows "No SIM card | Emergency calls only" on devices that are voice-capable.
- // This depends on mPlmn containing the text "Emergency calls only" when the radio
- // has some connectivity. Otherwise, it should be null or empty and just show
- // "No SIM card"
- carrierText = makeCarrierStringOnEmergencyCapable(
- getContext().getText(R.string.keyguard_missing_sim_message_short),
- plmn);
+ carrierText = null;
break;
case SimPermDisabled:
@@ -160,21 +188,19 @@ public class CarrierText extends TextView {
break;
case SimMissingLocked:
- carrierText = makeCarrierStringOnEmergencyCapable(
- getContext().getText(R.string.keyguard_missing_sim_message_short),
- plmn);
+ carrierText = null;
break;
case SimLocked:
carrierText = makeCarrierStringOnEmergencyCapable(
getContext().getText(R.string.keyguard_sim_locked_message),
- plmn);
+ text);
break;
case SimPukLocked:
carrierText = makeCarrierStringOnEmergencyCapable(
getContext().getText(R.string.keyguard_sim_puk_locked_message),
- plmn);
+ text);
break;
}
diff --git a/packages/Keyguard/src/com/android/keyguard/KeyguardMessageArea.java b/packages/Keyguard/src/com/android/keyguard/KeyguardMessageArea.java
index 9bc2a4d..236cbf6 100644
--- a/packages/Keyguard/src/com/android/keyguard/KeyguardMessageArea.java
+++ b/packages/Keyguard/src/com/android/keyguard/KeyguardMessageArea.java
@@ -153,7 +153,8 @@ class KeyguardMessageArea extends TextView {
mUpdateMonitor.registerCallback(mInfoCallback);
mHandler = new Handler(Looper.myLooper());
- mSeparator = getResources().getString(R.string.kg_text_message_separator);
+ mSeparator = getResources().getString(
+ com.android.internal.R.string.kg_text_message_separator);
update();
}
diff --git a/packages/Keyguard/src/com/android/keyguard/KeyguardUpdateMonitor.java b/packages/Keyguard/src/com/android/keyguard/KeyguardUpdateMonitor.java
index ff07dd7..8458ae0 100644
--- a/packages/Keyguard/src/com/android/keyguard/KeyguardUpdateMonitor.java
+++ b/packages/Keyguard/src/com/android/keyguard/KeyguardUpdateMonitor.java
@@ -97,7 +97,6 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener {
// Callback messages
private static final int MSG_TIME_UPDATE = 301;
private static final int MSG_BATTERY_UPDATE = 302;
- private static final int MSG_CARRIER_INFO_UPDATE = 303;
private static final int MSG_SIM_STATE_CHANGE = 304;
private static final int MSG_RINGER_MODE_CHANGED = 305;
private static final int MSG_PHONE_STATE_CHANGED = 306;
@@ -126,8 +125,6 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener {
private final Context mContext;
HashMap<Integer, SimData> mSimDatas = new HashMap<Integer, SimData>();
- private CharSequence mTelephonyPlmn;
- private CharSequence mTelephonySpn;
private int mRingMode;
private int mPhoneState;
private boolean mKeyguardIsVisible;
@@ -168,9 +165,6 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener {
case MSG_BATTERY_UPDATE:
handleBatteryUpdate((BatteryStatus) msg.obj);
break;
- case MSG_CARRIER_INFO_UPDATE:
- handleCarrierInfoUpdate();
- break;
case MSG_SIM_STATE_CHANGE:
handleSimStateChange(msg.arg1, msg.arg2, (State) msg.obj);
break;
@@ -290,6 +284,7 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener {
KeyguardUpdateMonitorCallback cb = mCallbacks.get(j).get();
if (cb != null) {
cb.onSimStateChanged(data.subId, data.slotId, data.simState);
+ cb.onRefreshCarrierInfo();
}
}
}
@@ -435,10 +430,6 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener {
|| Intent.ACTION_TIME_CHANGED.equals(action)
|| Intent.ACTION_TIMEZONE_CHANGED.equals(action)) {
mHandler.sendEmptyMessage(MSG_TIME_UPDATE);
- } else if (TelephonyIntents.SPN_STRINGS_UPDATED_ACTION.equals(action)) {
- mTelephonyPlmn = getTelephonyPlmnFrom(intent);
- mTelephonySpn = getTelephonySpnFrom(intent);
- mHandler.sendEmptyMessage(MSG_CARRIER_INFO_UPDATE);
} else if (Intent.ACTION_BATTERY_CHANGED.equals(action)) {
final int status = intent.getIntExtra(EXTRA_STATUS, BATTERY_STATUS_UNKNOWN);
final int plugged = intent.getIntExtra(EXTRA_PLUGGED, 0);
@@ -682,7 +673,6 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener {
// Take a guess at initial SIM state, battery status and PLMN until we get an update
mBatteryStatus = new BatteryStatus(BATTERY_STATUS_UNKNOWN, 100, 0, 0);
- mTelephonyPlmn = getDefaultPlmn();
// Watch for interesting updates
final IntentFilter filter = new IntentFilter();
@@ -692,7 +682,6 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener {
filter.addAction(Intent.ACTION_TIMEZONE_CHANGED);
filter.addAction(TelephonyIntents.ACTION_SIM_STATE_CHANGED);
filter.addAction(TelephonyManager.ACTION_PHONE_STATE_CHANGED);
- filter.addAction(TelephonyIntents.SPN_STRINGS_UPDATED_ACTION);
filter.addAction(AudioManager.RINGER_MODE_CHANGED_ACTION);
filter.addAction(Intent.ACTION_USER_REMOVED);
context.registerReceiver(mBroadcastReceiver, filter);
@@ -940,21 +929,6 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener {
}
/**
- * Handle {@link #MSG_CARRIER_INFO_UPDATE}
- */
- private void handleCarrierInfoUpdate() {
- if (DEBUG) Log.d(TAG, "handleCarrierInfoUpdate: plmn = " + mTelephonyPlmn
- + ", spn = " + mTelephonySpn);
-
- for (int i = 0; i < mCallbacks.size(); i++) {
- KeyguardUpdateMonitorCallback cb = mCallbacks.get(i).get();
- if (cb != null) {
- cb.onRefreshCarrierInfo(mTelephonyPlmn, mTelephonySpn);
- }
- }
- }
-
- /**
* Handle {@link #MSG_SIM_STATE_CHANGE}
*/
private void handleSimStateChange(int subId, int slotId, State state) {
@@ -1087,18 +1061,6 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener {
}
/**
- * @param intent The intent with action {@link TelephonyIntents#SPN_STRINGS_UPDATED_ACTION}
- * @return The string to use for the plmn, or null if it should not be shown.
- */
- private CharSequence getTelephonyPlmnFrom(Intent intent) {
- if (intent.getBooleanExtra(TelephonyIntents.EXTRA_SHOW_PLMN, false)) {
- final String plmn = intent.getStringExtra(TelephonyIntents.EXTRA_PLMN);
- return (plmn != null) ? plmn : getDefaultPlmn();
- }
- return null;
- }
-
- /**
* @return The default plmn (no service)
*/
private CharSequence getDefaultPlmn() {
@@ -1106,20 +1068,6 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener {
}
/**
- * @param intent The intent with action {@link Telephony.Intents#SPN_STRINGS_UPDATED_ACTION}
- * @return The string to use for the plmn, or null if it should not be shown.
- */
- private CharSequence getTelephonySpnFrom(Intent intent) {
- if (intent.getBooleanExtra(TelephonyIntents.EXTRA_SHOW_SPN, false)) {
- final String spn = intent.getStringExtra(TelephonyIntents.EXTRA_SPN);
- if (spn != null) {
- return spn;
- }
- }
- return null;
- }
-
- /**
* Remove the given observer's callback.
*
* @param callback The callback to remove
@@ -1159,7 +1107,7 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener {
callback.onTimeChanged();
callback.onRingerModeChanged(mRingMode);
callback.onPhoneStateChanged(mPhoneState);
- callback.onRefreshCarrierInfo(mTelephonyPlmn, mTelephonySpn);
+ callback.onRefreshCarrierInfo();
callback.onClockVisibilityChanged();
for (Entry<Integer, SimData> data : mSimDatas.entrySet()) {
final SimData state = data.getValue();
@@ -1219,14 +1167,6 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener {
}
}
- public CharSequence getTelephonyPlmn() {
- return mTelephonyPlmn;
- }
-
- public CharSequence getTelephonySpn() {
- return mTelephonySpn;
- }
-
/**
* @return Whether the device is provisioned (whether they have gone through
* the setup wizard)
@@ -1289,7 +1229,7 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener {
return false;
}
- private State getSimState(int subId) {
+ public State getSimState(int subId) {
if (mSimDatas.containsKey(subId)) {
return mSimDatas.get(subId).simState;
} else {
diff --git a/packages/Keyguard/src/com/android/keyguard/KeyguardUpdateMonitorCallback.java b/packages/Keyguard/src/com/android/keyguard/KeyguardUpdateMonitorCallback.java
index de72ddd..c2f355a 100644
--- a/packages/Keyguard/src/com/android/keyguard/KeyguardUpdateMonitorCallback.java
+++ b/packages/Keyguard/src/com/android/keyguard/KeyguardUpdateMonitorCallback.java
@@ -49,12 +49,8 @@ public class KeyguardUpdateMonitorCallback {
/**
* Called when the carrier PLMN or SPN changes.
- *
- * @param plmn The operator name of the registered network. May be null if it shouldn't
- * be displayed.
- * @param spn The service provider name. May be null if it shouldn't be displayed.
*/
- public void onRefreshCarrierInfo(CharSequence plmn, CharSequence spn) { }
+ public void onRefreshCarrierInfo() { }
/**
* Called when the ringer mode changes.