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

Commit dd705aca authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Automerger Merge Worker
Browse files

Merge "Defuse notification race around app stops" into tm-dev am: 81ac10a9

parents 8191f931 81ac10a9
Loading
Loading
Loading
Loading
+13 −1
Original line number Diff line number Diff line
@@ -5183,7 +5183,7 @@ public final class ActiveServices {
    }

    boolean bringDownDisabledPackageServicesLocked(String packageName, Set<String> filterByClasses,
            int userId, boolean evenPersistent, boolean doit) {
            int userId, boolean evenPersistent, boolean fullStop, boolean doit) {
        boolean didSomething = false;

        if (mTmpCollectionResults != null) {
@@ -5221,6 +5221,18 @@ public final class ActiveServices {
            if (size > 0) {
                mAm.updateOomAdjPendingTargetsLocked(OomAdjuster.OOM_ADJ_REASON_UNBIND_SERVICE);
            }
            if (fullStop && !mTmpCollectionResults.isEmpty()) {
                // if we're tearing down the app's entire service state, account for possible
                // races around FGS notifications by explicitly tidying up in a separate
                // pass post-shutdown
                final ArrayList<ServiceRecord> allServices =
                        (ArrayList<ServiceRecord>) mTmpCollectionResults.clone();
                mAm.mHandler.postDelayed(() -> {
                    for (int i = 0; i < allServices.size(); i++) {
                        allServices.get(i).cancelNotification();
                    }
                }, 250L);
            }
            mTmpCollectionResults.clear();
        }

+4 −3
Original line number Diff line number Diff line
@@ -4361,7 +4361,8 @@ public class ActivityManagerService extends IActivityManager.Stub
        // Clean-up disabled services.
        mServices.bringDownDisabledPackageServicesLocked(
                packageName, disabledClasses, userId, false /* evenPersistent */, true /* doIt */);
                packageName, disabledClasses, userId, false /* evenPersistent */,
                false /* fullStop */, true /* doIt */);
        // Clean-up disabled providers.
        ArrayList<ContentProviderRecord> providers = new ArrayList<>();
@@ -4436,7 +4437,7 @@ public class ActivityManagerService extends IActivityManager.Stub
            }
            mServices.bringDownDisabledPackageServicesLocked(
                    packageName, null, userId, false, true);
                    packageName, null, userId, false, true, true);
            if (mBooted) {
                mAtmInternal.resumeTopActivities(true);
@@ -4489,7 +4490,7 @@ public class ActivityManagerService extends IActivityManager.Stub
        }
        if (mServices.bringDownDisabledPackageServicesLocked(
                packageName, null /* filterByClasses */, userId, evenPersistent, doit)) {
                packageName, null /* filterByClasses */, userId, evenPersistent, true, doit)) {
            if (!doit) {
                return true;
            }