package L1;

import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteException;

/* JADX INFO: loaded from: classes.dex */
public final class P extends H {

    /* JADX INFO: renamed from: o, reason: collision with root package name */
    public static final String[] f1532o = {"app_version", "ALTER TABLE messages ADD COLUMN app_version TEXT;", "app_version_int", "ALTER TABLE messages ADD COLUMN app_version_int INTEGER;"};

    /* JADX INFO: renamed from: m, reason: collision with root package name */
    public final C0116m f1533m;

    /* JADX INFO: renamed from: n, reason: collision with root package name */
    public boolean f1534n;

    public P(C0146w0 c0146w0) {
        super(c0146w0);
        this.f1533m = new C0116m(this, ((C0146w0) this.f29k).f2032k);
    }

    @Override // L1.H
    public final boolean n() {
        return false;
    }

    public final void o() {
        int iDelete;
        C0146w0 c0146w0 = (C0146w0) this.f29k;
        k();
        try {
            SQLiteDatabase sQLiteDatabaseQ = q();
            if (sQLiteDatabaseQ == null || (iDelete = sQLiteDatabaseQ.delete("messages", null, null)) <= 0) {
                return;
            }
            X x5 = c0146w0.p;
            C0146w0.l(x5);
            x5.f1631x.c("Reset local analytics data. records", Integer.valueOf(iDelete));
        } catch (SQLiteException e2) {
            X x6 = c0146w0.p;
            C0146w0.l(x6);
            x6.p.c("Error resetting local analytics data. error", e2);
        }
    }

    /* JADX WARN: Removed duplicated region for block: B:32:0x0074 A[PHI: r5
      0x0074: PHI (r5v3 int) = (r5v1 int), (r5v1 int), (r5v4 int) binds: [B:28:0x006b, B:34:0x0084, B:31:0x0072] A[DONT_GENERATE, DONT_INLINE]] */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
        To view partially-correct code enable 'Show inconsistent code' option in preferences
    */
    public final boolean p() {
        /*
            r11 = this;
            java.lang.String r0 = "Error deleting app launch break from local database"
            r11.k()
            boolean r1 = r11.f1534n
            r2 = 0
            if (r1 == 0) goto Lc
            goto L9c
        Lc:
            java.lang.Object r1 = r11.f29k
            L1.w0 r1 = (L1.C0146w0) r1
            android.content.Context r3 = r1.f2032k
            java.lang.String r4 = "google_app_measurement_local.db"
            java.io.File r3 = r3.getDatabasePath(r4)
            boolean r3 = r3.exists()
            if (r3 == 0) goto L9c
            r3 = 5
            r4 = r2
            r5 = r3
        L21:
            if (r4 >= r3) goto L90
            r6 = 1
            r7 = 0
            android.database.sqlite.SQLiteDatabase r7 = r11.q()     // Catch: java.lang.Throwable -> L2f android.database.sqlite.SQLiteException -> L31 android.database.sqlite.SQLiteFullException -> L33 android.database.sqlite.SQLiteDatabaseLockedException -> L6c
            if (r7 != 0) goto L35
            r11.f1534n = r6     // Catch: java.lang.Throwable -> L2f android.database.sqlite.SQLiteException -> L31 android.database.sqlite.SQLiteFullException -> L33 android.database.sqlite.SQLiteDatabaseLockedException -> L6c
            goto L9c
        L2f:
            r0 = move-exception
            goto L8a
        L31:
            r8 = move-exception
            goto L52
        L33:
            r8 = move-exception
            goto L78
        L35:
            r7.beginTransaction()     // Catch: java.lang.Throwable -> L2f android.database.sqlite.SQLiteException -> L31 android.database.sqlite.SQLiteFullException -> L33 android.database.sqlite.SQLiteDatabaseLockedException -> L6c
            java.lang.String r8 = "messages"
            java.lang.String r9 = "type == ?"
            r10 = 3
            java.lang.String r10 = java.lang.Integer.toString(r10)     // Catch: java.lang.Throwable -> L2f android.database.sqlite.SQLiteException -> L31 android.database.sqlite.SQLiteFullException -> L33 android.database.sqlite.SQLiteDatabaseLockedException -> L6c
            java.lang.String[] r10 = new java.lang.String[]{r10}     // Catch: java.lang.Throwable -> L2f android.database.sqlite.SQLiteException -> L31 android.database.sqlite.SQLiteFullException -> L33 android.database.sqlite.SQLiteDatabaseLockedException -> L6c
            r7.delete(r8, r9, r10)     // Catch: java.lang.Throwable -> L2f android.database.sqlite.SQLiteException -> L31 android.database.sqlite.SQLiteFullException -> L33 android.database.sqlite.SQLiteDatabaseLockedException -> L6c
            r7.setTransactionSuccessful()     // Catch: java.lang.Throwable -> L2f android.database.sqlite.SQLiteException -> L31 android.database.sqlite.SQLiteFullException -> L33 android.database.sqlite.SQLiteDatabaseLockedException -> L6c
            r7.endTransaction()     // Catch: java.lang.Throwable -> L2f android.database.sqlite.SQLiteException -> L31 android.database.sqlite.SQLiteFullException -> L33 android.database.sqlite.SQLiteDatabaseLockedException -> L6c
            r7.close()
            return r6
        L52:
            if (r7 == 0) goto L5d
            boolean r9 = r7.inTransaction()     // Catch: java.lang.Throwable -> L2f
            if (r9 == 0) goto L5d
            r7.endTransaction()     // Catch: java.lang.Throwable -> L2f
        L5d:
            L1.X r9 = r1.p     // Catch: java.lang.Throwable -> L2f
            L1.C0146w0.l(r9)     // Catch: java.lang.Throwable -> L2f
            L1.V r9 = r9.p     // Catch: java.lang.Throwable -> L2f
            r9.c(r0, r8)     // Catch: java.lang.Throwable -> L2f
            r11.f1534n = r6     // Catch: java.lang.Throwable -> L2f
            if (r7 == 0) goto L87
            goto L74
        L6c:
            long r8 = (long) r5     // Catch: java.lang.Throwable -> L2f
            android.os.SystemClock.sleep(r8)     // Catch: java.lang.Throwable -> L2f
            int r5 = r5 + 20
            if (r7 == 0) goto L87
        L74:
            r7.close()
            goto L87
        L78:
            L1.X r9 = r1.p     // Catch: java.lang.Throwable -> L2f
            L1.C0146w0.l(r9)     // Catch: java.lang.Throwable -> L2f
            L1.V r9 = r9.p     // Catch: java.lang.Throwable -> L2f
            r9.c(r0, r8)     // Catch: java.lang.Throwable -> L2f
            r11.f1534n = r6     // Catch: java.lang.Throwable -> L2f
            if (r7 == 0) goto L87
            goto L74
        L87:
            int r4 = r4 + 1
            goto L21
        L8a:
            if (r7 == 0) goto L8f
            r7.close()
        L8f:
            throw r0
        L90:
            L1.X r0 = r1.p
            L1.C0146w0.l(r0)
            java.lang.String r1 = "Error deleting app launch break from local database in reasonable time"
            L1.V r0 = r0.f1626s
            r0.b(r1)
        L9c:
            return r2
        */
        throw new UnsupportedOperationException("Method not decompiled: L1.P.p():boolean");
    }

