Merge "Fixing nullPointer exception when wallpaper colors is null" into sc-dev

This commit is contained in:
Sunny Goyal
2021-05-03 17:59:05 +00:00
committed by Android (Google) Code Review

View File

@@ -19,6 +19,7 @@ package com.android.launcher3.util;
import static android.app.WallpaperColors.HINT_SUPPORTS_DARK_TEXT;
import static android.app.WallpaperColors.HINT_SUPPORTS_DARK_THEME;
import android.app.WallpaperColors;
import android.app.WallpaperManager;
import android.content.Context;
import android.content.res.TypedArray;
@@ -40,9 +41,14 @@ import com.android.launcher3.icons.GraphicsUtils;
public class Themes {
public static int getActivityThemeRes(Context context) {
int colorHints = Utilities.ATLEAST_P ? context.getSystemService(WallpaperManager.class)
.getWallpaperColors(WallpaperManager.FLAG_SYSTEM).getColorHints()
: 0;
final int colorHints;
if (Utilities.ATLEAST_P) {
WallpaperColors colors = context.getSystemService(WallpaperManager.class)
.getWallpaperColors(WallpaperManager.FLAG_SYSTEM);
colorHints = colors == null ? 0 : colors.getColorHints();
} else {
colorHints = 0;
}
return getActivityThemeRes(context, colorHints);
}