导航菜单

页面标题

页面副标题

OVO v3.139.0 - nba.java 源代码

正在查看: OVO v3.139.0 应用的 nba.java JAVA 源代码文件

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


package o.i;

import java.io.EOFException;
import java.io.IOException;
import java.net.InetAddress;
import java.net.InetSocketAddress;
import java.net.Socket;
import java.net.SocketAddress;
import java.net.URI;
import java.util.Collections;
import java.util.EnumMap;
import java.util.HashMap;
import java.util.IdentityHashMap;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.Locale;
import java.util.Map;
import java.util.Random;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.Executor;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ScheduledFuture;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.net.SocketFactory;
import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.SSLSession;
import javax.net.ssl.SSLSocket;
import javax.net.ssl.SSLSocketFactory;
import o.i.bg6;
import o.i.c40;
import o.i.c40.d;
import o.i.cj9;
import o.i.ef9;
import o.i.g69;
import o.i.hs4;
import o.i.ij7;
import o.i.ija;
import o.i.ija.b;
import o.i.jba;
import o.i.mba;
import o.i.quf;
import o.i.t40;
import o.i.t48;
import o.i.ur1;
import o.i.wt5;
import o.i.xt6;
import okhttp3.HttpUrl;
import okhttp3.internal.ws.RealWebSocket;

public final class nba implements y72, hs4.a, ija.c {
    public static final Map<mp4, zme> S;
    public static final Logger T;
    public final SocketFactory A;
    public final SSLSocketFactory B;
    public final HostnameVerifier C;
    public int D;
    public final LinkedList E;
    public final z72 F;
    public t48 G;
    public boolean H;
    public long I;
    public long J;
    public boolean K;
    public final Runnable L;
    public final int M;
    public final boolean N;
    public final quf O;
    public final a P;
    public final cu6 Q;
    public final int R;
    public final InetSocketAddress a;
    public final String b;
    public final String c;
    public final Random d;
    public final ote<doe> e;
    public final int f;
    public final bdg g;
    public g69.a h;
    public hs4 i;
    public ija j;
    public final Object k;

    public final mj7 f140l;
    public int m;
    public final HashMap n;

    public final Executor f141o;
    public final zyd p;
    public final ScheduledExecutorService q;
    public final int r;
    public int s;
    public d t;
    public t40 u;
    public zme v;
    public boolean w;
    public bu6 x;
    public boolean y;
    public boolean z;

    public class a extends bf0 {
        public a() {
            super(1);
        }

        public final void d() {
            nba.this.h.b(true);
        }

        public final void e() {
            nba.this.h.b(false);
        }
    }

    public class b implements Runnable {
        public final CountDownLatch a;
        public final c40 b;

        public class a implements rfe {
            @Override
            public final void close() {
            }

            @Override
            public final long read(yu0 yu0Var, long j) {
                return -1L;
            }

            @Override
            public final jef getTimeout() {
                return jef.NONE;
            }
        }

        public b(CountDownLatch countDownLatch, c40 c40Var) {
            this.a = countDownLatch;
            this.b = c40Var;
        }

