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;

/* JADX INFO: renamed from: ˌᵩﾞᵴ, reason: contains not printable characters */
/* JADX INFO: loaded from: classes3.dex */
public final /* synthetic */ class CallableC1632 implements Callable {

    /* JADX INFO: renamed from: ʽˈˋ, reason: contains not printable characters */
    public final /* synthetic */ C4655 f6518;

    /* JADX INFO: renamed from: ᵲᵶᵳˈ, reason: contains not printable characters */
    public final /* synthetic */ int f6519;

    public /* synthetic */ CallableC1632(C4655 c4655, int i) {
        this.f6519 = i;
        this.f6518 = c4655;
    }

    /* JADX INFO: renamed from: ᵲᵶᵳˈ, reason: contains not printable characters */
    private final Object m4522() {
        String string;
        C4655 c4655 = this.f6518;
        synchronized (c4655) {
            try {
                C3846 c3846 = (C3846) c4655.f17686.get();
                ArrayList arrayListM8557 = c3846.m8557();
                c3846.m8555();
                JSONArray jSONArray = new JSONArray();
                for (int i = 0; i < arrayListM8557.size(); i++) {
                    C3438 c3438 = (C3438) arrayListM8557.get(i);
                    JSONObject jSONObject = new JSONObject();
                    jSONObject.put("agent", c3438.f13266);
                    jSONObject.put("dates", new JSONArray((Collection) c3438.f13265));
                    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.f6519) {
            case 0:
                return m4522();
            default:
                C4655 c4655 = this.f6518;
                synchronized (c4655) {
                    C3846 c3846 = (C3846) c4655.f17686.get();
                    long jCurrentTimeMillis = System.currentTimeMillis();
                    C4776 c4776 = (C4776) c4655.f17684.get();
                    C1014 c1014 = c4776.f18165;
                    boolean zIsEmpty = c1014.m3355().isEmpty();
                    String str = c4776.f18166;
                    if (!zIsEmpty) {
                        str = str + ' ' + C4776.m9961(c1014.m3355());
                    }
                    c3846.m8560(jCurrentTimeMillis, str);
                    break;
                }
                return null;
        }
    }
}
