[Settings] Fix DataUsageUtilsTest

Fix DataUsageUtilsTest

Bug: 154564365
Test: make RunSettingsRoboTests -j ROBOTEST_FILTER=DataUsageUtilsTest
Test: make RunSettingsRoboTests -j ROBOTEST_FILTER=DataUsageSummaryTest
Change-Id: Iff614135dfb0015deb5220fbf7f9338322def507
This commit is contained in:
Bonian Chen
2020-04-24 10:43:42 +08:00
parent 4908511b17
commit 76627e415d
4 changed files with 13 additions and 35 deletions

View File

@@ -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);