Update Multi-SIM setting to use getSubIdForPhoneAccount API.
Settings app should not be parsing the subId direction from the phone account. Instead this CL updates the settings app to use a new API to grab the sub ID. Change-Id: Iefd1831b04c061168fa2b135a2d296a27e3d4e92
This commit is contained in:
@@ -29,6 +29,7 @@ import android.telecom.PhoneAccountHandle;
|
|||||||
import android.telecom.TelecomManager;
|
import android.telecom.TelecomManager;
|
||||||
import android.telephony.SubscriptionInfo;
|
import android.telephony.SubscriptionInfo;
|
||||||
import android.telephony.SubscriptionManager;
|
import android.telephony.SubscriptionManager;
|
||||||
|
import android.telephony.TelephonyManager;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.KeyEvent;
|
import android.view.KeyEvent;
|
||||||
@@ -138,17 +139,14 @@ public class SimDialogActivity extends Activity {
|
|||||||
|
|
||||||
private PhoneAccountHandle subscriptionIdToPhoneAccountHandle(final int subId) {
|
private PhoneAccountHandle subscriptionIdToPhoneAccountHandle(final int subId) {
|
||||||
final TelecomManager telecomManager = TelecomManager.from(this);
|
final TelecomManager telecomManager = TelecomManager.from(this);
|
||||||
|
final TelephonyManager telephonyManager = TelephonyManager.from(this);
|
||||||
final Iterator<PhoneAccountHandle> phoneAccounts =
|
final Iterator<PhoneAccountHandle> phoneAccounts =
|
||||||
telecomManager.getCallCapablePhoneAccounts().listIterator();
|
telecomManager.getCallCapablePhoneAccounts().listIterator();
|
||||||
|
|
||||||
while (phoneAccounts.hasNext()) {
|
while (phoneAccounts.hasNext()) {
|
||||||
final PhoneAccountHandle phoneAccountHandle = phoneAccounts.next();
|
final PhoneAccountHandle phoneAccountHandle = phoneAccounts.next();
|
||||||
final PhoneAccount phoneAccount = telecomManager.getPhoneAccount(phoneAccountHandle);
|
final PhoneAccount phoneAccount = telecomManager.getPhoneAccount(phoneAccountHandle);
|
||||||
final String phoneAccountId = phoneAccountHandle.getId();
|
if (subId == telephonyManager.getSubIdForPhoneAccount(phoneAccount)) {
|
||||||
|
|
||||||
if (phoneAccount.hasCapabilities(PhoneAccount.CAPABILITY_SIM_SUBSCRIPTION)
|
|
||||||
&& TextUtils.isDigitsOnly(phoneAccountId)
|
|
||||||
&& Integer.parseInt(phoneAccountId) == subId){
|
|
||||||
return phoneAccountHandle;
|
return phoneAccountHandle;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -210,6 +208,7 @@ public class SimDialogActivity extends Activity {
|
|||||||
ArrayList<SubscriptionInfo> callsSubInfoList = new ArrayList<SubscriptionInfo>();
|
ArrayList<SubscriptionInfo> callsSubInfoList = new ArrayList<SubscriptionInfo>();
|
||||||
if (id == CALLS_PICK) {
|
if (id == CALLS_PICK) {
|
||||||
final TelecomManager telecomManager = TelecomManager.from(context);
|
final TelecomManager telecomManager = TelecomManager.from(context);
|
||||||
|
final TelephonyManager telephonyManager = TelephonyManager.from(context);
|
||||||
final Iterator<PhoneAccountHandle> phoneAccounts =
|
final Iterator<PhoneAccountHandle> phoneAccounts =
|
||||||
telecomManager.getCallCapablePhoneAccounts().listIterator();
|
telecomManager.getCallCapablePhoneAccounts().listIterator();
|
||||||
|
|
||||||
@@ -219,13 +218,9 @@ public class SimDialogActivity extends Activity {
|
|||||||
final PhoneAccount phoneAccount =
|
final PhoneAccount phoneAccount =
|
||||||
telecomManager.getPhoneAccount(phoneAccounts.next());
|
telecomManager.getPhoneAccount(phoneAccounts.next());
|
||||||
list.add((String)phoneAccount.getLabel());
|
list.add((String)phoneAccount.getLabel());
|
||||||
// Added check to add entry into callsSubInforList only if phoneAccountId is int
|
int subId = telephonyManager.getSubIdForPhoneAccount(phoneAccount);
|
||||||
// Todo : Might have to change it later based on b/18904714
|
if (subId != SubscriptionManager.INVALID_SUBSCRIPTION_ID) {
|
||||||
if (phoneAccount.hasCapabilities(PhoneAccount.CAPABILITY_SIM_SUBSCRIPTION) &&
|
final SubscriptionInfo sir = Utils.findRecordBySubId(context, subId);
|
||||||
TextUtils.isDigitsOnly(phoneAccount.getAccountHandle().getId())) {
|
|
||||||
final String phoneAccountId = phoneAccount.getAccountHandle().getId();
|
|
||||||
final SubscriptionInfo sir = Utils.findRecordBySubId(context,
|
|
||||||
Integer.parseInt(phoneAccountId));
|
|
||||||
callsSubInfoList.add(sir);
|
callsSubInfoList.add(sir);
|
||||||
} else {
|
} else {
|
||||||
callsSubInfoList.add(null);
|
callsSubInfoList.add(null);
|
||||||
|
Reference in New Issue
Block a user