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

Commit 46d14dde authored by Paul Colța's avatar Paul Colța Committed by Gerrit Code Review
Browse files

Merge "Remove redundant <Give OSD name> for TV devices" into main

parents dff1d0ff 157ffd58
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -559,7 +559,9 @@ abstract class HdmiCecLocalDevice extends HdmiLocalDevice {

        HdmiDeviceInfo cecDeviceInfo = mService.getHdmiCecNetwork().getCecDeviceInfo(address);
        // If no non-default display name is available for the device, request the devices OSD name.
        if (cecDeviceInfo != null && cecDeviceInfo.getDisplayName().equals(
        // On TV devices, the OSD name is queried in NewDeviceAction instead.
        if (!mService.isTvDevice() && cecDeviceInfo != null
                && cecDeviceInfo.getDisplayName().equals(
                HdmiUtils.getDefaultDeviceName(address))) {
            mService.sendCecCommand(
                    HdmiCecMessageBuilder.buildGiveOsdNameCommand(
+22 −0
Original line number Diff line number Diff line
@@ -27,6 +27,8 @@ import static com.android.server.hdmi.HdmiControlService.INITIATED_BY_ENABLE_CEC

import static com.google.common.truth.Truth.assertThat;

import static junit.framework.Assert.assertEquals;

import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.mockito.ArgumentMatchers.any;
@@ -1648,4 +1650,24 @@ public class HdmiCecLocalDeviceTvTest {
        assertThat(mHdmiControlService.isSystemAudioActivated()).isTrue();

    }

    @Test
    public void newDeviceConnectedIfOnlyOneGiveOsdNameSent() {
        mHdmiControlService.getHdmiCecNetwork().clearDeviceList();
        assertThat(mHdmiControlService.getHdmiCecNetwork().getDeviceInfoList(false))
                .isEmpty();
        HdmiCecMessage reportPhysicalAddress =
                HdmiCecMessageBuilder.buildReportPhysicalAddressCommand(
                ADDR_PLAYBACK_2, 0x1000, HdmiDeviceInfo.DEVICE_PLAYBACK);
        HdmiCecMessage giveOsdName = HdmiCecMessageBuilder.buildGiveOsdNameCommand(
                ADDR_TV, ADDR_PLAYBACK_2);
        mNativeWrapper.onCecMessage(reportPhysicalAddress);
        mTestLooper.dispatchAll();

        // Wait until HdmiCecNetwork or NewDeviceAction is in progress
        mTestLooper.moveTimeForward(HdmiConfig.TIMEOUT_MS);

        // TV should only send <Give Osd Name> once
        assertEquals(1, Collections.frequency(mNativeWrapper.getResultMessages(), giveOsdName));
    }
}