FileDocCategorySizeDatePackage
InputChannel.javaAPI DocAndroid 5.1 API5329Thu Mar 12 22:22:10 GMT 2015android.view

InputChannel

public final class InputChannel extends Object implements android.os.Parcelable
An input channel specifies the file descriptors used to send input events to a window in another process. It is Parcelable so that it can be sent to the process that is to receive events. Only one thread should be reading from an InputChannel at a time.
hide

Fields Summary
private static final String
TAG
private static final boolean
DEBUG
public static final Parcelable.Creator
CREATOR
private long
mPtr
Constructors Summary
public InputChannel()
Creates an uninitialized input channel. It can be initialized by reading from a Parcel or by transferring the state of another input channel into this one.

    
Methods Summary
public intdescribeContents()

        return Parcelable.CONTENTS_FILE_DESCRIPTOR;
    
public voiddispose()
Disposes the input channel. Explicitly releases the reference this object is holding on the input channel. When all references are released, the input channel will be closed.

        nativeDispose(false);
    
public android.view.InputChanneldup()
Duplicates the input channel.

        InputChannel target = new InputChannel();
        nativeDup(target);
        return target;
    
protected voidfinalize()

        try {
            nativeDispose(true);
        } finally {
            super.finalize();
        }
    
public java.lang.StringgetName()
Gets the name of the input channel.

return
The input channel name.

        String name = nativeGetName();
        return name != null ? name : "uninitialized";
    
private native voidnativeDispose(boolean finalized)

private native voidnativeDup(android.view.InputChannel target)

private native java.lang.StringnativeGetName()

private static native android.view.InputChannel[]nativeOpenInputChannelPair(java.lang.String name)

private native voidnativeReadFromParcel(android.os.Parcel parcel)

private native voidnativeTransferTo(android.view.InputChannel other)

private native voidnativeWriteToParcel(android.os.Parcel parcel)

public static android.view.InputChannel[]openInputChannelPair(java.lang.String name)
Creates a new input channel pair. One channel should be provided to the input dispatcher and the other to the application's input queue.

param
name The descriptive (non-unique) name of the channel pair.
return
A pair of input channels. The first channel is designated as the server channel and should be used to publish input events. The second channel is designated as the client channel and should be used to consume input events.

        if (name == null) {
            throw new IllegalArgumentException("name must not be null");
        }

        if (DEBUG) {
            Slog.d(TAG, "Opening input channel pair '" + name + "'");
        }
        return nativeOpenInputChannelPair(name);
    
public voidreadFromParcel(android.os.Parcel in)

        if (in == null) {
            throw new IllegalArgumentException("in must not be null");
        }
        
        nativeReadFromParcel(in);
    
public java.lang.StringtoString()

        return getName();
    
public voidtransferTo(android.view.InputChannel outParameter)
Transfers ownership of the internal state of the input channel to another instance and invalidates this instance. This is used to pass an input channel as an out parameter in a binder call.

param
other The other input channel instance.

        if (outParameter == null) {
            throw new IllegalArgumentException("outParameter must not be null");
        }
        
        nativeTransferTo(outParameter);
    
public voidwriteToParcel(android.os.Parcel out, int flags)

        if (out == null) {
            throw new IllegalArgumentException("out must not be null");
        }
        
        nativeWriteToParcel(out);
        
        if ((flags & PARCELABLE_WRITE_RETURN_VALUE) != 0) {
            dispose();
        }