Flutter Engine
The Flutter Engine
|
Classes | |
class | SentConfiguration |
Public Member Functions | |
SentConfiguration | getConfiguration (int configGeneration) |
BasicMessageChannel.Reply | enqueueConfiguration (SentConfiguration config) |
A FIFO queue that maintains generations of configurations that are potentially used by the Flutter application.
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.
Definition at line 175 of file SettingsChannel.java.
|
inline |
Adds the most recently sent SentConfiguration
to the queue.
BasicMessageChannel.Reply
whose reply
method must be called when the embedder receives the reply for the sent configuration, to properly clean up older configurations in the queue. Definition at line 233 of file SettingsChannel.java.
|
inline |
Returns the SentConfiguration
associated with the given configGeneration
, and removes configurations older than the returned configurations from the queue as they are no longer needed.
Definition at line 191 of file SettingsChannel.java.