Background Platform Channels

Implement a way for Platform Channels to execute their host platform handlers on a background thread instead of forcing them to use the platform thread.

Design doc: https://docs.google.com/document/d/1Y-fFKimMxt7xtZcnPmYp4bRgOlVfS5-xOpdcWYfXJug/edit?usp=sharing

Example usage:

public class PluginCodelabPlugin implements FlutterPlugin, MethodCallHandler {
  private MethodChannel methodChannel;
  private BasicMessageChannel<Object> basicChannel;

  private static void setup(PluginCodelabPlugin plugin,
                            BinaryMessenger binaryMessenger) {
    // This is a new call to create the TaskQueue.
    BinaryMessenger.TaskQueue taskQueue = binaryMessenger.makeTaskQueue();
    // The 3rd parameter is new.
    plugin.methodChannel = new MethodChannel(binaryMessenger, "method", taskQueue);
    plugin.methodChannel.setMethodCallHandler(plugin);
    // The 4th parameter is new.
    plugin.basicChannel =
      new BasicMessageChannel<>(binaryMessenger,
                                "basic",
                                StandardMessageCodec.INSTANCE,
                                taskQueue);
    plugin.basicChannel.setMessageHandler((message, reply) -> reply.reply(null));
  }

  @Override
  public void onAttachedToEngine(@NonNull FlutterPluginBinding flutterPluginBinding) {
    setup(this, flutterPluginBinding.getBinaryMessenger());
  }

  @Override
  public void onMethodCall(@NonNull MethodCall call, @NonNull Result result) {
    result.notImplemented();
  }
}