Use default network template in billing cycle settings.

- if the network template is not set in the bundle arguments, use the
default network template for getting the billing data.
- change to use ConnectivityManager.from(context) in DataUsageUtils to
be consistent with the usage in other methods.

Change-Id: I25eb27f8f26d9ecafc66aa2c69806e94c6b63499
Fixes: 117452991
Test: make RunSettingsRoboTests
This commit is contained in:
Doris Ling
2018-10-09 17:10:34 -07:00
parent b3eaf62562
commit c4b40b0669
4 changed files with 59 additions and 10 deletions

View File

@@ -73,7 +73,8 @@ public class BillingCycleSettings extends DataUsageBaseFragment implements
static final String KEY_SET_DATA_LIMIT = "set_data_limit";
private static final String KEY_DATA_LIMIT = "data_limit";
private NetworkTemplate mNetworkTemplate;
@VisibleForTesting
NetworkTemplate mNetworkTemplate;
private Preference mBillingCycle;
private Preference mDataWarning;
private SwitchPreference mEnableDataWarning;
@@ -100,10 +101,15 @@ public class BillingCycleSettings extends DataUsageBaseFragment implements
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
mDataUsageController = new DataUsageController(getContext());
final Context context = getContext();
mDataUsageController = new DataUsageController(context);
Bundle args = getArguments();
mNetworkTemplate = args.getParcelable(DataUsageList.EXTRA_NETWORK_TEMPLATE);
if (mNetworkTemplate == null) {
mNetworkTemplate = DataUsageUtils.getDefaultTemplate(context,
DataUsageUtils.getDefaultSubscriptionId(context));
}
mBillingCycle = findPreference(KEY_BILLING_CYCLE);
mEnableDataWarning = (SwitchPreference) findPreference(KEY_SET_DATA_WARNING);

View File

@@ -172,8 +172,7 @@ public final class DataUsageUtils {
return SystemProperties.get(TEST_RADIOS_PROP).contains("wifi");
}
ConnectivityManager connectivityManager =
context.getSystemService(ConnectivityManager.class);
final ConnectivityManager connectivityManager = ConnectivityManager.from(context);
return connectivityManager != null && connectivityManager.isNetworkSupported(TYPE_WIFI);
}