导航菜单

页面标题

页面副标题

Mint v5.7.3 - d.java 源代码

正在查看: Mint v5.7.3 应用的 d.java JAVA 源代码文件

本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。


package qi;

import com.google.firebase.messaging.Constants;
import com.google.firebase.perf.FirebasePerformance;
import java.io.Closeable;
import java.io.IOException;
import java.net.ProtocolException;
import java.net.SocketTimeoutException;
import java.util.ArrayDeque;
import java.util.List;
import java.util.Random;
import java.util.concurrent.TimeUnit;
import kotlin.Metadata;
import kotlin.a0;
import kotlin.collections.r;
import kotlin.jvm.internal.m;
import oh.v;
import okhttp3.Call;
import okhttp3.Callback;
import okhttp3.EventListener;
import okhttp3.OkHttpClient;
import okhttp3.Protocol;
import okhttp3.Request;
import okhttp3.Response;
import okhttp3.WebSocket;
import okhttp3.WebSocketListener;
import qi.g;
import si.f;

@Metadata(d1 = {"\u0000¸\u0001\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\u0010\u000b\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\b\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\t\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0010\u000e\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0015\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0002\b\u0004\n\u0002\u0018\u0002\n\u0002\b\u000b\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0010\u0000\n\u0002\b\u000f\n\u0002\u0018\u0002\n\u0002\b\u0005\u0018\u0000 r2\u00020\u00012\u00020\u0002:\u0005\"&'$*BA\u0012\u0006\u0010o\u001a\u00020n\u0012\u0006\u00107\u001a\u00020\r\u0012\u0006\u0010<\u001a\u000208\u0012\u0006\u0010?\u001a\u00020=\u0012\u0006\u0010A\u001a\u00020\u000f\u0012\b\u0010C\u001a\u0004\u0018\u00010\u0003\u0012\u0006\u0010E\u001a\u00020\u000f¢\u0006\u0004\bp\u0010qJ\f\u0010\u0005\u001a\u00020\u0004*\u00020\u0003H\u0002J\u0018\u0010\n\u001a\u00020\u00042\u0006\u0010\u0007\u001a\u00020\u00062\u0006\u0010\t\u001a\u00020\bH\u0002J\b\u0010\f\u001a\u00020\u000bH\u0002J\b\u0010\u000e\u001a\u00020\rH\u0016J\b\u0010\u0010\u001a\u00020\u000fH\u0016J\b\u0010\u0011\u001a\u00020\u000bH\u0016J\u000e\u0010\u0014\u001a\u00020\u000b2\u0006\u0010\u0013\u001a\u00020\u0012J!\u0010\u0019\u001a\u00020\u000b2\u0006\u0010\u0016\u001a\u00020\u00152\b\u0010\u0018\u001a\u0004\u0018\u00010\u0017H\u0000¢\u0006\u0004\b\u0019\u0010\u001aJ\u0016\u0010\u001f\u001a\u00020\u000b2\u0006\u0010\u001c\u001a\u00020\u001b2\u0006\u0010\u001e\u001a\u00020\u001dJ\u0006\u0010 \u001a\u00020\u000bJ\u0010\u0010\"\u001a\u00020\u000b2\u0006\u0010!\u001a\u00020\u001bH\u0016J\u0010\u0010$\u001a\u00020\u000b2\u0006\u0010#\u001a\u00020\u0006H\u0016J\u0010\u0010&\u001a\u00020\u000b2\u0006\u0010%\u001a\u00020\u0006H\u0016J\u0010\u0010'\u001a\u00020\u000b2\u0006\u0010%\u001a\u00020\u0006H\u0016J\u0018\u0010*\u001a\u00020\u000b2\u0006\u0010(\u001a\u00020\b2\u0006\u0010)\u001a\u00020\u001bH\u0016J\u0010\u0010+\u001a\u00020\u00042\u0006\u0010!\u001a\u00020\u001bH\u0016J\u0010\u0010+\u001a\u00020\u00042\u0006\u0010#\u001a\u00020\u0006H\u0016J\u001a\u0010,\u001a\u00020\u00042\u0006\u0010(\u001a\u00020\b2\b\u0010)\u001a\u0004\u0018\u00010\u001bH\u0016J \u0010.\u001a\u00020\u00042\u0006\u0010(\u001a\u00020\b2\b\u0010)\u001a\u0004\u0018\u00010\u001b2\u0006\u0010-\u001a\u00020\u000fJ\u000f\u0010/\u001a\u00020\u0004H\u0000¢\u0006\u0004\b/\u00100J\u000f\u00101\u001a\u00020\u000bH\u0000¢\u0006\u0004\b1\u00102J\u001c\u00105\u001a\u00020\u000b2\n\u0010*\u001a\u000603j\u0002`42\b\u0010\u0016\u001a\u0004\u0018\u00010\u0015R\u0014\u00107\u001a\u00020\r8\u0002X\u0082\u0004¢\u0006\u0006\n\u0004\b\"\u00106R\u001a\u0010<\u001a\u0002088\u0000X\u0080\u0004¢\u0006\f\n\u0004\b&\u00109\u001a\u0004\b:\u0010;R\u0014\u0010?\u001a\u00020=8\u0002X\u0082\u0004¢\u0006\u0006\n\u0004\b'\u0010>R\u0014\u0010A\u001a\u00020\u000f8\u0002X\u0082\u0004¢\u0006\u0006\n\u0004\b$\u0010@R\u0018\u0010C\u001a\u0004\u0018\u00010\u00038\u0002@\u0002X\u0082\u000e¢\u0006\u0006\n\u0004\b*\u0010BR\u0016\u0010E\u001a\u00020\u000f8\u0002@\u0002X\u0082\u000e¢\u0006\u0006\n\u0004\bD\u0010@R\u0014\u0010H\u001a\u00020\u001b8\u0002X\u0082\u0004¢\u0006\u0006\n\u0004\bF\u0010GR\u0018\u0010L\u001a\u0004\u0018\u00010I8\u0002@\u0002X\u0082\u000e¢\u0006\u0006\n\u0004\bJ\u0010KR\u0018\u0010P\u001a\u0004\u0018\u00010M8\u0002@\u0002X\u0082\u000e¢\u0006\u0006\n\u0004\bN\u0010OR\u0018\u0010S\u001a\u0004\u0018\u00010Q8\u0002@\u0002X\u0082\u000e¢\u0006\u0006\n\u0004\b\u0019\u0010RR\u0018\u0010V\u001a\u0004\u0018\u00010T8\u0002@\u0002X\u0082\u000e¢\u0006\u0006\n\u0004\b.\u0010UR\u0016\u0010Y\u001a\u00020W8\u0002@\u0002X\u0082\u000e¢\u0006\u0006\n\u0004\b\u0014\u0010XR\u0018\u0010\u001c\u001a\u0004\u0018\u00010\u001b8\u0002@\u0002X\u0082\u000e¢\u0006\u0006\n\u0004\b5\u0010GR\u0018\u0010\u001e\u001a\u0004\u0018\u00010\u001d8\u0002@\u0002X\u0082\u000e¢\u0006\u0006\n\u0004\b:\u0010ZR\u001a\u0010]\u001a\b\u0012\u0004\u0012\u00020\u00060[8\u0002X\u0082\u0004¢\u0006\u0006\n\u0004\b\u001f\u0010\\R\u001a\u0010_\u001a\b\u0012\u0004\u0012\u00020^0[8\u0002X\u0082\u0004¢\u0006\u0006\n\u0004\b\u0005\u0010\\R\u0016\u0010\u0010\u001a\u00020\u000f8\u0002@\u0002X\u0082\u000e¢\u0006\u0006\n\u0004\b \u0010@R\u0016\u0010a\u001a\u00020\u00048\u0002@\u0002X\u0082\u000e¢\u0006\u0006\n\u0004\b\f\u0010`R\u0016\u0010c\u001a\u00020\b8\u0002@\u0002X\u0082\u000e¢\u0006\u0006\n\u0004\b\n\u0010bR\u0018\u0010d\u001a\u0004\u0018\u00010\u001b8\u0002@\u0002X\u0082\u000e¢\u0006\u0006\n\u0004\b/\u0010GR\u0016\u0010e\u001a\u00020\u00048\u0002@\u0002X\u0082\u000e¢\u0006\u0006\n\u0004\b1\u0010`R\u0016\u0010g\u001a\u00020\b8\u0002@\u0002X\u0082\u000e¢\u0006\u0006\n\u0004\bf\u0010bR\u0016\u0010i\u001a\u00020\b8\u0002@\u0002X\u0082\u000e¢\u0006\u0006\n\u0004\bh\u0010bR\u0016\u0010k\u001a\u00020\b8\u0002@\u0002X\u0082\u000e¢\u0006\u0006\n\u0004\bj\u0010bR\u0016\u0010m\u001a\u00020\u00048\u0002@\u0002X\u0082\u000e¢\u0006\u0006\n\u0004\bl\u0010`¨\u0006s"}, d2 = {"Lqi/d;", "Lokhttp3/WebSocket;", "Lqi/g$a;", "Lqi/e;", "", "p", "Lsi/f;", Constants.ScionAnalytics.MessageType.DATA_MESSAGE, "", "formatOpcode", "s", "Lug/a0;", "r", "Lokhttp3/Request;", "request", "", "queueSize", "cancel", "Lokhttp3/OkHttpClient;", "client", "l", "Lokhttp3/Response;", "response", "Lhi/c;", "exchange", "j", "(Lokhttp3/Response;Lhi/c;)V", "", "name", "Lqi/d$d;", "streams", "o", "q", "text", "a", "bytes", "d", "payload", "b", "c", "code", "reason", "e", "send", "close", "cancelAfterCloseMillis", "k", "t", "()Z", "u", "()V", "Ljava/lang/Exception;", "Lkotlin/Exception;", "m", "Lokhttp3/Request;", "originalRequest", "Lokhttp3/WebSocketListener;", "Lokhttp3/WebSocketListener;", "n", "()Lokhttp3/WebSocketListener;", "listener", "Ljava/util/Random;", "Ljava/util/Random;", "random", "J", "pingIntervalMillis", "Lqi/e;", "extensions", "f", "minimumDeflateSize", "g", "Ljava/lang/String;", "key", "Lokhttp3/Call;", "h", "Lokhttp3/Call;", "call", "Lgi/a;", "i", "Lgi/a;", "writerTask", "Lqi/g;", "Lqi/g;", "reader", "Lqi/h;", "Lqi/h;", "writer", "Lgi/d;", "Lgi/d;", "taskQueue", "Lqi/d$d;", "Ljava/util/ArrayDeque;", "Ljava/util/ArrayDeque;", "pongQueue", "", "messageAndCloseQueue", "Z", "enqueuedClose", "I", "receivedCloseCode", "receivedCloseReason", "failed", "v", "sentPingCount", "w", "receivedPingCount", "x", "receivedPongCount", "y", "awaitingPong", "Lgi/e;", "taskRunner", "<init>", "(Lgi/e;Lokhttp3/Request;Lokhttp3/WebSocketListener;Ljava/util/Random;JLqi/e;J)V", "z", "okhttp"}, k = 1, mv = {1, 6, 0})
public final class d implements WebSocket, g.a {

