diff --git a/services/inputflinger/InputReader.cpp b/services/inputflinger/InputReader.cpp index b183250fdb..6b1f6b44be 100644 --- a/services/inputflinger/InputReader.cpp +++ b/services/inputflinger/InputReader.cpp @@ -84,6 +84,7 @@ static const nsecs_t TOUCH_DATA_TIMEOUT = ms2ns(20); // data. static const nsecs_t STYLUS_DATA_LATENCY = ms2ns(10); +static const nsecs_t STYLUS_PALM_REJECTION_TIME = ms2ns(50); // --- Static Functions --- template @@ -6285,6 +6286,7 @@ void TouchInputMapper::dispatchPointerStylus(nsecs_t when, uint32_t policyFlags) mPointerSimple.currentProperties.id = 0; mPointerSimple.currentProperties.toolType = mCurrentCookedState.cookedPointerData.pointerProperties[index].toolType; + mLastStylusTime = when; // michael } else { down = false; hovering = false; @@ -6368,6 +6370,12 @@ void TouchInputMapper::dispatchPointerSimple(nsecs_t when, uint32_t policyFlags, } } + // michael + if (rejectPalm(when)) { // stylus is currently active + mPointerSimple.reset(); + return; + } + if (mPointerSimple.down && !down) { mPointerSimple.down = false; @@ -6488,6 +6496,9 @@ void TouchInputMapper::dispatchMotion(nsecs_t when, uint32_t policyFlags, uint32 const PointerProperties* properties, const PointerCoords* coords, const uint32_t* idToIndex, BitSet32 idBits, int32_t changedId, float xPrecision, float yPrecision, nsecs_t downTime) { + + if (rejectPalm(when)) return; // michael + PointerCoords pointerCoords[MAX_POINTERS]; PointerProperties pointerProperties[MAX_POINTERS]; uint32_t pointerCount = 0; @@ -6561,6 +6572,16 @@ void TouchInputMapper::fadePointer() { } } +nsecs_t TouchInputMapper::mLastStylusTime = 0; //michael + + +// michael +bool TouchInputMapper::rejectPalm(nsecs_t when) { + return (when - mLastStylusTime < STYLUS_PALM_REJECTION_TIME) && + mPointerSimple.currentProperties.toolType != AMOTION_EVENT_TOOL_TYPE_STYLUS && + mPointerSimple.currentProperties.toolType != AMOTION_EVENT_TOOL_TYPE_ERASER; +} + void TouchInputMapper::cancelTouch(nsecs_t when) { abortPointerUsage(when, 0 /*policyFlags*/); abortTouches(when, 0 /* policyFlags*/);