package defpackage;

import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.pm.ResolveInfo;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteDatabaseLockedException;
import android.database.sqlite.SQLiteException;
import android.database.sqlite.SQLiteFullException;
import android.os.Bundle;
import android.os.Parcel;
import android.os.RemoteException;
import android.os.SystemClock;
import android.text.TextUtils;
import android.util.Pair;
import com.google.android.gms.common.internal.safeparcel.SafeParcelReader$ParseException;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.atomic.AtomicReference;

/* JADX INFO: renamed from: ˌᵡˆ, reason: contains not printable characters */
/* JADX INFO: loaded from: classes3.dex */
public final class C1618 extends AbstractC2191 {

    /* JADX INFO: renamed from: ˈᵲᵢ, reason: contains not printable characters */
    public ScheduledExecutorService f6474;

    /* JADX INFO: renamed from: ˌᵨʠᵫ, reason: contains not printable characters */
    public final C1705 f6475;

    /* JADX INFO: renamed from: ˑˊᵲ, reason: contains not printable characters */
    public final C4697 f6476;

    /* JADX INFO: renamed from: ᵔᵖᵹᵫ, reason: contains not printable characters */
    public final ServiceConnectionC4728 f6477;

    /* JADX INFO: renamed from: ᵨᵼⁱ, reason: contains not printable characters */
    public InterfaceC0071 f6478;

    /* JADX INFO: renamed from: ᵯᵷʽ, reason: contains not printable characters */
    public volatile Boolean f6479;

    /* JADX INFO: renamed from: ᵶˇᵱ, reason: contains not printable characters */
    public final C4697 f6480;

    /* JADX INFO: renamed from: ᵸˆˁ, reason: contains not printable characters */
    public final ArrayList f6481;

    public C1618(C1103 c1103) {
        super(c1103);
        this.f6481 = new ArrayList();
        this.f6475 = new C1705(c1103.f4701);
        this.f6477 = new ServiceConnectionC4728(this);
        this.f6480 = new C4697(this, c1103, 0);
        this.f6476 = new C4697(this, c1103, 1);
    }

    /* JADX INFO: renamed from: ʽᵡᵢᵾ, reason: contains not printable characters */
    public final void m4457(Runnable runnable) {
        m6166();
        if (m4469()) {
            runnable.run();
            return;
        }
        ArrayList arrayList = this.f6481;
        long size = arrayList.size();
        C1103 c1103 = (C1103) ((ᵜᵪʾ) this).ˌᴵ;
        c1103.getClass();
        if (size >= 1000) {
            C3485 c3485 = c1103.f4729;
            C1103.m3564(c3485);
            c3485.f13423.m4476("Discarding data. Max runnable queue size reached");
        } else {
            arrayList.add(runnable);
            this.f6476.m9539(60000L);
            m4463();
        }
    }

    /* JADX INFO: renamed from: ʿٴˇ, reason: contains not printable characters */
    public final void m4458(AtomicReference atomicReference) {
        m6166();
        m5699();
        m4457(new ᵶᵮˋᵬ(this, atomicReference, m4471(false)));
    }

    /* JADX INFO: renamed from: ˀᵭ, reason: contains not printable characters */
    public final void m4459() {
        m6166();
        m5699();
        ServiceConnectionC4728 serviceConnectionC4728 = this.f6477;
        if (serviceConnectionC4728.f17983 != null && (serviceConnectionC4728.f17983.m1917() || serviceConnectionC4728.f17983.m1919())) {
            serviceConnectionC4728.f17983.m1912();
        }
        serviceConnectionC4728.f17983 = null;
        try {
            C0183.m1338().m1339(((C1103) ((ᵜᵪʾ) this).ˌᴵ).f4713, serviceConnectionC4728);
        } catch (IllegalArgumentException | IllegalStateException unused) {
        }
        this.f6478 = null;
    }

    /* JADX INFO: renamed from: ˁʢᵛ, reason: contains not printable characters */
    public final void m4460(C3833 c3833) {
        boolean zM9434;
        m6166();
        m5699();
        C1103 c1103 = (C1103) ((ᵜᵪʾ) this).ˌᴵ;
        c1103.getClass();
        C4421 c4421M3575 = c1103.m3575();
        C1103 c11032 = (C1103) ((ᵜᵪʾ) c4421M3575).ˌᴵ;
        C1103.m3567(c11032.f4730);
        byte[] bArrM7616 = C3335.m7616(c3833);
        if (bArrM7616.length > 131072) {
            C3485 c3485 = c11032.f4729;
            C1103.m3564(c3485);
            c3485.f13415.m4476("Conditional user property too long for local database. Sending directly to service");
            zM9434 = false;
        } else {
            zM9434 = c4421M3575.m9434(2, bArrM7616);
        }
        m4457(new RunnableC0742(this, m4471(true), zM9434, new C3833(c3833)));
    }

    /* JADX WARN: Removed duplicated region for block: B:42:0x00fa  */
    /* JADX WARN: Removed duplicated region for block: B:45:0x010f  */
    /* JADX WARN: Removed duplicated region for block: B:46:0x0111  */
    /* JADX INFO: renamed from: ˁˌᵩ, reason: contains not printable characters */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final boolean m4461() {
        m6166();
        m5699();
        if (this.f6479 == null) {
            m6166();
            m5699();
            C1103 c1103 = (C1103) ((ᵜᵪʾ) this).ˌᴵ;
            C3740 c3740 = c1103.f4727;
            C1103.m3567(c3740);
            c3740.ˈᵲᵢ();
            boolean z = false;
            Boolean boolValueOf = !c3740.m8407().contains("use_service") ? null : Boolean.valueOf(c3740.m8407().getBoolean("use_service", false));
            if (boolValueOf == null || !boolValueOf.booleanValue()) {
                C2303 c2303M3569 = ((C1103) ((ᵜᵪʾ) this).ˌᴵ).m3569();
                c2303M3569.m5699();
                if (c2303M3569.f9050 == 1) {
                    z = true;
                    if (!z && c1103.f4726.m8313()) {
                        C3485 c3485 = c1103.f4729;
                        C1103.m3564(c3485);
                        c3485.f13423.m4476("No way to upload. Consider using the full version of Analytics");
                    } else if (z) {
                        C3740 c37402 = c1103.f4727;
                        C1103.m3567(c37402);
                        c37402.ˈᵲᵢ();
                        SharedPreferences.Editor editorEdit = c37402.m8407().edit();
                        editorEdit.putBoolean("use_service", z);
                        editorEdit.apply();
                    }
                    z = z;
                } else {
                    C3485 c34852 = c1103.f4729;
                    C1103.m3564(c34852);
                    c34852.f13414.m4476("Checking service availability");
                    C3335 c3335 = c1103.f4730;
                    C1103.m3567(c3335);
                    int iM10399 = C5073.f19129.m10399(((C1103) ((ᵜᵪʾ) c3335).ˌᴵ).f4713, 12451000);
                    if (iM10399 != 0) {
                        if (iM10399 == 1) {
                            C3485 c34853 = c1103.f4729;
                            C1103.m3564(c34853);
                            c34853.f13414.m4476("Service missing");
                        } else if (iM10399 != 2) {
                            if (iM10399 != 3) {
                                C3485 c34854 = c1103.f4729;
                                if (iM10399 == 9) {
                                    C1103.m3564(c34854);
                                    c34854.f13424.m4476("Service invalid");
                                } else if (iM10399 != 18) {
                                    C1103.m3564(c34854);
                                    c34854.f13424.m4474(Integer.valueOf(iM10399), "Unexpected service status");
                                } else {
                                    C1103.m3564(c34854);
                                    c34854.f13424.m4476("Service updating");
                                }
                            } else {
                                C3485 c34855 = c1103.f4729;
                                C1103.m3564(c34855);
                                c34855.f13424.m4476("Service disabled");
                            }
                            z = false;
                        } else {
                            C3485 c34856 = c1103.f4729;
                            C1103.m3564(c34856);
                            c34856.f13416.m4476("Service container out of date");
                            C3335 c33352 = c1103.f4730;
                            C1103.m3567(c33352);
                            if (c33352.m7667() >= 17443) {
                                z = boolValueOf == null;
                                z = false;
                            }
                        }
                        if (!z) {
                            if (z) {
                            }
                            z = z;
                        }
                    } else {
                        C3485 c34857 = c1103.f4729;
                        C1103.m3564(c34857);
                        c34857.f13414.m4476("Service available");
                    }
                    z = true;
                    if (!z) {
                    }
                }
            }
            this.f6479 = Boolean.valueOf(z);
        }
        return this.f6479.booleanValue();
    }

