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

应用版本信息
应用名称:Epic Games Store
版本号:5.1.0
包名称:com.epicgames.portal

MD5 校验值:ac0107089df22e8b2a14c76c592b76ef

反编译源代码说明

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


package z1;

import android.content.Context;
import android.net.Uri;
import android.util.Log;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import com.epicgames.portal.cloud.launcher.model.BuildInfo;
import com.epicgames.portal.common.event.EventHandler;
import com.epicgames.portal.common.model.ErrorCode;
import com.epicgames.portal.common.model.ValueOrError;
import com.epicgames.portal.common.w;
import com.epicgames.portal.common.workscheduler.WorkScheduler;
import com.epicgames.portal.services.downloader.manager.model.DownloadProgress;
import com.epicgames.portal.services.downloader.model.DownloadProgressUpdatedArgs;
import com.epicgames.portal.services.downloader.model.DownloadRequest;
import com.tonyodev.fetch2.Download;
import com.tonyodev.fetch2.Request;
import com.tonyodev.fetch2core.DownloadBlock;
import i6.d;
import i6.j;
import i6.m;
import i6.n;
import i6.q;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.math.BigInteger;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.List;
import java.util.concurrent.TimeUnit;
import s6.k;
import x1.h;

public abstract class e implements g, EventHandler<DownloadProgress> {

    private static final ErrorCode f11105s = new ErrorCode("DM-DELETE");

    private static final ErrorCode f11106t = new ErrorCode("DM-DLFAILED");

    private static final ErrorCode f11107u = new ErrorCode("DM-NOFILE");

    private static final ErrorCode f11108v = new ErrorCode("DM-INTERNAL");

    private static final ErrorCode f11109w = new ErrorCode("DM-NOPERMS");

    private static final ErrorCode f11110x = new ErrorCode("DM-NOSPACE");

    private static final ErrorCode f11111y = new ErrorCode("DM-RETRIES");

    private static final ErrorCode f11112z = new ErrorCode("DM-UNKNOWN");

    protected i6.c f11113a;

    private int f11114b;

    protected final String f11119g;

    protected final int f11120h;

    protected final DownloadRequest f11121i;

    protected final u1.d f11122j;

    protected final Context f11123k;

    protected final WorkScheduler f11124l;

    protected final EventHandler<DownloadProgressUpdatedArgs> f11125m;

    private d f11130r;

    private long f11115c = 0;

    private long f11116d = 0;

    private long f11117e = 0;

    private float f11118f = 0.0f;

    private final com.epicgames.portal.common.event.c<ValueOrError<g>> f11126n = new com.epicgames.portal.common.event.c<>();

    int f11127o = 0;

    private boolean f11128p = false;

    private boolean f11129q = false;

    public static class a {

        static final int[] f11131a;

