From 74f7c8c90770ff95b0a07e5e731986489120591a Mon Sep 17 00:00:00 2001 From: Junyu Lai Date: Mon, 18 Apr 2022 16:41:54 +0800 Subject: [PATCH] Fix NetworkTemplate generates non-metered carrier template From current design, NetworkPolicyManagerService should only creates metered carrier/mobile templates. However, if someone calls the hidden API interface or the template was created before NetworkTemplate#Builder is published. The caller may create a non-metered carrier template and persist into the storage. This CL elimates this possibility and mark non-metered carrier template non-persistable, so devices could auto-recover from this symptom after reboot. Fix: 222382637 Test: TH Change-Id: I5265e371b0126ce65c32fb09a6e04223afb3d286 --- framework-t/src/android/net/NetworkTemplate.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/framework-t/src/android/net/NetworkTemplate.java b/framework-t/src/android/net/NetworkTemplate.java index 7b5afd7200..b82a126333 100644 --- a/framework-t/src/android/net/NetworkTemplate.java +++ b/framework-t/src/android/net/NetworkTemplate.java @@ -393,8 +393,9 @@ public final class NetworkTemplate implements Parcelable { //constructor passes METERED_YES for these types. this(matchRule, subscriberId, matchSubscriberIds, wifiNetworkKey != null ? new String[] { wifiNetworkKey } : new String[0], - (matchRule == MATCH_MOBILE || matchRule == MATCH_MOBILE_WILDCARD) ? METERED_YES - : METERED_ALL , ROAMING_ALL, DEFAULT_NETWORK_ALL, NETWORK_TYPE_ALL, + (matchRule == MATCH_MOBILE || matchRule == MATCH_MOBILE_WILDCARD + || matchRule == MATCH_CARRIER) ? METERED_YES : METERED_ALL, + ROAMING_ALL, DEFAULT_NETWORK_ALL, NETWORK_TYPE_ALL, OEM_MANAGED_ALL, NetworkStatsUtils.SUBSCRIBER_ID_MATCH_RULE_EXACT); }