    /* JADX INFO: renamed from: ˈⁱᵡ, reason: contains not printable characters */
    public final void m4462() {
        m6166();
        C1103 c1103 = (C1103) ((ᵜᵪʾ) this).ˌᴵ;
        C3485 c3485 = c1103.f4729;
        C1103.m3564(c3485);
        C1623 c1623 = c3485.f13414;
        ArrayList arrayList = this.f6481;
        c1623.m4474(Integer.valueOf(arrayList.size()), "Processing queued up service tasks");
        int size = arrayList.size();
        int i = 0;
        while (i < size) {
            Object obj = arrayList.get(i);
            i++;
            try {
                ((Runnable) obj).run();
            } catch (RuntimeException e) {
                C3485 c34852 = c1103.f4729;
                C1103.m3564(c34852);
                c34852.f13423.m4474(e, "Task exception while flushing queue");
            }
        }
        arrayList.clear();
        this.f6476.m9540();
    }

    /* JADX INFO: renamed from: ˉᵵᵜ, reason: contains not printable characters */
    public final void m4463() {
        m6166();
        m5699();
        if (m4469()) {
            return;
        }
        if (m4461()) {
            this.f6477.m9872();
            return;
        }
        C1103 c1103 = (C1103) ((ᵜᵪʾ) this).ˌᴵ;
        if (c1103.f4726.m8313()) {
            return;
        }
        List<ResolveInfo> listQueryIntentServices = c1103.f4713.getPackageManager().queryIntentServices(new Intent().setClassName(c1103.f4713, "com.google.android.gms.measurement.AppMeasurementService"), 65536);
        if (listQueryIntentServices == null || listQueryIntentServices.isEmpty()) {
            C3485 c3485 = c1103.f4729;
            C1103.m3564(c3485);
            c3485.f13423.m4476("Unable to use remote or local measurement implementation. Please register the AppMeasurementService service in the app manifest");
            return;
        }
        Intent intent = new Intent("com.google.android.gms.measurement.START");
        intent.setComponent(new ComponentName(c1103.f4713, "com.google.android.gms.measurement.AppMeasurementService"));
        ServiceConnectionC4728 serviceConnectionC4728 = this.f6477;
        C1618 c1618 = serviceConnectionC4728.f17982;
        c1618.m6166();
        Context context = ((C1103) ((ᵜᵪʾ) c1618).ˌᴵ).f4713;
        C0183 c0183M1338 = C0183.m1338();
        synchronized (serviceConnectionC4728) {
            try {
                boolean z = serviceConnectionC4728.f17981;
                C1618 c16182 = serviceConnectionC4728.f17982;
                if (z) {
                    C3485 c34852 = ((C1103) ((ᵜᵪʾ) c16182).ˌᴵ).f4729;
                    C1103.m3564(c34852);
                    c34852.f13414.m4476("Connection attempt already in progress");
                } else {
                    C3485 c34853 = ((C1103) ((ᵜᵪʾ) c16182).ˌᴵ).f4729;
                    C1103.m3564(c34853);
                    c34853.f13414.m4476("Using local app measurement service");
                    serviceConnectionC4728.f17981 = true;
                    c0183M1338.m1340(context, context.getClass().getName(), intent, c16182.f6477, 129, null);
                }
            } catch (Throwable th) {
                throw th;
            }
        }
    }

