Revert "Return anonymized MAC for apps targeting SDK < 30"

Revert "Soft-enable MAC address restrictions with allowlist."

Revert "Updates CTS tests for MAC address restrictions."

Revert submission 1518603-soft-restrict-mac

Reason for revert: Missing type check
Reverted Changes:
I0488932de:Soft-enable MAC address restrictions with allowlis...
Idb9d940e4:Updates CTS tests for MAC address restrictions.
I9461f287e:Return anonymized MAC for apps targeting SDK < 30

Change-Id: If2f98118938438a9fb9fad8400bc9cbf6aea6e4f
(cherry picked from commit 7753e032362c9ddc25ac56ac4dbc8b71f4f28127)
diff --git a/ojluni/src/main/java/java/net/NetworkInterface.java b/ojluni/src/main/java/java/net/NetworkInterface.java
index 587d19b..e56e0cb 100644
--- a/ojluni/src/main/java/java/net/NetworkInterface.java
+++ b/ojluni/src/main/java/java/net/NetworkInterface.java
@@ -37,11 +37,7 @@
 import java.util.Map;
 import java.util.NoSuchElementException;
 
-import android.compat.Compatibility;
-import android.compat.annotation.ChangeId;
-import android.compat.annotation.EnabledSince;
 import android.system.StructIfaddrs;
-import dalvik.annotation.compat.VersionCodes;
 import libcore.io.IoUtils;
 import libcore.io.Libcore;
 import sun.security.action.*;
@@ -51,7 +47,7 @@
 
 // Android-note: NetworkInterface has been rewritten to avoid native code.
 // Fix upstream bug not returning link-down interfaces. http://b/26238832
-// Android-added: Document restrictions for non-system apps. http://b/170188668
+// Android-added: Document restrictions for targetSdkVersion >= R. http://b/141455849
 /**
  * This class represents a Network Interface made up of a name,
  * and a list of IP addresses assigned to this interface.
@@ -62,28 +58,13 @@
  * <p>
  * <a name="access-restrictions"></a>Note that information about
  * {@link NetworkInterface}s may be restricted. For example, non-system apps
- * will only have access to information about {@link NetworkInterface}s that are
+ * with {@code targetSdkVersion >= android.os.Build.VERSION_CODES.R} will only
+ * have access to information about {@link NetworkInterface}s that are
  * associated with an {@link InetAddress}.
  *
  * @since 1.4
  */
 public final class NetworkInterface {
-    // Android-added: Anonymized address for apps targeting old API versions. http://b/170188668
-    /**
-     * If this change is enabled, {@link #getHardwareAddress()} returns null when the hardware
-     * address is <a href="#access-restrictions">inaccessible</a>. If the change is disabled, the
-     * default MAC address (02:00:00:00:00:00) is returned instead.
-     */
-    @ChangeId
-    @EnabledSince(targetSdkVersion=VersionCodes.R)
-    static final long RETURN_NULL_HARDWARE_ADDRESS = 170188668L;
-    // The default hardware address is a zeroed-out MAC address with only its
-    // locally-administered bit set, returned to apps targeting older API versions if they would
-    // otherwise see a null MAC address.
-    // Matches android.net.wifi.WifiInfo.DEFAULT_MAC_ADDRESS
-    private static final byte[] DEFAULT_MAC_ADDRESS = {
-        0x02, 0x00, 0x00, 0x00, 0x00, 0x00 };
-
     private String name;
     private String displayName;
     private int index;
@@ -291,7 +272,7 @@
         return "".equals(displayName) ? null : displayName;
     }
 
-    // Android-added: Document restrictions for non-system apps. http://b/170188668
+    // Android-added: Document restrictions for targetSdkVersion >= R. http://b/141455849
     /**
      * Searches for the network interface with the specified name.
      *
@@ -323,7 +304,7 @@
         return null;
     }
 
-    // Android-added: Document restrictions for non-system apps. http://b/170188668
+    // Android-added: Document restrictions for targetSdkVersion >= R. http://b/141455849
     /**
      * Get a network interface given its index.
      *
@@ -392,7 +373,7 @@
         return null;
     }
 
-    // Android-added: Document restrictions for non-system apps. http://b/170188668
+    // Android-added: Document restrictions for targetSdkVersion >= R. http://b/141455849
     /**
      * Returns all the interfaces on this machine. The {@code Enumeration}
      * contains at least one element, possibly representing a loopback
@@ -402,8 +383,10 @@
      * NOTE: can use getNetworkInterfaces()+getInetAddresses()
      *       to obtain all IP addresses for this node
      * <p>
-     * For non-system apps, this method will only return information for
-     * {@link NetworkInterface}s associated with an {@link InetAddress}.
+     * For non-system apps with
+     * {@code targetSdkVersion >= android.os.Build.VERSION_CODES.R}, this
+     * method will only return information for {@link NetworkInterface}s that
+     * are associated with an {@link InetAddress}.
      *
      * @return an Enumeration of NetworkInterfaces found on this machine
      *         that <a href="#access-restrictions">are accessible</a>.
@@ -579,7 +562,7 @@
         return (getFlags() & IFF_MULTICAST) != 0;
     }
 
-    // Android-added: Restrictions for non-system apps. http://b/170188668
+    // Android-added: Document restrictions for targetSdkVersion >= R. http://b/141455849
     /**
      * Returns the hardware address (usually MAC) of the interface if it
      * has one and if it can be accessed given the current privileges.
@@ -591,8 +574,8 @@
      *          manager is set and the caller does not have the permission
      *          NetPermission("getNetworkInformation"). For example, this
      *          method will generally return {@code null} when called by
-     *          non-system apps (or 02:00:00:00:00:00 for apps having
-     *          {@code targetSdkVersion < android.os.Build.VERSION_CODES.R}).
+     *          non-system apps having
+     *          {@code targetSdkVersion >= android.os.Build.VERSION_CODES.R}.
      *
      * @exception       SocketException if an I/O error occurs.
      * @since 1.6
@@ -611,12 +594,6 @@
         if (ni == null) {
             throw new SocketException("NetworkInterface doesn't exist anymore");
         }
-        // Return 02:00:00:00:00:00 for apps having a target SDK version < R if they would have
-        // otherwise gotten a null MAC address.
-        if (ni.hardwareAddr == null &&
-                !Compatibility.isChangeEnabled(RETURN_NULL_HARDWARE_ADDRESS)) {
-            return DEFAULT_MAC_ADDRESS.clone();
-        }
         return ni.hardwareAddr;
         // END Android-changed: Fix upstream not returning link-down interfaces. http://b/26238832
     }