diff options
author | James Mattis <jmattis@google.com> | 2022-01-20 16:25:05 -0800 |
---|---|---|
committer | James Mattis <jmattis@google.com> | 2022-02-01 21:10:18 -0800 |
commit | 0806138c1c0b9ecbf43f9b093bb0b4b01ecb68c6 (patch) | |
tree | bf4f3189fa67e2d31176ede6479697f1ac70da5d /java/com/android/server/ethernet/EthernetTracker.java | |
parent | 2143e4ff69eefb3f81c58d631af62155c46ecd86 (diff) | |
download | ethernet-0806138c1c0b9ecbf43f9b093bb0b4b01ecb68c6.tar.gz |
Implementation of Eth Connect & Disconnect Network
Implementation of EthernetService APIs for ConnectNetwork() and
DisconnectNetwork().
Bug: 210485380
Test: atest EthernetServiceTests
Change-Id: I4c3e361d052206cb28b97fc439bfeac8e7e0fec0
Diffstat (limited to 'java/com/android/server/ethernet/EthernetTracker.java')
-rw-r--r-- | java/com/android/server/ethernet/EthernetTracker.java | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/java/com/android/server/ethernet/EthernetTracker.java b/java/com/android/server/ethernet/EthernetTracker.java index 53af955..9784512 100644 --- a/java/com/android/server/ethernet/EthernetTracker.java +++ b/java/com/android/server/ethernet/EthernetTracker.java @@ -190,6 +190,18 @@ public class EthernetTracker { mFactory.updateInterface(iface, ipConfig, capabilities, listener)); } + @VisibleForTesting(visibility = PACKAGE) + protected void connectNetwork(@NonNull final String iface, + @Nullable final IInternalNetworkManagementListener listener) { + mHandler.post(() -> updateInterfaceState(iface, true, listener)); + } + + @VisibleForTesting(visibility = PACKAGE) + protected void disconnectNetwork(@NonNull final String iface, + @Nullable final IInternalNetworkManagementListener listener) { + mHandler.post(() -> updateInterfaceState(iface, false, listener)); + } + IpConfiguration getIpConfiguration(String iface) { return mIpConfigurations.get(iface); } @@ -354,9 +366,14 @@ public class EthernetTracker { } private void updateInterfaceState(String iface, boolean up) { + updateInterfaceState(iface, up, null /* listener */); + } + + private void updateInterfaceState(@NonNull final String iface, final boolean up, + @Nullable final IInternalNetworkManagementListener listener) { final int mode = getInterfaceMode(iface); final boolean factoryLinkStateUpdated = (mode == INTERFACE_MODE_CLIENT) - && mFactory.updateInterfaceLinkState(iface, up); + && mFactory.updateInterfaceLinkState(iface, up, listener); if (factoryLinkStateUpdated) { boolean restricted = isRestrictedInterface(iface); |