APK反编译源代码展示 - 南明离火平台提供

应用版本信息
应用名称:Pahlavanan cartoon
版本号:40711.0.0
包名称:ir.darchinstudio.pahlavanan

MD5 校验值:63e534d8efee12c91b8e626b68b614ab

反编译源代码说明

f.java 文件包含反编译后的源代码,请注意,该内容仅供学习和参考使用,不得用于非法用途。


package ir.tapsell.sdk.l;

import android.content.Context;
import android.net.Uri;
import java.io.File;
import java.io.IOException;
import java.net.InetAddress;
import java.net.ServerSocket;
import java.net.Socket;
import java.net.SocketException;
import java.util.Iterator;
import java.util.Locale;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Semaphore;

public class f {
    private static f i;
    private static final Semaphore j = new Semaphore(1);
    private final Object a;
    private final ExecutorService b;
    private final Map<String, g> c;
    private final ServerSocket d;
    private final int e;
    private final Thread f;
    private final ir.tapsell.sdk.l.c g;
    private final k h;

    public static final class b {
        private File a;
        private ir.tapsell.sdk.l.u.c d;
        private ir.tapsell.sdk.l.s.a c = new ir.tapsell.sdk.l.s.h(536870912);
        private ir.tapsell.sdk.l.s.c b = new ir.tapsell.sdk.l.s.f();
        private ir.tapsell.sdk.l.t.b e = new ir.tapsell.sdk.l.t.a();

        public b(Context context) {
            this.d = ir.tapsell.sdk.l.u.d.a(context);
            this.a = r.b(context);
        }

        private ir.tapsell.sdk.l.c b() {
            return new ir.tapsell.sdk.l.c(this.a, this.b, this.c, this.d, this.e);
        }

        public b a(int i) {
            this.c = new ir.tapsell.sdk.l.s.g(i);
            return this;
        }

        public b a(File file) {
            this.a = (File) l.a(file);
            return this;
        }

        public f a() {
            return new f(b());
        }
    }

    public final class c implements Runnable {
        private final Socket a;

        public c(Socket socket) {
            this.a = socket;
        }

        @Override
        public void run() {
            f.this.d(this.a);
        }
    }

    private final class d implements Runnable {
        private final CountDownLatch a;

        public d(CountDownLatch countDownLatch) {
            this.a = countDownLatch;
        }

        @Override
        public void run() {
            this.a.countDown();
            f.this.c();
        }
    }

    private f(ir.tapsell.sdk.l.c cVar) {
        this.a = new Object();
        this.b = Executors.newFixedThreadPool(8);
        this.c = new ConcurrentHashMap();
        this.g = (ir.tapsell.sdk.l.c) l.a(cVar);
        try {
            ServerSocket serverSocket = new ServerSocket(0, 8, InetAddress.getByName("127.0.0.1"));
            this.d = serverSocket;
            int localPort = serverSocket.getLocalPort();
            this.e = localPort;
            i.a("127.0.0.1", localPort);
            CountDownLatch countDownLatch = new CountDownLatch(1);
            Thread thread = new Thread(new d(countDownLatch));
            this.f = thread;
            thread.start();
            countDownLatch.await();
            this.h = new k("127.0.0.1", localPort);
            ir.tapsell.sdk.g.b.b(true, "Proxy cache server started. Is it alive? " + b());
        } catch (IOException | InterruptedException e) {
            this.b.shutdown();
            throw new IllegalStateException("Error starting local proxy server", e);
        }
    }

    private int a() {
        int i2;
        synchronized (this.a) {
            Iterator<g> it = this.c.values().iterator();
            i2 = 0;
            while (it.hasNext()) {
                i2 += it.next().b();
            }
        }
        return i2;
    }

