Merge "Add onSaveInstanceState support for GridPicker" into ub-launcher3-master
diff --git a/src/com/android/customization/model/theme/ThemeBundle.java b/src/com/android/customization/model/theme/ThemeBundle.java
index 8cb2865..43b07ff 100644
--- a/src/com/android/customization/model/theme/ThemeBundle.java
+++ b/src/com/android/customization/model/theme/ThemeBundle.java
@@ -62,6 +62,7 @@
import java.util.List;
import java.util.Map;
import java.util.Set;
+import java.util.stream.Collectors;
/**
* Represents a Theme component available in the system as a "persona" bundle.
@@ -87,7 +88,7 @@
mTitle = title;
mIsDefault = isDefault;
mPreviewInfo = previewInfo;
- mPackagesByCategory = Collections.unmodifiableMap(overlayPackages);
+ mPackagesByCategory = Collections.unmodifiableMap(removeNullValues(overlayPackages));
}
@Override
@@ -214,6 +215,13 @@
}
}
+ private Map<String, String> removeNullValues(Map<String, String> map) {
+ return map.entrySet()
+ .stream()
+ .filter(entry -> entry.getValue() != null)
+ .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
+ }
+
protected CharSequence getContentDescription(Context context) {
if (mContentDescription == null) {
CharSequence defaultName = context.getString(R.string.default_theme_title);
diff --git a/src/com/android/customization/picker/WallpaperPreviewer.java b/src/com/android/customization/picker/WallpaperPreviewer.java
index 0185925..8f69d59 100644
--- a/src/com/android/customization/picker/WallpaperPreviewer.java
+++ b/src/com/android/customization/picker/WallpaperPreviewer.java
@@ -174,7 +174,7 @@
mWallpaperConnection.setVisibility(true);
mHomePreview.post(() -> {
- if (!mWallpaperConnection.connect()) {
+ if (mWallpaperConnection != null && !mWallpaperConnection.connect()) {
mWallpaperConnection = null;
LiveTileOverlay.INSTANCE.detach(mHomePreview.getOverlay());
}