package F2;

import B0.A;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import d3.V0;
import e4.InterfaceC0876g;
import e4.RunnableC0873d;
import e4.ScheduledExecutorServiceC0875f;
import java.util.concurrent.Callable;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit;

/* JADX INFO: loaded from: classes.dex */
public final /* synthetic */ class g implements H2.b, InterfaceC0876g {

    /* JADX INFO: renamed from: q, reason: collision with root package name */
    public final /* synthetic */ int f2456q;

    /* JADX INFO: renamed from: r, reason: collision with root package name */
    public final /* synthetic */ long f2457r;

    /* JADX INFO: renamed from: s, reason: collision with root package name */
    public final /* synthetic */ Object f2458s;

    /* JADX INFO: renamed from: t, reason: collision with root package name */
    public final /* synthetic */ Object f2459t;

    /* JADX INFO: renamed from: u, reason: collision with root package name */
    public final /* synthetic */ Object f2460u;

    public /* synthetic */ g(i iVar, Iterable iterable, z2.i iVar2, long j8) {
        this.f2456q = 0;
        this.f2458s = iVar;
        this.f2459t = iterable;
        this.f2460u = iVar2;
        this.f2457r = j8;
    }

    @Override // e4.InterfaceC0876g
    public ScheduledFuture a(final V0 v02) {
        switch (this.f2456q) {
            case 1:
                ScheduledExecutorServiceC0875f scheduledExecutorServiceC0875f = (ScheduledExecutorServiceC0875f) this.f2458s;
                return scheduledExecutorServiceC0875f.f12460r.schedule(new RunnableC0873d(scheduledExecutorServiceC0875f, (Runnable) this.f2459t, v02, 1), this.f2457r, (TimeUnit) this.f2460u);
            default:
                final ScheduledExecutorServiceC0875f scheduledExecutorServiceC0875f2 = (ScheduledExecutorServiceC0875f) this.f2458s;
                final Callable callable = (Callable) this.f2459t;
                return scheduledExecutorServiceC0875f2.f12460r.schedule(new Callable() { // from class: e4.e
                    @Override // java.util.concurrent.Callable
                    public final Object call() {
                        ScheduledExecutorServiceC0875f scheduledExecutorServiceC0875f3 = scheduledExecutorServiceC0875f2;
                        return scheduledExecutorServiceC0875f3.f12459q.submit(new A(callable, 25, v02));
                    }
                }, this.f2457r, (TimeUnit) this.f2460u);
        }
    }

    @Override // H2.b
    public Object g() {
        i iVar = (i) this.f2458s;
        G2.h hVar = (G2.h) iVar.f2466c;
        hVar.getClass();
        Iterable iterable = (Iterable) this.f2459t;
        if (iterable.iterator().hasNext()) {
            String str = "UPDATE events SET num_attempts = num_attempts + 1 WHERE _id in " + G2.h.r(iterable);
            SQLiteDatabase sQLiteDatabaseA = hVar.a();
            sQLiteDatabaseA.beginTransaction();
            try {
                sQLiteDatabaseA.compileStatement(str).execute();
                Cursor cursorRawQuery = sQLiteDatabaseA.rawQuery("SELECT COUNT(*), transport_name FROM events WHERE num_attempts >= 16 GROUP BY transport_name", null);
                while (cursorRawQuery.moveToNext()) {
                    try {
                        hVar.m(cursorRawQuery.getInt(0), C2.d.f1171v, cursorRawQuery.getString(1));
                    } catch (Throwable th) {
                        cursorRawQuery.close();
                        throw th;
                    }
                }
                cursorRawQuery.close();
                sQLiteDatabaseA.compileStatement("DELETE FROM events WHERE num_attempts >= 16").execute();
                sQLiteDatabaseA.setTransactionSuccessful();
            } finally {
                sQLiteDatabaseA.endTransaction();
            }
        }
        hVar.g(new G2.e(iVar.f2470g.d() + this.f2457r, (z2.i) this.f2460u));
        return null;
    }

    public /* synthetic */ g(ScheduledExecutorServiceC0875f scheduledExecutorServiceC0875f, Object obj, long j8, TimeUnit timeUnit, int i) {
        this.f2456q = i;
        this.f2458s = scheduledExecutorServiceC0875f;
        this.f2459t = obj;
        this.f2457r = j8;
        this.f2460u = timeUnit;
    }
}