    private final Request originalRequest;

    private final WebSocketListener listener;

    private final Random random;

    private final long pingIntervalMillis;

    private WebSocketExtensions extensions;

    private long minimumDeflateSize;

    private final String key;

    private Call call;

    private gi.a writerTask;

    private qi.g reader;

    private qi.h writer;

    private gi.d taskQueue;

    private String name;

    private AbstractC0069d streams;

    private final ArrayDeque<si.f> pongQueue;

    private final ArrayDeque<Object> messageAndCloseQueue;

    private long queueSize;

    private boolean enqueuedClose;

    private int receivedCloseCode;

    private String receivedCloseReason;

    private boolean failed;

    private int sentPingCount;

    private int receivedPingCount;

    private int receivedPongCount;

    private boolean awaitingPong;
    private static final List<Protocol> A = r.e(Protocol.HTTP_1_1);

    @Metadata(d1 = {"\u0000 \n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0002\u0010\b\n\u0002\b\u0005\n\u0002\u0018\u0002\n\u0002\b\u0004\n\u0002\u0010\t\n\u0002\b\u0006\b\u0000\u0018\u00002\u00020\u0001B!\u0012\u0006\u0010\u0007\u001a\u00020\u0002\u0012\b\u0010\f\u001a\u0004\u0018\u00010\b\u0012\u0006\u0010\u0010\u001a\u00020\r¢\u0006\u0004\b\u0011\u0010\u0012R\u0017\u0010\u0007\u001a\u00020\u00028\u0006¢\u0006\f\n\u0004\b\u0003\u0010\u0004\u001a\u0004\b\u0005\u0010\u0006R\u0019\u0010\f\u001a\u0004\u0018\u00010\b8\u0006¢\u0006\f\n\u0004\b\u0005\u0010\t\u001a\u0004\b\n\u0010\u000bR\u0017\u0010\u0010\u001a\u00020\r8\u0006¢\u0006\f\n\u0004\b\n\u0010\u000e\u001a\u0004\b\u0003\u0010\u000f¨\u0006\u0013"}, d2 = {"Lqi/d$a;", "", "", "a", "I", "b", "()I", "code", "Lsi/f;", "Lsi/f;", "c", "()Lsi/f;", "reason", "", "J", "()J", "cancelAfterCloseMillis", "<init>", "(ILsi/f;J)V", "okhttp"}, k = 1, mv = {1, 6, 0})
    public static final class a {

