[MS50] Remove NetworkTemplate#buildTemplate* usages

This is a no-op refactoring.
These functions are deprecated and replaced by
NetworkTemplate#Builder, use public API instead.

Test: make RunSettingsLibRoboTests
Bug: 204830222
Change-Id: Idc2a09d8e3789ca2c7a97691cfad4b2e2b417f0d
This commit is contained in:
Junyu Lai
2022-01-10 13:26:04 +00:00
parent a4f936408c
commit 123f2e1581
14 changed files with 53 additions and 56 deletions

View File

@@ -17,6 +17,7 @@
package com.android.settings.datausage.lib;
import android.content.Context;
import android.net.NetworkStats;
import android.net.NetworkTemplate;
import android.telephony.SubscriptionInfo;
import android.telephony.SubscriptionManager;
@@ -26,6 +27,7 @@ import android.util.Log;
import com.android.internal.util.ArrayUtils;
import java.util.List;
import java.util.Set;
/**
* Lib class for data usage
@@ -71,12 +73,17 @@ public class DataUsageLib {
return NetworkTemplate.normalize(mobileTemplate, mergedSubscriberIds);
}
private static NetworkTemplate getMobileTemplateForSubId(
public static NetworkTemplate getMobileTemplateForSubId(
TelephonyManager telephonyManager, int subId) {
// The null subscriberId means that no any mobile/carrier network will be matched.
// Using old API: buildTemplateMobileAll for the null subscriberId to avoid NPE.
// Create template that matches any mobile network when the subscriberId is null.
String subscriberId = telephonyManager.getSubscriberId(subId);
return subscriberId != null ? NetworkTemplate.buildTemplateCarrierMetered(subscriberId)
: NetworkTemplate.buildTemplateMobileAll(subscriberId);
return subscriberId != null
? new NetworkTemplate.Builder(NetworkTemplate.MATCH_CARRIER)
.setSubscriberIds(Set.of(subscriberId))
.setMeteredness(NetworkStats.METERED_YES)
.build()
: new NetworkTemplate.Builder(NetworkTemplate.MATCH_MOBILE)
.setMeteredness(NetworkStats.METERED_YES)
.build();
}
}