From fdeee141d926f578b2878861dd0635ef073316bd Mon Sep 17 00:00:00 2001 From: Steven Ng Date: Wed, 24 Feb 2021 10:16:54 +0000 Subject: [PATCH] Replace the no preview layout check with Resources.ID_NULL(0) TODO: open up the RemoteViews(ApplicationInfo) API so that Launcher can inflate a layout from a work profile app. Test: Before this CL, install tasks app in work profile. Observed crash when tapping Tasks header in the widgets picker. After this CL, no crash observed when tapping Tasks header in the widgets picker. Bug: 181061277 Change-Id: I16c2b9aec5f4cabf15da35fea09f68c10797f5fa --- .../launcher3/dragndrop/LivePreviewWidgetCell.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/com/android/launcher3/dragndrop/LivePreviewWidgetCell.java b/src/com/android/launcher3/dragndrop/LivePreviewWidgetCell.java index 71e10a82b0..be6a07f004 100644 --- a/src/com/android/launcher3/dragndrop/LivePreviewWidgetCell.java +++ b/src/com/android/launcher3/dragndrop/LivePreviewWidgetCell.java @@ -1,6 +1,9 @@ package com.android.launcher3.dragndrop; +import static com.android.launcher3.Utilities.ATLEAST_S; + import android.content.Context; +import android.content.res.Resources; import android.graphics.Bitmap; import android.util.AttributeSet; import android.view.View; @@ -62,9 +65,10 @@ public class LivePreviewWidgetCell extends WidgetCell { @Override public void applyFromCellItem(WidgetItem item, WidgetPreviewLoader loader) { - if (mPreview == null + if (ATLEAST_S + && mPreview == null && item.widgetInfo != null - && item.widgetInfo.previewLayout != View.NO_ID) { + && item.widgetInfo.previewLayout != Resources.ID_NULL) { mPreview = new RemoteViews(item.widgetInfo.provider.getPackageName(), item.widgetInfo.previewLayout); }