Step Record v1.1.5版本的 MD5 值为:5797275f89198878d2f00ee92d534382

以下内容为反编译后的 h.java 源代码,内容仅作参考


package sg.bigo.ads.core.player.a;

import androidx.fragment.app.FragmentTransaction;
import com.chartboost.heliumsdk.impl.KKzzzzH1;
import java.io.BufferedInputStream;
import java.io.IOException;
import java.net.HttpURLConnection;
import java.net.Proxy;
import java.net.ProxySelector;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Locale;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;

public final class h {
    private final ExecutorService a = Executors.newSingleThreadExecutor(new sg.bigo.ads.common.g.b("Ping"));
    private final String b;
    private final int c;

    public class a implements Callable<Boolean> {
        private a() {
        }

        public a(h hVar, byte b) {
            this();
        }

        @Override
        public final Boolean call() {
            return Boolean.valueOf(h.this.b());
        }
    }

    public h(String str, int i) {
        this.b = (String) sg.bigo.ads.common.i.a(str);
        this.c = i;
    }

    private List<Proxy> c() {
        ArrayList arrayList = new ArrayList();
        try {
            return ProxySelector.getDefault().select(new URI(d()));
        } catch (URISyntaxException e) {
            sg.bigo.ads.common.l.a.a(0, "ProxyCache", "Pinger#getDefaultProxies, error message is : " + e.toString());
            return arrayList;
        }
    }

    private String d() {
        return String.format(Locale.US, "http://%s:%d/%s", this.b, Integer.valueOf(this.c), "ping");
    }

    public final boolean a() {
        String tz;
        int i = 70;
        byte b = 0;
        int i2 = 0;
        while (i2 < 3) {
            try {
            } catch (InterruptedException | ExecutionException unused) {
                tz = "Error pinging server due to unexpected error";
                sg.bigo.ads.common.l.a.a(0, "ProxyCache", tz);
                i2++;
                i *= 2;
            } catch (TimeoutException unused2) {
                tz = KKzzzzH1.tz("Error pinging server (attempt: ", i2, ", timeout: ", i, "). ");
                sg.bigo.ads.common.l.a.a(0, "ProxyCache", tz);
                i2++;
                i *= 2;
            }
            if (((Boolean) this.a.submit(new a(this, b)).get(i, TimeUnit.MILLISECONDS)).booleanValue()) {
                return true;
            }
            i2++;
            i *= 2;
        }
        sg.bigo.ads.common.l.a.a(0, "ProxyCache", String.format(Locale.US, "Error pinging server (attempts: %d, max timeout: %d). If you see this message, please, report at https://github.com/danikula/AndroidVideoCache/issues/134. Default proxies are: %s", Integer.valueOf(i2), Integer.valueOf(i / 2), c()));
        return false;
    }

    public final boolean b() {
        g gVar = new g(d());
        try {
            byte[] bytes = "ping ok".getBytes();
            try {
                HttpURLConnection b = gVar.b();
                gVar.a = b;
                if (b != null) {
                    gVar.b = new BufferedInputStream(gVar.a.getInputStream(), FragmentTransaction.TRANSIT_EXIT_MASK);
                }
            } catch (IOException e) {
                sg.bigo.ads.common.l.a.a(0, "ProxyCache", "Error opening connection for " + gVar.c + " with offset 0, error message is : " + e.toString());
            }
            byte[] bArr = new byte[bytes.length];
            gVar.a(bArr);
            boolean equals = Arrays.equals(bytes, bArr);
            sg.bigo.ads.common.l.a.a(0, 3, "ProxyCache", "Ping response: `" + new String(bArr) + "`, pinged? " + equals);
            return equals;
        } finally {
            gVar.a();
        }
    }
}