Fix that the file is not correctly flushed to the disk
Fix a bug where rollback is corrupted when system_server crasshes
and reboots into RAMDUMP mode.
AtomicFile.finishWrite() calls FileUtils.sync() on the stream internally
which requires the stream is flushed but not yet closed.
pw.close() will close the stream which conflicts the use of
AtomicFile.finishWrite().
Let's remove the use of PrintWriter and flush the stream before calling
AtomicFile.finishWrite() so the file is correctly persisted to the disk.
Bug: 199124163
Test: atest RollbackManagerHostTest#testNativeWatchdogTriggersRollback
and check no "AtomicFile: Failed to sync file output stream"
appears in the log messages.
Test: atest CtsRootRollbackManagerHostTestCases \
CtsRollbackManagerHostTestCases \
CtsRollbackManagerTestCases
Change-Id: I6c93f20949f6103a7fe28fa2955155cd19df018a
1 file changed