Don't delete widgets that violate min size requirement

Test: Manual
Bug: 194766124
Change-Id: I4713e65e27da23d833bb60fb556ae8924a63e305
This commit is contained in:
Steven Ng 2021-08-04 11:14:09 +01:00
parent 4a17e66166
commit b269cc5150
1 changed files with 6 additions and 11 deletions

View File

@ -760,16 +760,13 @@ public class LoaderTask implements Runnable {
if (widgetProviderInfo != null if (widgetProviderInfo != null
&& (appWidgetInfo.spanX < widgetProviderInfo.minSpanX && (appWidgetInfo.spanX < widgetProviderInfo.minSpanX
|| appWidgetInfo.spanY < widgetProviderInfo.minSpanY)) { || appWidgetInfo.spanY < widgetProviderInfo.minSpanY)) {
logDeleteWidgetInfo(mApp.getInvariantDeviceProfile(), FileLog.d(TAG, "Widget " + widgetProviderInfo.getComponent()
widgetProviderInfo); + " minSizes not meet: span=" + appWidgetInfo.spanX
+ "x" + appWidgetInfo.spanY + " minSpan="
// This can happen when display size changes.
c.markDeleted("Widget removed, min sizes not met: "
+ "span=" + appWidgetInfo.spanX + "x"
+ appWidgetInfo.spanY + " minSpan="
+ widgetProviderInfo.minSpanX + "x" + widgetProviderInfo.minSpanX + "x"
+ widgetProviderInfo.minSpanY); + widgetProviderInfo.minSpanY);
continue; logWidgetInfo(mApp.getInvariantDeviceProfile(),
widgetProviderInfo);
} }
if (!c.isOnWorkspaceOrHotseat()) { if (!c.isOnWorkspaceOrHotseat()) {
c.markDeleted("Widget found where container != " + c.markDeleted("Widget found where container != " +
@ -990,10 +987,8 @@ public class LoaderTask implements Runnable {
} }
@SuppressLint("NewApi") // Already added API check. @SuppressLint("NewApi") // Already added API check.
private static void logDeleteWidgetInfo(InvariantDeviceProfile idp, private static void logWidgetInfo(InvariantDeviceProfile idp,
LauncherAppWidgetProviderInfo widgetProviderInfo) { LauncherAppWidgetProviderInfo widgetProviderInfo) {
FileLog.d(TAG, "Deleting " + widgetProviderInfo.getComponent()
+ " due to min size constraint");
Point cellSize = new Point(); Point cellSize = new Point();
for (DeviceProfile deviceProfile : idp.supportedProfiles) { for (DeviceProfile deviceProfile : idp.supportedProfiles) {
deviceProfile.getCellSize(cellSize); deviceProfile.getCellSize(cellSize);