package com.google.android.datatransport.runtime.scheduling.persistence;

import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.util.Base64;
import com.google.android.datatransport.runtime.j;
import com.google.android.datatransport.runtime.scheduling.persistence.SQLiteEventStore;
import defpackage.hi7;
import defpackage.nl2;
import java.util.ArrayList;
import java.util.List;

/* JADX INFO: loaded from: classes.dex */
public final /* synthetic */ class h implements SQLiteEventStore.b {
    public final /* synthetic */ int a;

    public /* synthetic */ h(int i) {
        this.a = i;
    }

    @Override // com.google.android.datatransport.runtime.scheduling.persistence.SQLiteEventStore.b
    public final Object apply(Object obj) {
        int i = 1;
        switch (this.a) {
            case 0:
                nl2 nl2Var = SQLiteEventStore.f;
                return (List) SQLiteEventStore.w(((SQLiteDatabase) obj).rawQuery("SELECT distinct t._id, t.backend_name, t.priority, t.extras FROM transport_contexts AS t, events AS e WHERE e.context_id = t._id", new String[0]), new h(i));
            default:
                Cursor cursor = (Cursor) obj;
                nl2 nl2Var2 = SQLiteEventStore.f;
                ArrayList arrayList = new ArrayList();
                while (cursor.moveToNext()) {
                    j.a aVarA = com.google.android.datatransport.runtime.j.a();
                    aVarA.b(cursor.getString(1));
                    aVarA.d(hi7.b(cursor.getInt(2)));
                    String string = cursor.getString(3);
                    aVarA.c(string == null ? null : Base64.decode(string, 0));
                    arrayList.add(aVarA.a());
                }
                return arrayList;
        }
    }
}
