导航菜单

页面标题

页面副标题

Crafto v9.3.3 - DefaultErrorReporter.java 源代码

正在查看: Crafto v9.3.3 应用的 DefaultErrorReporter.java JAVA 源代码文件

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


package com.stripe.android.stripe3ds2.observability;

import Hk.p;
import Hk.q;
import Rk.a;
import android.content.Context;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageInfo;
import android.os.Build;
import com.google.firebase.perf.network.FirebasePerfUrlConnection;
import com.stripe.android.camera.scanui.CameraView;
import com.stripe.android.core.networking.AnalyticsFields;
import com.stripe.android.model.Stripe3ds2AuthParams;
import com.stripe.android.stripe3ds2.transaction.Logger;
import dl.I;
import dl.J;
import dl.g;
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.Collections;
import java.util.Map;
import java.util.Scanner;
import javax.net.ssl.HttpsURLConnection;
import kotlin.Metadata;
import kotlin.Pair;
import kotlin.Unit;
import kotlin.collections.CollectionsKt;
import kotlin.collections.F;
import kotlin.collections.Q;
import kotlin.collections.o;
import kotlin.collections.t;
import kotlin.coroutines.CoroutineContext;
import kotlin.jvm.functions.Function1;
import kotlin.jvm.internal.DefaultConstructorMarker;
import kotlin.jvm.internal.Intrinsics;
import org.jetbrains.annotations.NotNull;
import org.json.JSONArray;
import org.json.JSONObject;

@Metadata
public final class DefaultErrorReporter implements ErrorReporter {

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

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

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

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

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

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

    @Deprecated
    @NotNull
    private static final String USER_AGENT = "Android3ds2Sdk 6.1.5";

    @NotNull
    private final Config config;

    @NotNull
    private final Context context;

    @NotNull
    private final String environment;

    @NotNull
    private final String localeCountry;

    @NotNull
    private final Logger logger;
    private final int osVersion;

    @NotNull
    private final SentryConfig sentryConfig;

    @NotNull
    private final CoroutineContext workContext;

    @NotNull
    private static final Companion Companion = new Companion(null);

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

    @Metadata
    public static final class Companion {
        public Companion(DefaultConstructorMarker defaultConstructorMarker) {
            this();
        }

        private Companion() {
        }
    }

    @Metadata
    public interface Config {
        @NotNull
        Map<String, String> getCustomTags();
    }

    @Metadata
    public static final class EmptyConfig implements Config {

        @NotNull
        public static final EmptyConfig INSTANCE = new EmptyConfig();

        @NotNull
        private static final Map<String, String> customTags = Q.d();

        private EmptyConfig() {
        }

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

    public DefaultErrorReporter(@NotNull Context context, @NotNull Config config, @NotNull CoroutineContext coroutineContext, @NotNull Logger logger, @NotNull SentryConfig sentryConfig, @NotNull String str, @NotNull String str2, int i) {
        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 = i;
    }

    private final HttpsURLConnection createPostConnection() {
        HttpsURLConnection openConnection = openConnection();
        openConnection.setRequestMethod(HTTP_METHOD);
        openConnection.setDoOutput(true);
        for (Map.Entry entry : Q.g(new Pair[]{new Pair("Content-Type", CONTENT_TYPE), new Pair("User-Agent", USER_AGENT), new Pair(HEADER_SENTRY_AUTH, createSentryAuthHeader$3ds2sdk_release())}).entrySet()) {
            openConnection.setRequestProperty((String) entry.getKey(), (String) entry.getValue());
        }
        return openConnection;
    }

    private final String getResponseBody(InputStream inputStream) {
        String a;
        try {
            p.a aVar = p.b;
            Scanner useDelimiter = new Scanner(inputStream, CHARSET).useDelimiter("\\A");
            a = useDelimiter.hasNext() ? useDelimiter.next() : null;
            inputStream.close();
        } catch (Throwable th) {
            p.a aVar2 = p.b;
            a = q.a(th);
        }
        return a instanceof p.b ? null : a;
    }

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

    private final HttpsURLConnection openConnection() {
        URLConnection uRLConnection = (URLConnection) FirebasePerfUrlConnection.instrument(new URL("https://errors.stripe.com/api/" + this.sentryConfig.getProjectId() + "/store/").openConnection());
        if (uRLConnection != null) {
            return (HttpsURLConnection) uRLConnection;
        }
        throw new NullPointerException("null cannot be cast to non-null type javax.net.ssl.HttpsURLConnection");
    }

    public final void send(JSONObject jSONObject) {
        HttpsURLConnection createPostConnection = createPostConnection();
        OutputStream outputStream = createPostConnection.getOutputStream();
        try {
            Intrinsics.checkNotNullExpressionValue(outputStream, "os");
            Charset charset = StandardCharsets.UTF_8;
            Intrinsics.checkNotNullExpressionValue(charset, "UTF_8");
            OutputStreamWriter outputStreamWriter = new OutputStreamWriter(outputStream, charset);
            try {
                outputStreamWriter.write(jSONObject.toString());
                outputStreamWriter.flush();
                Unit unit = Unit.a;
                a.b(outputStreamWriter, (Throwable) null);
                a.b(outputStream, (Throwable) null);
                createPostConnection.connect();
                logResponse(createPostConnection, createPostConnection.getResponseCode());
                createPostConnection.disconnect();
            } finally {
            }
        } finally {
        }
    }

