Skip to content

fix: telemetry observers executing on main thread#94

Open
g4rb4g3 wants to merge 1 commit into
masterfrom
bugfix/android-auto-tlm-thread
Open

fix: telemetry observers executing on main thread#94
g4rb4g3 wants to merge 1 commit into
masterfrom
bugfix/android-auto-tlm-thread

Conversation

@g4rb4g3

@g4rb4g3 g4rb4g3 commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

This PR makes sure the callbacks for Android Auto and Android Automotive telemetry data are run on the proper AndroidTelemetryThread thread instead of the main thread.

@github-actions

Copy link
Copy Markdown
Contributor

No significant issues found.

@g4rb4g3

g4rb4g3 commented Jun 24, 2026

Copy link
Copy Markdown
Contributor Author

@claude please review

@claude

claude Bot commented Jun 24, 2026

Copy link
Copy Markdown

Claude finished @g4rb4g3's task in 57s —— View job


Review: Telemetry observers thread fix

  • Gather context and read changed files
  • Analyze the diff for correctness and issues
  • Post review findings

No significant issues found. The fix is correct and clean.

What the PR does: The Android Auto variant was using ContextCompat.getMainExecutor(carContext) to dispatch telemetry callbacks, meaning mModelListener, mEnergyLevelListener, mSpeedListener, and mMileageListener all fired on the main thread. The automotive variant had the same problem — Car.createCar(context) without a handler defaults to the main thread for CarPropertyManager callbacks.

This PR introduces a shared telemetryExecutor in the base TelemetryObserver class that delegates to the existing HandlerThread-backed handler, and wires both subclasses to use it. Both the executor (auto) and the Car.createCar(context, handler) overload (automotive) correctly route callbacks to the "AndroidTelemetryThread" looper, which is already started in the init block before either field is assigned.

Thread safety of telemetryCallbacks is covered by the pre-existing CopyOnWriteArrayList.


@g4rb4g3 g4rb4g3 requested a review from SamuelBrucksch June 24, 2026 16:12
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.

1 participant