Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Skip to content
Commit df278920 authored by Eric Biggers's avatar Eric Biggers
Browse files

LockSettingsStorage: make writeFile() use AtomicFile

Although writeFile() is usually used to create new files, there are some
edge cases in which it is used to overwrite files.  For example, the
spblob file is overwritten when a protector is upgraded from v1 to v2.

Therefore, writeFile() needs to be atomic to guarantee that data
corruption cannot occur.  Fix this by making it use AtomicFile.

This also has the advantage that it should perform better (despite some
overhead associated with AtomicFile) because it avoids an unnecessary
sync that is hidden in the constructor 'new RandomAccessFile(path,
"rws")'.  It is only necessary to sync after the data is written.

Bug: 232452368
Bug: 251131631
Bug: 251147505
Test: atest com.android.server.locksettings
Change-Id: Iaf00c58b9a40e757b03d8b93c39af45c3bf3bbcc
parent 70ec9d52
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment