package defpackage;

import android.content.ContentValues;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteException;
import android.os.Bundle;
import android.os.Parcelable;
import android.os.SystemClock;
import android.text.TextUtils;
import j$.util.DesugarCollections;
import j$.util.Objects;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Locale;
import java.util.Map;

/* JADX INFO: renamed from: ˎˁʿ, reason: contains not printable characters */
/* JADX INFO: loaded from: classes3.dex */
public final class C1694 extends AbstractC1850 {

    /* JADX INFO: renamed from: ᵨᵼⁱ, reason: contains not printable characters */
    public final C3760 f6692;

    /* JADX INFO: renamed from: ᵯᵷʽ, reason: contains not printable characters */
    public final C1705 f6693;

    /* JADX INFO: renamed from: ᵶˇᵱ, reason: contains not printable characters */
    public static final String[] f6690 = {"last_bundled_timestamp", "ALTER TABLE events ADD COLUMN last_bundled_timestamp INTEGER;", "last_bundled_day", "ALTER TABLE events ADD COLUMN last_bundled_day INTEGER;", "last_sampled_complex_event_id", "ALTER TABLE events ADD COLUMN last_sampled_complex_event_id INTEGER;", "last_sampling_rate", "ALTER TABLE events ADD COLUMN last_sampling_rate INTEGER;", "last_exempt_from_sampling", "ALTER TABLE events ADD COLUMN last_exempt_from_sampling INTEGER;", "current_session_count", "ALTER TABLE events ADD COLUMN current_session_count INTEGER;"};

    /* JADX INFO: renamed from: ˈᵲᵢ, reason: contains not printable characters */
    public static final String[] f6684 = {"associated_row_id", "ALTER TABLE upload_queue ADD COLUMN associated_row_id INTEGER;", "last_upload_timestamp", "ALTER TABLE upload_queue ADD COLUMN last_upload_timestamp INTEGER;"};

    /* JADX INFO: renamed from: ˌᵨʠᵫ, reason: contains not printable characters */
    public static final String[] f6687 = {"origin", "ALTER TABLE user_attributes ADD COLUMN origin TEXT;"};

    /* JADX INFO: renamed from: ᵸˆˁ, reason: contains not printable characters */
    public static final String[] f6691 = {"app_version", "ALTER TABLE apps ADD COLUMN app_version TEXT;", "app_store", "ALTER TABLE apps ADD COLUMN app_store TEXT;", "gmp_version", "ALTER TABLE apps ADD COLUMN gmp_version INTEGER;", "dev_cert_hash", "ALTER TABLE apps ADD COLUMN dev_cert_hash INTEGER;", "measurement_enabled", "ALTER TABLE apps ADD COLUMN measurement_enabled INTEGER;", "last_bundle_start_timestamp", "ALTER TABLE apps ADD COLUMN last_bundle_start_timestamp INTEGER;", "day", "ALTER TABLE apps ADD COLUMN day INTEGER;", "daily_public_events_count", "ALTER TABLE apps ADD COLUMN daily_public_events_count INTEGER;", "daily_events_count", "ALTER TABLE apps ADD COLUMN daily_events_count INTEGER;", "daily_conversions_count", "ALTER TABLE apps ADD COLUMN daily_conversions_count INTEGER;", "remote_config", "ALTER TABLE apps ADD COLUMN remote_config BLOB;", "config_fetched_time", "ALTER TABLE apps ADD COLUMN config_fetched_time INTEGER;", "failed_config_fetch_time", "ALTER TABLE apps ADD COLUMN failed_config_fetch_time INTEGER;", "app_version_int", "ALTER TABLE apps ADD COLUMN app_version_int INTEGER;", "firebase_instance_id", "ALTER TABLE apps ADD COLUMN firebase_instance_id TEXT;", "daily_error_events_count", "ALTER TABLE apps ADD COLUMN daily_error_events_count INTEGER;", "daily_realtime_events_count", "ALTER TABLE apps ADD COLUMN daily_realtime_events_count INTEGER;", "health_monitor_sample", "ALTER TABLE apps ADD COLUMN health_monitor_sample TEXT;", "android_id", "ALTER TABLE apps ADD COLUMN android_id INTEGER;", "adid_reporting_enabled", "ALTER TABLE apps ADD COLUMN adid_reporting_enabled INTEGER;", "ssaid_reporting_enabled", "ALTER TABLE apps ADD COLUMN ssaid_reporting_enabled INTEGER;", "admob_app_id", "ALTER TABLE apps ADD COLUMN admob_app_id TEXT;", "linked_admob_app_id", "ALTER TABLE apps ADD COLUMN linked_admob_app_id TEXT;", "dynamite_version", "ALTER TABLE apps ADD COLUMN dynamite_version INTEGER;", "safelisted_events", "ALTER TABLE apps ADD COLUMN safelisted_events TEXT;", "ga_app_id", "ALTER TABLE apps ADD COLUMN ga_app_id TEXT;", "config_last_modified_time", "ALTER TABLE apps ADD COLUMN config_last_modified_time TEXT;", "e_tag", "ALTER TABLE apps ADD COLUMN e_tag TEXT;", "session_stitching_token", "ALTER TABLE apps ADD COLUMN session_stitching_token TEXT;", "sgtm_upload_enabled", "ALTER TABLE apps ADD COLUMN sgtm_upload_enabled INTEGER;", "target_os_version", "ALTER TABLE apps ADD COLUMN target_os_version INTEGER;", "session_stitching_token_hash", "ALTER TABLE apps ADD COLUMN session_stitching_token_hash INTEGER;", "ad_services_version", "ALTER TABLE apps ADD COLUMN ad_services_version INTEGER;", "unmatched_first_open_without_ad_id", "ALTER TABLE apps ADD COLUMN unmatched_first_open_without_ad_id INTEGER;", "npa_metadata_value", "ALTER TABLE apps ADD COLUMN npa_metadata_value INTEGER;", "attribution_eligibility_status", "ALTER TABLE apps ADD COLUMN attribution_eligibility_status INTEGER;", "sgtm_preview_key", "ALTER TABLE apps ADD COLUMN sgtm_preview_key TEXT;", "dma_consent_state", "ALTER TABLE apps ADD COLUMN dma_consent_state INTEGER;", "daily_realtime_dcu_count", "ALTER TABLE apps ADD COLUMN daily_realtime_dcu_count INTEGER;", "bundle_delivery_index", "ALTER TABLE apps ADD COLUMN bundle_delivery_index INTEGER;", "serialized_npa_metadata", "ALTER TABLE apps ADD COLUMN serialized_npa_metadata TEXT;", "unmatched_pfo", "ALTER TABLE apps ADD COLUMN unmatched_pfo INTEGER;", "unmatched_uwa", "ALTER TABLE apps ADD COLUMN unmatched_uwa INTEGER;", "ad_campaign_info", "ALTER TABLE apps ADD COLUMN ad_campaign_info BLOB;", "daily_registered_triggers_count", "ALTER TABLE apps ADD COLUMN daily_registered_triggers_count INTEGER;", "client_upload_eligibility", "ALTER TABLE apps ADD COLUMN client_upload_eligibility INTEGER;", "gmp_version_for_remote_config", "ALTER TABLE apps ADD COLUMN gmp_version_for_remote_config INTEGER;", "last_diagnostics_signal_upload_timestamp", "ALTER TABLE apps ADD COLUMN last_diagnostics_signal_upload_timestamp INTEGER;"};

    /* JADX INFO: renamed from: ˑˊᵲ, reason: contains not printable characters */
    public static final String[] f6688 = {"realtime", "ALTER TABLE raw_events ADD COLUMN realtime INTEGER;", "elapsed_time", "ALTER TABLE raw_events ADD COLUMN elapsed_time INTEGER;"};

    /* JADX INFO: renamed from: ʿٴˇ, reason: contains not printable characters */
    public static final String[] f6681 = {"has_realtime", "ALTER TABLE queue ADD COLUMN has_realtime INTEGER;", "retry_count", "ALTER TABLE queue ADD COLUMN retry_count INTEGER;"};

    /* JADX INFO: renamed from: ᵠˏˏ, reason: contains not printable characters */
    public static final String[] f6689 = {"session_scoped", "ALTER TABLE event_filters ADD COLUMN session_scoped BOOLEAN;"};

    /* JADX INFO: renamed from: ˉᵵᵜ, reason: contains not printable characters */
    public static final String[] f6685 = {"session_scoped", "ALTER TABLE property_filters ADD COLUMN session_scoped BOOLEAN;"};

    /* JADX INFO: renamed from: ˁˌᵩ, reason: contains not printable characters */
    public static final String[] f6683 = {"previous_install_count", "ALTER TABLE app2 ADD COLUMN previous_install_count INTEGER;"};

    /* JADX INFO: renamed from: ˀᵭ, reason: contains not printable characters */
    public static final String[] f6682 = {"consent_source", "ALTER TABLE consent_settings ADD COLUMN consent_source INTEGER;", "dma_consent_settings", "ALTER TABLE consent_settings ADD COLUMN dma_consent_settings TEXT;", "storage_consent_at_bundling", "ALTER TABLE consent_settings ADD COLUMN storage_consent_at_bundling TEXT;"};

    /* JADX INFO: renamed from: ˊᵾʽʼ, reason: contains not printable characters */
    public static final String[] f6686 = {"idempotent", "CREATE INDEX IF NOT EXISTS trigger_uris_index ON trigger_uris (app_id);"};

    public C1694(C2894 c2894) {
        super(c2894);
        this.f6693 = new C1705(((C1103) ((ᵜᵪʾ) this).ˌᴵ).f4701);
        ((C1103) ((ᵜᵪʾ) this).ˌᴵ).getClass();
        this.f6692 = new C3760(this, ((C1103) ((ᵜᵪʾ) this).ˌᴵ).f4713);
    }

    /* JADX INFO: renamed from: ːᵝٴᵶ, reason: contains not printable characters */
    public static final String m4577(List list) {
        return list.isEmpty() ? "" : AbstractC3589.m8117(" AND (upload_type IN (", TextUtils.join(", ", list), "))");
    }

    /* JADX INFO: renamed from: ᵹʾᵢᵯ, reason: contains not printable characters */
    public static final void m4578(ContentValues contentValues, Object obj) {
        ᵘᵞʿⁱ.ˊᵫᵗ("value");
        ᵘᵞʿⁱ.ᵶᵥᵝ(obj);
        if (obj instanceof String) {
            contentValues.put("value", (String) obj);
            return;
        }
        if (obj instanceof Long) {
            contentValues.put("value", (Long) obj);
        } else if (obj instanceof Double) {
            contentValues.put("value", (Double) obj);
        } else {
            ᵕᵩʽᵲ.ᵮᵣᵗˈ("Invalid value type");
        }
    }

    /* JADX WARN: Removed duplicated region for block: B:17:0x0093 A[Catch: all -> 0x006d, SQLiteException -> 0x00a4, TryCatch #0 {SQLiteException -> 0x00a4, blocks: (B:15:0x0072, B:17:0x0093, B:20:0x00a6), top: B:30:0x0072 }] */
    /* JADX WARN: Removed duplicated region for block: B:20:0x00a6 A[Catch: all -> 0x006d, SQLiteException -> 0x00a4, TRY_LEAVE, TryCatch #0 {SQLiteException -> 0x00a4, blocks: (B:15:0x0072, B:17:0x0093, B:20:0x00a6), top: B:30:0x0072 }] */
    /* JADX INFO: renamed from: ʽᵡᵢᵾ, reason: contains not printable characters */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final long m4579(String str) {
        long j;
        long jM4582;
        ContentValues contentValues;
        C1103 c1103 = (C1103) ((ᵜᵪʾ) this).ˌᴵ;
        ᵘᵞʿⁱ.ˊᵫᵗ(str);
        ᵘᵞʿⁱ.ˊᵫᵗ("first_open_count");
        ˈᵲᵢ();
        m5026();
        SQLiteDatabase sQLiteDatabaseM4625 = m4625();
        sQLiteDatabaseM4625.beginTransaction();
        long j2 = 0;
        try {
            try {
                StringBuilder sb = new StringBuilder(48);
                sb.append("select first_open_count from app2 where app_id=?");
                j = -1;
                jM4582 = m4582(sb.toString(), new String[]{str}, -1L);
            } catch (SQLiteException e) {
                e = e;
            }
            if (jM4582 == -1) {
                ContentValues contentValues2 = new ContentValues();
                contentValues2.put("app_id", str);
                contentValues2.put("first_open_count", (Integer) 0);
                contentValues2.put("previous_install_count", (Integer) 0);
                if (sQLiteDatabaseM4625.insertWithOnConflict("app2", null, contentValues2, 5) == -1) {
                    C3485 c3485 = c1103.f4729;
                    C1103.m3564(c3485);
                    c3485.f13423.m4475("Failed to insert column (got -1). appId", C3485.m7979(str), "first_open_count");
                } else {
                    jM4582 = 0;
                    try {
                        contentValues = new ContentValues();
                        contentValues.put("app_id", str);
                        contentValues.put("first_open_count", Long.valueOf(1 + jM4582));
                        if (sQLiteDatabaseM4625.update("app2", contentValues, "app_id = ?", new String[]{str}) != 0) {
                            C3485 c34852 = c1103.f4729;
                            C1103.m3564(c34852);
                            c34852.f13423.m4475("Failed to update column (got 0). appId", C3485.m7979(str), "first_open_count");
                        } else {
                            sQLiteDatabaseM4625.setTransactionSuccessful();
                            j = jM4582;
                        }
                    } catch (SQLiteException e2) {
                        e = e2;
                        j2 = jM4582;
                        C3485 c34853 = c1103.f4729;
                        C1103.m3564(c34853);
                        c34853.f13423.m4477("Error inserting column. appId", C3485.m7979(str), "first_open_count", e);
                        j = j2;
                    }
                }
                C3485 c348532 = c1103.f4729;
                C1103.m3564(c348532);
                c348532.f13423.m4477("Error inserting column. appId", C3485.m7979(str), "first_open_count", e);
                j = j2;
            } else {
                contentValues = new ContentValues();
                contentValues.put("app_id", str);
                contentValues.put("first_open_count", Long.valueOf(1 + jM4582));
                if (sQLiteDatabaseM4625.update("app2", contentValues, "app_id = ?", new String[]{str}) != 0) {
                }
            }
            return j;
        } finally {
            sQLiteDatabaseM4625.endTransaction();
        }
    }

    /* JADX INFO: renamed from: ʿٴˇ, reason: contains not printable characters */
    public final long m4580(String str, C1027 c1027, String str2, Map map, EnumC4563 enumC4563, Long l) {
        int iDelete;
        C1103 c1103 = (C1103) ((ᵜᵪʾ) this).ˌᴵ;
        ˈᵲᵢ();
        m5026();
        ᵘᵞʿⁱ.ᵶᵥᵝ(c1027);
        ᵘᵞʿⁱ.ˊᵫᵗ(str);
        ˈᵲᵢ();
        m5026();
        if (m4610()) {
            C2894 c2894 = this.f18892;
            long jM6318 = c2894.f11122.f3532.m6318();
            ᵠʽᵲ r10 = c1103.f4701;
            C3485 c3485 = c1103.f4729;
            r10.getClass();
            long jElapsedRealtime = SystemClock.elapsedRealtime();
            if (Math.abs(jElapsedRealtime - jM6318) > ((Long) AbstractC3818.f14575.m1988(null)).longValue()) {
                c2894.f11122.f3532.m6316(jElapsedRealtime);
                ˈᵲᵢ();
                m5026();
                if (m4610() && (iDelete = m4625().delete("upload_queue", m4615(), new String[0])) > 0) {
                    C1103.m3564(c3485);
                    c3485.f13414.m4474(Integer.valueOf(iDelete), "Deleted stale MeasurementBatch rows from upload_queue. rowsDeleted");
                }
                ᵘᵞʿⁱ.ˊᵫᵗ(str);
                ˈᵲᵢ();
                m5026();
                try {
                    int iM8310 = c1103.f4726.m8310(str, AbstractC3818.f14578);
                    if (iM8310 > 0) {
                        m4625().delete("upload_queue", "rowid in (SELECT rowid FROM upload_queue WHERE app_id=? ORDER BY rowid DESC LIMIT -1 OFFSET ?)", new String[]{str, String.valueOf(iM8310)});
                    }
                } catch (SQLiteException e) {
                    C1103.m3564(c3485);
                    c3485.f13423.m4475("Error deleting over the limit queued batches. appId", C3485.m7979(str), e);
                }
            }
        }
        ArrayList arrayList = new ArrayList();
        for (Map.Entry entry : map.entrySet()) {
            String str3 = (String) entry.getKey();
            String str4 = (String) entry.getValue();
            StringBuilder sb = new StringBuilder(String.valueOf(str3).length() + 1 + String.valueOf(str4).length());
            sb.append(str3);
            sb.append("=");
            sb.append(str4);
            arrayList.add(sb.toString());
        }
        byte[] bArrM7714 = c1027.m7714();
        ContentValues contentValues = new ContentValues();
        contentValues.put("app_id", str);
        contentValues.put("measurement_batch", bArrM7714);
        contentValues.put("upload_uri", str2);
        contentValues.put("upload_headers", TextUtils.join("\r\n", arrayList));
        contentValues.put("upload_type", Integer.valueOf(enumC4563.f17350));
        ᵠʽᵲ r0 = c1103.f4701;
        C3485 c34852 = c1103.f4729;
        r0.getClass();
        contentValues.put("creation_timestamp", Long.valueOf(System.currentTimeMillis()));
        contentValues.put("retry_count", (Integer) 0);
        if (l != null) {
            contentValues.put("associated_row_id", l);
        }
        try {
            long jInsert = m4625().insert("upload_queue", null, contentValues);
            if (jInsert != -1) {
                return jInsert;
            }
            C1103.m3564(c34852);
            c34852.f13423.m4474(str, "Failed to insert MeasurementBatch (got -1) to upload_queue. appId");
            return -1L;
        } catch (SQLiteException e2) {
            C1103.m3564(c34852);
            c34852.f13423.m4475("Error storing MeasurementBatch to upload_queue. appId", str, e2);
            return -1L;
        }
    }

