package io.flutter.app; import android.app.Activity; import android.content.Context; import android.content.Intent; import io.flutter.embedding.engine.FlutterEngine; import io.flutter.plugin.common.BinaryMessenger; import io.flutter.plugin.common.PluginRegistry; import io.flutter.plugin.platform.PlatformViewRegistry; import io.flutter.plugin.platform.PlatformViewsController; import io.flutter.view.FlutterMain; import io.flutter.view.FlutterNativeView; import io.flutter.view.FlutterView; import io.flutter.view.TextureRegistry; import java.util.ArrayList; import java.util.Iterator; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; @Deprecated /* loaded from: classes5.dex */ public class FlutterPluginRegistry implements PluginRegistry, PluginRegistry.RequestPermissionsResultListener, PluginRegistry.ActivityResultListener, PluginRegistry.NewIntentListener, PluginRegistry.UserLeaveHintListener, PluginRegistry.ViewDestroyListener { private static final String TAG = "FlutterPluginRegistry"; private Activity mActivity; private Context mAppContext; private FlutterView mFlutterView; private FlutterNativeView mNativeView; private final Map mPluginMap = new LinkedHashMap(0); private final List mRequestPermissionsResultListeners = new ArrayList(0); private final List mActivityResultListeners = new ArrayList(0); private final List mNewIntentListeners = new ArrayList(0); private final List mUserLeaveHintListeners = new ArrayList(0); private final List mViewDestroyListeners = new ArrayList(0); private final PlatformViewsController mPlatformViewsController = new PlatformViewsController(); public PlatformViewsController getPlatformViewsController() { return this.mPlatformViewsController; } public FlutterPluginRegistry(FlutterNativeView flutterNativeView, Context context) { this.mNativeView = flutterNativeView; this.mAppContext = context; } public FlutterPluginRegistry(FlutterEngine flutterEngine, Context context) { this.mAppContext = context; } @Override // io.flutter.plugin.common.PluginRegistry public boolean hasPlugin(String str) { return this.mPluginMap.containsKey(str); } @Override // io.flutter.plugin.common.PluginRegistry public T valuePublishedByPlugin(String str) { return (T) this.mPluginMap.get(str); } @Override // io.flutter.plugin.common.PluginRegistry public PluginRegistry.Registrar registrarFor(String str) { if (this.mPluginMap.containsKey(str)) { throw new IllegalStateException("Plugin key " + str + " is already in use"); } this.mPluginMap.put(str, null); return new FlutterRegistrar(this, str); } public void attach(FlutterView flutterView, Activity activity) { this.mFlutterView = flutterView; this.mActivity = activity; this.mPlatformViewsController.attach(activity, flutterView, flutterView.getDartExecutor()); } public void detach() { this.mPlatformViewsController.detach(); this.mPlatformViewsController.onDetachedFromJNI(); this.mFlutterView = null; this.mActivity = null; } public void onPreEngineRestart() { this.mPlatformViewsController.onPreEngineRestart(); } /* loaded from: classes5.dex */ class FlutterRegistrar implements PluginRegistry.Registrar { private final String pluginKey; final FlutterPluginRegistry this$0; FlutterRegistrar(FlutterPluginRegistry flutterPluginRegistry, String str) { this.this$0 = flutterPluginRegistry; this.pluginKey = str; } @Override // io.flutter.plugin.common.PluginRegistry.Registrar public Activity activity() { return this.this$0.mActivity; } @Override // io.flutter.plugin.common.PluginRegistry.Registrar public Context context() { return this.this$0.mAppContext; } @Override // io.flutter.plugin.common.PluginRegistry.Registrar public Context activeContext() { return this.this$0.mActivity != null ? this.this$0.mActivity : this.this$0.mAppContext; } @Override // io.flutter.plugin.common.PluginRegistry.Registrar public BinaryMessenger messenger() { return this.this$0.mNativeView; } @Override // io.flutter.plugin.common.PluginRegistry.Registrar public TextureRegistry textures() { return this.this$0.mFlutterView; } @Override // io.flutter.plugin.common.PluginRegistry.Registrar public PlatformViewRegistry platformViewRegistry() { return this.this$0.mPlatformViewsController.getRegistry(); } @Override // io.flutter.plugin.common.PluginRegistry.Registrar public FlutterView view() { return this.this$0.mFlutterView; } @Override // io.flutter.plugin.common.PluginRegistry.Registrar public String lookupKeyForAsset(String str) { return FlutterMain.getLookupKeyForAsset(str); } @Override // io.flutter.plugin.common.PluginRegistry.Registrar public String lookupKeyForAsset(String str, String str2) { return FlutterMain.getLookupKeyForAsset(str, str2); } @Override // io.flutter.plugin.common.PluginRegistry.Registrar public PluginRegistry.Registrar publish(Object obj) { this.this$0.mPluginMap.put(this.pluginKey, obj); return this; } @Override // io.flutter.plugin.common.PluginRegistry.Registrar public PluginRegistry.Registrar addRequestPermissionsResultListener(PluginRegistry.RequestPermissionsResultListener requestPermissionsResultListener) { this.this$0.mRequestPermissionsResultListeners.add(requestPermissionsResultListener); return this; } @Override // io.flutter.plugin.common.PluginRegistry.Registrar public PluginRegistry.Registrar addActivityResultListener(PluginRegistry.ActivityResultListener activityResultListener) { this.this$0.mActivityResultListeners.add(activityResultListener); return this; } @Override // io.flutter.plugin.common.PluginRegistry.Registrar public PluginRegistry.Registrar addNewIntentListener(PluginRegistry.NewIntentListener newIntentListener) { this.this$0.mNewIntentListeners.add(newIntentListener); return this; } @Override // io.flutter.plugin.common.PluginRegistry.Registrar public PluginRegistry.Registrar addUserLeaveHintListener(PluginRegistry.UserLeaveHintListener userLeaveHintListener) { this.this$0.mUserLeaveHintListeners.add(userLeaveHintListener); return this; } @Override // io.flutter.plugin.common.PluginRegistry.Registrar public PluginRegistry.Registrar addViewDestroyListener(PluginRegistry.ViewDestroyListener viewDestroyListener) { this.this$0.mViewDestroyListeners.add(viewDestroyListener); return this; } } @Override // io.flutter.plugin.common.PluginRegistry.RequestPermissionsResultListener public boolean onRequestPermissionsResult(int i, String[] strArr, int[] iArr) { Iterator it = this.mRequestPermissionsResultListeners.iterator(); while (it.hasNext()) { if (it.next().onRequestPermissionsResult(i, strArr, iArr)) { return true; } } return false; } @Override // io.flutter.plugin.common.PluginRegistry.ActivityResultListener public boolean onActivityResult(int i, int i2, Intent intent) { Iterator it = this.mActivityResultListeners.iterator(); while (it.hasNext()) { if (it.next().onActivityResult(i, i2, intent)) { return true; } } return false; } @Override // io.flutter.plugin.common.PluginRegistry.NewIntentListener public boolean onNewIntent(Intent intent) { Iterator it = this.mNewIntentListeners.iterator(); while (it.hasNext()) { if (it.next().onNewIntent(intent)) { return true; } } return false; } @Override // io.flutter.plugin.common.PluginRegistry.UserLeaveHintListener public void onUserLeaveHint() { Iterator it = this.mUserLeaveHintListeners.iterator(); while (it.hasNext()) { it.next().onUserLeaveHint(); } } @Override // io.flutter.plugin.common.PluginRegistry.ViewDestroyListener public boolean onViewDestroy(FlutterNativeView flutterNativeView) { Iterator it = this.mViewDestroyListeners.iterator(); boolean z = false; while (it.hasNext()) { if (it.next().onViewDestroy(flutterNativeView)) { z = true; } } return z; } public void destroy() { this.mPlatformViewsController.onDetachedFromJNI(); } }