5package dev.flutter.scenarios;
13import androidx.annotation.NonNull;
14import androidx.annotation.Nullable;
15import androidx.core.view.WindowCompat;
16import androidx.core.view.WindowInsetsCompat;
17import androidx.core.view.WindowInsetsControllerCompat;
18import io.flutter.FlutterInjector;
19import io.flutter.embedding.engine.FlutterShellArgs;
20import io.flutter.embedding.engine.loader.FlutterLoader;
21import io.flutter.plugin.common.JSONMethodCodec;
22import io.flutter.plugin.common.MethodChannel;
23import java.util.HashMap;
25import java.util.Objects;
26import java.util.concurrent.atomic.AtomicBoolean;
30 protected void onCreate(@Nullable Bundle savedInstanceState) {
31 super.onCreate(savedInstanceState);
32 hideSystemBars(getWindow());
44 FlutterShellArgs
args = FlutterShellArgs.fromIntent(getIntent());
45 args.add(FlutterShellArgs.ARG_TRACE_STARTUP);
46 args.add(FlutterShellArgs.ARG_ENABLE_DART_PROFILING);
47 args.add(FlutterShellArgs.ARG_VERBOSE_LOGGING);
53 final Intent launchIntent = getIntent();
54 MethodChannel channel =
56 Objects.requireNonNull(getFlutterEngine()).getDartExecutor(),
58 JSONMethodCodec.INSTANCE);
59 Map<String, Object>
test =
new HashMap<>(2);
60 if (launchIntent.hasExtra(
"scenario_name")) {
61 test.put(
"name", launchIntent.getStringExtra(
"scenario_name"));
63 test.put(
"name",
"animated_color_square");
65 test.put(
"use_android_view", launchIntent.getBooleanExtra(
"use_android_view",
false));
67 "expect_android_view_fallback",
68 launchIntent.getBooleanExtra(
"expect_android_view_fallback",
false));
69 test.put(
"view_type", launchIntent.getStringExtra(
"view_type"));
71 channel.invokeMethod(
"set_scenario",
test);
87 FlutterLoader flutterLoader = FlutterInjector.instance().flutterLoader();
92 flutterLoader.startInitialization(getApplicationContext());
93 flutterLoader.ensureInitializationComplete(getApplication(),
new String[] {});
97 Handler mainHandler =
new Handler(Looper.getMainLooper());
99 final AtomicBoolean didInvokeCallback =
new AtomicBoolean(
false);
101 flutterLoader.ensureInitializationCompleteAsync(
102 getApplication(),
new String[] {}, mainHandler, () -> didInvokeCallback.set(
true));
106 if (!didInvokeCallback.get()) {
107 throw new RuntimeException(
108 "Failed test: FlutterLoader#ensureInitializationCompleteAsync() did not invoke its callback.");
114 final WindowInsetsControllerCompat insetController =
115 WindowCompat.getInsetsController(
window,
window.getDecorView());
116 assert insetController !=
null;
117 insetController.setSystemBarsBehavior(
118 WindowInsetsControllerCompat.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE);
119 insetController.hide(WindowInsetsCompat.Type.systemBars());
void testFlutterLoaderCallbackWhenInitializedTwice()
FlutterShellArgs getFlutterShellArgs()
void onFlutterUiDisplayed()
void onCreate(@Nullable Bundle savedInstanceState)
void getScenarioParams(@NonNull Map< String, Object > args)
G_BEGIN_DECLS G_MODULE_EXPORT FlValue * args