    /* JADX INFO: renamed from: ʿᵯᴵ, reason: contains not printable characters */
    public final boolean m4581(C4922 c4922) {
        C1103 c1103 = (C1103) ((ᵜᵪʾ) this).ˌᴵ;
        String str = c4922.f18717;
        ˈᵲᵢ();
        m5026();
        String str2 = c4922.f18720;
        String str3 = c4922.f18718;
        if (m4608(str2, str3) == null) {
            if (C3335.m7606(str3)) {
                if (m4613("select count(1) from user_attributes where app_id=? and name not like '!_%' escape '!'", new String[]{str2}) >= Math.max(Math.min(c1103.f4726.m8310(str2, AbstractC3818.f14519), 100), 25)) {
                    return false;
                }
            } else if (!"_npa".equals(str3)) {
                long jM4613 = m4613("select count(1) from user_attributes where app_id=? and origin=? AND name like '!_%' escape '!'", new String[]{str2, str});
                c1103.getClass();
                if (jM4613 >= 25) {
                    return false;
                }
            }
        }
        ContentValues contentValues = new ContentValues();
        contentValues.put("app_id", str2);
        contentValues.put("origin", str);
        contentValues.put("name", str3);
        contentValues.put("set_timestamp", Long.valueOf(c4922.f18721));
        m4578(contentValues, c4922.f18719);
        try {
            if (m4625().insertWithOnConflict("user_attributes", null, contentValues, 5) != -1) {
                return true;
            }
            C3485 c3485 = c1103.f4729;
            C1103.m3564(c3485);
            c3485.f13423.m4474(C3485.m7979(str2), "Failed to insert/update user property (got -1). appId");
            return true;
        } catch (SQLiteException e) {
            C3485 c34852 = c1103.f4729;
            C1103.m3564(c34852);
            c34852.f13423.m4475("Error storing user property. appId", C3485.m7979(str2), e);
            return true;
        }
    }

    /* JADX INFO: renamed from: ʿᵿʽᵞ, reason: contains not printable characters */
    public final long m4582(String str, String[] strArr, long j) {
        Cursor cursorRawQuery = null;
        try {
            try {
                cursorRawQuery = m4625().rawQuery(str, strArr);
                if (cursorRawQuery.moveToFirst()) {
                    j = cursorRawQuery.getLong(0);
                }
                cursorRawQuery.close();
                return j;
            } catch (SQLiteException e) {
                C3485 c3485 = ((C1103) ((ᵜᵪʾ) this).ˌᴵ).f4729;
                C1103.m3564(c3485);
                c3485.f13423.m4475("Database error", str, e);
                throw e;
            }
        } catch (Throwable th) {
            if (cursorRawQuery != null) {
                cursorRawQuery.close();
            }
            throw th;
        }
    }

    /* JADX WARN: Multi-variable type inference failed */
    /* JADX WARN: Removed duplicated region for block: B:24:0x005e  */
    /* JADX WARN: Removed duplicated region for block: B:26:0x0061 A[RETURN] */
    /* JADX WARN: Removed duplicated region for block: B:28:0x0064  */
    /* JADX WARN: Type inference failed for: r2v0 */
    /* JADX WARN: Type inference failed for: r2v1, types: [android.database.Cursor] */
    /* JADX WARN: Type inference failed for: r2v2 */
    /* JADX WARN: Type inference failed for: r3v0, types: [ˎˁʿ, ˏˌ, ᵜᵪʾ] */
    /* JADX WARN: Type inference failed for: r3v3 */
    /* JADX WARN: Type inference failed for: r3v4 */
    /* JADX WARN: Type inference failed for: r3v5 */
    /* JADX WARN: Type inference failed for: r3v7, types: [android.database.Cursor] */
    /* JADX WARN: Type inference failed for: r3v9, types: [android.database.Cursor] */
    /* JADX INFO: renamed from: ˀᵗ, reason: contains not printable characters */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final C0875 m4583(String str) throws Throwable {
        Throwable th;
        SQLiteException e;
        C1103 c1103 = (C1103) ((ᵜᵪʾ) this).ˌᴵ;
        ᵘᵞʿⁱ.ᵶᵥᵝ(str);
        ˈᵲᵢ();
        m5026();
        ?? r2 = 0;
        c0875M3065 = null;
        c0875M3065 = null;
        C0875 c0875M3065 = null;
        try {
            try {
                this = m4625().rawQuery("select consent_state, consent_source from consent_settings where app_id=? limit 1;", new String[]{str});
                try {
                    if (this.moveToFirst()) {
                        c0875M3065 = C0875.m3065(this.getInt(1), this.getString(0));
                    } else {
                        C3485 c3485 = c1103.f4729;
                        C1103.m3564(c3485);
                        c3485.f13414.m4476("No data found");
                    }
                } catch (SQLiteException e2) {
                    e = e2;
                    C3485 c34852 = c1103.f4729;
                    C1103.m3564(c34852);
                    c34852.f13423.m4474(e, "Error querying database.");
                    if (this != 0) {
                    }
                    if (c0875M3065 != null) {
                    }
                }
            } catch (Throwable th2) {
                th = th2;
                r2 = this;
                if (r2 != 0) {
                    r2.close();
                }
                throw th;
            }
        } catch (SQLiteException e3) {
            e = e3;
            this = 0;
        } catch (Throwable th3) {
            th = th3;
            if (r2 != 0) {
            }
            throw th;
        }
        this.close();
        return c0875M3065 != null ? C0875.f3871 : c0875M3065;
    }

    /* JADX INFO: renamed from: ˀᵛᵟ, reason: contains not printable characters */
    public final void m4584(String str, String str2) {
        ᵘᵞʿⁱ.ˊᵫᵗ(str);
        ᵘᵞʿⁱ.ˊᵫᵗ(str2);
        ˈᵲᵢ();
        m5026();
        try {
            m4625().delete("conditional_properties", "app_id=? and name=?", new String[]{str, str2});
        } catch (SQLiteException e) {
            C1103 c1103 = (C1103) ((ᵜᵪʾ) this).ˌᴵ;
            C3485 c3485 = c1103.f4729;
            C1103.m3564(c3485);
            c3485.f13423.m4477("Error deleting conditional property", C3485.m7979(str), c1103.f4717.m5502(str2), e);
        }
    }

    /* JADX INFO: renamed from: ˀᵝᵙᵛ, reason: contains not printable characters */
    public final List m4585(String str, String str2, String str3) {
        ᵘᵞʿⁱ.ˊᵫᵗ(str);
        ˈᵲᵢ();
        m5026();
        ArrayList arrayList = new ArrayList(3);
        arrayList.add(str);
        StringBuilder sb = new StringBuilder("app_id=?");
        if (!TextUtils.isEmpty(str2)) {
            arrayList.add(str2);
            sb.append(" and origin=?");
        }
        if (!TextUtils.isEmpty(str3)) {
            arrayList.add(String.valueOf(str3).concat("*"));
            sb.append(" and name glob ?");
        }
        return m4623(sb.toString(), (String[]) arrayList.toArray(new String[arrayList.size()]));
    }

    /* JADX WARN: Multi-variable type inference failed */
    /* JADX WARN: Removed duplicated region for block: B:23:0x003d  */
    /* JADX WARN: Type inference failed for: r1v0 */
    /* JADX WARN: Type inference failed for: r1v1, types: [android.database.Cursor] */
    /* JADX WARN: Type inference failed for: r1v2 */
    /* JADX INFO: renamed from: ˀᵭ, reason: contains not printable characters */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final String m4586() throws Throwable {
        SQLiteException e;
        Cursor cursorRawQuery;
        SQLiteDatabase sQLiteDatabaseM4625 = m4625();
        ?? r1 = 0;
        try {
            try {
                cursorRawQuery = sQLiteDatabaseM4625.rawQuery("select app_id from queue order by has_realtime desc, rowid asc limit 1;", null);
                try {
                    if (cursorRawQuery.moveToFirst()) {
                        String string = cursorRawQuery.getString(0);
                        cursorRawQuery.close();
                        return string;
                    }
                } catch (SQLiteException e2) {
                    e = e2;
                    C3485 c3485 = ((C1103) ((ᵜᵪʾ) this).ˌᴵ).f4729;
                    C1103.m3564(c3485);
                    c3485.f13423.m4474(e, "Database error getting next bundle app id");
                }
            } catch (Throwable th) {
                th = th;
                r1 = sQLiteDatabaseM4625;
                if (r1 != 0) {
                    r1.close();
                }
                throw th;
            }
        } catch (SQLiteException e3) {
            e = e3;
            cursorRawQuery = null;
        } catch (Throwable th2) {
            th = th2;
            if (r1 != 0) {
            }
            throw th;
        }
        if (cursorRawQuery != null) {
            cursorRawQuery.close();
        }
        return null;
    }

    /* JADX WARN: Removed duplicated region for block: B:122:0x0117 A[SYNTHETIC] */
    /* JADX WARN: Removed duplicated region for block: B:50:0x00f5  */
    /* JADX INFO: renamed from: ˁʢᵛ, reason: contains not printable characters */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final void m4587(String str, Long l, String str2, Bundle bundle) throws Throwable {
        Bundle bundle2;
        C3485 c3485;
        C5090 c5090;
        Cursor cursorQuery;
        C1694 c1694 = this;
        String str3 = str;
        C1103 c1103 = (C1103) ((ᵜᵪʾ) c1694).ˌᴵ;
        ᵘᵞʿⁱ.ᵶᵥᵝ(bundle);
        c1694.ˈᵲᵢ();
        c1694.m5026();
        C1983 c1983 = l != null ? new C1983(c1694, str3, l.longValue()) : new C1983(c1694, str3);
        List<C0755> listM5361 = c1983.m5361();
        while (!listM5361.isEmpty()) {
            for (C0755 c0755 : listM5361) {
                if (!TextUtils.isEmpty(str2)) {
                    Cursor cursor = null;
                    C5090 c50902 = null;
                    Cursor cursor2 = null;
                    try {
                        try {
                            cursorQuery = c1694.m4625().query("raw_events_metadata", new String[]{"metadata"}, "app_id = ? and metadata_fingerprint = ?", new String[]{str3, Long.toString(c0755.f3406)}, null, null, "rowid", "2");
                            try {
                                try {
                                } catch (SQLiteException e) {
                                    e = e;
                                    c5090 = null;
                                }
                            } catch (Throwable th) {
                                th = th;
                                cursor2 = cursorQuery;
                                if (cursor2 != null) {
                                    cursor2.close();
                                }
                                throw th;
                            }
                        } catch (Throwable th2) {
                            th = th2;
                        }
                    } catch (SQLiteException e2) {
                        e = e2;
                        c5090 = null;
                    }
                    if (cursorQuery.moveToFirst()) {
                        try {
                            c5090 = (C5090) ((C0542) C1962.m5264(C5090.m10417(), cursorQuery.getBlob(0))).m9869();
                            try {
                                if (cursorQuery.moveToNext()) {
                                    C3485 c34852 = c1103.f4729;
                                    C1103.m3564(c34852);
                                    c34852.f13424.m4474(C3485.m7979(str3), "Get multiple raw event metadata records, expected one. appId");
                                }
                                cursorQuery.close();
                                cursorQuery.close();
                            } catch (SQLiteException e3) {
                                e = e3;
                                cursor = cursorQuery;
                                C3485 c34853 = c1103.f4729;
                                C1103.m3564(c34853);
                                c34853.f13423.m4475("Data loss. Error selecting raw event. appId", C3485.m7979(str3), e);
                                if (cursor != null) {
                                    cursor.close();
                                }
                            }
                            c50902 = c5090;
                        } catch (IOException e4) {
                            C3485 c34854 = c1103.f4729;
                            C1103.m3564(c34854);
                            c34854.f13423.m4475("Data loss. Failed to merge raw event metadata. appId", C3485.m7979(str3), e4);
                            cursorQuery.close();
                        }
                        if (c50902 == null) {
                            Iterator it = c50902.m10426().iterator();
                            while (it.hasNext()) {
                                if (((C4822) it.next()).m10067().equals(str2)) {
                                    break;
                                }
                            }
                        }
                    } else {
                        C3485 c34855 = c1103.f4729;
                        C1103.m3564(c34855);
                        c34855.f13423.m4474(C3485.m7979(str3), "Raw event metadata record is missing. appId");
                    }
                    cursorQuery.close();
                    if (c50902 == null) {
                    }
                }
                C2894 c2894 = c1694.f18892;
                C1962 c1962 = c2894.f11095;
                C2894.m6882(c1962);
                C4943 c4943 = c0755.f3409;
                Bundle bundle3 = new Bundle();
                for (C0114 c0114 : c4943.m10263()) {
                    if (c0114.m1185()) {
                        bundle3.putDouble(c0114.m1189(), c0114.m1192());
                    } else if (c0114.m1201()) {
                        bundle3.putFloat(c0114.m1189(), c0114.m1203());
                    } else if (c0114.m1196()) {
                        bundle3.putLong(c0114.m1189(), c0114.m1200());
                    } else if (c0114.m1191()) {
                        bundle3.putString(c0114.m1189(), c0114.m1198());
                    } else if (c0114.m1204().isEmpty()) {
                        C3485 c34856 = ((C1103) ((ᵜᵪʾ) c1962).ˌᴵ).f4729;
                        C1103.m3564(c34856);
                        c34856.f13423.m4474(c0114, "Unexpected parameter type for parameter");
                    } else {
                        bundle3.putParcelableArray(c0114.m1189(), C1962.m5273(c0114.m1204()));
                    }
                }
                String string = bundle3.getString("_o");
                bundle3.remove("_o");
                String strM10274 = c4943.m10274();
                if (string == null) {
                    string = "";
                }
                C3335 c3335 = c1103.f4730;
                C3485 c34857 = c1103.f4729;
                C1103.m3567(c3335);
                if (strM10274.equals("_cmp")) {
                    bundle2 = new Bundle(bundle);
                    for (String str4 : bundle.keySet()) {
                        C0755 c07552 = c0755;
                        if (str4.startsWith("gad_")) {
                            bundle2.remove(str4);
                        }
                        c0755 = c07552;
                    }
                } else {
                    bundle2 = bundle;
                }
                C0755 c07553 = c0755;
                c3335.m7644(bundle3, bundle2);
                C4239 c4239 = new C4239((C1103) ((ᵜᵪʾ) c1694).ˌᴵ, string, str3, c4943.m10274(), c4943.m10277(), c4943.m10255(), c4943.m10264(), bundle3);
                long j = c07553.f3408;
                long j2 = c07553.f3406;
                boolean z = c07553.f3407;
                ˈᵲᵢ();
                m5026();
                String str5 = c4239.f16163;
                ᵘᵞʿⁱ.ˊᵫᵗ(str5);
                C1962 c19622 = c2894.f11095;
                C2894.m6882(c19622);
                byte[] bArrM7714 = c19622.m5280(c4239).m7714();
                ContentValues contentValues = new ContentValues();
                contentValues.put("app_id", str5);
                contentValues.put("name", c4239.f16160);
                contentValues.put("timestamp", Long.valueOf(c4239.f16165));
                contentValues.put("metadata_fingerprint", Long.valueOf(j2));
                contentValues.put("data", bArrM7714);
                contentValues.put("realtime", Integer.valueOf(z ? 1 : 0));
                contentValues.put("elapsed_time", Long.valueOf(c4239.f16162));
                try {
                    long jUpdate = m4625().update("raw_events", contentValues, "rowid = ?", new String[]{String.valueOf(j)});
                    if (jUpdate != 1) {
                        C1103.m3564(c34857);
                        c3485 = c34857;
                        try {
                            c3485.f13423.m4475("Failed to update raw event. appId, updatedRows", C3485.m7979(str5), Long.valueOf(jUpdate));
                        } catch (SQLiteException e5) {
                            e = e5;
                            C1103.m3564(c3485);
                            c3485.f13423.m4475("Error updating raw event. appId", C3485.m7979(str5), e);
                        }
                    }
                } catch (SQLiteException e6) {
                    e = e6;
                    c3485 = c34857;
                }
                c1694 = this;
                str3 = str;
            }
            listM5361 = c1983.m5361();
            c1694 = this;
            str3 = str;
        }
    }

