导航菜单

页面标题

页面副标题

Rilo v2.0.21 - DefaultErrorReporter.java 源代码

正在查看: Rilo v2.0.21 应用的 DefaultErrorReporter.java JAVA 源代码文件

本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。


package com.stripe.android.stripe3ds2.observability;

import android.content.Context;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageInfo;
import android.os.Build;
import com.stripe.android.model.Stripe3ds2AuthParams;
import com.stripe.android.stripe3ds2.transaction.Logger;
import com.tiktok.appevents.contents.TTContentsEventConstants;
import io.livekit.android.room.SignalClient;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.net.URL;
import java.net.URLConnection;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.util.Map;
import java.util.Scanner;
import javax.net.ssl.HttpsURLConnection;
import kotlin.Metadata;
import kotlin.Pair;
import kotlin.Result;
import kotlin.ResultKt;
import kotlin.TuplesKt;
import kotlin.Unit;
import kotlin.collections.ArraysKt;
import kotlin.collections.CollectionsKt;
import kotlin.collections.MapsKt;
import kotlin.coroutines.CoroutineContext;
import kotlin.io.CloseableKt;
import kotlin.jvm.functions.Function1;
import kotlin.jvm.internal.DefaultConstructorMarker;
import kotlin.jvm.internal.Intrinsics;
import kotlinx.coroutines.BuildersKt;
import kotlinx.coroutines.CoroutineScopeKt;
import kotlinx.coroutines.CoroutineStart;
import org.json.JSONArray;
import org.json.JSONObject;

