RK Android7.1 禁用 USB触摸

摘要:
Android输入系统(6)-多点触摸处理I和II。禁止触摸putflingerEventHub中的2.1.frameworkstativeservices。hEventHub-˃getEvents()以获取输入事件和设备添加/删除事件/**输入设备类*/enum{/*输入设备是键盘或有按钮。*/INPUT_DEVICE_CL

Android输入系统(6)——多点触摸处理

一.

二.禁用触摸

2.1.frameworks ativeservicesinputflingerEventHub.h

EventHub->getEvents(),获取输入事件和设备增删事件

/*
 * 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 ativeservicesinputflingerEventHub.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 ativeservicesinputflingerInputReader.cpp 多点触摸屏处理函数 处理数据上报 

输入系统 InputReader

  • 键盘类设备:KeyboardInputMapper
  • 触摸屏设备:MultiTouchInputMapper或SingleTouchInputMapper
  • 鼠标类设备:CursorInputMapper
--- 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;
     }
+}	
 }

三.禁用鼠标

3.1.鼠标、触摸休眠唤醒

mCursorButtonAccumulator.process(rawEvent);//按键
mCursorMotionAccumulator.process(rawEvent);//移动
mCursorScrollAccumulator.process(rawEvent);//滚动

--- 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_mouse [PROPERTY_VALUE_MAX];
+static	int   usb_mouse_flag = 0;
+
 // --- Static Functions ---
 
 template<typename T>
@@ -2622,6 +2625,11 @@ void CursorInputMapper::reset(nsecs_t when) {
 }
 
 void CursorInputMapper::process(const RawEvent* rawEvent) {
+	property_get("persist.sys.UsbMouse", usb_mouse, "0");
+	usb_mouse_flag = strtol(usb_mouse,0,0);
+	//ALOGD("gatsby CursorInputMapper %d",usb_mouse_flag);
+	if(!usb_mouse_flag){
+	//ALOGD("gatsby CursorInputMapperxxxxx %d",usb_mouse_flag);
     mCursorButtonAccumulator.process(rawEvent);
     mCursorMotionAccumulator.process(rawEvent);
     mCursorScrollAccumulator.process(rawEvent);
@@ -2629,6 +2637,7 @@ void CursorInputMapper::process(const RawEvent* rawEvent) {
     if (rawEvent->type == EV_SYN && rawEvent->code == SYN_REPORT) {
         sync(rawEvent->when);
     }
+	}
 }
 
 void CursorInputMapper::sync(nsecs_t when) {
@@ -3372,7 +3381,8 @@ void TouchInputMapper::configureParameters() {
     // Initial downs on external touch devices should wake the device.
     // Normally we don't do this for internal touch screens to prevent them from waking
     // up in your pocket but you can enable it using the input device configuration.
-    mParameters.wake = getDevice()->isExternal();
+    //mParameters.wake = getDevice()->isExternal();
+	mParameters.wake = 0;
     getDevice()->getConfiguration().tryGetProperty(String8("touch.wake"),
             mParameters.wake);
 }  

3.2.异常init.rc里面的服务老是重启

[ 3.434014] init: Service 'inputflinger' (pid 226) killed by signal 6
[ 3.434052] init: Service 'inputflinger' (pid 226) killing any children in process group

[    2.837536] init: Starting service 'inputflinger'...
[    2.838752] init: Starting service 'installd'...
[    2.839252] init: Starting service 'keystore'...
[    2.845439] init: Starting service 'mediacodec'...
[    2.845861] init: Starting service 'mediadrm'...
[    2.848736] init: Starting service 'mediaextractor'...
[    2.851013] init: Starting service 'media'...
[    2.855864] init: Starting service 'netd'...
[    2.856386] init: Service 'rootservice' (pid 217) exited with status 0
[    2.856576] init: Starting service 'gatekeeperd'...
[    2.864264] logd.daemon: reinit
[    2.871770] rk_gmac-dwmac ff290000.ethernet: rk_get_eth_addr: mac address: 3e:6e:85:07:a7:0e
[    2.871786] eth0: device MAC address 3e:6e:85:07:a7:0e
[    2.872398] init: Starting service 'perfprofd'...
[    2.872895] init: Service 'logd-reinit' (pid 202) exited with status 0
[    2.873057] init: Service 'akmd' (pid 221) exited with status 254
[    2.910133] ret = ffffffff
[    2.910574] init: Service 'up_eth0' (pid 220) exited with status 0
[    2.914185] init: Service 'drmservice' (pid 219) exited with status 0
[    2.945194] capability: warning: `daemonsu' uses 32-bit capabilities (legacy support in use)
[    2.946996] init: Untracked pid 233 exited with status 0
[    3.034081] read descriptors
[    3.034182] read strings
[    3.034962] pcd_pullup, is_on 1
[    3.226907] EXT4-fs (mmcblk2p10): re-mounted. Opts: (null)
[    3.231591] random: nonblocking pool is initialized
[    3.434014] init: Service 'inputflinger' (pid 226) killed by signal 6
[    3.434052] init: Service 'inputflinger' (pid 226) killing any children in process group

3.3.优化

--- 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_mouse [PROPERTY_VALUE_MAX];
+static	int   usb_mouse_flag = 0;
+
 // --- Static Functions ---
 
 template<typename T>
@@ -1260,6 +1263,7 @@ void CursorButtonAccumulator::clearButtons() {
 }
 
 void CursorButtonAccumulator::process(const RawEvent* rawEvent) {
+	if(!usb_mouse_flag){
     if (rawEvent->type == EV_KEY) {
         switch (rawEvent->code) {
         case BTN_LEFT:
@@ -1292,6 +1296,7 @@ void CursorButtonAccumulator::process(const RawEvent* rawEvent) {
             break;
         }
     }
+	}
 }
 
 uint32_t CursorButtonAccumulator::getButtonState() const {
@@ -1334,6 +1339,7 @@ void CursorMotionAccumulator::clearRelativeAxes() {
 }
 
 void CursorMotionAccumulator::process(const RawEvent* rawEvent) {
+	if(!usb_mouse_flag){
     if (rawEvent->type == EV_REL) {
         switch (rawEvent->code) {
         case REL_X:
@@ -1344,6 +1350,7 @@ void CursorMotionAccumulator::process(const RawEvent* rawEvent) {
             break;
         }
     }
+	}
 }
 
 void CursorMotionAccumulator::finishSync() {
@@ -1373,6 +1380,7 @@ void CursorScrollAccumulator::clearRelativeAxes() {
 }
 
 void CursorScrollAccumulator::process(const RawEvent* rawEvent) {
+	if(!usb_mouse_flag){
     if (rawEvent->type == EV_REL) {
         switch (rawEvent->code) {
         case REL_WHEEL:
@@ -1383,6 +1391,7 @@ void CursorScrollAccumulator::process(const RawEvent* rawEvent) {
             break;
         }
     }
+	}
 }
 
 void CursorScrollAccumulator::finishSync() {
@@ -2622,6 +2631,9 @@ void CursorInputMapper::reset(nsecs_t when) {
 }
 
 void CursorInputMapper::process(const RawEvent* rawEvent) {
+	property_get("persist.sys.UsbMouse", usb_mouse, "0");
+	usb_mouse_flag = strtol(usb_mouse,0,0);
+	//ALOGD("gatsby CursorInputMapper %d",usb_mouse_flag);
     mCursorButtonAccumulator.process(rawEvent);
     mCursorMotionAccumulator.process(rawEvent);
     mCursorScrollAccumulator.process(rawEvent);
@@ -3372,7 +3384,8 @@ void TouchInputMapper::configureParameters() {
     // Initial downs on external touch devices should wake the device.
     // Normally we don't do this for internal touch screens to prevent them from waking
     // up in your pocket but you can enable it using the input device configuration.
-    mParameters.wake = getDevice()->isExternal();
+    //mParameters.wake = getDevice()->isExternal();
+	mParameters.wake = 0;
     getDevice()->getConfiguration().tryGetProperty(String8("touch.wake"),
             mParameters.wake);
 }

免责声明:文章转载自《RK Android7.1 禁用 USB触摸》仅用于学习参考。如对内容有疑问,请及时联系本站处理。

上篇Oracle数据库sql常用python菜鸟教程学习13:文件操作下篇

宿迁高防,2C2G15M,22元/月;香港BGP,2C5G5M,25元/月 雨云优惠码:MjYwNzM=

相关文章

初学Python常见异常错误,总有一处你会遇到!

初学Python常见错误 忘记写冒号 误用= 错误 缩紧 变量没有定义 中英文输入法导致的错误 不同数据类型的拼接 索引位置问题 使用字典中不存在的键 忘了括号 漏传参数 缺失依赖库 使用了python中对关键词 编码问题 1. 忘记写冒号 在 if、elif、else、for、while、def语句后面忘记添加 : age = 42 if age...

2个小技巧

概述 沉迷业务,无法自拔ing,今天就水一下好了。记录 2 个小技巧,供以后开发时参考,相信对其他人也有用。 求最大值 一般对数据求最大值我是这么求的: const max = [1, 2, 3, 4, 5].reduce((accu, curr) => accu > curr ? accu : curr); 但是还有更简单完全不需要考虑兼容...

iptables详解之filter

iptables详解之filter iptables令很多小伙伴脑阔疼,下面我们来说说如何使用iptables。 一、iptables格式 1.1、iptables 帮助 通过iptables --help查看一下iptables用法 [root@note1 ~]# iptables --help iptables v1.4.21 Usage: ipta...

Logstash:处理多个input

我们知道Logstash的架构如下:   它的整个pipleline分为三个部分:    input插件:提取数据。 这可以来自日志文件,TCP或UDP侦听器,若干协议特定插件(如syslog或IRC)之一,甚至是排队系统(如Redis,AQMP或Kafka)。 此阶段使用围绕事件来源的元数据标记传入事件。    filter 插件:插件转换并丰富数据 ...

input上传图片并预览

首先说一下input 大家都知道上传文件,图片是通过input 的file进行上传的。 1. 首先是样式 大家都知道input在HTML的代码为 <input type="file">;在页面的样式是不可以更改的,如下图 但是最为一个投机取巧的前端,一切样式都是可以修改的。 效果图如下 代码: <input type="file...

js正则表达式限制文本框只能输入数字,小数点,英文字母

1.文本框只能输入数字代码(小数点也不能输入)<input onkeyup="this.value=this.value.replace(/\D/g,'')" onafterpaste="this.value=this.value.replace(/\D/g,'')"> 2.只能输入数字,能输小数点.<input onkeyup="if...