package org.chromium.net; import android.content.Context; import android.util.Log; import com.amazonaws.handlers.HandlerChainFactory$$ExternalSyntheticThrowCCEIfNotNull0; import java.lang.reflect.InvocationTargetException; import java.util.ArrayList; import java.util.Collections; import java.util.LinkedHashSet; import java.util.List; import java.util.Set; /* loaded from: classes5.dex */ public abstract class CronetProvider { public static final String TAG = "CronetProvider"; public static List getAllProviders(Context context) { LinkedHashSet linkedHashSet = new LinkedHashSet(); addCronetProviderFromResourceFile(context, linkedHashSet); addCronetProviderImplByClassName(context, "com.google.android.gms.net.PlayServicesCronetProvider", linkedHashSet, false); addCronetProviderImplByClassName(context, "com.google.android.gms.net.GmsCoreCronetProvider", linkedHashSet, false); addCronetProviderImplByClassName(context, "org.chromium.net.impl.NativeCronetProvider", linkedHashSet, false); addCronetProviderImplByClassName(context, "org.chromium.net.impl.JavaCronetProvider", linkedHashSet, false); return Collections.unmodifiableList(new ArrayList(linkedHashSet)); } public static boolean addCronetProviderImplByClassName(Context context, String str, Set set, boolean z) { try { HandlerChainFactory$$ExternalSyntheticThrowCCEIfNotNull0.m(context.getClassLoader().loadClass(str).asSubclass(CronetProvider.class).getConstructor(Context.class).newInstance(context)); set.add(null); return true; } catch (ClassNotFoundException e) { logReflectiveOperationException(str, z, e); return false; } catch (IllegalAccessException e2) { logReflectiveOperationException(str, z, e2); return false; } catch (InstantiationException e3) { logReflectiveOperationException(str, z, e3); return false; } catch (NoSuchMethodException e4) { logReflectiveOperationException(str, z, e4); return false; } catch (InvocationTargetException e5) { logReflectiveOperationException(str, z, e5); return false; } } public static void logReflectiveOperationException(String str, boolean z, Exception exc) { if (z) { Log.e(TAG, "Unable to load provider class: " + str, exc); return; } if (Log.isLoggable(TAG, 3)) { StringBuilder sb = new StringBuilder(); sb.append("Tried to load "); sb.append(str); sb.append(" provider class but it wasn't included in the app classpath"); } } public static boolean addCronetProviderFromResourceFile(Context context, Set set) { int identifier = context.getResources().getIdentifier("CronetProviderClassName", "string", context.getPackageName()); boolean z = false; if (identifier == 0) { return false; } String string = context.getResources().getString(identifier); if (string != null && !string.equals("com.google.android.gms.net.PlayServicesCronetProvider") && !string.equals("com.google.android.gms.net.GmsCoreCronetProvider") && !string.equals("org.chromium.net.impl.JavaCronetProvider") && !string.equals("org.chromium.net.impl.NativeCronetProvider")) { z = true; if (!addCronetProviderImplByClassName(context, string, set, true)) { Log.e(TAG, "Unable to instantiate Cronet implementation class " + string + " that is listed as in the app string resource file under CronetProviderClassName key"); } } return z; } }