    public final SQLiteDatabase q() {
        if (this.f1534n) {
            return null;
        }
        SQLiteDatabase writableDatabase = this.f1533m.getWritableDatabase();
        if (writableDatabase != null) {
            return writableDatabase;
        }
        this.f1534n = true;
        return null;
    }

    /* JADX WARN: Removed duplicated region for block: B:120:0x0173 A[SYNTHETIC] */
    /* JADX WARN: Removed duplicated region for block: B:121:0x0173 A[SYNTHETIC] */
    /* JADX WARN: Removed duplicated region for block: B:123:0x0173 A[SYNTHETIC] */
    /* JADX WARN: Removed duplicated region for block: B:40:0x00a4 A[Catch: all -> 0x0094, SQLiteDatabaseLockedException -> 0x0097, SQLiteException -> 0x00f2, SQLiteFullException -> 0x00f6, TRY_ENTER, TRY_LEAVE, TryCatch #8 {all -> 0x0094, blocks: (B:31:0x0089, B:33:0x008f, B:40:0x00a4, B:42:0x00ab, B:44:0x00c8, B:46:0x00d3, B:61:0x00fd, B:75:0x0125, B:77:0x012b, B:78:0x012e, B:93:0x015e, B:85:0x0149), top: B:109:0x0089 }] */
    /* JADX WARN: Removed duplicated region for block: B:60:0x00fa  */
    /* JADX WARN: Removed duplicated region for block: B:63:0x0108  */
    /* JADX WARN: Removed duplicated region for block: B:75:0x0125 A[Catch: all -> 0x0094, TRY_ENTER, TryCatch #8 {all -> 0x0094, blocks: (B:31:0x0089, B:33:0x008f, B:40:0x00a4, B:42:0x00ab, B:44:0x00c8, B:46:0x00d3, B:61:0x00fd, B:75:0x0125, B:77:0x012b, B:78:0x012e, B:93:0x015e, B:85:0x0149), top: B:109:0x0089 }] */
    /* JADX WARN: Removed duplicated region for block: B:80:0x013e  */
    /* JADX WARN: Removed duplicated region for block: B:88:0x0150  */
    /* JADX WARN: Removed duplicated region for block: B:90:0x0155 A[PHI: r8 r11 r16
      0x0155: PHI (r8v5 int) = (r8v3 int), (r8v3 int), (r8v6 int) binds: [B:81:0x0141, B:96:0x0170, B:89:0x0153] A[DONT_GENERATE, DONT_INLINE]
      0x0155: PHI (r11v7 android.database.sqlite.SQLiteDatabase) = 
      (r11v5 android.database.sqlite.SQLiteDatabase)
      (r11v6 android.database.sqlite.SQLiteDatabase)
      (r11v8 android.database.sqlite.SQLiteDatabase)
     binds: [B:81:0x0141, B:96:0x0170, B:89:0x0153] A[DONT_GENERATE, DONT_INLINE]
      0x0155: PHI (r16v7 boolean) = (r16v4 boolean), (r16v5 boolean), (r16v8 boolean) binds: [B:81:0x0141, B:96:0x0170, B:89:0x0153] A[DONT_GENERATE, DONT_INLINE]] */
    /* JADX WARN: Removed duplicated region for block: B:95:0x016d  */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
        To view partially-correct code enable 'Show inconsistent code' option in preferences
    */
    public final boolean r(int r20, byte[] r21) {
        /*
            Method dump skipped, instruction units count: 402
            To view this dump change 'Code comments level' option to 'DEBUG'
        */
        throw new UnsupportedOperationException("Method not decompiled: L1.P.r(int, byte[]):boolean");
    }
}
