Replace NetworkUtils methods

NetworkUtils is moved to connectivity mainline module which is
not accessible for module outside. getNetworkPart() method is
used by wifi lib and Settings but no usage inside the module,
so move the method to framework lib to share with wifi lib and
Settings.

Also, NetworkUtils.numericToInetAddress() method is also hidden
and deprecated. It should be replaced by
InetAddresses.parseNumericAddress().

Update the corresponding usage to refer to these methods.

Bug: 172183305
Test: atest SettingsRoboTests
Change-Id: I8240b1c74b53d5d66850d9a3ec7d5e5c11558e6a
Merged-In: I2fb674e0d7da0b11ba70177853fd6259bce372a3
This commit is contained in:
Chiachang Wang
2021-02-03 18:08:59 +08:00
parent ace5a90870
commit 0f40c023f6
4 changed files with 12 additions and 10 deletions

View File

@@ -18,12 +18,12 @@ package com.android.settings.wifi;
import android.content.Context;
import android.content.res.Resources;
import android.net.InetAddresses;
import android.net.IpConfiguration;
import android.net.IpConfiguration.IpAssignment;
import android.net.IpConfiguration.ProxySettings;
import android.net.LinkAddress;
import android.net.NetworkInfo.DetailedState;
import android.net.NetworkUtils;
import android.net.ProxyInfo;
import android.net.StaticIpConfiguration;
import android.net.Uri;
@@ -69,6 +69,7 @@ import android.widget.TextView;
import androidx.annotation.VisibleForTesting;
import com.android.net.module.util.NetUtils;
import com.android.net.module.util.ProxyUtils;
import com.android.settings.ProxySelector;
import com.android.settings.R;
@@ -898,7 +899,7 @@ public class WifiConfigController implements TextWatcher,
private Inet4Address getIPv4Address(String text) {
try {
return (Inet4Address) NetworkUtils.numericToInetAddress(text);
return (Inet4Address) InetAddresses.parseNumericAddress(text);
} catch (IllegalArgumentException | ClassCastException e) {
return null;
}
@@ -934,7 +935,7 @@ public class WifiConfigController implements TextWatcher,
if (TextUtils.isEmpty(gateway)) {
try {
//Extract a default gateway from IP address
InetAddress netPart = NetworkUtils.getNetworkPart(inetAddr, networkPrefixLength);
InetAddress netPart = NetUtils.getNetworkPart(inetAddr, networkPrefixLength);
byte[] addr = netPart.getAddress();
addr[addr.length - 1] = 1;
mGatewayView.setText(InetAddress.getByAddress(addr).getHostAddress());