Added cellular data popup in DataUsage
+ If the user attempts to enable data usage on a SIM that is not the
default, the system will confirm that the user wants data to go through
the new SIM.
Change-Id: Ia1652a30a3641bb29eadad20b2dc61321227a961
diff --git a/res/values/strings.xml b/res/values/strings.xml
index f8721c3..edbf03c 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -2114,6 +2114,10 @@
<string name="sim_multi_sims_title">Multiple SIMs found</string>
<!-- Multiple SIMs found summary. [CHAR LIMIT=100] -->
<string name="sim_multi_sims_summary">Choose the SIM you prefer for cellular data.</string>
+ <!-- Title asking user if they wish to change the default sim for cellular data. [CHAR LIMIT=30] -->
+ <string name="sim_change_data_title">Change data SIM?</string>
+ <!-- Message confirming the user wishes to change the default data SIM from one to another. [CHAR LIMIT=NONE] -->
+ <string name="sim_change_data_message">Use <xliff:g id="new_sim">%1$s</xliff:g> instead of <xliff:g id="old_sim">%2$s</xliff:g> for cellular data?</string>
<!-- Instructions telling the user that they entered the wrong SIM PIN for the last time.
Displayed in a dialog box. [CHAR LIMIT=100] -->
diff --git a/src/com/android/settings/DataUsageSummary.java b/src/com/android/settings/DataUsageSummary.java
index 6ee0ef0..6ad1b9c 100644
--- a/src/com/android/settings/DataUsageSummary.java
+++ b/src/com/android/settings/DataUsageSummary.java
@@ -1112,7 +1112,12 @@
final String currentTab = mCurrentTab;
if (isMobileTab(currentTab)) {
if (dataEnabled) {
- setMobileDataEnabled(true);
+ // If we are showing the Sim Card tile then we are a Multi-Sim device.
+ if (Utils.showSimCardTile(getActivity())) {
+ handleMultiSimDataDialog();
+ } else {
+ setMobileDataEnabled(true);
+ }
} else {
// disabling data; show confirmation dialog which eventually
// calls setMobileDataEnabled() once user confirms.
@@ -1124,6 +1129,36 @@
}
};
+ private void handleMultiSimDataDialog() {
+ final SubInfoRecord currentSir = getCurrentTabSubInfo(getActivity());
+ final SubInfoRecord nextSir = SubscriptionManager.getSubInfoForSubscriber(
+ SubscriptionManager.getDefaultDataSubId());
+
+ if (currentSir.subId == nextSir.subId) {
+ setMobileDataEnabled(true);
+ updateBody();
+ return;
+ }
+
+ AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
+
+ builder.setTitle(R.string.sim_change_data_title);
+ builder.setMessage(getActivity().getResources().getString(R.string.sim_change_data_message,
+ currentSir.displayName, nextSir.displayName));
+
+ builder.setPositiveButton(R.string.okay, new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog, int id) {
+ SubscriptionManager.setDefaultDataSubId(currentSir.subId);
+ setMobileDataEnabled(true);
+ updateBody();
+ }
+ });
+ builder.setNegativeButton(R.string.cancel, null);
+
+ builder.create().show();
+ }
+
private View.OnClickListener mDisableAtLimitListener = new View.OnClickListener() {
@Override
public void onClick(View v) {
@@ -2553,7 +2588,7 @@
private void addMobileTab(Context context, List<SubInfoRecord> subInfoList) {
if (subInfoList != null) {
for (SubInfoRecord subInfo : mSubInfoList) {
- if (hasReadyMobileRadio(context,subInfo.subId)) {
+ if (hasReadyMobileRadio(context, subInfo.subId)) {
mTabHost.addTab(buildTabSpec(mMobileTagMap.get(subInfo.subId),
subInfo.displayName));
}
@@ -2561,6 +2596,21 @@
}
}
+ private SubInfoRecord getCurrentTabSubInfo(Context context) {
+ if (mSubInfoList != null && mTabHost != null) {
+ final int currentTagIndex = mTabHost.getCurrentTab();
+ int i = 0;
+ for (SubInfoRecord subInfo : mSubInfoList) {
+ if (hasReadyMobileRadio(context, subInfo.subId)) {
+ if (i++ == currentTagIndex) {
+ return subInfo;
+ }
+ }
+ }
+ }
+ return null;
+ }
+
/**
* Init a map with subId key and mobile tag name
* @param subInfoList The subscription Info List