Handle <Set Osd Name> in TV.

When TV receives <Set Osd Name> it should update the name of
device and should notify them who are listening device changes.

Bug: 16115666
Change-Id: Ic3b60def8858ca5b7041202135d5dcaf47fa06e7
This commit is contained in:
Jungshik Jang
2014-07-07 15:02:47 +09:00
parent 42230728b8
commit 8f2ed357a2
2 changed files with 44 additions and 6 deletions

View File

@@ -160,6 +160,8 @@ abstract class HdmiCecLocalDevice {
return handleVendorCommand(message);
case Constants.MESSAGE_VENDOR_COMMAND_WITH_ID:
return handleVendorCommandWithId(message);
case Constants.MESSAGE_SET_OSD_NAME:
return handleSetOsdName(message);
default:
return false;
}
@@ -360,6 +362,11 @@ abstract class HdmiCecLocalDevice {
return true;
}
protected boolean handleSetOsdName(HdmiCecMessage message) {
// The default behavior of <Set Osd Name> is doing nothing.
return true;
}
@ServiceThreadOnly
final void handleAddressAllocated(int logicalAddress) {
assertRunOnServiceThread();

View File

@@ -31,6 +31,7 @@ import com.android.internal.annotations.GuardedBy;
import com.android.server.hdmi.DeviceDiscoveryAction.DeviceDiscoveryCallback;
import com.android.server.hdmi.HdmiAnnotations.ServiceThreadOnly;
import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
@@ -259,7 +260,7 @@ final class HdmiCecLocalDeviceTv extends HdmiCecLocalDevice {
int address = message.getSource();
int path = HdmiUtils.twoBytesToInt(message.getParams());
if (getDeviceInfo(address) == null) {
handleNewDeviceAtTheTailOfActivePath(address, path);
handleNewDeviceAtTheTailOfActivePath(path);
} else {
ActiveSourceHandler.create(this, null).process(address, path);
}
@@ -340,13 +341,13 @@ final class HdmiCecLocalDeviceTv extends HdmiCecLocalDevice {
int path = HdmiUtils.twoBytesToInt(message.getParams());
int address = message.getSource();
if (!isInDeviceList(path, address)) {
handleNewDeviceAtTheTailOfActivePath(address, path);
handleNewDeviceAtTheTailOfActivePath(path);
}
addAndStartAction(new NewDeviceAction(this, address, path));
return true;
}
private void handleNewDeviceAtTheTailOfActivePath(int address, int path) {
private void handleNewDeviceAtTheTailOfActivePath(int path) {
// Seq #22
if (isTailOfActivePath(path, getActivePath())) {
removeAction(RoutingControlAction.class);
@@ -440,6 +441,35 @@ final class HdmiCecLocalDeviceTv extends HdmiCecLocalDevice {
return handleTextViewOn(message);
}
@Override
@ServiceThreadOnly
protected boolean handleSetOsdName(HdmiCecMessage message) {
int source = message.getSource();
HdmiCecDeviceInfo deviceInfo = getDeviceInfo(source);
// If the device is not in device list, ignore it.
if (deviceInfo == null) {
Slog.e(TAG, "No source device info for <Set Osd Name>." + message);
return true;
}
String osdName = null;
try {
osdName = new String(message.getParams(), "US-ASCII");
} catch (UnsupportedEncodingException e) {
Slog.e(TAG, "Invalid <Set Osd Name> request:" + message, e);
return true;
}
if (deviceInfo.getDisplayName().equals(osdName)) {
Slog.i(TAG, "Ignore incoming <Set Osd Name> having same osd name:" + message);
return true;
}
addCecDevice(new HdmiCecDeviceInfo(deviceInfo.getLogicalAddress(),
deviceInfo.getPhysicalAddress(), deviceInfo.getDeviceType(),
deviceInfo.getVendorId(), osdName));
return true;
}
@ServiceThreadOnly
private void launchDeviceDiscovery() {
assertRunOnServiceThread();
@@ -729,7 +759,7 @@ final class HdmiCecLocalDeviceTv extends HdmiCecLocalDevice {
* that has the same logical address as new one has.
*/
@ServiceThreadOnly
HdmiCecDeviceInfo addDeviceInfo(HdmiCecDeviceInfo deviceInfo) {
private HdmiCecDeviceInfo addDeviceInfo(HdmiCecDeviceInfo deviceInfo) {
assertRunOnServiceThread();
HdmiCecDeviceInfo oldDeviceInfo = getDeviceInfo(deviceInfo.getLogicalAddress());
if (oldDeviceInfo != null) {
@@ -750,7 +780,7 @@ final class HdmiCecLocalDeviceTv extends HdmiCecLocalDevice {
* @return removed {@link HdmiCecDeviceInfo} it exists. Otherwise, returns {@code null}
*/
@ServiceThreadOnly
HdmiCecDeviceInfo removeDeviceInfo(int logicalAddress) {
private HdmiCecDeviceInfo removeDeviceInfo(int logicalAddress) {
assertRunOnServiceThread();
HdmiCecDeviceInfo deviceInfo = mDeviceInfos.get(logicalAddress);
if (deviceInfo != null) {
@@ -878,7 +908,8 @@ final class HdmiCecLocalDeviceTv extends HdmiCecLocalDevice {
}
/**
* Called when a device is newly added or a new device is detected.
* Called when a device is newly added or a new device is detected or
* existing device is updated.
*
* @param info device info of a new device.
*/