Bluetooth event loop dispatches dbus data on wakeup

On some occasions when the event loop thread and a binder thread are
both waiting for a message from dbus, both threads are not woken up
when a message is received. This causes applications not receiving
responses or events. This happens because both threads are listening
to same socket and both threads are not guaranteed to wake up when
there is data to read. To fix this we subscribe to callback to wake
the eventloop when an message is added to incoming queue.

To reproduce the issue:
1. Activate BT
2. Make phone Discoverable
3. Clock is ticking down from 120s
4. At 20s tap the setting again
5. Crash due to keyDispatchingTimedOut
6. Not possible to scan for other devices or making your phone discoverable again
7. Restart necessary

Tell tale sign:
07-25 16:37:12.240 E/ActivityManager( 262): ANR in com.android.settings
    (com.android.settings/.bluetooth.BluetoothSettings)
07-25 16:37:12.240 E/ActivityManager( 262): Reason: keyDispatchingTimedOut

Test case to verify this patch:
android.bluetooth.BluetoothStressTest#testDiscoverable

Change-Id: I7696b5722805e85cd0204ce2597e91594cbe6789
1 file changed