package com.mbridge.msdk.foundation.db;
/* compiled from: ReportErrorDao.java */
/* loaded from: classes5.dex */
public class l extends a {

    /* renamed from: a  reason: collision with root package name */
    private static l f3579a;

    private l(f fVar) {
        super(fVar);
    }

    public static l a(f fVar) {
        if (f3579a == null) {
            synchronized (l.class) {
                if (f3579a == null) {
                    f3579a = new l(fVar);
                }
            }
        }
        return f3579a;
    }

    public final synchronized void a(String str, String str2, long j) {
        if (str == null) {
            str = "";
        }
        if (getWritableDatabase() == null) {
            return;
        }
        getWritableDatabase().execSQL("DELETE from reporterror where url= ? and data= ? and time_stamp= ? or count > ?", new Object[]{str2, str, String.valueOf(j), 5});
    }

    /* JADX WARN: Code restructure failed: missing block: B:12:0x0026, code lost:
        if (r0 != null) goto L15;
     */
    /* JADX WARN: Code restructure failed: missing block: B:13:0x0028, code lost:
        r0.close();
     */
    /* JADX WARN: Code restructure failed: missing block: B:19:0x0032, code lost:
        if (r0 == null) goto L17;
     */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
        To view partially-correct add '--show-bad-code' argument
    */
    public final synchronized int a() {
        /*
            r10 = this;
            monitor-enter(r10)
            r0 = 1
            java.lang.String[] r3 = new java.lang.String[r0]     // Catch: java.lang.Throwable -> L3d
            java.lang.String r0 = " count(*) "
            r9 = 0
            r3[r9] = r0     // Catch: java.lang.Throwable -> L3d
            r0 = 0
            android.database.sqlite.SQLiteDatabase r1 = r10.getReadableDatabase()     // Catch: java.lang.Throwable -> L2c java.lang.Exception -> L2e
            java.lang.String r2 = "reporterror"
            r4 = 0
            r5 = 0
            r6 = 0
            r7 = 0
            r8 = 0
            android.database.Cursor r0 = r1.query(r2, r3, r4, r5, r6, r7, r8)     // Catch: java.lang.Throwable -> L2c java.lang.Exception -> L2e
            if (r0 == 0) goto L26
            boolean r1 = r0.moveToFirst()     // Catch: java.lang.Throwable -> L2c java.lang.Exception -> L2e
            if (r1 == 0) goto L26
            int r1 = r0.getInt(r9)     // Catch: java.lang.Throwable -> L2c java.lang.Exception -> L2e
            r9 = r1
        L26:
            if (r0 == 0) goto L35
        L28:
            r0.close()     // Catch: java.lang.Throwable -> L3d
            goto L35
        L2c:
            r1 = move-exception
            goto L37
        L2e:
            r1 = move-exception
            r1.printStackTrace()     // Catch: java.lang.Throwable -> L2c
            if (r0 == 0) goto L35
            goto L28
        L35:
            monitor-exit(r10)
            return r9
        L37:
            if (r0 == 0) goto L3c
            r0.close()     // Catch: java.lang.Throwable -> L3d
        L3c:
            throw r1     // Catch: java.lang.Throwable -> L3d
        L3d:
            r0 = move-exception
            monitor-exit(r10)
            throw r0
        */
        throw new UnsupportedOperationException("Method not decompiled: com.mbridge.msdk.foundation.db.l.a():int");
    }

