Flutter Engine
The Flutter Engine
Classes | Public Member Functions | Static Public Member Functions | Package Functions | List of all members
io.flutter.embedding.engine.FlutterJNI Class Reference

Classes

interface  AccessibilityDelegate
 
interface  AsyncWaitForVsyncDelegate
 
class  Factory
 

Public Member Functions

 FlutterJNI ()
 
void loadLibrary ()
 
void prefetchDefaultFontManager ()
 
void init ( @NonNull Context context, @NonNull String[] args, @Nullable String bundlePath, @NonNull String appStoragePath, @NonNull String engineCachesPath, long initTimeMillis)
 
boolean getIsSoftwareRenderingEnabled ()
 
void setRefreshRateFPS (float refreshRateFPS)
 
void updateDisplayMetrics (int displayId, float width, float height, float density)
 
void updateRefreshRate ()
 
void setAsyncWaitForVsyncDelegate (@Nullable AsyncWaitForVsyncDelegate delegate)
 
void onVsync (long frameDelayNanos, long refreshPeriodNanos, long cookie)
 
boolean isCodePointEmoji (int codePoint)
 
boolean isCodePointEmojiModifier (int codePoint)
 
boolean isCodePointEmojiModifierBase (int codePoint)
 
boolean isCodePointVariantSelector (int codePoint)
 
boolean isCodePointRegionalIndicator (int codePoint)
 
boolean isAttached ()
 
void attachToNative ()
 
long performNativeAttach (@NonNull FlutterJNI flutterJNI)
 
FlutterJNI spawn ( @Nullable String entrypointFunctionName, @Nullable String pathToEntrypointFunction, @Nullable String initialRoute, @Nullable List< String > entrypointArgs)
 
void detachFromNativeAndReleaseResources ()
 
void addIsDisplayingFlutterUiListener (@NonNull FlutterUiDisplayListener listener)
 
void removeIsDisplayingFlutterUiListener (@NonNull FlutterUiDisplayListener listener)
 
void onFirstFrame ()
 
void onSurfaceCreated (@NonNull Surface surface)
 
void onSurfaceWindowChanged (@NonNull Surface surface)
 
void onSurfaceChanged (int width, int height)
 
void onSurfaceDestroyed ()
 
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)
 
void dispatchPointerDataPacket (@NonNull ByteBuffer buffer, int position)
 
void setPlatformViewsController (@NonNull PlatformViewsController platformViewsController)
 
void setAccessibilityDelegate (@Nullable AccessibilityDelegate accessibilityDelegate)
 
void dispatchSemanticsAction (int nodeId, @NonNull AccessibilityBridge.Action action)
 
void dispatchSemanticsAction (int nodeId, @NonNull AccessibilityBridge.Action action, @Nullable Object args)
 
void dispatchSemanticsAction (int nodeId, int action, @Nullable ByteBuffer args, int argsPosition)
 
void setSemanticsEnabled (boolean enabled)
 
void setAccessibilityFeatures (int flags)
 
void registerTexture (long textureId, @NonNull SurfaceTextureWrapper textureWrapper)
 
void registerImageTexture (long textureId, @NonNull TextureRegistry.ImageConsumer imageTexture)
 
void markTextureFrameAvailable (long textureId)
 
void scheduleFrame ()
 
void unregisterTexture (long textureId)
 
void runBundleAndSnapshotFromLibrary ( @NonNull String bundlePath, @Nullable String entrypointFunctionName, @Nullable String pathToEntrypointFunction, @NonNull AssetManager assetManager, @Nullable List< String > entrypointArgs)
 
void setPlatformMessageHandler (@Nullable PlatformMessageHandler platformMessageHandler)
 
void cleanupMessageData (long messageData)
 
void handlePlatformMessage ( @NonNull final String channel, ByteBuffer message, final int replyId, final long messageData)
 
void dispatchEmptyPlatformMessage (@NonNull String channel, int responseId)
 
void dispatchPlatformMessage ( @NonNull String channel, @Nullable ByteBuffer message, int position, int responseId)
 
void invokePlatformMessageEmptyResponseCallback (int responseId)
 
void invokePlatformMessageResponseCallback (int responseId, @NonNull ByteBuffer message, int position)
 
void addEngineLifecycleListener (@NonNull EngineLifecycleListener engineLifecycleListener)
 
void removeEngineLifecycleListener ( @NonNull EngineLifecycleListener engineLifecycleListener)
 
void onDisplayOverlaySurface (int id, int x, int y, int width, int height)
 
void onBeginFrame ()
 
void onEndFrame ()
 
FlutterOverlaySurface createOverlaySurface ()
 
void destroyOverlaySurfaces ()
 
void setLocalizationPlugin (@Nullable LocalizationPlugin localizationPlugin)
 
String[] computePlatformResolvedLocale (@NonNull String[] strings)
 
float getScaledFontSize (float fontSize, int configurationId)
 
void setDeferredComponentManager ( @Nullable DeferredComponentManager deferredComponentManager)
 
void requestDartDeferredLibrary (int loadingUnitId)
 
void loadDartDeferredLibrary (int loadingUnitId, @NonNull String[] searchPaths)
 
void updateJavaAssetManager ( @NonNull AssetManager assetManager, @NonNull String assetBundlePath)
 
void deferredComponentInstallFailure (int loadingUnitId, @NonNull String error, boolean isTransient)
 
void onDisplayPlatformView (int viewId, int x, int y, int width, int height, int viewWidth, int viewHeight, FlutterMutatorsStack mutatorsStack)
 
Bitmap getBitmap ()
 
void notifyLowMemoryWarning ()
 

Static Public Member Functions

static String getVMServiceUri ()
 
static String getObservatoryUri ()
 
static native FlutterCallbackInformation nativeLookupCallbackInformation (long handle)
 
static native void nativeImageHeaderCallback (long imageGeneratorPointer, int width, int height)
 
static Bitmap decodeImage (@NonNull ByteBuffer buffer, long imageGeneratorAddress)
 

Package Functions

void onRenderingStopped ()
 

