Speculative fix: ensure avatars are not created with empty email addresses

b/17802490

I was unable to recreate this bug using 5 different renamed gmail accounts.
But, the code lends itself to locating the bug with a reasonable amount of
certainty.

ContactRequest throws IllegalArgumentException if it is created with a null
or "" email address.

SendersView.handlePriority(...) houses the algorithm that chooses the email
address used as the avatar for the TL entry. The algorithm already avoided
choosing null email addresses, but there was at least one code path through
the algorithm that would accept an empty email address.

Specifically, if all messages were read, and the last message was sent by
someone with an empty email address (obviously this represents bad data),
the algorithm would still happily choose that sender.

If this case happens, we do something the algorithm has done since time
immemorial: set the email address to the *name* of the particpant (which
is not empty). This will produce a failed avatar lookup and result in a
letter tile or generic avatar if the letter is not in A-Z.

Change-Id: I0a0ad0e5e66cc2316ef188b833485daa3c90c4b6
3 files changed