Methods Summary |
---|
static java.util.List | asImmutableList(int[] is)Convert integer array to list of {@link Integer}.
The result is immutable.
ArrayList<Integer> list = new ArrayList<>(is.length);
for (int type : is) {
list.add(type);
}
return Collections.unmodifiableList(list);
|
static boolean | checkCommandSource(HdmiCecMessage cmd, int expectedAddress, java.lang.String tag)Check if the given CEC message come from the given address.
int src = cmd.getSource();
if (src != expectedAddress) {
Slog.w(tag, "Invalid source [Expected:" + expectedAddress + ", Actual:" + src + "]");
return false;
}
return true;
|
static android.hardware.hdmi.HdmiDeviceInfo | cloneHdmiDeviceInfo(android.hardware.hdmi.HdmiDeviceInfo info, int newPowerStatus)Clone {@link HdmiDeviceInfo} with new power status.
return new HdmiDeviceInfo(info.getLogicalAddress(),
info.getPhysicalAddress(), info.getPortId(), info.getDeviceType(),
info.getVendorId(), info.getDisplayName(), newPowerStatus);
|
static java.lang.String | getDefaultDeviceName(int address)Return the default device name for a logical address. This is the name
by which the logical device is known to others until a name is
set explicitly using HdmiCecService.setOsdName.
if (isValidAddress(address)) {
return DEFAULT_NAMES[address];
}
return "";
|
static int | getTypeFromAddress(int address)Return the device type for the given logical address.
if (isValidAddress(address)) {
return ADDRESS_TO_TYPE[address];
}
return HdmiDeviceInfo.DEVICE_INACTIVE;
|
static boolean | isAffectingActiveRoutingPath(int activePath, int newPath)See if the new path is affecting the active path.
// The new path affects the current active path if the parent of the new path
// is an ancestor of the active path.
// (1.1.0.0, 2.0.0.0) -> true, new path alters the parent
// (1.1.0.0, 1.2.0.0) -> true, new path is a sibling
// (1.1.0.0, 1.2.1.0) -> false, new path is a descendant of a sibling
// (1.0.0.0, 3.2.0.0) -> false, in a completely different path
// Get the parent of the new path by clearing the least significant
// non-zero nibble.
for (int i = 0; i <= 12; i += 4) {
int nibble = (newPath >> i) & 0xF;
if (nibble != 0) {
int mask = 0xFFF0 << i;
newPath &= mask;
break;
}
}
if (newPath == 0x0000) {
return true; // Top path always affects the active path
}
return isInActiveRoutingPath(activePath, newPath);
|
static boolean | isInActiveRoutingPath(int activePath, int newPath)See if the new path is in the active path.
// Check each nibble of the currently active path and the new path till the position
// where the active nibble is not zero. For (activePath, newPath),
// (1.1.0.0, 1.0.0.0) -> true, new path is a parent
// (1.2.1.0, 1.2.1.2) -> true, new path is a descendant
// (1.1.0.0, 1.2.0.0) -> false, new path is a sibling
// (1.0.0.0, 2.0.0.0) -> false, in a completely different path
for (int i = 12; i >= 0; i -= 4) {
int nibbleActive = (activePath >> i) & 0xF;
if (nibbleActive == 0) {
break;
}
int nibbleNew = (newPath >> i) & 0xF;
if (nibbleNew == 0) {
break;
}
if (nibbleActive != nibbleNew) {
return false;
}
}
return true;
|
static boolean | isValidAddress(int address)Check if the given logical address is valid. A logical address is valid
if it is one allocated for an actual device which allows communication
with other logical devices.
return (Constants.ADDR_TV <= address && address <= Constants.ADDR_SPECIFIC_USE);
|
static int | languageToInt(java.lang.String language)Convert 3 byte-long language code in string to integer representation.
English(eng), for example, is converted to 0x656e67.
String normalized = language.toLowerCase();
return ((normalized.charAt(0) & 0xFF) << 16)
| ((normalized.charAt(1) & 0xFF) << 8)
| (normalized.charAt(2) & 0xFF);
|
static java.util.List | mergeToUnmodifiableList(java.util.List a, java.util.List b)
if (a.isEmpty() && b.isEmpty()) {
return Collections.emptyList();
}
if (a.isEmpty()) {
return Collections.unmodifiableList(b);
}
if (b.isEmpty()) {
return Collections.unmodifiableList(a);
}
List<T> newList = new ArrayList<>();
newList.addAll(a);
newList.addAll(b);
return Collections.unmodifiableList(newList);
|
static boolean | parseCommandParamSystemAudioStatus(HdmiCecMessage cmd)Parse the parameter block of CEC message as [System Audio Status].
return cmd.getParams()[0] == Constants.SYSTEM_AUDIO_STATUS_ON;
|
static java.util.List | sparseArrayToList(android.util.SparseArray array)
ArrayList<T> list = new ArrayList<>();
for (int i = 0; i < array.size(); ++i) {
list.add(array.valueAt(i));
}
return list;
|
static int | threeBytesToInt(byte[] data)Assemble three bytes into single integer value.
return ((data[0] & 0xFF) << 16) | ((data[1] & 0xFF) << 8) | (data[2] & 0xFF);
|
static int | twoBytesToInt(byte[] data, int offset)Assemble two bytes into single integer value.
return ((data[offset] & 0xFF) << 8) | (data[offset + 1] & 0xFF);
|
static int | twoBytesToInt(byte[] data)Assemble two bytes into single integer value.
return ((data[0] & 0xFF) << 8) | (data[1] & 0xFF);
|
static void | verifyAddressType(int logicalAddress, int deviceType)Verify if the given address is for the given device type. If not it will throw
{@link IllegalArgumentException}.
int actualDeviceType = getTypeFromAddress(logicalAddress);
if (actualDeviceType != deviceType) {
throw new IllegalArgumentException("Device type missmatch:[Expected:" + deviceType
+ ", Actual:" + actualDeviceType);
}
|