Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 9c2cb7e2 authored by Pinyao Ting's avatar Pinyao Ting
Browse files

Further defer loading widgets until it is absolutely needed.

Current implementation parses the provider info from all manifests in
every app the first time getInstalledProvidersForProfile is called,
which causes unnecessary delay on the call-site if only a single package
was requested.

This CL ensures widgets loading are deferred further down the line,
until it is absolutely needed to be parsed.

Bug: 202356231
Test: manual
Change-Id: I793bd818781ae956cd5bc590a315c669d01e7ca6
parent 286fd132
Loading
Loading
Loading
Loading
+9 −6
Original line number Diff line number Diff line
@@ -1617,14 +1617,17 @@ class AppWidgetServiceImpl extends IAppWidgetService.Stub implements WidgetBacku
            final int providerCount = mProviders.size();
            for (int i = 0; i < providerCount; i++) {
                Provider provider = mProviders.get(i);
                AppWidgetProviderInfo info = provider.getInfoLocked(mContext);
                final String providerPackageName = provider.id.componentName.getPackageName();

                // Ignore an invalid provider, one not matching the filter,
                // or one that isn't in the given package, if any.
                boolean inPackage = packageName == null
                        || providerPackageName.equals(packageName);
                if (provider.zombie || (info.widgetCategory & categoryFilter) == 0 || !inPackage) {
                // Ignore an invalid provider or one that isn't in the given package, if any.
                boolean inPackage = packageName == null || providerPackageName.equals(packageName);
                if (provider.zombie || !inPackage) {
                    continue;
                }

                // Ignore the ones not matching the filter.
                AppWidgetProviderInfo info = provider.getInfoLocked(mContext);
                if ((info.widgetCategory & categoryFilter) == 0) {
                    continue;
                }