Provide APIs to allow reusing the passed buffer.

no functional changes.

Test: existing.

Change-Id: I30fbf02b92e804238807b4c98c3536c5c4c60ca4

Consider DEX size for signature and checksum

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.

Test: manually verified, existing tests
Change-Id: I0b6ae946cca7c0e71bb5e1f0ecbe209b91347c9d

Write zeros to byte array output

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.

Dx had an assumption that a new output
array is always allocated, and it was
a performance optimization not to write
zeros out. That does not apply any more.

BUG=65363025
Test: ByteArrayAnnotatedOutputTest

Change-Id: I984076e8078f9ed977f10cacb9b1b135b1d6358e
4 files changed