@Metadata(d1 = {"\u0000Z\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\u0000\n\u0002\u0010\u000e\n\u0002\b\u0002\n\u0002\u0010\b\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\u0003\n\u0002\b\t\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\u0002\n\u0002\b\f\b\u0000\u0018\u0000 ,2\u00020\u0001:\u0003,-.BS\u0012\u0006\u0010\u0002\u001a\u00020\u0003\u0012\b\b\u0002\u0010\u0004\u001a\u00020\u0005\u0012\b\b\u0002\u0010\u0006\u001a\u00020\u0007\u0012\b\b\u0002\u0010\b\u001a\u00020\t\u0012\b\b\u0002\u0010\n\u001a\u00020\u000b\u0012\b\b\u0002\u0010\f\u001a\u00020\r\u0012\b\b\u0002\u0010\u000e\u001a\u00020\r\u0012\b\b\u0002\u0010\u000f\u001a\u00020\u0010¢\u0006\u0002\u0010\u0011J\b\u0010\u0012\u001a\u00020\u0013H\u0002J\u0015\u0010\u0014\u001a\u00020\u00152\u0006\u0010\u0016\u001a\u00020\u0017H\u0001¢\u0006\u0002\b\u0018J\r\u0010\u0019\u001a\u00020\u0015H\u0001¢\u0006\u0002\b\u001aJ\u0015\u0010\u001b\u001a\u00020\u00152\u0006\u0010\u0016\u001a\u00020\u0017H\u0001¢\u0006\u0002\b\u001cJ\r\u0010\u001d\u001a\u00020\rH\u0001¢\u0006\u0002\b\u001eJ\u0010\u0010\u001f\u001a\u00020\r2\u0006\u0010 \u001a\u00020!H\u0002J\u0018\u0010\"\u001a\u00020#2\u0006\u0010$\u001a\u00020\u00132\u0006\u0010%\u001a\u00020\u0010H\u0002J\u0010\u0010&\u001a\u00020#2\u0006\u0010'\u001a\u00020\u0017H\u0002J\b\u0010(\u001a\u00020\u0013H\u0002J\u0010\u0010)\u001a\u00020#2\u0006\u0010\u0016\u001a\u00020\u0017H\u0016J\u0010\u0010*\u001a\u00020#2\u0006\u0010+\u001a\u00020\u0015H\u0002R\u000e\u0010\u0004\u001a\u00020\u0005X\u0082\u0004¢\u0006\u0002\n\u0000R\u000e\u0010\u0002\u001a\u00020\u0003X\u0082\u0004¢\u0006\u0002\n\u0000R\u000e\u0010\f\u001a\u00020\rX\u0082\u0004¢\u0006\u0002\n\u0000R\u000e\u0010\u000e\u001a\u00020\rX\u0082\u0004¢\u0006\u0002\n\u0000R\u000e\u0010\b\u001a\u00020\tX\u0082\u0004¢\u0006\u0002\n\u0000R\u000e\u0010\u000f\u001a\u00020\u0010X\u0082\u0004¢\u0006\u0002\n\u0000R\u000e\u0010\n\u001a\u00020\u000bX\u0082\u0004¢\u0006\u0002\n\u0000R\u000e\u0010\u0006\u001a\u00020\u0007X\u0082\u0004¢\u0006\u0002\n\u0000¨\u0006/"}, d2 = {"Lcom/stripe/android/stripe3ds2/observability/DefaultErrorReporter;", "Lcom/stripe/android/stripe3ds2/observability/ErrorReporter;", "context", "Landroid/content/Context;", "config", "Lcom/stripe/android/stripe3ds2/observability/DefaultErrorReporter$Config;", "workContext", "Lkotlin/coroutines/CoroutineContext;", "logger", "Lcom/stripe/android/stripe3ds2/transaction/Logger;", "sentryConfig", "Lcom/stripe/android/stripe3ds2/observability/SentryConfig;", "environment", "", "localeCountry", "osVersion", "", "(Landroid/content/Context;Lcom/stripe/android/stripe3ds2/observability/DefaultErrorReporter$Config;Lkotlin/coroutines/CoroutineContext;Lcom/stripe/android/stripe3ds2/transaction/Logger;Lcom/stripe/android/stripe3ds2/observability/SentryConfig;Ljava/lang/String;Ljava/lang/String;I)V", "createPostConnection", "Ljavax/net/ssl/HttpsURLConnection;", "createRequestBody", "Lorg/json/JSONObject;", "t", "", "createRequestBody$3ds2sdk_release", "createRequestContexts", "createRequestContexts$3ds2sdk_release", "createRequestStacktrace", "createRequestStacktrace$3ds2sdk_release", "createSentryAuthHeader", "createSentryAuthHeader$3ds2sdk_release", "getResponseBody", "responseStream", "Ljava/io/InputStream;", "logResponse", "", "connection", "responseCode", "onFailure", "exception", "openConnection", "reportError", "send", "requestBody", "Companion", "Config", "EmptyConfig", "3ds2sdk_release"}, k = 1, mv = {1, 7, 1}, xi = 48)
public final class DefaultErrorReporter implements ErrorReporter {

    @Deprecated
    private static final String CONTENT_TYPE = "application/json; charset=utf-8";

    @Deprecated
    private static final String HEADER_CONTENT_TYPE = "Content-Type";

    @Deprecated
    private static final String HEADER_SENTRY_AUTH = "X-Sentry-Auth";

    @Deprecated
    private static final String HEADER_USER_AGENT = "User-Agent";

    @Deprecated
    private static final String HOST = "https://errors.stripe.com";

    @Deprecated
    private static final String HTTP_METHOD = "POST";

    @Deprecated
    private static final String USER_AGENT = "Android3ds2Sdk 6.1.7";
    private final Config config;
    private final Context context;
    private final String environment;
    private final String localeCountry;
    private final Logger logger;
    private final int osVersion;
    private final SentryConfig sentryConfig;
    private final CoroutineContext workContext;
    private static final Companion Companion = new Companion(null);

    @Deprecated
    private static final String CHARSET = StandardCharsets.UTF_8.name();

