Fix early termination of while loop in BluetoothSocket#write

While loop exits too early and misses writing remaining bytes.
Also restructured the loop itself to be more readable.

Change-Id: I71e9b331d20b5ae70175450c3346be43ab56c40c
1 file changed