导航菜单

页面标题

页面副标题

Moneyman v2.316.0.0 - VSAppCenterTelemetryUpload.java 源代码

正在查看: Moneyman v2.316.0.0 应用的 VSAppCenterTelemetryUpload.java JAVA 源代码文件

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


package com.exponea.sdk.telemetry.upload;

import B.AbstractC0151g;
import Eh.c;
import Eh.y;
import Wf.A;
import Wf.B;
import Wf.K;
import android.app.Application;
import android.os.Build;
import android.util.Base64;
import com.exponea.sdk.Exponea;
import com.exponea.sdk.models.Constants;
import com.exponea.sdk.services.inappcontentblock.ContentBlockCarouselViewController;
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.gson.g;
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.TimeZone;
import java.util.UUID;
import kg.k;
import kotlin.Metadata;
import kotlin.Result;
import kotlin.jvm.internal.d;
import kotlin.jvm.internal.i;
import okhttp3.Call;
import okhttp3.Callback;
import okhttp3.MediaType;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.RequestBody;
import okhttp3.Response;

@Metadata(d1 = {"\u0000~\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\u000e\n\u0002\b\u0006\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\b\n\u0002\u0018\u0002\n\u0002\b\u0004\n\u0002\u0010\u000b\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\u0004\b\u0000\u0018\u0000 92\u00020\u0001:\u00019B1\u0012\u0006\u0010\u0003\u001a\u00020\u0002\u0012\u0006\u0010\u0005\u001a\u00020\u0004\u0012\u0006\u0010\u0006\u001a\u00020\u0004\u0012\u0006\u0010\u0007\u001a\u00020\u0004\u0012\b\b\u0002\u0010\b\u001a\u00020\u0004¢\u0006\u0004\b\t\u0010\nJ\u0017\u0010\u000e\u001a\u00020\r2\u0006\u0010\f\u001a\u00020\u000bH\u0002¢\u0006\u0004\b\u000e\u0010\u000fJ\u0017\u0010\u0012\u001a\u00020\u00112\u0006\u0010\f\u001a\u00020\u0010H\u0002¢\u0006\u0004\b\u0012\u0010\u0013J\u0017\u0010\u0015\u001a\u00020\u00142\u0006\u0010\f\u001a\u00020\u0010H\u0002¢\u0006\u0004\b\u0015\u0010\u0016J\u000f\u0010\u0018\u001a\u00020\u0017H\u0002¢\u0006\u0004\b\u0018\u0010\u0019J\u0017\u0010\u001d\u001a\u00020\u001c2\u0006\u0010\u001b\u001a\u00020\u001aH\u0002¢\u0006\u0004\b\u001d\u0010\u001eJ4\u0010#\u001a\u00020!2\u0006\u0010\f\u001a\u00020\u000b2\u0018\u0010\"\u001a\u0014\u0012\n\u0012\b\u0012\u0004\u0012\u00020!0 \u0012\u0004\u0012\u00020!0\u001fH\u0016ø\u0001\u0000¢\u0006\u0004\b#\u0010$J4\u0010%\u001a\u00020!2\u0006\u0010\f\u001a\u00020\u00102\u0018\u0010\"\u001a\u0014\u0012\n\u0012\b\u0012\u0004\u0012\u00020!0 \u0012\u0004\u0012\u00020!0\u001fH\u0016ø\u0001\u0000¢\u0006\u0004\b%\u0010&J4\u0010(\u001a\u00020!2\u0006\u0010'\u001a\u00020\u00042\u0018\u0010\"\u001a\u0014\u0012\n\u0012\b\u0012\u0004\u0012\u00020!0 \u0012\u0004\u0012\u00020!0\u001fH\u0016ø\u0001\u0000¢\u0006\u0004\b(\u0010)J2\u0010,\u001a\u00020!2\u0006\u0010+\u001a\u00020*2\u0018\u0010\"\u001a\u0014\u0012\n\u0012\b\u0012\u0004\u0012\u00020!0 \u0012\u0004\u0012\u00020!0\u001fø\u0001\u0000¢\u0006\u0004\b,\u0010-R\u0014\u0010\u0005\u001a\u00020\u00048\u0002X\u0082\u0004¢\u0006\u0006\n\u0004\b\u0005\u0010.R\u0014\u0010\u0006\u001a\u00020\u00048\u0002X\u0082\u0004¢\u0006\u0006\n\u0004\b\u0006\u0010.R\u0014\u0010\u0007\u001a\u00020\u00048\u0002X\u0082\u0004¢\u0006\u0006\n\u0004\b\u0007\u0010.R\u0014\u0010\b\u001a\u00020\u00048\u0002X\u0082\u0004¢\u0006\u0006\n\u0004\b\b\u0010.R\u0014\u00100\u001a\u00020/8\u0002X\u0082\u0004¢\u0006\u0006\n\u0004\b0\u00101R\u0014\u00102\u001a\u00020\u00048\u0002X\u0082\u0004¢\u0006\u0006\n\u0004\b2\u0010.R\u0014\u00104\u001a\u0002038\u0002X\u0082\u0004¢\u0006\u0006\n\u0004\b4\u00105R\u0014\u00107\u001a\u0002068\u0002X\u0082\u0004¢\u0006\u0006\n\u0004\b7\u00108\u0082\u0002\u0004\n\u0002\b\u0019¨\u0006:"}, d2 = {"Lcom/exponea/sdk/telemetry/upload/VSAppCenterTelemetryUpload;", "Lcom/exponea/sdk/telemetry/upload/TelemetryUpload;", "Landroid/app/Application;", "application", ContentBlockCarouselViewController.EMPTY_PLACEHOLDER_ID, "installId", "sdkVersion", "userId", "uploadUrl", "<init>", "(Landroid/app/Application;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V", "Lcom/exponea/sdk/telemetry/model/EventLog;", "log", "Lcom/exponea/sdk/telemetry/upload/VSAppCenterAPIEventLog;", "getAPIEventLog", "(Lcom/exponea/sdk/telemetry/model/EventLog;)Lcom/exponea/sdk/telemetry/upload/VSAppCenterAPIEventLog;", "Lcom/exponea/sdk/telemetry/model/CrashLog;", "Lcom/exponea/sdk/telemetry/upload/VSAppCenterAPIErrorLog;", "getAPIErrorLog", "(Lcom/exponea/sdk/telemetry/model/CrashLog;)Lcom/exponea/sdk/telemetry/upload/VSAppCenterAPIErrorLog;", "Lcom/exponea/sdk/telemetry/upload/VSAppCenterAPIErrorAttachmentLog;", "getAPIErrorAttachment", "(Lcom/exponea/sdk/telemetry/model/CrashLog;)Lcom/exponea/sdk/telemetry/upload/VSAppCenterAPIErrorAttachmentLog;", "Lcom/exponea/sdk/telemetry/upload/VSAppCenterAPIDevice;", "getAPIDevice", "()Lcom/exponea/sdk/telemetry/upload/VSAppCenterAPIDevice;", "Lcom/exponea/sdk/telemetry/model/ErrorData;", "errorData", "Lcom/exponea/sdk/telemetry/upload/VSAppCenterAPIException;", "getAPIException", "(Lcom/exponea/sdk/telemetry/model/ErrorData;)Lcom/exponea/sdk/telemetry/upload/VSAppCenterAPIException;", "Lkotlin/Function1;", "Lkotlin/Result;", "LVf/A;", "callback", "uploadEventLog", "(Lcom/exponea/sdk/telemetry/model/EventLog;Lkg/k;)V", "uploadCrashLog", "(Lcom/exponea/sdk/telemetry/model/CrashLog;Lkg/k;)V", "runId", "uploadSessionStart", "(Ljava/lang/String;Lkg/k;)V", "Lcom/exponea/sdk/telemetry/upload/VSAppCenterAPIRequestData;", "data", "upload", "(Lcom/exponea/sdk/telemetry/upload/VSAppCenterAPIRequestData;Lkg/k;)V", "Ljava/lang/String;", ContentBlockCarouselViewController.EMPTY_PLACEHOLDER_ID, "isRunningTest", "Z", "APP_SECRET", "Lcom/exponea/sdk/telemetry/TelemetryUtility$AppInfo;", "appInfo", "Lcom/exponea/sdk/telemetry/TelemetryUtility$AppInfo;", "Lokhttp3/OkHttpClient;", "networkClient", "Lokhttp3/OkHttpClient;", "Companion", "sdk_release"}, k = 1, mv = {1, 9, 0}, xi = 48)
public final class VSAppCenterTelemetryUpload implements TelemetryUpload {
    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;
    private static final SimpleDateFormat isoDateFormat;
    private static final MediaType jsonMediaType;
    private final String APP_SECRET;
    private final TelemetryUtility.AppInfo appInfo;
    private final String installId;
    private final boolean isRunningTest;
    private final OkHttpClient networkClient;
    private final String sdkVersion;
    private final String uploadUrl;
    private final String userId;

