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

Commit 731c7bb7 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Return widget uid only when it is bound to screen" into tm-qpr-dev

parents e930c8d9 71e6090f
Loading
Loading
Loading
Loading
+7 −9
Original line number Diff line number Diff line
@@ -817,7 +817,8 @@ class AppWidgetServiceImpl extends IAppWidgetService.Stub implements WidgetBacku
            if (host != null) {
                host.callbacks = null;
                pruneHostLocked(host);
                mAppOpsManagerInternal.updateAppWidgetVisibility(host.getWidgetUids(), false);
                mAppOpsManagerInternal.updateAppWidgetVisibility(host.getWidgetUidsIfBound(),
                        false);
            }
        }
    }
@@ -888,12 +889,8 @@ class AppWidgetServiceImpl extends IAppWidgetService.Stub implements WidgetBacku
            Host host = lookupHostLocked(id);

            if (host != null) {
                try {
                    mAppOpsManagerInternal.updateAppWidgetVisibility(host.getWidgetUids(), false);
                } catch (NullPointerException e) {
                    Slog.e(TAG, "setAppWidgetHidden(): Getting host uids: " + host.toString(), e);
                    throw e;
                }
                mAppOpsManagerInternal.updateAppWidgetVisibility(host.getWidgetUidsIfBound(),
                        false);
            }
        }
    }
@@ -4345,14 +4342,15 @@ class AppWidgetServiceImpl extends IAppWidgetService.Stub implements WidgetBacku
                    PendingHostUpdate.appWidgetRemoved(appWidgetId));
        }

        public SparseArray<String> getWidgetUids() {
        public SparseArray<String> getWidgetUidsIfBound() {
            final SparseArray<String> uids = new SparseArray<>();
            for (int i = widgets.size() - 1; i >= 0; i--) {
                final Widget widget = widgets.get(i);
                if (widget.provider == null) {
                    if (DEBUG) {
                        Slog.e(TAG, "Widget with no provider " + widget.toString());
                        Slog.d(TAG, "Widget with no provider " + widget.toString());
                    }
                    continue;
                }
                final ProviderId providerId = widget.provider.id;
                uids.put(providerId.uid, providerId.componentName.getPackageName());