tidevice 的版本默认安装是0.6.12版本,agent 在执行时,获取到的 udid 异常,导致无法正确获取到对应的 udid,日志如下所示: 界面上展示的信息如下: 调试时发现由于 udid 是根据 tidevice list 获取到的结果取空格获取,但是高版本的 tidevice 空格数不一致,导致获取 udid 时将设备的名称也截取到了部分作为了 udid 值,从而出现该问题。 这里对获取 udid 做了修改,修改方式如下: public static Set<String> getRealDeviceList(boolean showLog) { String cmd = "tidevice list --json"; try { String cmdResponse = Terminal.execute(cmd, showLog); if (!StringUtils.hasText(cmdResponse)) { return new HashSet<>(); } // 处理返回的 json 数组,取出里面的 udid return JsonUtil.getAttributeSetForJsonString(cmdResponse, "udid"); } catch (IOException e) { logger.error("execute '{}' err", cmd, e); return new HashSet<>(); } } 也就是根据 json 结构去获取 udid 字段的值,处理过后,能够正确获取到 udid 的值,不再出现 udid 获取异常的问题。 同样的,属性和名称也因为空格问题导致获取不到,这里也做了修改,如下: public static String getModel(String mobileId) throws IOException { return Terminal.execute("tidevice -u "+ mobileId + " info -k ProductType").replace("'", ""); } 最后正常获取到的手机信息是这样的: 点击立即使用时,可以正常使用设备。
public static Set<String> getRealDeviceList(boolean showLog) { String cmd = "tidevice list --json"; try { String cmdResponse = Terminal.execute(cmd, showLog); if (!StringUtils.hasText(cmdResponse)) { return new HashSet<>(); } // 处理返回的 json 数组,取出里面的 udid return JsonUtil.getAttributeSetForJsonString(cmdResponse, "udid"); } catch (IOException e) { logger.error("execute '{}' err", cmd, e); return new HashSet<>(); } }
public static String getModel(String mobileId) throws IOException { return Terminal.execute("tidevice -u "+ mobileId + " info -k ProductType").replace("'", ""); }
Shirly 的确是,我之前是tidevice0.5.6版本,最近安装了新版本0.6.13,远控就无法识别了。退回旧版本就可以了。
不错,我都不知道新版tidevice有这个东西,不过新版Sonic已经弃用tidevice了,感谢分享
Eason 那太好了,不用因为 tidevice 版本问题出现各种奇葩问题了
Shirly v1.3.2开始弃用的,不过sib我还在优化中