导航菜单

页面标题

页面副标题

Moneyman v2.316.0.0 - VersionChecker.java 源代码

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

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


package com.exponea.sdk.util;

import Eh.A;
import Z.l;
import android.content.Context;
import com.exponea.sdk.BuildConfig;
import com.exponea.sdk.network.NetworkHandler;
import com.exponea.sdk.services.inappcontentblock.ContentBlockCarouselViewController;
import com.exponea.sdk.util.VersionChecker;
import com.google.gson.g;
import java.io.IOException;
import java.util.Arrays;
import kotlin.Metadata;
import kotlin.jvm.internal.i;
import okhttp3.Call;
import okhttp3.Callback;
import okhttp3.Response;
import okhttp3.ResponseBody;

@Metadata(d1 = {"\u0000.\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0010\u000e\n\u0002\b\u0002\n\u0002\u0010\b\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\b\b\u0000\u0018\u00002\u00020\u0001:\u0001\u0015B\u0017\u0012\u0006\u0010\u0003\u001a\u00020\u0002\u0012\u0006\u0010\u0005\u001a\u00020\u0004¢\u0006\u0004\b\u0006\u0010\u0007J\u001f\u0010\f\u001a\u00020\u000b2\u0006\u0010\t\u001a\u00020\b2\u0006\u0010\n\u001a\u00020\bH\u0002¢\u0006\u0004\b\f\u0010\rJ\r\u0010\u000f\u001a\u00020\u000e¢\u0006\u0004\b\u000f\u0010\u0010R\u0014\u0010\u0003\u001a\u00020\u00028\u0002X\u0082\u0004¢\u0006\u0006\n\u0004\b\u0003\u0010\u0011R\u0014\u0010\u0005\u001a\u00020\u00048\u0002X\u0082\u0004¢\u0006\u0006\n\u0004\b\u0005\u0010\u0012R\u0014\u0010\u0013\u001a\u00020\b8\u0002X\u0082D¢\u0006\u0006\n\u0004\b\u0013\u0010\u0014¨\u0006\u0016"}, d2 = {"Lcom/exponea/sdk/util/VersionChecker;", ContentBlockCarouselViewController.EMPTY_PLACEHOLDER_ID, "Lcom/exponea/sdk/network/NetworkHandler;", "networkManager", "Landroid/content/Context;", "context", "<init>", "(Lcom/exponea/sdk/network/NetworkHandler;Landroid/content/Context;)V", ContentBlockCarouselViewController.EMPTY_PLACEHOLDER_ID, "version1", "version2", ContentBlockCarouselViewController.EMPTY_PLACEHOLDER_ID, "compareVersions", "(Ljava/lang/String;Ljava/lang/String;)I", "LVf/A;", "warnIfNotLatestSDKVersion", "()V", "Lcom/exponea/sdk/network/NetworkHandler;", "Landroid/content/Context;", "baseUrl", "Ljava/lang/String;", "GitHubReleaseResponse", "sdk_release"}, k = 1, mv = {1, 9, 0}, xi = 48)
public final class VersionChecker {
    private final String baseUrl;
    private final Context context;
    private final NetworkHandler networkManager;

    @Metadata(d1 = {"\u0000\"\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0000\n\u0002\u0010\u000e\n\u0002\b\u0006\n\u0002\u0010\u000b\n\u0002\b\u0002\n\u0002\u0010\b\n\u0002\b\u0002\b\u0082\b\u0018\u00002\u00020\u0001B\r\u0012\u0006\u0010\u0002\u001a\u00020\u0003¢\u0006\u0002\u0010\u0004J\t\u0010\u0007\u001a\u00020\u0003HÆ\u0003J\u0013\u0010\b\u001a\u00020\u00002\b\b\u0002\u0010\u0002\u001a\u00020\u0003HÆ\u0001J\u0013\u0010\t\u001a\u00020\n2\b\u0010\u000b\u001a\u0004\u0018\u00010\u0001HÖ\u0003J\t\u0010\f\u001a\u00020\rHÖ\u0001J\t\u0010\u000e\u001a\u00020\u0003HÖ\u0001R\u0011\u0010\u0002\u001a\u00020\u0003¢\u0006\b\n\u0000\u001a\u0004\b\u0005\u0010\u0006¨\u0006\u000f"}, d2 = {"Lcom/exponea/sdk/util/VersionChecker$GitHubReleaseResponse;", ContentBlockCarouselViewController.EMPTY_PLACEHOLDER_ID, "tag_name", ContentBlockCarouselViewController.EMPTY_PLACEHOLDER_ID, "(Ljava/lang/String;)V", "getTag_name", "()Ljava/lang/String;", "component1", "copy", "equals", ContentBlockCarouselViewController.EMPTY_PLACEHOLDER_ID, "other", "hashCode", ContentBlockCarouselViewController.EMPTY_PLACEHOLDER_ID, "toString", "sdk_release"}, k = 1, mv = {1, 9, 0}, xi = 48)
    public static final class GitHubReleaseResponse {
        private final String tag_name;

        public GitHubReleaseResponse(String str) {
            i.g(str, "tag_name");
            this.tag_name = str;
        }

