package xyz.stream.utils;

import android.os.Bundle;
import android.os.SystemClock;
import com.google.android.gms.measurement.internal.m1;
import com.google.android.gms.measurement.internal.m3;
import com.google.android.gms.measurement.internal.n4;
import com.google.android.gms.measurement.internal.y0;
import java.io.File;

/* JADX INFO: loaded from: classes3.dex */
public final class k0 {

    /* JADX INFO: renamed from: e, reason: collision with root package name */
    public static volatile k0 f36156e;

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public Object f36157a;

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public long f36158b;

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public long f36159c;

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    public Object f36160d;

    public k0(String str, byte[] bArr, long j10, long j11) {
        this.f36157a = str;
        this.f36160d = bArr;
        this.f36158b = j10;
        this.f36159c = j11;
    }

    public static k0 a() {
        if (f36156e == null) {
            synchronized (k0.class) {
                try {
                    if (f36156e == null) {
                        k0 k0Var = new k0();
                        k0Var.f36158b = 0L;
                        k0Var.f36159c = 0L;
                        k0Var.f36157a = "";
                        f36156e = k0Var;
                    }
                } finally {
                }
            }
        }
        return f36156e;
    }

    public final void b(int i10) {
        StringBuilder sb = new StringBuilder();
        sb.append(e.d().f36112a.getCacheDir().getAbsolutePath());
        sb.append(i10 == 0 ? "/logs/sdk.log" : "/logs/video.log");
        File file = new File(sb.toString());
        if (file.exists()) {
            new Thread(new androidx.activity.n(this, i10, file, 22)).start();
        }
    }

    public final void c() {
        if (this.f36159c == 0 || SystemClock.uptimeMillis() - this.f36159c > 3600000) {
            this.f36159c = SystemClock.uptimeMillis();
            b(0);
        }
        if (this.f36158b == 0 || SystemClock.uptimeMillis() - this.f36158b > 3600000) {
            this.f36158b = SystemClock.uptimeMillis();
            b(1);
        }
    }

    public final boolean d(long j10, boolean z10, boolean z11) {
        ((m3) this.f36160d).w();
        ((m3) this.f36160d).D();
        if (((m1) ((m3) this.f36160d).f31277a).e()) {
            y0 y0VarU = ((m3) this.f36160d).u();
            ((i8.d) ((m3) this.f36160d).zzb()).getClass();
            y0VarU.f21999q.b(System.currentTimeMillis());
        }
        long j11 = j10 - this.f36158b;
        if (!z10 && j11 < 1000) {
            ((m3) this.f36160d).zzj().f21842n.b(Long.valueOf(j11), "Screen exposed for less than 1000 ms. Event not sent. time");
            return false;
        }
        if (!z11) {
            j11 = j10 - this.f36159c;
            this.f36159c = j10;
        }
        ((m3) this.f36160d).zzj().f21842n.b(Long.valueOf(j11), "Recording user engagement, ms");
        Bundle bundle = new Bundle();
        bundle.putLong("_et", j11);
        n4.X(((m3) this.f36160d).A().G(!((m3) this.f36160d).s().L()), bundle, true);
        if (!z11) {
            ((m3) this.f36160d).z().d0("auto", "_e", bundle);
        }
        this.f36158b = j10;
        ((com.google.android.gms.measurement.internal.p) this.f36157a).a();
        ((com.google.android.gms.measurement.internal.p) this.f36157a).b(((Long) com.google.android.gms.measurement.internal.z.f22022c0.a(null)).longValue());
        return true;
    }
}
