Assuming that google keeps the majority of/important patents then they basically bought the patents for $4.74 billion. They sold the "set top" division for $2.35 billion and now they're selling the mobility division for $2.91 billion. They also kept about $3 billion in cash that Motorolla was holding when they bought them for $13 billion.
That's not even counting whatever tax incentives they get from these deals. So all in all, it isn't as bad of a deal as it looks like on the surface (in fact I assume it is what Google was planning from the beginning).