A sudden shift in smartphone buying patterns has pushed one brand ahead, leaving Samsung struggling to respond and risking years of dominance.