Detailed Description

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();

Definition at line 106 of file FlutterJNI.java.

Constructor & Destructor Documentation

◆ FlutterJNI()

io.flutter.embedding.engine.FlutterJNI.FlutterJNI ( )
inline

Definition at line 116 of file FlutterJNI.java.

116 {
117 // We cache the main looper so that we can ensure calls are made on the main thread
118 // without consistently paying the synchronization cost of getMainLooper().
119 mainLooper = Looper.getMainLooper();
120 }

Member Function Documentation

◆ addEngineLifecycleListener()

void io.flutter.embedding.engine.FlutterJNI.addEngineLifecycleListener ( @NonNull EngineLifecycleListener  engineLifecycleListener)
inline

Adds the given engineLifecycleListener to be notified of Flutter engine lifecycle events, e.g., EngineLifecycleListener#onPreEngineRestart().

Definition at line 1186 of file FlutterJNI.java.

1186 {
1187 ensureRunningOnMainThread();
1188 engineLifecycleListeners.add(engineLifecycleListener);
1189 }

◆ addIsDisplayingFlutterUiListener()

void io.flutter.embedding.engine.FlutterJNI.addIsDisplayingFlutterUiListener ( @NonNull FlutterUiDisplayListener  listener)
inline

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.

Definition at line 529 of file FlutterJNI.java.

529 {
530 ensureRunningOnMainThread();
531 flutterUiDisplayListeners.add(listener);
532 }

◆ attachToNative()

void io.flutter.embedding.engine.FlutterJNI.attachToNative ( )
inline

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.

Definition at line 419 of file FlutterJNI.java.

419 {
420 ensureRunningOnMainThread();
421 ensureNotAttachedToNative();
422 shellHolderLock.writeLock().lock();
423 try {
424 nativeShellHolderId = performNativeAttach(this);
425 } finally {
426 shellHolderLock.writeLock().unlock();
427 }
428 }
long performNativeAttach(@NonNull FlutterJNI flutterJNI)

◆ cleanupMessageData()

void io.flutter.embedding.engine.FlutterJNI.cleanupMessageData ( long  messageData)
inline

Destroys the resources provided sent to handlePlatformMessage.

This can be called on any thread.

Parameters
messageDatathe argument sent to handlePlatformMessage.

Definition at line 1048 of file FlutterJNI.java.

1048 {
1049 // This doesn't rely on being attached like other methods.
1050 nativeCleanupMessageData(messageData);
1051 }

◆ computePlatformResolvedLocale()

String[] io.flutter.embedding.engine.FlutterJNI.computePlatformResolvedLocale ( @NonNull String[]  strings)
inline

Invoked by native to obtain the results of Android's locale resolution algorithm.

Definition at line 1278 of file FlutterJNI.java.

1278 {
1279 if (localizationPlugin == null) {
1280 return new String[0];
1281 }
1282 List<Locale> supportedLocales = new ArrayList<Locale>();
1283 final int localeDataLength = 3;
1284 for (int i = 0; i < strings.length; i += localeDataLength) {
1285 String languageCode = strings[i + 0];
1286 String countryCode = strings[i + 1];
1287 String scriptCode = strings[i + 2];
1288 // Convert to Locales via LocaleBuilder if available (API 21+) to include scriptCode.
1289 Locale.Builder localeBuilder = new Locale.Builder();
1290 if (!languageCode.isEmpty()) {
1291 localeBuilder.setLanguage(languageCode);
1292 }
1293 if (!countryCode.isEmpty()) {
1294 localeBuilder.setRegion(countryCode);
1295 }
1296 if (!scriptCode.isEmpty()) {
1297 localeBuilder.setScript(scriptCode);
1298 }
1299 supportedLocales.add(localeBuilder.build());
1300 }
1301
1302 Locale result = localizationPlugin.resolveNativeLocale(supportedLocales);
1303
1304 if (result == null) {
1305 return new String[0];
1306 }
1307 String[] output = new String[localeDataLength];
1308 output[0] = result.getLanguage();
1309 output[1] = result.getCountry();
1310 output[2] = result.getScript();
1311 return output;
1312 }
void add(sk_sp< SkIDChangeListener > listener) SK_EXCLUDES(fMutex)
Locale resolveNativeLocale(@Nullable List< Locale > supportedLocales)
GAsyncResult * result

◆ createOverlaySurface()

FlutterOverlaySurface io.flutter.embedding.engine.FlutterJNI.createOverlaySurface ( )
inline

Definition at line 1245 of file FlutterJNI.java.

1245 {
1246 ensureRunningOnMainThread();
1247 if (platformViewsController == null) {
1248 throw new RuntimeException(
1249 "platformViewsController must be set before attempting to position an overlay surface");
1250 }
1251 return platformViewsController.createOverlaySurface();
1252 }
FlutterOverlaySurface createOverlaySurface(@NonNull PlatformOverlayView imageView)

◆ decodeImage()

static Bitmap io.flutter.embedding.engine.FlutterJNI.decodeImage ( @NonNull ByteBuffer  buffer,
long  imageGeneratorAddress 
)
inlinestatic

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.

Definition at line 557 of file FlutterJNI.java.

