summaryrefslogtreecommitdiffstats
path: root/src/com/android/dialer/dialpad/DialpadFragment.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/com/android/dialer/dialpad/DialpadFragment.java')
-rw-r--r--src/com/android/dialer/dialpad/DialpadFragment.java53
1 files changed, 47 insertions, 6 deletions
diff --git a/src/com/android/dialer/dialpad/DialpadFragment.java b/src/com/android/dialer/dialpad/DialpadFragment.java
index 120e55f22..6ddf99378 100644
--- a/src/com/android/dialer/dialpad/DialpadFragment.java
+++ b/src/com/android/dialer/dialpad/DialpadFragment.java
@@ -1,4 +1,6 @@
/*
+ * Copyright (c) 2013, The Linux Foundation. All rights reserved.
+ * Not a Contribution.
* Copyright (C) 2011 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -42,6 +44,7 @@ import android.provider.Contacts.Phones;
import android.provider.Contacts.PhonesColumns;
import android.provider.ContactsContract.Intents;
import android.provider.Settings;
+import android.telephony.MSimTelephonyManager;
import android.telephony.PhoneNumberUtils;
import android.telephony.PhoneStateListener;
import android.telephony.TelephonyManager;
@@ -174,6 +177,8 @@ public class DialpadFragment extends Fragment
// This is the amount of screen the dialpad fragment takes up when fully displayed
private static final float DIALPAD_SLIDE_FRACTION = 0.67f;
+ private static final String SUBSCRIPTION_KEY = "subscription";
+
private static final String EMPTY_NUMBER = "";
private static final char PAUSE = ',';
private static final char WAIT = ';';
@@ -223,6 +228,7 @@ public class DialpadFragment extends Fragment
*/
private String mProhibitedPhoneNumberRegexp;
+ private int mSubscription = 0;
// Last number dialed, retrieved asynchronously from the call DB
// in onCreate. This number is displayed when the user hits the
@@ -1635,18 +1641,52 @@ public class DialpadFragment extends Fragment
*
* @return true if voicemail is enabled and accessibly. Note that this can be false
* "temporarily" after the app boot.
- * @see TelephonyManager#getVoiceMailNumber()
+ * @see MSimTelephonyManager#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 = Settings.Global.getInt(getActivity().getContentResolver(),
+ Settings.Global.MULTI_SIM_VOICE_PROMPT, 0) == 1;
+ Log.d(TAG, "prompt enabled : "+ promptEnabled);
+
+ if (promptEnabled) {
+ return hasVMNumber();
+ } else {
+ try {
+ if (MSimTelephonyManager.getDefault().isMultiSimEnabled()) {
+ mSubscription = MSimTelephonyManager.getDefault().
+ getPreferredVoiceSubscription();
+ Log.d(TAG, "Voicemail preferred sub id = "+ mSubscription);
+ return (MSimTelephonyManager.getDefault().
+ getVoiceMailNumber(mSubscription) != null);
+ } else {
+ return getTelephonyManager().getVoiceMailNumber() != null;
+ }
+ } catch (SecurityException se) {
+ // Possibly no READ_PHONE_STATE privilege.
+ Log.e(TAG, "SecurityException is thrown. Maybe privilege isn't sufficient.");
+ }
}
return false;
}
+ private boolean hasVMNumber() {
+ boolean hasVMNum = false;
+ int phoneCount = MSimTelephonyManager.getDefault().getPhoneCount();
+
+ for (int i = 0; i < phoneCount; i++) {
+ try {
+ hasVMNum = MSimTelephonyManager.getDefault().getVoiceMailNumber(i) != 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.
@@ -1721,6 +1761,7 @@ public class DialpadFragment extends Fragment
private Intent newFlashIntent() {
final Intent intent = CallUtil.getCallIntent(EMPTY_NUMBER);
intent.putExtra(EXTRA_SEND_EMPTY_FLASH, true);
+ intent.putExtra(SUBSCRIPTION_KEY, mSubscription);
return intent;
}