    @Metadata(d1 = {"\u0000\u0016\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0000\n\u0002\u0010$\n\u0002\u0010\u000e\n\u0002\b\u0003\bf\u0018\u00002\u00020\u0001R\u001e\u0010\u0002\u001a\u000e\u0012\u0004\u0012\u00020\u0004\u0012\u0004\u0012\u00020\u00040\u0003X¦\u0004¢\u0006\u0006\u001a\u0004\b\u0005\u0010\u0006ø\u0001\u0000\u0082\u0002\u0006\n\u0004\b!0\u0001¨\u0006\u0007À\u0006\u0001"}, d2 = {"Lcom/stripe/android/stripe3ds2/observability/DefaultErrorReporter$Config;", "", "customTags", "", "", "getCustomTags", "()Ljava/util/Map;", "3ds2sdk_release"}, k = 1, mv = {1, 7, 1}, xi = 48)
    public interface Config {
        Map<String, String> getCustomTags();
    }

    private final void logResponse(HttpsURLConnection connection, int responseCode) {
    }

    public DefaultErrorReporter(Context context, Config config, CoroutineContext coroutineContext, Logger logger, SentryConfig sentryConfig, String str, String str2, int i2) {
        Intrinsics.checkNotNullParameter(context, "context");
        Intrinsics.checkNotNullParameter(config, "config");
        Intrinsics.checkNotNullParameter(coroutineContext, "workContext");
        Intrinsics.checkNotNullParameter(logger, "logger");
        Intrinsics.checkNotNullParameter(sentryConfig, "sentryConfig");
        Intrinsics.checkNotNullParameter(str, "environment");
        Intrinsics.checkNotNullParameter(str2, "localeCountry");
        this.context = context;
        this.config = config;
        this.workContext = coroutineContext;
        this.logger = logger;
        this.sentryConfig = sentryConfig;
        this.environment = str;
        this.localeCountry = str2;
        this.osVersion = i2;
    }

    public DefaultErrorReporter(android.content.Context r9, com.stripe.android.stripe3ds2.observability.DefaultErrorReporter.Config r10, kotlin.coroutines.CoroutineContext r11, com.stripe.android.stripe3ds2.transaction.Logger r12, com.stripe.android.stripe3ds2.observability.SentryConfig r13, java.lang.String r14, java.lang.String r15, int r16, int r17, kotlin.jvm.internal.DefaultConstructorMarker r18) {
        throw new UnsupportedOperationException("Method not decompiled: com.stripe.android.stripe3ds2.observability.DefaultErrorReporter.<init>(android.content.Context, com.stripe.android.stripe3ds2.observability.DefaultErrorReporter$Config, kotlin.coroutines.CoroutineContext, com.stripe.android.stripe3ds2.transaction.Logger, com.stripe.android.stripe3ds2.observability.SentryConfig, java.lang.String, java.lang.String, int, int, kotlin.jvm.internal.DefaultConstructorMarker):void");
    }

    @Override
    public void reportError(Throwable t) {
        Intrinsics.checkNotNullParameter(t, "t");
        BuildersKt.launch$default(CoroutineScopeKt.CoroutineScope(this.workContext), (CoroutineContext) null, (CoroutineStart) null, new DefaultErrorReporter$reportError$1(this, t, null), 3, (Object) null);
    }

    public final void send(JSONObject requestBody) {
        HttpsURLConnection createPostConnection = createPostConnection();
        OutputStreamWriter outputStream = createPostConnection.getOutputStream();
        try {
            OutputStream outputStream2 = outputStream;
            Intrinsics.checkNotNullExpressionValue(outputStream2, SignalClient.CONNECT_QUERY_OS);
            Charset charset = StandardCharsets.UTF_8;
            Intrinsics.checkNotNullExpressionValue(charset, "UTF_8");
            outputStream = new OutputStreamWriter(outputStream2, charset);
            try {
                OutputStreamWriter outputStreamWriter = outputStream;
                outputStreamWriter.write(requestBody.toString());
                outputStreamWriter.flush();
                Unit unit = Unit.INSTANCE;
                CloseableKt.closeFinally(outputStream, (Throwable) null);
                Unit unit2 = Unit.INSTANCE;
                CloseableKt.closeFinally(outputStream, (Throwable) null);
                createPostConnection.connect();
                logResponse(createPostConnection, createPostConnection.getResponseCode());
                createPostConnection.disconnect();
            } finally {
            }
        } finally {
        }
    }

