翰林优商.apk(点击下载) / l.java


package com.bytedance.pangle.f;

import android.os.Build;
import android.system.ErrnoException;
import android.system.Os;
import android.system.OsConstants;
import com.bytedance.pangle.a.a.a;
import com.bytedance.pangle.util.FieldUtils;
import com.bytedance.pangle.util.h;
import java.io.FileDescriptor;
import java.io.IOException;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.nio.ByteBuffer;

/* access modifiers changed from: package-private */
public final class l implements k {
    private static final long a = Os.sysconf(OsConstants._SC_PAGESIZE);
    private final FileDescriptor b;
    private final long c;
    private final long d;

    l(FileDescriptor fileDescriptor, long j, long j2) {
        this.b = fileDescriptor;
        this.c = j;
        this.d = j2;
    }

    @Override // com.bytedance.pangle.f.k
    public final long a() {
        return this.d;
    }

    /* JADX WARNING: Removed duplicated region for block: B:24:0x005d A[SYNTHETIC, Splitter:B:24:0x005d] */
    /* JADX WARNING: Removed duplicated region for block: B:41:0x00c2 A[SYNTHETIC, Splitter:B:41:0x00c2] */
    /* JADX WARNING: Removed duplicated region for block: B:59:0x0114 A[SYNTHETIC, Splitter:B:59:0x0114] */
    /* JADX WARNING: Removed duplicated region for block: B:73:0x013d A[SYNTHETIC, Splitter:B:73:0x013d] */
    /* JADX WARNING: Removed duplicated region for block: B:79:? A[RETURN, SYNTHETIC] */
    @Override // com.bytedance.pangle.f.k
    public final void a(j jVar, long j, int i) {
        long j2;
        Throwable th;
        ErrnoException e;
        int i2;
        ByteBuffer byteBuffer;
        long j3 = this.c + j;
        long j4 = a;
        long j5 = (j3 / j4) * j4;
        int i3 = (int) (j3 - j5);
        long j6 = (long) (i + i3);
        try {
            ByteBuffer byteBuffer2 = null;
            if (h.c()) {
                try {
                    i2 = ((Integer) FieldUtils.readField(a.a(OsConstants.class, "MAP_POPULATE"), (Object) null)).intValue();
                } catch (IllegalAccessException e2) {
                    e2.printStackTrace();
                } catch (Exception e3) {
                    e3.printStackTrace();
                }
                j2 = Os.mmap(0, j6, OsConstants.PROT_READ, OsConstants.MAP_SHARED | i2, this.b, j5);
                if (!(Build.VERSION.SDK_INT < 24 && Build.VERSION.SDK_INT <= 28)) {
                    try {
                        Constructor a2 = a.a(Class.forName("java.nio.DirectByteBuffer"), Integer.TYPE, Long.TYPE, FileDescriptor.class, Runnable.class, Boolean.TYPE);
                        if (a2 != null && a2.isAccessible()) {
                            byteBuffer = (ByteBuffer) a2.newInstance(Integer.valueOf(i), Long.valueOf(((long) i3) + j2), this.b, null, Boolean.TRUE);
                        }
                    } catch (ClassNotFoundException e4) {
                        e4.printStackTrace();
                    } catch (IllegalAccessException e5) {
                        e5.printStackTrace();
                    } catch (InstantiationException e6) {
                        e6.printStackTrace();
                    } catch (InvocationTargetException e7) {
                        e7.printStackTrace();
                    } catch (Exception e8) {
                        e8.printStackTrace();
                    }
                    jVar.a(byteBuffer2);
                    if (j2 == 0) {
                        try {
                            Os.munmap(j2, j6);
                            return;
                        } catch (ErrnoException unused) {
                            return;
                        }
                    } else {
                        return;
                    }
                } else {
                    try {
                        Constructor a3 = a.a(Class.forName("java.nio.DirectByteBuffer"), Long.TYPE, Integer.TYPE);
                        if (a3 != null && a3.isAccessible()) {
                            byteBuffer = (ByteBuffer) a3.newInstance(Long.valueOf(((long) i3) + j2), Integer.valueOf(i));
                        }
                    } catch (ClassNotFoundException e9) {
                        e9.printStackTrace();
                    } catch (IllegalAccessException e10) {
                        e10.printStackTrace();
                    } catch (InstantiationException e11) {
                        e11.printStackTrace();
                    } catch (InvocationTargetException e12) {
                        e12.printStackTrace();
                    } catch (Exception e13) {
                        e13.printStackTrace();
                    }
                    jVar.a(byteBuffer2);
                    if (j2 == 0) {
                    }
                }
                byteBuffer2 = byteBuffer;
                jVar.a(byteBuffer2);
                if (j2 == 0) {
                }
            }
            i2 = 0;
            j2 = Os.mmap(0, j6, OsConstants.PROT_READ, OsConstants.MAP_SHARED | i2, this.b, j5);
            try {
                if (!(Build.VERSION.SDK_INT < 24 && Build.VERSION.SDK_INT <= 28)) {
                }
                byteBuffer2 = byteBuffer;
                jVar.a(byteBuffer2);
                if (j2 == 0) {
                }
            } catch (ErrnoException e14) {
                e = e14;
                try {
                    throw new IOException("Failed to mmap " + j6 + " bytes", e);
                } catch (Throwable th2) {
                    th = th2;
                    if (j2 != 0) {
                        try {
                            Os.munmap(j2, j6);
                        } catch (ErrnoException unused2) {
                        }
                    }
                    throw th;
                }
            }
        } catch (ErrnoException e15) {
            e = e15;
            j2 = 0;
            throw new IOException("Failed to mmap " + j6 + " bytes", e);
        } catch (Throwable th3) {
            th = th3;
            j2 = 0;
            if (j2 != 0) {
            }
            throw th;
        }
    }
}