557 {
558 if (Build.VERSION.SDK_INT >= API_LEVELS.API_28) {
559 ImageDecoder.Source source = ImageDecoder.createSource(buffer);
560 try {
561 return ImageDecoder.decodeBitmap(
562 source,
563 (decoder, info, src) -> {
564 // i.e. ARGB_8888
565 decoder.setTargetColorSpace(ColorSpace.get(ColorSpace.Named.SRGB));
566 // TODO(bdero): Switch to ALLOCATOR_HARDWARE for devices that have
567 // `AndroidBitmap_getHardwareBuffer` (API 30+) available once Skia supports
568 // `SkImage::MakeFromAHardwareBuffer` via dynamic lookups:
569 // https://skia-review.googlesource.com/c/skia/+/428960
570 decoder.setAllocator(ImageDecoder.ALLOCATOR_SOFTWARE);
571
572 Size size = info.getSize();
573 nativeImageHeaderCallback(imageGeneratorAddress, size.getWidth(), size.getHeight());
574 });
575 } catch (IOException e) {
576 Log.e(TAG, "Failed to decode image", e);
577 return null;
578 }
579 }
580 return null;
581 }
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
Definition: DM.cpp:213
static native void nativeImageHeaderCallback(long imageGeneratorPointer, int width, int height)
SkBitmap source
Definition: examples.cpp:28
void Log(const char *format,...) SK_PRINTF_LIKE(1
Definition: TestRunner.cpp:137
def Build(configs, env, options)
Definition: build.py:232
ColorSpace
Definition: image.h:16
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir Path to the cache directory This is different from the persistent_cache_path in embedder which is used for Skia shader cache icu native lib Path to the library file that exports the ICU data vm service The hostname IP address on which the Dart VM Service should be served If not defaults to or::depending on whether ipv6 is specified vm service A custom Dart VM Service port The default is to pick a randomly available open port disable vm Disable the Dart VM Service The Dart VM Service is never available in release mode disable vm service Disable mDNS Dart VM Service publication Bind to the IPv6 localhost address for the Dart VM Service Ignored if vm service host is set endless trace buffer
Definition: switches.h:126
it will be possible to load the file into Perfetto s trace viewer disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive keep the shell running after the Dart script has completed enable serial On low power devices with low core running concurrent GC tasks on threads can cause them to contend with the UI thread which could potentially lead to jank This option turns off all concurrent GC activities domain network JSON encoded network policy per domain This overrides the DisallowInsecureConnections switch Embedder can specify whether to allow or disallow insecure connections at a domain level old gen heap size
Definition: switches.h:259
TSize< Scalar > Size
Definition: size.h:137

◆ deferredComponentInstallFailure()

void io.flutter.embedding.engine.FlutterJNI.deferredComponentInstallFailure ( int  loadingUnitId,
@NonNull String  error,
boolean  isTransient 
)
inline

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
loadingUnitIdThe loadingUnitId that corresponds to the dart deferred library that failed to install.
errorThe error message to display.
isTransientWhen isTransient is false, new attempts to install will automatically result in same error in Dart before the request is passed to Android.

Definition at line 1431 of file FlutterJNI.java.

1432 {
1433 ensureRunningOnMainThread();
1434 nativeDeferredComponentInstallFailure(loadingUnitId, error, isTransient);
1435 }
const uint8_t uint32_t uint32_t GError ** error

◆ destroyOverlaySurfaces()

void io.flutter.embedding.engine.FlutterJNI.destroyOverlaySurfaces ( )
inline

Definition at line 1256 of file FlutterJNI.java.

1256 {
1257 ensureRunningOnMainThread();
1258 if (platformViewsController == null) {
1259 throw new RuntimeException(
1260 "platformViewsController must be set before attempting to destroy an overlay surface");
1261 }
1262 platformViewsController.destroyOverlaySurfaces();
1263 }

◆ detachFromNativeAndReleaseResources()

void io.flutter.embedding.engine.FlutterJNI.detachFromNativeAndReleaseResources ( )
inline

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), or accumulated thereafter.

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

Definition at line 493 of file FlutterJNI.java.

493 {
494 ensureRunningOnMainThread();
495 ensureAttachedToNative();
496 shellHolderLock.writeLock().lock();
497 try {
498 nativeDestroy(nativeShellHolderId);
499 nativeShellHolderId = null;
500 } finally {
501 shellHolderLock.writeLock().unlock();
502 }
503 }

◆ dispatchEmptyPlatformMessage()

void io.flutter.embedding.engine.FlutterJNI.dispatchEmptyPlatformMessage ( @NonNull String  channel,
int  responseId 
)
inline

Sends an empty reply (identified by responseId) from Android to Flutter over the given channel.

Definition at line 1087 of file FlutterJNI.java.

1087 {
1088 ensureRunningOnMainThread();
1089 if (isAttached()) {
1090 nativeDispatchEmptyPlatformMessage(nativeShellHolderId, channel, responseId);
1091 } else {
1092 Log.w(
1093 TAG,
1094 "Tried to send a platform message to Flutter, but FlutterJNI was detached from native C++. Could not send. Channel: "
1095 + channel
1096 + ". Response ID: "
1097 + responseId);
1098 }
1099 }

◆ dispatchPlatformMessage()

void io.flutter.embedding.engine.FlutterJNI.dispatchPlatformMessage ( @NonNull String  channel,
@Nullable ByteBuffer  message,
int  position,
int  responseId 
)
inline

Sends a reply message from Android to Flutter over the given channel.

Definition at line 1107 of file FlutterJNI.java.

1108 {
1109 ensureRunningOnMainThread();
1110 if (isAttached()) {
1111 nativeDispatchPlatformMessage(nativeShellHolderId, channel, message, position, responseId);
1112 } else {
1113 Log.w(
1114 TAG,
1115 "Tried to send a platform message to Flutter, but FlutterJNI was detached from native C++. Could not send. Channel: "
1116 + channel
1117 + ". Response ID: "
1118 + responseId);
1119 }
1120 }
Win32Message message

◆ dispatchPointerDataPacket()

void io.flutter.embedding.engine.FlutterJNI.dispatchPointerDataPacket ( @NonNull ByteBuffer  buffer,
int  position 
)
inline

Sends a packet of pointer data to Flutter's engine.

Definition at line 752 of file FlutterJNI.java.

752 {
753 ensureRunningOnMainThread();
754 ensureAttachedToNative();
755 nativeDispatchPointerDataPacket(nativeShellHolderId, buffer, position);
756 }

◆ dispatchSemanticsAction() [1/3]

void io.flutter.embedding.engine.FlutterJNI.dispatchSemanticsAction ( int  nodeId,
@NonNull AccessibilityBridge.Action  action 
)
inline

Sends a semantics action to Flutter's engine, without any additional arguments.

Definition at line 828 of file FlutterJNI.java.