    private final String getResponseBody(InputStream responseStream) {
        Object m1547constructorimpl;
        String str;
        try {
            Result.Companion companion = Result.INSTANCE;
            DefaultErrorReporter defaultErrorReporter = this;
            Scanner useDelimiter = new Scanner(responseStream, CHARSET).useDelimiter("\\A");
            if (useDelimiter.hasNext()) {
                str = useDelimiter.next();
            } else {
                str = null;
            }
            m1547constructorimpl = Result.m1547constructorimpl(str);
        } catch (Throwable th) {
            Result.Companion companion2 = Result.INSTANCE;
            m1547constructorimpl = Result.m1547constructorimpl(ResultKt.createFailure(th));
        }
        String str2 = (String) (Result.m1553isFailureimpl(m1547constructorimpl) ? null : m1547constructorimpl);
        return str2 == null ? "" : str2;
    }

    private final HttpsURLConnection createPostConnection() {
        HttpsURLConnection openConnection = openConnection();
        openConnection.setRequestMethod(HTTP_METHOD);
        openConnection.setDoOutput(true);
        for (Map.Entry entry : MapsKt.mapOf(new Pair[]{TuplesKt.to(HEADER_CONTENT_TYPE, CONTENT_TYPE), TuplesKt.to(HEADER_USER_AGENT, USER_AGENT), TuplesKt.to(HEADER_SENTRY_AUTH, createSentryAuthHeader$3ds2sdk_release())}).entrySet()) {
            openConnection.setRequestProperty((String) entry.getKey(), (String) entry.getValue());
        }
        return openConnection;
    }

    private final HttpsURLConnection openConnection() {
        URLConnection openConnection = new URL("https://errors.stripe.com/api/" + this.sentryConfig.getProjectId() + "/store/").openConnection();
        Intrinsics.checkNotNull(openConnection, "null cannot be cast to non-null type javax.net.ssl.HttpsURLConnection");
        return (HttpsURLConnection) openConnection;
    }

    public final JSONObject createRequestBody$3ds2sdk_release(Throwable t) {
        Intrinsics.checkNotNullParameter(t, "t");
        JSONObject put = new JSONObject().put("release", "[email protected]+24");
        JSONObject jSONObject = new JSONObject();
        JSONArray jSONArray = new JSONArray();
        JSONObject put2 = new JSONObject().put("type", t.getClass().getCanonicalName());
        String message = t.getMessage();
        if (message == null) {
            message = "";
        }
        JSONObject put3 = put.put("exception", jSONObject.put("values", jSONArray.put(put2.put(TTContentsEventConstants.Params.EVENT_PROPERTY_VALUE, message).put("stacktrace", createRequestStacktrace$3ds2sdk_release(t)))));
        JSONObject put4 = new JSONObject().put("locale", this.localeCountry).put("environment", this.environment).put("android_os_version", this.osVersion);
        for (Map.Entry<String, String> entry : this.config.getCustomTags().entrySet()) {
            put4.put(entry.getKey(), entry.getValue());
        }
        Unit unit = Unit.INSTANCE;
        JSONObject put5 = put3.put("tags", put4).put("contexts", createRequestContexts$3ds2sdk_release());
        Intrinsics.checkNotNullExpressionValue(put5, "JSONObject()\n           … createRequestContexts())");
        return put5;
    }