    /* JADX WARN: Multi-variable type inference failed */
    /* JADX WARN: Removed duplicated region for block: B:34:0x00ad A[Catch: all -> 0x00b1, TRY_ENTER, TryCatch #0 {, blocks: (B:27:0x00a3, B:19:0x0094, B:34:0x00ad, B:35:0x00b0), top: B:39:0x0003 }] */
    /* JADX WARN: Type inference failed for: r1v10 */
    /* JADX WARN: Type inference failed for: r1v14 */
    /* JADX WARN: Type inference failed for: r1v6, types: [java.util.List<com.mbridge.msdk.foundation.entity.l>] */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
        To view partially-correct add '--show-bad-code' argument
    */
    public final synchronized java.util.List<com.mbridge.msdk.foundation.entity.l> a(int r13) {
        /*
            r12 = this;
            monitor-enter(r12)
            r0 = 5
            r1 = 0
            r12.b(r0)     // Catch: java.lang.Throwable -> L98 java.lang.Exception -> L9a
            android.database.sqlite.SQLiteDatabase r2 = r12.getReadableDatabase()     // Catch: java.lang.Throwable -> L98 java.lang.Exception -> L9a
            java.lang.String r3 = "reporterror"
            r4 = 0
            r5 = 0
            r6 = 0
            r7 = 0
            r8 = 0
            r9 = 0
            java.lang.StringBuilder r0 = new java.lang.StringBuilder     // Catch: java.lang.Throwable -> L98 java.lang.Exception -> L9a
            r0.<init>()     // Catch: java.lang.Throwable -> L98 java.lang.Exception -> L9a
            java.lang.StringBuilder r13 = r0.append(r13)     // Catch: java.lang.Throwable -> L98 java.lang.Exception -> L9a
            java.lang.String r0 = ""
            java.lang.StringBuilder r13 = r13.append(r0)     // Catch: java.lang.Throwable -> L98 java.lang.Exception -> L9a
            java.lang.String r10 = r13.toString()     // Catch: java.lang.Throwable -> L98 java.lang.Exception -> L9a
            android.database.Cursor r13 = r2.query(r3, r4, r5, r6, r7, r8, r9, r10)     // Catch: java.lang.Throwable -> L98 java.lang.Exception -> L9a
            if (r13 == 0) goto L92
            int r0 = r13.getCount()     // Catch: java.lang.Exception -> L8d java.lang.Throwable -> La9
            if (r0 <= 0) goto L92
            java.util.ArrayList r0 = new java.util.ArrayList     // Catch: java.lang.Exception -> L8d java.lang.Throwable -> La9
            r0.<init>()     // Catch: java.lang.Exception -> L8d java.lang.Throwable -> La9
        L36:
            boolean r1 = r13.moveToNext()     // Catch: java.lang.Exception -> L8b java.lang.Throwable -> La9
            if (r1 == 0) goto L89
            java.lang.String r1 = "url"
            int r1 = r13.getColumnIndex(r1)     // Catch: java.lang.Exception -> L8b java.lang.Throwable -> La9
            java.lang.String r1 = r13.getString(r1)     // Catch: java.lang.Exception -> L8b java.lang.Throwable -> La9
            java.lang.String r2 = "data"
            int r2 = r13.getColumnIndex(r2)     // Catch: java.lang.Exception -> L8b java.lang.Throwable -> La9
            java.lang.String r2 = r13.getString(r2)     // Catch: java.lang.Exception -> L8b java.lang.Throwable -> La9
            java.lang.String r3 = "method"
            int r3 = r13.getColumnIndex(r3)     // Catch: java.lang.Exception -> L8b java.lang.Throwable -> La9
            java.lang.String r3 = r13.getString(r3)     // Catch: java.lang.Exception -> L8b java.lang.Throwable -> La9
            java.lang.String r4 = "unitId"
            int r4 = r13.getColumnIndex(r4)     // Catch: java.lang.Exception -> L8b java.lang.Throwable -> La9
            java.lang.String r4 = r13.getString(r4)     // Catch: java.lang.Exception -> L8b java.lang.Throwable -> La9
            java.lang.String r5 = "count"
            int r5 = r13.getColumnIndex(r5)     // Catch: java.lang.Exception -> L8b java.lang.Throwable -> La9
            int r5 = r13.getInt(r5)     // Catch: java.lang.Exception -> L8b java.lang.Throwable -> La9
            java.lang.String r6 = "time_stamp"
            int r6 = r13.getColumnIndex(r6)     // Catch: java.lang.Exception -> L8b java.lang.Throwable -> La9
            long r6 = r13.getLong(r6)     // Catch: java.lang.Exception -> L8b java.lang.Throwable -> La9
            com.mbridge.msdk.foundation.entity.l r8 = new com.mbridge.msdk.foundation.entity.l     // Catch: java.lang.Exception -> L8b java.lang.Throwable -> La9
            r8.<init>(r1, r3, r2, r4)     // Catch: java.lang.Exception -> L8b java.lang.Throwable -> La9
            int r5 = r5 + 1
            r8.a(r5)     // Catch: java.lang.Exception -> L8b java.lang.Throwable -> La9
            r8.a(r6)     // Catch: java.lang.Exception -> L8b java.lang.Throwable -> La9
            r0.add(r8)     // Catch: java.lang.Exception -> L8b java.lang.Throwable -> La9
            goto L36
        L89:
            r1 = r0
            goto L92
        L8b:
            r1 = move-exception
            goto L9e
        L8d:
            r0 = move-exception
            r11 = r1
            r1 = r0
            r0 = r11
            goto L9e
        L92:
            if (r13 == 0) goto La7
            r13.close()     // Catch: java.lang.Throwable -> Lb1
            goto La7
        L98:
            r0 = move-exception
            goto Lab
        L9a:
            r13 = move-exception
            r0 = r1
            r1 = r13
            r13 = r0
        L9e:
            r1.printStackTrace()     // Catch: java.lang.Throwable -> La9
            if (r13 == 0) goto La6
            r13.close()     // Catch: java.lang.Throwable -> Lb1
        La6:
            r1 = r0
        La7:
            monitor-exit(r12)
            return r1
        La9:
            r0 = move-exception
            r1 = r13
        Lab:
            if (r1 == 0) goto Lb0
            r1.close()     // Catch: java.lang.Throwable -> Lb1
        Lb0:
            throw r0     // Catch: java.lang.Throwable -> Lb1
        Lb1:
            r13 = move-exception
            monitor-exit(r12)
            throw r13
        */
        throw new UnsupportedOperationException("Method not decompiled: com.mbridge.msdk.foundation.db.l.a(int):java.util.List");
    }

