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
This commit is contained in:
@@ -279,6 +279,11 @@ public class DataUsageSummary extends HighlightingFragment implements Indexable
|
|||||||
|
|
||||||
private UidDetailProvider mUidDetailProvider;
|
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
|
@Override
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
@@ -965,23 +970,18 @@ public class DataUsageSummary extends HighlightingFragment implements Indexable
|
|||||||
updatePolicy(false);
|
updatePolicy(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Local cache of value, used to work around delays.
|
|
||||||
*/
|
|
||||||
private Boolean mMobileDataEnabled;
|
|
||||||
|
|
||||||
private boolean isMobileDataEnabled(int subId) {
|
private boolean isMobileDataEnabled(int subId) {
|
||||||
if (LOGD) Log.d(TAG, "isMobileDataEnabled:+ subId=" + subId);
|
if (LOGD) Log.d(TAG, "isMobileDataEnabled:+ subId=" + subId);
|
||||||
boolean isEnable = false;
|
boolean isEnable = false;
|
||||||
if (mMobileDataEnabled != null) {
|
if (mMobileDataEnabled.get(String.valueOf(subId)) != null) {
|
||||||
// TODO: deprecate and remove this once enabled flag is on policy
|
//TODO: deprecate and remove this once enabled flag is on policy
|
||||||
// Multiple Subscriptions, the value need to be reseted
|
//Multiple Subscriptions, the value need to be reseted
|
||||||
isEnable = mMobileDataEnabled.booleanValue();
|
isEnable = mMobileDataEnabled.get(String.valueOf(subId)).booleanValue();
|
||||||
if (LOGD) {
|
if (LOGD) {
|
||||||
Log.d(TAG, "isMobileDataEnabled: != null, subId=" + subId
|
Log.d(TAG, "isMobileDataEnabled: != null, subId=" + subId
|
||||||
+ " isEnable=" + isEnable);
|
+ " isEnable=" + isEnable);
|
||||||
}
|
}
|
||||||
mMobileDataEnabled = null;
|
mMobileDataEnabled.put(String.valueOf(subId), null);
|
||||||
} else {
|
} else {
|
||||||
// SUB SELECT
|
// SUB SELECT
|
||||||
isEnable = mTelephonyManager.getDataEnabled(subId);
|
isEnable = mTelephonyManager.getDataEnabled(subId);
|
||||||
@@ -996,7 +996,7 @@ public class DataUsageSummary extends HighlightingFragment implements Indexable
|
|||||||
private void setMobileDataEnabled(int subId, boolean enabled) {
|
private void setMobileDataEnabled(int subId, boolean enabled) {
|
||||||
if (LOGD) Log.d(TAG, "setMobileDataEnabled()");
|
if (LOGD) Log.d(TAG, "setMobileDataEnabled()");
|
||||||
mTelephonyManager.setDataEnabled(subId, enabled);
|
mTelephonyManager.setDataEnabled(subId, enabled);
|
||||||
mMobileDataEnabled = enabled;
|
mMobileDataEnabled.put(String.valueOf(subId), enabled);
|
||||||
updatePolicy(false);
|
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() {
|
private View.OnClickListener mDataEnabledListener = new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
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
|
// If the device is single SIM or is enabling data on the active data SIM then forgo
|
||||||
// the pop-up.
|
// the pop-up.
|
||||||
if (!Utils.showSimCardTile(context) ||
|
if (!Utils.showSimCardTile(context) ||
|
||||||
(nextSir != null && currentSir.getSubscriptionId() == nextSir.getSubscriptionId())) {
|
(nextSir != null && currentSir != null &&
|
||||||
|
currentSir.getSubscriptionId() == nextSir.getSubscriptionId())) {
|
||||||
setMobileDataEnabled(currentSir.getSubscriptionId(), true);
|
setMobileDataEnabled(currentSir.getSubscriptionId(), true);
|
||||||
|
if (nextSir != null && currentSir != null &&
|
||||||
|
currentSir.getSubscriptionId() == nextSir.getSubscriptionId()) {
|
||||||
|
disableDataForOtherSubscriptions(currentSir);
|
||||||
|
}
|
||||||
updateBody();
|
updateBody();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -1205,6 +1220,7 @@ public class DataUsageSummary extends HighlightingFragment implements Indexable
|
|||||||
public void onClick(DialogInterface dialog, int id) {
|
public void onClick(DialogInterface dialog, int id) {
|
||||||
mSubscriptionManager.setDefaultDataSubId(currentSir.getSubscriptionId());
|
mSubscriptionManager.setDefaultDataSubId(currentSir.getSubscriptionId());
|
||||||
setMobileDataEnabled(currentSir.getSubscriptionId(), true);
|
setMobileDataEnabled(currentSir.getSubscriptionId(), true);
|
||||||
|
disableDataForOtherSubscriptions(currentSir);
|
||||||
updateBody();
|
updateBody();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
Reference in New Issue
Block a user