    /* JADX INFO: renamed from: ˁˌᵩ, reason: contains not printable characters */
    public final void m4588(Long l) {
        C1103 c1103 = (C1103) ((ᵜᵪʾ) this).ˌᴵ;
        ˈᵲᵢ();
        m5026();
        try {
            if (m4625().delete("upload_queue", "rowid=?", new String[]{l.toString()}) != 1) {
                C3485 c3485 = c1103.f4729;
                C1103.m3564(c3485);
                c3485.f13424.m4476("Deleted fewer rows from upload_queue than expected");
            }
        } catch (SQLiteException e) {
            C3485 c34852 = c1103.f4729;
            C1103.m3564(c34852);
            c34852.f13423.m4474(e, "Failed to delete a MeasurementBatch in a upload_queue table");
            throw e;
        }
    }

    /* JADX INFO: renamed from: ˁᵺˈ, reason: contains not printable characters */
    public final void m4589(String str, String str2) {
        ᵘᵞʿⁱ.ˊᵫᵗ(str2);
        ˈᵲᵢ();
        m5026();
        try {
            m4625().delete(str, "app_id=?", new String[]{str2});
        } catch (SQLiteException e) {
            C3485 c3485 = ((C1103) ((ᵜᵪʾ) this).ˌᴵ).f4729;
            C1103.m3564(c3485);
            c3485.f13423.m4475("Error deleting snapshot. appId", C3485.m7979(str2), e);
        }
    }

    /* JADX WARN: Multi-variable type inference failed */
    /* JADX WARN: Removed duplicated region for block: B:42:0x00ef A[Catch: all -> 0x0079, SQLiteException -> 0x007c, TryCatch #4 {all -> 0x0079, blocks: (B:3:0x0017, B:8:0x002b, B:14:0x0049, B:15:0x0065, B:18:0x006d, B:19:0x0071, B:40:0x00c9, B:42:0x00ef, B:43:0x0101, B:44:0x0105, B:45:0x0115, B:47:0x011b, B:48:0x012b, B:60:0x0159, B:63:0x0161, B:64:0x016c, B:66:0x018c, B:67:0x019a, B:68:0x01a4, B:73:0x01e2, B:72:0x01d2, B:76:0x01e9, B:53:0x0146, B:78:0x01fb, B:82:0x020e, B:11:0x003d, B:29:0x0088, B:31:0x008e, B:35:0x009d, B:38:0x00c1, B:32:0x0093), top: B:89:0x0017 }] */
    /* JADX WARN: Removed duplicated region for block: B:43:0x0101 A[Catch: all -> 0x0079, SQLiteException -> 0x007c, TRY_LEAVE, TryCatch #4 {all -> 0x0079, blocks: (B:3:0x0017, B:8:0x002b, B:14:0x0049, B:15:0x0065, B:18:0x006d, B:19:0x0071, B:40:0x00c9, B:42:0x00ef, B:43:0x0101, B:44:0x0105, B:45:0x0115, B:47:0x011b, B:48:0x012b, B:60:0x0159, B:63:0x0161, B:64:0x016c, B:66:0x018c, B:67:0x019a, B:68:0x01a4, B:73:0x01e2, B:72:0x01d2, B:76:0x01e9, B:53:0x0146, B:78:0x01fb, B:82:0x020e, B:11:0x003d, B:29:0x0088, B:31:0x008e, B:35:0x009d, B:38:0x00c1, B:32:0x0093), top: B:89:0x0017 }] */
    /* JADX WARN: Removed duplicated region for block: B:66:0x018c A[Catch: all -> 0x0079, SQLiteException -> 0x007c, LOOP:0: B:66:0x018c->B:101:?, LOOP_START, TRY_LEAVE, TryCatch #4 {all -> 0x0079, blocks: (B:3:0x0017, B:8:0x002b, B:14:0x0049, B:15:0x0065, B:18:0x006d, B:19:0x0071, B:40:0x00c9, B:42:0x00ef, B:43:0x0101, B:44:0x0105, B:45:0x0115, B:47:0x011b, B:48:0x012b, B:60:0x0159, B:63:0x0161, B:64:0x016c, B:66:0x018c, B:67:0x019a, B:68:0x01a4, B:73:0x01e2, B:72:0x01d2, B:76:0x01e9, B:53:0x0146, B:78:0x01fb, B:82:0x020e, B:11:0x003d, B:29:0x0088, B:31:0x008e, B:35:0x009d, B:38:0x00c1, B:32:0x0093), top: B:89:0x0017 }] */
    /* JADX WARN: Removed duplicated region for block: B:76:0x01e9 A[Catch: all -> 0x0079, SQLiteException -> 0x007c, TryCatch #4 {all -> 0x0079, blocks: (B:3:0x0017, B:8:0x002b, B:14:0x0049, B:15:0x0065, B:18:0x006d, B:19:0x0071, B:40:0x00c9, B:42:0x00ef, B:43:0x0101, B:44:0x0105, B:45:0x0115, B:47:0x011b, B:48:0x012b, B:60:0x0159, B:63:0x0161, B:64:0x016c, B:66:0x018c, B:67:0x019a, B:68:0x01a4, B:73:0x01e2, B:72:0x01d2, B:76:0x01e9, B:53:0x0146, B:78:0x01fb, B:82:0x020e, B:11:0x003d, B:29:0x0088, B:31:0x008e, B:35:0x009d, B:38:0x00c1, B:32:0x0093), top: B:89:0x0017 }] */
    /* JADX WARN: Type inference failed for: r3v1 */
    /* JADX WARN: Type inference failed for: r3v12 */
    /* JADX WARN: Type inference failed for: r3v14, types: [java.lang.String] */
    /* JADX WARN: Type inference failed for: r3v15 */
    /* JADX WARN: Type inference failed for: r3v2, types: [java.lang.String] */
    /* JADX WARN: Type inference failed for: r3v6 */
    /* JADX WARN: Type inference failed for: r3v7, types: [java.lang.String] */
    /* JADX WARN: Type inference failed for: r9v0 */
    /* JADX WARN: Type inference failed for: r9v1 */
    /* JADX WARN: Type inference failed for: r9v2, types: [boolean] */
    /* JADX WARN: Type inference failed for: r9v24 */
    /* JADX WARN: Type inference failed for: r9v25 */
    /* JADX WARN: Type inference failed for: r9v3 */
    /* JADX WARN: Type inference failed for: r9v5 */
    /* JADX INFO: renamed from: ˆʤᵳ, reason: contains not printable characters */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final void m4590(String str, long j, long j2, C5227 c5227) {
        ?? IsEmpty;
        ?? string;
        SQLiteDatabase sQLiteDatabaseM4625;
        String[] strArr;
        String str2;
        String string2;
        ?? r3;
        long j3;
        String[] strArr2;
        String str3;
        C4225 c4225;
        C1103 c1103 = (C1103) ((ᵜᵪʾ) this).ˌᴵ;
        ˈᵲᵢ();
        m5026();
        Cursor cursorRawQuery = null;
        try {
            try {
                sQLiteDatabaseM4625 = m4625();
                IsEmpty = TextUtils.isEmpty(str);
            } catch (SQLiteException e) {
                e = e;
                IsEmpty = str;
            }
            if (IsEmpty != 0) {
                String[] strArr3 = j2 != -1 ? new String[]{String.valueOf(j2), String.valueOf(j)} : new String[]{String.valueOf(j)};
                str2 = j2 != -1 ? "rowid <= ? and " : "";
                StringBuilder sb = new StringBuilder(str2.length() + 148);
                sb.append("select app_id, metadata_fingerprint from raw_events where ");
                sb.append(str2);
                sb.append("app_id in (select app_id from apps where config_fetched_time >= ?) order by rowid limit 1;");
                cursorRawQuery = sQLiteDatabaseM4625.rawQuery(sb.toString(), strArr3);
                try {
                    if (cursorRawQuery.moveToFirst()) {
                        string = cursorRawQuery.getString(0);
                        try {
                            string2 = cursorRawQuery.getString(1);
                            cursorRawQuery.close();
                            r3 = string;
                            cursorRawQuery = sQLiteDatabaseM4625.query("raw_events_metadata", new String[]{"metadata"}, "app_id = ? and metadata_fingerprint = ?", new String[]{r3, string2}, null, null, "rowid", "2");
                            if (cursorRawQuery.moveToFirst()) {
                                C3485 c3485 = c1103.f4729;
                                C1103.m3564(c3485);
                                c3485.f13423.m4474(C3485.m7979(r3), "Raw event metadata record is missing. appId");
                            } else {
                                try {
                                    C5090 c5090 = (C5090) ((C0542) C1962.m5264(C5090.m10417(), cursorRawQuery.getBlob(0))).m9869();
                                    if (cursorRawQuery.moveToNext()) {
                                        C3485 c34852 = c1103.f4729;
                                        C1103.m3564(c34852);
                                        c34852.f13424.m4474(C3485.m7979(r3), "Get multiple raw event metadata records, expected one. appId");
                                    }
                                    cursorRawQuery.close();
                                    c5227.f19712 = c5090;
                                    long jM4582 = m4582("select (rowid - 1) as max_rowid from raw_events where app_id = ? and metadata_fingerprint != ? order by rowid limit 1;", new String[]{r3, string2}, -1L);
                                    if (j2 != -1) {
                                        j3 = j2;
                                    } else if (jM4582 != -1) {
                                        j3 = -1;
                                    } else {
                                        str3 = "app_id = ? and metadata_fingerprint = ?";
                                        strArr2 = new String[]{r3, string2};
                                        cursorRawQuery = sQLiteDatabaseM4625.query("raw_events", new String[]{"rowid", "name", "timestamp", "data", "elapsed_time"}, str3, strArr2, null, null, "rowid", null);
                                        if (cursorRawQuery.moveToFirst()) {
                                            C3485 c34853 = c1103.f4729;
                                            C1103.m3564(c34853);
                                            c34853.f13424.m4474(C3485.m7979(r3), "Raw event data disappeared while in transaction. appId");
                                        } else {
                                            do {
                                                long j4 = cursorRawQuery.getLong(0);
                                                byte[] blob = cursorRawQuery.getBlob(3);
                                                long j5 = cursorRawQuery.getLong(4);
                                                try {
                                                    c4225 = (C4225) C1962.m5264(C4943.m10252(), blob);
                                                    c4225.m9178(cursorRawQuery.getString(1));
                                                    long j6 = cursorRawQuery.getLong(2);
                                                    c4225.m9868();
                                                    ((C4943) c4225.f17955).m10257(j6);
                                                    c4225.m9868();
                                                    ((C4943) c4225.f17955).m10265(j5);
                                                } catch (IOException e2) {
                                                    C3485 c34854 = c1103.f4729;
                                                    C1103.m3564(c34854);
                                                    c34854.f13423.m4475("Data loss. Failed to merge raw event. appId", C3485.m7979(r3), e2);
                                                }
                                                if (!c5227.m10794(j4, (C4943) c4225.m9869())) {
                                                    break;
                                                }
                                            } while (cursorRawQuery.moveToNext());
                                        }
                                    }
                                    if (j3 != -1 && jM4582 != -1) {
                                        jM4582 = Math.min(j3, jM4582);
                                    } else if (j3 != -1) {
                                        jM4582 = j3;
                                    }
                                    str3 = "app_id = ? and metadata_fingerprint = ? and rowid <= ?";
                                    strArr2 = new String[]{r3, string2, String.valueOf(jM4582)};
                                    cursorRawQuery = sQLiteDatabaseM4625.query("raw_events", new String[]{"rowid", "name", "timestamp", "data", "elapsed_time"}, str3, strArr2, null, null, "rowid", null);
                                    if (cursorRawQuery.moveToFirst()) {
                                    }
                                } catch (IOException e3) {
                                    C3485 c34855 = c1103.f4729;
                                    C1103.m3564(c34855);
                                    c34855.f13423.m4475("Data loss. Failed to merge raw event metadata. appId", C3485.m7979(r3), e3);
                                }
                            }
                        } catch (SQLiteException e4) {
                            e = e4;
                            C3485 c34856 = c1103.f4729;
                            C1103.m3564(c34856);
                            c34856.f13423.m4475("Data loss. Error selecting raw event. appId", C3485.m7979(string), e);
                        }
                    }
                } catch (SQLiteException e5) {
                    e = e5;
                    string = str;
                }
                C3485 c348562 = c1103.f4729;
                C1103.m3564(c348562);
                c348562.f13423.m4475("Data loss. Error selecting raw event. appId", C3485.m7979(string), e);
            } else {
                try {
                    if (j2 != -1) {
                        String str4 = str;
                        strArr = new String[]{str4, String.valueOf(j2)};
                        IsEmpty = str4;
                    } else {
                        String str5 = str;
                        strArr = new String[]{str5};
                        IsEmpty = str5;
                    }
                    str2 = j2 != -1 ? " and rowid <= ?" : "";
                    StringBuilder sb2 = new StringBuilder(str2.length() + 84);
                    sb2.append("select metadata_fingerprint from raw_events where app_id = ?");
                    sb2.append(str2);
                    sb2.append(" order by rowid limit 1;");
                    cursorRawQuery = sQLiteDatabaseM4625.rawQuery(sb2.toString(), strArr);
                    if (cursorRawQuery.moveToFirst()) {
                        string2 = cursorRawQuery.getString(0);
                        cursorRawQuery.close();
                        r3 = IsEmpty;
                        cursorRawQuery = sQLiteDatabaseM4625.query("raw_events_metadata", new String[]{"metadata"}, "app_id = ? and metadata_fingerprint = ?", new String[]{r3, string2}, null, null, "rowid", "2");
                        if (cursorRawQuery.moveToFirst()) {
                        }
                    }
                } catch (SQLiteException e6) {
                    e = e6;
                    string = IsEmpty;
                    C3485 c3485622 = c1103.f4729;
                    C1103.m3564(c3485622);
                    c3485622.f13423.m4475("Data loss. Error selecting raw event. appId", C3485.m7979(string), e);
                }
            }
        } finally {
            if (0 != 0) {
                cursorRawQuery.close();
            }
        }
    }

    /* JADX INFO: renamed from: ˆˀᵯ, reason: contains not printable characters */
    public final void m4591(String str) {
        C3711 c3711M4601;
        m4589("events_snapshot", str);
        Cursor cursorQuery = null;
        try {
            try {
                cursorQuery = m4625().query("events", (String[]) Collections.singletonList("name").toArray(new String[0]), "app_id=?", new String[]{str}, null, null, null);
                if (cursorQuery.moveToFirst()) {
                    do {
                        String string = cursorQuery.getString(0);
                        if (string != null && (c3711M4601 = m4601("events", str, string)) != null) {
                            m4594("events_snapshot", c3711M4601);
                        }
                    } while (cursorQuery.moveToNext());
                }
            } catch (SQLiteException e) {
                C3485 c3485 = ((C1103) ((ᵜᵪʾ) this).ˌᴵ).f4729;
                C1103.m3564(c3485);
                c3485.f13423.m4475("Error creating snapshot. appId", C3485.m7979(str), e);
            }
            if (cursorQuery != null) {
                cursorQuery.close();
            }
        } finally {
        }
    }

    /* JADX WARN: Multi-variable type inference failed */
    /* JADX WARN: Removed duplicated region for block: B:29:0x008d  */
    /* JADX WARN: Removed duplicated region for block: B:35:? A[SYNTHETIC] */
    /* JADX WARN: Type inference failed for: r2v0 */
    /* JADX WARN: Type inference failed for: r2v1, types: [android.database.Cursor] */
    /* JADX WARN: Type inference failed for: r2v2 */
    /* JADX INFO: renamed from: ˆᵱʣ, reason: contains not printable characters */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final C2994 m4592(String str) throws Throwable {
        Throwable th;
        Cursor cursorQuery;
        C1103 c1103 = (C1103) ((ᵜᵪʾ) this).ˌᴵ;
        ᵘᵞʿⁱ.ˊᵫᵗ(str);
        ˈᵲᵢ();
        m5026();
        ?? r2 = 0;
        try {
            try {
                cursorQuery = m4625().query("apps", new String[]{"remote_config", "config_last_modified_time", "e_tag"}, "app_id=?", new String[]{str}, null, null, null);
                try {
                    if (cursorQuery.moveToFirst()) {
                        byte[] blob = cursorQuery.getBlob(0);
                        String string = cursorQuery.getString(1);
                        String string2 = cursorQuery.getString(2);
                        if (cursorQuery.moveToNext()) {
                            C3485 c3485 = c1103.f4729;
                            C1103.m3564(c3485);
                            c3485.f13423.m4474(C3485.m7979(str), "Got multiple records for app config, expected one. appId");
                        }
                        if (blob != null) {
                            C2994 c2994 = new C2994(blob, string, string2, 8);
                            cursorQuery.close();
                            return c2994;
                        }
                    }
                } catch (SQLiteException e) {
                    e = e;
                    C3485 c34852 = c1103.f4729;
                    C1103.m3564(c34852);
                    c34852.f13423.m4475("Error querying remote config. appId", C3485.m7979(str), e);
                }
            } catch (Throwable th2) {
                th = th2;
                r2 = this;
                if (r2 != 0) {
                    throw th;
                }
                r2.close();
                throw th;
            }
        } catch (SQLiteException e2) {
            e = e2;
            cursorQuery = null;
        } catch (Throwable th3) {
            th = th3;
            if (r2 != 0) {
            }
        }
        if (cursorQuery != null) {
            cursorQuery.close();
        }
        return null;
    }

