Package io.flutter.embedding.engine

# Class FlutterJNI

java.lang.Object
io.flutter.embedding.engine.FlutterJNI

public class FlutterJNI extends Object
Interface between Flutter embedding's Java code and Flutter engine's C/C++ code.

Flutter's engine is built with C/C++. The Android Flutter embedding is responsible for coordinating Android OS events and app user interactions with the C/C++ engine. Such coordination requires messaging from an Android app in Java code to the C/C++ engine code. This communication requires a JNI (Java Native Interface) API to cross the Java/native boundary.

The entirety of Flutter's JNI API is codified in `FlutterJNI`. There are multiple reasons that all such calls are centralized in one class. First, JNI calls are inherently static and contain no Java implementation, therefore there is little reason to associate calls with different classes. Second, every JNI call must be registered in C/C++ code and this registration becomes more complicated with every additional Java class that contains JNI calls. Third, most Android developers are not familiar with native development or JNI intricacies, therefore it is in the interest of future maintenance to reduce the API surface that includes JNI declarations. Thus, all Flutter JNI calls are centralized in `FlutterJNI`.

Despite the fact that individual JNI calls are inherently static, there is state that exists within `FlutterJNI`. Most calls within `FlutterJNI` correspond to a specific "platform view", of which there may be many. Therefore, each `FlutterJNI` instance holds onto a "native platform view ID" after `attachToNative()`, which is shared with the native C/C++ engine code. That ID is passed to every platform-view-specific native method. ID management is handled within `FlutterJNI` so that developers don't have to hold onto that ID.

To connect part of an Android app to Flutter's C/C++ engine, instantiate a `FlutterJNI` and then attach it to the native side:

     // Instantiate FlutterJNI and attach to the native side.
     FlutterJNI flutterJNI = new FlutterJNI();
     flutterJNI.attachToNative();

     // Use FlutterJNI as desired. flutterJNI.dispatchPointerDataPacket(...);

     // Destroy the connection to the native side and cleanup.
     flutterJNI.detachFromNativeAndReleaseResources();

To receive callbacks for certain events that occur on the native side, register listeners:

1. `addEngineLifecycleListener(FlutterEngine.EngineLifecycleListener)`
2. `addIsDisplayingFlutterUiListener(FlutterUiDisplayListener)`

To facilitate platform messages between Java and Dart running in Flutter, register a handler:

`setPlatformMessageHandler(PlatformMessageHandler)`

To invoke a native method that is not associated with a platform view, invoke it statically:

`bool enabled = FlutterJNI.getIsSoftwareRenderingEnabled();`

