Allow Launcher to automatically restore widgets

This replaces PendingAppWidgetHostView with configured widget view when
OPTION_APPWIDGET_RESTORE_COMPLETED is set to True by a widget provider.

Bug: 63667276
Test: Manual
Change-Id: Ide21f5e9a7dac7e3d6a745660a38ad0b951b47d3
This commit is contained in:
Samuel Fufa
2020-02-24 17:06:28 -08:00
parent d71c3b185d
commit 9151c011b9
5 changed files with 77 additions and 6 deletions

View File

@@ -49,6 +49,9 @@ import java.util.stream.Stream;
*/
public class WidgetManagerHelper {
//TODO: replace this with OPTION_APPWIDGET_RESTORE_COMPLETED b/63667276
public static final String WIDGET_OPTION_RESTORE_COMPLETED = "appWidgetRestoreCompleted";
final AppWidgetManager mAppWidgetManager;
final Context mContext;
@@ -127,6 +130,14 @@ public class WidgetManagerHelper {
return null;
}
/**
* Returns if a AppWidgetProvider has marked a widget restored
*/
public boolean isAppWidgetRestored(int appWidgetId) {
return !WidgetsModel.GO_DISABLE_WIDGETS && mAppWidgetManager.getAppWidgetOptions(
appWidgetId).getBoolean(WIDGET_OPTION_RESTORE_COMPLETED);
}
public static Map<ComponentKey, AppWidgetProviderInfo> getAllProvidersMap(Context context) {
if (WidgetsModel.GO_DISABLE_WIDGETS) {
return Collections.emptyMap();