Apk Done v1.0版本的 MD5 值为:44cfb8e1ce639995aa7f0de6a3a6388b

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


package com.appsgeyser.sdk.server.implementation;

import android.content.Context;
import android.content.pm.PackageManager;
import android.text.TextUtils;
import android.util.Base64;
import android.util.Log;
import com.android.installreferrer.api.ReferrerDetails;
import com.android.volley.Response;
import com.android.volley.VolleyError;
import com.appsgeyser.sdk.InternalEntryPoint;
import com.appsgeyser.sdk.PausedContentInfoActivity;
import com.appsgeyser.sdk.R;
import com.appsgeyser.sdk.ads.fastTrack.FastTrackAdsController;
import com.appsgeyser.sdk.configuration.Configuration;
import com.appsgeyser.sdk.configuration.Constants;
import com.appsgeyser.sdk.configuration.PreferencesCoder;
import com.appsgeyser.sdk.configuration.models.ConfigPhp;
import com.appsgeyser.sdk.datasdk.DataSdkController;
import com.appsgeyser.sdk.deviceidparser.DeviceIdParameters;
import com.appsgeyser.sdk.deviceidparser.DeviceIdParser;
import com.appsgeyser.sdk.hasher.Hasher;
import com.appsgeyser.sdk.push.OneSignalCreator;
import com.appsgeyser.sdk.server.StatController;
import com.appsgeyser.sdk.server.network.NetworkManager;
import com.appsgeyser.sdk.utils.DeviceInfoGetter;
import com.appsgeyser.sdk.utils.ReminderAlarmManager;
import com.appsgeyser.sdk.utils.VersionManager;
import com.google.gson.JsonParseException;
import com.google.gson.JsonSyntaxException;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
public class AppsgeyserServerClient {
    private ConfigPhp configPhpModel;
    List<ConfigPhpRequestListener> listenerList;
    private final NetworkManager networkManager;

    public interface ConfigPhpRequestListener {
        void receivedConfigPhp(ConfigPhp configPhp);
    }

    public static class SingletonHolder {
        static final AppsgeyserServerClient HOLDER_INSTANCE = new AppsgeyserServerClient();
    }

    private AppsgeyserServerClient() {
        this.listenerList = new ArrayList();
        this.networkManager = NetworkManager.getInstance();
    }

    public static AppsgeyserServerClient getInstance() {
        return SingletonHolder.HOLDER_INSTANCE;
    }

    private String getInstallerMarket(Context context) {
        try {
            String installerPackageName = context.getPackageManager().getInstallerPackageName(context.getPackageName());
            return installerPackageName == null ? "" : installerPackageName;
        } catch (Exception e) {
            if (TextUtils.isEmpty(e.getMessage())) {
                return "ERROR";
            }
            return "ERROR:" + e.getMessage();
        }
    }

    public void sendAfterInstallInfo(Context context) {
        sendRequestWithAllArgs("install", NetworkManager.RequestType.AFTERINSTALL.ordinal(), context);
    }

    public void sendUsageInfo(Context context) {
        sendRequestWithAllArgs("usage", NetworkManager.RequestType.USAGE.ordinal(), context);
    }

    public void sendAboutDialogVisitSite(Context context) {
        sendRequestSdkStatisticsWithArgs("about_dialog_visit_site", -980696864, context);
    }

    public void sendUpdateInfo(Context context) {
        int currentVersion = VersionManager.getCurrentVersion(context);
        int previousVersion = VersionManager.getPreviousVersion(context);
        if (previousVersion == -1) {
            VersionManager.updateVersion(context, currentVersion);
        } else if (currentVersion > previousVersion) {
            VersionManager.updateVersion(context, currentVersion);
            sendRequestWithAllArgs("update", NetworkManager.RequestType.UPDATE.ordinal(), context);
        }
    }