    /* JADX WARN: Removed duplicated region for block: B:258:0x043a A[Catch: all -> 0x0476, TRY_ENTER, TryCatch #50 {all -> 0x0476, blocks: (B:268:0x0466, B:258:0x043a, B:260:0x0440, B:261:0x0443, B:278:0x0487, B:207:0x0371, B:209:0x037b, B:214:0x038c), top: B:395:0x0466 }] */
    /* JADX WARN: Removed duplicated region for block: B:263:0x0452  */
    /* JADX WARN: Removed duplicated region for block: B:271:0x046d  */
    /* JADX WARN: Removed duplicated region for block: B:273:0x0472 A[PHI: r4 r6 r23 r24 r26 r36 r37
      0x0472: PHI (r4v15 android.database.sqlite.SQLiteDatabase) = 
      (r4v12 android.database.sqlite.SQLiteDatabase)
      (r4v13 android.database.sqlite.SQLiteDatabase)
      (r4v16 android.database.sqlite.SQLiteDatabase)
     binds: [B:264:0x0455, B:281:0x0499, B:272:0x0470] A[DONT_GENERATE, DONT_INLINE]
      0x0472: PHI (r6v5 int) = (r6v3 int), (r6v3 int), (r6v6 int) binds: [B:264:0x0455, B:281:0x0499, B:272:0x0470] A[DONT_GENERATE, DONT_INLINE]
      0x0472: PHI (r23v9 int) = (r23v6 int), (r23v7 int), (r23v10 int) binds: [B:264:0x0455, B:281:0x0499, B:272:0x0470] A[DONT_GENERATE, DONT_INLINE]
      0x0472: PHI (r24v9 java.lang.String) = (r24v6 java.lang.String), (r24v7 java.lang.String), (r24v10 java.lang.String) binds: [B:264:0x0455, B:281:0x0499, B:272:0x0470] A[DONT_GENERATE, DONT_INLINE]
      0x0472: PHI (r26v9 java.lang.String) = (r26v6 java.lang.String), (r26v7 java.lang.String), (r26v10 java.lang.String) binds: [B:264:0x0455, B:281:0x0499, B:272:0x0470] A[DONT_GENERATE, DONT_INLINE]
      0x0472: PHI (r36v9 int) = (r36v6 int), (r36v7 int), (r36v10 int) binds: [B:264:0x0455, B:281:0x0499, B:272:0x0470] A[DONT_GENERATE, DONT_INLINE]
      0x0472: PHI (r37v9 java.lang.String) = (r37v6 java.lang.String), (r37v7 java.lang.String), (r37v10 java.lang.String) binds: [B:264:0x0455, B:281:0x0499, B:272:0x0470] A[DONT_GENERATE, DONT_INLINE]] */
    /* JADX WARN: Removed duplicated region for block: B:280:0x0496  */
    /* JADX WARN: Removed duplicated region for block: B:285:0x04aa  */
    /* JADX WARN: Removed duplicated region for block: B:287:0x04af  */
    /* JADX WARN: Removed duplicated region for block: B:292:0x04c9  */
    /* JADX WARN: Removed duplicated region for block: B:293:0x04d2  */
    /* JADX WARN: Removed duplicated region for block: B:300:0x04ec  */
    /* JADX WARN: Removed duplicated region for block: B:305:0x058f  */
    /* JADX WARN: Removed duplicated region for block: B:337:0x0626  */
    /* JADX WARN: Removed duplicated region for block: B:456:0x049c A[SYNTHETIC] */
    /* JADX WARN: Removed duplicated region for block: B:457:0x049c A[SYNTHETIC] */
    /* JADX WARN: Removed duplicated region for block: B:459:0x049c A[SYNTHETIC] */
    /* JADX INFO: renamed from: ˊˌˊ, reason: contains not printable characters */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final void m4464(InterfaceC0071 interfaceC0071, AbstractC0106 abstractC0106, C2847 c2847) throws Throwable {
        ArrayList arrayList;
        C1103 c1103;
        Context context;
        C3485 c3485;
        int i;
        SQLiteDatabase sQLiteDatabase;
        int i2;
        String str;
        String str2;
        String str3;
        int i3;
        Cursor cursor;
        Cursor cursor2;
        Cursor cursorQuery;
        long j;
        String str4;
        String[] strArr;
        int i4;
        Cursor cursor3;
        C0511 c0511;
        long j2;
        String string;
        Parcel parcelObtain;
        C3590 c3590CreateFromParcel;
        int i5;
        C3833 c3833CreateFromParcel;
        C0973 c0973CreateFromParcel;
        int size;
        int size2;
        int i6;
        int i7;
        C0511 c05112;
        C1103 c11032;
        Context context2;
        C3485 c34852;
        long jElapsedRealtime;
        long j3;
        m6166();
        m5699();
        m4472();
        C1103 c11033 = (C1103) ((ᵜᵪʾ) this).ˌᴵ;
        c11033.getClass();
        Context context3 = c11033.f4713;
        C3691 c3691 = c11033.f4726;
        C3485 c34853 = c11033.f4729;
        ᵠʽᵲ r7 = c11033.f4701;
        int i8 = 100;
        C2847 c28472 = c2847;
        int i9 = 0;
        for (int i10 = 100; i9 < 1001 && i10 == i8; i10 = size) {
            ArrayList arrayList2 = new ArrayList();
            C4421 c4421M3575 = c11033.m3575();
            String str5 = "entry";
            int i11 = i8;
            String str6 = "type";
            String str7 = "rowid";
            ᵠʽᵲ r17 = r7;
            C1103 c11034 = (C1103) ((ᵜᵪʾ) c4421M3575).ˌᴵ;
            c4421M3575.m6166();
            int i12 = i9;
            if (c4421M3575.f16823) {
                c1103 = c11033;
                context = context3;
                c3485 = c34853;
            } else {
                arrayList = new ArrayList();
                c1103 = c11033;
                if (((C1103) ((ᵜᵪʾ) c4421M3575).ˌᴵ).f4713.getDatabasePath("google_app_measurement_local.db").exists()) {
                    int i13 = 5;
                    context = context3;
                    c3485 = c34853;
                    int i14 = 0;
                    int i15 = 5;
                    while (i14 < i13) {
                        try {
                            SQLiteDatabase sQLiteDatabaseM9435 = c4421M3575.m9435();
                            if (sQLiteDatabaseM9435 == null) {
                                try {
                                    try {
                                        c4421M3575.f16823 = true;
                                    } catch (Throwable th) {
                                        th = th;
                                        sQLiteDatabase = sQLiteDatabaseM9435;
                                        cursor = null;
                                        if (cursor != null) {
                                        }
                                        if (sQLiteDatabase != null) {
                                        }
                                        throw th;
                                    }
                                } catch (SQLiteDatabaseLockedException unused) {
                                    i2 = i14;
                                    str = str7;
                                    str3 = str5;
                                    sQLiteDatabase = sQLiteDatabaseM9435;
                                    i3 = 5;
                                    str2 = str6;
                                    cursor2 = null;
                                    try {
                                        SystemClock.sleep(i15);
                                        i15 += 20;
                                        if (cursor2 != null) {
                                        }
                                        if (sQLiteDatabase == null) {
                                        }
                                        i14 = i2 + 1;
                                        i13 = i3;
                                        str6 = str2;
                                        str5 = str3;
                                        str7 = str;
                                    } catch (Throwable th2) {
                                        th = th2;
                                        cursor = cursor2;
                                        if (cursor != null) {
                                            cursor.close();
                                        }
                                        if (sQLiteDatabase != null) {
                                            sQLiteDatabase.close();
                                        }
                                        throw th;
                                    }
                                } catch (SQLiteFullException e) {
                                    e = e;
                                    i2 = i14;
                                    str = str7;
                                    str3 = str5;
                                    sQLiteDatabase = sQLiteDatabaseM9435;
                                    i3 = 5;
                                    str2 = str6;
                                    cursor2 = null;
                                    C3485 c34854 = c11034.f4729;
                                    C1103.m3564(c34854);
                                    c34854.f13423.m4474(e, "Error reading entries from local database");
                                    c4421M3575.f16823 = true;
                                    if (cursor2 != null) {
                                    }
                                    if (sQLiteDatabase != null) {
                                    }
                                    i14 = i2 + 1;
                                    i13 = i3;
                                    str6 = str2;
                                    str5 = str3;
                                    str7 = str;
                                } catch (SQLiteException e2) {
                                    e = e2;
                                    i2 = i14;
                                    str = str7;
                                    str3 = str5;
                                    sQLiteDatabase = sQLiteDatabaseM9435;
                                    i3 = 5;
                                    str2 = str6;
                                    cursor2 = null;
                                    if (sQLiteDatabase != null) {
                                    }
                                    C3485 c34855 = c11034.f4729;
                                    C1103.m3564(c34855);
                                    c34855.f13423.m4474(e, "Error reading entries from local database");
                                    c4421M3575.f16823 = true;
                                    if (cursor2 != null) {
                                    }
                                    if (sQLiteDatabase != null) {
                                    }
                                    i14 = i2 + 1;
                                    i13 = i3;
                                    str6 = str2;
                                    str5 = str3;
                                    str7 = str;
                                }
                            } else {
                                sQLiteDatabaseM9435.beginTransaction();
                                try {
                                    cursorQuery = sQLiteDatabaseM9435.query("messages", new String[]{str7}, "type=?", new String[]{"3"}, null, null, "rowid desc", "1");
                                    try {
                                        long j4 = -1;
                                        if (cursorQuery.moveToFirst()) {
                                            i2 = i14;
                                            try {
                                                j = cursorQuery.getLong(0);
                                                try {
                                                    cursorQuery.close();
                                                } catch (SQLiteDatabaseLockedException unused2) {
                                                    str = str7;
                                                    str3 = str5;
                                                    sQLiteDatabase = sQLiteDatabaseM9435;
                                                    i3 = 5;
                                                    str2 = str6;
                                                    cursor2 = null;
                                                    SystemClock.sleep(i15);
                                                    i15 += 20;
                                                    if (cursor2 != null) {
                                                    }
                                                    if (sQLiteDatabase == null) {
                                                    }
                                                    i14 = i2 + 1;
                                                    i13 = i3;
                                                    str6 = str2;
                                                    str5 = str3;
                                                    str7 = str;
                                                } catch (SQLiteFullException e3) {
                                                    e = e3;
                                                    str = str7;
                                                    str3 = str5;
                                                    sQLiteDatabase = sQLiteDatabaseM9435;
                                                    i3 = 5;
                                                    str2 = str6;
                                                    cursor2 = null;
                                                    C3485 c348542 = c11034.f4729;
                                                    C1103.m3564(c348542);
                                                    c348542.f13423.m4474(e, "Error reading entries from local database");
                                                    c4421M3575.f16823 = true;
                                                    if (cursor2 != null) {
                                                        cursor2.close();
                                                    }
                                                    if (sQLiteDatabase != null) {
                                                    }
                                                    i14 = i2 + 1;
                                                    i13 = i3;
                                                    str6 = str2;
                                                    str5 = str3;
                                                    str7 = str;
                                                } catch (SQLiteException e4) {
                                                    e = e4;
                                                    str = str7;
                                                    str3 = str5;
                                                    sQLiteDatabase = sQLiteDatabaseM9435;
                                                    i3 = 5;
                                                    str2 = str6;
                                                    cursor2 = null;
                                                    if (sQLiteDatabase != null && sQLiteDatabase.inTransaction()) {
                                                        sQLiteDatabase.endTransaction();
                                                    }
                                                    C3485 c348552 = c11034.f4729;
                                                    C1103.m3564(c348552);
                                                    c348552.f13423.m4474(e, "Error reading entries from local database");
                                                    c4421M3575.f16823 = true;
                                                    if (cursor2 != null) {
                                                        cursor2.close();
                                                    }
                                                    if (sQLiteDatabase != null) {
                                                    }
                                                    i14 = i2 + 1;
                                                    i13 = i3;
                                                    str6 = str2;
                                                    str5 = str3;
                                                    str7 = str;
                                                }
                                            } catch (Throwable th3) {
                                                th = th3;
                                                str = str7;
                                                str3 = str5;
                                                sQLiteDatabase = sQLiteDatabaseM9435;
                                                i3 = 5;
                                                str2 = str6;
                                                if (cursorQuery != null) {
                                                    try {
                                                        cursorQuery.close();
                                                    } catch (SQLiteDatabaseLockedException unused3) {
                                                        cursor2 = null;
                                                        SystemClock.sleep(i15);
                                                        i15 += 20;
                                                        if (cursor2 != null) {
                                                        }
                                                        if (sQLiteDatabase == null) {
                                                        }
                                                        i14 = i2 + 1;
                                                        i13 = i3;
                                                        str6 = str2;
                                                        str5 = str3;
                                                        str7 = str;
                                                    } catch (SQLiteFullException e5) {
                                                        e = e5;
                                                        cursor2 = null;
                                                        C3485 c3485422 = c11034.f4729;
                                                        C1103.m3564(c3485422);
                                                        c3485422.f13423.m4474(e, "Error reading entries from local database");
                                                        c4421M3575.f16823 = true;
                                                        if (cursor2 != null) {
                                                        }
                                                        if (sQLiteDatabase != null) {
                                                        }
                                                        i14 = i2 + 1;
                                                        i13 = i3;
                                                        str6 = str2;
                                                        str5 = str3;
                                                        str7 = str;
                                                    } catch (SQLiteException e6) {
                                                        e = e6;
                                                        cursor2 = null;
                                                        if (sQLiteDatabase != null) {
                                                        }
                                                        C3485 c3485522 = c11034.f4729;
                                                        C1103.m3564(c3485522);
                                                        c3485522.f13423.m4474(e, "Error reading entries from local database");
                                                        c4421M3575.f16823 = true;
                                                        if (cursor2 != null) {
                                                        }
                                                        if (sQLiteDatabase != null) {
                                                        }
                                                        i14 = i2 + 1;
                                                        i13 = i3;
                                                        str6 = str2;
                                                        str5 = str3;
                                                        str7 = str;
                                                    } catch (Throwable th4) {
                                                        th = th4;
                                                        cursor = null;
                                                        if (cursor != null) {
                                                        }
                                                        if (sQLiteDatabase != null) {
                                                        }
                                                        throw th;
                                                    }
                                                }
                                                throw th;
                                            }
                                        } else {
                                            i2 = i14;
                                            cursorQuery.close();
                                            j = -1;
                                        }
                                        if (j != -1) {
                                            str4 = "rowid<?";
                                            strArr = new String[]{String.valueOf(j)};
                                        } else {
                                            str4 = null;
                                            strArr = null;
                                        }
                                        try {
                                            String[] strArr2 = {str7, str6, str5};
                                            C3691 c36912 = c11034.f4726;
                                            C0511 c05113 = AbstractC3818.f14493;
                                            str = str7;
                                            try {
                                                try {
                                                    int i16 = 4;
                                                    int i17 = 3;
                                                    if (c36912.m8314(null, c05113)) {
                                                        i4 = 5;
                                                        try {
                                                            strArr2 = new String[]{str, str6, str5, "app_version", "app_version_int"};
                                                        } catch (SQLiteDatabaseLockedException unused4) {
                                                            i3 = 5;
                                                            str3 = str5;
                                                            sQLiteDatabase = sQLiteDatabaseM9435;
                                                            str2 = str6;
                                                            cursor2 = null;
                                                            SystemClock.sleep(i15);
                                                            i15 += 20;
                                                            if (cursor2 != null) {
                                                            }
                                                            if (sQLiteDatabase == null) {
                                                            }
                                                            i14 = i2 + 1;
                                                            i13 = i3;
                                                            str6 = str2;
                                                            str5 = str3;
                                                            str7 = str;
                                                        } catch (SQLiteFullException e7) {
                                                            e = e7;
                                                            i3 = 5;
                                                            str3 = str5;
                                                            sQLiteDatabase = sQLiteDatabaseM9435;
                                                            str2 = str6;
                                                            cursor2 = null;
                                                            C3485 c34854222 = c11034.f4729;
                                                            C1103.m3564(c34854222);
                                                            c34854222.f13423.m4474(e, "Error reading entries from local database");
                                                            c4421M3575.f16823 = true;
                                                            if (cursor2 != null) {
                                                            }
                                                            if (sQLiteDatabase != null) {
                                                            }
                                                            i14 = i2 + 1;
                                                            i13 = i3;
                                                            str6 = str2;
                                                            str5 = str3;
                                                            str7 = str;
                                                        } catch (SQLiteException e8) {
                                                            e = e8;
                                                            i3 = 5;
                                                            str3 = str5;
                                                            sQLiteDatabase = sQLiteDatabaseM9435;
                                                            str2 = str6;
                                                            cursor2 = null;
                                                            if (sQLiteDatabase != null) {
                                                            }
                                                            C3485 c34855222 = c11034.f4729;
                                                            C1103.m3564(c34855222);
                                                            c34855222.f13423.m4474(e, "Error reading entries from local database");
                                                            c4421M3575.f16823 = true;
                                                            if (cursor2 != null) {
                                                            }
                                                            if (sQLiteDatabase != null) {
                                                            }
                                                            i14 = i2 + 1;
                                                            i13 = i3;
                                                            str6 = str2;
                                                            str5 = str3;
                                                            str7 = str;
                                                        }
                                                    } else {
                                                        i4 = 5;
                                                    }
                                                    try {
                                                        Cursor cursorQuery2 = sQLiteDatabaseM9435.query("messages", strArr2, str4, strArr, null, null, "rowid asc", Integer.toString(i11));
                                                        while (cursorQuery2.moveToNext()) {
                                                            try {
                                                                try {
                                                                    try {
                                                                        j4 = cursorQuery2.getLong(0);
                                                                        try {
                                                                            int i18 = cursorQuery2.getInt(1);
                                                                            str2 = str6;
                                                                            try {
                                                                                byte[] blob = cursorQuery2.getBlob(2);
                                                                                str3 = str5;
                                                                                try {
                                                                                    if (c11034.f4726.m8314(null, c05113)) {
                                                                                        try {
                                                                                            string = cursorQuery2.getString(i17);
                                                                                            cursor3 = cursorQuery2;
                                                                                            c0511 = c05113;
                                                                                            j2 = cursorQuery2.getLong(i16);
                                                                                        } catch (SQLiteDatabaseLockedException unused5) {
                                                                                            cursor2 = cursorQuery2;
                                                                                            sQLiteDatabase = sQLiteDatabaseM9435;
                                                                                            i3 = 5;
                                                                                            SystemClock.sleep(i15);
                                                                                            i15 += 20;
                                                                                            if (cursor2 != null) {
                                                                                            }
                                                                                            if (sQLiteDatabase == null) {
                                                                                            }
                                                                                            i14 = i2 + 1;
                                                                                            i13 = i3;
                                                                                            str6 = str2;
                                                                                            str5 = str3;
                                                                                            str7 = str;
                                                                                        } catch (SQLiteFullException e9) {
                                                                                            e = e9;
                                                                                            cursor2 = cursorQuery2;
                                                                                            sQLiteDatabase = sQLiteDatabaseM9435;
                                                                                            i3 = 5;
                                                                                            C3485 c348542222 = c11034.f4729;
                                                                                            C1103.m3564(c348542222);
                                                                                            c348542222.f13423.m4474(e, "Error reading entries from local database");
                                                                                            c4421M3575.f16823 = true;
                                                                                            if (cursor2 != null) {
                                                                                            }
                                                                                            if (sQLiteDatabase != null) {
                                                                                            }
                                                                                            i14 = i2 + 1;
                                                                                            i13 = i3;
                                                                                            str6 = str2;
                                                                                            str5 = str3;
                                                                                            str7 = str;
                                                                                        } catch (SQLiteException e10) {
                                                                                            e = e10;
                                                                                            cursor2 = cursorQuery2;
                                                                                            sQLiteDatabase = sQLiteDatabaseM9435;
                                                                                            i3 = 5;
                                                                                            if (sQLiteDatabase != null) {
                                                                                            }
                                                                                            C3485 c348552222 = c11034.f4729;
                                                                                            C1103.m3564(c348552222);
                                                                                            c348552222.f13423.m4474(e, "Error reading entries from local database");
                                                                                            c4421M3575.f16823 = true;
                                                                                            if (cursor2 != null) {
                                                                                            }
                                                                                            if (sQLiteDatabase != null) {
                                                                                            }
                                                                                            i14 = i2 + 1;
                                                                                            i13 = i3;
                                                                                            str6 = str2;
                                                                                            str5 = str3;
                                                                                            str7 = str;
                                                                                        }
                                                                                    } else {
                                                                                        cursor3 = cursorQuery2;
                                                                                        c0511 = c05113;
                                                                                        j2 = 0;
                                                                                        string = null;
                                                                                    }
                                                                                    if (i18 == 0) {
                                                                                        cursor2 = cursor3;
                                                                                        try {
                                                                                            try {
                                                                                                parcelObtain = Parcel.obtain();
                                                                                                try {
                                                                                                    try {
                                                                                                        parcelObtain.unmarshall(blob, 0, blob.length);
                                                                                                        parcelObtain.setDataPosition(0);
                                                                                                        C0357 c0357CreateFromParcel = C0357.CREATOR.createFromParcel(parcelObtain);
                                                                                                        if (c0357CreateFromParcel != null) {
                                                                                                            arrayList.add(new C3866(c0357CreateFromParcel, string, j2));
                                                                                                        }
                                                                                                    } catch (SafeParcelReader$ParseException unused6) {
                                                                                                        C3485 c34856 = c11034.f4729;
                                                                                                        C1103.m3564(c34856);
                                                                                                        c34856.f13423.m4476("Failed to load event from local database");
                                                                                                        parcelObtain.recycle();
                                                                                                    }
                                                                                                } finally {
                                                                                                }
                                                                                            } catch (Throwable th5) {
                                                                                                th = th5;
                                                                                                sQLiteDatabase = sQLiteDatabaseM9435;
                                                                                                cursor = cursor2;
                                                                                                if (cursor != null) {
                                                                                                }
                                                                                                if (sQLiteDatabase != null) {
                                                                                                }
                                                                                                throw th;
                                                                                            }
                                                                                        } catch (SQLiteDatabaseLockedException unused7) {
                                                                                            sQLiteDatabase = sQLiteDatabaseM9435;
                                                                                            i3 = 5;
                                                                                            SystemClock.sleep(i15);
                                                                                            i15 += 20;
                                                                                            if (cursor2 != null) {
                                                                                            }
                                                                                            if (sQLiteDatabase == null) {
                                                                                            }
                                                                                            i14 = i2 + 1;
                                                                                            i13 = i3;
                                                                                            str6 = str2;
                                                                                            str5 = str3;
                                                                                            str7 = str;
                                                                                        } catch (SQLiteFullException e11) {
                                                                                            e = e11;
                                                                                            sQLiteDatabase = sQLiteDatabaseM9435;
                                                                                            i3 = 5;
                                                                                            C3485 c3485422222 = c11034.f4729;
                                                                                            C1103.m3564(c3485422222);
                                                                                            c3485422222.f13423.m4474(e, "Error reading entries from local database");
                                                                                            c4421M3575.f16823 = true;
                                                                                            if (cursor2 != null) {
                                                                                            }
                                                                                            if (sQLiteDatabase != null) {
                                                                                            }
                                                                                            i14 = i2 + 1;
                                                                                            i13 = i3;
                                                                                            str6 = str2;
                                                                                            str5 = str3;
                                                                                            str7 = str;
                                                                                        } catch (SQLiteException e12) {
                                                                                            e = e12;
                                                                                            sQLiteDatabase = sQLiteDatabaseM9435;
                                                                                            i3 = 5;
                                                                                            if (sQLiteDatabase != null) {
                                                                                                sQLiteDatabase.endTransaction();
                                                                                            }
                                                                                            C3485 c3485522222 = c11034.f4729;
                                                                                            C1103.m3564(c3485522222);
                                                                                            c3485522222.f13423.m4474(e, "Error reading entries from local database");
                                                                                            c4421M3575.f16823 = true;
                                                                                            if (cursor2 != null) {
                                                                                            }
                                                                                            if (sQLiteDatabase != null) {
                                                                                            }
                                                                                            i14 = i2 + 1;
                                                                                            i13 = i3;
                                                                                            str6 = str2;
                                                                                            str5 = str3;
                                                                                            str7 = str;
                                                                                        }
                                                                                    } else {
                                                                                        cursor2 = cursor3;
                                                                                        if (i18 == 1) {
                                                                                            parcelObtain = Parcel.obtain();
                                                                                            try {
                                                                                                try {
                                                                                                    parcelObtain.unmarshall(blob, 0, blob.length);
                                                                                                    parcelObtain.setDataPosition(0);
                                                                                                    c0973CreateFromParcel = C0973.CREATOR.createFromParcel(parcelObtain);
                                                                                                } finally {
                                                                                                }
                                                                                            } catch (SafeParcelReader$ParseException unused8) {
                                                                                                C3485 c34857 = c11034.f4729;
                                                                                                C1103.m3564(c34857);
                                                                                                c34857.f13423.m4476("Failed to load user property from local database");
                                                                                                parcelObtain.recycle();
                                                                                                c0973CreateFromParcel = null;
                                                                                            }
                                                                                            if (c0973CreateFromParcel != null) {
                                                                                                arrayList.add(new C3866(c0973CreateFromParcel, string, j2));
                                                                                            }
                                                                                        } else if (i18 == 2) {
                                                                                            parcelObtain = Parcel.obtain();
                                                                                            try {
                                                                                                try {
                                                                                                    parcelObtain.unmarshall(blob, 0, blob.length);
                                                                                                    parcelObtain.setDataPosition(0);
                                                                                                    c3833CreateFromParcel = C3833.CREATOR.createFromParcel(parcelObtain);
                                                                                                } catch (SafeParcelReader$ParseException unused9) {
                                                                                                    C3485 c34858 = c11034.f4729;
                                                                                                    C1103.m3564(c34858);
                                                                                                    c34858.f13423.m4476("Failed to load conditional user property from local database");
                                                                                                    parcelObtain.recycle();
                                                                                                    c3833CreateFromParcel = null;
                                                                                                }
                                                                                                if (c3833CreateFromParcel != null) {
                                                                                                    arrayList.add(new C3866(c3833CreateFromParcel, string, j2));
                                                                                                }
                                                                                            } finally {
                                                                                            }
                                                                                        } else {
                                                                                            if (i18 == 4) {
                                                                                                try {
                                                                                                    parcelObtain = Parcel.obtain();
                                                                                                    try {
                                                                                                        try {
                                                                                                            try {
                                                                                                                parcelObtain.unmarshall(blob, 0, blob.length);
                                                                                                                parcelObtain.setDataPosition(0);
                                                                                                                c3590CreateFromParcel = C3590.CREATOR.createFromParcel(parcelObtain);
                                                                                                            } catch (Throwable th6) {
                                                                                                                th = th6;
                                                                                                                throw th;
                                                                                                            }
                                                                                                        } catch (SafeParcelReader$ParseException unused10) {
                                                                                                            C3485 c34859 = c11034.f4729;
                                                                                                            C1103.m3564(c34859);
                                                                                                            c34859.f13423.m4476("Failed to load default event parameters from local database");
                                                                                                            parcelObtain.recycle();
                                                                                                            c3590CreateFromParcel = null;
                                                                                                        }
                                                                                                    } catch (SafeParcelReader$ParseException unused11) {
                                                                                                    } catch (Throwable th7) {
                                                                                                        th = th7;
                                                                                                    }
                                                                                                } catch (SQLiteDatabaseLockedException unused12) {
                                                                                                    sQLiteDatabase = sQLiteDatabaseM9435;
                                                                                                    i3 = 5;
                                                                                                    SystemClock.sleep(i15);
                                                                                                    i15 += 20;
                                                                                                    if (cursor2 != null) {
                                                                                                    }
                                                                                                    if (sQLiteDatabase == null) {
                                                                                                    }
                                                                                                    i14 = i2 + 1;
                                                                                                    i13 = i3;
                                                                                                    str6 = str2;
                                                                                                    str5 = str3;
                                                                                                    str7 = str;
                                                                                                } catch (SQLiteFullException e13) {
                                                                                                    e = e13;
                                                                                                    sQLiteDatabase = sQLiteDatabaseM9435;
                                                                                                    i3 = 5;
                                                                                                    C3485 c34854222222 = c11034.f4729;
                                                                                                    C1103.m3564(c34854222222);
                                                                                                    c34854222222.f13423.m4474(e, "Error reading entries from local database");
                                                                                                    c4421M3575.f16823 = true;
                                                                                                    if (cursor2 != null) {
                                                                                                    }
                                                                                                    if (sQLiteDatabase != null) {
                                                                                                    }
                                                                                                    i14 = i2 + 1;
                                                                                                    i13 = i3;
                                                                                                    str6 = str2;
                                                                                                    str5 = str3;
                                                                                                    str7 = str;
                                                                                                } catch (SQLiteException e14) {
                                                                                                    e = e14;
                                                                                                    sQLiteDatabase = sQLiteDatabaseM9435;
                                                                                                    i3 = 5;
                                                                                                    if (sQLiteDatabase != null) {
                                                                                                    }
                                                                                                    C3485 c34855222222 = c11034.f4729;
                                                                                                    C1103.m3564(c34855222222);
                                                                                                    c34855222222.f13423.m4474(e, "Error reading entries from local database");
                                                                                                    c4421M3575.f16823 = true;
                                                                                                    if (cursor2 != null) {
                                                                                                    }
                                                                                                    if (sQLiteDatabase != null) {
                                                                                                    }
                                                                                                    i14 = i2 + 1;
                                                                                                    i13 = i3;
                                                                                                    str6 = str2;
                                                                                                    str5 = str3;
                                                                                                    str7 = str;
                                                                                                }
                                                                                                try {
                                                                                                    if (c3590CreateFromParcel != null) {
                                                                                                        arrayList.add(new C3866(c3590CreateFromParcel, string, j2));
                                                                                                    }
                                                                                                    i5 = 3;
                                                                                                } catch (SQLiteDatabaseLockedException unused13) {
                                                                                                    sQLiteDatabase = sQLiteDatabaseM9435;
                                                                                                    i3 = 5;
                                                                                                    SystemClock.sleep(i15);
                                                                                                    i15 += 20;
                                                                                                    if (cursor2 != null) {
                                                                                                    }
                                                                                                    if (sQLiteDatabase == null) {
                                                                                                    }
                                                                                                    i14 = i2 + 1;
                                                                                                    i13 = i3;
                                                                                                    str6 = str2;
                                                                                                    str5 = str3;
                                                                                                    str7 = str;
                                                                                                } catch (SQLiteFullException e15) {
                                                                                                    e = e15;
                                                                                                    sQLiteDatabase = sQLiteDatabaseM9435;
                                                                                                    i3 = 5;
                                                                                                    C3485 c348542222222 = c11034.f4729;
                                                                                                    C1103.m3564(c348542222222);
                                                                                                    c348542222222.f13423.m4474(e, "Error reading entries from local database");
                                                                                                    c4421M3575.f16823 = true;
                                                                                                    if (cursor2 != null) {
                                                                                                    }
                                                                                                    if (sQLiteDatabase != null) {
                                                                                                    }
                                                                                                    i14 = i2 + 1;
                                                                                                    i13 = i3;
                                                                                                    str6 = str2;
                                                                                                    str5 = str3;
                                                                                                    str7 = str;
                                                                                                } catch (SQLiteException e16) {
                                                                                                    e = e16;
                                                                                                    sQLiteDatabase = sQLiteDatabaseM9435;
                                                                                                    i3 = 5;
                                                                                                    if (sQLiteDatabase != null) {
                                                                                                    }
                                                                                                    C3485 c348552222222 = c11034.f4729;
                                                                                                    C1103.m3564(c348552222222);
                                                                                                    c348552222222.f13423.m4474(e, "Error reading entries from local database");
                                                                                                    c4421M3575.f16823 = true;
                                                                                                    if (cursor2 != null) {
                                                                                                    }
                                                                                                    if (sQLiteDatabase != null) {
                                                                                                    }
                                                                                                    i14 = i2 + 1;
                                                                                                    i13 = i3;
                                                                                                    str6 = str2;
                                                                                                    str5 = str3;
                                                                                                    str7 = str;
                                                                                                }
                                                                                            } else {
                                                                                                C3485 c348510 = c11034.f4729;
                                                                                                i5 = 3;
                                                                                                if (i18 == 3) {
                                                                                                    C1103.m3564(c348510);
                                                                                                    c348510.f13414.m4476("Skipping app launch break");
                                                                                                } else {
                                                                                                    C1103.m3564(c348510);
                                                                                                    c348510.f13423.m4476("Unknown record type in local database");
                                                                                                }
                                                                                            }
                                                                                            i17 = i5;
                                                                                            str6 = str2;
                                                                                            str5 = str3;
                                                                                            c05113 = c0511;
                                                                                            cursorQuery2 = cursor2;
                                                                                            i16 = 4;
                                                                                        }
                                                                                    }
                                                                                    i5 = 3;
                                                                                    i17 = i5;
                                                                                    str6 = str2;
                                                                                    str5 = str3;
                                                                                    c05113 = c0511;
                                                                                    cursorQuery2 = cursor2;
                                                                                    i16 = 4;
                                                                                } catch (SQLiteDatabaseLockedException unused14) {
                                                                                    cursor2 = cursorQuery2;
                                                                                } catch (SQLiteFullException e17) {
                                                                                    e = e17;
                                                                                    cursor2 = cursorQuery2;
                                                                                } catch (SQLiteException e18) {
                                                                                    e = e18;
                                                                                    cursor2 = cursorQuery2;
                                                                                }
                                                                            } catch (SQLiteDatabaseLockedException unused15) {
                                                                                cursor2 = cursorQuery2;
                                                                                str3 = str5;
                                                                                sQLiteDatabase = sQLiteDatabaseM9435;
                                                                                i3 = 5;
                                                                                SystemClock.sleep(i15);
                                                                                i15 += 20;
                                                                                if (cursor2 != null) {
                                                                                }
                                                                                if (sQLiteDatabase == null) {
                                                                                }
                                                                                i14 = i2 + 1;
                                                                                i13 = i3;
                                                                                str6 = str2;
                                                                                str5 = str3;
                                                                                str7 = str;
                                                                            } catch (SQLiteFullException e19) {
                                                                                e = e19;
                                                                                cursor2 = cursorQuery2;
                                                                                str3 = str5;
                                                                                sQLiteDatabase = sQLiteDatabaseM9435;
                                                                                i3 = 5;
                                                                                C3485 c3485422222222 = c11034.f4729;
                                                                                C1103.m3564(c3485422222222);
                                                                                c3485422222222.f13423.m4474(e, "Error reading entries from local database");
                                                                                c4421M3575.f16823 = true;
                                                                                if (cursor2 != null) {
                                                                                }
                                                                                if (sQLiteDatabase != null) {
                                                                                }
                                                                                i14 = i2 + 1;
                                                                                i13 = i3;
                                                                                str6 = str2;
                                                                                str5 = str3;
                                                                                str7 = str;
                                                                            } catch (SQLiteException e20) {
                                                                                e = e20;
                                                                                cursor2 = cursorQuery2;
                                                                                str3 = str5;
                                                                                sQLiteDatabase = sQLiteDatabaseM9435;
                                                                                i3 = 5;
                                                                                if (sQLiteDatabase != null) {
                                                                                }
                                                                                C3485 c3485522222222 = c11034.f4729;
                                                                                C1103.m3564(c3485522222222);
                                                                                c3485522222222.f13423.m4474(e, "Error reading entries from local database");
                                                                                c4421M3575.f16823 = true;
                                                                                if (cursor2 != null) {
                                                                                }
                                                                                if (sQLiteDatabase != null) {
                                                                                }
                                                                                i14 = i2 + 1;
                                                                                i13 = i3;
                                                                                str6 = str2;
                                                                                str5 = str3;
                                                                                str7 = str;
                                                                            }
                                                                        } catch (SQLiteDatabaseLockedException unused16) {
                                                                            cursor2 = cursorQuery2;
                                                                            str2 = str6;
                                                                        } catch (SQLiteFullException e21) {
                                                                            e = e21;
                                                                            cursor2 = cursorQuery2;
                                                                            str2 = str6;
                                                                        } catch (SQLiteException e22) {
                                                                            e = e22;
                                                                            cursor2 = cursorQuery2;
                                                                            str2 = str6;
                                                                        }
                                                                    } catch (SQLiteDatabaseLockedException unused17) {
                                                                        cursor2 = cursorQuery2;
                                                                        str2 = str6;
                                                                        str3 = str5;
                                                                    } catch (SQLiteFullException e23) {
                                                                        e = e23;
                                                                        cursor2 = cursorQuery2;
                                                                        str2 = str6;
                                                                        str3 = str5;
                                                                    } catch (SQLiteException e24) {
                                                                        e = e24;
                                                                        cursor2 = cursorQuery2;
                                                                        str2 = str6;
                                                                        str3 = str5;
                                                                    }
                                                                } catch (Throwable th8) {
                                                                    th = th8;
                                                                    cursor2 = cursorQuery2;
                                                                }
                                                            } catch (SQLiteDatabaseLockedException unused18) {
                                                                cursor2 = cursorQuery2;
                                                                str2 = str6;
                                                                str3 = str5;
                                                            } catch (SQLiteFullException e25) {
                                                                e = e25;
                                                                cursor2 = cursorQuery2;
                                                                str2 = str6;
                                                                str3 = str5;
                                                            } catch (SQLiteException e26) {
                                                                e = e26;
                                                                cursor2 = cursorQuery2;
                                                                str2 = str6;
                                                                str3 = str5;
                                                            }
                                                        }
                                                        cursor2 = cursorQuery2;
                                                        str2 = str6;
                                                        str3 = str5;
                                                        i = 0;
                                                        sQLiteDatabase = sQLiteDatabaseM9435;
                                                    } catch (SQLiteDatabaseLockedException unused19) {
                                                        str3 = str5;
                                                        sQLiteDatabase = sQLiteDatabaseM9435;
                                                        str2 = str6;
                                                        i3 = i4;
                                                        cursor2 = null;
                                                        SystemClock.sleep(i15);
                                                        i15 += 20;
                                                        if (cursor2 != null) {
                                                            cursor2.close();
                                                        }
                                                        if (sQLiteDatabase == null) {
                                                            sQLiteDatabase.close();
                                                        }
                                                        i14 = i2 + 1;
                                                        i13 = i3;
                                                        str6 = str2;
                                                        str5 = str3;
                                                        str7 = str;
                                                    }
                                                } catch (SQLiteDatabaseLockedException unused20) {
                                                    str3 = str5;
                                                    sQLiteDatabase = sQLiteDatabaseM9435;
                                                    str2 = str6;
                                                    i3 = 5;
                                                    cursor2 = null;
                                                    SystemClock.sleep(i15);
                                                    i15 += 20;
                                                    if (cursor2 != null) {
                                                    }
                                                    if (sQLiteDatabase == null) {
                                                    }
                                                    i14 = i2 + 1;
                                                    i13 = i3;
                                                    str6 = str2;
                                                    str5 = str3;
                                                    str7 = str;
                                                }
                                                try {
                                                    if (sQLiteDatabase.delete("messages", "rowid <= ?", new String[]{Long.toString(j4)}) < arrayList.size()) {
                                                        C3485 c348511 = c11034.f4729;
                                                        C1103.m3564(c348511);
                                                        c348511.f13423.m4476("Fewer entries removed from local database than expected");
                                                    }
                                                    sQLiteDatabase.setTransactionSuccessful();
                                                    sQLiteDatabase.endTransaction();
                                                    cursor2.close();
                                                    sQLiteDatabase.close();
                                                } catch (SQLiteDatabaseLockedException unused21) {
                                                    i3 = 5;
                                                    SystemClock.sleep(i15);
                                                    i15 += 20;
                                                    if (cursor2 != null) {
                                                    }
                                                    if (sQLiteDatabase == null) {
                                                    }
                                                    i14 = i2 + 1;
                                                    i13 = i3;
                                                    str6 = str2;
                                                    str5 = str3;
                                                    str7 = str;
                                                } catch (SQLiteFullException e27) {
                                                    e = e27;
                                                    i3 = 5;
                                                    C3485 c34854222222222 = c11034.f4729;
                                                    C1103.m3564(c34854222222222);
                                                    c34854222222222.f13423.m4474(e, "Error reading entries from local database");
                                                    c4421M3575.f16823 = true;
                                                    if (cursor2 != null) {
                                                    }
                                                    if (sQLiteDatabase != null) {
                                                    }
                                                    i14 = i2 + 1;
                                                    i13 = i3;
                                                    str6 = str2;
                                                    str5 = str3;
                                                    str7 = str;
                                                } catch (SQLiteException e28) {
                                                    e = e28;
                                                    i3 = 5;
                                                    if (sQLiteDatabase != null) {
                                                    }
                                                    C3485 c34855222222222 = c11034.f4729;
                                                    C1103.m3564(c34855222222222);
                                                    c34855222222222.f13423.m4474(e, "Error reading entries from local database");
                                                    c4421M3575.f16823 = true;
                                                    if (cursor2 != null) {
                                                    }
                                                    if (sQLiteDatabase != null) {
                                                    }
                                                    i14 = i2 + 1;
                                                    i13 = i3;
                                                    str6 = str2;
                                                    str5 = str3;
                                                    str7 = str;
                                                }
                                            } catch (SQLiteFullException e29) {
                                                e = e29;
                                                str3 = str5;
                                                sQLiteDatabase = sQLiteDatabaseM9435;
                                                str2 = str6;
                                                i3 = 5;
                                                cursor2 = null;
                                                C3485 c348542222222222 = c11034.f4729;
                                                C1103.m3564(c348542222222222);
                                                c348542222222222.f13423.m4474(e, "Error reading entries from local database");
                                                c4421M3575.f16823 = true;
                                                if (cursor2 != null) {
                                                }
                                                if (sQLiteDatabase != null) {
                                                }
                                                i14 = i2 + 1;
                                                i13 = i3;
                                                str6 = str2;
                                                str5 = str3;
                                                str7 = str;
                                            } catch (SQLiteException e30) {
                                                e = e30;
                                                str3 = str5;
                                                sQLiteDatabase = sQLiteDatabaseM9435;
                                                str2 = str6;
                                                i3 = 5;
                                                cursor2 = null;
                                                if (sQLiteDatabase != null) {
                                                }
                                                C3485 c348552222222222 = c11034.f4729;
                                                C1103.m3564(c348552222222222);
                                                c348552222222222.f13423.m4474(e, "Error reading entries from local database");
                                                c4421M3575.f16823 = true;
                                                if (cursor2 != null) {
                                                }
                                                if (sQLiteDatabase != null) {
                                                }
                                                i14 = i2 + 1;
                                                i13 = i3;
                                                str6 = str2;
                                                str5 = str3;
                                                str7 = str;
                                            }
                                        } catch (SQLiteDatabaseLockedException unused22) {
                                            str = str7;
                                        } catch (SQLiteFullException e31) {
                                            e = e31;
                                            str = str7;
                                        } catch (SQLiteException e32) {
                                            e = e32;
                                            str = str7;
                                        }
                                    } catch (Throwable th9) {
                                        th = th9;
                                        i2 = i14;
                                    }
                                } catch (Throwable th10) {
                                    th = th10;
                                    i2 = i14;
                                    str = str7;
                                    str3 = str5;
                                    sQLiteDatabase = sQLiteDatabaseM9435;
                                    i3 = 5;
                                    str2 = str6;
                                    cursorQuery = null;
                                }
                            }
                        } catch (SQLiteDatabaseLockedException unused23) {
                            i2 = i14;
                            str = str7;
                            str2 = str6;
                            str3 = str5;
                            i3 = 5;
                            sQLiteDatabase = null;
                        } catch (SQLiteFullException e33) {
                            e = e33;
                            i2 = i14;
                            str = str7;
                            str2 = str6;
                            str3 = str5;
                            i3 = 5;
                            sQLiteDatabase = null;
                        } catch (SQLiteException e34) {
                            e = e34;
                            i2 = i14;
                            str = str7;
                            str2 = str6;
                            str3 = str5;
                            i3 = 5;
                            sQLiteDatabase = null;
                        } catch (Throwable th11) {
                            th = th11;
                            sQLiteDatabase = null;
                        }
                    }
                    i = 0;
                    C3485 c348512 = c11034.f4729;
                    C1103.m3564(c348512);
                    c348512.f13424.m4476("Failed to read events from database in reasonable time");
                    arrayList = null;
                } else {
                    context = context3;
                    c3485 = c34853;
                    i = 0;
                }
                if (arrayList == null) {
                    arrayList2.addAll(arrayList);
                    size = arrayList.size();
                } else {
                    size = i;
                }
                if (abstractC0106 != null && size < i11) {
                    arrayList2.add(new C3866(abstractC0106, c28472.f10915, c28472.f10914));
                }
                size2 = arrayList2.size();
                i6 = i;
                while (i6 < size2) {
                    C3866 c3866 = (C3866) arrayList2.get(i6);
                    AbstractC0106 abstractC01062 = c3866.f14770;
                    C0511 c05114 = AbstractC3818.f14493;
                    if (c3691.m8314(null, c05114)) {
                        String str8 = c3866.f14768;
                        if (TextUtils.isEmpty(str8)) {
                            i7 = size;
                            c05112 = c05114;
                        } else {
                            c05112 = c05114;
                            i7 = size;
                            c28472 = new C2847(c28472.f10910, c28472.f10918, str8, c3866.f14769, c28472.f10924, c28472.f10925, c28472.f10927, c28472.f10904, c28472.f10911, c28472.f10928, c28472.f10898, c28472.f10920, c28472.f10906, c28472.f10903, c28472.f10901, c28472.f10909, c28472.f10908, c28472.f10917, c28472.f10926, c28472.f10913, c28472.f10897, c28472.f10905, c28472.f10923, c28472.f10919, c28472.f10907, c28472.f10902, c28472.f10900, c28472.f10912, c28472.f10916, c28472.f10899, c28472.f10921, c28472.f10922);
                        }
                    }
                    if (abstractC01062 instanceof C0357) {
                        try {
                            r17.getClass();
                            long jCurrentTimeMillis = System.currentTimeMillis();
                            try {
                                r17.getClass();
                                jElapsedRealtime = SystemClock.elapsedRealtime();
                                try {
                                    try {
                                        interfaceC0071.mo1108((C0357) abstractC01062, c28472);
                                        C1103.m3564(c3485);
                                        c34852 = c3485;
                                        try {
                                            c34852.f13414.m4476("Logging telemetry for logEvent from database");
                                            if (C2994.f11532 == null) {
                                                c11032 = c1103;
                                                context2 = context;
                                                try {
                                                    C2994.f11532 = new C2994(context2, c11032);
                                                } catch (RemoteException e35) {
                                                    e = e35;
                                                    j3 = jCurrentTimeMillis;
                                                    C1103.m3564(c34852);
                                                    c34852.f13423.m4474(e, "Failed to send event to the service");
                                                    if (j3 != 0) {
                                                        if (C2994.f11532 == null) {
                                                            C2994.f11532 = new C2994(context2, c11032);
                                                        }
                                                        C2994 c2994 = C2994.f11532;
                                                        r17.getClass();
                                                        long jCurrentTimeMillis2 = System.currentTimeMillis();
                                                        r17.getClass();
                                                        c2994.m7079(13, (int) (SystemClock.elapsedRealtime() - jElapsedRealtime), j3, jCurrentTimeMillis2);
                                                    }
                                                }
                                            } else {
                                                c11032 = c1103;
                                                context2 = context;
                                            }
                                            C2994 c29942 = C2994.f11532;
                                            r17.getClass();
                                            long jCurrentTimeMillis3 = System.currentTimeMillis();
                                            r17.getClass();
                                            c29942.m7079(0, (int) (SystemClock.elapsedRealtime() - jElapsedRealtime), jCurrentTimeMillis, jCurrentTimeMillis3);
                                        } catch (RemoteException e36) {
                                            e = e36;
                                            c11032 = c1103;
                                            context2 = context;
                                        }
                                    } catch (RemoteException e37) {
                                        e = e37;
                                        c11032 = c1103;
                                        context2 = context;
                                        c34852 = c3485;
                                        j3 = jCurrentTimeMillis;
                                        C1103.m3564(c34852);
                                        c34852.f13423.m4474(e, "Failed to send event to the service");
                                        if (j3 != 0) {
                                        }
                                        i6++;
                                        c3485 = c34852;
                                        c1103 = c11032;
                                        context = context2;
                                        size = i7;
                                    }
                                } catch (RemoteException e38) {
                                    e = e38;
                                }
                            } catch (RemoteException e39) {
                                e = e39;
                                c11032 = c1103;
                                context2 = context;
                                c34852 = c3485;
                                jElapsedRealtime = 0;
                            }
                        } catch (RemoteException e40) {
                            e = e40;
                            c11032 = c1103;
                            context2 = context;
                            c34852 = c3485;
                            jElapsedRealtime = 0;
                            j3 = 0;
                        }
                    } else {
                        c11032 = c1103;
                        context2 = context;
                        c34852 = c3485;
                        if (abstractC01062 instanceof C0973) {
                            try {
                                interfaceC0071.mo1090((C0973) abstractC01062, c28472);
                            } catch (RemoteException e41) {
                                C1103.m3564(c34852);
                                c34852.f13423.m4474(e41, "Failed to send user property to the service");
                            }
                        } else if (abstractC01062 instanceof C3833) {
                            try {
                                interfaceC0071.mo1095((C3833) abstractC01062, c28472);
                            } catch (RemoteException e42) {
                                C1103.m3564(c34852);
                                c34852.f13423.m4474(e42, "Failed to send conditional user property to the service");
                            }
                        } else {
                            if (c3691.m8314(null, c05112) && (abstractC01062 instanceof C3590)) {
                                try {
                                    interfaceC0071.mo1100(((C3590) abstractC01062).m8121(), c28472);
                                } catch (RemoteException e43) {
                                    C1103.m3564(c34852);
                                    c34852.f13423.m4474(e43, "Failed to send default event parameters to the service");
                                }
                            } else {
                                C1103.m3564(c34852);
                                c34852.f13423.m4476("Discarding data. Unrecognized parcel type.");
                            }
                            i6++;
                            c3485 = c34852;
                            c1103 = c11032;
                            context = context2;
                            size = i7;
                        }
                    }
                    i6++;
                    c3485 = c34852;
                    c1103 = c11032;
                    context = context2;
                    size = i7;
                }
                c34853 = c3485;
                c11033 = c1103;
                context3 = context;
                r7 = r17;
                i8 = 100;
                i9 = i12 + 1;
            }
            i = 0;
            arrayList = null;
            if (arrayList == null) {
            }
            if (abstractC0106 != null) {
                arrayList2.add(new C3866(abstractC0106, c28472.f10915, c28472.f10914));
            }
            size2 = arrayList2.size();
            i6 = i;
            while (i6 < size2) {
            }
            c34853 = c3485;
            c11033 = c1103;
            context3 = context;
            r7 = r17;
            i8 = 100;
            i9 = i12 + 1;
        }
    }

