Android BLE on really Cheap tablets

I'm working on an Android app that scans and makes BLE connections. The app scans for devices advertising a particular service. The app uses startScan with a PendingIntent.

The devices the app is looking for include some status information in the manufacturers data portion of the advertisement. The app uses that data to determine the state of the advertising device and may decide that it needs to connect to it.

Once the app has determined that it needs to connect to a device, it waits until another advertisement from the device is received and then it initiates a connection. Once the connection is up, the app will read or write to one characteristic and disconnect after the operation completes.

This works on most Android devices. Specifically, It does not work on some really cheap tablets. Android stops delivering scan results after the program tries to make a connection. The read or write operation successfully completes and the program is left waiting for more scan results.

If the user presses the power button to put the device to sleep and then presses it again to bring up the lock screen, the scan results start coming in and everything starts working again. The user must lock and unlock the device after every BLE connection.

I tried stopping the scan before each connection attempt and restarting it after the connection completes. It did not appear to have any effect on the behavior of the program.

Passing true or false for the autoConnect parameter to connectGatt also makes no difference.

Any ideas?

Related