Android MotionEvent触摸屏幕

129 阅读10分钟

injectTouch

package com.qxtool;

import android.annotation.SuppressLint;
import android.graphics.Point;
import android.hardware.input.InputManager;
import android.os.Process;
import android.os.SystemClock;
import android.view.InputEvent;
import android.view.KeyEvent;
import android.view.MotionEvent;
import android.view.MotionEvent.PointerCoords;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.nio.channels.FileChannel;
import java.nio.channels.FileLock;
import java.util.ArrayList;
import java.util.Arrays;

public class QXToolMain {
    public class BKPoint {
        int id;
        int value;
        int x;
        int y;

        public BKPoint(int arg4, int arg5, int arg6, int arg7) {
            this.id = -1;
            this.value = 0;
            this.x = 0;
            this.y = 0;
            this.id = arg4;
            this.value = arg5;
            this.x = arg6;
            this.y = arg7;
        }

        public BKPoint() {
            this.id = -1;
            this.value = 0;
            this.x = 0;
            this.y = 0;
            this.id = -1;
            this.value = 0;
            this.x = 0;
            this.y = 0;
        }
    }

    public boolean DEBUG_MSG;
    private static final int MAX_TOUCH_POINT = 9;
    private ArrayList<BKPoint> PointerEnable;
    private BKPoint[] curPoints;
    private int fps;
    private Method injectPointerEvent;
    public int[] lastBuf;
    private int lastKeyCode;
    private BKPoint[] lastPoints;
    private long lastTimeStick;
    public int loopIndex;
    private InputManager mInputManager;
    private InputStream m_ReceIn;
    private int orientation;
    private int sConnect;
    private int win_height;
    private int win_width;

    public QXToolMain() {
        super();
        this.DEBUG_MSG = true;
        this.lastPoints = new BKPoint[9];
        this.curPoints = new BKPoint[9];
        this.sConnect = 0;
        this.lastKeyCode = 0;
        this.win_width = 0;
        this.win_height = 0;
        this.orientation = 1;
        this.PointerEnable = new ArrayList();
        this.lastTimeStick = 0;
        this.fps = 0;
        this.injectPointerEvent = null;
        this.mInputManager = null;
        this.lastBuf = null;
        this.loopIndex = 3;
    }

    public int FindKey(int arg4) {
        int v1 = this.PointerEnable.size();
        int v0 = 0;
        while (true) {
            if (v0 >= v1) {
                return -1;
            } else if (this.PointerEnable.get(v0).value != arg4) {
                ++v0;
                continue;
            }
            return v0;
        }
    }

    public void InjectDown(int arg27, int arg28, int arg29) {
        int v23;
        try {
            if (this.FindKey(arg27) >= 0) {
                this.InjectUp(arg27);
            }

            int v11 = this.PointerEnable.size() + 1;
            MotionEvent.PointerProperties[] v12 = new MotionEvent.PointerProperties[v11];

            int v4;
            for (v4 = 0; true; ++v4) {
                int v25 = 1;
                v23 = 0;
                while (v23 < v11 - 1) {
                    if (v4 == this.PointerEnable.get(v23).id) {
                        v25 = 0;
                    } else {
                        ++v23;
                        continue;
                    }
                    break;
                }
                if (v25 != 0) {
                    break;
                }
            }

            BKPoint v2 = new BKPoint(v4, arg27, arg28, arg29);
            this.PointerEnable.add(v4, v2);
            PointerCoords[] v13 = new PointerCoords[v11];
            for (v23 = 0; v23 < v11; ++v23) {
                v12[v23] = new MotionEvent.PointerProperties();
                v12[v23].toolType = MotionEvent.TOOL_TYPE_FINGER;
                v12[v23].id = this.PointerEnable.get(v23).id;
                v13[v23] = new PointerCoords();
                v13[v23].x = ((float) this.PointerEnable.get(v23).x);
                v13[v23].y = ((float) this.PointerEnable.get(v23).y);
            }
//            this.injectEvent(MotionEvent.obtain(SystemClock.uptimeMillis(), SystemClock.uptimeMillis(), MotionEvent.ACTION_DOWN, arg28, arg29, 0));
            int did = DevicesIdUtls.getDevicesId(0x1002);
//            System.out.println("did:"+did);
            if (v11 > 1) {
                this.injectEvent(MotionEvent.obtain(SystemClock.uptimeMillis(), SystemClock.uptimeMillis(), v2.id * 0x100 + 5, v11, v12, v13, 0, 0, 0f, 0f, did, 0, 0x1002, 0));
                return;
            }
            this.injectEvent(MotionEvent.obtain(SystemClock.uptimeMillis(), SystemClock.uptimeMillis(), 0, v11, v12, v13, 0, 0, 0f, 0f, did, 0, 0x1002, 0));
        } catch (Exception v21) {
            v21.printStackTrace();
            System.out.println("Excption InjectDown e=" + v21.getMessage());
        }
    }