        private final int code;

        private final si.f reason;

        private final long cancelAfterCloseMillis;

        public a(int i, si.f fVar, long j) {
            this.code = i;
            this.reason = fVar;
            this.cancelAfterCloseMillis = j;
        }

        public final long getCancelAfterCloseMillis() {
            return this.cancelAfterCloseMillis;
        }

        public final int getCode() {
            return this.code;
        }

        public final si.f getReason() {
            return this.reason;
        }
    }

    @Metadata(d1 = {"\u0000\u0018\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0002\u0010\b\n\u0002\b\u0005\n\u0002\u0018\u0002\n\u0002\b\u0006\b\u0000\u0018\u00002\u00020\u0001B\u0017\u0012\u0006\u0010\u0007\u001a\u00020\u0002\u0012\u0006\u0010\u000b\u001a\u00020\b¢\u0006\u0004\b\f\u0010\rR\u0017\u0010\u0007\u001a\u00020\u00028\u0006¢\u0006\f\n\u0004\b\u0003\u0010\u0004\u001a\u0004\b\u0005\u0010\u0006R\u0017\u0010\u000b\u001a\u00020\b8\u0006¢\u0006\f\n\u0004\b\u0005\u0010\t\u001a\u0004\b\u0003\u0010\n¨\u0006\u000e"}, d2 = {"Lqi/d$c;", "", "", "a", "I", "b", "()I", "formatOpcode", "Lsi/f;", "Lsi/f;", "()Lsi/f;", Constants.ScionAnalytics.MessageType.DATA_MESSAGE, "<init>", "(ILsi/f;)V", "okhttp"}, k = 1, mv = {1, 6, 0})
    public static final class c {

