Move Ethernet related files to f/b/packages/ConnectivityT.

ethernet-service is going to be moved into Connectivity mainline module.
Move all ethernet related files in f/b/ to f/b/packages/ConnectivityT so
that it's easier to migrate these files to Connectivity module finally
after clearing the hidden API usages. Below files to be moved:

Ethernet framework related files:
    - EthernetManager.java
    - EthernetNetworkSpecifier.java
    - IEthernetManager.aidl
    - IEthernetServiceListener.aidl
    - ITetheredInterfaceCallback.aidl

Ethernet service related files:
    - IpConfigStore.java(EthernetConfigStore has dependency on the class)

For the ethernet-service related files, keep it as-is temproraliy and
fix the hiden API dependencies in f/opt/net/ethernet/. After this work
is done, then migrating the whole of ethernet folder to Connectivity
module completely.

This CL also fixes some minor errors of code style format to pass the
code style check.

Bug: 210586283
Test: build pass
      atest FrameworksNetTests
      atest EthernetServiceTests
Change-Id: Ib359d29d5221105f648bc4194c6d6dbe4cc6e3e5
This commit is contained in:
Xiao Ma
2021-12-14 09:38:32 +00:00
parent 25c2be8f36
commit 202317df53
8 changed files with 54 additions and 10 deletions

View File

@@ -114,6 +114,23 @@ filegroup {
],
}
// Ethernet related libraries.
filegroup {
name: "framework-connectivity-ethernet-sources",
srcs: [
"src/android/net/EthernetManager.java",
"src/android/net/EthernetNetworkSpecifier.java",
"src/android/net/IEthernetManager.aidl",
"src/android/net/IEthernetServiceListener.aidl",
"src/android/net/ITetheredInterfaceCallback.aidl",
],
path: "src",
visibility: [
"//visibility:private",
],
}
// Connectivity-T common libraries.
filegroup {
@@ -130,6 +147,7 @@ filegroup {
filegroup {
name: "framework-connectivity-tiramisu-sources",
srcs: [
":framework-connectivity-ethernet-sources",
":framework-connectivity-ipsec-sources",
":framework-connectivity-netstats-sources",
":framework-connectivity-nsd-sources",

View File

@@ -61,11 +61,25 @@ filegroup {
],
}
// Ethernet related libraries.
filegroup {
name: "services.connectivity-ethernet-sources",
srcs: [
"src/com/android/server/net/IpConfigStore.java",
],
path: "src",
visibility: [
"//frameworks/opt/net/ethernet",
],
}
// Connectivity-T common libraries.
filegroup {
name: "services.connectivity-tiramisu-sources",
srcs: [
":services.connectivity-ethernet-sources",
":services.connectivity-ipsec-sources",
":services.connectivity-netstats-sources",
":services.connectivity-nsd-sources",

View File

@@ -44,6 +44,9 @@ import java.net.InetAddress;
import java.util.ArrayList;
import java.util.List;
/**
* This class provides an API to store and manage L3 network IP configuration.
*/
public class IpConfigStore {
private static final String TAG = "IpConfigStore";
private static final boolean DBG = false;
@@ -78,6 +81,9 @@ public class IpConfigStore {
return writeConfig(out, configKey, config, IPCONFIG_FILE_VERSION);
}
/**
* Write the IP configuration with the given parameters to {@link DataOutputStream}.
*/
@VisibleForTesting
public static boolean writeConfig(DataOutputStream out, String configKey,
IpConfiguration config, int version) throws IOException {
@@ -177,7 +183,7 @@ public class IpConfigStore {
}
/**
* @Deprecated use {@link #writeIpConfigurations(String, ArrayMap)} instead.
* @deprecated use {@link #writeIpConfigurations(String, ArrayMap)} instead.
* New method uses string as network identifier which could be interface name or MAC address or
* other token.
*/
@@ -186,22 +192,28 @@ public class IpConfigStore {
final SparseArray<IpConfiguration> networks) {
mWriter.write(filePath, out -> {
out.writeInt(IPCONFIG_FILE_VERSION);
for(int i = 0; i < networks.size(); i++) {
for (int i = 0; i < networks.size(); i++) {
writeConfig(out, String.valueOf(networks.keyAt(i)), networks.valueAt(i));
}
});
}
/**
* Write the IP configuration associated to the target networks to the destination path.
*/
public void writeIpConfigurations(String filePath,
ArrayMap<String, IpConfiguration> networks) {
mWriter.write(filePath, out -> {
out.writeInt(IPCONFIG_FILE_VERSION);
for(int i = 0; i < networks.size(); i++) {
for (int i = 0; i < networks.size(); i++) {
writeConfig(out, networks.keyAt(i), networks.valueAt(i));
}
});
}
/**
* Read the IP configuration from the destination path to {@link BufferedInputStream}.
*/
public static ArrayMap<String, IpConfiguration> readIpConfigurations(String filePath) {
BufferedInputStream bufferedInputStream;
try {
@@ -215,7 +227,7 @@ public class IpConfigStore {
return readIpConfigurations(bufferedInputStream);
}
/** @Deprecated use {@link #readIpConfigurations(String)} */
/** @deprecated use {@link #readIpConfigurations(String)} */
@Deprecated
public static SparseArray<IpConfiguration> readIpAndProxyConfigurations(String filePath) {
BufferedInputStream bufferedInputStream;
@@ -230,7 +242,7 @@ public class IpConfigStore {
return readIpAndProxyConfigurations(bufferedInputStream);
}
/** @Deprecated use {@link #readIpConfigurations(InputStream)} */
/** @deprecated use {@link #readIpConfigurations(InputStream)} */
@Deprecated
public static SparseArray<IpConfiguration> readIpAndProxyConfigurations(
InputStream inputStream) {
@@ -420,7 +432,7 @@ public class IpConfigStore {
if (in != null) {
try {
in.close();
} catch (Exception e) {}
} catch (Exception e) { }
}
}