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

Commit b43f5315 authored by Automerger Merge Worker's avatar Automerger Merge Worker
Browse files

Merge "Fix some @hide usage in Tethering" am: b763432e am: aff6974b

Change-Id: Ie88cd6ef541d5bd9fcec2e26c03277c75919a1a0
parents 76131d77 aff6974b
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -613,13 +613,13 @@ filegroup {
    name: "framework-tethering-shared-srcs",
    srcs: [
        "core/java/android/util/LocalLog.java",
        "core/java/com/android/internal/util/BitUtils.java",
        "core/java/com/android/internal/util/IndentingPrintWriter.java",
        "core/java/com/android/internal/util/IState.java",
        "core/java/com/android/internal/util/MessageUtils.java",
        "core/java/com/android/internal/util/Preconditions.java",
        "core/java/com/android/internal/util/State.java",
        "core/java/com/android/internal/util/StateMachine.java",
        "core/java/android/net/shared/Inet4AddressUtils.java",
    ],
}

+2 −0
Original line number Diff line number Diff line
@@ -13,3 +13,5 @@ rule com.android.internal.util.State* com.android.networkstack.tethering.util.St
rule com.android.internal.util.StateMachine* com.android.networkstack.tethering.util.StateMachine@1

rule android.net.LocalLog* com.android.networkstack.tethering.LocalLog@1

rule android.net.shared.Inet4AddressUtils* com.android.networkstack.tethering.shared.Inet4AddressUtils@1
+11 −5
Original line number Diff line number Diff line
@@ -20,11 +20,11 @@ import static android.net.shared.Inet4AddressUtils.inet4AddressToIntHTH;

import android.annotation.NonNull;
import android.net.LinkAddress;

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

import java.net.Inet4Address;
import java.util.Collection;
import java.util.Collections;
import java.util.Set;

