Emulator: handle OOM and Protocol error cases
- OutOfMemoryError can happen naturally if the size of the clipboard is
too large to allocate. We should prefer to drop the clipboard data if
we have a choice between that and crashing the system server.
- OutOfMemoryError can happen unnatturally if the protocol gets out of
sync with the host. This can happen quite easily if there is a caught
exception and the clipboard monitor tries to keep on trucking, since
the protocol doesn't have any built in synchronisation to catch back
up to the start of the next message again. The only option to prevent
that at the moment is to just close the pipe and reopen it in case
of failure to understand something.
Bug: 231340598
Test: presubmit
Change-Id: Icceb8ec8b3988c32a2eb5f5598a43753460fc26b
1 file changed