package o4;

import androidx.work.impl.WorkDatabase;
import com.google.android.gms.internal.atv_ads_framework.d1;

/* JADX INFO: loaded from: classes.dex */
public final class f {

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public final WorkDatabase f31387a;

    public f(WorkDatabase workDatabase) {
        this.f31387a = workDatabase;
    }

    public final int a(String str) {
        WorkDatabase workDatabase = this.f31387a;
        workDatabase.beginTransaction();
        try {
            Long longValue = ((d1) workDatabase.preferenceDao()).getLongValue(str);
            int i10 = 0;
            int iIntValue = longValue != null ? longValue.intValue() : 0;
            if (iIntValue != Integer.MAX_VALUE) {
                i10 = iIntValue + 1;
            }
            ((d1) workDatabase.preferenceDao()).k(new n4.d(str, i10));
            workDatabase.setTransactionSuccessful();
            workDatabase.endTransaction();
            return iIntValue;
        } catch (Throwable th) {
            workDatabase.endTransaction();
            throw th;
        }
    }
}