    /* JADX INFO: renamed from: ˈⁱᵡ, reason: contains not printable characters */
    public final boolean m4593(String str, String str2) {
        return m4613("select count(1) from raw_events where app_id = ? and name = ?", new String[]{str, str2}) > 0;
    }

    /* JADX INFO: renamed from: ˉˆᵗ, reason: contains not printable characters */
    public final void m4594(String str, C3711 c3711) {
        C1103 c1103 = (C1103) ((ᵜᵪʾ) this).ˌᴵ;
        ᵘᵞʿⁱ.ᵶᵥᵝ(c3711);
        ˈᵲᵢ();
        m5026();
        ContentValues contentValues = new ContentValues();
        String str2 = c3711.f14133;
        contentValues.put("app_id", str2);
        contentValues.put("name", c3711.f14128);
        contentValues.put("lifetime_count", Long.valueOf(c3711.f14130));
        contentValues.put("current_bundle_count", Long.valueOf(c3711.f14136));
        contentValues.put("last_fire_timestamp", Long.valueOf(c3711.f14138));
        contentValues.put("last_bundled_timestamp", Long.valueOf(c3711.f14134));
        contentValues.put("last_bundled_day", c3711.f14129);
        contentValues.put("last_sampled_complex_event_id", c3711.f14137);
        contentValues.put("last_sampling_rate", c3711.f14132);
        contentValues.put("current_session_count", Long.valueOf(c3711.f14131));
        Boolean bool = c3711.f14135;
        contentValues.put("last_exempt_from_sampling", (bool == null || !bool.booleanValue()) ? null : 1L);
        try {
            if (m4625().insertWithOnConflict(str, null, contentValues, 5) == -1) {
                C3485 c3485 = c1103.f4729;
                C1103.m3564(c3485);
                c3485.f13423.m4474(C3485.m7979(str2), "Failed to insert/update event aggregates (got -1). appId");
            }
        } catch (SQLiteException e) {
            C3485 c34852 = c1103.f4729;
            C1103.m3564(c34852);
            c34852.f13423.m4475("Error storing event aggregates. appId", C3485.m7979(str2), e);
        }
    }

    /* JADX INFO: renamed from: ˉᵵᵜ, reason: contains not printable characters */
    public final boolean m4595(String str) {
        EnumC4563[] enumC4563Arr = {EnumC4563.f17345};
        ArrayList arrayList = new ArrayList(1);
        arrayList.add(Integer.valueOf(enumC4563Arr[0].f17350));
        String strM4577 = m4577(arrayList);
        String strM4615 = m4615();
        StringBuilder sb = new StringBuilder(strM4577.length() + 61 + strM4615.length());
        sb.append("SELECT COUNT(1) > 0 FROM upload_queue WHERE app_id=?");
        sb.append(strM4577);
        sb.append(" AND NOT ");
        sb.append(strM4615);
        return m4613(sb.toString(), new String[]{str}) != 0;
    }

    /* JADX WARN: Removed duplicated region for block: B:131:0x0407  */
    /* JADX INFO: renamed from: ˊʧᵖ, reason: contains not printable characters */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final C2019 m4596(String str) throws Throwable {
        Cursor cursorQuery;
        Boolean boolValueOf;
        String string;
        C1103 c1103 = (C1103) ((ᵜᵪʾ) this).ˌᴵ;
        ᵘᵞʿⁱ.ˊᵫᵗ(str);
        ˈᵲᵢ();
        m5026();
        Cursor cursor = null;
        try {
            cursorQuery = m4625().query("apps", new String[]{"app_instance_id", "gmp_app_id", "resettable_device_id_hash", "last_bundle_index", "last_bundle_start_timestamp", "last_bundle_end_timestamp", "app_version", "app_store", "gmp_version", "dev_cert_hash", "measurement_enabled", "day", "daily_public_events_count", "daily_events_count", "daily_conversions_count", "config_fetched_time", "failed_config_fetch_time", "app_version_int", "firebase_instance_id", "daily_error_events_count", "daily_realtime_events_count", "health_monitor_sample", "android_id", "adid_reporting_enabled", "admob_app_id", "dynamite_version", "safelisted_events", "ga_app_id", "session_stitching_token", "sgtm_upload_enabled", "target_os_version", "session_stitching_token_hash", "ad_services_version", "unmatched_first_open_without_ad_id", "npa_metadata_value", "attribution_eligibility_status", "sgtm_preview_key", "dma_consent_state", "daily_realtime_dcu_count", "bundle_delivery_index", "serialized_npa_metadata", "unmatched_pfo", "unmatched_uwa", "ad_campaign_info", "client_upload_eligibility", "last_diagnostics_signal_upload_timestamp"}, "app_id=?", new String[]{str}, null, null, null);
            try {
                try {
                    if (cursorQuery.moveToFirst()) {
                        C2894 c2894 = this.f18892;
                        C2019 c2019 = new C2019(c2894.f11114, str);
                        C1103 c11032 = c2019.f8027;
                        C0875 c0875M6888 = c2894.m6888(str);
                        EnumC0174 enumC0174 = EnumC0174.f1598;
                        if (c0875M6888.m3073(enumC0174)) {
                            c2019.m5422(cursorQuery.getString(0));
                        }
                        boolean z = true;
                        c2019.m5398(cursorQuery.getString(1));
                        if (c2894.m6888(str).m3073(EnumC0174.f1599)) {
                            c2019.m5397(cursorQuery.getString(2));
                        }
                        c2019.m5424(cursorQuery.getLong(3));
                        c2019.m5417(cursorQuery.getLong(4));
                        c2019.m5432(cursorQuery.getLong(5));
                        c2019.m5395(cursorQuery.getString(6));
                        c2019.m5420(cursorQuery.getString(7));
                        c2019.m5403(cursorQuery.getLong(8));
                        c2019.m5431(cursorQuery.getLong(9));
                        c2019.m5436(cursorQuery.isNull(10) || cursorQuery.getInt(10) != 0);
                        c2019.m5438(cursorQuery.getLong(11));
                        c2019.m5430(cursorQuery.getLong(12));
                        c2019.m5435(cursorQuery.getLong(13));
                        c2019.m5427(cursorQuery.getLong(14));
                        c2019.m5439(cursorQuery.getLong(15));
                        c2019.m5433(cursorQuery.getLong(16));
                        c2019.m5423(cursorQuery.isNull(17) ? -2147483648L : cursorQuery.getInt(17));
                        c2019.m5405(cursorQuery.getString(18));
                        c2019.m5409(cursorQuery.getLong(19));
                        c2019.m5419(cursorQuery.getLong(20));
                        c2019.m5418(cursorQuery.getString(21));
                        boolean z2 = cursorQuery.isNull(23) || cursorQuery.getInt(23) != 0;
                        C1961 c1961 = c11032.f4707;
                        C1103.m3564(c1961);
                        c1961.m5243();
                        c2019.f8019 |= c2019.f8017 != z2;
                        c2019.f8017 = z2;
                        c2019.m5413(cursorQuery.isNull(25) ? 0L : cursorQuery.getLong(25));
                        if (!cursorQuery.isNull(26)) {
                            c2019.m5425(Arrays.asList(cursorQuery.getString(26).split(",", -1)));
                        }
                        if (c2894.m6888(str).m3073(enumC0174)) {
                            String string2 = cursorQuery.getString(28);
                            C1961 c19612 = c11032.f4707;
                            C1103.m3564(c19612);
                            c19612.m5243();
                            c2019.f8019 |= !Objects.equals(c2019.f8008, string2);
                            c2019.f8008 = string2;
                        }
                        boolean z3 = (cursorQuery.isNull(29) || cursorQuery.getInt(29) == 0) ? false : true;
                        C1961 c19613 = c11032.f4707;
                        C1103.m3564(c19613);
                        c19613.m5243();
                        c2019.f8019 |= c2019.f8002 != z3;
                        c2019.f8002 = z3;
                        c2019.m5404(cursorQuery.getLong(39));
                        String string3 = cursorQuery.getString(36);
                        C1961 c19614 = c11032.f4707;
                        C1103.m3564(c19614);
                        c19614.m5243();
                        c2019.f8019 |= c2019.f8007 != string3;
                        c2019.f8007 = string3;
                        c2019.m5434(cursorQuery.getLong(30));
                        c2019.m5399(cursorQuery.getLong(31));
                        C0756.m2702();
                        if (c1103.f4726.m8314(str, AbstractC3818.f14557)) {
                            int i = cursorQuery.getInt(32);
                            C1961 c19615 = c11032.f4707;
                            C1103.m3564(c19615);
                            c19615.m5243();
                            c2019.f8019 |= c2019.f8012 != i;
                            c2019.f8012 = i;
                            c2019.m5411(cursorQuery.getLong(35));
                        }
                        boolean z4 = (cursorQuery.isNull(33) || cursorQuery.getInt(33) == 0) ? false : true;
                        C1961 c19616 = c11032.f4707;
                        C1103.m3564(c19616);
                        c19616.m5243();
                        c2019.f8019 |= c2019.f8021 != z4;
                        c2019.f8021 = z4;
                        if (cursorQuery.isNull(34)) {
                            boolValueOf = null;
                        } else {
                            boolValueOf = Boolean.valueOf(cursorQuery.getInt(34) != 0);
                        }
                        C1961 c19617 = c11032.f4707;
                        C1103.m3564(c19617);
                        c19617.m5243();
                        c2019.f8019 |= !Objects.equals(c2019.f8025, boolValueOf);
                        c2019.f8025 = boolValueOf;
                        c2019.m5421(cursorQuery.getInt(37));
                        c2019.m5429(cursorQuery.getInt(38));
                        if (cursorQuery.isNull(40)) {
                            string = "";
                        } else {
                            string = cursorQuery.getString(40);
                            ᵘᵞʿⁱ.ᵶᵥᵝ(string);
                        }
                        C1961 c19618 = c11032.f4707;
                        C1103.m3564(c19618);
                        c19618.m5243();
                        c2019.f8019 |= c2019.f8018 != string;
                        c2019.f8018 = string;
                        if (!cursorQuery.isNull(41)) {
                            Long lValueOf = Long.valueOf(cursorQuery.getLong(41));
                            C1961 c19619 = c11032.f4707;
                            C1103.m3564(c19619);
                            c19619.m5243();
                            c2019.f8019 |= !Objects.equals(c2019.f8024, lValueOf);
                            c2019.f8024 = lValueOf;
                        }
                        if (!cursorQuery.isNull(42)) {
                            Long lValueOf2 = Long.valueOf(cursorQuery.getLong(42));
                            C1961 c196110 = c11032.f4707;
                            C1103.m3564(c196110);
                            c196110.m5243();
                            c2019.f8019 |= !Objects.equals(c2019.f8030, lValueOf2);
                            c2019.f8030 = lValueOf2;
                        }
                        byte[] blob = cursorQuery.getBlob(43);
                        C1961 c196111 = c11032.f4707;
                        C1103.m3564(c196111);
                        c196111.m5243();
                        c2019.f8019 |= c2019.f7998 != blob;
                        c2019.f7998 = blob;
                        if (!cursorQuery.isNull(44)) {
                            int i2 = cursorQuery.getInt(44);
                            C1961 c196112 = c11032.f4707;
                            C1103.m3564(c196112);
                            c196112.m5243();
                            boolean z5 = c2019.f8019;
                            if (c2019.f7994 == i2) {
                                z = false;
                            }
                            c2019.f8019 = z | z5;
                            c2019.f7994 = i2;
                        }
                        if (c1103.f4726.m8314(str, AbstractC3818.f14478) && !cursorQuery.isNull(45)) {
                            c2019.m5406(cursorQuery.getLong(45));
                        }
                        C1961 c196113 = c11032.f4707;
                        C1103.m3564(c196113);
                        c196113.m5243();
                        c2019.f8019 = false;
                        if (cursorQuery.moveToNext()) {
                            C3485 c3485 = c1103.f4729;
                            C1103.m3564(c3485);
                            c3485.f13423.m4474(C3485.m7979(str), "Got multiple records for app, expected one. appId");
                        }
                        cursorQuery.close();
                        return c2019;
                    }
                } catch (SQLiteException e) {
                    e = e;
                    C3485 c34852 = c1103.f4729;
                    C1103.m3564(c34852);
                    c34852.f13423.m4475("Error querying app. appId", C3485.m7979(str), e);
                }
            } catch (Throwable th) {
                th = th;
                cursor = cursorQuery;
                if (cursor != null) {
                    cursor.close();
                }
                throw th;
            }
        } catch (SQLiteException e2) {
            e = e2;
            cursorQuery = null;
        } catch (Throwable th2) {
            th = th2;
            if (cursor != null) {
            }
            throw th;
        }
        if (cursorQuery != null) {
            cursorQuery.close();
        }
        return null;
    }

    /* JADX INFO: renamed from: ˊˌˊ, reason: contains not printable characters */
    public final void m4597(String str, Long l, long j, C4943 c4943) {
        ˈᵲᵢ();
        m5026();
        ᵘᵞʿⁱ.ᵶᵥᵝ(c4943);
        ᵘᵞʿⁱ.ˊᵫᵗ(str);
        C1103 c1103 = (C1103) ((ᵜᵪʾ) this).ˌᴵ;
        byte[] bArrM7714 = c4943.m7714();
        C3485 c3485 = c1103.f4729;
        C3485 c34852 = c1103.f4729;
        C1103.m3564(c3485);
        c3485.f13414.m4475("Saving complex main event, appId, data size", c1103.f4717.m5504(str), Integer.valueOf(bArrM7714.length));
        ContentValues contentValues = new ContentValues();
        contentValues.put("app_id", str);
        contentValues.put("event_id", l);
        contentValues.put("children_to_process", Long.valueOf(j));
        contentValues.put("main_event", bArrM7714);
        try {
            if (m4625().insertWithOnConflict("main_event_params", null, contentValues, 5) == -1) {
                C1103.m3564(c34852);
                c34852.f13423.m4474(C3485.m7979(str), "Failed to insert complex main event (got -1). appId");
            }
        } catch (SQLiteException e) {
            C1103.m3564(c34852);
            c34852.f13423.m4475("Error storing complex main event. appId", C3485.m7979(str), e);
        }
    }

    /* JADX INFO: renamed from: ˊᵡᵗʨ, reason: contains not printable characters */
    public final void m4598() {
        ˈᵲᵢ();
        m5026();
        if (m4610()) {
            C2894 c2894 = this.f18892;
            long jM6318 = c2894.f11122.f3531.m6318();
            C1103 c1103 = (C1103) ((ᵜᵪʾ) this).ˌᴵ;
            c1103.f4701.getClass();
            long jElapsedRealtime = SystemClock.elapsedRealtime();
            if (Math.abs(jElapsedRealtime - jM6318) > ((Long) AbstractC3818.f14575.m1988(null)).longValue()) {
                c2894.f11122.f3531.m6316(jElapsedRealtime);
                ˈᵲᵢ();
                m5026();
                if (m4610()) {
                    SQLiteDatabase sQLiteDatabaseM4625 = m4625();
                    c1103.f4701.getClass();
                    int iDelete = sQLiteDatabaseM4625.delete("queue", "abs(bundle_end_timestamp - ?) > cast(? as integer)", new String[]{String.valueOf(System.currentTimeMillis()), String.valueOf(((Long) AbstractC3818.f14539.m1988(null)).longValue())});
                    if (iDelete > 0) {
                        C3485 c3485 = c1103.f4729;
                        C1103.m3564(c3485);
                        c3485.f13414.m4474(Integer.valueOf(iDelete), "Deleted stale rows. rowsDeleted");
                    }
                }
            }
        }
    }

