This is the Android owner of the core engine Shell. More...
#include <android_shell_holder.h>
Public Member Functions | |
| AndroidShellHolder (const flutter::Settings &settings, std::shared_ptr< PlatformViewAndroidJNI > jni_facade, AndroidRenderingAPI android_rendering_api) | |
| ~AndroidShellHolder () | |
| bool | IsValid () const |
| std::unique_ptr< AndroidShellHolder > | Spawn (std::shared_ptr< PlatformViewAndroidJNI > jni_facade, const std::string &entrypoint, const std::string &libraryUrl, const std::string &initial_route, const std::vector< std::string > &entrypoint_args, int64_t engine_id) const |
| This is a factory for a derived AndroidShellHolder from an existing AndroidShellHolder. | |
| void | Launch (std::unique_ptr< APKAssetProvider > apk_asset_provider, const std::string &entrypoint, const std::string &libraryUrl, const std::vector< std::string > &entrypoint_args, int64_t engine_id) |
| const flutter::Settings & | GetSettings () const |
| fml::WeakPtr< PlatformViewAndroid > | GetPlatformView () |
| bool | IsSurfaceControlEnabled () |
| Rasterizer::Screenshot | Screenshot (Rasterizer::ScreenshotType type, bool base64_encode) |
| void | NotifyLowMemoryWarning () |
| const std::shared_ptr< PlatformMessageHandler > & | GetPlatformMessageHandler () const |
| void | UpdateDisplayMetrics () |
| const std::unique_ptr< Shell > & | GetShellForTesting () const |
This is the Android owner of the core engine Shell.
This is the top orchestrator class on the C++ side for the Android embedding. It corresponds to a FlutterEngine on the Java side. This class is in C++ because the Shell is in C++ and an Android orchestrator needs to exist to compose it with other Android specific C++ components such as the PlatformViewAndroid. This composition of many-to-one C++ components would be difficult to do through JNI whereas a FlutterEngine and AndroidShellHolder has a 1:1 relationship.
Technically, the FlutterJNI class owns this AndroidShellHolder class instance, but the FlutterJNI class is meant to be mostly static and has minimal state to perform the C++ pointer <-> Java class instance translation.
Definition at line 38 of file android_shell_holder.h.
| flutter::AndroidShellHolder::AndroidShellHolder | ( | const flutter::Settings & | settings, |
| std::shared_ptr< PlatformViewAndroidJNI > | jni_facade, | ||
| AndroidRenderingAPI | android_rendering_api | ||
| ) |
Definition at line 82 of file android_shell_holder.cc.
References flutter::AndroidPlatformThreadConfigSetter(), flutter::buffer, flutter::Shell::Create(), fml::MessageLoop::EnsureInitializedForCurrentThread(), FML_DCHECK, FML_DLOG, FML_LOG, fml::MessageLoop::GetCurrent(), flutter::GetDefaultPlatformData(), flutter::TaskRunners::GetIOTaskRunner(), fml::MessageLoop::GetTaskRunner(), flutter::ThreadHost::ThreadHostConfig::io_config, fml::Thread::kDisplay, flutter::Settings::kEnabled, flutter::ThreadHost::kIo, fml::Thread::kNormal, fml::Thread::kRaster, flutter::ThreadHost::kRaster, flutter::ThreadHost::kUi, flutter::AndroidImageGenerator::MakeFromData(), flutter::ThreadHost::ThreadHostConfig::MakeThreadName(), flutter::Settings::merged_platform_ui_thread, flutter::ThreadHost::ThreadHostConfig::raster_config, and flutter::ThreadHost::ThreadHostConfig::ui_config.
| flutter::AndroidShellHolder::~AndroidShellHolder | ( | ) |
Definition at line 209 of file android_shell_holder.cc.
|
inline |
Definition at line 102 of file android_shell_holder.h.
| fml::WeakPtr< PlatformViewAndroid > flutter::AndroidShellHolder::GetPlatformView | ( | ) |
Definition at line 316 of file android_shell_holder.cc.
References FML_DCHECK.
Referenced by IsSurfaceControlEnabled().
| const flutter::Settings & flutter::AndroidShellHolder::GetSettings | ( | ) | const |
Definition at line 218 of file android_shell_holder.cc.
Referenced by Spawn().
|
inline |
Definition at line 110 of file android_shell_holder.h.
| bool flutter::AndroidShellHolder::IsSurfaceControlEnabled | ( | ) |
Definition at line 367 of file android_shell_holder.cc.
References GetPlatformView().
| bool flutter::AndroidShellHolder::IsValid | ( | ) | const |
Definition at line 214 of file android_shell_holder.cc.
Referenced by Launch(), and Screenshot().
| void flutter::AndroidShellHolder::Launch | ( | std::unique_ptr< APKAssetProvider > | apk_asset_provider, |
| const std::string & | entrypoint, | ||
| const std::string & | libraryUrl, | ||
| const std::vector< std::string > & | entrypoint_args, | ||
| int64_t | engine_id | ||
| ) |
Definition at line 287 of file android_shell_holder.cc.
References IsValid(), and UpdateDisplayMetrics().
| void flutter::AndroidShellHolder::NotifyLowMemoryWarning | ( | ) |
Definition at line 321 of file android_shell_holder.cc.
References FML_DCHECK.
| Rasterizer::Screenshot flutter::AndroidShellHolder::Screenshot | ( | Rasterizer::ScreenshotType | type, |
| bool | base64_encode | ||
| ) |
Definition at line 307 of file android_shell_holder.cc.
References IsValid(), flutter::Rasterizer::kUnknown, and type.
| std::unique_ptr< AndroidShellHolder > flutter::AndroidShellHolder::Spawn | ( | std::shared_ptr< PlatformViewAndroidJNI > | jni_facade, |
| const std::string & | entrypoint, | ||
| const std::string & | libraryUrl, | ||
| const std::string & | initial_route, | ||
| const std::vector< std::string > & | entrypoint_args, | ||
| int64_t | engine_id | ||
| ) | const |
This is a factory for a derived AndroidShellHolder from an existing AndroidShellHolder.
Creates one Shell from another Shell where the created Shell takes the opportunity to share any internal components it can. This results is a Shell that has a smaller startup time cost and a smaller memory footprint than an Shell created with a Create function.
The new Shell is returned in a new AndroidShellHolder instance.
The new Shell's flutter::Settings cannot be changed from that of the initial Shell. The RunConfiguration subcomponent can be changed however in the spawned Shell to run a different entrypoint than the existing shell.
Since the AndroidShellHolder both binds downwards to a Shell and also upwards to JNI callbacks that the PlatformViewAndroid makes, the JNI instance holding this AndroidShellHolder should be created first to supply the jni_facade callback.
| [in] | jni_facade | this argument should be the JNI callback facade of a new JNI instance meant to hold this AndroidShellHolder. |
Definition at line 222 of file android_shell_holder.cc.
References FML_DCHECK, flutter::PlatformViewAndroid::GetAndroidContext(), and GetSettings().
| void flutter::AndroidShellHolder::UpdateDisplayMetrics | ( | ) |