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
This commit is contained in:
Dianne Hackborn
2010-03-18 22:47:17 -07:00
parent b58fd82261
commit 1afd1c90eb
11 changed files with 87 additions and 58 deletions

View File

@ -68,6 +68,7 @@ import org.xmlpull.v1.XmlSerializer;
import com.android.internal.content.PackageMonitor;
import com.android.internal.service.wallpaper.ImageWallpaper;
import com.android.internal.util.FastXmlSerializer;
import com.android.internal.util.JournaledFile;
import com.android.server.DevicePolicyManagerService.ActiveAdmin;
import com.android.server.DevicePolicyManagerService.MyPackageMonitor;
@ -804,6 +805,9 @@ class WallpaperManagerService extends IWallpaperManager.Stub {
}
res = r.openRawResource(resId);
if (WALLPAPER_FILE.exists()) {
WALLPAPER_FILE.delete();
}
fos = new FileOutputStream(WALLPAPER_FILE);
byte[] buffer = new byte[32768];