1

Maybe the question should be - "how to keep the CPU awake with screen off", but I'm not sure yet, here's why:

I'm trying to use my android device as a DLNA player, that streams music to a DLNA renderer. The problem is that the playback keeps stopping with the screen off, using apps like n7player and doubleTwist music player. Logically, these apps should keep the CPU awake when the music is playing, but if they don't, I have tried the following to keep the CPU awake:

  • Disabling battery optimizations on these apps;
  • an Automate script without the "keep screen on" option;
  • This command - echo mylockname >/sys/power/wake_lock;

But these solutions didn't solve my problem, the playback keeps stopping after awhile, when the screen turns off. If the screen is kept on, by using the caffeine function for example, there are no issues, but I would like to keep the screen off to save some battery and maybe prolong the life of the device.

So if the solutions I have mentioned really keep the CPU awake, maybe there is something else that these players need to keep the playback going.

Update: Screen backlight off app - this seems like the most promising approach and maybe works on some devices as expected, but not on mine (Samsung SM-T585 tablet). It should turn off the screen backlight and it does so by setting the brightness level to 0. Maybe some devices completely turn off the backlight in this case, but my tablet keeps emmiting very low light. So if anyone knows a way to completely turn off the backlight - please let me know.

2

So, the only way I have found yet, to stream music to a DLNA device with screen off, using these apps, is to disable Doze mode by using this command in terminal:

dumpsys deviceidle disable

followed by dumpsys deviceidle enable when I no longer need streaming.

Now just need to find the way to automate this with tasker.

  • +1 for self answering :). – beeshyams Nov 29 '18 at 7:29
  • Thanks, but less aggressive and more automated solutions are still highly welcome :) – mnd Nov 29 '18 at 7:36
  • Automation can be achieved IMO. You can ask a separate question linking this as background but "less aggressive", I am not sure – beeshyams Nov 29 '18 at 8:22
  • 1
    In Tasker, you would need root access. The task would be Code, Run Shell, Command: your command, tick Use Root. Assign the task to a profile and enjoy. – Firelord Nov 29 '18 at 8:59
  • The task - yes. But I'm not sure what profile to create, that would be the trigger for enabling Doze again. I was testing with Autotools plugin, which has a variable that shows if music is playing at the moment (%atmusicplaying). Funny thing is that it is set to "true", only when the music is playing on the device. But if music is output through dlna, the variable stays false, even though the player is playing music and in its notification the "play" button changes to "pause" and so on. – mnd Nov 29 '18 at 13:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.