summaryrefslogtreecommitdiffstats
path: root/src/com/android/settings/DataUsageSummary.java
diff options
context:
space:
mode:
authorSanket Padawe <sanketpadawe@google.com>2015-01-14 11:03:33 -0800
committerSanket Padawe <sanketpadawe@google.com>2015-01-14 11:03:33 -0800
commitd819270f0f2bc8c2b6583d2986b282d9e8279ab9 (patch)
treee64f0d63d117ba334aa7336a23ffe17dab7eb0c9 /src/com/android/settings/DataUsageSummary.java
parent26310772872b327029cad560fa7b3e797b7980e9 (diff)
downloadpackages_apps_Settings-d819270f0f2bc8c2b6583d2986b282d9e8279ab9.zip
packages_apps_Settings-d819270f0f2bc8c2b6583d2986b282d9e8279ab9.tar.gz
packages_apps_Settings-d819270f0f2bc8c2b6583d2986b282d9e8279ab9.tar.bz2
Fixed data connection toggle UI issue due to local cache maintained.
+ Fixed the scenario wherein more than 1 sim cannot be "On" at the same time. Bug: 18916033 Change-Id: Ia95b54c9ee29d360a1b4542f00a9f698615912bb
Diffstat (limited to 'src/com/android/settings/DataUsageSummary.java')
-rw-r--r--src/com/android/settings/DataUsageSummary.java40
1 files changed, 28 insertions, 12 deletions
diff --git a/src/com/android/settings/DataUsageSummary.java b/src/com/android/settings/DataUsageSummary.java
index 2908829..6de7399 100644
--- a/src/com/android/settings/DataUsageSummary.java
+++ b/src/com/android/settings/DataUsageSummary.java
@@ -279,6 +279,11 @@ public class DataUsageSummary extends HighlightingFragment implements Indexable
private UidDetailProvider mUidDetailProvider;
+ /**
+ * Local cache of data enabled for subId, used to work around delays.
+ */
+ private final Map<String, Boolean> mMobileDataEnabled = new HashMap<String, Boolean>();
+
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
@@ -965,23 +970,18 @@ public class DataUsageSummary extends HighlightingFragment implements Indexable
updatePolicy(false);
}
- /**
- * Local cache of value, used to work around delays.
- */
- private Boolean mMobileDataEnabled;
-
private boolean isMobileDataEnabled(int subId) {
if (LOGD) Log.d(TAG, "isMobileDataEnabled:+ subId=" + subId);
boolean isEnable = false;
- if (mMobileDataEnabled != null) {
- // TODO: deprecate and remove this once enabled flag is on policy
- // Multiple Subscriptions, the value need to be reseted
- isEnable = mMobileDataEnabled.booleanValue();
+ if (mMobileDataEnabled.get(String.valueOf(subId)) != null) {
+ //TODO: deprecate and remove this once enabled flag is on policy
+ //Multiple Subscriptions, the value need to be reseted
+ isEnable = mMobileDataEnabled.get(String.valueOf(subId)).booleanValue();
if (LOGD) {
Log.d(TAG, "isMobileDataEnabled: != null, subId=" + subId
+ " isEnable=" + isEnable);
}
- mMobileDataEnabled = null;
+ mMobileDataEnabled.put(String.valueOf(subId), null);
} else {
// SUB SELECT
isEnable = mTelephonyManager.getDataEnabled(subId);
@@ -996,7 +996,7 @@ public class DataUsageSummary extends HighlightingFragment implements Indexable
private void setMobileDataEnabled(int subId, boolean enabled) {
if (LOGD) Log.d(TAG, "setMobileDataEnabled()");
mTelephonyManager.setDataEnabled(subId, enabled);
- mMobileDataEnabled = enabled;
+ mMobileDataEnabled.put(String.valueOf(subId), enabled);
updatePolicy(false);
}
@@ -1149,6 +1149,16 @@ public class DataUsageSummary extends HighlightingFragment implements Indexable
}
}
+ private void disableDataForOtherSubscriptions(SubscriptionInfo currentSir) {
+ if (mSubInfoList != null) {
+ for (SubscriptionInfo subInfo : mSubInfoList) {
+ if (subInfo.getSubscriptionId() != currentSir.getSubscriptionId()) {
+ setMobileDataEnabled(subInfo.getSubscriptionId(), false);
+ }
+ }
+ }
+ }
+
private View.OnClickListener mDataEnabledListener = new View.OnClickListener() {
@Override
public void onClick(View v) {
@@ -1184,8 +1194,13 @@ public class DataUsageSummary extends HighlightingFragment implements Indexable
// If the device is single SIM or is enabling data on the active data SIM then forgo
// the pop-up.
if (!Utils.showSimCardTile(context) ||
- (nextSir != null && currentSir.getSubscriptionId() == nextSir.getSubscriptionId())) {
+ (nextSir != null && currentSir != null &&
+ currentSir.getSubscriptionId() == nextSir.getSubscriptionId())) {
setMobileDataEnabled(currentSir.getSubscriptionId(), true);
+ if (nextSir != null && currentSir != null &&
+ currentSir.getSubscriptionId() == nextSir.getSubscriptionId()) {
+ disableDataForOtherSubscriptions(currentSir);
+ }
updateBody();
return;
}
@@ -1205,6 +1220,7 @@ public class DataUsageSummary extends HighlightingFragment implements Indexable
public void onClick(DialogInterface dialog, int id) {
mSubscriptionManager.setDefaultDataSubId(currentSir.getSubscriptionId());
setMobileDataEnabled(currentSir.getSubscriptionId(), true);
+ disableDataForOtherSubscriptions(currentSir);
updateBody();
}
});