3

How do I keep my WiFi running when my phone's screen is off and locked?

Facts:

  1. The biggest battery drain is my screen usage
  2. WiFi uses your battery, but not nearly as badly as the screen
  3. I use my phone to stream audio
  4. I intentionally turn off my phone's screen to save my phone's battery
  5. If I'm playing a local file that I previously downloaded, then I have no issues with the audio stopping when my screen is off.
  6. If I'm streaming audio, then sometime after I turn off my phone's screen, the audio streaming stops (I guess after it locks and the the stream buffer is empty)
  7. Immediately after I wake my screen, the audio stream resumes. Unlocking the phone is not necessary to resume the audio stream.

I assume, therefore, that my phone is disabling my WiFi sometime after my handset's screen is turned off.

I am running LineageOS 18 (Android 11).

How do I prevent my android device from disabling my WiFi when the screen is off?

2
  • Have you tried to disable battery optimization for the used streaming app? Is your screen LCD or OLED? For LCD reducing the brightness to a minimum can be a workaround (but restoring brightness can get a little difficult depending on the environment brightness). For OLED try to use an app that shows a black screen only and that keeps the phone awake.
    – Robert
    Sep 14, 2021 at 18:35
  • see also stackoverflow.com/questions/50115053/… Sep 25, 2021 at 15:46

3 Answers 3

1

To accomplish what you want, you can install the app Fake Standby. It is a free open-source application.

Fake Standby will turn off your screen while keeping apps running. This will allow you to listen to audio (podcasts, for example) without draining your battery so much.

I've used it many times, and it has worked well for me.

2
  • 2
    Technically, this app uses black, full-screen overlay, which is what Robert suggested in the comment.
    – Andrew T.
    Sep 15, 2021 at 7:05
  • Does this prevent your phone from locking? For security reasons, I do not want to use an app that is going to prevent my screen from locking. And also, I see a lot of unnecessary risk in allowing an app to draw over other apps (though I do appreciate that it's open source). Sep 19, 2021 at 12:18
1

I know of no way to disable doze as the admin of the OS (Android) itself

(but please comment on this if there's some way to do it with Xposed or similar)

From the app (developer) itself

The Google documentation on MediaPlayer specifically tell developers to use WifiLock to prevent wifi from being disabled if the app streams media

If you are streaming media over the network and you are using Wi-Fi, you probably want to hold a WifiLock as well, which you must acquire and release manually.

source: https://developer.android.com/guide/topics/media/mediaplayer

The Google documentation on WifiLock can be found here:

Battery Optimization

You can disalbe "Battery Optimization" on a per-app basis by going to your Android Settings -> Apps & notifications -> Special app access -> Battery optimization.

From the drop-down at the top, choose All apps

Scroll-down to the app that you're having issues with. Click it, and choose Don't optimize

Intermediary (eg network stack) apps

In my case I found that the issue was actually not the app itself, but an intermediary network app that wasn't doing the WifiLock. In my case it was the OpenVPN for Android app.

The solution was to open OpenVPN for Android, go to Settings and uncheck Pause VPN connection after screen off

Now my audio stream doesn't cut-off shortly after the screen locks.

0

Head away to the battery section in Lineage OS settings and disable power manager.

If that doesn't work, something is wrong either with your vendor or the kernel.

Also keep in mind that while asking device specific questions, it's highly recommended to include basic information such as your device model, vendor info (ie using stock vendor or not etc), state of boot image etc. If not everything, atleast provide the device model

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .