libcutils: add socket_get_local_port().

Tests that require a local server currently hardcode a test value,
which can run into conflicts depending on what's currently running on
the machine.

This CL adds socket_get_local_port(), which lets us pass 0 so the
system picks an open port and we can query which port it chose.

Bug: http://b/26236380
Change-Id: I01d1558884e7636081d9a357db6faa86929934f6
diff --git a/include/cutils/sockets.h b/include/cutils/sockets.h
index e25c555..6cffe12 100644
--- a/include/cutils/sockets.h
+++ b/include/cutils/sockets.h
@@ -132,6 +132,11 @@
 int socket_set_receive_timeout(cutils_socket_t sock, int timeout_ms);
 
 /*
+ * Returns the local port the socket is bound to or -1 on error.
+ */
+int socket_get_local_port(cutils_socket_t sock);
+
+/*
  * socket_peer_is_trusted - Takes a socket which is presumed to be a
  * connected local socket (e.g. AF_LOCAL) and returns whether the peer
  * (the userid that owns the process on the other end of that socket)