Store active source/active port in HdmiControlService when disabled

This lets the service keep track of the latest change made by TV app
or TIF regarding active source/port.

Bug: 16222083
Change-Id: I0f1a4520eb3e52ca5024567b0f1fbe4fd59e8cbf
This commit is contained in:
Jinsuk Kim
2014-07-11 17:04:32 +09:00
parent af2acf0447
commit 09ffc846af
2 changed files with 26 additions and 7 deletions

View File

@@ -162,6 +162,11 @@ final class HdmiCecLocalDeviceTv extends HdmiCecLocalDevice {
handleSelectInternalSource(callback);
return;
}
if (!mService.isControlEnabled()) {
setActiveSource(targetAddress);
invokeCallback(callback, HdmiControlManager.RESULT_INCORRECT_MODE);
return;
}
HdmiCecDeviceInfo targetDevice = getDeviceInfo(targetAddress);
if (targetDevice == null) {
invokeCallback(callback, HdmiControlManager.RESULT_TARGET_NOT_AVAILABLE);
@@ -240,18 +245,23 @@ final class HdmiCecLocalDeviceTv extends HdmiCecLocalDevice {
void doManualPortSwitching(int portId, IHdmiControlCallback callback) {
assertRunOnServiceThread();
// Seq #20
if (!mService.isControlEnabled() || portId == getActivePortId()) {
if (!mService.isValidPortId(portId)) {
invokeCallback(callback, HdmiControlManager.RESULT_INCORRECT_MODE);
return;
}
// TODO: Make sure this call does not stem from <Active Source> message reception.
if (!mService.isControlEnabled()) {
setActivePortId(portId);
invokeCallback(callback, HdmiControlManager.RESULT_INCORRECT_MODE);
return;
}
if (portId == getActivePortId()) {
invokeCallback(callback, HdmiControlManager.RESULT_SUCCESS);
return;
}
setActivePortId(portId);
// TODO: Return immediately if the operation is triggered by <Text/Image View On>
// and this is the first notification about the active input after power-on.
// TODO: Handle invalid port id / active input which should be treated as an
// internal tuner.
// and this is the first notification about the active input after power-on
// (switch to HDMI didn't happen so far but is expected to happen soon).
removeAction(RoutingControlAction.class);
int oldPath = mService.portIdToPath(mService.portIdToPath(getActivePortId()));

View File

@@ -398,6 +398,15 @@ public final class HdmiControlService extends SystemService {
return Constants.INVALID_PORT_ID;
}
boolean isValidPortId(int portId) {
for (HdmiPortInfo info : mPortInfo) {
if (portId == info.getId()) {
return true;
}
}
return false;
}
/**
* Returns {@link Looper} for IO operation.
*