Force save cached pages to file.

Bug: 253568736
Test: atest PackageManagerSettingsTests android.content.pm.cts.PackageManagerTest
Change-Id: I2d1c39f066fc40d3896f1e0c441bcb53ab2da70c
This commit is contained in:
Alex Buynytskyy
2023-01-17 09:07:17 -08:00
parent db87c40756
commit aafba6db94

View File

@@ -2693,10 +2693,15 @@ public final class Settings implements Watchable, Snappable {
FileUtils.S_IRUSR | FileUtils.S_IWUSR | FileUtils.S_IRGRP | FileUtils.S_IWGRP,
-1, -1);
try {
FileUtils.copy(mSettingsFilename, mSettingsReserveCopyFilename);
try (FileInputStream in = new FileInputStream(mSettingsFilename);
FileOutputStream out = new FileOutputStream(mSettingsReserveCopyFilename)) {
FileUtils.copy(in, out);
out.flush();
FileUtils.sync(out);
} catch (IOException e) {
Slog.e(TAG, "Failed to backup settings", e);
Slog.e(TAG,
"Failed to write reserve copy of settings: " + mSettingsReserveCopyFilename,
e);
}
try {