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

Commit 75349869 authored by Sihua Ma's avatar Sihua Ma Committed by Automerger Merge Worker
Browse files

Merge "Add function to AppWidgetService for updating widget visibility" into...

Merge "Add function to AppWidgetService for updating widget visibility" into tm-qpr-dev am: d776e8d5 am: a5186e82

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/20003665



Change-Id: I40681069bbb22b4da1e8e7284ba0441afa7b83b1
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents 4a5f2fbb a5186e82
Loading
Loading
Loading
Loading
+16 −0
Original line number Diff line number Diff line
@@ -328,6 +328,22 @@ public class AppWidgetHost {
        }
    }

    /**
     * Set the visibiity of all widgets associated with this host to hidden
     *
     * @hide
     */
    public void setAppWidgetHidden() {
        if (sService == null) {
            return;
        }
        try {
            sService.setAppWidgetHidden(mContextOpPackageName, mHostId);
        } catch (RemoteException e) {
            throw new RuntimeException("System server dead?", e);
        }
    }

    /**
     * Set the host's interaction handler.
     *
+1 −0
Original line number Diff line number Diff line
@@ -45,6 +45,7 @@ interface IAppWidgetService {
    @UnsupportedAppUsage(maxTargetSdk = 30, trackingBug = 170729553)
    RemoteViews getAppWidgetViews(String callingPackage, int appWidgetId);
    int[] getAppWidgetIdsForHost(String callingPackage, int hostId);
    void setAppWidgetHidden(in String callingPackage, int hostId);
    IntentSender createAppWidgetConfigIntentSender(String callingPackage, int appWidgetId,
            int intentFlags);

+27 −0
Original line number Diff line number Diff line
@@ -871,6 +871,33 @@ class AppWidgetServiceImpl extends IAppWidgetService.Stub implements WidgetBacku
        }
    }

    @Override
    public void setAppWidgetHidden(String callingPackage, int hostId) {
        final int userId = UserHandle.getCallingUserId();

        if (DEBUG) {
            Slog.i(TAG, "setAppWidgetHidden() " + userId);
        }

        mSecurityPolicy.enforceCallFromPackage(callingPackage);

        synchronized (mLock) {
            ensureGroupStateLoadedLocked(userId, /* enforceUserUnlockingOrUnlocked */false);

            HostId id = new HostId(Binder.getCallingUid(), hostId, callingPackage);
            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;
                }
            }
        }
    }

    @Override
    public void deleteAppWidgetId(String callingPackage, int appWidgetId) {
        final int userId = UserHandle.getCallingUserId();