Package io.flutter.embedding.engine.systemchannels

# 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 `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

  Nested Classes
  Modifier and Type
  Class
  Description
  `static class`
  `SettingsChannel.ConfigurationQueue.SentConfiguration`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `ConfigurationQueue()`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `BasicMessageChannel.Reply`
  `enqueueConfiguration(SettingsChannel.ConfigurationQueue.SentConfiguration config)`
  Adds the most recently sent `SettingsChannel.ConfigurationQueue.SentConfiguration` to the queue.
  `SettingsChannel.ConfigurationQueue.SentConfiguration`
  `getConfiguration(int configGeneration)`
  Returns the `SettingsChannel.ConfigurationQueue.SentConfiguration` associated with the given `configGeneration`, and removes configurations older than the returned configurations from the queue as they are no longer needed.

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Constructor Details

  - ### ConfigurationQueue

    public ConfigurationQueue()

- ## Method Details

  - ### getConfiguration

    public SettingsChannel.ConfigurationQueue.SentConfiguration getConfiguration(int configGeneration)
    Returns the `SettingsChannel.ConfigurationQueue.SentConfiguration` associated with the given `configGeneration`, 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 sent `SettingsChannel.ConfigurationQueue.SentConfiguration` to the queue.
    Returns:
      a `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.