Fix a bug in BitOutputStream where any trailing zeros will be discarded along
with an optimization to avoid maintaining two copies of data in memory during
toByteArray.

Test: atest frameworks/base/services/tests/servicestests/src/com/android/server/integrity
Bug: 143697198
Change-Id: Ide9256d7bdf5a268920a944206af8ea2b03201a4
7 files changed