Protect against missing subscriptions
Bug: 26676464 Change-Id: I428dd60e6774f7ca88423edb7a87e51ee8a7dadd
This commit is contained in:
@@ -77,6 +77,9 @@ public class DataUsageSummary extends DataUsageBase implements Indexable {
|
||||
addPreferencesFromResource(R.xml.data_usage);
|
||||
|
||||
int defaultSubId = getDefaultSubscriptionId(getContext());
|
||||
if (defaultSubId == SubscriptionManager.INVALID_SUBSCRIPTION_ID) {
|
||||
hasMobileData = false;
|
||||
}
|
||||
mDefaultTemplate = getDefaultTemplate(getContext(), defaultSubId);
|
||||
if (hasMobileData) {
|
||||
mLimitPreference = findPreference(KEY_LIMIT_SUMMARY);
|
||||
@@ -279,7 +282,7 @@ public class DataUsageSummary extends DataUsageBase implements Indexable {
|
||||
}
|
||||
|
||||
public static NetworkTemplate getDefaultTemplate(Context context, int defaultSubId) {
|
||||
if (hasMobileData(context)) {
|
||||
if (hasMobileData(context) && defaultSubId != SubscriptionManager.INVALID_SUBSCRIPTION_ID) {
|
||||
TelephonyManager telephonyManager = TelephonyManager.from(context);
|
||||
NetworkTemplate mobileAll = NetworkTemplate.buildTemplateMobileAll(
|
||||
telephonyManager.getSubscriberId(defaultSubId));
|
||||
|
Reference in New Issue
Block a user