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

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

Change-Id: I3c9f37030330a629aff0d3ea06a386e8cf6d2e59
This commit is contained in:
Sunny Goyal
2021-05-03 18:34:07 +00:00
committed by Automerger Merge Worker
+9 -3
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);
}