feat(tracker): resilient user-session restart + previous-exit classification#222
Draft
adsamcik wants to merge 1 commit into
Draft
feat(tracker): resilient user-session restart + previous-exit classification#222adsamcik wants to merge 1 commit into
adsamcik wants to merge 1 commit into
Conversation
…ication - TrackerService: return START_REDELIVER_INTENT (was START_STICKY) for user-initiated sessions so Android re-delivers the original start intent (carrying ARG_IS_USER_INITIATED) after a system kill, instead of a null intent that forces in-memory fallback recovery. - Application: classify the previous process exit via ApplicationExitInfo (API 30+) and log abnormal terminations (LOW_MEMORY/SIGNALED/CRASH/ANR) vs normal ones. Foundation for crash-informed recovery and for respecting user-requested force-stops. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This was referenced Jun 25, 2026
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.
Summary
Process-death resilience follow-ups from the tracking-architecture review (P0). Two focused, low-risk changes.
1.
START_REDELIVER_INTENTfor user sessionsOn
dev/v10,TrackerServicereturnsSTART_STICKYfor user-initiated sessions. After a system kill,START_STICKYre-creates the service with a null intent, so the originalARG_IS_USER_INITIATEDflag is lost and the code must fall back to in-memory recovery (sessionInfo/controller.sessionInfoFlow), which is gone after a full process kill.Switching to
START_REDELIVER_INTENTmakes Android re-deliver the original start intent (with its extras) on restart, so the session resumes with the correct flags. This is the pattern OsmAnd'sNavigationServiceuses. Auto-tracking sessions remainSTART_NOT_STICKY(re-triggered byActivityWatcherService).2.
ApplicationExitInfoprevious-exit classificationApplicationnow queriesActivityManager.getHistoricalProcessExitReasons()(API 30+) at startup and logs the previous exit reason, distinguishing abnormal terminations (LOW_MEMORY / SIGNALED / CRASH / CRASH_NATIVE / ANR) from normal ones (USER_REQUESTED, USER_STOPPED, OTHER). Defensive try/catch (some OEM builds throw).This makes OEM/low-memory kills observable in crash reports and is the foundation for:
Verification
./gradlew :app:compileDebugKotlin— BUILD SUCCESSFUL.Follow-up (filed separately)
The heavier P0 item — a durable active-session descriptor + an
onTaskRemoved/onDestroyrestart watchdog (GPSLoggerRestarterReceiverpattern) + wiringApplicationExitInfointo an automatic WAL-drain worker — is tracked as a separate issue because it needs on-device validation (restart-loop / battery safety) that can't be done from a compile check.Notes
Draft — opened for review.