    static {
        MediaType parse = MediaType.Companion.parse("application/json");
        i.d(parse);
        jsonMediaType = parse;
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");
        isoDateFormat = simpleDateFormat;
        simpleDateFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
    }

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

    private final VSAppCenterAPIDevice getAPIDevice() {
        String packageName = this.appInfo.getPackageName();
        String m7 = AbstractC0151g.m(this.appInfo.getPackageName(), "-", this.appInfo.getVersionName());
        String versionCode = this.appInfo.getVersionCode();
        String str = this.sdkVersion;
        String str2 = Build.VERSION.RELEASE;
        i.f(str2, "RELEASE");
        String str3 = Build.MODEL;
        String locale = Locale.getDefault().toString();
        i.f(locale, "toString(...)");
        return new VSAppCenterAPIDevice(packageName, m7, versionCode, "ExponeaSDK.android", str, Constants.DeviceInfo.osName, str2, str3, locale);
    }

    private final VSAppCenterAPIErrorAttachmentLog getAPIErrorAttachment(CrashLog log) {
        String str;
        List<String> logs = log.getLogs();
        if (logs == null || (str = K.T(logs, "\n", (String) null, (String) null, (k) null, 62)) == null) {
            str = ContentBlockCarouselViewController.EMPTY_PLACEHOLDER_ID;
        }
        byte[] bytes = str.getBytes(c.a);
        i.f(bytes, "this as java.lang.String).getBytes(charset)");
        String encodeToString = Base64.encodeToString(bytes, 2);
        String uuid = UUID.randomUUID().toString();
        i.f(uuid, "toString(...)");
        String runId = log.getRunId();
        String str2 = this.userId;
        VSAppCenterAPIDevice aPIDevice = getAPIDevice();
        String format = isoDateFormat.format(new Date(log.getTimestampMS()));
        i.f(format, "format(...)");
        String id = log.getId();
        i.d(encodeToString);
        return new VSAppCenterAPIErrorAttachmentLog(uuid, runId, str2, aPIDevice, format, id, "text/plain", encodeToString);
    }