    public void InjectMove(int arg22, int arg23, int arg24) {
        try {
            int v20 = this.FindKey(arg22);
            if (v20 >= 0) {
                int v7 = this.PointerEnable.size();
                this.PointerEnable.get(v20).x = arg23;
                this.PointerEnable.get(v20).y = arg24;
                MotionEvent.PointerProperties[] v8 = new MotionEvent.PointerProperties[v7];
                PointerCoords[] v9 = new PointerCoords[v7];
                int v19;
                for (v19 = 0; v19 < v7; ++v19) {
                    v8[v19] = new MotionEvent.PointerProperties();
                    v8[v19].id = this.PointerEnable.get(v19).id;
                    v8[v19].toolType = MotionEvent.TOOL_TYPE_FINGER;
                    v9[v19] = new PointerCoords();
                    v9[v19].x = ((float) this.PointerEnable.get(v19).x);
                    v9[v19].y = ((float) this.PointerEnable.get(v19).y);
                }
                int did = DevicesIdUtls.getDevicesId(0x1002);
//                this.injectEvent(MotionEvent.obtain(SystemClock.uptimeMillis(), SystemClock.uptimeMillis(), MotionEvent.ACTION_MOVE, arg23, arg24, 0));
                this.injectEvent(MotionEvent.obtain(SystemClock.uptimeMillis(), SystemClock.uptimeMillis(), 2, v7, v8, v9, 0, 0, 0f, 0f, did, 0, 0x1002, 0));
            }
        } catch (Exception v17) {
            System.out.println("Excption InjectMove e=" + v17.getMessage());
        }
    }

    public void InjectUp(int arg22) {
        try {
            while (true) {
                int v20 = this.FindKey(arg22);
                if (v20 < 0) {
                    return;
                }

                int v7 = this.PointerEnable.size();
                MotionEvent.PointerProperties[] v8 = new MotionEvent.PointerProperties[v7];
                PointerCoords[] v9 = new PointerCoords[v7];
                int v19;
                for (v19 = 0; v19 < v7; ++v19) {
                    v8[v19] = new MotionEvent.PointerProperties();
                    v8[v19].id = this.PointerEnable.get(v19).id;
                    v8[v19].toolType = MotionEvent.TOOL_TYPE_FINGER;
                    v9[v19] = new PointerCoords();
                    v9[v19].x = ((float) this.PointerEnable.get(v19).x);
                    v9[v19].y = ((float) this.PointerEnable.get(v19).y);
                }
//                this.injectEvent(MotionEvent.obtain(SystemClock.uptimeMillis(), SystemClock.uptimeMillis(), MotionEvent.ACTION_UP, 0, 0, 0));
                int did = DevicesIdUtls.getDevicesId(0x1002);
                if (v7 > 1) {
                    this.injectEvent(MotionEvent.obtain(SystemClock.uptimeMillis(), SystemClock.uptimeMillis(), v20 * 0x100 + 6, v7, v8, v9, 0, 0, 0f, 0f, did, 0, 0x1002, 0));
                } else {
                    this.injectEvent(MotionEvent.obtain(SystemClock.uptimeMillis(), SystemClock.uptimeMillis(), 1, v7, v8, v9, 0, 0, 0f, 0f, did, 0, 0x1002, 0));
                }

                this.PointerEnable.remove(v20);
            }

        } catch (Exception v17) {
            System.out.println("Excption InjectUp e=" + v17.getMessage());
            return;
        }
    }

