package n4;

import android.os.Build;
import androidx.room.RoomDatabase;
import androidx.work.BackoffPolicy;
import androidx.work.NetworkType;
import androidx.work.OutOfQuotaPolicy;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.ObjectOutputStream;
import java.util.HashSet;

/* JADX INFO: loaded from: classes.dex */
public final class c extends androidx.room.i {

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

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

    /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
    public c(Object obj, RoomDatabase roomDatabase, int i10) {
        super(roomDatabase);
        this.f30805d = i10;
        this.f30806e = obj;
        nb.g.i(roomDatabase, "database");
    }

    @Override // androidx.room.t0
    public final String b() {
        switch (this.f30805d) {
            case 0:
                return "INSERT OR IGNORE INTO `Dependency` (`work_spec_id`,`prerequisite_id`) VALUES (?,?)";
            case 1:
                return "INSERT OR REPLACE INTO `Preference` (`key`,`long_value`) VALUES (?,?)";
            case 2:
                return "INSERT OR REPLACE INTO `SystemIdInfo` (`work_spec_id`,`system_id`) VALUES (?,?)";
            case 3:
                return "INSERT OR IGNORE INTO `WorkName` (`name`,`work_spec_id`) VALUES (?,?)";
            case 4:
                return "INSERT OR REPLACE INTO `WorkProgress` (`work_spec_id`,`progress`) VALUES (?,?)";
            case 5:
                return "INSERT OR IGNORE INTO `WorkSpec` (`id`,`state`,`worker_class_name`,`input_merger_class_name`,`input`,`output`,`initial_delay`,`interval_duration`,`flex_duration`,`run_attempt_count`,`backoff_policy`,`backoff_delay_duration`,`period_start_time`,`minimum_retention_duration`,`schedule_requested_at`,`run_in_foreground`,`out_of_quota_policy`,`required_network_type`,`requires_charging`,`requires_device_idle`,`requires_battery_not_low`,`requires_storage_not_low`,`trigger_content_update_delay`,`trigger_max_content_delay`,`content_uri_triggers`) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
            default:
                return "INSERT OR IGNORE INTO `WorkTag` (`tag`,`work_spec_id`) VALUES (?,?)";
        }
    }

