Replace copy-on-write PDB with an empty one

This is follow-up for aosp/1549486. It replaces the copy-on-write PDB
with an empty PDB created by the gsid because exposing the real PDB
in the DSU mode is unnecessary. The empty PDB will triggers formatting
during boot. To support this, we replace all OutputStream operations
with FileChannel operations backed by a RandomAccessFile to avoid
the backing file to be truncated during formatting. This also simplify
the current implementation which mixes OutputStream and FileChannel.
We appened a FileChannel.force() to FileChannel operations because the
PDB can be a raw block or a backing file on a file system. The force
method can make sure the file system cache is flushed.

Bug: 175852148
Test: vts-tradefed run vts -m vts_kernel_net_tests
Test: gts-tradefed run gts -m GtsOemLockServiceTestCases -t com.google.android.oemlock.gts.OemLockServiceTest
Test: cts-tradefed run cts -m CtsPermission2TestCases -t android.permission2.cts.PrivappPermissionsTest

Change-Id: I9aaa2193a3c7a93988590276cdbdf1a21f230cb3
1 file changed