        public static GitHubReleaseResponse copy$default(GitHubReleaseResponse gitHubReleaseResponse, String str, int i5, Object obj) {
            if ((i5 & 1) != 0) {
                str = gitHubReleaseResponse.tag_name;
            }
            return gitHubReleaseResponse.copy(str);
        }

        public final String getTag_name() {
            return this.tag_name;
        }

        public final GitHubReleaseResponse copy(String tag_name) {
            i.g(tag_name, "tag_name");
            return new GitHubReleaseResponse(tag_name);
        }

        public boolean equals(Object other) {
            if (this == other) {
                return true;
            }
            return (other instanceof GitHubReleaseResponse) && i.b(this.tag_name, ((GitHubReleaseResponse) other).tag_name);
        }

        public final String getTag_name() {
            return this.tag_name;
        }

        public int hashCode() {
            return this.tag_name.hashCode();
        }

        public String toString() {
            return l.p("GitHubReleaseResponse(tag_name=", this.tag_name, ")");
        }
    }

    public VersionChecker(NetworkHandler networkHandler, Context context) {
        i.g(networkHandler, "networkManager");
        i.g(context, "context");
        this.networkManager = networkHandler;
        this.context = context;
        this.baseUrl = "https://api.github.com/repos/exponea/%s/releases/latest";
    }

    public final int compareVersions(String version1, String version2) {
        String[] strArr = (String[]) A.Q(version1, new String[]{"."}, 0, 6).toArray(new String[0]);
        String[] strArr2 = (String[]) A.Q(version2, new String[]{"."}, 0, 6).toArray(new String[0]);
        int length = strArr.length;
        int length2 = strArr2.length;
        if (length < length2) {
            length = length2;
        }
        int i5 = 0;
        while (i5 < length) {
            int i7 = i.i(i5 < strArr.length ? Integer.parseInt(strArr[i5]) : 0, i5 < strArr2.length ? Integer.parseInt(strArr2[i5]) : 0);
            if (i7 != 0) {
                return i7;
            }
            i5++;
        }
        return 0;
    }

    public final void warnIfNotLatestSDKVersion() {
        final String str;
        final String str2;
        if (ExtensionsKt.isReactNativeSDK(this.context)) {
            str = ExtensionsKt.getReactNativeSDKVersion(this.context);
            str2 = "exponea-react-native-sdk";
        } else if (ExtensionsKt.isFlutterSDK(this.context)) {
            str = ExtensionsKt.getFlutterSDKVersion(this.context);
            str2 = "exponea-flutter-sdk";
        } else if (ExtensionsKt.isXamarinSDK(this.context)) {
            str = ExtensionsKt.getXamarinSDKVersion(this.context);
            str2 = "exponea-xamarin-sdk";
        } else if (ExtensionsKt.isMauiSDK(this.context)) {
            str = ExtensionsKt.getMauiSDKVersion(this.context);
            str2 = "bloomreach-maui-sdk";
        } else {
            str = BuildConfig.EXPONEA_VERSION_NAME;
            str2 = "exponea-android-sdk";
        }
        String format = String.format(this.baseUrl, Arrays.copyOf(new Object[]{str2}, 1));
        if (str != null) {
            NetworkHandler.DefaultImpls.get$default(this.networkManager, format, null, 2, null).enqueue(new Callback() {
                public void onFailure(Call call, IOException e4) {
                    i.g(call, "call");
                    i.g(e4, "e");
                    String localizedMessage = e4.getLocalizedMessage();
                    if (localizedMessage == null) {
                        localizedMessage = "Unknown error";
                    }
                    Logger.INSTANCE.e(this, "Failed to retrieve last Exponea SDK version: ".concat(localizedMessage));
                }

                public void onResponse(Call call, Response response) {
                    int compareVersions;
                    i.g(call, "call");
                    i.g(response, "response");
                    try {
                        try {
                            if (response.isSuccessful()) {
                                g companion = ExponeaGson.INSTANCE.getInstance();
                                ResponseBody body = response.body();
                                String tag_name = ((VersionChecker.GitHubReleaseResponse) companion.b(VersionChecker.GitHubReleaseResponse.class, body != null ? body.string() : null)).getTag_name();
                                compareVersions = VersionChecker.this.compareVersions(tag_name, str);
                                if (compareVersions > 0) {
                                    Logger.INSTANCE.e("EXPONEA", "####\n#### A newer version of the Exponea SDK is available!\n#### Your version: " + str + "  Last version: " + tag_name + "\n#### Upgrade to the latest version to benefit from the new features and better stability:\n#### https://github.com/exponea/" + str2 + "/releases\n####");
                                }
                            }
                            response.close();
                        } catch (Exception e4) {
                            String localizedMessage = e4.getLocalizedMessage();
                            if (localizedMessage == null) {
                                localizedMessage = "Unknown error";
                            }
                            Logger.INSTANCE.e(this, "Failed to retrieve last Exponea SDK version: ".concat(localizedMessage));
                            response.close();
                        }
                    } catch (Throwable th) {
                        response.close();
                        throw th;
                    }
                }
            });
        }
    }
}