From 90f86baebdb53f2edb5e2bd2b3f6f43bc802f9a9 Mon Sep 17 00:00:00 2001 From: Christopher Tate Date: Thu, 11 Sep 2014 12:37:19 -0700 Subject: Write new wallpaper files from scratch... ...rather than overwriting the existing wallpaper bitmap file "in place." If the new bitmap is smaller than the previous one, we wind up with the previous image's contents as spurious trailing file contents. Also, it means that if any wallpaper image is particularly large on disk, then we'll forever be backing up that high-water-mark amount of data every time the wallpaper is changed. The fix is to open the "write the new bitmap to disk" fd with MODE_TRUNCATE. Bug 17285333 Change-Id: I3d8708d72e316834b7ecec20386153a703efddd9 --- .../core/java/com/android/server/wallpaper/WallpaperManagerService.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/core/java/com/android/server/wallpaper/WallpaperManagerService.java b/services/core/java/com/android/server/wallpaper/WallpaperManagerService.java index e1ade63a2cb8..a8245e785346 100644 --- a/services/core/java/com/android/server/wallpaper/WallpaperManagerService.java +++ b/services/core/java/com/android/server/wallpaper/WallpaperManagerService.java @@ -843,7 +843,7 @@ public class WallpaperManagerService extends IWallpaperManager.Stub { } File file = new File(dir, WALLPAPER); ParcelFileDescriptor fd = ParcelFileDescriptor.open(file, - MODE_CREATE|MODE_READ_WRITE); + MODE_CREATE|MODE_READ_WRITE|MODE_TRUNCATE); if (!SELinux.restorecon(file)) { return null; } -- cgit v1.2.3-59-g8ed1b