blob: 45d1aad8d3a48a16d95f3acd0e16cf8eb9b1f4ff [file] [log] [blame]
Jim Miller109f1fd2012-09-19 20:44:16 -07001/*
2 * Copyright (C) 2012 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
Jim Miller5ecd8112013-01-09 18:50:26 -080017package com.android.keyguard;
Jim Millerf9cb7ba2012-09-17 22:31:56 -070018
Jason Monk9ff69bd2014-12-02 16:43:17 -050019import java.util.List;
20import java.util.Locale;
Sanket Padaweb8726b72015-04-01 14:02:16 -070021import java.util.Objects;
Jason Monk9ff69bd2014-12-02 16:43:17 -050022
Jim Millerf9cb7ba2012-09-17 22:31:56 -070023import android.content.Context;
Jason Monkde3260b2015-02-24 08:55:26 -050024import android.content.Intent;
25import android.content.IntentFilter;
Jorim Jaggi25807932014-04-24 23:29:46 +020026import android.content.res.TypedArray;
Jason Monk83bc2aaf2014-12-05 10:16:24 -050027import android.net.ConnectivityManager;
Etan Cohen47051d82015-07-06 16:19:04 -070028import android.net.wifi.WifiManager;
29import android.telephony.ServiceState;
Jason Monk9ff69bd2014-12-02 16:43:17 -050030import android.telephony.SubscriptionInfo;
Jim Millerf9cb7ba2012-09-17 22:31:56 -070031import android.text.TextUtils;
Jason Monk9ff69bd2014-12-02 16:43:17 -050032import android.text.method.SingleLineTransformationMethod;
Jim Millerf9cb7ba2012-09-17 22:31:56 -070033import android.util.AttributeSet;
Jason Monk9ff69bd2014-12-02 16:43:17 -050034import android.util.Log;
Victoria Lease1d80e972013-11-01 16:34:03 -070035import android.view.View;
Jim Millerf9cb7ba2012-09-17 22:31:56 -070036import android.widget.TextView;
37
Jim Millerf9cb7ba2012-09-17 22:31:56 -070038import com.android.internal.telephony.IccCardConstants;
39import com.android.internal.telephony.IccCardConstants.State;
Jason Monkde3260b2015-02-24 08:55:26 -050040import com.android.internal.telephony.TelephonyIntents;
Jason Monk726fb282015-03-31 12:56:11 -040041import com.android.settingslib.WirelessUtils;
Wileen Chiu6b8b22e2014-10-29 22:48:21 +053042import android.telephony.TelephonyManager;
Jim Millerf9cb7ba2012-09-17 22:31:56 -070043
44public class CarrierText extends TextView {
Jason Monk9ff69bd2014-12-02 16:43:17 -050045 private static final boolean DEBUG = KeyguardConstants.DEBUG;
46 private static final String TAG = "CarrierText";
47
Jim Millere9be1402012-11-01 16:14:20 -070048 private static CharSequence mSeparator;
49
Adrian Roosc2e01682015-01-15 23:20:20 +010050 private final boolean mIsEmergencyCallCapable;
51
Jason Monk9ff69bd2014-12-02 16:43:17 -050052 private KeyguardUpdateMonitor mKeyguardUpdateMonitor;
Jim Millerf9cb7ba2012-09-17 22:31:56 -070053
Etan Cohen47051d82015-07-06 16:19:04 -070054 private WifiManager mWifiManager;
55
Wileen Chiu6b8b22e2014-10-29 22:48:21 +053056 private boolean[] mSimErrorState = new boolean[TelephonyManager.getDefault().getPhoneCount()];
57
Jim Millerf9cb7ba2012-09-17 22:31:56 -070058 private KeyguardUpdateMonitorCallback mCallback = new KeyguardUpdateMonitorCallback() {
Jim Millerf9cb7ba2012-09-17 22:31:56 -070059 @Override
Jason Monk9ff69bd2014-12-02 16:43:17 -050060 public void onRefreshCarrierInfo() {
61 updateCarrierText();
Jim Millerf9cb7ba2012-09-17 22:31:56 -070062 }
Jim Miller20daffd2013-10-07 14:59:53 -070063
Jorim Jaggi0d210f62015-07-10 14:24:44 -070064 public void onFinishedGoingToSleep(int why) {
Jim Miller20daffd2013-10-07 14:59:53 -070065 setSelected(false);
66 };
67
Jorim Jaggi0d210f62015-07-10 14:24:44 -070068 public void onStartedWakingUp() {
Jim Miller20daffd2013-10-07 14:59:53 -070069 setSelected(true);
70 };
Wileen Chiu6b8b22e2014-10-29 22:48:21 +053071
72 public void onSimStateChanged(int subId, int slotId, IccCardConstants.State simState) {
73 if (slotId < 0) {
74 Log.d(TAG, "onSimStateChanged() - slotId invalid: " + slotId);
75 return;
76 }
77
78 if (DEBUG) Log.d(TAG,"onSimStateChanged: " + getStatusForIccState(simState));
79 if (getStatusForIccState(simState) == StatusMode.SimIoError) {
80 mSimErrorState[slotId] = true;
81 updateCarrierText();
82 } else if (mSimErrorState[slotId]) {
83 mSimErrorState[slotId] = false;
84 updateCarrierText();
85 }
86 };
Jim Millerf9cb7ba2012-09-17 22:31:56 -070087 };
88 /**
89 * The status of this lock screen. Primarily used for widgets on LockScreen.
90 */
Jim Miller109f1fd2012-09-19 20:44:16 -070091 private static enum StatusMode {
Jim Millerf9cb7ba2012-09-17 22:31:56 -070092 Normal, // Normal case (sim card present, it's not locked)
93 NetworkLocked, // SIM card is 'network locked'.
94 SimMissing, // SIM card is missing.
95 SimMissingLocked, // SIM card is missing, and device isn't provisioned; don't allow access
96 SimPukLocked, // SIM card is PUK locked because SIM entered wrong too many times
97 SimLocked, // SIM card is currently locked
Jim Miller109f1fd2012-09-19 20:44:16 -070098 SimPermDisabled, // SIM card is permanently disabled due to PUK unlock failure
Wileen Chiu6b8b22e2014-10-29 22:48:21 +053099 SimNotReady, // SIM is not ready yet. May never be on devices w/o a SIM.
100 SimIoError; // SIM card is faulty
Jim Millerf9cb7ba2012-09-17 22:31:56 -0700101 }
102
103 public CarrierText(Context context) {
104 this(context, null);
105 }
106
107 public CarrierText(Context context, AttributeSet attrs) {
108 super(context, attrs);
Adrian Roosc2e01682015-01-15 23:20:20 +0100109 mIsEmergencyCallCapable = context.getResources().getBoolean(
110 com.android.internal.R.bool.config_voice_capable);
Jorim Jaggi25807932014-04-24 23:29:46 +0200111 boolean useAllCaps;
112 TypedArray a = context.getTheme().obtainStyledAttributes(
113 attrs, R.styleable.CarrierText, 0, 0);
114 try {
115 useAllCaps = a.getBoolean(R.styleable.CarrierText_allCaps, false);
116 } finally {
117 a.recycle();
118 }
Victoria Lease1d80e972013-11-01 16:34:03 -0700119 setTransformationMethod(new CarrierTextTransformationMethod(mContext, useAllCaps));
Etan Cohen47051d82015-07-06 16:19:04 -0700120
121 mWifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
Jim Millerf9cb7ba2012-09-17 22:31:56 -0700122 }
123
Wileen Chiu6b8b22e2014-10-29 22:48:21 +0530124 /**
125 * Checks if there are faulty cards. Adds the text depending on the slot of the card
126 * @param text: current carrier text based on the sim state
127 * @param noSims: whether a valid sim card is inserted
128 * @return text
129 */
130 private CharSequence updateCarrierTextWithSimIoError(CharSequence text, boolean noSims) {
131 final CharSequence carrier = "";
132 CharSequence carrierTextForSimIOError = getCarrierTextForSimState(
133 IccCardConstants.State.CARD_IO_ERROR, carrier);
134 for (int index = 0; index < mSimErrorState.length; index++) {
135 if (mSimErrorState[index]) {
136 // In the case when no sim cards are detected but a faulty card is inserted
137 // overwrite the text and only show "Invalid card"
138 if (noSims) {
139 return concatenate(carrierTextForSimIOError,
140 getContext().getText(com.android.internal.R.string.emergency_calls_only));
141 } else if (index == 0) {
142 // prepend "Invalid card" when faulty card is inserted in slot 0
143 text = concatenate(carrierTextForSimIOError, text);
144 } else {
145 // concatenate "Invalid card" when faulty card is inserted in slot 1
146 text = concatenate(text, carrierTextForSimIOError);
147 }
148 }
149 }
150 return text;
151 }
152
Jason Monk9ff69bd2014-12-02 16:43:17 -0500153 protected void updateCarrierText() {
154 boolean allSimsMissing = true;
Etan Cohen47051d82015-07-06 16:19:04 -0700155 boolean anySimReadyAndInService = false;
Jason Monk9ff69bd2014-12-02 16:43:17 -0500156 CharSequence displayText = null;
157
158 List<SubscriptionInfo> subs = mKeyguardUpdateMonitor.getSubscriptionInfo(false);
159 final int N = subs.size();
160 if (DEBUG) Log.d(TAG, "updateCarrierText(): " + N);
161 for (int i = 0; i < N; i++) {
Etan Cohen47051d82015-07-06 16:19:04 -0700162 int subId = subs.get(i).getSubscriptionId();
163 State simState = mKeyguardUpdateMonitor.getSimState(subId);
Jason Monk9ff69bd2014-12-02 16:43:17 -0500164 CharSequence carrierName = subs.get(i).getCarrierName();
165 CharSequence carrierTextForSimState = getCarrierTextForSimState(simState, carrierName);
Etan Cohen47051d82015-07-06 16:19:04 -0700166 if (DEBUG) {
167 Log.d(TAG, "Handling (subId=" + subId + "): " + simState + " " + carrierName);
168 }
Jason Monk9ff69bd2014-12-02 16:43:17 -0500169 if (carrierTextForSimState != null) {
170 allSimsMissing = false;
171 displayText = concatenate(displayText, carrierTextForSimState);
172 }
Etan Cohen47051d82015-07-06 16:19:04 -0700173 if (simState == IccCardConstants.State.READY) {
174 ServiceState ss = mKeyguardUpdateMonitor.mServiceStates.get(subId);
175 if (ss != null && ss.getDataRegState() == ServiceState.STATE_IN_SERVICE) {
176 // hack for WFC (IWLAN) not turning off immediately once
177 // Wi-Fi is disassociated or disabled
178 if (ss.getRilDataRadioTechnology() != ServiceState.RIL_RADIO_TECHNOLOGY_IWLAN
179 || (mWifiManager.isWifiEnabled()
180 && mWifiManager.getConnectionInfo() != null
181 && mWifiManager.getConnectionInfo().getBSSID() != null)) {
182 if (DEBUG) {
183 Log.d(TAG, "SIM ready and in service: subId=" + subId + ", ss=" + ss);
184 }
185 anySimReadyAndInService = true;
186 }
187 }
188 }
Jason Monk9ff69bd2014-12-02 16:43:17 -0500189 }
190 if (allSimsMissing) {
191 if (N != 0) {
192 // Shows "No SIM card | Emergency calls only" on devices that are voice-capable.
193 // This depends on mPlmn containing the text "Emergency calls only" when the radio
194 // has some connectivity. Otherwise, it should be null or empty and just show
195 // "No SIM card"
196 // Grab the first subscripton, because they all should contain the emergency text,
197 // described above.
198 displayText = makeCarrierStringOnEmergencyCapable(
199 getContext().getText(R.string.keyguard_missing_sim_message_short),
200 subs.get(0).getCarrierName());
201 } else {
202 // We don't have a SubscriptionInfo to get the emergency calls only from.
Jason Monkde3260b2015-02-24 08:55:26 -0500203 // Grab it from the old sticky broadcast if possible instead. We can use it
204 // here because no subscriptions are active, so we don't have
205 // to worry about MSIM clashing.
206 CharSequence text =
207 getContext().getText(com.android.internal.R.string.emergency_calls_only);
208 Intent i = getContext().registerReceiver(null,
209 new IntentFilter(TelephonyIntents.SPN_STRINGS_UPDATED_ACTION));
210 if (i != null) {
211 String spn = "";
212 String plmn = "";
213 if (i.getBooleanExtra(TelephonyIntents.EXTRA_SHOW_SPN, false)) {
214 spn = i.getStringExtra(TelephonyIntents.EXTRA_SPN);
215 }
216 if (i.getBooleanExtra(TelephonyIntents.EXTRA_SHOW_PLMN, false)) {
217 plmn = i.getStringExtra(TelephonyIntents.EXTRA_PLMN);
218 }
219 if (DEBUG) Log.d(TAG, "Getting plmn/spn sticky brdcst " + plmn + "/" + spn);
Sanket Padaweb8726b72015-04-01 14:02:16 -0700220 if (Objects.equals(plmn, spn)) {
221 text = plmn;
222 } else {
223 text = concatenate(plmn, spn);
224 }
Jason Monkde3260b2015-02-24 08:55:26 -0500225 }
Jason Monk9ff69bd2014-12-02 16:43:17 -0500226 displayText = makeCarrierStringOnEmergencyCapable(
Jason Monkde3260b2015-02-24 08:55:26 -0500227 getContext().getText(R.string.keyguard_missing_sim_message_short), text);
Jason Monk9ff69bd2014-12-02 16:43:17 -0500228 }
229 }
Etan Cohen47051d82015-07-06 16:19:04 -0700230
Wileen Chiu6b8b22e2014-10-29 22:48:21 +0530231 displayText = updateCarrierTextWithSimIoError(displayText, allSimsMissing);
Etan Cohen47051d82015-07-06 16:19:04 -0700232 // APM (airplane mode) != no carrier state. There are carrier services
233 // (e.g. WFC = Wi-Fi calling) which may operate in APM.
234 if (!anySimReadyAndInService && WirelessUtils.isAirplaneModeOn(mContext)) {
Jason Monk726fb282015-03-31 12:56:11 -0400235 displayText = getContext().getString(R.string.airplane_mode);
236 }
Jason Monk9ff69bd2014-12-02 16:43:17 -0500237 setText(displayText);
Jim Millerf9cb7ba2012-09-17 22:31:56 -0700238 }
239
240 @Override
241 protected void onFinishInflate() {
242 super.onFinishInflate();
Jason Monk9ff69bd2014-12-02 16:43:17 -0500243 mSeparator = getResources().getString(
244 com.android.internal.R.string.kg_text_message_separator);
Jorim Jaggi0d210f62015-07-10 14:24:44 -0700245 boolean shouldMarquee = KeyguardUpdateMonitor.getInstance(mContext).isDeviceInteractive();
246 setSelected(shouldMarquee); // Allow marquee to work.
Jim Millerf9cb7ba2012-09-17 22:31:56 -0700247 }
248
Jim Miller0928e012012-11-06 18:43:22 -0800249 @Override
250 protected void onAttachedToWindow() {
251 super.onAttachedToWindow();
Jason Monk83bc2aaf2014-12-05 10:16:24 -0500252 if (ConnectivityManager.from(mContext).isNetworkSupported(
253 ConnectivityManager.TYPE_MOBILE)) {
254 mKeyguardUpdateMonitor = KeyguardUpdateMonitor.getInstance(mContext);
255 mKeyguardUpdateMonitor.registerCallback(mCallback);
256 } else {
257 // Don't listen and clear out the text when the device isn't a phone.
258 mKeyguardUpdateMonitor = null;
259 setText("");
260 }
Jim Miller0928e012012-11-06 18:43:22 -0800261 }
262
263 @Override
264 protected void onDetachedFromWindow() {
265 super.onDetachedFromWindow();
Jason Monk83bc2aaf2014-12-05 10:16:24 -0500266 if (mKeyguardUpdateMonitor != null) {
267 mKeyguardUpdateMonitor.removeCallback(mCallback);
268 }
Jim Miller0928e012012-11-06 18:43:22 -0800269 }
270
Matthew Ng3a6db672017-11-28 14:35:25 -0800271 @Override
272 protected void onVisibilityChanged(View changedView, int visibility) {
273 super.onVisibilityChanged(changedView, visibility);
274
275 // Only show marquee when visible
276 if (visibility == VISIBLE) {
277 setEllipsize(TextUtils.TruncateAt.MARQUEE);
278 } else {
279 setEllipsize(TextUtils.TruncateAt.END);
280 }
281 }
282
Jim Millerf9cb7ba2012-09-17 22:31:56 -0700283 /**
284 * Top-level function for creating carrier text. Makes text based on simState, PLMN
285 * and SPN as well as device capabilities, such as being emergency call capable.
286 *
287 * @param simState
Jason Monk9ff69bd2014-12-02 16:43:17 -0500288 * @param text
Jim Millerf9cb7ba2012-09-17 22:31:56 -0700289 * @param spn
Jason Monk9ff69bd2014-12-02 16:43:17 -0500290 * @return Carrier text if not in missing state, null otherwise.
Jim Millerf9cb7ba2012-09-17 22:31:56 -0700291 */
292 private CharSequence getCarrierTextForSimState(IccCardConstants.State simState,
Jason Monk9ff69bd2014-12-02 16:43:17 -0500293 CharSequence text) {
Jim Millerf9cb7ba2012-09-17 22:31:56 -0700294 CharSequence carrierText = null;
295 StatusMode status = getStatusForIccState(simState);
296 switch (status) {
297 case Normal:
Jason Monk9ff69bd2014-12-02 16:43:17 -0500298 carrierText = text;
Jim Millerf9cb7ba2012-09-17 22:31:56 -0700299 break;
300
Jim Miller109f1fd2012-09-19 20:44:16 -0700301 case SimNotReady:
Jason Monk9ff69bd2014-12-02 16:43:17 -0500302 // Null is reserved for denoting missing, in this case we have nothing to display.
303 carrierText = ""; // nothing to display yet.
Jim Miller109f1fd2012-09-19 20:44:16 -0700304 break;
305
Jim Millerf9cb7ba2012-09-17 22:31:56 -0700306 case NetworkLocked:
307 carrierText = makeCarrierStringOnEmergencyCapable(
Jason Monk9ff69bd2014-12-02 16:43:17 -0500308 mContext.getText(R.string.keyguard_network_locked_message), text);
Jim Millerf9cb7ba2012-09-17 22:31:56 -0700309 break;
310
311 case SimMissing:
Jason Monk9ff69bd2014-12-02 16:43:17 -0500312 carrierText = null;
Jim Millerf9cb7ba2012-09-17 22:31:56 -0700313 break;
314
315 case SimPermDisabled:
316 carrierText = getContext().getText(
Jim Miller5ecd8112013-01-09 18:50:26 -0800317 R.string.keyguard_permanent_disabled_sim_message_short);
Jim Millerf9cb7ba2012-09-17 22:31:56 -0700318 break;
319
320 case SimMissingLocked:
Jason Monk9ff69bd2014-12-02 16:43:17 -0500321 carrierText = null;
Jim Millerf9cb7ba2012-09-17 22:31:56 -0700322 break;
323
324 case SimLocked:
325 carrierText = makeCarrierStringOnEmergencyCapable(
Jim Miller5ecd8112013-01-09 18:50:26 -0800326 getContext().getText(R.string.keyguard_sim_locked_message),
Jason Monk9ff69bd2014-12-02 16:43:17 -0500327 text);
Jim Millerf9cb7ba2012-09-17 22:31:56 -0700328 break;
329
330 case SimPukLocked:
331 carrierText = makeCarrierStringOnEmergencyCapable(
Jim Miller5ecd8112013-01-09 18:50:26 -0800332 getContext().getText(R.string.keyguard_sim_puk_locked_message),
Jason Monk9ff69bd2014-12-02 16:43:17 -0500333 text);
Jim Millerf9cb7ba2012-09-17 22:31:56 -0700334 break;
Wileen Chiu6b8b22e2014-10-29 22:48:21 +0530335 case SimIoError:
336 carrierText = makeCarrierStringOnEmergencyCapable(
337 getContext().getText(R.string.keyguard_sim_error_message_short),
338 text);
339 break;
Jim Millerf9cb7ba2012-09-17 22:31:56 -0700340 }
341
342 return carrierText;
343 }
344
345 /*
346 * Add emergencyCallMessage to carrier string only if phone supports emergency calls.
347 */
348 private CharSequence makeCarrierStringOnEmergencyCapable(
349 CharSequence simMessage, CharSequence emergencyCallMessage) {
Adrian Roosc2e01682015-01-15 23:20:20 +0100350 if (mIsEmergencyCallCapable) {
Jim Millerf9cb7ba2012-09-17 22:31:56 -0700351 return concatenate(simMessage, emergencyCallMessage);
352 }
353 return simMessage;
354 }
355
356 /**
357 * Determine the current status of the lock screen given the SIM state and other stuff.
358 */
359 private StatusMode getStatusForIccState(IccCardConstants.State simState) {
360 // Since reading the SIM may take a while, we assume it is present until told otherwise.
361 if (simState == null) {
362 return StatusMode.Normal;
363 }
364
365 final boolean missingAndNotProvisioned =
366 !KeyguardUpdateMonitor.getInstance(mContext).isDeviceProvisioned()
367 && (simState == IccCardConstants.State.ABSENT ||
368 simState == IccCardConstants.State.PERM_DISABLED);
369
370 // Assume we're NETWORK_LOCKED if not provisioned
371 simState = missingAndNotProvisioned ? IccCardConstants.State.NETWORK_LOCKED : simState;
372 switch (simState) {
373 case ABSENT:
374 return StatusMode.SimMissing;
375 case NETWORK_LOCKED:
376 return StatusMode.SimMissingLocked;
377 case NOT_READY:
Jim Miller109f1fd2012-09-19 20:44:16 -0700378 return StatusMode.SimNotReady;
Jim Millerf9cb7ba2012-09-17 22:31:56 -0700379 case PIN_REQUIRED:
380 return StatusMode.SimLocked;
381 case PUK_REQUIRED:
382 return StatusMode.SimPukLocked;
383 case READY:
384 return StatusMode.Normal;
385 case PERM_DISABLED:
386 return StatusMode.SimPermDisabled;
387 case UNKNOWN:
388 return StatusMode.SimMissing;
Wileen Chiu6b8b22e2014-10-29 22:48:21 +0530389 case CARD_IO_ERROR:
390 return StatusMode.SimIoError;
Jim Millerf9cb7ba2012-09-17 22:31:56 -0700391 }
392 return StatusMode.SimMissing;
393 }
394
395 private static CharSequence concatenate(CharSequence plmn, CharSequence spn) {
396 final boolean plmnValid = !TextUtils.isEmpty(plmn);
397 final boolean spnValid = !TextUtils.isEmpty(spn);
398 if (plmnValid && spnValid) {
Sanket Padaweb8726b72015-04-01 14:02:16 -0700399 return new StringBuilder().append(plmn).append(mSeparator).append(spn).toString();
Jim Millerf9cb7ba2012-09-17 22:31:56 -0700400 } else if (plmnValid) {
401 return plmn;
402 } else if (spnValid) {
403 return spn;
404 } else {
405 return "";
406 }
407 }
408
409 private CharSequence getCarrierHelpTextForSimState(IccCardConstants.State simState,
410 String plmn, String spn) {
411 int carrierHelpTextId = 0;
412 StatusMode status = getStatusForIccState(simState);
413 switch (status) {
414 case NetworkLocked:
Jim Miller5ecd8112013-01-09 18:50:26 -0800415 carrierHelpTextId = R.string.keyguard_instructions_when_pattern_disabled;
Jim Millerf9cb7ba2012-09-17 22:31:56 -0700416 break;
417
418 case SimMissing:
Jim Miller5ecd8112013-01-09 18:50:26 -0800419 carrierHelpTextId = R.string.keyguard_missing_sim_instructions_long;
Jim Millerf9cb7ba2012-09-17 22:31:56 -0700420 break;
421
422 case SimPermDisabled:
Jim Miller5ecd8112013-01-09 18:50:26 -0800423 carrierHelpTextId = R.string.keyguard_permanent_disabled_sim_instructions;
Jim Millerf9cb7ba2012-09-17 22:31:56 -0700424 break;
425
426 case SimMissingLocked:
Jim Miller5ecd8112013-01-09 18:50:26 -0800427 carrierHelpTextId = R.string.keyguard_missing_sim_instructions;
Jim Millerf9cb7ba2012-09-17 22:31:56 -0700428 break;
429
430 case Normal:
431 case SimLocked:
432 case SimPukLocked:
433 break;
434 }
435
436 return mContext.getText(carrierHelpTextId);
437 }
Victoria Lease1d80e972013-11-01 16:34:03 -0700438
439 private class CarrierTextTransformationMethod extends SingleLineTransformationMethod {
440 private final Locale mLocale;
441 private final boolean mAllCaps;
442
443 public CarrierTextTransformationMethod(Context context, boolean allCaps) {
444 mLocale = context.getResources().getConfiguration().locale;
445 mAllCaps = allCaps;
446 }
447
448 @Override
449 public CharSequence getTransformation(CharSequence source, View view) {
450 source = super.getTransformation(source, view);
451
452 if (mAllCaps && source != null) {
453 source = source.toString().toUpperCase(mLocale);
454 }
455
456 return source;
457 }
458 }
Jim Millerf9cb7ba2012-09-17 22:31:56 -0700459}