Warkop v5.73.0版本的 MD5 值为:a4330ec2d6f5e146f59fc7622f3cdb45

以下内容为反编译后的 VSAppCenterTelemetryUpload.java 源代码,内容仅作参考


package com.exponea.sdk.telemetry.upload;

import android.app.Application;
import android.os.Build;
import android.util.Base64;
import co.g0;
import co.r;
import co.s;
import com.exponea.sdk.models.Constants;
import com.exponea.sdk.telemetry.TelemetryUtility;
import com.exponea.sdk.telemetry.model.CrashLog;
import com.exponea.sdk.telemetry.model.ErrorData;
import com.exponea.sdk.telemetry.model.ErrorStackTraceElement;
import com.exponea.sdk.telemetry.model.EventLog;
import com.exponea.sdk.util.ExtensionsKt;
import com.exponea.sdk.util.Logger;
import com.google.firebase.perf.network.FirebasePerfOkHttpClient;
import com.google.gson.Gson;
import j$.util.DesugarTimeZone;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Locale;
import java.util.UUID;
import kotlin.Metadata;
import kotlin.jvm.internal.k;
import kotlin.text.b;
import ns.b0;
import ns.c0;
import ns.d0;
import ns.e;
import ns.f;
import ns.x;
import ns.z;
import org.jetbrains.annotations.NotNull;
import p029do.u;
import p029do.v;
import p031.p032.p033.InterfaceC4850;
import qo.l;

