TARGET_SIMULATOR is long dead.

Change-Id: I6ba4a55c865370f12ae30f445661b54bbc714f8a
Fix bug in PAN code where no new PAN connections can be made.

If you call PAN_connect() followed quickly by PAN_disconnect(),
you won't be able to establish any additional PANU connections.
This happens because the connection never has a chance to make
it into PAN_STATE_CONNECTED and num_conns only gets decremented
if you disconnect in the connected state. As a result, subsequent
calls to connect will fail because the stack still believes there
to be an existing connection.

Change-Id: Id24873828ca4f517496cb19a44993d0e8e837a1e
Fix uipc.c to never pass -1 to FD_ISSET.

The behavior of FD_ISSET when passed -1 is undefined.

I checked all calls of FD_SET and FD_CLR in this file, and they all
seem to be correctly guarded. None of the FD_ISSET calls were, so I
added a SAFE_FD_ISSET macro to return false when passed -1, which is
presumably what the callers intended.

This allows Bluetooth to be enabled on a device where the C library
aborts if passed any out of range fd.

Bug: 11047121
Change-Id: I261404a5a80884d5e9edab8beb3c93969113dc76
Use 0000 as pin key for PORCHE_PAIRING_CONFLICT issue

For PORCHE_PAIRING_CONFLICT issue when there are no other paired devices
available in bluetooth list pairing always fails (as per implementation
in bluedroid stack).
In this case when pin key request is received use 0000 as the pin key
so that pairing is successful.

Bug 67614

Change-Id: I67b2e689cfcc52c93fdda62dd742812698baa0e6
Don't leak process-private data on Change Local Name command.

The Change Local Name command to the controller doesn't zero out
the contents of the command buffer before setting the contents. As
a result, the controller sees both the new device name and then
random data left over on the heap from previous operations. This
random data may contain sensitive information. Although the device
name is null-terminated, a controller may inadvertently leak the
additional information over the network.

This change fixes the behaviour by zeroing out the entire command
buffer before copying the device name into it. If the device name
doesn't occupy the entire buffer, the rest of it will be zero.

http://b/12949068

Change-Id: I4dd6ce6dd6709589fcd1e23f974db820820bc8e1