From d909dadc8ddd83c1597426ebc187ee840f04588c Mon Sep 17 00:00:00 2001 From: Patrick Rohr Date: Wed, 11 Jun 2025 13:14:54 -0700 Subject: [PATCH] Change mIfaceMatch to precompiled Pattern See ag/33952010. Test: TH Flag: EXEMPT mainline Bug: 1000001 Change-Id: I29694e9b60a24f21290f903760dc96cb679b46e2 --- .../src/com/android/server/ethernet/EthernetTracker.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/service-t/src/com/android/server/ethernet/EthernetTracker.java b/service-t/src/com/android/server/ethernet/EthernetTracker.java index 51bf00cae8..fe608683b5 100644 --- a/service-t/src/com/android/server/ethernet/EthernetTracker.java +++ b/service-t/src/com/android/server/ethernet/EthernetTracker.java @@ -131,7 +131,7 @@ public class EthernetTracker { * Use shouldTrackInterface to check if a interface name is a valid ethernet interface (this * includes test interfaces if setIncludeTestInterfaces is set to true). */ - private final String mIfaceMatch; + private final Pattern mIfaceMatch; /** * Track test interfaces if true, don't track otherwise. @@ -311,7 +311,7 @@ public class EthernetTracker { ifaceMatchRegex = "eth\\d+"; } } - mIfaceMatch = ifaceMatchRegex; + mIfaceMatch = Pattern.compile(ifaceMatchRegex); // Read default Ethernet interface configuration from resources final String[] interfaceConfigs = mDeps.getInterfaceConfigFromResource(context); @@ -829,7 +829,7 @@ public class EthernetTracker { } private boolean shouldTrackInterface(String iface) { - return iface.matches(mIfaceMatch) || isValidTestInterface(iface); + return mIfaceMatch.matcher(iface).matches() || isValidTestInterface(iface); } /**