diff options
author | Nancy Chen <nancychen@google.com> | 2014-10-22 21:22:26 +0000 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2014-10-22 21:22:26 +0000 |
commit | 11d2c3b284d7e53d76af708be5fdab5bce01b4c0 (patch) | |
tree | a62574ca24ebe6ab6a57a34170836d85f19be943 /src | |
parent | b54c100efcca875debb53b16ac03eeb81070c5e6 (diff) | |
parent | 8c258ac5eee9d1e0c3f8a4d895dda84a2c9ac71a (diff) |
am 8c258ac5: Generalize the device IMEI display for IMEI/MEID and multi-SIM.
* commit '8c258ac5eee9d1e0c3f8a4d895dda84a2c9ac71a':
Generalize the device IMEI display for IMEI/MEID and multi-SIM.
Diffstat (limited to 'src')
-rw-r--r-- | src/com/android/dialer/SpecialCharSequenceMgr.java | 73 |
1 files changed, 23 insertions, 50 deletions
diff --git a/src/com/android/dialer/SpecialCharSequenceMgr.java b/src/com/android/dialer/SpecialCharSequenceMgr.java index 14b26eccc..8e56e45e5 100644 --- a/src/com/android/dialer/SpecialCharSequenceMgr.java +++ b/src/com/android/dialer/SpecialCharSequenceMgr.java @@ -39,6 +39,9 @@ import android.widget.Toast; import com.android.common.io.MoreCloseables; import com.android.contacts.common.database.NoNullCursorAsyncQueryHandler; +import java.util.ArrayList; +import java.util.List; + /** * Helper class to listen for some magic character sequences * that are handled specially by the dialer. @@ -80,20 +83,10 @@ public class SpecialCharSequenceMgr { } public static boolean handleChars(Context context, String input, EditText textField) { - return handleChars(context, input, false, textField); - } - - static boolean handleChars(Context context, String input) { - return handleChars(context, input, false, null); - } - - static boolean handleChars(Context context, String input, boolean useSystemWindow, - EditText textField) { - //get rid of the separators so that the string gets parsed correctly String dialString = PhoneNumberUtils.stripSeparators(input); - if (handleIMEIDisplay(context, dialString, useSystemWindow) + if (handleDeviceIdDisplay(context, dialString) || handleRegulatoryInfoDisplay(context, dialString) || handlePinEntry(context, dialString) || handleAdnEntry(context, dialString, textField) @@ -233,20 +226,30 @@ public class SpecialCharSequenceMgr { return false; } - static boolean handleIMEIDisplay(Context context, String input, boolean useSystemWindow) { + + // TODO: Use TelephonyCapabilities.getDeviceIdLabel() to get the device id label instead of a + // hard-coded string. + static boolean handleDeviceIdDisplay(Context context, String input) { TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE); + if (telephonyManager != null && input.equals(MMI_IMEI_DISPLAY)) { - int phoneType = telephonyManager.getPhoneType(); - if (phoneType == TelephonyManager.PHONE_TYPE_GSM) { - showIMEIPanel(context, useSystemWindow, telephonyManager); - return true; - } else if (phoneType == TelephonyManager.PHONE_TYPE_CDMA) { - showMEIDPanel(context, useSystemWindow, telephonyManager); - return true; + int labelResId = (telephonyManager.getPhoneType() == TelephonyManager.PHONE_TYPE_GSM) ? + R.string.imei : R.string.meid; + + List<String> deviceIds = new ArrayList<String>(); + for (int slot = 0; slot < telephonyManager.getPhoneCount(); slot++) { + deviceIds.add(telephonyManager.getDeviceId(slot)); } - } + AlertDialog alert = new AlertDialog.Builder(context) + .setTitle(labelResId) + .setItems(deviceIds.toArray(new String[deviceIds.size()]), null) + .setPositiveButton(R.string.ok, null) + .setCancelable(false) + .show(); + return true; + } return false; } @@ -264,36 +267,6 @@ public class SpecialCharSequenceMgr { return false; } - // TODO: Combine showIMEIPanel() and showMEIDPanel() into a single - // generic "showDeviceIdPanel()" method, like in the apps/Phone - // version of SpecialCharSequenceMgr.java. (This will require moving - // the phone app's TelephonyCapabilities.getDeviceIdLabel() method - // into the telephony framework, though.) - - private static void showIMEIPanel(Context context, boolean useSystemWindow, - TelephonyManager telephonyManager) { - String imeiStr = telephonyManager.getDeviceId(); - - AlertDialog alert = new AlertDialog.Builder(context) - .setTitle(R.string.imei) - .setMessage(imeiStr) - .setPositiveButton(android.R.string.ok, null) - .setCancelable(false) - .show(); - } - - private static void showMEIDPanel(Context context, boolean useSystemWindow, - TelephonyManager telephonyManager) { - String meidStr = telephonyManager.getDeviceId(); - - AlertDialog alert = new AlertDialog.Builder(context) - .setTitle(R.string.meid) - .setMessage(meidStr) - .setPositiveButton(android.R.string.ok, null) - .setCancelable(false) - .show(); - } - /******* * This code is used to handle SIM Contact queries *******/ |