diff --git a/engine/src/flutter/shell/platform/android/android_shell_holder.cc b/engine/src/flutter/shell/platform/android/android_shell_holder.cc index dd2c34c468..9a11a97c45 100644 --- a/engine/src/flutter/shell/platform/android/android_shell_holder.cc +++ b/engine/src/flutter/shell/platform/android/android_shell_holder.cc @@ -180,12 +180,14 @@ AndroidShellHolder::AndroidShellHolder( const std::shared_ptr& jni_facade, const std::shared_ptr& thread_host, std::unique_ptr shell, + std::unique_ptr apk_asset_provider, const fml::WeakPtr& platform_view) : settings_(settings), jni_facade_(jni_facade), platform_view_(platform_view), thread_host_(thread_host), - shell_(std::move(shell)) { + shell_(std::move(shell)), + apk_asset_provider_(std::move(apk_asset_provider)) { FML_DCHECK(jni_facade); FML_DCHECK(shell_); FML_DCHECK(shell_->IsSetup()); @@ -270,9 +272,9 @@ std::unique_ptr AndroidShellHolder::Spawn( shell_->Spawn(std::move(config.value()), initial_route, on_create_platform_view, on_create_rasterizer); - return std::unique_ptr( - new AndroidShellHolder(GetSettings(), jni_facade, thread_host_, - std::move(shell), weak_platform_view)); + return std::unique_ptr(new AndroidShellHolder( + GetSettings(), jni_facade, thread_host_, std::move(shell), + apk_asset_provider_->Clone(), weak_platform_view)); } void AndroidShellHolder::Launch( diff --git a/engine/src/flutter/shell/platform/android/android_shell_holder.h b/engine/src/flutter/shell/platform/android/android_shell_holder.h index 36c0b9629f..06866862f6 100644 --- a/engine/src/flutter/shell/platform/android/android_shell_holder.h +++ b/engine/src/flutter/shell/platform/android/android_shell_holder.h @@ -128,6 +128,7 @@ class AndroidShellHolder { const std::shared_ptr& jni_facade, const std::shared_ptr& thread_host, std::unique_ptr shell, + std::unique_ptr apk_asset_provider, const fml::WeakPtr& platform_view); static void ThreadDestructCallback(void* value); std::optional BuildRunConfiguration( diff --git a/engine/src/flutter/testing/scenario_app/android/BUILD.gn b/engine/src/flutter/testing/scenario_app/android/BUILD.gn index 200c90784f..111b7be100 100644 --- a/engine/src/flutter/testing/scenario_app/android/BUILD.gn +++ b/engine/src/flutter/testing/scenario_app/android/BUILD.gn @@ -21,9 +21,11 @@ _android_sources = [ "app/src/androidTest/java/dev/flutter/scenariosui/PlatformViewWithTextureViewUiTest.java", "app/src/androidTest/java/dev/flutter/scenariosui/ScreenshotUtil.java", "app/src/androidTest/java/dev/flutter/scenariosui/SpawnEngineTests.java", + "app/src/androidTest/java/dev/flutter/scenariosui/SpawnMultiEngineTest.java", "app/src/main/AndroidManifest.xml", "app/src/main/java/dev/flutter/scenarios/GetBitmapActivity.java", "app/src/main/java/dev/flutter/scenarios/PlatformViewsActivity.java", + "app/src/main/java/dev/flutter/scenarios/SpawnMultiEngineActivity.java", "app/src/main/java/dev/flutter/scenarios/SpawnedEngineActivity.java", "app/src/main/java/dev/flutter/scenarios/StrictModeFlutterActivity.java", "app/src/main/java/dev/flutter/scenarios/SurfacePlatformViewFactory.java", diff --git a/engine/src/flutter/testing/scenario_app/android/app/src/androidTest/java/dev/flutter/scenariosui/SpawnMultiEngineTest.java b/engine/src/flutter/testing/scenario_app/android/app/src/androidTest/java/dev/flutter/scenariosui/SpawnMultiEngineTest.java new file mode 100644 index 0000000000..bc1017b760 --- /dev/null +++ b/engine/src/flutter/testing/scenario_app/android/app/src/androidTest/java/dev/flutter/scenariosui/SpawnMultiEngineTest.java @@ -0,0 +1,37 @@ +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +package dev.flutter.scenariosui; + +import android.content.Intent; +import androidx.annotation.NonNull; +import androidx.test.filters.LargeTest; +import androidx.test.rule.ActivityTestRule; +import androidx.test.runner.AndroidJUnit4; +import dev.flutter.scenarios.SpawnMultiEngineActivity; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.junit.runner.RunWith; + +@RunWith(AndroidJUnit4.class) +@LargeTest +public class SpawnMultiEngineTest { + Intent intent; + + @Rule @NonNull + public ActivityTestRule activityRule = + new ActivityTestRule<>( + SpawnMultiEngineActivity.class, /*initialTouchMode=*/ false, /*launchActivity=*/ false); + + @Before + public void setUp() { + intent = new Intent(Intent.ACTION_MAIN); + } + + @Test + public void testSpawnedEngine() throws Exception { + activityRule.launchActivity(intent); + } +} diff --git a/engine/src/flutter/testing/scenario_app/android/app/src/main/AndroidManifest.xml b/engine/src/flutter/testing/scenario_app/android/app/src/main/AndroidManifest.xml index 7952e14f9e..96ec901014 100644 --- a/engine/src/flutter/testing/scenario_app/android/app/src/main/AndroidManifest.xml +++ b/engine/src/flutter/testing/scenario_app/android/app/src/main/AndroidManifest.xml @@ -37,6 +37,18 @@ + + + + + +