package com.ironsource; import android.content.ContentValues; import android.content.Context; import android.database.sqlite.SQLiteDatabase; import android.database.sqlite.SQLiteOpenHelper; import android.os.SystemClock; import android.provider.BaseColumns; /* loaded from: classes2.dex */ public class q9 extends SQLiteOpenHelper implements ie { private static q9 f = null; private static final String g = " TEXT"; private static final String h = " INTEGER"; private static final String i = ","; private final r9 a; private final int b; private final int c; private final String d; private final String e; public static abstract class a implements BaseColumns { public static final String a = "events"; public static final int b = 4; public static final String c = "eventid"; public static final String d = "timestamp"; public static final String e = "type"; public static final String f = "data"; } public q9(Context context, String str, int i2) { super(context, str, (SQLiteDatabase.CursorFactory) null, i2); this.a = new r9(); this.b = 4; this.c = 400; this.d = "DROP TABLE IF EXISTS events"; this.e = "CREATE TABLE events (_id INTEGER PRIMARY KEY,eventid INTEGER,timestamp INTEGER,type TEXT,data TEXT )"; } private ContentValues a(kb kbVar, String str) { if (kbVar == null) { return null; } ContentValues contentValues = new ContentValues(4); contentValues.put("eventid", Integer.valueOf(kbVar.c())); contentValues.put("timestamp", Long.valueOf(kbVar.d())); contentValues.put("type", str); contentValues.put("data", kbVar.a()); return contentValues; } private synchronized SQLiteDatabase a(boolean z) throws Throwable { int i2 = 0; while (true) { try { if (z) { return this.a.a(true, this); } return this.a.a(false, this); } catch (Throwable th) { try { i9.d().a(th); i2++; if (i2 >= 4) { throw th; } SystemClock.sleep(i2 * 400); } catch (Throwable th2) { throw th2; } } } } public static synchronized q9 a(Context context, String str, int i2) { q9 q9Var; synchronized (q9.class) { try { if (f == null) { f = new q9(context, str, i2); } q9Var = f; } catch (Throwable th) { throw th; } } return q9Var; } /* JADX WARN: Code restructure failed: missing block: B:41:0x0075, code lost: if (r1.isOpen() != false) goto L42; */ @Override // com.ironsource.ie /* Code decompiled incorrectly, please refer to instructions dump. To view partially-correct add '--show-bad-code' argument */ public synchronized java.util.ArrayList a(java.lang.String r12) { /* r11 = this; monitor-enter(r11) java.util.ArrayList r0 = new java.util.ArrayList // Catch: java.lang.Throwable -> L6f r0.() // Catch: java.lang.Throwable -> L6f r1 = 0 r2 = 0 android.database.sqlite.SQLiteDatabase r1 = r11.a(r1) // Catch: java.lang.Throwable -> L78 java.lang.String r6 = "type = ?" java.lang.String[] r7 = new java.lang.String[]{r12} // Catch: java.lang.Throwable -> L60 java.lang.String r10 = "timestamp ASC" java.lang.String r4 = "events" r5 = 0 r8 = 0 r9 = 0 r3 = r1 android.database.Cursor r2 = r3.query(r4, r5, r6, r7, r8, r9, r10) // Catch: java.lang.Throwable -> L60 int r12 = r2.getCount() // Catch: java.lang.Throwable -> L60 if (r12 <= 0) goto L65 r2.moveToFirst() // Catch: java.lang.Throwable -> L60 L27: boolean r12 = r2.isAfterLast() // Catch: java.lang.Throwable -> L60 if (r12 != 0) goto L62 java.lang.String r12 = "eventid" int r12 = r2.getColumnIndex(r12) // Catch: java.lang.Throwable -> L60 if (r12 >= 0) goto L36 goto L27 L36: int r12 = r2.getInt(r12) // Catch: java.lang.Throwable -> L60 java.lang.String r3 = "timestamp" int r3 = r2.getColumnIndex(r3) // Catch: java.lang.Throwable -> L60 if (r3 >= 0) goto L43 goto L27 L43: long r3 = r2.getLong(r3) // Catch: java.lang.Throwable -> L60 java.lang.String r5 = "data" int r5 = r2.getColumnIndex(r5) // Catch: java.lang.Throwable -> L60 if (r5 >= 0) goto L50 goto L27 L50: java.lang.String r5 = r2.getString(r5) // Catch: java.lang.Throwable -> L60 com.ironsource.kb r6 = new com.ironsource.kb // Catch: java.lang.Throwable -> L60 r6.(r12, r3, r5) // Catch: java.lang.Throwable -> L60 r0.add(r6) // Catch: java.lang.Throwable -> L60 r2.moveToNext() // Catch: java.lang.Throwable -> L60 goto L27 L60: r12 = move-exception goto L7a L62: r2.close() // Catch: java.lang.Throwable -> L60 L65: boolean r12 = r2.isClosed() // Catch: java.lang.Throwable -> L6f if (r12 != 0) goto L71 r2.close() // Catch: java.lang.Throwable -> L6f goto L71 L6f: r12 = move-exception goto Lb8 L71: boolean r12 = r1.isOpen() // Catch: java.lang.Throwable -> L6f if (r12 == 0) goto L9e goto L9b L78: r12 = move-exception r1 = r2 L7a: com.ironsource.i9 r3 = com.ironsource.i9.d() // Catch: java.lang.Throwable -> La0 r3.a(r12) // Catch: java.lang.Throwable -> La0 java.lang.String r3 = "IronSource" java.lang.String r4 = "Exception while loading events: " android.util.Log.e(r3, r4, r12) // Catch: java.lang.Throwable -> La0 if (r2 == 0) goto L93 boolean r12 = r2.isClosed() // Catch: java.lang.Throwable -> L6f if (r12 != 0) goto L93 r2.close() // Catch: java.lang.Throwable -> L6f L93: if (r1 == 0) goto L9e boolean r12 = r1.isOpen() // Catch: java.lang.Throwable -> L6f if (r12 == 0) goto L9e L9b: r1.close() // Catch: java.lang.Throwable -> L6f L9e: monitor-exit(r11) return r0 La0: r12 = move-exception if (r2 == 0) goto Lac boolean r0 = r2.isClosed() // Catch: java.lang.Throwable -> L6f if (r0 != 0) goto Lac r2.close() // Catch: java.lang.Throwable -> L6f Lac: if (r1 == 0) goto Lb7 boolean r0 = r1.isOpen() // Catch: java.lang.Throwable -> L6f if (r0 == 0) goto Lb7 r1.close() // Catch: java.lang.Throwable -> L6f Lb7: throw r12 // Catch: java.lang.Throwable -> L6f Lb8: monitor-exit(r11) throw r12 */ throw new UnsupportedOperationException("Method not decompiled: com.ironsource.q9.a(java.lang.String):java.util.ArrayList"); } /* JADX WARN: Code restructure failed: missing block: B:30:0x0037, code lost: if (r0.isOpen() != false) goto L31; */ @Override // com.ironsource.ie /* Code decompiled incorrectly, please refer to instructions dump. To view partially-correct add '--show-bad-code' argument */ public synchronized void a(java.util.List r5, java.lang.String r6) { /* r4 = this; monitor-enter(r4) if (r5 == 0) goto L68 boolean r0 = r5.isEmpty() // Catch: java.lang.Throwable -> L3a if (r0 == 0) goto La goto L68 La: r0 = 1 r1 = 0 android.database.sqlite.SQLiteDatabase r0 = r4.a(r0) // Catch: java.lang.Throwable -> L3c java.util.Iterator r5 = r5.iterator() // Catch: java.lang.Throwable -> L2e L14: boolean r2 = r5.hasNext() // Catch: java.lang.Throwable -> L2e if (r2 == 0) goto L31 java.lang.Object r2 = r5.next() // Catch: java.lang.Throwable -> L2e com.ironsource.kb r2 = (com.ironsource.kb) r2 // Catch: java.lang.Throwable -> L2e android.content.ContentValues r2 = r4.a(r2, r6) // Catch: java.lang.Throwable -> L2e if (r0 == 0) goto L14 if (r2 == 0) goto L14 java.lang.String r3 = "events" r0.insert(r3, r1, r2) // Catch: java.lang.Throwable -> L2e goto L14 L2e: r5 = move-exception r1 = r0 goto L3d L31: if (r0 == 0) goto L57 boolean r5 = r0.isOpen() // Catch: java.lang.Throwable -> L3a if (r5 == 0) goto L57 goto L54 L3a: r5 = move-exception goto L66 L3c: r5 = move-exception L3d: com.ironsource.i9 r6 = com.ironsource.i9.d() // Catch: java.lang.Throwable -> L59 r6.a(r5) // Catch: java.lang.Throwable -> L59 java.lang.String r6 = "IronSource" java.lang.String r0 = "Exception while saving events: " android.util.Log.e(r6, r0, r5) // Catch: java.lang.Throwable -> L59 if (r1 == 0) goto L57 boolean r5 = r1.isOpen() // Catch: java.lang.Throwable -> L3a if (r5 == 0) goto L57 r0 = r1 L54: r0.close() // Catch: java.lang.Throwable -> L3a L57: monitor-exit(r4) return L59: r5 = move-exception if (r1 == 0) goto L65 boolean r6 = r1.isOpen() // Catch: java.lang.Throwable -> L3a if (r6 == 0) goto L65 r1.close() // Catch: java.lang.Throwable -> L3a L65: throw r5 // Catch: java.lang.Throwable -> L3a L66: monitor-exit(r4) throw r5 L68: monitor-exit(r4) return */ throw new UnsupportedOperationException("Method not decompiled: com.ironsource.q9.a(java.util.List, java.lang.String):void"); } /* JADX WARN: Code restructure failed: missing block: B:10:0x0015, code lost: if (r1.isOpen() != false) goto L20; */ @Override // com.ironsource.ie /* Code decompiled incorrectly, please refer to instructions dump. To view partially-correct add '--show-bad-code' argument */ public synchronized void b(java.lang.String r4) { /* r3 = this; monitor-enter(r3) java.lang.String r0 = "type = ?" java.lang.String[] r4 = new java.lang.String[]{r4} // Catch: java.lang.Throwable -> L18 r1 = 1 android.database.sqlite.SQLiteDatabase r1 = r3.a(r1) // Catch: java.lang.Throwable -> L1c java.lang.String r2 = "events" r1.delete(r2, r0, r4) // Catch: java.lang.Throwable -> L1a boolean r4 = r1.isOpen() // Catch: java.lang.Throwable -> L18 if (r4 == 0) goto L37 goto L34 L18: r4 = move-exception goto L46 L1a: r4 = move-exception goto L1e L1c: r4 = move-exception r1 = 0 L1e: com.ironsource.i9 r0 = com.ironsource.i9.d() // Catch: java.lang.Throwable -> L39 r0.a(r4) // Catch: java.lang.Throwable -> L39 java.lang.String r0 = "IronSource" java.lang.String r2 = "Exception while clearing events: " android.util.Log.e(r0, r2, r4) // Catch: java.lang.Throwable -> L39 if (r1 == 0) goto L37 boolean r4 = r1.isOpen() // Catch: java.lang.Throwable -> L18 if (r4 == 0) goto L37 L34: r1.close() // Catch: java.lang.Throwable -> L18 L37: monitor-exit(r3) return L39: r4 = move-exception if (r1 == 0) goto L45 boolean r0 = r1.isOpen() // Catch: java.lang.Throwable -> L18 if (r0 == 0) goto L45 r1.close() // Catch: java.lang.Throwable -> L18 L45: throw r4 // Catch: java.lang.Throwable -> L18 L46: monitor-exit(r3) throw r4 */ throw new UnsupportedOperationException("Method not decompiled: com.ironsource.q9.b(java.lang.String):void"); } @Override // android.database.sqlite.SQLiteOpenHelper public void onCreate(SQLiteDatabase sQLiteDatabase) { sQLiteDatabase.execSQL("CREATE TABLE events (_id INTEGER PRIMARY KEY,eventid INTEGER,timestamp INTEGER,type TEXT,data TEXT )"); } @Override // android.database.sqlite.SQLiteOpenHelper public void onUpgrade(SQLiteDatabase sQLiteDatabase, int i2, int i3) { sQLiteDatabase.execSQL("DROP TABLE IF EXISTS events"); onCreate(sQLiteDatabase); } }