Add HdmiCecDeviceInfo to HdmiCecLocalDevice
As HdmiCecLoclaDevice is a wrapper for local devices it should include cec device info. Change-Id: I479665b2aa6bd56470b79dbbb7fb1015f6356090
This commit is contained in:
@@ -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();
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user