package com.google.android.gms.common.api.internal;

import android.content.Intent;
import android.os.Bundle;
import android.os.Looper;
import androidx.annotation.Nullable;
import java.io.FileDescriptor;
import java.io.PrintWriter;
import java.util.Collections;
import java.util.Iterator;
import java.util.Map;

/* JADX INFO: loaded from: classes2.dex */
public final class a1 {

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public final Map f8219a = Collections.synchronizedMap(new androidx.collection.f());

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public int f8220b = 0;

    @Nullable
    private Bundle zzc;

    public final void a(h hVar) {
        Map map = this.f8219a;
        if (map.containsKey("ConnectionlessLifecycleHelper")) {
            StringBuilder sb = new StringBuilder("ConnectionlessLifecycleHelper".length() + 59);
            sb.append("LifecycleCallback with tag ConnectionlessLifecycleHelper already added to this fragment.");
            throw new IllegalArgumentException(sb.toString());
        }
        map.put("ConnectionlessLifecycleHelper", hVar);
        if (this.f8220b > 0) {
            new o8.e(Looper.getMainLooper(), 2).post(new n0.a(this, hVar));
        }
    }

    public final void b(Bundle bundle) {
        if (bundle == null) {
            return;
        }
        for (Map.Entry entry : this.f8219a.entrySet()) {
            Bundle bundle2 = new Bundle();
            t0 t0Var = (t0) ((w0) ((h) entry.getValue())).f8300c.get();
            if (t0Var != null) {
                bundle2.putBoolean("resolving_error", true);
                bundle2.putInt("failed_client_id", t0Var.f8290a);
                e8.b bVar = t0Var.f8291b;
                bundle2.putInt("failed_status", bVar.f25514b);
                bundle2.putParcelable("failed_resolution", bVar.getResolution());
            }
            bundle.putBundle((String) entry.getKey(), bundle2);
        }
    }

    public final /* synthetic */ Bundle c() {
        return this.zzc;
    }

    @Nullable
    public final h zza(String str, Class cls) {
        return (h) cls.cast(this.f8219a.get(str));
    }

    public final void zze(@Nullable Bundle bundle) {
        this.f8220b = 1;
        this.zzc = bundle;
        for (Map.Entry entry : this.f8219a.entrySet()) {
            ((h) entry.getValue()).onCreate(bundle != null ? bundle.getBundle((String) entry.getKey()) : null);
        }
    }

    public final void zzh(int i10, int i11, @Nullable Intent intent) {
        Iterator it = this.f8219a.values().iterator();
        while (it.hasNext()) {
            ((h) it.next()).onActivityResult(i10, i11, intent);
        }
    }

    public final void zzl(String str, @Nullable FileDescriptor fileDescriptor, PrintWriter printWriter, @Nullable String[] strArr) {
        Iterator it = this.f8219a.values().iterator();
        while (it.hasNext()) {
            ((h) it.next()).dump(str, fileDescriptor, printWriter, strArr);
        }
    }
}
