summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarcos Marado <mmarado@cyngn.com>2016-09-21 12:23:17 +0100
committerMarcos Marado <mmarado@cyngn.com>2016-10-20 16:50:02 +0100
commitafcb74c49c0e9366cf46be0d73137e927abc826e (patch)
tree9c4157b2e30072ce171fe454d000564600133a94
parent7619c3c57f0e9cd41a26aa8170ecae05591ac466 (diff)
downloadandroid_packages_apps_Messaging-afcb74c49c0e9366cf46be0d73137e927abc826e.tar.gz
android_packages_apps_Messaging-afcb74c49c0e9366cf46be0d73137e927abc826e.tar.bz2
android_packages_apps_Messaging-afcb74c49c0e9366cf46be0d73137e927abc826e.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. Change-Id: I366e25602db2f96ffb95192c7664993834ba99fc
-rw-r--r--src/com/android/messaging/ui/conversation/ComposeMessageView.java16
-rwxr-xr-xsrc/com/cyanogenmod/messaging/quickmessage/QuickMessagePopup.java16
2 files changed, 30 insertions, 2 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() {
diff --git a/src/com/cyanogenmod/messaging/quickmessage/QuickMessagePopup.java b/src/com/cyanogenmod/messaging/quickmessage/QuickMessagePopup.java
index 6c4af67..0bf8b7f 100755
--- a/src/com/cyanogenmod/messaging/quickmessage/QuickMessagePopup.java
+++ b/src/com/cyanogenmod/messaging/quickmessage/QuickMessagePopup.java
@@ -62,6 +62,7 @@ import com.cyanogenmod.messaging.ui.QuickMessageView;
import com.cyanogenmod.messaging.util.PrefsUtils;
import java.util.ArrayList;
+import java.util.Iterator;
import java.util.List;
public class QuickMessagePopup extends Activity {
@@ -401,7 +402,20 @@ public class QuickMessagePopup extends Activity {
@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() {