package com.appsflyer.internal;

import android.content.Context;
import android.util.Log;
import com.appsflyer.AFFacebookDeferredDeeplink;
import com.appsflyer.AppsFlyerLibCore;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

public final class z {

    /* renamed from: ˏ  reason: contains not printable characters */
    public static z f2161 = new z();

    /* renamed from: ˋ  reason: contains not printable characters */
    public static List<AFFacebookDeferredDeeplink> m1254(Context context) {
        ArrayList arrayList = new ArrayList();
        try {
            File file = new File(context.getFilesDir(), "AFRequestCache");
            if (!file.exists()) {
                file.mkdir();
            } else {
                File[] listFiles = file.listFiles();
                for (File file2 : listFiles) {
                    StringBuilder sb = new StringBuilder("Found cached request");
                    sb.append(file2.getName());
                    Log.i(AppsFlyerLibCore.LOG_TAG, sb.toString());
                    arrayList.add(m1258(file2));
                }
            }
        } catch (Exception unused) {
            Log.i(AppsFlyerLibCore.LOG_TAG, "Could not cache request");
        }
        return arrayList;
    }

    /* renamed from: ˎ  reason: contains not printable characters */
    public static z m1255() {
        return f2161;
    }

    /* JADX WARNING: Removed duplicated region for block: B:13:0x0025 A[SYNTHETIC, Splitter:B:13:0x0025] */
    /* JADX WARNING: Removed duplicated region for block: B:21:0x002c A[SYNTHETIC, Splitter:B:21:0x002c] */
    /* renamed from: ˏ  reason: contains not printable characters */
    public static AFFacebookDeferredDeeplink m1258(File file) {
        FileReader fileReader;
        Throwable th;
        try {
            fileReader = new FileReader(file);
            try {
                char[] cArr = new char[((int) file.length())];
                fileReader.read(cArr);
                AFFacebookDeferredDeeplink aFFacebookDeferredDeeplink = new AFFacebookDeferredDeeplink(cArr);
                aFFacebookDeferredDeeplink.f1856 = file.getName();
                try {
                    fileReader.close();
                } catch (IOException unused) {
                }
                return aFFacebookDeferredDeeplink;
            } catch (Exception unused2) {
                if (fileReader != null) {
                    try {
                        fileReader.close();
                    } catch (IOException unused3) {
                    }
                }
                return null;
            } catch (Throwable th2) {
                th = th2;
                if (fileReader != null) {
                    try {
                        fileReader.close();
                    } catch (IOException unused4) {
                    }
                }
                throw th;
            }
        } catch (Exception unused5) {
            fileReader = null;
            if (fileReader != null) {
            }
            return null;
        } catch (Throwable th3) {
            th = th3;
            fileReader = null;
            if (fileReader != null) {
            }
            throw th;
        }
    }

    /* renamed from: ˎ  reason: contains not printable characters */
    public static File m1256(Context context) {
        return new File(context.getFilesDir(), "AFRequestCache");
    }

    /* renamed from: ˎ  reason: contains not printable characters */
    public static void m1257(String str, Context context) {
        File file = new File(new File(context.getFilesDir(), "AFRequestCache"), str);
        StringBuilder sb = new StringBuilder("Deleting ");
        sb.append(str);
        sb.append(" from cache");
        Log.i(AppsFlyerLibCore.LOG_TAG, sb.toString());
        if (file.exists()) {
            try {
                file.delete();
            } catch (Exception e) {
                StringBuilder sb2 = new StringBuilder("Could not delete ");
                sb2.append(str);
                sb2.append(" from cache");
                Log.i(AppsFlyerLibCore.LOG_TAG, sb2.toString(), e);
            }
        }
    }
}
