package k8;

import android.content.Context;
import android.os.IBinder;
import androidx.annotation.NonNull;
import com.google.android.gms.common.annotation.KeepForSdk;
import com.google.android.gms.common.internal.w;
import com.google.android.gms.dynamic.RemoteCreator$RemoteCreatorException;
import e8.g;

/* JADX INFO: loaded from: classes2.dex */
public abstract class c {
    private final String zza;
    private Object zzb;

    public c(String str) {
        this.zza = str;
    }

    public abstract Object getRemoteCreator(IBinder iBinder);

    @NonNull
    @KeepForSdk
    public final Object getRemoteCreatorInstance(@NonNull Context context) throws RemoteCreator$RemoteCreatorException {
        if (this.zzb == null) {
            w.checkNotNull(context);
            Context remoteContext = g.getRemoteContext(context);
            if (remoteContext == null) {
                throw new RemoteCreator$RemoteCreatorException("Could not get remote context.");
            }
            try {
                this.zzb = getRemoteCreator((IBinder) remoteContext.getClassLoader().loadClass(this.zza).newInstance());
            } catch (ClassNotFoundException e10) {
                throw new RemoteCreator$RemoteCreatorException("Could not load creator class.", e10);
            } catch (IllegalAccessException e11) {
                throw new RemoteCreator$RemoteCreatorException("Could not access creator.", e11);
            } catch (InstantiationException e12) {
                throw new RemoteCreator$RemoteCreatorException("Could not instantiate creator.", e12);
            }
        }
        return this.zzb;
    }
}