@Metadata(d1 = {"\u0000v\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\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\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0010\u000e\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\u0007\n\u0002\u0010\u000b\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\u0005\b\u0000\u0018\u0000 02\u00020\u0001:\u00010B1\u0012\u0006\u0010-\u001a\u00020,\u0012\u0006\u0010\u001d\u001a\u00020\u0017\u0012\u0006\u0010\u001f\u001a\u00020\u0017\u0012\u0006\u0010 \u001a\u00020\u0017\u0012\b\b\u0002\u0010!\u001a\u00020\u0017¢\u0006\u0004\b.\u0010/J\u0010\u0010\u0005\u001a\u00020\u00042\u0006\u0010\u0003\u001a\u00020\u0002H\u0002J\u0010\u0010\b\u001a\u00020\u00072\u0006\u0010\u0003\u001a\u00020\u0006H\u0002J\u0010\u0010\n\u001a\u00020\t2\u0006\u0010\u0003\u001a\u00020\u0006H\u0002J\b\u0010\f\u001a\u00020\u000bH\u0002J\u0010\u0010\u0010\u001a\u00020\u000f2\u0006\u0010\u000e\u001a\u00020\rH\u0002J-\u0010\u0015\u001a\u00020\u00132\u0006\u0010\u0003\u001a\u00020\u00022\u0018\u0010\u0014\u001a\u0014\u0012\n\u0012\b\u0012\u0004\u0012\u00020\u00130\u0012\u0012\u0004\u0012\u00020\u00130\u0011H\u0016ø\u0001\u0000J-\u0010\u0016\u001a\u00020\u00132\u0006\u0010\u0003\u001a\u00020\u00062\u0018\u0010\u0014\u001a\u0014\u0012\n\u0012\b\u0012\u0004\u0012\u00020\u00130\u0012\u0012\u0004\u0012\u00020\u00130\u0011H\u0016ø\u0001\u0000J-\u0010\u0019\u001a\u00020\u00132\u0006\u0010\u0018\u001a\u00020\u00172\u0018\u0010\u0014\u001a\u0014\u0012\n\u0012\b\u0012\u0004\u0012\u00020\u00130\u0012\u0012\u0004\u0012\u00020\u00130\u0011H\u0016ø\u0001\u0000J+\u0010\u001c\u001a\u00020\u00132\u0006\u0010\u001b\u001a\u00020\u001a2\u0018\u0010\u0014\u001a\u0014\u0012\n\u0012\b\u0012\u0004\u0012\u00020\u00130\u0012\u0012\u0004\u0012\u00020\u00130\u0011ø\u0001\u0000R\u0014\u0010\u001d\u001a\u00020\u00178\u0002X\u0082\u0004¢\u0006\u0006\n\u0004\b\u001d\u0010\u001eR\u0014\u0010\u001f\u001a\u00020\u00178\u0002X\u0082\u0004¢\u0006\u0006\n\u0004\b\u001f\u0010\u001eR\u0014\u0010 \u001a\u00020\u00178\u0002X\u0082\u0004¢\u0006\u0006\n\u0004\b \u0010\u001eR\u0014\u0010!\u001a\u00020\u00178\u0002X\u0082\u0004¢\u0006\u0006\n\u0004\b!\u0010\u001eR\u0014\u0010#\u001a\u00020\"8\u0002X\u0082\u0004¢\u0006\u0006\n\u0004\b#\u0010$R\u0014\u0010%\u001a\u00020\u00178\u0002X\u0082\u0004¢\u0006\u0006\n\u0004\b%\u0010\u001eR\u0014\u0010'\u001a\u00020&8\u0002X\u0082\u0004¢\u0006\u0006\n\u0004\b'\u0010(R\u0014\u0010*\u001a\u00020)8\u0002X\u0082\u0004¢\u0006\u0006\n\u0004\b*\u0010+\u0082\u0002\u0004\n\u0002\b\u0019¨\u00061"}, d2 = {"Lcom/exponea/sdk/telemetry/upload/VSAppCenterTelemetryUpload;", "Lcom/exponea/sdk/telemetry/upload/TelemetryUpload;", "Lcom/exponea/sdk/telemetry/model/EventLog;", "log", "Lcom/exponea/sdk/telemetry/upload/VSAppCenterAPIEventLog;", "getAPIEventLog", "Lcom/exponea/sdk/telemetry/model/CrashLog;", "Lcom/exponea/sdk/telemetry/upload/VSAppCenterAPIErrorLog;", "getAPIErrorLog", "Lcom/exponea/sdk/telemetry/upload/VSAppCenterAPIErrorAttachmentLog;", "getAPIErrorAttachment", "Lcom/exponea/sdk/telemetry/upload/VSAppCenterAPIDevice;", "getAPIDevice", "Lcom/exponea/sdk/telemetry/model/ErrorData;", "errorData", "Lcom/exponea/sdk/telemetry/upload/VSAppCenterAPIException;", "getAPIException", "Lkotlin/Function1;", "Lco/r;", "Lco/g0;", "callback", "uploadEventLog", "uploadCrashLog", "", "runId", "uploadSessionStart", "Lcom/exponea/sdk/telemetry/upload/VSAppCenterAPIRequestData;", "data", "upload", "installId", "Ljava/lang/String;", "sdkVersion", "userId", "uploadUrl", "", "isRunningTest", "Z", "APP_SECRET", "Lcom/exponea/sdk/telemetry/TelemetryUtility$AppInfo;", "appInfo", "Lcom/exponea/sdk/telemetry/TelemetryUtility$AppInfo;", "Lns/z;", "networkClient", "Lns/z;", "Landroid/app/Application;", "application", "<init>", "(Landroid/app/Application;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V", "Companion", "sdk_release"}, k = 1, mv = {1, 7, 1})
public final class VSAppCenterTelemetryUpload implements TelemetryUpload {

    @NotNull
    private static final String DEFAULT_UPLOAD_URL = "https://in.appcenter.ms/logs?Api-Version=1.0.0";
    private static final int MAX_EVENT_PROPERTIES = 20;

    @NotNull
    private static final SimpleDateFormat isoDateFormat;

    @NotNull
    private final String APP_SECRET;

    @NotNull
    private final TelemetryUtility.AppInfo appInfo;

    @NotNull
    private final String installId;
    private final boolean isRunningTest;

    @NotNull
    private final z networkClient;

    @NotNull
    private final String sdkVersion;

