小红书.apk(点击下载) / d.java


package nq2;

import ac2.k;
import android.os.Process;
import cc2.g;
import cc2.o;
import cn.jiguang.union.ads.api.JUnionAdError;
import com.ali.auth.third.login.LoginConstants;
import com.xingin.scalpel.hprof.ForkJvmHeapDumper;
import com.xingin.scalpel.memory.FDDumpBridge;
import com.xingin.uploader.api.BatchParams;
import com.xingin.uploader.api.BatchResult;
import com.xingin.uploader.api.BatchUploadListener;
import com.xingin.uploader.api.FileBatchUploader;
import com.xingin.uploader.api.RobusterClient;
import com.xingin.utils.XYUtilsCenter;
import com.xingin.utils.core.f0;
import com.xingin.utils.core.t;
import io.sentry.android.core.protocol.MemoryExceptionInfo;
import java.io.File;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import ko2.e;
import kotlin.Lazy;
import kotlin.LazyKt__LazyJVMKt;
import kotlin.Metadata;
import kotlin.Unit;
import kotlin.jvm.functions.Function0;
import kotlin.jvm.functions.Function1;
import kotlin.jvm.internal.Intrinsics;
import kotlin.jvm.internal.Lambda;
import kotlin.text.StringsKt__StringsJVMKt;
import kotlin.text.StringsKt__StringsKt;
import w13.bd;
import y7.f;
import z60.h;

@Metadata(bv = {}, d1 = {"\u00004\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\u0002\n\u0000\n\u0002\u0010\u000e\n\u0002\b\u0002\n\u0002\u0010\u000b\n\u0002\b\u0005\n\u0002\u0010\t\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\b\bÆ\u0002\u0018\u00002\u00020\u0001B\t\b\u0002¢\u0006\u0004\b\u0018\u0010\u0019J\u000e\u0010\u0005\u001a\u00020\u00042\u0006\u0010\u0003\u001a\u00020\u0002J\u000e\u0010\u0007\u001a\u00020\u00062\u0006\u0010\u0003\u001a\u00020\u0002J\u0006\u0010\b\u001a\u00020\u0004J\u000e\u0010\n\u001a\u00020\t2\u0006\u0010\u0003\u001a\u00020\u0002J\u0006\u0010\u000b\u001a\u00020\tJ\u0006\u0010\f\u001a\u00020\tJ\u0006\u0010\r\u001a\u00020\tJ\u0006\u0010\u000e\u001a\u00020\tJ\u0010\u0010\u0011\u001a\u00020\t2\u0006\u0010\u0010\u001a\u00020\u000fH\u0002R\u001d\u0010\u0017\u001a\u0004\u0018\u00010\u00128BX‚„\u0002¢\u0006\f\n\u0004\b\u0013\u0010\u0014\u001a\u0004\b\u0015\u0010\u0016¨\u0006\u001a"}, d2 = {"Lnq2/d;", "", "Lmx2/c;", "eventInfoReadonly", "", "j", "", "b", "l", "", f.f156778k, "d", "g", h.f160753a, "e", "", "fileSzie", "i", "Ljava/io/File;", "oomDumpDir$delegate", "Lkotlin/Lazy;", "c", "()Ljava/io/File;", "oomDumpDir", "<init>", "()V", "app_PublishGooglePlayRelease"}, k = 1, mv = {1, 6, 0})
/* compiled from: OOMDumper.kt */
public final class d {

    /* renamed from: a  reason: collision with root package name */
    public static final d f111153a = new d();

    /* renamed from: b  reason: collision with root package name */
    public static final Lazy f111154b = LazyKt__LazyJVMKt.lazy(a.f111155a);

    @Metadata(bv = {}, d1 = {"\u0000\b\n\u0002\u0018\u0002\n\u0002\b\u0002\u0010\u0001\u001a\u0004\u0018\u00010\u0000H\n¢\u0006\u0004\b\u0001\u0010\u0002"}, d2 = {"Ljava/io/File;", "a", "()Ljava/io/File;"}, k = 3, mv = {1, 6, 0})
    /* compiled from: OOMDumper.kt */
    public static final class a extends Lambda implements Function0<File> {

        /* renamed from: a  reason: collision with root package name */
        public static final a f111155a = new a();

        public a() {
            super(0);
        }

