287 lines
12 KiB
Java
287 lines
12 KiB
Java
package io.flutter.embedding.engine.loader;
|
|
|
|
import android.content.Context;
|
|
import android.hardware.display.DisplayManager;
|
|
import android.os.Bundle;
|
|
import android.os.Handler;
|
|
import android.os.Looper;
|
|
import android.os.SystemClock;
|
|
import com.huawei.hms.support.api.entity.common.CommonConstant;
|
|
import io.flutter.FlutterInjector;
|
|
import io.flutter.Log;
|
|
import io.flutter.embedding.engine.FlutterJNI;
|
|
import io.flutter.embedding.engine.loader.FlutterLoader;
|
|
import io.flutter.util.HandlerCompat;
|
|
import io.flutter.util.PathUtils;
|
|
import io.flutter.util.TraceSection;
|
|
import io.flutter.view.VsyncWaiter;
|
|
import java.io.File;
|
|
import java.util.concurrent.Callable;
|
|
import java.util.concurrent.ExecutorService;
|
|
import java.util.concurrent.Future;
|
|
|
|
/* loaded from: classes.dex */
|
|
public class FlutterLoader {
|
|
static final String AOT_SHARED_LIBRARY_NAME = "aot-shared-library-name";
|
|
static final String AOT_VMSERVICE_SHARED_LIBRARY_NAME = "aot-vmservice-shared-library-name";
|
|
static final String AUTOMATICALLY_REGISTER_PLUGINS_KEY = "automatically-register-plugins";
|
|
private static final String DEFAULT_KERNEL_BLOB = "kernel_blob.bin";
|
|
private static final String DEFAULT_LIBRARY = "libflutter.so";
|
|
private static final String ENABLE_IMPELLER_META_DATA_KEY = "io.flutter.embedding.android.EnableImpeller";
|
|
private static final String ENABLE_SKPARAGRAPH_META_DATA_KEY = "io.flutter.embedding.android.EnableSkParagraph";
|
|
static final String FLUTTER_ASSETS_DIR_KEY = "flutter-assets-dir";
|
|
static final String ISOLATE_SNAPSHOT_DATA_KEY = "isolate-snapshot-data";
|
|
private static final String LEAK_VM_META_DATA_KEY = "io.flutter.embedding.android.LeakVM";
|
|
private static final String OLD_GEN_HEAP_SIZE_META_DATA_KEY = "io.flutter.embedding.android.OldGenHeapSize";
|
|
static final String SNAPSHOT_ASSET_PATH_KEY = "snapshot-asset-path";
|
|
private static final String TAG = "FlutterLoader";
|
|
private static final String VMSERVICE_SNAPSHOT_LIBRARY = "libvmservice_snapshot.so";
|
|
static final String VM_SNAPSHOT_DATA_KEY = "vm-snapshot-data";
|
|
private static FlutterLoader instance;
|
|
private ExecutorService executorService;
|
|
private FlutterApplicationInfo flutterApplicationInfo;
|
|
private FlutterJNI flutterJNI;
|
|
Future<InitResult> initResultFuture;
|
|
private long initStartTimestampMillis;
|
|
private boolean initialized;
|
|
private Settings settings;
|
|
|
|
/* loaded from: classes.dex */
|
|
public static class Settings {
|
|
private String logTag;
|
|
|
|
public String getLogTag() {
|
|
return this.logTag;
|
|
}
|
|
|
|
public void setLogTag(String str) {
|
|
this.logTag = str;
|
|
}
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: private */
|
|
public ResourceExtractor initResources(Context context) {
|
|
return null;
|
|
}
|
|
|
|
public boolean initialized() {
|
|
return this.initialized;
|
|
}
|
|
|
|
public FlutterLoader() {
|
|
this(FlutterInjector.instance().getFlutterJNIFactory().provideFlutterJNI());
|
|
}
|
|
|
|
public FlutterLoader(FlutterJNI flutterJNI) {
|
|
this(flutterJNI, FlutterInjector.instance().executorService());
|
|
}
|
|
|
|
public FlutterLoader(FlutterJNI flutterJNI, ExecutorService executorService) {
|
|
this.initialized = false;
|
|
this.flutterJNI = flutterJNI;
|
|
this.executorService = executorService;
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: package-private */
|
|
/* loaded from: classes.dex */
|
|
public static class InitResult {
|
|
final String appStoragePath;
|
|
final String dataDirPath;
|
|
final String engineCachesPath;
|
|
|
|
/* synthetic */ InitResult(String str, String str2, String str3, AnonymousClass1 anonymousClass1) {
|
|
this(str, str2, str3);
|
|
}
|
|
|
|
private InitResult(String str, String str2, String str3) {
|
|
this.appStoragePath = str;
|
|
this.engineCachesPath = str2;
|
|
this.dataDirPath = str3;
|
|
}
|
|
}
|
|
|
|
public void startInitialization(Context context) {
|
|
startInitialization(context, new Settings());
|
|
}
|
|
|
|
public void startInitialization(Context context, Settings settings) {
|
|
if (this.settings != null) {
|
|
return;
|
|
}
|
|
if (Looper.myLooper() != Looper.getMainLooper()) {
|
|
throw new IllegalStateException("startInitialization must be called on the main thread");
|
|
}
|
|
TraceSection.begin("FlutterLoader#startInitialization");
|
|
try {
|
|
Context applicationContext = context.getApplicationContext();
|
|
this.settings = settings;
|
|
this.initStartTimestampMillis = SystemClock.uptimeMillis();
|
|
this.flutterApplicationInfo = ApplicationInfoLoader.load(applicationContext);
|
|
VsyncWaiter.getInstance((DisplayManager) applicationContext.getSystemService(CommonConstant.ReqAccessTokenParam.DISPLAY_LABEL), this.flutterJNI).init();
|
|
this.initResultFuture = this.executorService.submit(new AnonymousClass1(this, applicationContext));
|
|
} finally {
|
|
TraceSection.end();
|
|
}
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: package-private */
|
|
/* renamed from: io.flutter.embedding.engine.loader.FlutterLoader$1, reason: invalid class name */
|
|
/* loaded from: classes.dex */
|
|
public class AnonymousClass1 implements Callable<InitResult> {
|
|
final FlutterLoader this$0;
|
|
final Context val$appContext;
|
|
|
|
AnonymousClass1(FlutterLoader flutterLoader, Context context) {
|
|
this.this$0 = flutterLoader;
|
|
this.val$appContext = context;
|
|
}
|
|
|
|
/* JADX WARN: Can't rename method to resolve collision */
|
|
@Override // java.util.concurrent.Callable
|
|
public InitResult call() {
|
|
TraceSection.begin("FlutterLoader initTask");
|
|
try {
|
|
ResourceExtractor initResources = this.this$0.initResources(this.val$appContext);
|
|
this.this$0.flutterJNI.loadLibrary();
|
|
this.this$0.flutterJNI.updateRefreshRate();
|
|
this.this$0.executorService.execute(new Runnable(this) { // from class: io.flutter.embedding.engine.loader.FlutterLoader$1$$ExternalSyntheticLambda0
|
|
public final FlutterLoader.AnonymousClass1 f$0;
|
|
|
|
{
|
|
this.f$0 = this;
|
|
}
|
|
|
|
@Override // java.lang.Runnable
|
|
public final void run() {
|
|
this.f$0.m334lambda$call$0$ioflutterembeddingengineloaderFlutterLoader$1();
|
|
}
|
|
});
|
|
if (initResources != null) {
|
|
initResources.waitForCompletion();
|
|
}
|
|
return new InitResult(PathUtils.getFilesDir(this.val$appContext), PathUtils.getCacheDirectory(this.val$appContext), PathUtils.getDataDirectory(this.val$appContext), null);
|
|
} finally {
|
|
TraceSection.end();
|
|
}
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: package-private */
|
|
/* renamed from: lambda$call$0$io-flutter-embedding-engine-loader-FlutterLoader$1, reason: not valid java name */
|
|
public /* synthetic */ void m334lambda$call$0$ioflutterembeddingengineloaderFlutterLoader$1() {
|
|
this.this$0.flutterJNI.prefetchDefaultFontManager();
|
|
}
|
|
}
|
|
|
|
/* JADX WARN: Removed duplicated region for block: B:38:0x017a */
|
|
/* JADX WARN: Removed duplicated region for block: B:43:0x017d */
|
|
/*
|
|
Code decompiled incorrectly, please refer to instructions dump.
|
|
To view partially-correct add '--show-bad-code' argument
|
|
*/
|
|
public void ensureInitializationComplete(android.content.Context r15, java.lang.String[] r16) {
|
|
/*
|
|
Method dump skipped, instructions count: 465
|
|
To view this dump add '--comments-level debug' option
|
|
*/
|
|
throw new UnsupportedOperationException("Method not decompiled: io.flutter.embedding.engine.loader.FlutterLoader.ensureInitializationComplete(android.content.Context, java.lang.String[]):void");
|
|
}
|
|
|
|
private static boolean isLeakVM(Bundle bundle) {
|
|
if (bundle == null) {
|
|
return true;
|
|
}
|
|
return bundle.getBoolean(LEAK_VM_META_DATA_KEY, true);
|
|
}
|
|
|
|
public void ensureInitializationCompleteAsync(final Context context, final String[] strArr, final Handler handler, final Runnable runnable) {
|
|
if (Looper.myLooper() != Looper.getMainLooper()) {
|
|
throw new IllegalStateException("ensureInitializationComplete must be called on the main thread");
|
|
}
|
|
if (this.settings == null) {
|
|
throw new IllegalStateException("ensureInitializationComplete must be called after startInitialization");
|
|
}
|
|
if (this.initialized) {
|
|
handler.post(runnable);
|
|
} else {
|
|
this.executorService.execute(new Runnable(this, context, strArr, handler, runnable) { // from class: io.flutter.embedding.engine.loader.FlutterLoader$$ExternalSyntheticLambda1
|
|
public final FlutterLoader f$0;
|
|
public final Context f$1;
|
|
public final String[] f$2;
|
|
public final Handler f$3;
|
|
public final Runnable f$4;
|
|
|
|
{
|
|
this.f$0 = this;
|
|
this.f$1 = context;
|
|
this.f$2 = strArr;
|
|
this.f$3 = handler;
|
|
this.f$4 = runnable;
|
|
}
|
|
|
|
@Override // java.lang.Runnable
|
|
public final void run() {
|
|
this.f$0.m333xa15f5dc1(this.f$1, this.f$2, this.f$3, this.f$4);
|
|
}
|
|
});
|
|
}
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: package-private */
|
|
/* renamed from: lambda$ensureInitializationCompleteAsync$1$io-flutter-embedding-engine-loader-FlutterLoader, reason: not valid java name */
|
|
public /* synthetic */ void m333xa15f5dc1(final Context context, final String[] strArr, final Handler handler, final Runnable runnable) {
|
|
try {
|
|
this.initResultFuture.get();
|
|
HandlerCompat.createAsyncHandler(Looper.getMainLooper()).post(new Runnable(this, context, strArr, handler, runnable) { // from class: io.flutter.embedding.engine.loader.FlutterLoader$$ExternalSyntheticLambda0
|
|
public final FlutterLoader f$0;
|
|
public final Context f$1;
|
|
public final String[] f$2;
|
|
public final Handler f$3;
|
|
public final Runnable f$4;
|
|
|
|
{
|
|
this.f$0 = this;
|
|
this.f$1 = context;
|
|
this.f$2 = strArr;
|
|
this.f$3 = handler;
|
|
this.f$4 = runnable;
|
|
}
|
|
|
|
@Override // java.lang.Runnable
|
|
public final void run() {
|
|
this.f$0.m332xafb5b7a2(this.f$1, this.f$2, this.f$3, this.f$4);
|
|
}
|
|
});
|
|
} catch (Exception e) {
|
|
Log.e(TAG, "Flutter initialization failed.", e);
|
|
throw new RuntimeException(e);
|
|
}
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: package-private */
|
|
/* renamed from: lambda$ensureInitializationCompleteAsync$0$io-flutter-embedding-engine-loader-FlutterLoader, reason: not valid java name */
|
|
public /* synthetic */ void m332xafb5b7a2(Context context, String[] strArr, Handler handler, Runnable runnable) {
|
|
ensureInitializationComplete(context.getApplicationContext(), strArr);
|
|
handler.post(runnable);
|
|
}
|
|
|
|
public String findAppBundlePath() {
|
|
return this.flutterApplicationInfo.flutterAssetsDir;
|
|
}
|
|
|
|
public String getLookupKeyForAsset(String str) {
|
|
return fullAssetPathFrom(str);
|
|
}
|
|
|
|
public String getLookupKeyForAsset(String str, String str2) {
|
|
return getLookupKeyForAsset("packages" + File.separator + str2 + File.separator + str);
|
|
}
|
|
|
|
public boolean automaticallyRegisterPlugins() {
|
|
return this.flutterApplicationInfo.automaticallyRegisterPlugins;
|
|
}
|
|
|
|
private String fullAssetPathFrom(String str) {
|
|
return this.flutterApplicationInfo.flutterAssetsDir + File.separator + str;
|
|
}
|
|
}
|