[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:
@@ -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();
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user