FileDocCategorySizeDatePackage
DevicePowerStatusAction.javaAPI DocAndroid 5.1 API3610Thu Mar 12 22:22:42 GMT 2015com.android.server.hdmi

DevicePowerStatusAction

public final class DevicePowerStatusAction extends HdmiCecFeatureAction
Feature action that queries the power status of other device. This action is initiated via {@link HdmiPlaybackClient#queryDisplayStatus(DisplayStatusCallback)} from the Android system working as playback device to get the power status of TV device.

Package-private, accessed by {@link HdmiControlService} only.

Fields Summary
private static final String
TAG
private static final int
STATE_WAITING_FOR_REPORT_POWER_STATUS
private final int
mTargetAddress
private final android.hardware.hdmi.IHdmiControlCallback
mCallback
Constructors Summary
private DevicePowerStatusAction(HdmiCecLocalDevice localDevice, int targetAddress, android.hardware.hdmi.IHdmiControlCallback callback)

        super(localDevice);
        mTargetAddress = targetAddress;
        mCallback = callback;
    
Methods Summary
static com.android.server.hdmi.DevicePowerStatusActioncreate(HdmiCecLocalDevice source, int targetAddress, android.hardware.hdmi.IHdmiControlCallback callback)


       
                
        if (source == null || callback == null) {
            Slog.e(TAG, "Wrong arguments");
            return null;
        }
        return new DevicePowerStatusAction(source, targetAddress, callback);
    
voidhandleTimerEvent(int state)

        if (mState != state) {
            return;
        }
        if (state == STATE_WAITING_FOR_REPORT_POWER_STATUS) {
            // Got no response from TV. Report status 'unknown'.
            invokeCallback(HdmiControlManager.POWER_STATUS_UNKNOWN);
            finish();
        }
    
private voidinvokeCallback(int result)

        try {
            mCallback.onComplete(result);
        } catch (RemoteException e) {
            Slog.e(TAG, "Callback failed:" + e);
        }
    
booleanprocessCommand(HdmiCecMessage cmd)

        if (mState != STATE_WAITING_FOR_REPORT_POWER_STATUS
               || mTargetAddress != cmd.getSource()) {
            return false;
        }
        if (cmd.getOpcode() == Constants.MESSAGE_REPORT_POWER_STATUS) {
            int status = cmd.getParams()[0];
            invokeCallback(status);
            finish();
            return true;
        }
        return false;
    
private voidqueryDevicePowerStatus()

        sendCommand(HdmiCecMessageBuilder.buildGiveDevicePowerStatus(getSourceAddress(),
                mTargetAddress));
    
booleanstart()

        queryDevicePowerStatus();
        mState = STATE_WAITING_FOR_REPORT_POWER_STATUS;
        addTimer(mState, HdmiConfig.TIMEOUT_MS);
        return true;