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

import android.app.PendingIntent;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.os.Looper;
import androidx.annotation.Nullable;
import java.util.concurrent.atomic.AtomicReference;

/* JADX INFO: loaded from: classes2.dex */
public abstract class w0 extends h implements DialogInterface.OnCancelListener {

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public volatile boolean f8299b;

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public final AtomicReference f8300c;

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    public final o8.e f8301d;

    /* JADX INFO: renamed from: e, reason: collision with root package name */
    public final e8.d f8302e;

    /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
    public w0(i iVar) {
        super(iVar);
        e8.d dVar = e8.d.f25520d;
        this.f8300c = new AtomicReference(null);
        this.f8301d = new o8.e(Looper.getMainLooper(), 0);
        this.f8302e = dVar;
    }

    private static final int zae(@Nullable t0 t0Var) {
        if (t0Var == null) {
            return -1;
        }
        return t0Var.f8290a;
    }

    public final void b(e8.b bVar, int i10) {
        this.f8300c.set(null);
        ((x) this).f8304g.j(bVar, i10);
    }

    @Override // com.google.android.gms.common.api.internal.h
    public final void onActivityResult(int i10, int i11, Intent intent) {
        AtomicReference atomicReference = this.f8300c;
        t0 t0Var = (t0) atomicReference.get();
        if (i10 != 1) {
            if (i10 == 2) {
                int iB = this.f8302e.b(a(), e8.e.f25521a);
                if (iB == 0) {
                    atomicReference.set(null);
                    o8.e eVar = ((x) this).f8304g.f8244k;
                    eVar.sendMessage(eVar.obtainMessage(3));
                    return;
                } else {
                    if (t0Var == null) {
                        return;
                    }
                    if (t0Var.f8291b.f25514b == 18 && iB == 18) {
                        return;
                    }
                }
            }
        } else if (i11 == -1) {
            atomicReference.set(null);
            o8.e eVar2 = ((x) this).f8304g.f8244k;
            eVar2.sendMessage(eVar2.obtainMessage(3));
            return;
        } else if (i11 == 0) {
            if (t0Var != null) {
                b(new e8.b(intent != null ? intent.getIntExtra("<<ResolutionFailureErrorDetail>>", 13) : 13, null, t0Var.f8291b.toString()), zae(t0Var));
                return;
            }
            return;
        }
        if (t0Var != null) {
            b(t0Var.f8291b, t0Var.f8290a);
        }
    }

    @Override // android.content.DialogInterface.OnCancelListener
    public final void onCancel(DialogInterface dialogInterface) {
        b(new e8.b(13, null), zae((t0) this.f8300c.get()));
    }

    @Override // com.google.android.gms.common.api.internal.h
    public final void onCreate(@Nullable Bundle bundle) {
        super.onCreate(bundle);
        if (bundle != null) {
            this.f8300c.set(bundle.getBoolean("resolving_error", false) ? new t0(new e8.b(bundle.getInt("failed_status"), (PendingIntent) bundle.getParcelable("failed_resolution")), bundle.getInt("failed_client_id", -1)) : null);
        }
    }
}
