Loading services/input/InputDispatcher.cpp +45 −28 Original line number Diff line number Diff line Loading @@ -1060,14 +1060,26 @@ int32_t InputDispatcher::findTouchedWindowTargetsLocked(nsecs_t currentTime, // Update the touch state as needed based on the properties of the touch event. int32_t injectionResult = INPUT_EVENT_INJECTION_PENDING; InjectionPermission injectionPermission = INJECTION_PERMISSION_UNKNOWN; bool isSplit, wrongDevice; if (maskedAction == AMOTION_EVENT_ACTION_DOWN) { mTempTouchState.reset(); mTempTouchState.down = true; mTempTouchState.deviceId = entry->deviceId; isSplit = false; wrongDevice = false; } else { mTempTouchState.copyFrom(mTouchState); isSplit = mTempTouchState.split; wrongDevice = mTempTouchState.down && mTempTouchState.deviceId != entry->deviceId; if (wrongDevice) { #if DEBUG_INPUT_DISPATCHER_POLICY LOGD("Dropping event because a pointer for a different device is already down."); #endif injectionResult = INPUT_EVENT_INJECTION_FAILED; goto Failed; } } bool isSplit = mTempTouchState.split && mTempTouchState.down; if (maskedAction == AMOTION_EVENT_ACTION_DOWN || (isSplit && maskedAction == AMOTION_EVENT_ACTION_POINTER_DOWN)) { /* Case 1: New splittable pointer going down. */ Loading Loading @@ -1279,6 +1291,7 @@ Failed: // Update final pieces of touch state if the injector had permission. if (injectionPermission == INJECTION_PERMISSION_GRANTED) { if (!wrongDevice) { if (maskedAction == AMOTION_EVENT_ACTION_UP || maskedAction == AMOTION_EVENT_ACTION_CANCEL) { // All pointers up or canceled. Loading Loading @@ -1312,6 +1325,7 @@ Failed: // Save changes to touch state. mTouchState.copyFrom(mTempTouchState); } } else { #if DEBUG_FOCUS LOGD("Not updating touch focus because injection was denied."); Loading Loading @@ -2768,6 +2782,7 @@ void InputDispatcher::dumpDispatchStateLocked(String8& dump) { dump.appendFormat(INDENT "TouchDown: %s\n", toString(mTouchState.down)); dump.appendFormat(INDENT "TouchSplit: %s\n", toString(mTouchState.split)); dump.appendFormat(INDENT "TouchDeviceId: %d\n", mTouchState.deviceId); if (!mTouchState.windows.isEmpty()) { dump.append(INDENT "TouchedWindows:\n"); for (size_t i = 0; i < mTouchState.windows.size(); i++) { Loading Loading @@ -3642,7 +3657,7 @@ InputDispatcher::CommandEntry::~CommandEntry() { // --- InputDispatcher::TouchState --- InputDispatcher::TouchState::TouchState() : down(false), split(false) { down(false), split(false), deviceId(-1) { } InputDispatcher::TouchState::~TouchState() { Loading @@ -3651,12 +3666,14 @@ InputDispatcher::TouchState::~TouchState() { void InputDispatcher::TouchState::reset() { down = false; split = false; deviceId = -1; windows.clear(); } void InputDispatcher::TouchState::copyFrom(const TouchState& other) { down = other.down; split = other.split; deviceId = other.deviceId; windows.clear(); windows.appendVector(other.windows); } Loading services/input/InputDispatcher.h +1 −0 Original line number Diff line number Diff line Loading @@ -957,6 +957,7 @@ private: struct TouchState { bool down; bool split; int32_t deviceId; // id of the device that is currently down, others are rejected Vector<TouchedWindow> windows; TouchState(); Loading Loading
services/input/InputDispatcher.cpp +45 −28 Original line number Diff line number Diff line Loading @@ -1060,14 +1060,26 @@ int32_t InputDispatcher::findTouchedWindowTargetsLocked(nsecs_t currentTime, // Update the touch state as needed based on the properties of the touch event. int32_t injectionResult = INPUT_EVENT_INJECTION_PENDING; InjectionPermission injectionPermission = INJECTION_PERMISSION_UNKNOWN; bool isSplit, wrongDevice; if (maskedAction == AMOTION_EVENT_ACTION_DOWN) { mTempTouchState.reset(); mTempTouchState.down = true; mTempTouchState.deviceId = entry->deviceId; isSplit = false; wrongDevice = false; } else { mTempTouchState.copyFrom(mTouchState); isSplit = mTempTouchState.split; wrongDevice = mTempTouchState.down && mTempTouchState.deviceId != entry->deviceId; if (wrongDevice) { #if DEBUG_INPUT_DISPATCHER_POLICY LOGD("Dropping event because a pointer for a different device is already down."); #endif injectionResult = INPUT_EVENT_INJECTION_FAILED; goto Failed; } } bool isSplit = mTempTouchState.split && mTempTouchState.down; if (maskedAction == AMOTION_EVENT_ACTION_DOWN || (isSplit && maskedAction == AMOTION_EVENT_ACTION_POINTER_DOWN)) { /* Case 1: New splittable pointer going down. */ Loading Loading @@ -1279,6 +1291,7 @@ Failed: // Update final pieces of touch state if the injector had permission. if (injectionPermission == INJECTION_PERMISSION_GRANTED) { if (!wrongDevice) { if (maskedAction == AMOTION_EVENT_ACTION_UP || maskedAction == AMOTION_EVENT_ACTION_CANCEL) { // All pointers up or canceled. Loading Loading @@ -1312,6 +1325,7 @@ Failed: // Save changes to touch state. mTouchState.copyFrom(mTempTouchState); } } else { #if DEBUG_FOCUS LOGD("Not updating touch focus because injection was denied."); Loading Loading @@ -2768,6 +2782,7 @@ void InputDispatcher::dumpDispatchStateLocked(String8& dump) { dump.appendFormat(INDENT "TouchDown: %s\n", toString(mTouchState.down)); dump.appendFormat(INDENT "TouchSplit: %s\n", toString(mTouchState.split)); dump.appendFormat(INDENT "TouchDeviceId: %d\n", mTouchState.deviceId); if (!mTouchState.windows.isEmpty()) { dump.append(INDENT "TouchedWindows:\n"); for (size_t i = 0; i < mTouchState.windows.size(); i++) { Loading Loading @@ -3642,7 +3657,7 @@ InputDispatcher::CommandEntry::~CommandEntry() { // --- InputDispatcher::TouchState --- InputDispatcher::TouchState::TouchState() : down(false), split(false) { down(false), split(false), deviceId(-1) { } InputDispatcher::TouchState::~TouchState() { Loading @@ -3651,12 +3666,14 @@ InputDispatcher::TouchState::~TouchState() { void InputDispatcher::TouchState::reset() { down = false; split = false; deviceId = -1; windows.clear(); } void InputDispatcher::TouchState::copyFrom(const TouchState& other) { down = other.down; split = other.split; deviceId = other.deviceId; windows.clear(); windows.appendVector(other.windows); } Loading
services/input/InputDispatcher.h +1 −0 Original line number Diff line number Diff line Loading @@ -957,6 +957,7 @@ private: struct TouchState { bool down; bool split; int32_t deviceId; // id of the device that is currently down, others are rejected Vector<TouchedWindow> windows; TouchState(); Loading