package a4;

import android.webkit.ServiceWorkerController;
import android.webkit.ServiceWorkerWebSettings;
import androidx.annotation.Nullable;
import java.lang.reflect.InvocationHandler;
import org.chromium.support_lib_boundary.ServiceWorkerControllerBoundaryInterface;
import org.chromium.support_lib_boundary.ServiceWorkerWebSettingsBoundaryInterface;

/* JADX INFO: loaded from: classes.dex */
public final class z extends z3.k {

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public ServiceWorkerController f371a;

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public ServiceWorkerControllerBoundaryInterface f372b;

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public final a0 f373c;

    public z() {
        b bVar = k0.f325h;
        if (bVar.a()) {
            ServiceWorkerController serviceWorkerController = ServiceWorkerController.getInstance();
            this.f371a = serviceWorkerController;
            this.f372b = null;
            if (serviceWorkerController == null) {
                this.f371a = ServiceWorkerController.getInstance();
            }
            ServiceWorkerWebSettings serviceWorkerWebSettings = this.f371a.getServiceWorkerWebSettings();
            a0 a0Var = new a0();
            a0Var.f296a = serviceWorkerWebSettings;
            this.f373c = a0Var;
            return;
        }
        if (!bVar.b()) {
            throw k0.a();
        }
        this.f371a = null;
        ServiceWorkerControllerBoundaryInterface serviceWorkerController2 = m0.f345a.getServiceWorkerController();
        this.f372b = serviceWorkerController2;
        InvocationHandler serviceWorkerWebSettings2 = serviceWorkerController2.getServiceWorkerWebSettings();
        a0 a0Var2 = new a0();
        a0Var2.f297b = (ServiceWorkerWebSettingsBoundaryInterface) ee.b.castToSuppLibClass(ServiceWorkerWebSettingsBoundaryInterface.class, serviceWorkerWebSettings2);
        this.f373c = a0Var2;
    }

    @Override // z3.k
    public void setServiceWorkerClient(@Nullable z3.i iVar) {
        b bVar = k0.f325h;
        if (bVar.a()) {
            if (iVar == null) {
                if (this.f371a == null) {
                    this.f371a = ServiceWorkerController.getInstance();
                }
                f.setServiceWorkerClient(this.f371a, null);
                return;
            } else {
                if (this.f371a == null) {
                    this.f371a = ServiceWorkerController.getInstance();
                }
                this.f371a.setServiceWorkerClient(new q(iVar));
                return;
            }
        }
        if (!bVar.b()) {
            throw k0.a();
        }
        if (iVar == null) {
            if (this.f372b == null) {
                this.f372b = m0.f345a.getServiceWorkerController();
            }
            this.f372b.setServiceWorkerClient(null);
        } else {
            if (this.f372b == null) {
                this.f372b = m0.f345a.getServiceWorkerController();
            }
            this.f372b.setServiceWorkerClient(ee.b.createInvocationHandlerFor(new y(iVar)));
        }
    }
}
