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

Commit c1c02dcb authored by Remi NGUYEN VAN's avatar Remi NGUYEN VAN Committed by Lorenzo Colitti
Browse files

Remove NetworkStack dependencies on hidden members

 - DhcpClient only shares its handler with IpClient, and NetworkMonitor
   has its own handler: remove Protocol.BASE_DHCP,
   Protocol.BASE_NETWORK_MONITOR
 - Remove dependency on Network.netid in NetworkMonitor
 - Remove dependency on Sets.newArraySet in DhcpServingParams
 - Remove dependency on formatDuration() in DhcpClient
 - Replace isMetered() with hasCapability() in NetworkMonitor
 - Use WifiManager.isScanAlwaysAvailable instead of reading setting

Test: atest FrameworksNetTests NetworkStackTests
Bug: 112869080
Change-Id: Ieef54d847ddc081fb33cbad0b050b06d2e52548e
parent a27da72c
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -3252,6 +3252,7 @@ package android.net.metrics {
  public class IpConnectivityLog {
    method public boolean log(long, android.net.metrics.IpConnectivityLog.Event);
    method public boolean log(String, android.net.metrics.IpConnectivityLog.Event);
    method public boolean log(android.net.Network, int[], android.net.metrics.IpConnectivityLog.Event);
    method public boolean log(int, int[], android.net.metrics.IpConnectivityLog.Event);
    method public boolean log(android.net.metrics.IpConnectivityLog.Event);
  }
+1 −0
Original line number Diff line number Diff line
@@ -718,6 +718,7 @@ package android.net.metrics {
  public class IpConnectivityLog {
    method public boolean log(long, android.net.metrics.IpConnectivityLog.Event);
    method public boolean log(String, android.net.metrics.IpConnectivityLog.Event);
    method public boolean log(android.net.Network, int[], android.net.metrics.IpConnectivityLog.Event);
    method public boolean log(int, int[], android.net.metrics.IpConnectivityLog.Event);
    method public boolean log(android.net.metrics.IpConnectivityLog.Event);
  }
+13 −0
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@ import android.annotation.TestApi;
import android.annotation.UnsupportedAppUsage;
import android.net.ConnectivityMetricsEvent;
import android.net.IIpConnectivityMetrics;
import android.net.Network;
import android.os.Parcelable;
import android.os.RemoteException;
import android.os.ServiceManager;
@@ -126,6 +127,18 @@ public class IpConnectivityLog {
        return log(ev);
    }

    /**
     * Log an IpConnectivity event.
     * @param network the network associated with the event.
     * @param transports the current transports of the network associated with the event, as defined
     * in NetworkCapabilities.
     * @param data is a Parcelable instance representing the event.
     * @return true if the event was successfully logged.
     */
    public boolean log(Network network, int[] transports, Event data) {
        return log(network.netId, transports, data);
    }

    /**
     * Log an IpConnectivity event.
     * @param netid the id of the network associated with the event.
+0 −2
Original line number Diff line number Diff line
@@ -53,7 +53,6 @@ public class Protocol {
    public static final int BASE_WIFI_PASSPOINT_MANAGER                             = 0x00028000;
    public static final int BASE_WIFI_PASSPOINT_SERVICE                             = 0x00028100;
    public static final int BASE_WIFI_LOGGER                                        = 0x00028300;
    public static final int BASE_DHCP                                               = 0x00030000;
    public static final int BASE_DATA_CONNECTION                                    = 0x00040000;
    public static final int BASE_DATA_CONNECTION_AC                                 = 0x00041000;
    public static final int BASE_DATA_CONNECTION_TRACKER                            = 0x00042000;
@@ -62,7 +61,6 @@ public class Protocol {
    public static final int BASE_NETWORK_STATE_TRACKER                              = 0x00070000;
    public static final int BASE_CONNECTIVITY_MANAGER                               = 0x00080000;
    public static final int BASE_NETWORK_AGENT                                      = 0x00081000;
    public static final int BASE_NETWORK_MONITOR                                    = 0x00082000;
    public static final int BASE_NETWORK_FACTORY                                    = 0x00083000;
    public static final int BASE_ETHERNET                                           = 0x00084000;
    public static final int BASE_LOWPAN                                             = 0x00085000;
+5 −5
Original line number Diff line number Diff line
@@ -30,10 +30,10 @@ import android.annotation.Nullable;
import android.net.IpPrefix;
import android.net.LinkAddress;
import android.net.NetworkUtils;

import com.google.android.collect.Sets;
import android.util.ArraySet;

import java.net.Inet4Address;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
@@ -208,7 +208,7 @@ public class DhcpServingParams {
         * but it must always be set explicitly before building the {@link DhcpServingParams}.
         */
        public Builder setDefaultRouters(@NonNull Inet4Address... defaultRouters) {
            return setDefaultRouters(Sets.newArraySet(defaultRouters));
            return setDefaultRouters(new ArraySet<>(Arrays.asList(defaultRouters)));
        }

        /**
@@ -238,7 +238,7 @@ public class DhcpServingParams {
         * building the {@link DhcpServingParams}.
         */
        public Builder setDnsServers(@NonNull Inet4Address... dnsServers) {
            return setDnsServers(Sets.newArraySet(dnsServers));
            return setDnsServers(new ArraySet<>(Arrays.asList(dnsServers)));
        }

        /**
@@ -268,7 +268,7 @@ public class DhcpServingParams {
         * and do not need to be set here.
         */
        public Builder setExcludedAddrs(@NonNull Inet4Address... excludedAddrs) {
            return setExcludedAddrs(Sets.newArraySet(excludedAddrs));
            return setExcludedAddrs(new ArraySet<>(Arrays.asList(excludedAddrs)));
        }

        /**
Loading