Skip to content

Commit

Permalink
Move Inet[4]AddressUtils to libs/net
Browse files Browse the repository at this point in the history
The classes should not be picked up from frameworks/base, as they are
part of several mainline modules.

Also refine comments in DhcpResults following feedback in previous
change.

Bug: 151052811
Test: m; manual: flashed, wifi and telephony working
Test: atest NetworkStackCoverageTests
Change-Id: I7074651c6a2a7a6b11bcf13cc4bb03833d7d655f
  • Loading branch information
RemiNVG committed Jun 12, 2020
1 parent 0109b8d commit eee629f
Show file tree
Hide file tree
Showing 15 changed files with 29 additions and 257 deletions.
4 changes: 0 additions & 4 deletions Android.bp
Original file line number Diff line number Diff line change
Expand Up @@ -700,15 +700,13 @@ filegroup {
"core/java/com/android/internal/util/TrafficStatsConstants.java",
"core/java/com/android/internal/util/WakeupMessage.java",
"core/java/com/android/internal/util/TokenBucket.java",
"core/java/android/net/shared/*.java",
],
}

filegroup {
name: "framework-services-net-module-wifi-shared-srcs",
srcs: [
"core/java/android/net/DhcpResults.java",
"core/java/android/net/shared/InetAddressUtils.java",
"core/java/android/net/util/IpUtils.java",
"core/java/android/util/LocalLog.java",
],
Expand All @@ -725,7 +723,6 @@ filegroup {
"core/java/com/android/internal/util/State.java",
"core/java/com/android/internal/util/StateMachine.java",
"core/java/com/android/internal/util/TrafficStatsConstants.java",
"core/java/android/net/shared/Inet4AddressUtils.java",
],
}

