package defpackage;

import android.util.Base64OutputStream;
import java.io.ByteArrayOutputStream;
import java.util.ArrayList;
import java.util.Collection;
import java.util.concurrent.Callable;
import java.util.zip.GZIPOutputStream;
import org.json.JSONArray;
import org.json.JSONObject;

/* renamed from: ˁᵱᵭˉ, reason: contains not printable characters */
/* loaded from: classes3.dex */
public final /* synthetic */ class CallableC0750 implements Callable {

    /* renamed from: ᵥᵯˎ, reason: contains not printable characters */
    public final /* synthetic */ int f3601;

    /* renamed from: ᵴᵳ, reason: contains not printable characters */
    public final /* synthetic */ C1054 f3602;

    public /* synthetic */ CallableC0750(C1054 c1054, int i) {
        this.f3601 = i;
        this.f3602 = c1054;
    }

    /* renamed from: ᵥᵯˎ, reason: contains not printable characters */
    private final Object m2816() {
        String string;
        C1054 c1054 = this.f3602;
        synchronized (c1054) {
            try {
                C4839 c4839 = (C4839) c1054.f4577.get();
                ArrayList arrayListM10170 = c4839.m10170();
                c4839.m10172();
                JSONArray jSONArray = new JSONArray();
                for (int i = 0; i < arrayListM10170.size(); i++) {
                    C3005 c3005 = (C3005) arrayListM10170.get(i);
                    JSONObject jSONObject = new JSONObject();
                    jSONObject.put("agent", c3005.f11586);
                    jSONObject.put("dates", new JSONArray((Collection) c3005.f11587));
                    jSONArray.put(jSONObject);
                }
                JSONObject jSONObject2 = new JSONObject();
                jSONObject2.put("heartbeats", jSONArray);
                jSONObject2.put("version", "2");
                ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
                Base64OutputStream base64OutputStream = new Base64OutputStream(byteArrayOutputStream, 11);
                try {
                    GZIPOutputStream gZIPOutputStream = new GZIPOutputStream(base64OutputStream);
                    try {
                        gZIPOutputStream.write(jSONObject2.toString().getBytes("UTF-8"));
                        gZIPOutputStream.close();
                        base64OutputStream.close();
                        string = byteArrayOutputStream.toString("UTF-8");
                    } finally {
                    }
                } finally {
                }
            } catch (Throwable th) {
                throw th;
            }
        }
        return string;
    }

    @Override // java.util.concurrent.Callable
    public final Object call() {
        switch (this.f3601) {
            case 0:
                return m2816();
            default:
                C1054 c1054 = this.f3602;
                synchronized (c1054) {
                    C4839 c4839 = (C4839) c1054.f4577.get();
                    long jCurrentTimeMillis = System.currentTimeMillis();
                    C3113 c3113 = (C3113) c1054.f4576.get();
                    ᵤٴˁ r4 = c3113.f11874;
                    boolean zIsEmpty = r4.ᵴᵳ().isEmpty();
                    String str = c3113.f11873;
                    if (!zIsEmpty) {
                        str = str + ' ' + C3113.m7450(r4.ᵴᵳ());
                    }
                    c4839.m10168(jCurrentTimeMillis, str);
                }
                return null;
        }
    }
}
