private static Object getIBluetoothManager() throws NoSuchMethodException, InvocationTargetException, IllegalAccessException {

        BluetoothAdapter bluetoothAdapter = BluetoothAdapter.getDefaultAdapter();

        if (bluetoothAdapter == null) {
            return null;
        }

        Method getBluetoothManagerMethod = getMethodFromClass(bluetoothAdapter.getClass(), "getBluetoothManager");
        return getBluetoothManagerMethod.invoke(bluetoothAdapter);
    }
Some implementations of Bluetooth Stack have a race condition where autoConnect flag
is not properly set before calling connectGatt. That's the reason for using reflection
to set the flag manually.
rxandroidble/src/main/java/com/polidea/rxandroidble2/internal/util/BleConnectionCompat.java