    public final JSONObject createRequestBody$3ds2sdk_release(Throwable th) {
        Intrinsics.checkNotNullParameter(th, "t");
        JSONObject put = new JSONObject().put("release", "[email protected]+22");
        JSONObject jSONObject = new JSONObject();
        JSONArray jSONArray = new JSONArray();
        JSONObject put2 = new JSONObject().put("type", th.getClass().getCanonicalName());
        String message = th.getMessage();
        if (message == null) {
            message = CameraView.FILL_ASPECT_RATIO;
        }
        JSONObject put3 = put.put("exception", jSONObject.put("values", jSONArray.put(put2.put("value", message).put("stacktrace", createRequestStacktrace$3ds2sdk_release(th)))));
        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.a;
        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() {
        PackageInfo a;
        ApplicationInfo applicationInfo;
        int i = 0;
        try {
            p.a aVar = p.b;
            a = this.context.getPackageManager().getPackageInfo(this.context.getPackageName(), 0);
        } catch (Throwable th) {
            p.a aVar2 = p.b;
            a = q.a(th);
        }
        if (a instanceof p.b) {
            a = null;
        }
        PackageInfo packageInfo = a;
        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(AnalyticsFields.APP_NAME, loadLabel);
        String str = packageInfo != null ? packageInfo.versionName : null;
        if (str == null) {
            str = CameraView.FILL_ASPECT_RATIO;
        }
        JSONObject put2 = jSONObject.put(Stripe3ds2AuthParams.FIELD_APP, put.put(AnalyticsFields.APP_VERSION, str));
        JSONObject put3 = new JSONObject().put("name", "Android").put("version", Build.VERSION.RELEASE);
        String str2 = Build.TYPE;
        JSONObject put4 = put2.put("os", put3.put("type", str2).put("build", Build.DISPLAY));
        JSONObject put5 = new JSONObject().put("model_id", Build.ID).put("model", Build.MODEL).put("manufacturer", Build.MANUFACTURER).put("type", str2);
        JSONArray jSONArray = new JSONArray();
        String[] strArr = Build.SUPPORTED_ABIS;
        Intrinsics.checkNotNullExpressionValue(strArr, "SUPPORTED_ABIS");
        int length = strArr.length;
        while (i < length) {
            String str3 = strArr[i];
            i++;
            jSONArray.put(str3);
        }
        Unit unit = Unit.a;
        JSONObject put6 = put4.put("device", put5.put("archs", jSONArray));
        Intrinsics.checkNotNullExpressionValue(put6, "JSONObject()\n           …          )\n            )");
        return put6;
    }

    public final JSONObject createRequestStacktrace$3ds2sdk_release(Throwable th) {
        F I;
        Intrinsics.checkNotNullParameter(th, "t");
        JSONObject jSONObject = new JSONObject();
        JSONArray jSONArray = new JSONArray();
        StackTraceElement[] stackTrace = th.getStackTrace();
        Intrinsics.checkNotNullExpressionValue(stackTrace, "t.stackTrace");
        Intrinsics.checkNotNullParameter(stackTrace, "<this>");
        if (stackTrace.length == 0) {
            I = F.a;
        } else {
            I = o.I(stackTrace);
            Intrinsics.checkNotNullParameter(I, "<this>");
            Collections.reverse(I);
        }
        for (StackTraceElement stackTraceElement : (Iterable) I) {
            jSONArray.put(new JSONObject().put("lineno", stackTraceElement.getLineNumber()).put("filename", stackTraceElement.getClassName()).put("function", stackTraceElement.getMethodName()));
        }
        Unit unit = Unit.a;
        JSONObject put = jSONObject.put("frames", jSONArray);
        Intrinsics.checkNotNullExpressionValue(put, "JSONObject()\n           …          }\n            )");
        return put;
    }

    public final String createSentryAuthHeader$3ds2sdk_release() {
        return CollectionsKt.J(t.i(new String[]{"Sentry", CollectionsKt.J(t.i(new Pair[]{new Pair("sentry_key", this.sentryConfig.getKey()), new Pair("sentry_version", this.sentryConfig.getVersion()), new Pair("sentry_timestamp", this.sentryConfig.getTimestamp()), new Pair("sentry_client", USER_AGENT), new Pair("sentry_secret", this.sentryConfig.getSecret())}), ", ", (String) null, (String) null, new Function1<Pair<? extends String, ? extends String>, CharSequence>() {
            @NotNull
            public final CharSequence invoke(@NotNull Pair<String, String> pair) {
                Intrinsics.checkNotNullParameter(pair, "$dstr$key$value");
                return ((String) pair.a) + '=' + ((String) pair.b);
            }
        }, 30)}), " ", (String) null, (String) null, (Function1) null, 62);
    }

    @Override
    public void reportError(@NotNull Throwable th) {
        Intrinsics.checkNotNullParameter(th, "t");
        g.b(I.a(this.workContext), (CoroutineContext) null, (J) null, new DefaultErrorReporter$reportError$1(this, th, null), 3);
    }

    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");
    }

    private final void logResponse(HttpsURLConnection httpsURLConnection, int i) {
    }
}