Adding support for pending widgets in AutoInstall layout
> Pending widgets whill show a loading progress while the app
is being installed.
> Extra bind options can be defined using the tub tags
<extra key="key-name" value="key-value" />
These are sent as widget options when the widget is bound.
> If the widget has any config activity, it is not shown
> Required attributes:
className, packageName, x, y, spanY, spanY & screen
Bug: 30279609
Change-Id: I1338618bfa5d86967339dffb68c12b1add6eb5d7
diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java
index 886c5f0..c6fee8d 100644
--- a/src/com/android/launcher3/Launcher.java
+++ b/src/com/android/launcher3/Launcher.java
@@ -3952,14 +3952,30 @@
pendingInfo.minSpanX = item.minSpanX;
pendingInfo.minSpanY = item.minSpanY;
Bundle options = WidgetHostViewLoader.getDefaultOptionsForWidget(this, pendingInfo);
+
+ boolean isDirectConfig =
+ item.hasRestoreFlag(LauncherAppWidgetInfo.FLAG_DIRECT_CONFIG);
+ if (isDirectConfig && item.bindOptions != null) {
+ Bundle newOptions = item.bindOptions.getExtras();
+ if (options != null) {
+ newOptions.putAll(options);
+ }
+ options = newOptions;
+ }
boolean success = mAppWidgetManager.bindAppWidgetIdIfAllowed(
item.appWidgetId, appWidgetInfo, options);
+ // We tried to bind once. If we were not able to bind, we would need to
+ // go through the permission dialog, which means we cannot skip the config
+ // activity.
+ item.bindOptions = null;
+ item.restoreStatus &= ~LauncherAppWidgetInfo.FLAG_DIRECT_CONFIG;
+
// Bind succeeded
if (success) {
// If the widget has a configure activity, it is still needs to set it up,
// otherwise the widget is ready to go.
- item.restoreStatus = (appWidgetInfo.configure == null)
+ item.restoreStatus = (appWidgetInfo.configure == null) || isDirectConfig
? LauncherAppWidgetInfo.RESTORE_COMPLETED
: LauncherAppWidgetInfo.FLAG_UI_NOT_READY;
}