    public void analyzeOrientation(String arg7) {
        if (arg7.contains("SurfaceOrientation: ")) {
            String[] v2 = arg7.split("\n");
            if (this.DEBUG_MSG) {
                int v1;
                for (v1 = 0; v1 < v2.length; ++v1) {
                    System.out.println("getOrientation=" + v2[v1]);
                }
            }

            if (v2.length > 0) {
                arg7 = v2[v2.length - 1];
            }

            arg7 = arg7.replace("\n", "").replace(" ", "").replace("SurfaceOrientation:", "");
            if (this.DEBUG_MSG) {
                System.out.println("surfaceOrientation:@" + arg7 + "@");
            }

            try {
                this.orientation = Integer.parseInt(arg7);
            } catch (Exception v0) {
                System.out.println("Exception orientation");
            }

            if (!this.DEBUG_MSG) {
                return;
            }

            System.out.println("orientation=" + this.orientation);
        }
    }

    public static String bytesToHexString(byte[] arg6) {
        String v4;
        StringBuilder v2 = new StringBuilder();
        if (arg6 == null || arg6.length <= 0) {
            v4 = null;
        } else {
            int v1;
            for (v1 = 0; v1 < arg6.length; ++v1) {
                String v0 = Integer.toHexString(arg6[v1] & 0xFF);
                if (v0.length() < 2) {
                    v2.append(0);
                }

                v2.append(v0);
                v2.append(",");
            }

            v4 = v2.toString();
        }

        return v4;
    }

    public void doExit() {
        System.out.println("Exit Jar.");
        Process.killProcess(Process.myPid());
    }

    private void doRunDriver() {
        if (this.injectinit()) {
            this.initPoints();
            this.initWinSize();
            if (this.DEBUG_MSG) {
                System.out.println("Flydigi run server");
            }

            if (!this.initLoadSo()) {
                return;
            }

            this.initAndRun();
        }
    }

    public Point getDisplayPosition(int arg4, int arg5, int arg6) {
        Point v0 = new Point();
        if (this.orientation == 1) {
            v0.x = arg6;
            v0.y = this.win_width - arg5;
        } else if (this.orientation == 3) {
            v0.x = this.win_height - arg6;
            v0.y = arg5;
        } else if (this.orientation == 0) {
            v0.x = arg5;
            v0.y = arg6;
        } else if (this.orientation == 2) {
            v0.x = this.win_width - arg5;
            v0.y = this.win_height - arg6;
        }

        return v0;
    }

    public void getOrientation() {
        System.out.println("run start " + System.currentTimeMillis());
        String v0 = this.runShell("dumpsys input | grep SurfaceOrientation\n", "SurfaceOrientation");
        System.out.println("run end   " + System.currentTimeMillis());
        System.out.println("run ps: " + v0);
        this.analyzeOrientation(v0);
    }