828 {
829 dispatchSemanticsAction(nodeId, action, null);
830 }
void dispatchSemanticsAction(int nodeId, @NonNull AccessibilityBridge.Action action)

◆ dispatchSemanticsAction() [2/3]

void io.flutter.embedding.engine.FlutterJNI.dispatchSemanticsAction ( int  nodeId,
@NonNull AccessibilityBridge.Action  action,
@Nullable Object  args 
)
inline

Sends a semantics action to Flutter's engine, with additional arguments.

Definition at line 833 of file FlutterJNI.java.

834 {
835 ensureAttachedToNative();
836
837 ByteBuffer encodedArgs = null;
838 int position = 0;
839 if (args != null) {
840 encodedArgs = StandardMessageCodec.INSTANCE.encodeMessage(args);
841 position = encodedArgs.position();
842 }
843 dispatchSemanticsAction(nodeId, action.value, encodedArgs, position);
844 }
G_BEGIN_DECLS G_MODULE_EXPORT FlValue * args

◆ dispatchSemanticsAction() [3/3]

void io.flutter.embedding.engine.FlutterJNI.dispatchSemanticsAction ( int  nodeId,
int  action,
@Nullable ByteBuffer  args,
int  argsPosition 
)
inline

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).

Definition at line 855 of file FlutterJNI.java.

856 {
857 ensureRunningOnMainThread();
858 ensureAttachedToNative();
859 nativeDispatchSemanticsAction(nativeShellHolderId, nodeId, action, args, argsPosition);
860 }

◆ getBitmap()

Bitmap io.flutter.embedding.engine.FlutterJNI.getBitmap ( )
inline

Definition at line 1464 of file FlutterJNI.java.

1464 {
1465 ensureRunningOnMainThread();
1466 ensureAttachedToNative();
1467 return nativeGetBitmap(nativeShellHolderId);
1468 }

◆ getIsSoftwareRenderingEnabled()

boolean io.flutter.embedding.engine.FlutterJNI.getIsSoftwareRenderingEnabled ( )
inline

Checks launch settings for whether software rendering is requested.

The value is the same per program.

Definition at line 239 of file FlutterJNI.java.

239 {
240 return nativeGetIsSoftwareRenderingEnabled();
241 }

◆ getObservatoryUri()

static String io.flutter.embedding.engine.FlutterJNI.getObservatoryUri ( )
inlinestatic

VM Service URI for the VM instance.

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

Deprecated:
replaced by getVMServiceUri().

Definition at line 264 of file FlutterJNI.java.

264 {
265 return vmServiceUri;
266 }

◆ getScaledFontSize()

float io.flutter.embedding.engine.FlutterJNI.getScaledFontSize ( float  fontSize,
int  configurationId 
)
inline

Definition at line 1316 of file FlutterJNI.java.

1316 {
1317 final DisplayMetrics metrics = SettingsChannel.getPastDisplayMetrics(configurationId);
1318 if (metrics == null) {
1319 Log.e(
1320 TAG,
1321 "getScaledFontSize called with configurationId "
1322 + String.valueOf(configurationId)
1323 + ", which can't be found.");
1324 return -1f;
1325 }
1326 return TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, fontSize, metrics)
1327 / metrics.density;
1328 }

◆ getVMServiceUri()

static String io.flutter.embedding.engine.FlutterJNI.getVMServiceUri ( )
inlinestatic

VM Service URI for the VM instance.

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

Definition at line 250 of file FlutterJNI.java.

250 {
251 return vmServiceUri;
252 }

◆ handlePlatformMessage()

void io.flutter.embedding.engine.FlutterJNI.handlePlatformMessage ( @NonNull final String  channel,
ByteBuffer  message,
final int  replyId,
final long  messageData 
)
inline

Definition at line 1057 of file FlutterJNI.java.

1061 {
1062 if (platformMessageHandler != null) {
1063 platformMessageHandler.handleMessageFromDart(channel, message, replyId, messageData);
1064 } else {
1065 nativeCleanupMessageData(messageData);
1066 }
1067 // TODO(mattcarroll): log dropped messages when in debug mode
1068 // (https://github.com/flutter/flutter/issues/25391)
1069 }
void handleMessageFromDart( @NonNull final String channel, @Nullable ByteBuffer message, final int replyId, long messageData)

◆ init()

void io.flutter.embedding.engine.FlutterJNI.init ( @NonNull Context  context,
@NonNull String[]  args,
@Nullable String  bundlePath,
@NonNull String  appStoragePath,
@NonNull String  engineCachesPath,
long  initTimeMillis 
)
inline

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
contextThe application context.
argsArguments to the Dart VM/Flutter engine.
bundlePathFor JIT runtimes, the path to the Dart kernel file for the application.
appStoragePathThe path to the application data directory.
engineCachesPathThe path to the application cache directory.
initTimeMillisThe time, in milliseconds, taken for initialization.

Definition at line 194 of file FlutterJNI.java.

200 {
201 if (FlutterJNI.initCalled) {
202 Log.w(TAG, "FlutterJNI.init called more than once");
203 }
204
205 FlutterJNI.nativeInit(
206 context, args, bundlePath, appStoragePath, engineCachesPath, initTimeMillis);
207 FlutterJNI.initCalled = true;
208 }

◆ invokePlatformMessageEmptyResponseCallback()

void io.flutter.embedding.engine.FlutterJNI.invokePlatformMessageEmptyResponseCallback ( int  responseId)
inline

Definition at line 1131 of file FlutterJNI.java.

1131 {
1132 // Called on any thread.
1133 shellHolderLock.readLock().lock();
1134 try {
1135 if (isAttached()) {
1136 nativeInvokePlatformMessageEmptyResponseCallback(nativeShellHolderId, responseId);
1137 } else {
1138 Log.w(
1139 TAG,
1140 "Tried to send a platform message response, but FlutterJNI was detached from native C++. Could not send. Response ID: "
1141 + responseId);
1142 }
1143 } finally {
1144 shellHolderLock.readLock().unlock();
1145 }
1146 }

◆ invokePlatformMessageResponseCallback()

