Reuse the underlying byte array for ByteArray

Reuse the byte array for dex file output.

When calculating signature and checksum for a DEX
file, consider the size of the DEX file, instead of
the array. An array bigger than the file can be
allocated, and this would lead to wrong signature
and checksum calculation.

Because we reuse the output array
between seprate dx invocations, we
must write zeros to array. Otherwise, we might
end up picking up the output from
previous invocation.

The BaseDumper now tracks the number of read
bytes instead of the position.

Test: existing
Change-Id: I17126cfc02330bb459ae48be781e83ea997e4137
8 files changed