        @Override
        public final void run() {
            nba nbaVar;
            d dVar;
            Socket c;
            SSLSession sSLSession;
            Socket socket;
            try {
                this.a.await();
            } catch (InterruptedException unused) {
                Thread.currentThread().interrupt();
            }
            moc g = snk.g(new a());
            try {
                try {
                    nba nbaVar2 = nba.this;
                    cu6 cu6Var = nbaVar2.Q;
                    if (cu6Var == null) {
                        c = nbaVar2.A.createSocket(nbaVar2.a.getAddress(), nba.this.a.getPort());
                    } else {
                        SocketAddress socketAddress = cu6Var.a;
                        if (!(socketAddress instanceof InetSocketAddress)) {
                            throw new bne(zme.f254l.g("Unsupported SocketAddress implementation " + nba.this.Q.a.getClass()));
                        }
                        c = nba.c(nbaVar2, cu6Var.b, (InetSocketAddress) socketAddress, cu6Var.c, cu6Var.d);
                    }
                    Socket socket2 = c;
                    nba nbaVar3 = nba.this;
                    SSLSocketFactory sSLSocketFactory = nbaVar3.B;
                    if (sSLSocketFactory != null) {
                        HostnameVerifier hostnameVerifier = nbaVar3.C;
                        String str = nbaVar3.b;
                        URI a2 = bg6.a(str);
                        if (a2.getHost() != null) {
                            str = a2.getHost();
                        }
                        SSLSocket a3 = sba.a(sSLSocketFactory, hostnameVerifier, socket2, str, nba.this.l(), nba.this.F);
                        sSLSession = a3.getSession();
                        socket = a3;
                    } else {
                        sSLSession = null;
                        socket = socket2;
                    }
                    socket.setTcpNoDelay(true);
                    moc g2 = snk.g(snk.u(socket));
                    this.b.a(snk.r(socket), socket);
                    nba nbaVar4 = nba.this;
                    t40 t40Var = nbaVar4.u;
                    t40Var.getClass();
                    t40.a aVar = new t40.a(t40Var);
                    aVar.c(xf6.a, socket.getRemoteSocketAddress());
                    aVar.c(xf6.b, socket.getLocalSocketAddress());
                    aVar.c(xf6.c, sSLSession);
                    aVar.c(yf6.a, sSLSession == null ? ard.NONE : ard.PRIVACY_AND_INTEGRITY);
                    nbaVar4.u = aVar.a();
                    nba nbaVar5 = nba.this;
                    nbaVar5.t = nbaVar5.new d(nbaVar5.g.b(g2));
                    synchronized (nba.this.k) {
                        nba.this.getClass();
                        if (sSLSession != null) {
                            nba nbaVar6 = nba.this;
                            new ij7.a(sSLSession);
                            nbaVar6.getClass();
                        }
                    }
                } catch (Throwable th) {
                    nba nbaVar7 = nba.this;
                    nbaVar7.t = nbaVar7.new d(nbaVar7.g.b(g));
                    throw th;
                }
            } catch (bne e) {
                nba.this.s(0, mp4.INTERNAL_ERROR, e.a);
                nbaVar = nba.this;
                dVar = nbaVar.new d(nbaVar.g.b(g));
                nbaVar.t = dVar;
            } catch (Exception e2) {
                nba.this.onException(e2);
                nbaVar = nba.this;
                dVar = nbaVar.new d(nbaVar.g.b(g));
                nbaVar.t = dVar;
            }
        }
    }

    public class c implements Runnable {
        public c() {
        }

        @Override
        public final void run() {
            nba.this.getClass();
            nba nbaVar = nba.this;
            nbaVar.f141o.execute(nbaVar.t);
            synchronized (nba.this.k) {
                nba nbaVar2 = nba.this;
                nbaVar2.D = Integer.MAX_VALUE;
                nbaVar2.t();
            }
            nba.this.getClass();
        }
    }

    public class d implements wt5.a, Runnable {
        public final wt5 b;
        public final oba a = new oba(Level.FINE);
        public boolean c = true;

        public d(wt5 wt5Var) {
            this.b = wt5Var;
        }

        @Override
        public final void run() {
            nba nbaVar;
            zme zmeVar;
            String name = Thread.currentThread().getName();
            Thread.currentThread().setName("OkHttpClientTransport");
            while (((xt6.c) this.b).a(this)) {
                try {
                    t48 t48Var = nba.this.G;
                    if (t48Var != null) {
                        t48Var.a();
                    }
                } catch (Throwable th) {
                    try {
                        nba nbaVar2 = nba.this;
                        mp4 mp4Var = mp4.PROTOCOL_ERROR;
                        zme f = zme.f254l.g("error in frame handler").f(th);
                        Map<mp4, zme> map = nba.S;
                        nbaVar2.s(0, mp4Var, f);
                        try {
                            ((xt6.c) this.b).close();
                        } catch (IOException e) {
                            nba.T.log(Level.INFO, "Exception closing frame reader", (Throwable) e);
                        }
                        nbaVar = nba.this;
                    } catch (Throwable th2) {
                        try {
                            ((xt6.c) this.b).close();
                        } catch (IOException e2) {
                            nba.T.log(Level.INFO, "Exception closing frame reader", (Throwable) e2);
                        }
                        nba.this.h.c();
                        Thread.currentThread().setName(name);
                        throw th2;
                    }
                }
            }
            synchronized (nba.this.k) {
                zmeVar = nba.this.v;
            }
            if (zmeVar == null) {
                zmeVar = zme.m.g("End of stream or IOException");
            }
            nba.this.s(0, mp4.INTERNAL_ERROR, zmeVar);
            try {
                ((xt6.c) this.b).close();
            } catch (IOException e3) {
                nba.T.log(Level.INFO, "Exception closing frame reader", (Throwable) e3);
            }
            nbaVar = nba.this;
            nbaVar.h.c();
            Thread.currentThread().setName(name);
        }
    }

