117 lines
5.8 KiB
Java
117 lines
5.8 KiB
Java
package d2;
|
|
|
|
import android.content.Context;
|
|
import android.database.sqlite.SQLiteDatabase;
|
|
import android.database.sqlite.SQLiteOpenHelper;
|
|
import java.util.Arrays;
|
|
import java.util.List;
|
|
|
|
/* loaded from: classes3.dex */
|
|
public final class j extends SQLiteOpenHelper {
|
|
|
|
/* renamed from: c, reason: collision with root package name */
|
|
public static final String f6191c = "INSERT INTO global_log_event_state VALUES (" + System.currentTimeMillis() + ")";
|
|
|
|
/* renamed from: d, reason: collision with root package name */
|
|
public static final int f6192d = 5;
|
|
|
|
/* renamed from: e, reason: collision with root package name */
|
|
public static final List f6193e = Arrays.asList(new i(0), new i(1), new i(2), new i(3), new i(4));
|
|
|
|
/* renamed from: a, reason: collision with root package name */
|
|
public final int f6194a;
|
|
|
|
/* renamed from: b, reason: collision with root package name */
|
|
public boolean f6195b;
|
|
|
|
public j(Context context, int i, String str) {
|
|
super(context, str, (SQLiteDatabase.CursorFactory) null, i);
|
|
this.f6195b = false;
|
|
this.f6194a = i;
|
|
}
|
|
|
|
public static void d(SQLiteDatabase sQLiteDatabase, int i, int i4) {
|
|
List list = f6193e;
|
|
if (i4 > list.size()) {
|
|
throw new IllegalArgumentException("Migration from " + i + " to " + i4 + " was requested, but cannot be performed. Only " + list.size() + " migrations are provided");
|
|
}
|
|
while (i < i4) {
|
|
switch (((i) list.get(i)).f6190a) {
|
|
case 0:
|
|
sQLiteDatabase.execSQL("CREATE TABLE events (_id INTEGER PRIMARY KEY, context_id INTEGER NOT NULL, transport_name TEXT NOT NULL, timestamp_ms INTEGER NOT NULL, uptime_ms INTEGER NOT NULL, payload BLOB NOT NULL, code INTEGER, num_attempts INTEGER NOT NULL,FOREIGN KEY (context_id) REFERENCES transport_contexts(_id) ON DELETE CASCADE)");
|
|
sQLiteDatabase.execSQL("CREATE TABLE event_metadata (_id INTEGER PRIMARY KEY, event_id INTEGER NOT NULL, name TEXT NOT NULL, value TEXT NOT NULL,FOREIGN KEY (event_id) REFERENCES events(_id) ON DELETE CASCADE)");
|
|
sQLiteDatabase.execSQL("CREATE TABLE transport_contexts (_id INTEGER PRIMARY KEY, backend_name TEXT NOT NULL, priority INTEGER NOT NULL, next_request_ms INTEGER NOT NULL)");
|
|
sQLiteDatabase.execSQL("CREATE INDEX events_backend_id on events(context_id)");
|
|
sQLiteDatabase.execSQL("CREATE UNIQUE INDEX contexts_backend_priority on transport_contexts(backend_name, priority)");
|
|
break;
|
|
case 1:
|
|
sQLiteDatabase.execSQL("ALTER TABLE transport_contexts ADD COLUMN extras BLOB");
|
|
sQLiteDatabase.execSQL("CREATE UNIQUE INDEX contexts_backend_priority_extras on transport_contexts(backend_name, priority, extras)");
|
|
sQLiteDatabase.execSQL("DROP INDEX contexts_backend_priority");
|
|
break;
|
|
case 2:
|
|
sQLiteDatabase.execSQL("ALTER TABLE events ADD COLUMN payload_encoding TEXT");
|
|
break;
|
|
case 3:
|
|
sQLiteDatabase.execSQL("ALTER TABLE events ADD COLUMN inline BOOLEAN NOT NULL DEFAULT 1");
|
|
sQLiteDatabase.execSQL("DROP TABLE IF EXISTS event_payloads");
|
|
sQLiteDatabase.execSQL("CREATE TABLE event_payloads (sequence_num INTEGER NOT NULL, event_id INTEGER NOT NULL, bytes BLOB NOT NULL,FOREIGN KEY (event_id) REFERENCES events(_id) ON DELETE CASCADE,PRIMARY KEY (sequence_num, event_id))");
|
|
break;
|
|
default:
|
|
sQLiteDatabase.execSQL("DROP TABLE IF EXISTS log_event_dropped");
|
|
sQLiteDatabase.execSQL("DROP TABLE IF EXISTS global_log_event_state");
|
|
sQLiteDatabase.execSQL("CREATE TABLE log_event_dropped (log_source VARCHAR(45) NOT NULL,reason INTEGER NOT NULL,events_dropped_count BIGINT NOT NULL,PRIMARY KEY(log_source, reason))");
|
|
sQLiteDatabase.execSQL("CREATE TABLE global_log_event_state (last_metrics_upload_ms BIGINT PRIMARY KEY)");
|
|
sQLiteDatabase.execSQL(f6191c);
|
|
break;
|
|
}
|
|
i++;
|
|
}
|
|
}
|
|
|
|
@Override // android.database.sqlite.SQLiteOpenHelper
|
|
public final void onConfigure(SQLiteDatabase sQLiteDatabase) {
|
|
this.f6195b = true;
|
|
sQLiteDatabase.rawQuery("PRAGMA busy_timeout=0;", new String[0]).close();
|
|
sQLiteDatabase.setForeignKeyConstraintsEnabled(true);
|
|
}
|
|
|
|
@Override // android.database.sqlite.SQLiteOpenHelper
|
|
public final void onCreate(SQLiteDatabase sQLiteDatabase) {
|
|
if (!this.f6195b) {
|
|
onConfigure(sQLiteDatabase);
|
|
}
|
|
d(sQLiteDatabase, 0, this.f6194a);
|
|
}
|
|
|
|
@Override // android.database.sqlite.SQLiteOpenHelper
|
|
public final void onDowngrade(SQLiteDatabase sQLiteDatabase, int i, int i4) {
|
|
sQLiteDatabase.execSQL("DROP TABLE events");
|
|
sQLiteDatabase.execSQL("DROP TABLE event_metadata");
|
|
sQLiteDatabase.execSQL("DROP TABLE transport_contexts");
|
|
sQLiteDatabase.execSQL("DROP TABLE IF EXISTS event_payloads");
|
|
sQLiteDatabase.execSQL("DROP TABLE IF EXISTS log_event_dropped");
|
|
sQLiteDatabase.execSQL("DROP TABLE IF EXISTS global_log_event_state");
|
|
if (!this.f6195b) {
|
|
onConfigure(sQLiteDatabase);
|
|
}
|
|
d(sQLiteDatabase, 0, i4);
|
|
}
|
|
|
|
@Override // android.database.sqlite.SQLiteOpenHelper
|
|
public final void onOpen(SQLiteDatabase sQLiteDatabase) {
|
|
if (this.f6195b) {
|
|
return;
|
|
}
|
|
onConfigure(sQLiteDatabase);
|
|
}
|
|
|
|
@Override // android.database.sqlite.SQLiteOpenHelper
|
|
public final void onUpgrade(SQLiteDatabase sQLiteDatabase, int i, int i4) {
|
|
if (!this.f6195b) {
|
|
onConfigure(sQLiteDatabase);
|
|
}
|
|
d(sQLiteDatabase, i, i4);
|
|
}
|
|
}
|