    private final VSAppCenterAPIErrorLog getAPIErrorLog(CrashLog log) {
        String id = 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;
        String format = simpleDateFormat.format(new Date(log.getTimestampMS()));
        String format2 = simpleDateFormat.format(new Date(log.getLaunchTimestampMS()));
        i.d(format);
        i.d(format2);
        return new VSAppCenterAPIErrorLog(id, runId, str, aPIDevice, format, fatal, aPIException, format2, 0, null, 768, null);
    }

    private final VSAppCenterAPIEventLog getAPIEventLog(EventLog log) {
        String id = log.getId();
        String runId = log.getRunId();
        String str = this.userId;
        VSAppCenterAPIDevice aPIDevice = getAPIDevice();
        String format = isoDateFormat.format(new Date(log.getTimestampMS()));
        i.f(format, "format(...)");
        return new VSAppCenterAPIEventLog(id, runId, str, aPIDevice, format, log.getName(), log.getProperties());
    }

    private final VSAppCenterAPIException getAPIException(ErrorData errorData) {
        String type = errorData.getType();
        String message = errorData.getMessage();
        List<ErrorStackTraceElement> stackTrace = errorData.getStackTrace();
        ArrayList arrayList = new ArrayList(B.o(stackTrace, 10));
        for (ErrorStackTraceElement errorStackTraceElement : stackTrace) {
            arrayList.add(new VSAppCenterAPIExceptionFrame(errorStackTraceElement.getClassName(), errorStackTraceElement.getMethodName(), y.t(errorStackTraceElement.getFileName(), ".java", ".kt"), errorStackTraceElement.getLineNumber()));
        }
        return new VSAppCenterAPIException(type, message, arrayList, null, errorData.getCause() != null ? A.d(new VSAppCenterAPIException[]{getAPIException(errorData.getCause())}) : new ArrayList(), 8, null);
    }

