package com.google.android.gms.measurement.internal;

import android.app.ActivityManager;
import android.os.Bundle;
import android.os.SystemClock;
import android.text.TextUtils;
import com.google.android.gms.internal.measurement.zzs;
import java.util.EnumMap;
import java.util.List;

/* JADX INFO: loaded from: classes2.dex */
public final class h implements m4 {

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public final /* synthetic */ int f21646a;

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public final Object f21647b;

    public /* synthetic */ h(Object obj, int i10) {
        this.f21646a = i10;
        this.f21647b = obj;
    }

    public static h e(String str) {
        return new h((TextUtils.isEmpty(str) || str.length() > 1) ? zzjh.UNINITIALIZED : b2.e(str.charAt(0)), 1);
    }

    public final void a(long j10, boolean z10) {
        m3 m3Var = (m3) this.f21647b;
        m3Var.w();
        m3Var.G();
        if (m3Var.u().B(j10)) {
            m3Var.u().f21995m.a(true);
            m3Var.x().I();
        }
        m3Var.u().f21999q.b(j10);
        if (m3Var.u().f21995m.b()) {
            g(j10);
        }
    }

    public final void b(zzs zzsVar, String str, List list, boolean z10, boolean z11) {
        int i10 = i1.f21657a[zzsVar.ordinal()];
        Object obj = this.f21647b;
        r0 r0Var = i10 != 1 ? i10 != 2 ? i10 != 3 ? i10 != 4 ? ((e1) obj).zzj().f21840l : ((e1) obj).zzj().f21842n : z10 ? ((e1) obj).zzj().f21838j : !z11 ? ((e1) obj).zzj().f21839k : ((e1) obj).zzj().f21837i : z10 ? ((e1) obj).zzj().f21835g : !z11 ? ((e1) obj).zzj().f21836h : ((e1) obj).zzj().f21834f : ((e1) obj).zzj().f21841m;
        int size = list.size();
        if (size == 1) {
            r0Var.b(list.get(0), str);
            return;
        }
        if (size == 2) {
            r0Var.a(list.get(0), list.get(1), str);
        } else if (size != 3) {
            r0Var.c(str);
        } else {
            r0Var.d(str, list.get(0), list.get(1), list.get(2));
        }
    }

    /* JADX WARN: Removed duplicated region for block: B:14:0x001b  */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final void c(zzje$zza zzje_zza, int i10) {
        zzak zzakVar = zzak.UNSET;
        if (i10 == -30) {
            zzakVar = zzak.TCF;
        } else if (i10 == -20) {
            zzakVar = zzak.API;
        } else if (i10 == -10) {
            zzakVar = zzak.MANIFEST;
        } else if (i10 != 0) {
            if (i10 == 30) {
                zzakVar = zzak.INITIALIZATION;
            }
        }
        ((EnumMap) this.f21647b).put(zzje_zza, zzakVar);
    }

    public final void d(zzje$zza zzje_zza, zzak zzakVar) {
        ((EnumMap) this.f21647b).put(zzje_zza, zzakVar);
    }

    public final void f() {
        m3 m3Var = (m3) this.f21647b;
        m3Var.w();
        y0 y0VarU = m3Var.u();
        ((i8.d) m3Var.zzb()).getClass();
        if (y0VarU.B(System.currentTimeMillis())) {
            m3Var.u().f21995m.a(true);
            ActivityManager.RunningAppProcessInfo runningAppProcessInfo = new ActivityManager.RunningAppProcessInfo();
            ActivityManager.getMyMemoryState(runningAppProcessInfo);
            if (runningAppProcessInfo.importance == 100) {
                m3Var.zzj().f21842n.c("Detected application was in foreground");
                ((i8.d) m3Var.zzb()).getClass();
                g(System.currentTimeMillis());
            }
        }
    }

    public final void g(long j10) {
        m3 m3Var = (m3) this.f21647b;
        m3Var.w();
        if (((m1) m3Var.f31277a).e()) {
            m3Var.u().f21999q.b(j10);
            ((i8.d) m3Var.zzb()).getClass();
            long jElapsedRealtime = SystemClock.elapsedRealtime();
            p0 p0VarZzj = m3Var.zzj();
            p0VarZzj.f21842n.b(Long.valueOf(jElapsedRealtime), "Session started, time");
            Long lValueOf = Long.valueOf(j10 / 1000);
            m3Var.z().S("auto", "_sid", lValueOf, j10);
            y0 y0VarU = m3Var.u();
            y0VarU.f22000r.b(lValueOf.longValue());
            m3Var.u().f21995m.a(false);
            Bundle bundle = new Bundle();
            bundle.putLong("_sid", lValueOf.longValue());
            m3Var.z().Q("auto", "_s", bundle, j10);
            String strF = m3Var.u().f22005w.f();
            if (TextUtils.isEmpty(strF)) {
                return;
            }
            Bundle bundle2 = new Bundle();
            bundle2.putString("_ffr", strF);
            m3Var.z().Q("auto", "_ssr", bundle2, j10);
        }
    }

    public final String toString() {
        switch (this.f21646a) {
            case 0:
                StringBuilder sb = new StringBuilder("1");
                for (zzje$zza zzje_zza : zzje$zza.values()) {
                    zzak zzakVar = (zzak) ((EnumMap) this.f21647b).get(zzje_zza);
                    if (zzakVar == null) {
                        zzakVar = zzak.UNSET;
                    }
                    sb.append(zzakVar.zzl);
                }
                return sb.toString();
            default:
                return super.toString();
        }
    }

    @Override // com.google.android.gms.measurement.internal.m4
    public final void zza(String str, String str2, Bundle bundle) {
        boolean zIsEmpty = TextUtils.isEmpty(str);
        Object obj = this.f21647b;
        if (!zIsEmpty) {
            ((m1) ((g2) obj).f31277a).getClass();
            throw new IllegalStateException("Unexpected call on client side");
        }
        g2 g2Var = (g2) obj;
        ((i8.d) g2Var.zzb()).getClass();
        g2Var.R("auto", str2, bundle, true, true, System.currentTimeMillis());
    }

    public h(c1 c1Var) {
        this.f21646a = 2;
        com.google.android.gms.common.internal.w.checkNotNull(c1Var);
        this.f21647b = c1Var;
    }

    public h() {
        this.f21646a = 0;
        this.f21647b = new EnumMap(zzje$zza.class);
    }

    public h(EnumMap enumMap) {
        this.f21646a = 0;
        EnumMap enumMap2 = new EnumMap(zzje$zza.class);
        this.f21647b = enumMap2;
        enumMap2.putAll(enumMap);
    }
}
