Build ethernet framework source into framework-connectivity-tiramisu
- move ethernet APIs, build it into framework-connectivity-tiramisu - start ethernet service from ConnectivityServiceInitializer - fix EthernetManager dependnecy in Tethering module - fix EthernetNetworkSpecifier dependency in framework-connectivity - fix the ethernet related config resource Bug: 210586283 Test: m Test: atest FrameworksNetTests EthernetServiceTests Change-Id: I54857b8517649048a343c72797668394d5225766 Merged-In: I54857b8517649048a343c72797668394d5225766
This commit is contained in:
@@ -127,6 +127,7 @@ java_sdk_library {
|
||||
"//frameworks/base/tests/vcn",
|
||||
"//frameworks/libs/net/common/testutils",
|
||||
"//frameworks/libs/net/common/tests:__subpackages__",
|
||||
"//frameworks/opt/net/ethernet/tests:__subpackages__",
|
||||
"//frameworks/opt/telephony/tests/telephonytests",
|
||||
"//packages/modules/CaptivePortalLogin/tests",
|
||||
"//packages/modules/Connectivity/Tethering/tests:__subpackages__",
|
||||
|
||||
@@ -61,6 +61,14 @@ package android.app.usage {
|
||||
|
||||
package android.net {
|
||||
|
||||
public final class EthernetNetworkSpecifier extends android.net.NetworkSpecifier implements android.os.Parcelable {
|
||||
ctor public EthernetNetworkSpecifier(@NonNull String);
|
||||
method public int describeContents();
|
||||
method @Nullable public String getInterfaceName();
|
||||
method public void writeToParcel(@NonNull android.os.Parcel, int);
|
||||
field @NonNull public static final android.os.Parcelable.Creator<android.net.EthernetNetworkSpecifier> CREATOR;
|
||||
}
|
||||
|
||||
public final class IpSecAlgorithm implements android.os.Parcelable {
|
||||
ctor public IpSecAlgorithm(@NonNull String, @NonNull byte[]);
|
||||
ctor public IpSecAlgorithm(@NonNull String, @NonNull byte[], int);
|
||||
|
||||
@@ -31,6 +31,22 @@ package android.net {
|
||||
method public static void registerServiceWrappers();
|
||||
}
|
||||
|
||||
public class EthernetManager {
|
||||
method @RequiresPermission(android.Manifest.permission.ACCESS_NETWORK_STATE) public void addInterfaceStateListener(@NonNull java.util.concurrent.Executor, @NonNull android.net.EthernetManager.InterfaceStateListener);
|
||||
method public void removeInterfaceStateListener(@NonNull android.net.EthernetManager.InterfaceStateListener);
|
||||
method public void setIncludeTestInterfaces(boolean);
|
||||
field public static final int ROLE_CLIENT = 1; // 0x1
|
||||
field public static final int ROLE_NONE = 0; // 0x0
|
||||
field public static final int ROLE_SERVER = 2; // 0x2
|
||||
field public static final int STATE_ABSENT = 0; // 0x0
|
||||
field public static final int STATE_LINK_DOWN = 1; // 0x1
|
||||
field public static final int STATE_LINK_UP = 2; // 0x2
|
||||
}
|
||||
|
||||
public static interface EthernetManager.InterfaceStateListener {
|
||||
method public void onInterfaceStateChanged(@NonNull String, int, int, @Nullable android.net.IpConfiguration);
|
||||
}
|
||||
|
||||
public class IpSecManager {
|
||||
field public static final int DIRECTION_FWD = 2; // 0x2
|
||||
}
|
||||
|
||||
@@ -12,6 +12,45 @@ package android.app.usage {
|
||||
|
||||
package android.net {
|
||||
|
||||
public class EthernetManager {
|
||||
method @RequiresPermission(anyOf={android.net.NetworkStack.PERMISSION_MAINLINE_NETWORK_STACK, android.Manifest.permission.NETWORK_STACK, android.Manifest.permission.MANAGE_ETHERNET_NETWORKS}) public void connectNetwork(@NonNull String, @Nullable java.util.concurrent.Executor, @Nullable java.util.function.BiConsumer<android.net.Network,android.net.EthernetNetworkManagementException>);
|
||||
method @RequiresPermission(anyOf={android.net.NetworkStack.PERMISSION_MAINLINE_NETWORK_STACK, android.Manifest.permission.NETWORK_STACK, android.Manifest.permission.MANAGE_ETHERNET_NETWORKS}) public void disconnectNetwork(@NonNull String, @Nullable java.util.concurrent.Executor, @Nullable java.util.function.BiConsumer<android.net.Network,android.net.EthernetNetworkManagementException>);
|
||||
method @NonNull @RequiresPermission(anyOf={android.Manifest.permission.NETWORK_STACK, android.net.NetworkStack.PERMISSION_MAINLINE_NETWORK_STACK}) public android.net.EthernetManager.TetheredInterfaceRequest requestTetheredInterface(@NonNull java.util.concurrent.Executor, @NonNull android.net.EthernetManager.TetheredInterfaceCallback);
|
||||
method @RequiresPermission(anyOf={android.net.NetworkStack.PERMISSION_MAINLINE_NETWORK_STACK, android.Manifest.permission.NETWORK_STACK, android.Manifest.permission.MANAGE_ETHERNET_NETWORKS}) public void updateConfiguration(@NonNull String, @NonNull android.net.EthernetNetworkUpdateRequest, @Nullable java.util.concurrent.Executor, @Nullable java.util.function.BiConsumer<android.net.Network,android.net.EthernetNetworkManagementException>);
|
||||
}
|
||||
|
||||
public static interface EthernetManager.TetheredInterfaceCallback {
|
||||
method public void onAvailable(@NonNull String);
|
||||
method public void onUnavailable();
|
||||
}
|
||||
|
||||
public static class EthernetManager.TetheredInterfaceRequest {
|
||||
method public void release();
|
||||
}
|
||||
|
||||
public final class EthernetNetworkManagementException extends java.lang.RuntimeException implements android.os.Parcelable {
|
||||
ctor public EthernetNetworkManagementException(@NonNull String);
|
||||
method public int describeContents();
|
||||
method public void writeToParcel(@NonNull android.os.Parcel, int);
|
||||
field @NonNull public static final android.os.Parcelable.Creator<android.net.EthernetNetworkManagementException> CREATOR;
|
||||
}
|
||||
|
||||
public final class EthernetNetworkUpdateRequest implements android.os.Parcelable {
|
||||
method public int describeContents();
|
||||
method @NonNull public android.net.IpConfiguration getIpConfiguration();
|
||||
method @Nullable public android.net.NetworkCapabilities getNetworkCapabilities();
|
||||
method public void writeToParcel(@NonNull android.os.Parcel, int);
|
||||
field @NonNull public static final android.os.Parcelable.Creator<android.net.EthernetNetworkUpdateRequest> CREATOR;
|
||||
}
|
||||
|
||||
public static final class EthernetNetworkUpdateRequest.Builder {
|
||||
ctor public EthernetNetworkUpdateRequest.Builder();
|
||||
ctor public EthernetNetworkUpdateRequest.Builder(@NonNull android.net.EthernetNetworkUpdateRequest);
|
||||
method @NonNull public android.net.EthernetNetworkUpdateRequest build();
|
||||
method @NonNull public android.net.EthernetNetworkUpdateRequest.Builder setIpConfiguration(@NonNull android.net.IpConfiguration);
|
||||
method @NonNull public android.net.EthernetNetworkUpdateRequest.Builder setNetworkCapabilities(@Nullable android.net.NetworkCapabilities);
|
||||
}
|
||||
|
||||
public class IpSecManager {
|
||||
method @RequiresPermission(android.Manifest.permission.MANAGE_IPSEC_TUNNELS) public void applyTunnelModeTransform(@NonNull android.net.IpSecManager.IpSecTunnelInterface, int, @NonNull android.net.IpSecTransform) throws java.io.IOException;
|
||||
method @NonNull @RequiresPermission(android.Manifest.permission.MANAGE_IPSEC_TUNNELS) public android.net.IpSecManager.IpSecTunnelInterface createIpSecTunnelInterface(@NonNull java.net.InetAddress, @NonNull java.net.InetAddress, @NonNull android.net.Network) throws java.io.IOException, android.net.IpSecManager.ResourceUnavailableException;
|
||||
|
||||
@@ -86,6 +86,7 @@ java_defaults {
|
||||
],
|
||||
static_libs: [
|
||||
"framework-connectivity-protos",
|
||||
"modules-utils-backgroundthread",
|
||||
"modules-utils-build",
|
||||
"modules-utils-preconditions",
|
||||
],
|
||||
@@ -139,6 +140,7 @@ java_sdk_library {
|
||||
"//frameworks/base/tests/vcn",
|
||||
"//frameworks/libs/net/common/testutils",
|
||||
"//frameworks/libs/net/common/tests:__subpackages__",
|
||||
"//frameworks/opt/net/ethernet/tests:__subpackages__",
|
||||
"//frameworks/opt/telephony/tests/telephonytests",
|
||||
"//packages/modules/CaptivePortalLogin/tests",
|
||||
"//packages/modules/Connectivity/Tethering/tests:__subpackages__",
|
||||
|
||||
@@ -30,6 +30,7 @@ java_library {
|
||||
min_sdk_version: "30",
|
||||
srcs: [
|
||||
"src/**/*.java",
|
||||
":ethernet-service-updatable-sources",
|
||||
":services.connectivity-tiramisu-updatable-sources",
|
||||
],
|
||||
libs: [
|
||||
@@ -39,6 +40,7 @@ java_library {
|
||||
"framework-tethering.stubs.module_lib",
|
||||
"service-connectivity-pre-jarjar",
|
||||
"service-nearby-pre-jarjar",
|
||||
"ServiceConnectivityResources",
|
||||
"unsupportedappusage",
|
||||
],
|
||||
static_libs: [
|
||||
|
||||
@@ -21,6 +21,8 @@ import android.util.Log;
|
||||
|
||||
import com.android.modules.utils.build.SdkLevel;
|
||||
import com.android.networkstack.apishim.ConstantsShim;
|
||||
import com.android.server.ethernet.EthernetService;
|
||||
import com.android.server.ethernet.EthernetServiceImpl;
|
||||
import com.android.server.nearby.NearbyService;
|
||||
|
||||
/**
|
||||
@@ -29,15 +31,19 @@ import com.android.server.nearby.NearbyService;
|
||||
*/
|
||||
public final class ConnectivityServiceInitializer extends SystemService {
|
||||
private static final String TAG = ConnectivityServiceInitializer.class.getSimpleName();
|
||||
private final Context mContext;
|
||||
private final ConnectivityService mConnectivity;
|
||||
private final IpSecService mIpSecService;
|
||||
private final NsdService mNsdService;
|
||||
private final NearbyService mNearbyService;
|
||||
private final EthernetServiceImpl mEthernetServiceImpl;
|
||||
|
||||
public ConnectivityServiceInitializer(Context context) {
|
||||
super(context);
|
||||
mContext = context;
|
||||
// Load JNI libraries used by ConnectivityService and its dependencies
|
||||
System.loadLibrary("service-connectivity");
|
||||
mEthernetServiceImpl = createEthernetService(context);
|
||||
mConnectivity = new ConnectivityService(context);
|
||||
mIpSecService = createIpSecService(context);
|
||||
mNsdService = createNsdService(context);
|
||||
@@ -46,6 +52,12 @@ public final class ConnectivityServiceInitializer extends SystemService {
|
||||
|
||||
@Override
|
||||
public void onStart() {
|
||||
if (mConnectivity.deviceSupportsEthernet(mContext)) {
|
||||
Log.i(TAG, "Registering " + Context.ETHERNET_SERVICE);
|
||||
publishBinderService(Context.ETHERNET_SERVICE, mEthernetServiceImpl,
|
||||
/* allowIsolated= */ false);
|
||||
}
|
||||
|
||||
Log.i(TAG, "Registering " + Context.CONNECTIVITY_SERVICE);
|
||||
publishBinderService(Context.CONNECTIVITY_SERVICE, mConnectivity,
|
||||
/* allowIsolated= */ false);
|
||||
@@ -65,6 +77,7 @@ public final class ConnectivityServiceInitializer extends SystemService {
|
||||
publishBinderService(ConstantsShim.NEARBY_SERVICE, mNearbyService,
|
||||
/* allowIsolated= */ false);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -72,6 +85,10 @@ public final class ConnectivityServiceInitializer extends SystemService {
|
||||
if (mNearbyService != null) {
|
||||
mNearbyService.onBootPhase(phase);
|
||||
}
|
||||
|
||||
if (phase == SystemService.PHASE_SYSTEM_SERVICES_READY && mEthernetServiceImpl != null) {
|
||||
mEthernetServiceImpl.start();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -106,4 +123,15 @@ public final class ConnectivityServiceInitializer extends SystemService {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return EthernetServiceImpl instance or null if current SDK is lower than T or Ethernet
|
||||
* service isn't necessary.
|
||||
*/
|
||||
private EthernetServiceImpl createEthernetService(final Context context) {
|
||||
if (!SdkLevel.isAtLeastT() || !mConnectivity.deviceSupportsEthernet(context)) {
|
||||
return null;
|
||||
}
|
||||
return EthernetService.create(context);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -114,6 +114,7 @@ java_library {
|
||||
"net-utils-device-common",
|
||||
"net-utils-device-common-bpf",
|
||||
"net-utils-device-common-netlink",
|
||||
"net-utils-services-common",
|
||||
"netd-client",
|
||||
"networkstack-client",
|
||||
"PlatformProperties",
|
||||
|
||||
@@ -136,4 +136,36 @@
|
||||
extreme adverse effects on performance of the new network.
|
||||
-->
|
||||
<bool translatable="false" name="config_cellular_radio_timesharing_capable">true</bool>
|
||||
|
||||
<!-- Configure ethernet tcp buffersizes in the form:
|
||||
rmem_min,rmem_def,rmem_max,wmem_min,wmem_def,wmem_max -->
|
||||
<string translatable="false" name="config_ethernet_tcp_buffers">524288,1048576,3145728,524288,1048576,2097152</string>
|
||||
|
||||
<!-- Configuration of Ethernet interfaces in the following format:
|
||||
<interface name|mac address>;[Network Capabilities];[IP config];[Override Transport]
|
||||
Where
|
||||
[Network Capabilities] Optional. A comma separated list of network capabilities.
|
||||
Values must be from NetworkCapabilities#NET_CAPABILITY_* constants.
|
||||
The NOT_ROAMING, NOT_CONGESTED and NOT_SUSPENDED capabilities are always
|
||||
added automatically because this configuration provides no way to update
|
||||
them dynamically.
|
||||
[IP config] Optional. If empty or not specified - DHCP will be used, otherwise
|
||||
use the following format to specify static IP configuration:
|
||||
ip=<ip-address/mask> gateway=<ip-address> dns=<comma-sep-ip-addresses>
|
||||
domains=<comma-sep-domains>
|
||||
[Override Transport] Optional. An override network transport type to allow
|
||||
the propagation of an interface type on the other end of a local Ethernet
|
||||
interface. Value must be from NetworkCapabilities#TRANSPORT_* constants. If
|
||||
left out, this will default to TRANSPORT_ETHERNET.
|
||||
-->
|
||||
<string-array translatable="false" name="config_ethernet_interfaces">
|
||||
<!--
|
||||
<item>eth1;12,13,14,15;ip=192.168.0.10/24 gateway=192.168.0.1 dns=4.4.4.4,8.8.8.8</item>
|
||||
<item>eth2;;ip=192.168.0.11/24</item>
|
||||
<item>eth3;12,13,14,15;ip=192.168.0.12/24;1</item>
|
||||
-->
|
||||
</string-array>
|
||||
|
||||
<!-- Regex of wired ethernet ifaces -->
|
||||
<string translatable="false" name="config_ethernet_iface_regex">eth\\d</string>
|
||||
</resources>
|
||||
|
||||
@@ -37,6 +37,9 @@
|
||||
<item type="drawable" name="stat_notify_wifi_in_range"/>
|
||||
<item type="drawable" name="stat_notify_rssi_in_range"/>
|
||||
<item type="bool" name="config_cellular_radio_timesharing_capable" />
|
||||
<item type="string" name="config_ethernet_tcp_buffers"/>
|
||||
<item type="array" name="config_ethernet_interfaces"/>
|
||||
<item type="string" name="config_ethernet_iface_regex"/>
|
||||
</policy>
|
||||
</overlayable>
|
||||
</resources>
|
||||
|
||||
@@ -936,7 +936,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
||||
}
|
||||
// Ethernet is often not specified in the configs, although many devices can use it via
|
||||
// USB host adapters. Add it as long as the ethernet service is here.
|
||||
if (ctx.getSystemService(Context.ETHERNET_SERVICE) != null) {
|
||||
if (deviceSupportsEthernet(ctx)) {
|
||||
addSupportedType(TYPE_ETHERNET);
|
||||
}
|
||||
|
||||
@@ -1621,6 +1621,15 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
||||
mContext);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check whether or not the device supports Ethernet transport.
|
||||
*/
|
||||
public static boolean deviceSupportsEthernet(final Context context) {
|
||||
final PackageManager pm = context.getPackageManager();
|
||||
return pm.hasSystemFeature(PackageManager.FEATURE_ETHERNET)
|
||||
|| pm.hasSystemFeature(PackageManager.FEATURE_USB_HOST);
|
||||
}
|
||||
|
||||
private static NetworkCapabilities createDefaultNetworkCapabilitiesForUid(int uid) {
|
||||
return createDefaultNetworkCapabilitiesForUidRangeSet(Collections.singleton(
|
||||
new UidRange(uid, uid)));
|
||||
|
||||
@@ -36,6 +36,7 @@ import static android.content.Intent.ACTION_USER_ADDED;
|
||||
import static android.content.Intent.ACTION_USER_REMOVED;
|
||||
import static android.content.Intent.ACTION_USER_UNLOCKED;
|
||||
import static android.content.pm.PackageInfo.REQUESTED_PERMISSION_GRANTED;
|
||||
import static android.content.pm.PackageManager.FEATURE_ETHERNET;
|
||||
import static android.content.pm.PackageManager.FEATURE_WIFI;
|
||||
import static android.content.pm.PackageManager.FEATURE_WIFI_DIRECT;
|
||||
import static android.content.pm.PackageManager.GET_PERMISSIONS;
|
||||
@@ -1739,6 +1740,7 @@ public class ConnectivityServiceTest {
|
||||
mockDefaultPackages();
|
||||
mockHasSystemFeature(FEATURE_WIFI, true);
|
||||
mockHasSystemFeature(FEATURE_WIFI_DIRECT, true);
|
||||
mockHasSystemFeature(FEATURE_ETHERNET, true);
|
||||
doReturn(true).when(mTelephonyManager).isDataCapable();
|
||||
|
||||
FakeSettingsProvider.clearSettingsProvider();
|
||||
|
||||
@@ -23,6 +23,8 @@ package com.android.server
|
||||
|
||||
import android.content.Context
|
||||
import android.content.pm.PackageManager
|
||||
import android.content.pm.PackageManager.FEATURE_ETHERNET
|
||||
import android.content.pm.PackageManager.FEATURE_USB_HOST
|
||||
import android.content.pm.PackageManager.FEATURE_WIFI
|
||||
import android.content.pm.PackageManager.FEATURE_WIFI_DIRECT
|
||||
import android.net.ConnectivityManager.TYPE_ETHERNET
|
||||
@@ -40,7 +42,6 @@ import android.net.ConnectivityManager.TYPE_VPN
|
||||
import android.net.ConnectivityManager.TYPE_WIFI
|
||||
import android.net.ConnectivityManager.TYPE_WIFI_P2P
|
||||
import android.net.ConnectivityManager.TYPE_WIMAX
|
||||
import android.net.EthernetManager
|
||||
import android.net.NetworkInfo.DetailedState.CONNECTED
|
||||
import android.net.NetworkInfo.DetailedState.DISCONNECTED
|
||||
import android.os.Build
|
||||
@@ -82,9 +83,8 @@ class LegacyTypeTrackerTest {
|
||||
private val mContext = mock(Context::class.java).apply {
|
||||
doReturn(true).`when`(mPm).hasSystemFeature(FEATURE_WIFI)
|
||||
doReturn(true).`when`(mPm).hasSystemFeature(FEATURE_WIFI_DIRECT)
|
||||
doReturn(true).`when`(mPm).hasSystemFeature(FEATURE_ETHERNET)
|
||||
doReturn(mPm).`when`(this).packageManager
|
||||
doReturn(mock(EthernetManager::class.java)).`when`(this).getSystemService(
|
||||
Context.ETHERNET_SERVICE)
|
||||
}
|
||||
private val mTm = mock(TelephonyManager::class.java).apply {
|
||||
doReturn(true).`when`(this).isDataCapable
|
||||
@@ -105,7 +105,8 @@ class LegacyTypeTrackerTest {
|
||||
|
||||
@Test
|
||||
fun testSupportedTypes_NoEthernet() {
|
||||
doReturn(null).`when`(mContext).getSystemService(Context.ETHERNET_SERVICE)
|
||||
doReturn(false).`when`(mPm).hasSystemFeature(FEATURE_ETHERNET)
|
||||
doReturn(false).`when`(mPm).hasSystemFeature(FEATURE_USB_HOST)
|
||||
assertFalse(makeTracker().isTypeSupported(TYPE_ETHERNET))
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user