General: Pick the right monitor mode automatically#591
Merged
Conversation
- Seed connectedDevices flow with onStart so ALWAYS autolaunch fires before HEADSET profile binds - Gate UnavailableMissingPermission classification on Android 12+ (BLUETOOTH_CONNECT only exists from API 31) - Treat blank/empty profile.address as unpaired (matches AutoConnect) - Subscribe DeviceSettingsViewModel to nudgeCapabilityStore.availability so UI updates immediately on verdict change - Seed availability StateFlow with the persisted value via valueBlocking to close the cold-start race
Consolidate the nudge availability DataStoreValue with the rest of the persisted settings instead of carrying it in a separate Hilt module + DataStore file. Matches the existing convention where compat-style flags (offloaded filtering, indirect callbacks, etc.) live alongside theme/notification settings. NudgeCapabilityStore keeps the verdict-mapping behavior; only the source of the persisted value changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changed
The "Monitor mode" setting in General Settings has been removed. The app now picks the right mode automatically based on your profile setup — no more guessing whether to use "When app is open", "When device is connected", or "Always".
The choice was always opaque: the right answer depended on whether your profile had a paired device, whether auto-connect was enabled, and whether the BluetoothHeadset reflection trick still works on your Android version. Most users had no way to know which to pick.
Technical Context
MANUAL; paired + no auto-connect →AUTOMATIC; paired + auto-connect + nudge available/unknown →ALWAYS; paired + auto-connect + nudge known broken →AUTOMATIC.AutoConnectonly ever targets the primary device, so a secondary profile'sautoConnectsetting can't actually fire — demandingALWAYSfor it would be wasted scanning.UNKNOWN/AVAILABLE/BROKEN) persisted in a newNudgeCapabilityStore.UNKNOWNis treated as "assume available" so we get one shot to learn whether nudge works on the device. This replaces the old_isNudgeAvailable: Boolean = truefield that reset every process restart, burning battery inALWAYSmode until the next failed attempt.nudgeConnection()now returns a typedNudgeAttemptResultdiscriminating success, rejection, missing-permission failures (transient — don't persistBROKEN), and hidden-API failures (persistent). Previously a missingBLUETOOTH_CONNECTwould have permanently disabled auto-connect.OverviewViewModel.workerAutolaunchis now reactive to mode changes. It used to only re-evaluate whenmissingScanPermissionsemitted, so a transitionAUTOMATIC → ALWAYS(e.g. after enabling auto-connect) wouldn't actually start the monitor. The newcombine(...)of permissions + effective mode + connected devices fixes that.DeviceSettingsViewModelno longer imperatively forcesALWAYSwhenautoConnectis toggled on. The resolver derives that from profile state, which means togglingautoConnectoff again now properly relaxes back toAUTOMATIC— previously the bump was sticky.core.monitor.modeDataStore key on existing installs is silently ignored (Preferences DataStore tolerates orphan keys). No active migration needed.