    private synchronized int b(int i) {
        try {
        } catch (Exception unused) {
            return -1;
        }
        return getWritableDatabase().rawQuery("DELETE FROM reporterror WHERE count >= ?", new String[]{String.valueOf(i)}).getCount();
    }

    public final synchronized int a(String str) {
        try {
            String[] strArr = {str};
            if (getWritableDatabase() == null) {
                return -1;
            }
            return getWritableDatabase().delete("reporterror", "url=?", strArr);
        } catch (Exception unused) {
            return -1;
        }
    }

    /* JADX WARN: Code restructure failed: missing block: B:14:0x002a, code lost:
        if (r0 == null) goto L11;
     */
    /* JADX WARN: Code restructure failed: missing block: B:7:0x001e, code lost:
        if (r0 != null) goto L9;
     */
    /* JADX WARN: Code restructure failed: missing block: B:8:0x0020, code lost:
        r0.close();
     */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
        To view partially-correct add '--show-bad-code' argument
    */
    public final synchronized int b() {
        /*
            r11 = this;
            monitor-enter(r11)
            r0 = 1
            java.lang.String[] r3 = new java.lang.String[r0]     // Catch: java.lang.Throwable -> L35
            java.lang.String r0 = " count(*) "
            r10 = 0
            r3[r10] = r0     // Catch: java.lang.Throwable -> L35
            r0 = 0
            android.database.sqlite.SQLiteDatabase r1 = r11.getReadableDatabase()     // Catch: java.lang.Throwable -> L24 java.lang.Exception -> L26
            java.lang.String r2 = "reporterror"
            r4 = 0
            r5 = 0
            r6 = 0
            r7 = 0
            r8 = 0
            r9 = 0
            android.database.Cursor r0 = r1.query(r2, r3, r4, r5, r6, r7, r8, r9)     // Catch: java.lang.Throwable -> L24 java.lang.Exception -> L26
            int r10 = r0.getCount()     // Catch: java.lang.Throwable -> L24 java.lang.Exception -> L26
            if (r0 == 0) goto L2d
        L20:
            r0.close()     // Catch: java.lang.Throwable -> L35
            goto L2d
        L24:
            r1 = move-exception
            goto L2f
        L26:
            r1 = move-exception
            r1.printStackTrace()     // Catch: java.lang.Throwable -> L24
            if (r0 == 0) goto L2d
            goto L20
        L2d:
            monitor-exit(r11)
            return r10
        L2f:
            if (r0 == 0) goto L34
            r0.close()     // Catch: java.lang.Throwable -> L35
        L34:
            throw r1     // Catch: java.lang.Throwable -> L35
        L35:
            r0 = move-exception
            monitor-exit(r11)
            throw r0
        */
        throw new UnsupportedOperationException("Method not decompiled: com.mbridge.msdk.foundation.db.l.b():int");
    }
}
