Fix Inet6AddressImpl.lookupAllHostAddr() to accept [] in IPv6 hosts.

The method tolerated optional [ ] around numeric IPv6 addresses until
CL [1] changed that. This behavior change was probably accidental since
CL [1] was a refactoring; it broke InetAddressTest.test_getByName_valid().

This CL reverts the behavior change by reusing logic from a previously
private method InetAddress.parseNumericAddressStripOptionalBrackets().
The method is moved to InetAdddressUtils and renamed that it also
does not throw. The logic that dealt with null or empty addresses
is moved into a private helper method InetAddress._parseNumericAddress()
because Inet6AddressImpl.lookupAllHostAddr() already does its own
check for null / "" and the logic used before CL [1] was built on top of
InetAddress.parseNumericAddressNoThrow() which didn't duplicate the
null / "" check, either.

[1] http://r.android.com/845943 commit a4df237dd8a022d0bfc408de28d40df9c6354c52

Bug: 122277354
Bug: 121326251

Test: atest CtsLibcoreTestCases:libcore.java.net.InetAddressTest
Test: atest CtsLibcoreTestCases

Change-Id: I9e1e758969c1efcc3455b3393323f44b2e5bca44
3 files changed