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

Commit 181bd09c authored by Paul Colța's avatar Paul Colța Committed by Android (Google) Code Review
Browse files

Merge "HDMI: Ignore additional parameters in <User Control Pressed> messages"

parents bcb8ed23 5bac9d02
Loading
Loading
Loading
Loading
+7 −1
Original line number Diff line number Diff line
@@ -213,7 +213,13 @@ final class HdmiCecKeycode {
        }

        private int toAndroidKeycodeIfMatched(byte[] cecKeycodeAndParams) {
            if (Arrays.equals(mCecKeycodeAndParams, cecKeycodeAndParams)) {
            if (cecKeycodeAndParams.length < mCecKeycodeAndParams.length) {
                return UNSUPPORTED_KEYCODE;
            }
            byte[] trimmedCecKeycodeAndParams = new byte[mCecKeycodeAndParams.length];
            System.arraycopy(cecKeycodeAndParams, 0, trimmedCecKeycodeAndParams, 0,
                    mCecKeycodeAndParams.length);
            if (Arrays.equals(mCecKeycodeAndParams, trimmedCecKeycodeAndParams)) {
                return mAndroidKeycode;
            } else {
                return UNSUPPORTED_KEYCODE;
+13 −0
Original line number Diff line number Diff line
@@ -503,6 +503,19 @@ public class HdmiCecLocalDeviceTest {
                .adjustStreamVolume(anyInt(), eq(AudioManager.ADJUST_UNMUTE), anyInt());
    }

    @Test
    public void handleUserControlPressed_ignoreAdditionalParameters() {
        byte[] params = new byte[] {
                (byte) (HdmiCecKeycode.CEC_KEYCODE_POWER_TOGGLE_FUNCTION & 0xFF), (byte) 0xFF};
        mPowerStatus = HdmiControlManager.POWER_STATUS_STANDBY;
        @Constants.HandleMessageResult int result = mHdmiLocalDevice.handleUserControlPressed(
                HdmiCecMessageBuilder.buildUserControlPressed(ADDR_TV, ADDR_PLAYBACK_1, params));

        assertEquals(Constants.HANDLED, result);
        assertThat(mWakeupMessageReceived).isTrue();
        assertThat(mStandbyMessageReceived).isFalse();
    }

    @Test
    public void handleVendorCommand_notHandled() {
        HdmiCecMessage vendorCommand = HdmiCecMessageBuilder.buildVendorCommand(ADDR_TV,