Merge "[Settings] Fix DataUsageUtilsTest" into rvc-dev
This commit is contained in:
@@ -95,8 +95,8 @@ public class DataUsageSummary extends DataUsageBaseFragment implements DataUsage
|
||||
boolean hasWifiRadio = DataUsageUtils.hasWifiRadio(context);
|
||||
if (hasMobileData) {
|
||||
addMobileSection(defaultSubId);
|
||||
if (DataUsageUtils.hasSim(context) && hasWifiRadio) {
|
||||
// If the device has a SIM installed, the data usage section shows usage for mobile,
|
||||
if (hasActiveSubscription() && hasWifiRadio) {
|
||||
// If the device has active SIM, the data usage section shows usage for mobile,
|
||||
// and the WiFi section is added if there is a WiFi radio - legacy behavior.
|
||||
addWifiSection();
|
||||
}
|
||||
@@ -156,6 +156,13 @@ public class DataUsageSummary extends DataUsageBaseFragment implements DataUsage
|
||||
mProxySubscriptionMgr.setLifecycle(getLifecycle());
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
boolean hasActiveSubscription() {
|
||||
final List<SubscriptionInfo> subInfoList =
|
||||
mProxySubscriptionMgr.getActiveSubscriptionsInfo();
|
||||
return ((subInfoList != null) && (subInfoList.size() > 0));
|
||||
}
|
||||
|
||||
private void addMobileSection(int subId, SubscriptionInfo subInfo) {
|
||||
TemplatePreferenceCategory category = (TemplatePreferenceCategory)
|
||||
inflatePreferences(R.xml.data_usage_cellular);
|
||||
|
@@ -151,22 +151,6 @@ public final class DataUsageUtils extends com.android.settingslib.net.DataUsageU
|
||||
return connectivityManager != null && connectivityManager.isNetworkSupported(TYPE_WIFI);
|
||||
}
|
||||
|
||||
public static boolean hasSim(Context context) {
|
||||
// Access cache within ProxySubscriptionManager to speed up
|
||||
final List<SubscriptionInfo> subInfoList =
|
||||
ProxySubscriptionManager.getInstance(context)
|
||||
.getActiveSubscriptionsInfo();
|
||||
if ((subInfoList != null) && (subInfoList.size() > 0)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
TelephonyManager telephonyManager = context.getSystemService(TelephonyManager.class);
|
||||
final int simState = telephonyManager.getSimState();
|
||||
// Note that pulling the SIM card returns UNKNOWN, not ABSENT.
|
||||
return simState != TelephonyManager.SIM_STATE_ABSENT
|
||||
&& simState != TelephonyManager.SIM_STATE_UNKNOWN;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the default subscription if available else returns
|
||||
* SubscriptionManager#INVALID_SUBSCRIPTION_ID
|
||||
|
Reference in New Issue
Block a user