    /* JADX INFO: renamed from: ˊᵡᵗʨ, reason: contains not printable characters */
    public final boolean m4465() {
        m6166();
        m5699();
        if (!m4461()) {
            return true;
        }
        C3335 c3335 = ((C1103) ((ᵜᵪʾ) this).ˌᴵ).f4730;
        C1103.m3567(c3335);
        return c3335.m7667() >= 241200;
    }

    /* JADX INFO: renamed from: ˊᵾʽʼ, reason: contains not printable characters */
    public final boolean m4466() {
        m6166();
        m5699();
        if (!m4461()) {
            return true;
        }
        C3335 c3335 = ((C1103) ((ᵜᵪʾ) this).ˌᴵ).f4730;
        C1103.m3567(c3335);
        return c3335.m7667() >= ((Integer) AbstractC3818.f14511.m1988(null)).intValue();
    }

    /* JADX INFO: renamed from: ˑʢ, reason: contains not printable characters */
    public final void m4467() {
        m6166();
        C1705 c1705 = this.f6475;
        ((ᵠʽᵲ) c1705.f6817).getClass();
        c1705.f6818 = SystemClock.elapsedRealtime();
        ((C1103) ((ᵜᵪʾ) this).ˌᴵ).getClass();
        this.f6480.m9539(((Long) AbstractC3818.f14546.m1988(null)).longValue());
    }