        private final int formatOpcode;

        private final si.f data;

        public c(int i, si.f data) {
            m.g(data, "data");
            this.formatOpcode = i;
            this.data = data;
        }

        public final si.f getData() {
            return this.data;
        }

        public final int getFormatOpcode() {
            return this.formatOpcode;
        }
    }

    @Metadata(d1 = {"\u0000 \n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\u0010\u000b\n\u0002\b\u0004\n\u0002\u0018\u0002\n\u0002\b\u0005\n\u0002\u0018\u0002\n\u0002\b\b\b&\u0018\u00002\u00020\u0001B\u001f\u0012\u0006\u0010\u0006\u001a\u00020\u0002\u0012\u0006\u0010\f\u001a\u00020\u0007\u0012\u0006\u0010\u0012\u001a\u00020\r¢\u0006\u0004\b\u0013\u0010\u0014R\u0017\u0010\u0006\u001a\u00020\u00028\u0006¢\u0006\f\n\u0004\b\u0003\u0010\u0004\u001a\u0004\b\u0003\u0010\u0005R\u0017\u0010\f\u001a\u00020\u00078\u0006¢\u0006\f\n\u0004\b\b\u0010\t\u001a\u0004\b\n\u0010\u000bR\u0017\u0010\u0012\u001a\u00020\r8\u0006¢\u0006\f\n\u0004\b\u000e\u0010\u000f\u001a\u0004\b\u0010\u0010\u0011¨\u0006\u0015"}, d2 = {"Lqi/d$d;", "Ljava/io/Closeable;", "", "a", "Z", "()Z", "client", "Lsi/e;", "b", "Lsi/e;", "g", "()Lsi/e;", "source", "Lsi/d;", "c", "Lsi/d;", "e", "()Lsi/d;", "sink", "<init>", "(ZLsi/e;Lsi/d;)V", "okhttp"}, k = 1, mv = {1, 6, 0})
    public static abstract class AbstractC0069d implements Closeable {

        private final boolean client;

        private final si.e source;

        private final si.d sink;

        public AbstractC0069d(boolean z, si.e source, si.d sink) {
            m.g(source, "source");
            m.g(sink, "sink");
            this.client = z;
            this.source = source;
            this.sink = sink;
        }

        public final boolean getClient() {
            return this.client;
        }

        public final si.d getSink() {
            return this.sink;
        }

        public final si.e getSource() {
            return this.source;
        }
    }

