人脸识别门禁一体机链接adb操作

                                                           人脸识别门禁一体机链接adb操作

Today接到一个在面板机调试推流工具的项目,数据线链接上面板机以后输入adb命令是这样子的。设置里打开开发人员选项—打开USB 调试还是不行。

一番尝试后,反编译系统自带的推流工具。在项目里用代码可以实现。将数值写入到系统文件中,这个path不同的Android设备可能不同.

public static final String MODE_DEVICE_HOST_GPIO1 = "/sys/class/gpio/gpio1153/value";
public static final String MODE_DEVICE_HOST_GPIO2 = "/sys/class/gpio/gpio1133/value";
 /**
     * @param i
     * 进入adb调试模式.
     */
    public void deviceModeChange(int i) {
        boolean isHost1 = DevicesUtils.writeSysFileValue(MODE_DEVICE_HOST_GPIO1, String.valueOf(i));
        boolean isHost2 = DevicesUtils.writeSysFileValue(MODE_DEVICE_HOST_GPIO2, String.valueOf(i));
        if (isHost1&&isHost2){
            Toast.makeText(MainActivity.this, "device model", Toast.LENGTH_LONG).show();
        }else{
            Toast.makeText(MainActivity.this, "device model is error", Toast.LENGTH_LONG).show();
        }
    }

写入文件的方法:

public static boolean writeSysFileValue(String path, String value){
        Log.w("yangTest","writeSysFileValue "+path+"  "+value);
        File file;
        boolean success = false;
        file = new File(path);
        FileOutputStream fileOutputStream2 = null;
        try {
            fileOutputStream2 = new FileOutputStream(file);
            fileOutputStream2.write((value + "\n").getBytes());
            fileOutputStream2.flush();
            success = true;
        } catch (IOException e1) {
            e1.printStackTrace();
            success = false;
        }catch (NullPointerException e){
            e.printStackTrace();
        }finally {
            try {
                fileOutputStream2.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return success;
    }

调用方法:

deviceModeChange(0);

猜你喜欢

转载自blog.csdn.net/qq_39792615/article/details/107459037