package defpackage;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteDatabaseLockedException;
import android.database.sqlite.SQLiteException;
import android.database.sqlite.SQLiteOpenHelper;
import android.os.SystemClock;

/* JADX INFO: renamed from: ᵨᵢʩʝ, reason: contains not printable characters */
/* JADX INFO: loaded from: classes3.dex */
public final class C3760 extends SQLiteOpenHelper {

    /* JADX INFO: renamed from: ˌᴵ, reason: contains not printable characters */
    public final /* synthetic */ int f14306;

    /* JADX INFO: renamed from: ᵜᵪʾ, reason: contains not printable characters */
    public final /* synthetic */ ᵜᵪʾ f14307;

    public C3760(Context context, String str) {
        super(context, true == str.equals("") ? null : str, (SQLiteDatabase.CursorFactory) null, 1);
    }

    /* JADX WARN: 'this' call moved to the top of the method (can break code semantics) */
    public C3760(C1694 c1694, Context context) {
        this(context, "google_app_measurement.db");
        this.f14306 = 0;
        this.f14307 = c1694;
    }

    /* JADX WARN: 'this' call moved to the top of the method (can break code semantics) */
    public C3760(C4421 c4421, Context context) {
        this(context, "google_app_measurement_local.db");
        this.f14306 = 1;
        this.f14307 = c4421;
    }

    /* JADX INFO: renamed from: ːˏᵟᵯ, reason: contains not printable characters */
    private final void m8416(SQLiteDatabase sQLiteDatabase, int i, int i2) {
    }

    /* JADX INFO: renamed from: ᵟᵹᵙ, reason: contains not printable characters */
    private final void m8417(SQLiteDatabase sQLiteDatabase, int i, int i2) {
    }

    /* JADX INFO: renamed from: ᵱʡˏ, reason: contains not printable characters */
    private final void m8418(SQLiteDatabase sQLiteDatabase, int i, int i2) {
    }

    /* JADX INFO: renamed from: ᵲᵶᵳˈ, reason: contains not printable characters */
    private final void m8419(SQLiteDatabase sQLiteDatabase, int i, int i2) {
    }

    @Override // android.database.sqlite.SQLiteOpenHelper
    public final SQLiteDatabase getWritableDatabase() {
        int i = this.f14306;
        ᵜᵪʾ r1 = this.f14307;
        switch (i) {
            case 0:
                C1694 c1694 = (C1694) r1;
                C1103 c1103 = (C1103) ((ᵜᵪʾ) c1694).ˌᴵ;
                C1103 c11032 = (C1103) ((ᵜᵪʾ) c1694).ˌᴵ;
                c1103.getClass();
                C1705 c1705 = c1694.f6693;
                if (c1705.f6818 != 0) {
                    ((ᵠʽᵲ) c1705.f6817).getClass();
                    if (SystemClock.elapsedRealtime() - c1705.f6818 < 3600000) {
                        throw new SQLiteException("Database open failed");
                    }
                }
                try {
                    return super.getWritableDatabase();
                } catch (SQLiteException unused) {
                    ((ᵠʽᵲ) c1705.f6817).getClass();
                    c1705.f6818 = SystemClock.elapsedRealtime();
                    C3485 c3485 = c11032.f4729;
                    C1103.m3564(c3485);
                    c3485.f13423.m4476("Opening the database failed, dropping and recreating it");
                    if (!c11032.f4713.getDatabasePath("google_app_measurement.db").delete()) {
                        C3485 c34852 = c11032.f4729;
                        C1103.m3564(c34852);
                        c34852.f13423.m4474("google_app_measurement.db", "Failed to delete corrupted db file");
                    }
                    try {
                        SQLiteDatabase writableDatabase = super.getWritableDatabase();
                        c1705.f6818 = 0L;
                        return writableDatabase;
                    } catch (SQLiteException e) {
                        C3485 c34853 = c11032.f4729;
                        C1103.m3564(c34853);
                        c34853.f13423.m4474(e, "Failed to open freshly created database");
                        throw e;
                    }
                }
            default:
                C4421 c4421 = (C4421) r1;
                try {
                    return super.getWritableDatabase();
                } catch (SQLiteDatabaseLockedException e2) {
                    throw e2;
                } catch (SQLiteException unused2) {
                    C1103 c11033 = (C1103) ((ᵜᵪʾ) c4421).ˌᴵ;
                    C3485 c34854 = c11033.f4729;
                    C1103.m3564(c34854);
                    c34854.f13423.m4476("Opening the local database failed, dropping and recreating it");
                    if (!c11033.f4713.getDatabasePath("google_app_measurement_local.db").delete()) {
                        C3485 c34855 = c11033.f4729;
                        C1103.m3564(c34855);
                        c34855.f13423.m4474("google_app_measurement_local.db", "Failed to delete corrupted local db file");
                    }
                    try {
                        return super.getWritableDatabase();
                    } catch (SQLiteException e3) {
                        C3485 c34856 = ((C1103) ((ᵜᵪʾ) c4421).ˌᴵ).f4729;
                        C1103.m3564(c34856);
                        c34856.f13423.m4474(e3, "Failed to open local database. Events will bypass local storage");
                        return null;
                    }
                }
        }
    }

