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

Commit 178cb913 authored by Arthur Ishiguro's avatar Arthur Ishiguro
Browse files

Fix service endpoint ID generation logic

Bug: 382547520
Flag: android.chre.flags.offload_implementation
Test: Compile
Change-Id: Ie64dc5120903e30a80ac3dd349e3dfa4274e3050
parent 4ebe13b1
Loading
Loading
Loading
Loading
+7 −3
Original line number Diff line number Diff line
@@ -65,8 +65,12 @@ import java.util.concurrent.ConcurrentHashMap;
    /** Variables for managing endpoint ID creation */
    private final Object mEndpointLock = new Object();

    /**
     * The next available endpoint ID to register. Per EndpointId.aidl definition, dynamic
     * endpoint IDs must have the left-most bit as 1, and the values 0/-1 are invalid.
     */
    @GuardedBy("mEndpointLock")
    private long mNextEndpointId = 0;
    private long mNextEndpointId = -2;

    /** The minimum session ID reservable by endpoints (retrieved from HAL) */
    private final int mMinSessionId;
@@ -282,10 +286,10 @@ import java.util.concurrent.ConcurrentHashMap;
    /** @return an available endpoint ID */
    private long getNewEndpointId() {
        synchronized (mEndpointLock) {
            if (mNextEndpointId == Long.MAX_VALUE) {
            if (mNextEndpointId >= 0) {
                throw new IllegalStateException("Too many endpoints connected");
            }
            return mNextEndpointId++;
            return mNextEndpointId--;
        }
    }