damonkohler / sl4a

SL4A brings scripting languages to Android by allowing you to edit and execute scripts and interactive interpreters directly on the Android device.
Apache License 2.0
2.42k stars 804 forks source link

Bluetooth Crash #217

Open damonkohler opened 9 years ago

damonkohler commented 9 years ago

From @GoogleCodeExporter on May 31, 2015 11:27

The following program will reportedly cause the Terminal to seize up after 
calling droid.bluetoothWrite(result + '\n').

import android
import time

print 'print works at this point'
droid = android.Android()
droid.toggleBluetoothState(True)
droid.dialogCreateAlert('Be a server?')
droid.dialogSetPositiveButtonText('Yes')
droid.dialogSetNegativeButtonText('No')
droid.dialogShow()
result = droid.dialogGetResponse()
is_server = result.result['which'] == 'positive'
if is_server:
 droid.bluetoothMakeDiscoverable()
 droid.bluetoothAccept()
else:
 droid.bluetoothConnect('00001101-0000-1000-8000-00805F9B34FB')

if is_server:
 result = droid.getInput('Chat', 'Enter a message').result
 if result is None:
   droid.exit()
 droid.bluetoothWrite(result + '\n')

print 'print stops working at this point, printing one character then
nothing ever again'

while True:
 droid.makeToast("attempting read")
 if droid.bluetoothReadReady():
   print droid.bluetoothRead()

 result = droid.getInput('Chat', 'Enter a message').result
 if result is None:
   break
 droid.bluetoothWrite(result + '\r' + '\n')

droid.exit()

Original issue reported on code.google.com by damonkoh...@gmail.com on 6 Sep 2010 at 7:42

Copied from original issue: damonkohler/android-scripting#418