SetArcTransmissionStateActionpublic final class SetArcTransmissionStateAction extends HdmiCecFeatureAction Feature action that handles enabling/disabling of ARC transmission channel.
Once TV gets <Initiate ARC>, TV sends <Report ARC Initiated> to AV Receiver.
If it fails or it gets <Terminate ARC>, TV just disables ARC. |
Fields Summary |
---|
private static final String | TAG | private static final int | STATE_WAITING_TIMEOUT | private final boolean | mEnabled | private final int | mAvrAddress |
Constructors Summary |
---|
SetArcTransmissionStateAction(HdmiCecLocalDevice source, int avrAddress, boolean enabled)
super(source);
HdmiUtils.verifyAddressType(getSourceAddress(), HdmiDeviceInfo.DEVICE_TV);
HdmiUtils.verifyAddressType(avrAddress, HdmiDeviceInfo.DEVICE_AUDIO_SYSTEM);
mAvrAddress = avrAddress;
mEnabled = enabled;
|
Methods Summary |
---|
void | handleTimerEvent(int state)
if (mState != state || mState != STATE_WAITING_TIMEOUT) {
return;
}
// Expire timeout for <Feature Abort>.
finish();
| boolean | processCommand(HdmiCecMessage cmd)
if (mState != STATE_WAITING_TIMEOUT) {
return false;
}
int opcode = cmd.getOpcode();
if (opcode == Constants.MESSAGE_FEATURE_ABORT) {
int originalOpcode = cmd.getParams()[0] & 0xFF;
if (originalOpcode == Constants.MESSAGE_REPORT_ARC_INITIATED) {
HdmiLogger.debug("Feature aborted for <Report Arc Initiated>");
setArcStatus(false);
finish();
return true;
}
}
return false;
| private void | sendReportArcInitiated()
HdmiCecMessage command =
HdmiCecMessageBuilder.buildReportArcInitiated(getSourceAddress(), mAvrAddress);
sendCommand(command, new HdmiControlService.SendMessageCallback() {
@Override
public void onSendCompleted(int error) {
if (error != Constants.SEND_RESULT_SUCCESS) {
// If fails to send <Report ARC Initiated>, disable ARC and
// send <Report ARC Terminated> directly.
setArcStatus(false);
HdmiLogger.debug("Failed to send <Report Arc Initiated>.");
finish();
}
}
});
| private void | setArcStatus(boolean enabled)
boolean wasEnabled = tv().setArcStatus(enabled);
Slog.i(TAG, "Change arc status [old:" + wasEnabled + ", new:" + enabled + "]");
// If enabled before and set to "disabled" and send <Report Arc Terminated> to
// av reciever.
if (!enabled && wasEnabled) {
sendCommand(HdmiCecMessageBuilder.buildReportArcTerminated(getSourceAddress(),
mAvrAddress));
}
| boolean | start()
if (mEnabled) {
// Enable ARC status immediately after sending <Report Arc Initiated>.
// If AVR responds with <Feature Abort>, disable ARC status again.
// This is different from spec that says that turns ARC status to
// "Enabled" if <Report ARC Initiated> is acknowledged and no
// <Feature Abort> is received.
// But implemented this way to save the time having to wait for
// <Feature Abort>.
setArcStatus(true);
// If succeeds to send <Report ARC Initiated>, wait general timeout
// to check whether there is no <Feature Abort> for <Report ARC Initiated>.
mState = STATE_WAITING_TIMEOUT;
addTimer(mState, HdmiConfig.TIMEOUT_MS);
sendReportArcInitiated();
} else {
setArcStatus(false);
finish();
}
return true;
|
|