9157654
- 发布:2023-03-31 10:46
- 更新:2023-03-31 11:22
- 阅读:521
提供一个思路,开发uts插件判断本机是否开启了adb,示例如下:
public static hasADB(): boolean {
let cmd = arrayOf<string>("/bin/sh", "-c", "getprop | grep init.svc.adbd");
let exec = Runtime.getRuntime().exec(cmd);
let bufferedReader = new BufferedReader(new InputStreamReader(exec.getInputStream(), "utf-8"));
let tmp = new CharArray(1024);
let result = false;
do {
let len = bufferedReader.read(tmp);
if (len == -1) {
break;
}
let res = new String(tmp, 0, len);
result = res.includes("running");
} while (true)
exec.getInputStream().close();
bufferedReader.close();
return result;
}
9157654 (作者)
那像 IOS 16 添加了开发者模式这个用什么去判断呢
2023-03-31 11:30
DCloud_App_Array
回复 9157654: iOS平台还没做,应该也是可以使用uts插件实现
2023-03-31 11:47
9157654 (作者)
回复 DCloud_App_Array: 这是属于API插件了是吧
2023-03-31 11:54
DCloud_App_Array
回复 9157654: 是的,参考文档:https://uniapp.dcloud.net.cn/plugin/uts-plugin.html
2023-03-31 11:56