Class SettingsChannel.ConfigurationQueue
- java.lang.Object
-
- io.flutter.embedding.engine.systemchannels.SettingsChannel.ConfigurationQueue
-
- Enclosing class:
- SettingsChannel
public static class SettingsChannel.ConfigurationQueue extends Object
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
SettingsChanneland 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#applyDimensiondoes 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
Nested Classes Modifier and Type Class Description static classSettingsChannel.ConfigurationQueue.SentConfiguration
-
Constructor Summary
Constructors Constructor Description ConfigurationQueue()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description BasicMessageChannel.ReplyenqueueConfiguration(SettingsChannel.ConfigurationQueue.SentConfiguration config)Adds the most recently sentSettingsChannel.ConfigurationQueue.SentConfigurationto the queue.SettingsChannel.ConfigurationQueue.SentConfigurationgetConfiguration(int configGeneration)Returns theSettingsChannel.ConfigurationQueue.SentConfigurationassociated with the givenconfigGeneration, and removes configurations older than the returned configurations from the queue as they are no longer needed.
-
-
-
Method Detail
-
getConfiguration
public SettingsChannel.ConfigurationQueue.SentConfiguration getConfiguration(int configGeneration)
Returns theSettingsChannel.ConfigurationQueue.SentConfigurationassociated 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.SentConfigurationto the queue.- Returns:
- a
BasicMessageChannel.Replywhosereplymethod must be called when the embedder receives the reply for the sent configuration, to properly clean up older configurations in the queue.
-
-