        /* renamed from: a */
        public final File invoke() {
            return XYUtilsCenter.e().getExternalFilesDir("oom_dump");
        }
    }

    @Metadata(bv = {}, d1 = {"\u0000\f\n\u0002\u0018\u0002\n\u0002\u0010\u0002\n\u0002\b\u0002\u0010\u0002\u001a\u00020\u0001*\u00020\u0000H\n¢\u0006\u0004\b\u0002\u0010\u0003"}, d2 = {"Lw13/bd$a;", "", "a", "(Lw13/bd$a;)V"}, k = 3, mv = {1, 6, 0})
    /* compiled from: OOMDumper.kt */
    public static final class b extends Lambda implements Function1<bd.a, Unit> {

        /* renamed from: a  reason: collision with root package name */
        public final /* synthetic */ File f111156a;

        /* JADX INFO: super call moved to the top of the method (can break code semantics) */
        public b(File file) {
            super(1);
            this.f111156a = file;
        }

        public final void a(bd.a aVar) {
            Intrinsics.checkNotNullParameter(aVar, "$this$withInfraOomHprofDump");
            aVar.u(1036);
            aVar.v(1.0f);
            aVar.r("start");
            aVar.s(this.f111156a.getName());
            aVar.t((int) this.f111156a.length());
        }

        /* Return type fixed from 'java.lang.Object' to match base method */
        /* JADX DEBUG: Method arguments types fixed to match base method, original types: [java.lang.Object] */
        @Override // kotlin.jvm.functions.Function1
        public /* bridge */ /* synthetic */ Unit invoke(bd.a aVar) {
            a(aVar);
            return Unit.INSTANCE;
        }
    }

    @Metadata(bv = {}, d1 = {"\u0000+\n\u0000\n\u0002\u0018\u0002\n\u0002\u0010 \n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0010\u0002\n\u0000\n\u0002\u0010\u000e\n\u0002\b\u0004\n\u0002\u0010\u0006\n\u0002\b\u0005*\u0001\u0000\b\n\u0018\u00002\u00020\u0001J$\u0010\u0007\u001a\u00020\u00062\f\u0010\u0004\u001a\b\u0012\u0004\u0012\u00020\u00030\u00022\f\u0010\u0005\u001a\b\u0012\u0004\u0012\u00020\u00030\u0002H\u0016J$\u0010\f\u001a\u00020\u00062\u0006\u0010\t\u001a\u00020\b2\b\u0010\n\u001a\u0004\u0018\u00010\b2\b\u0010\u000b\u001a\u0004\u0018\u00010\u0003H\u0016J\u0010\u0010\u000f\u001a\u00020\u00062\u0006\u0010\u000e\u001a\u00020\rH\u0016J\u0010\u0010\u0010\u001a\u00020\u00062\u0006\u0010\u000b\u001a\u00020\u0003H\u0016J\u0010\u0010\u0011\u001a\u00020\u00062\u0006\u0010\u000b\u001a\u00020\u0003H\u0016¨\u0006\u0012"}, d2 = {"nq2/d$c", "Lcom/xingin/uploader/api/BatchUploadListener;", "", "Lcom/xingin/uploader/api/BatchResult;", "successPathList", "failedPathList", "", "onComplete", "", "errCode", "errMsg", "result", "onFailed", "", "percent", "onProgress", "onStart", "onSuccess", "app_PublishGooglePlayRelease"}, k = 1, mv = {1, 6, 0})
    /* compiled from: OOMDumper.kt */
    public static final class c implements BatchUploadListener {

        @Metadata(bv = {}, d1 = {"\u0000\f\n\u0002\u0018\u0002\n\u0002\u0010\u0002\n\u0002\b\u0002\u0010\u0002\u001a\u00020\u0001*\u00020\u0000H\n¢\u0006\u0004\b\u0002\u0010\u0003"}, d2 = {"Lw13/bd$a;", "", "a", "(Lw13/bd$a;)V"}, k = 3, mv = {1, 6, 0})
        /* compiled from: OOMDumper.kt */
        public static final class a extends Lambda implements Function1<bd.a, Unit> {

            /* renamed from: a  reason: collision with root package name */
            public final /* synthetic */ BatchResult f111157a;

            /* renamed from: b  reason: collision with root package name */
            public final /* synthetic */ long f111158b;

