BT settings wait for HS service before connect.  DO NOT MERGE

Bluetooth connections from Settings app can sometimes fail if the
connection to BluetoothHeadsetService isn't ready. Changed code to
delay any headset connect or disconnect attempt when the service isn't
connected until onServiceConnected() is called.

Tested by adding a call to Thread.sleep(5000) before the return
statement in BluetoothHeadsetService.onBind(). This makes it easier to
kill the phone process and then attempt to connect in the settings app
before the service restarts.

Bug: 3048839
Change-Id: I2114ff8ad67c8c672fcf6ce0bf3de61fca7a49b3
1 file changed