Merge changes Ib7d53620,I2d4c5d64

* changes:
  Add regex metric test
  Fix metrictests build and run failures
diff --git a/libart/src/main/java/dalvik/system/VMRuntime.java b/libart/src/main/java/dalvik/system/VMRuntime.java
index a97d7fc..6171cb6 100644
--- a/libart/src/main/java/dalvik/system/VMRuntime.java
+++ b/libart/src/main/java/dalvik/system/VMRuntime.java
@@ -475,12 +475,6 @@
     public native void clampGrowthLimit();
 
     /**
-     * Returns true if either a Java debugger or native debugger is active.
-     */
-    @FastNative
-    public native boolean isDebuggerActive();
-
-    /**
      * Returns true if native debugging is on.
      */
     @libcore.api.CorePlatformApi
diff --git a/libart/src/main/java/java/lang/Daemons.java b/libart/src/main/java/java/lang/Daemons.java
index 183a588..568614f 100644
--- a/libart/src/main/java/java/lang/Daemons.java
+++ b/libart/src/main/java/java/lang/Daemons.java
@@ -29,6 +29,7 @@
 import libcore.util.EmptyArray;
 
 import dalvik.system.VMRuntime;
+import dalvik.system.VMDebug;
 
 /**
  * Calls Object.finalize() on objects in the finalizer reference queue. The VM
@@ -322,7 +323,7 @@
                     continue;
                 }
                 final Object finalizing = waitForFinalization();
-                if (finalizing != null && !VMRuntime.getRuntime().isDebuggerActive()) {
+                if (finalizing != null && !VMDebug.isDebuggerConnected()) {
                     finalizerTimedOut(finalizing);
                     break;
                 }
diff --git a/luni/src/test/java/libcore/java/net/NetworkInterfaceTest.java b/luni/src/test/java/libcore/java/net/NetworkInterfaceTest.java
index 51c8b04..0547462 100644
--- a/luni/src/test/java/libcore/java/net/NetworkInterfaceTest.java
+++ b/luni/src/test/java/libcore/java/net/NetworkInterfaceTest.java
@@ -16,8 +16,8 @@
 
 package libcore.java.net;
 
-import junit.framework.TestCase;
 
+import android.system.StructIfaddrs;
 import java.io.BufferedReader;
 import java.io.FileDescriptor;
 import java.io.InputStreamReader;
@@ -29,6 +29,7 @@
 import java.net.MulticastSocket;
 import java.net.NetworkInterface;
 import java.net.SocketException;
+import java.util.Arrays;
 import java.util.Collections;
 import java.util.Enumeration;
 import java.util.HashSet;
@@ -37,6 +38,11 @@
 import java.util.regex.Pattern;
 import libcore.io.IoUtils;
 import libcore.io.Libcore;
+import libcore.junit.junit3.TestCaseWithRules;
+import libcore.junit.util.SwitchTargetSdkVersionRule;
+import libcore.junit.util.SwitchTargetSdkVersionRule.TargetSdkVersion;
+import org.junit.Rule;
+import org.junit.rules.TestRule;
 
 import static android.system.OsConstants.AF_INET;
 import static android.system.OsConstants.IFF_LOOPBACK;
@@ -47,7 +53,10 @@
 import static android.system.OsConstants.SOCK_DGRAM;
 import static java.net.NetworkInterface.getNetworkInterfaces;
 
-public class NetworkInterfaceTest extends TestCase {
+public class NetworkInterfaceTest extends TestCaseWithRules {
+    @Rule
+    public TestRule switchTargetSdkVersionRule = SwitchTargetSdkVersionRule.getInstance();
+
     // http://code.google.com/p/android/issues/detail?id=13784
     private final static int ARPHRD_ETHER = 1; // from if_arp.h
     public void testIPv6() throws Exception {
@@ -100,7 +109,6 @@
             }
             // Ethernet
             if (isEthernet(nif.getName())) {
-                assertEquals(6, nif.getHardwareAddress().length);
                 for (InterfaceAddress ia : nif.getInterfaceAddresses()) {
                     if (ia.getAddress() instanceof Inet4Address) {
                         assertNotNull(ia.getBroadcast());
@@ -110,6 +118,24 @@
         }
     }
 
+    @TargetSdkVersion(29)
+    public void testGetHardwareAddress_compat_returnsHardwareAddress() throws Exception {
+        // Ensure apps with a targetSdk version <= 29 are able to access the MAC address of ethernet
+        // devices.
+        for (NetworkInterface nif : Collections.list(getNetworkInterfaces())) {
+            if (isEthernet(nif.getName())) {
+                assertEquals(6, nif.getHardwareAddress().length);
+            }
+        }
+    }
+
+    public void testGetHardwareAddress_returnsNull() throws Exception {
+        // Hardware addresses should be unavailable to non-system apps.
+        for (NetworkInterface nif : Collections.list(getNetworkInterfaces())) {
+            assertNull(nif.getHardwareAddress());
+        }
+    }
+
     public void testLoopback() throws Exception {
         NetworkInterface lo = NetworkInterface.getByName("lo");
         assertNull(lo.getHardwareAddress());
@@ -201,31 +227,16 @@
         } catch(SocketException expected) {}
     }
 
-    // b/29243557
-    public void testGetNetworkInterfaces() throws Exception {
-        // Check that the interfaces we get from #getNetworkInterfaces agrees with IP-LINK(8).
+    public void testGetNetworkInterfaces_matchesIfaddrs() throws Exception {
+        StructIfaddrs[] ifaddrs = Libcore.os.getifaddrs();
+        Set<String> ifaddrsNames = new HashSet<>();
+        Arrays.asList(ifaddrs).forEach(ifa -> ifaddrsNames.add(ifa.ifa_name));
 
-        // Parse output of ip link.
-        String[] cmd = { "ip", "link" };
-        Process proc = Runtime.getRuntime().exec(cmd);
-        BufferedReader stdInput = new BufferedReader(new InputStreamReader(proc.getInputStream()));
-        Set<String> expectedNiNames = new HashSet<>();
-        for (String s; (s = stdInput.readLine()) != null; ) {
-            String[] split = s.split(": |@");
-            try {
-                if (split.length > 2) {
-                    expectedNiNames.add(split[1]);
-                }
-            } catch (NumberFormatException e) {
-                // Skip this line.
-            }
-        }
-
-        Enumeration<NetworkInterface> nifs = NetworkInterface.getNetworkInterfaces();
+        List<NetworkInterface> nifs = Collections.list(NetworkInterface.getNetworkInterfaces());
         Set<String> actualNiNames = new HashSet<>();
-        Collections.list(nifs).forEach(ni -> actualNiNames.add(ni.getName()));
+        nifs.forEach(ni -> actualNiNames.add(ni.getName()));
 
-        assertEquals(expectedNiNames, actualNiNames);
+        assertEquals(ifaddrsNames, actualNiNames);
     }
 
     // Calling getSubInterfaces on interfaces with no subinterface should not throw NPE.
diff --git a/ojluni/src/main/java/java/net/NetworkInterface.java b/ojluni/src/main/java/java/net/NetworkInterface.java
index eab09ab..673a1d2 100644
--- a/ojluni/src/main/java/java/net/NetworkInterface.java
+++ b/ojluni/src/main/java/java/net/NetworkInterface.java
@@ -37,9 +37,6 @@
 import java.util.Map;
 import java.util.NoSuchElementException;
 
-import android.compat.annotation.ChangeId;
-import android.compat.Compatibility;
-import android.system.Os;
 import android.system.StructIfaddrs;
 import libcore.io.IoUtils;
 import libcore.io.Libcore;
@@ -61,21 +58,6 @@
  * @since 1.4
  */
 public final class NetworkInterface {
-    // BEGIN Android-added: Return anonymized device address to non-system processes.
-    /**
-     * Gates whether calls to {@link #getHardwareAddress()} made by non-system processes
-     * to return the actual MAC address (pre-change behavior) or an anonymized MAC address
-     * (post-change behavior). Future versions of Android will enforce the post-change
-     * behavior through SELinux.
-     */
-    @ChangeId
-    static final long ANONYMIZED_DEVICE_ADDRESS_CHANGE_ID = 141455849L;
-    // This is used instead of the own device MAC.
-    private static final byte[] ANONYMIZED_DEVICE_ADDRESS = {0x02, 0x00, 0x00, 0x00, 0x00, 0x00};
-    // First UID of non-system applications. See {@code android.os.Process.FIRST_APPLICATION_UID}.
-    private static final int FIRST_APPLICATION_UID = 10000;
-    // END Android-added: Return anonymized device address to non-system processes.
-
     private String name;
     private String displayName;
     private int index;
@@ -569,23 +551,8 @@
         if (ni == null) {
             throw new SocketException("NetworkInterface doesn't exist anymore");
         }
+        return ni.hardwareAddr;
         // END Android-changed: Fix upstream not returning link-down interfaces. http://b/26238832
-        // BEGIN Android-changed: Return anonymized device address to non-system processes.
-        if (!Compatibility.isChangeEnabled(ANONYMIZED_DEVICE_ADDRESS_CHANGE_ID)) {
-            return ni.hardwareAddr;
-        } else {
-            if (ni.hardwareAddr == null) {
-                // MAC address does not exist or is not accessible.
-                return null;
-            }
-            if (Os.getuid() < FIRST_APPLICATION_UID) {
-                // This is a system process. Return the actual MAC address.
-                return ni.hardwareAddr;
-            } else {
-                return ANONYMIZED_DEVICE_ADDRESS;
-            }
-        }
-        // END Android-changed: Return anonymized device address to non-system processes.
     }
 
     /**