一.拔插usb触摸导致浏览器页面重新刷新

二.禁用触摸
2.1.\frameworks\native\services\inputflinger\EventHub.h
/*
* Input device classes.
*/
enum {
/* The input device is a keyboard or has buttons. */
INPUT_DEVICE_CLASS_KEYBOARD = 0x00000001,
/* The input device is an alpha-numeric keyboard (not just a dial pad). */
INPUT_DEVICE_CLASS_ALPHAKEY = 0x00000002,
/* The input device is a touchscreen or a touchpad (either single-touch or multi-touch). */
INPUT_DEVICE_CLASS_TOUCH = 0x00000004,
/* The input device is a cursor device such as a trackball or mouse. */
INPUT_DEVICE_CLASS_CURSOR = 0x00000008,
/* The input device is a multi-touch touchscreen. */
INPUT_DEVICE_CLASS_TOUCH_MT = 0x00000010,
/* The input device is a directional pad (implies keyboard, has DPAD keys). */
INPUT_DEVICE_CLASS_DPAD = 0x00000020,
/* The input device is a gamepad (implies keyboard, has BUTTON keys). */
INPUT_DEVICE_CLASS_GAMEPAD = 0x00000040,
/* The input device has switches. */
INPUT_DEVICE_CLASS_SWITCH = 0x00000080,
/* The input device is a joystick (implies gamepad, has joystick absolute axes). */
INPUT_DEVICE_CLASS_JOYSTICK = 0x00000100,
/* The input device has a vibrator (supports FF_RUMBLE). */
INPUT_DEVICE_CLASS_VIBRATOR = 0x00000200,
/* The input device has a mouse. */
INPUT_DEVICE_CLASS_KEYMOUSE = 0x00000400,
/* The input device has a microphone. */
INPUT_DEVICE_CLASS_MIC = 0x00000400,
/* The input device is an external stylus (has data we want to fuse with touch data). */
INPUT_DEVICE_CLASS_EXTERNAL_STYLUS = 0x00000800,
/* The input device has a rotary encoder */
INPUT_DEVICE_CLASS_ROTARY_ENCODER = 0x00001000,
/* The input device is virtual (not a real device, not part of UI configuration). */
INPUT_DEVICE_CLASS_VIRTUAL = 0x40000000,
/* The input device is external (not built-in). */
INPUT_DEVICE_CLASS_EXTERNAL = 0x80000000,
};
2.2.frameworks\native\services\inputflinger\EventHub.cpp Mapper只处理一次 不能根据属性同步
触摸
--- a/frameworks/native/services/inputflinger/EventHub.cpp
+++ b/frameworks/native/services/inputflinger/EventHub.cpp
@@ -1199,7 +1199,10 @@ status_t EventHub::openDeviceLocked(const char *devicePath) {
device->classes |= INPUT_DEVICE_CLASS_ROTARY_ENCODER;
}
}
-
+ char usb_touch [PROPERTY_VALUE_MAX];
+ int usb_touch_flag = 0;
+ property_get("persist.sys.UsbTouch", usb_touch, "0");
+ usb_touch_flag = strtol(usb_touch,0,0);
// See if this is a touch pad.
// Is this a new modern multi-touch driver?
if (test_bit(ABS_MT_POSITION_X, device->absBitmask)
@@ -1208,13 +1211,21 @@ status_t EventHub::openDeviceLocked(const char *devicePath) {
// with the ABS_MT range. Try to confirm that the device really is
// a touch screen.
if (test_bit(BTN_TOUCH, device->keyBitmask) || !haveGamepadButtons) {
- device->classes |= INPUT_DEVICE_CLASS_TOUCH | INPUT_DEVICE_CLASS_TOUCH_MT;
+ device->classes |= INPUT_DEVICE_CLASS_TOUCH | INPUT_DEVICE_CLASS_TOUCH_MT;
+ if(usb_touch_flag){
+ ALOGD("gatsby INPUT_DEVICE_CLASS_TOUCH INPUT_DEVICE_CLASS_TOUCH_MT");
+ return -1;
+ }
}
// Is this an old style single-touch driver?
} else if (test_bit(BTN_TOUCH, device->keyBitmask)
&& test_bit(ABS_X, device->absBitmask)
&& test_bit(ABS_Y, device->absBitmask)) {
- device->classes |= INPUT_DEVICE_CLASS_TOUCH;
+ device->classes |= INPUT_DEVICE_CLASS_TOUCH;
+ if(usb_touch_flag){
+ ALOGD("gatsby INPUT_DEVICE_CLASS_TOUCH");
+ return -1;
+ }
// Is this a BT stylus?
} else if ((test_bit(ABS_PRESSURE, device->absBitmask) ||
test_bit(BTN_TOUCH, device->keyBitmask))
键盘
device->classes |= INPUT_DEVICE_CLASS_KEYBOARD | INPUT_DEVICE_CLASS_KEYMOUSE;
鼠标
device->classes |= INPUT_DEVICE_CLASS_CURSOR;
2.3.frameworks\native\services\inputflinger\InputReader.cpp 多点触摸屏处理函数 处理数据上报
--- a/frameworks/native/services/inputflinger/InputReader.cpp
+++ b/frameworks/native/services/inputflinger/InputReader.cpp
@@ -85,6 +85,9 @@ static const nsecs_t STYLUS_DATA_LATENCY = ms2ns(10);
static const int KEYCODE_ENTER = 28;
static const int KEYCODE_DPAD_CENTER = 232;
+static char usb_touch [PROPERTY_VALUE_MAX];
+static int usb_touch_flag = 0;
+
// --- Static Functions ---
template<typename T>
@@ -1739,6 +1742,10 @@ void MultiTouchMotionAccumulator::clearSlots(int32_t initialSlot) {
}
void MultiTouchMotionAccumulator::process(const RawEvent* rawEvent) {
+ //ALOGD("gatsby MultiTouchMotionAccumulator");
+ property_get("persist.sys.UsbTouch", usb_touch, "0");
+ usb_touch_flag = strtol(usb_touch,0,0);
+if(usb_touch_flag){
if (rawEvent->type == EV_ABS) {
bool newSlot = false;
if (mUsingSlotsProtocol) {
@@ -1821,6 +1828,7 @@ void MultiTouchMotionAccumulator::process(const RawEvent* rawEvent) {
// MultiTouch Sync: The driver has returned all data for *one* of the pointers.
mCurrentSlot += 1;
}
+}
}
原文:https://www.cnblogs.com/crushgirl/p/15200388.html