Merge "CEC: Add logic to return to internal source" into lmp-mr1-dev
This commit is contained in:
@@ -77,10 +77,19 @@ public class HdmiDeviceInfo implements Parcelable {
|
|||||||
/** Invalid port ID */
|
/** Invalid port ID */
|
||||||
public static final int PORT_INVALID = -1;
|
public static final int PORT_INVALID = -1;
|
||||||
|
|
||||||
|
/** Invalid device ID */
|
||||||
|
public static final int ID_INVALID = 0xFFFF;
|
||||||
|
|
||||||
|
/** Device info used to indicate an inactivated device. */
|
||||||
|
public static final HdmiDeviceInfo INACTIVE_DEVICE = new HdmiDeviceInfo();
|
||||||
|
|
||||||
private static final int HDMI_DEVICE_TYPE_CEC = 0;
|
private static final int HDMI_DEVICE_TYPE_CEC = 0;
|
||||||
private static final int HDMI_DEVICE_TYPE_MHL = 1;
|
private static final int HDMI_DEVICE_TYPE_MHL = 1;
|
||||||
private static final int HDMI_DEVICE_TYPE_HARDWARE = 2;
|
private static final int HDMI_DEVICE_TYPE_HARDWARE = 2;
|
||||||
|
|
||||||
|
// Type used to indicate the device that has relinquished its active source status.
|
||||||
|
private static final int HDMI_DEVICE_TYPE_INACTIVE = 100;
|
||||||
|
|
||||||
// Offset used for id value. MHL devices, for instance, will be assigned the value from
|
// Offset used for id value. MHL devices, for instance, will be assigned the value from
|
||||||
// ID_OFFSET_MHL.
|
// ID_OFFSET_MHL.
|
||||||
private static final int ID_OFFSET_CEC = 0x0;
|
private static final int ID_OFFSET_CEC = 0x0;
|
||||||
@@ -130,6 +139,8 @@ public class HdmiDeviceInfo implements Parcelable {
|
|||||||
return new HdmiDeviceInfo(physicalAddress, portId, adopterId, deviceId);
|
return new HdmiDeviceInfo(physicalAddress, portId, adopterId, deviceId);
|
||||||
case HDMI_DEVICE_TYPE_HARDWARE:
|
case HDMI_DEVICE_TYPE_HARDWARE:
|
||||||
return new HdmiDeviceInfo(physicalAddress, portId);
|
return new HdmiDeviceInfo(physicalAddress, portId);
|
||||||
|
case HDMI_DEVICE_TYPE_INACTIVE:
|
||||||
|
return HdmiDeviceInfo.INACTIVE_DEVICE;
|
||||||
default:
|
default:
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -208,7 +219,6 @@ public class HdmiDeviceInfo implements Parcelable {
|
|||||||
|
|
||||||
mDeviceId = -1;
|
mDeviceId = -1;
|
||||||
mAdopterId = -1;
|
mAdopterId = -1;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -236,6 +246,28 @@ public class HdmiDeviceInfo implements Parcelable {
|
|||||||
mAdopterId = deviceId;
|
mAdopterId = deviceId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor. Used to initialize the instance representing an inactivated device.
|
||||||
|
* Can be passed input change listener to indicate the active source yielded
|
||||||
|
* its status, hence the listener should take an appropriate action such as
|
||||||
|
* switching to other input.
|
||||||
|
*/
|
||||||
|
public HdmiDeviceInfo() {
|
||||||
|
mHdmiDeviceType = HDMI_DEVICE_TYPE_INACTIVE;
|
||||||
|
mPhysicalAddress = PATH_INVALID;
|
||||||
|
mId = ID_INVALID;
|
||||||
|
|
||||||
|
mLogicalAddress = -1;
|
||||||
|
mDeviceType = DEVICE_INACTIVE;
|
||||||
|
mPortId = PORT_INVALID;
|
||||||
|
mDevicePowerStatus = HdmiControlManager.POWER_STATUS_UNKNOWN;
|
||||||
|
mDisplayName = "Inactive";
|
||||||
|
mVendorId = 0;
|
||||||
|
|
||||||
|
mDeviceId = -1;
|
||||||
|
mAdopterId = -1;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the id of the device.
|
* Returns the id of the device.
|
||||||
*/
|
*/
|
||||||
@@ -363,6 +395,14 @@ public class HdmiDeviceInfo implements Parcelable {
|
|||||||
return mHdmiDeviceType == HDMI_DEVICE_TYPE_MHL;
|
return mHdmiDeviceType == HDMI_DEVICE_TYPE_MHL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return {@code true} if the device represents an inactivated device that relinquishes
|
||||||
|
* its status as active source by <Active Source> (HDMI-CEC) or Content-off (MHL).
|
||||||
|
*/
|
||||||
|
public boolean isInactivated() {
|
||||||
|
return mHdmiDeviceType == HDMI_DEVICE_TYPE_INACTIVE;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns display (OSD) name of the device.
|
* Returns display (OSD) name of the device.
|
||||||
*/
|
*/
|
||||||
@@ -411,6 +451,8 @@ public class HdmiDeviceInfo implements Parcelable {
|
|||||||
dest.writeInt(mDeviceId);
|
dest.writeInt(mDeviceId);
|
||||||
dest.writeInt(mAdopterId);
|
dest.writeInt(mAdopterId);
|
||||||
break;
|
break;
|
||||||
|
case HDMI_DEVICE_TYPE_INACTIVE:
|
||||||
|
// flow through
|
||||||
default:
|
default:
|
||||||
// no-op
|
// no-op
|
||||||
}
|
}
|
||||||
@@ -438,6 +480,9 @@ public class HdmiDeviceInfo implements Parcelable {
|
|||||||
case HDMI_DEVICE_TYPE_HARDWARE:
|
case HDMI_DEVICE_TYPE_HARDWARE:
|
||||||
s.append("Hardware: ");
|
s.append("Hardware: ");
|
||||||
break;
|
break;
|
||||||
|
case HDMI_DEVICE_TYPE_INACTIVE:
|
||||||
|
s.append("Inactivated: ");
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -476,7 +476,7 @@ final class HdmiCecLocalDeviceTv extends HdmiCecLocalDevice {
|
|||||||
HdmiDeviceInfo info = getCecDeviceInfo(logicalAddress);
|
HdmiDeviceInfo info = getCecDeviceInfo(logicalAddress);
|
||||||
if (info == null) {
|
if (info == null) {
|
||||||
if (!handleNewDeviceAtTheTailOfActivePath(physicalAddress)) {
|
if (!handleNewDeviceAtTheTailOfActivePath(physicalAddress)) {
|
||||||
HdmiLogger.debug("Device info not found: %X; buffering the command", logicalAddress);
|
HdmiLogger.debug("Device info %X not found; buffering the command", logicalAddress);
|
||||||
mDelayedMessageBuffer.add(message);
|
mDelayedMessageBuffer.add(message);
|
||||||
}
|
}
|
||||||
} else if (!isInputReady(info.getId())) {
|
} else if (!isInputReady(info.getId())) {
|
||||||
@@ -517,6 +517,12 @@ final class HdmiCecLocalDeviceTv extends HdmiCecLocalDevice {
|
|||||||
|
|
||||||
doManualPortSwitching(portId, null);
|
doManualPortSwitching(portId, null);
|
||||||
setPrevPortId(Constants.INVALID_PORT_ID);
|
setPrevPortId(Constants.INVALID_PORT_ID);
|
||||||
|
} else {
|
||||||
|
// No HDMI port to switch to was found. Notify the input change listers to
|
||||||
|
// switch to the lastly shown internal input.
|
||||||
|
mActiveSource.invalidate();
|
||||||
|
setActivePath(Constants.INVALID_PHYSICAL_ADDRESS);
|
||||||
|
mService.invokeInputChangeListener(HdmiDeviceInfo.INACTIVE_DEVICE);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -1826,6 +1832,7 @@ final class HdmiCecLocalDeviceTv extends HdmiCecLocalDevice {
|
|||||||
pw.println("mAutoDeviceOff: " + mAutoDeviceOff);
|
pw.println("mAutoDeviceOff: " + mAutoDeviceOff);
|
||||||
pw.println("mAutoWakeup: " + mAutoWakeup);
|
pw.println("mAutoWakeup: " + mAutoWakeup);
|
||||||
pw.println("mSkipRoutingControl: " + mSkipRoutingControl);
|
pw.println("mSkipRoutingControl: " + mSkipRoutingControl);
|
||||||
|
pw.println("mPrevPortId: " + mPrevPortId);
|
||||||
pw.println("CEC devices:");
|
pw.println("CEC devices:");
|
||||||
pw.increaseIndent();
|
pw.increaseIndent();
|
||||||
for (HdmiDeviceInfo info : mSafeAllDeviceInfos) {
|
for (HdmiDeviceInfo info : mSafeAllDeviceInfos) {
|
||||||
|
|||||||
@@ -2252,16 +2252,17 @@ public final class HdmiControlService extends SystemService {
|
|||||||
assertRunOnServiceThread();
|
assertRunOnServiceThread();
|
||||||
if (tv() == null) return;
|
if (tv() == null) return;
|
||||||
final int lastInput = contentOn ? tv().getActivePortId() : Constants.INVALID_PORT_ID;
|
final int lastInput = contentOn ? tv().getActivePortId() : Constants.INVALID_PORT_ID;
|
||||||
tv().doManualPortSwitching(portId, new IHdmiControlCallback.Stub() {
|
if (portId != Constants.INVALID_PORT_ID) {
|
||||||
@Override
|
tv().doManualPortSwitching(portId, new IHdmiControlCallback.Stub() {
|
||||||
public void onComplete(int result) throws RemoteException {
|
@Override
|
||||||
// Keep the last input to switch back later when RAP[ContentOff] is received.
|
public void onComplete(int result) throws RemoteException {
|
||||||
// This effectively sets the port to invalid one if the switching is for
|
// Keep the last input to switch back later when RAP[ContentOff] is received.
|
||||||
// RAP[ContentOff].
|
// This effectively sets the port to invalid one if the switching is for
|
||||||
setLastInputForMhl(lastInput);
|
// RAP[ContentOff].
|
||||||
}
|
setLastInputForMhl(lastInput);
|
||||||
});
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
// MHL device is always directly connected to the port. Update the active port ID to avoid
|
// MHL device is always directly connected to the port. Update the active port ID to avoid
|
||||||
// unnecessary post-routing control task.
|
// unnecessary post-routing control task.
|
||||||
tv().setActivePortId(portId);
|
tv().setActivePortId(portId);
|
||||||
@@ -2271,7 +2272,8 @@ public final class HdmiControlService extends SystemService {
|
|||||||
// may not be the MHL-enabled one. In this case the device info to be passed to
|
// may not be the MHL-enabled one. In this case the device info to be passed to
|
||||||
// input change listener should be the one describing the corresponding HDMI port.
|
// input change listener should be the one describing the corresponding HDMI port.
|
||||||
HdmiMhlLocalDeviceStub device = mMhlController.getLocalDevice(portId);
|
HdmiMhlLocalDeviceStub device = mMhlController.getLocalDevice(portId);
|
||||||
HdmiDeviceInfo info = (device != null) ? device.getInfo() : mPortDeviceMap.get(portId);
|
HdmiDeviceInfo info = (device != null) ? device.getInfo()
|
||||||
|
: mPortDeviceMap.get(portId, HdmiDeviceInfo.INACTIVE_DEVICE);
|
||||||
invokeInputChangeListener(info);
|
invokeInputChangeListener(info);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user