    static {
        EnumMap enumMap = new EnumMap(mp4.class);
        mp4 mp4Var = mp4.NO_ERROR;
        zme zmeVar = zme.f254l;
        enumMap.put((EnumMap) mp4Var, (mp4) zmeVar.g("No error: A GRPC status of OK should have been sent"));
        enumMap.put((EnumMap) mp4.PROTOCOL_ERROR, (mp4) zmeVar.g("Protocol error"));
        enumMap.put((EnumMap) mp4.INTERNAL_ERROR, (mp4) zmeVar.g("Internal error"));
        enumMap.put((EnumMap) mp4.FLOW_CONTROL_ERROR, (mp4) zmeVar.g("Flow control error"));
        enumMap.put((EnumMap) mp4.STREAM_CLOSED, (mp4) zmeVar.g("Stream closed"));
        enumMap.put((EnumMap) mp4.FRAME_TOO_LARGE, (mp4) zmeVar.g("Frame too large"));
        enumMap.put((EnumMap) mp4.REFUSED_STREAM, (mp4) zme.m.g("Refused stream"));
        enumMap.put((EnumMap) mp4.CANCEL, (mp4) zme.f.g("Cancelled"));
        enumMap.put((EnumMap) mp4.COMPRESSION_ERROR, (mp4) zmeVar.g("Compression error"));
        enumMap.put((EnumMap) mp4.CONNECT_ERROR, (mp4) zmeVar.g("Connect error"));
        enumMap.put((EnumMap) mp4.ENHANCE_YOUR_CALM, (mp4) zme.k.g("Enhance your calm"));
        enumMap.put((EnumMap) mp4.INADEQUATE_SECURITY, (mp4) zme.i.g("Inadequate security"));
        S = Collections.unmodifiableMap(enumMap);
        T = Logger.getLogger(nba.class.getName());
    }

    public nba() {
        throw null;
    }

    public nba(jba.f fVar, InetSocketAddress inetSocketAddress, String str, String str2, t40 t40Var, cu6 cu6Var, kba kbaVar) {
        bg6.d dVar = bg6.r;
        xt6 xt6Var = new xt6();
        this.d = new Random();
        Object obj = new Object();
        this.k = obj;
        this.n = new HashMap();
        this.D = 0;
        this.E = new LinkedList();
        this.P = new a();
        this.R = 30000;
        ly6.i(inetSocketAddress, "address");
        this.a = inetSocketAddress;
        this.b = str;
        this.r = fVar.j;
        this.f = fVar.n;
        Executor executor = fVar.b;
        ly6.i(executor, "executor");
        this.f141o = executor;
        this.p = new zyd(fVar.b);
        ScheduledExecutorService scheduledExecutorService = fVar.d;
        ly6.i(scheduledExecutorService, "scheduledExecutorService");
        this.q = scheduledExecutorService;
        this.m = 3;
        SocketFactory socketFactory = fVar.f;
        this.A = socketFactory == null ? SocketFactory.getDefault() : socketFactory;
        this.B = fVar.g;
        this.C = fVar.h;
        z72 z72Var = fVar.i;
        ly6.i(z72Var, "connectionSpec");
        this.F = z72Var;
        ly6.i(dVar, "stopwatchFactory");
        this.e = dVar;
        this.g = xt6Var;
        StringBuilder sb = new StringBuilder();
        if (str2 != null) {
            sb.append(str2);
            sb.append(' ');
        }
        sb.append("grpc-java-okhttp/1.57.2");
        this.c = sb.toString();
        this.Q = cu6Var;
        this.L = kbaVar;
        this.M = fVar.p;
        quf.a aVar = fVar.e;
        aVar.getClass();
        this.O = new quf(aVar.a);
        this.f140l = mj7.a(nba.class, inetSocketAddress.toString());
        t40 t40Var2 = t40.b;
        t40.b<t40> bVar = yf6.b;
        IdentityHashMap identityHashMap = new IdentityHashMap(1);
        identityHashMap.put(bVar, t40Var);
        for (Map.Entry<t40.b<?>, Object> entry : t40Var2.a.entrySet()) {
            if (!identityHashMap.containsKey(entry.getKey())) {
                identityHashMap.put(entry.getKey(), entry.getValue());
            }
        }
        this.u = new t40(identityHashMap);
        this.N = fVar.q;
        synchronized (obj) {
        }
    }

