summaryrefslogtreecommitdiffstats
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
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
-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() {