    /* JADX INFO: renamed from: ˊᵶᵕᵛ, reason: contains not printable characters */
    public final C0222 m4599(long j, String str, long j2, boolean z, boolean z2, boolean z3, boolean z4, boolean z5, boolean z6, boolean z7) {
        C1103 c1103 = (C1103) ((ᵜᵪʾ) this).ˌᴵ;
        ᵘᵞʿⁱ.ˊᵫᵗ(str);
        ˈᵲᵢ();
        m5026();
        String[] strArr = {str};
        C0222 c0222 = new C0222();
        Cursor cursorQuery = null;
        try {
            try {
                SQLiteDatabase sQLiteDatabaseM4625 = m4625();
                cursorQuery = sQLiteDatabaseM4625.query("apps", new String[]{"day", "daily_events_count", "daily_public_events_count", "daily_conversions_count", "daily_error_events_count", "daily_realtime_events_count", "daily_realtime_dcu_count", "daily_registered_triggers_count"}, "app_id=?", new String[]{str}, null, null, null);
                if (cursorQuery.moveToFirst()) {
                    if (cursorQuery.getLong(0) == j) {
                        c0222.f1719 = cursorQuery.getLong(1);
                        c0222.f1722 = cursorQuery.getLong(2);
                        c0222.f1720 = cursorQuery.getLong(3);
                        c0222.f1724 = cursorQuery.getLong(4);
                        c0222.f1721 = cursorQuery.getLong(5);
                        c0222.f1725 = cursorQuery.getLong(6);
                        c0222.f1723 = cursorQuery.getLong(7);
                    }
                    if (z) {
                        c0222.f1719 += j2;
                    }
                    if (z2) {
                        c0222.f1722 += j2;
                    }
                    if (z3) {
                        c0222.f1720 += j2;
                    }
                    if (z4) {
                        c0222.f1724 += j2;
                    }
                    if (z5) {
                        c0222.f1721 += j2;
                    }
                    if (z6) {
                        c0222.f1725 += j2;
                    }
                    if (z7) {
                        c0222.f1723 += j2;
                    }
                    ContentValues contentValues = new ContentValues();
                    contentValues.put("day", Long.valueOf(j));
                    contentValues.put("daily_public_events_count", Long.valueOf(c0222.f1722));
                    contentValues.put("daily_events_count", Long.valueOf(c0222.f1719));
                    contentValues.put("daily_conversions_count", Long.valueOf(c0222.f1720));
                    contentValues.put("daily_error_events_count", Long.valueOf(c0222.f1724));
                    contentValues.put("daily_realtime_events_count", Long.valueOf(c0222.f1721));
                    contentValues.put("daily_realtime_dcu_count", Long.valueOf(c0222.f1725));
                    contentValues.put("daily_registered_triggers_count", Long.valueOf(c0222.f1723));
                    sQLiteDatabaseM4625.update("apps", contentValues, "app_id=?", strArr);
                } else {
                    C3485 c3485 = c1103.f4729;
                    C1103.m3564(c3485);
                    c3485.f13424.m4474(C3485.m7979(str), "Not updating daily counts, app is not known. appId");
                }
            } catch (SQLiteException e) {
                C3485 c34852 = c1103.f4729;
                C1103.m3564(c34852);
                c34852.f13423.m4475("Error updating daily counts. appId", C3485.m7979(str), e);
            }
            if (cursorQuery != null) {
                cursorQuery.close();
            }
            return c0222;
        } finally {
        }
    }

    /* JADX INFO: renamed from: ˊᵾʽʼ, reason: contains not printable characters */
    public final void m4600(long j) {
        ˈᵲᵢ();
        m5026();
        try {
            if (m4625().delete("queue", "rowid=?", new String[]{String.valueOf(j)}) == 1) {
            } else {
                throw new SQLiteException("Deleted fewer rows from queue than expected");
            }
        } catch (SQLiteException e) {
            C3485 c3485 = ((C1103) ((ᵜᵪʾ) this).ˌᴵ).f4729;
            C1103.m3564(c3485);
            c3485.f13423.m4474(e, "Failed to delete a bundle in a queue table");
            throw e;
        }
    }

    /* JADX WARN: Multi-variable type inference failed */
    /* JADX WARN: Removed duplicated region for block: B:54:0x0129  */
    /* JADX WARN: Type inference failed for: r3v3 */
    /* JADX WARN: Type inference failed for: r3v4, types: [android.database.Cursor] */
    /* JADX WARN: Type inference failed for: r3v5 */
    /* JADX INFO: renamed from: ˋʿᐧ, reason: contains not printable characters */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final C3711 m4601(String str, String str2, String str3) throws Throwable {
        Cursor cursorQuery;
        Boolean boolValueOf;
        C1103 c1103 = (C1103) ((ᵜᵪʾ) this).ˌᴵ;
        ᵘᵞʿⁱ.ˊᵫᵗ(str2);
        ᵘᵞʿⁱ.ˊᵫᵗ(str3);
        ˈᵲᵢ();
        m5026();
        ArrayList arrayList = new ArrayList(Arrays.asList("lifetime_count", "current_bundle_count", "last_fire_timestamp", "last_bundled_timestamp", "last_bundled_day", "last_sampled_complex_event_id", "last_sampling_rate", "last_exempt_from_sampling", "current_session_count"));
        ?? r3 = 0;
        try {
            try {
                cursorQuery = m4625().query(str, (String[]) arrayList.toArray(new String[0]), "app_id=? and name=?", new String[]{str2, str3}, null, null, null);
                try {
                    if (cursorQuery.moveToFirst()) {
                        long j = cursorQuery.getLong(0);
                        long j2 = cursorQuery.getLong(1);
                        long j3 = cursorQuery.getLong(2);
                        long j4 = 0;
                        long j5 = cursorQuery.isNull(3) ? 0L : cursorQuery.getLong(3);
                        Long lValueOf = cursorQuery.isNull(4) ? null : Long.valueOf(cursorQuery.getLong(4));
                        Long lValueOf2 = cursorQuery.isNull(5) ? null : Long.valueOf(cursorQuery.getLong(5));
                        Long lValueOf3 = cursorQuery.isNull(6) ? null : Long.valueOf(cursorQuery.getLong(6));
                        if (cursorQuery.isNull(7)) {
                            boolValueOf = null;
                        } else {
                            boolValueOf = Boolean.valueOf(cursorQuery.getLong(7) == 1);
                        }
                        if (!cursorQuery.isNull(8)) {
                            j4 = cursorQuery.getLong(8);
                        }
                        C3711 c3711 = new C3711(str2, str3, j, j2, j4, j3, j5, lValueOf, lValueOf2, lValueOf3, boolValueOf);
                        if (cursorQuery.moveToNext()) {
                            C3485 c3485 = c1103.f4729;
                            C1103.m3564(c3485);
                            c3485.f13423.m4474(C3485.m7979(str2), "Got multiple records for event aggregates, expected one. appId");
                        }
                        cursorQuery.close();
                        return c3711;
                    }
                } catch (SQLiteException e) {
                    e = e;
                    C3485 c34852 = c1103.f4729;
                    C1103.m3564(c34852);
                    c34852.f13423.m4477("Error querying events. appId", C3485.m7979(str2), c1103.f4717.m5504(str3), e);
                }
            } catch (Throwable th) {
                th = th;
                r3 = arrayList;
                if (r3 != 0) {
                    r3.close();
                }
                throw th;
            }
        } catch (SQLiteException e2) {
            e = e2;
            cursorQuery = null;
        } catch (Throwable th2) {
            th = th2;
            if (r3 != 0) {
            }
            throw th;
        }
        if (cursorQuery != null) {
            cursorQuery.close();
        }
        return null;
    }

    /* JADX INFO: renamed from: ˋᵤᵦ, reason: contains not printable characters */
    public final void m4602(C5090 c5090, boolean z) {
        ˈᵲᵢ();
        m5026();
        ᵘᵞʿⁱ.ˊᵫᵗ(c5090.m10481());
        if (!c5090.m10484()) {
            ᵷᵝˎ.ᵱʡˏ();
            return;
        }
        m4598();
        C1103 c1103 = (C1103) ((ᵜᵪʾ) this).ˌᴵ;
        ᵠʽᵲ r1 = c1103.f4701;
        C3485 c3485 = c1103.f4729;
        r1.getClass();
        long jCurrentTimeMillis = System.currentTimeMillis();
        long jM10547 = c5090.m10547();
        C0511 c0511 = AbstractC3818.f14539;
        if (jM10547 < jCurrentTimeMillis - ((Long) c0511.m1988(null)).longValue() || c5090.m10547() > ((Long) c0511.m1988(null)).longValue() + jCurrentTimeMillis) {
            C1103.m3564(c3485);
            c3485.f13424.m4477("Storing bundle outside of the max uploading time span. appId, now, timestamp", C3485.m7979(c5090.m10481()), Long.valueOf(jCurrentTimeMillis), Long.valueOf(c5090.m10547()));
        }
        byte[] bArrM7714 = c5090.m7714();
        try {
            C1962 c1962 = this.f18892.f11095;
            C2894.m6882(c1962);
            byte[] bArrM5282 = c1962.m5282(bArrM7714);
            C1103.m3564(c3485);
            c3485.f13414.m4474(Integer.valueOf(bArrM5282.length), "Saving bundle, size");
            ContentValues contentValues = new ContentValues();
            contentValues.put("app_id", c5090.m10481());
            contentValues.put("bundle_end_timestamp", Long.valueOf(c5090.m10547()));
            contentValues.put("data", bArrM5282);
            contentValues.put("has_realtime", Integer.valueOf(z ? 1 : 0));
            if (c5090.m10439()) {
                contentValues.put("retry_count", Integer.valueOf(c5090.m10504()));
            }
            try {
                if (m4625().insert("queue", null, contentValues) == -1) {
                    C1103.m3564(c3485);
                    c3485.f13423.m4474(C3485.m7979(c5090.m10481()), "Failed to insert bundle (got -1). appId");
                }
            } catch (SQLiteException e) {
                C1103.m3564(c3485);
                c3485.f13423.m4475("Error storing bundle. appId", C3485.m7979(c5090.m10481()), e);
            }
        } catch (IOException e2) {
            C1103.m3564(c3485);
            c3485.f13423.m4475("Data loss. Failed to serialize bundle. appId", C3485.m7979(c5090.m10481()), e2);
        }
    }

    /* JADX INFO: renamed from: ˋᵯᵩ, reason: contains not printable characters */
    public final C0399 m4603(String str, long j, byte[] bArr, String str2, String str3, int i, int i2, long j2, long j3, long j4) {
        EnumC4563 enumC4563;
        C1103 c1103 = (C1103) ((ᵜᵪʾ) this).ˌᴵ;
        if (TextUtils.isEmpty(str2)) {
            C3485 c3485 = c1103.f4729;
            C1103.m3564(c3485);
            c3485.f13416.m4476("Upload uri is null or empty. Destination is unknown. Dropping batch. ");
            return null;
        }
        try {
            C4798 c4798 = (C4798) C1962.m5264(C1027.m3410(), bArr);
            EnumC4563[] enumC4563ArrValues = EnumC4563.values();
            int length = enumC4563ArrValues.length;
            int i3 = 0;
            while (true) {
                if (i3 >= length) {
                    enumC4563 = EnumC4563.f17343;
                    break;
                }
                enumC4563 = enumC4563ArrValues[i3];
                if (enumC4563.f17350 == i) {
                    break;
                }
                i3++;
            }
            if (enumC4563 != EnumC4563.f17345 && enumC4563 != EnumC4563.f17349 && i2 > 0) {
                ArrayList arrayList = new ArrayList();
                Iterator it = DesugarCollections.unmodifiableList(((C1027) c4798.f17955).m3417()).iterator();
                while (it.hasNext()) {
                    C0542 c0542 = (C0542) ((C5090) it.next()).m9884();
                    c0542.m9868();
                    ((C5090) c0542.f17955).m10447(i2);
                    arrayList.add((C5090) c0542.m9869());
                }
                c4798.m9868();
                ((C1027) c4798.f17955).m3411();
                c4798.m9868();
                ((C1027) c4798.f17955).m3418(arrayList);
            }
            HashMap map = new HashMap();
            if (str3 != null) {
                String[] strArrSplit = str3.split("\r\n");
                int length2 = strArrSplit.length;
                int i4 = 0;
                while (true) {
                    if (i4 >= length2) {
                        break;
                    }
                    String str4 = strArrSplit[i4];
                    if (str4.isEmpty()) {
                        break;
                    }
                    String[] strArrSplit2 = str4.split("=", 2);
                    if (strArrSplit2.length != 2) {
                        C3485 c34852 = c1103.f4729;
                        C1103.m3564(c34852);
                        c34852.f13423.m4474(str4, "Invalid upload header: ");
                        break;
                    }
                    map.put(strArrSplit2[0], strArrSplit2[1]);
                    i4++;
                }
            }
            return new C0399(j, (C1027) c4798.m9869(), str2, map, enumC4563, j2, j3, j4, i2);
        } catch (IOException e) {
            C3485 c34853 = c1103.f4729;
            C1103.m3564(c34853);
            c34853.f13423.m4475("Failed to queued MeasurementBatch from upload_queue. appId", str, e);
            return null;
        }
    }

    /* JADX INFO: renamed from: ˏʜᵪ, reason: contains not printable characters */
    public final C3711 m4604(String str, C4943 c4943, String str2) throws Throwable {
        C3711 c3711M4601 = m4601("events", str, c4943.m10274());
        if (c3711M4601 != null) {
            long j = c3711M4601.f14131 + 1;
            long j2 = c3711M4601.f14136 + 1;
            return new C3711(c3711M4601.f14133, c3711M4601.f14128, c3711M4601.f14130 + 1, j2, j, c3711M4601.f14138, c3711M4601.f14134, c3711M4601.f14129, c3711M4601.f14137, c3711M4601.f14132, c3711M4601.f14135);
        }
        C1103 c1103 = (C1103) ((ᵜᵪʾ) this).ˌᴵ;
        C3485 c3485 = c1103.f4729;
        C1103.m3564(c3485);
        c3485.f13424.m4475("Event aggregate wasn't created during raw event logging. appId, event", C3485.m7979(str), c1103.f4717.m5504(str2));
        return new C3711(str, c4943.m10274(), 1L, 1L, 1L, c4943.m10277(), 0L, null, null, null, null);
    }

    /* JADX INFO: renamed from: ˏʽˊᵰ, reason: contains not printable characters */
    public final void m4605() {
        m5026();
        m4625().setTransactionSuccessful();
    }

    /* JADX INFO: renamed from: ˏᵩʨ, reason: contains not printable characters */
    public final void m4606(String str, C2004 c2004) {
        ˈᵲᵢ();
        m5026();
        ᵘᵞʿⁱ.ˊᵫᵗ(str);
        C1103 c1103 = (C1103) ((ᵜᵪʾ) this).ˌᴵ;
        ᵠʽᵲ r1 = c1103.f4701;
        C3485 c3485 = c1103.f4729;
        r1.getClass();
        long jCurrentTimeMillis = System.currentTimeMillis();
        C0511 c0511 = AbstractC3818.f14570;
        long jLongValue = jCurrentTimeMillis - ((Long) c0511.m1988(null)).longValue();
        long j = c2004.f7927;
        if (j < jLongValue || j > ((Long) c0511.m1988(null)).longValue() + jCurrentTimeMillis) {
            C1103.m3564(c3485);
            c3485.f13424.m4477("Storing trigger URI outside of the max retention time span. appId, now, timestamp", C3485.m7979(str), Long.valueOf(jCurrentTimeMillis), Long.valueOf(j));
        }
        C1103.m3564(c3485);
        c3485.f13414.m4476("Saving trigger URI");
        ContentValues contentValues = new ContentValues();
        contentValues.put("app_id", str);
        contentValues.put("trigger_uri", c2004.f7925);
        contentValues.put("source", Integer.valueOf(c2004.f7926));
        contentValues.put("timestamp_millis", Long.valueOf(j));
        try {
            if (m4625().insert("trigger_uris", null, contentValues) == -1) {
                C1103.m3564(c3485);
                c3485.f13423.m4474(C3485.m7979(str), "Failed to insert trigger URI (got -1). appId");
            }
        } catch (SQLiteException e) {
            C1103.m3564(c3485);
            c3485.f13423.m4475("Error storing trigger URI. appId", C3485.m7979(str), e);
        }
    }

    /* JADX INFO: renamed from: ˑʢ, reason: contains not printable characters */
    public final Object m4607(Cursor cursor, int i) {
        C1103 c1103 = (C1103) ((ᵜᵪʾ) this).ˌᴵ;
        int type = cursor.getType(i);
        if (type == 0) {
            C3485 c3485 = c1103.f4729;
            C1103.m3564(c3485);
            c3485.f13423.m4476("Loaded invalid null value from database");
            return null;
        }
        if (type == 1) {
            return Long.valueOf(cursor.getLong(i));
        }
        if (type == 2) {
            return Double.valueOf(cursor.getDouble(i));
        }
        if (type == 3) {
            return cursor.getString(i);
        }
        if (type != 4) {
            C3485 c34852 = c1103.f4729;
            C1103.m3564(c34852);
            c34852.f13423.m4474(Integer.valueOf(type), "Loaded invalid unknown value type, ignoring it");
            return null;
        }
        C3485 c34853 = c1103.f4729;
        C1103.m3564(c34853);
        c34853.f13423.m4476("Loaded invalid blob type value, ignoring it");
        return null;
    }

