Fixing nullPointer exception when wallpaper colors is null
Bug: 186722571
Test: Presubmit
Change-Id: Iee0d15d460de47cc20395cf9f3d92784aef6268e
diff --git a/src/com/android/launcher3/util/Themes.java b/src/com/android/launcher3/util/Themes.java
index 11b856e..99942aa 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.Configuration;
@@ -41,9 +42,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);
}