    public int getRealKeyCode(int arg7) {
        int v0 = 8;
        int v1 = 7;
        int v3 = 4;
        int v2 = 3;
        if (arg7 != 2) {
            if (arg7 == v2) {
                v0 = 9;
            } else if (arg7 == v3) {
                v0 = 10;
            } else if (arg7 == 5) {
                v0 = 11;
            } else if (arg7 == 6) {
                v0 = 12;
            } else if (arg7 == v1) {
                v0 = 13;
            } else if (arg7 == v0) {
                v0 = 14;
            } else if (arg7 == 9) {
                v0 = 15;
            } else if (arg7 == 10) {
                v0 = 16;
            } else if (arg7 == 11) {
                v0 = v1;
            } else if (arg7 == 12) {
                v0 = 69;
            } else if (arg7 == 15) {
                v0 = 61;
            } else if (arg7 == 16) {
                v0 = 45;
            } else if (arg7 == 17) {
                v0 = 51;
            } else if (arg7 == 18) {
                v0 = 33;
            } else if (arg7 == 19) {
                v0 = 46;
            } else if (arg7 == 20) {
                v0 = 0x30;
            } else if (arg7 == 21) {
                v0 = 53;
            } else if (arg7 == 22) {
                v0 = 49;
            } else if (arg7 == 23) {
                v0 = 37;
            } else if (arg7 == 24) {
                v0 = 43;
            } else if (arg7 == 25) {
                v0 = 44;
            } else if (arg7 == 28) {
                v0 = 66;
            } else if (arg7 == 30) {
                v0 = 29;
            } else if (arg7 == 0x1F) {
                v0 = 0x2F;
            } else if (arg7 == 0x20) {
                v0 = 0x20;
            } else if (arg7 == 33) {
                v0 = 34;
            } else if (arg7 == 34) {
                v0 = 35;
            } else if (arg7 == 35) {
                v0 = 36;
            } else if (arg7 == 36) {
                v0 = 38;
            } else if (arg7 == 37) {
                v0 = 39;
            } else if (arg7 == 38) {
                v0 = 40;
            } else if (arg7 == 39) {
                v0 = 74;
            } else if (arg7 == 40) {
                v0 = 75;
            } else if (arg7 == 41) {
                v0 = 68;
            } else if (arg7 == 43) {
                v0 = 73;
            } else if (arg7 == 44) {
                v0 = 54;
            } else if (arg7 == 45) {
                v0 = 52;
            } else if (arg7 == 46) {
                v0 = 0x1F;
            } else if (arg7 == 0x2F) {
                v0 = 50;
            } else if (arg7 == 0x30) {
                v0 = 30;
            } else if (arg7 == 49) {
                v0 = 42;
            } else if (arg7 == 50) {
                v0 = 41;
            } else if (arg7 == 51) {
                v0 = 55;
            } else if (arg7 == 53) {
                v0 = 76;
            } else if (arg7 == 57) {
                v0 = 62;
            } else if (arg7 == 59) {
                v0 = 0x83;
            } else if (arg7 == 60) {
                v0 = 0x84;
            } else if (arg7 == 61) {
                v0 = 0x85;
            } else if (arg7 == 62) {
                v0 = 0x86;
            } else if (arg7 == 0x3F) {
                v0 = 0x87;
            } else if (arg7 == 0x40) {
                v0 = 0x88;
            } else if (arg7 == 65) {
                v0 = 0x89;
            } else if (arg7 == 66) {
                v0 = 0x8A;
            } else if (arg7 == 67) {
                v0 = 0x8B;
            } else if (arg7 == 68) {
                v0 = 140;
            } else if (arg7 == 87) {
                v0 = 0x8D;
            } else if (arg7 == 88) {
                v0 = 0x8E;
            } else if (arg7 == 89) {
                v0 = 0xD9;
            } else if (arg7 == 92) {
                v0 = 0xD6;
            } else if (arg7 == 94) {
                v0 = 0xD5;
            } else if (arg7 == 99) {
                v0 = 120;
            } else if (arg7 == 102) {
                v0 = v2;
            } else if (arg7 == 110) {
                v0 = 0x7C;
            } else if (arg7 == 0x71) {
                v0 = 91;
            } else if (arg7 == 0x74) {
                v0 = 26;
            } else if (arg7 == 0x7C) {
                v0 = 0xD8;
            } else if (arg7 == 0x85) {
                v0 = 278;
            } else if (arg7 == 0x87) {
                v0 = 279;
            } else if (arg7 == 0x89) {
                v0 = 277;
            } else if (arg7 == 0x8A) {
                v0 = 0x103;
            } else if (arg7 == 0x8B) {
                v0 = 82;
            } else if (arg7 == 0x8E) {
                v0 = 0xDF;
            } else if (arg7 == 0x8F) {
                v0 = 0xE0;
            } else if (arg7 == 0x9E) {
                v0 = v3;
            } else if (arg7 == 0x9F) {
                v0 = 0x7D;
            } else if (arg7 == 0xAC) {
                v0 = v2;
            } else if (arg7 == 0xD4) {
                v0 = 27;
            } else if (arg7 == 0xD9) {
                v0 = 84;
            } else if (arg7 == 0xF0) {
                v0 = 0;
            } else if (arg7 == 355) {
                v0 = 28;
            } else if (arg7 == 358) {
                v0 = 0xA5;
            } else if (arg7 == 377) {
                v0 = 170;
            } else if (arg7 == 397) {
                v0 = 0xD0;
            } else if (arg7 == 411) {
                v0 = 0x79;
            } else if (arg7 == 580) {
                v0 = 0xBB;
            } else {
                v0 = 0;
            }
        }

        return v0;
    }

