Methods Summary |
---|
protected void | finishWithCallback(int returnCode)
if (mCallback != null) {
try {
mCallback.onComplete(returnCode);
} catch (RemoteException e) {
Slog.e(TAG, "Failed to invoke callback.", e);
}
}
finish();
|
private int | getSystemAudioModeRequestParam()
// <System Audio Mode Request> takes the physical address of the source device
// as a parameter. Get it from following candidates, in the order listed below:
// 1) physical address of the active source
// 2) active routing path
// 3) physical address of TV
if (tv().getActiveSource().isValid()) {
return tv().getActiveSource().physicalAddress;
}
int param = tv().getActivePath();
return param != Constants.INVALID_PHYSICAL_ADDRESS
? param : Constants.PATH_INTERNAL;
|
private void | handleSendSystemAudioModeRequestTimeout()
if (!mTargetAudioStatus // Don't retry for Off case.
|| mSendRetryCount++ >= MAX_SEND_RETRY_COUNT) {
HdmiLogger.debug("[T]:wait for <Set System Audio Mode>.");
setSystemAudioMode(false);
finishWithCallback(HdmiControlManager.RESULT_TIMEOUT);
return;
}
sendSystemAudioModeRequest();
|
final void | handleTimerEvent(int state)
if (mState != state) {
return;
}
switch (mState) {
case STATE_WAIT_FOR_SET_SYSTEM_AUDIO_MODE:
handleSendSystemAudioModeRequestTimeout();
return;
}
|
final boolean | processCommand(HdmiCecMessage cmd)
if (cmd.getSource() != mAvrLogicalAddress) {
return false;
}
switch (mState) {
case STATE_WAIT_FOR_SET_SYSTEM_AUDIO_MODE:
if (cmd.getOpcode() == Constants.MESSAGE_FEATURE_ABORT
&& (cmd.getParams()[0] & 0xFF)
== Constants.MESSAGE_SYSTEM_AUDIO_MODE_REQUEST) {
HdmiLogger.debug("Failed to start system audio mode request.");
setSystemAudioMode(false);
finishWithCallback(HdmiControlManager.RESULT_EXCEPTION);
return true;
}
if (cmd.getOpcode() != Constants.MESSAGE_SET_SYSTEM_AUDIO_MODE
|| !HdmiUtils.checkCommandSource(cmd, mAvrLogicalAddress, TAG)) {
return false;
}
boolean receivedStatus = HdmiUtils.parseCommandParamSystemAudioStatus(cmd);
if (receivedStatus == mTargetAudioStatus) {
setSystemAudioMode(receivedStatus);
startAudioStatusAction();
return true;
} else {
HdmiLogger.debug("Unexpected system audio mode request:" + receivedStatus);
// Unexpected response, consider the request is newly initiated by AVR.
// To return 'false' will initiate new SystemAudioActionFromAvr by the control
// service.
finishWithCallback(HdmiControlManager.RESULT_EXCEPTION);
return false;
}
default:
return false;
}
|
protected void | removeSystemAudioActionInProgress()
removeActionExcept(SystemAudioActionFromTv.class, this);
removeActionExcept(SystemAudioActionFromAvr.class, this);
|
protected void | sendSystemAudioModeRequest()
List<RoutingControlAction> routingActions = getActions(RoutingControlAction.class);
if (!routingActions.isEmpty()) {
mState = STATE_CHECK_ROUTING_IN_PRGRESS;
// Should have only one Routing Control Action
RoutingControlAction routingAction = routingActions.get(0);
routingAction.addOnFinishedCallback(this, new Runnable() {
@Override
public void run() {
sendSystemAudioModeRequestInternal();
}
});
return;
}
sendSystemAudioModeRequestInternal();
|
private void | sendSystemAudioModeRequestInternal()
HdmiCecMessage command = HdmiCecMessageBuilder.buildSystemAudioModeRequest(
getSourceAddress(),
mAvrLogicalAddress, getSystemAudioModeRequestParam(), mTargetAudioStatus);
sendCommand(command, new HdmiControlService.SendMessageCallback() {
@Override
public void onSendCompleted(int error) {
if (error != Constants.SEND_RESULT_SUCCESS) {
HdmiLogger.debug("Failed to send <System Audio Mode Request>:" + error);
setSystemAudioMode(false);
finishWithCallback(HdmiControlManager.RESULT_COMMUNICATION_FAILED);
}
}
});
mState = STATE_WAIT_FOR_SET_SYSTEM_AUDIO_MODE;
addTimer(mState, mTargetAudioStatus ? ON_TIMEOUT_MS : OFF_TIMEOUT_MS);
|
protected void | setSystemAudioMode(boolean mode)
tv().setSystemAudioMode(mode, true);
|
protected void | startAudioStatusAction()
addAndStartAction(new SystemAudioStatusAction(tv(), mAvrLogicalAddress, mCallback));
finish();
|