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.44k stars 800 forks source link

In remote server mode bluetoothActiveConnections() lies after script reconnect #70

Closed damonkohler closed 9 years ago

damonkohler commented 9 years ago

From @GoogleCodeExporter on May 31, 2015 11:31

SL4A r6

How to reproduce:
1. Start SL4A in remote public server
2. Connect to remote public server (e.g. run script)
3. Connect to BT device - 
bluetoothConnect('00001101-0000-1000-8000-00805F9B34FB', BT_MAC)
4. bluetoothActiveConnections() returns actual info - All ok:
<<client: sent: "{"params":[],"method":"bluetoothActiveConnections","id":4}">>
<<client: rcvd: 
"{"error":null,"id":4,"result":{"39c68254-9507-481c-8e4f-1cb04e8111a0":"00:12:02
:10:03:65"}}">>
$result = {
            'error' => undef,
            'id' => 4,
            'result' => {
                          '39c68254-9507-481c-8e4f-1cb04e8111a0' => '00:12:02:10:03:65'
                        }
          };
5. Disconnect to remote public server (e.g. terminate script)
6. Reconnect to remote public server (e.g. run script again)
7. bluetoothConnect('00001101-0000-1000-8000-00805F9B34FB', BT_MAC) will fail 
with "bluetoothConnect('00001101-0000-1000-8000-00805F9B34FB', BT_MAC)" - It's 
OK, since we already do this at step #3
8. If run bluetoothActiveConnections() - it will tell me "NO active 
connections" - WRONG:
<<client: sent: "{"params":[],"method":"bluetoothActiveConnections","id":1}">>
<<client: rcvd: "{"error":null,"id":1,"result":{}}">>
$result = {
            'error' => undef,
            'id' => 1,
            'result' => {}
          };

Perl script:
===========================
use strict;
use warnings;

use Android;
local $| = 1;

my  $droid   = Android->new();

my  $res = $droid->bluetoothActiveConnections();

    $res = $droid->bluetoothConnect('00001101-0000-1000-8000-00805F9B34FB', '00:12:02:10:03:65');
    exit if (defined($res->{error}));

my  $bt_id = $res->{result};

    $res = $droid->bluetoothActiveConnections();

    $droid->bluetoothWrite("Hello!\n\r", $bt_id);

    exit;

Original issue reported on code.google.com by amurch...@gmail.com on 26 Aug 2012 at 6:54

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

damonkohler commented 9 years ago

This issue was moved to damonkohler/sl4a#69