0

我正在使用 Xposed 框架来挂钩方法:“onInterceptTouchEvent” 此代码在后台运行,我正在尝试挂钩我的 Glaxy S4 设备上所有应用程序中的每个触摸手势。

我正在尝试将 MotionEvent 对象的数据写入文件,但是当“com.sec.android.app.launcher”中发生触摸手势时,我收到异常:“打开失败:EACCES(权限被拒绝)”

我尝试使用同步类或在函数上加锁,但没有帮助。

我添加了“uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" 所以这不是问题

另一个问题,为什么 onInterceptTouchEvent somteimes 会出现 onlt ACTION_DOWN?

这是我的代码:

findAndHookMethod("android.view.ViewGroup", lpparam.classLoader, "onInterceptTouchEvent", MotionEvent.class, new XC_MethodHook() {

        @Override
        protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
           MotionEvent motionEvent = (MotionEvent) param.args[0];

           String path =Environment.getExternalStorageDirectory().toString();

           try {
                File file = new File(path);
                file.mkdir();
                path += "/" + filename;
                file = new File(path);
                CSVWriter writer = null;
                FileWriter fw = new FileWriter(path, true);
                writer = new CSVWriter(fw);

                writer.writeNext(new String[]{otionEvent.getEventTime() + "",
                     motionEvent.getRawX() + "",
                     motionEvent.getRawY() + ""
                });

                writer.close();



           } catch (Exception e) {
                Toast.makeText(AndroidAppHelper.currentApplication().getBaseContext(), e.getMessage());

           }

}
4

0 回答 0