    /* JADX WARN: Unsupported multi-entry loop pattern (BACK_EDGE: B:88:0x01cf -> B:99:0x01e9). Please report as a decompilation issue!!! */
    @Override // androidx.room.i
    public final void d(l3.j jVar, Object obj) throws Throwable {
        int i10;
        int i11;
        Throwable th;
        ObjectOutputStream objectOutputStream;
        HashSet<androidx.work.f> hashSet;
        int i12 = 2;
        switch (this.f30805d) {
            case 0:
                a aVar = (a) obj;
                String str = aVar.f30803a;
                if (str == null) {
                    jVar.d(1);
                } else {
                    jVar.l(1, str);
                }
                String str2 = aVar.f30804b;
                if (str2 == null) {
                    jVar.d(2);
                    return;
                } else {
                    jVar.l(2, str2);
                    return;
                }
            case 1:
                d dVar = (d) obj;
                String str3 = dVar.f30807a;
                if (str3 == null) {
                    jVar.d(1);
                } else {
                    jVar.l(1, str3);
                }
                Long l10 = dVar.mValue;
                if (l10 == null) {
                    jVar.d(2);
                    return;
                } else {
                    jVar.a(2, l10.longValue());
                    return;
                }
            case 2:
                String str4 = ((g) obj).f30808a;
                if (str4 == null) {
                    jVar.d(1);
                } else {
                    jVar.l(1, str4);
                }
                jVar.a(2, r0.f30809b);
                return;
            case 3:
                i iVar = (i) obj;
                String str5 = iVar.f30810a;
                if (str5 == null) {
                    jVar.d(1);
                } else {
                    jVar.l(1, str5);
                }
                String str6 = iVar.f30811b;
                if (str6 == null) {
                    jVar.d(2);
                    return;
                } else {
                    jVar.l(2, str6);
                    return;
                }
            case 4:
                k kVar = (k) obj;
                String str7 = kVar.f30812a;
                if (str7 == null) {
                    jVar.d(1);
                } else {
                    jVar.l(1, str7);
                }
                byte[] bArrB = androidx.work.i.b(kVar.f30813b);
                if (bArrB == null) {
                    jVar.d(2);
                    return;
                } else {
                    jVar.w(2, bArrB);
                    return;
                }
            case 5:
                o oVar = (o) obj;
                String str8 = oVar.f30818a;
                if (str8 == null) {
                    jVar.d(1);
                } else {
                    jVar.l(1, str8);
                }
                jVar.a(2, androidx.datastore.preferences.core.c.r(oVar.f30819b));
                String str9 = oVar.f30820c;
                if (str9 == null) {
                    jVar.d(3);
                } else {
                    jVar.l(3, str9);
                }
                String str10 = oVar.f30821d;
                if (str10 == null) {
                    jVar.d(4);
                } else {
                    jVar.l(4, str10);
                }
                byte[] bArrB2 = androidx.work.i.b(oVar.f30822e);
                if (bArrB2 == null) {
                    jVar.d(5);
                } else {
                    jVar.w(5, bArrB2);
                }
                byte[] bArrB3 = androidx.work.i.b(oVar.f30823f);
                if (bArrB3 == null) {
                    jVar.d(6);
                } else {
                    jVar.w(6, bArrB3);
                }
                jVar.a(7, oVar.f30824g);
                jVar.a(8, oVar.f30825h);
                jVar.a(9, oVar.f30826i);
                jVar.a(10, oVar.f30828k);
                BackoffPolicy backoffPolicy = oVar.f30829l;
                int iOrdinal = backoffPolicy.ordinal();
                if (iOrdinal == 0) {
                    i10 = 0;
                } else {
                    if (iOrdinal != 1) {
                        throw new IllegalArgumentException("Could not convert " + backoffPolicy + " to int");
                    }
                    i10 = 1;
                }
                jVar.a(11, i10);
                jVar.a(12, oVar.f30830m);
                jVar.a(13, oVar.f30831n);
                jVar.a(14, oVar.f30832o);
                jVar.a(15, oVar.f30833p);
                jVar.a(16, oVar.f30834q ? 1L : 0L);
                OutOfQuotaPolicy outOfQuotaPolicy = oVar.f30835r;
                int iOrdinal2 = outOfQuotaPolicy.ordinal();
                if (iOrdinal2 == 0) {
                    i11 = 0;
                } else {
                    if (iOrdinal2 != 1) {
                        throw new IllegalArgumentException("Could not convert " + outOfQuotaPolicy + " to int");
                    }
                    i11 = 1;
                }
                jVar.a(17, i11);
                androidx.work.e eVar = oVar.f30827j;
                if (eVar == null) {
                    jVar.d(18);
                    jVar.d(19);
                    jVar.d(20);
                    jVar.d(21);
                    jVar.d(22);
                    jVar.d(23);
                    jVar.d(24);
                    jVar.d(25);
                    return;
                }
                NetworkType networkType = eVar.f4549a;
                int iOrdinal3 = networkType.ordinal();
                if (iOrdinal3 == 0) {
                    i12 = 0;
                } else if (iOrdinal3 == 1) {
                    i12 = 1;
                } else if (iOrdinal3 != 2) {
                    if (iOrdinal3 == 3) {
                        i12 = 3;
                    } else if (iOrdinal3 == 4) {
                        i12 = 4;
                    } else {
                        if (Build.VERSION.SDK_INT < 30 || networkType != NetworkType.f4511f) {
                            throw new IllegalArgumentException("Could not convert " + networkType + " to int");
                        }
                        i12 = 5;
                    }
                }
                jVar.a(18, i12);
                jVar.a(19, eVar.f4550b ? 1L : 0L);
                jVar.a(20, eVar.f4551c ? 1L : 0L);
                jVar.a(21, eVar.f4552d ? 1L : 0L);
                jVar.a(22, eVar.f4553e ? 1L : 0L);
                jVar.a(23, eVar.f4554f);
                jVar.a(24, eVar.f4555g);
                androidx.work.g gVar = eVar.f4556h;
                byte[] byteArray = null;
                objectOutputStream = null;
                ObjectOutputStream objectOutputStream2 = null;
                if (gVar.f4559a.size() != 0) {
                    ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
                    try {
                        try {
                            try {
                                objectOutputStream = new ObjectOutputStream(byteArrayOutputStream);
                                hashSet = gVar.f4559a;
                            } catch (IOException e10) {
                                e = e10;
                            }
                        } catch (Throwable th2) {
                            th = th2;
                        }
                        try {
                            objectOutputStream.writeInt(hashSet.size());
                            for (androidx.work.f fVar : hashSet) {
                                objectOutputStream.writeUTF(fVar.f4557a.toString());
                                objectOutputStream.writeBoolean(fVar.f4558b);
                                break;
                            }
                            try {
                                objectOutputStream.close();
                            } catch (IOException e11) {
                                e11.printStackTrace();
                            }
                            byteArrayOutputStream.close();
                        } catch (IOException e12) {
                            e = e12;
                            objectOutputStream2 = objectOutputStream;
                            e.printStackTrace();
                            if (objectOutputStream2 != null) {
                                try {
                                    objectOutputStream2.close();
                                } catch (IOException e13) {
                                    e13.printStackTrace();
                                }
                            }
                            byteArrayOutputStream.close();
                        } catch (Throwable th3) {
                            th = th3;
                            objectOutputStream2 = objectOutputStream;
                            if (objectOutputStream2 != null) {
                                try {
                                    objectOutputStream2.close();
                                } catch (IOException e14) {
                                    e14.printStackTrace();
                                }
                            }
                            try {
                                byteArrayOutputStream.close();
                                throw th;
                            } catch (IOException e15) {
                                e15.printStackTrace();
                                throw th;
                            }
                        }
                    } catch (IOException e16) {
                        e16.printStackTrace();
                    }
                    byteArray = byteArrayOutputStream.toByteArray();
                }
                if (byteArray == null) {
                    jVar.d(25);
                    return;
                } else {
                    jVar.w(25, byteArray);
                    return;
                }
            default:
                s sVar = (s) obj;
                String str11 = sVar.f30848a;
                if (str11 == null) {
                    jVar.d(1);
                } else {
                    jVar.l(1, str11);
                }
                String str12 = sVar.f30849b;
                if (str12 == null) {
                    jVar.d(2);
                    return;
                } else {
                    jVar.l(2, str12);
                    return;
                }
        }
    }
}
