package com.facebook.appevents.iap; import androidx.annotation.RestrictTo; import com.facebook.internal.instrument.crashshield.CrashShieldHandler; import java.lang.reflect.Method; import java.util.List; import java.util.concurrent.atomic.AtomicBoolean; import kotlin.jvm.internal.DefaultConstructorMarker; import kotlin.jvm.internal.Intrinsics; @RestrictTo({RestrictTo.Scope.LIBRARY_GROUP}) /* loaded from: classes2.dex */ public final class InAppPurchaseSkuDetailsWrapper { private static final String CLASSNAME_SKU_DETAILS_PARAMS = "com.android.billingclient.api.SkuDetailsParams"; private static final String CLASSNAME_SKU_DETAILS_PARAMS_BUILDER = "com.android.billingclient.api.SkuDetailsParams$Builder"; private static final String METHOD_BUILD = "build"; private static final String METHOD_NEW_BUILDER = "newBuilder"; private static final String METHOD_SET_SKU_LIST = "setSkusList"; private static final String METHOD_SET_TYPE = "setType"; private static InAppPurchaseSkuDetailsWrapper instance; private final Method buildMethod; private final Class builderClazz; private final Method newBuilderMethod; private final Method setSkusListMethod; private final Method setTypeMethod; private final Class skuDetailsParamsClazz; public static final Companion Companion = new Companion(null); private static final AtomicBoolean initialized = new AtomicBoolean(false); public static final InAppPurchaseSkuDetailsWrapper getOrCreateInstance() { if (CrashShieldHandler.isObjectCrashing(InAppPurchaseSkuDetailsWrapper.class)) { return null; } try { return Companion.getOrCreateInstance(); } catch (Throwable th) { CrashShieldHandler.handleThrowable(th, InAppPurchaseSkuDetailsWrapper.class); return null; } } public InAppPurchaseSkuDetailsWrapper(Class skuDetailsParamsClazz, Class builderClazz, Method newBuilderMethod, Method setTypeMethod, Method setSkusListMethod, Method buildMethod) { Intrinsics.checkNotNullParameter(skuDetailsParamsClazz, "skuDetailsParamsClazz"); Intrinsics.checkNotNullParameter(builderClazz, "builderClazz"); Intrinsics.checkNotNullParameter(newBuilderMethod, "newBuilderMethod"); Intrinsics.checkNotNullParameter(setTypeMethod, "setTypeMethod"); Intrinsics.checkNotNullParameter(setSkusListMethod, "setSkusListMethod"); Intrinsics.checkNotNullParameter(buildMethod, "buildMethod"); this.skuDetailsParamsClazz = skuDetailsParamsClazz; this.builderClazz = builderClazz; this.newBuilderMethod = newBuilderMethod; this.setTypeMethod = setTypeMethod; this.setSkusListMethod = setSkusListMethod; this.buildMethod = buildMethod; } public static final /* synthetic */ AtomicBoolean access$getInitialized$cp() { if (CrashShieldHandler.isObjectCrashing(InAppPurchaseSkuDetailsWrapper.class)) { return null; } try { return initialized; } catch (Throwable th) { CrashShieldHandler.handleThrowable(th, InAppPurchaseSkuDetailsWrapper.class); return null; } } public static final /* synthetic */ InAppPurchaseSkuDetailsWrapper access$getInstance$cp() { if (CrashShieldHandler.isObjectCrashing(InAppPurchaseSkuDetailsWrapper.class)) { return null; } try { return instance; } catch (Throwable th) { CrashShieldHandler.handleThrowable(th, InAppPurchaseSkuDetailsWrapper.class); return null; } } public static final /* synthetic */ void access$setInstance$cp(InAppPurchaseSkuDetailsWrapper inAppPurchaseSkuDetailsWrapper) { if (CrashShieldHandler.isObjectCrashing(InAppPurchaseSkuDetailsWrapper.class)) { return; } try { instance = inAppPurchaseSkuDetailsWrapper; } catch (Throwable th) { CrashShieldHandler.handleThrowable(th, InAppPurchaseSkuDetailsWrapper.class); } } public final Class getSkuDetailsParamsClazz() { if (CrashShieldHandler.isObjectCrashing(this)) { return null; } try { return this.skuDetailsParamsClazz; } catch (Throwable th) { CrashShieldHandler.handleThrowable(th, this); return null; } } public final Object getSkuDetailsParams(String str, List list) { Object invokeMethod; Object invokeMethod2; if (CrashShieldHandler.isObjectCrashing(this)) { return null; } try { InAppPurchaseUtils inAppPurchaseUtils = InAppPurchaseUtils.INSTANCE; Object invokeMethod3 = InAppPurchaseUtils.invokeMethod(this.skuDetailsParamsClazz, this.newBuilderMethod, null, new Object[0]); if (invokeMethod3 != null && (invokeMethod = InAppPurchaseUtils.invokeMethod(this.builderClazz, this.setTypeMethod, invokeMethod3, str)) != null && (invokeMethod2 = InAppPurchaseUtils.invokeMethod(this.builderClazz, this.setSkusListMethod, invokeMethod, list)) != null) { return InAppPurchaseUtils.invokeMethod(this.builderClazz, this.buildMethod, invokeMethod2, new Object[0]); } return null; } catch (Throwable th) { CrashShieldHandler.handleThrowable(th, this); return null; } } public static final class Companion { public /* synthetic */ Companion(DefaultConstructorMarker defaultConstructorMarker) { this(); } private Companion() { } public final InAppPurchaseSkuDetailsWrapper getOrCreateInstance() { if (InAppPurchaseSkuDetailsWrapper.access$getInitialized$cp().get()) { return InAppPurchaseSkuDetailsWrapper.access$getInstance$cp(); } createInstance(); InAppPurchaseSkuDetailsWrapper.access$getInitialized$cp().set(true); return InAppPurchaseSkuDetailsWrapper.access$getInstance$cp(); } private final void createInstance() { Class cls = InAppPurchaseUtils.getClass(InAppPurchaseSkuDetailsWrapper.CLASSNAME_SKU_DETAILS_PARAMS); Class cls2 = InAppPurchaseUtils.getClass(InAppPurchaseSkuDetailsWrapper.CLASSNAME_SKU_DETAILS_PARAMS_BUILDER); if (cls == null || cls2 == null) { return; } Method method = InAppPurchaseUtils.getMethod(cls, InAppPurchaseSkuDetailsWrapper.METHOD_NEW_BUILDER, new Class[0]); Method method2 = InAppPurchaseUtils.getMethod(cls2, InAppPurchaseSkuDetailsWrapper.METHOD_SET_TYPE, String.class); Method method3 = InAppPurchaseUtils.getMethod(cls2, InAppPurchaseSkuDetailsWrapper.METHOD_SET_SKU_LIST, List.class); Method method4 = InAppPurchaseUtils.getMethod(cls2, InAppPurchaseSkuDetailsWrapper.METHOD_BUILD, new Class[0]); if (method == null || method2 == null || method3 == null || method4 == null) { return; } InAppPurchaseSkuDetailsWrapper.access$setInstance$cp(new InAppPurchaseSkuDetailsWrapper(cls, cls2, method, method2, method3, method4)); } } }