中建乐购 v3.2.2版本的 MD5 值为:0553721e6bc6ba8dd67004696a555b81

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


package com.danikula.videocache;

import java.io.IOException;
import java.io.OutputStream;
import java.net.Proxy;
import java.net.ProxySelector;
import java.net.Socket;
import java.net.URI;
import java.net.URISyntaxException;
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;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class m {
    private static final Logger f6060a = LoggerFactory.getLogger("Pinger");
    private static final String f6061b = "ping";
    private static final String f6062c = "ping ok";
    private final ExecutorService f6063d = Executors.newSingleThreadExecutor();
    private final String f6064e;
    private final int f6065f;

    public m(String str, int i2) {
        this.f6064e = (String) n.a(str);
        this.f6065f = i2;
    }

    public boolean a(int i2, int i3) {
        n.a(i2 >= 1);
        n.a(i3 > 0);
        int i4 = i3;
        int i5 = 0;
        while (i5 < i2) {
            try {
            } catch (InterruptedException | ExecutionException e2) {
                f6060a.error("Error pinging server due to unexpected error", e2);
            } catch (TimeoutException unused) {
                f6060a.warn("Error pinging server (attempt: " + i5 + ", timeout: " + i4 + "). ");
            }
            if (((Boolean) this.f6063d.submit(new a()).get(i4, TimeUnit.MILLISECONDS)).booleanValue()) {
                return true;
            }
            i5++;
            i4 *= 2;
        }
        String format = 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(i5), Integer.valueOf(i4 / 2), a());
        f6060a.error(format, (Throwable) new ProxyCacheException(format));
        return false;
    }

    private List<Proxy> a() {
        try {
            return ProxySelector.getDefault().select(new URI(c()));
        } catch (URISyntaxException e2) {
            throw new IllegalStateException(e2);
        }
    }

    public boolean a(String str) {
        return f6061b.equals(str);
    }

    public void a(Socket socket) throws IOException {
        OutputStream outputStream = socket.getOutputStream();
        outputStream.write("HTTP/1.1 200 OK\n\n".getBytes());
        outputStream.write(f6062c.getBytes());
    }

    public boolean b() throws ProxyCacheException {
        k kVar = new k(c());
        try {
            byte[] bytes = f6062c.getBytes();
            kVar.a(0L);
            byte[] bArr = new byte[bytes.length];
            kVar.a(bArr);
            boolean equals = Arrays.equals(bytes, bArr);
            Logger logger = f6060a;
            logger.info("Ping response: `" + new String(bArr) + "`, pinged? " + equals);
            return equals;
        } catch (ProxyCacheException e2) {
            f6060a.error("Error reading ping response", (Throwable) e2);
            return false;
        } finally {
            kVar.b();
        }
    }

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

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

        @Override
        public Boolean call() throws Exception {
            return Boolean.valueOf(m.this.b());
        }
    }
}