    @Override // defpackage.AbstractC1850
    /* JADX INFO: renamed from: ˑˊᵲ */
    public final void mo2842() {
        C1103 c1103 = (C1103) ((ᵜᵪʾ) this).ˌᴵ;
        if (c1103.f4726.m8314(null, AbstractC3818.f14549)) {
            C1961 c1961 = c1103.f4707;
            C1103.m3564(c1961);
            c1961.m5246(new RunnableC1726(2, this));
        }
    }

    /* JADX WARN: Removed duplicated region for block: B:34:0x009d  */
    /* JADX WARN: Removed duplicated region for block: B:43:? A[SYNTHETIC] */
    /* JADX INFO: renamed from: ᵕᵜʽᵰ, reason: contains not printable characters */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final C4922 m4608(String str, String str2) throws Throwable {
        Throwable th;
        String str3;
        String str4;
        SQLiteException sQLiteException;
        Cursor cursorQuery;
        C1103 c1103 = (C1103) ((ᵜᵪʾ) this).ˌᴵ;
        ᵘᵞʿⁱ.ˊᵫᵗ(str);
        ᵘᵞʿⁱ.ˊᵫᵗ(str2);
        ˈᵲᵢ();
        m5026();
        Cursor cursor = null;
        try {
            cursorQuery = m4625().query("user_attributes", new String[]{"set_timestamp", "value", "origin"}, "app_id=? and name=?", new String[]{str, str2}, null, null, null);
            try {
                try {
                } catch (Throwable th2) {
                    th = th2;
                    cursor = cursorQuery;
                    if (cursor != null) {
                        throw th;
                    }
                    cursor.close();
                    throw th;
                }
            } catch (SQLiteException e) {
                e = e;
                str3 = str;
                str4 = str2;
            }
        } catch (SQLiteException e2) {
            str3 = str;
            str4 = str2;
            sQLiteException = e2;
            cursorQuery = null;
        } catch (Throwable th3) {
            th = th3;
            if (cursor != null) {
            }
        }
        if (cursorQuery.moveToFirst()) {
            long j = cursorQuery.getLong(0);
            Object objM4607 = m4607(cursorQuery, 1);
            if (objM4607 != null) {
                str3 = str;
                str4 = str2;
                try {
                    C4922 c4922 = new C4922(str3, cursorQuery.getString(2), str4, j, objM4607);
                    if (cursorQuery.moveToNext()) {
                        C3485 c3485 = c1103.f4729;
                        C1103.m3564(c3485);
                        c3485.f13423.m4474(C3485.m7979(str3), "Got multiple records for user property, expected one. appId");
                    }
                    cursorQuery.close();
                    return c4922;
                } catch (SQLiteException e3) {
                    e = e3;
                }
            }
            sQLiteException = e;
            C3485 c34852 = c1103.f4729;
            C1103.m3564(c34852);
            c34852.f13423.m4477("Error querying user property. appId", C3485.m7979(str3), c1103.f4717.m5502(str4), sQLiteException);
        }
        if (cursorQuery != null) {
            cursorQuery.close();
        }
        return null;
    }

    /* JADX INFO: renamed from: ᵗᵭ, reason: contains not printable characters */
    public final void m4609(String str, C0875 c0875) {
        ᵘᵞʿⁱ.ᵶᵥᵝ(str);
        ᵘᵞʿⁱ.ᵶᵥᵝ(c0875);
        ˈᵲᵢ();
        m5026();
        ContentValues contentValues = new ContentValues();
        contentValues.put("app_id", str);
        contentValues.put("consent_state", c0875.m3071());
        contentValues.put("consent_source", Integer.valueOf(c0875.f3872));
        m4622(contentValues);
    }

    /* JADX INFO: renamed from: ᵘᵝ, reason: contains not printable characters */
    public final boolean m4610() {
        return ((C1103) ((ᵜᵪʾ) this).ˌᴵ).f4713.getDatabasePath("google_app_measurement.db").exists();
    }

    /* JADX INFO: renamed from: ᵘᵫᵡ, reason: contains not printable characters */
    public final C0222 m4611(long j, String str, boolean z, boolean z2, boolean z3, boolean z4) {
        return m4599(j, str, 1L, false, false, z, false, z2, z3, z4);
    }

    /* JADX WARN: Removed duplicated region for block: B:50:0x00cb  */
    /* JADX WARN: Removed duplicated region for block: B:55:0x00d7  */
    /* JADX WARN: Removed duplicated region for block: B:7:0x0054  */
    /* JADX WARN: Removed duplicated region for block: B:9:0x005b  */
    /* JADX INFO: renamed from: ᵚᵹᵔᵜ, reason: contains not printable characters */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final void m4612(String str) throws Throwable {
        boolean z;
        C3711 c3711M4601;
        ArrayList arrayList = new ArrayList(Arrays.asList("name", "lifetime_count"));
        C3711 c3711M46012 = m4601("events", str, "_f");
        C3711 c3711M46013 = m4601("events", str, "_v");
        m4589("events", str);
        Cursor cursorQuery = null;
        boolean z2 = false;
        try {
            cursorQuery = m4625().query("events_snapshot", (String[]) arrayList.toArray(new String[0]), "app_id=?", new String[]{str}, null, null, null);
        } catch (SQLiteException e) {
            e = e;
            z = false;
        } catch (Throwable th) {
            th = th;
            z = false;
        }
        if (!cursorQuery.moveToFirst()) {
            cursorQuery.close();
            if (c3711M46012 != null) {
                m4594("events", c3711M46012);
            } else if (c3711M46013 != null) {
                m4594("events", c3711M46013);
            }
            m4589("events_snapshot", str);
        }
        boolean z3 = false;
        z = false;
        do {
            try {
                String string = cursorQuery.getString(0);
                if (cursorQuery.getLong(1) >= 1) {
                    if ("_f".equals(string)) {
                        z3 = true;
                    } else if ("_v".equals(string)) {
                        z = true;
                    }
                }
                if (string != null && (c3711M4601 = m4601("events_snapshot", str, string)) != null) {
                    m4594("events", c3711M4601);
                }
            } catch (SQLiteException e2) {
                e = e2;
                z2 = z3;
                try {
                    C3485 c3485 = ((C1103) ((ᵜᵪʾ) this).ˌᴵ).f4729;
                    C1103.m3564(c3485);
                    c3485.f13423.m4475("Error querying snapshot. appId", C3485.m7979(str), e);
                    z3 = z2;
                } catch (Throwable th2) {
                    th = th2;
                    if (cursorQuery != null) {
                        cursorQuery.close();
                    }
                    if (z2 && c3711M46012 != null) {
                        m4594("events", c3711M46012);
                    } else if (!z && c3711M46013 != null) {
                        m4594("events", c3711M46013);
                    }
                    m4589("events_snapshot", str);
                    throw th;
                }
            } catch (Throwable th3) {
                th = th3;
                z2 = z3;
                if (cursorQuery != null) {
                }
                if (z2) {
                    if (!z) {
                        m4594("events", c3711M46013);
                    }
                }
                m4589("events_snapshot", str);
                throw th;
            }
        } while (cursorQuery.moveToNext());
        if (cursorQuery != null) {
            cursorQuery.close();
        }
        if (z3 || c3711M46012 == null) {
            if (!z && c3711M46013 != null) {
            }
        }
        m4589("events_snapshot", str);
    }

    /* JADX INFO: renamed from: ᵛˀˊ, reason: contains not printable characters */
    public final long m4613(String str, String[] strArr) {
        Cursor cursor = null;
        try {
            try {
                Cursor cursorRawQuery = m4625().rawQuery(str, strArr);
                if (!cursorRawQuery.moveToFirst()) {
                    throw new SQLiteException("Database returned empty set");
                }
                long j = cursorRawQuery.getLong(0);
                cursorRawQuery.close();
                return j;
            } catch (SQLiteException e) {
                C3485 c3485 = ((C1103) ((ᵜᵪʾ) this).ˌᴵ).f4729;
                C1103.m3564(c3485);
                c3485.f13423.m4475("Database error", str, e);
                throw e;
            }
        } catch (Throwable th) {
            if (0 != 0) {
                cursor.close();
            }
            throw th;
        }
    }

    /* JADX INFO: renamed from: ᵛˑﹳ, reason: contains not printable characters */
    public final void m4614(ArrayList arrayList) {
        C1103 c1103 = (C1103) ((ᵜᵪʾ) this).ˌᴵ;
        ˈᵲᵢ();
        m5026();
        ᵘᵞʿⁱ.ᵶᵥᵝ(arrayList);
        if (arrayList.size() == 0) {
            ᵕᵩʽᵲ.ᵮᵣᵗˈ("Given Integer is zero");
            return;
        }
        if (m4610()) {
            String strJoin = TextUtils.join(",", arrayList);
            String strM2864 = AbstractC0793.m2864(new StringBuilder(String.valueOf(strJoin).length() + 2), "(", strJoin, ")");
            if (m4613(AbstractC0793.m2864(new StringBuilder(strM2864.length() + 80), "SELECT COUNT(1) FROM queue WHERE rowid IN ", strM2864, " AND retry_count =  2147483647 LIMIT 1"), null) > 0) {
                C3485 c3485 = c1103.f4729;
                C1103.m3564(c3485);
                c3485.f13424.m4476("The number of upload retries exceeds the limit. Will remain unchanged.");
            }
            try {
                SQLiteDatabase sQLiteDatabaseM4625 = m4625();
                StringBuilder sb = new StringBuilder(strM2864.length() + 127);
                sb.append("UPDATE queue SET retry_count = IFNULL(retry_count, 0) + 1 WHERE rowid IN ");
                sb.append(strM2864);
                sb.append(" AND (retry_count IS NULL OR retry_count < 2147483647)");
                sQLiteDatabaseM4625.execSQL(sb.toString());
            } catch (SQLiteException e) {
                C3485 c34852 = c1103.f4729;
                C1103.m3564(c34852);
                c34852.f13423.m4474(e, "Error incrementing retry count. error");
            }
        }
    }

    /* JADX INFO: renamed from: ᵜᵤ, reason: contains not printable characters */
    public final String m4615() {
        ((C1103) ((ᵜᵪʾ) this).ˌᴵ).f4701.getClass();
        long jCurrentTimeMillis = System.currentTimeMillis();
        Locale locale = Locale.US;
        Long l = (Long) AbstractC3818.f14500.m1988(null);
        l.getClass();
        String str = "(upload_type = 1 AND ABS(creation_timestamp - " + jCurrentTimeMillis + ") > " + l + ")";
        String strM2870 = AbstractC0793.m2870(AbstractC3653.m8220(jCurrentTimeMillis, "(upload_type != 1 AND ABS(creation_timestamp - ", ") > "), ((Long) AbstractC3818.f14539.m1988(null)).longValue(), ")");
        StringBuilder sb = new StringBuilder(AbstractC3653.m8238(str.length(), 5, strM2870.length(), 1));
        AbstractC3589.m8100(sb, "(", str, " OR ", strM2870);
        sb.append(")");
        return sb.toString();
    }

    /* JADX INFO: renamed from: ᵞᵛᵘ, reason: contains not printable characters */
    public final long m4616(String str) {
        ᵘᵞʿⁱ.ˊᵫᵗ(str);
        return m4582("select count(1) from events where app_id=? and name not like '!_%' escape '!'", new String[]{str}, 0L);
    }

    /* JADX WARN: Multi-variable type inference failed */
    /* JADX WARN: Type inference failed for: r0v1, types: [java.util.ArrayList] */
    /* JADX WARN: Type inference failed for: r0v4, types: [java.util.List] */
    /* JADX WARN: Type inference failed for: r0v6, types: [java.util.List] */
    /* JADX INFO: renamed from: ᵟᵴᵥ, reason: contains not printable characters */
    public final List m4617(String str) {
        String str2;
        SQLiteException sQLiteException;
        C1103 c1103 = (C1103) ((ᵜᵪʾ) this).ˌᴵ;
        ᵘᵞʿⁱ.ˊᵫᵗ(str);
        ˈᵲᵢ();
        m5026();
        ?? arrayList = new ArrayList();
        Cursor cursorQuery = null;
        try {
            try {
                c1103.getClass();
                cursorQuery = m4625().query("user_attributes", new String[]{"name", "origin", "set_timestamp", "value"}, "app_id=?", new String[]{str}, null, null, "rowid", "1000");
                if (cursorQuery.moveToFirst()) {
                    while (true) {
                        String string = cursorQuery.getString(0);
                        String string2 = cursorQuery.getString(1);
                        if (string2 == null) {
                            string2 = "";
                        }
                        String str3 = string2;
                        long j = cursorQuery.getLong(2);
                        Object objM4607 = m4607(cursorQuery, 3);
                        if (objM4607 == null) {
                            try {
                                C3485 c3485 = c1103.f4729;
                                C1103.m3564(c3485);
                                c3485.f13423.m4474(C3485.m7979(str), "Read invalid user property value, ignoring it. appId");
                                str2 = str;
                            } catch (SQLiteException e) {
                                sQLiteException = e;
                                str2 = str;
                                C3485 c34852 = c1103.f4729;
                                C1103.m3564(c34852);
                                c34852.f13423.m4475("Error querying user properties. appId", C3485.m7979(str2), sQLiteException);
                                arrayList = Collections.EMPTY_LIST;
                            }
                        } else {
                            str2 = str;
                            try {
                                arrayList.add(new C4922(str2, str3, string, j, objM4607));
                            } catch (SQLiteException e2) {
                                e = e2;
                                sQLiteException = e;
                                C3485 c348522 = c1103.f4729;
                                C1103.m3564(c348522);
                                c348522.f13423.m4475("Error querying user properties. appId", C3485.m7979(str2), sQLiteException);
                                arrayList = Collections.EMPTY_LIST;
                            }
                        }
                        if (!cursorQuery.moveToNext()) {
                            break;
                        }
                        str = str2;
                    }
                }
            } finally {
            }
        } catch (SQLiteException e3) {
            e = e3;
            str2 = str;
        }
        if (cursorQuery != null) {
            cursorQuery.close();
        }
        return arrayList;
    }

    /* JADX WARN: Multi-variable type inference failed */
    /* JADX WARN: Type inference failed for: r0v3, types: [java.util.List] */
    /* JADX WARN: Type inference failed for: r0v4, types: [java.util.List] */
    /* JADX WARN: Type inference failed for: r0v5, types: [java.util.ArrayList] */
    /* JADX INFO: renamed from: ᵠˏˏ, reason: contains not printable characters */
    public final List m4618(String str, C4920 c4920, int i) {
        ?? arrayList;
        ᵘᵞʿⁱ.ˊᵫᵗ(str);
        ˈᵲᵢ();
        m5026();
        Cursor cursorQuery = null;
        try {
            try {
                SQLiteDatabase sQLiteDatabaseM4625 = m4625();
                String[] strArr = {"rowId", "app_id", "measurement_batch", "upload_uri", "upload_headers", "upload_type", "retry_count", "creation_timestamp", "associated_row_id", "last_upload_timestamp"};
                String strM4577 = m4577(c4920.f18712);
                String strM4615 = m4615();
                StringBuilder sb = new StringBuilder(strM4577.length() + 17 + strM4615.length());
                sb.append("app_id=?");
                sb.append(strM4577);
                sb.append(" AND NOT ");
                sb.append(strM4615);
                cursorQuery = sQLiteDatabaseM4625.query("upload_queue", strArr, sb.toString(), new String[]{str}, null, null, "creation_timestamp ASC", i > 0 ? String.valueOf(i) : null);
                arrayList = new ArrayList();
                while (cursorQuery.moveToNext()) {
                    C0399 c0399M4603 = m4603(str, cursorQuery.getLong(0), cursorQuery.getBlob(2), cursorQuery.getString(3), cursorQuery.getString(4), cursorQuery.getInt(5), cursorQuery.getInt(6), cursorQuery.getLong(7), cursorQuery.getLong(8), cursorQuery.getLong(9));
                    if (c0399M4603 != null) {
                        arrayList.add(c0399M4603);
                    }
                }
            } catch (SQLiteException e) {
                C3485 c3485 = ((C1103) ((ᵜᵪʾ) this).ˌᴵ).f4729;
                C1103.m3564(c3485);
                c3485.f13423.m4475("Error to querying MeasurementBatch from upload_queue. appId", str, e);
                arrayList = Collections.EMPTY_LIST;
            }
            return arrayList;
        } finally {
            if (cursorQuery != null) {
                cursorQuery.close();
            }
        }
    }