/**
@@ -68,7 +68,7 @@ public class DhcpServingParamsParcelExt extends DhcpServingParamsParcel {
     * but it must always be set explicitly.
     */
    public DhcpServingParamsParcelExt setDefaultRouters(@NonNull Inet4Address... defaultRouters) {
        return setDefaultRouters(Sets.newArraySet(defaultRouters));
        return setDefaultRouters(newArraySet(defaultRouters));
    }

    /**
@@ -96,7 +96,7 @@ public class DhcpServingParamsParcelExt extends DhcpServingParamsParcel {
     * <p>This may be an empty list of servers, but it must always be set explicitly.
     */
    public DhcpServingParamsParcelExt setDnsServers(@NonNull Inet4Address... dnsServers) {
        return setDnsServers(Sets.newArraySet(dnsServers));
        return setDnsServers(newArraySet(dnsServers));
    }

    /**
@@ -126,7 +126,7 @@ public class DhcpServingParamsParcelExt extends DhcpServingParamsParcel {
     * and do not need to be set here.
     */
    public DhcpServingParamsParcelExt setExcludedAddrs(@NonNull Inet4Address... excludedAddrs) {
        return setExcludedAddrs(Sets.newArraySet(excludedAddrs));
        return setExcludedAddrs(newArraySet(excludedAddrs));
    }

    /**
@@ -169,4 +169,10 @@ public class DhcpServingParamsParcelExt extends DhcpServingParamsParcel {
        }
        return res;
    }

    private static ArraySet<Inet4Address> newArraySet(Inet4Address... addrs) {
        ArraySet<Inet4Address> addrSet = new ArraySet<>(addrs.length);
        Collections.addAll(addrSet, addrs);
        return addrSet;
    }
}
+17 −16
Original line number Diff line number Diff line
@@ -17,10 +17,12 @@
package android.net.ip;

import static android.net.InetAddresses.parseNumericAddress;
import static android.net.RouteInfo.RTN_UNICAST;
import static android.net.dhcp.IDhcpServer.STATUS_SUCCESS;
import static android.net.util.NetworkConstants.FF;
import static android.net.util.NetworkConstants.RFC7421_PREFIX_LENGTH;
import static android.net.util.NetworkConstants.asByte;
import static android.net.util.TetheringMessageBase.BASE_IPSERVER;

import android.net.ConnectivityManager;
import android.net.INetd;
@@ -46,11 +48,9 @@ import android.os.Message;
import android.os.RemoteException;
import android.os.ServiceSpecificException;
import android.util.Log;
import android.util.Slog;
import android.util.SparseArray;

import com.android.internal.util.MessageUtils;
import com.android.internal.util.Protocol;
import com.android.internal.util.State;
import com.android.internal.util.StateMachine;

@@ -153,27 +153,26 @@ public class IpServer extends StateMachine {
                DhcpServerCallbacks cb);
    }

    private static final int BASE_IFACE              = Protocol.BASE_TETHERING + 100;
    // request from the user that it wants to tether
    public static final int CMD_TETHER_REQUESTED            = BASE_IFACE + 2;
    public static final int CMD_TETHER_REQUESTED            = BASE_IPSERVER + 1;
    // request from the user that it wants to untether
    public static final int CMD_TETHER_UNREQUESTED          = BASE_IFACE + 3;
    public static final int CMD_TETHER_UNREQUESTED          = BASE_IPSERVER + 2;
    // notification that this interface is down
    public static final int CMD_INTERFACE_DOWN              = BASE_IFACE + 4;
    public static final int CMD_INTERFACE_DOWN              = BASE_IPSERVER + 3;
    // notification from the master SM that it had trouble enabling IP Forwarding
    public static final int CMD_IP_FORWARDING_ENABLE_ERROR  = BASE_IFACE + 7;
    public static final int CMD_IP_FORWARDING_ENABLE_ERROR  = BASE_IPSERVER + 4;
    // notification from the master SM that it had trouble disabling IP Forwarding
    public static final int CMD_IP_FORWARDING_DISABLE_ERROR = BASE_IFACE + 8;
    public static final int CMD_IP_FORWARDING_DISABLE_ERROR = BASE_IPSERVER + 5;
    // notification from the master SM that it had trouble starting tethering
    public static final int CMD_START_TETHERING_ERROR       = BASE_IFACE + 9;
    public static final int CMD_START_TETHERING_ERROR       = BASE_IPSERVER + 6;
    // notification from the master SM that it had trouble stopping tethering
    public static final int CMD_STOP_TETHERING_ERROR        = BASE_IFACE + 10;
    public static final int CMD_STOP_TETHERING_ERROR        = BASE_IPSERVER + 7;
    // notification from the master SM that it had trouble setting the DNS forwarders
    public static final int CMD_SET_DNS_FORWARDERS_ERROR    = BASE_IFACE + 11;
    public static final int CMD_SET_DNS_FORWARDERS_ERROR    = BASE_IPSERVER + 8;
    // the upstream connection has changed
    public static final int CMD_TETHER_CONNECTION_CHANGED   = BASE_IFACE + 12;
    public static final int CMD_TETHER_CONNECTION_CHANGED   = BASE_IPSERVER + 9;
    // new IPv6 tethering parameters need to be processed
    public static final int CMD_IPV6_TETHER_UPDATE          = BASE_IFACE + 13;
    public static final int CMD_IPV6_TETHER_UPDATE          = BASE_IPSERVER + 10;

    private final State mInitialState;
    private final State mLocalHotspotState;
@@ -486,7 +485,9 @@ public class IpServer extends StateMachine {
        }

        // Directly-connected route.
        final RouteInfo route = new RouteInfo(linkAddr);
        final IpPrefix ipv4Prefix = new IpPrefix(linkAddr.getAddress(),
                linkAddr.getPrefixLength());
        final RouteInfo route = new RouteInfo(ipv4Prefix, null, null, RTN_UNICAST);
        if (enabled) {
            mLinkProperties.addLinkAddress(linkAddr);
            mLinkProperties.addRoute(route);
@@ -1007,7 +1008,7 @@ public class IpServer extends StateMachine {
            String ifname, HashSet<IpPrefix> prefixes) {
        final ArrayList<RouteInfo> localRoutes = new ArrayList<RouteInfo>();
        for (IpPrefix ipp : prefixes) {
            localRoutes.add(new RouteInfo(ipp, null, ifname));
            localRoutes.add(new RouteInfo(ipp, null, ifname, RTN_UNICAST));
        }
        return localRoutes;
    }
@@ -1019,7 +1020,7 @@ public class IpServer extends StateMachine {
        try {
            return Inet6Address.getByAddress(null, dnsBytes, 0);
        } catch (UnknownHostException e) {
            Slog.wtf(TAG, "Failed to construct Inet6Address from: " + localPrefix);
            Log.wtf(TAG, "Failed to construct Inet6Address from: " + localPrefix);
            return null;
        }
    }
+3 −7
Original line number Diff line number Diff line
@@ -22,14 +22,13 @@ import static android.system.OsConstants.AF_INET6;
import static android.system.OsConstants.IPPROTO_ICMPV6;
import static android.system.OsConstants.SOCK_RAW;
import static android.system.OsConstants.SOL_SOCKET;
import static android.system.OsConstants.SO_BINDTODEVICE;
import static android.system.OsConstants.SO_SNDTIMEO;

import android.net.IpPrefix;
import android.net.LinkAddress;
import android.net.NetworkUtils;
import android.net.TrafficStats;
import android.net.util.InterfaceParams;
import android.net.util.SocketUtils;
import android.net.util.TetheringUtils;
import android.system.ErrnoException;
import android.system.Os;
@@ -39,8 +38,6 @@ import android.util.Log;
import com.android.internal.annotations.GuardedBy;
import com.android.internal.util.TrafficStatsConstants;

import libcore.io.IoBridge;

import java.io.FileDescriptor;
import java.io.IOException;
import java.net.Inet6Address;
@@ -612,8 +609,7 @@ public class RouterAdvertisementDaemon {
            // Setting SNDTIMEO is purely for defensive purposes.
            Os.setsockoptTimeval(
                    mSocket, SOL_SOCKET, SO_SNDTIMEO, StructTimeval.fromMillis(send_timout_ms));
            Os.setsockoptIfreq(mSocket, SOL_SOCKET, SO_BINDTODEVICE, mInterface.name);
            NetworkUtils.protectFromVpn(mSocket);
            SocketUtils.bindSocketToInterface(mSocket, mInterface.name);
            TetheringUtils.setupRaSocket(mSocket, mInterface.index);
        } catch (ErrnoException | IOException e) {
            Log.e(TAG, "Failed to create RA daemon socket: " + e);
@@ -628,7 +624,7 @@ public class RouterAdvertisementDaemon {
    private void closeSocket() {
        if (mSocket != null) {
            try {
                IoBridge.closeAndSignalBlockedThreads(mSocket);
                SocketUtils.closeSocket(mSocket);
            } catch (IOException ignored) { }
        }
        mSocket = null;
Loading