Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 7b465b09 authored by Jeff Brown's avatar Jeff Brown Committed by Android (Google) Code Review
Browse files

Merge "Fix dispatcher crash when input monitoring enabled. Also ensure that we...

Merge "Fix dispatcher crash when input monitoring enabled. Also ensure that we actually log assertion failures."
parents 6063b6de b6110c2d
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -724,7 +724,7 @@ void VelocityTracker::addMovement(nsecs_t eventTime, BitSet32 idBits, const Posi
            LOGD("  %d: position (%0.3f, %0.3f), vx=%0.3f, vy=%0.3f, speed=%0.3f",
                    id, positions[index].x, positions[index].y, vx, vy, sqrtf(vx * vx + vy * vy));
        } else {
            assert(vx == 0 && vy == 0);
            LOG_ASSERT(vx == 0 && vy == 0);
            LOGD("  %d: position (%0.3f, %0.3f), velocity not available",
                    id, positions[index].x, positions[index].y);
        }
+1 −1
Original line number Diff line number Diff line
@@ -450,7 +450,7 @@ EventHub::Device* EventHub::getDeviceLocked(int32_t deviceId) const {
size_t EventHub::getEvents(int timeoutMillis, RawEvent* buffer, size_t bufferSize) {
    // Note that we only allow one caller to getEvents(), so don't need
    // to do locking here...  only when adding/removing devices.
    assert(bufferSize >= 1);
    LOG_ASSERT(bufferSize >= 1);

    if (!mOpened) {
        mError = openPlatformInput() ? NO_ERROR : UNKNOWN_ERROR;
+21 −20
Original line number Diff line number Diff line
@@ -369,7 +369,7 @@ void InputDispatcher::dispatchOnceInnerLocked(nsecs_t keyRepeatTimeout,

    // Now we have an event to dispatch.
    // All events are eventually dequeued and processed this way, even if we intend to drop them.
    assert(mPendingEvent != NULL);
    LOG_ASSERT(mPendingEvent != NULL);
    bool done = false;
    DropReason dropReason = DROP_REASON_NOT_DROPPED;
    if (!(mPendingEvent->policyFlags & POLICY_FLAG_PASS_TO_USER)) {
@@ -431,7 +431,7 @@ void InputDispatcher::dispatchOnceInnerLocked(nsecs_t keyRepeatTimeout,
    }

    default:
        assert(false);
        LOG_ASSERT(false);
        break;
    }

@@ -558,7 +558,7 @@ void InputDispatcher::dropInboundEventLocked(EventEntry* entry, DropReason dropR
        reason = "inbound event was dropped because it is stale";
        break;
    default:
        assert(false);
        LOG_ASSERT(false);
        return;
    }

@@ -962,7 +962,7 @@ void InputDispatcher::dispatchEventToCurrentInputTargetsLocked(nsecs_t currentTi
            toString(resumeWithAppendedMotionSample));
#endif

    assert(eventEntry->dispatchInProgress); // should already have been set to true
    LOG_ASSERT(eventEntry->dispatchInProgress); // should already have been set to true

    pokeUserActivityLocked(eventEntry);

@@ -1596,9 +1596,10 @@ void InputDispatcher::addMonitoringTargetsLocked() {

        InputTarget& target = mCurrentInputTargets.editTop();
        target.inputChannel = mMonitoringChannels[i];
        target.flags = 0;
        target.flags = InputTarget::FLAG_DISPATCH_AS_IS;
        target.xOffset = 0;
        target.yOffset = 0;
        target.pointerIds.clear();
    }
}

@@ -1711,7 +1712,7 @@ void InputDispatcher::prepareDispatchCycleLocked(nsecs_t currentTime,

    // Make sure we are never called for streaming when splitting across multiple windows.
    bool isSplit = inputTarget->flags & InputTarget::FLAG_SPLIT;
    assert(! (resumeWithAppendedMotionSample && isSplit));
    LOG_ASSERT(! (resumeWithAppendedMotionSample && isSplit));

    // Skip this event if the connection status is not normal.
    // We don't want to enqueue additional outbound events if the connection is broken.
@@ -1725,7 +1726,7 @@ void InputDispatcher::prepareDispatchCycleLocked(nsecs_t currentTime,

    // Split a motion event if needed.
    if (isSplit) {
        assert(eventEntry->type == EventEntry::TYPE_MOTION);
        LOG_ASSERT(eventEntry->type == EventEntry::TYPE_MOTION);

        MotionEntry* originalMotionEntry = static_cast<MotionEntry*>(eventEntry);
        if (inputTarget->pointerIds.count() != originalMotionEntry->pointerCount) {
@@ -1832,7 +1833,7 @@ void InputDispatcher::prepareDispatchCycleLocked(nsecs_t currentTime,
            resumeWithAppendedMotionSample, InputTarget::FLAG_DISPATCH_AS_IS);

    // If the outbound queue was previously empty, start the dispatch cycle going.
    if (wasEmpty) {
    if (wasEmpty && !connection->outboundQueue.isEmpty()) {
        activateConnectionLocked(connection.get());
        startDispatchCycleLocked(currentTime, connection);
    }
@@ -1880,11 +1881,11 @@ void InputDispatcher::startDispatchCycleLocked(nsecs_t currentTime,
            connection->getInputChannelName());
#endif

    assert(connection->status == Connection::STATUS_NORMAL);
    assert(! connection->outboundQueue.isEmpty());
    LOG_ASSERT(connection->status == Connection::STATUS_NORMAL);
    LOG_ASSERT(! connection->outboundQueue.isEmpty());

    DispatchEntry* dispatchEntry = connection->outboundQueue.headSentinel.next;
    assert(! dispatchEntry->inProgress);
    LOG_ASSERT(! dispatchEntry->inProgress);

    // Mark the dispatch entry as in progress.
    dispatchEntry->inProgress = true;
@@ -2005,7 +2006,7 @@ void InputDispatcher::startDispatchCycleLocked(nsecs_t currentTime,
    }

    default: {
        assert(false);
        LOG_ASSERT(false);
    }
    }

@@ -2242,7 +2243,7 @@ void InputDispatcher::synthesizeCancelationEventsForConnectionLocked(

InputDispatcher::MotionEntry*
InputDispatcher::splitMotionEvent(const MotionEntry* originalMotionEntry, BitSet32 pointerIds) {
    assert(pointerIds.value != 0);
    LOG_ASSERT(pointerIds.value != 0);

    uint32_t splitPointerIndexMap[MAX_POINTERS];
    int32_t splitPointerIds[MAX_POINTERS];
@@ -3510,7 +3511,7 @@ void InputDispatcher::doDispatchCycleFinishedLockedInterruptible(
                        return;
                    }

                    assert(connection->outboundQueue.headSentinel.next == dispatchEntry);
                    LOG_ASSERT(connection->outboundQueue.headSentinel.next == dispatchEntry);

                    // Latch the fallback keycode for this key on an initial down.
                    // The fallback keycode cannot change at any other point in the lifecycle.
@@ -3523,7 +3524,7 @@ void InputDispatcher::doDispatchCycleFinishedLockedInterruptible(
                        connection->inputState.setFallbackKey(originalKeyCode, fallbackKeyCode);
                    }

                    assert(fallbackKeyCode != -1);
                    LOG_ASSERT(fallbackKeyCode != -1);

                    // Cancel the fallback key if the policy decides not to send it anymore.
                    // We will continue to dispatch the key to the policy but we will no
@@ -3761,7 +3762,7 @@ void InputDispatcher::Allocator::releaseInjectionState(InjectionState* injection
    if (injectionState->refCount == 0) {
        mInjectionStatePool.free(injectionState);
    } else {
        assert(injectionState->refCount > 0);
        LOG_ASSERT(injectionState->refCount > 0);
    }
}

@@ -3777,7 +3778,7 @@ void InputDispatcher::Allocator::releaseEventEntry(EventEntry* entry) {
        releaseMotionEntry(static_cast<MotionEntry*>(entry));
        break;
    default:
        assert(false);
        LOG_ASSERT(false);
        break;
    }
}
@@ -3789,7 +3790,7 @@ void InputDispatcher::Allocator::releaseConfigurationChangedEntry(
        releaseEventEntryInjectionState(entry);
        mConfigurationChangeEntryPool.free(entry);
    } else {
        assert(entry->refCount > 0);
        LOG_ASSERT(entry->refCount > 0);
    }
}

@@ -3799,7 +3800,7 @@ void InputDispatcher::Allocator::releaseKeyEntry(KeyEntry* entry) {
        releaseEventEntryInjectionState(entry);
        mKeyEntryPool.free(entry);
    } else {
        assert(entry->refCount > 0);
        LOG_ASSERT(entry->refCount > 0);
    }
}

@@ -3814,7 +3815,7 @@ void InputDispatcher::Allocator::releaseMotionEntry(MotionEntry* entry) {
        }
        mMotionEntryPool.free(entry);
    } else {
        assert(entry->refCount > 0);
        LOG_ASSERT(entry->refCount > 0);
    }
}

+18 −18
Original line number Diff line number Diff line
@@ -293,7 +293,7 @@ void InputReader::processEvents(const RawEvent* rawEvents, size_t count) {
                handleConfigurationChanged(rawEvent->when);
                break;
            default:
                assert(false); // can't happen
                LOG_ASSERT(false); // can't happen
                break;
            }
        }
@@ -1378,7 +1378,7 @@ void CursorInputMapper::dumpParameters(String8& dump) {
        dump.append(INDENT4 "Mode: navigation\n");
        break;
    default:
        assert(false);
        LOG_ASSERT(false);
    }

    dump.appendFormat(INDENT4 "OrientationAware: %s\n",
@@ -1801,7 +1801,7 @@ void TouchInputMapper::configure() {
        mPointerSource = AINPUT_SOURCE_MOUSE;
        break;
    default:
        assert(false);
        LOG_ASSERT(false);
    }

    // Configure absolute axis information.
@@ -1874,7 +1874,7 @@ void TouchInputMapper::dumpParameters(String8& dump) {
        dump.append(INDENT4 "DeviceType: pointer\n");
        break;
    default:
        assert(false);
        LOG_ASSERT(false);
    }

    dump.appendFormat(INDENT4 "AssociatedDisplayId: %d\n",
@@ -2509,7 +2509,7 @@ void TouchInputMapper::dumpCalibration(String8& dump) {
        dump.append(INDENT4 "touch.touchSize.calibration: pressure\n");
        break;
    default:
        assert(false);
        LOG_ASSERT(false);
    }

    // Tool Size
@@ -2527,7 +2527,7 @@ void TouchInputMapper::dumpCalibration(String8& dump) {
        dump.append(INDENT4 "touch.toolSize.calibration: area\n");
        break;
    default:
        assert(false);
        LOG_ASSERT(false);
    }

    if (mCalibration.haveToolSizeLinearScale) {
@@ -2567,7 +2567,7 @@ void TouchInputMapper::dumpCalibration(String8& dump) {
        dump.append(INDENT4 "touch.pressure.calibration: amplitude\n");
        break;
    default:
        assert(false);
        LOG_ASSERT(false);
    }

    switch (mCalibration.pressureSource) {
@@ -2580,7 +2580,7 @@ void TouchInputMapper::dumpCalibration(String8& dump) {
    case Calibration::PRESSURE_SOURCE_DEFAULT:
        break;
    default:
        assert(false);
        LOG_ASSERT(false);
    }

    if (mCalibration.havePressureScale) {
@@ -2597,7 +2597,7 @@ void TouchInputMapper::dumpCalibration(String8& dump) {
        dump.append(INDENT4 "touch.size.calibration: normalized\n");
        break;
    default:
        assert(false);
        LOG_ASSERT(false);
    }

    // Orientation
@@ -2612,7 +2612,7 @@ void TouchInputMapper::dumpCalibration(String8& dump) {
        dump.append(INDENT4 "touch.orientation.calibration: vector\n");
        break;
    default:
        assert(false);
        LOG_ASSERT(false);
    }
}

@@ -2901,7 +2901,7 @@ void TouchInputMapper::dispatchTouches(nsecs_t when, uint32_t policyFlags) {
        // Although applications receive new locations as part of individual pointer up
        // events, they do not generally handle them except when presented in a move event.
        if (moveNeeded) {
            assert(moveIdBits.value == dispatchedIdBits.value);
            LOG_ASSERT(moveIdBits.value == dispatchedIdBits.value);
            dispatchMotion(when, policyFlags, mTouchSource,
                    AMOTION_EVENT_ACTION_MOVE, 0, metaState, 0,
                    mCurrentTouchCoords, mCurrentTouch.idToIndex, dispatchedIdBits, -1,
@@ -3550,7 +3550,7 @@ void TouchInputMapper::preparePointerGestures(nsecs_t when,
        // Case 4. Exactly one finger down, button is not pressed. (HOVER)
        // The pointer follows the active touch point.
        // Emit HOVER_MOVE events at the pointer location.
        assert(activeTouchId >= 0);
        LOG_ASSERT(activeTouchId >= 0);

#if DEBUG_GESTURES
        LOGD("Gestures: HOVER");
@@ -3600,7 +3600,7 @@ void TouchInputMapper::preparePointerGestures(nsecs_t when,
        // Fix the centroid of the figure when the gesture actually starts.
        // We do not recalculate the centroid at any other time during the gesture because
        // it would affect the relationship of the touch points relative to the pointer location.
        assert(activeTouchId >= 0);
        LOG_ASSERT(activeTouchId >= 0);

        uint32_t currentTouchPointerCount = mCurrentTouch.pointerCount;
        if (currentTouchPointerCount > MAX_POINTERS) {
@@ -3712,7 +3712,7 @@ void TouchInputMapper::preparePointerGestures(nsecs_t when,
                    "activeGestureId=%d, currentTouchPointerCount=%d",
                    activeTouchId, mPointerGesture.activeGestureId, currentTouchPointerCount);
#endif
            assert(mPointerGesture.activeGestureId >= 0);
            LOG_ASSERT(mPointerGesture.activeGestureId >= 0);

            float x = (mCurrentTouch.pointers[0].x + mCurrentTouch.pointers[1].x
                    - mPointerGesture.initialCentroidX * 2) * 0.5f
@@ -3736,7 +3736,7 @@ void TouchInputMapper::preparePointerGestures(nsecs_t when,
                    "activeGestureId=%d, currentTouchPointerCount=%d",
                    activeTouchId, mPointerGesture.activeGestureId, currentTouchPointerCount);
#endif
            assert(mPointerGesture.activeGestureId >= 0);
            LOG_ASSERT(mPointerGesture.activeGestureId >= 0);

            mPointerGesture.currentGesturePointerCount = currentTouchPointerCount;
            mPointerGesture.currentGestureIdBits.clear();
@@ -3895,7 +3895,7 @@ void TouchInputMapper::dispatchMotion(nsecs_t when, uint32_t policyFlags, uint32
        pointerCount += 1;
    }

    assert(pointerCount != 0);
    LOG_ASSERT(pointerCount != 0);

    if (changedId >= 0 && pointerCount == 1) {
        // Replace initial down and final up action.
@@ -3907,7 +3907,7 @@ void TouchInputMapper::dispatchMotion(nsecs_t when, uint32_t policyFlags, uint32
            action = AMOTION_EVENT_ACTION_UP;
        } else {
            // Can't happen.
            assert(false);
            LOG_ASSERT(false);
        }
    }

@@ -4072,7 +4072,7 @@ void TouchInputMapper::calculatePointerIds() {
                    // Previous iterations consumed the root element of the heap.
                    // Pop root element off of the heap (sift down).
                    heapSize -= 1;
                    assert(heapSize > 0);
                    LOG_ASSERT(heapSize > 0);

                    // Sift down.
                    heap[0] = heap[heapSize];