summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorNancy Chen <nancychen@google.com>2014-10-20 19:33:55 -0700
committerNancy Chen <nancychen@google.com>2014-10-22 11:50:18 -0700
commit8c258ac5eee9d1e0c3f8a4d895dda84a2c9ac71a (patch)
treed0b750c91582c509987ef439837bcecc2f782c5f /src
parent6ba0977dcebb38910bd5afdd9259e1e3e3edd524 (diff)
Generalize the device IMEI display for IMEI/MEID and multi-SIM.
The user can initiate a call to display the IMEI device ID from the dialpad. Since the code is almost identical for the IMEI/MEID cases, factor out into one method. Also in the case where there is more than one IMEI device ID (i.e. multi-SIM with multiple SIMs inserted), display a list of IDs in order of slot number. Bug: 17917937 Change-Id: Id465a5498787a0fe72d8317412c6eb7a2ec61d28
Diffstat (limited to 'src')
-rw-r--r--src/com/android/dialer/SpecialCharSequenceMgr.java73
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
*******/