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

Commit f7ecc88b authored by Jungshik Jang's avatar Jungshik Jang Committed by Android (Google) Code Review
Browse files

Merge "DO NOT MERGE: Add HdmiCecDeviceInfo to HdmiCecLocalDevice" into lmp-preview-dev

parents a8b57081 562ef5c5
Loading
Loading
Loading
Loading
+2 −3
Original line number Diff line number Diff line
@@ -76,8 +76,8 @@ final class HdmiCecController {

    private HdmiControlService mService;

    // Map-like container of all cec devices. A logical address of device is
    // used as key of container.
    // Map-like container of all cec devices including local ones.
    // A logical address of device is used as key of container.
    private final SparseArray<HdmiCecDeviceInfo> mDeviceInfos = new SparseArray<>();

    // Stores the local CEC devices in the system.
@@ -265,7 +265,6 @@ final class HdmiCecController {
     *
     * <p>Declared as package-private. accessed by {@link HdmiControlService} only.
     */
    // TODO: put local devices to this list.
    List<HdmiCecDeviceInfo> getDeviceInfoList() {
        assertRunOnServiceThread();

+25 −0
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@ package com.android.server.hdmi;
import com.android.server.hdmi.HdmiCecController.AllocateLogicalAddressCallback;

import android.hardware.hdmi.HdmiCec;
import android.hardware.hdmi.HdmiCecDeviceInfo;

/**
 * Class that models a logical CEC device hosted in this system. Handles initialization,
@@ -30,6 +31,7 @@ abstract class HdmiCecLocalDevice {
    protected final int mDeviceType;
    protected int mAddress;
    protected int mPreferredAddress;
    protected HdmiCecDeviceInfo mDeviceInfo;

    protected HdmiCecLocalDevice(HdmiCecController controller, int deviceType) {
        mController = controller;
@@ -57,11 +59,34 @@ abstract class HdmiCecLocalDevice {
            @Override
            public void onAllocated(int deviceType, int logicalAddress) {
                mAddress = mPreferredAddress = logicalAddress;

                // Create and set device info.
                HdmiCecDeviceInfo deviceInfo = createDeviceInfo(mAddress, deviceType);
                setDeviceInfo(deviceInfo);
                mController.addDeviceInfo(deviceInfo);

                mController.addLogicalAddress(logicalAddress);
            }
        });
    }

    private final HdmiCecDeviceInfo createDeviceInfo(int logicalAddress, int deviceType) {
        int vendorId = mController.getVendorId();
        int physicalAddress = mController.getPhysicalAddress();
        // TODO: get device name read from system configuration.
        String displayName = HdmiCec.getDefaultDeviceName(logicalAddress);
        return new HdmiCecDeviceInfo(logicalAddress,
                physicalAddress, deviceType, vendorId, displayName);
    }

    HdmiCecDeviceInfo getDeviceInfo() {
        return mDeviceInfo;
    }

    void setDeviceInfo(HdmiCecDeviceInfo info) {
        mDeviceInfo = info;
    }

    // Returns true if the logical address is same as the argument.
    boolean isAddressOf(int addr) {
        return addr == mAddress;