Loading api/current.txt +11 −0 Original line number Diff line number Diff line Loading @@ -12394,6 +12394,17 @@ package android.hardware.hdmi { method public void onMessageReceived(android.hardware.hdmi.HdmiCecMessage); } public final class HdmiCecDeviceInfo implements android.os.Parcelable { method public int describeContents(); method public int getDeviceType(); method public java.lang.String getDisplayName(); method public int getLogicalAddress(); method public int getPhysicalAddress(); method public int getVendorId(); method public void writeToParcel(android.os.Parcel, int); field public static final android.os.Parcelable.Creator CREATOR; } public final class HdmiCecManager { method public android.hardware.hdmi.HdmiCecClient getClient(int, android.hardware.hdmi.HdmiCecClient.Listener); } core/java/android/hardware/hdmi/HdmiCecDeviceInfo.java 0 → 100644 +168 −0 Original line number Diff line number Diff line /* * Copyright (C) 2014 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package android.hardware.hdmi; import android.os.Parcel; import android.os.Parcelable; /** * A class to encapsulate device information for HDMI-CEC. This container * include basic information such as logical address, physical address and * device type, and additional information like vendor id and osd name. */ public final class HdmiCecDeviceInfo implements Parcelable { // Logical address, phsical address, device type, vendor id and display name // are immutable value. private final int mLogicalAddress; private final int mPhysicalAddress; private final int mDeviceType; private final int mVendorId; private final String mDisplayName; /** * A helper class to deserialize {@link HdmiCecDeviceInfo} for a parcel. */ public static final Parcelable.Creator<HdmiCecDeviceInfo> CREATOR = new Parcelable.Creator<HdmiCecDeviceInfo>() { @Override public HdmiCecDeviceInfo createFromParcel(Parcel source) { int logicalAddress = source.readInt(); int physicalAddress = source.readInt(); int deviceType = source.readInt(); int vendorId = source.readInt(); String displayName = source.readString(); return new HdmiCecDeviceInfo(logicalAddress, physicalAddress, deviceType, vendorId, displayName); } @Override public HdmiCecDeviceInfo[] newArray(int size) { return new HdmiCecDeviceInfo[size]; } }; /** * Constructor. * * @param logicalAddress logical address of HDMI-Cec device. * For more details, refer {@link HdmiCec} * @param physicalAddress physical address of HDMI-Cec device * @param deviceType type of device. For more details, refer {@link HdmiCec} * @param vendorId vendor id of device. It's used for vendor specific command * @param displayName name of device * @hide */ public HdmiCecDeviceInfo(int logicalAddress, int physicalAddress, int deviceType, int vendorId, String displayName) { mLogicalAddress = logicalAddress; mPhysicalAddress = physicalAddress; mDeviceType = deviceType; mDisplayName = displayName; mVendorId = vendorId; } /** * Return the logical address of the device. It can have 0-15 values. * For more details, refer constants between {@link HdmiCec#ADDR_TV} * and {@link HdmiCec#ADDR_UNREGISTERED}. */ public int getLogicalAddress() { return mLogicalAddress; } /** * Return the physical address of the device. */ public int getPhysicalAddress() { return mPhysicalAddress; } /** * Return type of the device. For more details, refer constants between * {@link HdmiCec#DEVICE_TV} and {@link HdmiCec#DEVICE_INACTIVE}. */ public int getDeviceType() { return mDeviceType; } /** * Return display (OSD) name of the device. */ public String getDisplayName() { return mDisplayName; } /** * Return vendor id of the device. Vendor id is used to distinguish devices * built by other manufactures. This is required for vendor-specific command * on CEC standard. */ public int getVendorId() { return mVendorId; } /** * Describe the kinds of special objects contained in this Parcelable's * marshalled representation. */ @Override public int describeContents() { return 0; } /** * Serialize this object into a {@link Parcel}. * * @param dest The Parcel in which the object should be written. * @param flags Additional flags about how the object should be written. * May be 0 or {@link Parcelable#PARCELABLE_WRITE_RETURN_VALUE}. */ @Override public void writeToParcel(Parcel dest, int flags) { dest.writeInt(mLogicalAddress); dest.writeInt(mPhysicalAddress); dest.writeInt(mDeviceType); dest.writeInt(mVendorId); dest.writeString(mDisplayName); } @Override public String toString() { StringBuffer s = new StringBuffer(); s.append("logical_address: ").append(mLogicalAddress).append(", "); s.append("physical_address: ").append(mPhysicalAddress).append(", "); s.append("device_type: ").append(mDeviceType).append(", "); s.append("vendor_id: ").append(mVendorId).append(", "); s.append("display_name: ").append(mDisplayName); return s.toString(); } @Override public boolean equals(Object obj) { if (!(obj instanceof HdmiCecDeviceInfo)) { return false; } HdmiCecDeviceInfo other = (HdmiCecDeviceInfo) obj; return mLogicalAddress == other.mLogicalAddress && mPhysicalAddress == other.mPhysicalAddress && mDeviceType == other.mDeviceType && mVendorId == other.mVendorId && mDisplayName.equals(other.mDisplayName); } } services/core/java/com/android/server/hdmi/HdmiCecController.java +72 −0 Original line number Diff line number Diff line Loading @@ -17,13 +17,17 @@ package com.android.server.hdmi; import android.hardware.hdmi.HdmiCec; import android.hardware.hdmi.HdmiCecDeviceInfo; import android.hardware.hdmi.HdmiCecMessage; import android.os.Handler; import android.os.Looper; import android.os.Message; import android.util.Slog; import android.util.SparseArray; import java.util.ArrayList; import java.util.Arrays; import java.util.List; /** * Manages HDMI-CEC command and behaviors. It converts user's command into CEC command Loading Loading @@ -63,6 +67,11 @@ class HdmiCecController { // interacts with HAL. private long mNativePtr; // Map-like container of all cec devices. A logical address of device is // used as key of container. private final SparseArray<HdmiCecDeviceInfo> mDeviceInfos = new SparseArray<HdmiCecDeviceInfo>(); // Private constructor. Use HdmiCecController.create(). private HdmiCecController() { } Loading Loading @@ -136,6 +145,69 @@ class HdmiCecController { } } /** * Add a new {@link HdmiCecDeviceInfo}. It returns old device info which has the same * logical address as new device info's. * * <p>Declared as package-private. accessed by {@link HdmiControlService} only. * * @param deviceInfo a new {@link HdmiCecDeviceInfo} to be added. * @return {@code null} if it is new device. Otherwise, returns old {@HdmiCecDeviceInfo} * that has the same logical address as new one has. */ HdmiCecDeviceInfo addDeviceInfo(HdmiCecDeviceInfo deviceInfo) { HdmiCecDeviceInfo oldDeviceInfo = getDeviceInfo(deviceInfo.getLogicalAddress()); if (oldDeviceInfo != null) { removeDeviceInfo(deviceInfo.getLogicalAddress()); } mDeviceInfos.append(deviceInfo.getLogicalAddress(), deviceInfo); return oldDeviceInfo; } /** * Remove a device info corresponding to the given {@code logicalAddress}. * It returns removed {@link HdmiCecDeviceInfo} if exists. * * <p>Declared as package-private. accessed by {@link HdmiControlService} only. * * @param logicalAddress logical address of device to be removed * @return removed {@link HdmiCecDeviceInfo} it exists. Otherwise, returns {@code null} */ HdmiCecDeviceInfo removeDeviceInfo(int logicalAddress) { HdmiCecDeviceInfo deviceInfo = mDeviceInfos.get(logicalAddress); if (deviceInfo != null) { mDeviceInfos.remove(logicalAddress); } return deviceInfo; } /** * Return a list of all {@HdmiCecDeviceInfo}. * * <p>Declared as package-private. accessed by {@link HdmiControlService} only. */ List<HdmiCecDeviceInfo> getDeviceInfoList() { List<HdmiCecDeviceInfo> deviceInfoList = new ArrayList<HdmiCecDeviceInfo>( mDeviceInfos.size()); for (int i = 0; i < mDeviceInfos.size(); ++i) { deviceInfoList.add(mDeviceInfos.valueAt(i)); } return deviceInfoList; } /** * Return a {@link HdmiCecDeviceInfo} corresponding to the given {@code logicalAddress}. * * <p>Declared as package-private. accessed by {@link HdmiControlService} only. * * @param logicalAddress logical address to be retrieved * @return {@link HdmiCecDeviceInfo} matched with the given {@code logicalAddress}. * Returns null if no logical address matched */ HdmiCecDeviceInfo getDeviceInfo(int logicalAddress) { return mDeviceInfos.get(logicalAddress); } private void init(HdmiControlService service, long nativePtr) { mIoHandler = new IoHandler(service.getServiceLooper()); mControlHandler = new ControlHandler(service.getServiceLooper()); Loading Loading
api/current.txt +11 −0 Original line number Diff line number Diff line Loading @@ -12394,6 +12394,17 @@ package android.hardware.hdmi { method public void onMessageReceived(android.hardware.hdmi.HdmiCecMessage); } public final class HdmiCecDeviceInfo implements android.os.Parcelable { method public int describeContents(); method public int getDeviceType(); method public java.lang.String getDisplayName(); method public int getLogicalAddress(); method public int getPhysicalAddress(); method public int getVendorId(); method public void writeToParcel(android.os.Parcel, int); field public static final android.os.Parcelable.Creator CREATOR; } public final class HdmiCecManager { method public android.hardware.hdmi.HdmiCecClient getClient(int, android.hardware.hdmi.HdmiCecClient.Listener); }
core/java/android/hardware/hdmi/HdmiCecDeviceInfo.java 0 → 100644 +168 −0 Original line number Diff line number Diff line /* * Copyright (C) 2014 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package android.hardware.hdmi; import android.os.Parcel; import android.os.Parcelable; /** * A class to encapsulate device information for HDMI-CEC. This container * include basic information such as logical address, physical address and * device type, and additional information like vendor id and osd name. */ public final class HdmiCecDeviceInfo implements Parcelable { // Logical address, phsical address, device type, vendor id and display name // are immutable value. private final int mLogicalAddress; private final int mPhysicalAddress; private final int mDeviceType; private final int mVendorId; private final String mDisplayName; /** * A helper class to deserialize {@link HdmiCecDeviceInfo} for a parcel. */ public static final Parcelable.Creator<HdmiCecDeviceInfo> CREATOR = new Parcelable.Creator<HdmiCecDeviceInfo>() { @Override public HdmiCecDeviceInfo createFromParcel(Parcel source) { int logicalAddress = source.readInt(); int physicalAddress = source.readInt(); int deviceType = source.readInt(); int vendorId = source.readInt(); String displayName = source.readString(); return new HdmiCecDeviceInfo(logicalAddress, physicalAddress, deviceType, vendorId, displayName); } @Override public HdmiCecDeviceInfo[] newArray(int size) { return new HdmiCecDeviceInfo[size]; } }; /** * Constructor. * * @param logicalAddress logical address of HDMI-Cec device. * For more details, refer {@link HdmiCec} * @param physicalAddress physical address of HDMI-Cec device * @param deviceType type of device. For more details, refer {@link HdmiCec} * @param vendorId vendor id of device. It's used for vendor specific command * @param displayName name of device * @hide */ public HdmiCecDeviceInfo(int logicalAddress, int physicalAddress, int deviceType, int vendorId, String displayName) { mLogicalAddress = logicalAddress; mPhysicalAddress = physicalAddress; mDeviceType = deviceType; mDisplayName = displayName; mVendorId = vendorId; } /** * Return the logical address of the device. It can have 0-15 values. * For more details, refer constants between {@link HdmiCec#ADDR_TV} * and {@link HdmiCec#ADDR_UNREGISTERED}. */ public int getLogicalAddress() { return mLogicalAddress; } /** * Return the physical address of the device. */ public int getPhysicalAddress() { return mPhysicalAddress; } /** * Return type of the device. For more details, refer constants between * {@link HdmiCec#DEVICE_TV} and {@link HdmiCec#DEVICE_INACTIVE}. */ public int getDeviceType() { return mDeviceType; } /** * Return display (OSD) name of the device. */ public String getDisplayName() { return mDisplayName; } /** * Return vendor id of the device. Vendor id is used to distinguish devices * built by other manufactures. This is required for vendor-specific command * on CEC standard. */ public int getVendorId() { return mVendorId; } /** * Describe the kinds of special objects contained in this Parcelable's * marshalled representation. */ @Override public int describeContents() { return 0; } /** * Serialize this object into a {@link Parcel}. * * @param dest The Parcel in which the object should be written. * @param flags Additional flags about how the object should be written. * May be 0 or {@link Parcelable#PARCELABLE_WRITE_RETURN_VALUE}. */ @Override public void writeToParcel(Parcel dest, int flags) { dest.writeInt(mLogicalAddress); dest.writeInt(mPhysicalAddress); dest.writeInt(mDeviceType); dest.writeInt(mVendorId); dest.writeString(mDisplayName); } @Override public String toString() { StringBuffer s = new StringBuffer(); s.append("logical_address: ").append(mLogicalAddress).append(", "); s.append("physical_address: ").append(mPhysicalAddress).append(", "); s.append("device_type: ").append(mDeviceType).append(", "); s.append("vendor_id: ").append(mVendorId).append(", "); s.append("display_name: ").append(mDisplayName); return s.toString(); } @Override public boolean equals(Object obj) { if (!(obj instanceof HdmiCecDeviceInfo)) { return false; } HdmiCecDeviceInfo other = (HdmiCecDeviceInfo) obj; return mLogicalAddress == other.mLogicalAddress && mPhysicalAddress == other.mPhysicalAddress && mDeviceType == other.mDeviceType && mVendorId == other.mVendorId && mDisplayName.equals(other.mDisplayName); } }
services/core/java/com/android/server/hdmi/HdmiCecController.java +72 −0 Original line number Diff line number Diff line Loading @@ -17,13 +17,17 @@ package com.android.server.hdmi; import android.hardware.hdmi.HdmiCec; import android.hardware.hdmi.HdmiCecDeviceInfo; import android.hardware.hdmi.HdmiCecMessage; import android.os.Handler; import android.os.Looper; import android.os.Message; import android.util.Slog; import android.util.SparseArray; import java.util.ArrayList; import java.util.Arrays; import java.util.List; /** * Manages HDMI-CEC command and behaviors. It converts user's command into CEC command Loading Loading @@ -63,6 +67,11 @@ class HdmiCecController { // interacts with HAL. private long mNativePtr; // Map-like container of all cec devices. A logical address of device is // used as key of container. private final SparseArray<HdmiCecDeviceInfo> mDeviceInfos = new SparseArray<HdmiCecDeviceInfo>(); // Private constructor. Use HdmiCecController.create(). private HdmiCecController() { } Loading Loading @@ -136,6 +145,69 @@ class HdmiCecController { } } /** * Add a new {@link HdmiCecDeviceInfo}. It returns old device info which has the same * logical address as new device info's. * * <p>Declared as package-private. accessed by {@link HdmiControlService} only. * * @param deviceInfo a new {@link HdmiCecDeviceInfo} to be added. * @return {@code null} if it is new device. Otherwise, returns old {@HdmiCecDeviceInfo} * that has the same logical address as new one has. */ HdmiCecDeviceInfo addDeviceInfo(HdmiCecDeviceInfo deviceInfo) { HdmiCecDeviceInfo oldDeviceInfo = getDeviceInfo(deviceInfo.getLogicalAddress()); if (oldDeviceInfo != null) { removeDeviceInfo(deviceInfo.getLogicalAddress()); } mDeviceInfos.append(deviceInfo.getLogicalAddress(), deviceInfo); return oldDeviceInfo; } /** * Remove a device info corresponding to the given {@code logicalAddress}. * It returns removed {@link HdmiCecDeviceInfo} if exists. * * <p>Declared as package-private. accessed by {@link HdmiControlService} only. * * @param logicalAddress logical address of device to be removed * @return removed {@link HdmiCecDeviceInfo} it exists. Otherwise, returns {@code null} */ HdmiCecDeviceInfo removeDeviceInfo(int logicalAddress) { HdmiCecDeviceInfo deviceInfo = mDeviceInfos.get(logicalAddress); if (deviceInfo != null) { mDeviceInfos.remove(logicalAddress); } return deviceInfo; } /** * Return a list of all {@HdmiCecDeviceInfo}. * * <p>Declared as package-private. accessed by {@link HdmiControlService} only. */ List<HdmiCecDeviceInfo> getDeviceInfoList() { List<HdmiCecDeviceInfo> deviceInfoList = new ArrayList<HdmiCecDeviceInfo>( mDeviceInfos.size()); for (int i = 0; i < mDeviceInfos.size(); ++i) { deviceInfoList.add(mDeviceInfos.valueAt(i)); } return deviceInfoList; } /** * Return a {@link HdmiCecDeviceInfo} corresponding to the given {@code logicalAddress}. * * <p>Declared as package-private. accessed by {@link HdmiControlService} only. * * @param logicalAddress logical address to be retrieved * @return {@link HdmiCecDeviceInfo} matched with the given {@code logicalAddress}. * Returns null if no logical address matched */ HdmiCecDeviceInfo getDeviceInfo(int logicalAddress) { return mDeviceInfos.get(logicalAddress); } private void init(HdmiControlService service, long nativePtr) { mIoHandler = new IoHandler(service.getServiceLooper()); mControlHandler = new ControlHandler(service.getServiceLooper()); Loading