package h6;

import android.database.Cursor;
import androidx.sqlite.db.SupportSQLiteStatement;
import f5.z;
import java.util.ArrayList;
import java.util.List;

/* loaded from: classes.dex */
public final class k implements j {

    /* renamed from: a, reason: collision with root package name */
    private final f5.r f20869a;

    /* renamed from: b, reason: collision with root package name */
    private final f5.j f20870b;

    /* renamed from: c, reason: collision with root package name */
    private final z f20871c;

    /* loaded from: classes.dex */
    class a extends f5.j {
        a(f5.r rVar) {
            super(rVar);
        }

        @Override // f5.z
        public String e() {
            return "INSERT OR REPLACE INTO `SystemIdInfo` (`work_spec_id`,`system_id`) VALUES (?,?)";
        }

        @Override // f5.j
        /* renamed from: l, reason: merged with bridge method [inline-methods] */
        public void i(SupportSQLiteStatement supportSQLiteStatement, i iVar) {
            String str = iVar.f20867a;
            if (str == null) {
                supportSQLiteStatement.bindNull(1);
            } else {
                supportSQLiteStatement.bindString(1, str);
            }
            supportSQLiteStatement.bindLong(2, iVar.f20868b);
        }
    }

    /* loaded from: classes.dex */
    class b extends z {
        b(f5.r rVar) {
            super(rVar);
        }

        @Override // f5.z
        public String e() {
            return "DELETE FROM SystemIdInfo where work_spec_id=?";
        }
    }

    public k(f5.r rVar) {
        this.f20869a = rVar;
        this.f20870b = new a(rVar);
        this.f20871c = new b(rVar);
    }

    @Override // h6.j
    public List a() {
        f5.u d10 = f5.u.d("SELECT DISTINCT work_spec_id FROM SystemIdInfo", 0);
        this.f20869a.d();
        Cursor b10 = h5.b.b(this.f20869a, d10, false, null);
        try {
            ArrayList arrayList = new ArrayList(b10.getCount());
            while (b10.moveToNext()) {
                arrayList.add(b10.getString(0));
            }
            return arrayList;
        } finally {
            b10.close();
            d10.release();
        }
    }

    @Override // h6.j
    public void b(i iVar) {
        this.f20869a.d();
        this.f20869a.e();
        try {
            this.f20870b.k(iVar);
            this.f20869a.C();
        } finally {
            this.f20869a.i();
        }
    }

    @Override // h6.j
    public i c(String str) {
        f5.u d10 = f5.u.d("SELECT `SystemIdInfo`.`work_spec_id` AS `work_spec_id`, `SystemIdInfo`.`system_id` AS `system_id` FROM SystemIdInfo WHERE work_spec_id=?", 1);
        if (str == null) {
            d10.bindNull(1);
        } else {
            d10.bindString(1, str);
        }
        this.f20869a.d();
        Cursor b10 = h5.b.b(this.f20869a, d10, false, null);
        try {
            return b10.moveToFirst() ? new i(b10.getString(h5.a.d(b10, "work_spec_id")), b10.getInt(h5.a.d(b10, "system_id"))) : null;
        } finally {
            b10.close();
            d10.release();
        }
    }

    @Override // h6.j
    public void d(String str) {
        this.f20869a.d();
        SupportSQLiteStatement b10 = this.f20871c.b();
        if (str == null) {
            b10.bindNull(1);
        } else {
            b10.bindString(1, str);
        }
        this.f20869a.e();
        try {
            b10.executeUpdateDelete();
            this.f20869a.C();
        } finally {
            this.f20869a.i();
            this.f20871c.h(b10);
        }
    }
}
