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

Commit c7eeb40e authored by TYM Tsai's avatar TYM Tsai
Browse files

Fix deadlock between PMS and AMS

Move reportComponentStateChanged() out of holding mLock to avoid
deadlock.

Symptom:
At thread 1,
PackageManagerService#setEnabledSettings held mLock
-> reportComponentStateChanged ...
--> AppOpsService#verifyAndGetBypass ask the this of AppOpsService
At thread 2,
Executor of AppOpsUidStateTrackerImpl held the this of AppOpsService
-> getPackagesForUid() ...
-->PackageManagerService#snapshotComputer ask mLock

Bug: 339045335
Bug: 340962640
Test: atest CtsPackageManagerTestCases
Change-Id: I7238a779202daceb3f2d69ced20ce41c7d1749c2
parent 1107f93b
Loading
Loading
Loading
Loading
+4 −3
Original line number Original line Diff line number Diff line
@@ -4052,9 +4052,6 @@ public class PackageManagerService implements PackageSender, TestUtilityService
                return;
                return;
            }
            }


            // Log the metrics when the component state is changed.
            PackageMetrics.reportComponentStateChanged(computer, componentStateMetricsList, userId);

            if (isSynchronous) {
            if (isSynchronous) {
                flushPackageRestrictionsAsUserInternalLocked(userId);
                flushPackageRestrictionsAsUserInternalLocked(userId);
            } else {
            } else {
@@ -4074,6 +4071,10 @@ public class PackageManagerService implements PackageSender, TestUtilityService
            }
            }
        }
        }


        // Log the metrics when the component state is changed.
        PackageMetrics.reportComponentStateChanged(snapshotComputer(), componentStateMetricsList,
                userId);

        final long callingId = Binder.clearCallingIdentity();
        final long callingId = Binder.clearCallingIdentity();
        try {
        try {
            final Computer newSnapshot = snapshotComputer();
            final Computer newSnapshot = snapshotComputer();