summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNancy Chen <nancychen@google.com>2014-10-20 19:33:55 -0700
committerEd Mancebo <emancebo@cyngn.com>2015-06-16 19:02:46 +0000
commite228f6ee368af08f02220b6ad733be125e6fd936 (patch)
tree95854e73804f3134b582832c0aa4ba97d2668537
parente466140205d15df27bdcf0a7ae3146d97d3b8d62 (diff)
downloadandroid_packages_apps_Dialer-stable/cm-12.0-YNG1TA.tar.gz
android_packages_apps_Dialer-stable/cm-12.0-YNG1TA.tar.bz2
android_packages_apps_Dialer-stable/cm-12.0-YNG1TA.zip
Generalize the device IMEI display for IMEI/MEID and multi-SIM.stable/cm-12.0-YNG1TA
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 (cherry picked from commit 320a75a2fbcad43e1615ad79a78e34214b852984)
-rw-r--r--src/com/android/dialer/SpecialCharSequenceMgr.java84
1 files changed, 22 insertions, 62 deletions
diff --git a/src/com/android/dialer/SpecialCharSequenceMgr.java b/src/com/android/dialer/SpecialCharSequenceMgr.java
index 6a16ecbe7..f2e30a11c 100644
--- a/src/com/android/dialer/SpecialCharSequenceMgr.java
+++ b/src/com/android/dialer/SpecialCharSequenceMgr.java
@@ -42,6 +42,8 @@ import android.widget.Toast;
import com.android.common.io.MoreCloseables;
import com.android.contacts.common.database.NoNullCursorAsyncQueryHandler;
import com.android.internal.telephony.ITelephony;
+import java.util.ArrayList;
+import java.util.List;
/**
* Helper class to listen for some magic character sequences
* that are handled specially by the dialer.
@@ -87,23 +89,13 @@ 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 (context.getResources().getBoolean(R.bool.def_dialer_secretcode_enabled) ||
context.getResources().getBoolean(R.bool.def_dialer_settings_diagport_enabled)) {
if (handlePRLVersion(context, dialString)
- || handleIMEIDisplay(context, dialString, useSystemWindow)
+ || handleDeviceIdDisplay(context, dialString)
|| handleRegulatoryInfoDisplay(context, dialString)
|| handleEngineerModeDisplay(context, dialString)
|| handlePinEntry(context, dialString)
@@ -115,7 +107,7 @@ public class SpecialCharSequenceMgr {
}
} else {
if (handlePRLVersion(context, dialString)
- || handleIMEIDisplay(context, dialString, useSystemWindow)
+ || handleDeviceIdDisplay(context, dialString)
|| handleRegulatoryInfoDisplay(context, dialString)
|| handleEngineerModeDisplay(context, dialString)
|| handlePinEntry(context, dialString)
@@ -300,26 +292,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;
- long subId = SubscriptionManager.getDefaultVoiceSubId();
- phoneType = telephonyManager.getCurrentPhoneType(subId);
- if (telephonyManager.isMultiSimEnabled()) {
- return handleMSimIMEIDisplay(context, telephonyManager);
- }
+ int labelResId = (telephonyManager.getPhoneType() == TelephonyManager.PHONE_TYPE_GSM) ?
+ R.string.imei : R.string.meid;
- 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;
+ 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;
}
@@ -365,42 +361,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 = null;
- long subId = SubscriptionManager.getDefaultVoiceSubId();
- int slotId = SubscriptionManager.getSlotId(subId);
- imeiStr = telephonyManager.getDeviceId(slotId);
-
- 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 = null;
- long subId = SubscriptionManager.getDefaultVoiceSubId();
- int slotId = SubscriptionManager.getSlotId(subId);
- meidStr = telephonyManager.getDeviceId(slotId);
-
- AlertDialog alert = new AlertDialog.Builder(context)
- .setTitle(R.string.meid)
- .setMessage(meidStr)
- .setPositiveButton(android.R.string.ok, null)
- .setCancelable(false)
- .show();
- }
-
static boolean handleEngineerModeDisplay(Context context, String input) {
if (input.equals(MMI_ENGINEER_MODE_DISPLAY)) {
Intent intent = new Intent(SECRET_CODE_ACTION,