Skip to content

feat: add global toggle to turn off background scanning and connection loops#132

Open
Falak-Parmar wants to merge 1 commit into
sameerasw:mainfrom
Falak-Parmar:feature/airsync-active-toggle
Open

feat: add global toggle to turn off background scanning and connection loops#132
Falak-Parmar wants to merge 1 commit into
sameerasw:mainfrom
Falak-Parmar:feature/airsync-active-toggle

Conversation

@Falak-Parmar

Copy link
Copy Markdown

Description

This pull request implements a global AirSync Active toggle feature that allows users to completely turn off the background connection and discovery services, resolving the background scanning behavior discussed in #131.

Key Changes

  1. Persistent Preference: Added an app_enabled preference key (defaulting to true) inside DataStoreManager.kt.
  2. Dashboard UI Toggle:
    • Implemented a two-state dashboard in AirSyncMainScreen.kt.
    • OFF State: Displays a clean, minimal landing layout with the monochrome AirSync logo and a large "Turn On AirSync" button.
    • ON State: Displays the active dashboard, with a clean "AirSync Active" toggle row at the very top of the list for quick access.
  3. Service Management & Safety:
    • Intercepted service starts in ServiceManager.shouldServiceRun() so that background scans/UDP/mDNS do not execute when toggled off.
    • Fixed potential Android OS crashes (ForegroundServiceDidNotStartInTimeException) in AirSyncService.onStartCommand() by ensuring startForeground() is called before stopSelf() in the early-exit guard.
    • Avoided calling startForegroundService() entirely in the service helper if the app is disabled.
  4. Connection Blockers:
    • Added guards inside WebSocketUtil.connect() and WebSocketUtil.requestAutoReconnect() to reject any incoming/outgoing manual or automatic WebSocket connection requests when the setting is toggled off.

References

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature Request] Add a global "AirSync Active" switch to completely stop background scanning and connection loops

1 participant