I am experiencing serious issues with Android 6.0 and some devices with Bluetooth Low Energy. One of those conflictive devices is this one:
DEVICE INFO:
Name: Samsung Galaxy SV
Model number: SM-G900V
Android vers: 6.0.1
Patch level: May 1, 2016
Hard. vers: G900V.05
If I make some stress test based on connecting and disconnecting the app to a BLE peripheral the success ratio barely reaches 50%.
Reading the latest documentation of Android, they recommend to specify the transport mode in the last parameter of connectGatt method to enforce BLE transport connectivity instead of BR/EDR:
device.connectGatt(this, false, mGattCallback, BluetoothDevice.TRANSPORT_LE);
Nothing changed with this improvement.
Following some suggestions and also reading about BLE connectivity issues, I found several related issues with Samsung Galaxy S6 and in one of those they suggested a series of steps to fix BLE connectivity problems. The key one was to clear Bluetooth Share system app data. Doing so, connectivity ratio increased in almost 100% of success immediately. However, if you wait and play with some other BLE apps and connect to other peripherals the problem will be back sooner or later.
There are some apps in Google Play that tries to fix these BLE issues and what they basically do is:
/system/bin/rm -r /data/misc/bluetoothd/*
/system/bin/rm -r /data/misc/hcid/*
Although it is a way to clear bluetooth cache, it requires the device to be rooted which is not a reasonable solution for professional apps.
None of the private Android API's I researched helped me to solve this issue, and the only similar one I found was to enforce service discovery cache cleanup which has nothing to do with the issue.
Using a BLE packet sniffer I see that the ADV_CONNECT_REQ
is not even sent from the device to the peripheral, and after a while the Android stack triggers the STATE_DISCONNECTED
event in BluetoothGattCallback
.
I don't exactly know why this problem occurs in some 6.0 devices and not in others since Bluetooth Share cache seems to be the problem. What is exactly stored there? Just previously connected/paired devices? Am I the only one experiencing this issue? If not, how do you guys tackle it? I would hate to instruct final users on how to Clear Bluetooth Share app Data.