    public void getWindowSize(String arg12) {
        String v4;
        String[] v5 = arg12.split("\n");
        if (v5.length <= 0) {
            v4 = arg12;
        } else {
            if (v5.length > 1 && !v5[1].equals("")) {
                v4 = v5[1];
//                label_8:
                String[] v3 = v4.substring(v4.indexOf(": ") + 2).split("x");
                if (v3.length == 2) {
                    System.out.println("width :@" + v3[0] + "@");
                    System.out.println("height:@" + v3[1] + "@");
                    try {
                        this.win_width = Integer.parseInt(v3[0]);
                    } catch (Exception v0) {
                        System.out.println("Exception win_width");
                    }

                    try {
                        this.win_height = Integer.parseInt(v3[1]);
                    } catch (Exception v0) {
                        System.out.println("Exception win_height");
                    }

                    if (this.win_width <= this.win_height) {
//                        label_52:
                        System.out.println("wm size:width=" + this.win_width + ",height=" + this.win_height);
                    }

                    int v2 = this.win_height;
                    this.win_height = this.win_width;
                    this.win_width = v2;
                }
                System.out.println("wm size:width=" + this.win_width + ",height=" + this.win_height);

            }
            v4 = v5[0];
        }

//        label_8:
        String[] v3 = v4.substring(v4.indexOf(": ") + 2).split("x");
        if (v3.length == 2) {
            System.out.println("width :@" + v3[0] + "@");
            System.out.println("height:@" + v3[1] + "@");
            try {
                this.win_width = Integer.parseInt(v3[0]);
            } catch (Exception v0) {
                System.out.println("Exception win_width");
            }

            try {
                this.win_height = Integer.parseInt(v3[1]);
            } catch (Exception v0) {
                System.out.println("Exception win_height");
            }

            if (this.win_width <= this.win_height) {
//                label_52:
                System.out.println("wm size:width=" + this.win_width + ",height=" + this.win_height);
            }

            int v2 = this.win_height;
            this.win_height = this.win_width;
            this.win_width = v2;
        }
        System.out.println("wm size:width=" + this.win_width + ",height=" + this.win_height);
    }

    public void initAndRun() {
        System.out.println("Java run start.");
        try {
            keymappingInit();
        } catch (Exception | UnsatisfiedLinkError v0) {
            v0.printStackTrace();
            System.out.println(v0.getMessage());
        }
        System.out.println("keymappingInit end.");
    }

    @SuppressLint("UnsafeDynamicallyLoadedCode")
    private boolean initLoadSo() {
        try {
            System.load("/data/local/tmp/libandtest.so");
        } catch (Exception | UnsatisfiedLinkError v0) {
            v0.printStackTrace();
            System.out.println(v0.getMessage());
        }

        return true;
    }

    public void initPoints() {
        int v0;
        for (v0 = 0; v0 < 9; ++v0) {
            this.lastPoints[v0] = new BKPoint();
            this.curPoints[v0] = new BKPoint();
        }
    }

    private void initWinSize() {
        String v0 = this.runShell("wm size\n", null);
        if (this.DEBUG_MSG) {
            System.out.println("get wm size: " + v0);
        }
        this.getWindowSize(v0);
    }

    public void injectEvent(MotionEvent arg6) {
        arg6.setSource(0x1002);
        boolean b = false;
        try {
            System.out.println("mo:"+arg6.toString());
            b = (boolean) this.injectPointerEvent.invoke(this.mInputManager, arg6, 0);
        } catch (IllegalAccessException e) {
            e.printStackTrace();
            System.out.println("injectEvent(MotionEvent) IllegalAccessException=" + e.getMessage());

        } catch (InvocationTargetException e) {
            e.printStackTrace();
            System.out.println("injectEvent(MotionEvent) InvocationTargetException=" + e.getMessage());
        }
        System.out.println("ret:" + b);
    }

    public void injectEvent(int arg15, int arg16) {
        long v2 = System.currentTimeMillis();
        this.injectEvent(new KeyEvent(v2, v2, arg16, arg15, 0, 0, -1, 0, 0, 0x101));
    }