    @NotNull
    private final String uploadUrl;

    @NotNull
    private final String userId;

    @NotNull
    private static final x jsonMediaType = x.INSTANCE.b("application/json");

    static {
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");
        isoDateFormat = simpleDateFormat;
        simpleDateFormat.setTimeZone(DesugarTimeZone.getTimeZone("UTC"));
    }

    public VSAppCenterTelemetryUpload(@NotNull Application application, @NotNull String str, @NotNull String str2, @NotNull String str3, @NotNull String str4) {
        boolean z15;
        String str5;
        this.installId = str;
        this.sdkVersion = str2;
        this.userId = str3;
        this.uploadUrl = str4;
        try {
            Class.forName("com.exponea.ExponeaTestClass");
            z15 = true;
        } catch (ClassNotFoundException unused) {
            z15 = false;
        }
        this.isRunningTest = z15;
        if (ExtensionsKt.isCalledFromExampleApp(application) || z15) {
            str5 = "19dca50b-3467-488b-b1fa-47fb9258901a";
        } else if (ExtensionsKt.isReactNativeSDK(application)) {
            str5 = "0be0c184-73d2-49d2-aa90-31c3895c2c54";
        } else if (ExtensionsKt.isCapacitorSDK(application)) {
            str5 = "c942008a-ab47-42e3-82b0-5cbafb068344";
        } else if (ExtensionsKt.isFlutterSDK(application)) {
            str5 = "05eaf27b-3955-4151-a524-f423615efeb2";
        } else if (ExtensionsKt.isXamarinSDK(application)) {
            str5 = "0b7cbf35-00cd-4a36-b2a1-c4c51450ec31";
        } else {
            str5 = ExtensionsKt.isMauiSDK(application) ? "430d3892-0dba-4185-9da3-3ea153ea97e9" : "67e2bde9-3c20-4259-b8e4-428b4f89ca8d";
        }
        this.APP_SECRET = str5;
        this.appInfo = TelemetryUtility.INSTANCE.getAppInfo$sdk_release(application);
        this.networkClient = new z();
    }

    private final VSAppCenterAPIDevice getAPIDevice() {
        return new VSAppCenterAPIDevice(this.appInfo.getPackageName(), this.appInfo.getPackageName() + '-' + this.appInfo.getVersionName(), this.appInfo.getVersionCode(), "ExponeaSDK.android", this.sdkVersion, Constants.DeviceInfo.osName, Build.VERSION.RELEASE, Build.MODEL, Locale.getDefault().toString());
    }

    private final VSAppCenterAPIErrorAttachmentLog getAPIErrorAttachment(CrashLog log) {
        String str;
        List<String> logs = log.getLogs();
        if (logs == null || str == null) {
            str = "";
        }
        return new VSAppCenterAPIErrorAttachmentLog(UUID.randomUUID().toString(), log.getRunId(), this.userId, getAPIDevice(), isoDateFormat.format(new Date(log.getTimestampMS())), log.getId(), InterfaceC4850.TEXT, Base64.encodeToString(str.getBytes(b.UTF_8), 2));
    }

    private final VSAppCenterAPIErrorLog getAPIErrorLog(CrashLog log) {
        String id5 = log.getId();
        String runId = log.getRunId();
        boolean fatal = log.getFatal();
        String str = this.userId;
        VSAppCenterAPIDevice aPIDevice = getAPIDevice();
        VSAppCenterAPIException aPIException = getAPIException(log.getErrorData());
        SimpleDateFormat simpleDateFormat = isoDateFormat;
        return new VSAppCenterAPIErrorLog(id5, runId, str, aPIDevice, simpleDateFormat.format(new Date(log.getTimestampMS())), fatal, aPIException, simpleDateFormat.format(new Date(log.getLaunchTimestampMS())), 0, null, 768, null);
    }

