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

Commit 9da498e1 authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Update NPE check w.r.t. proc state locking." into main

parents 3ceb8316 d4935a10
Loading
Loading
Loading
Loading
+12 −6
Original line number Diff line number Diff line
@@ -40,7 +40,7 @@ public final class ContentProviderConnection extends Binder implements
    public final String clientPackage;
    public AssociationState.SourceState association;
    public final long createTime;
    private Object mProcStatsLock;  // Internal lock for accessing AssociationState
    private volatile Object mProcStatsLock;  // Internal lock for accessing AssociationState

    /**
     * Internal lock that guards access to the two counters.
@@ -118,21 +118,27 @@ public final class ContentProviderConnection extends Binder implements
     * Track the given proc state change.
     */
    public void trackProcState(int procState, int seq) {
        if (association != null) {
        if (association == null) {
            return; // early exit to optimize on oomadj cycles
        }
        synchronized (mProcStatsLock) {
            if (association != null) { // due to race-conditions, association may have become null
                association.trackProcState(procState, seq, SystemClock.uptimeMillis());
            }
        }
    }

    public void stopAssociation() {
        if (association != null) {
        if (association == null) {
            return; // early exit to optimize on oomadj cycles
        }
        synchronized (mProcStatsLock) {
            if (association != null) {  // due to race-conditions, association may have become null
                association.stop();
            }
                association = null;
            }
        }
    }

    public String toString() {
        StringBuilder sb = new StringBuilder(128);