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: I2fb674e0d7da0b11ba70177853fd6259bce372a3
This commit is contained in:
Chiachang Wang
2021-02-04 10:01:37 +08:00
parent 3717d5feda
commit 384b88e3fb
3 changed files with 10 additions and 8 deletions

View File

@@ -40,7 +40,6 @@ import android.net.Network;
import android.net.NetworkCapabilities;
import android.net.NetworkInfo;
import android.net.NetworkRequest;
import android.net.NetworkUtils;
import android.net.RouteInfo;
import android.net.Uri;
import android.net.wifi.WifiConfiguration;
@@ -64,6 +63,7 @@ import androidx.preference.PreferenceCategory;
import androidx.preference.PreferenceFragmentCompat;
import androidx.preference.PreferenceScreen;
import com.android.net.module.util.NetUtils;
import com.android.settings.R;
import com.android.settings.Utils;
import com.android.settings.core.FeatureFlags;
@@ -875,7 +875,7 @@ public class WifiDetailPreferenceController2 extends AbstractPreferenceControlle
try {
InetAddress all = InetAddress.getByAddress(
new byte[]{(byte) 255, (byte) 255, (byte) 255, (byte) 255});
return NetworkUtils.getNetworkPart(all, prefixLength).getHostAddress();
return NetUtils.getNetworkPart(all, prefixLength).getHostAddress();
} catch (UnknownHostException e) {
return null;
}