Search code examples
androidappiumappium-android

How to get network providers name in Appium through Java?


Is there any way to fetch network providers name in Appium through java? I tried below code to add in my script but I am not sure which class or jar to use for TelephonyManager.

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

Solution

  • To get carrier information you can use ADB:

    adb shell dumpsys telephony.registry
    

    To run adb via Appium you have to use mobile-command API:

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

    NOTE: as documentation states you have to start Appium server with --relaxed-security flag