Fix bug with bind()/connect() and IPv4 addresses

Our standard utilities for converting InetAddress to sockaddr convert
IPv4 addresses to IPv4-mapped sockaddr_in6 instances.  This works fine
for most use cases, but when calling functions with AF_INET (aka IPv4)
sockets returned from Libcore.os.socket(), they need to be given a
sockaddr_in or they fail with EAFNOSUPPORT.

We have a utility to deal with this (NET_IPV4_FALLBACK), but the
versions of bind() and connect() that took SocketAddress instances
instead of InetAddress instances didn't use it.  Follow the lead of
sendTo() and convert InetSocketAddress instances to InetAddress/port
pairs and call the InetAddress version of the call so we get the
benefit of NET_IPV4_FALLBACK.

Bug: 123562238
Test: cts -m CtsLibcoreTestCases
Change-Id: Ib8c1fda7be3dda8e6eee31fd15f2d0c4567a5712
2 files changed