void io.flutter.embedding.engine.FlutterJNI.invokePlatformMessageResponseCallback ( int  responseId,
@NonNull ByteBuffer  message,
int  position 
)
inline

Definition at line 1153 of file FlutterJNI.java.

1154 {
1155 // Called on any thread.
1156 if (!message.isDirect()) {
1157 throw new IllegalArgumentException("Expected a direct ByteBuffer.");
1158 }
1159 shellHolderLock.readLock().lock();
1160 try {
1161 if (isAttached()) {
1162 nativeInvokePlatformMessageResponseCallback(
1163 nativeShellHolderId, responseId, message, position);
1164 } else {
1165 Log.w(
1166 TAG,
1167 "Tried to send a platform message response, but FlutterJNI was detached from native C++. Could not send. Response ID: "
1168 + responseId);
1169 }
1170 } finally {
1171 shellHolderLock.readLock().unlock();
1172 }
1173 }

◆ isAttached()

boolean io.flutter.embedding.engine.FlutterJNI.isAttached ( )
inline

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

Definition at line 408 of file FlutterJNI.java.

408 {
409 return nativeShellHolderId != null;
410 }

◆ isCodePointEmoji()

boolean io.flutter.embedding.engine.FlutterJNI.isCodePointEmoji ( int  codePoint)
inline

Definition at line 353 of file FlutterJNI.java.

353 {
354 return nativeFlutterTextUtilsIsEmoji(codePoint);
355 }

◆ isCodePointEmojiModifier()

boolean io.flutter.embedding.engine.FlutterJNI.isCodePointEmojiModifier ( int  codePoint)
inline

Definition at line 359 of file FlutterJNI.java.

359 {
360 return nativeFlutterTextUtilsIsEmojiModifier(codePoint);
361 }

◆ isCodePointEmojiModifierBase()

boolean io.flutter.embedding.engine.FlutterJNI.isCodePointEmojiModifierBase ( int  codePoint)
inline

Definition at line 365 of file FlutterJNI.java.

365 {
366 return nativeFlutterTextUtilsIsEmojiModifierBase(codePoint);
367 }

◆ isCodePointRegionalIndicator()

boolean io.flutter.embedding.engine.FlutterJNI.isCodePointRegionalIndicator ( int  codePoint)
inline

Definition at line 377 of file FlutterJNI.java.

377 {
378 return nativeFlutterTextUtilsIsRegionalIndicator(codePoint);
379 }

◆ isCodePointVariantSelector()

boolean io.flutter.embedding.engine.FlutterJNI.isCodePointVariantSelector ( int  codePoint)
inline

Definition at line 371 of file FlutterJNI.java.

371 {
372 return nativeFlutterTextUtilsIsVariationSelector(codePoint);
373 }

◆ loadDartDeferredLibrary()

void io.flutter.embedding.engine.FlutterJNI.loadDartDeferredLibrary ( int  loadingUnitId,
@NonNull String[]  searchPaths 
)
inline

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
loadingUnitIdThe 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.
searchPathsAn 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.

Definition at line 1383 of file FlutterJNI.java.

1383 {
1384 ensureRunningOnMainThread();
1385 ensureAttachedToNative();
1386 nativeLoadDartDeferredLibrary(nativeShellHolderId, loadingUnitId, searchPaths);
1387 }

◆ loadLibrary()

void io.flutter.embedding.engine.FlutterJNI.loadLibrary ( )
inline

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.

Definition at line 142 of file FlutterJNI.java.

142 {
143 if (FlutterJNI.loadLibraryCalled) {
144 Log.w(TAG, "FlutterJNI.loadLibrary called more than once");
145 }
146
147 System.loadLibrary("flutter");
148 FlutterJNI.loadLibraryCalled = true;
149 }

◆ markTextureFrameAvailable()

void io.flutter.embedding.engine.FlutterJNI.markTextureFrameAvailable ( long  textureId)
inline

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.

Definition at line 941 of file FlutterJNI.java.

941 {
942 ensureRunningOnMainThread();
943 ensureAttachedToNative();
944 nativeMarkTextureFrameAvailable(nativeShellHolderId, textureId);
945 }

◆ nativeImageHeaderCallback()

static native void io.flutter.embedding.engine.FlutterJNI.nativeImageHeaderCallback ( long  imageGeneratorPointer,
int  width,
int  height 
)
static

◆ nativeLookupCallbackInformation()

static native FlutterCallbackInformation io.flutter.embedding.engine.FlutterJNI.nativeLookupCallbackInformation ( long  handle)
static

◆ notifyLowMemoryWarning()

void io.flutter.embedding.engine.FlutterJNI.notifyLowMemoryWarning ( )
inline

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.

Definition at line 1481 of file FlutterJNI.java.

1481 {
1482 ensureRunningOnMainThread();
1483 ensureAttachedToNative();
1484 nativeNotifyLowMemoryWarning(nativeShellHolderId);
1485 }

◆ onBeginFrame()

void io.flutter.embedding.engine.FlutterJNI.onBeginFrame ( )
inline

Definition at line 1223 of file FlutterJNI.java.

1223 {
1224 ensureRunningOnMainThread();
1225 if (platformViewsController == null) {
1226 throw new RuntimeException(
1227 "platformViewsController must be set before attempting to begin the frame");
1228 }
1229 platformViewsController.onBeginFrame();
1230 }

◆ onDisplayOverlaySurface()

void io.flutter.embedding.engine.FlutterJNI.onDisplayOverlaySurface ( int  id,
int  x,
int  y,
int  width,
int  height 
)
inline

Definition at line 1212 of file FlutterJNI.java.

1212 {
1213 ensureRunningOnMainThread();
1214 if (platformViewsController == null) {
1215 throw new RuntimeException(
1216 "platformViewsController must be set before attempting to position an overlay surface");
1217 }
1218 platformViewsController.onDisplayOverlaySurface(id, x, y, width, height);
1219 }
void onDisplayOverlaySurface(int id, int x, int y, int width, int height)
double y
double x
int32_t height
int32_t width

◆ onDisplayPlatformView()