    private final VSAppCenterAPIEventLog getAPIEventLog(EventLog log) {
        return new VSAppCenterAPIEventLog(log.getId(), log.getRunId(), this.userId, getAPIDevice(), isoDateFormat.format(new Date(log.getTimestampMS())), log.getName(), log.getProperties());
    }

    private final VSAppCenterAPIException getAPIException(ErrorData errorData) {
        int v15;
        ArrayList arrayList;
        String P;
        String type = errorData.getType();
        String message = errorData.getMessage();
        List<ErrorStackTraceElement> stackTrace = errorData.getStackTrace();
        v15 = v.v(stackTrace, 10);
        ArrayList arrayList2 = new ArrayList(v15);
        for (ErrorStackTraceElement errorStackTraceElement : stackTrace) {
            String className = errorStackTraceElement.getClassName();
            String methodName = errorStackTraceElement.getMethodName();
            P = kotlin.text.v.P(errorStackTraceElement.getFileName(), ".java", ".kt", false, 4, null);
            arrayList2.add(new VSAppCenterAPIExceptionFrame(className, methodName, P, errorStackTraceElement.getLineNumber()));
        }
        if (errorData.getCause() != null) {
            arrayList = u.g(getAPIException(errorData.getCause()));
        } else {
            arrayList = new ArrayList();
        }
        return new VSAppCenterAPIException(type, message, arrayList2, null, arrayList, 8, null);
    }

    public final void upload(@NotNull VSAppCenterAPIRequestData vSAppCenterAPIRequestData, @NotNull final l<? super r<g0>, g0> lVar) {
        FirebasePerfOkHttpClient.enqueue(this.networkClient.a(new b0.a().v(this.uploadUrl).a("App-Secret", this.APP_SECRET).a("Install-ID", this.installId).m(c0.INSTANCE.f(jsonMediaType, new Gson().x(vSAppCenterAPIRequestData))).b()), new f() {
            @Override
            public void onFailure(@NotNull e eVar, @NotNull IOException iOException) {
                l<r<g0>, g0> lVar2 = lVar;
                r.Companion companion = r.INSTANCE;
                lVar2.invoke(r.a(r.b(s.a(iOException))));
            }

            @Override
            public void onResponse(@NotNull e eVar, @NotNull d0 d0Var) {
                l<r<g0>, g0> lVar2 = lVar;
                r.Companion companion = r.INSTANCE;
                lVar2.invoke(r.a(r.b(g0.f25238a)));
                d0Var.close();
            }
        });
    }

    @Override
    public void uploadCrashLog(@NotNull CrashLog crashLog, @NotNull l<? super r<g0>, g0> lVar) {
        ArrayList g15;
        g15 = u.g(getAPIErrorLog(crashLog));
        if (crashLog.getLogs() != null) {
            g15.add(getAPIErrorAttachment(crashLog));
        }
        upload(new VSAppCenterAPIRequestData(g15), lVar);
    }

    @Override
    public void uploadEventLog(@NotNull EventLog eventLog, @NotNull l<? super r<g0>, g0> lVar) {
        ArrayList g15;
        if (eventLog.getProperties().size() > 20) {
            Logger.INSTANCE.e(this, "VS only accepts up to 20 event properties, " + eventLog.getProperties().size() + " provided.");
        }
        g15 = u.g(getAPIEventLog(eventLog));
        upload(new VSAppCenterAPIRequestData(g15), lVar);
    }

    @Override
    public void uploadSessionStart(@NotNull String str, @NotNull l<? super r<g0>, g0> lVar) {
        ArrayList g15;
        g15 = u.g(new VSAppCenterAPIStartSession(UUID.randomUUID().toString(), str, null, getAPIDevice(), isoDateFormat.format(new Date()), 4, null));
        upload(new VSAppCenterAPIRequestData(g15), lVar);
    }

    public VSAppCenterTelemetryUpload(Application application, String str, String str2, String str3, String str4, int i15, k kVar) {
        this(application, str, str2, str3, (i15 & 16) != 0 ? DEFAULT_UPLOAD_URL : str4);
    }
}