Android 系统禁用触摸屏

需求:设置开关可以打开或者关闭屏幕触摸

实现:
 

1.打开文件

./frameworks/base/core/java/android/view/ViewGroup.java

2.找到 public boolean dispatchTouchEvent(MotionEvent ev) 方法中开头添加如下代码

        if(SystemProperties.get("system.touchevent.disable").equals("1")){
            Slog.e(TAG,"system disable touch event.");
            return true;
        }

3.打包重新烧录,或者adb push out/xxxx/framework/  /system/ 并重启

4.通过

adb shell setprop system.touchevent.disable 1  //使能屏幕触摸

adb shell setprop system.touchevent.disable 0  //关闭屏幕触摸

来使能/关闭屏幕的触摸功能 

猜你喜欢

转载自blog.csdn.net/MilesMatheson/article/details/128096694