Android Bluetooth pairing limitation

  • Replies:2
  • Forum posts: 3

May 19, 2020, 1:43:06 PM via Website

There is a 100 device limit in Android for the maximum number of paired Bluetooth devices. This causes problems for my App used for reading the meter status.

Multiple solutions to the problem looks possible.

  • Solutions that replace the Bluetooth lib library all require some form of rooting the device.
  • Use AOSP and GSI to update system image of device.
  • Manufacturers use different solutions for partitioning etc. of phones so it’s very hard to create a portable solution even when using GSI.

  • Replace only the Bluetooth library
    Replacing only the lib may be more general, but it also requires rooting and installation of TWRP.

  • Use the ndk to patch/replace the pairing code or try to integrate the App deeper in the stack
    There is an interesting old paten for “Centralized Bluetooth Device Pairing”

  • Patch of Bluetooth library
    The idea is to just change BTM_SEC_MAX_DEVICE_RECORDS variable. If we can change or override this variable outside in some configuration file and do not build source is more desirable.
    If we can just build and replace component which allow it to keep more then 100 paired Bluetooth device is ideal
    The below code seems to be culprit as mentioned in this link (
    According to the Bluetooth implementation, if there are more than 100 device records the allocation will fail. The responsible BTM_SEC_MAX_DEVICE_RECORDS is defined in bt_target.h:
    /* The number of security records for peer devices. */
    This is then used inside btm_dev.c, specifically in BTM_SecAddDevice which returns false after 100 pairings:
    /* There is no device record, allocate one.

    • If we can not find an empty spot for this one, let it fail. */
      for (i = 0; i < BTM_SEC_MAX_DEVICE_RECORDS; i++)

* If I update the #define BTM_SEC_MAX_DEVICE_RECORDS from 100 to lets say 1000, do I need to build the complete GIS image and install.
* Or, can I only update the BT library?
* Or, any other methods?

  • Forum posts: 1,459

May 20, 2020, 6:20:34 AM via Website

If you have changed the macro BTM_SEC_MAX_DEVICE_RECORDS which is defined in bt_target.h, you must recompile all .c files which incude bt_target.h in order to rebuild the BT library. And then, you can update the BT library after you have rooted your device.

Download size < 0.08 MB. But also Ad-free, Pure & Accurate enough.
The minimalist app is available on Google Play
Your 5-star is appreciated. Blog:

  • Forum posts: 14

May 21, 2020, 4:06:45 AM via Website

Hi, Repair is the best way to recover your phone. Do not leave it for too long, the electronics will have a big problem.