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

Commit d4935a10 authored by Varun Shah's avatar Varun Shah
Browse files

Update NPE check w.r.t. proc state locking.

Fixes: 373519351
Test: atest ContentProviderTest
Flag: EXEMPT bugfix
Change-Id: Idea78ff1544b096a4d2d50d491b4c83ed23c342b
parent 79e00d91
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);