Methods Summary |
---|
private boolean | handleReportPowerStatus(HdmiCecMessage cmd)
int sourceAddress = cmd.getSource();
int oldStatus = mPowerStatus.get(sourceAddress, INVALID_POWER_STATUS);
if (oldStatus == INVALID_POWER_STATUS) {
// if no device exists for incoming message, hands it over to other actions.
return false;
}
int newStatus = cmd.getParams()[0] & 0xFF;
updatePowerStatus(sourceAddress, newStatus, true);
return true;
|
private void | handleTimeout()
for (int i = 0; i < mPowerStatus.size(); ++i) {
int logicalAddress = mPowerStatus.keyAt(i);
updatePowerStatus(logicalAddress, POWER_STATUS_UNKNOWN, false);
}
mPowerStatus.clear();
mState = STATE_WAIT_FOR_NEXT_MONITORING;
|
void | handleTimerEvent(int state)
switch (mState) {
case STATE_WAIT_FOR_NEXT_MONITORING:
queryPowerStatus();
break;
case STATE_WAIT_FOR_REPORT_POWER_STATUS:
handleTimeout();
break;
}
|
boolean | processCommand(HdmiCecMessage cmd)
if (mState == STATE_WAIT_FOR_REPORT_POWER_STATUS
&& cmd.getOpcode() == Constants.MESSAGE_REPORT_POWER_STATUS) {
return handleReportPowerStatus(cmd);
}
return false;
|
private void | queryPowerStatus()
List<HdmiDeviceInfo> deviceInfos = tv().getDeviceInfoList(false);
resetPowerStatus(deviceInfos);
for (HdmiDeviceInfo info : deviceInfos) {
final int logicalAddress = info.getLogicalAddress();
sendCommand(HdmiCecMessageBuilder.buildGiveDevicePowerStatus(getSourceAddress(),
logicalAddress),
new SendMessageCallback() {
@Override
public void onSendCompleted(int error) {
// If fails to send <Give Device Power Status>,
// update power status into UNKNOWN.
if (error != Constants.SEND_RESULT_SUCCESS) {
updatePowerStatus(logicalAddress, POWER_STATUS_UNKNOWN, true);
}
}
});
}
mState = STATE_WAIT_FOR_REPORT_POWER_STATUS;
// Add both timers, monitoring and timeout.
addTimer(STATE_WAIT_FOR_NEXT_MONITORING, MONITIROING_INTERNAL_MS);
addTimer(STATE_WAIT_FOR_REPORT_POWER_STATUS, REPORT_POWER_STATUS_TIMEOUT_MS);
|
private void | resetPowerStatus(java.util.List deviceInfos)
mPowerStatus.clear();
for (HdmiDeviceInfo info : deviceInfos) {
mPowerStatus.append(info.getLogicalAddress(), info.getDevicePowerStatus());
}
|
boolean | start()
queryPowerStatus();
return true;
|
private void | updatePowerStatus(int logicalAddress, int newStatus, boolean remove)
tv().updateDevicePowerStatus(logicalAddress, newStatus);
if (remove) {
mPowerStatus.delete(logicalAddress);
}
|