    @Override // defpackage.AbstractC2191
    /* JADX INFO: renamed from: ˑˊᵲ */
    public final boolean mo4346() {
        return false;
    }

    /* JADX INFO: renamed from: ᵛˑﹳ, reason: contains not printable characters */
    public final void m4468(ComponentName componentName) {
        m6166();
        if (this.f6478 != null) {
            this.f6478 = null;
            C3485 c3485 = ((C1103) ((ᵜᵪʾ) this).ˌᴵ).f4729;
            C1103.m3564(c3485);
            c3485.f13414.m4474(componentName, "Disconnected from device MeasurementService");
            m6166();
            m4463();
        }
    }

    /* JADX INFO: renamed from: ᵞᵛᵘ, reason: contains not printable characters */
    public final boolean m4469() {
        m6166();
        m5699();
        return this.f6478 != null;
    }

    /* JADX WARN: Removed duplicated region for block: B:13:0x0056  */
    /* JADX WARN: Removed duplicated region for block: B:14:0x0059  */
    /* JADX INFO: renamed from: ᵠˏˏ, reason: contains not printable characters */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final void m4470(Bundle bundle) {
        boolean z;
        boolean zM9434;
        m6166();
        m5699();
        C3590 c3590 = new C3590(bundle);
        m4472();
        C1103 c1103 = (C1103) ((ᵜᵪʾ) this).ˌᴵ;
        if (c1103.f4726.m8314(null, AbstractC3818.f14493)) {
            C4421 c4421M3575 = c1103.m3575();
            C1103 c11032 = (C1103) ((ᵜᵪʾ) c4421M3575).ˌᴵ;
            C3335 c3335 = c11032.f4730;
            C3485 c3485 = c11032.f4729;
            C1103.m3567(c3335);
            byte[] bArrM7616 = C3335.m7616(c3590);
            if (bArrM7616 == null) {
                C1103.m3564(c3485);
                c3485.f13415.m4476("Null default event parameters; not writing to database");
            } else if (bArrM7616.length > 131072) {
                C1103.m3564(c3485);
                c3485.f13415.m4476("Default event parameters too long for local database. Sending directly to service");
            } else {
                zM9434 = c4421M3575.m9434(4, bArrM7616);
                z = !zM9434;
            }
            zM9434 = false;
            if (!zM9434) {
            }
        }
        m4457(new RunnableC1505(this, m4471(false), z, c3590, bundle));
    }

