package androidx.work.impl.workers;

import android.content.Context;
import android.database.Cursor;
import androidx.work.Worker;
import androidx.work.WorkerParameters;
import androidx.work.impl.WorkDatabase;
import androidx.work.impl.WorkDatabase_Impl;
import java.util.ArrayList;
import java.util.concurrent.TimeUnit;
import o.AbstractC0277Kr;
import o.BP;
import o.C0585Wo;
import o.C0608Xl;
import o.C0669Zu;
import o.C0804bM;
import o.C1449i30;
import o.C2062oc0;
import o.C2651um0;
import o.C3031ym0;
import o.Co0;
import o.Dm0;
import o.Em0;
import o.Gm0;
import o.YT;

/* compiled from: r8-map-id-3b7cc9102578c509342fa2f0fabed2bfc72239cd258d579fc679bfcbc198b048 */
/* loaded from: classes.dex */
public final class DiagnosticsWorker extends Worker {
    public DiagnosticsWorker(Context context, WorkerParameters workerParameters) {
        super(context, workerParameters);
    }

    @Override // androidx.work.Worker
    public final C0804bM f() throws Throwable {
        C1449i30 c1449i30;
        C2062oc0 c2062oc0;
        C3031ym0 c3031ym0;
        Gm0 gm0;
        C2651um0 c2651um0H = C2651um0.H(this.l);
        WorkDatabase workDatabase = c2651um0H.m;
        Em0 em0S = workDatabase.s();
        C3031ym0 c3031ym0Q = workDatabase.q();
        Gm0 gm0T = workDatabase.t();
        C2062oc0 c2062oc0O = workDatabase.o();
        ((BP) c2651um0H.l.f).getClass();
        long jCurrentTimeMillis = System.currentTimeMillis() - TimeUnit.DAYS.toMillis(1L);
        em0S.getClass();
        C1449i30 c1449i30D = C1449i30.d(1, "SELECT * FROM workspec WHERE last_enqueue_time >= ? AND state IN (2, 3, 5) ORDER BY last_enqueue_time DESC");
        c1449i30D.B(1, jCurrentTimeMillis);
        WorkDatabase_Impl workDatabase_Impl = em0S.a;
        workDatabase_Impl.b();
        Cursor cursorL = workDatabase_Impl.l(c1449i30D);
        try {
            int iB = Co0.B(cursorL, "id");
            int iB2 = Co0.B(cursorL, "state");
            int iB3 = Co0.B(cursorL, "worker_class_name");
            int iB4 = Co0.B(cursorL, "input_merger_class_name");
            int iB5 = Co0.B(cursorL, "input");
            int iB6 = Co0.B(cursorL, "output");
            int iB7 = Co0.B(cursorL, "initial_delay");
            int iB8 = Co0.B(cursorL, "interval_duration");
            int iB9 = Co0.B(cursorL, "flex_duration");
            int iB10 = Co0.B(cursorL, "run_attempt_count");
            int iB11 = Co0.B(cursorL, "backoff_policy");
            c1449i30 = c1449i30D;
            try {
                int iB12 = Co0.B(cursorL, "backoff_delay_duration");
                int iB13 = Co0.B(cursorL, "last_enqueue_time");
                int iB14 = Co0.B(cursorL, "minimum_retention_duration");
                int iB15 = Co0.B(cursorL, "schedule_requested_at");
                int iB16 = Co0.B(cursorL, "run_in_foreground");
                int iB17 = Co0.B(cursorL, "out_of_quota_policy");
                int iB18 = Co0.B(cursorL, "period_count");
                int iB19 = Co0.B(cursorL, "generation");
                int iB20 = Co0.B(cursorL, "next_schedule_time_override");
                int iB21 = Co0.B(cursorL, "next_schedule_time_override_generation");
                int iB22 = Co0.B(cursorL, "stop_reason");
                int iB23 = Co0.B(cursorL, "required_network_type");
                int iB24 = Co0.B(cursorL, "requires_charging");
                int iB25 = Co0.B(cursorL, "requires_device_idle");
                int iB26 = Co0.B(cursorL, "requires_battery_not_low");
                int iB27 = Co0.B(cursorL, "requires_storage_not_low");
                int iB28 = Co0.B(cursorL, "trigger_content_update_delay");
                int iB29 = Co0.B(cursorL, "trigger_max_content_delay");
                int iB30 = Co0.B(cursorL, "content_uri_triggers");
                int i = iB14;
                ArrayList arrayList = new ArrayList(cursorL.getCount());
                while (cursorL.moveToNext()) {
                    byte[] blob = null;
                    String string = cursorL.isNull(iB) ? null : cursorL.getString(iB);
                    int iE = YT.E(cursorL.getInt(iB2));
                    String string2 = cursorL.isNull(iB3) ? null : cursorL.getString(iB3);
                    String string3 = cursorL.isNull(iB4) ? null : cursorL.getString(iB4);
                    C0585Wo c0585WoA = C0585Wo.a(cursorL.isNull(iB5) ? null : cursorL.getBlob(iB5));
                    C0585Wo c0585WoA2 = C0585Wo.a(cursorL.isNull(iB6) ? null : cursorL.getBlob(iB6));
                    long j = cursorL.getLong(iB7);
                    long j2 = cursorL.getLong(iB8);
                    long j3 = cursorL.getLong(iB9);
                    int i2 = cursorL.getInt(iB10);
                    int iB31 = YT.B(cursorL.getInt(iB11));
                    long j4 = cursorL.getLong(iB12);
                    long j5 = cursorL.getLong(iB13);
                    int i3 = i;
                    long j6 = cursorL.getLong(i3);
                    int i4 = iB9;
                    int i5 = iB15;
                    long j7 = cursorL.getLong(i5);
                    iB15 = i5;
                    int i6 = iB16;
                    boolean z = cursorL.getInt(i6) != 0;
                    iB16 = i6;
                    int i7 = iB17;
                    int iD = YT.D(cursorL.getInt(i7));
                    iB17 = i7;
                    int i8 = iB18;
                    int i9 = cursorL.getInt(i8);
                    iB18 = i8;
                    int i10 = iB19;
                    int i11 = cursorL.getInt(i10);
                    iB19 = i10;
                    int i12 = iB20;
                    long j8 = cursorL.getLong(i12);
                    iB20 = i12;
                    int i13 = iB21;
                    int i14 = cursorL.getInt(i13);
                    iB21 = i13;
                    int i15 = iB22;
                    int i16 = cursorL.getInt(i15);
                    iB22 = i15;
                    int i17 = iB23;
                    int iC = YT.C(cursorL.getInt(i17));
                    iB23 = i17;
                    int i18 = iB24;
                    boolean z2 = cursorL.getInt(i18) != 0;
                    iB24 = i18;
                    int i19 = iB25;
                    boolean z3 = cursorL.getInt(i19) != 0;
                    iB25 = i19;
                    int i20 = iB26;
                    boolean z4 = cursorL.getInt(i20) != 0;
                    iB26 = i20;
                    int i21 = iB27;
                    boolean z5 = cursorL.getInt(i21) != 0;
                    iB27 = i21;
                    int i22 = iB28;
                    long j9 = cursorL.getLong(i22);
                    iB28 = i22;
                    int i23 = iB29;
                    long j10 = cursorL.getLong(i23);
                    iB29 = i23;
                    int i24 = iB30;
                    if (!cursorL.isNull(i24)) {
                        blob = cursorL.getBlob(i24);
                    }
                    iB30 = i24;
                    arrayList.add(new Dm0(string, iE, string2, string3, c0585WoA, c0585WoA2, j, j2, j3, new C0608Xl(iC, z2, z3, z4, z5, j9, j10, YT.k(blob)), i2, iB31, j4, j5, j6, j7, z, iD, i9, i11, j8, i14, i16));
                    iB9 = i4;
                    i = i3;
                }
                cursorL.close();
                c1449i30.release();
                ArrayList arrayListD = em0S.d();
                ArrayList arrayListA = em0S.a();
                if (arrayList.isEmpty()) {
                    c2062oc0 = c2062oc0O;
                    c3031ym0 = c3031ym0Q;
                    gm0 = gm0T;
                } else {
                    C0669Zu c0669ZuE = C0669Zu.e();
                    int i25 = AbstractC0277Kr.a;
                    c0669ZuE.getClass();
                    C0669Zu c0669ZuE2 = C0669Zu.e();
                    c2062oc0 = c2062oc0O;
                    c3031ym0 = c3031ym0Q;
                    gm0 = gm0T;
                    AbstractC0277Kr.a(c3031ym0, gm0, c2062oc0, arrayList);
                    c0669ZuE2.getClass();
                }
                if (!arrayListD.isEmpty()) {
                    C0669Zu c0669ZuE3 = C0669Zu.e();
                    int i26 = AbstractC0277Kr.a;
                    c0669ZuE3.getClass();
                    C0669Zu c0669ZuE4 = C0669Zu.e();
                    AbstractC0277Kr.a(c3031ym0, gm0, c2062oc0, arrayListD);
                    c0669ZuE4.getClass();
                }
                if (!arrayListA.isEmpty()) {
                    C0669Zu c0669ZuE5 = C0669Zu.e();
                    int i27 = AbstractC0277Kr.a;
                    c0669ZuE5.getClass();
                    C0669Zu c0669ZuE6 = C0669Zu.e();
                    AbstractC0277Kr.a(c3031ym0, gm0, c2062oc0, arrayListA);
                    c0669ZuE6.getClass();
                }
                return new C0804bM(C0585Wo.b);
            } catch (Throwable th) {
                th = th;
                cursorL.close();
                c1449i30.release();
                throw th;
            }
        } catch (Throwable th2) {
            th = th2;
            c1449i30 = c1449i30D;
        }
    }
}
