Foreign automakers are increasingly being edged out of China by local rivals including electric-vehicle leader BYD.