    public void getConfigPhp(final Context context, DeviceIdParameters deviceIdParameters, ConfigPhpRequestListener configPhpRequestListener) {
        String str;
        String str2;
        ConfigPhp configPhp = this.configPhpModel;
        if (configPhp != null) {
            configPhpRequestListener.receivedConfigPhp(configPhp);
        } else if (this.listenerList.size() > 0) {
            this.listenerList.add(configPhpRequestListener);
        } else {
            Configuration configuration = Configuration.getInstance(context);
            this.listenerList.add(configPhpRequestListener);
            String str3 = "";
            String advId = deviceIdParameters != null ? deviceIdParameters.getAdvId() : "";
            if (TextUtils.isEmpty(advId)) {
                str = "";
            } else {
                str = "&advid=" + advId;
            }
            configuration.loadConfiguration();
            try {
                str2 = context.getPackageManager().getPackageInfo(context.getPackageName(), 0).versionName;
            } catch (PackageManager.NameNotFoundException unused) {
                str2 = "";
            }
            try {
                str3 = String.valueOf(context.getPackageManager().getPackageInfo(context.getPackageName(), 0).versionCode);
            } catch (PackageManager.NameNotFoundException unused2) {
            }
            String str4 = getBaseConfigUrl(context) + "?widgetId=" + configuration.getApplicationId() + "&guid=" + configuration.getAppGuid() + "&v=" + Constants.PLATFORM_VERSION + "&market=" + getInstallerMarket(context) + "&cadmobid=" + context.getString(R.string.customAdmobAppID) + "&templateVersion=" + configuration.getTemplateVersion() + "&appVersionName=" + str2 + "&appVersionCode=" + str3 + str;
            final PreferencesCoder preferencesCoder = new PreferencesCoder(context);
            preferencesCoder.savePrefString("ConfigPhpURLWithParams", str4);
            this.networkManager.sendRequestAsync(str4, Integer.valueOf(NetworkManager.RequestType.CONFIG_PHP.ordinal()), context, new OnRequestDoneListener() {
                @Override
                public void onRequestDone(String str5, int i, String str6) {
                    preferencesCoder.savePrefString("ServerResponse", str6);
                    try {
                        AppsgeyserServerClient.this.configPhpModel = ConfigPhp.parseFromJson(str6);
                        if (AppsgeyserServerClient.this.configPhpModel.getStatUrls() != null) {
                            StatController.getInstance().init(new HashMap<>(AppsgeyserServerClient.this.configPhpModel.getStatUrls()));
                        }
                        preferencesCoder.savePrefBoolean("ConfigAppBanned", AppsgeyserServerClient.this.configPhpModel.isAppBanActive());
                    } catch (JsonSyntaxException unused3) {
                        for (ConfigPhpRequestListener configPhpRequestListener2 : AppsgeyserServerClient.this.listenerList) {
                            AppsgeyserServerClient.this.onGetConfigErrorResponse(context, configPhpRequestListener2, preferencesCoder);
                        }
                    }
                    if (!AppsgeyserServerClient.this.configPhpModel.isAppBanActive()) {
                        DataSdkController.startDataSdkController(context, AppsgeyserServerClient.this.configPhpModel);
                        if (!FastTrackAdsController.getInstance().isActive()) {
                            FastTrackAdsController.getInstance().requestInit(AppsgeyserServerClient.this.configPhpModel, context);
                        }
                        for (ConfigPhpRequestListener configPhpRequestListener3 : AppsgeyserServerClient.this.listenerList) {
                            configPhpRequestListener3.receivedConfigPhp(AppsgeyserServerClient.this.configPhpModel);
                        }
                        if (AppsgeyserServerClient.this.configPhpModel.isPushNotificationsActive()) {
                            AppsgeyserServerClient.this.initPush(context, AppsgeyserServerClient.this.configPhpModel.getOneSignalAppId());
                        }
                        if (AppsgeyserServerClient.this.configPhpModel.getAdditionalJsCode() != null) {
                            InternalEntryPoint.getInstance().setAdditionalJsCode(AppsgeyserServerClient.this.configPhpModel.getAdditionalJsCode());
                        }
                        if (AppsgeyserServerClient.this.configPhpModel.isInactivityReminderEnabled()) {
                            ReminderAlarmManager.startReminderAlarm(context, AppsgeyserServerClient.this.configPhpModel.getInactivityDaysPeriod(), true);
                        }
                        AppsgeyserServerClient.this.listenerList.clear();
                        return;
                    }
                    PausedContentInfoActivity.startPausedContentInfoActivity(context, false);
                }
            }, new Response.ErrorListener() {
                @Override
                public void onErrorResponse(VolleyError volleyError) {
                    for (ConfigPhpRequestListener configPhpRequestListener2 : AppsgeyserServerClient.this.listenerList) {
                        AppsgeyserServerClient.this.onGetConfigErrorResponse(context, configPhpRequestListener2, preferencesCoder);
                    }
                    AppsgeyserServerClient.this.listenerList.clear();
                    InternalEntryPoint.getInstance().setConsentRequestProcessActive(false);
                }
            });
        }
    }

