Merge "Fixing nullPointer exception when wallpaper colors is null" into sc-dev
diff --git a/src/com/android/launcher3/util/Themes.java b/src/com/android/launcher3/util/Themes.java
index 898ac25..06cac08 100644
--- a/src/com/android/launcher3/util/Themes.java
+++ b/src/com/android/launcher3/util/Themes.java
@@ -19,6 +19,7 @@
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 @@
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);
}