From d8fdea1c6eb0a27dd82912425d7a51894a371f3b Mon Sep 17 00:00:00 2001 From: Varun Anand Date: Sun, 17 Feb 2019 23:15:15 -0800 Subject: [PATCH] Add unit tests related to data accounting for VPNs with one underlying network. This is to establish a baseline for the existing behavior, and to ensure that following changes are not causing a regression in existing behavior. This CL is also adding missing cleanup for NetworkStatsCollectionTest which was forcing all network types in NetworkTemplate that was causing NetworkStatsService related tests to fail. Bug: 113122541 Bug: 120145746 Test: atest FrameworksNetTests Change-Id: I285f186cfb16bc9fa704c797996b1e4f8a73dee4 --- core/java/android/net/NetworkTemplate.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/core/java/android/net/NetworkTemplate.java b/core/java/android/net/NetworkTemplate.java index bb75c63436..60ae352d5c 100644 --- a/core/java/android/net/NetworkTemplate.java +++ b/core/java/android/net/NetworkTemplate.java @@ -40,6 +40,7 @@ import android.os.Parcelable; import android.util.BackupUtils; import android.util.Log; +import com.android.internal.annotations.VisibleForTesting; import com.android.internal.util.ArrayUtils; import java.io.ByteArrayOutputStream; @@ -89,10 +90,22 @@ public class NetworkTemplate implements Parcelable { private static boolean sForceAllNetworkTypes = false; + /** + * Results in matching against all mobile network types. + * + *

See {@link #matchesMobile} and {@link matchesMobileWildcard}. + */ + @VisibleForTesting public static void forceAllNetworkTypes() { sForceAllNetworkTypes = true; } + /** Resets the affect of {@link #forceAllNetworkTypes}. */ + @VisibleForTesting + public static void resetForceAllNetworkTypes() { + sForceAllNetworkTypes = false; + } + /** * Template to match {@link ConnectivityManager#TYPE_MOBILE} networks with * the given IMSI.