Check if caller is suspending package before unsuspended broadcast

The code falsely assumed the caller unsuspending a package was the one
previously suspending it. This checks that the caller actually is the
only suspending package in the map.

Also adjusts some test callback infrastructure to make it easier to
use and read.

Bug: 232319688

Merged-In: Ie06df12ff3da6cf209fb3149e6aa80b0e63ce56e
Change-Id: Ie06df12ff3da6cf209fb3149e6aa80b0e63ce56e
This commit is contained in:
Winson
2022-09-09 15:32:36 -07:00
committed by Winson Chiu
parent a7e845486e
commit d161411c44

View File

@@ -160,9 +160,11 @@ public final class SuspendPackageHelper {
}
}
// If size one, the package will be unsuspended from this call
boolean packageUnsuspended =
!suspended && CollectionUtils.size(suspendParamsMap) <= 1;
// If only the callingPackage is suspending this package,
// it will be unsuspended when this change is committed
boolean packageUnsuspended = !suspended
&& CollectionUtils.size(suspendParamsMap) == 1
&& suspendParamsMap.containsKey(callingPackage);
if (suspended || packageUnsuspended) {
changedPackagesList.add(packageName);
changedUids.add(UserHandle.getUid(userId, packageState.getAppId()));