Move trimV4AddrZeros to libs/net
The utility is @UnsupportedAppUsage, and also used by internal classes like WifiTrackerLib or Mms, so it needs to be in a shared location. Bug: 182859030 Test: m Change-Id: I25cb374f4743a5869e9da5b01d3a543a9a165c0e
This commit is contained in:
@@ -323,22 +323,7 @@ public class NetworkUtils {
|
||||
*/
|
||||
@UnsupportedAppUsage
|
||||
public static String trimV4AddrZeros(String addr) {
|
||||
if (addr == null) return null;
|
||||
String[] octets = addr.split("\\.");
|
||||
if (octets.length != 4) return addr;
|
||||
StringBuilder builder = new StringBuilder(16);
|
||||
String result = null;
|
||||
for (int i = 0; i < 4; i++) {
|
||||
try {
|
||||
if (octets[i].length() > 3) return addr;
|
||||
builder.append(Integer.parseInt(octets[i]));
|
||||
} catch (NumberFormatException e) {
|
||||
return addr;
|
||||
}
|
||||
if (i < 3) builder.append('.');
|
||||
}
|
||||
result = builder.toString();
|
||||
return result;
|
||||
return Inet4AddressUtils.trimAddressZeros(addr);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user