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

Commit a19ea443 authored by Liana Kazanova (xWF)'s avatar Liana Kazanova (xWF) Committed by Android (Google) Code Review
Browse files

Merge "Revert "Prevent unintentional removal of widgets pinned by another host"" into main

parents 22d1c0bf 69af3e57
Loading
Loading
Loading
Loading
+0 −20
Original line number Diff line number Diff line
@@ -5666,13 +5666,6 @@ class AppWidgetServiceImpl extends IAppWidgetService.Stub implements WidgetBacku
        }

        public boolean canAccessAppWidget(Widget widget, int uid, String packageName) {
            if (isDifferentPackageFromHost(widget.host, packageName)
                    && isDifferentPackageFromProvider(widget.provider, packageName)) {
                // Apps providing AppWidget are only allowed to access widgets provided by the
                // same package. Similarly, apps hosting AppWidget are only allowed to access
                // widgets hosted by the same package.
                return false;
            }
            if (isHostInPackageForUid(widget.host, uid, packageName)) {
                // Apps hosting the AppWidget have access to it.
                return true;
@@ -5775,19 +5768,6 @@ class AppWidgetServiceImpl extends IAppWidgetService.Stub implements WidgetBacku
                    && provider.id.componentName.getPackageName().equals(packageName);
        }

        private boolean isDifferentPackageFromHost(
                @Nullable final Host host, @Nullable final String packageName) {
            return packageName == null || host == null || host.id == null
                || !packageName.equals(host.id.packageName);
        }

        private boolean isDifferentPackageFromProvider(
                @Nullable final Provider provider, @Nullable final String packageName) {
            return packageName == null || provider == null || provider.id == null
                    || provider.id.componentName == null
                    || !packageName.equals(provider.id.componentName.getPackageName());
        }

        private boolean isProfileEnabled(int profileId) {
            final long identity = Binder.clearCallingIdentity();
            try {