    /* JADX WARN: Not initialized variable reg: 8, insn: 0x00f0: MOVE (r7 I:??[OBJECT, ARRAY]) = (r8 I:??[OBJECT, ARRAY]), block:B:29:0x00f0 */
    /* JADX WARN: Removed duplicated region for block: B:36:0x0110  */
    /* JADX WARN: Removed duplicated region for block: B:39:0x0116  */
    /* JADX INFO: renamed from: ᵠᵚˀᵫ, reason: contains not printable characters */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final C3833 m4619(String str, String str2) throws Throwable {
        String str3;
        Cursor cursorQuery;
        Cursor cursor;
        C1103 c1103 = (C1103) ((ᵜᵪʾ) this).ˌᴵ;
        ᵘᵞʿⁱ.ˊᵫᵗ(str);
        ᵘᵞʿⁱ.ˊᵫᵗ(str2);
        ˈᵲᵢ();
        m5026();
        Cursor cursor2 = null;
        try {
            try {
                cursorQuery = m4625().query("conditional_properties", new String[]{"origin", "value", "active", "trigger_event_name", "trigger_timeout", "timed_out_event", "creation_timestamp", "triggered_event", "triggered_timestamp", "time_to_live", "expired_event"}, "app_id=? and name=?", new String[]{str, str2}, null, null, null);
                try {
                } catch (SQLiteException e) {
                    e = e;
                    str3 = str2;
                }
            } catch (Throwable th) {
                th = th;
                cursor2 = cursor;
                if (cursor2 != null) {
                    cursor2.close();
                }
                throw th;
            }
        } catch (SQLiteException e2) {
            e = e2;
            str3 = str2;
            cursorQuery = null;
        } catch (Throwable th2) {
            th = th2;
            if (cursor2 != null) {
            }
            throw th;
        }
        if (!cursorQuery.moveToFirst()) {
            if (cursorQuery != null) {
                cursorQuery.close();
            }
            return null;
        }
        String string = cursorQuery.getString(0);
        if (string == null) {
            string = "";
        }
        String str4 = string;
        Object objM4607 = m4607(cursorQuery, 1);
        boolean z = cursorQuery.getInt(2) != 0;
        String string2 = cursorQuery.getString(3);
        long j = cursorQuery.getLong(4);
        C1962 c1962 = this.f18892.f11095;
        C2894.m6882(c1962);
        byte[] blob = cursorQuery.getBlob(5);
        Parcelable.Creator<C0357> creator = C0357.CREATOR;
        C0357 c0357 = (C0357) c1962.m5281(blob, creator);
        long j2 = cursorQuery.getLong(6);
        C2894.m6882(c1962);
        C0357 c03572 = (C0357) c1962.m5281(cursorQuery.getBlob(7), creator);
        long j3 = cursorQuery.getLong(8);
        long j4 = cursorQuery.getLong(9);
        C2894.m6882(c1962);
        str3 = str2;
        try {
            C3833 c3833 = new C3833(str, str4, new C0973(j3, objM4607, str3, str4), j2, z, string2, c0357, j, c03572, j4, (C0357) c1962.m5281(cursorQuery.getBlob(10), creator));
            if (cursorQuery.moveToNext()) {
                C3485 c3485 = c1103.f4729;
                C1103.m3564(c3485);
                c3485.f13423.m4475("Got multiple records for conditional property, expected one", C3485.m7979(str), c1103.f4717.m5502(str3));
            }
            cursorQuery.close();
            return c3833;
        } catch (SQLiteException e3) {
            e = e3;
        }
        C3485 c34852 = c1103.f4729;
        C1103.m3564(c34852);
        c34852.f13423.m4477("Error querying conditional property", C3485.m7979(str), c1103.f4717.m5502(str3), e);
        if (cursorQuery != null) {
        }
        return null;
    }

    /* JADX INFO: renamed from: ᵠᵲˁ, reason: contains not printable characters */
    public final boolean m4620(C3833 c3833) {
        C1103 c1103 = (C1103) ((ᵜᵪʾ) this).ˌᴵ;
        ˈᵲᵢ();
        m5026();
        String str = c3833.f14633;
        ᵘᵞʿⁱ.ᵶᵥᵝ(str);
        if (m4608(str, c3833.f14636.f4262) == null) {
            long jM4613 = m4613("SELECT COUNT(1) FROM conditional_properties WHERE app_id=?", new String[]{str});
            c1103.getClass();
            if (jM4613 >= 1000) {
                return false;
            }
        }
        ContentValues contentValues = new ContentValues();
        contentValues.put("app_id", str);
        contentValues.put("origin", c3833.f14637);
        contentValues.put("name", c3833.f14636.f4262);
        Object objM3298 = c3833.f14636.m3298();
        ᵘᵞʿⁱ.ᵶᵥᵝ(objM3298);
        m4578(contentValues, objM3298);
        contentValues.put("active", Boolean.valueOf(c3833.f14639));
        contentValues.put("trigger_event_name", c3833.f14640);
        contentValues.put("trigger_timeout", Long.valueOf(c3833.f14634));
        C0357 c0357 = c3833.f14632;
        C3335 c3335 = c1103.f4730;
        C3485 c3485 = c1103.f4729;
        C1103.m3567(c3335);
        contentValues.put("timed_out_event", C3335.m7616(c0357));
        contentValues.put("creation_timestamp", Long.valueOf(c3833.f14638));
        C1103.m3567(c3335);
        contentValues.put("triggered_event", C3335.m7616(c3833.f14641));
        contentValues.put("triggered_timestamp", Long.valueOf(c3833.f14636.f4261));
        contentValues.put("time_to_live", Long.valueOf(c3833.f14635));
        contentValues.put("expired_event", C3335.m7616(c3833.f14631));
        try {
            if (m4625().insertWithOnConflict("conditional_properties", null, contentValues, 5) != -1) {
                return true;
            }
            C1103.m3564(c3485);
            c3485.f13423.m4474(C3485.m7979(str), "Failed to insert/update conditional user property (got -1)");
            return true;
        } catch (SQLiteException e) {
            C1103.m3564(c3485);
            c3485.f13423.m4475("Error storing conditional user property", C3485.m7979(str), e);
            return true;
        }
    }

    /* JADX WARN: Removed duplicated region for block: B:16:0x0034  */
    /* JADX INFO: renamed from: ᵡᵶ, reason: contains not printable characters */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final String m4621(String str, String[] strArr) {
        Cursor cursorRawQuery = null;
        try {
            try {
                cursorRawQuery = m4625().rawQuery(str, strArr);
                if (!cursorRawQuery.moveToFirst()) {
                    cursorRawQuery.close();
                    return "";
                }
                String string = cursorRawQuery.getString(0);
                cursorRawQuery.close();
                return string;
            } catch (SQLiteException e) {
                C3485 c3485 = ((C1103) ((ᵜᵪʾ) this).ˌᴵ).f4729;
                C1103.m3564(c3485);
                c3485.f13423.m4475("Database error", str, e);
                throw e;
            }
        } catch (Throwable th) {
            if (cursorRawQuery != null) {
            }
            throw th;
        }
        if (cursorRawQuery != null) {
            cursorRawQuery.close();
        }
        throw th;
    }

    /* JADX INFO: renamed from: ᵡᵶᵬʤ, reason: contains not printable characters */
    public final void m4622(ContentValues contentValues) {
        C1103 c1103 = (C1103) ((ᵜᵪʾ) this).ˌᴵ;
        try {
            SQLiteDatabase sQLiteDatabaseM4625 = m4625();
            if (contentValues.getAsString("app_id") == null) {
                C3485 c3485 = c1103.f4729;
                C1103.m3564(c3485);
                c3485.f13417.m4474(C3485.m7979("app_id"), "Value of the primary key is not set.");
                return;
            }
            new StringBuilder(10).append("app_id = ?");
            if (sQLiteDatabaseM4625.update("consent_settings", contentValues, r5.toString(), new String[]{r4}) == 0 && sQLiteDatabaseM4625.insertWithOnConflict("consent_settings", null, contentValues, 5) == -1) {
                C3485 c34852 = c1103.f4729;
                C1103.m3564(c34852);
                c34852.f13423.m4475("Failed to insert/update table (got -1). key", C3485.m7979("consent_settings"), C3485.m7979("app_id"));
            }
        } catch (SQLiteException e) {
            C3485 c34853 = c1103.f4729;
            C1103.m3564(c34853);
            c34853.f13423.m4477("Error storing into table. key", C3485.m7979("consent_settings"), C3485.m7979("app_id"), e);
        }
    }

    /* JADX WARN: Code restructure failed: missing block: B:7:0x0055, code lost:
    
        r0 = r1.f4729;
        defpackage.C1103.m3564(r0);
        r0.f13423.m4474(1000, "Read more than the max allowed conditional properties, ignoring extra");
     */
    /* JADX WARN: Multi-variable type inference failed */
    /* JADX WARN: Type inference failed for: r2v0, types: [java.util.ArrayList] */
    /* JADX WARN: Type inference failed for: r2v2, types: [java.util.List] */
    /* JADX WARN: Type inference failed for: r2v3, types: [java.util.List] */
    /* JADX INFO: renamed from: ᵣʚʿ, reason: contains not printable characters */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final List m4623(String str, String[] strArr) {
        C1103 c1103 = (C1103) ((ᵜᵪʾ) this).ˌᴵ;
        ˈᵲᵢ();
        m5026();
        ?? arrayList = new ArrayList();
        Cursor cursorQuery = null;
        try {
            try {
                c1103.getClass();
                cursorQuery = m4625().query("conditional_properties", new String[]{"app_id", "origin", "name", "value", "active", "trigger_event_name", "trigger_timeout", "timed_out_event", "creation_timestamp", "triggered_event", "triggered_timestamp", "time_to_live", "expired_event"}, str, strArr, null, null, "rowid", "1001");
                if (cursorQuery.moveToFirst()) {
                    while (true) {
                        if (arrayList.size() >= 1000) {
                            break;
                        }
                        String string = cursorQuery.getString(0);
                        String string2 = cursorQuery.getString(1);
                        String string3 = cursorQuery.getString(2);
                        Object objM4607 = m4607(cursorQuery, 3);
                        boolean z = cursorQuery.getInt(4) != 0;
                        String string4 = cursorQuery.getString(5);
                        long j = cursorQuery.getLong(6);
                        C1962 c1962 = this.f18892.f11095;
                        C2894.m6882(c1962);
                        byte[] blob = cursorQuery.getBlob(7);
                        Parcelable.Creator<C0357> creator = C0357.CREATOR;
                        C0357 c0357 = (C0357) c1962.m5281(blob, creator);
                        long j2 = cursorQuery.getLong(8);
                        C2894.m6882(c1962);
                        C0357 c03572 = (C0357) c1962.m5281(cursorQuery.getBlob(9), creator);
                        long j3 = cursorQuery.getLong(10);
                        long j4 = cursorQuery.getLong(11);
                        C2894.m6882(c1962);
                        arrayList.add(new C3833(string, string2, new C0973(j3, objM4607, string3, string2), j2, z, string4, c0357, j, c03572, j4, (C0357) c1962.m5281(cursorQuery.getBlob(12), creator)));
                        if (!cursorQuery.moveToNext()) {
                            break;
                        }
                    }
                }
            } catch (SQLiteException e) {
                C3485 c3485 = c1103.f4729;
                C1103.m3564(c3485);
                c3485.f13423.m4474(e, "Error querying conditional user property value");
                arrayList = Collections.EMPTY_LIST;
            }
            if (cursorQuery != null) {
                cursorQuery.close();
            }
            return arrayList;
        } catch (Throwable th) {
            if (cursorQuery != null) {
                cursorQuery.close();
            }
            throw th;
        }
    }

    /* JADX INFO: renamed from: ᵧᵠᵾ, reason: contains not printable characters */
    public final void m4624(C2019 c2019, boolean z) {
        C1103 c1103 = (C1103) ((ᵜᵪʾ) this).ˌᴵ;
        C1103 c11032 = c2019.f8027;
        ˈᵲᵢ();
        m5026();
        String strM5415 = c2019.m5415();
        ᵘᵞʿⁱ.ᵶᵥᵝ(strM5415);
        ContentValues contentValues = new ContentValues();
        contentValues.put("app_id", strM5415);
        EnumC0174 enumC0174 = EnumC0174.f1598;
        C2894 c2894 = this.f18892;
        if (z) {
            contentValues.put("app_instance_id", (String) null);
        } else if (c2894.m6888(strM5415).m3073(enumC0174)) {
            contentValues.put("app_instance_id", c2019.m5396());
        }
        contentValues.put("gmp_app_id", c2019.m5402());
        if (c2894.m6888(strM5415).m3073(EnumC0174.f1599)) {
            C1961 c1961 = c11032.f4707;
            C1103.m3564(c1961);
            c1961.m5243();
            contentValues.put("resettable_device_id_hash", c2019.f8020);
        }
        C1961 c19612 = c11032.f4707;
        C1103.m3564(c19612);
        c19612.m5243();
        contentValues.put("last_bundle_index", Long.valueOf(c2019.f8029));
        C1961 c19613 = c11032.f4707;
        C1103.m3564(c19613);
        c19613.m5243();
        contentValues.put("last_bundle_start_timestamp", Long.valueOf(c2019.f8003));
        C1961 c19614 = c11032.f4707;
        C1103.m3564(c19614);
        c19614.m5243();
        contentValues.put("last_bundle_end_timestamp", Long.valueOf(c2019.f8034));
        contentValues.put("app_version", c2019.m5414());
        C1961 c19615 = c11032.f4707;
        C1103.m3564(c19615);
        c19615.m5243();
        contentValues.put("app_store", c2019.f8023);
        C1961 c19616 = c11032.f4707;
        C1103.m3564(c19616);
        c19616.m5243();
        contentValues.put("gmp_version", Long.valueOf(c2019.f8015));
        C1961 c19617 = c11032.f4707;
        C1103.m3564(c19617);
        c19617.m5243();
        contentValues.put("dev_cert_hash", Long.valueOf(c2019.f8005));
        C1961 c19618 = c11032.f4707;
        C1103.m3564(c19618);
        c19618.m5243();
        contentValues.put("measurement_enabled", Boolean.valueOf(c2019.f8022));
        C1961 c19619 = c11032.f4707;
        C1961 c196110 = c11032.f4707;
        C1103.m3564(c19619);
        c19619.m5243();
        contentValues.put("day", Long.valueOf(c2019.f8004));
        C1103.m3564(c196110);
        c196110.m5243();
        contentValues.put("daily_public_events_count", Long.valueOf(c2019.f8001));
        C1103.m3564(c196110);
        c196110.m5243();
        contentValues.put("daily_events_count", Long.valueOf(c2019.f8013));
        C1103.m3564(c196110);
        c196110.m5243();
        contentValues.put("daily_conversions_count", Long.valueOf(c2019.f8028));
        C1961 c196111 = c11032.f4707;
        C1103.m3564(c196111);
        c196111.m5243();
        contentValues.put("config_fetched_time", Long.valueOf(c2019.f8016));
        C1961 c196112 = c11032.f4707;
        C1103.m3564(c196112);
        c196112.m5243();
        contentValues.put("failed_config_fetch_time", Long.valueOf(c2019.f7999));
        contentValues.put("app_version_int", Long.valueOf(c2019.m5400()));
        contentValues.put("firebase_instance_id", c2019.m5408());
        C1103.m3564(c196110);
        c196110.m5243();
        contentValues.put("daily_error_events_count", Long.valueOf(c2019.f8010));
        C1103.m3564(c196110);
        c196110.m5243();
        contentValues.put("daily_realtime_events_count", Long.valueOf(c2019.f7991));
        C1103.m3564(c196110);
        c196110.m5243();
        contentValues.put("health_monitor_sample", c2019.f7996);
        contentValues.put("android_id", (Long) 0L);
        C1961 c196113 = c11032.f4707;
        C1103.m3564(c196113);
        c196113.m5243();
        contentValues.put("adid_reporting_enabled", Boolean.valueOf(c2019.f8017));
        contentValues.put("dynamite_version", Long.valueOf(c2019.m5394()));
        if (c2894.m6888(strM5415).m3073(enumC0174)) {
            C1961 c196114 = c11032.f4707;
            C1103.m3564(c196114);
            c196114.m5243();
            contentValues.put("session_stitching_token", c2019.f8008);
        }
        contentValues.put("sgtm_upload_enabled", Boolean.valueOf(c2019.m5428()));
        C1961 c196115 = c11032.f4707;
        C1103.m3564(c196115);
        c196115.m5243();
        contentValues.put("target_os_version", Long.valueOf(c2019.f8006));
        C1961 c196116 = c11032.f4707;
        C1103.m3564(c196116);
        c196116.m5243();
        contentValues.put("session_stitching_token_hash", Long.valueOf(c2019.f8014));
        C0756.m2702();
        C3691 c3691 = c1103.f4726;
        C3485 c3485 = c1103.f4729;
        if (c3691.m8314(strM5415, AbstractC3818.f14557)) {
            C1961 c196117 = c11032.f4707;
            C1103.m3564(c196117);
            c196117.m5243();
            contentValues.put("ad_services_version", Integer.valueOf(c2019.f8012));
            C1961 c196118 = c11032.f4707;
            C1103.m3564(c196118);
            c196118.m5243();
            contentValues.put("attribution_eligibility_status", Long.valueOf(c2019.f7995));
        }
        C1961 c196119 = c11032.f4707;
        C1103.m3564(c196119);
        c196119.m5243();
        contentValues.put("unmatched_first_open_without_ad_id", Boolean.valueOf(c2019.f8021));
        contentValues.put("npa_metadata_value", c2019.m5416());
        C1961 c196120 = c11032.f4707;
        C1103.m3564(c196120);
        c196120.m5243();
        contentValues.put("bundle_delivery_index", Long.valueOf(c2019.f7992));
        contentValues.put("sgtm_preview_key", c2019.m5437());
        C1103.m3564(c196110);
        c196110.m5243();
        contentValues.put("dma_consent_state", Integer.valueOf(c2019.f8033));
        C1103.m3564(c196110);
        c196110.m5243();
        contentValues.put("daily_realtime_dcu_count", Integer.valueOf(c2019.f8011));
        contentValues.put("serialized_npa_metadata", c2019.m5401());
        contentValues.put("client_upload_eligibility", Integer.valueOf(c2019.m5412()));
        C1961 c196121 = c11032.f4707;
        C1103.m3564(c196121);
        c196121.m5243();
        ArrayList arrayList = c2019.f7997;
        if (arrayList != null) {
            if (arrayList.isEmpty()) {
                C1103.m3564(c3485);
                c3485.f13424.m4474(strM5415, "Safelisted events should not be an empty list. appId");
            } else {
                contentValues.put("safelisted_events", TextUtils.join(",", arrayList));
            }
        }
        if (c3691.m8314(null, AbstractC3818.f14567) && !contentValues.containsKey("safelisted_events")) {
            contentValues.put("safelisted_events", (String) null);
        }
        C1961 c196122 = c11032.f4707;
        C1103.m3564(c196122);
        c196122.m5243();
        contentValues.put("unmatched_pfo", c2019.f8024);
        C1961 c196123 = c11032.f4707;
        C1103.m3564(c196123);
        c196123.m5243();
        contentValues.put("unmatched_uwa", c2019.f8030);
        C1961 c196124 = c11032.f4707;
        C1103.m3564(c196124);
        c196124.m5243();
        contentValues.put("ad_campaign_info", c2019.f7998);
        if (c3691.m8314(strM5415, AbstractC3818.f14478)) {
            C1961 c196125 = c11032.f4707;
            C1103.m3564(c196125);
            c196125.m5243();
            contentValues.put("last_diagnostics_signal_upload_timestamp", Long.valueOf(c2019.f7993));
        }
        try {
            SQLiteDatabase sQLiteDatabaseM4625 = m4625();
            if (sQLiteDatabaseM4625.update("apps", contentValues, "app_id = ?", new String[]{strM5415}) == 0 && sQLiteDatabaseM4625.insertWithOnConflict("apps", null, contentValues, 5) == -1) {
                C1103.m3564(c3485);
                c3485.f13423.m4474(C3485.m7979(strM5415), "Failed to insert/update app (got -1). appId");
            }
        } catch (SQLiteException e) {
            C1103.m3564(c3485);
            c3485.f13423.m4475("Error storing app. appId", C3485.m7979(strM5415), e);
        }
    }