    public final void upload(VSAppCenterAPIRequestData data, final k callback) {
        i.g(data, "data");
        i.g(callback, "callback");
        if (Exponea.INSTANCE.isStopped$sdk_release()) {
            Logger.INSTANCE.e(this, "Telemetry events has not been uploaded, SDK is stopping");
            int i5 = Result.b;
            callback.invoke(new Result(kotlin.c.a(new Exception("Telemetry events has not been uploaded, SDK is stopping"))));
            return;
        }
        String h3 = new g().h(data);
        Request.Builder addHeader = new Request.Builder().url(this.uploadUrl).addHeader("App-Secret", this.APP_SECRET).addHeader("Install-ID", this.installId);
        RequestBody.Companion companion = RequestBody.Companion;
        MediaType mediaType = jsonMediaType;
        i.d(h3);
        this.networkClient.newCall(addHeader.post(companion.create(mediaType, h3)).build()).enqueue(new Callback() {
            public void onFailure(Call call, IOException e4) {
                i.g(call, "call");
                i.g(e4, "e");
                k kVar = callback;
                int i7 = Result.b;
                kVar.invoke(new Result(kotlin.c.a(e4)));
            }

            public void onResponse(Call call, Response response) {
                i.g(call, "call");
                i.g(response, "response");
                k kVar = callback;
                int i7 = Result.b;
                kVar.invoke(new Result(Vf.A.a));
                response.close();
            }
        });
    }

    @Override
    public void uploadCrashLog(CrashLog log, k callback) {
        i.g(log, "log");
        i.g(callback, "callback");
        ArrayList d7 = A.d(new VSAppCenterAPILog[]{getAPIErrorLog(log)});
        if (log.getLogs() != null) {
            d7.add(getAPIErrorAttachment(log));
        }
        upload(new VSAppCenterAPIRequestData(d7), callback);
    }

    @Override
    public void uploadEventLog(EventLog log, k callback) {
        i.g(log, "log");
        i.g(callback, "callback");
        if (log.getProperties().size() > 20) {
            Logger.INSTANCE.e(this, "VS only accepts up to 20 event properties, " + log.getProperties().size() + " provided.");
        }
        upload(new VSAppCenterAPIRequestData(A.d(new VSAppCenterAPIEventLog[]{getAPIEventLog(log)})), callback);
    }

    @Override
    public void uploadSessionStart(String runId, k callback) {
        i.g(runId, "runId");
        i.g(callback, "callback");
        String uuid = UUID.randomUUID().toString();
        String format = isoDateFormat.format(new Date());
        VSAppCenterAPIDevice aPIDevice = getAPIDevice();
        i.d(uuid);
        i.d(format);
        upload(new VSAppCenterAPIRequestData(A.d(new VSAppCenterAPIStartSession[]{new VSAppCenterAPIStartSession(uuid, runId, null, aPIDevice, format, 4, null)})), callback);
    }

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