From 212037f7cdbf3ac3712ab16f885d62da7f850fe0 Mon Sep 17 00:00:00 2001 From: Kenny Guy Date: Thu, 15 Jan 2015 18:14:46 +0000 Subject: Sync file before using JournaledFile commit. Ext4 doesn't guarantee that write file.new / close file.new rename file.new to file will mean data in file.new makes it to file atomically. The rename may happen with previous contents of file.new and then later update to new contents See docs for noauto_da_alloc So rebooting the device during JournaledFile.commit may mean we are left with an empty file. Bug: 18590558 Change-Id: I35322c82871bed30c2c6ebbd1388338f0471f3ba --- .../com/android/server/devicepolicy/DevicePolicyManagerService.java | 3 +++ 1 file changed, 3 insertions(+) (limited to 'services/devicepolicy/java') diff --git a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java index 579fae4..aae496c 100644 --- a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java +++ b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java @@ -60,6 +60,7 @@ import android.os.AsyncTask; import android.os.Binder; import android.os.Bundle; import android.os.Environment; +import android.os.FileUtils; import android.os.Handler; import android.os.IBinder; import android.os.PersistableBundle; @@ -1348,6 +1349,8 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub { out.endTag(null, "policies"); out.endDocument(); + stream.flush(); + FileUtils.sync(stream); stream.close(); journal.commit(); sendChangedNotification(userHandle); -- cgit v1.1