void io.flutter.embedding.engine.FlutterJNI.onDisplayPlatformView ( int  viewId,
int  x,
int  y,
int  width,
int  height,
int  viewWidth,
int  viewHeight,
FlutterMutatorsStack  mutatorsStack 
)
inline

Definition at line 1444 of file FlutterJNI.java.

1452 {
1453 ensureRunningOnMainThread();
1454 if (platformViewsController == null) {
1455 throw new RuntimeException(
1456 "platformViewsController must be set before attempting to position a platform view");
1457 }
1458 platformViewsController.onDisplayPlatformView(
1459 viewId, x, y, width, height, viewWidth, viewHeight, mutatorsStack);
1460 }
void onDisplayPlatformView(int viewId, int x, int y, int width, int height, int viewWidth, int viewHeight, @NonNull FlutterMutatorsStack mutatorsStack)

◆ onEndFrame()

void io.flutter.embedding.engine.FlutterJNI.onEndFrame ( )
inline

Definition at line 1234 of file FlutterJNI.java.

1234 {
1235 ensureRunningOnMainThread();
1236 if (platformViewsController == null) {
1237 throw new RuntimeException(
1238 "platformViewsController must be set before attempting to end the frame");
1239 }
1240 platformViewsController.onEndFrame();
1241 }

◆ onFirstFrame()

void io.flutter.embedding.engine.FlutterJNI.onFirstFrame ( )
inline

Definition at line 587 of file FlutterJNI.java.

587 {
588 ensureRunningOnMainThread();
589
590 for (FlutterUiDisplayListener listener : flutterUiDisplayListeners) {
591 listener.onFlutterUiDisplayed();
592 }
593 }

◆ onRenderingStopped()

void io.flutter.embedding.engine.FlutterJNI.onRenderingStopped ( )
inlinepackage

Definition at line 598 of file FlutterJNI.java.

598 {
599 ensureRunningOnMainThread();
600
601 for (FlutterUiDisplayListener listener : flutterUiDisplayListeners) {
602 listener.onFlutterUiNoLongerDisplayed();
603 }
604 }

◆ onSurfaceChanged()

void io.flutter.embedding.engine.FlutterJNI.onSurfaceChanged ( int  width,
int  height 
)
inline

Call this method when the Surface changes that was previously registered with onSurfaceCreated(Surface).

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

Definition at line 647 of file FlutterJNI.java.

647 {
648 ensureRunningOnMainThread();
649 ensureAttachedToNative();
650 nativeSurfaceChanged(nativeShellHolderId, width, height);
651 }

◆ onSurfaceCreated()

void io.flutter.embedding.engine.FlutterJNI.onSurfaceCreated ( @NonNull Surface  surface)
inline

Call this method when a Surface has been created onto which you would like Flutter to paint.

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

Definition at line 614 of file FlutterJNI.java.

614 {
615 ensureRunningOnMainThread();
616 ensureAttachedToNative();
617 nativeSurfaceCreated(nativeShellHolderId, surface);
618 }
VkSurfaceKHR surface
Definition: main.cc:49

◆ onSurfaceDestroyed()

void io.flutter.embedding.engine.FlutterJNI.onSurfaceDestroyed ( )
inline

Call this method when the Surface is destroyed that was previously registered with onSurfaceCreated(Surface).

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

Definition at line 663 of file FlutterJNI.java.

663 {
664 ensureRunningOnMainThread();
665 ensureAttachedToNative();
667 nativeSurfaceDestroyed(nativeShellHolderId);
668 }

◆ onSurfaceWindowChanged()

void io.flutter.embedding.engine.FlutterJNI.onSurfaceWindowChanged ( @NonNull Surface  surface)
inline

In hybrid composition, call this method when the Surface has changed.

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

Definition at line 630 of file FlutterJNI.java.

630 {
631 ensureRunningOnMainThread();
632 ensureAttachedToNative();
633 nativeSurfaceWindowChanged(nativeShellHolderId, surface);
634 }

◆ onVsync()

void io.flutter.embedding.engine.FlutterJNI.onVsync ( long  frameDelayNanos,
long  refreshPeriodNanos,
long  cookie 
)
inline

Notifies the engine that the Choreographer has signaled a vsync.

Parameters
frameDelayNanosThe time in nanoseconds when the frame started being rendered, subtracted from the System#nanoTime timebase.
refreshPeriodNanosThe display refresh period in nanoseconds.
cookieAn opaque handle to the C++ VSyncWaiter object.

Definition at line 342 of file FlutterJNI.java.

342 {
343 nativeOnVsync(frameDelayNanos, refreshPeriodNanos, cookie);
344 }

◆ performNativeAttach()

long io.flutter.embedding.engine.FlutterJNI.performNativeAttach ( @NonNull FlutterJNI  flutterJNI)
inline

Definition at line 431 of file FlutterJNI.java.

431 {
432 return nativeAttach(flutterJNI);
433 }

◆ prefetchDefaultFontManager()

void io.flutter.embedding.engine.FlutterJNI.prefetchDefaultFontManager ( )
inline

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.

Definition at line 163 of file FlutterJNI.java.

163 {
164 if (FlutterJNI.prefetchDefaultFontManagerCalled) {
165 Log.w(TAG, "FlutterJNI.prefetchDefaultFontManager called more than once");
166 }
167
168 FlutterJNI.nativePrefetchDefaultFontManager();
169 FlutterJNI.prefetchDefaultFontManagerCalled = true;
170 }

◆ registerImageTexture()

void io.flutter.embedding.engine.FlutterJNI.registerImageTexture ( long  textureId,
@NonNull TextureRegistry.ImageConsumer  imageTexture 
)
inline

Registers a ImageTexture with the given id.

REQUIRED: Callers should eventually unregisterTexture with the same id.

Definition at line 918 of file FlutterJNI.java.

919 {
920 ensureRunningOnMainThread();
921 ensureAttachedToNative();
922 nativeRegisterImageTexture(
923 nativeShellHolderId,
924 textureId,
925 new WeakReference<TextureRegistry.ImageConsumer>(imageTexture));
926 }