    @Metadata(d1 = {"\u0000\u0010\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\u0010\t\n\u0002\b\u0004\b\u0082\u0004\u0018\u00002\u00020\u0001B\u0007¢\u0006\u0004\b\u0004\u0010\u0005J\b\u0010\u0003\u001a\u00020\u0002H\u0016¨\u0006\u0006"}, d2 = {"Lqi/d$e;", "Lgi/a;", "", "f", "<init>", "(Lqi/d;)V", "okhttp"}, k = 1, mv = {1, 6, 0})
    private final class e extends gi.a {
        final d e;

        public e(d this$0) {
            super(m.o(this$0.name, " writer"), false, 2, null);
            m.g(this$0, "this$0");
            this.e = this$0;
        }

        @Override
        public long f() {
            try {
                return this.e.t() ? 0L : -1L;
            } catch (IOException e) {
                this.e.m(e, null);
                return -1L;
            }
        }
    }

    @Metadata(d1 = {"\u0000#\n\u0000\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0003*\u0001\u0000\b\n\u0018\u00002\u00020\u0001J\u0018\u0010\u0007\u001a\u00020\u00062\u0006\u0010\u0003\u001a\u00020\u00022\u0006\u0010\u0005\u001a\u00020\u0004H\u0016J\u0018\u0010\n\u001a\u00020\u00062\u0006\u0010\u0003\u001a\u00020\u00022\u0006\u0010\t\u001a\u00020\bH\u0016¨\u0006\u000b"}, d2 = {"qi/d$f", "Lokhttp3/Callback;", "Lokhttp3/Call;", "call", "Lokhttp3/Response;", "response", "Lug/a0;", "onResponse", "Ljava/io/IOException;", "e", "onFailure", "okhttp"}, k = 1, mv = {1, 6, 0})
    public static final class f implements Callback {
        final Request b;

        f(Request request) {
            this.b = request;
        }

        @Override
        public void onFailure(Call call, IOException e) {
            m.g(call, "call");
            m.g(e, "e");
            d.this.m(e, null);
        }

        @Override
        public void onResponse(Call call, Response response) {
            m.g(call, "call");
            m.g(response, "response");
            hi.c exchange = response.getExchange();
            try {
                d.this.j(response, exchange);
                m.d(exchange);
                AbstractC0069d m = exchange.m();
                WebSocketExtensions a = WebSocketExtensions.INSTANCE.a(response.headers());
                d.this.extensions = a;
                if (!d.this.p(a)) {
                    d dVar = d.this;
                    synchronized (dVar) {
                        dVar.messageAndCloseQueue.clear();
                        dVar.close(1010, "unexpected Sec-WebSocket-Extensions in response header");
                    }
                }
                try {
                    d.this.o(di.e.i + " WebSocket " + this.b.url().redact(), m);
                    d.this.getListener().onOpen(d.this, response);
                    d.this.q();
                } catch (Exception e) {
                    d.this.m(e, null);
                }
            } catch (IOException e2) {
                if (exchange != null) {
                    exchange.v();
                }
                d.this.m(e2, response);
                di.e.m(response);
            }
        }
    }

    @Metadata(d1 = {"\u0000\u0011\n\u0000\n\u0002\u0018\u0002\n\u0002\u0010\t\n\u0002\b\u0002*\u0001\u0000\b\n\u0018\u00002\u00020\u0001J\b\u0010\u0003\u001a\u00020\u0002H\u0016¨\u0006\u0004"}, d2 = {"qi/d$g", "Lgi/a;", "", "f", "okhttp"}, k = 1, mv = {1, 6, 0})
    public static final class g extends gi.a {
        final String e;
        final d f;
        final long g;

        public g(String str, d dVar, long j) {
            super(str, false, 2, null);
            this.e = str;
            this.f = dVar;
            this.g = j;
        }

        @Override
        public long f() {
            this.f.u();
            return this.g;
        }
    }

    @Metadata(d1 = {"\u0000\u0011\n\u0000\n\u0002\u0018\u0002\n\u0002\u0010\t\n\u0002\b\u0002*\u0001\u0000\b\n\u0018\u00002\u00020\u0001J\b\u0010\u0003\u001a\u00020\u0002H\u0016¨\u0006\u0004¸\u0006\u0000"}, d2 = {"gi/c", "Lgi/a;", "", "f", "okhttp"}, k = 1, mv = {1, 6, 0})
    public static final class h extends gi.a {
        final String e;
        final boolean f;
        final d g;

        public h(String str, boolean z, d dVar) {
            super(str, z);
            this.e = str;
            this.f = z;
            this.g = dVar;
        }