        static {
            int[] iArr = new int[i6.b.values().length];
            f11131a = iArr;
            try {
                iArr[i6.b.f5793i.ordinal()] = 1;
            } catch (NoSuchFieldError unused) {
            }
            try {
                f11131a[i6.b.f5798n.ordinal()] = 2;
            } catch (NoSuchFieldError unused2) {
            }
            try {
                f11131a[i6.b.f5799o.ordinal()] = 3;
            } catch (NoSuchFieldError unused3) {
            }
            try {
                f11131a[i6.b.f5794j.ordinal()] = 4;
            } catch (NoSuchFieldError unused4) {
            }
            try {
                f11131a[i6.b.f5795k.ordinal()] = 5;
            } catch (NoSuchFieldError unused5) {
            }
            try {
                f11131a[i6.b.f5801q.ordinal()] = 6;
            } catch (NoSuchFieldError unused6) {
            }
            try {
                f11131a[i6.b.f5809y.ordinal()] = 7;
            } catch (NoSuchFieldError unused7) {
            }
            try {
                f11131a[i6.b.f5797m.ordinal()] = 8;
            } catch (NoSuchFieldError unused8) {
            }
            try {
                f11131a[i6.b.f5800p.ordinal()] = 9;
            } catch (NoSuchFieldError unused9) {
            }
            try {
                f11131a[i6.b.f5807w.ordinal()] = 10;
            } catch (NoSuchFieldError unused10) {
            }
            try {
                f11131a[i6.b.f5796l.ordinal()] = 11;
            } catch (NoSuchFieldError unused11) {
            }
            try {
                f11131a[i6.b.f5803s.ordinal()] = 12;
            } catch (NoSuchFieldError unused12) {
            }
            try {
                f11131a[i6.b.f5804t.ordinal()] = 13;
            } catch (NoSuchFieldError unused13) {
            }
            try {
                f11131a[i6.b.f5810z.ordinal()] = 14;
            } catch (NoSuchFieldError unused14) {
            }
            try {
                f11131a[i6.b.f5802r.ordinal()] = 15;
            } catch (NoSuchFieldError unused15) {
            }
            try {
                f11131a[i6.b.f5806v.ordinal()] = 16;
            } catch (NoSuchFieldError unused16) {
            }
            try {
                f11131a[i6.b.f5805u.ordinal()] = 17;
            } catch (NoSuchFieldError unused17) {
            }
            try {
                f11131a[i6.b.f5792h.ordinal()] = 18;
            } catch (NoSuchFieldError unused18) {
            }
            try {
                f11131a[i6.b.f5808x.ordinal()] = 19;
            } catch (NoSuchFieldError unused19) {
            }
        }
    }

    static final class b extends w<e> {

        private final int f11132e;

        b(e eVar, int i10) {
            super(eVar, "fetch-download-resume");
            this.f11132e = i10;
        }

        @Override
        public void onRun(e eVar) {
            eVar.s(this.f11132e);
        }
    }

    public static final class c extends w<e> {
        c(e eVar) {
            super(eVar, "fetch-download-retry");
        }

        @Override
        public void onRun(e eVar) {
            Log.v("DownloadFileState", "onRun - retry");
            ValueOrError J = eVar.J();
            if (J.isError()) {
                eVar.y(J.getErrorCode());
            } else {
                eVar.f11125m.invoke(new DownloadProgressUpdatedArgs(eVar.f11120h, eVar.f11121i, 0, 0, true));
            }
        }
    }

    public final class d implements j {

        private final EventHandler<DownloadProgress> f11133a;

        private final BuildInfo f11134b;

        private final u1.d f11135c;

        d(EventHandler<DownloadProgress> eventHandler, BuildInfo buildInfo, u1.d dVar) {
            this.f11133a = eventHandler;
            this.f11134b = buildInfo;
            this.f11135c = dVar;
        }

        private void A(ErrorCode errorCode) {
            this.f11133a.invoke(new DownloadProgress(this.f11134b, errorCode));
        }

        private void B(Download download, boolean z10, boolean z11) {
            this.f11133a.invoke(new DownloadProgress(this.f11134b, (int) download.f(), (int) download.i(), z10, z11));
        }

        @Override
        public void a(@NonNull Download download, @NonNull List<? extends DownloadBlock> list, int i10) {
            Log.d("DownloadFileState", "onStarted: ");
        }

        @Override
        public void b(@NonNull Download download, @NonNull i6.b bVar, @Nullable Throwable th) {
            if (th != null) {
                Log.e("DownloadFileState", "Download failed with exception", th);
            } else {
                Log.e("DownloadFileState", "Download failed");
            }
            ErrorCode I = e.I(bVar);
            if (I != null) {
                A(I);
            }
            Log.e("DownloadFileState", "onError " + I);
        }

