package com.appsflyer.internal;

import android.net.Uri;
import android.text.TextUtils;
import com.appsflyer.AFLogger;
import com.appsflyer.AppsFlyerLibCore;
import com.appsflyer.OneLinkHttpTask;
import com.appsflyer.ServerConfigHandler;
import com.appsflyer.share.Constants;
import java.io.IOException;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import javax.net.ssl.HttpsURLConnection;
import org.json.JSONException;
import org.json.JSONObject;

public final class ad extends OneLinkHttpTask {

    /* renamed from: ˋ  reason: contains not printable characters */
    public static List<String> f1976 = Arrays.asList("onelink.me", "onelnk.com", "app.aflink.com");

    /* renamed from: ˊ  reason: contains not printable characters */
    public String f1977;

    /* renamed from: ॱ  reason: contains not printable characters */
    public a f1978;

    public interface a {
        /* renamed from: ˏ  reason: contains not printable characters */
        void m1171(String str);

        /* renamed from: ˏ  reason: contains not printable characters */
        void m1172(Map<String, String> map);
    }

    public ad(Uri uri, AppsFlyerLibCore appsFlyerLibCore) {
        super(appsFlyerLibCore);
        if (!(TextUtils.isEmpty(uri.getHost()) || TextUtils.isEmpty(uri.getPath()))) {
            boolean z = false;
            for (String str : f1976) {
                if (uri.getHost().contains(str)) {
                    z = true;
                }
            }
            if (g.f2074 != null) {
                StringBuilder sb = new StringBuilder("Validate custom domain URLs: ");
                sb.append(Arrays.asList(g.f2074));
                AFLogger.afRDLog(sb.toString());
                String[] strArr = g.f2074;
                for (String str2 : strArr) {
                    if (uri.getHost().contains(str2) && str2 != "") {
                        StringBuilder sb2 = new StringBuilder("DeepLink matches customDomain: ");
                        sb2.append(uri.toString());
                        AFLogger.afDebugLog(sb2.toString());
                        z = true;
                    }
                }
            }
            String[] split = uri.getPath().split(Constants.URL_PATH_DELIMITER);
            if (z && split.length == 3) {
                this.f1943 = split[1];
                this.f1977 = split[2];
            }
        }
    }

    @Override // com.appsflyer.OneLinkHttpTask
    /* renamed from: ˋ  reason: contains not printable characters */
    public final void m1167() {
        this.f1978.m1171("Can't get one link data");
    }

    @Override // com.appsflyer.OneLinkHttpTask
    /* renamed from: ˎ  reason: contains not printable characters */
    public final void m1168(String str) {
        try {
            HashMap hashMap = new HashMap();
            JSONObject jSONObject = new JSONObject(str);
            Iterator<String> keys = jSONObject.keys();
            while (keys.hasNext()) {
                String next = keys.next();
                hashMap.put(next, jSONObject.optString(next));
            }
            this.f1978.m1172(hashMap);
        } catch (JSONException e) {
            this.f1978.m1171("Can't parse one link data");
            AFLogger.afErrorLog("Error while parsing to json ".concat(String.valueOf(str)), e);
        }
    }

    @Override // com.appsflyer.OneLinkHttpTask
    /* renamed from: ˏ  reason: contains not printable characters */
    public final void m1169(HttpsURLConnection httpsURLConnection) throws JSONException, IOException {
        httpsURLConnection.setRequestMethod("GET");
    }

    @Override // com.appsflyer.OneLinkHttpTask
    /* renamed from: ॱ  reason: contains not printable characters */
    public final String m1170() {
        StringBuilder sb = new StringBuilder();
        sb.append(ServerConfigHandler.getUrl("https://%sonelink.%s/shortlink-sdk/v1"));
        sb.append(Constants.URL_PATH_DELIMITER);
        sb.append(this.f1943);
        sb.append("?id=");
        sb.append(this.f1977);
        return sb.toString();
    }
}
