Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit cf77c50b authored by Lorenzo Colitti's avatar Lorenzo Colitti Committed by android-build-merger
Browse files

Merge changes If28f0be6,If0f80067

am: 96529ad7

Change-Id: I108d3c36ce11af544ccfed9291dc38c690724915
parents bdce8daa 96529ad7
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -28888,6 +28888,7 @@ package android.net {
    method public boolean addRoute(@NonNull android.net.RouteInfo);
    method public void clear();
    method public int describeContents();
    method @Nullable public java.net.Inet4Address getDhcpServerAddress();
    method @NonNull public java.util.List<java.net.InetAddress> getDnsServers();
    method @Nullable public String getDomains();
    method @Nullable public android.net.ProxyInfo getHttpProxy();
@@ -28899,6 +28900,7 @@ package android.net {
    method @NonNull public java.util.List<android.net.RouteInfo> getRoutes();
    method public boolean isPrivateDnsActive();
    method public boolean isWakeOnLanSupported();
    method public void setDhcpServerAddress(@Nullable java.net.Inet4Address);
    method public void setDnsServers(@NonNull java.util.Collection<java.net.InetAddress>);
    method public void setDomains(@Nullable String);
    method public void setHttpProxy(@Nullable android.net.ProxyInfo);
+50 −3
Original line number Diff line number Diff line
@@ -63,6 +63,7 @@ public final class LinkProperties implements Parcelable {
    private String mPrivateDnsServerName;
    private String mDomains;
    private ArrayList<RouteInfo> mRoutes = new ArrayList<>();
    private Inet4Address mDhcpServerAddress;
    private ProxyInfo mHttpProxy;
    private int mMtu;
    // in the format "rmem_min,rmem_def,rmem_max,wmem_min,wmem_def,wmem_max"
@@ -196,6 +197,7 @@ public final class LinkProperties implements Parcelable {
                addStackedLink(l);
            }
            setMtu(source.mMtu);
            setDhcpServerAddress(source.getDhcpServerAddress());
            mTcpBufferSizes = source.mTcpBufferSizes;
            mNat64Prefix = source.mNat64Prefix;
            mWakeOnLanSupported = source.mWakeOnLanSupported;
@@ -459,6 +461,24 @@ public final class LinkProperties implements Parcelable {
        mPrivateDnsServerName = privateDnsServerName;
    }

    /**
     * Set DHCP server address.
     *
     * @param serverAddress the server address to set.
     */
    public void setDhcpServerAddress(@Nullable Inet4Address serverAddress) {
        mDhcpServerAddress = serverAddress;
    }

     /**
     * Get DHCP server address
     *
     * @return The current DHCP server address.
     */
    public @Nullable Inet4Address getDhcpServerAddress() {
        return mDhcpServerAddress;
    }

    /**
     * Returns the private DNS server name that is in use. If not {@code null},
     * private DNS is in strict mode. In this mode, applications should ensure
@@ -851,6 +871,7 @@ public final class LinkProperties implements Parcelable {
        mHttpProxy = null;
        mStackedLinks.clear();
        mMtu = 0;
        mDhcpServerAddress = null;
        mTcpBufferSizes = null;
        mNat64Prefix = null;
        mWakeOnLanSupported = false;
@@ -919,6 +940,11 @@ public final class LinkProperties implements Parcelable {
            resultJoiner.add("WakeOnLanSupported: true");
        }

        if (mDhcpServerAddress != null) {
            resultJoiner.add("ServerAddress:");
            resultJoiner.add(mDhcpServerAddress.toString());
        }

        if (mTcpBufferSizes != null) {
            resultJoiner.add("TcpBufferSizes:");
            resultJoiner.add(mTcpBufferSizes);
@@ -1272,6 +1298,17 @@ public final class LinkProperties implements Parcelable {
        return TextUtils.equals(getInterfaceName(), target.getInterfaceName());
    }

    /**
     * Compares this {@code LinkProperties} DHCP server address against the target
     *
     * @param target LinkProperties to compare.
     * @return {@code true} if both are identical, {@code false} otherwise.
     * @hide
     */
    public boolean isIdenticalDhcpServerAddress(@NonNull LinkProperties target) {
        return Objects.equals(mDhcpServerAddress, target.mDhcpServerAddress);
    }

    /**
     * Compares this {@code LinkProperties} interface addresses against the target
     *
@@ -1489,6 +1526,7 @@ public final class LinkProperties implements Parcelable {
         */
        return isIdenticalInterfaceName(target)
                && isIdenticalAddresses(target)
                && isIdenticalDhcpServerAddress(target)
                && isIdenticalDnses(target)
                && isIdenticalPrivateDns(target)
                && isIdenticalValidatedPrivateDnses(target)
@@ -1613,6 +1651,7 @@ public final class LinkProperties implements Parcelable {
                + mMtu * 51
                + ((null == mTcpBufferSizes) ? 0 : mTcpBufferSizes.hashCode())
                + (mUsePrivateDns ? 57 : 0)
                + ((null == mDhcpServerAddress) ? 0 : mDhcpServerAddress.hashCode())
                + mPcscfs.size() * 67
                + ((null == mPrivateDnsServerName) ? 0 : mPrivateDnsServerName.hashCode())
                + Objects.hash(mNat64Prefix)
@@ -1635,6 +1674,7 @@ public final class LinkProperties implements Parcelable {
        dest.writeString(mPrivateDnsServerName);
        writeAddresses(dest, mPcscfs);
        dest.writeString(mDomains);
        writeAddress(dest, mDhcpServerAddress);
        dest.writeInt(mMtu);
        dest.writeString(mTcpBufferSizes);
        dest.writeInt(mRoutes.size());
@@ -1663,8 +1703,9 @@ public final class LinkProperties implements Parcelable {
        }
    }

    private static void writeAddress(@NonNull Parcel dest, @NonNull InetAddress addr) {
        dest.writeByteArray(addr.getAddress());
    private static void writeAddress(@NonNull Parcel dest, @Nullable InetAddress addr) {
        byte[] addressBytes = (addr == null ? null : addr.getAddress());
        dest.writeByteArray(addressBytes);
        if (addr instanceof Inet6Address) {
            final Inet6Address v6Addr = (Inet6Address) addr;
            final boolean hasScopeId = v6Addr.getScopeId() != 0;
@@ -1673,9 +1714,11 @@ public final class LinkProperties implements Parcelable {
        }
    }

    @NonNull
    @Nullable
    private static InetAddress readAddress(@NonNull Parcel p) throws UnknownHostException {
        final byte[] addr = p.createByteArray();
        if (addr == null) return null;

        if (addr.length == INET6_ADDR_LENGTH) {
            final boolean hasScopeId = p.readBoolean();
            final int scopeId = hasScopeId ? p.readInt() : 0;
@@ -1722,6 +1765,10 @@ public final class LinkProperties implements Parcelable {
                    } catch (UnknownHostException e) { }
                }
                netProp.setDomains(in.readString());
                try {
                    netProp.setDhcpServerAddress((Inet4Address) InetAddress
                            .getByAddress(in.createByteArray()));
                } catch (UnknownHostException e) { }
                netProp.setMtu(in.readInt());
                netProp.setTcpBufferSizes(in.readString());
                addressCount = in.readInt();
+16 −1
Original line number Diff line number Diff line
@@ -38,6 +38,7 @@ import androidx.test.runner.AndroidJUnit4;
import org.junit.Test;
import org.junit.runner.RunWith;

import java.net.Inet4Address;
import java.net.InetAddress;
import java.util.ArrayList;
import java.util.Arrays;
@@ -65,6 +66,7 @@ public class LinkPropertiesTest {
    private static final InetAddress GATEWAY62 = address("fe80::6:22%lo");
    private static final InetAddress TESTIPV4ADDR = address("192.168.47.42");
    private static final InetAddress TESTIPV6ADDR = address("fe80::7:33%43");
    private static final Inet4Address DHCPSERVER = (Inet4Address) address("192.0.2.1");
    private static final String NAME = "qmi0";
    private static final String DOMAINS = "google.com";
    private static final String PRIV_DNS_SERVER_NAME = "private.dns.com";
@@ -93,6 +95,7 @@ public class LinkPropertiesTest {
        assertNull(lp.getHttpProxy());
        assertNull(lp.getTcpBufferSizes());
        assertNull(lp.getNat64Prefix());
        assertNull(lp.getDhcpServerAddress());
        assertFalse(lp.isProvisioned());
        assertFalse(lp.isIpv4Provisioned());
        assertFalse(lp.isIpv6Provisioned());
@@ -119,6 +122,7 @@ public class LinkPropertiesTest {
        lp.setMtu(MTU);
        lp.setTcpBufferSizes(TCP_BUFFER_SIZES);
        lp.setNat64Prefix(new IpPrefix("2001:db8:0:64::/96"));
        lp.setDhcpServerAddress(DHCPSERVER);
        lp.setWakeOnLanSupported(true);
        return lp;
    }
@@ -960,11 +964,13 @@ public class LinkPropertiesTest {

        source.setWakeOnLanSupported(true);

        source.setDhcpServerAddress((Inet4Address) GATEWAY1);

        final LinkProperties stacked = new LinkProperties();
        stacked.setInterfaceName("test-stacked");
        source.addStackedLink(stacked);

        assertParcelSane(source, 15 /* fieldCount */);
        assertParcelSane(source, 16 /* fieldCount */);
    }

    @Test
@@ -1090,6 +1096,15 @@ public class LinkPropertiesTest {
        assertFalse(lp.isPrivateDnsActive());
    }

    @Test
    public void testDhcpServerAddress() {
        final LinkProperties lp = makeTestObject();
        assertEquals(DHCPSERVER, lp.getDhcpServerAddress());

        lp.clear();
        assertNull(lp.getDhcpServerAddress());
    }

    @Test
    public void testWakeOnLanSupported() {
        final LinkProperties lp = makeTestObject();