            /* JADX INFO: super call moved to the top of the method (can break code semantics) */
            public a(BatchResult batchResult, long j14) {
                super(1);
                this.f111157a = batchResult;
                this.f111158b = j14;
            }

            public final void a(bd.a aVar) {
                Intrinsics.checkNotNullParameter(aVar, "$this$withInfraOomHprofDump");
                aVar.u(1036);
                aVar.v(1.0f);
                aVar.r(JUnionAdError.Message.SUCCESS);
                aVar.s(this.f111157a.getFileId());
                aVar.t((int) this.f111158b);
            }

            /* Return type fixed from 'java.lang.Object' to match base method */
            /* JADX DEBUG: Method arguments types fixed to match base method, original types: [java.lang.Object] */
            @Override // kotlin.jvm.functions.Function1
            public /* bridge */ /* synthetic */ Unit invoke(bd.a aVar) {
                a(aVar);
                return Unit.INSTANCE;
            }
        }

        public static final void b(BatchResult batchResult, long j14) {
            Intrinsics.checkNotNullParameter(batchResult, "$result");
            qe2.a.a().p4("infra_oom_hprof_dump").G3(new a(batchResult, j14)).b();
        }

        @Override // com.xingin.uploader.api.BatchUploadListener
        public void onComplete(List<BatchResult> list, List<BatchResult> list2) {
            Intrinsics.checkNotNullParameter(list, "successPathList");
            Intrinsics.checkNotNullParameter(list2, "failedPathList");
            e.a("Scalpel.OOMDumper", "onComplete success=" + list + " failed=" + list2);
            Iterator<T> it3 = list.iterator();
            while (it3.hasNext()) {
                String path = it3.next().getPath();
                if (path != null) {
                    t.q(path);
                }
            }
        }

        @Override // com.xingin.uploader.api.BatchUploadListener
        public void onFailed(String str, String str2, BatchResult batchResult) {
            Intrinsics.checkNotNullParameter(str, "errCode");
            String path = batchResult != null ? batchResult.getPath() : null;
            e.a("Scalpel.OOMDumper", "onFailed " + str + " " + str2 + " " + path);
        }

        @Override // com.xingin.uploader.api.BatchUploadListener
        public void onProgress(double d14) {
        }

        @Override // com.xingin.uploader.api.BatchUploadListener
        public void onStart(BatchResult batchResult) {
            Intrinsics.checkNotNullParameter(batchResult, "result");
            String path = batchResult.getPath();
            e.a("Scalpel.OOMDumper", "onStart " + path);
        }

        /* JADX WARNING: Code restructure failed: missing block: B:8:0x0035, code lost:
            if (r0 == null) goto L_0x0037;
         */
        @Override // com.xingin.uploader.api.BatchUploadListener
        public void onSuccess(BatchResult batchResult) {
            Intrinsics.checkNotNullParameter(batchResult, "result");
            e.a("Scalpel.OOMDumper", "onSuccess success=" + batchResult.getPath());
            String path = batchResult.getPath();
            String str = null;
            boolean z14 = true;
            if (path != null) {
                if (!(path.length() > 0)) {
                    path = null;
                }
            }
            path = "";
            we2.d.c(new e(batchResult, new File(path).length()));
            String fileId = batchResult.getFileId();
            if (fileId != null) {
                if (fileId.length() <= 0) {
                    z14 = false;
                }
                if (z14) {
                    str = fileId;
                }
                if (str != null) {
                    MemoryExceptionInfo memoryExceptionInfo = new MemoryExceptionInfo(MemoryExceptionInfo.b.OOM);
                    memoryExceptionInfo.setHprofUrl("http://others-1251524319.cos.ap-shanghai.myqcloud.com/" + str);
                    memoryExceptionInfo.setHprofEncodeType(MemoryExceptionInfo.a.TAILOR);
                    fx2.f.y(memoryExceptionInfo);
                }
            }
        }
    }

    public static final void k(File file) {
        Intrinsics.checkNotNullParameter(file, "$hprofFile");
        qe2.a.a().p4("infra_oom_hprof_dump").G3(new b(file)).b();
    }

