package p138.p176.p177.p242.p265.p266;

import android.database.sqlite.SQLiteException;
import android.os.SystemClock;
import java.util.List;
import java.util.Map;
import p138.p176.p177.p242.p246.p253.C4312;

/* JADX INFO: renamed from: ދ.ހ.֏.ހ.ބ.֏.ү, reason: contains not printable characters */
/* JADX INFO: loaded from: classes.dex */
public final class C4855 implements InterfaceC4865 {

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public final /* synthetic */ String f14590;

    /* JADX INFO: renamed from: ؠ, reason: contains not printable characters */
    public final /* synthetic */ C4889 f14591;

    public C4855(C4889 c4889, String str) {
        this.f14591 = c4889;
        this.f14590 = str;
    }

    @Override // p138.p176.p177.p242.p265.p266.InterfaceC4865
    /* JADX INFO: renamed from: ֏ */
    public final void mo8029(String str, int i, Throwable th, byte[] bArr, Map<String, List<String>> map) {
        C4900 c4900M8301;
        long jLongValue;
        C4889 c4889 = this.f14591;
        c4889.m8310();
        c4889.m8305();
        if (bArr == null) {
            try {
                bArr = new byte[0];
            } finally {
                c4889.f14726 = false;
                c4889.m8282();
            }
        }
        List<Long> list = c4889.f14730;
        c4889.f14730 = null;
        boolean z = true;
        if ((i == 200 || i == 204) && th == null) {
            try {
                C4898 c4898 = c4889.f14718.m8501().f14648;
                if (((C4312) c4889.f14718.f15022) == null) {
                    throw null;
                }
                c4898.m8317(System.currentTimeMillis());
                c4889.f14718.m8501().f14649.m8317(0L);
                c4889.m8313();
                c4889.f14718.mo8165().f14452.m8036("Successful upload. Got network response. code, size", Integer.valueOf(i), Integer.valueOf(bArr.length));
                c4889.m8301().m8358();
                try {
                    for (Long l : list) {
                        try {
                            c4900M8301 = c4889.m8301();
                            jLongValue = l.longValue();
                            c4900M8301.mo8008();
                            c4900M8301.m8155();
                        } catch (SQLiteException e) {
                            if (c4889.f14731 == null || !c4889.f14731.contains(l)) {
                                throw e;
                            }
                        }
                        try {
                            if (c4900M8301.m8354().delete("queue", "rowid=?", new String[]{String.valueOf(jLongValue)}) != 1) {
                                throw new SQLiteException("Deleted fewer rows from queue than expected");
                            }
                        } catch (SQLiteException e2) {
                            c4900M8301.mo8165().f14444.m8035("Failed to delete a bundle in a queue table", e2);
                            throw e2;
                        }
                    }
                    c4889.m8301().m8353();
                    c4889.m8301().m8359();
                    c4889.f14731 = null;
                    if (c4889.m8299().m8534() && c4889.m8312()) {
                        c4889.m8306();
                    } else {
                        c4889.f14732 = -1L;
                        c4889.m8313();
                    }
                    c4889.f14721 = 0L;
                } catch (Throwable th2) {
                    c4889.m8301().m8359();
                    throw th2;
                }
            } catch (SQLiteException e3) {
                c4889.f14718.mo8165().f14444.m8035("Database error while trying to delete uploaded bundles", e3);
                if (((C4312) c4889.f14718.f15022) == null) {
                    throw null;
                }
                c4889.f14721 = SystemClock.elapsedRealtime();
                c4889.f14718.mo8165().f14452.m8035("Disable upload, time", Long.valueOf(c4889.f14721));
            }
        } else {
            c4889.f14718.mo8165().f14452.m8036("Network upload failed. Will retry later. code, error", Integer.valueOf(i), th);
            C4898 c48982 = c4889.f14718.m8501().f14649;
            if (((C4312) c4889.f14718.f15022) == null) {
                throw null;
            }
            c48982.m8317(System.currentTimeMillis());
            if (i != 503 && i != 429) {
                z = false;
            }
            if (z) {
                C4898 c48983 = c4889.f14718.m8501().f14650;
                if (((C4312) c4889.f14718.f15022) == null) {
                    throw null;
                }
                c48983.m8317(System.currentTimeMillis());
            }
            c4889.m8301().m8330(list);
            c4889.m8313();
        }
    }
}
