ping not working when screen off

Post your questions and help other users.

Moderator: Martin

Post Reply
Frejoh466
Posts: 10
Joined: 30 Apr 2017 18:38

ping not working when screen off

Post by Frejoh466 » 14 Apr 2018 09:56

So I'm trying to test if I have access to internet, so I run ping www.google.com, if false turn on wifi, then turn on mobile.

So what I found out was that the ping command does not work when the screen is black, but once I wake the phone the ping commands work. The phones does have internet access when the screen is off, as I can download a http page.

Is there a fix for this or an other way to test if I have internet access?

Code: Select all

14.04.2018 07:16:45.344 [Get weather] End executing action 'Set Mobile Datanetwork State: On'
14.04.2018 07:16:45.345 [Get weather] Flow continues executing with the next step.
14.04.2018 07:16:45.345 [Get weather] Start executing action 'Set WiFi State: On'
14.04.2018 07:16:45.345 [Get weather] Action 'Set WiFi State: On' enable = true
14.04.2018 07:16:45.353 [Get weather] End executing action 'Set WiFi State: On'
14.04.2018 07:16:45.353 [Get weather] Flow continues executing with the next step.
14.04.2018 07:16:45.353 [Get weather] Start executing action 'Sleep: 20s (keep device awake)'
14.04.2018 07:16:45.354 [Get weather] Action 'Sleep: 20s (keep device awake)' Sleeping for 20s (keep device awake)
14.04.2018 07:17:05.368 [Get weather] End executing action 'Sleep: 20s (keep device awake)'
14.04.2018 07:17:05.370 [Get weather] Flow continues executing with the next step.
14.04.2018 07:17:05.371 [Get weather] Start executing condition 'Host Reachable: ping www.google.com'
14.04.2018 07:17:05.376 [Get weather] Condition 'Host Reachable: ping www.google.com' Executing ping to host 'www.google.com'
14.04.2018 07:17:15.393 Process is still running, ending now
14.04.2018 07:17:15.471 [Get weather] Condition 'Host Reachable: ping www.google.com' Timeout in ping. Treating as unreachable.
14.04.2018 07:17:15.471 [Get weather] End executing condition 'Host Reachable: ping www.google.com' with return value false
14.04.2018 07:17:15.472 [Get weather] Flow continues executing with the next step.
14.04.2018 07:17:15.472 [Get weather] Start executing action 'Set Mobile Datanetwork State: On'
14.04.2018 07:17:15.616 Result: Parcel(00000000    '....')
I'm running a Oneplus 1 on LineageOS 15

User avatar
Desmanto
Posts: 2709
Joined: 21 Jul 2017 17:50

Re: ping not working when screen off

Post by Desmanto » 14 Apr 2018 10:28

At mine it is still pinging after it sleep, LP 5.1. I tried in Bliss with Oreo 8.0, when it lock the device the ping still work (continue to the true branch). Maybe it is something with the sleep policy which suspend Autamagic function. Try to recheck again all permission for Automagic, make sure it is whitelisted from battery optimization and its kind.

You can try alternative using execute command. Other thing you can test is to ping from terminal emulator (other app), and let it ping continuously, lock the phone, wait several seconds and unlock it again to see if all the pings works properly.
Index of Automagic useful thread List of my other useful posts (and others')
Xiaomi Redmi Note 5 (whyred), AOSP Extended v6.7 build 20200310 Official, Android Pie 9.0, Rooted.

Frejoh466
Posts: 10
Joined: 30 Apr 2017 18:38

Re: ping not working when screen off

Post by Frejoh466 » 14 Apr 2018 12:10

Changing ping to host seems to work.

User avatar
digitalstone
Posts: 342
Joined: 21 Oct 2017 12:36
Location: The Netherlands

Re: ping not working when screen off

Post by digitalstone » 14 Apr 2018 13:43

Ping to host works, but not to an external address... that sounds like Automagic is running still.
But your wifi might gets disabled for energy efficiency.

2 things you want to check that i can come up with are:
- Settings ---> Battery Optimization (3-dots upper right)
- Settings ---> Wifi ---> 'settings wheel' ---> "Keep WI-FI" on during sleep"
Phone: LG Nexus 5X (rooted vanilla Android 7.1.2)

Post Reply