        @Override
        public void c(@NonNull Download download, long j10, long j11) {
            if (j11 > e.this.f11116d) {
                e.this.f11116d = j11;
            }
            e.this.f11117e = download.i();
            e.this.f11118f = ((float) download.i()) / ((float) download.f());
            Log.v("DownloadFileState", "onProgress : " + e.this.f11118f);
            B(download, false, e.this.f11129q);
        }

        @Override
        public void d(@NonNull Download download, @NonNull DownloadBlock downloadBlock, int i10) {
        }

        @Override
        public void h(@NonNull Download download) {
            Log.v("DownloadFileState", "onAdded");
            if (e.this.f11115c <= 0) {
                e.this.f11115c = System.currentTimeMillis();
            }
        }

        @Override
        public void i(@NonNull Download download) {
            Log.d("DownloadFileState", "onWaitingNetwork: ");
        }

        @Override
        public void n(Download download) {
            Log.v("DownloadFileState", "onCancelled");
            String t10 = download.t();
            File file = new File(t10);
            if (file.exists()) {
                if (file.delete()) {
                    Log.i("DownloadFileState", "Deleted partial download for file: " + t10);
                    return;
                }
                Log.e("DownloadFileState", "Failed to delete partial download for file: " + t10);
            }
        }

        @Override
        public void o(@NonNull Download download) {
            if (download.getStatus() == q.FAILED) {
                ErrorCode I = e.I(download.F());
                if (I != null) {
                    A(I);
                }
                Log.e("DownloadFileState", "onResumed - " + I);
                return;
            }
            Log.v("DownloadFileState", "onResumed - no error");
            B(download, false, false);
        }

        @Override
        public void r(@NonNull Download download) {
            Log.v("DownloadFileState", "onRemoved");
        }

        @Override
        public void t(@NonNull Download download) {
            Log.v("DownloadFileState", "onDeleted");
        }

        @Override
        public void u(@NonNull Download download) {
            Log.v("DownloadFileState", "onPause");
            B(download, true, true);
        }

        @Override
        public void w(@NonNull Download download) {
            Log.v("DownloadFileState", "onCompleted");
            B(download, false, false);
            e.this.A();
        }

        @Override
        public void y(@NonNull Download download, boolean z10) {
            Log.v("DownloadFileState", "onQueued paused=" + e.this.f11129q);
            if (e.this.f11129q) {
                e.this.E();
            }
            B(download, true, e.this.f11129q);
        }
    }

    public e(String str, int i10, DownloadRequest downloadRequest, Context context, WorkScheduler workScheduler, u1.d dVar, EventHandler<DownloadProgressUpdatedArgs> eventHandler) {
        this.f11119g = str;
        this.f11120h = i10;
        this.f11121i = downloadRequest;
        this.f11124l = workScheduler;
        this.f11122j = dVar;
        this.f11123k = context;
        this.f11125m = eventHandler;
    }

    public static void C(Request request) {
    }

    public void D(i6.b bVar) {
        Throwable a10 = bVar.a();
        if (a10 != null) {
            Log.e("DownloadFileState", "Failed to enqueue download", a10);
        } else {
            Log.e("DownloadFileState", "Failed to enqueue download");
        }
        ErrorCode I = I(bVar);
        if (I != null) {
            invoke(new DownloadProgress(this.f11121i.buildInfo, I));
        }
    }

    public void E() {
        try {
            i6.c cVar = this.f11113a;
            if (cVar == null || cVar.isClosed()) {
                return;
            }
            Log.v("DownloadFileState", "pausing...");
            this.f11129q = true;
            this.f11113a.w(this.f11114b);
        } catch (m6.a e10) {
            Log.e("DownloadFileState", "Error while pausing download", e10);
        }
    }

