正在查看: Rilo v2.0.21 应用的 StripeBrowserLauncherViewModel.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: Rilo v2.0.21 应用的 StripeBrowserLauncherViewModel.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
package com.stripe.android.payments;
import android.app.Application;
import android.content.Intent;
import android.net.Uri;
import androidx.browser.customtabs.CustomTabColorSchemeParams;
import androidx.browser.customtabs.CustomTabsIntent;
import androidx.lifecycle.SavedStateHandle;
import androidx.lifecycle.SavedStateHandleSupport;
import androidx.lifecycle.ViewModel;
import androidx.lifecycle.ViewModelProvider;
import androidx.lifecycle.viewmodel.CreationExtras;
import com.stripe.android.PaymentConfiguration;
import com.stripe.android.auth.PaymentBrowserAuthContract;
import com.stripe.android.core.browser.BrowserCapabilities;
import com.stripe.android.core.browser.BrowserCapabilitiesSupplier;
import com.stripe.android.core.exception.LocalStripeException;
import com.stripe.android.core.exception.StripeException;
import com.stripe.android.core.networking.AnalyticsRequestExecutor;
import com.stripe.android.core.networking.DefaultAnalyticsRequestExecutor;
import com.stripe.android.networking.PaymentAnalyticsEvent;
import com.stripe.android.networking.PaymentAnalyticsRequestFactory;
import com.stripe.android.payments.PaymentFlowResult;
import com.stripe.android.utils.CreationExtrasKtxKt;
import com.tiktok.appevents.contents.TTContentsEventConstants;
import kotlin.Metadata;
import kotlin.NoWhenBranchMatchedException;
import kotlin.jvm.functions.Function1;
import kotlin.jvm.internal.Intrinsics;
@Metadata(d1 = {"\u0000V\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\u0010\u000e\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\u0010\u000b\n\u0002\b\b\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0004\n\u0002\u0010\u0002\n\u0002\b\u0003\b\u0000\u0018\u0000 #2\u00020\u0001:\u0002#$BI\u0012\u0006\u0010\u0002\u001a\u00020\u0003\u0012\u0006\u0010\u0004\u001a\u00020\u0005\u0012\u0006\u0010\u0006\u001a\u00020\u0007\u0012\u0006\u0010\b\u001a\u00020\t\u0012\u0006\u0010\n\u001a\u00020\t\u0012\u0006\u0010\u000b\u001a\u00020\f\u0012\u0012\u0010\r\u001a\u000e\u0012\u0004\u0012\u00020\u000f\u0012\u0004\u0012\u00020\u00100\u000e¢\u0006\u0002\u0010\u0011J\u0018\u0010\u0018\u001a\u00020\u00192\u0006\u0010\u001a\u001a\u00020\u001b2\u0006\u0010\u001c\u001a\u00020\u001dH\u0002J\u0010\u0010\u001e\u001a\u0004\u0018\u00010\u000f2\u0006\u0010\u001a\u001a\u00020\u001bJ\u000e\u0010\u001f\u001a\u00020\u000f2\u0006\u0010\u001a\u001a\u00020\u001bJ\u000e\u0010 \u001a\u00020\u000f2\u0006\u0010\u001a\u001a\u00020\u001bJ\b\u0010!\u001a\u00020\"H\u0002R\u000e\u0010\u0002\u001a\u00020\u0003X\u0082\u0004¢\u0006\u0002\n\u0000R\u000e\u0010\u0006\u001a\u00020\u0007X\u0082\u0004¢\u0006\u0002\n\u0000R$\u0010\u0013\u001a\u00020\u00102\u0006\u0010\u0012\u001a\u00020\u00108F@FX\u0086\u000e¢\u0006\f\u001a\u0004\b\u0014\u0010\u0015\"\u0004\b\u0016\u0010\u0017R\u000e\u0010\b\u001a\u00020\tX\u0082\u0004¢\u0006\u0002\n\u0000R\u001a\u0010\r\u001a\u000e\u0012\u0004\u0012\u00020\u000f\u0012\u0004\u0012\u00020\u00100\u000eX\u0082\u0004¢\u0006\u0002\n\u0000R\u000e\u0010\u0004\u001a\u00020\u0005X\u0082\u0004¢\u0006\u0002\n\u0000R\u000e\u0010\n\u001a\u00020\tX\u0082\u0004¢\u0006\u0002\n\u0000R\u000e\u0010\u000b\u001a\u00020\fX\u0082\u0004¢\u0006\u0002\n\u0000¨\u0006%"}, d2 = {"Lcom/stripe/android/payments/StripeBrowserLauncherViewModel;", "Landroidx/lifecycle/ViewModel;", "analyticsRequestExecutor", "Lcom/stripe/android/core/networking/AnalyticsRequestExecutor;", "paymentAnalyticsRequestFactory", "Lcom/stripe/android/networking/PaymentAnalyticsRequestFactory;", "browserCapabilities", "Lcom/stripe/android/core/browser/BrowserCapabilities;", "intentChooserTitle", "", "resolveErrorMessage", "savedStateHandle", "Landroidx/lifecycle/SavedStateHandle;", "intentResolver", "Lkotlin/Function1;", "Landroid/content/Intent;", "", "(Lcom/stripe/android/core/networking/AnalyticsRequestExecutor;Lcom/stripe/android/networking/PaymentAnalyticsRequestFactory;Lcom/stripe/android/core/browser/BrowserCapabilities;Ljava/lang/String;Ljava/lang/String;Landroidx/lifecycle/SavedStateHandle;Lkotlin/jvm/functions/Function1;)V", TTContentsEventConstants.Params.EVENT_PROPERTY_VALUE, "hasLaunched", "getHasLaunched", "()Z", "setHasLaunched", "(Z)V", "createCustomTabsIntent", "Landroidx/browser/customtabs/CustomTabsIntent;", "args", "Lcom/stripe/android/auth/PaymentBrowserAuthContract$Args;", "url", "Landroid/net/Uri;", "createLaunchIntent", "getFailureIntent", "getResultIntent", "logBrowserCapabilities", "", "Companion", "Factory", "payments-core_release"}, k = 1, mv = {1, 8, 0}, xi = 48)
public final class StripeBrowserLauncherViewModel extends ViewModel {
public static final String KEY_HAS_LAUNCHED = "has_launched";
private final AnalyticsRequestExecutor analyticsRequestExecutor;
private final BrowserCapabilities browserCapabilities;
private final String intentChooserTitle;
private final Function1<Intent, Boolean> intentResolver;
private final PaymentAnalyticsRequestFactory paymentAnalyticsRequestFactory;
private final String resolveErrorMessage;
private final SavedStateHandle savedStateHandle;
@Metadata(k = 3, mv = {1, 8, 0}, xi = 48)
public class WhenMappings {
public static final int[] $EnumSwitchMapping$0;
static {
int[] iArr = new int[BrowserCapabilities.values().length];
try {
iArr[BrowserCapabilities.CustomTabs.ordinal()] = 1;
} catch (NoSuchFieldError unused) {
}
try {
iArr[BrowserCapabilities.Unknown.ordinal()] = 2;
} catch (NoSuchFieldError unused2) {
}
$EnumSwitchMapping$0 = iArr;
}
}
public StripeBrowserLauncherViewModel(AnalyticsRequestExecutor analyticsRequestExecutor, PaymentAnalyticsRequestFactory paymentAnalyticsRequestFactory, BrowserCapabilities browserCapabilities, String str, String str2, SavedStateHandle savedStateHandle, Function1<? super Intent, Boolean> function1) {
Intrinsics.checkNotNullParameter(analyticsRequestExecutor, "analyticsRequestExecutor");
Intrinsics.checkNotNullParameter(paymentAnalyticsRequestFactory, "paymentAnalyticsRequestFactory");
Intrinsics.checkNotNullParameter(browserCapabilities, "browserCapabilities");
Intrinsics.checkNotNullParameter(str, "intentChooserTitle");
Intrinsics.checkNotNullParameter(str2, "resolveErrorMessage");
Intrinsics.checkNotNullParameter(savedStateHandle, "savedStateHandle");
Intrinsics.checkNotNullParameter(function1, "intentResolver");
this.analyticsRequestExecutor = analyticsRequestExecutor;
this.paymentAnalyticsRequestFactory = paymentAnalyticsRequestFactory;
this.browserCapabilities = browserCapabilities;
this.intentChooserTitle = str;
this.resolveErrorMessage = str2;
this.savedStateHandle = savedStateHandle;
this.intentResolver = function1;
}
public final boolean getHasLaunched() {
Boolean bool = (Boolean) this.savedStateHandle.get(KEY_HAS_LAUNCHED);
if (bool != null) {
return bool.booleanValue();
}
return false;
}
public final void setHasLaunched(boolean z) {
this.savedStateHandle.set(KEY_HAS_LAUNCHED, Boolean.valueOf(z));
}
public final Intent createLaunchIntent(PaymentBrowserAuthContract.Args args) {
Intent intent;
Intrinsics.checkNotNullParameter(args, "args");
Uri parse = Uri.parse(args.getUrl());
logBrowserCapabilities();
int i2 = WhenMappings.$EnumSwitchMapping$0[this.browserCapabilities.ordinal()];
if (i2 == 1) {
Intrinsics.checkNotNullExpressionValue(parse, "url");
intent = createCustomTabsIntent(args, parse).intent;
} else {
if (i2 != 2) {
throw new NoWhenBranchMatchedException();
}
intent = new Intent("android.intent.action.VIEW", parse);
}
Intrinsics.checkNotNullExpressionValue(intent, "when (browserCapabilitie…)\n }\n }");
if (((Boolean) this.intentResolver.invoke(intent)).booleanValue()) {
return Intent.createChooser(intent, this.intentChooserTitle);
}
return null;
}
private final CustomTabsIntent createCustomTabsIntent(PaymentBrowserAuthContract.Args args, Uri url) {
CustomTabColorSchemeParams customTabColorSchemeParams;
Integer statusBarColor = args.getStatusBarColor();
if (statusBarColor != null) {
customTabColorSchemeParams = new CustomTabColorSchemeParams.Builder().setToolbarColor(statusBarColor.intValue()).build();
} else {
customTabColorSchemeParams = null;
}
CustomTabsIntent.Builder shareState = new CustomTabsIntent.Builder().setShareState(2);
if (customTabColorSchemeParams != null) {
shareState.setDefaultColorSchemeParams(customTabColorSchemeParams);
}
CustomTabsIntent build = shareState.build();
Intrinsics.checkNotNullExpressionValue(build, "Builder()\n .s… }\n .build()");
build.intent.setData(url);
return build;
}
public final Intent getResultIntent(PaymentBrowserAuthContract.Args args) {
Intrinsics.checkNotNullParameter(args, "args");
Uri parse = Uri.parse(args.getUrl());
Intent intent = new Intent();
String clientSecret = args.getClientSecret();
String lastPathSegment = parse.getLastPathSegment();
if (lastPathSegment == null) {
lastPathSegment = "";
}
String stripeAccountId = args.getStripeAccountId();
Intent putExtras = intent.putExtras(new PaymentFlowResult.Unvalidated(clientSecret, 0, null, args.getShouldCancelSource(), lastPathSegment, null, stripeAccountId, 38, null).toBundle());
Intrinsics.checkNotNullExpressionValue(putExtras, "Intent().putExtras(\n … ).toBundle()\n )");
return putExtras;
}
public final Intent getFailureIntent(PaymentBrowserAuthContract.Args args) {
Intrinsics.checkNotNullParameter(args, "args");
Uri parse = Uri.parse(args.getUrl());
StripeException localStripeException = new LocalStripeException(this.resolveErrorMessage);
Intent intent = new Intent();
String clientSecret = args.getClientSecret();
String lastPathSegment = parse.getLastPathSegment();
if (lastPathSegment == null) {
lastPathSegment = "";
}
String stripeAccountId = args.getStripeAccountId();
StripeException stripeException = localStripeException;
Intent putExtras = intent.putExtras(new PaymentFlowResult.Unvalidated(clientSecret, 2, stripeException, args.getShouldCancelSource(), lastPathSegment, null, stripeAccountId, 32, null).toBundle());
Intrinsics.checkNotNullExpressionValue(putExtras, "Intent().putExtras(\n … ).toBundle()\n )");
return putExtras;
}
private final void logBrowserCapabilities() {
PaymentAnalyticsEvent paymentAnalyticsEvent;
int i2 = WhenMappings.$EnumSwitchMapping$0[this.browserCapabilities.ordinal()];
if (i2 == 1) {
paymentAnalyticsEvent = PaymentAnalyticsEvent.AuthWithCustomTabs;
} else {
if (i2 != 2) {
throw new NoWhenBranchMatchedException();
}
paymentAnalyticsEvent = PaymentAnalyticsEvent.AuthWithDefaultBrowser;
}
this.analyticsRequestExecutor.executeAsync(PaymentAnalyticsRequestFactory.createRequest$payments_core_release$default(this.paymentAnalyticsRequestFactory, paymentAnalyticsEvent, null, null, null, null, 30, null));
}
@Metadata(d1 = {"\u0000 \n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0002\b\u0007\u0018\u00002\u00020\u0001B\u0005¢\u0006\u0002\u0010\u0002J-\u0010\u0003\u001a\u0002H\u0004\"\b\b\u0000\u0010\u0004*\u00020\u00052\f\u0010\u0006\u001a\b\u0012\u0004\u0012\u0002H\u00040\u00072\u0006\u0010\b\u001a\u00020\tH\u0016¢\u0006\u0002\u0010\n¨\u0006\u000b"}, d2 = {"Lcom/stripe/android/payments/StripeBrowserLauncherViewModel$Factory;", "Landroidx/lifecycle/ViewModelProvider$Factory;", "()V", "create", "T", "Landroidx/lifecycle/ViewModel;", "modelClass", "Ljava/lang/Class;", "extras", "Landroidx/lifecycle/viewmodel/CreationExtras;", "(Ljava/lang/Class;Landroidx/lifecycle/viewmodel/CreationExtras;)Landroidx/lifecycle/ViewModel;", "payments-core_release"}, k = 1, mv = {1, 8, 0}, xi = 48)
public static final class Factory implements ViewModelProvider.Factory {
public static final int $stable = 0;
public <T extends ViewModel> T create(Class<T> modelClass, CreationExtras extras) {
Intrinsics.checkNotNullParameter(modelClass, "modelClass");
Intrinsics.checkNotNullParameter(extras, "extras");
final Application requireApplication = CreationExtrasKtxKt.requireApplication(extras);
SavedStateHandle createSavedStateHandle = SavedStateHandleSupport.createSavedStateHandle(extras);
Application application = requireApplication;
PaymentConfiguration companion = PaymentConfiguration.Companion.getInstance(application);
BrowserCapabilitiesSupplier browserCapabilitiesSupplier = new BrowserCapabilitiesSupplier(application);
AnalyticsRequestExecutor defaultAnalyticsRequestExecutor = new DefaultAnalyticsRequestExecutor();
PaymentAnalyticsRequestFactory paymentAnalyticsRequestFactory = new PaymentAnalyticsRequestFactory(application, companion.getPublishableKey(), null, 4, null);
BrowserCapabilities browserCapabilities = browserCapabilitiesSupplier.get();
String string = requireApplication.getString(com.stripe.android.R.string.stripe_verify_your_payment);
Intrinsics.checkNotNullExpressionValue(string, "application.getString(R.…ripe_verify_your_payment)");
String string2 = requireApplication.getString(com.stripe.android.R.string.stripe_failure_reason_authentication);
Intrinsics.checkNotNullExpressionValue(string2, "application.getString(R.…re_reason_authentication)");
return new StripeBrowserLauncherViewModel(defaultAnalyticsRequestExecutor, paymentAnalyticsRequestFactory, browserCapabilities, string, string2, createSavedStateHandle, new Function1<Intent, Boolean>() {
{
super(1);
}
public final Boolean invoke(Intent intent) {
Intrinsics.checkNotNullParameter(intent, "it");
return Boolean.valueOf(intent.resolveActivity(requireApplication.getPackageManager()) != null);
}
});
}
}
}