- ## Nested Class Summary

  Nested Classes
  Modifier and Type
  Class
  Description
  `static interface`
  `FlutterJNI.AccessibilityDelegate`
  Delegate responsible for creating and updating Android-side caches of Flutter's semantics tree and custom accessibility actions.
  `static interface`
  `FlutterJNI.AsyncWaitForVsyncDelegate`
  `static class`
  `FlutterJNI.Factory`
  A factory for creating `FlutterJNI` instances.

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `FlutterJNI()`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `addEngineLifecycleListener(FlutterEngine.EngineLifecycleListener engineLifecycleListener)`
  Adds the given `engineLifecycleListener` to be notified of Flutter engine lifecycle events, e.g., `FlutterEngine.EngineLifecycleListener.onPreEngineRestart()`.
  `void`
  `addIsDisplayingFlutterUiListener(FlutterUiDisplayListener listener)`
  Adds a `FlutterUiDisplayListener`, which receives a callback when Flutter's engine notifies `FlutterJNI` that Flutter is painting pixels to the `Surface` that was provided to Flutter.
  `void`
  `addResizingFlutterUiListener(FlutterUiResizeListener listener)`
  Adds a `FlutterUiResizeListener`, which receives a callback when Flutter's engine notifies `FlutterJNI` that Flutter is has resized the surface based on the content size.
  `void`
  `applyTransactions()`
  `void`
  `attachToNative()`
  Attaches this `FlutterJNI` instance to Flutter's native engine, which allows for communication between Android code and Flutter's platform agnostic engine.
  `void`
  `cleanupMessageData(long messageData)`
  Destroys the resources provided sent to `handlePlatformMessage`.
  `String[]`
  `computePlatformResolvedLocale(String[] strings)`
  Invoked by native to obtain the results of Android's locale resolution algorithm.
  `FlutterOverlaySurface`
  `createOverlaySurface()`
  `FlutterOverlaySurface`
  `createOverlaySurface2()`
  `SurfaceControl.Transaction`
  `createTransaction()`
  `static Bitmap`
  `decodeImage(ByteBuffer buffer, long imageGeneratorAddress)`
  Called by native as a fallback method of image decoding.
  `void`
  `deferredComponentInstallFailure(int loadingUnitId, String error, boolean isTransient)`
  Indicates that a failure was encountered during the Android portion of downloading a dynamic feature module and loading a dart deferred library, which is typically done by DeferredComponentManager.
  `void`
  `destroyOverlaySurface2()`
  `void`
  `destroyOverlaySurfaces()`
  `void`
  `detachFromNativeAndReleaseResources()`
  Detaches this `FlutterJNI` instance from Flutter's native engine, which precludes any further communication between Android code and Flutter's platform agnostic engine.
  `void`
  `dispatchEmptyPlatformMessage(String channel, int responseId)`
  Sends an empty reply (identified by `responseId`) from Android to Flutter over the given `channel`.
  `void`
  `dispatchPlatformMessage(String channel, ByteBuffer message, int position, int responseId)`
  Sends a reply `message` from Android to Flutter over the given `channel`.
  `void`
  `dispatchPointerDataPacket(ByteBuffer buffer, int position)`
  Sends a packet of pointer data to Flutter's engine.
  `void`
  `dispatchSemanticsAction(int nodeId, int action, ByteBuffer args, int argsPosition)`
  Sends a semantics action to Flutter's engine, given arguments that are already encoded for the engine.
  `void`
  `dispatchSemanticsAction(int nodeId, AccessibilityBridge.Action action)`
  Sends a semantics action to Flutter's engine, without any additional arguments.
  `void`
  `dispatchSemanticsAction(int nodeId, AccessibilityBridge.Action action, Object args)`
  Sends a semantics action to Flutter's engine, with additional arguments.
  `void`
  `endFrame2()`
  `Bitmap`
  `getBitmap()`
  `boolean`
  `getIsSoftwareRenderingEnabled()`
  Checks launch settings for whether software rendering is requested.
  `float`
  `getScaledFontSize(float fontSize, int configurationId)`
  `static String`
  `getVMServiceUri()`
  VM Service URI for the VM instance.
  `void`
  `handlePlatformMessage(String channel, ByteBuffer message, int replyId, long messageData)`
  `void`
  `hideOverlaySurface2()`
  `void`
  `hidePlatformView2(int viewId)`
  `void`
  `init(Context context, String[] args, String bundlePath, String appStoragePath, String engineCachesPath, long initTimeMillis, int apiLevel)`
  Perform one time initialization of the Dart VM and Flutter engine.
  `void`
  `invokePlatformMessageEmptyResponseCallback(int responseId)`
  `void`
  `invokePlatformMessageResponseCallback(int responseId, ByteBuffer message, int position)`
  `boolean`
  `isAttached()`
  Returns true if this instance of `FlutterJNI` is connected to Flutter's native engine via a Java Native Interface (JNI).
  `boolean`
  `isCodePointEmoji(int codePoint)`
  `boolean`
  `isCodePointEmojiModifier(int codePoint)`
  `boolean`
  `isCodePointEmojiModifierBase(int codePoint)`
  `boolean`
  `isCodePointRegionalIndicator(int codePoint)`
  `boolean`
  `isCodePointVariantSelector(int codePoint)`
  `boolean`
  `IsSurfaceControlEnabled()`
  Whether the SurfaceControl swapchain required for hcpp is enabled and active.
  `void`
  `loadDartDeferredLibrary(int loadingUnitId, String[] searchPaths)`
  Searches each of the provided paths for a valid Dart shared library .so file and resolves symbols to load into the dart VM.
  `void`
  `loadLibrary(Context context)`
  Loads the libflutter.so C++ library.
  `void`
  `markTextureFrameAvailable(long textureId)`
  Call this method to inform Flutter that a texture previously registered with `registerTexture(long, SurfaceTextureWrapper)` has a new frame available.
  `void`
  `maybeResizeSurfaceView(int width, int height)`
  `static void`
  `nativeImageHeaderCallback(long imageGeneratorPointer, int width, int height)`
  `static FlutterCallbackInformation`
  `nativeLookupCallbackInformation(long handle)`
  Deprecated.
  `void`
  `notifyLowMemoryWarning()`
  Notifies the Dart VM of a low memory event, or that the application is in a state such that now is an appropriate time to free resources, such as going to the background.
  `void`
  `onBeginFrame()`
  `void`
  `onDisplayOverlaySurface(int id, int x, int y, int width, int height)`
  `void`
  `onDisplayPlatformView(int viewId, int x, int y, int width, int height, int viewWidth, int viewHeight, FlutterMutatorsStack mutatorsStack)`
  `void`
  `onDisplayPlatformView2(int viewId, int x, int y, int width, int height, int viewWidth, int viewHeight, FlutterMutatorsStack mutatorsStack)`
  `void`
  `onEndFrame()`
  `void`
  `onFirstFrame()`
  `void`
  `onSurfaceChanged(int width, int height)`
  Call this method when the `Surface` changes that was previously registered with `onSurfaceCreated(Surface)`.
  `void`
  `onSurfaceCreated(Surface surface)`
  Call this method when a `Surface` has been created onto which you would like Flutter to paint.
  `void`
  `onSurfaceDestroyed()`
  Call this method when the `Surface` is destroyed that was previously registered with `onSurfaceCreated(Surface)`.
  `void`
  `onSurfaceWindowChanged(Surface surface)`
  In hybrid composition, call this method when the `Surface` has changed.
  `void`
  `onVsync(long frameDelayNanos, long refreshPeriodNanos, long cookie)`
  Notifies the engine that the Choreographer has signaled a vsync.
  `long`
  `performNativeAttach(FlutterJNI flutterJNI)`
  `void`
  `prefetchDefaultFontManager()`
  Prefetch the default font manager provided by txt::GetDefaultFontManager() which is a process-wide singleton owned by Skia.
  `void`
  `registerImageTexture(long textureId, TextureRegistry.ImageConsumer imageTexture, boolean resetOnBackground)`
  Registers a ImageTexture with the given id.
  `void`
  `registerTexture(long textureId, SurfaceTextureWrapper textureWrapper)`
  Gives control of a `SurfaceTexture` to Flutter so that Flutter can display that texture within Flutter's UI.
  `void`
  `removeEngineLifecycleListener(FlutterEngine.EngineLifecycleListener engineLifecycleListener)`
  Removes the given `engineLifecycleListener`, which was previously added using `addIsDisplayingFlutterUiListener(FlutterUiDisplayListener)`.
  `void`
  `removeIsDisplayingFlutterUiListener(FlutterUiDisplayListener listener)`
  Removes a `FlutterUiDisplayListener` that was added with `addIsDisplayingFlutterUiListener(FlutterUiDisplayListener)`.
  `void`
  `removeResizingFlutterUiListener(FlutterUiResizeListener listener)`
  Removes a `FlutterUiResizeListener` that was added with `addResizingFlutterUiListener(FlutterUiResizeListener)`.
  `void`
  `requestDartDeferredLibrary(int loadingUnitId)`
  Called by dart to request that a Dart deferred library corresponding to loadingUnitId be downloaded (if necessary) and loaded into the dart vm.
  `void`
  `runBundleAndSnapshotFromLibrary(String bundlePath, String entrypointFunctionName, String pathToEntrypointFunction, AssetManager assetManager, List<String> entrypointArgs, long engineId)`
  Executes a Dart entrypoint.
  `void`
  `scheduleFrame()`
  Schedule the engine to draw a frame but does not invalidate the layout tree.
  `void`
  `setAccessibilityDelegate(FlutterJNI.AccessibilityDelegate accessibilityDelegate)`
  Sets the `FlutterJNI.AccessibilityDelegate` for the attached Flutter context.
  `void`
  `setAccessibilityFeatures(int flags)`
  `void`
  `setAccessibilityFeaturesInNative(int flags)`
  `void`
  `setAsyncWaitForVsyncDelegate(FlutterJNI.AsyncWaitForVsyncDelegate delegate)`
  The Android vsync waiter implementation in C++ needs to know when a vsync signal arrives, which is obtained via Java API.
  `void`
  `setDeferredComponentManager(io.flutter.embedding.engine.deferredcomponents.DeferredComponentManager deferredComponentManager)`
  Sets the deferred component manager that is used to download and install split features.
  `void`
  `setLocalizationPlugin(io.flutter.plugin.localization.LocalizationPlugin localizationPlugin)`
  Sets the localization plugin that is used in various localization methods.
  `void`
  `setPlatformMessageHandler(PlatformMessageHandler platformMessageHandler)`
  Sets the handler for all platform messages that come from the attached platform view to Java.
  `void`
  `setPlatformViewsController(PlatformViewsController platformViewsController)`
  `void`
  `setPlatformViewsController2(PlatformViewsController2 platformViewsController2)`
  `void`
  `setRefreshRateFPS(float refreshRateFPS)`
  Notifies the engine about the refresh rate of the display when the API level is below 30.
  `void`
  `setSemanticsEnabled(boolean enabled)`
  Instructs Flutter to enable/disable its semantics tree, which is used by Flutter to support accessibility and related behaviors.
  `void`
  `setSemanticsEnabledInNative(boolean enabled)`
  `void`
  `setSemanticsTreeEnabled(boolean enabled)`
  Invoked by native to notify framework started or stopped compiling accessibility tree.
  `void`
  `setSettingsChannel(SettingsChannel settingsChannel)`
  `void`
  `setViewportMetrics(float devicePixelRatio, int physicalWidth, int physicalHeight, int physicalPaddingTop, int physicalPaddingRight, int physicalPaddingBottom, int physicalPaddingLeft, int physicalViewInsetTop, int physicalViewInsetRight, int physicalViewInsetBottom, int physicalViewInsetLeft, int systemGestureInsetTop, int systemGestureInsetRight, int systemGestureInsetBottom, int systemGestureInsetLeft, int physicalTouchSlop, int[] displayFeaturesBounds, int[] displayFeaturesType, int[] displayFeaturesState, int minWidth, int maxWidth, int minHeight, int maxHeight)`
  Call this method to notify Flutter of the current device viewport metrics that are applies to the Flutter UI that is being rendered.
  `void`
  `showOverlaySurface2()`
  `FlutterJNI`
  `spawn(String entrypointFunctionName, String pathToEntrypointFunction, String initialRoute, List<String> entrypointArgs, long engineId)`
  Spawns a new FlutterJNI instance from the current instance.
  `void`
  `swapTransactions()`
  `void`
  `unregisterTexture(long textureId)`
  Unregisters a texture that was registered with `registerTexture(long, SurfaceTextureWrapper)`.
  `void`
  `updateDisplayMetrics(int displayId, float width, float height, float density)`
  `void`
  `updateJavaAssetManager(AssetManager assetManager, String assetBundlePath)`
  Adds the specified AssetManager as an APKAssetResolver in the Flutter Engine's AssetManager.
  `void`
  `updateRefreshRate()`

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

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