    public static void b(nba nbaVar, mp4 mp4Var, String str) {
        nbaVar.getClass();
        nbaVar.s(0, mp4Var, w(mp4Var).a(str));
    }

    public static Socket c(nba nbaVar, InetSocketAddress inetSocketAddress, InetSocketAddress inetSocketAddress2, String str, String str2) throws bne {
        Socket createSocket;
        String str3;
        int i;
        String str4;
        nbaVar.getClass();
        Socket socket = null;
        try {
            InetAddress address = inetSocketAddress2.getAddress();
            SocketFactory socketFactory = nbaVar.A;
            createSocket = address != null ? socketFactory.createSocket(inetSocketAddress2.getAddress(), inetSocketAddress2.getPort()) : socketFactory.createSocket(inetSocketAddress2.getHostName(), inetSocketAddress2.getPort());
        } catch (IOException e) {
            e = e;
        }
        try {
            createSocket.setTcpNoDelay(true);
            createSocket.setSoTimeout(nbaVar.R);
            rfe u = snk.u(createSocket);
            loc f = snk.f(snk.r(createSocket));
            syc i3 = nbaVar.i(inetSocketAddress, str, str2);
            lk6 lk6Var = i3.b;
            qu6 qu6Var = i3.a;
            f.V(String.format(Locale.US, "CONNECT %s:%d HTTP/1.1", qu6Var.a, Integer.valueOf(qu6Var.b)));
            f.V("\r\n");
            int length = lk6Var.a.length / 2;
            for (int i5 = 0; i5 < length; i5++) {
                int i6 = i5 * 2;
                String[] strArr = lk6Var.a;
                if (i6 >= 0 && i6 < strArr.length) {
                    str3 = strArr[i6];
                    f.V(str3);
                    f.V(": ");
                    i = i6 + 1;
                    if (i >= 0 && i < strArr.length) {
                        str4 = strArr[i];
                        f.V(str4);
                        f.V("\r\n");
                    }
                    str4 = null;
                    f.V(str4);
                    f.V("\r\n");
                }
                str3 = null;
                f.V(str3);
                f.V(": ");
                i = i6 + 1;
                if (i >= 0) {
                    str4 = strArr[i];
                    f.V(str4);
                    f.V("\r\n");
                }
                str4 = null;
                f.V(str4);
                f.V("\r\n");
            }
            f.V("\r\n");
            f.flush();
            dne a2 = dne.a(q(u));
            while (!q(u).equals(HttpUrl.FRAGMENT_ENCODE_SET)) {
            }
            int i7 = a2.b;
            if (i7 >= 200 && i7 < 300) {
                createSocket.setSoTimeout(0);
                return createSocket;
            }
            yu0 yu0Var = new yu0();
            try {
                createSocket.shutdownOutput();
                u.read(yu0Var, RealWebSocket.DEFAULT_MINIMUM_DEFLATE_SIZE);
            } catch (IOException e2) {
                yu0Var.b0("Unable to read body: " + e2.toString());
            }
            try {
                createSocket.close();
            } catch (IOException unused) {
            }
            throw new bne(zme.m.g(String.format(Locale.US, "Response returned from proxy was not successful (expected 2xx, got %d %s). Response body:\n%s", Integer.valueOf(i7), a2.c, yu0Var.o())));
        } catch (IOException e3) {
            e = e3;
            socket = createSocket;
            if (socket != null) {
                bg6.b(socket);
            }
            throw new bne(zme.m.g("Failed trying to connect with proxy").f(e));
        }
    }

