Make sure keys get flushed when connection falls apart.

This is for the event that a key has been intercepted, sent to the app,
and the app hasn't handled it yet. If the connection dies, the key is
lost. So flush all pending keys.

Test: Unit test (this would have caught me introducing this bug in the
first place).

Bug:74593001
Change-Id: I5a94aafe5c58f18a3e9ca46f7cd5a9cb71d38aaa
2 files changed