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

Commit 3eaa85f1 authored by Amy's avatar Amy Committed by shubang
Browse files

Fix pathToPort logic in HdmiControlService

ag/5306538

The logic is not correct. Only correct when the target device is directly connected
to the current device.

Test: atest com.android.server.hdmi
Change-Id: Ia090bd70069b3457a975b03574347640151cf5ac
parent 1e4a8cc5
Loading
Loading
Loading
Loading
+6 −3
Original line number Original line Diff line number Diff line
@@ -828,11 +828,14 @@ public class HdmiControlService extends SystemService {
        int mask = 0xF000;
        int mask = 0xF000;
        int finalMask = 0xF000;
        int finalMask = 0xF000;
        int physicalAddress = getPhysicalAddress();
        int physicalAddress = getPhysicalAddress();
        while (physicalAddress != 0) {
        int maskedAddress = physicalAddress;
            physicalAddress &= mask;

            mask >>= 4;
        while (maskedAddress != 0) {
            maskedAddress = physicalAddress & mask;
            finalMask |= mask;
            finalMask |= mask;
            mask >>= 4;
        }
        }

        int portAddress = path & finalMask;
        int portAddress = path & finalMask;
        return mPortIdMap.get(portAddress, Constants.INVALID_PORT_ID);
        return mPortIdMap.get(portAddress, Constants.INVALID_PORT_ID);
    }
    }
+7 −3
Original line number Original line Diff line number Diff line
@@ -137,11 +137,15 @@ public class HdmiControlServiceTest {


        mLocalDevices.add(mMyAudioSystemDevice);
        mLocalDevices.add(mMyAudioSystemDevice);
        mLocalDevices.add(mMyPlaybackDevice);
        mLocalDevices.add(mMyPlaybackDevice);
        mHdmiPortInfo = new HdmiPortInfo[2];
        mHdmiPortInfo = new HdmiPortInfo[4];
        mHdmiPortInfo[0] =
        mHdmiPortInfo[0] =
            new HdmiPortInfo(1, HdmiPortInfo.PORT_INPUT, 0x2100, true, false, false);
            new HdmiPortInfo(1, HdmiPortInfo.PORT_INPUT, 0x2100, true, false, false);
        mHdmiPortInfo[1] =
        mHdmiPortInfo[1] =
            new HdmiPortInfo(2, HdmiPortInfo.PORT_INPUT, 0x2200, true, false, false);
            new HdmiPortInfo(2, HdmiPortInfo.PORT_INPUT, 0x2200, true, false, false);
        mHdmiPortInfo[2] =
            new HdmiPortInfo(3, HdmiPortInfo.PORT_INPUT, 0x2000, true, false, false);
        mHdmiPortInfo[3] =
            new HdmiPortInfo(4, HdmiPortInfo.PORT_INPUT, 0x3000, true, false, false);
        mNativeWrapper.setPortInfo(mHdmiPortInfo);
        mNativeWrapper.setPortInfo(mHdmiPortInfo);
        mHdmiControlService.initPortInfo();
        mHdmiControlService.initPortInfo();
        mHdmiControlService.allocateLogicalAddress(mLocalDevices, INITIATED_BY_ENABLE_CEC);
        mHdmiControlService.allocateLogicalAddress(mLocalDevices, INITIATED_BY_ENABLE_CEC);
@@ -182,8 +186,8 @@ public class HdmiControlServiceTest {
    @Test
    @Test
    public void pathToPort_pathExists_weAreTv() {
    public void pathToPort_pathExists_weAreTv() {
        mNativeWrapper.setPhysicalAddress(0x0000);
        mNativeWrapper.setPhysicalAddress(0x0000);
        assertThat(mHdmiControlService.pathToPortId(0x2120)).isEqualTo(2);
        assertThat(mHdmiControlService.pathToPortId(0x2120)).isEqualTo(3);
        assertThat(mHdmiControlService.pathToPortId(0x1234)).isEqualTo(1);
        assertThat(mHdmiControlService.pathToPortId(0x3234)).isEqualTo(4);
    }
    }


    @Test
    @Test