    public static String q(rfe rfeVar) throws IOException {
        yu0 yu0Var = new yu0();
        while (rfeVar.read(yu0Var, 1L) != -1) {
            if (yu0Var.e(yu0Var.b - 1) == 10) {
                return yu0Var.f0();
            }
        }
        throw new EOFException("\\n not found: " + yu0Var.n1().j());
    }

    public static zme w(mp4 mp4Var) {
        zme zmeVar = S.get(mp4Var);
        if (zmeVar != null) {
            return zmeVar;
        }
        return zme.g.g("Unknown http2 error code: " + mp4Var.httpCode);
    }

    @Override
    public final ija.b[] a() {
        ija.b[] bVarArr;
        synchronized (this.k) {
            bVarArr = new ija.b[this.n.size()];
            Iterator it = this.n.values().iterator();
            int i = 0;
            while (it.hasNext()) {
                bVarArr[i] = ((mba) it.next()).f125l.r();
                i++;
            }
        }
        return bVarArr;
    }

    @Override
    public final void d(zme zmeVar) {
        synchronized (this.k) {
            if (this.v != null) {
                return;
            }
            this.v = zmeVar;
            this.h.d(zmeVar);
            v();
        }
    }

    @Override
    public final void e(t48.c.a aVar, uh3 uh3Var) {
        long nextLong;
        synchronized (this.k) {
            try {
                boolean z = true;
                if (!(this.i != null)) {
                    throw new IllegalStateException();
                }
                if (this.y) {
                    bne m = m();
                    Logger logger = bu6.g;
                    try {
                        uh3Var.execute(new au6(aVar, m));
                    } catch (Throwable th) {
                        bu6.g.log(Level.SEVERE, "Failed to execute PingCallback", th);
                    }
                    return;
                }
                bu6 bu6Var = this.x;
                if (bu6Var != null) {
                    nextLong = 0;
                    z = false;
                } else {
                    nextLong = this.d.nextLong();
                    doe doeVar = (doe) this.e.get();
                    doeVar.b();
                    bu6 bu6Var2 = new bu6(nextLong, doeVar);
                    this.x = bu6Var2;
                    this.O.getClass();
                    bu6Var = bu6Var2;
                }
                if (z) {
                    this.i.ping(false, (int) (nextLong >>> 32), (int) nextLong);
                }
                bu6Var.a(aVar, uh3Var);
            } finally {
            }
        }
    }

    @Override
    public final mj7 f() {
        return this.f140l;
    }

    @Override
    public final tr1 g(ef9 ef9Var, ne9 ne9Var, q11 q11Var, vr1[] vr1VarArr) {
        ly6.i(ef9Var, "method");
        ly6.i(ne9Var, "headers");
        t40 t40Var = this.u;
        xme xmeVar = new xme(vr1VarArr);
        for (vr1 vr1Var : vr1VarArr) {
            vr1Var.W(t40Var, ne9Var);
        }
        synchronized (this.k) {
            try {
                try {
                    return new mba(ef9Var, ne9Var, this.i, this, this.j, this.k, this.r, this.f, this.b, this.c, xmeVar, this.O, q11Var, this.N);
                } catch (Throwable th) {
                    th = th;
                    throw th;
                }
            } catch (Throwable th2) {
                th = th2;
            }
        }
    }

    @Override
    public final Runnable h(g69.a aVar) {
        this.h = aVar;
        if (this.H) {
            t48 t48Var = new t48(new t48.c(this), this.q, this.I, this.J, this.K);
            this.G = t48Var;
            t48Var.c();
        }
        c40 c40Var = new c40(this.p, this);
        c40.d dVar = c40Var.new d(this.g.a(snk.f(c40Var)));
        synchronized (this.k) {
            hs4 hs4Var = new hs4(this, dVar);
            this.i = hs4Var;
            this.j = new ija(this, hs4Var);
        }
        CountDownLatch countDownLatch = new CountDownLatch(1);
        this.p.execute(new b(countDownLatch, c40Var));
        try {
            r();
            countDownLatch.countDown();
            this.p.execute(new c());
            return null;
        } catch (Throwable th) {
            countDownLatch.countDown();
            throw th;
        }
    }

