package com.google.android.gms.internal.ads;

import android.net.Uri;
import android.os.SystemClock;
import android.webkit.WebView;
import androidx.annotation.Nullable;
import androidx.webkit.ProfileStore;
import java.lang.reflect.InvocationTargetException;

/* JADX INFO: loaded from: classes2.dex */
public final class z60 {

    @Nullable
    private z3.b zza = null;

    public final void a(WebView webView) {
        if (this.zza != null) {
            try {
                Uri uri = z3.b0.f37032a;
                if (!a4.k0.S.b()) {
                    throw a4.k0.a();
                }
                z3.b0.e(webView).f346a.setProfile("GMA_WEBVIEW_PROFILE");
                p7.l0.g("WebViewCompat Profile is defined");
            } catch (IllegalStateException e10) {
                q7.j.d("WebViewCompat error: ".concat(e10.toString()));
                if (((Boolean) n7.y.f31093e.f31096c.b(ao.f8958lf)).booleanValue()) {
                    m7.n.C.f30469h.d("WebViewCompat.setProfile", e10);
                }
            }
        }
    }

    public final void b(b50 b50Var) {
        ProfileStore profileStore;
        if (!z3.c0.a("MULTI_PROFILE")) {
            q7.j.a("WebViewFeature.MULTI_PROFILE is not supported");
            return;
        }
        try {
            profileStore = (ProfileStore) yi1.zza("androidx.webkit.ProfileStore", "getInstance", new xi1[0]);
        } catch (ClassCastException | ClassNotFoundException | IllegalAccessException | IllegalStateException | NoSuchMethodException | InvocationTargetException e10) {
            q7.j.a("Unable to get ProfileStore instance: ".concat(String.valueOf(e10.getMessage())));
            try {
                profileStore = (ProfileStore) yi1.zza("androidx.webkit.ProfileStore$-CC", "getInstance", new xi1[0]);
            } catch (ClassCastException | ClassNotFoundException | IllegalAccessException | IllegalStateException | NoSuchMethodException | InvocationTargetException e11) {
                q7.j.a("Unable to get ProfileStore instance: ".concat(String.valueOf(e11.getMessage())));
                profileStore = null;
            }
        }
        Object obj = b50Var.f9401b;
        if (profileStore == null) {
            q7.j.d("WebViewCompat failure: No instance");
            if (((Boolean) n7.y.f31093e.f31096c.b(ao.f8941kf)).booleanValue()) {
                br0 br0VarA = ((c70) obj).f9789b.a();
                br0VarA.zzc("action", "webview_p_f");
                br0VarA.zzc("webview_p_f", "No instance");
                br0VarA.b();
                return;
            }
            return;
        }
        this.zza = profileStore.getOrCreateProfile("GMA_WEBVIEW_PROFILE");
        if (((Boolean) n7.y.f31093e.f31096c.b(ao.f8941kf)).booleanValue()) {
            m7.n.C.f30472k.getClass();
            long jElapsedRealtime = SystemClock.elapsedRealtime() - b50Var.f9400a;
            br0 br0VarA2 = ((c70) obj).f9789b.a();
            br0VarA2.zzc("action", "webview_p_l");
            br0VarA2.zzc("webview_p_l", Long.toString(jElapsedRealtime));
            br0VarA2.b();
        }
    }
}
