summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAdnan Begovic <adnan@cyngn.com>2016-06-13 17:26:59 -0700
committerAdnan Begovic <adnan@cyngn.com>2016-06-14 11:17:47 -0700
commit8b93a6dd0b28f5bb2bfe66e841bb3fc18c8fa5a5 (patch)
treee504f5be2b9f55c5986a69eba9dcbd06baea7bf3
parent3ddf05c90e60fcae94fefb04e4ace9a9a6716365 (diff)
downloadandroid_packages_apps_Messaging-8b93a6dd0b28f5bb2bfe66e841bb3fc18c8fa5a5.tar.gz
android_packages_apps_Messaging-8b93a6dd0b28f5bb2bfe66e841bb3fc18c8fa5a5.tar.bz2
android_packages_apps_Messaging-8b93a6dd0b28f5bb2bfe66e841bb3fc18c8fa5a5.zip
messaging: Filter out SIP accounts from SelectAccountDialogFragments.
Change-Id: Iff9f3115efa7fae1244cc5712daf1a2cfd31a4dd TICKET: CYNGNOS-2982 (cherry picked from commit 358c6adb6d6314d45aa8b7a955cd4246a6db8d21)
-rw-r--r--src/com/android/messaging/ui/conversation/ComposeMessageView.java12
-rw-r--r--src/com/android/messaging/util/PhoneUtils.java17
-rwxr-xr-xsrc/com/cyanogenmod/messaging/quickmessage/QuickMessagePopup.java13
3 files changed, 42 insertions, 0 deletions
diff --git a/src/com/android/messaging/ui/conversation/ComposeMessageView.java b/src/com/android/messaging/ui/conversation/ComposeMessageView.java
index 771c1f7..dc2b231 100644
--- a/src/com/android/messaging/ui/conversation/ComposeMessageView.java
+++ b/src/com/android/messaging/ui/conversation/ComposeMessageView.java
@@ -26,6 +26,7 @@ import android.os.Bundle;
import android.preference.PreferenceManager;
import android.support.v7.app.ActionBar;
import android.telecom.TelecomManager;
+import android.telecom.PhoneAccount;
import android.telecom.PhoneAccountHandle;
import android.telephony.TelephonyManager;
import android.telephony.SmsManager;
@@ -224,6 +225,17 @@ public class ComposeMessageView extends LinearLayout
(TelecomManager) activity.getSystemService(Context.TELECOM_SERVICE);
final List<PhoneAccountHandle> handles = telecomMgr.getCallCapablePhoneAccounts();
+ //trim out SIP accounts
+ for (PhoneAccountHandle handle : handles) {
+ PhoneAccount phoneAccount = PhoneUtils.getAccountOrNull(activity, handle);
+ if (phoneAccount != null) {
+ Uri address = phoneAccount.getAddress();
+ if (address != null && address.getScheme() == PhoneAccount.SCHEME_SIP) {
+ handles.remove(handle);
+ }
+ }
+ }
+
final SelectPhoneAccountDialogFragment.SelectPhoneAccountListener listener =
new SelectPhoneAccountDialogFragment.SelectPhoneAccountListener() {
@Override
diff --git a/src/com/android/messaging/util/PhoneUtils.java b/src/com/android/messaging/util/PhoneUtils.java
index 469a347..3bf784e 100644
--- a/src/com/android/messaging/util/PhoneUtils.java
+++ b/src/com/android/messaging/util/PhoneUtils.java
@@ -29,6 +29,9 @@ import android.provider.Telephony;
import android.support.v4.util.ArrayMap;
import android.support.v4.text.BidiFormatter;
import android.support.v4.text.TextDirectionHeuristicsCompat;
+import android.telecom.TelecomManager;
+import android.telecom.PhoneAccount;
+import android.telecom.PhoneAccountHandle;
import android.telephony.PhoneNumberUtils;
import android.telephony.SmsManager;
import android.telephony.SubscriptionInfo;
@@ -1050,4 +1053,18 @@ public abstract class PhoneUtils {
return isCDMAPhone(subscription) && isNetworkRoaming(subscription);
}
+ /**
+ * Retrieve the account metadata, but if the account does not exist or the device has only a
+ * single registered and enabled account, return null.
+ */
+ public static PhoneAccount getAccountOrNull(Context context,
+ PhoneAccountHandle accountHandle) {
+ TelecomManager telecomManager =
+ (TelecomManager) context.getSystemService(Context.TELECOM_SERVICE);
+ final PhoneAccount account = telecomManager.getPhoneAccount(accountHandle);
+ if (telecomManager.getCallCapablePhoneAccounts().size() <= 1) {
+ return null;
+ }
+ return account;
+ }
}
diff --git a/src/com/cyanogenmod/messaging/quickmessage/QuickMessagePopup.java b/src/com/cyanogenmod/messaging/quickmessage/QuickMessagePopup.java
index af74454..82331b2 100755
--- a/src/com/cyanogenmod/messaging/quickmessage/QuickMessagePopup.java
+++ b/src/com/cyanogenmod/messaging/quickmessage/QuickMessagePopup.java
@@ -21,10 +21,12 @@ import android.app.DialogFragment;
import android.app.NotificationManager;
import android.content.Context;
import android.content.Intent;
+import android.net.Uri;
import android.os.Bundle;
import android.service.notification.StatusBarNotification;
import android.support.v4.view.PagerAdapter;
import android.support.v4.view.ViewPager;
+import android.telecom.PhoneAccount;
import android.telecom.PhoneAccountHandle;
import android.telecom.TelecomManager;
import android.telephony.TelephonyManager;
@@ -380,6 +382,17 @@ public class QuickMessagePopup extends Activity {
(TelecomManager) activity.getSystemService(Context.TELECOM_SERVICE);
final List<PhoneAccountHandle> handles = telecomMgr.getCallCapablePhoneAccounts();
+ //trim out SIP accounts
+ for (PhoneAccountHandle handle : handles) {
+ PhoneAccount phoneAccount = PhoneUtils.getAccountOrNull(activity, handle);
+ if (phoneAccount != null) {
+ Uri address = phoneAccount.getAddress();
+ if (address != null && address.getScheme() == PhoneAccount.SCHEME_SIP) {
+ handles.remove(handle);
+ }
+ }
+ }
+
final SelectPhoneAccountDialogFragment.SelectPhoneAccountListener listener =
new SelectPhoneAccountDialogFragment.SelectPhoneAccountListener() {
@Override