summaryrefslogtreecommitdiffstats
path: root/core/java/android/os
diff options
context:
space:
mode:
authorDianne Hackborn <hackbod@google.com>2010-03-18 22:47:17 -0700
committerDianne Hackborn <hackbod@google.com>2010-03-19 13:59:07 -0700
commit1afd1c90ebe789b8d3a137004127a50d2db7e3b5 (patch)
tree8ebbf7ee08b4aa0dab01a37a16b81c51af019d42 /core/java/android/os
parentb58fd82261efee1131eee7dcf3d66f98b11b5d24 (diff)
downloadframeworks_base-1afd1c90ebe789b8d3a137004127a50d2db7e3b5.zip
frameworks_base-1afd1c90ebe789b8d3a137004127a50d2db7e3b5.tar.gz
frameworks_base-1afd1c90ebe789b8d3a137004127a50d2db7e3b5.tar.bz2
Maybe fix issue #2457218: Corrupt batterystats.bin file preventing phone boot - LIBtt68127
No steps to repro, but makes the code more robust by using the standard JournaledFile class and doing sanity checks on the input it reads. This required moving the JournaledFile class in to the framework (and we really should get rid of either it or AtomicFile, but they have different recovery semantics so that is tough). Also went through and cleaned up the file management in various places. Change-Id: Ieb7268d8435e77dff66b6e67bb63b62e5dea572e
Diffstat (limited to 'core/java/android/os')
-rw-r--r--core/java/android/os/FileUtils.java3
1 files changed, 3 insertions, 0 deletions
diff --git a/core/java/android/os/FileUtils.java b/core/java/android/os/FileUtils.java
index 4780cf3..a17b7fe 100644
--- a/core/java/android/os/FileUtils.java
+++ b/core/java/android/os/FileUtils.java
@@ -115,6 +115,9 @@ public class FileUtils
*/
public static boolean copyToFile(InputStream inputStream, File destFile) {
try {
+ if (destFile.exists()) {
+ destFile.delete();
+ }
OutputStream out = new FileOutputStream(destFile);
try {
byte[] buffer = new byte[4096];