        @Override
        public long f() {
            this.g.cancel();
            return -1L;
        }
    }

    public d(gi.e taskRunner, Request originalRequest, WebSocketListener listener, Random random, long j, WebSocketExtensions webSocketExtensions, long j2) {
        m.g(taskRunner, "taskRunner");
        m.g(originalRequest, "originalRequest");
        m.g(listener, "listener");
        m.g(random, "random");
        this.originalRequest = originalRequest;
        this.listener = listener;
        this.random = random;
        this.pingIntervalMillis = j;
        this.extensions = webSocketExtensions;
        this.minimumDeflateSize = j2;
        this.taskQueue = taskRunner.i();
        this.pongQueue = new ArrayDeque<>();
        this.messageAndCloseQueue = new ArrayDeque<>();
        this.receivedCloseCode = -1;
        if (!m.b(FirebasePerformance.HttpMethod.GET, originalRequest.method())) {
            throw new IllegalArgumentException(m.o("Request must be GET: ", originalRequest.method()).toString());
        }
        f.Companion companion = si.f.INSTANCE;
        byte[] bArr = new byte[16];
        random.nextBytes(bArr);
        a0 a0Var = a0.a;
        this.key = f.Companion.f(companion, bArr, 0, 0, 3, null).a();
    }

    public final boolean p(WebSocketExtensions webSocketExtensions) {
        if (!webSocketExtensions.unknownValues && webSocketExtensions.clientMaxWindowBits == null) {
            return webSocketExtensions.serverMaxWindowBits == null || new lh.h(8, 15).h(webSocketExtensions.serverMaxWindowBits.intValue());
        }
        return false;
    }

    private final void r() {
        if (!di.e.h || Thread.holdsLock(this)) {
            gi.a aVar = this.writerTask;
            if (aVar != null) {
                gi.d.j(this.taskQueue, aVar, 0L, 2, null);
                return;
            }
            return;
        }
        throw new AssertionError("Thread " + ((Object) Thread.currentThread().getName()) + " MUST hold lock on " + this);
    }

    private final synchronized boolean s(si.f data, int formatOpcode) {
        if (!this.failed && !this.enqueuedClose) {
            if (this.queueSize + data.u() > 16777216) {
                close(1001, null);
                return false;
            }
            this.queueSize += data.u();
            this.messageAndCloseQueue.add(new c(formatOpcode, data));
            r();
            return true;
        }
        return false;
    }

    @Override
    public void a(String text) throws IOException {
        m.g(text, "text");
        this.listener.onMessage(this, text);
    }

    @Override
    public synchronized void b(si.f payload) {
        m.g(payload, "payload");
        if (!this.failed && (!this.enqueuedClose || !this.messageAndCloseQueue.isEmpty())) {
            this.pongQueue.add(payload);
            r();
            this.receivedPingCount++;
        }
    }

    @Override
    public synchronized void c(si.f payload) {
        m.g(payload, "payload");
        this.receivedPongCount++;
        this.awaitingPong = false;
    }

    @Override
    public void cancel() {
        Call call = this.call;
        m.d(call);
        call.cancel();
    }

    @Override
    public boolean close(int code, String reason) {
        return k(code, reason, 60000L);
    }

    @Override
    public void d(si.f bytes) throws IOException {
        m.g(bytes, "bytes");
        this.listener.onMessage(this, bytes);
    }

    @Override
    public void e(int i, String reason) {
        AbstractC0069d abstractC0069d;
        qi.g gVar;
        qi.h hVar;
        m.g(reason, "reason");
        boolean z = true;
        if (!(i != -1)) {
            throw new IllegalArgumentException("Failed requirement.".toString());
        }
        synchronized (this) {
            if (this.receivedCloseCode != -1) {
                z = false;
            }
            if (!z) {
                throw new IllegalStateException("already closed".toString());
            }
            this.receivedCloseCode = i;
            this.receivedCloseReason = reason;
            abstractC0069d = null;
            if (this.enqueuedClose && this.messageAndCloseQueue.isEmpty()) {
                AbstractC0069d abstractC0069d2 = this.streams;
                this.streams = null;
                gVar = this.reader;
                this.reader = null;
                hVar = this.writer;
                this.writer = null;
                this.taskQueue.o();
                abstractC0069d = abstractC0069d2;
            } else {
                gVar = null;
                hVar = null;
            }
            a0 a0Var = a0.a;
        }
        try {
            this.listener.onClosing(this, i, reason);
            if (abstractC0069d != null) {
                this.listener.onClosed(this, i, reason);
            }
        } finally {
            if (abstractC0069d != null) {
                di.e.m(abstractC0069d);
            }
            if (gVar != null) {
                di.e.m(gVar);
            }
            if (hVar != null) {
                di.e.m(hVar);
            }
        }
    }

