Foxconn net profit rises in second quarter on AI demand