Apple supplier Foxconn posts better-than expected second quarter profit