Expand Down Expand Up @@ -1162,7 +1159,6 @@ java_library {
srcs: [
"core/java/android/content/pm/BaseParceledListSlice.java",
"core/java/android/content/pm/ParceledListSlice.java",
"core/java/android/net/shared/Inet4AddressUtils.java",
"core/java/android/os/HandlerExecutor.java",
"core/java/com/android/internal/util/AsyncChannel.java",
"core/java/com/android/internal/util/AsyncService.java",
Expand Down
3 changes: 2 additions & 1 deletion core/java/android/net/DhcpResults.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,13 @@

import android.annotation.Nullable;
import android.compat.annotation.UnsupportedAppUsage;
import android.net.shared.InetAddressUtils;
import android.os.Parcel;
import android.os.Parcelable;
import android.text.TextUtils;
import android.util.Log;

import com.android.net.module.util.InetAddressUtils;

import java.net.Inet4Address;
import java.net.InetAddress;
import java.util.ArrayList;
Expand Down
3 changes: 2 additions & 1 deletion core/java/android/net/NetworkUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,14 @@

import android.annotation.NonNull;
import android.compat.annotation.UnsupportedAppUsage;
import android.net.shared.Inet4AddressUtils;
import android.os.Build;
import android.system.ErrnoException;
import android.system.Os;
import android.util.Log;
import android.util.Pair;

import com.android.net.module.util.Inet4AddressUtils;

import java.io.FileDescriptor;
import java.math.BigInteger;
import java.net.Inet4Address;
Expand Down
2 changes: 1 addition & 1 deletion core/java/android/net/StaticIpConfiguration.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@
import android.annotation.SystemApi;
import android.annotation.TestApi;
import android.compat.annotation.UnsupportedAppUsage;
import android.net.shared.InetAddressUtils;
import android.os.Parcel;
import android.os.Parcelable;

import com.android.internal.util.Preconditions;
import com.android.net.module.util.InetAddressUtils;

import java.net.InetAddress;
import java.util.ArrayList;
Expand Down
166 changes: 0 additions & 166 deletions core/java/android/net/shared/Inet4AddressUtils.java

This file was deleted.

58 changes: 0 additions & 58 deletions core/java/android/net/shared/InetAddressUtils.java

This file was deleted.

18 changes: 6 additions & 12 deletions packages/Tethering/jarjar-rules.txt
Original file line number Diff line number Diff line change
@@ -1,17 +1,11 @@
# These must be kept in sync with the framework-tethering-shared-srcs filegroup.
# If there are files in that filegroup that do not appear here, the classes in the
# Classes from the framework-tethering-shared-srcs filegroup.
# If there are files in that filegroup that are not covered below, the classes in the
# module will be overwritten by the ones in the framework.
# Don't jar-jar the entire package because tethering still use some internal classes
# (like TrafficStatsConstants in com.android.internal.util)
# TODO: simply these when tethering is built as system_current.
rule com.android.internal.util.BitUtils* com.android.networkstack.tethering.util.BitUtils@1
rule com.android.internal.util.IndentingPrintWriter.java* com.android.networkstack.tethering.util.IndentingPrintWriter.java@1
rule com.android.internal.util.IState.java* com.android.networkstack.tethering.util.IState.java@1
rule com.android.internal.util.MessageUtils* com.android.networkstack.tethering.util.MessageUtils@1
rule com.android.internal.util.State* com.android.networkstack.tethering.util.State@1
rule com.android.internal.util.StateMachine* com.android.networkstack.tethering.util.StateMachine@1
rule com.android.internal.util.TrafficStatsConstants* com.android.networkstack.tethering.util.TrafficStatsConstants@1

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

rule android.net.shared.Inet4AddressUtils* com.android.networkstack.tethering.shared.Inet4AddressUtils@1

# Classes from net-utils-framework-common
rule com.android.net.module.util.** com.android.networkstack.tethering.util.@1
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

package android.net.dhcp;

import static android.net.shared.Inet4AddressUtils.inet4AddressToIntHTH;
import static com.android.net.module.util.Inet4AddressUtils.inet4AddressToIntHTH;

import android.net.LinkAddress;
import android.util.ArraySet;
Expand Down
3 changes: 2 additions & 1 deletion packages/Tethering/src/android/net/ip/IpServer.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,14 @@
import static android.net.RouteInfo.RTN_UNICAST;
import static android.net.TetheringManager.TetheringRequest.checkStaticAddressConfiguration;
import static android.net.dhcp.IDhcpServer.STATUS_SUCCESS;
import static android.net.shared.Inet4AddressUtils.intToInet4AddressHTH;
import static android.net.util.NetworkConstants.RFC7421_PREFIX_LENGTH;
import static android.net.util.NetworkConstants.asByte;
import static android.net.util.PrefixUtils.asIpPrefix;
import static android.net.util.TetheringMessageBase.BASE_IPSERVER;
import static android.system.OsConstants.RT_SCOPE_UNIVERSE;

import static com.android.net.module.util.Inet4AddressUtils.intToInet4AddressHTH;

import android.net.INetd;
import android.net.INetworkStackStatusCallback;
import android.net.IpPrefix;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@
import static android.net.netlink.StructNdMsg.NUD_FAILED;
import static android.net.netlink.StructNdMsg.NUD_REACHABLE;
import static android.net.netlink.StructNdMsg.NUD_STALE;
import static android.net.shared.Inet4AddressUtils.intToInet4AddressHTH;

import static com.android.net.module.util.Inet4AddressUtils.intToInet4AddressHTH;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
import static android.net.TetheringManager.TETHER_HARDWARE_OFFLOAD_STARTED;
import static android.net.TetheringManager.TETHER_HARDWARE_OFFLOAD_STOPPED;
import static android.net.dhcp.IDhcpServer.STATUS_SUCCESS;
import static android.net.shared.Inet4AddressUtils.intToInet4AddressHTH;
import static android.net.wifi.WifiManager.EXTRA_WIFI_AP_INTERFACE_NAME;
import static android.net.wifi.WifiManager.EXTRA_WIFI_AP_MODE;
import static android.net.wifi.WifiManager.EXTRA_WIFI_AP_STATE;
Expand All @@ -48,6 +47,7 @@
import static android.net.wifi.WifiManager.WIFI_AP_STATE_ENABLED;
import static android.telephony.SubscriptionManager.INVALID_SUBSCRIPTION_ID;

import static com.android.net.module.util.Inet4AddressUtils.intToInet4AddressHTH;
import static com.android.networkstack.tethering.TetheringNotificationUpdater.DOWNSTREAM_NONE;
import static com.android.networkstack.tethering.UpstreamNetworkMonitor.EVENT_ON_CAPABILITIES;

Expand Down
13 changes: 7 additions & 6 deletions services/net/java/android/net/ip/IpClientCallbacks.java
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,13 @@ public void onPostDhcpAction() {}
*/
public void onNewDhcpResults(DhcpResultsParcelable dhcpResults) {
// In general callbacks would not use a parcelable directly (DhcpResultsParcelable), and
// would use a wrapper instead. But there are already two classes in the tree for DHCP
// information: DhcpInfo and DhcpResults, and each of them do not expose an appropriate API
// (they are bags of mutable fields and can't be changed because they are public API and
// @UnsupportedAppUsage). Adding a third class would cost more than the gain considering
// that the only client of this callback is WiFi, which will end up converting the results
// to DhcpInfo anyway.
// would use a wrapper instead, because of the lack of safety of stable parcelables. But
// there are already two classes in the tree for DHCP information: DhcpInfo and DhcpResults,
// and neither of them exposes an appropriate API (they are bags of mutable fields and can't
// be changed because they are public API and @UnsupportedAppUsage, being no better than the
// stable parcelable). Adding a third class would cost more than the gain considering that
// the only client of this callback is WiFi, which will end up converting the results to
// DhcpInfo anyway.
}

/**
Expand Down
Loading

0 comments on commit eee629f

Please sign in to comment.