    private ValueOrError<Void> H(BuildInfo.ManifestDownloadInfo manifestDownloadInfo) {
        Request request = new Request(u(manifestDownloadInfo), v(manifestDownloadInfo).toString());
        request.m(i6.a.REPLACE_EXISTING);
        request.y(n.NORMAL);
        request.x(m.ALL);
        request.v(this.f11120h);
        List<BuildInfo.ManifestDownloadInfo.Header> list = manifestDownloadInfo.headers;
        if (list != null) {
            for (BuildInfo.ManifestDownloadInfo.Header header : list) {
                request.a(header.name, header.value);
            }
        }
        if (this.f11113a == null) {
            this.f11113a = i6.c.f5814a.a(new d.a(this.f11123k).c(this.f11123k.getPackageName()).b(true).d(200L).a());
        }
        d dVar = this.f11130r;
        if (dVar != null) {
            this.f11113a.m(dVar);
            this.f11130r = null;
        }
        d dVar2 = new d(this, this.f11121i.buildInfo, this.f11122j);
        this.f11130r = dVar2;
        this.f11113a.x(dVar2);
        this.f11114b = request.getId();
        this.f11113a.z(request, new k() {
            @Override
            public final void a(Object obj) {
                e.C((Request) obj);
            }
        }, new k() {
            @Override
            public final void a(Object obj) {
                e.this.D((i6.b) obj);
            }
        });
        return new ValueOrError<>(null);
    }

    public static ErrorCode I(i6.b bVar) {
        if (bVar == null) {
            return null;
        }
        switch (a.f11131a[bVar.ordinal()]) {
            case 1:
                return null;
            case 2:
                return f11109w;
            case 3:
                return f11110x;
            case 4:
                return f11107u;
            case 5:
            case 6:
            case 7:
            case 8:
            case 9:
            case 10:
            case 11:
                return f11106t;
            case 12:
            case 13:
            case 14:
            case 15:
            case 16:
            case 17:
                return f11108v;
            default:
                return f11112z;
        }
    }

    public ValueOrError<Void> J() {
        BuildInfo.ManifestDownloadInfo x10 = x();
        while (x10 != null) {
            ValueOrError<Void> H = H(x10);
            if (H.isError()) {
                ErrorCode errorCode = H.getErrorCode();
                if (errorCode.equals(f11109w)) {
                    this.f11125m.invoke(new DownloadProgressUpdatedArgs(this.f11120h, this.f11121i, errorCode));
                    return H;
                }
                this.f11127o++;
                x10 = x();
            } else {
                this.f11125m.invoke(new DownloadProgressUpdatedArgs(this.f11120h, this.f11121i, 0, 0, true));
                return new ValueOrError<>();
            }
        }
        return new ValueOrError<>(null, f11111y);
    }

    public void s(int i10) {
        this.f11113a.y(i10);
    }

    private BuildInfo.ManifestDownloadInfo x() {
        List<BuildInfo.ManifestDownloadInfo> list = this.f11121i.buildInfo.manifests;
        for (int i10 = this.f11127o; i10 < list.size(); i10++) {
            BuildInfo.ManifestDownloadInfo manifestDownloadInfo = list.get(i10);
            if (manifestDownloadInfo.uri.startsWith("http")) {
                return manifestDownloadInfo;
            }
            this.f11127o++;
        }
        return null;
    }

    protected abstract ValueOrError<g> A();

    @Override
    public boolean invoke(DownloadProgress downloadProgress) {
        if (this.f11128p) {
            Log.v("DownloadFileState", "invoke - cancelled");
            return false;
        }
        ValueOrError<Void> valueOrError = downloadProgress.complete;
        if (valueOrError == null) {
            Log.v("DownloadFileState", "invoke - progress");
            z(downloadProgress);
            return true;
        }
        ErrorCode errorCode = valueOrError.getErrorCode();
        if (errorCode == null) {
            File v10 = v(this.f11121i.buildInfo.manifests.get(this.f11127o));
            if (v10.exists()) {
                if (!K(v10)) {
                    errorCode = h.f10748n;
                }
            } else {
                errorCode = h.f10747m;
            }
        }
        if (errorCode == null) {
            Log.v("DownloadFileState", "invoke - success");
            A();
            return false;
        }
        if (!errorCode.equals(f11106t) && !errorCode.equals(f11112z)) {
            Log.v("DownloadFileState", "invoke - error");
            y(errorCode);
            return false;
        }
        Log.v("DownloadFileState", "invoke - error retry");
        if (this.f11129q) {
            return false;
        }
        Log.v("DownloadFileState", "retry");
        this.f11127o++;
        this.f11124l.h1(new c(this), 4000L, TimeUnit.MILLISECONDS);
        return true;
    }

