Cyber Surfer v5.2.5版本的 MD5 值为:db13c5fce988de393e52d2679f934b22

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


package com.appsflyer;

import android.text.TextUtils;
import java.io.IOException;
import java.net.URL;
import java.util.Map;
import javax.net.ssl.HttpsURLConnection;
import org.json.JSONException;
public abstract class OneLinkHttpTask implements Runnable {
    protected static String BASE_URL = "https://%sonelink.%s/shortlink-sdk/v1";
    static final String NO_CONNECTION_ERROR_MSG = "Can't get one link data";
    private static final int WAIT_TIMEOUT = 3000;
    private AppsFlyerLibCore afLib;
    private HttpsUrlConnectionProvider connectionProvider;
    public String oneLinkId;

    public static class HttpsUrlConnectionProvider {
        final HttpsURLConnection AFDateFormat(String str) throws IOException {
            return (HttpsURLConnection) new URL(str).openConnection();
        }
    }

    public OneLinkHttpTask(AppsFlyerLibCore appsFlyerLibCore) {
        this.afLib = appsFlyerLibCore;
    }

    private void doRequest() {
        String str;
        long currentTimeMillis = System.currentTimeMillis() / 1000;
        String str2 = "";
        String oneLinkUrl = getOneLinkUrl();
        AFLogger.afRDLog("oneLinkUrl: " + oneLinkUrl);
        try {
            HttpsURLConnection AFDateFormat = this.connectionProvider.AFDateFormat(oneLinkUrl);
            AFDateFormat.addRequestProperty("content-type", "application/json");
            AFDateFormat.addRequestProperty("authorization", HashUtils.getOneLinkAuthorization(currentTimeMillis));
            AFDateFormat.addRequestProperty("af-timestamp", String.valueOf(currentTimeMillis));
            AFDateFormat.setReadTimeout(3000);
            AFDateFormat.setConnectTimeout(3000);
            initRequest(AFDateFormat);
            int responseCode = AFDateFormat.getResponseCode();
            str = this.afLib.readServerResponse(AFDateFormat);
            try {
                if (responseCode == 200) {
                    AFLogger.afInfoLog("Status 200 ok");
                } else {
                    str2 = "Response code = " + responseCode + " content = " + str;
                }
            } catch (Throwable th) {
                th = th;
                str2 = str;
                AFLogger.afErrorLog("Error while calling " + oneLinkUrl, th);
                str = str2;
                str2 = "Error while calling " + oneLinkUrl + " stacktrace: " + th.toString();
                if (TextUtils.isEmpty(str2)) {
                }
            }
        } catch (Throwable th2) {
            th = th2;
        }
        if (TextUtils.isEmpty(str2)) {
            AFLogger.afWarnLog("Connection error: " + str2);
            onErrorResponse();
            return;
        }
        AFLogger.afInfoLog("Connection call succeeded: " + str);
        handleResponse(str);
    }

    public static void setUrl(Map<String, String> map) {
        for (Map.Entry<String, String> entry : map.entrySet()) {
            if ("onelink".equals(entry.getKey())) {
                BASE_URL = entry.getValue();
            }
        }
    }

    protected abstract String getOneLinkUrl();

    protected abstract void handleResponse(String str);

    protected abstract void initRequest(HttpsURLConnection httpsURLConnection) throws JSONException, IOException;

    protected abstract void onErrorResponse();

    @Override
    public void run() {
        doRequest();
    }

    public void setConnProvider(HttpsUrlConnectionProvider httpsUrlConnectionProvider) {
        this.connectionProvider = httpsUrlConnectionProvider;
    }
}