package com.flurry.android;

import java.io.ByteArrayOutputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.util.Map;

/* loaded from: /storage/emulated/0/Documents/jadec/sources/com.UBI.A90.WW/dex-files/0.dex */
final class ak {
    private int a;
    private String b;
    private Map<String, String> c;
    private long d;
    private boolean e;
    private long f;

    public ak(int i, String str, Map<String, String> map, long j, boolean z) {
        this.a = i;
        this.b = str;
        this.c = map;
        this.d = j;
        this.e = z;
    }

    public final boolean a(String str) {
        return this.e && this.f == 0 && this.b.equals(str);
    }

    public final void a(long j) {
        this.f = j - this.d;
        bc.a("FlurryAgent", "Ended event '" + this.b + "' (" + this.d + ") after " + this.f + "ms");
    }

    public final byte[] a() {
        DataOutputStream dataOutputStream;
        Throwable th;
        DataOutputStream dataOutputStream2;
        byte[] bArr;
        ByteArrayOutputStream byteArrayOutputStream;
        try {
            byteArrayOutputStream = new ByteArrayOutputStream();
            dataOutputStream = new DataOutputStream(byteArrayOutputStream);
        } catch (IOException e) {
            dataOutputStream2 = null;
        } catch (Throwable th2) {
            dataOutputStream = null;
            th = th2;
        }
        try {
            dataOutputStream.writeShort(this.a);
            dataOutputStream.writeUTF(this.b);
            if (this.c == null) {
                dataOutputStream.writeShort(0);
            } else {
                dataOutputStream.writeShort(this.c.size());
                for (Map.Entry<String, String> entry : this.c.entrySet()) {
                    dataOutputStream.writeUTF(y.a(entry.getKey()));
                    dataOutputStream.writeUTF(y.a(entry.getValue()));
                }
            }
            dataOutputStream.writeLong(this.d);
            dataOutputStream.writeLong(this.f);
            dataOutputStream.flush();
            bArr = byteArrayOutputStream.toByteArray();
            y.a(dataOutputStream);
        } catch (IOException e2) {
            dataOutputStream2 = dataOutputStream;
            try {
                bArr = new byte[0];
                y.a(dataOutputStream2);
                return bArr;
            } catch (Throwable th3) {
                th = th3;
                dataOutputStream = dataOutputStream2;
                y.a(dataOutputStream);
                throw th;
            }
        } catch (Throwable th4) {
            th = th4;
            y.a(dataOutputStream);
            throw th;
        }
        return bArr;
    }
}
