@@ -106,6 +106,24 @@ public class FlutterJNI {
106106 // platform thread and doesn't require locking.
107107 private ReentrantReadWriteLock shellHolderLock = new ReentrantReadWriteLock ();
108108
109+ // Prefer using the FlutterJNI.Factory so it's easier to test.
110+ public FlutterJNI () {
111+ // We cache the main looper so that we can ensure calls are made on the main thread
112+ // without consistently paying the synchronization cost of getMainLooper().
113+ mainLooper = Looper .getMainLooper ();
114+ }
115+
116+ /**
117+ * A factory for creating {@code FlutterJNI} instances. Useful for FlutterJNI injections during
118+ * tests.
119+ */
120+ public static class Factory {
121+ /** @return a {@link FlutterJNI} instance. */
122+ public FlutterJNI provideFlutterJNI () {
123+ return new FlutterJNI ();
124+ }
125+ }
126+
109127 // BEGIN Methods related to loading for FlutterLoader.
110128 /**
111129 * Loads the libflutter.so C++ library.
@@ -126,6 +144,8 @@ public void loadLibrary() {
126144
127145 private static boolean loadLibraryCalled = false ;
128146
147+ private static native void nativePrefetchDefaultFontManager ();
148+
129149 /**
130150 * Prefetch the default font manager provided by SkFontMgr::RefDefault() which is a process-wide
131151 * singleton owned by Skia. Note that, the first call to SkFontMgr::RefDefault() will take
@@ -142,10 +162,16 @@ public void prefetchDefaultFontManager() {
142162 FlutterJNI .prefetchDefaultFontManagerCalled = true ;
143163 }
144164
145- private static native void nativePrefetchDefaultFontManager ();
146-
147165 private static boolean prefetchDefaultFontManagerCalled = false ;
148166
167+ private static native void nativeInit (
168+ @ NonNull Context context ,
169+ @ NonNull String [] args ,
170+ @ Nullable String bundlePath ,
171+ @ NonNull String appStoragePath ,
172+ @ NonNull String engineCachesPath ,
173+ long initTimeMillis );
174+
149175 /**
150176 * Perform one time initialization of the Dart VM and Flutter engine.
151177 *
@@ -174,14 +200,6 @@ public void init(
174200 FlutterJNI .initCalled = true ;
175201 }
176202
177- private static native void nativeInit (
178- @ NonNull Context context ,
179- @ NonNull String [] args ,
180- @ Nullable String bundlePath ,
181- @ NonNull String appStoragePath ,
182- @ NonNull String engineCachesPath ,
183- long initTimeMillis );
184-
185203 private static boolean initCalled = false ;
186204 // END methods related to FlutterLoader
187205
@@ -201,23 +219,23 @@ private static native void nativeInit(
201219
202220 private native boolean nativeGetIsSoftwareRenderingEnabled ();
203221
204- @ UiThread
205222 /**
206223 * Checks launch settings for whether software rendering is requested.
207224 *
208225 * <p>The value is the same per program.
209226 */
227+ @ UiThread
210228 public boolean getIsSoftwareRenderingEnabled () {
211229 return nativeGetIsSoftwareRenderingEnabled ();
212230 }
213231
214- @ Nullable
215232 /**
216233 * Observatory URI for the VM instance.
217234 *
218235 * <p>Its value is set by the native engine once {@link #init(Context, String[], String, String,
219236 * String, long)} is run.
220237 */
238+ @ Nullable
221239 public static String getObservatoryUri () {
222240 return observatoryUri ;
223241 }
@@ -245,7 +263,7 @@ public void setRefreshRateFPS(float refreshRateFPS) {
245263 * The Android vsync waiter implementation in C++ needs to know when a vsync signal arrives, which
246264 * is obtained via Java API. The delegate set here is called on the C++ side when the engine is
247265 * ready to wait for the next vsync signal. The delegate is expected to add a postFrameCallback to
248- * the {@link android.view.Choreographer}, and call {@link nativeOnVsync } to notify the engine.
266+ * the {@link android.view.Choreographer}, and call {@link onVsync } to notify the engine.
249267 *
250268 * @param delegate The delegate that will call the engine back on the next vsync signal.
251269 */
@@ -264,6 +282,8 @@ private static void asyncWaitForVsync(final long cookie) {
264282 }
265283 }
266284
285+ private native void nativeOnVsync (long frameDelayNanos , long refreshPeriodNanos , long cookie );
286+
267287 /**
268288 * Notifies the engine that the Choreographer has signaled a vsync.
269289 *
@@ -272,23 +292,44 @@ private static void asyncWaitForVsync(final long cookie) {
272292 * @param refreshPeriodNanos The display refresh period in nanoseconds.
273293 * @param cookie An opaque handle to the C++ VSyncWaiter object.
274294 */
275- public native void nativeOnVsync (long frameDelayNanos , long refreshPeriodNanos , long cookie );
295+ public void onVsync (long frameDelayNanos , long refreshPeriodNanos , long cookie ) {
296+ nativeOnVsync (frameDelayNanos , refreshPeriodNanos , cookie );
297+ }
276298
277- // TODO(mattcarroll): add javadocs
278299 @ NonNull
300+ @ Deprecated
279301 public static native FlutterCallbackInformation nativeLookupCallbackInformation (long handle );
280302
281303 // ----- Start FlutterTextUtils Methods ----
304+ private native boolean nativeFlutterTextUtilsIsEmoji (int codePoint );
282305
283- public native boolean nativeFlutterTextUtilsIsEmoji (int codePoint );
306+ public boolean isCodePointEmoji (int codePoint ) {
307+ return nativeFlutterTextUtilsIsEmoji (codePoint );
308+ }
309+
310+ private native boolean nativeFlutterTextUtilsIsEmojiModifier (int codePoint );
284311
285- public native boolean nativeFlutterTextUtilsIsEmojiModifier (int codePoint );
312+ public boolean isCodePointEmojiModifier (int codePoint ) {
313+ return nativeFlutterTextUtilsIsEmojiModifier (codePoint );
314+ }
286315
287- public native boolean nativeFlutterTextUtilsIsEmojiModifierBase (int codePoint );
316+ private native boolean nativeFlutterTextUtilsIsEmojiModifierBase (int codePoint );
317+
318+ public boolean isCodePointEmojiModifierBase (int codePoint ) {
319+ return nativeFlutterTextUtilsIsEmojiModifierBase (codePoint );
320+ }
288321
289- public native boolean nativeFlutterTextUtilsIsVariationSelector (int codePoint );
322+ private native boolean nativeFlutterTextUtilsIsVariationSelector (int codePoint );
290323
291- public native boolean nativeFlutterTextUtilsIsRegionalIndicator (int codePoint );
324+ public boolean isCodePointVariantSelector (int codePoint ) {
325+ return nativeFlutterTextUtilsIsVariationSelector (codePoint );
326+ }
327+
328+ private native boolean nativeFlutterTextUtilsIsRegionalIndicator (int codePoint );
329+
330+ public boolean isCodePointRegionalIndicator (int codePoint ) {
331+ return nativeFlutterTextUtilsIsRegionalIndicator (codePoint );
332+ }
292333
293334 // ----- End Engine FlutterTextUtils Methods ----
294335
@@ -312,13 +353,6 @@ private static void asyncWaitForVsync(final long cookie) {
312353
313354 @ NonNull private final Looper mainLooper ; // cached to avoid synchronization on repeat access.
314355
315- // Prefer using the FlutterJNI.Factory so it's easier to test.
316- public FlutterJNI () {
317- // We cache the main looper so that we can ensure calls are made on the main thread
318- // without consistently paying the synchronization cost of getMainLooper().
319- mainLooper = Looper .getMainLooper ();
320- }
321-
322356 // ------ Start Native Attach/Detach Support ----
323357 /**
324358 * Returns true if this instance of {@code FlutterJNI} is connected to Flutter's native engine via
@@ -1402,15 +1436,4 @@ void updateSemantics(
14021436 public interface AsyncWaitForVsyncDelegate {
14031437 void asyncWaitForVsync (final long cookie );
14041438 }
1405-
1406- /**
1407- * A factory for creating {@code FlutterJNI} instances. Useful for FlutterJNI injections during
1408- * tests.
1409- */
1410- public static class Factory {
1411- /** @return a {@link FlutterJNI} instance. */
1412- public FlutterJNI provideFlutterJNI () {
1413- return new FlutterJNI ();
1414- }
1415- }
14161439}
0 commit comments