Fix occasional bad placement of Conversation header

This CL refactors the header placement logic to be "simpler", in that
we're abstracting a lot of the state manipulation behind a new inner
class, and are consolidating manipulation of that state to fewer
places in the overall algorithm.

Additional tests and comments have been added to hopefully further
improve robustness and clarity, respectively.

Fixes: 158475746
Test: atest, manual
Change-Id: I92a62cd5e46bfd1aff897b4189e53bc6768623d3
5 files changed