Loading packages/Keyguard/src/com/android/keyguard/CarrierText.java +49 −0 Original line number Diff line number Diff line Loading @@ -39,6 +39,7 @@ import com.android.internal.telephony.IccCardConstants; import com.android.internal.telephony.IccCardConstants.State; import com.android.internal.telephony.TelephonyIntents; import com.android.settingslib.WirelessUtils; import android.telephony.TelephonyManager; public class CarrierText extends TextView { private static final boolean DEBUG = KeyguardConstants.DEBUG; Loading @@ -52,6 +53,8 @@ public class CarrierText extends TextView { private WifiManager mWifiManager; private boolean[] mSimErrorState = new boolean[TelephonyManager.getDefault().getPhoneCount()]; private KeyguardUpdateMonitorCallback mCallback = new KeyguardUpdateMonitorCallback() { @Override public void onRefreshCarrierInfo() { Loading @@ -65,6 +68,22 @@ public class CarrierText extends TextView { public void onStartedWakingUp() { setSelected(true); }; public void onSimStateChanged(int subId, int slotId, IccCardConstants.State simState) { if (slotId < 0) { Log.d(TAG, "onSimStateChanged() - slotId invalid: " + slotId); return; } Log.d(TAG,"onSimStateChanged: " + getStatusForIccState(simState)); if (getStatusForIccState(simState) == StatusMode.SimIoError) { mSimErrorState[slotId] = true; updateCarrierText(); } else if (mSimErrorState[slotId]) { mSimErrorState[slotId] = false; updateCarrierText(); } }; }; /** * The status of this lock screen. Primarily used for widgets on LockScreen. Loading Loading @@ -102,6 +121,35 @@ public class CarrierText extends TextView { mWifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE); } /** * Checks if there are faulty cards. Adds the text depending on the slot of the card * @param text: current carrier text based on the sim state * @param noSims: whether a valid sim card is inserted * @return text */ private CharSequence updateCarrierTextWithSimIoError(CharSequence text, boolean noSims) { final CharSequence carrier = ""; CharSequence carrierTextForSimState = getCarrierTextForSimState( IccCardConstants.State.CARD_IO_ERROR, carrier); for (int index = 0; index < mSimErrorState.length; index++) { if (mSimErrorState[index]) { // In the case when no sim cards are detected but a faulty card is inserted // overwrite the text and only show "Invalid card" if (noSims) { return concatenate(carrierTextForSimState, getContext().getText(com.android.internal.R.string.emergency_calls_only)); } else if (index == 0) { // prepend "Invalid card" when faulty card is inserted in slot 0 text = concatenate(carrierTextForSimState, text); } else { // concatenate "Invalid card" when faulty card is inserted in slot 1 text = concatenate(text, carrierTextForSimState); } } } return text; } protected void updateCarrierText() { boolean allSimsMissing = true; boolean anySimReadyAndInService = false; Loading Loading @@ -180,6 +228,7 @@ public class CarrierText extends TextView { } } displayText = updateCarrierTextWithSimIoError(displayText, allSimsMissing); // APM (airplane mode) != no carrier state. There are carrier services // (e.g. WFC = Wi-Fi calling) which may operate in APM. if (!anySimReadyAndInService && WirelessUtils.isAirplaneModeOn(mContext)) { Loading Loading
packages/Keyguard/src/com/android/keyguard/CarrierText.java +49 −0 Original line number Diff line number Diff line Loading @@ -39,6 +39,7 @@ import com.android.internal.telephony.IccCardConstants; import com.android.internal.telephony.IccCardConstants.State; import com.android.internal.telephony.TelephonyIntents; import com.android.settingslib.WirelessUtils; import android.telephony.TelephonyManager; public class CarrierText extends TextView { private static final boolean DEBUG = KeyguardConstants.DEBUG; Loading @@ -52,6 +53,8 @@ public class CarrierText extends TextView { private WifiManager mWifiManager; private boolean[] mSimErrorState = new boolean[TelephonyManager.getDefault().getPhoneCount()]; private KeyguardUpdateMonitorCallback mCallback = new KeyguardUpdateMonitorCallback() { @Override public void onRefreshCarrierInfo() { Loading @@ -65,6 +68,22 @@ public class CarrierText extends TextView { public void onStartedWakingUp() { setSelected(true); }; public void onSimStateChanged(int subId, int slotId, IccCardConstants.State simState) { if (slotId < 0) { Log.d(TAG, "onSimStateChanged() - slotId invalid: " + slotId); return; } Log.d(TAG,"onSimStateChanged: " + getStatusForIccState(simState)); if (getStatusForIccState(simState) == StatusMode.SimIoError) { mSimErrorState[slotId] = true; updateCarrierText(); } else if (mSimErrorState[slotId]) { mSimErrorState[slotId] = false; updateCarrierText(); } }; }; /** * The status of this lock screen. Primarily used for widgets on LockScreen. Loading Loading @@ -102,6 +121,35 @@ public class CarrierText extends TextView { mWifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE); } /** * Checks if there are faulty cards. Adds the text depending on the slot of the card * @param text: current carrier text based on the sim state * @param noSims: whether a valid sim card is inserted * @return text */ private CharSequence updateCarrierTextWithSimIoError(CharSequence text, boolean noSims) { final CharSequence carrier = ""; CharSequence carrierTextForSimState = getCarrierTextForSimState( IccCardConstants.State.CARD_IO_ERROR, carrier); for (int index = 0; index < mSimErrorState.length; index++) { if (mSimErrorState[index]) { // In the case when no sim cards are detected but a faulty card is inserted // overwrite the text and only show "Invalid card" if (noSims) { return concatenate(carrierTextForSimState, getContext().getText(com.android.internal.R.string.emergency_calls_only)); } else if (index == 0) { // prepend "Invalid card" when faulty card is inserted in slot 0 text = concatenate(carrierTextForSimState, text); } else { // concatenate "Invalid card" when faulty card is inserted in slot 1 text = concatenate(text, carrierTextForSimState); } } } return text; } protected void updateCarrierText() { boolean allSimsMissing = true; boolean anySimReadyAndInService = false; Loading Loading @@ -180,6 +228,7 @@ public class CarrierText extends TextView { } } displayText = updateCarrierTextWithSimIoError(displayText, allSimsMissing); // APM (airplane mode) != no carrier state. There are carrier services // (e.g. WFC = Wi-Fi calling) which may operate in APM. if (!anySimReadyAndInService && WirelessUtils.isAirplaneModeOn(mContext)) { Loading