feat: enhance background streaming functionality with improved wake lock management

- Updated the wake lock duration in BackgroundStreamingHandler to 3 hours, ensuring the service remains active for longer periods.
- Modified the keepAlive method to support both iOS and Android, allowing for better background task management across platforms.
- Implemented a periodic keep-alive timer in VoiceCallService to refresh the wake lock every 5 minutes, enhancing service reliability during voice calls.
- Added debug logging for successful keep-alive invocations, improving traceability of background operations.
This commit is contained in:
cogwheel0
2025-10-10 19:59:17 +05:30
parent 86892d21c8
commit 4eb1191748
3 changed files with 26 additions and 4 deletions

View File

@@ -169,12 +169,16 @@ class BackgroundStreamingHandler {
return _streamStates[streamId];
}
/// Keep alive the background task (iOS only)
/// Keep alive the background task
///
/// On iOS: Refreshes background task to prevent early termination
/// On Android: Refreshes wake lock to keep service running
Future<void> keepAlive() async {
if (!Platform.isIOS) return;
if (!Platform.isIOS && !Platform.isAndroid) return;
try {
await _channel.invokeMethod('keepAlive');
DebugLogger.stream('keepalive-success', scope: 'background');
} catch (e) {
DebugLogger.error('keepalive-failed', scope: 'background', error: e);
}