    public final o.i.syc i(java.net.InetSocketAddress r19, java.lang.String r20, java.lang.String r21) {
        throw new UnsupportedOperationException("Method not decompiled: o.i.nba.i(java.net.InetSocketAddress, java.lang.String, java.lang.String):o.i.syc");
    }

    @Override
    public final void j(zme zmeVar) {
        d(zmeVar);
        synchronized (this.k) {
            Iterator it = this.n.entrySet().iterator();
            while (it.hasNext()) {
                Map.Entry entry = (Map.Entry) it.next();
                it.remove();
                ((mba) entry.getValue()).f125l.k(new ne9(), zmeVar, false);
                p((mba) entry.getValue());
            }
            for (mba mbaVar : this.E) {
                mbaVar.f125l.l(zmeVar, ur1.a.MISCARRIED, true, new ne9());
                p(mbaVar);
            }
            this.E.clear();
            v();
        }
    }

    public final void k(int i, zme zmeVar, ur1.a aVar, boolean z, mp4 mp4Var, ne9 ne9Var) {
        synchronized (this.k) {
            mba mbaVar = (mba) this.n.remove(Integer.valueOf(i));
            if (mbaVar != null) {
                if (mp4Var != null) {
                    this.i.g1(i, mp4.CANCEL);
                }
                if (zmeVar != null) {
                    mba.b bVar = mbaVar.f125l;
                    if (ne9Var == null) {
                        ne9Var = new ne9();
                    }
                    bVar.l(zmeVar, aVar, z, ne9Var);
                }
                if (!t()) {
                    v();
                    p(mbaVar);
                }
            }
        }
    }

    public final int l() {
        URI a2 = bg6.a(this.b);
        return a2.getPort() != -1 ? a2.getPort() : this.a.getPort();
    }

    public final bne m() {
        synchronized (this.k) {
            zme zmeVar = this.v;
            if (zmeVar != null) {
                return new bne(zmeVar);
            }
            return new bne(zme.m.g("Connection closed"));
        }
    }

    public final mba n(int i) {
        mba mbaVar;
        synchronized (this.k) {
            mbaVar = (mba) this.n.get(Integer.valueOf(i));
        }
        return mbaVar;
    }

    public final boolean o(int i) {
        boolean z;
        synchronized (this.k) {
            if (i < this.m) {
                z = true;
                if ((i & 1) == 1) {
                }
            }
            z = false;
        }
        return z;
    }

    @Override
    public final void onException(Exception exc) {
        s(0, mp4.INTERNAL_ERROR, zme.m.f(exc));
    }

    public final void p(mba mbaVar) {
        if (this.z && this.E.isEmpty() && this.n.isEmpty()) {
            this.z = false;
            t48 t48Var = this.G;
            if (t48Var != null) {
                synchronized (t48Var) {
                    if (!t48Var.d) {
                        t48.e eVar = t48Var.e;
                        if (eVar == t48.e.PING_SCHEDULED || eVar == t48.e.PING_DELAYED) {
                            t48Var.e = t48.e.IDLE;
                        }
                        if (t48Var.e == t48.e.PING_SENT) {
                            t48Var.e = t48.e.IDLE_AND_PING_SENT;
                        }
                    }
                }
            }
        }
        if (mbaVar.c) {
            this.P.g(mbaVar, false);
        }
    }

    public final void r() {
        synchronized (this.k) {
            this.i.connectionPreface();
            e1e e1eVar = new e1e();
            e1eVar.b(7, this.f);
            this.i.i0(e1eVar);
            if (this.f > 65535) {
                this.i.windowUpdate(0, r1 - 65535);
            }
        }
    }

