调试步骤

  1. android打开调试命令

    val p = Runtime.getRuntime().exec("su");
    val outpustStream = DataOutputStream(p.outputStream)
    outpustStream.writeBytes("setprop persist.internet.adb.enable 1\n");   //  1: 启用adb  0:禁用adb
    outpustStream.writeBytes("exit\n");
    outpustStream.flush();
    
    text = try {
        p.waitFor()
        if (p.exitValue() != 255) {
            "ok"
        } else {
            "process exit value is: ${p.exitValue()}"
        }
    } catch (e: IOException) {
        "process waitfor exception: $e"
    }
    
  2. 使用adb通过usb网络连接设备

    adb connect [设备IP地址] 
    
  3. QtScrcpy连接设备屏幕

参考文档