The FBI has unlocked the iPhone used by one of the San Bernardino terror attackers, ending a heated legal standoff with Apple that had pitted US authorities against Silicon Valley.