    public final void j(Response response, hi.c exchange) throws IOException {
        m.g(response, "response");
        if (response.code() != 101) {
            throw new ProtocolException("Expected HTTP 101 response but was '" + response.code() + ' ' + response.message() + '\'');
        }
        String header$default = Response.header$default(response, "Connection", null, 2, null);
        if (!v.t("Upgrade", header$default, true)) {
            throw new ProtocolException("Expected 'Connection' header value 'Upgrade' but was '" + ((Object) header$default) + '\'');
        }
        String header$default2 = Response.header$default(response, "Upgrade", null, 2, null);
        if (!v.t("websocket", header$default2, true)) {
            throw new ProtocolException("Expected 'Upgrade' header value 'websocket' but was '" + ((Object) header$default2) + '\'');
        }
        String header$default3 = Response.header$default(response, "Sec-WebSocket-Accept", null, 2, null);
        String a2 = si.f.INSTANCE.d(m.o(this.key, "258EAFA5-E914-47DA-95CA-C5AB0DC85B11")).s().a();
        if (m.b(a2, header$default3)) {
            if (exchange == null) {
                throw new ProtocolException("Web Socket exchange missing: bad interceptor?");
            }
            return;
        }
        throw new ProtocolException("Expected 'Sec-WebSocket-Accept' header value '" + a2 + "' but was '" + ((Object) header$default3) + '\'');
    }

    public final synchronized boolean k(int code, String reason, long cancelAfterCloseMillis) {
        si.f fVar;
        qi.f.a.c(code);
        if (reason != null) {
            fVar = si.f.INSTANCE.d(reason);
            if (!(((long) fVar.u()) <= 123)) {
                throw new IllegalArgumentException(m.o("reason.size() > 123: ", reason).toString());
            }
        } else {
            fVar = null;
        }
        if (!this.failed && !this.enqueuedClose) {
            this.enqueuedClose = true;
            this.messageAndCloseQueue.add(new a(code, fVar, cancelAfterCloseMillis));
            r();
            return true;
        }
        return false;
    }

    public final void l(OkHttpClient client) {
        m.g(client, "client");
        if (this.originalRequest.header("Sec-WebSocket-Extensions") != null) {
            m(new ProtocolException("Request header not permitted: 'Sec-WebSocket-Extensions'"), null);
            return;
        }
        OkHttpClient build = client.newBuilder().eventListener(EventListener.NONE).protocols(A).build();
        Request build2 = this.originalRequest.newBuilder().header("Upgrade", "websocket").header("Connection", "Upgrade").header("Sec-WebSocket-Key", this.key).header("Sec-WebSocket-Version", "13").header("Sec-WebSocket-Extensions", "permessage-deflate").build();
        hi.e eVar = new hi.e(build, build2, true);
        this.call = eVar;
        m.d(eVar);
        eVar.enqueue(new f(build2));
    }

    public final void m(Exception e2, Response response) {
        m.g(e2, "e");
        synchronized (this) {
            if (this.failed) {
                return;
            }
            this.failed = true;
            AbstractC0069d abstractC0069d = this.streams;
            this.streams = null;
            qi.g gVar = this.reader;
            this.reader = null;
            qi.h hVar = this.writer;
            this.writer = null;
            this.taskQueue.o();
            a0 a0Var = a0.a;
            try {
                this.listener.onFailure(this, e2, response);
            } finally {
                if (abstractC0069d != null) {
                    di.e.m(abstractC0069d);
                }
                if (gVar != null) {
                    di.e.m(gVar);
                }
                if (hVar != null) {
                    di.e.m(hVar);
                }
            }
        }
    }

    public final WebSocketListener getListener() {
        return this.listener;
    }

