HTC's Q2 earnings rebounds on flagship phone