    public final String b(mx2.c cVar) {
        Intrinsics.checkNotNullParameter(cVar, "eventInfoReadonly");
        String n14 = vt2.f.g().n("sentry_" + cVar.f(), "");
        if (n14 == null || n14.length() == 0) {
            n14 = "oom_" + com.xingin.utils.core.c.j() + LoginConstants.UNDER_LINE + cVar.f() + ".hprof";
            vt2.f.g().u("sentry_" + cVar.f(), n14);
        }
        e.a("Scalpel.OOMDumper", "getHprofFileId fileId=" + n14);
        Intrinsics.checkNotNullExpressionValue(n14, "fileId");
        return n14;
    }

    public final File c() {
        return (File) f111154b.getValue();
    }

    public final boolean d() {
        return FDDumpBridge.a() <= 4096 && ((float) new File("/proc/self/fd").listFiles().length) >= k.a.f2894a.a().b().b();
    }

    public final boolean e() {
        return (((float) (Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory())) * 1.0f) / ((float) Runtime.getRuntime().maxMemory()) >= k.a.f2894a.a().j().c();
    }

    public final boolean f(mx2.c cVar) {
        String b14;
        Intrinsics.checkNotNullParameter(cVar, "eventInfoReadonly");
        mx2.b e14 = cVar.e();
        if (e14 == null || (b14 = e14.b()) == null) {
            return false;
        }
        return StringsKt__StringsKt.contains$default((CharSequence) b14, (CharSequence) "OutOfMemoryError", false, 2, (Object) null);
    }

    public final boolean g() {
        return (com.xingin.utils.core.f.m() || com.xingin.utils.core.f.l()) && ((float) jh2.c.f95561c.g(Process.myPid())) >= k.a.f2894a.a().c().b();
    }

    public final boolean h() {
        g a14 = k.a.f2894a.a();
        cc2.e eVar = cc2.e.f11385i;
        if (!eVar.k()) {
            return false;
        }
        Long l14 = ri2.a.f126222d.s(false).get("VmSize");
        return ((float) ((int) (l14 != null ? l14.longValue() : 0))) / eVar.j() >= a14.m().c();
    }

    public final boolean i(long j14) {
        int i10 = (j14 > 0 ? 1 : (j14 == 0 ? 0 : -1));
        if (i10 > 0 && ((float) j14) <= o.b.f11416a.a(50)) {
            return true;
        }
        if (i10 <= 0 || ((float) j14) > o.b.f11416a.a(100) || !f0.m()) {
            return false;
        }
        return true;
    }

    public final void j(mx2.c cVar) {
        Intrinsics.checkNotNullParameter(cVar, "eventInfoReadonly");
        if (f(cVar)) {
            File file = new File(c(), b(cVar));
            if (!file.exists()) {
                File parentFile = file.getParentFile();
                if (parentFile != null) {
                    parentFile.mkdirs();
                }
                file.createNewFile();
            }
            boolean a14 = new ForkJvmHeapDumper().a(file.getAbsolutePath());
            String absolutePath = file.getAbsolutePath();
            String f14 = cVar.f();
            e.a("Scalpel.OOMDumper", "ForkJvmHeapDumper result=" + a14 + ", path=" + absolutePath + " " + f14);
            if (a14) {
                we2.d.c(new c(file));
            }
            l();
        }
    }

    public final void l() {
        File[] listFiles;
        ArrayList arrayList = new ArrayList();
        ArrayList arrayList2 = new ArrayList();
        File c14 = c();
        if (!(c14 == null || (listFiles = c14.listFiles()) == null)) {
            int i10 = 0;
            for (File file : listFiles) {
                e.a("Scalpel.OOMDumper", "scanHprofIfNeed " + file.getName());
                String name = file.getName();
                Intrinsics.checkNotNullExpressionValue(name, "it.name");
                if ((StringsKt__StringsJVMKt.endsWith$default(name, "hprof", false, 2, null)) && f111153a.i(file.length()) && i10 <= 5) {
                    arrayList.add(file.getAbsolutePath());
                    arrayList2.add(file.getName());
                    i10++;
                }
            }
        }
        e.a("Scalpel.OOMDumper", "scanHprofIfNeed size " + arrayList.size() + ", " + arrayList2.size());
        if (!(arrayList.isEmpty() || arrayList2.isEmpty())) {
            new FileBatchUploader(new RobusterClient(3, "other", null, 4, null)).batchUploadFile(new BatchParams(arrayList, null, arrayList2, 2, null), new c());
        }
    }
}