    public final void o(String name, AbstractC0069d streams) throws IOException {
        m.g(name, "name");
        m.g(streams, "streams");
        WebSocketExtensions webSocketExtensions = this.extensions;
        m.d(webSocketExtensions);
        synchronized (this) {
            this.name = name;
            this.streams = streams;
            this.writer = new qi.h(streams.getClient(), streams.getSink(), this.random, webSocketExtensions.perMessageDeflate, webSocketExtensions.a(streams.getClient()), this.minimumDeflateSize);
            this.writerTask = new e(this);
            long j = this.pingIntervalMillis;
            if (j != 0) {
                long nanos = TimeUnit.MILLISECONDS.toNanos(j);
                this.taskQueue.i(new g(m.o(name, " ping"), this, nanos), nanos);
            }
            if (!this.messageAndCloseQueue.isEmpty()) {
                r();
            }
            a0 a0Var = a0.a;
        }
        this.reader = new qi.g(streams.getClient(), streams.getSource(), this, webSocketExtensions.perMessageDeflate, webSocketExtensions.a(!streams.getClient()));
    }

    public final void q() throws IOException {
        while (this.receivedCloseCode == -1) {
            qi.g gVar = this.reader;
            m.d(gVar);
            gVar.a();
        }
    }

    @Override
    public synchronized long queueSize() {
        return this.queueSize;
    }

    @Override
    public Request getOriginalRequest() {
        return this.originalRequest;
    }

    @Override
    public boolean send(String text) {
        m.g(text, "text");
        return s(si.f.INSTANCE.d(text), 1);
    }

    @Override
    public boolean send(si.f bytes) {
        m.g(bytes, "bytes");
        return s(bytes, 2);
    }

    public final boolean t() throws IOException {
        String str;
        qi.g gVar;
        qi.h hVar;
        int i;
        AbstractC0069d abstractC0069d;
        synchronized (this) {
            if (this.failed) {
                return false;
            }
            qi.h hVar2 = this.writer;
            si.f poll = this.pongQueue.poll();
            Object obj = null;
            if (poll == null) {
                Object poll2 = this.messageAndCloseQueue.poll();
                if (poll2 instanceof a) {
                    i = this.receivedCloseCode;
                    str = this.receivedCloseReason;
                    if (i != -1) {
                        abstractC0069d = this.streams;
                        this.streams = null;
                        gVar = this.reader;
                        this.reader = null;
                        hVar = this.writer;
                        this.writer = null;
                        this.taskQueue.o();
                    } else {
                        long cancelAfterCloseMillis = ((a) poll2).getCancelAfterCloseMillis();
                        this.taskQueue.i(new h(m.o(this.name, " cancel"), true, this), TimeUnit.MILLISECONDS.toNanos(cancelAfterCloseMillis));
                        abstractC0069d = null;
                        gVar = null;
                        hVar = null;
                    }
                } else {
                    if (poll2 == null) {
                        return false;
                    }
                    str = null;
                    gVar = null;
                    hVar = null;
                    i = -1;
                    abstractC0069d = null;
                }
                obj = poll2;
            } else {
                str = null;
                gVar = null;
                hVar = null;
                i = -1;
                abstractC0069d = null;
            }
            a0 a0Var = a0.a;
            try {
                if (poll != null) {
                    m.d(hVar2);
                    hVar2.k(poll);
                } else if (obj instanceof c) {
                    c cVar = (c) obj;
                    m.d(hVar2);
                    hVar2.g(cVar.getFormatOpcode(), cVar.getData());
                    synchronized (this) {
                        this.queueSize -= cVar.getData().u();
                    }
                } else {
                    if (!(obj instanceof a)) {
                        throw new AssertionError();
                    }
                    a aVar = (a) obj;
                    m.d(hVar2);
                    hVar2.a(aVar.getCode(), aVar.getReason());
                    if (abstractC0069d != null) {
                        WebSocketListener webSocketListener = this.listener;
                        m.d(str);
                        webSocketListener.onClosed(this, i, str);
                    }
                }
                return true;
            } finally {
                if (abstractC0069d != null) {
                    di.e.m(abstractC0069d);
                }
                if (gVar != null) {
                    di.e.m(gVar);
                }
                if (hVar != null) {
                    di.e.m(hVar);
                }
            }
        }
    }

    public final void u() {
        synchronized (this) {
            if (this.failed) {
                return;
            }
            qi.h hVar = this.writer;
            if (hVar == null) {
                return;
            }
            int i = this.awaitingPong ? this.sentPingCount : -1;
            this.sentPingCount++;
            this.awaitingPong = true;
            a0 a0Var = a0.a;
            if (i == -1) {
                try {
                    hVar.j(si.f.e);
                    return;
                } catch (IOException e2) {
                    m(e2, null);
                    return;
                }
            }
            m(new SocketTimeoutException("sent ping but didn't receive pong within " + this.pingIntervalMillis + "ms (after " + (i - 1) + " successful ping/pongs)"), null);
        }
    }
}