    public void F(ErrorCode errorCode) {
        if (this.f11117e <= 0) {
            return;
        }
        this.f11122j.c(new u1.a("Portal.Downloader.Stats").d("AppName", this.f11121i.buildInfo.appName).d("BuildLabel", this.f11121i.buildInfo.labelName).d("ErrorCode", errorCode != null ? errorCode.toString() : "OK").b("FinalProgressPercent", this.f11118f).d("PeakDownloadSpeed", Long.toString(this.f11116d)).e("ProcessSuccess", errorCode == null).d("TotalDownloadedData", Long.toString(this.f11117e)).b("TotalElapsedTime", ((float) (System.currentTimeMillis() - this.f11115c)) / 1000.0f).d("DownloaderType", "FetchDownloader").d("Status", "Started").a());
    }

    public void G() {
        i6.c cVar = this.f11113a;
        if (cVar != null) {
            cVar.close();
            this.f11113a = null;
        }
    }

    protected boolean K(File file) {
        return false;
    }

    @Override
    public com.epicgames.portal.common.event.b<ValueOrError<g>> a() {
        return this.f11126n;
    }

    @Override
    public void cancel() {
        Log.v("DownloadFileState", "cancel");
        this.f11129q = false;
        try {
            i6.c cVar = this.f11113a;
            if (cVar != null) {
                cVar.a(this.f11114b);
            }
        } catch (m6.a e10) {
            Log.e("DownloadFileState", "Error while canceling download", e10);
        }
        this.f11128p = true;
        y(h.f10746l);
    }

    @Override
    public void g() {
        Log.v("DownloadFileState", "resume : " + this.f11129q);
        if (this.f11129q) {
            this.f11129q = false;
            try {
                i6.c cVar = this.f11113a;
                if (cVar != null) {
                    if (!cVar.isClosed()) {
                        Log.v("DownloadFileState", "resuming...");
                        this.f11124l.h1(new b(this, this.f11114b), 1000L, TimeUnit.MILLISECONDS);
                    } else {
                        Log.v("DownloadFileState", "starting...");
                        start();
                    }
                }
            } catch (m6.a e10) {
                Log.e("DownloadFileState", "Error when resuming download", e10);
            }
        }
    }

    @Override
    public boolean isRelated(Object obj) {
        return false;
    }

    @Override
    public void j() {
        Log.v("DownloadFileState", "pause");
        E();
    }

    public void r(ValueOrError<g> valueOrError) {
        this.f11126n.c(valueOrError);
    }

    @Override
    public ValueOrError<g> start() {
        this.f11129q = false;
        this.f11127o = 0;
        File v10 = v(this.f11121i.buildInfo.manifests.get(0));
        if (v10.exists()) {
            if (K(v10)) {
                return A();
            }
            if (!v10.delete()) {
                return y(f11105s);
            }
            Log.i("DownloadManager", "Deleted file for failing verification: " + v10.toString());
        }
        ValueOrError<Void> J = J();
        if (J.isError()) {
            return y(J.getErrorCode());
        }
        this.f11125m.invoke(new DownloadProgressUpdatedArgs(this.f11120h, this.f11121i, 0, 0, true));
        return new ValueOrError<>(this);
    }

