diff --git a/src/com/android/launcher3/model/DatabaseHelper.java b/src/com/android/launcher3/model/DatabaseHelper.java index 13605101e7..88ca0093bd 100644 --- a/src/com/android/launcher3/model/DatabaseHelper.java +++ b/src/com/android/launcher3/model/DatabaseHelper.java @@ -333,7 +333,7 @@ public class DatabaseHelper extends NoLocaleSQLiteHelper implements for (int widgetId : allWidgets) { if (!validWidgets.contains(widgetId)) { try { - FileLog.d(TAG, "Deleting invalid widget " + widgetId); + FileLog.d(TAG, "Deleting widget not found in db: appWidgetId=" + widgetId); holder.deleteAppWidgetId(widgetId); isAnyWidgetRemoved = true; } catch (RuntimeException e) { @@ -342,15 +342,17 @@ public class DatabaseHelper extends NoLocaleSQLiteHelper implements } } if (isAnyWidgetRemoved) { - final String allWidgetsIds = Arrays.stream(allWidgets).mapToObj(String::valueOf) + final String allLauncherHostWidgetIds = Arrays.stream(allWidgets) + .mapToObj(String::valueOf) .collect(Collectors.joining(",", "[", "]")); - final String validWidgetsIds = Arrays.stream( + final String allValidLauncherDbWidgetIds = Arrays.stream( validWidgets.getArray().toArray()).mapToObj(String::valueOf) .collect(Collectors.joining(",", "[", "]")); FileLog.d(TAG, - "One or more widgets was removed. db_path=" + db.getPath() - + " allWidgetsIds=" + allWidgetsIds - + ", validWidgetsIds=" + validWidgetsIds); + "One or more widgets was removed: " + + " allLauncherHostWidgetIds=" + allLauncherHostWidgetIds + + ", allValidLauncherDbWidgetIds=" + allValidLauncherDbWidgetIds + ); } } finally { holder.destroy(); diff --git a/src/com/android/launcher3/model/WorkspaceItemProcessor.kt b/src/com/android/launcher3/model/WorkspaceItemProcessor.kt index 59f56dfaa8..22e5eb4949 100644 --- a/src/com/android/launcher3/model/WorkspaceItemProcessor.kt +++ b/src/com/android/launcher3/model/WorkspaceItemProcessor.kt @@ -410,14 +410,21 @@ class WorkspaceItemProcessor( appWidgetInfo.restoreStatus = c.restoreFlag if (appWidgetInfo.spanX <= 0 || appWidgetInfo.spanY <= 0) { c.markDeleted( - "Widget has invalid size: ${appWidgetInfo.spanX}x${appWidgetInfo.spanY}", + "processWidget: Widget has invalid size: ${appWidgetInfo.spanX}x${appWidgetInfo.spanY}" + + ", id=${c.id}," + + ", appWidgetId=${c.appWidgetId}," + + ", component=${component}", RestoreError.INVALID_LOCATION ) return } if (!c.isOnWorkspaceOrHotseat) { c.markDeleted( - "Widget found where container != CONTAINER_DESKTOP nor CONTAINER_HOTSEAT - ignoring!", + "processWidget: invalid Widget container != CONTAINER_DESKTOP nor CONTAINER_HOTSEAT." + + " id=${c.id}," + + ", appWidgetId=${c.appWidgetId}," + + ", component=${component}," + + ", container=${c.container}", RestoreError.INVALID_LOCATION ) return @@ -428,7 +435,12 @@ class WorkspaceItemProcessor( val inflationResult = widgetInflater.inflateAppWidget(appWidgetInfo) var shouldUpdate = inflationResult.isUpdate val lapi = inflationResult.widgetInfo - + FileLog.d( + TAG, + "processWidget: id=${c.id}" + + ", appWidgetId=${c.appWidgetId}" + + ", inflationResult=$inflationResult" + ) when (inflationResult.type) { WidgetInflater.TYPE_DELETE -> { c.markDeleted(inflationResult.reason, inflationResult.restoreErrorType) @@ -448,7 +460,11 @@ class WorkspaceItemProcessor( ) { // Restore never started c.markDeleted( - "Unrestored widget removed: $component", + "processWidget: Unrestored Pending widget removed:" + + " id=${c.id}" + + ", appWidgetId=${c.appWidgetId}" + + ", component=${component}" + + ", restoreFlag:=${c.restoreFlag}", RestoreError.APP_NOT_INSTALLED ) return @@ -491,7 +507,10 @@ class WorkspaceItemProcessor( if (appWidgetInfo.spanX < lapi.minSpanX || appWidgetInfo.spanY < lapi.minSpanY) { FileLog.d( TAG, - "Widget ${lapi.component} minSizes not meet: span=${appWidgetInfo.spanX}x${appWidgetInfo.spanY} minSpan=${lapi.minSpanX}x${lapi.minSpanY}" + " processWidget: Widget ${lapi.component} minSizes not met: span=${appWidgetInfo.spanX}x${appWidgetInfo.spanY} minSpan=${lapi.minSpanX}x${lapi.minSpanY}," + + " id: ${c.id}," + + " appWidgetId: ${c.appWidgetId}," + + " component=${component}" ) logWidgetInfo(app.invariantDeviceProfile, lapi) } diff --git a/src/com/android/launcher3/provider/RestoreDbTask.java b/src/com/android/launcher3/provider/RestoreDbTask.java index 99542f3fca..756153e5c4 100644 --- a/src/com/android/launcher3/provider/RestoreDbTask.java +++ b/src/com/android/launcher3/provider/RestoreDbTask.java @@ -456,7 +456,7 @@ public class RestoreDbTask { logDatabaseWidgetInfo(controller); for (int i = 0; i < oldWidgetIds.length; i++) { - FileLog.i(TAG, "Widget state restore id " + oldWidgetIds[i] + " => " + newWidgetIds[i]); + FileLog.i(TAG, "migrating appWidgetId: " + oldWidgetIds[i] + " => " + newWidgetIds[i]); final AppWidgetProviderInfo provider = widgets.getAppWidgetInfo(newWidgetIds[i]); final int state; diff --git a/src/com/android/launcher3/widget/WidgetManagerHelper.java b/src/com/android/launcher3/widget/WidgetManagerHelper.java index 52767a4135..ba7e0754a9 100644 --- a/src/com/android/launcher3/widget/WidgetManagerHelper.java +++ b/src/com/android/launcher3/widget/WidgetManagerHelper.java @@ -30,6 +30,7 @@ import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.annotation.RequiresApi; +import com.android.launcher3.logging.FileLog; import com.android.launcher3.model.WidgetsModel; import com.android.launcher3.model.data.LauncherAppWidgetInfo; import com.android.launcher3.pm.UserCache; @@ -46,6 +47,7 @@ import java.util.stream.Stream; */ public class WidgetManagerHelper { + private static final String TAG = "WidgetManagerHelper"; //TODO: replace this with OPTION_APPWIDGET_RESTORE_COMPLETED b/63667276 public static final String WIDGET_OPTION_RESTORE_COMPLETED = "appWidgetRestoreCompleted"; @@ -60,6 +62,7 @@ public class WidgetManagerHelper { /** * @see AppWidgetManager#getAppWidgetInfo(int) */ + @Nullable public LauncherAppWidgetProviderInfo getLauncherAppWidgetInfo( int appWidgetId, ComponentName componentName) { @@ -69,7 +72,14 @@ public class WidgetManagerHelper { } AppWidgetProviderInfo info = mAppWidgetManager.getAppWidgetInfo(appWidgetId); - return info == null ? null : LauncherAppWidgetProviderInfo.fromProviderInfo(mContext, info); + if (info == null) { + FileLog.w(TAG, + "getLauncherAppWidgetInfo: AppWidgetManager returned null AppWidgetInfo for" + + " appWidgetId=" + appWidgetId + + ", componentName=" + componentName); + return null; + } + return LauncherAppWidgetProviderInfo.fromProviderInfo(mContext, info); } /** @@ -137,9 +147,8 @@ public class WidgetManagerHelper { /** * Load RemoteViews preview for this provider if available. * - * @param info The provider info for the widget you want to preview. + * @param info The provider info for the widget you want to preview. * @param widgetCategory The widget category for which you want to display previews. - * * @return Returns the widget preview that matches selected category, if available. */ @Nullable