◆ registerTexture()

void io.flutter.embedding.engine.FlutterJNI.registerTexture ( long  textureId,
@NonNull SurfaceTextureWrapper  textureWrapper 
)
inline

Gives control of a SurfaceTexture to Flutter so that Flutter can display that texture within Flutter's UI.

Definition at line 900 of file FlutterJNI.java.

900 {
901 ensureRunningOnMainThread();
902 ensureAttachedToNative();
903 nativeRegisterTexture(
904 nativeShellHolderId, textureId, new WeakReference<SurfaceTextureWrapper>(textureWrapper));
905 }

◆ removeEngineLifecycleListener()

void io.flutter.embedding.engine.FlutterJNI.removeEngineLifecycleListener ( @NonNull EngineLifecycleListener  engineLifecycleListener)
inline

Removes the given engineLifecycleListener, which was previously added using addIsDisplayingFlutterUiListener(FlutterUiDisplayListener).

Definition at line 1196 of file FlutterJNI.java.

1197 {
1198 ensureRunningOnMainThread();
1199 engineLifecycleListeners.remove(engineLifecycleListener);
1200 }

◆ removeIsDisplayingFlutterUiListener()

void io.flutter.embedding.engine.FlutterJNI.removeIsDisplayingFlutterUiListener ( @NonNull FlutterUiDisplayListener  listener)
inline

Removes a FlutterUiDisplayListener that was added with addIsDisplayingFlutterUiListener(FlutterUiDisplayListener).

Definition at line 539 of file FlutterJNI.java.

539 {
540 ensureRunningOnMainThread();
541 flutterUiDisplayListeners.remove(listener);
542 }

◆ requestDartDeferredLibrary()

void io.flutter.embedding.engine.FlutterJNI.requestDartDeferredLibrary ( int  loadingUnitId)
inline

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
loadingUnitIdThe loadingUnitId is assigned during compile time by gen_snapshot and is automatically retrieved when loadLibrary() is called on a dart deferred library.

Definition at line 1355 of file FlutterJNI.java.

1355 {
1356 if (deferredComponentManager != null) {
1357 deferredComponentManager.installDeferredComponent(loadingUnitId, null);
1358 } else {
1359 // TODO(garyq): Add link to setup/instructions guide wiki.
1360 Log.e(
1361 TAG,
1362 "No DeferredComponentManager found. Android setup must be completed before using split AOT deferred components.");
1363 }
1364 }
abstract void installDeferredComponent(int loadingUnitId, String componentName)

◆ runBundleAndSnapshotFromLibrary()

void io.flutter.embedding.engine.FlutterJNI.runBundleAndSnapshotFromLibrary ( @NonNull String  bundlePath,
@Nullable String  entrypointFunctionName,
@Nullable String  pathToEntrypointFunction,
@NonNull AssetManager  assetManager,
@Nullable List< String >  entrypointArgs 
)
inline

Executes a Dart entrypoint.

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

Definition at line 981 of file FlutterJNI.java.

986 {
987 ensureRunningOnMainThread();
988 ensureAttachedToNative();
989 nativeRunBundleAndSnapshotFromLibrary(
990 nativeShellHolderId,
991 bundlePath,
992 entrypointFunctionName,
993 pathToEntrypointFunction,
994 assetManager,
995 entrypointArgs);
996 }

◆ scheduleFrame()

void io.flutter.embedding.engine.FlutterJNI.scheduleFrame ( )
inline

Schedule the engine to draw a frame but does not invalidate the layout tree.

Definition at line 951 of file FlutterJNI.java.

951 {
952 ensureRunningOnMainThread();
953 ensureAttachedToNative();
954 nativeScheduleFrame(nativeShellHolderId);
955 }

◆ setAccessibilityDelegate()

void io.flutter.embedding.engine.FlutterJNI.setAccessibilityDelegate ( @Nullable AccessibilityDelegate  accessibilityDelegate)
inline

Sets the AccessibilityDelegate for the attached Flutter context.

The 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 AccessibilityDelegate and the surrounding responsibilities.

Definition at line 780 of file FlutterJNI.java.

780 {
781 ensureRunningOnMainThread();
782 this.accessibilityDelegate = accessibilityDelegate;
783 }

◆ setAccessibilityFeatures()

void io.flutter.embedding.engine.FlutterJNI.setAccessibilityFeatures ( int  flags)
inline

Definition at line 885 of file FlutterJNI.java.

885 {
886 ensureRunningOnMainThread();
887 ensureAttachedToNative();
888 nativeSetAccessibilityFeatures(nativeShellHolderId, flags);
889 }
FlutterSemanticsFlag flags

◆ setAsyncWaitForVsyncDelegate()

void io.flutter.embedding.engine.FlutterJNI.setAsyncWaitForVsyncDelegate ( @Nullable AsyncWaitForVsyncDelegate  delegate)
inline

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 android.view.Choreographer, and call onVsync to notify the engine.

Parameters
delegateThe delegate that will call the engine back on the next vsync signal.

Definition at line 317 of file FlutterJNI.java.

317 {
318 asyncWaitForVsyncDelegate = delegate;
319 }

◆ setDeferredComponentManager()

void io.flutter.embedding.engine.FlutterJNI.setDeferredComponentManager ( @Nullable DeferredComponentManager  deferredComponentManager)
inline

Sets the deferred component manager that is used to download and install split features.

Definition at line 1334 of file FlutterJNI.java.

1335 {
1336 ensureRunningOnMainThread();
1337 this.deferredComponentManager = deferredComponentManager;
1338 if (deferredComponentManager != null) {
1339 deferredComponentManager.setJNI(this);
1340 }
1341 }

◆ setLocalizationPlugin()

void io.flutter.embedding.engine.FlutterJNI.setLocalizationPlugin ( @Nullable LocalizationPlugin  localizationPlugin)
inline

Sets the localization plugin that is used in various localization methods.

Definition at line 1270 of file FlutterJNI.java.

