Enable/Disable data network not working

Hello,

I am trying to turn off my data network with the io.appium.settings/.Settings app and it doesn’t seem to work. (wifi interaction commands work perfectly).

The command suggested on GitHub starts the app, it prompts the correct message (Enabling / Disabling data connection), but it does not do anything (data network status remains unchanged).

The command I am trying to run is: adb shell am start -n io.appium.settings/.Settings -e data off

All the devices I tried it on are 4.4 + and the io.appium.settings app is the one that Appium pushes to the device. Also, my OS is Windows.

What am I doing wrong? :confused:

Thanks,
Sealview

Same with me tried on 4.2+ devices code work fine but it is not enabling n disabling data network
tried on window platform with appium 1.2.4.1

It’s not working for me either. I’m using a MacOS box and Appium 1.3.5.

Out of curiosity, how is airplane mode working for you with this command? Looking through the source code, I see only wifi and data services.

1 Like

How can we get adb commands ?
Could you please tell me…!!! Thank you in advance.

I meant using the same command as Appium framework does , the .Settings app only controls WiFi and Data, but appium also provides solution to interact with airplane mode, but not through this app. Perhaps I should edit the post since it is related to the .Settings app.

adb shell settings put global airplane_mode_on 0
adb shell am broadcast -a android.intent.action.AIRPLANE_MODE --ez state false

Bhaskar,

Are you asking which adb commands to use, which Sealview answered below, or how to access adb commands at all?

Yes @willosser ,Thanks for your reply. Let me know “how to access adb commands at all?”

Thanking you in advance.!!!

You can get access to adb through any normal shell/system access. In Ruby it would be as simple as

adb_output = adb shell #{command}

Access to adb is limited in Appium so that Grid Providers can support Appium and not worry about customers trashing their devices. On our project, we have created an adb class that provides limited access to adb command we expect will eventually be integrated into Appium.

Have you opened up an issue on github?

Hey, yes, I just did.

This command is working fine for me:

adb shell am start -n io.appium.settings/.Settings -e data off/on

1 Like

What do you mean “worked” ? Did it disable / enable data connection? Or did it just start the .Settings acticity and prompted a message about data connection?

Hi @Sealview ,

For Enabling data Connection : adb shell am start -n io.appium.settings/.Settings -e data on
& for Disabling : adb shell am start -n io.appium.settings/.Settings -e data off .

I got a message in my mobile stating that, enabling data connection, and then it turn on mobile data. I have checked it , it works fine.

What version of Appium are you using? I’m on 1.3.5. I see the appium settings window appear and go away, but when I check mobile data in settings, it remains unchanged.

This does not works for me also.

Sony Xperia running on 4.4.2.

Is https://github.com/appium/io.appium.settings being updated?

I believe this is an Android problem. I dug into the Appium code and tried to use the underlying Android calls, and those didn’t work reliably.

yeah, probably. Thats why I asked about the project status because there might be others way to achieve same result.

Actually was just able to do it with old

((AndroidDriver)Drivers.getDriver(device)).setNetworkConnection(new NetworkConnectionSetting(false, true, false));
1 Like

adb shell am start -n io.appium.settings/.Settings -e wifi off/on

This is working for disabling enabling wifi. Thanks.

Could you tell us what device and what version of Android you tested this on?

I am testing on Android v5.0. (Machine OS: Windows 7)