正在查看: Perplexity v2.48.1 应用的 BillingWrapper.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: Perplexity v2.48.1 应用的 BillingWrapper.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
package com.revenuecat.purchases.google;
import Hc.C0027m;
import Qa.d;
import Qa.f;
import Qa.g;
import Qa.i;
import Qa.j;
import Qa.k;
import Qa.m;
import Qa.u;
import W9.l;
import android.app.Activity;
import android.content.Context;
import android.os.Handler;
import android.text.TextUtils;
import com.android.billingclient.api.Purchase;
import com.android.billingclient.api.PurchaseHistoryRecord;
import com.mapbox.common.location.e;
import com.revenuecat.purchases.NoCoreLibraryDesugaringException;
import com.revenuecat.purchases.PostReceiptInitiationSource;
import com.revenuecat.purchases.PresentedOfferingContext;
import com.revenuecat.purchases.ProductType;
import com.revenuecat.purchases.PurchasesError;
import com.revenuecat.purchases.PurchasesErrorCode;
import com.revenuecat.purchases.PurchasesStateProvider;
import com.revenuecat.purchases.ReplacementMode;
import com.revenuecat.purchases.common.BillingAbstract;
import com.revenuecat.purchases.common.DateProvider;
import com.revenuecat.purchases.common.DefaultDateProvider;
import com.revenuecat.purchases.common.LogIntent;
import com.revenuecat.purchases.common.LogUtilsKt;
import com.revenuecat.purchases.common.LogWrapperKt;
import com.revenuecat.purchases.common.PurchaseExtensionsKt;
import com.revenuecat.purchases.common.ReplaceProductInfo;
import com.revenuecat.purchases.common.UtilsKt;
import com.revenuecat.purchases.common.caching.DeviceCache;
import com.revenuecat.purchases.common.diagnostics.DiagnosticsTracker;
import com.revenuecat.purchases.google.usecase.AcknowledgePurchaseUseCase;
import com.revenuecat.purchases.google.usecase.AcknowledgePurchaseUseCaseParams;
import com.revenuecat.purchases.google.usecase.BillingClientUseCase;
import com.revenuecat.purchases.google.usecase.ConsumePurchaseUseCase;
import com.revenuecat.purchases.google.usecase.ConsumePurchaseUseCaseParams;
import com.revenuecat.purchases.google.usecase.GetBillingConfigUseCase;
import com.revenuecat.purchases.google.usecase.GetBillingConfigUseCaseParams;
import com.revenuecat.purchases.google.usecase.QueryProductDetailsUseCase;
import com.revenuecat.purchases.google.usecase.QueryProductDetailsUseCaseParams;
import com.revenuecat.purchases.google.usecase.QueryPurchaseHistoryUseCase;
import com.revenuecat.purchases.google.usecase.QueryPurchaseHistoryUseCaseParams;
import com.revenuecat.purchases.google.usecase.QueryPurchasesByTypeUseCase;
import com.revenuecat.purchases.google.usecase.QueryPurchasesByTypeUseCaseParams;
import com.revenuecat.purchases.google.usecase.QueryPurchasesUseCase;
import com.revenuecat.purchases.google.usecase.QueryPurchasesUseCaseParams;
import com.revenuecat.purchases.models.GooglePurchasingData;
import com.revenuecat.purchases.models.GoogleReplacementMode;
import com.revenuecat.purchases.models.InAppMessageType;
import com.revenuecat.purchases.models.PurchaseState;
import com.revenuecat.purchases.models.PurchasingData;
import com.revenuecat.purchases.models.StoreProduct;
import com.revenuecat.purchases.models.StoreTransaction;
import com.revenuecat.purchases.utils.Result;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentLinkedQueue;
import kotlin.Metadata;
import kotlin.NoWhenBranchMatchedException;
import kotlin.Pair;
import kotlin.Unit;
import kotlin.collections.EmptyList;
import kotlin.jvm.functions.Function0;
import kotlin.jvm.functions.Function1;
import kotlin.jvm.internal.DefaultConstructorMarker;
import kotlin.jvm.internal.Intrinsics;
import kotlin.jvm.internal.Lambda;
import kotlin.jvm.internal.SourceDebugExtension;
import kotlin.sequences.SequencesKt;
@Metadata(d1 = {"\u0000¤\u0002\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0010\t\n\u0000\n\u0002\u0010\u0002\n\u0002\b\u0005\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\"\n\u0002\u0010\u000e\n\u0000\n\u0002\u0018\u0002\n\u0002\u0010 \n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\u000b\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0002\b\u0004\n\u0002\u0018\u0002\n\u0002\b\u0004\n\u0002\u0018\u0002\n\u0002\b\u0004\n\u0002\u0018\u0002\n\u0002\b\t\n\u0002\u0010$\n\u0002\b\n\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\b\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\t\n\u0002\u0018\u0002\n\u0002\b\u0007\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\n\n\u0002\u0018\u0002\n\u0002\b\u0006\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\u0011\n\u0002\u0010%\n\u0002\u0018\u0002\n\u0002\b\u0005\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\f\b\u0000\u0018\u0000 ¶\u00012\u00020\u00012\u00020\u00022\u00020\u0003:\u0004·\u0001¶\u0001B;\u0012\u0006\u0010\u0005\u001a\u00020\u0004\u0012\u0006\u0010\u0007\u001a\u00020\u0006\u0012\u0006\u0010\t\u001a\u00020\b\u0012\b\u0010\u000b\u001a\u0004\u0018\u00010\n\u0012\u0006\u0010\r\u001a\u00020\f\u0012\b\b\u0002\u0010\u000f\u001a\u00020\u000e¢\u0006\u0004\b\u0010\u0010\u0011J\u0017\u0010\u0015\u001a\u00020\u00142\u0006\u0010\u0013\u001a\u00020\u0012H\u0016¢\u0006\u0004\b\u0015\u0010\u0016J\u000f\u0010\u0017\u001a\u00020\u0014H\u0016¢\u0006\u0004\b\u0017\u0010\u0018J\u000f\u0010\u0019\u001a\u00020\u0014H\u0014¢\u0006\u0004\b\u0019\u0010\u0018J[\u0010'\u001a\u00020\u00142\u0006\u0010\u001b\u001a\u00020\u001a2\f\u0010\u001e\u001a\b\u0012\u0004\u0012\u00020\u001d0\u001c2\u001c\u0010#\u001a\u0018\u0012\n\u0012\b\u0012\u0004\u0012\u00020!0 \u0012\u0004\u0012\u00020\u00140\u001fj\u0002`\"2\u0016\u0010&\u001a\u0012\u0012\u0004\u0012\u00020$\u0012\u0004\u0012\u00020\u00140\u001fj\u0002`%H\u0016¢\u0006\u0004\b'\u0010(JE\u00104\u001a\u00020\u00142\u0006\u0010*\u001a\u00020)2\u0006\u0010+\u001a\u00020\u001d2\u0006\u0010-\u001a\u00020,2\b\u0010/\u001a\u0004\u0018\u00010.2\b\u00101\u001a\u0004\u0018\u0001002\b\u00103\u001a\u0004\u0018\u000102H\u0016¢\u0006\u0004\b4\u00105JC\u00109\u001a\u00020\u00142\u0006\u0010\u001b\u001a\u00020\u001d2\u0018\u00107\u001a\u0014\u0012\n\u0012\b\u0012\u0004\u0012\u0002060 \u0012\u0004\u0012\u00020\u00140\u001f2\u0012\u00108\u001a\u000e\u0012\u0004\u0012\u00020$\u0012\u0004\u0012\u00020\u00140\u001f¢\u0006\u0004\b9\u0010:JE\u0010<\u001a\u00020\u00142\u0006\u0010+\u001a\u00020\u001d2\u0018\u00107\u001a\u0014\u0012\n\u0012\b\u0012\u0004\u0012\u00020;0 \u0012\u0004\u0012\u00020\u00140\u001f2\u0012\u00108\u001a\u000e\u0012\u0004\u0012\u00020$\u0012\u0004\u0012\u00020\u00140\u001fH\u0016¢\u0006\u0004\b<\u0010:J/\u0010B\u001a\u00020\u00142\u0006\u0010=\u001a\u0002022\u0006\u0010>\u001a\u00020;2\u0006\u0010?\u001a\u0002022\u0006\u0010A\u001a\u00020@H\u0016¢\u0006\u0004\bB\u0010CJB\u0010K\u001a\u00020\u00142\u0006\u0010D\u001a\u00020\u001d2\u0006\u0010A\u001a\u00020@2!\u0010H\u001a\u001d\u0012\u0013\u0012\u00110\u001d¢\u0006\f\bE\u0012\b\bF\u0012\u0004\b\b(G\u0012\u0004\u0012\u00020\u00140\u001fH\u0000¢\u0006\u0004\bI\u0010JJB\u0010N\u001a\u00020\u00142\u0006\u0010D\u001a\u00020\u001d2\u0006\u0010A\u001a\u00020@2!\u0010L\u001a\u001d\u0012\u0013\u0012\u00110\u001d¢\u0006\f\bE\u0012\b\bF\u0012\u0004\b\b(G\u0012\u0004\u0012\u00020\u00140\u001fH\u0000¢\u0006\u0004\bM\u0010JJK\u0010Q\u001a\u00020\u00142\u0006\u0010+\u001a\u00020\u001d2\u001e\u0010P\u001a\u001a\u0012\u0010\u0012\u000e\u0012\u0004\u0012\u00020\u001d\u0012\u0004\u0012\u00020;0O\u0012\u0004\u0012\u00020\u00140\u001f2\u0012\u0010&\u001a\u000e\u0012\u0004\u0012\u00020$\u0012\u0004\u0012\u00020\u00140\u001fH\u0016¢\u0006\u0004\bQ\u0010:JO\u0010T\u001a\u00020\u00142\u0006\u0010+\u001a\u00020\u001d2\u0006\u0010\u001b\u001a\u00020\u001a2\u0006\u0010R\u001a\u00020\u001d2\u0012\u0010S\u001a\u000e\u0012\u0004\u0012\u00020;\u0012\u0004\u0012\u00020\u00140\u001f2\u0012\u0010&\u001a\u000e\u0012\u0004\u0012\u00020$\u0012\u0004\u0012\u00020\u00140\u001fH\u0016¢\u0006\u0004\bT\u0010UJ+\u0010Y\u001a\u00020\u00142\u0006\u0010G\u001a\u00020\u001d2\u0012\u0010V\u001a\u000e\u0012\u0004\u0012\u00020\u001a\u0012\u0004\u0012\u00020\u00140\u001fH\u0001¢\u0006\u0004\bW\u0010XJ'\u0010^\u001a\u00020\u00142\u0006\u0010[\u001a\u00020Z2\u000e\u0010]\u001a\n\u0012\u0004\u0012\u00020\\\u0018\u00010 H\u0016¢\u0006\u0004\b^\u0010_J\u0017\u0010`\u001a\u00020\u00142\u0006\u0010[\u001a\u00020ZH\u0016¢\u0006\u0004\b`\u0010aJ\u000f\u0010b\u001a\u00020\u0014H\u0016¢\u0006\u0004\bb\u0010\u0018J\u000f\u0010c\u001a\u000202H\u0016¢\u0006\u0004\bc\u0010dJ3\u0010i\u001a\u00020\u00142\u0006\u0010*\u001a\u00020)2\f\u0010f\u001a\b\u0012\u0004\u0012\u00020e0 2\f\u0010h\u001a\b\u0012\u0004\u0012\u00020\u00140gH\u0016¢\u0006\u0004\bi\u0010jJ;\u0010k\u001a\u00020\u00142\u0012\u0010P\u001a\u000e\u0012\u0004\u0012\u00020\u001d\u0012\u0004\u0012\u00020\u00140\u001f2\u0016\u0010&\u001a\u0012\u0012\u0004\u0012\u00020$\u0012\u0004\u0012\u00020\u00140\u001fj\u0002`%H\u0016¢\u0006\u0004\bk\u0010lJ\u000f\u0010m\u001a\u00020\u0014H\u0002¢\u0006\u0004\bm\u0010\u0018J1\u0010o\u001a\u00020\u00142\n\b\u0002\u0010\u0013\u001a\u0004\u0018\u00010\u00122\u0014\u0010n\u001a\u0010\u0012\u0006\u0012\u0004\u0018\u00010$\u0012\u0004\u0012\u00020\u00140\u001fH\u0002¢\u0006\u0004\bo\u0010pJ\u001f\u0010s\u001a\u00020\u00142\u0006\u0010*\u001a\u00020)2\u0006\u0010r\u001a\u00020qH\u0003¢\u0006\u0004\bs\u0010tJG\u0010v\u001a\u00020\u00142\u0006\u0010\u001b\u001a\u00020\u001d2\u0006\u0010G\u001a\u00020\u001d2\u0012\u0010V\u001a\u000e\u0012\u0004\u0012\u00020\u001a\u0012\u0004\u0012\u00020\u00140\u001f2\u0012\u0010u\u001a\u000e\u0012\u0004\u0012\u000202\u0012\u0004\u0012\u00020\u00140\u001fH\u0002¢\u0006\u0004\bv\u0010wJ\u000f\u0010x\u001a\u00020\u0014H\u0002¢\u0006\u0004\bx\u0010\u0018J(\u0010|\u001a\u00020\u00142\u0017\u0010{\u001a\u0013\u0012\u0004\u0012\u00020y\u0012\u0004\u0012\u00020\u00140\u001f¢\u0006\u0002\bzH\u0002¢\u0006\u0004\b|\u0010}J\u000f\u0010~\u001a\u00020\u001dH\u0002¢\u0006\u0004\b~\u0010\u007fJ?\u0010\u0082\u0001\u001a\u00020\u00142\u0006\u0010>\u001a\u00020\\2#\u0010\u0081\u0001\u001a\u001e\u0012\u0014\u0012\u00120;¢\u0006\r\bE\u0012\t\bF\u0012\u0005\b\b(\u0080\u0001\u0012\u0004\u0012\u00020\u00140\u001fH\u0002¢\u0006\u0006\b\u0082\u0001\u0010\u0083\u0001J\u0011\u0010\u0084\u0001\u001a\u00020\u0014H\u0002¢\u0006\u0005\b\u0084\u0001\u0010\u0018J'\u0010\u0088\u0001\u001a\u00020\u00142\b\u0010\u0086\u0001\u001a\u00030\u0085\u00012\t\u0010\u0087\u0001\u001a\u0004\u0018\u00010\u001dH\u0002¢\u0006\u0006\b\u0088\u0001\u0010\u0089\u0001J)\u0010\u008a\u0001\u001a\u00020\u00142\u0006\u0010[\u001a\u00020Z2\u000e\u0010]\u001a\n\u0012\u0004\u0012\u00020\\\u0018\u00010 H\u0002¢\u0006\u0005\b\u008a\u0001\u0010_JE\u0010\u008d\u0001\u001a\u000f\u0012\u0004\u0012\u00020q\u0012\u0004\u0012\u00020$0\u008c\u00012\b\u0010\u008b\u0001\u001a\u00030\u0085\u00012\b\u0010/\u001a\u0004\u0018\u00010.2\u0006\u0010+\u001a\u00020\u001d2\b\u00103\u001a\u0004\u0018\u000102H\u0002¢\u0006\u0006\b\u008d\u0001\u0010\u008e\u0001J;\u0010\u0090\u0001\u001a\u000f\u0012\u0004\u0012\u00020q\u0012\u0004\u0012\u00020$0\u008c\u00012\b\u0010\u008b\u0001\u001a\u00030\u008f\u00012\u0006\u0010+\u001a\u00020\u001d2\b\u00103\u001a\u0004\u0018\u000102H\u0002¢\u0006\u0006\b\u0090\u0001\u0010\u0091\u0001JE\u0010\u0093\u0001\u001a\u000f\u0012\u0004\u0012\u00020q\u0012\u0004\u0012\u00020$0\u008c\u00012\b\u0010\u008b\u0001\u001a\u00030\u0092\u00012\b\u0010/\u001a\u0004\u0018\u00010.2\u0006\u0010+\u001a\u00020\u001d2\b\u00103\u001a\u0004\u0018\u000102H\u0002¢\u0006\u0006\b\u0093\u0001\u0010\u0094\u0001J\u001b\u0010\u0096\u0001\u001a\u00020\u00142\u0007\u0010\u0095\u0001\u001a\u00020$H\u0002¢\u0006\u0006\b\u0096\u0001\u0010\u0097\u0001R\u0015\u0010\u0005\u001a\u00020\u00048\u0002X\u0082\u0004¢\u0006\u0007\n\u0005\b\u0005\u0010\u0098\u0001R\u0015\u0010\u0007\u001a\u00020\u00068\u0002X\u0082\u0004¢\u0006\u0007\n\u0005\b\u0007\u0010\u0099\u0001R\u0015\u0010\t\u001a\u00020\b8\u0002X\u0082\u0004¢\u0006\u0007\n\u0005\b\t\u0010\u009a\u0001R\u0017\u0010\u000b\u001a\u0004\u0018\u00010\n8\u0002X\u0082\u0004¢\u0006\u0007\n\u0005\b\u000b\u0010\u009b\u0001R\u0015\u0010\u000f\u001a\u00020\u000e8\u0002X\u0082\u0004¢\u0006\u0007\n\u0005\b\u000f\u0010\u009c\u0001R6\u0010\u009e\u0001\u001a\u0004\u0018\u00010y2\t\u0010\u009d\u0001\u001a\u0004\u0018\u00010y8F@FX\u0086\u000e¢\u0006\u0018\n\u0006\b\u009e\u0001\u0010\u009f\u0001\u001a\u0006\b \u0001\u0010¡\u0001\"\u0006\b¢\u0001\u0010£\u0001R4\u0010¦\u0001\u001a\u0010\u0012\u0004\u0012\u00020\u001d\u0012\u0005\u0012\u00030¥\u00010¤\u00018\u0000X\u0081\u0004¢\u0006\u0017\n\u0006\b¦\u0001\u0010§\u0001\u0012\u0005\bª\u0001\u0010\u0018\u001a\u0006\b¨\u0001\u0010©\u0001RK\u0010®\u0001\u001a6\u00121\u0012/\u0012\"\u0012 \u0012\u0016\u0012\u0014\u0018\u00010$¢\u0006\r\bE\u0012\t\bF\u0012\u0005\b\b(\u00ad\u0001\u0012\u0004\u0012\u00020\u00140\u001f\u0012\u0006\u0012\u0004\u0018\u00010\u00120¬\u00010«\u00018\u0002X\u0082\u0004¢\u0006\b\n\u0006\b®\u0001\u0010¯\u0001R\u0019\u0010°\u0001\u001a\u00020\u00128\u0002@\u0002X\u0082\u000e¢\u0006\b\n\u0006\b°\u0001\u0010±\u0001R\"\u0010²\u0001\u001a\u0002022\u0007\u0010\u009d\u0001\u001a\u0002028B@BX\u0082\u000e¢\u0006\b\n\u0006\b²\u0001\u0010³\u0001R\u0013\u0010µ\u0001\u001a\u0002028F¢\u0006\u0007\u001a\u0005\b´\u0001\u0010d¨\u0006¸\u0001"}, d2 = {"Lcom/revenuecat/purchases/google/BillingWrapper;", "Lcom/revenuecat/purchases/common/BillingAbstract;", "LQa/u;", "LQa/d;", "Lcom/revenuecat/purchases/google/BillingWrapper$ClientFactory;", "clientFactory", "Landroid/os/Handler;", "mainHandler", "Lcom/revenuecat/purchases/common/caching/DeviceCache;", "deviceCache", "Lcom/revenuecat/purchases/common/diagnostics/DiagnosticsTracker;", "diagnosticsTrackerIfEnabled", "Lcom/revenuecat/purchases/PurchasesStateProvider;", "purchasesStateProvider", "Lcom/revenuecat/purchases/common/DateProvider;", "dateProvider", "<init>", "(Lcom/revenuecat/purchases/google/BillingWrapper$ClientFactory;Landroid/os/Handler;Lcom/revenuecat/purchases/common/caching/DeviceCache;Lcom/revenuecat/purchases/common/diagnostics/DiagnosticsTracker;Lcom/revenuecat/purchases/PurchasesStateProvider;Lcom/revenuecat/purchases/common/DateProvider;)V", "", "delayMilliseconds", "", "startConnectionOnMainThread", "(J)V", "startConnection", "()V", "endConnection", "Lcom/revenuecat/purchases/ProductType;", "productType", "", "", "productIds", "Lkotlin/Function1;", "", "Lcom/revenuecat/purchases/models/StoreProduct;", "Lcom/revenuecat/purchases/common/StoreProductsCallback;", "onReceive", "Lcom/revenuecat/purchases/PurchasesError;", "Lcom/revenuecat/purchases/PurchasesErrorCallback;", "onError", "queryProductDetailsAsync", "(Lcom/revenuecat/purchases/ProductType;Ljava/util/Set;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;)V", "Landroid/app/Activity;", "activity", "appUserID", "Lcom/revenuecat/purchases/models/PurchasingData;", "purchasingData", "Lcom/revenuecat/purchases/common/ReplaceProductInfo;", "replaceProductInfo", "Lcom/revenuecat/purchases/PresentedOfferingContext;", "presentedOfferingContext", "", "isPersonalizedPrice", "makePurchaseAsync", "(Landroid/app/Activity;Ljava/lang/String;Lcom/revenuecat/purchases/models/PurchasingData;Lcom/revenuecat/purchases/common/ReplaceProductInfo;Lcom/revenuecat/purchases/PresentedOfferingContext;Ljava/lang/Boolean;)V", "Lcom/android/billingclient/api/PurchaseHistoryRecord;", "onReceivePurchaseHistory", "onReceivePurchaseHistoryError", "queryPurchaseHistoryAsync", "(Ljava/lang/String;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;)V", "Lcom/revenuecat/purchases/models/StoreTransaction;", "queryAllPurchases", "finishTransactions", "purchase", "shouldConsume", "Lcom/revenuecat/purchases/PostReceiptInitiationSource;", "initiationSource", "consumeAndSave", "(ZLcom/revenuecat/purchases/models/StoreTransaction;ZLcom/revenuecat/purchases/PostReceiptInitiationSource;)V", "token", "Lkotlin/ParameterName;", "name", "purchaseToken", "onConsumed", "consumePurchase$purchases_defaultsRelease", "(Ljava/lang/String;Lcom/revenuecat/purchases/PostReceiptInitiationSource;Lkotlin/jvm/functions/Function1;)V", "consumePurchase", "onAcknowledged", "acknowledge$purchases_defaultsRelease", "acknowledge", "", "onSuccess", "queryPurchases", "productId", "onCompletion", "findPurchaseInPurchaseHistory", "(Ljava/lang/String;Lcom/revenuecat/purchases/ProductType;Ljava/lang/String;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;)V", "listener", "getPurchaseType$purchases_defaultsRelease", "(Ljava/lang/String;Lkotlin/jvm/functions/Function1;)V", "getPurchaseType", "LQa/j;", "billingResult", "Lcom/android/billingclient/api/Purchase;", "purchases", "onPurchasesUpdated", "(LQa/j;Ljava/util/List;)V", "onBillingSetupFinished", "(LQa/j;)V", "onBillingServiceDisconnected", "isConnected", "()Z", "Lcom/revenuecat/purchases/models/InAppMessageType;", "inAppMessageTypes", "Lkotlin/Function0;", "subscriptionStatusChange", "showInAppMessagesIfNeeded", "(Landroid/app/Activity;Ljava/util/List;Lkotlin/jvm/functions/Function0;)V", "getStorefront", "(Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;)V", "executePendingRequests", "request", "executeRequestOnUIThread", "(Ljava/lang/Long;Lkotlin/jvm/functions/Function1;)V", "LQa/i;", "params", "launchBillingFlow", "(Landroid/app/Activity;LQa/i;)V", "resultHandler", "queryPurchaseType", "(Ljava/lang/String;Ljava/lang/String;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;)V", "retryBillingServiceConnectionWithExponentialBackoff", "LQa/b;", "Lkotlin/ExtensionFunctionType;", "receivingFunction", "withConnectedClient", "(Lkotlin/jvm/functions/Function1;)V", "getStackTrace", "()Ljava/lang/String;", "storeTxn", "completion", "getStoreTransaction", "(Lcom/android/billingclient/api/Purchase;Lkotlin/jvm/functions/Function1;)V", "trackProductDetailsNotSupportedIfNeeded", "Lcom/revenuecat/purchases/models/GooglePurchasingData;", "googlePurchasingData", "oldProductId", "trackPurchaseStartIfNeeded", "(Lcom/revenuecat/purchases/models/GooglePurchasingData;Ljava/lang/String;)V", "trackPurchaseUpdateReceivedIfNeeded", "purchaseInfo", "Lcom/revenuecat/purchases/utils/Result;", "buildPurchaseParams", "(Lcom/revenuecat/purchases/models/GooglePurchasingData;Lcom/revenuecat/purchases/common/ReplaceProductInfo;Ljava/lang/String;Ljava/lang/Boolean;)Lcom/revenuecat/purchases/utils/Result;", "Lcom/revenuecat/purchases/models/GooglePurchasingData$InAppProduct;", "buildOneTimePurchaseParams", "(Lcom/revenuecat/purchases/models/GooglePurchasingData$InAppProduct;Ljava/lang/String;Ljava/lang/Boolean;)Lcom/revenuecat/purchases/utils/Result;", "Lcom/revenuecat/purchases/models/GooglePurchasingData$Subscription;", "buildSubscriptionPurchaseParams", "(Lcom/revenuecat/purchases/models/GooglePurchasingData$Subscription;Lcom/revenuecat/purchases/common/ReplaceProductInfo;Ljava/lang/String;Ljava/lang/Boolean;)Lcom/revenuecat/purchases/utils/Result;", "error", "sendErrorsToAllPendingRequests", "(Lcom/revenuecat/purchases/PurchasesError;)V", "Lcom/revenuecat/purchases/google/BillingWrapper$ClientFactory;", "Landroid/os/Handler;", "Lcom/revenuecat/purchases/common/caching/DeviceCache;", "Lcom/revenuecat/purchases/common/diagnostics/DiagnosticsTracker;", "Lcom/revenuecat/purchases/common/DateProvider;", "<set-?>", "billingClient", "LQa/b;", "getBillingClient", "()LQa/b;", "setBillingClient", "(LQa/b;)V", "", "Lcom/revenuecat/purchases/google/PurchaseContext;", "purchaseContext", "Ljava/util/Map;", "getPurchaseContext$purchases_defaultsRelease", "()Ljava/util/Map;", "getPurchaseContext$purchases_defaultsRelease$annotations", "Ljava/util/concurrent/ConcurrentLinkedQueue;", "Lkotlin/Pair;", "connectionError", "serviceRequests", "Ljava/util/concurrent/ConcurrentLinkedQueue;", "reconnectMilliseconds", "J", "reconnectionAlreadyScheduled", "Z", "getAppInBackground", "appInBackground", "Companion", "ClientFactory", "purchases_defaultsRelease"}, k = 1, mv = {1, 8, 0}, xi = 48)
@SourceDebugExtension
public final class BillingWrapper extends BillingAbstract implements u, d {
private static final Companion Companion = new Companion(null);
private static final int MAX_PENDING_REQUEST_COUNT_REPORTED = 100;
private volatile Qa.b billingClient;
private final ClientFactory clientFactory;
private final DateProvider dateProvider;
private final DeviceCache deviceCache;
private final DiagnosticsTracker diagnosticsTrackerIfEnabled;
private final Handler mainHandler;
private final Map<String, PurchaseContext> purchaseContext;
private long reconnectMilliseconds;
private boolean reconnectionAlreadyScheduled;
private final ConcurrentLinkedQueue<Pair<Function1<PurchasesError, Unit>, Long>> serviceRequests;
@Metadata(d1 = {"\u0000$\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\u000b\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0005\u0018\u00002\u00020\u0001B\u0017\u0012\u0006\u0010\u0003\u001a\u00020\u0002\u0012\u0006\u0010\u0005\u001a\u00020\u0004¢\u0006\u0004\b\u0006\u0010\u0007J\u0017\u0010\u000b\u001a\u00020\n2\u0006\u0010\t\u001a\u00020\bH\u0007¢\u0006\u0004\b\u000b\u0010\fR\u0014\u0010\u0003\u001a\u00020\u00028\u0002X\u0082\u0004¢\u0006\u0006\n\u0004\b\u0003\u0010\rR\u0014\u0010\u0005\u001a\u00020\u00048\u0002X\u0082\u0004¢\u0006\u0006\n\u0004\b\u0005\u0010\u000e¨\u0006\u000f"}, d2 = {"Lcom/revenuecat/purchases/google/BillingWrapper$ClientFactory;", "", "Landroid/content/Context;", "context", "", "pendingTransactionsForPrepaidPlansEnabled", "<init>", "(Landroid/content/Context;Z)V", "LQa/u;", "listener", "LQa/b;", "buildClient", "(LQa/u;)LQa/b;", "Landroid/content/Context;", "Z", "purchases_defaultsRelease"}, k = 1, mv = {1, 8, 0}, xi = 48)
@SourceDebugExtension
public static final class ClientFactory {
private final Context context;
private final boolean pendingTransactionsForPrepaidPlansEnabled;
public ClientFactory(Context context, boolean z) {
Intrinsics.h(context, "context");
this.context = context;
this.pendingTransactionsForPrepaidPlansEnabled = z;
}
public final Qa.b buildClient(u listener) {
Intrinsics.h(listener, "listener");
m mVar = new m(this.pendingTransactionsForPrepaidPlansEnabled, 0);
C0027m c0027m = new C0027m(this.context);
c0027m.a = mVar;
c0027m.b = listener;
return c0027m.a();
}
}
@Metadata(d1 = {"\u0000\u0012\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0002\b\u0002\n\u0002\u0010\b\n\u0000\b\u0082\u0003\u0018\u00002\u00020\u0001B\u0007\b\u0002¢\u0006\u0002\u0010\u0002R\u000e\u0010\u0003\u001a\u00020\u0004X\u0082T¢\u0006\u0002\n\u0000¨\u0006\u0005"}, d2 = {"Lcom/revenuecat/purchases/google/BillingWrapper$Companion;", "", "()V", "MAX_PENDING_REQUEST_COUNT_REPORTED", "", "purchases_defaultsRelease"}, k = 1, mv = {1, 8, 0}, xi = 48)
public static final class Companion {
public Companion(DefaultConstructorMarker defaultConstructorMarker) {
this();
}
private Companion() {
}
}
public BillingWrapper(ClientFactory clientFactory, Handler handler, DeviceCache deviceCache, DiagnosticsTracker diagnosticsTracker, PurchasesStateProvider purchasesStateProvider, DateProvider dateProvider, int i, DefaultConstructorMarker defaultConstructorMarker) {
this(clientFactory, handler, deviceCache, diagnosticsTracker, purchasesStateProvider, (i & 32) != 0 ? new DefaultDateProvider() : dateProvider);
}
private final Result<i, PurchasesError> buildOneTimePurchaseParams(GooglePurchasingData.InAppProduct purchaseInfo, String appUserID, Boolean isPersonalizedPrice) {
l lVar = new l(10, false);
lVar.u(purchaseInfo.getProductDetails());
g m = lVar.m();
try {
f fVar = new f();
Jl.d dVar = new Jl.d();
dVar.b = 0;
dVar.a = true;
fVar.d = dVar;
fVar.b = new ArrayList(A9.b.J(m));
fVar.a = UtilsKt.sha256(appUserID);
if (isPersonalizedPrice != null) {
fVar.c = isPersonalizedPrice.booleanValue();
}
return new Result.Success(fVar.a());
} catch (NoClassDefFoundError e) {
throw new NoCoreLibraryDesugaringException(e);
}
}
public final Result<i, PurchasesError> buildPurchaseParams(GooglePurchasingData purchaseInfo, ReplaceProductInfo replaceProductInfo, String appUserID, Boolean isPersonalizedPrice) {
if (purchaseInfo instanceof GooglePurchasingData.InAppProduct) {
return buildOneTimePurchaseParams((GooglePurchasingData.InAppProduct) purchaseInfo, appUserID, isPersonalizedPrice);
}
if (purchaseInfo instanceof GooglePurchasingData.Subscription) {
return buildSubscriptionPurchaseParams((GooglePurchasingData.Subscription) purchaseInfo, replaceProductInfo, appUserID, isPersonalizedPrice);
}
throw new NoWhenBranchMatchedException();
}
private final Result<i, PurchasesError> buildSubscriptionPurchaseParams(GooglePurchasingData.Subscription purchaseInfo, ReplaceProductInfo replaceProductInfo, String appUserID, Boolean isPersonalizedPrice) {
l lVar = new l(10, false);
String token = purchaseInfo.getToken();
if (TextUtils.isEmpty(token)) {
throw new IllegalArgumentException("offerToken can not be empty");
}
lVar.y = token;
lVar.u(purchaseInfo.getProductDetails());
g m = lVar.m();
try {
f fVar = new f();
Jl.d dVar = new Jl.d();
dVar.b = 0;
dVar.a = true;
fVar.d = dVar;
fVar.b = new ArrayList(A9.b.J(m));
if (replaceProductInfo != null) {
BillingFlowParamsExtensionsKt.setUpgradeInfo(fVar, replaceProductInfo);
Unit unit = Unit.a;
} else {
fVar.a = UtilsKt.sha256(appUserID);
}
if (isPersonalizedPrice != null) {
fVar.c = isPersonalizedPrice.booleanValue();
}
return new Result.Success(fVar.a());
} catch (NoClassDefFoundError e) {
throw new NoCoreLibraryDesugaringException(e);
}
}
public static final void endConnection$lambda$9(BillingWrapper billingWrapper) {
Intrinsics.h(billingWrapper, "this$0");
synchronized (billingWrapper) {
try {
Qa.b bVar = billingWrapper.billingClient;
if (bVar != null) {
LogWrapperKt.log(LogIntent.DEBUG, String.format("Ending connection for %s", Arrays.copyOf(new Object[]{bVar}, 1)));
bVar.c();
}
billingWrapper.billingClient = null;
Unit unit = Unit.a;
} catch (Throwable th) {
throw th;
}
}
}
private final void executePendingRequests() {
Pair<Function1<PurchasesError, Unit>, Long> poll;
final int i = 1;
synchronized (this) {
while (true) {
try {
Qa.b bVar = this.billingClient;
if (bVar == null || !bVar.e() || (poll = this.serviceRequests.poll()) == null) {
break;
}
final Function1 function1 = (Function1) poll.w;
Long l = (Long) poll.x;
if (l != null) {
final int i2 = 0;
this.mainHandler.postDelayed(new Runnable() {
@Override
public final void run() {
switch (i2) {
case 0:
BillingWrapper.executePendingRequests$lambda$3$lambda$2$lambda$0(function1);
break;
default:
BillingWrapper.executePendingRequests$lambda$3$lambda$2$lambda$1(function1);
break;
}
}
}, l.longValue());
} else {
this.mainHandler.post(new Runnable() {
@Override
public final void run() {
switch (i) {
case 0:
BillingWrapper.executePendingRequests$lambda$3$lambda$2$lambda$0(function1);
break;
default:
BillingWrapper.executePendingRequests$lambda$3$lambda$2$lambda$1(function1);
break;
}
}
});
}
} catch (Throwable th) {
throw th;
}
}
Unit unit = Unit.a;
}
}
public static final void executePendingRequests$lambda$3$lambda$2$lambda$0(Function1 function1) {
Intrinsics.h(function1, "$request");
function1.invoke((Object) null);
}
public static final void executePendingRequests$lambda$3$lambda$2$lambda$1(Function1 function1) {
Intrinsics.h(function1, "$request");
function1.invoke((Object) null);
}
public final synchronized void executeRequestOnUIThread(Long delayMilliseconds, Function1<? super PurchasesError, Unit> request) {
try {
if (getPurchasesUpdatedListener() != null) {
this.serviceRequests.add(new Pair<>(request, delayMilliseconds));
Qa.b bVar = this.billingClient;
if (bVar == null || bVar.e()) {
executePendingRequests();
} else {
BillingAbstract.startConnectionOnMainThread$default(this, 0L, 1, null);
}
} else {
request.invoke(new PurchasesError(PurchasesErrorCode.UnknownError, "BillingWrapper is not attached to a listener"));
}
} catch (Throwable th) {
throw th;
}
}
public static void executeRequestOnUIThread$default(BillingWrapper billingWrapper, Long l, Function1 function1, int i, Object obj) {
if ((i & 1) != 0) {
l = null;
}
billingWrapper.executeRequestOnUIThread(l, function1);
}
public static void getPurchaseContext$purchases_defaultsRelease$annotations() {
}
private final String getStackTrace() {
StringWriter stringWriter = new StringWriter();
new Throwable().printStackTrace(new PrintWriter(stringWriter));
String stringWriter2 = stringWriter.toString();
Intrinsics.g(stringWriter2, "stringWriter.toString()");
return stringWriter2;
}
private final void getStoreTransaction(final Purchase purchase, final Function1<? super StoreTransaction, Unit> completion) {
e.D(new Object[]{PurchaseExtensionsKt.toHumanReadableDescription(purchase)}, 1, "BillingWrapper purchases updated: %s", LogIntent.DEBUG);
synchronized (this) {
PurchaseContext purchaseContext = this.purchaseContext.get(PurchaseExtensionsKt.getFirstProductId(purchase));
if (purchaseContext != null && purchaseContext.getProductType() != null) {
completion.invoke(StoreTransactionConversionsKt.toStoreTransaction(purchase, purchaseContext));
return;
}
String b = purchase.b();
Intrinsics.g(b, "purchase.purchaseToken");
getPurchaseType$purchases_defaultsRelease(b, new Function1<ProductType, Unit>() {
{
super(1);
}
public Object invoke(Object obj) {
invoke((ProductType) obj);
return Unit.a;
}
public final void invoke(ProductType productType) {
Intrinsics.h(productType, "type");
completion.invoke(StoreTransactionConversionsKt.toStoreTransaction$default(purchase, productType, null, null, null, 14, null));
}
});
Unit unit = Unit.a;
}
}
public final void launchBillingFlow(final Activity activity, final i params) {
if (activity.getIntent() == null) {
LogWrapperKt.log(LogIntent.WARNING, "Activity passed into launchBillingFlow has a null intent, which may cause a crash. See https://github.com/RevenueCat/purchases-android/issues/381 for more information.");
}
withConnectedClient(new Function1<Qa.b, Unit>() {
{
super(1);
}
public Object invoke(Object obj) {
invoke((Qa.b) obj);
return Unit.a;
}
public final void invoke(Qa.b bVar) {
Intrinsics.h(bVar, "$this$withConnectedClient");
j f = bVar.f(activity, params);
if (f.a == 0) {
f = null;
}
if (f != null) {
e.D(new Object[]{BillingResultExtensionsKt.toHumanReadableDescription(f)}, 1, "Failed to launch billing intent. %s", LogIntent.GOOGLE_ERROR);
}
}
});
}
public static final void onBillingSetupFinished$lambda$18(j jVar, BillingWrapper billingWrapper) {
PurchasesError billingResponseToPurchasesError;
Intrinsics.h(jVar, "$billingResult");
Intrinsics.h(billingWrapper, "this$0");
int i = jVar.a;
if (i != 6) {
if (i != 7 && i != 8) {
if (i != 12) {
switch (i) {
case -2:
case 3:
String humanReadableDescription = BillingResultExtensionsKt.toHumanReadableDescription(jVar);
if (Intrinsics.c(jVar.b, ErrorsKt.IN_APP_BILLING_LESS_THAN_3_ERROR_MESSAGE)) {
billingResponseToPurchasesError = new PurchasesError(PurchasesErrorCode.StoreProblemError, String.format("Billing is not available in this device. Make sure there's an account configured in Play Store. Reopen the Play Store or clean its caches if this keeps happening. Original error message: %s", Arrays.copyOf(new Object[]{humanReadableDescription}, 1)));
LogUtilsKt.errorLog(billingResponseToPurchasesError);
} else {
billingResponseToPurchasesError = ErrorsKt.billingResponseToPurchasesError(jVar.a, String.format("Billing is not available in this device. %s", Arrays.copyOf(new Object[]{humanReadableDescription}, 1)));
LogUtilsKt.errorLog(billingResponseToPurchasesError);
}
billingWrapper.sendErrorsToAllPendingRequests(billingResponseToPurchasesError);
break;
case 0:
LogIntent logIntent = LogIntent.DEBUG;
Qa.b bVar = billingWrapper.billingClient;
LogWrapperKt.log(logIntent, String.format("Billing Service Setup finished for %s", Arrays.copyOf(new Object[]{bVar != null ? bVar.toString() : null}, 1)));
BillingAbstract.StateListener stateListener = billingWrapper.getStateListener();
if (stateListener != null) {
stateListener.onConnected();
}
billingWrapper.executePendingRequests();
billingWrapper.reconnectMilliseconds = 1000L;
billingWrapper.trackProductDetailsNotSupportedIfNeeded();
break;
}
return;
}
}
e.D(new Object[]{BillingResultExtensionsKt.toHumanReadableDescription(jVar)}, 1, "Billing Service Setup finished with error code: %s", LogIntent.GOOGLE_WARNING);
return;
}
e.D(new Object[]{BillingResultExtensionsKt.toHumanReadableDescription(jVar)}, 1, "Billing Service Setup finished with error code: %s", LogIntent.GOOGLE_WARNING);
billingWrapper.retryBillingServiceConnectionWithExponentialBackoff();
}
public final void queryPurchaseType(String productType, final String purchaseToken, final Function1<? super ProductType, Unit> listener, final Function1<? super Boolean, Unit> resultHandler) {
BillingClientUseCase.run$default(new QueryPurchasesByTypeUseCase(new QueryPurchasesByTypeUseCaseParams(this.dateProvider, this.diagnosticsTrackerIfEnabled, getAppInBackground(), productType), new Function1<Map<String, ? extends StoreTransaction>, Unit>() {
{
super(1);
}
public final void invoke(Map<String, StoreTransaction> map) {
Intrinsics.h(map, "purchases");
Function1<Boolean, Unit> function1 = resultHandler;
Collection<StoreTransaction> values = map.values();
String str = purchaseToken;
boolean z = false;
if (!(values instanceof Collection) || !values.isEmpty()) {
Iterator<T> it = values.iterator();
while (true) {
if (!it.hasNext()) {
break;
} else if (Intrinsics.c(((StoreTransaction) it.next()).getPurchaseToken(), str)) {
z = true;
break;
}
}
}
function1.invoke(Boolean.valueOf(z));
}
public Object invoke(Object obj) {
invoke((Map<String, StoreTransaction>) obj);
return Unit.a;
}
}, new Function1<PurchasesError, Unit>() {
{
super(1);
}
public final void invoke(PurchasesError purchasesError) {
Intrinsics.h(purchasesError, "error");
LogUtilsKt.errorLog(purchasesError);
listener.invoke(ProductType.UNKNOWN);
}
public Object invoke(Object obj) {
invoke((PurchasesError) obj);
return Unit.a;
}
}, new BillingWrapper$queryPurchaseType$3(this), new BillingWrapper$queryPurchaseType$4(this)), 0L, 1, null);
}
private final void retryBillingServiceConnectionWithExponentialBackoff() {
if (this.reconnectionAlreadyScheduled) {
LogWrapperKt.log(LogIntent.WARNING, "BillingClient connection retry already scheduled. Ignoring");
return;
}
e.D(new Object[]{Long.valueOf(this.reconnectMilliseconds)}, 1, "Retrying BillingClient connection after backoff of %s milliseconds.", LogIntent.WARNING);
this.reconnectionAlreadyScheduled = true;
startConnectionOnMainThread(this.reconnectMilliseconds);
this.reconnectMilliseconds = Math.min(this.reconnectMilliseconds * 2, 900000L);
}
private final synchronized void sendErrorsToAllPendingRequests(PurchasesError error) {
while (true) {
Pair<Function1<PurchasesError, Unit>, Long> poll = this.serviceRequests.poll();
if (poll != null) {
this.mainHandler.post(new aa.d(17, (Function1) poll.w, error));
}
}
}
public static final void sendErrorsToAllPendingRequests$lambda$36$lambda$35(Function1 function1, PurchasesError purchasesError) {
Intrinsics.h(function1, "$serviceRequest");
Intrinsics.h(purchasesError, "$error");
function1.invoke(purchasesError);
}
public static final void startConnectionOnMainThread$lambda$4(BillingWrapper billingWrapper) {
Intrinsics.h(billingWrapper, "this$0");
billingWrapper.startConnection();
}
private final void trackProductDetailsNotSupportedIfNeeded() {
int i;
if (this.diagnosticsTrackerIfEnabled == null) {
return;
}
Qa.b bVar = this.billingClient;
j d = bVar != null ? bVar.d("fff") : null;
if (d == null || (i = d.a) != -2) {
return;
}
DiagnosticsTracker diagnosticsTracker = this.diagnosticsTrackerIfEnabled;
String str = d.b;
Intrinsics.g(str, "billingResult.debugMessage");
diagnosticsTracker.trackProductDetailsNotSupported(i, str);
}
public final void trackPurchaseStartIfNeeded(com.revenuecat.purchases.models.GooglePurchasingData r10, java.lang.String r11) {
throw new UnsupportedOperationException("Method not decompiled: com.revenuecat.purchases.google.BillingWrapper.trackPurchaseStartIfNeeded(com.revenuecat.purchases.models.GooglePurchasingData, java.lang.String):void");
}
private final void trackPurchaseUpdateReceivedIfNeeded(j billingResult, List<? extends Purchase> purchases) {
ArrayList arrayList;
DiagnosticsTracker diagnosticsTracker = this.diagnosticsTrackerIfEnabled;
if (diagnosticsTracker == null) {
return;
}
ArrayList arrayList2 = null;
if (purchases != null) {
arrayList = new ArrayList();
Iterator<T> it = purchases.iterator();
while (it.hasNext()) {
bl.c.n0(arrayList, ((Purchase) it.next()).a());
}
} else {
arrayList = null;
}
if (purchases != null) {
arrayList2 = new ArrayList(bl.b.a0(purchases, 10));
Iterator<T> it2 = purchases.iterator();
while (it2.hasNext()) {
int i = 1;
if (((Purchase) it2.next()).c.optInt("purchaseState", 1) == 4) {
i = 2;
}
arrayList2.add(PurchaseStateConversionsKt.toRevenueCatPurchaseState(i).name());
}
}
int i2 = billingResult.a;
String str = billingResult.b;
Intrinsics.g(str, "billingResult.debugMessage");
diagnosticsTracker.trackGooglePurchaseUpdateReceived(arrayList, arrayList2, i2, str);
}
public final void withConnectedClient(Function1<? super Qa.b, Unit> receivingFunction) {
Qa.b bVar = this.billingClient;
Unit unit = null;
if (bVar != null) {
if (!bVar.e()) {
bVar = null;
}
if (bVar != null) {
receivingFunction.invoke(bVar);
unit = Unit.a;
}
}
if (unit == null) {
e.D(new Object[]{getStackTrace()}, 1, "Billing is disconnected and purchase methods won't work. Stacktrace: %s", LogIntent.GOOGLE_WARNING);
}
}
public final void acknowledge$purchases_defaultsRelease(String token, PostReceiptInitiationSource initiationSource, Function1<? super String, Unit> onAcknowledged) {
Intrinsics.h(token, "token");
Intrinsics.h(initiationSource, "initiationSource");
Intrinsics.h(onAcknowledged, "onAcknowledged");
LogWrapperKt.log(LogIntent.PURCHASE, String.format("Acknowledging purchase with token %s", Arrays.copyOf(new Object[]{token}, 1)));
BillingClientUseCase.run$default(new AcknowledgePurchaseUseCase(new AcknowledgePurchaseUseCaseParams(token, initiationSource, getAppInBackground()), onAcknowledged, new Function1<PurchasesError, Unit>() {
public final void invoke(PurchasesError purchasesError) {
Intrinsics.h(purchasesError, "<anonymous parameter 0>");
}
public Object invoke(Object obj) {
invoke((PurchasesError) obj);
return Unit.a;
}
}, new BillingWrapper$acknowledge$2(this), new BillingWrapper$acknowledge$3(this)), 0L, 1, null);
}
@Override
public void consumeAndSave(boolean finishTransactions, StoreTransaction purchase, boolean shouldConsume, PostReceiptInitiationSource initiationSource) {
Intrinsics.h(purchase, "purchase");
Intrinsics.h(initiationSource, "initiationSource");
if (purchase.getType() == ProductType.UNKNOWN || purchase.getPurchaseState() == PurchaseState.PENDING) {
return;
}
Purchase originalGooglePurchase = StoreTransactionConversionsKt.getOriginalGooglePurchase(purchase);
boolean optBoolean = originalGooglePurchase != null ? originalGooglePurchase.c.optBoolean("acknowledged", true) : false;
if (purchase.getType() != ProductType.INAPP) {
if (!finishTransactions || optBoolean) {
this.deviceCache.addSuccessfullyPostedToken(purchase.getPurchaseToken());
return;
} else {
acknowledge$purchases_defaultsRelease(purchase.getPurchaseToken(), initiationSource, new BillingWrapper$consumeAndSave$3(this.deviceCache));
return;
}
}
if (finishTransactions && shouldConsume) {
consumePurchase$purchases_defaultsRelease(purchase.getPurchaseToken(), initiationSource, new BillingWrapper$consumeAndSave$1(this.deviceCache));
} else if (!finishTransactions || optBoolean) {
this.deviceCache.addSuccessfullyPostedToken(purchase.getPurchaseToken());
} else {
LogWrapperKt.log(LogIntent.PURCHASE, "Not consuming in-app purchase according to server configuration. This is expected for non-consumable products. The user won't be able to purchase this product again.");
acknowledge$purchases_defaultsRelease(purchase.getPurchaseToken(), initiationSource, new BillingWrapper$consumeAndSave$2(this.deviceCache));
}
}
public final void consumePurchase$purchases_defaultsRelease(String token, PostReceiptInitiationSource initiationSource, Function1<? super String, Unit> onConsumed) {
Intrinsics.h(token, "token");
Intrinsics.h(initiationSource, "initiationSource");
Intrinsics.h(onConsumed, "onConsumed");
LogWrapperKt.log(LogIntent.PURCHASE, String.format("Consuming purchase with token %s", Arrays.copyOf(new Object[]{token}, 1)));
BillingClientUseCase.run$default(new ConsumePurchaseUseCase(new ConsumePurchaseUseCaseParams(token, initiationSource, getAppInBackground()), onConsumed, new Function1<PurchasesError, Unit>() {
public final void invoke(PurchasesError purchasesError) {
Intrinsics.h(purchasesError, "<anonymous parameter 0>");
}
public Object invoke(Object obj) {
invoke((PurchasesError) obj);
return Unit.a;
}
}, new BillingWrapper$consumePurchase$2(this), new BillingWrapper$consumePurchase$3(this)), 0L, 1, null);
}
@Override
public void endConnection() {
this.mainHandler.post(new b(this, 0));
}
@Override
public void findPurchaseInPurchaseHistory(String appUserID, final ProductType productType, final String productId, final Function1<? super StoreTransaction, Unit> onCompletion, final Function1<? super PurchasesError, Unit> onError) {
Function1<? super PurchasesError, Unit> function1;
Intrinsics.h(appUserID, "appUserID");
Intrinsics.h(productType, "productType");
Intrinsics.h(productId, "productId");
Intrinsics.h(onCompletion, "onCompletion");
Intrinsics.h(onError, "onError");
LogWrapperKt.log(LogIntent.DEBUG, String.format("Querying Purchase with %s and type %s", Arrays.copyOf(new Object[]{productId, productType.name()}, 2)));
String googleProductType = ProductTypeConversionsKt.toGoogleProductType(productType);
Unit unit = null;
if (googleProductType != null) {
function1 = onError;
BillingClientUseCase.run$default(new QueryPurchaseHistoryUseCase(new QueryPurchaseHistoryUseCaseParams(this.dateProvider, this.diagnosticsTrackerIfEnabled, googleProductType, getAppInBackground()), new Function1<List<? extends PurchaseHistoryRecord>, Unit>() {
{
super(1);
}
public final void invoke(List<? extends PurchaseHistoryRecord> list) {
Object obj;
Intrinsics.h(list, "purchasesList");
String str = productId;
Iterator<T> it = list.iterator();
while (true) {
if (!it.hasNext()) {
obj = null;
break;
} else {
obj = it.next();
if (((PurchaseHistoryRecord) obj).a().contains(str)) {
break;
}
}
}
PurchaseHistoryRecord purchaseHistoryRecord = (PurchaseHistoryRecord) obj;
StoreTransaction storeTransaction = purchaseHistoryRecord != null ? StoreTransactionConversionsKt.toStoreTransaction(purchaseHistoryRecord, ProductType.this) : null;
if (storeTransaction != null) {
onCompletion.invoke(storeTransaction);
} else {
onError.invoke(new PurchasesError(PurchasesErrorCode.PurchaseInvalidError, String.format("Couldn't find existing purchase for SKU: %s", Arrays.copyOf(new Object[]{productId}, 1))));
}
}
public Object invoke(Object obj) {
invoke((List<? extends PurchaseHistoryRecord>) obj);
return Unit.a;
}
}, function1, new BillingWrapper$findPurchaseInPurchaseHistory$1$2(this), new BillingWrapper$findPurchaseInPurchaseHistory$1$3(this)), 0L, 1, null);
unit = Unit.a;
} else {
function1 = onError;
}
if (unit == null) {
function1.invoke(new PurchasesError(PurchasesErrorCode.PurchaseInvalidError, "Type of product not recognized."));
}
}
public final boolean getAppInBackground() {
return getPurchasesStateProvider().getPurchasesState().getAppInBackground();
}
public final synchronized Qa.b getBillingClient() {
return this.billingClient;
}
public final Map<String, PurchaseContext> getPurchaseContext$purchases_defaultsRelease() {
return this.purchaseContext;
}
public final void getPurchaseType$purchases_defaultsRelease(final String purchaseToken, final Function1<? super ProductType, Unit> listener) {
Intrinsics.h(purchaseToken, "purchaseToken");
Intrinsics.h(listener, "listener");
queryPurchaseType("subs", purchaseToken, listener, new Function1<Boolean, Unit>() {
{
super(1);
}
public Object invoke(Object obj) {
invoke(((Boolean) obj).booleanValue());
return Unit.a;
}
public final void invoke(boolean z) {
if (z) {
listener.invoke(ProductType.SUBS);
return;
}
BillingWrapper billingWrapper = this;
String str = purchaseToken;
final Function1<ProductType, Unit> function1 = listener;
billingWrapper.queryPurchaseType("inapp", str, function1, new Function1<Boolean, Unit>() {
{
super(1);
}
public Object invoke(Object obj) {
invoke(((Boolean) obj).booleanValue());
return Unit.a;
}
public final void invoke(boolean z2) {
if (z2) {
function1.invoke(ProductType.INAPP);
} else {
function1.invoke(ProductType.UNKNOWN);
}
}
});
}
});
}
@Override
public void getStorefront(final Function1<? super String, Unit> onSuccess, Function1<? super PurchasesError, Unit> onError) {
Intrinsics.h(onSuccess, "onSuccess");
Intrinsics.h(onError, "onError");
LogUtilsKt.verboseLog("Billing client: Initiating getting country code.");
BillingClientUseCase.run$default(new GetBillingConfigUseCase(new GetBillingConfigUseCaseParams(getAppInBackground()), this.deviceCache, new Function1<Qa.e, Unit>() {
{
super(1);
}
public final void invoke(Qa.e eVar) {
Intrinsics.h(eVar, "billingConfig");
Function1<String, Unit> function1 = onSuccess;
String str = eVar.a;
Intrinsics.g(str, "billingConfig.countryCode");
function1.invoke(str);
}
public Object invoke(Object obj) {
invoke((Qa.e) obj);
return Unit.a;
}
}, onError, new BillingWrapper$getStorefront$2(this), new BillingWrapper$getStorefront$3(this)), 0L, 1, null);
}
@Override
public boolean getConnected() {
Qa.b bVar = this.billingClient;
if (bVar != null) {
return bVar.e();
}
return false;
}
@Override
public void makePurchaseAsync(final Activity activity, final String appUserID, final PurchasingData purchasingData, final ReplaceProductInfo replaceProductInfo, PresentedOfferingContext presentedOfferingContext, final Boolean isPersonalizedPrice) {
String optionId;
ReplacementMode replacementMode;
Intrinsics.h(activity, "activity");
Intrinsics.h(appUserID, "appUserID");
Intrinsics.h(purchasingData, "purchasingData");
final GooglePurchasingData googlePurchasingData = purchasingData instanceof GooglePurchasingData ? (GooglePurchasingData) purchasingData : null;
if (googlePurchasingData == null) {
PurchasesError purchasesError = new PurchasesError(PurchasesErrorCode.UnknownError, String.format("Purchase for a %s purchase must be a %s.", Arrays.copyOf(new Object[]{"Play", "GooglePurchasingData"}, 2)));
LogUtilsKt.errorLog(purchasesError);
BillingAbstract.PurchasesUpdatedListener purchasesUpdatedListener = getPurchasesUpdatedListener();
if (purchasesUpdatedListener != null) {
purchasesUpdatedListener.onPurchasesFailedToUpdate(purchasesError);
return;
}
return;
}
if (googlePurchasingData instanceof GooglePurchasingData.InAppProduct) {
optionId = null;
} else {
if (!(googlePurchasingData instanceof GooglePurchasingData.Subscription)) {
throw new NoWhenBranchMatchedException();
}
optionId = ((GooglePurchasingData.Subscription) googlePurchasingData).getOptionId();
}
if (replaceProductInfo != null) {
e.D(new Object[]{replaceProductInfo.getOldPurchase().getProductIds().get(0), googlePurchasingData.getProductId()}, 2, "Moving from old SKU %s to sku %s", LogIntent.PURCHASE);
} else {
e.D(new Object[]{googlePurchasingData.getProductId()}, 1, "Purchasing product: %s", LogIntent.PURCHASE);
}
synchronized (this) {
if (replaceProductInfo != null) {
try {
replacementMode = replaceProductInfo.getReplacementMode();
} catch (Throwable th) {
throw th;
}
} else {
replacementMode = null;
}
String productId = replacementMode == GoogleReplacementMode.DEFERRED ? (String) bl.f.F0(replaceProductInfo.getOldPurchase().getProductIds()) : googlePurchasingData.getProductId();
Map<String, PurchaseContext> map = this.purchaseContext;
ProductType productType = googlePurchasingData.getProductType();
ReplacementMode replacementMode2 = replaceProductInfo != null ? replaceProductInfo.getReplacementMode() : null;
map.put(productId, new PurchaseContext(productType, presentedOfferingContext, optionId, replacementMode2 instanceof GoogleReplacementMode ? (GoogleReplacementMode) replacementMode2 : null));
Unit unit = Unit.a;
}
executeRequestOnUIThread$default(this, null, new Function1<PurchasesError, Unit>() {
{
super(1);
}
public Object invoke(Object obj) {
invoke((PurchasesError) obj);
return Unit.a;
}
public final void invoke(PurchasesError purchasesError2) {
Result.Success buildPurchaseParams;
BillingAbstract.PurchasesUpdatedListener purchasesUpdatedListener2;
StoreTransaction oldPurchase;
List<String> productIds;
buildPurchaseParams = BillingWrapper.this.buildPurchaseParams((GooglePurchasingData) purchasingData, replaceProductInfo, appUserID, isPersonalizedPrice);
if (!(buildPurchaseParams instanceof Result.Success)) {
if (!(buildPurchaseParams instanceof Result.Error) || (purchasesUpdatedListener2 = BillingWrapper.this.getPurchasesUpdatedListener()) == null) {
return;
}
purchasesUpdatedListener2.onPurchasesFailedToUpdate((PurchasesError) ((Result.Error) buildPurchaseParams).getValue());
return;
}
BillingWrapper billingWrapper = BillingWrapper.this;
GooglePurchasingData googlePurchasingData2 = googlePurchasingData;
ReplaceProductInfo replaceProductInfo2 = replaceProductInfo;
billingWrapper.trackPurchaseStartIfNeeded(googlePurchasingData2, (replaceProductInfo2 == null || (oldPurchase = replaceProductInfo2.getOldPurchase()) == null || (productIds = oldPurchase.getProductIds()) == null) ? null : (String) bl.f.H0(productIds));
BillingWrapper.this.launchBillingFlow(activity, (i) buildPurchaseParams.getValue());
}
}, 1, null);
}
public void onBillingServiceDisconnected() {
LogIntent logIntent = LogIntent.WARNING;
Qa.b bVar = this.billingClient;
e.D(new Object[]{bVar != null ? bVar.toString() : null}, 1, "Billing Service disconnected for %s", logIntent);
DiagnosticsTracker diagnosticsTracker = this.diagnosticsTrackerIfEnabled;
if (diagnosticsTracker != null) {
diagnosticsTracker.trackGoogleBillingServiceDisconnected();
}
}
public void onBillingSetupFinished(j billingResult) {
Intrinsics.h(billingResult, "billingResult");
DiagnosticsTracker diagnosticsTracker = this.diagnosticsTrackerIfEnabled;
if (diagnosticsTracker != null) {
int i = billingResult.a;
String str = billingResult.b;
Intrinsics.g(str, "billingResult.debugMessage");
diagnosticsTracker.trackGoogleBillingSetupFinished(i, str, SequencesKt.u0(SequencesKt.D0(bl.f.w0(this.serviceRequests), 100)));
}
this.mainHandler.post(new aa.d(16, billingResult, this));
}
public void onPurchasesUpdated(j billingResult, List<? extends Purchase> purchases) {
Intrinsics.h(billingResult, "billingResult");
trackPurchaseUpdateReceivedIfNeeded(billingResult, purchases);
final List<? extends Purchase> list = purchases == null ? EmptyList.w : purchases;
if (billingResult.a == 0 && !list.isEmpty()) {
final ArrayList arrayList = new ArrayList();
Iterator<T> it = list.iterator();
while (it.hasNext()) {
getStoreTransaction((Purchase) it.next(), new Function1<StoreTransaction, Unit>() {
{
super(1);
}
public Object invoke(Object obj) {
invoke((StoreTransaction) obj);
return Unit.a;
}
public final void invoke(StoreTransaction storeTransaction) {
BillingAbstract.PurchasesUpdatedListener purchasesUpdatedListener;
Intrinsics.h(storeTransaction, "storeTxn");
arrayList.add(storeTransaction);
if (arrayList.size() != list.size() || (purchasesUpdatedListener = this.getPurchasesUpdatedListener()) == null) {
return;
}
purchasesUpdatedListener.onPurchasesUpdated(arrayList);
}
});
}
return;
}
LogIntent logIntent = LogIntent.GOOGLE_ERROR;
StringBuilder sb = new StringBuilder();
sb.append(String.format("BillingWrapper purchases failed to update: %s", Arrays.copyOf(new Object[]{BillingResultExtensionsKt.toHumanReadableDescription(billingResult)}, 1)));
String str = null;
List<? extends Purchase> list2 = !list.isEmpty() ? list : null;
if (list2 != null) {
str = "Purchases:" + bl.f.M0(list2, ", ", (String) null, (String) null, new Function1<Purchase, CharSequence>() {
public final CharSequence invoke(Purchase purchase) {
Intrinsics.h(purchase, "it");
return PurchaseExtensionsKt.toHumanReadableDescription(purchase);
}
}, 30);
}
sb.append(str);
LogWrapperKt.log(logIntent, sb.toString());
String str2 = "Error updating purchases. " + BillingResultExtensionsKt.toHumanReadableDescription(billingResult);
int i = billingResult.a;
if (purchases == null && i == 0) {
str2 = "Error: onPurchasesUpdated received an OK BillingResult with a Null purchases list.";
i = 6;
}
PurchasesError billingResponseToPurchasesError = ErrorsKt.billingResponseToPurchasesError(i, str2);
LogUtilsKt.errorLog(billingResponseToPurchasesError);
BillingAbstract.PurchasesUpdatedListener purchasesUpdatedListener = getPurchasesUpdatedListener();
if (purchasesUpdatedListener != null) {
purchasesUpdatedListener.onPurchasesFailedToUpdate(billingResponseToPurchasesError);
}
}
@Override
public void queryAllPurchases(String appUserID, final Function1<? super List<StoreTransaction>, Unit> onReceivePurchaseHistory, final Function1<? super PurchasesError, Unit> onReceivePurchaseHistoryError) {
Intrinsics.h(appUserID, "appUserID");
Intrinsics.h(onReceivePurchaseHistory, "onReceivePurchaseHistory");
Intrinsics.h(onReceivePurchaseHistoryError, "onReceivePurchaseHistoryError");
queryPurchaseHistoryAsync("subs", new Function1<List<? extends PurchaseHistoryRecord>, Unit>() {
{
super(1);
}
public Object invoke(Object obj) {
invoke((List<? extends PurchaseHistoryRecord>) obj);
return Unit.a;
}
public final void invoke(final List<? extends PurchaseHistoryRecord> list) {
Intrinsics.h(list, "subsPurchasesList");
BillingWrapper billingWrapper = BillingWrapper.this;
final Function1<List<StoreTransaction>, Unit> function1 = onReceivePurchaseHistory;
billingWrapper.queryPurchaseHistoryAsync("inapp", new Function1<List<? extends PurchaseHistoryRecord>, Unit>() {
{
super(1);
}
public Object invoke(Object obj) {
invoke((List<? extends PurchaseHistoryRecord>) obj);
return Unit.a;
}
public final void invoke(List<? extends PurchaseHistoryRecord> list2) {
Intrinsics.h(list2, "inAppPurchasesList");
Function1<List<StoreTransaction>, Unit> function12 = function1;
List<PurchaseHistoryRecord> list3 = list;
ArrayList arrayList = new ArrayList(bl.b.a0(list3, 10));
Iterator<T> it = list3.iterator();
while (it.hasNext()) {
arrayList.add(StoreTransactionConversionsKt.toStoreTransaction((PurchaseHistoryRecord) it.next(), ProductType.SUBS));
}
ArrayList arrayList2 = new ArrayList(bl.b.a0(list2, 10));
Iterator<T> it2 = list2.iterator();
while (it2.hasNext()) {
arrayList2.add(StoreTransactionConversionsKt.toStoreTransaction((PurchaseHistoryRecord) it2.next(), ProductType.INAPP));
}
function12.invoke(bl.f.X0(arrayList, arrayList2));
}
}, onReceivePurchaseHistoryError);
}
}, onReceivePurchaseHistoryError);
}
@Override
public void queryProductDetailsAsync(ProductType productType, Set<String> productIds, Function1<? super List<? extends StoreProduct>, Unit> onReceive, Function1<? super PurchasesError, Unit> onError) {
Intrinsics.h(productType, "productType");
Intrinsics.h(productIds, "productIds");
Intrinsics.h(onReceive, "onReceive");
Intrinsics.h(onError, "onError");
LogWrapperKt.log(LogIntent.DEBUG, String.format("Requesting products from the store with identifiers: %s", Arrays.copyOf(new Object[]{bl.f.M0(productIds, (String) null, (String) null, (String) null, (Function1) null, 63)}, 1)));
BillingClientUseCase.run$default(new QueryProductDetailsUseCase(new QueryProductDetailsUseCaseParams(this.dateProvider, this.diagnosticsTrackerIfEnabled, productIds, productType, getAppInBackground()), onReceive, onError, new BillingWrapper$queryProductDetailsAsync$useCase$1(this), new BillingWrapper$queryProductDetailsAsync$useCase$2(this)), 0L, 1, null);
}
public final void queryPurchaseHistoryAsync(String productType, Function1<? super List<? extends PurchaseHistoryRecord>, Unit> onReceivePurchaseHistory, Function1<? super PurchasesError, Unit> onReceivePurchaseHistoryError) {
Intrinsics.h(productType, "productType");
Intrinsics.h(onReceivePurchaseHistory, "onReceivePurchaseHistory");
Intrinsics.h(onReceivePurchaseHistoryError, "onReceivePurchaseHistoryError");
LogWrapperKt.log(LogIntent.DEBUG, String.format("Querying purchase history for type %s", Arrays.copyOf(new Object[]{productType}, 1)));
BillingClientUseCase.run$default(new QueryPurchaseHistoryUseCase(new QueryPurchaseHistoryUseCaseParams(this.dateProvider, this.diagnosticsTrackerIfEnabled, productType, getAppInBackground()), onReceivePurchaseHistory, onReceivePurchaseHistoryError, new BillingWrapper$queryPurchaseHistoryAsync$1(this), new BillingWrapper$queryPurchaseHistoryAsync$2(this)), 0L, 1, null);
}
@Override
public void queryPurchases(String appUserID, Function1<? super Map<String, StoreTransaction>, Unit> onSuccess, Function1<? super PurchasesError, Unit> onError) {
Intrinsics.h(appUserID, "appUserID");
Intrinsics.h(onSuccess, "onSuccess");
Intrinsics.h(onError, "onError");
LogWrapperKt.log(LogIntent.DEBUG, "Querying purchases");
BillingClientUseCase.run$default(new QueryPurchasesUseCase(new QueryPurchasesUseCaseParams(this.dateProvider, this.diagnosticsTrackerIfEnabled, getAppInBackground()), onSuccess, onError, new BillingWrapper$queryPurchases$1(this), new BillingWrapper$queryPurchases$2(this)), 0L, 1, null);
}
public final synchronized void setBillingClient(Qa.b bVar) {
this.billingClient = bVar;
}
@Override
public void showInAppMessagesIfNeeded(Activity activity, List<? extends InAppMessageType> inAppMessageTypes, final Function0<Unit> subscriptionStatusChange) {
Intrinsics.h(activity, "activity");
Intrinsics.h(inAppMessageTypes, "inAppMessageTypes");
Intrinsics.h(subscriptionStatusChange, "subscriptionStatusChange");
if (inAppMessageTypes.isEmpty()) {
LogUtilsKt.errorLog$default("Tried to show in-app messages without specifying any types. Please add what types of in-app message you want to display.", null, 2, null);
return;
}
HashSet hashSet = new HashSet();
Iterator<? extends InAppMessageType> it = inAppMessageTypes.iterator();
while (it.hasNext()) {
hashSet.add(Integer.valueOf(it.next().getInAppMessageCategoryId()));
}
final k kVar = new k(hashSet);
final WeakReference weakReference = new WeakReference(activity);
executeRequestOnUIThread$default(this, null, new Function1<PurchasesError, Unit>() {
@Metadata(d1 = {"\u0000\f\n\u0002\u0018\u0002\n\u0002\u0010\u0002\n\u0002\b\u0003\u0010\u0004\u001a\u00020\u0001*\u00020\u0000H\n¢\u0006\u0004\b\u0002\u0010\u0003"}, d2 = {"LQa/b;", "", "invoke", "(LQa/b;)V", "<anonymous>"}, k = 3, mv = {1, 8, 0})
public static final class AnonymousClass1 extends Lambda implements Function1<Qa.b, Unit> {
final k $inAppMessageParams;
final Function0<Unit> $subscriptionStatusChange;
final WeakReference<Activity> $weakActivity;
public AnonymousClass1(WeakReference<Activity> weakReference, k kVar, Function0<Unit> function0) {
super(1);
this.$weakActivity = weakReference;
this.$inAppMessageParams = kVar;
this.$subscriptionStatusChange = function0;
}
public static final void invoke$lambda$1(Function0 function0, Qa.l lVar) {
Intrinsics.h(function0, "$subscriptionStatusChange");
Intrinsics.h(lVar, "inAppMessageResult");
int i = lVar.a;
if (i == 0) {
LogUtilsKt.verboseLog("No Google Play in-app message was available.");
} else if (i != 1) {
LogUtilsKt.errorLog$default(String.format("Unexpected billing code: %s", Arrays.copyOf(new Object[]{Integer.valueOf(i)}, 1)), null, 2, null);
} else {
LogUtilsKt.debugLog("Subscription status was updated from in-app message.");
function0.invoke();
}
}
public Object invoke(Object obj) {
invoke((Qa.b) obj);
return Unit.a;
}
public final void invoke(Qa.b bVar) {
Intrinsics.h(bVar, "$this$withConnectedClient");
Activity activity = this.$weakActivity.get();
if (activity == null) {
LogUtilsKt.debugLog("Activity is null, not showing Google Play in-app message.");
return;
}
k kVar = this.$inAppMessageParams;
final Function0<Unit> function0 = this.$subscriptionStatusChange;
Object obj =
throw new UnsupportedOperationException("Method not decompiled: com.revenuecat.purchases.google.BillingWrapper$showInAppMessagesIfNeeded$1.AnonymousClass1.invoke(Qa.b):void");
}
}
{
super(1);
}
public Object invoke(Object obj) {
invoke((PurchasesError) obj);
return Unit.a;
}
public final void invoke(PurchasesError purchasesError) {
if (purchasesError != null) {
LogUtilsKt.errorLog$default(String.format("Error connecting to billing client to display in-app messages: %s", Arrays.copyOf(new Object[]{purchasesError}, 1)), null, 2, null);
} else {
BillingWrapper.this.withConnectedClient(new AnonymousClass1(weakReference, kVar, subscriptionStatusChange));
}
}
}, 1, null);
}
@Override
public void startConnection() {
synchronized (this) {
try {
if (this.billingClient == null) {
this.billingClient = this.clientFactory.buildClient(this);
}
this.reconnectionAlreadyScheduled = false;
Qa.b bVar = this.billingClient;
if (bVar != null) {
if (!bVar.e()) {
LogWrapperKt.log(LogIntent.DEBUG, String.format("Starting connection for %s", Arrays.copyOf(new Object[]{bVar}, 1)));
DiagnosticsTracker diagnosticsTracker = this.diagnosticsTrackerIfEnabled;
if (diagnosticsTracker != null) {
diagnosticsTracker.trackGoogleBillingStartConnection();
}
try {
bVar.h(this);
} catch (IllegalStateException e) {
LogWrapperKt.log(LogIntent.GOOGLE_ERROR, String.format("There was an IllegalStateException when connecting to BillingClient. This has been reported to occur on Samsung devices on unknown circumstances.\nException: %s", Arrays.copyOf(new Object[]{e}, 1)));
sendErrorsToAllPendingRequests(new PurchasesError(PurchasesErrorCode.StoreProblemError, e.getMessage()));
}
}
Unit unit = Unit.a;
}
} catch (Throwable th) {
throw th;
}
}
}
@Override
public void startConnectionOnMainThread(long delayMilliseconds) {
this.mainHandler.postDelayed(new b(this, 1), delayMilliseconds);
}
public BillingWrapper(ClientFactory clientFactory, Handler handler, DeviceCache deviceCache, DiagnosticsTracker diagnosticsTracker, PurchasesStateProvider purchasesStateProvider, DateProvider dateProvider) {
super(purchasesStateProvider);
Intrinsics.h(clientFactory, "clientFactory");
Intrinsics.h(handler, "mainHandler");
Intrinsics.h(deviceCache, "deviceCache");
Intrinsics.h(purchasesStateProvider, "purchasesStateProvider");
Intrinsics.h(dateProvider, "dateProvider");
this.clientFactory = clientFactory;
this.mainHandler = handler;
this.deviceCache = deviceCache;
this.diagnosticsTrackerIfEnabled = diagnosticsTracker;
this.dateProvider = dateProvider;
this.purchaseContext = new LinkedHashMap();
this.serviceRequests = new ConcurrentLinkedQueue<>();
this.reconnectMilliseconds = 1000L;
}
}