package defpackage;

import android.database.Cursor;
import android.database.sqlite.SQLiteException;
import com.hierynomus.protocol.transport.TransportException;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

/* renamed from: ᵳᵗʛˊ, reason: contains not printable characters */
/* loaded from: classes3.dex */
public final class C4574 {

    /* renamed from: ˏᵙ, reason: contains not printable characters */
    public final /* synthetic */ Object f17005;

    /* renamed from: ᵥᵯˎ, reason: contains not printable characters */
    public long f17006;

    /* renamed from: ᵴᵳ, reason: contains not printable characters */
    public final Object f17007;

    public C4574(C3500 c3500, C0515 c0515, long j) {
        this.f17005 = c3500;
        this.f17007 = c0515;
        this.f17006 = j;
    }

    public C4574(C5218 c5218, String str) {
        this.f17005 = c5218;
        ᵩʛʽ.ˏˋٴ(str);
        this.f17007 = str;
        this.f17006 = -1L;
    }

    public C4574(C5218 c5218, String str, long j) {
        this.f17005 = c5218;
        ᵩʛʽ.ˏˋٴ(str);
        this.f17007 = str;
        this.f17006 = c5218.m10815("select rowid from raw_events where app_id = ? and timestamp < ? order by rowid desc limit 1", new String[]{str, String.valueOf(j)}, -1L);
    }

    /* renamed from: ᵥᵯˎ, reason: contains not printable characters */
    public void m9727() {
        C3500 c3500 = (C3500) this.f17005;
        EnumC2857 enumC2857 = (EnumC2857) ((C1326) c3500.f13111.f18820).f5442;
        C0515 c0515 = (C0515) this.f17007;
        long j = c0515.f2676;
        long j2 = c0515.f2675;
        C1069 c1069 = new C1069(4, enumC2857, EnumC2703.f10482);
        C0663 c0663 = (C0663) ((InterfaceC4029) ((ᵢˇᵭ) c1069).ᵧᵾˀˈ);
        c0663.f3286 = j;
        if (j2 != 0) {
            c0663.f3294 |= 2;
            c0663.f3285 = j2;
        }
        try {
            c3500.f13118.ˌʾˀ(Long.valueOf(this.f17006)).m2660(c1069);
        } catch (TransportException unused) {
            C3500.f13104.mo2394(c1069, "Failed to send {}");
        }
    }

    /* JADX WARN: Multi-variable type inference failed */
    /* JADX WARN: Type inference failed for: r3v2, types: [java.util.List] */
    /* renamed from: ᵴᵳ, reason: contains not printable characters */
    public List m9728() {
        ArrayList arrayList;
        C5218 c5218 = (C5218) this.f17005;
        ArrayList arrayList2 = new ArrayList();
        String str = (String) this.f17007;
        Cursor cursorQuery = null;
        try {
            try {
                cursorQuery = c5218.m10779().query("raw_events", new String[]{"rowid", "name", "timestamp", "metadata_fingerprint", "data", "realtime", "elapsed_time"}, "app_id = ? and rowid > ?", new String[]{str, String.valueOf(this.f17006)}, null, null, "rowid", "1000");
                if (cursorQuery.moveToFirst()) {
                    do {
                        long j = cursorQuery.getLong(0);
                        long j2 = cursorQuery.getLong(3);
                        boolean z = cursorQuery.getLong(5) == 1;
                        long j3 = cursorQuery.getLong(6);
                        byte[] blob = cursorQuery.getBlob(4);
                        if (j > this.f17006) {
                            this.f17006 = j;
                        }
                        try {
                            C0245 c0245 = (C0245) C1680.m4831(C2461.m6272(), blob);
                            String string = cursorQuery.getString(1);
                            if (string == null) {
                                string = "";
                            }
                            c0245.m1556(string);
                            long j4 = cursorQuery.getLong(2);
                            c0245.m11120();
                            ((C2461) c0245.f20589).m6274(j4);
                            c0245.m11120();
                            ((C2461) c0245.f20589).m6293(j3);
                            arrayList2.add(new C4749(j, j2, z, (C2461) c0245.m11118()));
                        } catch (IOException e) {
                            C1736 c1736 = ((C4205) ((ᵢˇᵭ) c5218).ᵧᵾˀˈ).f15715;
                            C4205.m9132(c1736);
                            c1736.f6937.m6037("Data loss. Failed to merge raw event. appId", C1736.m4941(str), e);
                        }
                    } while (cursorQuery.moveToNext());
                } else {
                    arrayList = Collections.EMPTY_LIST;
                }
            } finally {
                if (0 != 0) {
                    cursorQuery.close();
                }
            }
        } catch (SQLiteException e2) {
            C1736 c17362 = ((C4205) ((ᵢˇᵭ) c5218).ᵧᵾˀˈ).f15715;
            C4205.m9132(c17362);
            c17362.f6937.m6037("Data loss. Error querying raw events batch. appId", C1736.m4941(str), e2);
            arrayList = arrayList2;
        }
        return arrayList;
    }
}
