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

Unverified Commit 9b5d27da authored by Harold Tan's avatar Harold Tan Committed by Michael Bestas
Browse files

WiredAccessoryManager: Update stream index assignment

DP device node index was mistakenly being used as
stream index in the constructor of UEventInfo class.

Add logic to differentiate stream index assignment
under single and multiple active DP connection scenarios.

CRs-Fixed: 2998257
Change-Id: I96a261237431959c8d7e49b887c91858616de8a7
parent fa374e68
Loading
Loading
Loading
Loading
+11 −1
Original line number Diff line number Diff line
@@ -559,6 +559,9 @@ final class WiredAccessoryManager implements WiredAccessoryCallbacks {
            for (int i = 0; i < mUEventInfo.size(); ++i) {
                UEventInfo uei = mUEventInfo.get(i);
                if (devPath.equals(uei.getDevPath())) {
                    if (state == 1 && mDpCount > 0) {
                        uei.setStreamIndex(mDpCount);
                    }
                    updateLocked(name, uei.getDevAddress(),
                            uei.computeNewHeadsetState(mHeadsetState, state));
                    return;
@@ -592,7 +595,6 @@ final class WiredAccessoryManager implements WiredAccessoryCallbacks {
                        assert(idx2 != -1);
                        int dev = Integer.parseInt(mDevName.substring(idx + 1, idx2));
                        int cable = Integer.parseInt(mDevName.substring(idx2 + 1));
                        mDevAddress = "controller=" + cable + ";stream=" + dev;
                        if (LOG) {
                            Slog.v(TAG, "UEvent dev address " + mDevAddress);
                        }
@@ -679,6 +681,14 @@ final class WiredAccessoryManager implements WiredAccessoryCallbacks {
                }
            }

            public void setStreamIndex(int streamIndex) {
                int index1 = mDevAddress.indexOf("=");
                int index2 = mDevAddress.indexOf("=", index1 + 1);

                String allExceptStreamIdx = mDevAddress.substring(0, index2 + 1);
                mDevAddress = allExceptStreamIdx + String.valueOf(streamIndex);
            }

            public String getDevName() {
                return mDevName;
            }