mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
Parse impeller setting from the bundle on Android (flutter/engine#33442)
This commit is contained in:
parent
1f1b53711a
commit
79bb017c96
@ -40,6 +40,8 @@ public class FlutterLoader {
|
||||
"io.flutter.embedding.android.OldGenHeapSize";
|
||||
private static final String ENABLE_SKPARAGRAPH_META_DATA_KEY =
|
||||
"io.flutter.embedding.android.EnableSkParagraph";
|
||||
private static final String ENABLE_IMPELLER_META_DATA_KEY =
|
||||
"io.flutter.embedding.android.EnableImpeller";
|
||||
|
||||
/**
|
||||
* Set whether leave or clean up the VM after the last shell shuts down. It can be set from app's
|
||||
@ -316,9 +318,11 @@ public class FlutterLoader {
|
||||
shellArgs.add("--prefetched-default-font-manager");
|
||||
|
||||
if (metaData == null || metaData.getBoolean(ENABLE_SKPARAGRAPH_META_DATA_KEY, true)) {
|
||||
|
||||
shellArgs.add("--enable-skparagraph");
|
||||
}
|
||||
if (metaData != null && metaData.getBoolean(ENABLE_IMPELLER_META_DATA_KEY, false)) {
|
||||
shellArgs.add("--enable-impeller");
|
||||
}
|
||||
|
||||
final String leakVM = isLeakVM(metaData) ? "true" : "false";
|
||||
shellArgs.add("--leak-vm=" + leakVM);
|
||||
|
||||
@ -157,6 +157,46 @@ public class FlutterLoaderTest {
|
||||
verify(mockExecutorService, times(1)).submit(any(Callable.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void itDoesNotSetEnableImpellerByDefault() {
|
||||
FlutterJNI mockFlutterJNI = mock(FlutterJNI.class);
|
||||
FlutterLoader flutterLoader = new FlutterLoader(mockFlutterJNI);
|
||||
|
||||
assertFalse(flutterLoader.initialized());
|
||||
flutterLoader.startInitialization(ctx);
|
||||
flutterLoader.ensureInitializationComplete(ctx, null);
|
||||
shadowOf(getMainLooper()).idle();
|
||||
|
||||
final String enableImpellerArg = "--enable-impeller";
|
||||
ArgumentCaptor<String[]> shellArgsCaptor = ArgumentCaptor.forClass(String[].class);
|
||||
verify(mockFlutterJNI, times(1))
|
||||
.init(eq(ctx), shellArgsCaptor.capture(), anyString(), anyString(), anyString(), anyLong());
|
||||
List<String> arguments = Arrays.asList(shellArgsCaptor.getValue());
|
||||
assertFalse(arguments.contains(enableImpellerArg));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void itSetsEnableImpellerFromMetaData() {
|
||||
FlutterJNI mockFlutterJNI = mock(FlutterJNI.class);
|
||||
FlutterLoader flutterLoader = new FlutterLoader(mockFlutterJNI);
|
||||
Bundle metaData = new Bundle();
|
||||
metaData.putBoolean("io.flutter.embedding.android.EnableImpeller", true);
|
||||
ctx.getApplicationInfo().metaData = metaData;
|
||||
|
||||
FlutterLoader.Settings settings = new FlutterLoader.Settings();
|
||||
assertFalse(flutterLoader.initialized());
|
||||
flutterLoader.startInitialization(ctx, settings);
|
||||
flutterLoader.ensureInitializationComplete(ctx, null);
|
||||
shadowOf(getMainLooper()).idle();
|
||||
|
||||
final String enableImpellerArg = "--enable-impeller";
|
||||
ArgumentCaptor<String[]> shellArgsCaptor = ArgumentCaptor.forClass(String[].class);
|
||||
verify(mockFlutterJNI, times(1))
|
||||
.init(eq(ctx), shellArgsCaptor.capture(), anyString(), anyString(), anyString(), anyLong());
|
||||
List<String> arguments = Arrays.asList(shellArgsCaptor.getValue());
|
||||
assertTrue(arguments.contains(enableImpellerArg));
|
||||
}
|
||||
|
||||
@Test
|
||||
@TargetApi(23)
|
||||
@Config(sdk = 23)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user