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
Loading
Please register or sign in to comment