导航菜单

页面标题

页面副标题

Dostt v1.0.89 - a.java 源代码

正在查看: Dostt v1.0.89 应用的 a.java JAVA 源代码文件

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


package expo.modules.fetch;

import Aj.o;
import android.content.Context;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.lang.ref.WeakReference;
import java.net.URL;
import java.net.URLConnection;
import kotlin.jvm.internal.DefaultConstructorMarker;
import kotlin.jvm.internal.r;
import nk.G;
import nk.g;
import okhttp3.HttpUrl;
import okhttp3.Interceptor;
import okhttp3.MediaType;
import okhttp3.Protocol;
import okhttp3.Request;
import okhttp3.Response;
import okhttp3.ResponseBody;

public final class a implements Interceptor {
    public static final C0184a b = new C0184a(null);
    private final WeakReference a;

    public static final class C0184a {
        public C0184a(DefaultConstructorMarker defaultConstructorMarker) {
            this();
        }

        public final URL a(URL url) {
            r.f(url, "url");
            if (!r.b(url.getProtocol(), "file")) {
                return url;
            }
            return new URL("http://filesystem.local" + url.getPath());
        }

        private C0184a() {
        }
    }

    public a(Context context) {
        r.f(context, "context");
        this.a = new WeakReference(context);
    }

    private final Response c(Request request) {
        return new Response.Builder().r(request).p(Protocol.d).g(404).m("File not found").b(ResponseBody.b.a("File not found", MediaType.e.a("text/plain"))).c();
    }

    private final MediaType d(String str) {
        String guessContentTypeFromName = URLConnection.guessContentTypeFromName(str);
        if (guessContentTypeFromName == null) {
            guessContentTypeFromName = "application/octet-stream";
        }
        MediaType.Companion companion = MediaType.e;
        MediaType b2 = companion.b(guessContentTypeFromName);
        return b2 == null ? companion.a("application/octet-stream") : b2;
    }

    private final String e(HttpUrl httpUrl) {
        return o.G(httpUrl.toString(), "http://filesystem.local", "file://", false, 4, (Object) null);
    }

    public Response a(Interceptor.Chain chain) {
        r.f(chain, "chain");
        Request m = chain.m();
        String e = e(m.l());
        if (!o.K(e, "file://", false, 2, (Object) null)) {
            return chain.a(m);
        }
        if (o.K(e, "file:///android_asset/", false, 2, (Object) null)) {
            String v0 = o.v0(e, "file:///android_asset/");
            Context context = (Context) this.a.get();
            if (context == null) {
                throw new Wf.b();
            }
            try {
                return new Response.Builder().r(m).p(Protocol.d).g(200).m("OK").b(b(context, v0)).c();
            } catch (IOException unused) {
                return c(m);
            }
        }
        String substring = e.substring(7);
        r.e(substring, "substring(...)");
        File file = new File(substring);
        if (!file.exists()) {
            return c(m);
        }
        ResponseBody.Companion companion = ResponseBody.b;
        g d = G.d(G.k(file));
        String name = file.getName();
        r.e(name, "getName(...)");
        return new Response.Builder().r(m).p(Protocol.d).g(200).m("OK").b(companion.b(d, d(name), file.length())).c();
    }

    public final ResponseBody b(Context context, String fileName) {
        r.f(context, "context");
        r.f(fileName, "fileName");
        InputStream open = context.getAssets().open(fileName);
        r.e(open, "open(...)");
        return ResponseBody.Companion.e(ResponseBody.b, G.d(G.l(open)), d(fileName), 0L, 2, (Object) null);
    }
}