    @Override // android.database.sqlite.SQLiteOpenHelper
    public final void onCreate(SQLiteDatabase sQLiteDatabase) {
        int i = this.f14306;
        ᵜᵪʾ r1 = this.f14307;
        switch (i) {
            case 0:
                C3485 c3485 = ((C1103) ((ᵜᵪʾ) ((C1694) r1)).ˌᴵ).f4729;
                C1103.m3564(c3485);
                ᵹˊᵫˋ.ʿٴˇ(c3485, sQLiteDatabase);
                break;
            default:
                C3485 c34852 = ((C1103) ((ᵜᵪʾ) ((C4421) r1)).ˌᴵ).f4729;
                C1103.m3564(c34852);
                ᵹˊᵫˋ.ʿٴˇ(c34852, sQLiteDatabase);
                break;
        }
    }

    @Override // android.database.sqlite.SQLiteOpenHelper
    public final void onDowngrade(SQLiteDatabase sQLiteDatabase, int i, int i2) {
        int i3 = this.f14306;
    }

    @Override // android.database.sqlite.SQLiteOpenHelper
    public final void onOpen(SQLiteDatabase sQLiteDatabase) {
        int i = this.f14306;
        ᵜᵪʾ r12 = this.f14307;
        switch (i) {
            case 0:
                C1103 c1103 = (C1103) ((ᵜᵪʾ) ((C1694) r12)).ˌᴵ;
                C3485 c3485 = c1103.f4729;
                C1103.m3564(c3485);
                ᵹˊᵫˋ.ˑˊᵲ(c3485, sQLiteDatabase, "events", "CREATE TABLE IF NOT EXISTS events ( app_id TEXT NOT NULL, name TEXT NOT NULL, lifetime_count INTEGER NOT NULL, current_bundle_count INTEGER NOT NULL, last_fire_timestamp INTEGER NOT NULL, PRIMARY KEY (app_id, name)) ;", "app_id,name,lifetime_count,current_bundle_count,last_fire_timestamp", C1694.f6690);
                C3485 c34852 = c1103.f4729;
                C1103.m3564(c34852);
                ᵹˊᵫˋ.ˑˊᵲ(c34852, sQLiteDatabase, "events_snapshot", "CREATE TABLE IF NOT EXISTS events_snapshot ( app_id TEXT NOT NULL, name TEXT NOT NULL, lifetime_count INTEGER NOT NULL, current_bundle_count INTEGER NOT NULL, last_fire_timestamp INTEGER NOT NULL, last_bundled_timestamp INTEGER, last_bundled_day INTEGER, last_sampled_complex_event_id INTEGER, last_sampling_rate INTEGER, last_exempt_from_sampling INTEGER, current_session_count INTEGER, PRIMARY KEY (app_id, name)) ;", "app_id,name,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", (String[]) null);
                C1103.m3564(c34852);
                ᵹˊᵫˋ.ˑˊᵲ(c34852, sQLiteDatabase, "conditional_properties", "CREATE TABLE IF NOT EXISTS conditional_properties ( app_id TEXT NOT NULL, origin TEXT NOT NULL, name TEXT NOT NULL, value BLOB NOT NULL, creation_timestamp INTEGER NOT NULL, active INTEGER NOT NULL, trigger_event_name TEXT, trigger_timeout INTEGER NOT NULL, timed_out_event BLOB,triggered_event BLOB, triggered_timestamp INTEGER NOT NULL, time_to_live INTEGER NOT NULL, expired_event BLOB, PRIMARY KEY (app_id, name)) ;", "app_id,origin,name,value,active,trigger_event_name,trigger_timeout,creation_timestamp,timed_out_event,triggered_event,triggered_timestamp,time_to_live,expired_event", (String[]) null);
                C1103.m3564(c34852);
                ᵹˊᵫˋ.ˑˊᵲ(c34852, sQLiteDatabase, "user_attributes", "CREATE TABLE IF NOT EXISTS user_attributes ( app_id TEXT NOT NULL, name TEXT NOT NULL, set_timestamp INTEGER NOT NULL, value BLOB NOT NULL, PRIMARY KEY (app_id, name)) ;", "app_id,name,set_timestamp,value", C1694.f6687);
                C1103.m3564(c34852);
                ᵹˊᵫˋ.ˑˊᵲ(c34852, sQLiteDatabase, "apps", "CREATE TABLE IF NOT EXISTS apps ( app_id TEXT NOT NULL, app_instance_id TEXT, gmp_app_id TEXT, resettable_device_id_hash TEXT, last_bundle_index INTEGER NOT NULL, last_bundle_end_timestamp INTEGER NOT NULL, PRIMARY KEY (app_id)) ;", "app_id,app_instance_id,gmp_app_id,resettable_device_id_hash,last_bundle_index,last_bundle_end_timestamp", C1694.f6691);
                C1103.m3564(c34852);
                ᵹˊᵫˋ.ˑˊᵲ(c34852, sQLiteDatabase, "queue", "CREATE TABLE IF NOT EXISTS queue ( app_id TEXT NOT NULL, bundle_end_timestamp INTEGER NOT NULL, data BLOB NOT NULL);", "app_id,bundle_end_timestamp,data", C1694.f6681);
                C1103.m3564(c34852);
                ᵹˊᵫˋ.ˑˊᵲ(c34852, sQLiteDatabase, "raw_events_metadata", "CREATE TABLE IF NOT EXISTS raw_events_metadata ( app_id TEXT NOT NULL, metadata_fingerprint INTEGER NOT NULL, metadata BLOB NOT NULL, PRIMARY KEY (app_id, metadata_fingerprint));", "app_id,metadata_fingerprint,metadata", (String[]) null);
                C1103.m3564(c34852);
                ᵹˊᵫˋ.ˑˊᵲ(c34852, sQLiteDatabase, "raw_events", "CREATE TABLE IF NOT EXISTS raw_events ( app_id TEXT NOT NULL, name TEXT NOT NULL, timestamp INTEGER NOT NULL, metadata_fingerprint INTEGER NOT NULL, data BLOB NOT NULL);", "app_id,name,timestamp,metadata_fingerprint,data", C1694.f6688);
                C1103.m3564(c34852);
                ᵹˊᵫˋ.ˑˊᵲ(c34852, sQLiteDatabase, "event_filters", "CREATE TABLE IF NOT EXISTS event_filters ( app_id TEXT NOT NULL, audience_id INTEGER NOT NULL, filter_id INTEGER NOT NULL, event_name TEXT NOT NULL, data BLOB NOT NULL, PRIMARY KEY (app_id, event_name, audience_id, filter_id));", "app_id,audience_id,filter_id,event_name,data", C1694.f6689);
                C1103.m3564(c34852);
                ᵹˊᵫˋ.ˑˊᵲ(c34852, sQLiteDatabase, "property_filters", "CREATE TABLE IF NOT EXISTS property_filters ( app_id TEXT NOT NULL, audience_id INTEGER NOT NULL, filter_id INTEGER NOT NULL, property_name TEXT NOT NULL, data BLOB NOT NULL, PRIMARY KEY (app_id, property_name, audience_id, filter_id));", "app_id,audience_id,filter_id,property_name,data", C1694.f6685);
                C1103.m3564(c34852);
                ᵹˊᵫˋ.ˑˊᵲ(c34852, sQLiteDatabase, "audience_filter_values", "CREATE TABLE IF NOT EXISTS audience_filter_values ( app_id TEXT NOT NULL, audience_id INTEGER NOT NULL, current_results BLOB, PRIMARY KEY (app_id, audience_id));", "app_id,audience_id,current_results", (String[]) null);
                C1103.m3564(c34852);
                ᵹˊᵫˋ.ˑˊᵲ(c34852, sQLiteDatabase, "app2", "CREATE TABLE IF NOT EXISTS app2 ( app_id TEXT NOT NULL, first_open_count INTEGER NOT NULL, PRIMARY KEY (app_id));", "app_id,first_open_count", C1694.f6683);
                C1103.m3564(c34852);
                ᵹˊᵫˋ.ˑˊᵲ(c34852, sQLiteDatabase, "main_event_params", "CREATE TABLE IF NOT EXISTS main_event_params ( app_id TEXT NOT NULL, event_id TEXT NOT NULL, children_to_process INTEGER NOT NULL, main_event BLOB NOT NULL, PRIMARY KEY (app_id));", "app_id,event_id,children_to_process,main_event", (String[]) null);
                C1103.m3564(c34852);
                ᵹˊᵫˋ.ˑˊᵲ(c34852, sQLiteDatabase, "default_event_params", "CREATE TABLE IF NOT EXISTS default_event_params ( app_id TEXT NOT NULL, parameters BLOB NOT NULL, PRIMARY KEY (app_id));", "app_id,parameters", (String[]) null);
                C1103.m3564(c34852);
                ᵹˊᵫˋ.ˑˊᵲ(c34852, sQLiteDatabase, "consent_settings", "CREATE TABLE IF NOT EXISTS consent_settings ( app_id TEXT NOT NULL, consent_state TEXT NOT NULL, PRIMARY KEY (app_id));", "app_id,consent_state", C1694.f6682);
                C0756.m2702();
                C1103.m3564(c34852);
                ᵹˊᵫˋ.ˑˊᵲ(c34852, sQLiteDatabase, "trigger_uris", "CREATE TABLE IF NOT EXISTS trigger_uris ( app_id TEXT NOT NULL, trigger_uri TEXT NOT NULL, timestamp_millis INTEGER NOT NULL, source INTEGER NOT NULL);", "app_id,trigger_uri,source,timestamp_millis", C1694.f6686);
                C1103.m3564(c34852);
                ᵹˊᵫˋ.ˑˊᵲ(c34852, sQLiteDatabase, "upload_queue", "CREATE TABLE IF NOT EXISTS upload_queue ( app_id TEXT NOT NULL, upload_uri TEXT NOT NULL, upload_headers TEXT NOT NULL, upload_type INTEGER NOT NULL, measurement_batch BLOB NOT NULL, retry_count INTEGER NOT NULL, creation_timestamp INTEGER NOT NULL );", "app_id,upload_uri,upload_headers,upload_type,measurement_batch,retry_count,creation_timestamp", C1694.f6684);
                C1103.m3564(c34852);
                ᵹˊᵫˋ.ˑˊᵲ(c34852, sQLiteDatabase, "diagnostic_signals", "CREATE TABLE IF NOT EXISTS diagnostic_signals ( app_id TEXT NOT NULL, signal_name TEXT NOT NULL, metadata TEXT NOT NULL, count INTEGER NOT NULL, last_increment_timestamp INTEGER NOT NULL);", "app_id,signal_name,metadata,count,last_increment_timestamp", (String[]) null);
                C1103.m3564(c34852);
                ᵹˊᵫˋ.ˑˊᵲ(c34852, sQLiteDatabase, "no_data_mode_events", "CREATE TABLE IF NOT EXISTS no_data_mode_events ( app_id TEXT NOT NULL, name TEXT NOT NULL, data BLOB NOT NULL, timestamp_millis INTEGER NOT NULL);", "app_id,name,data,timestamp_millis", (String[]) null);
                break;
            default:
                C3485 c34853 = ((C1103) ((ᵜᵪʾ) ((C4421) r12)).ˌᴵ).f4729;
                C1103.m3564(c34853);
                ᵹˊᵫˋ.ˑˊᵲ(c34853, sQLiteDatabase, "messages", "create table if not exists messages ( type INTEGER NOT NULL, entry BLOB NOT NULL)", "type,entry", C4421.f16821);
                break;
        }
    }

    @Override // android.database.sqlite.SQLiteOpenHelper
    public final void onUpgrade(SQLiteDatabase sQLiteDatabase, int i, int i2) {
        int i3 = this.f14306;
    }
}
