Two hours into the flight from Los Angeles to Shanghai, the United Airlines 787 pulled a U-turn and was redirected to San Francisco.