Only fetching relevant widget info during first pass

This avoids loading resources for allwidget providers when they
are not added to homescreen.

Test: Verified on device
Bug: 180867488
Change-Id: If9adde8eb035ecac75dc4e3e37cd3f0f526865e5
This commit is contained in:
Sunny Goyal
2021-02-24 14:25:45 -08:00
parent d6844dcb7f
commit ca6a539faa
2 changed files with 8 additions and 19 deletions

View File

@@ -31,14 +31,11 @@ import com.android.launcher3.LauncherAppWidgetProviderInfo;
import com.android.launcher3.model.WidgetsModel;
import com.android.launcher3.model.data.LauncherAppWidgetInfo;
import com.android.launcher3.pm.UserCache;
import com.android.launcher3.util.ComponentKey;
import com.android.launcher3.util.PackageUserKey;
import com.android.launcher3.widget.custom.CustomWidgetManager;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;
import java.util.stream.Stream;
@@ -122,15 +119,6 @@ public class WidgetManagerHelper {
appWidgetId).getBoolean(WIDGET_OPTION_RESTORE_COMPLETED);
}
public static Map<ComponentKey, AppWidgetProviderInfo> getAllProvidersMap(Context context) {
if (WidgetsModel.GO_DISABLE_WIDGETS) {
return Collections.emptyMap();
}
return allWidgetsSteam(context).collect(
Collectors.toMap(info -> new ComponentKey(info.provider, info.getProfile()),
Function.identity()));
}
private static Stream<AppWidgetProviderInfo> allWidgetsSteam(Context context) {
AppWidgetManager awm = context.getSystemService(AppWidgetManager.class);
return Stream.concat(