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

Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Launcher3/+/14391145

Change-Id: I461076d67ff84e3c5eb4e6b2336117ced0994785
This commit is contained in:
Sunny Goyal
2021-05-03 18:11:08 +00:00
committed by Automerger Merge Worker

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);
}