NetworkPolicy: Replace fake allLocks

Use platform support for multiple locks.

Bug: 72666911
Test: m javac-check RUN_ERROR_PRONE=true
Change-Id: If19038307baa53b5912252ab34024494df943d24
This commit is contained in:
Andreas Gampe
2018-10-24 19:42:52 -07:00
parent 6f7d3848c5
commit e8e2ebd651

View File

@@ -270,14 +270,12 @@ import java.util.concurrent.TimeUnit;
* enforcement.
*
* <p>
* This class uses 2-3 locks to synchronize state:
* This class uses 2 locks to synchronize state:
* <ul>
* <li>{@code mUidRulesFirstLock}: used to guard state related to individual UIDs (such as firewall
* rules).
* <li>{@code mNetworkPoliciesSecondLock}: used to guard state related to network interfaces (such
* as network policies).
* <li>{@code allLocks}: not a "real" lock, but an indication (through @GuardedBy) that all locks
* must be held.
* </ul>
*
* <p>
@@ -419,7 +417,8 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub {
final Object mUidRulesFirstLock = new Object();
final Object mNetworkPoliciesSecondLock = new Object();
@GuardedBy("allLocks") volatile boolean mSystemReady;
@GuardedBy({"mUidRulesFirstLock", "mNetworkPoliciesSecondLock"})
volatile boolean mSystemReady;
@GuardedBy("mUidRulesFirstLock") volatile boolean mRestrictBackground;
@GuardedBy("mUidRulesFirstLock") volatile boolean mRestrictPower;
@@ -545,7 +544,7 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub {
private final ServiceThread mUidEventThread;
@GuardedBy("allLocks")
@GuardedBy({"mUidRulesFirstLock", "mNetworkPoliciesSecondLock"})
private final AtomicFile mPolicyFile;
private final AppOpsManager mAppOps;