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

Commit 43375255 authored by Shubang Lu's avatar Shubang Lu Committed by Android (Google) Code Review
Browse files

Merge changes Ic1afbadf,I4074a924,If38b8c6d,I7fe7a17e

* changes:
  Broadcast Active Source when user enables HDMI CEC control.
  Use portid to physical address mapping to get correct port address.
  Add classes to hold Short Audio Descriptor xml parsed data.
  Implement find key receiver method for Audio System device to send key code to active source.
parents 7f7d8fb5 b9d7f432
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
package com.android.server.hdmi;

import android.annotation.IntDef;
import android.annotation.StringDef;
import android.hardware.hdmi.HdmiDeviceInfo;

import java.lang.annotation.Retention;
@@ -222,6 +223,15 @@ final class Constants {
    static final int AUDIO_CODEC_WMAPRO = 0xE; // Support WMA-Pro
    static final int AUDIO_CODEC_MAX = 0xF;

    @StringDef({
        AUDIO_DEVICE_ARC_IN,
        AUDIO_DEVICE_SPDIF,
    })
    public @interface AudioDevice {}

    static final String AUDIO_DEVICE_ARC_IN = "ARC_IN";
    static final String AUDIO_DEVICE_SPDIF = "SPDIF";

    // Bit mask used to get the routing path of the top level device.
    // When &'d with the path 1.2.2.0 (0x1220), for instance, gives 1.0.0.0.
    static final int ROUTING_PATH_TOP_MASK = 0xF000;
+9 −3
Original line number Diff line number Diff line
@@ -269,6 +269,10 @@ public class HdmiCecLocalDeviceAudioSystem extends HdmiCecLocalDeviceSource {
    @ServiceThreadOnly
    protected void onAddressAllocated(int logicalAddress, int reason) {
        assertRunOnServiceThread();
        if (reason == mService.INITIATED_BY_ENABLE_CEC) {
            mService.setAndBroadcastActiveSource(mService.getPhysicalAddress(),
                    getDeviceInfo().getDeviceType(), Constants.ADDR_BROADCAST);
        }
        mService.sendCecCommand(
                HdmiCecMessageBuilder.buildReportPhysicalAddressCommand(
                        mAddress, mService.getPhysicalAddress(), mDeviceType));
@@ -288,7 +292,10 @@ public class HdmiCecLocalDeviceAudioSystem extends HdmiCecLocalDeviceSource {

    @Override
    protected int findKeyReceiverAddress() {
        return Constants.ADDR_TV;
        if (getActiveSource().isValid()) {
            return getActiveSource().logicalAddress;
        }
        return Constants.ADDR_INVALID;
    }

    @VisibleForTesting
@@ -1051,8 +1058,7 @@ public class HdmiCecLocalDeviceAudioSystem extends HdmiCecLocalDeviceSource {
            return;
        }

        int routingInformationPath =
                getActivePathOnSwitchFromActivePortId(getRoutingPort());
        int routingInformationPath = mService.portIdToPath(getRoutingPort());
        // If current device is already the leaf of the whole HDMI system, will do nothing.
        if (routingInformationPath == mService.getPhysicalAddress()) {
            HdmiLogger.debug("Current device can't assign valid physical address"
+4 −0
Original line number Diff line number Diff line
@@ -77,6 +77,10 @@ public class HdmiCecLocalDevicePlayback extends HdmiCecLocalDeviceSource {
    @ServiceThreadOnly
    protected void onAddressAllocated(int logicalAddress, int reason) {
        assertRunOnServiceThread();
        if (reason == mService.INITIATED_BY_ENABLE_CEC) {
            mService.setAndBroadcastActiveSource(mService.getPhysicalAddress(),
                    getDeviceInfo().getDeviceType(), Constants.ADDR_BROADCAST);
        }
        mService.sendCecCommand(HdmiCecMessageBuilder.buildReportPhysicalAddressCommand(
                mAddress, mService.getPhysicalAddress(), mDeviceType));
        mService.sendCecCommand(HdmiCecMessageBuilder.buildDeviceVendorIdCommand(
+1 −1
Original line number Diff line number Diff line
@@ -218,7 +218,7 @@ abstract class HdmiCecLocalDeviceSource extends HdmiCecLocalDevice {
    // This method should only be called when the device can be the active source.
    protected void setAndBroadcastActiveSource(HdmiCecMessage message, int physicalAddress) {
        mService.setAndBroadcastActiveSource(
                message, physicalAddress, getDeviceInfo().getDeviceType());
                physicalAddress, getDeviceInfo().getDeviceType(), message.getSource());
    }

    @ServiceThreadOnly
+3 −3
Original line number Diff line number Diff line
@@ -2707,14 +2707,14 @@ public class HdmiControlService extends SystemService {
    // For example, when receiving broadcast messages, all the device types will call this
    // method but only one of them will be the Active Source.
    protected void setAndBroadcastActiveSource(
            HdmiCecMessage message, int physicalAddress, int deviceType) {
            int physicalAddress, int deviceType, int source) {
        // If the device has both playback and audio system logical addresses,
        // playback will claim active source. Otherwise audio system will.
        if (deviceType == HdmiDeviceInfo.DEVICE_PLAYBACK) {
            HdmiCecLocalDevicePlayback playback = playback();
            playback.setIsActiveSource(true);
            playback.wakeUpIfActiveSource();
            playback.maySendActiveSource(message.getSource());
            playback.maySendActiveSource(source);
            setActiveSource(playback.mAddress, physicalAddress);
        }

@@ -2725,7 +2725,7 @@ public class HdmiControlService extends SystemService {
            } else {
                audioSystem.setIsActiveSource(true);
                audioSystem.wakeUpIfActiveSource();
                audioSystem.maySendActiveSource(message.getSource());
                audioSystem.maySendActiveSource(source);
                setActiveSource(audioSystem.mAddress, physicalAddress);
            }
        }
Loading