Class SettingsChannel.ConfigurationQueue
- Enclosing class:
- SettingsChannel
Platform configurations needed by the Flutter app (for example, text scale factor) are retrived on the platform thread, serialized and sent to the Flutter application running on the Flutter UI thread. However, configurations exposed as functions that take parameters are typically not serializable. To allow the Flutter app to access these configurations, one possible solution is to create dart bindings that allow the Flutter framework to invoke these functions via JNI synchronously. To ensure the serialized configuration and these functions represent the same set of configurations at any given time, a "generation" id is used in these synchronous calls, to keep them consistent with the serialized configuration that the Flutter app most recently received and is currently using.
A unique generation identifier is generated by the SettingsChannel
and associated
with a configuration when it sends a serialized configuration to the Flutter framework. This
queue keeps different generations of configurations that could be used by the Flutter
framework, and cleans up old configurations that the Flutter framework no longer uses. When the
Flutter framework invokes a function to access the configuration with a generation identifier,
this queue finds the configuration with that identifier and also cleans up configurations that
are no longer needed.
This mechanism is only needed because TypedValue#applyDimension
does not take the
current text scale factor as an input. Once the AndroidX API that allows us to query the scaled
font size with a pure function is available, we can scrap this class and make the
implementation much simpler.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionAdds the most recently sentSettingsChannel.ConfigurationQueue.SentConfiguration
to the queue.getConfiguration
(int configGeneration) Returns theSettingsChannel.ConfigurationQueue.SentConfiguration
associated with the givenconfigGeneration
, and removes configurations older than the returned configurations from the queue as they are no longer needed.
-
Constructor Details
-
ConfigurationQueue
public ConfigurationQueue()
-
-
Method Details
-
getConfiguration
Returns theSettingsChannel.ConfigurationQueue.SentConfiguration
associated with the givenconfigGeneration
, and removes configurations older than the returned configurations from the queue as they are no longer needed. -
enqueueConfiguration
@UiThread @Nullable public BasicMessageChannel.Reply enqueueConfiguration(SettingsChannel.ConfigurationQueue.SentConfiguration config) Adds the most recently sentSettingsChannel.ConfigurationQueue.SentConfiguration
to the queue.- Returns:
- a
BasicMessageChannel.Reply
whosereply
method must be called when the embedder receives the reply for the sent configuration, to properly clean up older configurations in the queue.
-