Speed up user-switching wallpaper changes

Previous work in ImageWallpaper cached the bitmap for a user
to avoid reloading it (an expensive operation on large-display devices)
when we could simply re-use it. User switching still caused a reload, however,
since the place where we cache the bitmap (ImageWallpaper) is in an instance
that is re-created on user-switch.

A simple fix is to have the ImageWallpaper stop telling the WallpaperManager
to erase its own cache of the bitmap prior to re-loading it. That step is
unnecessary, since a bitmap that is cached can be assumed to be valid. A wallpaper
change will correctly null out that cached version, so if the cached bitmap
is non-null, then we can simply use it as-is.

The fix is to remove the call to forgetLoadedWallpaper() and allow the caching
mechanism to do its job.

Issue #7986933 user switching on lock screen is slow (sometimes like molasses)

Change-Id: I447754ab85337bc8ae59b4ad6c3e6c2b30e13735
This commit is contained in:
Chet Haase
2013-04-30 15:10:51 -07:00
parent ef325d0608
commit b432ef98f0

View File

@@ -388,7 +388,6 @@ public class ImageWallpaper extends WallpaperService {
private void updateWallpaperLocked() {
Throwable exception = null;
try {
mWallpaperManager.forgetLoadedWallpaper(); // force reload
mBackground = null;
mBackground = mWallpaperManager.getBitmap();
} catch (RuntimeException e) {