    public final void s(int i, mp4 mp4Var, zme zmeVar) {
        synchronized (this.k) {
            if (this.v == null) {
                this.v = zmeVar;
                this.h.d(zmeVar);
            }
            if (mp4Var != null && !this.w) {
                this.w = true;
                this.i.o0(mp4Var, new byte[0]);
            }
            Iterator it = this.n.entrySet().iterator();
            while (it.hasNext()) {
                Map.Entry entry = (Map.Entry) it.next();
                if (((Integer) entry.getKey()).intValue() > i) {
                    it.remove();
                    ((mba) entry.getValue()).f125l.l(zmeVar, ur1.a.REFUSED, false, new ne9());
                    p((mba) entry.getValue());
                }
            }
            for (mba mbaVar : this.E) {
                mbaVar.f125l.l(zmeVar, ur1.a.MISCARRIED, true, new ne9());
                p(mbaVar);
            }
            this.E.clear();
            v();
        }
    }

    public final boolean t() {
        boolean z = false;
        while (true) {
            LinkedList linkedList = this.E;
            if (linkedList.isEmpty() || this.n.size() >= this.D) {
                break;
            }
            u((mba) linkedList.poll());
            z = true;
        }
        return z;
    }

    public final String toString() {
        cj9.a b2 = cj9.b(this);
        b2.a(this.f140l.c, "logId");
        b2.b(this.a, "address");
        return b2.toString();
    }

    public final void u(mba mbaVar) {
        ly6.n("StreamId already assigned", mbaVar.f125l.L == -1);
        this.n.put(Integer.valueOf(this.m), mbaVar);
        if (!this.z) {
            this.z = true;
            t48 t48Var = this.G;
            if (t48Var != null) {
                t48Var.b();
            }
        }
        if (mbaVar.c) {
            this.P.g(mbaVar, true);
        }
        mba.b bVar = mbaVar.f125l;
        int i = this.m;
        ly6.l(i, "the stream has been started with id %s", bVar.L == -1);
        bVar.L = i;
        ija ijaVar = bVar.G;
        bVar.K = ijaVar.new b(i, ijaVar.c, bVar);
        mba.b bVar2 = mba.this.f125l;
        if (!(bVar2.j != null)) {
            throw new IllegalStateException();
        }
        synchronized (bVar2.b) {
            ly6.n("Already allocated", !bVar2.f);
            bVar2.f = true;
        }
        bVar2.h();
        quf qufVar = bVar2.c;
        qufVar.getClass();
        qufVar.a.a();
        if (bVar.I) {
            bVar.F.J(mba.this.f126o, bVar.L, bVar.y);
            for (rwh rwhVar : mba.this.j.a) {
                ((vr1) rwhVar).V();
            }
            bVar.y = null;
            yu0 yu0Var = bVar.z;
            if (yu0Var.b > 0) {
                bVar.G.a(bVar.A, bVar.K, yu0Var, bVar.B);
            }
            bVar.I = false;
        }
        ef9.c cVar = mbaVar.h.a;
        if ((cVar != ef9.c.UNARY && cVar != ef9.c.SERVER_STREAMING) || mbaVar.f126o) {
            this.i.flush();
        }
        int i3 = this.m;
        if (i3 < 2147483645) {
            this.m = i3 + 2;
        } else {
            this.m = Integer.MAX_VALUE;
            s(Integer.MAX_VALUE, mp4.NO_ERROR, zme.m.g("Stream ids exhausted"));
        }
    }

    public final void v() {
        if (this.v == null || !this.n.isEmpty() || !this.E.isEmpty() || this.y) {
            return;
        }
        this.y = true;
        t48 t48Var = this.G;
        if (t48Var != null) {
            synchronized (t48Var) {
                t48.e eVar = t48Var.e;
                t48.e eVar2 = t48.e.DISCONNECTED;
                if (eVar != eVar2) {
                    t48Var.e = eVar2;
                    ScheduledFuture<?> scheduledFuture = t48Var.f;
                    if (scheduledFuture != null) {
                        scheduledFuture.cancel(false);
                    }
                    ScheduledFuture<?> scheduledFuture2 = t48Var.g;
                    if (scheduledFuture2 != null) {
                        scheduledFuture2.cancel(false);
                        t48Var.g = null;
                    }
                }
            }
        }
        bu6 bu6Var = this.x;
        if (bu6Var != null) {
            bu6Var.c(m());
            this.x = null;
        }
        if (!this.w) {
            this.w = true;
            this.i.o0(mp4.NO_ERROR, new byte[0]);
        }
        this.i.close();
    }
}