Allow PhoneAccountHandle in SubscriptionInfoHelper
SubscriptionInfoHelper is used by voicemail settings to determine which
account the settings is for. Previously ACTION_CONFIGURE_VOICEMAIL
states TelephonyManager.EXTRA_PHONE_ACCOUNT_HANDLE can be used to
specify account but only subId was supported.
Fixes: 69313740
Test: make
Change-Id: I559af5d6cbac6ad090c6b33a37a41ad49deca136
diff --git a/src/com/android/phone/NotificationMgr.java b/src/com/android/phone/NotificationMgr.java
index fbb6dc5..a21bdcc 100644
--- a/src/com/android/phone/NotificationMgr.java
+++ b/src/com/android/phone/NotificationMgr.java
@@ -45,7 +45,6 @@
import android.telephony.ServiceState;
import android.telephony.SubscriptionInfo;
import android.telephony.SubscriptionManager;
-import android.telephony.SubscriptionManager.OnSubscriptionsChangedListener;
import android.telephony.TelephonyManager;
import android.text.TextUtils;
import android.util.ArrayMap;
@@ -171,7 +170,7 @@
/* package */ void refreshMwi(int subId) {
// In a single-sim device, subId can be -1 which means "no sub id". In this case we will
// reference the single subid stored in the mMwiVisible map.
- if (subId == SubscriptionInfoHelper.NO_SUB_ID) {
+ if (subId == SubscriptionManager.INVALID_SUBSCRIPTION_ID) {
if (mMwiVisible.keySet().size() == 1) {
Set<Integer> keySet = mMwiVisible.keySet();
Iterator<Integer> keyIt = keySet.iterator();
diff --git a/src/com/android/phone/SubscriptionInfoHelper.java b/src/com/android/phone/SubscriptionInfoHelper.java
index 8c9edf3..7c373e0 100644
--- a/src/com/android/phone/SubscriptionInfoHelper.java
+++ b/src/com/android/phone/SubscriptionInfoHelper.java
@@ -20,6 +20,7 @@
import android.content.Context;
import android.content.Intent;
import android.content.res.Resources;
+import android.telecom.PhoneAccountHandle;
import android.telephony.SubscriptionInfo;
import android.telephony.SubscriptionManager;
import android.telephony.TelephonyManager;
@@ -36,7 +37,6 @@
* helping extract this info and perform common operations using this info.
*/
public class SubscriptionInfoHelper {
- public static final int NO_SUB_ID = -1;
// Extra on intent containing the id of a subscription.
public static final String SUB_ID_EXTRA =
@@ -47,7 +47,7 @@
private Context mContext;
- private int mSubId = NO_SUB_ID;
+ private int mSubId = SubscriptionManager.INVALID_SUBSCRIPTION_ID;
private String mSubLabel;
/**
@@ -55,7 +55,14 @@
*/
public SubscriptionInfoHelper(Context context, Intent intent) {
mContext = context;
- mSubId = intent.getIntExtra(SUB_ID_EXTRA, NO_SUB_ID);
+ PhoneAccountHandle phoneAccountHandle =
+ intent.getParcelableExtra(TelephonyManager.EXTRA_PHONE_ACCOUNT_HANDLE);
+ if (phoneAccountHandle != null) {
+ mSubId = PhoneUtils.getSubIdForPhoneAccountHandle(phoneAccountHandle);
+ }
+ if (mSubId == SubscriptionManager.INVALID_SUBSCRIPTION_ID) {
+ mSubId = intent.getIntExtra(SUB_ID_EXTRA, SubscriptionManager.INVALID_SUBSCRIPTION_ID);
+ }
mSubLabel = intent.getStringExtra(SUB_LABEL_EXTRA);
}
@@ -117,7 +124,7 @@
}
public boolean hasSubId() {
- return mSubId != NO_SUB_ID;
+ return mSubId != SubscriptionManager.INVALID_SUBSCRIPTION_ID;
}
public int getSubId() {