package F2;

import android.content.ContentValues;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import g3.InterfaceC0983a;
import g3.o;
import g4.C0986a;
import java.util.HashMap;
import n4.C1300l0;

/* JADX INFO: loaded from: classes.dex */
public final /* synthetic */ class h implements H2.b, G2.f, InterfaceC0983a, D4.a {

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

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

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

    public /* synthetic */ h(Object obj, long j8, Object obj2) {
        this.f2462r = obj;
        this.f2461q = j8;
        this.f2463s = obj2;
    }

    @Override // G2.f
    public Object apply(Object obj) {
        SQLiteDatabase sQLiteDatabase = (SQLiteDatabase) obj;
        int i = ((C2.d) this.f2463s).f1175q;
        String string = Integer.toString(i);
        String str = (String) this.f2462r;
        Cursor cursorRawQuery = sQLiteDatabase.rawQuery("SELECT 1 FROM log_event_dropped WHERE log_source = ? AND reason = ?", new String[]{str, string});
        try {
            boolean z8 = cursorRawQuery.getCount() > 0;
            cursorRawQuery.close();
            long j8 = this.f2461q;
            if (z8) {
                sQLiteDatabase.execSQL("UPDATE log_event_dropped SET events_dropped_count = events_dropped_count + " + j8 + " WHERE log_source = ? AND reason = ?", new String[]{str, Integer.toString(i)});
                return null;
            }
            ContentValues contentValues = new ContentValues();
            contentValues.put("log_source", str);
            contentValues.put("reason", Integer.valueOf(i));
            contentValues.put("events_dropped_count", Long.valueOf(j8));
            sQLiteDatabase.insert("log_event_dropped", null, contentValues);
            return null;
        } catch (Throwable th) {
            cursorRawQuery.close();
            throw th;
        }
    }

    @Override // D4.a
    public void d(D4.b bVar) {
        ((C0986a) bVar.get()).d((String) this.f2462r, this.f2461q, (C1300l0) this.f2463s);
    }

    @Override // g3.InterfaceC0983a
    public Object e(o oVar) {
        return ((M4.i) this.f2462r).b(oVar, this.f2461q, (HashMap) this.f2463s);
    }

    @Override // H2.b
    public Object g() {
        i iVar = (i) this.f2462r;
        long jD = iVar.f2470g.d() + this.f2461q;
        G2.h hVar = (G2.h) iVar.f2466c;
        z2.i iVar2 = (z2.i) this.f2463s;
        hVar.getClass();
        hVar.g(new G2.e(jD, iVar2));
        return null;
    }

    public /* synthetic */ h(Object obj, Object obj2, long j8) {
        this.f2462r = obj;
        this.f2463s = obj2;
        this.f2461q = j8;
    }
}
