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;

/* renamed from: ᵲᐧᵕ, reason: contains not printable characters */
/* loaded from: classes3.dex */
public final class C4492 extends SQLiteOpenHelper {

    /* renamed from: ᵢˇᵭ, reason: contains not printable characters */
    public final /* synthetic */ ᵢˇᵭ f16746;

    /* renamed from: ᵧᵾˀˈ, reason: contains not printable characters */
    public final /* synthetic */ int f16747;

    public C4492(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 C4492(C1206 c1206, Context context) {
        this(context, "google_app_measurement_local.db");
        this.f16747 = 1;
        this.f16746 = c1206;
    }

    /* JADX WARN: 'this' call moved to the top of the method (can break code semantics) */
    public C4492(C5218 c5218, Context context) {
        this(context, "google_app_measurement.db");
        this.f16747 = 0;
        this.f16746 = c5218;
    }

    /* renamed from: ˌʾˀ, reason: contains not printable characters */
    private final void m9566(SQLiteDatabase sQLiteDatabase, int i, int i2) {
    }

    /* renamed from: ˏᵙ, reason: contains not printable characters */
    private final void m9567(SQLiteDatabase sQLiteDatabase, int i, int i2) {
    }

    /* renamed from: ᵞʡ, reason: contains not printable characters */
    private final void m9568(SQLiteDatabase sQLiteDatabase, int i, int i2) {
    }

    /* renamed from: ᵥᵯˎ, reason: contains not printable characters */
    private final void m9569(SQLiteDatabase sQLiteDatabase, int i, int i2) {
    }

    @Override // android.database.sqlite.SQLiteOpenHelper
    public final SQLiteDatabase getWritableDatabase() {
        int i = this.f16747;
        ᵢˇᵭ r1 = this.f16746;
        switch (i) {
            case 0:
                C5218 c5218 = (C5218) r1;
                C4205 c4205 = (C4205) ((ᵢˇᵭ) c5218).ᵧᵾˀˈ;
                C4205 c42052 = (C4205) ((ᵢˇᵭ) c5218).ᵧᵾˀˈ;
                c4205.getClass();
                C3293 c3293 = c5218.f19485;
                if (c3293.f12337 != 0) {
                    ((ˊᵻ) c3293.f12339).getClass();
                    if (SystemClock.elapsedRealtime() - c3293.f12337 < 3600000) {
                        throw new SQLiteException("Database open failed");
                    }
                }
                try {
                    return super.getWritableDatabase();
                } catch (SQLiteException unused) {
                    ((ˊᵻ) c3293.f12339).getClass();
                    c3293.f12337 = SystemClock.elapsedRealtime();
                    C1736 c1736 = c42052.f15715;
                    C4205.m9132(c1736);
                    c1736.f6937.m6038("Opening the database failed, dropping and recreating it");
                    if (!c42052.f15719.getDatabasePath("google_app_measurement.db").delete()) {
                        C1736 c17362 = c42052.f15715;
                        C4205.m9132(c17362);
                        c17362.f6937.m6039("google_app_measurement.db", "Failed to delete corrupted db file");
                    }
                    try {
                        SQLiteDatabase writableDatabase = super.getWritableDatabase();
                        c3293.f12337 = 0L;
                        return writableDatabase;
                    } catch (SQLiteException e) {
                        C1736 c17363 = c42052.f15715;
                        C4205.m9132(c17363);
                        c17363.f6937.m6039(e, "Failed to open freshly created database");
                        throw e;
                    }
                }
            default:
                C1206 c1206 = (C1206) r1;
                try {
                    return super.getWritableDatabase();
                } catch (SQLiteDatabaseLockedException e2) {
                    throw e2;
                } catch (SQLiteException unused2) {
                    C4205 c42053 = (C4205) ((ᵢˇᵭ) c1206).ᵧᵾˀˈ;
                    C1736 c17364 = c42053.f15715;
                    C4205.m9132(c17364);
                    c17364.f6937.m6038("Opening the local database failed, dropping and recreating it");
                    if (!c42053.f15719.getDatabasePath("google_app_measurement_local.db").delete()) {
                        C1736 c17365 = c42053.f15715;
                        C4205.m9132(c17365);
                        c17365.f6937.m6039("google_app_measurement_local.db", "Failed to delete corrupted local db file");
                    }
                    try {
                        return super.getWritableDatabase();
                    } catch (SQLiteException e3) {
                        C1736 c17366 = ((C4205) ((ᵢˇᵭ) c1206).ᵧᵾˀˈ).f15715;
                        C4205.m9132(c17366);
                        c17366.f6937.m6039(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.f16747;
        ᵢˇᵭ r1 = this.f16746;
        switch (i) {
            case 0:
                C1736 c1736 = ((C4205) ((ᵢˇᵭ) ((C5218) r1)).ᵧᵾˀˈ).f15715;
                C4205.m9132(c1736);
                ᵿᵧ.ˑᵝﹳᵜ(c1736, sQLiteDatabase);
                break;
            default:
                C1736 c17362 = ((C4205) ((ᵢˇᵭ) ((C1206) r1)).ᵧᵾˀˈ).f15715;
                C4205.m9132(c17362);
                ᵿᵧ.ˑᵝﹳᵜ(c17362, sQLiteDatabase);
                break;
        }
    }

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

    @Override // android.database.sqlite.SQLiteOpenHelper
    public final void onOpen(SQLiteDatabase sQLiteDatabase) {
        int i = this.f16747;
        ᵢˇᵭ r12 = this.f16746;
        switch (i) {
            case 0:
                C4205 c4205 = (C4205) ((ᵢˇᵭ) ((C5218) r12)).ᵧᵾˀˈ;
                C1736 c1736 = c4205.f15715;
                C4205.m9132(c1736);
                ᵿᵧ.ᵡᵘˎʽ(c1736, 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", C5218.f19480);
                C1736 c17362 = c4205.f15715;
                C4205.m9132(c17362);
                ᵿᵧ.ᵡᵘˎʽ(c17362, 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);
                C4205.m9132(c17362);
                ᵿᵧ.ᵡᵘˎʽ(c17362, 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);
                C4205.m9132(c17362);
                ᵿᵧ.ᵡᵘˎʽ(c17362, 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", C5218.f19479);
                C4205.m9132(c17362);
                ᵿᵧ.ᵡᵘˎʽ(c17362, 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", C5218.f19477);
                C4205.m9132(c17362);
                ᵿᵧ.ᵡᵘˎʽ(c17362, 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", C5218.f19482);
                C4205.m9132(c17362);
                ᵿᵧ.ᵡᵘˎʽ(c17362, 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);
                C4205.m9132(c17362);
                ᵿᵧ.ᵡᵘˎʽ(c17362, 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", C5218.f19476);
                C4205.m9132(c17362);
                ᵿᵧ.ᵡᵘˎʽ(c17362, 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", C5218.f19481);
                C4205.m9132(c17362);
                ᵿᵧ.ᵡᵘˎʽ(c17362, 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", C5218.f19484);
                C4205.m9132(c17362);
                ᵿᵧ.ᵡᵘˎʽ(c17362, 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);
                C4205.m9132(c17362);
                ᵿᵧ.ᵡᵘˎʽ(c17362, 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", C5218.f19478);
                C4205.m9132(c17362);
                ᵿᵧ.ᵡᵘˎʽ(c17362, 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);
                C4205.m9132(c17362);
                ᵿᵧ.ᵡᵘˎʽ(c17362, 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);
                C4205.m9132(c17362);
                ᵿᵧ.ᵡᵘˎʽ(c17362, 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", C5218.f19483);
                C0491.m2132();
                C4205.m9132(c17362);
                ᵿᵧ.ᵡᵘˎʽ(c17362, 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", C5218.f19475);
                C4205.m9132(c17362);
                ᵿᵧ.ᵡᵘˎʽ(c17362, 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", C5218.f19474);
                C4205.m9132(c17362);
                ᵿᵧ.ᵡᵘˎʽ(c17362, 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);
                C4205.m9132(c17362);
                ᵿᵧ.ᵡᵘˎʽ(c17362, 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:
                C1736 c17363 = ((C4205) ((ᵢˇᵭ) ((C1206) r12)).ᵧᵾˀˈ).f15715;
                C4205.m9132(c17363);
                ᵿᵧ.ᵡᵘˎʽ(c17363, sQLiteDatabase, "messages", "create table if not exists messages ( type INTEGER NOT NULL, entry BLOB NOT NULL)", "type,entry", C1206.f5129);
                break;
        }
    }

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