Refactor helpers out of LibcoreHeapMetricsTest.

This is basically just moving code around. Separating the concern of
interacting with the device means that the test itself is a lot
cleaner and it'll be easier to see what's going on once we start
adding more tests and more real host-side business logic (such as more
complicated analysis of the heap dumps).

Test: tradefed.sh run commandAndExit template/local_min --template:map test=libcore-memory-metrics-tests
Bug: 67999970
Change-Id: Ifd148b10e5de94c8865613e44ee61bc1d3325b1e
2 files changed