FileDocCategorySizeDatePackage
HdmiClient.javaAPI DocAndroid 5.1 API3895Thu Mar 12 22:22:10 GMT 2015android.hardware.hdmi

HdmiClient

public abstract class HdmiClient extends Object
Parent for classes of various HDMI-CEC device type used to access the HDMI control system service. Contains methods and data used in common.
hide

Fields Summary
private static final String
TAG
final IHdmiControlService
mService
private IHdmiVendorCommandListener
mIHdmiVendorCommandListener
Constructors Summary
HdmiClient(IHdmiControlService service)


    /* package */   

    /* package */   
        mService = service;
    
Methods Summary
public HdmiDeviceInfogetActiveSource()
Returns the active source information.

return
{@link HdmiDeviceInfo} object that describes the active source or active routing path

        try {
            return mService.getActiveSource();
        } catch (RemoteException e) {
            Log.e(TAG, "getActiveSource threw exception ", e);
        }
        return null;
    
abstract intgetDeviceType()

private static IHdmiVendorCommandListenergetListenerWrapper(android.hardware.hdmi.HdmiControlManager.VendorCommandListener listener)

        return new IHdmiVendorCommandListener.Stub() {
            @Override
            public void onReceived(int srcAddress, int destAddress, byte[] params,
                    boolean hasVendorId) {
                listener.onReceived(srcAddress, destAddress, params, hasVendorId);
            }
            @Override
            public void onControlStateChanged(boolean enabled, int reason) {
                listener.onControlStateChanged(enabled, reason);
            }
        };
    
public voidsendKeyEvent(int keyCode, boolean isPressed)
Sends a key event to other logical device.

param
keyCode key code to send. Defined in {@link android.view.KeyEvent}.
param
isPressed true if this is key press event

        try {
            mService.sendKeyEvent(getDeviceType(), keyCode, isPressed);
        } catch (RemoteException e) {
            Log.e(TAG, "sendKeyEvent threw exception ", e);
        }
    
public voidsendVendorCommand(int targetAddress, byte[] params, boolean hasVendorId)
Sends vendor-specific command.

param
targetAddress address of the target device
param
params vendor-specific parameter. For <Vendor Command With ID> do not include the first 3 bytes (vendor ID).
param
hasVendorId {@code true} if the command type will be <Vendor Command With ID>. {@code false} if the command will be <Vendor Command>

        try {
            mService.sendVendorCommand(getDeviceType(), targetAddress, params, hasVendorId);
        } catch (RemoteException e) {
            Log.e(TAG, "failed to send vendor command: ", e);
        }
    
public voidsetVendorCommandListener(android.hardware.hdmi.HdmiControlManager.VendorCommandListener listener)
Sets a listener used to receive incoming vendor-specific command.

param
listener listener object

        if (listener == null) {
            throw new IllegalArgumentException("listener cannot be null");
        }
        if (mIHdmiVendorCommandListener != null) {
            throw new IllegalStateException("listener was already set");
        }
        try {
            IHdmiVendorCommandListener wrappedListener = getListenerWrapper(listener);
            mService.addVendorCommandListener(wrappedListener, getDeviceType());
            mIHdmiVendorCommandListener = wrappedListener;
        } catch (RemoteException e) {
            Log.e(TAG, "failed to set vendor command listener: ", e);
        }