Methods Summary |
---|
int | getTargetAddress()
return mTarget.getLogicalAddress();
|
private boolean | handleReportPowerStatus(int powerStatus)
switch (powerStatus) {
case HdmiControlManager.POWER_STATUS_ON:
sendSetStreamPath();
return true;
case HdmiControlManager.POWER_STATUS_TRANSIENT_TO_STANDBY:
if (mPowerStatusCounter < 4) {
mState = STATE_WAIT_FOR_DEVICE_TO_TRANSIT_TO_STANDBY;
addTimer(mState, TIMEOUT_TRANSIT_TO_STANDBY_MS);
} else {
sendSetStreamPath();
}
return true;
case HdmiControlManager.POWER_STATUS_STANDBY:
if (mPowerStatusCounter == 0) {
turnOnDevice();
} else {
sendSetStreamPath();
}
return true;
case HdmiControlManager.POWER_STATUS_TRANSIENT_TO_ON:
if (mPowerStatusCounter < LOOP_COUNTER_MAX) {
mState = STATE_WAIT_FOR_DEVICE_POWER_ON;
addTimer(mState, TIMEOUT_POWER_ON_MS);
} else {
sendSetStreamPath();
}
return true;
}
return false;
|
public void | handleTimerEvent(int timeoutState)
if (mState != timeoutState) {
Slog.w(TAG, "Timer in a wrong state. Ignored.");
return;
}
switch (mState) {
case STATE_WAIT_FOR_REPORT_POWER_STATUS:
if (tv().isPowerStandbyOrTransient()) {
invokeCallback(HdmiControlManager.RESULT_INCORRECT_MODE);
finish();
return;
}
sendSetStreamPath();
break;
case STATE_WAIT_FOR_DEVICE_TO_TRANSIT_TO_STANDBY:
case STATE_WAIT_FOR_DEVICE_POWER_ON:
mPowerStatusCounter++;
queryDevicePowerStatus();
break;
}
|
private void | invokeCallback(int result)
if (mCallback == null) {
return;
}
try {
mCallback.onComplete(result);
} catch (RemoteException e) {
Slog.e(TAG, "Callback failed:" + e);
}
|
public boolean | processCommand(HdmiCecMessage cmd)
if (cmd.getSource() != getTargetAddress()) {
return false;
}
int opcode = cmd.getOpcode();
byte[] params = cmd.getParams();
switch (mState) {
case STATE_WAIT_FOR_REPORT_POWER_STATUS:
if (opcode == Constants.MESSAGE_REPORT_POWER_STATUS) {
return handleReportPowerStatus(params[0]);
}
return false;
default:
break;
}
return false;
|
private void | queryDevicePowerStatus()
sendCommand(mGivePowerStatus, new SendMessageCallback() {
@Override
public void onSendCompleted(int error) {
if (error != Constants.SEND_RESULT_SUCCESS) {
invokeCallback(HdmiControlManager.RESULT_COMMUNICATION_FAILED);
finish();
return;
}
}
});
mState = STATE_WAIT_FOR_REPORT_POWER_STATUS;
addTimer(mState, HdmiConfig.TIMEOUT_MS);
|
private void | sendSetStreamPath()
// Turn the active source invalidated, which remains so till <Active Source> comes from
// the selected device.
tv().getActiveSource().invalidate();
tv().setActivePath(mTarget.getPhysicalAddress());
sendCommand(HdmiCecMessageBuilder.buildSetStreamPath(
getSourceAddress(), mTarget.getPhysicalAddress()));
invokeCallback(HdmiControlManager.RESULT_SUCCESS);
finish();
|
public boolean | start()
// Seq #9
queryDevicePowerStatus();
return true;
|
private void | turnOnDevice()
sendUserControlPressedAndReleased(mTarget.getLogicalAddress(),
HdmiCecKeycode.CEC_KEYCODE_POWER);
sendUserControlPressedAndReleased(mTarget.getLogicalAddress(),
HdmiCecKeycode.CEC_KEYCODE_POWER_ON_FUNCTION);
mState = STATE_WAIT_FOR_DEVICE_POWER_ON;
addTimer(mState, TIMEOUT_POWER_ON_MS);
|