    /* JADX WARN: Removed duplicated region for block: B:25:0x00a1  */
    /* JADX INFO: renamed from: ᵨˈʼﹶ, reason: contains not printable characters */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final C2847 m4471(boolean z) {
        long jAbs;
        Pair pair;
        C1103 c1103 = (C1103) ((ᵜᵪʾ) this).ˌᴵ;
        c1103.getClass();
        C2303 c2303M3569 = c1103.m3569();
        String strM2864 = null;
        if (z) {
            C3485 c3485 = c1103.f4729;
            C1103.m3564(c3485);
            C1103 c11032 = (C1103) ((ᵜᵪʾ) c3485).ˌᴵ;
            C3740 c3740 = c11032.f4727;
            C1103.m3567(c3740);
            if (c3740.f14217 != null) {
                C3740 c37402 = c11032.f4727;
                C1103.m3567(c37402);
                C5227 c5227 = c37402.f14217;
                C3740 c37403 = (C3740) c5227.f19716;
                c37403.ˈᵲᵢ();
                c37403.ˈᵲᵢ();
                long j = ((C3740) c5227.f19716).m8407().getLong((String) c5227.f19712, 0L);
                if (j == 0) {
                    c5227.m10790();
                    jAbs = 0;
                } else {
                    ((C1103) ((ᵜᵪʾ) c37403).ˌᴵ).f4701.getClass();
                    jAbs = Math.abs(j - System.currentTimeMillis());
                }
                long j2 = c5227.f19713;
                if (jAbs < j2) {
                    pair = null;
                    if (pair != null) {
                    }
                } else if (jAbs > j2 + j2) {
                    c5227.m10790();
                    pair = null;
                    if (pair != null && pair != C3740.f14197) {
                        String strValueOf = String.valueOf(pair.second);
                        String str = (String) pair.first;
                        strM2864 = AbstractC0793.m2864(new StringBuilder(strValueOf.length() + 1 + String.valueOf(str).length()), strValueOf, ":", str);
                    }
                } else {
                    String string = c37403.m8407().getString((String) c5227.f19715, null);
                    long j3 = c37403.m8407().getLong((String) c5227.f19714, 0L);
                    c5227.m10790();
                    pair = (string == null || j3 <= 0) ? C3740.f14197 : new Pair(string, Long.valueOf(j3));
                    if (pair != null) {
                        String strValueOf2 = String.valueOf(pair.second);
                        String str2 = (String) pair.first;
                        strM2864 = AbstractC0793.m2864(new StringBuilder(strValueOf2.length() + 1 + String.valueOf(str2).length()), strValueOf2, ":", str2);
                    }
                }
            }
        }
        return c2303M3569.m5930(strM2864);
    }

    /* JADX INFO: renamed from: ᵵᵬᵽ, reason: contains not printable characters */
    public final void m4472() {
        ((C1103) ((ᵜᵪʾ) this).ˌᴵ).getClass();
    }
}