    public final JSONObject createRequestContexts$3ds2sdk_release() {
        Object m1547constructorimpl;
        ApplicationInfo applicationInfo;
        try {
            Result.Companion companion = Result.INSTANCE;
            DefaultErrorReporter defaultErrorReporter = this;
            m1547constructorimpl = Result.m1547constructorimpl(this.context.getPackageManager().getPackageInfo(this.context.getPackageName(), 0));
        } catch (Throwable th) {
            Result.Companion companion2 = Result.INSTANCE;
            m1547constructorimpl = Result.m1547constructorimpl(ResultKt.createFailure(th));
        }
        if (Result.m1553isFailureimpl(m1547constructorimpl)) {
            m1547constructorimpl = null;
        }
        PackageInfo packageInfo = (PackageInfo) m1547constructorimpl;
        CharSequence loadLabel = (packageInfo == null || (applicationInfo = packageInfo.applicationInfo) == null) ? null : applicationInfo.loadLabel(this.context.getPackageManager());
        JSONObject jSONObject = new JSONObject();
        JSONObject put = new JSONObject().put("app_identifier", this.context.getPackageName()).put("app_name", loadLabel);
        String str = packageInfo != null ? packageInfo.versionName : null;
        if (str == null) {
            str = "";
        }
        JSONObject put2 = jSONObject.put(Stripe3ds2AuthParams.FIELD_APP, put.put("app_version", str)).put(SignalClient.CONNECT_QUERY_OS, new JSONObject().put("name", "Android").put(SignalClient.CONNECT_QUERY_VERSION, Build.VERSION.RELEASE).put("type", Build.TYPE).put("build", Build.DISPLAY));
        JSONObject put3 = new JSONObject().put("model_id", Build.ID).put("model", Build.MODEL).put("manufacturer", Build.MANUFACTURER).put("type", Build.TYPE);
        JSONArray jSONArray = new JSONArray();
        String[] strArr = Build.SUPPORTED_ABIS;
        Intrinsics.checkNotNullExpressionValue(strArr, "SUPPORTED_ABIS");
        for (String str2 : strArr) {
            jSONArray.put(str2);
        }
        Unit unit = Unit.INSTANCE;
        JSONObject put4 = put2.put("device", put3.put("archs", jSONArray));
        Intrinsics.checkNotNullExpressionValue(put4, "JSONObject()\n           …          )\n            )");
        return put4;
    }

    public final JSONObject createRequestStacktrace$3ds2sdk_release(Throwable t) {
        Intrinsics.checkNotNullParameter(t, "t");
        JSONObject jSONObject = new JSONObject();
        JSONArray jSONArray = new JSONArray();
        StackTraceElement[] stackTrace = t.getStackTrace();
        Intrinsics.checkNotNullExpressionValue(stackTrace, "t.stackTrace");
        for (StackTraceElement stackTraceElement : ArraysKt.reversed(stackTrace)) {
            jSONArray.put(new JSONObject().put("lineno", stackTraceElement.getLineNumber()).put("filename", stackTraceElement.getClassName()).put("function", stackTraceElement.getMethodName()));
        }
        Unit unit = Unit.INSTANCE;
        JSONObject put = jSONObject.put("frames", jSONArray);
        Intrinsics.checkNotNullExpressionValue(put, "JSONObject()\n           …          }\n            )");
        return put;
    }

    public final String createSentryAuthHeader$3ds2sdk_release() {
        return CollectionsKt.joinToString$default(CollectionsKt.listOf(new String[]{"Sentry", CollectionsKt.joinToString$default(CollectionsKt.listOf(new Pair[]{TuplesKt.to("sentry_key", this.sentryConfig.getKey()), TuplesKt.to("sentry_version", this.sentryConfig.getVersion()), TuplesKt.to("sentry_timestamp", this.sentryConfig.getTimestamp()), TuplesKt.to("sentry_client", USER_AGENT), TuplesKt.to("sentry_secret", this.sentryConfig.getSecret())}), ", ", (CharSequence) null, (CharSequence) null, 0, (CharSequence) null, new Function1<Pair<? extends String, ? extends String>, CharSequence>() {
            public final CharSequence invoke(Pair<String, String> pair) {
                Intrinsics.checkNotNullParameter(pair, "<name for destructuring parameter 0>");
                return pair.component1() + '=' + pair.component2();
            }
        }, 30, (Object) null)}), " ", (CharSequence) null, (CharSequence) null, 0, (CharSequence) null, (Function1) null, 62, (Object) null);
    }

