Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 30693374 authored by Joe Onorato's avatar Joe Onorato
Browse files

If the image wallpaper fails to load, including via an OutOfMemoryError...

If the image wallpaper fails to load, including via an OutOfMemoryError because of a big bitmap, reset to the default.

Bug: 3139118
Change-Id: Iff02e7440019598cce0cc87e4031a157e3feb641
parent e8934a67
Loading
Loading
Loading
Loading
+19 −1
Original line number Diff line number Diff line
@@ -16,6 +16,8 @@

package com.android.internal.service.wallpaper;

import java.io.IOException;

import com.android.internal.view.WindowManagerPolicyThread;

import android.app.WallpaperManager;
@@ -169,10 +171,26 @@ public class ImageWallpaper extends WallpaperService {

        void updateWallpaper() {
            synchronized (mLock) {
                Throwable exception = null;
                try {
                    mBackground = mWallpaperManager.getFastDrawable();
                } catch (RuntimeException e) {
                    Log.w("ImageWallpaper", "Unable to load wallpaper!", e);
                    exception = e;
                } catch (OutOfMemoryError e) {
                    exception = e;
                }
                if (exception != null) {
                    mBackground = null;
                    // Note that if we do fail at this, and the default wallpaper can't
                    // be loaded, we will go into a cycle.  Don't do a build where the
                    // default wallpaper can't be loaded.
                    Log.w("ImageWallpaper", "Unable to load wallpaper!", exception);
                    try {
                        mWallpaperManager.clear();
                    } catch (IOException ex) {
                        // now we're really screwed.
                        Log.w("ImageWallpaper", "Unable reset to default wallpaper!", ex);
                    }
                }
            }
        }