1270 {
1271 ensureRunningOnMainThread();
1272 this.localizationPlugin = localizationPlugin;
1273 }

◆ setPlatformMessageHandler()

void io.flutter.embedding.engine.FlutterJNI.setPlatformMessageHandler ( @Nullable PlatformMessageHandler  platformMessageHandler)
inline

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:

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. See io.flutter.view.FlutterNativeView for an example implementation.

Definition at line 1034 of file FlutterJNI.java.

1034 {
1035 ensureRunningOnMainThread();
1036 this.platformMessageHandler = platformMessageHandler;
1037 }

◆ setPlatformViewsController()

void io.flutter.embedding.engine.FlutterJNI.setPlatformViewsController ( @NonNull PlatformViewsController  platformViewsController)
inline

Definition at line 763 of file FlutterJNI.java.

763 {
764 ensureRunningOnMainThread();
765 this.platformViewsController = platformViewsController;
766 }

◆ setRefreshRateFPS()

void io.flutter.embedding.engine.FlutterJNI.setRefreshRateFPS ( float  refreshRateFPS)
inline

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 android.view.Display#getRefreshRate frequently, since it is expensive on some vendor implementations.

Parameters
refreshRateFPSThe refresh rate in nanoseconds.

Definition at line 279 of file FlutterJNI.java.

279 {
280 // This is ok because it only ever tracks the refresh rate of the main
281 // display. If we ever need to support the refresh rate of other displays
282 // on Android we will need to refactor this. Static lookup makes things a
283 // bit easier on the C++ side.
284 FlutterJNI.refreshRateFPS = refreshRateFPS;
286 }

◆ setSemanticsEnabled()

void io.flutter.embedding.engine.FlutterJNI.setSemanticsEnabled ( boolean  enabled)
inline

Instructs Flutter to enable/disable its semantics tree, which is used by Flutter to support accessibility and related behaviors.

Definition at line 874 of file FlutterJNI.java.

874 {
875 ensureRunningOnMainThread();
876 ensureAttachedToNative();
877 nativeSetSemanticsEnabled(nativeShellHolderId, enabled);
878 }

◆ setViewportMetrics()

void io.flutter.embedding.engine.FlutterJNI.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 
)
inline

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.

Definition at line 680 of file FlutterJNI.java.

699 {
700 ensureRunningOnMainThread();
701 ensureAttachedToNative();
702 nativeSetViewportMetrics(
703 nativeShellHolderId,
704 devicePixelRatio,
705 physicalWidth,
706 physicalHeight,
707 physicalPaddingTop,
708 physicalPaddingRight,
709 physicalPaddingBottom,
710 physicalPaddingLeft,
711 physicalViewInsetTop,
712 physicalViewInsetRight,
713 physicalViewInsetBottom,
714 physicalViewInsetLeft,
715 systemGestureInsetTop,
716 systemGestureInsetRight,
717 systemGestureInsetBottom,
718 systemGestureInsetLeft,
719 physicalTouchSlop,
720 displayFeaturesBounds,
721 displayFeaturesType,
722 displayFeaturesState);
723 }

◆ spawn()

FlutterJNI io.flutter.embedding.engine.FlutterJNI.spawn ( @Nullable String  entrypointFunctionName,
@Nullable String  pathToEntrypointFunction,
@Nullable String  initialRoute,
@Nullable List< String >  entrypointArgs 
)
inline

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) shouldn't be called again on the spawned FlutterJNI instance.

Definition at line 452 of file FlutterJNI.java.

456 {
457 ensureRunningOnMainThread();
458 ensureAttachedToNative();
459 FlutterJNI spawnedJNI =
460 nativeSpawn(
461 nativeShellHolderId,
462 entrypointFunctionName,
463 pathToEntrypointFunction,
464 initialRoute,
465 entrypointArgs);
466 Preconditions.checkState(
467 spawnedJNI.nativeShellHolderId != null && spawnedJNI.nativeShellHolderId != 0,
468 "Failed to spawn new JNI connected shell from existing shell.");
469
470 return spawnedJNI;
471 }

◆ unregisterTexture()

void io.flutter.embedding.engine.FlutterJNI.unregisterTexture ( long  textureId)
inline

Unregisters a texture that was registered with registerTexture(long, SurfaceTextureWrapper).

Definition at line 964 of file FlutterJNI.java.

964 {
965 ensureRunningOnMainThread();
966 ensureAttachedToNative();
967 nativeUnregisterTexture(nativeShellHolderId, textureId);
968 }

◆ updateDisplayMetrics()

void io.flutter.embedding.engine.FlutterJNI.updateDisplayMetrics ( int  displayId,
float  width,
float  height,
float  density 
)
inline

Definition at line 288 of file FlutterJNI.java.

288 {
289 FlutterJNI.displayWidth = width;
290 FlutterJNI.displayHeight = height;
291 FlutterJNI.displayDensity = density;
292 if (!FlutterJNI.loadLibraryCalled) {
293 return;
294 }
295 nativeUpdateDisplayMetrics(nativeShellHolderId);
296 }

◆ updateJavaAssetManager()

void io.flutter.embedding.engine.FlutterJNI.updateJavaAssetManager ( @NonNull AssetManager  assetManager,
@NonNull String  assetBundlePath 
)
inline

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
assetManagerAn android AssetManager that is able to access the newly downloaded assets.
assetBundlePathThe subdirectory that the flutter assets are stored in. The typical value is flutter_assets.

Definition at line 1403 of file FlutterJNI.java.

1404 {
1405 ensureRunningOnMainThread();
1406 ensureAttachedToNative();
1407 nativeUpdateJavaAssetManager(nativeShellHolderId, assetManager, assetBundlePath);
1408 }

◆ updateRefreshRate()

void io.flutter.embedding.engine.FlutterJNI.updateRefreshRate ( )
inline

Definition at line 300 of file FlutterJNI.java.

300 {
301 if (!FlutterJNI.loadLibraryCalled) {
302 return;
303 }
304 nativeUpdateRefreshRate(refreshRateFPS);
305 }

The documentation for this class was generated from the following file: