Tidy the PacketSocketAddress API

Remove two constructors from the Core Platform API and replace
with a multi-purpose replacement. Make fields final. Improve
docs slightly.

Bug: 133196453
Bug: 124232146
Test: build only
Change-Id: I660949785bca33648458364a29de722ecec8f82c
diff --git a/luni/src/main/java/android/system/PacketSocketAddress.java b/luni/src/main/java/android/system/PacketSocketAddress.java
index d375226..d1e9591 100644
--- a/luni/src/main/java/android/system/PacketSocketAddress.java
+++ b/luni/src/main/java/android/system/PacketSocketAddress.java
@@ -30,23 +30,23 @@
 @libcore.api.CorePlatformApi
 public final class PacketSocketAddress extends SocketAddress {
     /** Protocol. An Ethernet protocol type, e.g., {@code ETH_P_IPV6}. */
-    public short sll_protocol;
+    public final short sll_protocol;
 
     /** Interface index. */
-    public int sll_ifindex;
+    public final int sll_ifindex;
 
     /** ARP hardware type. One of the {@code ARPHRD_*} constants. */
-    public short sll_hatype;
+    public final short sll_hatype;
 
     /** Packet type. One of the {@code PACKET_*} constants, such as {@code PACKET_OTHERHOST}. */
-    public byte sll_pkttype;
+    public final byte sll_pkttype;
 
     /** Hardware address. */
-    public byte[] sll_addr;
+    public final byte[] sll_addr;
 
-    /** Constructs a new PacketSocketAddress. */
-    public PacketSocketAddress(short sll_protocol, int sll_ifindex,
-            short sll_hatype, byte sll_pkttype, byte[] sll_addr) {
+    /** Constructs a new PacketSocketAddress. Used from native code. */
+    public PacketSocketAddress(short sll_protocol, int sll_ifindex, short sll_hatype,
+            byte sll_pkttype, byte[] sll_addr) {
         this.sll_protocol = sll_protocol;
         this.sll_ifindex = sll_ifindex;
         this.sll_hatype = sll_hatype;
@@ -54,17 +54,38 @@
         this.sll_addr = sll_addr;
     }
 
-    /** Constructs a new PacketSocketAddress suitable for binding to. */
-    @UnsupportedAppUsage
+    /** Constructs a new PacketSocketAddress with all the "in" parameters. */
     @libcore.api.CorePlatformApi
-    public PacketSocketAddress(short sll_protocol, int sll_ifindex) {
-        this(sll_protocol, sll_ifindex, (short) 0, (byte) 0, null);
+    public PacketSocketAddress(short sll_protocol, int sll_ifindex, byte[] sll_addr) {
+        this.sll_protocol = sll_protocol;
+        this.sll_ifindex = sll_ifindex;
+        this.sll_hatype = (short) 0;
+        this.sll_pkttype = (byte) 0;
+        this.sll_addr = sll_addr;
     }
 
-    /** Constructs a new PacketSocketAddress suitable for sending to. */
+    /** Legacy constructor. Kept for @UnsupportedAppUsage only. */
     @UnsupportedAppUsage
-    @libcore.api.CorePlatformApi
+    public PacketSocketAddress(short sll_protocol, int sll_ifindex) {
+        this.sll_protocol = sll_protocol;
+        this.sll_ifindex = sll_ifindex;
+        this.sll_hatype = (short) 0;
+        this.sll_pkttype = (byte) 0;
+        this.sll_addr = null;
+    }
+
+    /** Legacy constructor. Kept for @UnsupportedAppUsage only. */
+    @UnsupportedAppUsage
     public PacketSocketAddress(int sll_ifindex, byte[] sll_addr) {
-        this((short) 0, sll_ifindex, (short) 0, (byte) 0, sll_addr);
+        this.sll_protocol = (short) 0;
+        this.sll_ifindex = sll_ifindex;
+        this.sll_hatype = (short) 0;
+        this.sll_pkttype = (byte) 0;
+        this.sll_addr = sll_addr;
+    }
+
+    @Override
+    public String toString() {
+        return Objects.toString(this);
     }
 }
diff --git a/mmodules/core_platform_api/api/platform/current-api.txt b/mmodules/core_platform_api/api/platform/current-api.txt
index d127436..d59d230 100644
--- a/mmodules/core_platform_api/api/platform/current-api.txt
+++ b/mmodules/core_platform_api/api/platform/current-api.txt
@@ -105,8 +105,7 @@
   }
 
   public final class PacketSocketAddress extends java.net.SocketAddress {
-    ctor @dalvik.annotation.compat.UnsupportedAppUsage public PacketSocketAddress(short, int);
-    ctor @dalvik.annotation.compat.UnsupportedAppUsage public PacketSocketAddress(int, byte[]);
+    ctor public PacketSocketAddress(short, int, byte[]);
   }
 
   public final class StructCapUserData {