package defpackage;

import android.net.NetworkRequest;
import android.os.Build;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.ObjectOutputStream;
import java.util.ArrayList;
import java.util.Set;

/* JADX INFO: renamed from: ᵛٴˏ, reason: contains not printable characters */
/* JADX INFO: loaded from: classes3.dex */
public final class C2789 extends ᵱˉˈ {

    /* JADX INFO: renamed from: ˋˈ, reason: contains not printable characters */
    public final /* synthetic */ int f10731;

    public /* synthetic */ C2789(int i) {
        this.f10731 = i;
    }

    /* JADX INFO: renamed from: ˋˈ, reason: contains not printable characters */
    public final String m6777() {
        switch (this.f10731) {
            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`,`generation`,`system_id`) VALUES (?,?,?)";
            case 3:
                return "INSERT OR IGNORE INTO `WorkName` (`name`,`work_spec_id`) VALUES (?,?)";
            case 4:
                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`,`last_enqueue_time`,`minimum_retention_duration`,`schedule_requested_at`,`run_in_foreground`,`out_of_quota_policy`,`period_count`,`generation`,`next_schedule_time_override`,`next_schedule_time_override_generation`,`stop_reason`,`trace_tag`,`backoff_on_system_interruptions`,`required_network_type`,`required_network_request`,`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 INFO: renamed from: ᵨᵣ, reason: contains not printable characters */
    public final void m6778(InterfaceC4296 interfaceC4296, Object obj) throws IOException {
        int i;
        int i2;
        int[] iArrM9010;
        int[] iArrM90102;
        byte[] byteArray;
        byte[] byteArray2;
        int i3 = 3;
        switch (this.f10731) {
            case 0:
                C3104 c3104 = (C3104) obj;
                interfaceC4296.mo3333(1, c3104.f11880);
                interfaceC4296.mo3333(2, c3104.f11879);
                return;
            case 1:
                C3545 c3545 = (C3545) obj;
                interfaceC4296.mo3333(1, c3545.f13606);
                interfaceC4296.mo3328(c3545.f13605.longValue(), 2);
                return;
            case 2:
                interfaceC4296.mo3333(1, ((C2258) obj).f8923);
                interfaceC4296.mo3328(r13.f8921, 2);
                interfaceC4296.mo3328(r13.f8922, 3);
                return;
            case 3:
                C5387 c5387 = (C5387) obj;
                interfaceC4296.mo3333(1, c5387.f20404);
                interfaceC4296.mo3333(2, c5387.f20403);
                return;
            case 4:
                C2590 c2590 = (C2590) obj;
                interfaceC4296.mo3333(1, c2590.f10017);
                interfaceC4296.mo3328(AbstractC3481.m7937(c2590.f9998), 2);
                interfaceC4296.mo3333(3, c2590.f10006);
                interfaceC4296.mo3333(4, c2590.f10020);
                C1946 c1946 = C1946.f7745;
                interfaceC4296.mo3335(5, ᵬʕˎʽ.ᵨᵼⁱ(c2590.f10011));
                interfaceC4296.mo3335(6, ᵬʕˎʽ.ᵨᵼⁱ(c2590.f10022));
                interfaceC4296.mo3328(c2590.f10018, 7);
                interfaceC4296.mo3328(c2590.f10002, 8);
                interfaceC4296.mo3328(c2590.f10021, 9);
                interfaceC4296.mo3328(c2590.f10019, 10);
                int iM8218 = AbstractC3653.m8218(c2590.f10014);
                if (iM8218 == 0) {
                    i = 0;
                } else {
                    if (iM8218 != 1) {
                        C1685.m4561();
                        return;
                    }
                    i = 1;
                }
                interfaceC4296.mo3328(i, 11);
                interfaceC4296.mo3328(c2590.f10009, 12);
                interfaceC4296.mo3328(c2590.f10003, 13);
                interfaceC4296.mo3328(c2590.f10013, 14);
                interfaceC4296.mo3328(c2590.f10010, 15);
                interfaceC4296.mo3328(c2590.f10015 ? 1L : 0L, 16);
                int iM82182 = AbstractC3653.m8218(c2590.f10000);
                if (iM82182 == 0) {
                    i2 = 0;
                } else {
                    if (iM82182 != 1) {
                        C1685.m4561();
                        return;
                    }
                    i2 = 1;
                }
                interfaceC4296.mo3328(i2, 17);
                interfaceC4296.mo3328(c2590.f9999, 18);
                interfaceC4296.mo3328(c2590.f10005, 19);
                interfaceC4296.mo3328(c2590.f10001, 20);
                interfaceC4296.mo3328(c2590.f10004, 21);
                interfaceC4296.mo3328(c2590.f10008, 22);
                String str = c2590.f10007;
                if (str == null) {
                    interfaceC4296.mo3334(23);
                } else {
                    interfaceC4296.mo3333(23, str);
                }
                Boolean bool = c2590.f10012;
                if ((bool != null ? Integer.valueOf(bool.booleanValue() ? 1 : 0) : null) == null) {
                    interfaceC4296.mo3334(24);
                } else {
                    interfaceC4296.mo3328(r6.intValue(), 24);
                }
                C1078 c1078 = c2590.f10016;
                int i4 = c1078.f4608;
                int iM82183 = AbstractC3653.m8218(i4);
                if (iM82183 == 0) {
                    i3 = 0;
                } else if (iM82183 == 1) {
                    i3 = 1;
                } else if (iM82183 == 2) {
                    i3 = 2;
                } else if (iM82183 != 3) {
                    if (iM82183 == 4) {
                        i3 = 4;
                    } else if (Build.VERSION.SDK_INT < 30 || i4 != 6) {
                        C3226.m7372("Could not convert ", AbstractC0793.m2869(i4), " to int");
                        i3 = 0;
                    } else {
                        i3 = 5;
                    }
                }
                interfaceC4296.mo3328(i3, 25);
                C3512 c3512 = c1078.f4604;
                int i5 = Build.VERSION.SDK_INT;
                if (i5 < 28) {
                    byteArray = new byte[0];
                } else {
                    NetworkRequest networkRequest = (NetworkRequest) c3512.f13494;
                    if (networkRequest == null) {
                        byteArray = new byte[0];
                    } else {
                        ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
                        try {
                            ObjectOutputStream objectOutputStream = new ObjectOutputStream(byteArrayOutputStream);
                            try {
                                if (i5 >= 31) {
                                    iArrM9010 = AbstractC5241.m10805(networkRequest);
                                } else {
                                    int[] iArr = {2, 0, 3, 6, 10, 9, 8, 4, 1, 5};
                                    ArrayList arrayList = new ArrayList();
                                    for (int i6 = 0; i6 < 10; i6++) {
                                        int i7 = iArr[i6];
                                        if (AbstractC0562.m2160(networkRequest, i7)) {
                                            arrayList.add(Integer.valueOf(i7));
                                        }
                                    }
                                    iArrM9010 = AbstractC4126.m9010(arrayList);
                                }
                                if (Build.VERSION.SDK_INT >= 31) {
                                    iArrM90102 = AbstractC5241.m10806(networkRequest);
                                } else {
                                    int[] iArr2 = {17, 5, 2, 10, 29, 19, 3, 32, 7, 4, 12, 36, 23, 0, 33, 20, 11, 13, 18, 21, 15, 35, 34, 8, 1, 25, 14, 16, 6, 9};
                                    ArrayList arrayList2 = new ArrayList();
                                    for (int i8 = 0; i8 < 30; i8++) {
                                        int i9 = iArr2[i8];
                                        if (AbstractC0562.m2156(networkRequest, i9)) {
                                            arrayList2.add(Integer.valueOf(i9));
                                        }
                                    }
                                    iArrM90102 = AbstractC4126.m9010(arrayList2);
                                }
                                objectOutputStream.writeInt(iArrM9010.length);
                                for (int i10 : iArrM9010) {
                                    objectOutputStream.writeInt(i10);
                                }
                                objectOutputStream.writeInt(iArrM90102.length);
                                for (int i11 : iArrM90102) {
                                    objectOutputStream.writeInt(i11);
                                }
                                objectOutputStream.close();
                                byteArrayOutputStream.close();
                                byteArray = byteArrayOutputStream.toByteArray();
                            } finally {
                            }
                        } finally {
                        }
                    }
                }
                interfaceC4296.mo3335(26, byteArray);
                interfaceC4296.mo3328(c1078.f4606 ? 1L : 0L, 27);
                interfaceC4296.mo3328(c1078.f4610 ? 1L : 0L, 28);
                interfaceC4296.mo3328(c1078.f4607 ? 1L : 0L, 29);
                interfaceC4296.mo3328(c1078.f4612 ? 1L : 0L, 30);
                interfaceC4296.mo3328(c1078.f4609, 31);
                interfaceC4296.mo3328(c1078.f4605, 32);
                Set<C3646> set = c1078.f4611;
                if (set.isEmpty()) {
                    byteArray2 = new byte[0];
                } else {
                    ByteArrayOutputStream byteArrayOutputStream2 = new ByteArrayOutputStream();
                    try {
                        ObjectOutputStream objectOutputStream2 = new ObjectOutputStream(byteArrayOutputStream2);
                        try {
                            objectOutputStream2.writeInt(set.size());
                            for (C3646 c3646 : set) {
                                objectOutputStream2.writeUTF(c3646.f13855.toString());
                                objectOutputStream2.writeBoolean(c3646.f13854);
                                break;
                            }
                            objectOutputStream2.close();
                            byteArrayOutputStream2.close();
                            byteArray2 = byteArrayOutputStream2.toByteArray();
                        } finally {
                        }
                    } finally {
                    }
                }
                interfaceC4296.mo3335(33, byteArray2);
                return;
            default:
                C4626 c4626 = (C4626) obj;
                interfaceC4296.mo3333(1, c4626.f17593);
                interfaceC4296.mo3333(2, c4626.f17592);
                return;
        }
    }
}
