adamahani / android-obd-reader

Automatically exported from code.google.com/p/android-obd-reader
0 stars 0 forks source link

Broken on android 4.2.1 and up #22

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Open App
2. Try and connect with android 4.2.1 or higher
3. It wont connect when executing socket.connect();

What is the expected output? What do you see instead?
Should connect.

What version of the product are you using? On what operating system?
Android 4.3
I have tested on multiple devices. Worked on all devices lower than android 
4.2.1

Please provide any additional information below.
I'm thinking this is actually a bug with android, however, apps like torque 
still work on the new versions of android.

Original issue reported on code.google.com by KentGAnd...@gmail.com on 5 Aug 2013 at 9:22

GoogleCodeExporter commented 9 years ago
Google introduced a new Bluetooth stack with Android 4.2, which appears to 
behave differently from the previous versions. This link

http://stackoverflow.com/questions/13460569/bluetooth-rfcomm-connection-couldnt-
be-established-consecutively-on-android-4-2

mentions some issues, but it doesn't seem like obd-reader is suffering from 
them.

There's another one on Bluetooth connection issues:

http://stackoverflow.com/questions/12818800/should-i-leave-the-bluetooth-reflect
ion-hack-in-production-code

which mentions a hack that has made connections work again in some cases. Maybe 
that helps... the hack prevents disovery before connecting; something similar 
was committed to Android code in 
https://android.googlesource.com/platform/external/bluetooth/bluedroid/+/e17bf00
3d4eefdc8525e55894210e9ee494972b8

Original comment by mich...@vonglasow.com on 10 Aug 2013 at 8:40

GoogleCodeExporter commented 9 years ago
The hack suggested doesn't work for me.  Same errors persist. 
According to the question in stackoverflow, it was never tested on 4.2

Original comment by KentGAnd...@gmail.com on 13 Aug 2013 at 6:46

GoogleCodeExporter commented 9 years ago
Just tried on Android 4.3 (Cyanogenmod 10.2RC1) and got a different picture 
than before. RFCOMM *supposedly* works in 4.3 (though I don't have any app to 
verify this). Also, the Bluetooth keyboard which I didn't get to work with 4.2 
works with no issues under 4.3.

However, with OBD II Reader, the connect still fails and I get the following 
errors:

11-27 23:37:25.101 D/ObdGatewayService( 2696): Starting service..
11-27 23:37:25.101 D/ObdGatewayService( 2696): Stopping Bluetooth discovery.
11-27 23:37:25.105 D/BluetoothAdapterService(1100024472)( 860): getState(): 
mAdapterProperties: com.android.bluetooth.btservice.AdapterProperties@41912b20
11-27 23:37:25.105 E/ ( 860): ### ASSERT : 
external/bluetooth/bluedroid/main/../btif/src/btif_dm.c line 1237 unhandled 
search services event (6) ###
11-27 23:37:25.113 D/ObdGatewayService( 2696): Starting OBD connection..
11-27 23:37:25.113 W/BluetoothAdapter( 2696): getBluetoothService() called with 
no BluetoothManagerCallback
11-27 23:37:25.113 D/BTIF_SOCK( 860): service_uuid: 
00001101-0000-1000-8000-00805f9b34fb
11-27 23:37:25.113 D/BluetoothSocket( 2696): connect(), SocketState: INIT, mPfd:
{ParcelFileDescriptor: FileDescriptor[53]}

11-27 23:37:25.453 E/bt-rfcomm( 860): PORT_DataInd, p_port:0x53974948, 
p_data_co_callback is null
11-27 23:37:25.527 W/bt-btif ( 860): info:x0
11-27 23:37:25.527 D/ ( 860): remote version info [00:0d:18:a0:4e:35]: 3, 7b, 
229
11-27 23:37:25.527 D/btif_config_util( 860): btif_config_save_file(L153): in 
file name:/data/misc/bluedroid/bt_config.new
11-27 23:37:25.695 W/bt-sdp ( 860): process_service_search_attr_rsp
11-27 23:37:25.722 E/bt-btif ( 860): DISCOVERY_COMP_EVT slot id:13, failed to 
find channle, status:1, scn:0
11-27 23:37:25.726 W/bt-btif ( 860): invalid rfc slot id: 13
11-27 23:37:25.726 E/ObdGatewayService( 2696): There was an error while 
establishing connection. -> read failed, socket might closed or timeout, read 
ret: -1
11-27 23:37:25.726 D/ObdGatewayService( 2696): Stopping service..

Since the Bluetooth stack changed completely, some things may work differently. 
Apparently, Bluedroid is pickier about call parameters than Bluez was. My 
suspicion is that OBD II Reader is doing some operation that Bluedroid doesn't 
like (but which Bluez would handle).

I see three errors in the lo, which might have to do with it:
- the assert error (which seems to be a log entry from the Bluetooth stack 
itself - if it's related to the app, it might be a parameter issue)
- bt-rfcomm: PORT_DataInd, p_port:0x53974948, p_data_co_callback is null (there 
is an earlier warning about a missing BluetoothManagerCallback, which may be 
related)
- bt-btif: DISCOVERY_COMP_EVT, failed to find channel (surrounded by two 
warnings)

2696 seems to be the ODB II Reader process, 860 appears to be a 
Bluetooth-related system service. (I tested two apps and got PID 860 in the 
logs for both apps.)

Original comment by mich...@vonglasow.com on 28 Nov 2013 at 7:07

GoogleCodeExporter commented 9 years ago
I see the project has moved to github and this issue is now at 
https://github.com/pires/android-obd-reader/issues/7, I will post updates there

Original comment by mich...@vonglasow.com on 29 Nov 2013 at 9:03