    public void injectEvent(KeyEvent arg6) {
        int v2 = 2;
        try {
            this.injectPointerEvent.invoke(this.mInputManager, arg6, 0);
        } catch (Exception v1) {
            System.out.println("injectEvent(KeyEvent) exception=" + v1.getMessage());
        }
    }

    public boolean injectinit() {
        if (this.DEBUG_MSG) {
            System.out.println("init inject start");
        }
        try {
            this.mInputManager = (InputManager) Class.forName("android.hardware.input.InputManager").getMethod("getInstance").invoke(null);
        } catch (Exception v1) {
            System.out.println("injectinit exception=" + v1.getMessage());
            return false;
        }

        try {
            this.injectPointerEvent = this.mInputManager.getClass().getMethod("injectInputEvent", InputEvent.class, Integer.TYPE);
        } catch (Exception v1) {
            System.out.println("injectinit exception=" + v1.getMessage());
            return false;
        }

        if (this.DEBUG_MSG) {
            System.out.println("init inject end");
        }

        return true;
    }

    public native void keymappingInit();

    public static void main(String[] arg1) {
        new QXToolMain().run();
    }

    /**
     * @param arg13 3 个一组 最多9组
     *              0 value
     *              1 x
     *              2 y
     *              27 orientation 屏幕方向
     *              28 key
     */
    public void receiveTouchData(int id0,int x0,int y0,int id1,int x1,int y1,int id2,int x2,int y2,int orientation,int key) {
        int v11 = 0xFF00;
        float v10 = 4096f;
        float v9 = 1f;
        synchronized (this) {
            try {
                int arg13[] = new int[10];
                arg13[0] = id0;
                arg13[1] = x0;
                arg13[2] = y0;
//                arg13[3] = id0;
//                arg13[4] = x0+200;
//                arg13[5] = y0+200;
                if (this.lastBuf == null || !Arrays.equals(arg13, this.lastBuf)) {
                    this.lastBuf = arg13;
                    this.loopIndex = 3;
                } else {
                    --this.loopIndex;
                }
                if (this.loopIndex > 0) {
//                    this.orientation = arg13[27] & 0xFF;
                    this.orientation = orientation & 0xFF;
                    int v3;
                    for (v3 = 0; v3 < 3; ++v3) {
                        this.curPoints[v3].value = arg13[v3 * 3];
                        int v0 = arg13[v3 * 3 + 1];
                        int v1 = arg13[v3 * 3 + 2];
                        System.out.println(" "+this.curPoints[v3].value+" x:" + v0 + " y:" + v1);
                        if (this.orientation == 0 || this.orientation == 2) {
                            this.curPoints[v3].x = ((int) ((((float) v0)) * v9 * (((float) this.win_width)) / v10));
                            this.curPoints[v3].y = ((int) ((((float) v1)) * v9 * (((float) this.win_height)) / v10));
                        } else {
//                            this.curPoints[v3].x = ((int) ((((float) v0)) * v9 * (((float) this.win_height)) / v10));
//                            this.curPoints[v3].y = ((int) ((((float) v1)) * v9 * (((float) this.win_width)) / v10));
                            this.curPoints[v3].x = v0;
                            this.curPoints[v3].y = v1;
                        }

                        if (this.curPoints[v3].value != 1 || this.lastPoints[v3].value > 0) {
                            if (this.curPoints[v3].value <= 0 && this.lastPoints[v3].value == 1) {
                                if (this.DEBUG_MSG) {
                                    System.out.println("InjectUp Point[" + v3 + "] x=" + this.curPoints[v3].x + " y=" + this.curPoints[v3].y);
                                }
                                this.InjectUp(v3);
                                this.lastPoints[v3].value = this.curPoints[v3].value;
                                this.lastPoints[v3].x = this.curPoints[v3].x;
                                this.lastPoints[v3].y = this.curPoints[v3].y;
                                continue;
                            }

                            if (this.curPoints[v3].value != 1 || this.lastPoints[v3].value != 1) {
                                this.lastPoints[v3].value = this.curPoints[v3].value;
                                this.lastPoints[v3].x = this.curPoints[v3].x;
                                this.lastPoints[v3].y = this.curPoints[v3].y;
                                continue;
                            }

                            if (this.DEBUG_MSG) {
                                System.out.println("InjectMove Point[" + v3 + "] x=" + this.curPoints[v3].x + " y=" + this.curPoints[v3].y);
                            }

                            if (Math.abs(this.curPoints[v3].x - this.lastPoints[v3].x) < 1 && Math.abs(this.curPoints[v3].y - this.lastPoints[v3].y) < 1) {
                                this.lastPoints[v3].value = this.curPoints[v3].value;
                                this.lastPoints[v3].x = this.curPoints[v3].x;
                                this.lastPoints[v3].y = this.curPoints[v3].y;
                                continue;
                            }
                            this.InjectMove(v3, this.curPoints[v3].x, this.curPoints[v3].y);
                            this.lastPoints[v3].value = this.curPoints[v3].value;
                            this.lastPoints[v3].x = this.curPoints[v3].x;
                            this.lastPoints[v3].y = this.curPoints[v3].y;
                        } else {
                            if (this.DEBUG_MSG) {
                                System.out.println("InjectDown Point[" + v3 + "] x=" + this.curPoints[v3].x + " y=" + this.curPoints[v3].y);
                            }
                            this.InjectDown(v3, this.curPoints[v3].x, this.curPoints[v3].y);
                            this.lastPoints[v3].value = this.curPoints[v3].value;
                            this.lastPoints[v3].x = this.curPoints[v3].x;
                            this.lastPoints[v3].y = this.curPoints[v3].y;
                        }
                    }
//                    int v4 = this.getRealKeyCode(arg13[47] << 8 & v11 | arg13[46] & 0xFF);
//                    int v4 = this.getRealKeyCode(arg13[28]);
                    int v4 = this.getRealKeyCode(key);
                    if (v4 > 0) {
                        if (this.lastKeyCode == 0) {
                            this.injectEvent(v4, 0);
                        }
                    } else if (v4 == 0 && this.lastKeyCode > 0) {
                        this.injectEvent(this.lastKeyCode, 1);
                    }
                    this.lastKeyCode = v4;
                }
            } catch (Throwable v5) {
                System.out.println("Excption receiveTouchData e=" + v5.getMessage());
            }
        }
    }

