diff --git a/shell/platform/android/io/flutter/app/FlutterActivity.java b/shell/platform/android/io/flutter/app/FlutterActivity.java index 6f8c13f46218b..816b0c13e3684 100644 --- a/shell/platform/android/io/flutter/app/FlutterActivity.java +++ b/shell/platform/android/io/flutter/app/FlutterActivity.java @@ -15,7 +15,13 @@ import io.flutter.view.FlutterNativeView; import io.flutter.view.FlutterView; -/** Base class for activities that use Flutter. */ +/** + * Deprecated base class for activities that use Flutter. + * + *
Deprecation: {@link io.flutter.embedding.android.FlutterActivity} is the new API that now + * replaces this class. See https://flutter.dev/go/android-project-migration for more migration + * details. + */ public class FlutterActivity extends Activity implements FlutterView.Provider, PluginRegistry, ViewFactory { private static final String TAG = "FlutterActivity"; diff --git a/shell/platform/android/io/flutter/app/FlutterApplication.java b/shell/platform/android/io/flutter/app/FlutterApplication.java index 1a5716d3c6d5b..1dc11e868c8d3 100644 --- a/shell/platform/android/io/flutter/app/FlutterApplication.java +++ b/shell/platform/android/io/flutter/app/FlutterApplication.java @@ -12,6 +12,9 @@ /** * Flutter implementation of {@link android.app.Application}, managing application-level global * initializations. + * + *
Using this {@link android.app.Application} is not required when using APIs in the package + * {@code io.flutter.embedding.android} since they self-initialize on first use. */ public class FlutterApplication extends Application { @Override diff --git a/shell/platform/android/io/flutter/app/FlutterPluginRegistry.java b/shell/platform/android/io/flutter/app/FlutterPluginRegistry.java index 54d9c801f4f80..b1979694cffdf 100644 --- a/shell/platform/android/io/flutter/app/FlutterPluginRegistry.java +++ b/shell/platform/android/io/flutter/app/FlutterPluginRegistry.java @@ -21,6 +21,8 @@ import java.util.List; import java.util.Map; +/// This class is now deprecated. See https://flutter.dev/go/android-project-migration for +/// migration instructions. public class FlutterPluginRegistry implements PluginRegistry, PluginRegistry.RequestPermissionsResultListener, diff --git a/shell/platform/android/io/flutter/embedding/android/FlutterActivity.java b/shell/platform/android/io/flutter/embedding/android/FlutterActivity.java index fa74bc53fd7d5..cb88fa4430e25 100644 --- a/shell/platform/android/io/flutter/embedding/android/FlutterActivity.java +++ b/shell/platform/android/io/flutter/embedding/android/FlutterActivity.java @@ -51,11 +51,27 @@ *
{@code FlutterActivity} is the simplest and most direct way to integrate Flutter within an * Android app. * + *
FlutterActivity responsibilities + * + *
{@code FlutterActivity} maintains the following responsibilities: + * + *
Dart entrypoint, initial route, and app bundle path * *
The Dart entrypoint executed within this {@code Activity} is "main()" by default. To change * the entrypoint that a {@code FlutterActivity} executes, subclass {@code FlutterActivity} and - * override {@link #getDartEntrypointFunctionName()}. + * override {@link #getDartEntrypointFunctionName()}. For non-main Dart entrypoints to not be + * tree-shaken away, you need to annotate those functions with {@code @pragma('vm:entry-point')} in + * Dart. * *
The Flutter route that is initially loaded within this {@code Activity} is "/". The initial * route may be specified explicitly by passing the name of the route as a {@code String} in {@link @@ -73,11 +89,8 @@ *
The Dart entrypoint and app bundle path are not supported as {@code Intent} parameters due to - * security concerns. If such configurations were exposed via {@code Intent}, then a {@code - * FlutterActivity} that is {@code exported} from your Android app would allow other apps to invoke - * arbitrary Dart entrypoints in your app by specifying different Dart entrypoints for your {@code - * FlutterActivity}. Therefore, these configurations are not available via {@code Intent}. + *
The Dart entrypoint and app bundle path are not supported as {@code Intent} parameters since + * your Dart library entrypoints are your private APIs and Intents are invocable by other processes. * *
Using a cached FlutterEngine * @@ -85,8 +98,10 @@ * new one. Use {@link #withCachedEngine(String)} to build a {@code FlutterActivity} {@code Intent} * that is configured to use an existing, cached {@link FlutterEngine}. {@link * io.flutter.embedding.engine.FlutterEngineCache} is the cache that is used to obtain a given - * cached {@link FlutterEngine}. An {@code IllegalStateException} will be thrown if a cached engine - * is requested but does not exist in the cache. + * cached {@link FlutterEngine}. You must create and put a {@link FlutterEngine} into the {@link + * io.flutter.embedding.engine.FlutterEngineCache} yourself before using the {@link + * #withCachedEngine(String)} builder. An {@code IllegalStateException} will be thrown if a cached + * engine is requested but does not exist in the cache. * *
When using a cached {@link FlutterEngine}, that {@link FlutterEngine} should already be * executing Dart code, which means that the Dart entrypoint and initial route have already been @@ -105,6 +120,9 @@ *
See https://flutter.dev/docs/development/add-to-app/performance for additional performance + * explorations on engine loading. + * *
The following illustrates how to pre-warm and cache a {@link FlutterEngine}: * *
{@code
@@ -126,20 +144,6 @@
* FlutterView}. Using a {@link FlutterView} requires forwarding some calls from an {@code
* Activity}, as well as forwarding lifecycle calls from an {@code Activity} or a {@code Fragment}.
*
- * FlutterActivity responsibilities
- *
- *
{@code FlutterActivity} maintains the following responsibilities:
- *
- *
Launch Screen and Splash Screen * *
{@code FlutterActivity} supports the display of an Android "launch screen" as well as a @@ -196,8 +200,12 @@ public class FlutterActivity extends Activity private static final String TAG = "FlutterActivity"; /** - * Creates an {@link Intent} that launches a {@code FlutterActivity}, which executes a {@code - * main()} Dart entrypoint, and displays the "/" route as Flutter's initial route. + * Creates an {@link Intent} that launches a {@code FlutterActivity}, which creates a {@link + * FlutterEngine} that executes a {@code main()} Dart entrypoint, and displays the "/" route as + * Flutter's initial route. + * + *
Consider using the {@link #withCachedEngine(String)} {@link Intent} builder to control when + * the {@link FlutterEngine} should be created in your application. */ @NonNull public static Intent createDefaultIntent(@NonNull Context launchContext) { diff --git a/shell/platform/android/io/flutter/embedding/engine/FlutterEngine.java b/shell/platform/android/io/flutter/embedding/engine/FlutterEngine.java index 0c094e0bb1e7f..b817618c72108 100644 --- a/shell/platform/android/io/flutter/embedding/engine/FlutterEngine.java +++ b/shell/platform/android/io/flutter/embedding/engine/FlutterEngine.java @@ -44,7 +44,8 @@ * interaction. * *
Multiple {@code FlutterEngine}s may exist, execute Dart code, and render UIs within a single - * Android app. + * Android app. Flutter at this point makes no guarantees on the performance of running multiple + * engines. Use at your own risk. See https://github.com/flutter/flutter/issues/37644 for details. * *
To start running Dart and/or Flutter within this {@code FlutterEngine}, get a reference to * this engine's {@link DartExecutor} and then use {@link diff --git a/shell/platform/android/io/flutter/embedding/engine/dart/DartExecutor.java b/shell/platform/android/io/flutter/embedding/engine/dart/DartExecutor.java index 4ae449a3d1f69..edf9ef9adbdd9 100644 --- a/shell/platform/android/io/flutter/embedding/engine/dart/DartExecutor.java +++ b/shell/platform/android/io/flutter/embedding/engine/dart/DartExecutor.java @@ -26,8 +26,7 @@ * *
To specify a Dart callback to execute, use a {@link DartCallback}. A given Dart callback must * be registered with the Dart VM to be invoked by a {@link DartExecutor}. To execute the callback, - * pass the {@link DartCallback} to {@link #executeDartCallback(DartCallback)}. TODO(mattcarroll): - * add a reference to docs about background/plugin execution + * pass the {@link DartCallback} to {@link #executeDartCallback(DartCallback)}. * *
Once started, a {@link DartExecutor} cannot be stopped. The associated Dart code will execute * until it completes, or until the {@link io.flutter.embedding.engine.FlutterEngine} that owns this diff --git a/shell/platform/android/io/flutter/plugin/common/PluginRegistry.java b/shell/platform/android/io/flutter/plugin/common/PluginRegistry.java index f0082bc667488..abd06c30f2f49 100644 --- a/shell/platform/android/io/flutter/plugin/common/PluginRegistry.java +++ b/shell/platform/android/io/flutter/plugin/common/PluginRegistry.java @@ -24,6 +24,9 @@ * registrant class is, again by default, called from the application's main {@link Activity}, which * defaults to an instance of {@link io.flutter.app.FlutterActivity}, itself a {@link * PluginRegistry}. + * + *
This class is now deprecated. See https://flutter.dev/go/android-project-migration for + * migration details. */ public interface PluginRegistry { /** diff --git a/shell/platform/android/io/flutter/view/FlutterMain.java b/shell/platform/android/io/flutter/view/FlutterMain.java index 34a9a2582c1cc..bbcea46b3775e 100644 --- a/shell/platform/android/io/flutter/view/FlutterMain.java +++ b/shell/platform/android/io/flutter/view/FlutterMain.java @@ -11,7 +11,11 @@ import android.support.annotation.VisibleForTesting; import io.flutter.embedding.engine.loader.FlutterLoader; -/** A class to intialize the Flutter engine. */ +/** + * A legacy class to initialize the Flutter engine. + * + *
Replaced by {@link io.flutter.embedding.engine.loader.FlutterLoader}. + */ public class FlutterMain { public static class Settings { diff --git a/shell/platform/android/io/flutter/view/FlutterView.java b/shell/platform/android/io/flutter/view/FlutterView.java index 55977a0f42b02..98066479053f0 100644 --- a/shell/platform/android/io/flutter/view/FlutterView.java +++ b/shell/platform/android/io/flutter/view/FlutterView.java @@ -60,7 +60,12 @@ import java.util.Locale; import java.util.concurrent.atomic.AtomicLong; -/** An Android view containing a Flutter app. */ +/** + * Deprecated Android view containing a Flutter app. + * + *
Deprecation: {@link io.flutter.embedding.android.FlutterView} is the new API that now replaces + * this class. See https://flutter.dev/go/android-project-migration for more migration details. + */ public class FlutterView extends SurfaceView implements BinaryMessenger, TextureRegistry { /** * Interface for those objects that maintain and expose a reference to a {@code FlutterView} (such