package com.google.android.gms.safetynet;

import X.4N2;
import X.C18518Kc;
import X.C30968nP;
import X.C33198r0;
import X.C33208r1;
import android.os.Parcel;
import android.os.ParcelFileDescriptor;
import android.os.Parcelable;
import com.bytedance.covode.number.Covode;
import com.bytedance.frameworks.apm.trace.MethodCollector;
import com.bytedance.ies.abmock.SettingsManager;
import com.google.android.gms.common.data.DataHolder;
import com.google.android.gms.common.internal.safeparcel.AbstractSafeParcelable;
import java.io.BufferedOutputStream;
import java.io.Closeable;
import java.io.DataOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;

public class SafeBrowsingData extends AbstractSafeParcelable {
    public static final Parcelable.Creator<SafeBrowsingData> CREATOR = new C30968nP();
    public static final String LJI = SafeBrowsingData.class.getSimpleName();
    public String LIZ;
    public DataHolder LIZIZ;
    public ParcelFileDescriptor LIZJ;
    public long LIZLLL;
    public byte[] LJ;
    public byte[] LJFF;
    public File LJII;

    static {
        Covode.recordClassIndex(43812);
    }

    public SafeBrowsingData() {
        this((String) null, (DataHolder) null, (ParcelFileDescriptor) null, 0, (byte[]) null);
    }

    public SafeBrowsingData(String str, DataHolder dataHolder, ParcelFileDescriptor parcelFileDescriptor, long j, byte[] bArr) {
        this.LIZ = str;
        this.LIZIZ = dataHolder;
        this.LIZJ = parcelFileDescriptor;
        this.LIZLLL = j;
        this.LJ = bArr;
    }

    /* JADX WARNING: Removed duplicated region for block: B:17:0x0032  */
    /* JADX WARNING: Removed duplicated region for block: B:24:0x003c  */
    /* Code decompiled incorrectly, please refer to instructions dump. */
    private final java.io.FileOutputStream LIZ() {
        /*
            r5 = this;
            r4 = 4646(0x1226, float:6.51E-42)
            com.bytedance.frameworks.apm.trace.MethodCollector.i(r4)
            java.io.File r2 = r5.LJII
            r3 = 0
            if (r2 != 0) goto L_0x000e
            com.bytedance.frameworks.apm.trace.MethodCollector.o(r4)
            return r3
        L_0x000e:
            java.lang.String r1 = "xlb"
            java.lang.String r0 = ".tmp"
            java.io.File r2 = java.io.File.createTempFile(r1, r0, r2)     // Catch:{ IOException -> 0x0039, all -> 0x002c }
            java.io.FileOutputStream r1 = new java.io.FileOutputStream     // Catch:{ IOException -> 0x003a, all -> 0x002f }
            r1.<init>(r2)     // Catch:{ IOException -> 0x003a, all -> 0x002f }
            r0 = 268435456(0x10000000, float:2.5243549E-29)
            android.os.ParcelFileDescriptor r0 = android.os.ParcelFileDescriptor.open(r2, r0)     // Catch:{ IOException -> 0x003a, all -> 0x002f }
            r5.LIZJ = r0     // Catch:{ IOException -> 0x003a, all -> 0x002f }
            if (r2 == 0) goto L_0x0028
            LIZ((java.io.File) r2)
        L_0x0028:
            com.bytedance.frameworks.apm.trace.MethodCollector.o(r4)
            return r1
        L_0x002c:
            r0 = move-exception
            r2 = r3
            goto L_0x0030
        L_0x002f:
            r0 = move-exception
        L_0x0030:
            if (r2 == 0) goto L_0x0035
            LIZ((java.io.File) r2)
        L_0x0035:
            com.bytedance.frameworks.apm.trace.MethodCollector.o(r4)
            throw r0
        L_0x0039:
            r2 = r3
        L_0x003a:
            if (r2 == 0) goto L_0x003f
            LIZ((java.io.File) r2)
        L_0x003f:
            com.bytedance.frameworks.apm.trace.MethodCollector.o(r4)
            return r3
        */
        throw new UnsupportedOperationException("Method not decompiled: com.google.android.gms.safetynet.SafeBrowsingData.LIZ():java.io.FileOutputStream");
    }

    public static void LIZ(Closeable closeable) {
        try {
            closeable.close();
        } catch (IOException unused) {
        }
    }

    public void writeToParcel(Parcel parcel, int i) {
        FileOutputStream LIZ2;
        MethodCollector.i(4636);
        if (!(this.LIZJ != null || this.LJFF == null || (LIZ2 = LIZ()) == null)) {
            DataOutputStream dataOutputStream = new DataOutputStream(new BufferedOutputStream(LIZ2));
            try {
                dataOutputStream.writeInt(this.LJFF.length);
                dataOutputStream.write(this.LJFF);
                LIZ((Closeable) dataOutputStream);
                i |= 1;
            } catch (IOException unused) {
                LIZ((Closeable) dataOutputStream);
            } catch (Throwable th) {
                LIZ((Closeable) dataOutputStream);
                MethodCollector.o(4636);
                throw th;
            }
        }
        C30968nP.LIZ(this, parcel, i);
        this.LIZJ = null;
        MethodCollector.o(4636);
    }

    public static boolean LIZ(File file) {
        MethodCollector.i(4735);
        try {
            C33208r1 r3 = C18518Kc.LIZIZ() ? (C33208r1) SettingsManager.LIZ().LIZ("storage_intercepter_key", C33208r1.class, 4N2.LIZ) : 4N2.LIZ;
            if (C33198r0.LIZ(file.getAbsolutePath(), r3)) {
                C33198r0.LIZ(file, new RuntimeException(), "exception_delete_log", C33198r0.LIZ(r3));
            }
            if (C33198r0.LIZJ(file.getAbsolutePath(), r3)) {
                C33198r0.LIZ(file, new RuntimeException(), "exception_handle", C33198r0.LIZ(r3));
                MethodCollector.o(4735);
                return false;
            }
        } catch (Throwable unused) {
        }
        boolean delete = file.delete();
        MethodCollector.o(4735);
        return delete;
    }
}