    public void sendClickInfo(String str, Context context) {
        this.networkManager.sendRequestAsync(str, Integer.valueOf(NetworkManager.RequestType.CLICK.ordinal()), context, this.networkManager.getEmptyRequestDoneListener(context), this.networkManager.getDefaultErrorListener(Integer.valueOf(NetworkManager.RequestType.CLICK.ordinal()), context));
    }

    public void sendApplicationMode(Context context) {
        Configuration configuration = Configuration.getInstance(context);
        this.networkManager.sendRequestAsync("http://ads.appsgeyser.com/checkstatus.php?wid=" + configuration.getApplicationId(), Integer.valueOf(NetworkManager.RequestType.APPMODE.ordinal()), context, this.networkManager.getEmptyRequestDoneListener(context), this.networkManager.getDefaultErrorListener(Integer.valueOf(NetworkManager.RequestType.APPMODE.ordinal()), context));
    }

    private void sendRequestWithAllArgs(String str, int i, Context context) {
        String str2;
        String str3;
        String str4 = "";
        Configuration configuration = Configuration.getInstance(context);
        String advId = DeviceIdParser.getInstance().getDeviceIdParameters().getAdvId();
        try {
            str2 = context.getPackageManager().getPackageInfo(context.getPackageName(), 0).versionName;
        } catch (PackageManager.NameNotFoundException unused) {
            str2 = "";
        }
        try {
            str4 = String.valueOf(context.getPackageManager().getPackageInfo(context.getPackageName(), 0).versionCode);
        } catch (PackageManager.NameNotFoundException unused2) {
        }
        if (!TextUtils.isEmpty(advId)) {
            str3 = context.getString(R.string.statDomainUrl) + "statistics.php?action=" + str + "&name=" + configuration.getApplicationId() + "&id=" + configuration.getAppGuid() + "&v=" + Constants.PLATFORM_VERSION + "&p=android&advid=" + advId + "&market=" + getInstallerMarket(context) + DeviceInfoGetter.getDeviceInfo(context) + "&templateversion=" + configuration.getTemplateVersion() + "&appversionname=" + str2 + "&appversioncode=" + str4;
        } else {
            str3 = context.getString(R.string.statDomainUrl) + "statistics.php?action=" + str + "&name=" + configuration.getApplicationId() + "&id=" + configuration.getAppGuid() + "&v=" + Constants.PLATFORM_VERSION + "&p=android&market=" + getInstallerMarket(context) + DeviceInfoGetter.getDeviceInfo(context) + "&templateversion=" + configuration.getTemplateVersion() + "&appversionname=" + str2 + "&appversioncode=" + str4;
        }
        this.networkManager.sendRequestAsync(str3, Integer.valueOf(i), context, this.networkManager.getEmptyRequestDoneListener(context), this.networkManager.getDefaultErrorListener(Integer.valueOf(i), context));
    }

    public void sendReferrerStatsRequest(Context context, Constants.ReferrerInfoStatus referrerInfoStatus, ReferrerDetails referrerDetails) {
        String str;
        String str2 = "";
        Configuration configuration = Configuration.getInstance(context);
        try {
            str = context.getPackageManager().getPackageInfo(context.getPackageName(), 0).versionName;
        } catch (PackageManager.NameNotFoundException unused) {
            str = "";
        }
        try {
            str2 = String.valueOf(context.getPackageManager().getPackageInfo(context.getPackageName(), 0).versionCode);
        } catch (PackageManager.NameNotFoundException unused2) {
        }
        StringBuilder sb = new StringBuilder();
        sb.append("http://stat.appsgeyser.com/referrer.php");
        int i = AnonymousClass3.$SwitchMap$com$appsgeyser$sdk$configuration$Constants$ReferrerInfoStatus[referrerInfoStatus.ordinal()];
        if (i == 1) {
            sb.append("?action=add&status=ok");
        } else if (i == 2) {
            sb.append("?action=add&status=feature_not_supported");
        } else if (i == 3) {
            sb.append("?action=add&status=unavailable");
        } else if (i == 4) {
            sb.append("?action=add&status=remote_exception");
        }
        sb.append("&wid=");
        sb.append(configuration.getApplicationId());
        sb.append("&templateversion=");
        sb.append(configuration.getTemplateVersion());
        sb.append("&appversionname=");
        sb.append(str);
        sb.append("&appversioncode=");
        sb.append(str2);
        String sb2 = sb.toString();
        HashMap hashMap = new HashMap();
        if (referrerInfoStatus == Constants.ReferrerInfoStatus.OK && referrerDetails != null) {
            hashMap.put("referrerUrl", referrerDetails.getInstallReferrer());
            hashMap.put("referrerClickTime", String.valueOf(referrerDetails.getReferrerClickTimestampSeconds()));
            hashMap.put("appInstallTime", String.valueOf(referrerDetails.getInstallBeginTimestampSeconds()));
            hashMap.put("instantExperienceLaunched", String.valueOf(referrerDetails.getGooglePlayInstantParam()));
        }
        this.networkManager.sendRequestAsyncPost(sb2, Integer.valueOf(NetworkManager.RequestType.REFERRER.ordinal()), context, this.networkManager.getEmptyRequestDoneListener(context), this.networkManager.getDefaultErrorListener(Integer.valueOf(NetworkManager.RequestType.REFERRER.ordinal()), context), hashMap);
    }