    /* JADX INFO: renamed from: ᵧᵢᵴᵸ, reason: contains not printable characters */
    public final SQLiteDatabase m4625() {
        ˈᵲᵢ();
        try {
            return this.f6692.getWritableDatabase();
        } catch (SQLiteException e) {
            C3485 c3485 = ((C1103) ((ᵜᵪʾ) this).ˌᴵ).f4729;
            C1103.m3564(c3485);
            c3485.f13424.m4474(e, "Error opening database");
            throw e;
        }
    }

    /* JADX INFO: renamed from: ᵨˈʼﹶ, reason: contains not printable characters */
    public final void m4626(List list) {
        ᵘᵞʿⁱ.ᵶᵥᵝ(list);
        ˈᵲᵢ();
        m5026();
        StringBuilder sb = new StringBuilder("rowid in (");
        for (int i = 0; i < list.size(); i++) {
            if (i != 0) {
                sb.append(",");
            }
            sb.append(((Long) list.get(i)).longValue());
        }
        sb.append(")");
        int iDelete = m4625().delete("raw_events", sb.toString(), null);
        if (iDelete != list.size()) {
            C3485 c3485 = ((C1103) ((ᵜᵪʾ) this).ˌᴵ).f4729;
            C1103.m3564(c3485);
            c3485.f13423.m4475("Deleted fewer rows from raw events table than expected", Integer.valueOf(iDelete), Integer.valueOf(list.size()));
        }
    }

    /* JADX INFO: renamed from: ᵫˈᵹ, reason: contains not printable characters */
    public final List m4627(String str) {
        List list;
        String string;
        C1103 c1103 = (C1103) ((ᵜᵪʾ) this).ˌᴵ;
        ˈᵲᵢ();
        m5026();
        ArrayList arrayList = new ArrayList();
        try {
            SQLiteDatabase sQLiteDatabaseM4625 = m4625();
            sQLiteDatabaseM4625.beginTransaction();
            Cursor cursorQuery = null;
            try {
                try {
                    cursorQuery = sQLiteDatabaseM4625.query("diagnostic_signals", new String[]{"signal_name", "metadata", "count"}, "app_id=?", new String[]{str}, null, null, "rowid", null);
                    if (cursorQuery.moveToFirst()) {
                        boolean zIsEmpty = str.isEmpty();
                        do {
                            String string2 = cursorQuery.getString(0);
                            if (cursorQuery.isNull(1)) {
                                string = "";
                            } else {
                                string = cursorQuery.getString(1);
                                ᵘᵞʿⁱ.ᵶᵥᵝ(string);
                            }
                            if (string2 == null) {
                                C3485 c3485 = c1103.f4729;
                                C1103.m3564(c3485);
                                c3485.f13423.m4474(C3485.m7979(str), "Read null value from diagnostic signals table, ignoring it. appId");
                            } else {
                                long j = cursorQuery.getLong(2);
                                C3926 c3926M9090 = C4163.m9090();
                                c3926M9090.m9868();
                                ((C4163) c3926M9090.f17955).m9091(string2);
                                c3926M9090.m9868();
                                ((C4163) c3926M9090.f17955).m9093(j);
                                c3926M9090.m9868();
                                ((C4163) c3926M9090.f17955).m9094(string);
                                if (zIsEmpty) {
                                    c3926M9090.m9868();
                                    ((C4163) c3926M9090.f17955).m9092();
                                }
                                arrayList.add((C4163) c3926M9090.m9869());
                            }
                        } while (cursorQuery.moveToNext());
                        sQLiteDatabaseM4625.delete("diagnostic_signals", "app_id=?", new String[]{str});
                        sQLiteDatabaseM4625.setTransactionSuccessful();
                        list = arrayList;
                    } else {
                        sQLiteDatabaseM4625.setTransactionSuccessful();
                        list = arrayList;
                    }
                } catch (SQLiteException e) {
                    C3485 c34852 = c1103.f4729;
                    C1103.m3564(c34852);
                    c34852.f13423.m4475("Error querying or deleting diagnostic signals. appId", C3485.m7979(str), e);
                    list = Collections.EMPTY_LIST;
                }
                if (cursorQuery != null) {
                    cursorQuery.close();
                }
                sQLiteDatabaseM4625.endTransaction();
                return list;
            } catch (Throwable th) {
                if (0 != 0) {
                    cursorQuery.close();
                }
                sQLiteDatabaseM4625.endTransaction();
                throw th;
            }
        } catch (SQLiteException e2) {
            C3485 c34853 = c1103.f4729;
            C1103.m3564(c34853);
            c34853.f13423.m4475("Error opening database for diagnostic signals. appId", C3485.m7979(str), e2);
            return Collections.EMPTY_LIST;
        }
    }

    /* JADX INFO: renamed from: ᵬᵦˋ, reason: contains not printable characters */
    public final C0875 m4628(String str) {
        ᵘᵞʿⁱ.ᵶᵥᵝ(str);
        ˈᵲᵢ();
        m5026();
        return C0875.m3065(100, m4621("select storage_consent_at_bundling from consent_settings where app_id=? limit 1;", new String[]{str}));
    }

    /* JADX INFO: renamed from: ᵮᵟᵡ, reason: contains not printable characters */
    public final void m4629() {
        m5026();
        m4625().beginTransaction();
    }

    /* JADX INFO: renamed from: ᵯˇ, reason: contains not printable characters */
    public final void m4630() {
        m5026();
        m4625().endTransaction();
    }

    /* JADX INFO: renamed from: ᵱᵭ, reason: contains not printable characters */
    public final void m4631(String str, String str2) {
        ᵘᵞʿⁱ.ˊᵫᵗ(str);
        ᵘᵞʿⁱ.ˊᵫᵗ(str2);
        ˈᵲᵢ();
        m5026();
        try {
            m4625().delete("user_attributes", "app_id=? and name=?", new String[]{str, str2});
        } catch (SQLiteException e) {
            C1103 c1103 = (C1103) ((ᵜᵪʾ) this).ˌᴵ;
            C3485 c3485 = c1103.f4729;
            C1103.m3564(c3485);
            c3485.f13423.m4477("Error deleting user property. appId", C3485.m7979(str), c1103.f4717.m5502(str2), e);
        }
    }

    /* JADX INFO: renamed from: ᵵᵬᵽ, reason: contains not printable characters */
    public final void m4632(Long l) {
        C1103 c1103 = (C1103) ((ᵜᵪʾ) this).ˌᴵ;
        ˈᵲᵢ();
        m5026();
        if (m4610()) {
            StringBuilder sb = new StringBuilder(l.toString().length() + 86);
            sb.append("SELECT COUNT(1) FROM upload_queue WHERE rowid = ");
            sb.append(l);
            sb.append(" AND retry_count =  2147483647 LIMIT 1");
            if (m4613(sb.toString(), null) > 0) {
                C3485 c3485 = c1103.f4729;
                C1103.m3564(c3485);
                c3485.f13424.m4476("The number of upload retries exceeds the limit. Will remain unchanged.");
            }
            try {
                SQLiteDatabase sQLiteDatabaseM4625 = m4625();
                c1103.f4701.getClass();
                long jCurrentTimeMillis = System.currentTimeMillis();
                StringBuilder sb2 = new StringBuilder(String.valueOf(jCurrentTimeMillis).length() + 60);
                sb2.append(" SET retry_count = retry_count + 1, last_upload_timestamp = ");
                sb2.append(jCurrentTimeMillis);
                String string = sb2.toString();
                StringBuilder sb3 = new StringBuilder(string.length() + 34 + l.toString().length() + 29);
                sb3.append("UPDATE upload_queue");
                sb3.append(string);
                sb3.append(" WHERE rowid = ");
                sb3.append(l);
                sb3.append(" AND retry_count < 2147483647");
                sQLiteDatabaseM4625.execSQL(sb3.toString());
            } catch (SQLiteException e) {
                C3485 c34852 = c1103.f4729;
                C1103.m3564(c34852);
                c34852.f13423.m4474(e, "Error incrementing retry count. error");
            }
        }
    }

    /* JADX INFO: renamed from: ᵵᵸᵕᵸ, reason: contains not printable characters */
    public final void m4633(String str, C0875 c0875) {
        ᵘᵞʿⁱ.ᵶᵥᵝ(str);
        ˈᵲᵢ();
        m5026();
        m4609(str, m4583(str));
        ContentValues contentValues = new ContentValues();
        contentValues.put("app_id", str);
        contentValues.put("storage_consent_at_bundling", c0875.m3071());
        m4622(contentValues);
    }

    /* JADX WARN: Code restructure failed: missing block: B:21:0x00b1, code lost:
    
        defpackage.C1103.m3564(r13);
        r13.f13423.m4474(1000, "Read more than the max allowed user properties, ignoring excess");
     */
    /* JADX WARN: Multi-variable type inference failed */
    /* JADX WARN: Removed duplicated region for block: B:49:0x012e  */
    /* JADX WARN: Removed duplicated region for block: B:53:0x0135  */
    /* JADX WARN: Type inference failed for: r3v0, types: [java.util.ArrayList] */
    /* JADX WARN: Type inference failed for: r3v1, types: [java.util.List] */
    /* JADX WARN: Type inference failed for: r3v3, types: [java.util.List] */
    /* JADX INFO: renamed from: ᵽˀᵥ, reason: contains not printable characters */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final List m4634(String str, String str2, String str3) throws Throwable {
        Cursor cursor;
        String str4;
        Cursor cursorQuery;
        String str5;
        C1103 c1103 = (C1103) ((ᵜᵪʾ) this).ˌᴵ;
        ᵘᵞʿⁱ.ˊᵫᵗ(str);
        ˈᵲᵢ();
        m5026();
        ?? arrayList = new ArrayList();
        try {
            ArrayList arrayList2 = new ArrayList(3);
            String str6 = str;
            arrayList2.add(str6);
            StringBuilder sb = new StringBuilder("app_id=?");
            if (!TextUtils.isEmpty(str2)) {
                arrayList2.add(str2);
                sb.append(" and origin=?");
            }
            if (!TextUtils.isEmpty(str3)) {
                StringBuilder sb2 = new StringBuilder(String.valueOf(str3).length() + 1);
                sb2.append(str3);
                sb2.append("*");
                arrayList2.add(sb2.toString());
                sb.append(" and name glob ?");
            }
            String[] strArr = (String[]) arrayList2.toArray(new String[arrayList2.size()]);
            String string = sb.toString();
            c1103.getClass();
            C3485 c3485 = c1103.f4729;
            cursorQuery = m4625().query("user_attributes", new String[]{"name", "set_timestamp", "value", "origin"}, string, strArr, null, null, "rowid", "1001");
            try {
                try {
                    if (cursorQuery.moveToFirst()) {
                        str4 = str2;
                        while (true) {
                            try {
                                if (arrayList.size() >= 1000) {
                                    break;
                                }
                                String string2 = cursorQuery.getString(0);
                                long j = cursorQuery.getLong(1);
                                Object objM4607 = m4607(cursorQuery, 2);
                                String string3 = cursorQuery.getString(3);
                                if (objM4607 == null) {
                                    try {
                                        C1103.m3564(c3485);
                                        c3485.f13423.m4477("(2)Read invalid user property value, ignoring it", C3485.m7979(str6), string3, str3);
                                        str5 = string3;
                                    } catch (SQLiteException e) {
                                        e = e;
                                        str5 = string3;
                                        cursor = cursorQuery;
                                        str4 = str5;
                                        try {
                                            C3485 c34852 = c1103.f4729;
                                            C1103.m3564(c34852);
                                            c34852.f13423.m4477("(2)Error querying user properties", C3485.m7979(str), str4, e);
                                            arrayList = Collections.EMPTY_LIST;
                                            cursorQuery = cursor;
                                        } catch (Throwable th) {
                                            th = th;
                                            if (cursor != null) {
                                            }
                                            throw th;
                                        }
                                    }
                                } else {
                                    str5 = string3;
                                    try {
                                        arrayList.add(new C4922(str, str5, string2, j, objM4607));
                                    } catch (SQLiteException e2) {
                                        e = e2;
                                        cursor = cursorQuery;
                                        str4 = str5;
                                        C3485 c348522 = c1103.f4729;
                                        C1103.m3564(c348522);
                                        c348522.f13423.m4477("(2)Error querying user properties", C3485.m7979(str), str4, e);
                                        arrayList = Collections.EMPTY_LIST;
                                        cursorQuery = cursor;
                                    }
                                }
                                if (!cursorQuery.moveToNext()) {
                                    break;
                                }
                                str6 = str;
                                str4 = str5;
                            } catch (SQLiteException e3) {
                                e = e3;
                                cursor = cursorQuery;
                                C3485 c3485222 = c1103.f4729;
                                C1103.m3564(c3485222);
                                c3485222.f13423.m4477("(2)Error querying user properties", C3485.m7979(str), str4, e);
                                arrayList = Collections.EMPTY_LIST;
                                cursorQuery = cursor;
                                if (cursorQuery != null) {
                                }
                                return arrayList;
                            }
                        }
                    }
                } catch (Throwable th2) {
                    th = th2;
                    cursor = cursorQuery;
                    if (cursor != null) {
                        cursor.close();
                    }
                    throw th;
                }
            } catch (SQLiteException e4) {
                e = e4;
                str4 = str2;
            }
        } catch (SQLiteException e5) {
            e = e5;
            str4 = str2;
            cursor = null;
        } catch (Throwable th3) {
            th = th3;
            cursor = null;
        }
        if (cursorQuery != null) {
            cursorQuery.close();
        }
        return arrayList;
    }
}