    public void run() {
        this.doRunDriver();
        if (this.DEBUG_MSG) {
            System.out.println("Flydigi InjectEvent Service start running");
        }
        File v4 = new File("/data/local/tmp/qx_proc.lock");
        if (!v4.exists()) {
            try {
                if (v4.createNewFile()) {
                    if (this.DEBUG_MSG) {
                        System.out.println("Success: create service file lock");
                    }
                }
                if (this.DEBUG_MSG) {
                    System.out.println("Fail: create service file lock");
                }
            } catch (IOException v1) {
                System.out.println("Fail: create service file lock err=" + v1.toString());
            }
        }

        FileOutputStream v5 = null;
        FileChannel v0 = null;
        try {
            v5 = new FileOutputStream(v4);
            v0 = v5.getChannel();
            FileLock v3 = v0.lock();
            if (this.DEBUG_MSG) {
                System.out.println("Release service file lock");
            }
            this.doRunDriver();
            v3.release();
            v0.close();
            v5.close();
        } catch (IOException e) {
            e.printStackTrace();
            if (this.DEBUG_MSG) {
                System.out.println("Flydigi InjectEvent Service stop running");
            }
            if (v0 != null) {
                try {
                    v0.close();
                } catch (IOException e1) {
                    e1.printStackTrace();
                }
            }
            if (v5 != null) {
                try {
                    v5.close();
                } catch (IOException e1) {
                    e1.printStackTrace();
                }
            }
            this.doExit();
        }
    }

    public String runShell(String arg11, String arg12) {
        String v5;
        StringBuilder v6 = new StringBuilder();
        try {
            BufferedReader v0 = new BufferedReader(new InputStreamReader(Runtime.getRuntime().exec(arg11).getInputStream()));
            while ((v5 = v0.readLine()) != null) {
                if (arg12 == null || v5.contains(((CharSequence) arg12))) {
                    v6.append(v5);
                    v6.append("\n");
                }
            }
        } catch (IOException v1) {
            System.out.println("Exception runShell err=" + v1.getMessage());
        }
        return v6.toString();
    }
}