Methods Summary |
---|
private void | finishWithCallback(int result)
invokeCallback(result);
finish();
|
private int | getTvPowerStatus()
return tv().getPowerStatus();
|
private void | handlDevicePowerStatusAckResult(boolean acked)
if (acked) {
mState = STATE_WAIT_FOR_REPORT_POWER_STATUS;
addTimer(mState, TIMEOUT_REPORT_POWER_STATUS_MS);
} else {
tv().updateActiveInput(mCurrentRoutingPath, mNotifyInputChange);
sendSetStreamPath();
finishWithCallback(HdmiControlManager.RESULT_SUCCESS);
}
|
private void | handleReportPowerStatus(int devicePowerStatus)
if (isPowerOnOrTransient(getTvPowerStatus())) {
tv().updateActiveInput(mCurrentRoutingPath, mNotifyInputChange);
if (isPowerOnOrTransient(devicePowerStatus)) {
sendSetStreamPath();
}
}
finishWithCallback(HdmiControlManager.RESULT_SUCCESS);
|
public void | handleTimerEvent(int timeoutState)
if (mState != timeoutState || mState == STATE_NONE) {
Slog.w("CEC", "Timer in a wrong state. Ignored.");
return;
}
switch (timeoutState) {
case STATE_WAIT_FOR_ROUTING_INFORMATION:
HdmiDeviceInfo device = tv().getDeviceInfoByPath(mCurrentRoutingPath);
if (device != null && mQueryDevicePowerStatus) {
int deviceLogicalAddress = device.getLogicalAddress();
queryDevicePowerStatus(deviceLogicalAddress, new SendMessageCallback() {
@Override
public void onSendCompleted(int error) {
handlDevicePowerStatusAckResult(
error == HdmiControlManager.RESULT_SUCCESS);
}
});
} else {
tv().updateActiveInput(mCurrentRoutingPath, mNotifyInputChange);
finishWithCallback(HdmiControlManager.RESULT_SUCCESS);
}
return;
case STATE_WAIT_FOR_REPORT_POWER_STATUS:
if (isPowerOnOrTransient(getTvPowerStatus())) {
tv().updateActiveInput(mCurrentRoutingPath, mNotifyInputChange);
sendSetStreamPath();
}
finishWithCallback(HdmiControlManager.RESULT_SUCCESS);
return;
}
|
private void | invokeCallback(int result)
if (mCallback == null) {
return;
}
try {
mCallback.onComplete(result);
} catch (RemoteException e) {
// Do nothing.
}
|
private static boolean | isPowerOnOrTransient(int status)
return status == HdmiControlManager.POWER_STATUS_ON
|| status == HdmiControlManager.POWER_STATUS_TRANSIENT_TO_ON;
|
public boolean | processCommand(HdmiCecMessage cmd)
int opcode = cmd.getOpcode();
byte[] params = cmd.getParams();
if (mState == STATE_WAIT_FOR_ROUTING_INFORMATION
&& opcode == Constants.MESSAGE_ROUTING_INFORMATION) {
// Keep updating the physicalAddress as we receive <Routing Information>.
// If the routing path doesn't belong to the currently active one, we should
// ignore it since it might have come from other routing change sequence.
int routingPath = HdmiUtils.twoBytesToInt(params);
if (!HdmiUtils.isInActiveRoutingPath(mCurrentRoutingPath, routingPath)) {
return true;
}
mCurrentRoutingPath = routingPath;
// Stop possible previous routing change sequence if in progress.
removeActionExcept(RoutingControlAction.class, this);
addTimer(mState, TIMEOUT_ROUTING_INFORMATION_MS);
return true;
} else if (mState == STATE_WAIT_FOR_REPORT_POWER_STATUS
&& opcode == Constants.MESSAGE_REPORT_POWER_STATUS) {
handleReportPowerStatus(cmd.getParams()[0]);
return true;
}
return false;
|
private void | queryDevicePowerStatus(int address, com.android.server.hdmi.HdmiControlService.SendMessageCallback callback)
sendCommand(HdmiCecMessageBuilder.buildGiveDevicePowerStatus(getSourceAddress(), address),
callback);
|
private void | sendSetStreamPath()
sendCommand(HdmiCecMessageBuilder.buildSetStreamPath(getSourceAddress(),
mCurrentRoutingPath));
|
public boolean | start()
mState = STATE_WAIT_FOR_ROUTING_INFORMATION;
addTimer(mState, TIMEOUT_ROUTING_INFORMATION_MS);
return true;
|