I have to test how my app behaves in doze mode. According to the documentation, I first must make the device think it's unplugged by entering the following command in the terminal:
$ adb shell dumpsys battery unplug
However, nothing happens and it logs:
Can't find service: battery
What should I do?
There is no battery service as the log points out (this may be device specific).
Enter the following command to find existing battery related services:
it will result in something like this
It makes sense that to manage the battery, you should use the batterymanager.
outputs (in case the usb charged is plugged)
then, when you type
and run the previous command again, it outputs
Which validates that you should use the batterymanager service instead of battery.