如何通过Java获取Appium中的网络提供商名称?

时间:2018-09-14 06:57:34

标签: android appium appium-android

是否可以通过Java获取Appium中的网络提供商名称? 我尝试使用下面的代码在脚本中添加代码,但是我不确定要为TelephonyManager使用哪个类或jar。

TelephonyManager manager = (TelephonyManager)getSystemService(Context.TELEPHONY_SERVICE);
String carrierName = manager.getNetworkOperatorName(); // alphabetic name of current registered operator
return carrierName;

1 个答案:

答案 0 :(得分:0)

get carrier information,您可以使用 ADB

adb shell dumpsys telephony.registry

要通过Appium运行adb,您必须使用 mobile-command API

Object result = driver.executeScript(
    "mobile: shell",
    "dumpsys telephony.registry"
);

注意:如文档所述,您必须使用--relaxed-security标志启动Appium服务器

相关问题