package o;

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 com.google.android.gms.common.util.Clock;

/* compiled from: r8-map-id-3b7cc9102578c509342fa2f0fabed2bfc72239cd258d579fc679bfcbc198b048 */
/* renamed from: o.vo0, reason: case insensitive filesystem */
/* loaded from: classes.dex */
public final class C2750vo0 extends SQLiteOpenHelper {
    public final /* synthetic */ int l;
    public final /* synthetic */ Eu0 m;

    /* JADX WARN: 'this' call moved to the top of the method (can break code semantics) */
    public C2750vo0(C2940xo0 c2940xo0, Context context) {
        this(context, "google_app_measurement.db");
        this.l = 0;
        this.m = c2940xo0;
    }

    @Override // android.database.sqlite.SQLiteOpenHelper
    public final SQLiteDatabase getWritableDatabase() {
        switch (this.l) {
            case 0:
                C2940xo0 c2940xo0 = (C2940xo0) this.m;
                Kr0 kr0 = (Kr0) c2940xo0.a;
                Kr0 kr02 = (Kr0) c2940xo0.a;
                kr0.getClass();
                C0189Hh c0189Hh = c2940xo0.e;
                if (c0189Hh.m != 0 && ((Clock) c0189Hh.n).elapsedRealtime() - c0189Hh.m < 3600000) {
                    throw new SQLiteException("Database open failed");
                }
                try {
                    return super.getWritableDatabase();
                } catch (SQLiteException unused) {
                    c0189Hh.m = ((Clock) c0189Hh.n).elapsedRealtime();
                    Nq0 nq0 = kr02.f;
                    Kr0.l(nq0);
                    nq0.f.b("Opening the database failed, dropping and recreating it");
                    if (!kr02.a.getDatabasePath("google_app_measurement.db").delete()) {
                        Nq0 nq02 = kr02.f;
                        Kr0.l(nq02);
                        nq02.f.c("google_app_measurement.db", "Failed to delete corrupted db file");
                    }
                    try {
                        SQLiteDatabase writableDatabase = super.getWritableDatabase();
                        c0189Hh.m = 0L;
                        return writableDatabase;
                    } catch (SQLiteException e) {
                        Nq0 nq03 = kr02.f;
                        Kr0.l(nq03);
                        nq03.f.c(e, "Failed to open freshly created database");
                        throw e;
                    }
                }
            default:
                Cq0 cq0 = (Cq0) this.m;
                try {
                    return super.getWritableDatabase();
                } catch (SQLiteDatabaseLockedException e2) {
                    throw e2;
                } catch (SQLiteException unused2) {
                    Kr0 kr03 = (Kr0) cq0.a;
                    Nq0 nq04 = kr03.f;
                    Kr0.l(nq04);
                    nq04.f.b("Opening the local database failed, dropping and recreating it");
                    if (!kr03.a.getDatabasePath("google_app_measurement_local.db").delete()) {
                        Nq0 nq05 = kr03.f;
                        Kr0.l(nq05);
                        nq05.f.c("google_app_measurement_local.db", "Failed to delete corrupted local db file");
                    }
                    try {
                        return super.getWritableDatabase();
                    } catch (SQLiteException e3) {
                        Nq0 nq06 = ((Kr0) cq0.a).f;
                        Kr0.l(nq06);
                        nq06.f.c(e3, "Failed to open local database. Events will bypass local storage");
                        return null;
                    }
                }
        }
    }

    @Override // android.database.sqlite.SQLiteOpenHelper
    public final void onCreate(SQLiteDatabase sQLiteDatabase) {
        switch (this.l) {
            case 0:
                Nq0 nq0 = ((Kr0) ((C2940xo0) this.m).a).f;
                Kr0.l(nq0);
                AbstractC2841wm0.M(nq0, sQLiteDatabase);
                break;
            default:
                Nq0 nq02 = ((Kr0) ((Cq0) this.m).a).f;
                Kr0.l(nq02);
                AbstractC2841wm0.M(nq02, sQLiteDatabase);
                break;
        }
    }

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

    @Override // android.database.sqlite.SQLiteOpenHelper
    public final void onOpen(SQLiteDatabase sQLiteDatabase) throws Throwable {
        switch (this.l) {
            case 0:
                Kr0 kr0 = (Kr0) ((C2940xo0) this.m).a;
                Nq0 nq0 = kr0.f;
                Kr0.l(nq0);
                AbstractC2841wm0.L(nq0, 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", C2940xo0.f);
                Nq0 nq02 = kr0.f;
                Kr0.l(nq02);
                AbstractC2841wm0.L(nq02, 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", null);
                Kr0.l(nq02);
                AbstractC2841wm0.L(nq02, 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", null);
                Kr0.l(nq02);
                AbstractC2841wm0.L(nq02, 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", C2940xo0.h);
                Kr0.l(nq02);
                AbstractC2841wm0.L(nq02, 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", C2940xo0.i);
                Kr0.l(nq02);
                AbstractC2841wm0.L(nq02, 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", C2940xo0.k);
                Kr0.l(nq02);
                AbstractC2841wm0.L(nq02, 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", null);
                Kr0.l(nq02);
                AbstractC2841wm0.L(nq02, 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", C2940xo0.j);
                Kr0.l(nq02);
                AbstractC2841wm0.L(nq02, 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", C2940xo0.l);
                Kr0.l(nq02);
                AbstractC2841wm0.L(nq02, 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", C2940xo0.m);
                Kr0.l(nq02);
                AbstractC2841wm0.L(nq02, 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", null);
                Kr0.l(nq02);
                AbstractC2841wm0.L(nq02, 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", C2940xo0.n);
                Kr0.l(nq02);
                AbstractC2841wm0.L(nq02, 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", null);
                Kr0.l(nq02);
                AbstractC2841wm0.L(nq02, 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", null);
                Kr0.l(nq02);
                AbstractC2841wm0.L(nq02, 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", C2940xo0.f794o);
                Xv0.a();
                Kr0.l(nq02);
                AbstractC2841wm0.L(nq02, 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", C2940xo0.p);
                Kr0.l(nq02);
                AbstractC2841wm0.L(nq02, 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", C2940xo0.g);
                Kr0.l(nq02);
                AbstractC2841wm0.L(nq02, 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", null);
                break;
            default:
                Nq0 nq03 = ((Kr0) ((Cq0) this.m).a).f;
                Kr0.l(nq03);
                AbstractC2841wm0.L(nq03, sQLiteDatabase, "messages", "create table if not exists messages ( type INTEGER NOT NULL, entry BLOB NOT NULL)", "type,entry", Cq0.e);
                break;
        }
    }

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

    /* JADX WARN: 'this' call moved to the top of the method (can break code semantics) */
    public C2750vo0(Cq0 cq0, Context context) {
        this(context, "google_app_measurement_local.db");
        this.l = 1;
        this.m = cq0;
    }

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

    private final void b(SQLiteDatabase sQLiteDatabase, int i, int i2) {
    }

    private final void c(SQLiteDatabase sQLiteDatabase, int i, int i2) {
    }

    private final void d(SQLiteDatabase sQLiteDatabase, int i, int i2) {
    }

    private final void f(SQLiteDatabase sQLiteDatabase, int i, int i2) {
    }
}
