diff options
-rw-r--r-- | src/com/android/dialer/SpecialCharSequenceMgr.java | 34 | ||||
-rw-r--r-- | src/com/android/dialer/dialpad/DialpadFragment.java | 35 |
2 files changed, 56 insertions, 13 deletions
diff --git a/src/com/android/dialer/SpecialCharSequenceMgr.java b/src/com/android/dialer/SpecialCharSequenceMgr.java index 14b26eccc..ba44555cb 100644 --- a/src/com/android/dialer/SpecialCharSequenceMgr.java +++ b/src/com/android/dialer/SpecialCharSequenceMgr.java @@ -27,9 +27,12 @@ import android.content.Intent; import android.database.Cursor; import android.net.Uri; import android.os.Looper; +import android.os.RemoteException; +import android.os.ServiceManager; import android.provider.Settings; import android.telecom.TelecomManager; import android.telephony.PhoneNumberUtils; +import android.telephony.SubscriptionManager; import android.telephony.TelephonyManager; import android.util.Log; import android.view.WindowManager; @@ -38,7 +41,7 @@ import android.widget.Toast; import com.android.common.io.MoreCloseables; import com.android.contacts.common.database.NoNullCursorAsyncQueryHandler; - +import com.android.internal.telephony.ITelephony; /** * Helper class to listen for some magic character sequences * that are handled specially by the dialer. @@ -208,7 +211,9 @@ public class SpecialCharSequenceMgr { sc.progressDialog.show(); // run the query. - handler.startQuery(ADN_QUERY_TOKEN, sc, Uri.parse("content://icc/adn"), + long subId = SubscriptionManager.getDefaultVoiceSubId(); + Uri uri = Uri.parse("content://icc/adn/subId/" + subId); + handler.startQuery(ADN_QUERY_TOKEN, sc, uri, new String[]{ADN_PHONE_NUMBER_COLUMN_NAME}, null, null, null); if (sPreviousAdnQueryHandler != null) { @@ -226,9 +231,14 @@ public class SpecialCharSequenceMgr { static boolean handlePinEntry(Context context, String input) { if ((input.startsWith("**04") || input.startsWith("**05")) && input.endsWith("#")) { - TelecomManager telecomManager = - (TelecomManager) context.getSystemService(Context.TELECOM_SERVICE); - return telecomManager.handleMmi(input); + long subId = SubscriptionManager.getDefaultVoiceSubId(); + try { + return ITelephony.Stub.asInterface(ServiceManager.getService( + Context.TELEPHONY_SERVICE)).handlePinMmiForSubscriber(subId, input); + } catch(RemoteException ex) { + Log.e(TAG, "Remote Exception "+ex); + return false; + } } return false; } @@ -237,7 +247,9 @@ public class SpecialCharSequenceMgr { TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE); if (telephonyManager != null && input.equals(MMI_IMEI_DISPLAY)) { - int phoneType = telephonyManager.getPhoneType(); + int phoneType; + long subId = SubscriptionManager.getDefaultVoiceSubId(); + phoneType = telephonyManager.getCurrentPhoneType(subId); if (phoneType == TelephonyManager.PHONE_TYPE_GSM) { showIMEIPanel(context, useSystemWindow, telephonyManager); return true; @@ -272,7 +284,10 @@ public class SpecialCharSequenceMgr { private static void showIMEIPanel(Context context, boolean useSystemWindow, TelephonyManager telephonyManager) { - String imeiStr = telephonyManager.getDeviceId(); + 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) @@ -284,7 +299,10 @@ public class SpecialCharSequenceMgr { private static void showMEIDPanel(Context context, boolean useSystemWindow, TelephonyManager telephonyManager) { - String meidStr = telephonyManager.getDeviceId(); + 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) diff --git a/src/com/android/dialer/dialpad/DialpadFragment.java b/src/com/android/dialer/dialpad/DialpadFragment.java index ee799dd07..6e870cf8c 100644 --- a/src/com/android/dialer/dialpad/DialpadFragment.java +++ b/src/com/android/dialer/dialpad/DialpadFragment.java @@ -41,6 +41,7 @@ import android.telecom.PhoneAccount; import android.telecom.TelecomManager; import android.telephony.PhoneNumberUtils; import android.telephony.PhoneStateListener; +import android.telephony.SubscriptionManager; import android.telephony.TelephonyManager; import android.text.Editable; import android.text.SpannableString; @@ -1640,15 +1641,39 @@ public class DialpadFragment extends AnalyticsFragment * @see TelephonyManager#getVoiceMailNumber() */ private boolean isVoicemailAvailable() { - try { - return getTelephonyManager().getVoiceMailNumber() != null; - } catch (SecurityException se) { - // Possibly no READ_PHONE_STATE privilege. - Log.w(TAG, "SecurityException is thrown. Maybe privilege isn't sufficient."); + boolean promptEnabled = SubscriptionManager.isVoicePromptEnabled(); + if (promptEnabled) { + hasVMNumber(); + } else { + long subId = SubscriptionManager.getDefaultVoiceSubId(); + try { + return getTelephonyManager().getVoiceMailNumber(subId) != null; + } catch (SecurityException se) { + // Possibly no READ_PHONE_STATE privilege. + Log.w(TAG, "SecurityException is thrown. Maybe privilege isn't sufficient."); + } } return false; } + private boolean hasVMNumber() { + boolean hasVMNum = false; + int phoneCount = getTelephonyManager().getPhoneCount(); + for (int i = 0; i < phoneCount; i++) { + try { + long[] subId = SubscriptionManager.getSubId(i); + hasVMNum = getTelephonyManager().getVoiceMailNumber(subId[0]) != null; + } catch (SecurityException se) { + // Possibly no READ_PHONE_STATE privilege. + Log.e(TAG, "hasVMNumber: SecurityException, Maybe privilege isn't sufficient."); + } + if (hasVMNum) { + break; + } + } + return hasVMNum; + } + /** * Returns true of the newDigit parameter can be added at the current selection * point, otherwise returns false. |