    static class AnonymousClass3 {
        static final int[] $SwitchMap$com$appsgeyser$sdk$configuration$Constants$ReferrerInfoStatus;

        static {
            int[] iArr = new int[Constants.ReferrerInfoStatus.values().length];
            $SwitchMap$com$appsgeyser$sdk$configuration$Constants$ReferrerInfoStatus = iArr;
            try {
                iArr[Constants.ReferrerInfoStatus.OK.ordinal()] = 1;
            } catch (NoSuchFieldError unused) {
            }
            try {
                $SwitchMap$com$appsgeyser$sdk$configuration$Constants$ReferrerInfoStatus[Constants.ReferrerInfoStatus.FEATURE_NOT_SUPPORTED.ordinal()] = 2;
            } catch (NoSuchFieldError unused2) {
            }
            try {
                $SwitchMap$com$appsgeyser$sdk$configuration$Constants$ReferrerInfoStatus[Constants.ReferrerInfoStatus.UNAVAILABLE.ordinal()] = 3;
            } catch (NoSuchFieldError unused3) {
            }
            try {
                $SwitchMap$com$appsgeyser$sdk$configuration$Constants$ReferrerInfoStatus[Constants.ReferrerInfoStatus.REMOTE_EXCEPTION.ordinal()] = 4;
            } catch (NoSuchFieldError unused4) {
            }
        }
    }

    private void sendRequestSdkStatisticsWithArgs(String str, int i, Context context) {
        Configuration configuration = Configuration.getInstance(context);
        this.networkManager.sendRequestAsync(context.getString(R.string.statDomainUrl) + "sdk_statistics.php?action=" + str + "&wdid=" + configuration.getApplicationId() + "&guid=" + configuration.getAppGuid() + "&v=" + Constants.PLATFORM_VERSION + "&p=android" + DeviceInfoGetter.getDeviceInfo(context) + "&templateversion=" + configuration.getTemplateVersion(), Integer.valueOf(i), context, this.networkManager.getEmptyRequestDoneListener(context), this.networkManager.getDefaultErrorListener(Integer.valueOf(i), context));
    }

    public void onGetConfigErrorResponse(Context context, ConfigPhpRequestListener configPhpRequestListener, PreferencesCoder preferencesCoder) {
        String prefString = preferencesCoder.getPrefString("ServerResponse", "");
        if (!prefString.equals("")) {
            try {
                ConfigPhp parseFromJson = ConfigPhp.parseFromJson(prefString);
                this.configPhpModel = parseFromJson;
                configPhpRequestListener.receivedConfigPhp(parseFromJson);
            } catch (JsonParseException e) {
                Log.d("JsonParseException", e.toString());
            }
        }
        DataSdkController.onGetConfigErrorResponse(context);
    }

    public void initPush(Context context, String str) {
        OneSignalCreator.init(context.getApplicationContext(), str);
    }

    public void setConfigPhpModel(ConfigPhp configPhp) {
        this.configPhpModel = configPhp;
    }

    private String getBaseConfigUrl(Context context) {
        byte[] decode = Base64.decode(context.getString(R.string.configDomainUrl), 0);
        StringBuilder sb = new StringBuilder();
        sb.append("appsgeyser.com/");
        sb.append(Hasher.md5(Configuration.getInstance(context).getApplicationId() + ":appsgeyser.com/"));
        byte[] bytes = sb.substring(0, decode.length).getBytes(StandardCharsets.UTF_8);
        byte[] bArr = new byte[decode.length];
        for (int i = 0; i < decode.length; i++) {
            bArr[i] = (byte) (decode[i] ^ bytes[i]);
        }
        return new String(bArr, StandardCharsets.UTF_8);
    }
}