    public static f a(Context context) {
        if (i == null) {
            try {
                j.acquire();
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            i = new b(context).a(10).a(new File(context.getFilesDir(), "videos")).a();
            j.release();
        }
        return i;
    }

    private String a(String str) {
        return String.format(Locale.US, "http://%s:%d/%s", "127.0.0.1", Integer.valueOf(this.e), o.c(str));
    }

    private void a(File file) {
        try {
            this.g.c.a(file);
        } catch (IOException e) {
            ir.tapsell.sdk.g.b.b("Error touching file " + file);
            e.printStackTrace();
        }
    }

    private void a(Throwable th) {
        ir.tapsell.sdk.g.b.b("HttpProxyCacheServer error");
        th.printStackTrace();
    }

    private void a(Socket socket) {
        try {
            if (socket.isClosed()) {
                return;
            }
            socket.close();
        } catch (IOException e) {
            a(new n("Error closing socket", e));
        }
    }

    private File b(String str) {
        ir.tapsell.sdk.l.c cVar = this.g;
        return new File(cVar.a, cVar.b.a(str));
    }

    private void b(Socket socket) {
        try {
            if (socket.isInputShutdown()) {
                return;
            }
            socket.shutdownInput();
        } catch (SocketException unused) {
            ir.tapsell.sdk.g.b.a("Releasing input stream… Socket is closed by client.");
        } catch (IOException e) {
            a(new n("Error closing socket input stream", e));
        }
    }

    private boolean b() {
        return this.h.a(3, 70);
    }

    private g c(String str) {
        g gVar;
        synchronized (this.a) {
            gVar = this.c.get(str);
            if (gVar == null) {
                gVar = new g(str, this.g);
                this.c.put(str, gVar);
            }
        }
        return gVar;
    }

    public void c() {
        while (!Thread.currentThread().isInterrupted()) {
            try {
                Socket accept = this.d.accept();
                ir.tapsell.sdk.g.b.a("Accept new socket " + accept);
                this.b.submit(new c(accept));
            } catch (IOException e) {
                a(new n("Error during waiting connection", e));
                return;
            }
        }
    }

    private void c(Socket socket) {
        try {
            if (socket.isOutputShutdown()) {
                return;
            }
            socket.shutdownOutput();
        } catch (IOException e) {
            ir.tapsell.sdk.g.b.b("Failed to close socket on proxy side: {}. It seems client have already closed connection.", e.getMessage());
        }
    }

    public void d(Socket socket) {
        StringBuilder sb;
        try {
            try {
                ir.tapsell.sdk.l.d a2 = ir.tapsell.sdk.l.d.a(socket.getInputStream());
                ir.tapsell.sdk.g.b.a("Request to cache proxy:" + a2);
                String b2 = o.b(a2.a);
                if (this.h.a(b2)) {
                    this.h.a(socket);
                } else {
                    c(b2).a(a2, socket);
                }
                e(socket);
                sb = new StringBuilder("Opened connections: ");
            } catch (n e) {
                e = e;
                a(new n("Error processing request", e));
                e(socket);
                sb = new StringBuilder("Opened connections: ");
            } catch (SocketException unused) {
                ir.tapsell.sdk.g.b.a("Closing socket… Socket is closed by client.");
                e(socket);
                sb = new StringBuilder("Opened connections: ");
            } catch (IOException e2) {
                e = e2;
                a(new n("Error processing request", e));
                e(socket);
                sb = new StringBuilder("Opened connections: ");
            }
            sb.append(a());
            ir.tapsell.sdk.g.b.a(sb.toString());
        } catch (Throwable th) {
            e(socket);
            ir.tapsell.sdk.g.b.a("Opened connections: " + a());
            throw th;
        }
    }

    private void e(Socket socket) {
        b(socket);
        c(socket);
        a(socket);
    }

    public String a(String str, boolean z) {
        if (!z || !e(str)) {
            return b() ? a(str) : str;
        }
        File b2 = b(str);
        a(b2);
        return Uri.fromFile(b2).toString();
    }

    public String d(String str) {
        return a(str, true);
    }

    public boolean e(String str) {
        l.a(str, "Url can't be null!");
        return b(str).exists();
    }
}