summaryrefslogtreecommitdiffstats
path: root/src/com/android/messaging/ui/conversation/ComposeMessageView.java
diff options
context:
space:
mode:
authorMarcos Marado <mmarado@cyngn.com>2016-09-21 12:23:17 +0100
committerAdrian DC <radian.dc@gmail.com>2016-12-04 00:34:42 +0100
commitfa6fd70b3b5c5b4f34e124b203885a54540baa71 (patch)
treeb45329215f50820e6e9616664c3a9a532a80d858 /src/com/android/messaging/ui/conversation/ComposeMessageView.java
parent66ad9cdc7042ef4eafc51a6c76440eb3c4bff581 (diff)
downloadandroid_packages_apps_Messaging-fa6fd70b3b5c5b4f34e124b203885a54540baa71.tar.gz
android_packages_apps_Messaging-fa6fd70b3b5c5b4f34e124b203885a54540baa71.tar.bz2
android_packages_apps_Messaging-fa6fd70b3b5c5b4f34e124b203885a54540baa71.zip
really use the subId: PhoneAccountHandle
PhoneAccountHandle's getId does *not* return subId, nor an int, but an unique String identifier: "A connection service must select identifiers that are stable for the lifetime of their users' relationship with their service, across many Android devices. For example, a good set of identifiers might be the email addresses with which with users registered for their accounts with a particular service." Not only onSimSelected is expecting to receive int subId, but more importantly, if you try to Integer.valueOf(selectedAccountHandle.getId()) you'll probably bump into a few NumberFormatException's (if the identifier is an email address, as the previous text suggests, this is what's going to happen). Fix this by actually using the subId for the PhoneAccount that has that PhoneAccountHandle. RM-290 Change-Id: I366e25602db2f96ffb95192c7664993834ba99fc
Diffstat (limited to 'src/com/android/messaging/ui/conversation/ComposeMessageView.java')
-rw-r--r--src/com/android/messaging/ui/conversation/ComposeMessageView.java16
1 files changed, 15 insertions, 1 deletions
diff --git a/src/com/android/messaging/ui/conversation/ComposeMessageView.java b/src/com/android/messaging/ui/conversation/ComposeMessageView.java
index cb6562f..ae1bbec 100644
--- a/src/com/android/messaging/ui/conversation/ComposeMessageView.java
+++ b/src/com/android/messaging/ui/conversation/ComposeMessageView.java
@@ -87,6 +87,7 @@ import com.cyanogenmod.messaging.util.PrefsUtils;
import java.util.ArrayList;
import java.util.Collection;
+import java.util.Iterator;
import java.util.List;
/**
@@ -244,7 +245,20 @@ public class ComposeMessageView extends LinearLayout
@Override
public void onPhoneAccountSelected(PhoneAccountHandle selectedAccountHandle,
boolean setDefault) {
- cb.onSimSelected(Integer.valueOf(selectedAccountHandle.getId()));
+ // we need the subId and we only have a PhoneAccountHandle
+ TelephonyManager telephonyManager =
+ (TelephonyManager) mContext.getSystemService(Context.TELEPHONY_SERVICE);
+ Iterator<PhoneAccountHandle> phoneAccounts =
+ telecomMgr.getCallCapablePhoneAccounts().listIterator();
+ int subId = 0; // defaulting to 0, just in case
+ while (phoneAccounts.hasNext()) {
+ PhoneAccountHandle p = phoneAccounts.next();
+ if (p.getId() == selectedAccountHandle.getId()) {
+ PhoneAccount phoneAccount = telecomMgr.getPhoneAccount(p);
+ subId = telephonyManager.getSubIdForPhoneAccount(phoneAccount);
+ }
+ }
+ cb.onSimSelected(subId);
}
@Override
public void onDialogDismissed() {