Loading Android.bp +1 −0 Original line number Original line Diff line number Diff line Loading @@ -90,6 +90,7 @@ java_defaults { "netd_aidl_interface-unstable-java", "netd_aidl_interface-unstable-java", "netlink-client", "netlink-client", "networkstack-client", "networkstack-client", "net-utils-framework-common", "datastallprotosnano", "datastallprotosnano", "statsprotos", "statsprotos", "captiveportal-lib", "captiveportal-lib", Loading common/moduleutils/src/android/net/shared/NetdUtils.java +39 −2 Original line number Original line Diff line number Diff line Loading @@ -17,6 +17,7 @@ package android.net.shared; package android.net.shared; import static android.net.RouteInfo.RTN_UNICAST; import static android.net.RouteInfo.RTN_UNICAST; import static android.system.OsConstants.EBUSY; import android.net.INetd; import android.net.INetd; import android.net.IpPrefix; import android.net.IpPrefix; Loading @@ -24,6 +25,8 @@ import android.net.RouteInfo; import android.net.TetherConfigParcel; import android.net.TetherConfigParcel; import android.os.RemoteException; import android.os.RemoteException; import android.os.ServiceSpecificException; import android.os.ServiceSpecificException; import android.os.SystemClock; import android.util.Log; import java.util.ArrayList; import java.util.ArrayList; import java.util.List; import java.util.List; Loading @@ -33,6 +36,8 @@ import java.util.List; * @hide * @hide */ */ public class NetdUtils { public class NetdUtils { private static final String TAG = NetdUtils.class.getSimpleName(); /** Start tethering. */ /** Start tethering. */ public static void tetherStart(final INetd netd, final boolean usingLegacyDnsProxy, public static void tetherStart(final INetd netd, final boolean usingLegacyDnsProxy, final String[] dhcpRange) throws RemoteException, ServiceSpecificException { final String[] dhcpRange) throws RemoteException, ServiceSpecificException { Loading @@ -45,14 +50,46 @@ public class NetdUtils { /** Setup interface for tethering. */ /** Setup interface for tethering. */ public static void tetherInterface(final INetd netd, final String iface, final IpPrefix dest) public static void tetherInterface(final INetd netd, final String iface, final IpPrefix dest) throws RemoteException, ServiceSpecificException { throws RemoteException, ServiceSpecificException { netd.tetherInterfaceAdd(iface); tetherInterface(netd, iface, dest, 20 /* maxAttempts */, 50 /* pollingIntervalMs */); } netd.networkAddInterface(INetd.LOCAL_NET_ID, iface); /** Setup interface with configurable retries for tethering. */ public static void tetherInterface(final INetd netd, final String iface, final IpPrefix dest, int maxAttempts, int pollingIntervalMs) throws RemoteException, ServiceSpecificException { netd.tetherInterfaceAdd(iface); networkAddInterface(netd, iface, maxAttempts, pollingIntervalMs); List<RouteInfo> routes = new ArrayList<>(); List<RouteInfo> routes = new ArrayList<>(); routes.add(new RouteInfo(dest, null, iface, RTN_UNICAST)); routes.add(new RouteInfo(dest, null, iface, RTN_UNICAST)); RouteUtils.addRoutesToLocalNetwork(netd, iface, routes); RouteUtils.addRoutesToLocalNetwork(netd, iface, routes); } } /** * Retry Netd#networkAddInterface for EBUSY error code. * If the same interface (e.g., wlan0) is in client mode and then switches to tethered mode. * There can be a race where puts the interface into the local network but interface is still * in use in netd because the ConnectivityService thread hasn't processed the disconnect yet. * See b/158269544 for detail. */ private static void networkAddInterface(final INetd netd, final String iface, int maxAttempts, int pollingIntervalMs) throws ServiceSpecificException, RemoteException { for (int i = 1; i <= maxAttempts; i++) { try { netd.networkAddInterface(INetd.LOCAL_NET_ID, iface); return; } catch (ServiceSpecificException e) { if (e.errorCode == EBUSY && i < maxAttempts) { SystemClock.sleep(pollingIntervalMs); continue; } Log.e(TAG, "Retry Netd#networkAddInterface failure: " + e); throw e; } } } /** Reset interface for tethering. */ /** Reset interface for tethering. */ public static void untetherInterface(final INetd netd, String iface) public static void untetherInterface(final INetd netd, String iface) throws RemoteException, ServiceSpecificException { throws RemoteException, ServiceSpecificException { Loading jarjar-rules-shared.txt +2 −2 Original line number Original line Diff line number Diff line Loading @@ -3,8 +3,8 @@ rule com.android.net.module.util.** com.android.networkstack.util.@1 rule com.android.internal.util.** android.net.networkstack.util.@1 rule com.android.internal.util.** android.net.networkstack.util.@1 rule android.net.shared.Inet4AddressUtils* android.net.networkstack.shared.Inet4AddressUtils@1 # Classes from net-utils-framework-common rule android.net.shared.InetAddressUtils* android.net.networkstack.shared.InetAddressUtils@1 rule com.android.net.module.util.** com.android.networkstack.util.@1 # Ignore DhcpResultsParcelable, but jarjar DhcpResults # Ignore DhcpResultsParcelable, but jarjar DhcpResults # TODO: move DhcpResults into services.net and delete from here # TODO: move DhcpResults into services.net and delete from here Loading src/android/net/dhcp/DhcpLease.java +1 −1 Original line number Original line Diff line number Diff line Loading @@ -16,7 +16,7 @@ package android.net.dhcp; package android.net.dhcp; import static android.net.shared.Inet4AddressUtils.inet4AddressToIntHTH; import static com.android.net.module.util.Inet4AddressUtils.inet4AddressToIntHTH; import android.net.MacAddress; import android.net.MacAddress; import android.os.SystemClock; import android.os.SystemClock; Loading src/android/net/dhcp/DhcpLeaseRepository.java +3 −3 Original line number Original line Diff line number Diff line Loading @@ -18,10 +18,10 @@ package android.net.dhcp; import static android.net.dhcp.DhcpLease.EXPIRATION_NEVER; import static android.net.dhcp.DhcpLease.EXPIRATION_NEVER; import static android.net.dhcp.DhcpLease.inet4AddrToString; import static android.net.dhcp.DhcpLease.inet4AddrToString; import static android.net.shared.Inet4AddressUtils.inet4AddressToIntHTH; import static android.net.shared.Inet4AddressUtils.intToInet4AddressHTH; import static android.net.shared.Inet4AddressUtils.prefixLengthToV4NetmaskIntHTH; import static com.android.net.module.util.Inet4AddressUtils.inet4AddressToIntHTH; import static com.android.net.module.util.Inet4AddressUtils.intToInet4AddressHTH; import static com.android.net.module.util.Inet4AddressUtils.prefixLengthToV4NetmaskIntHTH; import static com.android.server.util.NetworkStackConstants.IPV4_ADDR_ANY; import static com.android.server.util.NetworkStackConstants.IPV4_ADDR_ANY; import static com.android.server.util.NetworkStackConstants.IPV4_ADDR_BITS; import static com.android.server.util.NetworkStackConstants.IPV4_ADDR_BITS; Loading Loading
Android.bp +1 −0 Original line number Original line Diff line number Diff line Loading @@ -90,6 +90,7 @@ java_defaults { "netd_aidl_interface-unstable-java", "netd_aidl_interface-unstable-java", "netlink-client", "netlink-client", "networkstack-client", "networkstack-client", "net-utils-framework-common", "datastallprotosnano", "datastallprotosnano", "statsprotos", "statsprotos", "captiveportal-lib", "captiveportal-lib", Loading
common/moduleutils/src/android/net/shared/NetdUtils.java +39 −2 Original line number Original line Diff line number Diff line Loading @@ -17,6 +17,7 @@ package android.net.shared; package android.net.shared; import static android.net.RouteInfo.RTN_UNICAST; import static android.net.RouteInfo.RTN_UNICAST; import static android.system.OsConstants.EBUSY; import android.net.INetd; import android.net.INetd; import android.net.IpPrefix; import android.net.IpPrefix; Loading @@ -24,6 +25,8 @@ import android.net.RouteInfo; import android.net.TetherConfigParcel; import android.net.TetherConfigParcel; import android.os.RemoteException; import android.os.RemoteException; import android.os.ServiceSpecificException; import android.os.ServiceSpecificException; import android.os.SystemClock; import android.util.Log; import java.util.ArrayList; import java.util.ArrayList; import java.util.List; import java.util.List; Loading @@ -33,6 +36,8 @@ import java.util.List; * @hide * @hide */ */ public class NetdUtils { public class NetdUtils { private static final String TAG = NetdUtils.class.getSimpleName(); /** Start tethering. */ /** Start tethering. */ public static void tetherStart(final INetd netd, final boolean usingLegacyDnsProxy, public static void tetherStart(final INetd netd, final boolean usingLegacyDnsProxy, final String[] dhcpRange) throws RemoteException, ServiceSpecificException { final String[] dhcpRange) throws RemoteException, ServiceSpecificException { Loading @@ -45,14 +50,46 @@ public class NetdUtils { /** Setup interface for tethering. */ /** Setup interface for tethering. */ public static void tetherInterface(final INetd netd, final String iface, final IpPrefix dest) public static void tetherInterface(final INetd netd, final String iface, final IpPrefix dest) throws RemoteException, ServiceSpecificException { throws RemoteException, ServiceSpecificException { netd.tetherInterfaceAdd(iface); tetherInterface(netd, iface, dest, 20 /* maxAttempts */, 50 /* pollingIntervalMs */); } netd.networkAddInterface(INetd.LOCAL_NET_ID, iface); /** Setup interface with configurable retries for tethering. */ public static void tetherInterface(final INetd netd, final String iface, final IpPrefix dest, int maxAttempts, int pollingIntervalMs) throws RemoteException, ServiceSpecificException { netd.tetherInterfaceAdd(iface); networkAddInterface(netd, iface, maxAttempts, pollingIntervalMs); List<RouteInfo> routes = new ArrayList<>(); List<RouteInfo> routes = new ArrayList<>(); routes.add(new RouteInfo(dest, null, iface, RTN_UNICAST)); routes.add(new RouteInfo(dest, null, iface, RTN_UNICAST)); RouteUtils.addRoutesToLocalNetwork(netd, iface, routes); RouteUtils.addRoutesToLocalNetwork(netd, iface, routes); } } /** * Retry Netd#networkAddInterface for EBUSY error code. * If the same interface (e.g., wlan0) is in client mode and then switches to tethered mode. * There can be a race where puts the interface into the local network but interface is still * in use in netd because the ConnectivityService thread hasn't processed the disconnect yet. * See b/158269544 for detail. */ private static void networkAddInterface(final INetd netd, final String iface, int maxAttempts, int pollingIntervalMs) throws ServiceSpecificException, RemoteException { for (int i = 1; i <= maxAttempts; i++) { try { netd.networkAddInterface(INetd.LOCAL_NET_ID, iface); return; } catch (ServiceSpecificException e) { if (e.errorCode == EBUSY && i < maxAttempts) { SystemClock.sleep(pollingIntervalMs); continue; } Log.e(TAG, "Retry Netd#networkAddInterface failure: " + e); throw e; } } } /** Reset interface for tethering. */ /** Reset interface for tethering. */ public static void untetherInterface(final INetd netd, String iface) public static void untetherInterface(final INetd netd, String iface) throws RemoteException, ServiceSpecificException { throws RemoteException, ServiceSpecificException { Loading
jarjar-rules-shared.txt +2 −2 Original line number Original line Diff line number Diff line Loading @@ -3,8 +3,8 @@ rule com.android.net.module.util.** com.android.networkstack.util.@1 rule com.android.internal.util.** android.net.networkstack.util.@1 rule com.android.internal.util.** android.net.networkstack.util.@1 rule android.net.shared.Inet4AddressUtils* android.net.networkstack.shared.Inet4AddressUtils@1 # Classes from net-utils-framework-common rule android.net.shared.InetAddressUtils* android.net.networkstack.shared.InetAddressUtils@1 rule com.android.net.module.util.** com.android.networkstack.util.@1 # Ignore DhcpResultsParcelable, but jarjar DhcpResults # Ignore DhcpResultsParcelable, but jarjar DhcpResults # TODO: move DhcpResults into services.net and delete from here # TODO: move DhcpResults into services.net and delete from here Loading
src/android/net/dhcp/DhcpLease.java +1 −1 Original line number Original line Diff line number Diff line Loading @@ -16,7 +16,7 @@ package android.net.dhcp; package android.net.dhcp; import static android.net.shared.Inet4AddressUtils.inet4AddressToIntHTH; import static com.android.net.module.util.Inet4AddressUtils.inet4AddressToIntHTH; import android.net.MacAddress; import android.net.MacAddress; import android.os.SystemClock; import android.os.SystemClock; Loading
src/android/net/dhcp/DhcpLeaseRepository.java +3 −3 Original line number Original line Diff line number Diff line Loading @@ -18,10 +18,10 @@ package android.net.dhcp; import static android.net.dhcp.DhcpLease.EXPIRATION_NEVER; import static android.net.dhcp.DhcpLease.EXPIRATION_NEVER; import static android.net.dhcp.DhcpLease.inet4AddrToString; import static android.net.dhcp.DhcpLease.inet4AddrToString; import static android.net.shared.Inet4AddressUtils.inet4AddressToIntHTH; import static android.net.shared.Inet4AddressUtils.intToInet4AddressHTH; import static android.net.shared.Inet4AddressUtils.prefixLengthToV4NetmaskIntHTH; import static com.android.net.module.util.Inet4AddressUtils.inet4AddressToIntHTH; import static com.android.net.module.util.Inet4AddressUtils.intToInet4AddressHTH; import static com.android.net.module.util.Inet4AddressUtils.prefixLengthToV4NetmaskIntHTH; import static com.android.server.util.NetworkStackConstants.IPV4_ADDR_ANY; import static com.android.server.util.NetworkStackConstants.IPV4_ADDR_ANY; import static com.android.server.util.NetworkStackConstants.IPV4_ADDR_BITS; import static com.android.server.util.NetworkStackConstants.IPV4_ADDR_BITS; Loading