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

import android.os.Bundle;
import android.os.Parcel;
import android.util.Log;
import java.util.concurrent.atomic.AtomicReference;

/* JADX INFO: loaded from: classes.dex */
public final class G extends AbstractBinderC0720x implements L {

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

    /* JADX INFO: renamed from: f, reason: collision with root package name */
    public boolean f9591f;

    public G() {
        super("com.google.android.gms.measurement.api.internal.IBundleReceiver");
        this.f9590e = new AtomicReference();
    }

    /* JADX WARN: Code restructure failed: missing block: B:3:0x0002, code lost:
    
        r3 = r3.get("r");
     */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public static final Object e(Bundle bundle, Class cls) {
        Object obj;
        if (bundle == null || obj == null) {
            return null;
        }
        try {
            return cls.cast(obj);
        } catch (ClassCastException e8) {
            Log.w("AM", "Unexpected object type. Expected, Received: " + cls.getCanonicalName() + ", " + obj.getClass().getCanonicalName(), e8);
            throw e8;
        }
    }

    @Override // com.google.android.gms.internal.measurement.AbstractBinderC0720x
    public final boolean c(int i, Parcel parcel, Parcel parcel2) {
        if (i != 1) {
            return false;
        }
        Bundle bundle = (Bundle) AbstractC0725y.a(parcel, Bundle.CREATOR);
        AbstractC0725y.b(parcel);
        m(bundle);
        parcel2.writeNoException();
        return true;
    }

    public final Bundle d(long j8) {
        Bundle bundle;
        AtomicReference atomicReference = this.f9590e;
        synchronized (atomicReference) {
            if (!this.f9591f) {
                try {
                    atomicReference.wait(j8);
                } catch (InterruptedException unused) {
                    return null;
                }
            }
            bundle = (Bundle) this.f9590e.get();
        }
        return bundle;
    }

    @Override // com.google.android.gms.internal.measurement.L
    public final void m(Bundle bundle) {
        AtomicReference atomicReference = this.f9590e;
        synchronized (atomicReference) {
            try {
                try {
                    atomicReference.set(bundle);
                    this.f9591f = true;
                } finally {
                    this.f9590e.notify();
                }
            } catch (Throwable th) {
                throw th;
            }
        }
    }
}
