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

Commit 74bae9a8 authored by Android Build Merger (Role)'s avatar Android Build Merger (Role) Committed by Android (Google) Code Review
Browse files

Merge "Merge "Remove last NetworkStack usage of hidden APIs" am: 16ec5d03...

Merge "Merge "Remove last NetworkStack usage of hidden APIs" am: 16ec5d03 am: 4845df3c am: 14062be8"
parents fdf43845 4a80077d
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -922,6 +922,7 @@ filegroup {
        "core/java/android/annotation/UnsupportedAppUsage.java",
        "core/java/android/net/DhcpResults.java",
        "core/java/android/util/LocalLog.java",
        "core/java/com/android/internal/annotations/GuardedBy.java",
        "core/java/com/android/internal/annotations/VisibleForTesting.java",
        "core/java/com/android/internal/util/HexDump.java",
        "core/java/com/android/internal/util/IndentingPrintWriter.java",
+16 −13
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
package android.net;

import android.annotation.UnsupportedAppUsage;
import android.net.shared.InetAddressUtils;
import android.os.Parcel;
import android.os.Parcelable;
import android.text.TextUtils;
@@ -73,19 +74,21 @@ public final class DhcpResults implements Parcelable {
    public StaticIpConfiguration toStaticIpConfiguration() {
        final StaticIpConfiguration s = new StaticIpConfiguration();
        // All these except dnsServers are immutable, so no need to make copies.
        s.ipAddress = ipAddress;
        s.gateway = gateway;
        s.dnsServers.addAll(dnsServers);
        s.domains = domains;
        s.setIpAddress(ipAddress);
        s.setGateway(gateway);
        for (InetAddress addr : dnsServers) {
            s.addDnsServer(addr);
        }
        s.setDomains(domains);
        return s;
    }

    public DhcpResults(StaticIpConfiguration source) {
        if (source != null) {
            ipAddress = source.ipAddress;
            gateway = source.gateway;
            dnsServers.addAll(source.dnsServers);
            domains = source.domains;
            ipAddress = source.getIpAddress();
            gateway = source.getGateway();
            dnsServers.addAll(source.getDnsServers());
            domains = source.getDomains();
        }
    }

@@ -177,7 +180,7 @@ public final class DhcpResults implements Parcelable {
        toStaticIpConfiguration().writeToParcel(dest, flags);
        dest.writeInt(leaseDuration);
        dest.writeInt(mtu);
        NetworkUtils.parcelInetAddress(dest, serverAddress, flags);
        InetAddressUtils.parcelInetAddress(dest, serverAddress, flags);
        dest.writeString(vendorInfo);
    }

@@ -191,7 +194,7 @@ public final class DhcpResults implements Parcelable {
        final DhcpResults dhcpResults = new DhcpResults(s);
        dhcpResults.leaseDuration = in.readInt();
        dhcpResults.mtu = in.readInt();
        dhcpResults.serverAddress = (Inet4Address) NetworkUtils.unparcelInetAddress(in);
        dhcpResults.serverAddress = (Inet4Address) InetAddressUtils.unparcelInetAddress(in);
        dhcpResults.vendorInfo = in.readString();
        return dhcpResults;
    }
@@ -200,7 +203,7 @@ public final class DhcpResults implements Parcelable {
    // Not part of the superclass because they're only used by the JNI iterface to the DHCP daemon.
    public boolean setIpAddress(String addrString, int prefixLength) {
        try {
            Inet4Address addr = (Inet4Address) NetworkUtils.numericToInetAddress(addrString);
            Inet4Address addr = (Inet4Address) InetAddresses.parseNumericAddress(addrString);
            ipAddress = new LinkAddress(addr, prefixLength);
        } catch (IllegalArgumentException|ClassCastException e) {
            Log.e(TAG, "setIpAddress failed with addrString " + addrString + "/" + prefixLength);
@@ -211,7 +214,7 @@ public final class DhcpResults implements Parcelable {

    public boolean setGateway(String addrString) {
        try {
            gateway = NetworkUtils.numericToInetAddress(addrString);
            gateway = InetAddresses.parseNumericAddress(addrString);
        } catch (IllegalArgumentException e) {
            Log.e(TAG, "setGateway failed with addrString " + addrString);
            return true;
@@ -222,7 +225,7 @@ public final class DhcpResults implements Parcelable {
    public boolean addDns(String addrString) {
        if (TextUtils.isEmpty(addrString) == false) {
            try {
                dnsServers.add(NetworkUtils.numericToInetAddress(addrString));
                dnsServers.add(InetAddresses.parseNumericAddress(addrString));
            } catch (IllegalArgumentException e) {
                Log.e(TAG, "addDns failed with addrString " + addrString);
                return true;
+3 −1
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@
package android.net;

import android.net.INetworkMonitorCallbacks;
import android.net.NetworkParcelable;
import android.net.dhcp.DhcpServingParamsParcel;
import android.net.dhcp.IDhcpServerCallbacks;
import android.net.ip.IIpClientCallbacks;
@@ -24,6 +25,7 @@ import android.net.ip.IIpClientCallbacks;
oneway interface INetworkStackConnector {
    void makeDhcpServer(in String ifName, in DhcpServingParamsParcel params,
        in IDhcpServerCallbacks cb);
    void makeNetworkMonitor(int netId, String name, in INetworkMonitorCallbacks cb);
    void makeNetworkMonitor(in NetworkParcelable network, String name,
        in INetworkMonitorCallbacks cb);
    void makeIpClient(in String ifName, in IIpClientCallbacks callbacks);
}
 No newline at end of file
+3 −2
Original line number Diff line number Diff line
@@ -104,10 +104,11 @@ public class NetworkStack {
     *
     * <p>The INetworkMonitor will be returned asynchronously through the provided callbacks.
     */
    public void makeNetworkMonitor(Network network, String name, INetworkMonitorCallbacks cb) {
    public void makeNetworkMonitor(
            NetworkParcelable network, String name, INetworkMonitorCallbacks cb) {
        requestConnector(connector -> {
            try {
                connector.makeNetworkMonitor(network.netId, name, cb);
                connector.makeNetworkMonitor(network, name, cb);
            } catch (RemoteException e) {
                e.rethrowFromSystemServer();
            }
+0 −27
Original line number Diff line number Diff line
@@ -23,7 +23,6 @@ import android.annotation.NonNull;
import android.annotation.UnsupportedAppUsage;
import android.net.shared.Inet4AddressUtils;
import android.os.Build;
import android.os.Parcel;
import android.system.ErrnoException;
import android.system.Os;
import android.util.Log;
@@ -251,32 +250,6 @@ public class NetworkUtils {
        return InetAddress.parseNumericAddress(addrString);
    }

    /**
     * Writes an InetAddress to a parcel. The address may be null. This is likely faster than
     * calling writeSerializable.
     */
    protected static void parcelInetAddress(Parcel parcel, InetAddress address, int flags) {
        byte[] addressArray = (address != null) ? address.getAddress() : null;
        parcel.writeByteArray(addressArray);
    }

    /**
     * Reads an InetAddress from a parcel. Returns null if the address that was written was null
     * or if the data is invalid.
     */
    protected static InetAddress unparcelInetAddress(Parcel in) {
        byte[] addressArray = in.createByteArray();
        if (addressArray == null) {
            return null;
        }
        try {
            return InetAddress.getByAddress(addressArray);
        } catch (UnknownHostException e) {
            return null;
        }
    }


    /**
     *  Masks a raw IP address byte array with the specified prefix length.
     */
Loading