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

Commit 7084c606 authored by Christoph Studer's avatar Christoph Studer
Browse files

Guard against null default wallpaper

Deal with WallpaperManager.getBuiltInDrawable() returning null.

Bug: 13109487
Change-Id: Ib5665a0eb947e9784cdcd0e8dfab1a01b4deca82
parent e8cc0905
Loading
Loading
Loading
Loading
+15 −9
Original line number Diff line number Diff line
@@ -16,7 +16,6 @@

package com.android.launcher3;

import android.animation.Animator;
import android.animation.LayoutTransition;
import android.app.ActionBar;
import android.app.Activity;
@@ -33,7 +32,6 @@ import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Matrix;
import android.graphics.Paint;
import android.graphics.Point;
import android.graphics.PorterDuff;
import android.graphics.Rect;
@@ -248,6 +246,12 @@ public class WallpaperPickerActivity extends WallpaperCropActivity {
            Drawable defaultWallpaper = WallpaperManager.getInstance(a).getBuiltInDrawable(
                    c.getWidth(), c.getHeight(), false, 0.5f, 0.5f);

            if (defaultWallpaper == null) {
                Log.w(TAG, "Null default wallpaper encountered.");
                c.setTileSource(null, null);
                return;
            }

            c.setTileSource(
                    new DrawableTileSource(a, defaultWallpaper, DrawableTileSource.MAX_PREVIEW_SIZE), null);
            c.setScale(1f);
@@ -419,6 +423,7 @@ public class WallpaperPickerActivity extends WallpaperCropActivity {
        // Add a tile for the default wallpaper
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
            DefaultWallpaperInfo defaultWallpaperInfo = getDefaultWallpaper();
            if (defaultWallpaperInfo != null) {
                FrameLayout defaultWallpaperTile = (FrameLayout) createImageTileView(
                        getLayoutInflater(), 0, null, mWallpapersView, defaultWallpaperInfo.mThumb);
                setWallpaperItemPaddingToZero(defaultWallpaperTile);
@@ -427,6 +432,7 @@ public class WallpaperPickerActivity extends WallpaperCropActivity {
                defaultWallpaperTile.setOnClickListener(mThumbnailOnClickListener);
                defaultWallpaperInfo.setView(defaultWallpaperTile);
            }
        }

        // Select the first item; wait for a layout pass so that we initialize the dimensions of
        // cropView or the defaultWallpaperView first