383 lines
15 KiB
Java
383 lines
15 KiB
Java
package io.flutter.app;
|
|
|
|
import android.R;
|
|
import android.animation.Animator;
|
|
import android.animation.AnimatorListenerAdapter;
|
|
import android.app.Activity;
|
|
import android.app.Application;
|
|
import android.content.Context;
|
|
import android.content.Intent;
|
|
import android.content.pm.PackageManager;
|
|
import android.content.res.Configuration;
|
|
import android.content.res.Resources;
|
|
import android.graphics.drawable.Drawable;
|
|
import android.os.Bundle;
|
|
import android.util.TypedValue;
|
|
import android.view.View;
|
|
import android.view.ViewGroup;
|
|
import android.view.Window;
|
|
import android.view.WindowManager;
|
|
import com.google.android.gms.maps.model.BitmapDescriptorFactory;
|
|
import com.google.android.libraries.places.api.model.PlaceTypes;
|
|
import io.flutter.Log;
|
|
import io.flutter.embedding.engine.FlutterShellArgs;
|
|
import io.flutter.plugin.common.PluginRegistry;
|
|
import io.flutter.plugin.platform.PlatformPlugin;
|
|
import io.flutter.util.Preconditions;
|
|
import io.flutter.view.FlutterMain;
|
|
import io.flutter.view.FlutterNativeView;
|
|
import io.flutter.view.FlutterRunArguments;
|
|
import io.flutter.view.FlutterView;
|
|
import java.util.ArrayList;
|
|
import org.bouncycastle.asn1.cmp.PKIFailureInfo;
|
|
|
|
@Deprecated
|
|
/* loaded from: classes5.dex */
|
|
public final class FlutterActivityDelegate implements FlutterActivityEvents, FlutterView.Provider, PluginRegistry {
|
|
private static final String SPLASH_SCREEN_META_DATA_KEY = "io.flutter.app.android.SplashScreenUntilFirstFrame";
|
|
private static final String TAG = "FlutterActivityDelegate";
|
|
private static final WindowManager.LayoutParams matchParent = new WindowManager.LayoutParams(-1, -1);
|
|
private final Activity activity;
|
|
private FlutterView flutterView;
|
|
private View launchView;
|
|
private final ViewFactory viewFactory;
|
|
|
|
/* loaded from: classes5.dex */
|
|
public interface ViewFactory {
|
|
FlutterNativeView createFlutterNativeView();
|
|
|
|
FlutterView createFlutterView(Context context);
|
|
|
|
boolean retainFlutterNativeView();
|
|
}
|
|
|
|
@Override // io.flutter.view.FlutterView.Provider
|
|
public final FlutterView getFlutterView() {
|
|
return this.flutterView;
|
|
}
|
|
|
|
@Override // android.content.ComponentCallbacks
|
|
public final void onConfigurationChanged(Configuration configuration) {
|
|
}
|
|
|
|
public FlutterActivityDelegate(Activity activity, ViewFactory viewFactory) {
|
|
this.activity = (Activity) Preconditions.checkNotNull(activity);
|
|
this.viewFactory = (ViewFactory) Preconditions.checkNotNull(viewFactory);
|
|
}
|
|
|
|
@Override // io.flutter.plugin.common.PluginRegistry
|
|
public final boolean hasPlugin(String str) {
|
|
return this.flutterView.getPluginRegistry().hasPlugin(str);
|
|
}
|
|
|
|
@Override // io.flutter.plugin.common.PluginRegistry
|
|
public final <T> T valuePublishedByPlugin(String str) {
|
|
return (T) this.flutterView.getPluginRegistry().valuePublishedByPlugin(str);
|
|
}
|
|
|
|
@Override // io.flutter.plugin.common.PluginRegistry
|
|
public final PluginRegistry.Registrar registrarFor(String str) {
|
|
return this.flutterView.getPluginRegistry().registrarFor(str);
|
|
}
|
|
|
|
@Override // io.flutter.plugin.common.PluginRegistry.RequestPermissionsResultListener
|
|
public final boolean onRequestPermissionsResult(int i, String[] strArr, int[] iArr) {
|
|
return this.flutterView.getPluginRegistry().onRequestPermissionsResult(i, strArr, iArr);
|
|
}
|
|
|
|
@Override // io.flutter.plugin.common.PluginRegistry.ActivityResultListener
|
|
public final boolean onActivityResult(int i, int i2, Intent intent) {
|
|
return this.flutterView.getPluginRegistry().onActivityResult(i, i2, intent);
|
|
}
|
|
|
|
@Override // io.flutter.app.FlutterActivityEvents
|
|
public final void onCreate(Bundle bundle) {
|
|
String findAppBundlePath;
|
|
Window window = this.activity.getWindow();
|
|
window.addFlags(PKIFailureInfo.systemUnavail);
|
|
window.setStatusBarColor(1073741824);
|
|
window.getDecorView().setSystemUiVisibility(PlatformPlugin.DEFAULT_SYSTEM_UI);
|
|
FlutterMain.ensureInitializationComplete(this.activity.getApplicationContext(), getArgsFromIntent(this.activity.getIntent()));
|
|
FlutterView createFlutterView = this.viewFactory.createFlutterView(this.activity);
|
|
this.flutterView = createFlutterView;
|
|
if (createFlutterView == null) {
|
|
FlutterView flutterView = new FlutterView(this.activity, null, this.viewFactory.createFlutterNativeView());
|
|
this.flutterView = flutterView;
|
|
flutterView.setLayoutParams(matchParent);
|
|
this.activity.setContentView(this.flutterView);
|
|
View createLaunchView = createLaunchView();
|
|
this.launchView = createLaunchView;
|
|
if (createLaunchView != null) {
|
|
addLaunchView();
|
|
}
|
|
}
|
|
if (loadIntent(this.activity.getIntent()) || (findAppBundlePath = FlutterMain.findAppBundlePath()) == null) {
|
|
return;
|
|
}
|
|
runBundle(findAppBundlePath);
|
|
}
|
|
|
|
@Override // io.flutter.app.FlutterActivityEvents
|
|
public final void onNewIntent(Intent intent) {
|
|
if (isDebuggable() && loadIntent(intent)) {
|
|
return;
|
|
}
|
|
this.flutterView.getPluginRegistry().onNewIntent(intent);
|
|
}
|
|
|
|
private boolean isDebuggable() {
|
|
return (this.activity.getApplicationInfo().flags & 2) != 0;
|
|
}
|
|
|
|
@Override // io.flutter.app.FlutterActivityEvents
|
|
public final void onPause() {
|
|
Application application = (Application) this.activity.getApplicationContext();
|
|
if (application instanceof FlutterApplication) {
|
|
FlutterApplication flutterApplication = (FlutterApplication) application;
|
|
if (this.activity.equals(flutterApplication.getCurrentActivity())) {
|
|
flutterApplication.setCurrentActivity(null);
|
|
}
|
|
}
|
|
FlutterView flutterView = this.flutterView;
|
|
if (flutterView != null) {
|
|
flutterView.onPause();
|
|
}
|
|
}
|
|
|
|
@Override // io.flutter.app.FlutterActivityEvents
|
|
public final void onStart() {
|
|
FlutterView flutterView = this.flutterView;
|
|
if (flutterView != null) {
|
|
flutterView.onStart();
|
|
}
|
|
}
|
|
|
|
@Override // io.flutter.app.FlutterActivityEvents
|
|
public final void onResume() {
|
|
Application application = (Application) this.activity.getApplicationContext();
|
|
if (application instanceof FlutterApplication) {
|
|
((FlutterApplication) application).setCurrentActivity(this.activity);
|
|
}
|
|
}
|
|
|
|
@Override // io.flutter.app.FlutterActivityEvents
|
|
public final void onStop() {
|
|
this.flutterView.onStop();
|
|
}
|
|
|
|
@Override // io.flutter.app.FlutterActivityEvents
|
|
public final void onPostResume() {
|
|
FlutterView flutterView = this.flutterView;
|
|
if (flutterView != null) {
|
|
flutterView.onPostResume();
|
|
}
|
|
}
|
|
|
|
@Override // io.flutter.app.FlutterActivityEvents
|
|
public final void onDestroy() {
|
|
Application application = (Application) this.activity.getApplicationContext();
|
|
if (application instanceof FlutterApplication) {
|
|
FlutterApplication flutterApplication = (FlutterApplication) application;
|
|
if (this.activity.equals(flutterApplication.getCurrentActivity())) {
|
|
flutterApplication.setCurrentActivity(null);
|
|
}
|
|
}
|
|
FlutterView flutterView = this.flutterView;
|
|
if (flutterView != null) {
|
|
if (flutterView.getPluginRegistry().onViewDestroy(this.flutterView.getFlutterNativeView()) || this.viewFactory.retainFlutterNativeView()) {
|
|
this.flutterView.detach();
|
|
} else {
|
|
this.flutterView.destroy();
|
|
}
|
|
}
|
|
}
|
|
|
|
@Override // io.flutter.app.FlutterActivityEvents
|
|
public final boolean onBackPressed() {
|
|
FlutterView flutterView = this.flutterView;
|
|
if (flutterView == null) {
|
|
return false;
|
|
}
|
|
flutterView.popRoute();
|
|
return true;
|
|
}
|
|
|
|
@Override // io.flutter.app.FlutterActivityEvents
|
|
public final void onUserLeaveHint() {
|
|
this.flutterView.getPluginRegistry().onUserLeaveHint();
|
|
}
|
|
|
|
@Override // android.content.ComponentCallbacks2
|
|
public final void onTrimMemory(int i) {
|
|
if (i == 10) {
|
|
this.flutterView.onMemoryPressure();
|
|
}
|
|
}
|
|
|
|
@Override // android.content.ComponentCallbacks
|
|
public final void onLowMemory() {
|
|
this.flutterView.onMemoryPressure();
|
|
}
|
|
|
|
private static String[] getArgsFromIntent(Intent intent) {
|
|
ArrayList arrayList = new ArrayList();
|
|
if (intent.getBooleanExtra(FlutterShellArgs.ARG_KEY_TRACE_STARTUP, false)) {
|
|
arrayList.add(FlutterShellArgs.ARG_TRACE_STARTUP);
|
|
}
|
|
if (intent.getBooleanExtra(FlutterShellArgs.ARG_KEY_START_PAUSED, false)) {
|
|
arrayList.add(FlutterShellArgs.ARG_START_PAUSED);
|
|
}
|
|
if (intent.getBooleanExtra(FlutterShellArgs.ARG_KEY_DISABLE_SERVICE_AUTH_CODES, false)) {
|
|
arrayList.add(FlutterShellArgs.ARG_DISABLE_SERVICE_AUTH_CODES);
|
|
}
|
|
if (intent.getBooleanExtra(FlutterShellArgs.ARG_KEY_USE_TEST_FONTS, false)) {
|
|
arrayList.add(FlutterShellArgs.ARG_USE_TEST_FONTS);
|
|
}
|
|
if (intent.getBooleanExtra(FlutterShellArgs.ARG_KEY_ENABLE_DART_PROFILING, false)) {
|
|
arrayList.add(FlutterShellArgs.ARG_ENABLE_DART_PROFILING);
|
|
}
|
|
if (intent.getBooleanExtra(FlutterShellArgs.ARG_KEY_ENABLE_SOFTWARE_RENDERING, false)) {
|
|
arrayList.add(FlutterShellArgs.ARG_ENABLE_SOFTWARE_RENDERING);
|
|
}
|
|
if (intent.getBooleanExtra(FlutterShellArgs.ARG_KEY_SKIA_DETERMINISTIC_RENDERING, false)) {
|
|
arrayList.add(FlutterShellArgs.ARG_SKIA_DETERMINISTIC_RENDERING);
|
|
}
|
|
if (intent.getBooleanExtra(FlutterShellArgs.ARG_KEY_TRACE_SKIA, false)) {
|
|
arrayList.add(FlutterShellArgs.ARG_TRACE_SKIA);
|
|
}
|
|
if (intent.getBooleanExtra(FlutterShellArgs.ARG_KEY_TRACE_SYSTRACE, false)) {
|
|
arrayList.add(FlutterShellArgs.ARG_TRACE_SYSTRACE);
|
|
}
|
|
if (intent.getBooleanExtra(FlutterShellArgs.ARG_KEY_DUMP_SHADER_SKP_ON_SHADER_COMPILATION, false)) {
|
|
arrayList.add(FlutterShellArgs.ARG_DUMP_SHADER_SKP_ON_SHADER_COMPILATION);
|
|
}
|
|
if (intent.getBooleanExtra(FlutterShellArgs.ARG_KEY_CACHE_SKSL, false)) {
|
|
arrayList.add(FlutterShellArgs.ARG_CACHE_SKSL);
|
|
}
|
|
if (intent.getBooleanExtra(FlutterShellArgs.ARG_KEY_PURGE_PERSISTENT_CACHE, false)) {
|
|
arrayList.add(FlutterShellArgs.ARG_PURGE_PERSISTENT_CACHE);
|
|
}
|
|
if (intent.getBooleanExtra(FlutterShellArgs.ARG_KEY_VERBOSE_LOGGING, false)) {
|
|
arrayList.add(FlutterShellArgs.ARG_VERBOSE_LOGGING);
|
|
}
|
|
int intExtra = intent.getIntExtra(FlutterShellArgs.ARG_KEY_OBSERVATORY_PORT, 0);
|
|
if (intExtra > 0) {
|
|
arrayList.add(FlutterShellArgs.ARG_OBSERVATORY_PORT + Integer.toString(intExtra));
|
|
}
|
|
if (intent.getBooleanExtra(FlutterShellArgs.ARG_KEY_ENDLESS_TRACE_BUFFER, false)) {
|
|
arrayList.add(FlutterShellArgs.ARG_ENDLESS_TRACE_BUFFER);
|
|
}
|
|
if (intent.hasExtra(FlutterShellArgs.ARG_KEY_DART_FLAGS)) {
|
|
arrayList.add("--dart-flags=" + intent.getStringExtra(FlutterShellArgs.ARG_KEY_DART_FLAGS));
|
|
}
|
|
if (arrayList.isEmpty()) {
|
|
return null;
|
|
}
|
|
return (String[]) arrayList.toArray(new String[arrayList.size()]);
|
|
}
|
|
|
|
private boolean loadIntent(Intent intent) {
|
|
if (!"android.intent.action.RUN".equals(intent.getAction())) {
|
|
return false;
|
|
}
|
|
String stringExtra = intent.getStringExtra(PlaceTypes.ROUTE);
|
|
String dataString = intent.getDataString();
|
|
if (dataString == null) {
|
|
dataString = FlutterMain.findAppBundlePath();
|
|
}
|
|
if (stringExtra != null) {
|
|
this.flutterView.setInitialRoute(stringExtra);
|
|
}
|
|
runBundle(dataString);
|
|
return true;
|
|
}
|
|
|
|
private void runBundle(String str) {
|
|
if (this.flutterView.getFlutterNativeView().isApplicationRunning()) {
|
|
return;
|
|
}
|
|
FlutterRunArguments flutterRunArguments = new FlutterRunArguments();
|
|
flutterRunArguments.bundlePath = str;
|
|
flutterRunArguments.entrypoint = "main";
|
|
this.flutterView.runFromBundle(flutterRunArguments);
|
|
}
|
|
|
|
private View createLaunchView() {
|
|
Drawable launchScreenDrawableFromActivityTheme;
|
|
if (!showSplashScreenUntilFirstFrame().booleanValue() || (launchScreenDrawableFromActivityTheme = getLaunchScreenDrawableFromActivityTheme()) == null) {
|
|
return null;
|
|
}
|
|
View view = new View(this.activity);
|
|
view.setLayoutParams(matchParent);
|
|
view.setBackground(launchScreenDrawableFromActivityTheme);
|
|
return view;
|
|
}
|
|
|
|
private Drawable getLaunchScreenDrawableFromActivityTheme() {
|
|
TypedValue typedValue = new TypedValue();
|
|
if (!this.activity.getTheme().resolveAttribute(R.attr.windowBackground, typedValue, true) || typedValue.resourceId == 0) {
|
|
return null;
|
|
}
|
|
try {
|
|
return this.activity.getResources().getDrawable(typedValue.resourceId);
|
|
} catch (Resources.NotFoundException unused) {
|
|
Log.e(TAG, "Referenced launch screen windowBackground resource does not exist");
|
|
return null;
|
|
}
|
|
}
|
|
|
|
private Boolean showSplashScreenUntilFirstFrame() {
|
|
boolean z = false;
|
|
try {
|
|
Bundle bundle = this.activity.getPackageManager().getActivityInfo(this.activity.getComponentName(), 128).metaData;
|
|
if (bundle != null) {
|
|
if (bundle.getBoolean(SPLASH_SCREEN_META_DATA_KEY)) {
|
|
z = true;
|
|
}
|
|
}
|
|
return Boolean.valueOf(z);
|
|
} catch (PackageManager.NameNotFoundException unused) {
|
|
return false;
|
|
}
|
|
}
|
|
|
|
private void addLaunchView() {
|
|
View view = this.launchView;
|
|
if (view == null) {
|
|
return;
|
|
}
|
|
this.activity.addContentView(view, matchParent);
|
|
this.flutterView.addFirstFrameListener(new AnonymousClass1(this));
|
|
this.activity.setTheme(R.style.Theme.Black.NoTitleBar);
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: package-private */
|
|
/* renamed from: io.flutter.app.FlutterActivityDelegate$1, reason: invalid class name */
|
|
/* loaded from: classes5.dex */
|
|
public class AnonymousClass1 implements FlutterView.FirstFrameListener {
|
|
final FlutterActivityDelegate this$0;
|
|
|
|
AnonymousClass1(FlutterActivityDelegate flutterActivityDelegate) {
|
|
this.this$0 = flutterActivityDelegate;
|
|
}
|
|
|
|
@Override // io.flutter.view.FlutterView.FirstFrameListener
|
|
public void onFirstFrame() {
|
|
this.this$0.launchView.animate().alpha(BitmapDescriptorFactory.HUE_RED).setListener(new AnimatorListenerAdapter(this) { // from class: io.flutter.app.FlutterActivityDelegate.1.1
|
|
final AnonymousClass1 this$1;
|
|
|
|
{
|
|
this.this$1 = this;
|
|
}
|
|
|
|
@Override // android.animation.AnimatorListenerAdapter, android.animation.Animator.AnimatorListener
|
|
public void onAnimationEnd(Animator animator) {
|
|
((ViewGroup) this.this$1.this$0.launchView.getParent()).removeView(this.this$1.this$0.launchView);
|
|
this.this$1.this$0.launchView = null;
|
|
}
|
|
});
|
|
this.this$0.flutterView.removeFirstFrameListener(this);
|
|
}
|
|
}
|
|
}
|