Skip to content

Restart tracking after a reboot or an app update - #159

Merged
dzid26 merged 1 commit into
mainfrom
work/auto-start
Oct 8, 2026
Merged

dzid26 merged 1 commit into
mainfrom
work/auto-start

Conversation

@dzid26

@dzid26 dzid26 commented Oct 8, 2026

Copy link
Copy Markdown
Collaborator

Summary

Tracking only started when the app was opened, so a reboot or an update left it off until then. This adds a manifest-declared receiver for BOOT_COMPLETED and MY_PACKAGE_REPLACED (plus RECEIVE_BOOT_COMPLETED). There is no issue for this; the owner approved it directly on 2026-10-08.

The receiver starts BleTrackingService through the existing BleTrackingService.start(context) only when all of these hold:

  • tracking is enabled (the preference the controller reads, via BleControllerHolder.get(context).state);
  • at least one car is paired (Vehicle.isPaired; the controller already drops key slots with no stored key on load);
  • the Bluetooth runtime permissions and, on API 33+, POST_NOTIFICATIONS are still granted.

Otherwise it does nothing. The decision is a pure function, shouldAutoStartTracking. It deliberately does not use shouldTrack(), which needs a READY connection. TeslaBleController.kt is untouched (#158). The service's onStartCommand already calls ensureConnected(), so no connection logic is duplicated. BleTrackingService.start already caught IllegalStateException (covers ForegroundServiceStartNotAllowedException); it now logs the exception class name, with no VIN or key, instead of swallowing it silently.

The README gains a short note: tracking resumes after a reboot or update; some phones (Xiaomi, Huawei, Oppo/Vivo, Samsung "sleeping apps") need autostart allowed or battery set to unrestricted; after a force stop nothing restarts until the app is opened. The master plan has a new checked line.

Type

  • Bug fix
  • Feature
  • Protocol / crypto change
  • Docs / CI / tooling
  • Refactor (no behavior change)

Testing

  • ./gradlew :core:test :app:assembleDebug :app:testDebugUnitTest :app:lintDebug ktlintCheck detekt pass locally.
  • New AutoStartTest covers the start decision (all conditions true; each one false in turn).
  • Not verified: the receiver itself on a device or emulator (no device here), nor OEM autostart behavior.

Manual check for the owner:

  1. Pair a car with tracking on, reboot the phone, unlock it. The tracking notification should appear without opening the app.
  2. With the app installed and tracking on, run adb install -r app-debug.apk. The notification should come back without opening the app.
  3. Optional negatives: with tracking switched off, no notification after reboot; after "Force stop" in system settings, nothing restarts until the app is opened.

Checklist

  • Protocol changes ship test vectors; expected.txt regenerated, not hand-edited (n/a, no protocol change)
  • No VINs, keys, or decrypted payloads in logs
  • Docs/master-plan updated where relevant
  • New source files carry SPDX-License-Identifier: AGPL-3.0-only

🤖 Generated with Claude Code

https://claude.ai/code/session_0129RzhbEE2cboMcYyZMuxqX


Generated by Claude Code

Add a BOOT_COMPLETED / MY_PACKAGE_REPLACED receiver that starts the
tracking service when tracking is on, a car is paired and the Bluetooth
and notification permissions are still granted. It reuses
BleTrackingService.start, which reconnects the paired cars; a refused
start is now logged (no VIN or key).

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0129RzhbEE2cboMcYyZMuxqX
@github-actions

github-actions Bot commented Oct 8, 2026

Copy link
Copy Markdown
Contributor

Screenshots

App screenshots: light and dark

Captured from the demo build at 807473b.

Debug APK: zip from Android CI (GitHub sign-in needed)

@dzid26
dzid26 merged commit 9190a2f into main Oct 8, 2026
5 checks passed
@dzid26
dzid26 deleted the work/auto-start branch October 8, 2026 22:40
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.

2 participants