private void addKeyState(int deviceId, int source, int keyCode) { android.view.InputEventConsistencyVerifier.KeyState state = android.view.InputEventConsistencyVerifier .KeyState.obtain(deviceId, source, keyCode); state.next = mKeyStateList; mKeyStateList = state; }
private android.view.InputEventConsistencyVerifier.KeyState findKeyState(int deviceId , int source, int keyCode, bool remove) { android.view.InputEventConsistencyVerifier.KeyState last = null; android.view.InputEventConsistencyVerifier.KeyState state = mKeyStateList; while (state != null) { if (state.deviceId == deviceId && state.source == source && state.keyCode == keyCode) { if (remove) { if (last != null) { last.next = state.next; } else { mKeyStateList = state.next; } state.next = null; } return(state); } last = state; state = state.next; } return(null); }
public void recycle() { lock (mRecycledListLock) { next = mRecycledList; mRecycledList = next; } }
/// <summary>Resets the state of the input event consistency verifier.</summary> /// <remarks>Resets the state of the input event consistency verifier.</remarks> public void reset() { mLastEvent = null; mLastNestingLevel = 0; mTrackballDown = false; mTrackballUnhandled = false; mTouchEventStreamPointers = 0; mTouchEventStreamIsTainted = false; mTouchEventStreamUnhandled = false; mHoverEntered = false; while (mKeyStateList != null) { android.view.InputEventConsistencyVerifier.KeyState state = mKeyStateList; mKeyStateList = state.next; state.recycle(); } }
/// <summary> /// Notifies the verifier that a given event was unhandled and the rest of the /// trace for the event should be ignored. /// </summary> /// <remarks> /// Notifies the verifier that a given event was unhandled and the rest of the /// trace for the event should be ignored. /// This method should only be called if the event was previously checked by /// the consistency verifier using /// <see cref="onInputEvent(InputEvent, int)">onInputEvent(InputEvent, int)</see> /// and other methods. /// </remarks> /// <param name="event">The event.</param> /// <param name="nestingLevel"> /// The nesting level: 0 if called from the base class, /// or 1 from a subclass. If the event was already checked by this consistency verifier /// at a higher nesting level, it will not be checked again. Used to handle the situation /// where a subclass dispatching method delegates to its superclass's dispatching method /// and both dispatching methods call into the consistency verifier. /// </param> public void onUnhandledEvent(android.view.InputEvent @event, int nestingLevel) { if (nestingLevel != mLastNestingLevel) { return; } if (mRecentEventsUnhandled != null) { mRecentEventsUnhandled[mMostRecentEventIndex] = true; } if (@event is android.view.KeyEvent) { android.view.KeyEvent keyEvent = (android.view.KeyEvent)@event; int deviceId = keyEvent.getDeviceId(); int source = keyEvent.getSource(); int keyCode = keyEvent.getKeyCode(); android.view.InputEventConsistencyVerifier.KeyState state = findKeyState(deviceId , source, keyCode, false); if (state != null) { state.unhandled = true; } } else { android.view.MotionEvent motionEvent = (android.view.MotionEvent)@event; if (motionEvent.isTouchEvent()) { mTouchEventStreamUnhandled = true; } else { if ((motionEvent.getSource() & android.view.InputDevice.SOURCE_CLASS_TRACKBALL) != 0) { if (mTrackballDown) { mTrackballUnhandled = true; } } } } }
public static android.view.InputEventConsistencyVerifier.KeyState obtain(int deviceId , int source, int keyCode) { android.view.InputEventConsistencyVerifier.KeyState state; lock (mRecycledListLock) { state = mRecycledList; if (state != null) { mRecycledList = state.next; } else { state = new android.view.InputEventConsistencyVerifier.KeyState(); } } state.deviceId = deviceId; state.source = source; state.keyCode = keyCode; state.unhandled = false; return(state); }
public void recycle() { lock (mRecycledListLock) { next = mRecycledList; mRecycledList = next; } }
public static android.view.InputEventConsistencyVerifier.KeyState obtain(int deviceId , int source, int keyCode) { android.view.InputEventConsistencyVerifier.KeyState state; lock (mRecycledListLock) { state = mRecycledList; if (state != null) { mRecycledList = state.next; } else { state = new android.view.InputEventConsistencyVerifier.KeyState(); } } state.deviceId = deviceId; state.source = source; state.keyCode = keyCode; state.unhandled = false; return state; }
private void addKeyState(int deviceId, int source, int keyCode) { android.view.InputEventConsistencyVerifier.KeyState state = android.view.InputEventConsistencyVerifier .KeyState.obtain(deviceId, source, keyCode); state.next = mKeyStateList; mKeyStateList = state; }
private android.view.InputEventConsistencyVerifier.KeyState findKeyState(int deviceId , int source, int keyCode, bool remove) { android.view.InputEventConsistencyVerifier.KeyState last = null; android.view.InputEventConsistencyVerifier.KeyState state = mKeyStateList; while (state != null) { if (state.deviceId == deviceId && state.source == source && state.keyCode == keyCode) { if (remove) { if (last != null) { last.next = state.next; } else { mKeyStateList = state.next; } state.next = null; } return state; } last = state; state = state.next; } return null; }
/// <summary>Resets the state of the input event consistency verifier.</summary> /// <remarks>Resets the state of the input event consistency verifier.</remarks> public void reset() { mLastEvent = null; mLastNestingLevel = 0; mTrackballDown = false; mTrackballUnhandled = false; mTouchEventStreamPointers = 0; mTouchEventStreamIsTainted = false; mTouchEventStreamUnhandled = false; mHoverEntered = false; while (mKeyStateList != null) { android.view.InputEventConsistencyVerifier.KeyState state = mKeyStateList; mKeyStateList = state.next; state.recycle(); } }
/// <summary>Checks a key event.</summary> /// <remarks>Checks a key event.</remarks> /// <param name="event">The event.</param> /// <param name="nestingLevel"> /// The nesting level: 0 if called from the base class, /// or 1 from a subclass. If the event was already checked by this consistency verifier /// at a higher nesting level, it will not be checked again. Used to handle the situation /// where a subclass dispatching method delegates to its superclass's dispatching method /// and both dispatching methods call into the consistency verifier. /// </param> public void onKeyEvent(android.view.KeyEvent @event, int nestingLevel) { if (!startEvent(@event, nestingLevel, EVENT_TYPE_KEY)) { return; } try { ensureMetaStateIsNormalized(@event.getMetaState()); int action = @event.getAction(); int deviceId = @event.getDeviceId(); int source = @event.getSource(); int keyCode = @event.getKeyCode(); switch (action) { case android.view.KeyEvent.ACTION_DOWN: { android.view.InputEventConsistencyVerifier.KeyState state = findKeyState(deviceId , source, keyCode, false); if (state != null) { // If the key is already down, ensure it is a repeat. // We don't perform this check when processing raw device input // because the input dispatcher itself is responsible for setting // the key repeat count before it delivers input events. if (state.unhandled) { state.unhandled = false; } else { if ((mFlags & FLAG_RAW_DEVICE_INPUT) == 0 && @event.getRepeatCount() == 0) { problem("ACTION_DOWN but key is already down and this event " + "is not a key repeat." ); } } } else { addKeyState(deviceId, source, keyCode); } break; } case android.view.KeyEvent.ACTION_UP: { android.view.InputEventConsistencyVerifier.KeyState state = findKeyState(deviceId , source, keyCode, true); if (state == null) { problem("ACTION_UP but key was not down."); } else { state.recycle(); } break; } case android.view.KeyEvent.ACTION_MULTIPLE: { break; } default: { problem("Invalid action " + android.view.KeyEvent.actionToString(action) + " for key event." ); break; } } } finally { finishEvent(); } }