Merge "Guard against NPE inside BaseIconFactory Bug: 137253043" into ub-launcher3-qt-r1-dev
am: b1b4562a46
Change-Id: If97029ff59cc426db1dd4a7d433a5ab264eabeba
This commit is contained in:
commit
7f7ba484a8
|
@ -22,6 +22,7 @@ import android.graphics.drawable.Drawable;
|
|||
import android.os.Build;
|
||||
import android.os.Process;
|
||||
import android.os.UserHandle;
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
/**
|
||||
* This class will be moved to androidx library. There shouldn't be any dependency outside
|
||||
|
@ -154,7 +155,7 @@ public class BaseIconFactory implements AutoCloseable {
|
|||
* @param scale returns the scale result from normalization
|
||||
* @return a bitmap suitable for disaplaying as an icon at various system UIs.
|
||||
*/
|
||||
public BitmapInfo createBadgedIconBitmap(Drawable icon, UserHandle user,
|
||||
public BitmapInfo createBadgedIconBitmap(@NonNull Drawable icon, UserHandle user,
|
||||
boolean shrinkNonAdaptiveIcons, boolean isInstantApp, float[] scale) {
|
||||
if (scale == null) {
|
||||
scale = new float[1];
|
||||
|
@ -207,8 +208,11 @@ public class BaseIconFactory implements AutoCloseable {
|
|||
mDisableColorExtractor = true;
|
||||
}
|
||||
|
||||
private Drawable normalizeAndWrapToAdaptiveIcon(Drawable icon, boolean shrinkNonAdaptiveIcons,
|
||||
RectF outIconBounds, float[] outScale) {
|
||||
private Drawable normalizeAndWrapToAdaptiveIcon(@NonNull Drawable icon,
|
||||
boolean shrinkNonAdaptiveIcons, RectF outIconBounds, float[] outScale) {
|
||||
if (icon == null) {
|
||||
return null;
|
||||
}
|
||||
float scale = 1f;
|
||||
|
||||
if (shrinkNonAdaptiveIcons && ATLEAST_OREO) {
|
||||
|
@ -264,7 +268,7 @@ public class BaseIconFactory implements AutoCloseable {
|
|||
* @param icon drawable that should be flattened to a bitmap
|
||||
* @param scale the scale to apply before drawing {@param icon} on the canvas
|
||||
*/
|
||||
public Bitmap createIconBitmap(Drawable icon, float scale, int size) {
|
||||
public Bitmap createIconBitmap(@NonNull Drawable icon, float scale, int size) {
|
||||
Bitmap bitmap = Bitmap.createBitmap(size, size, Bitmap.Config.ARGB_8888);
|
||||
if (icon == null) {
|
||||
return bitmap;
|
||||
|
|
Loading…
Reference in New Issue