    public String t(File file) {
        MessageDigest messageDigest;
        FileInputStream fileInputStream;
        if (!file.exists()) {
            return "";
        }
        FileInputStream fileInputStream2 = null;
        try {
            messageDigest = MessageDigest.getInstance("SHA1");
            fileInputStream = new FileInputStream(file);
        } catch (IOException | NoSuchAlgorithmException unused) {
        } catch (Throwable th) {
            th = th;
        }
        try {
            byte[] bArr = new byte[16384];
            while (true) {
                int read = fileInputStream.read(bArr);
                if (read <= 0) {
                    break;
                }
                messageDigest.update(bArr, 0, read);
            }
            String replace = String.format("%40s", new BigInteger(1, messageDigest.digest()).toString(16)).replace(' ', '0');
            try {
                fileInputStream.close();
            } catch (IOException e10) {
                StringWriter stringWriter = new StringWriter();
                e10.printStackTrace(new PrintWriter(stringWriter));
                Log.e("IgnoredException", stringWriter.toString());
            }
            return replace;
        } catch (IOException | NoSuchAlgorithmException unused2) {
            fileInputStream2 = fileInputStream;
            if (fileInputStream2 != null) {
                try {
                    fileInputStream2.close();
                } catch (IOException e11) {
                    StringWriter stringWriter2 = new StringWriter();
                    e11.printStackTrace(new PrintWriter(stringWriter2));
                    Log.e("IgnoredException", stringWriter2.toString());
                }
            }
            return "";
        } catch (Throwable th2) {
            th = th2;
            fileInputStream2 = fileInputStream;
            if (fileInputStream2 != null) {
                try {
                    fileInputStream2.close();
                } catch (IOException e12) {
                    StringWriter stringWriter3 = new StringWriter();
                    e12.printStackTrace(new PrintWriter(stringWriter3));
                    Log.e("IgnoredException", stringWriter3.toString());
                }
            }
            throw th;
        }
    }

    public String u(BuildInfo.ManifestDownloadInfo manifestDownloadInfo) {
        StringBuilder sb = new StringBuilder(manifestDownloadInfo.uri);
        List<BuildInfo.ManifestDownloadInfo.QueryParam> list = manifestDownloadInfo.queryParams;
        if (list != null && list.size() > 0) {
            BuildInfo.ManifestDownloadInfo.QueryParam queryParam = list.get(0);
            sb.append("?");
            sb.append(queryParam.name);
            sb.append("=");
            sb.append(queryParam.value);
            int size = list.size();
            for (int i10 = 1; i10 < size; i10++) {
                BuildInfo.ManifestDownloadInfo.QueryParam queryParam2 = list.get(i10);
                sb.append("&");
                sb.append(queryParam2.name);
                sb.append("=");
                sb.append(queryParam2.value);
            }
        }
        return sb.toString();
    }

    public File v(BuildInfo.ManifestDownloadInfo manifestDownloadInfo) {
        return new File(this.f11121i.location + "/" + w(manifestDownloadInfo));
    }

    public String w(BuildInfo.ManifestDownloadInfo manifestDownloadInfo) {
        return Uri.parse(manifestDownloadInfo.uri).getLastPathSegment();
    }

    public ValueOrError<g> y(ErrorCode errorCode) {
        G();
        this.f11125m.invoke(new DownloadProgressUpdatedArgs(this.f11120h, this.f11121i, errorCode));
        r(new ValueOrError<>(null, errorCode));
        return new ValueOrError<>(null, errorCode);
    }

    protected void z(DownloadProgress downloadProgress) {
        EventHandler<DownloadProgressUpdatedArgs> eventHandler = this.f11125m;
        int i10 = this.f11120h;
        DownloadRequest downloadRequest = this.f11121i;
        int i11 = downloadProgress.max;
        eventHandler.invoke(new DownloadProgressUpdatedArgs(i10, downloadRequest, i11, downloadProgress.progress, i11 <= 0, downloadProgress.paused));
    }
}