Google was building a secret mobile product to fend off chief rival Microsoft. Then Apple announced the iPhone, and everything changed.