You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
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.
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
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.
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.