- ## Constructor Details

  - ### FlutterJNI

    public FlutterJNI()

- ## Method Details

  - ### loadLibrary

    public void loadLibrary(Context context)
    Loads the libflutter.so C++ library.

    This must be called before any other native methods, and can be overridden by tests to avoid loading native libraries.

    This method should only be called once across all FlutterJNI instances.

  - ### prefetchDefaultFontManager

    public void prefetchDefaultFontManager()
    Prefetch the default font manager provided by txt::GetDefaultFontManager() which is a process-wide singleton owned by Skia. Note that, the first call to txt::GetDefaultFontManager() will take noticeable time, but later calls will return a reference to the preexisting font manager.

    This method should only be called once across all FlutterJNI instances.

  - ### init

    public void init(@NonNull Context context, @NonNull String[] args, @Nullable String bundlePath, @NonNull String appStoragePath, @NonNull String engineCachesPath, long initTimeMillis, int apiLevel)
    Perform one time initialization of the Dart VM and Flutter engine.

    This method must be called only once. Calling more than once will cause an exception.

    Parameters:
      `context` - The application context.
      `args` - Arguments to the Dart VM/Flutter engine.
      `bundlePath` - For JIT runtimes, the path to the Dart kernel file for the application.
      `appStoragePath` - The path to the application data directory.
      `engineCachesPath` - The path to the application cache directory.
      `initTimeMillis` - The time, in milliseconds, taken for initialization.
      `apiLevel` - The current Android API level.

  - ### getIsSoftwareRenderingEnabled

    @UiThread public boolean getIsSoftwareRenderingEnabled()
    Checks launch settings for whether software rendering is requested.

    The value is the same per program.

  - ### getVMServiceUri

    @Nullable public static String getVMServiceUri()
    VM Service URI for the VM instance.

    Its value is set by the native engine once `init(Context, String[], String, String, String, long, int)` is run.

  - ### setRefreshRateFPS

    public void setRefreshRateFPS(float refreshRateFPS)
    Notifies the engine about the refresh rate of the display when the API level is below 30.

    For API 30 and above, this value is ignored.

    Calling this method multiple times will update the refresh rate for the next vsync period. However, callers should avoid calling `Display.getRefreshRate()` frequently, since it is expensive on some vendor implementations.

    Parameters:
      `refreshRateFPS` - The refresh rate in nanoseconds.

  - ### updateDisplayMetrics

    public void updateDisplayMetrics(int displayId, float width, float height, float density)

  - ### updateRefreshRate

    public void updateRefreshRate()

  - ### setAsyncWaitForVsyncDelegate

    public void setAsyncWaitForVsyncDelegate(@Nullable FlutterJNI.AsyncWaitForVsyncDelegate delegate)
    The Android vsync waiter implementation in C++ needs to know when a vsync signal arrives, which is obtained via Java API. The delegate set here is called on the C++ side when the engine is ready to wait for the next vsync signal. The delegate is expected to add a postFrameCallback to the `Choreographer`, and call `onVsync(long,long,long)` to notify the engine.
    Parameters:
      `delegate` - The delegate that will call the engine back on the next vsync signal.

  - ### onVsync

    public void onVsync(long frameDelayNanos, long refreshPeriodNanos, long cookie)
    Notifies the engine that the Choreographer has signaled a vsync.
    Parameters:
      `frameDelayNanos` - The time in nanoseconds when the frame started being rendered, subtracted from the `System.nanoTime()` timebase.
      `refreshPeriodNanos` - The display refresh period in nanoseconds.
      `cookie` - An opaque handle to the C++ VSyncWaiter object.

  - ### nativeLookupCallbackInformation

    @NonNull @Deprecated public static FlutterCallbackInformation nativeLookupCallbackInformation(long handle)
    Deprecated.

  - ### isCodePointEmoji

    public boolean isCodePointEmoji(int codePoint)

  - ### isCodePointEmojiModifier

    public boolean isCodePointEmojiModifier(int codePoint)

  - ### isCodePointEmojiModifierBase

    public boolean isCodePointEmojiModifierBase(int codePoint)

  - ### isCodePointVariantSelector

    public boolean isCodePointVariantSelector(int codePoint)

  - ### isCodePointRegionalIndicator

    public boolean isCodePointRegionalIndicator(int codePoint)

  - ### isAttached

    public boolean isAttached()
    Returns true if this instance of `FlutterJNI` is connected to Flutter's native engine via a Java Native Interface (JNI).

  - ### attachToNative

    @UiThread public void attachToNative()
    Attaches this `FlutterJNI` instance to Flutter's native engine, which allows for communication between Android code and Flutter's platform agnostic engine.

    This method must not be invoked if `FlutterJNI` is already attached to native.

  - ### performNativeAttach

    @VisibleForTesting public long performNativeAttach(@NonNull FlutterJNI flutterJNI)

  - ### spawn

    @UiThread @NonNull public FlutterJNI spawn(@Nullable String entrypointFunctionName, @Nullable String pathToEntrypointFunction, @Nullable String initialRoute, @Nullable List<String> entrypointArgs, long engineId)
    Spawns a new FlutterJNI instance from the current instance.

    This creates another native shell from the current shell. This causes the 2 shells to re-use some of the shared resources, reducing the total memory consumption versus creating a new FlutterJNI by calling its standard constructor.

    This can only be called once the current FlutterJNI instance is attached by calling `attachToNative()`.

    Static methods that should be only called once such as `init(Context, String[], String, String, String, long, int)` shouldn't be called again on the spawned FlutterJNI instance.

  - ### detachFromNativeAndReleaseResources

    @UiThread public void detachFromNativeAndReleaseResources()
    Detaches this `FlutterJNI` instance from Flutter's native engine, which precludes any further communication between Android code and Flutter's platform agnostic engine.

    This method must not be invoked if `FlutterJNI` is not already attached to native.

    Invoking this method will result in the release of all native-side resources that were set up during `attachToNative()` or `spawn(String, String, String, List, long)`, or accumulated thereafter.

    It is permissible to re-attach this instance to native after detaching it from native.

  - ### addIsDisplayingFlutterUiListener

    @UiThread public void addIsDisplayingFlutterUiListener(@NonNull FlutterUiDisplayListener listener)
    Adds a `FlutterUiDisplayListener`, which receives a callback when Flutter's engine notifies `FlutterJNI` that Flutter is painting pixels to the `Surface` that was provided to Flutter.

  - ### removeIsDisplayingFlutterUiListener

    public void removeIsDisplayingFlutterUiListener(@NonNull FlutterUiDisplayListener listener)
    Removes a `FlutterUiDisplayListener` that was added with `addIsDisplayingFlutterUiListener(FlutterUiDisplayListener)`.

  - ### addResizingFlutterUiListener

    @UiThread public void addResizingFlutterUiListener(@NonNull FlutterUiResizeListener listener)
    Adds a `FlutterUiResizeListener`, which receives a callback when Flutter's engine notifies `FlutterJNI` that Flutter is has resized the surface based on the content size.

  - ### removeResizingFlutterUiListener

    @UiThread public void removeResizingFlutterUiListener(@NonNull FlutterUiResizeListener listener)
    Removes a `FlutterUiResizeListener` that was added with `addResizingFlutterUiListener(FlutterUiResizeListener)`.

  - ### nativeImageHeaderCallback

    public static void nativeImageHeaderCallback(long imageGeneratorPointer, int width, int height)

  - ### decodeImage

    @VisibleForTesting @Nullable public static Bitmap decodeImage(@NonNull ByteBuffer buffer, long imageGeneratorAddress)
    Called by native as a fallback method of image decoding. There are other ways to decode images on lower API levels, they involve copying the native data _and_ do not support any additional formats, whereas ImageDecoder supports HEIF images. Unlike most other methods called from native, this method is expected to be called on a worker thread, since it only uses thread safe methods and may take multiple frames to complete.

  - ### onFirstFrame

    @VisibleForTesting @UiThread public void onFirstFrame()

  - ### onSurfaceCreated

    @UiThread public void onSurfaceCreated(@NonNull Surface surface)
    Call this method when a `Surface` has been created onto which you would like Flutter to paint.

    See `SurfaceHolder.Callback.surfaceCreated(SurfaceHolder)` for an example of where this call might originate.

  - ### onSurfaceWindowChanged

    @UiThread public void onSurfaceWindowChanged(@NonNull Surface surface)
    In hybrid composition, call this method when the `Surface` has changed.

    In hybrid composition, the root surfaces changes from `SurfaceHolder.getSurface()` to `ImageReader.getSurface()` when a platform view is in the current frame.

  - ### onSurfaceChanged

    @UiThread public void onSurfaceChanged(int width, int height)
    Call this method when the `Surface` changes that was previously registered with `onSurfaceCreated(Surface)`.

    See `SurfaceHolder.Callback.surfaceChanged(SurfaceHolder, int, int, int)` for an example of where this call might originate.

  - ### onSurfaceDestroyed

    @UiThread public void onSurfaceDestroyed()
    Call this method when the `Surface` is destroyed that was previously registered with `onSurfaceCreated(Surface)`.

    See `SurfaceHolder.Callback.surfaceDestroyed(SurfaceHolder)` for an example of where this call might originate.

  - ### setViewportMetrics

    @UiThread public void setViewportMetrics(float devicePixelRatio, int physicalWidth, int physicalHeight, int physicalPaddingTop, int physicalPaddingRight, int physicalPaddingBottom, int physicalPaddingLeft, int physicalViewInsetTop, int physicalViewInsetRight, int physicalViewInsetBottom, int physicalViewInsetLeft, int systemGestureInsetTop, int systemGestureInsetRight, int systemGestureInsetBottom, int systemGestureInsetLeft, int physicalTouchSlop, int[] displayFeaturesBounds, int[] displayFeaturesType, int[] displayFeaturesState, int minWidth, int maxWidth, int minHeight, int maxHeight)
    Call this method to notify Flutter of the current device viewport metrics that are applies to the Flutter UI that is being rendered.

    This method should be invoked with initial values upon attaching to native. Then, it should be invoked any time those metrics change while `FlutterJNI` is attached to native.

  - ### dispatchPointerDataPacket

    @UiThread public void dispatchPointerDataPacket(@NonNull ByteBuffer buffer, int position)
    Sends a packet of pointer data to Flutter's engine.

  - ### setPlatformViewsController

    @UiThread public void setPlatformViewsController(@NonNull PlatformViewsController platformViewsController)

  - ### setPlatformViewsController2

    @UiThread public void setPlatformViewsController2(@NonNull PlatformViewsController2 platformViewsController2)

  - ### setAccessibilityDelegate

    @UiThread public void setAccessibilityDelegate(@Nullable FlutterJNI.AccessibilityDelegate accessibilityDelegate)
    Sets the `FlutterJNI.AccessibilityDelegate` for the attached Flutter context.

    The `FlutterJNI.AccessibilityDelegate` is responsible for maintaining an Android-side cache of Flutter's semantics tree and custom accessibility actions. This cache should be hooked up to Android's accessibility system.

    See `AccessibilityBridge` for an example of an `FlutterJNI.AccessibilityDelegate` and the surrounding responsibilities.

  - ### setSemanticsTreeEnabled

    @UiThread public void setSemanticsTreeEnabled(boolean enabled)
    Invoked by native to notify framework started or stopped compiling accessibility tree.

    The embedding needs to be prepare to receive accessibility tree updates when true, and clean up when false.

    Parameters:
      `enabled` - True if the framework is compiling the accessibility tree.

  - ### dispatchSemanticsAction

    public void dispatchSemanticsAction(int nodeId, @NonNull AccessibilityBridge.Action action)
    Sends a semantics action to Flutter's engine, without any additional arguments.

  - ### dispatchSemanticsAction

    public void dispatchSemanticsAction(int nodeId, @NonNull AccessibilityBridge.Action action, @Nullable Object args)
    Sends a semantics action to Flutter's engine, with additional arguments.

  - ### dispatchSemanticsAction

    @UiThread public void dispatchSemanticsAction(int nodeId, int action, @Nullable ByteBuffer args, int argsPosition)
    Sends a semantics action to Flutter's engine, given arguments that are already encoded for the engine.

    To send a semantics action that has not already been encoded, see `dispatchSemanticsAction(int, AccessibilityBridge.Action)` and `dispatchSemanticsAction(int, AccessibilityBridge.Action, Object)`.

  - ### setSemanticsEnabled

    @UiThread public void setSemanticsEnabled(boolean enabled)
    Instructs Flutter to enable/disable its semantics tree, which is used by Flutter to support accessibility and related behaviors.

  - ### setSemanticsEnabledInNative

    @VisibleForTesting public void setSemanticsEnabledInNative(boolean enabled)

  - ### setAccessibilityFeatures

    @UiThread public void setAccessibilityFeatures(int flags)

  - ### setAccessibilityFeaturesInNative

    @VisibleForTesting public void setAccessibilityFeaturesInNative(int flags)

  - ### registerTexture

    @UiThread public void registerTexture(long textureId, @NonNull SurfaceTextureWrapper textureWrapper)
    Gives control of a `SurfaceTexture` to Flutter so that Flutter can display that texture within Flutter's UI.

  - ### registerImageTexture

    @UiThread public void registerImageTexture(long textureId, @NonNull TextureRegistry.ImageConsumer imageTexture, boolean resetOnBackground)
    Registers a ImageTexture with the given id.

    REQUIRED: Callers should eventually unregisterTexture with the same id.

  - ### markTextureFrameAvailable

    @UiThread public void markTextureFrameAvailable(long textureId)
    Call this method to inform Flutter that a texture previously registered with `registerTexture(long, SurfaceTextureWrapper)` has a new frame available.

    Invoking this method instructs Flutter to update its presentation of the given texture so that the new frame is displayed.

  - ### scheduleFrame

    @UiThread public void scheduleFrame()
    Schedule the engine to draw a frame but does not invalidate the layout tree.

  - ### unregisterTexture

    @UiThread public void unregisterTexture(long textureId)
    Unregisters a texture that was registered with `registerTexture(long, SurfaceTextureWrapper)`.

  - ### runBundleAndSnapshotFromLibrary

    @UiThread public void runBundleAndSnapshotFromLibrary(@NonNull String bundlePath, @Nullable String entrypointFunctionName, @Nullable String pathToEntrypointFunction, @NonNull AssetManager assetManager, @Nullable List<String> entrypointArgs, long engineId)
    Executes a Dart entrypoint.

    This can only be done once per JNI attachment because a Dart isolate can only be entered once.

  - ### setPlatformMessageHandler

    @UiThread public void setPlatformMessageHandler(@Nullable PlatformMessageHandler platformMessageHandler)
    Sets the handler for all platform messages that come from the attached platform view to Java.

    Communication between a specific Flutter context (Dart) and the host platform (Java) is accomplished by passing messages. Messages can be sent from Java to Dart with the corresponding `FlutterJNI` methods:

    - `dispatchPlatformMessage(String, ByteBuffer, int, int)`
    - `dispatchEmptyPlatformMessage(String, int)`

    `FlutterJNI` is also the recipient of all platform messages sent from its attached Flutter context. `FlutterJNI` does not know what to do with these messages, so a handler is exposed to allow these messages to be processed in whatever manner is desired:

    `setPlatformMessageHandler(PlatformMessageHandler)`

    If a message is received but no `PlatformMessageHandler` is registered, that message will be dropped (ignored). Therefore, when using `FlutterJNI` to integrate a Flutter context in an app, a `PlatformMessageHandler` must be registered for 2-way Java/Dart communication to operate correctly. Moreover, the handler must be implemented such that fundamental platform messages are handled as expected.

  - ### cleanupMessageData

    public void cleanupMessageData(long messageData)
    Destroys the resources provided sent to `handlePlatformMessage`.

    This can be called on any thread.

    Parameters:
      `messageData` - the argument sent to handlePlatformMessage.

  - ### handlePlatformMessage

    @VisibleForTesting public void handlePlatformMessage(@NonNull String channel, ByteBuffer message, int replyId, long messageData)

  - ### dispatchEmptyPlatformMessage

    @UiThread public void dispatchEmptyPlatformMessage(@NonNull String channel, int responseId)
    Sends an empty reply (identified by `responseId`) from Android to Flutter over the given `channel`.

  - ### dispatchPlatformMessage

    @UiThread public void dispatchPlatformMessage(@NonNull String channel, @Nullable ByteBuffer message, int position, int responseId)
    Sends a reply `message` from Android to Flutter over the given `channel`.

  - ### invokePlatformMessageEmptyResponseCallback

    public void invokePlatformMessageEmptyResponseCallback(int responseId)

  - ### invokePlatformMessageResponseCallback

    public void invokePlatformMessageResponseCallback(int responseId, @NonNull ByteBuffer message, int position)

  - ### addEngineLifecycleListener

    @UiThread public void addEngineLifecycleListener(@NonNull FlutterEngine.EngineLifecycleListener engineLifecycleListener)
    Adds the given `engineLifecycleListener` to be notified of Flutter engine lifecycle events, e.g., `FlutterEngine.EngineLifecycleListener.onPreEngineRestart()`.

  - ### removeEngineLifecycleListener

    @UiThread public void removeEngineLifecycleListener(@NonNull FlutterEngine.EngineLifecycleListener engineLifecycleListener)
    Removes the given `engineLifecycleListener`, which was previously added using `addIsDisplayingFlutterUiListener(FlutterUiDisplayListener)`.

  - ### onDisplayOverlaySurface

    @UiThread public void onDisplayOverlaySurface(int id, int x, int y, int width, int height)

  - ### onBeginFrame

    @UiThread public void onBeginFrame()

  - ### onEndFrame

    @UiThread public void onEndFrame()

  - ### createOverlaySurface

    @UiThread public FlutterOverlaySurface createOverlaySurface()

  - ### destroyOverlaySurfaces

    @UiThread public void destroyOverlaySurfaces()

  - ### maybeResizeSurfaceView

    @UiThread public void maybeResizeSurfaceView(int width, int height)

  - ### createTransaction

    @UiThread public SurfaceControl.Transaction createTransaction()

  - ### swapTransactions

    @UiThread public void swapTransactions()

  - ### applyTransactions

    @UiThread public void applyTransactions()

  - ### endFrame2

    @UiThread public void endFrame2()

  - ### createOverlaySurface2

    @UiThread public FlutterOverlaySurface createOverlaySurface2()

  - ### showOverlaySurface2

    @UiThread public void showOverlaySurface2()

  - ### hideOverlaySurface2

    @UiThread public void hideOverlaySurface2()

  - ### destroyOverlaySurface2

    @UiThread public void destroyOverlaySurface2()

  - ### onDisplayPlatformView2

    @UiThread public void onDisplayPlatformView2(int viewId, int x, int y, int width, int height, int viewWidth, int viewHeight, FlutterMutatorsStack mutatorsStack)

  - ### hidePlatformView2

    @UiThread public void hidePlatformView2(int viewId)

  - ### setLocalizationPlugin

    @UiThread public void setLocalizationPlugin(@Nullable io.flutter.plugin.localization.LocalizationPlugin localizationPlugin)
    Sets the localization plugin that is used in various localization methods.

  - ### computePlatformResolvedLocale

    @VisibleForTesting public String[] computePlatformResolvedLocale(@NonNull String[] strings)
    Invoked by native to obtain the results of Android's locale resolution algorithm.

  - ### getScaledFontSize

    @Nullable public float getScaledFontSize(float fontSize, int configurationId)

  - ### setSettingsChannel

    @UiThread public void setSettingsChannel(@Nullable SettingsChannel settingsChannel)

  - ### setDeferredComponentManager

    @UiThread public void setDeferredComponentManager(@Nullable io.flutter.embedding.engine.deferredcomponents.DeferredComponentManager deferredComponentManager)
    Sets the deferred component manager that is used to download and install split features.

  - ### requestDartDeferredLibrary

    @UiThread public void requestDartDeferredLibrary(int loadingUnitId)
    Called by dart to request that a Dart deferred library corresponding to loadingUnitId be downloaded (if necessary) and loaded into the dart vm.

    This method delegates the task to DeferredComponentManager, which handles the download and loading of the dart library and any assets.

    Parameters:
      `loadingUnitId` - The loadingUnitId is assigned during compile time by gen_snapshot and is automatically retrieved when loadLibrary() is called on a dart deferred library.

  - ### loadDartDeferredLibrary

    @UiThread public void loadDartDeferredLibrary(int loadingUnitId, @NonNull String[] searchPaths)
    Searches each of the provided paths for a valid Dart shared library .so file and resolves symbols to load into the dart VM.

    Successful loading of the dart library completes the future returned by loadLibrary() that triggered the install/load process.

    Parameters:
      `loadingUnitId` - The loadingUnitId is assigned during compile time by gen_snapshot and is automatically retrieved when loadLibrary() is called on a dart deferred library. This is used to identify which Dart deferred library the resolved correspond to.
      `searchPaths` - An array of paths in which to look for valid dart shared libraries. This supports paths within zipped apks as long as the apks are not compressed using the `path/to/apk.apk!path/inside/apk/lib.so` format. Paths will be tried first to last and ends when a library is successfully found. When the found library is invalid, no additional paths will be attempted.

  - ### updateJavaAssetManager

    @UiThread public void updateJavaAssetManager(@NonNull AssetManager assetManager, @NonNull String assetBundlePath)
    Adds the specified AssetManager as an APKAssetResolver in the Flutter Engine's AssetManager.

    This may be used to update the engine AssetManager when a new deferred component is installed and a new Android AssetManager is created with access to new assets.

    Parameters:
      `assetManager` - An android AssetManager that is able to access the newly downloaded assets.
      `assetBundlePath` - The subdirectory that the flutter assets are stored in. The typical value is `flutter_assets`.

  - ### deferredComponentInstallFailure

    @UiThread public void deferredComponentInstallFailure(int loadingUnitId, @NonNull String error, boolean isTransient)
    Indicates that a failure was encountered during the Android portion of downloading a dynamic feature module and loading a dart deferred library, which is typically done by DeferredComponentManager.

    This will inform dart that the future returned by loadLibrary() should complete with an error.

    Parameters:
      `loadingUnitId` - The loadingUnitId that corresponds to the dart deferred library that failed to install.
      `error` - The error message to display.
      `isTransient` - When isTransient is false, new attempts to install will automatically result in same error in Dart before the request is passed to Android.

  - ### onDisplayPlatformView

    @UiThread public void onDisplayPlatformView(int viewId, int x, int y, int width, int height, int viewWidth, int viewHeight, FlutterMutatorsStack mutatorsStack)

  - ### getBitmap

    @UiThread public Bitmap getBitmap()

  - ### notifyLowMemoryWarning

    @UiThread public void notifyLowMemoryWarning()
    Notifies the Dart VM of a low memory event, or that the application is in a state such that now is an appropriate time to free resources, such as going to the background.

    This is distinct from sending a SystemChannel message about low memory, which only notifies the running Flutter application.

  - ### IsSurfaceControlEnabled

    public boolean IsSurfaceControlEnabled()
    Whether the SurfaceControl swapchain required for hcpp is enabled and active.