FileDocCategorySizeDatePackage
InputQueue.javaAPI DocAndroid 5.1 API4877Thu Mar 12 22:22:10 GMT 2015android.view

InputQueue

public final class InputQueue extends Object
An input queue provides a mechanism for an application to receive incoming input events. Currently only usable from native code.

Fields Summary
private final android.util.LongSparseArray
mActiveEventArray
private final android.util.Pools.Pool
mActiveInputEventPool
private final dalvik.system.CloseGuard
mCloseGuard
private long
mPtr
Constructors Summary
public InputQueue()

hide


         
             
             
           
         

      
      
        mPtr = nativeInit(new WeakReference<InputQueue>(this), Looper.myQueue());

        mCloseGuard.open("dispose");
    
Methods Summary
public voiddispose()

hide

        dispose(false);
    
public voiddispose(boolean finalized)

hide

        if (mCloseGuard != null) {
            if (finalized) {
                mCloseGuard.warnIfOpen();
            }
            mCloseGuard.close();
        }

        if (mPtr != 0) {
            nativeDispose(mPtr);
            mPtr = 0;
        }
    
protected voidfinalize()

        try {
            dispose(true);
        } finally {
            super.finalize();
        }
    
private voidfinishInputEvent(long id, boolean handled)

        int index = mActiveEventArray.indexOfKey(id);
        if (index >= 0) {
            ActiveInputEvent e = mActiveEventArray.valueAt(index);
            mActiveEventArray.removeAt(index);
            e.mCallback.onFinishedInputEvent(e.mToken, handled);
            recycleActiveInputEvent(e);
        }
    
public longgetNativePtr()

hide

        return mPtr;
    
private static native voidnativeDispose(long ptr)

private static native longnativeInit(java.lang.ref.WeakReference weakQueue, android.os.MessageQueue messageQueue)

private static native longnativeSendKeyEvent(long ptr, KeyEvent e, boolean preDispatch)

private static native longnativeSendMotionEvent(long ptr, MotionEvent e)

private android.view.InputQueue$ActiveInputEventobtainActiveInputEvent(java.lang.Object token, android.view.InputQueue$FinishedInputEventCallback callback)

        ActiveInputEvent e = mActiveInputEventPool.acquire();
        if (e == null) {
            e = new ActiveInputEvent();
        }
        e.mToken = token;
        e.mCallback = callback;
        return e;
    
private voidrecycleActiveInputEvent(android.view.InputQueue$ActiveInputEvent e)

        e.recycle();
        mActiveInputEventPool.release(e);
    
public voidsendInputEvent(InputEvent e, java.lang.Object token, boolean predispatch, android.view.InputQueue$FinishedInputEventCallback callback)

hide

        ActiveInputEvent event = obtainActiveInputEvent(token, callback);
        long id;
        if (e instanceof KeyEvent) {
            id = nativeSendKeyEvent(mPtr, (KeyEvent) e, predispatch);
        } else {
            id = nativeSendMotionEvent(mPtr, (MotionEvent) e);
        }
        mActiveEventArray.put(id, event);