feat: enhance background streaming service with foreground handling

- Improved BackgroundStreamingService to manage foreground service notifications more effectively, ensuring compliance with Android requirements.
- Implemented dynamic foreground service type resolution based on microphone permission, enhancing service behavior based on app state.
- Added checks for app foreground status in connectivity management, improving responsiveness to network changes.
- Refactored notification handling to streamline service lifecycle management and improve code maintainability.
This commit is contained in:
cogwheel0
2025-10-09 15:47:27 +05:30
parent 162a5e0781
commit c073d71363
4 changed files with 161 additions and 9 deletions

View File

@@ -85,6 +85,7 @@ class RouterNotifier extends ChangeNotifier {
}
final authState = ref.read(authNavigationStateProvider);
final connectivityService = ref.read(connectivityServiceProvider);
if (location == Routes.serverConnection) {
return authState == AuthNavigationState.authenticated
@@ -102,7 +103,9 @@ class RouterNotifier extends ChangeNotifier {
final shouldShowConnectionIssue =
!reviewerMode &&
connectivity == ConnectivityStatus.offline &&
authState == AuthNavigationState.authenticated;
authState == AuthNavigationState.authenticated &&
connectivityService.isAppForeground &&
!connectivityService.isOfflineSuppressed;
if (shouldShowConnectionIssue) {
return location == Routes.connectionIssue ? null : Routes.connectionIssue;