Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Work Manager on chinese ROMs like Xiaomi and oppo, when under battery optimization, increase the scheduled delay of work by several hours

Work Manager on Chinese ROMs like Xiaomi and Oppo, when under battery optimization, increase the scheduled delay of work by several hours., however, I have noticed some apps are able to have scheduled jobs run quietly flawlessly even under battery optimization. There is one difference I noticed is that they show a notification every time the job runs, so would that be responsible for keeping the app alive by the battery optimizer?

And I also noticed, that after I force stopped that app, after 24 hours it started working again, but how is that possible? Can anyone shed any light on what is going on behind the scenes, and what method they would be using?

Let me know if there are any more details required.

like image 578
Aviharsh Shukla Avatar asked Jan 25 '20 05:01

Aviharsh Shukla


2 Answers

Xiomi MiUi 11 (chinese version of firmware) Work Manager very badly by default and runs in random order several times and after a few hours it just stops working.Further nothing happens. To solve the problem, I took 2 steps

1. Settings->Battery & perfomance -> App battery saver -> Select you application -> No restrictions

2. Settings -> Apps -> Permissions -> Autostart -> Add your application to autostart

After I added to Autostart and No restrictions battery. I rebooted the device and it worked correctly with Work Manager. I think that on Chinese devices that have heavily modified android, it is only possible to manually add launch permissions.

like image 60
Александр Инженер Avatar answered Oct 05 '22 23:10

Александр Инженер


So, turns out the solution to keep the jobs running on time is to enable auto-start and disable battery optimization for the devices. Guiding your users to do so is inconvenient but as of now, this is what can be done!

like image 27
Aviharsh Shukla Avatar answered Oct 05 '22 23:10

Aviharsh Shukla