feat: disable screen wake lock on Android
CI / format (push) Has been cancelled
CI / test (push) Has been cancelled
CI / packaging (push) Has been cancelled

This commit is contained in:
Tien Do Nam
2026-07-26 02:44:34 +02:00
parent 8296237a6b
commit dae4f261b1
+8
View File
@@ -62,12 +62,17 @@ class _ProgressPageState extends State<ProgressPage> with Refena {
bool _advanced = false;
/// On Android the foreground service keeps the process and the connection alive,
/// so there is no reason to also keep the screen on.
bool get _useWakelock => checkPlatformIsNot([TargetPlatform.android]);
@override
void initState() {
super.initState();
// init
WidgetsBinding.instance.addPostFrameCallback((_) {
if (_useWakelock) {
try {
unawaited(WakelockPlus.enable());
} catch (_) {}
@@ -89,6 +94,7 @@ class _ProgressPageState extends State<ProgressPage> with Refena {
} catch (_) {}
}
});
}
if (ref.read(settingsProvider).autoFinish) {
_finishTimer = Timer.periodic(const Duration(seconds: 1), (timer) {
@@ -174,10 +180,12 @@ class _ProgressPageState extends State<ProgressPage> with Refena {
_finishTimer?.cancel();
_wakelockPlusTimer?.cancel();
TaskbarHelper.clearProgressBar(); // ignore: discarded_futures
if (_useWakelock) {
try {
WakelockPlus.disable(); // ignore: discarded_futures
} catch (_) {}
}
}
@override
Widget build(BuildContext context) {