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

Commit 90706894 authored by Ryan Mitchell's avatar Ryan Mitchell
Browse files

Fix app widget deadlock when toggling overlays

AppWidgetManager uses ActivityManager so we must update it without
holding the AMS lock.

Bug: 195649929
Bug: 193866093
Test: Repeatedly change wallpaper & style color to a "basic" color
      and go back to launcher to observe overlay correct color is
      applied
Change-Id: I7a3ba2af026b98c87da8ebbe4dbca602f8c4bcf2
parent a57b0e9c
Loading
Loading
Loading
Loading
+16 −14
Original line number Diff line number Diff line
@@ -16570,15 +16570,23 @@ public class ActivityManagerService extends IActivityManager.Stub
        enforceCallingPermission(android.Manifest.permission.CHANGE_CONFIGURATION,
                "scheduleApplicationInfoChanged()");
        synchronized (mProcLock) {
        final long origId = Binder.clearCallingIdentity();
        try {
                updateApplicationInfoLOSP(packageNames, userId);
            final boolean updateFrameworkRes = packageNames.contains("android");
            synchronized (mProcLock) {
                updateApplicationInfoLOSP(packageNames, updateFrameworkRes, userId);
            }
            AppWidgetManagerInternal widgets = LocalServices.getService(
                    AppWidgetManagerInternal.class);
            if (widgets != null) {
                widgets.applyResourceOverlaysToWidgets(new HashSet<>(packageNames), userId,
                        updateFrameworkRes);
            }
        } finally {
            Binder.restoreCallingIdentity(origId);
        }
    }
    }
    /**
     * Synchronously update the system ActivityThread, bypassing any deferred threading so any
@@ -16593,18 +16601,12 @@ public class ActivityManagerService extends IActivityManager.Stub
    }
    @GuardedBy(anyOf = {"this", "mProcLock"})
    private void updateApplicationInfoLOSP(@NonNull List<String> packagesToUpdate, int userId) {
        final boolean updateFrameworkRes = packagesToUpdate.contains("android");
    private void updateApplicationInfoLOSP(@NonNull List<String> packagesToUpdate,
            boolean updateFrameworkRes, int userId) {
        if (updateFrameworkRes) {
            ParsingPackageUtils.readConfigUseRoundIcon(null);
        }
        AppWidgetManagerInternal widgets = LocalServices.getService(AppWidgetManagerInternal.class);
        if (widgets != null) {
            widgets.applyResourceOverlaysToWidgets(new HashSet<>(packagesToUpdate), userId,
                    updateFrameworkRes);
        }
        mProcessList.updateApplicationInfoLOSP(packagesToUpdate, userId, updateFrameworkRes);
        if (updateFrameworkRes) {