package com.ifpdos.videopresenter.d;

import android.os.Environment;
import java.io.File;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;

/* JADX INFO: compiled from: FileUtils.java */
/* JADX INFO: loaded from: classes.dex */
public class a {

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    private static final String f2380a;

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    private static final String f2381b;

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    private static final SimpleDateFormat f2382c;

    static {
        StringBuilder sb = new StringBuilder();
        sb.append(c());
        String str = File.separator;
        sb.append(str);
        sb.append("TestServer");
        String string = sb.toString();
        f2380a = string;
        f2381b = string + str + "camera";
        f2382c = new SimpleDateFormat("yyyyMMddHHmmss", Locale.ENGLISH);
    }

    private static String a() {
        File file = new File(f2381b);
        if (!file.exists()) {
            file.mkdirs();
        }
        return file + File.separator + String.format(Locale.getDefault(), "%s%3d", b(), Long.valueOf(System.currentTimeMillis() % 1000)) + ".jpg";
    }

    private static String b() {
        return f2382c.format(new Date());
    }

    private static String c() {
        File externalStorageDirectory = Environment.getExternalStorageState().equals("mounted") ? Environment.getExternalStorageDirectory() : null;
        return externalStorageDirectory == null ? "/mnt/sdcard" : externalStorageDirectory.toString();
    }

    /* JADX WARN: Removed duplicated region for block: B:52:0x0062 A[EXC_TOP_SPLITTER, SYNTHETIC] */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
        To view partially-correct add '--show-bad-code' argument
    */
    public static java.lang.String d(android.graphics.Bitmap r7) throws java.lang.Throwable {
        /*
            java.lang.String r0 = "FileUtils"
            r1 = 0
            r2 = 0
            java.lang.String r3 = a()     // Catch: java.lang.Throwable -> L31 java.io.IOException -> L35
            java.io.FileOutputStream r4 = new java.io.FileOutputStream     // Catch: java.io.IOException -> L2c java.lang.Throwable -> L31
            r4.<init>(r3)     // Catch: java.io.IOException -> L2c java.lang.Throwable -> L31
            android.graphics.Bitmap$CompressFormat r1 = android.graphics.Bitmap.CompressFormat.JPEG     // Catch: java.io.IOException -> L2a java.lang.Throwable -> L5f
            r5 = 100
            boolean r2 = r7.compress(r1, r5, r4)     // Catch: java.io.IOException -> L2a java.lang.Throwable -> L5f
            r4.flush()     // Catch: java.io.IOException -> L2a java.lang.Throwable -> L5f
            r4.close()     // Catch: java.io.IOException -> L25
            boolean r1 = r7.isRecycled()     // Catch: java.io.IOException -> L25
            if (r1 != 0) goto L4c
            r7.recycle()     // Catch: java.io.IOException -> L25
            goto L4c
        L25:
            r7 = move-exception
            b.c.d.d.c.d(r0, r7)
            goto L4c
        L2a:
            r1 = move-exception
            goto L39
        L2c:
            r4 = move-exception
            r6 = r4
            r4 = r1
            r1 = r6
            goto L39
        L31:
            r2 = move-exception
            r4 = r1
            r1 = r2
            goto L60
        L35:
            r3 = move-exception
            r4 = r1
            r1 = r3
            r3 = r4
        L39:
            b.c.d.d.c.d(r0, r1)     // Catch: java.lang.Throwable -> L5f
            if (r4 == 0) goto L41
            r4.close()     // Catch: java.io.IOException -> L25
        L41:
            if (r7 == 0) goto L4c
            boolean r1 = r7.isRecycled()     // Catch: java.io.IOException -> L25
            if (r1 != 0) goto L4c
            r7.recycle()     // Catch: java.io.IOException -> L25
        L4c:
            java.io.File r7 = new java.io.File
            r7.<init>(r3)
            if (r2 != 0) goto L5e
            boolean r0 = r7.exists()
            if (r0 == 0) goto L5c
            r7.delete()
        L5c:
            java.lang.String r3 = ""
        L5e:
            return r3
        L5f:
            r1 = move-exception
        L60:
            if (r4 == 0) goto L68
            r4.close()     // Catch: java.io.IOException -> L66
            goto L68
        L66:
            r7 = move-exception
            goto L74
        L68:
            if (r7 == 0) goto L77
            boolean r2 = r7.isRecycled()     // Catch: java.io.IOException -> L66
            if (r2 != 0) goto L77
            r7.recycle()     // Catch: java.io.IOException -> L66
            goto L77
        L74:
            b.c.d.d.c.d(r0, r7)
        L77:
            throw r1
        */
        throw new UnsupportedOperationException("Method not decompiled: com.ifpdos.videopresenter.d.a.d(android.graphics.Bitmap):java.lang.String");
    }
}