    public final void onFailure(Throwable exception) {
        this.logger.error("Failed to send error report.", exception);
    }

    @Metadata(d1 = {"\u0000\u0018\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0010$\n\u0002\u0010\u000e\n\u0002\b\u0003\bÀ\u0002\u0018\u00002\u00020\u0001B\u0007\b\u0002¢\u0006\u0002\u0010\u0002R \u0010\u0003\u001a\u000e\u0012\u0004\u0012\u00020\u0005\u0012\u0004\u0012\u00020\u00050\u0004X\u0096\u0004¢\u0006\b\n\u0000\u001a\u0004\b\u0006\u0010\u0007¨\u0006\b"}, d2 = {"Lcom/stripe/android/stripe3ds2/observability/DefaultErrorReporter$EmptyConfig;", "Lcom/stripe/android/stripe3ds2/observability/DefaultErrorReporter$Config;", "()V", "customTags", "", "", "getCustomTags", "()Ljava/util/Map;", "3ds2sdk_release"}, k = 1, mv = {1, 7, 1}, xi = 48)
    public static final class EmptyConfig implements Config {
        public static final EmptyConfig INSTANCE = new EmptyConfig();
        private static final Map<String, String> customTags = MapsKt.emptyMap();

        private EmptyConfig() {
        }

        @Override
        public Map<String, String> getCustomTags() {
            return customTags;
        }
    }

    @Metadata(d1 = {"\u0000\u0014\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0002\b\u0002\n\u0002\u0010\u000e\n\u0002\b\t\b\u0082\u0003\u0018\u00002\u00020\u0001B\u0007\b\u0002¢\u0006\u0002\u0010\u0002R\u0016\u0010\u0003\u001a\n \u0005*\u0004\u0018\u00010\u00040\u0004X\u0082\u0004¢\u0006\u0002\n\u0000R\u000e\u0010\u0006\u001a\u00020\u0004X\u0082T¢\u0006\u0002\n\u0000R\u000e\u0010\u0007\u001a\u00020\u0004X\u0082T¢\u0006\u0002\n\u0000R\u000e\u0010\b\u001a\u00020\u0004X\u0082T¢\u0006\u0002\n\u0000R\u000e\u0010\t\u001a\u00020\u0004X\u0082T¢\u0006\u0002\n\u0000R\u000e\u0010\n\u001a\u00020\u0004X\u0082T¢\u0006\u0002\n\u0000R\u000e\u0010\u000b\u001a\u00020\u0004X\u0082T¢\u0006\u0002\n\u0000R\u000e\u0010\f\u001a\u00020\u0004X\u0082T¢\u0006\u0002\n\u0000¨\u0006\r"}, d2 = {"Lcom/stripe/android/stripe3ds2/observability/DefaultErrorReporter$Companion;", "", "()V", "CHARSET", "", "kotlin.jvm.PlatformType", "CONTENT_TYPE", "HEADER_CONTENT_TYPE", "HEADER_SENTRY_AUTH", "HEADER_USER_AGENT", "HOST", "HTTP_METHOD", "USER_AGENT", "3ds2sdk_release"}, k = 1, mv = {1, 7, 1}, xi = 48)
    private static final class Companion {
        public Companion(DefaultConstructorMarker defaultConstructorMarker) {
            this();
        }

        private Companion() {
        }
    }
}