Added Cellular Data for Multi-Sim Data Usage

+ Bug Fix: SimSettings would crash if a SIM was not in the first slot.

Change-Id: Iee75ea78dde72dc7d2d588caff1ddd451347a8f5
This commit is contained in:
PauloftheWest
2014-10-28 08:30:05 -07:00
parent 917aaf9ebd
commit 98523c8b8b
2 changed files with 28 additions and 10 deletions

View File

@@ -941,7 +941,8 @@ public class DataUsageSummary extends HighlightingFragment implements Indexable
mMobileDataEnabled = null; mMobileDataEnabled = null;
} else { } else {
//SUB SELECT //SUB SELECT
isEnable = mTelephonyManager.getDataEnabled() && isMobileDataAvailable(subId); isEnable = mTelephonyManager.getDataEnabled()
&& (subId == SubscriptionManager.getDefaultDataSubId());
} }
return isEnable; return isEnable;
} }
@@ -2594,8 +2595,21 @@ public class DataUsageSummary extends HighlightingFragment implements Indexable
} }
//SUB SELECT //SUB SELECT
private boolean isMobileDataAvailable(int subId) { private boolean isMobileDataAvailable(long subId) {
int[] subIds = SubscriptionManager.getSubId(PhoneConstants.SUB1); int[] subIds = SubscriptionManager.getSubId(PhoneConstants.SUB1);
return subIds[0] == subId; if (subIds != null && subIds[0] == subId) {
return true;
}
subIds = SubscriptionManager.getSubId(PhoneConstants.SUB2);
if (subIds != null && subIds[0] == subId) {
return true;
}
subIds = SubscriptionManager.getSubId(PhoneConstants.SUB3);
if (subIds != null && subIds[0] == subId) {
return true;
}
return false;
} }
} }

View File

@@ -121,9 +121,11 @@ public class SimSettings extends RestrictedSettingsFragment implements Indexable
* By UX design we use only one Subscription Information(SubInfo) record per SIM slot. * By UX design we use only one Subscription Information(SubInfo) record per SIM slot.
* mAvalableSubInfos is the list of SubInfos we present to the user. * mAvalableSubInfos is the list of SubInfos we present to the user.
* mSubInfoList is the list of all SubInfos. * mSubInfoList is the list of all SubInfos.
* mSelectableSubInfos is the list of SubInfos that a user can select for data, calls, and SMS.
*/ */
private List<SubInfoRecord> mAvailableSubInfos = null; private List<SubInfoRecord> mAvailableSubInfos = null;
private List<SubInfoRecord> mSubInfoList = null; private List<SubInfoRecord> mSubInfoList = null;
private List<SubInfoRecord> mSelectableSubInfos = null;
private SubInfoRecord mCellularData = null; private SubInfoRecord mCellularData = null;
private SubInfoRecord mCalls = null; private SubInfoRecord mCalls = null;
@@ -186,6 +188,7 @@ public class SimSettings extends RestrictedSettingsFragment implements Indexable
final int numSlots = tm.getSimCount(); final int numSlots = tm.getSimCount();
mAvailableSubInfos = new ArrayList<SubInfoRecord>(numSlots); mAvailableSubInfos = new ArrayList<SubInfoRecord>(numSlots);
mSelectableSubInfos = new ArrayList<SubInfoRecord>();
mNumSims = 0; mNumSims = 0;
for (int i = 0; i < numSlots; ++i) { for (int i = 0; i < numSlots; ++i) {
final SubInfoRecord sir = findRecordBySlotId(i); final SubInfoRecord sir = findRecordBySlotId(i);
@@ -193,6 +196,7 @@ public class SimSettings extends RestrictedSettingsFragment implements Indexable
mAvailableSubInfos.add(sir); mAvailableSubInfos.add(sir);
if (sir != null) { if (sir != null) {
mNumSims++; mNumSims++;
mSelectableSubInfos.add(sir);
} }
} }
@@ -345,7 +349,7 @@ public class SimSettings extends RestrictedSettingsFragment implements Indexable
@Override @Override
public Dialog onCreateDialog(final int id) { public Dialog onCreateDialog(final int id) {
final ArrayList<String> list = new ArrayList<String>(); final ArrayList<String> list = new ArrayList<String>();
final int availableSubInfoLength = mAvailableSubInfos.size(); final int selectableSubInfoLength = mSelectableSubInfos.size();
final DialogInterface.OnClickListener selectionListener = final DialogInterface.OnClickListener selectionListener =
new DialogInterface.OnClickListener() { new DialogInterface.OnClickListener() {
@@ -355,18 +359,18 @@ public class SimSettings extends RestrictedSettingsFragment implements Indexable
final SubInfoRecord sir; final SubInfoRecord sir;
if (id == DATA_PICK) { if (id == DATA_PICK) {
sir = mAvailableSubInfos.get(value); sir = mSelectableSubInfos.get(value);
SubscriptionManager.setDefaultDataSubId(sir.subId); SubscriptionManager.setDefaultDataSubId(sir.subId);
} else if (id == CALLS_PICK) { } else if (id == CALLS_PICK) {
if (value != 0) { if (value != 0) {
sir = mAvailableSubInfos.get(value -1); sir = mSelectableSubInfos.get(value -1);
SubscriptionManager.setDefaultVoiceSubId(sir.subId); SubscriptionManager.setDefaultVoiceSubId(sir.subId);
} else { } else {
SubscriptionManager SubscriptionManager
.setDefaultVoiceSubId(SubscriptionManager.ASK_USER_SUB_ID); .setDefaultVoiceSubId(SubscriptionManager.ASK_USER_SUB_ID);
} }
} else if (id == SMS_PICK) { } else if (id == SMS_PICK) {
sir = mAvailableSubInfos.get(value); sir = mSelectableSubInfos.get(value);
SubscriptionManager.setDefaultSmsSubId(sir.subId); SubscriptionManager.setDefaultSmsSubId(sir.subId);
} }
@@ -377,12 +381,12 @@ public class SimSettings extends RestrictedSettingsFragment implements Indexable
if (id == CALLS_PICK) { if (id == CALLS_PICK) {
list.add(getResources().getString(R.string.sim_calls_ask_first_prefs_title)); list.add(getResources().getString(R.string.sim_calls_ask_first_prefs_title));
} }
for (int i = 0; i < availableSubInfoLength; ++i) { for (int i = 0; i < selectableSubInfoLength; ++i) {
final SubInfoRecord sir = mAvailableSubInfos.get(i); final SubInfoRecord sir = mSelectableSubInfos.get(i);
list.add(sir.displayName); list.add(sir.displayName);
} }
String[] arr = new String[availableSubInfoLength]; String[] arr = new String[selectableSubInfoLength];
arr = list.toArray(arr); arr = list.toArray(arr);
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());