The (Android) app we're working on is depended on it's plugged-in (AC) status.
Because we want to run the app on a real device connected to our buildserver we need a way to fake this behaviour in order to fully test the app without actually removing the device from power.
Now I've learned about adb shell dumpsys battery ac 0|1
which allowed me to set it.
But I was unable to get this working during the test itself with:
Process.run('adb', [
'shell',
'dumpsys',
'battery',
'set',
'ac',
'1',
]);
This results in the following error:
══╡ EXCEPTION CAUGHT BY FLUTTER TEST FRAMEWORK ╞═════════════════
The following ProcessException was thrown running a test:
Permission denied
Command: adb shell dumpsys battery set ac 1
I also tried it with sudo
, but that resulted in the same.