导航菜单

页面标题

页面副标题

любовь v1.0.6 - AppProtectManager.java 源代码

正在查看: любовь v1.0.6 应用的 AppProtectManager.java JAVA 源代码文件

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


package com.app.protect;

import a.a.a.a6501;
import a.a.a.a6502;
import a.a.a.a6503;
import a.a.a.a6504;
import a.a.a.a6507;
import a.a.a.a6508;
import a.a.a.a6509;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.SharedPreferences;
import android.os.Build;
import android.os.Handler;
import android.os.Looper;
import android.provider.Settings;
import android.text.TextUtils;
import androidx.core.app.NotificationCompat;
import androidx.core.view.InputDeviceCompat;
import androidx.core.view.PointerIconCompat;
import androidx.exifinterface.media.ExifInterface;
import com.baidu.lbsapi.auth.LBSAuthManager;
import com.baidu.location.LocationClientOption;
import com.baidu.mapapi.UIMsg;
import com.bumptech.glide.load.Key;
import com.google.android.gms.common.internal.ImagesContract;
import java.io.BufferedReader;
import java.io.File;
import java.io.InputStreamReader;
import java.math.BigInteger;
import java.net.BindException;
import java.net.HttpURLConnection;
import java.net.InetAddress;
import java.net.Socket;
import java.net.SocketTimeoutException;
import java.net.URL;
import java.net.URLEncoder;
import java.nio.ByteBuffer;
import java.nio.channels.SelectionKey;
import java.nio.channels.Selector;
import java.nio.channels.SocketChannel;
import java.security.MessageDigest;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Objects;
import java.util.Random;
import java.util.Scanner;
import java.util.Stack;
import java.util.TimeZone;
import java.util.UUID;
import java.util.concurrent.ConcurrentLinkedQueue;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicLong;
import java.util.concurrent.atomic.AtomicReference;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java9.util.concurrent.CompletableFuture;
import java9.util.concurrent.CompletionStage;
import java9.util.function.BiConsumer;
import java9.util.function.Function;
import java9.util.function.Supplier;
import org.json.JSONObject;
import org.xbill.DNS.Lookup;
import org.xbill.DNS.SimpleResolver;
import org.xbill.DNS.TXTRecord;

public class AppProtectManager {
    public static Map<Integer, Integer> a6503;
    public static boolean a6504;
    public static Selector a6508;
    public static CompletableFuture<Void> a6512;
    public static CompletableFuture<Void> a6513;
    public static CompletableFuture<Void> a6514;
    public static CompletableFuture<String> a6520;
    public static ExecutorService a6521;
    public static ExecutorService a6522;
    public static ExecutorService a6523;
    public static ExecutorService a6524;
    public static ScheduledExecutorService a6525;
    public static ScheduledExecutorService a6526;
    public static ScheduledExecutorService a6527;
    public static Future<?> a6528;
    public static Future<?> a6529;
    public static Future<?> a6530;
    public static String a6531;
    public static String a6532;
    public static String a6533;
    public static long a6535;
    public static long a6537;
    public static Context a6541;
    public static String a6548;
    public static String a6576;
    public static String a6577;
    public static Map<Integer, Integer> a6578;
    public static String a6579;
    public static long a6589;
    public static String a6603;
    public static String a6604;
    public static String a6605;
    public static String a6606;
    public static String a6607;
    public static AlertDialog a6619;
    public static final int[] a6477 = {445, 593, 707, 901, InputDeviceCompat.SOURCE_GAMEPAD, 1068, 1353, 1434, 1723, 2745, 3127, 3128, 3129, 3130, 3333, 4444, 4786, 539};
    public static final int[] a6500 = {4900, 4901, 4902, 4903, 4904, 4905, 4906, 4907, 4908, 4909, 4910, 4911, 4912, 4913, 4914, 4915, 4916, 4917};
    public static final int[] a6501 = {5554, 5800, 5900, 6167, 6667, 8998, 9996, 8866};
    public static final int[] a6502 = {7800, 7801, 7802, 7803, 7804, 7805, 7806, 7807};
    public static final ArrayList<HashMap<a6500, a6500>> a6506 = new ArrayList<>();
    public static final ArrayList<HashMap<a6500, a6500>> a6507 = new ArrayList<>();
    public static final List<a6507> a6509 = new ArrayList();
    public static final List<a6509> a6510 = new ArrayList();
    public static final AtomicBoolean a6511 = new AtomicBoolean(false);
    public static int a6515 = 0;
    public static long a6516 = 0;
    public static final AtomicReference<CompletableFuture<Void>> a6517 = new AtomicReference<>();
    public static final List<CompletableFuture<String>> a6518 = new ArrayList();
    public static final List<CompletableFuture<String>> a6519 = new ArrayList();
    public static String a6534 = "";
    public static long a6536 = -1;
    public static final AtomicLong a6538 = new AtomicLong(-1);
    public static final AtomicLong a6539 = new AtomicLong(-1);
    public static final AtomicLong a6540 = new AtomicLong(-1);
    public static final ConcurrentLinkedQueue<a6507> a6542 = new ConcurrentLinkedQueue<>();
    public static boolean a6543 = false;
    public static boolean a6544 = false;
    public static final String[] a6545 = new String[4];
    public static final int[] a6546 = new int[4];
    public static final String[] a6547 = new String[4];
    public static final int[] a6549 = new int[4];
    public static final int[] a6550 = new int[4];
    public static final int[] a6551 = new int[4];
    public static final int[] a6552 = new int[4];
    public static final int[] a6553 = new int[4];
    public static final a6508[] a6554 = new a6508[3];
    public static final String[] a6555 = new String[3];
    public static final SocketChannel[] a6556 = new SocketChannel[6];
    public static final SocketChannel[] a6557 = new SocketChannel[5];
    public static a6477 a6558 = new a6477();
    public static String a6559 = "";
    public static String a6560 = "";
    public static boolean a6561 = false;
    public static boolean a6562 = false;
    public static int a6563 = 1;
    public static int a6564 = 0;
    public static boolean a6565 = false;
    public static int a6566 = 0;
    public static int a6567 = 0;
    public static int a6568 = 0;
    public static int a6569 = 0;
    public static String a6570 = "0";
    public static int a6571 = 0;
    public static int a6572 = 0;
    public static int a6573 = 0;
    public static int a6574 = 1;
    public static int a6575 = 0;
    public static String a6580 = "0";
    public static boolean a6581 = false;
    public static boolean a6582 = false;
    public static boolean a6583 = false;
    public static boolean a6584 = true;
    public static boolean a6585 = false;
    public static long a6586 = -1;
    public static double a6587 = -1.0d;
    public static final Object a6588 = new Object();
    public static String a6590 = "";
    public static final int[] a6591 = new int[4];
    public static int a6592 = 200;
    public static String a6593 = "";
    public static final int[] a6594 = new int[4];
    public static String a6595 = "";
    public static int a6596 = 0;
    public static final StringBuilder a6597 = new StringBuilder();
    public static final AtomicInteger a6598 = new AtomicInteger(0);
    public static long a6599 = System.currentTimeMillis();
    public static final AtomicInteger a6600 = new AtomicInteger(0);
    public static long a6601 = System.currentTimeMillis();
    public static final String[] a6602 = {"https://2024.ipchaxun.com", "https://myip.ipip.net", "https://ifconfig.me", "https://ident.me", "https://api.ipify.org", "https://whois.pconline.com.cn/ipJson.jsp?ip=&json=true"};
    public static final String[] a6608 = new String[3];
    public static boolean a6609 = false;
    public static final String[] a6610 = {"2,1,4,3", "1,3,4,2", "3,4,2,1", "4,2,3,1"};
    public static final String[] a6611 = {"30,21,90,210", "23,33,77,55", "43,66,43,21", "90,21,45,61"};
    public static final AtomicLong a6612 = new AtomicLong(0);
    public static final AtomicBoolean a6613 = new AtomicBoolean(false);
    public static final long[] a6614 = new long[12];
    public static int a6615 = -1;
    public static String a6616 = "";
    public static int a6617 = 0;
    public static final DialogInterface.OnClickListener a6618 = new DialogInterface.OnClickListener() {
        @Override
        public final void onClick(DialogInterface dialogInterface, int i) {
            AppProtectManager.a6477(dialogInterface, i);
        }
    };
    public static final Handler a6620 = new Handler(Looper.getMainLooper());

    public static class a6477 {
        public int a6477;
        public String a6500;
        public String a6501;
        public int a6502;
        public int a6503;
        public String a6504;
        public int a6506;
        public int a6507;
        public int a6508;
        public int a6509;
        public int a6510;
        public String a6511;
        public String a6512;
        public String a6513;
        public int a6514;
        public int a6515;
        public int a6516;
        public int a6517;
        public String a6518;
        public String a6519;
        public String a6520;
        public int a6521;
        public int a6522;
        public int a6523;
        public int a6524;
        public String a6525;
        public String a6526;
        public String a6527;
        public int a6528;
        public int a6529;
        public int a6530;
        public int a6531;
        public String a6532;
        public String a6533;
        public String a6534;
        public int a6535;
        public String a6536;
        public int a6537;
        public int a6538;
        public int a6539;
        public int a6540;
        public int a6541;
        public int a6542;
        public int a6543;
        public int a6544;
        public String a6545;
        public String a6546;
        public String a6547;
        public String a6548;
        public String a6549;
        public String a6550;
        public int a6551;
        public long a6552;
    }

    public static class a6500 {
        public final String a6477;
        public final int a6500;
        public final int a6501;
        public int a6502;
        public int a6503;
        public boolean a6504;
        public String a6506 = "";

        public a6500(String str, int i, int i2, boolean z, int i3, int i4) {
            this.a6477 = str;
            this.a6500 = i;
            this.a6501 = i4;
            this.a6502 = i2;
            this.a6503 = i3;
            this.a6504 = z;
        }

        public boolean equals(Object obj) {
            if (this == obj) {
                return true;
            }
            if (obj == null || a6500.class != obj.getClass()) {
                return false;
            }
            a6500 a6500Var = (a6500) obj;
            return this.a6500 == a6500Var.a6500 && Objects.equals(this.a6477, a6500Var.a6477);
        }

        public int hashCode() {
            return Objects.hash(this.a6477, Integer.valueOf(this.a6500));
        }
    }

    public static int a6477(int i) {
        ArrayList arrayList;
        synchronized (a6509) {
            arrayList = new ArrayList(a6509);
        }
        int i2 = 0;
        Iterator it = arrayList.iterator();
        while (it.hasNext()) {
            a6507 a6507Var = (a6507) it.next();
            if (a6507Var.a6524 == i) {
                i2 += a6507Var.a6477();
            }
        }
        return i2;
    }

    public static int a6477(int i, int i2, int i3) {
        int i4;
        int i5;
        if (i > 10000 && i < 30000) {
            return (((i3 + LocationClientOption.MIN_AUTO_NOTIFY_INTERVAL) + (i2 * 100)) + i) - 1;
        }
        if (i <= 5000) {
            i5 = i2 * 2;
        } else {
            if (i > 10000) {
                if (i > 100000 && i <= 105000) {
                    i4 = i3 + 18000;
                    i2 *= 2;
                } else {
                    if (i > 105001 && i <= 110000) {
                        return i3 + 18000 + (i2 * 2) + 1;
                    }
                    if (i >= 1000000) {
                        return i3 + 22000 + ((i2 - 1800) * 10) + (i - 1000001);
                    }
                    i4 = i3 + UIMsg.m_AppUI.MSG_RADAR_SEARCH_RETURN_RESULT;
                }
                return i4 + i2;
            }
            i5 = (i2 * 2) + 1;
        }
        return i3 + i5 + LocationClientOption.MIN_AUTO_NOTIFY_INTERVAL;
    }

    public static int a6477(String str, int i, int i2) {
        try {
            if (!a6507(str)) {
                int[] iArr = new int[4];
                iArr[0] = i - 5;
                String[] a64772 = a6477(str, '.');
                iArr[1] = ((iArr[0] * (a6511(a64772[2]) + a6511(a64772[3]))) % 1000) + 33300;
                iArr[2] = (iArr[0] % 444) + 8500;
                iArr[3] = iArr[2] + 26;
                i = i2 < 2 ? iArr[i2] + 79 : iArr[i2];
            }
        } catch (Exception e) {
        }
        return i;
    }

    public static int a6477(java.lang.String r7, int r8, int r9, int r10) {
        throw new UnsupportedOperationException("Method not decompiled: com.app.protect.AppProtectManager.a6477(java.lang.String, int, int, int):int");
    }

    public static int a6477(String str, int i, String str2) {
        int i2 = 0;
        try {
            if (!a6507(str)) {
                int[] iArr = new int[4];
                iArr[0] = a6511(str) + 56666;
                String[] a64772 = a6477(str2, '.');
                iArr[1] = ((iArr[0] * (a6511(a64772[2]) + a6511(a64772[3]))) % 1000) + 33300;
                iArr[2] = (iArr[0] % 444) + 8500;
                iArr[3] = iArr[2] + 26;
                i2 = i < 2 ? iArr[i] + 79 : iArr[i];
            }
        } catch (Exception e) {
        }
        return i2;
    }

    public static a6477 a6477(String str) {
        a6477 a6477Var = new a6477();
        try {
            JSONObject jSONObject = new JSONObject(str);
            if (!jSONObject.isNull("result")) {
                a6477Var.a6477 = jSONObject.getInt("result");
            }
            if (!jSONObject.isNull("uid")) {
                a6477Var.a6500 = jSONObject.getString("uid");
            }
            if (!jSONObject.isNull("start_ip")) {
                a6477Var.a6501 = jSONObject.getString("start_ip");
            }
            if (!jSONObject.isNull("conn_mode")) {
                a6477Var.a6502 = jSONObject.getInt("conn_mode");
            }
            if (!jSONObject.isNull("conn_num")) {
                a6477Var.a6503 = jSONObject.getInt("conn_num");
            }
            if (!jSONObject.isNull("conn_num2")) {
                a6477Var.a6504 = jSONObject.getString("conn_num2");
            }
            if (!jSONObject.isNull("mobile_mode")) {
                a6477Var.a6506 = jSONObject.getInt("mobile_mode");
            }
            if (!jSONObject.isNull("encrypt")) {
                a6477Var.a6507 = jSONObject.getInt("encrypt");
            }
            if (!jSONObject.isNull("start_port")) {
                a6477Var.a6508 = jSONObject.getInt("start_port");
            }
            if (!jSONObject.isNull("comm_port")) {
                a6477Var.a6509 = jSONObject.getInt("comm_port");
            }
            if (!jSONObject.isNull("add_port")) {
                a6477Var.a6510 = jSONObject.getInt("add_port");
            }
            if (!jSONObject.isNull("version")) {
                a6477Var.a6511 = jSONObject.getString("version");
            }
            if (!jSONObject.isNull("to_ip")) {
                a6477Var.a6512 = jSONObject.getString("to_ip");
            }
            if (!jSONObject.isNull(NotificationCompat.CATEGORY_MESSAGE)) {
                a6477Var.a6513 = jSONObject.getString(NotificationCompat.CATEGORY_MESSAGE);
            }
            if (!jSONObject.isNull("encrypt2")) {
                a6477Var.a6514 = jSONObject.getInt("encrypt2");
            }
            if (!jSONObject.isNull("start_port2")) {
                a6477Var.a6515 = jSONObject.getInt("start_port2");
            }
            if (!jSONObject.isNull("comm_port2")) {
                a6477Var.a6516 = jSONObject.getInt("comm_port2");
            }
            if (!jSONObject.isNull("add_port2")) {
                a6477Var.a6517 = jSONObject.getInt("add_port2");
            }
            if (!jSONObject.isNull("version2")) {
                a6477Var.a6518 = jSONObject.getString("version2");
            }
            if (!jSONObject.isNull("to_ip2")) {
                a6477Var.a6519 = jSONObject.getString("to_ip2");
            }
            if (!jSONObject.isNull("msg2")) {
                a6477Var.a6520 = jSONObject.getString("msg2");
            }
            if (!jSONObject.isNull("encrypt3")) {
                a6477Var.a6521 = jSONObject.getInt("encrypt3");
            }
            if (!jSONObject.isNull("start_port3")) {
                a6477Var.a6522 = jSONObject.getInt("start_port3");
            }
            if (!jSONObject.isNull("comm_port3")) {
                a6477Var.a6523 = jSONObject.getInt("comm_port3");
            }
            if (!jSONObject.isNull("add_port3")) {
                a6477Var.a6524 = jSONObject.getInt("add_port3");
            }
            if (!jSONObject.isNull("version3")) {
                a6477Var.a6525 = jSONObject.getString("version3");
            }
            if (!jSONObject.isNull("to_ip3")) {
                a6477Var.a6526 = jSONObject.getString("to_ip3");
            }
            if (!jSONObject.isNull("msg3")) {
                a6477Var.a6527 = jSONObject.getString("msg3");
            }
            if (!jSONObject.isNull("encrypt4")) {
                a6477Var.a6528 = jSONObject.getInt("encrypt4");
            }
            if (!jSONObject.isNull("start_port4")) {
                a6477Var.a6529 = jSONObject.getInt("start_port4");
            }
            if (!jSONObject.isNull("comm_port4")) {
                a6477Var.a6530 = jSONObject.getInt("comm_port4");
            }
            if (!jSONObject.isNull("add_port4")) {
                a6477Var.a6531 = jSONObject.getInt("add_port4");
            }
            if (!jSONObject.isNull("version4")) {
                a6477Var.a6532 = jSONObject.getString("version4");
            }
            if (!jSONObject.isNull("to_ip4")) {
                a6477Var.a6533 = jSONObject.getString("to_ip4");
            }
            if (!jSONObject.isNull("msg4")) {
                a6477Var.a6534 = jSONObject.getString("msg4");
            }
            if (!jSONObject.isNull("uniq_mode")) {
                a6477Var.a6535 = jSONObject.getInt("uniq_mode");
            }
            if (!jSONObject.isNull("band_str")) {
                a6477Var.a6544 = jSONObject.getInt("band_str");
            }
            if (!jSONObject.isNull("now_version")) {
                a6477Var.a6549 = jSONObject.getString("now_version");
            }
            if (!jSONObject.isNull(ImagesContract.URL)) {
                a6477Var.a6536 = jSONObject.getString(ImagesContract.URL);
            }
            if (!jSONObject.isNull("dnsGroup")) {
                a6477Var.a6545 = jSONObject.getString("dnsGroup");
            }
            if (!jSONObject.isNull("sniOpen")) {
                a6477Var.a6546 = jSONObject.getString("sniOpen");
            }
            if (!jSONObject.isNull("shortConnection")) {
                a6477Var.a6547 = jSONObject.getString("shortConnection");
            }
            if (!jSONObject.isNull("id1")) {
                a6477Var.a6537 = jSONObject.getInt("id1");
            }
            if (!jSONObject.isNull("id2")) {
                a6477Var.a6538 = jSONObject.getInt("id2");
            }
            if (!jSONObject.isNull("id3")) {
                a6477Var.a6539 = jSONObject.getInt("id3");
            }
            if (!jSONObject.isNull("id4")) {
                a6477Var.a6540 = jSONObject.getInt("id4");
            }
            if (!jSONObject.isNull("pack_mode")) {
                a6477Var.a6541 = jSONObject.getInt("pack_mode");
            }
            if (!jSONObject.isNull("pack_num")) {
                a6477Var.a6542 = jSONObject.getInt("pack_num");
            }
            if (!jSONObject.isNull("conn_num3")) {
                a6477Var.a6543 = jSONObject.getInt("conn_num3");
            }
            if (!jSONObject.isNull("useHighPort")) {
                a6477Var.a6550 = jSONObject.getString("useHighPort");
            }
        } catch (Exception e) {
        }
        return a6477Var;
    }

    public static String a6477() {
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < 3; i++) {
            sb.append(a6555[i]);
            sb.append('|');
        }
        return sb.toString();
    }

    public static String a6477(a6477 a6477Var) {
        try {
            JSONObject jSONObject = new JSONObject();
            jSONObject.put("result", a6477Var.a6477);
            jSONObject.put("uid", a6477Var.a6500 != null ? a6477Var.a6500 : JSONObject.NULL);
            jSONObject.put("start_ip", a6477Var.a6501 != null ? a6477Var.a6501 : JSONObject.NULL);
            jSONObject.put("conn_mode", a6477Var.a6502);
            jSONObject.put("conn_num", a6477Var.a6503);
            jSONObject.put("conn_num2", a6477Var.a6504 != null ? a6477Var.a6504 : JSONObject.NULL);
            jSONObject.put("mobile_mode", a6477Var.a6506);
            jSONObject.put("encrypt", a6477Var.a6507);
            jSONObject.put("start_port", a6477Var.a6508);
            jSONObject.put("comm_port", a6477Var.a6509);
            jSONObject.put("add_port", a6477Var.a6510);
            jSONObject.put("version", a6477Var.a6511 != null ? a6477Var.a6511 : JSONObject.NULL);
            jSONObject.put("to_ip", a6477Var.a6512 != null ? a6477Var.a6512 : JSONObject.NULL);
            jSONObject.put(NotificationCompat.CATEGORY_MESSAGE, a6477Var.a6513 != null ? a6477Var.a6513 : JSONObject.NULL);
            jSONObject.put("encrypt2", a6477Var.a6514);
            jSONObject.put("start_port2", a6477Var.a6515);
            jSONObject.put("comm_port2", a6477Var.a6516);
            jSONObject.put("add_port2", a6477Var.a6517);
            jSONObject.put("version2", a6477Var.a6518 != null ? a6477Var.a6518 : JSONObject.NULL);
            jSONObject.put("to_ip2", a6477Var.a6519 != null ? a6477Var.a6519 : JSONObject.NULL);
            jSONObject.put("msg2", a6477Var.a6520 != null ? a6477Var.a6520 : JSONObject.NULL);
            jSONObject.put("encrypt3", a6477Var.a6521);
            jSONObject.put("start_port3", a6477Var.a6522);
            jSONObject.put("comm_port3", a6477Var.a6523);
            jSONObject.put("add_port3", a6477Var.a6524);
            jSONObject.put("version3", a6477Var.a6525 != null ? a6477Var.a6525 : JSONObject.NULL);
            jSONObject.put("to_ip3", a6477Var.a6526 != null ? a6477Var.a6526 : JSONObject.NULL);
            jSONObject.put("msg3", a6477Var.a6527 != null ? a6477Var.a6527 : JSONObject.NULL);
            jSONObject.put("encrypt4", a6477Var.a6528);
            jSONObject.put("start_port4", a6477Var.a6529);
            jSONObject.put("comm_port4", a6477Var.a6530);
            jSONObject.put("add_port4", a6477Var.a6531);
            jSONObject.put("version4", a6477Var.a6532 != null ? a6477Var.a6532 : JSONObject.NULL);
            jSONObject.put("to_ip4", a6477Var.a6533 != null ? a6477Var.a6533 : JSONObject.NULL);
            jSONObject.put("msg4", a6477Var.a6534 != null ? a6477Var.a6534 : JSONObject.NULL);
            jSONObject.put("uniq_mode", a6477Var.a6535);
            jSONObject.put("band_str", a6477Var.a6544);
            jSONObject.put("now_version", a6477Var.a6549 != null ? a6477Var.a6549 : JSONObject.NULL);
            jSONObject.put(ImagesContract.URL, a6477Var.a6536 != null ? a6477Var.a6536 : JSONObject.NULL);
            jSONObject.put("dnsGroup", a6477Var.a6545 != null ? a6477Var.a6545 : JSONObject.NULL);
            jSONObject.put("sniOpen", a6477Var.a6546 != null ? a6477Var.a6546 : JSONObject.NULL);
            jSONObject.put("shortConnection", a6477Var.a6547 != null ? a6477Var.a6547 : JSONObject.NULL);
            jSONObject.put("id1", a6477Var.a6537);
            jSONObject.put("id2", a6477Var.a6538);
            jSONObject.put("id3", a6477Var.a6539);
            jSONObject.put("id4", a6477Var.a6540);
            jSONObject.put("pack_mode", a6477Var.a6541);
            jSONObject.put("pack_num", a6477Var.a6542);
            jSONObject.put("conn_num3", a6477Var.a6543);
            jSONObject.put("response", a6477Var.a6548 != null ? a6477Var.a6548 : JSONObject.NULL);
            jSONObject.put("useHighPort", a6477Var.a6550 != null ? a6477Var.a6550 : JSONObject.NULL);
            return jSONObject.toString();
        } catch (Exception e) {
            return "";
        }
    }

    public static String a6477(String str, int i) {
        try {
            if (!a6507(str)) {
                long parseLong = Long.parseLong(str);
                int i2 = (int) (parseLong % 25718923);
                int i3 = i2 % 98600;
                int[] iArr = {(int) (parseLong / 25718923), i2 / 98600, i3 / 364, i3 % 364};
                String[] a64772 = a6477(a6610[i], ',');
                int[] iArr2 = new int[4];
                for (int i4 = 0; i4 < a64772.length; i4++) {
                    iArr2[i4] = iArr[a6511(a64772[i4]) - 1];
                }
                String[] a64773 = a6477(a6611[i], ',');
                for (int i5 = 0; i5 < a64773.length; i5++) {
                    int a65112 = iArr2[i5] - a6511(a64773[i5]);
                    if (a65112 < 0) {
                        a65112 += 256;
                    }
                    iArr2[i5] = a65112;
                }
                StringBuilder sb = new StringBuilder();
                for (int i6 = 0; i6 < 4; i6++) {
                    sb.append(iArr2[i6]);
                    if (i6 < 3) {
                        sb.append('.');
                    }
                }
                return sb.toString();
            }
        } catch (Exception e) {
        }
        return "";
    }

    public static String a6477(SocketChannel socketChannel) {
        Socket socket;
        InetAddress inetAddress;
        if (socketChannel == null || !socketChannel.isConnected() || (socket = socketChannel.socket()) == null || (inetAddress = socket.getInetAddress()) == null) {
            return null;
        }
        return inetAddress.getHostAddress();
    }

    public static Void a6477(Throwable th) {
        Throwable cause = th.getCause();
        if (cause instanceof InterruptedException) {
            Thread.currentThread().interrupt();
        } else {
            if (!(cause instanceof SocketTimeoutException)) {
                a6564++;
                a6519();
            } else if (a6562) {
                a6567++;
            } else {
                a6566 = PointerIconCompat.TYPE_ALIAS;
            }
            if (!a6562) {
                a6562 = true;
            }
            if (a6507()) {
                a6565 = a6566 == 0;
                a6528();
            }
        }
        String str = "Exception getDynamicIP: " + th.getMessage();
        a6504.a6501();
        return null;
    }

    public static CompletableFuture<Void> a6477(final String str, final String str2, final String str3, final long j) {
        return CompletableFuture.supplyAsync(new Supplier() {
            public final Object get() {
                return AppProtectManager.a6477(str, j, str3, str2);
            }
        });
    }

    public static void a6477(int i, int i2, String str) {
        StringBuilder sb;
        if (a6582) {
            return;
        }
        a6582 = true;
        if (i <= 5 || i != i2) {
            StringBuilder sb2 = new StringBuilder();
            sb2.append("本地端口已被占用,监听失败(");
            sb2.append(str);
            String str2 = ")";
            sb2.append(")");
            String sb3 = sb2.toString();
            int i3 = a6574;
            if (i3 != 2) {
                if (i3 == 3) {
                    sb = new StringBuilder();
                    sb.append("Local port listening failed (Port number: ");
                    sb.append(str);
                    str2 = ")\nPlease avoid popular ports and consider using higher port numbers.";
                }
                a6477("", sb3, false, UIMsg.m_AppUI.MSG_APP_GPS);
            }
            sb = new StringBuilder();
            sb.append("本地端口已被占用,監聽失敗(");
            sb.append(str);
            sb.append(str2);
            sb3 = sb.toString();
            a6477("", sb3, false, UIMsg.m_AppUI.MSG_APP_GPS);
        }
    }

    public static void a6477(int r15, long r16, java.util.concurrent.atomic.AtomicReference r18, java.util.concurrent.atomic.AtomicReference r19, boolean r20, int r21, java.lang.String r22, int r23, boolean r24, java.lang.String r25, java.util.List r26) {
        throw new UnsupportedOperationException("Method not decompiled: com.app.protect.AppProtectManager.a6477(int, long, java.util.concurrent.atomic.AtomicReference, java.util.concurrent.atomic.AtomicReference, boolean, int, java.lang.String, int, boolean, java.lang.String, java.util.List):void");
    }

    public static void a6477(final int r19, final java.lang.String r20, final int r21, final java.lang.String r22, final java.util.concurrent.atomic.AtomicReference<com.app.protect.AppProtectManager.a6477> r23, java.util.concurrent.ExecutorService r24, final boolean r25, final boolean r26, boolean r27) {
        throw new UnsupportedOperationException("Method not decompiled: com.app.protect.AppProtectManager.a6477(int, java.lang.String, int, java.lang.String, java.util.concurrent.atomic.AtomicReference, java.util.concurrent.ExecutorService, boolean, boolean, boolean):void");
    }

    public static void a6477(int i, SocketChannel socketChannel, String str, boolean z) {
        ByteBuffer allocate = ByteBuffer.allocate(16384);
        try {
            if (socketChannel.read(allocate) > 0) {
                allocate.flip();
                byte[] bArr = new byte[allocate.remaining()];
                allocate.get(bArr);
                byte[] bytes = str.getBytes(a6503.a6477);
                String replace = new String(a6507.a6477(bytes, bArr), a6503.a6477).replace("\u0000", "");
                if (!z && i < a6594.length) {
                    int[] iArr = a6594;
                    iArr[i] = iArr[i] + 10;
                }
                a6583 = true;
                int nextInt = new Random().nextInt(10) + 11;
                StringBuilder sb = new StringBuilder();
                sb.append(0);
                sb.append("|");
                StringBuilder sb2 = new StringBuilder();
                sb2.append(0);
                sb2.append(replace);
                sb2.append("-pZERyQYmz5mIYHWOxifKerOLYpR9tm0i");
                sb.append(a6504(sb2.toString()));
                sb.append("|");
                sb.append(a.a.a.a6477.a6477(nextInt));
                ByteBuffer wrap = ByteBuffer.wrap(a6507.a6477(bytes, sb.toString().getBytes(a6503.a6477)));
                while (wrap.hasRemaining()) {
                    socketChannel.write(wrap);
                }
                allocate.compact();
                Thread.sleep(3L);
            }
        } catch (Exception e) {
        }
    }

    public static void a6477(long j) {
        Arrays.fill(a6614, j);
        a6615 = -1;
    }

    public static void a6477(long j, long j2) {
        a6538.set(j);
        a6539.set(j2);
    }

    public static void a6477(a6508 a6508Var, int i) {
        for (CompletableFuture<String> completableFuture : a6508Var.a6477) {
            if (!completableFuture.isCancelled()) {
                a6503((String) completableFuture.join(), i);
            }
        }
    }

    public static void a6477(a6508 a6508Var, CompletableFuture completableFuture, String str, Throwable th) {
        if (a6507(str)) {
            return;
        }
        for (CompletableFuture<String> completableFuture2 : a6508Var.a6477) {
            if (completableFuture2 != completableFuture) {
                completableFuture2.cancel(true);
            }
        }
        a6508Var.a6500.complete((Object) null);
    }

    public static void a6477(DialogInterface dialogInterface, int i) {
        a6529();
        Context context = a6541;
        if (context instanceof Activity) {
            ((Activity) context).finishAffinity();
        }
    }

    public static void a6477(final String str, final long j) {
        int i = a6558.a6477;
        if (i == 1088 || i == 1004 || i == 1005 || i == 1024) {
            return;
        }
        CompletableFuture.completedFuture((Object) null).thenCompose(new Function() {
            public <V> Function<T, V> andThen(Function<? super R, ? extends V> function) {
                return Function.-CC.$default$andThen(this, function);
            }

            public final Object apply(Object obj) {
                CompletionStage a64772;
                a64772 = AppProtectManager.a6477(str, AppProtectManager.a6533, AppProtectManager.a6532, j);
                return a64772;
            }

            public <V> Function<V, R> compose(Function<? super V, ? extends T> function) {
                return Function.-CC.$default$compose(this, function);
            }
        }).thenRun(new Runnable() {
            @Override
            public final void run() {
                AppProtectManager.a6516();
            }
        }).exceptionally(new Function() {
            public <V> Function<T, V> andThen(Function<? super R, ? extends V> function) {
                return Function.-CC.$default$andThen(this, function);
            }

            public final Object apply(Object obj) {
                return AppProtectManager.a6503((Throwable) obj);
            }

            public <V> Function<V, R> compose(Function<? super V, ? extends T> function) {
                return Function.-CC.$default$compose(this, function);
            }
        });
    }

    public static void a6477(String str, final String str2, final boolean z, final int i) {
        Context context = a6541;
        if (context instanceof Activity) {
            final Activity activity = (Activity) context;
            activity.runOnUiThread(new Runnable() {
                @Override
                public final void run() {
                    AppProtectManager.a6477(str2, z, activity, i);
                }
            });
        }
    }

    public static void a6477(String str, boolean z, Activity activity, int i) {
        a6620.removeCallbacksAndMessages(null);
        AlertDialog alertDialog = a6619;
        if (alertDialog == null || !alertDialog.isShowing()) {
            AlertDialog.Builder builder = new AlertDialog.Builder(activity);
            builder.setMessage(str).setPositiveButton(z ? "关闭" : "确认", z ? a6618 : null);
            AlertDialog create = builder.create();
            a6619 = create;
            create.show();
        } else {
            a6619.setMessage(str);
            a6619.setButton(-1, z ? "关闭" : "确认", z ? a6618 : null);
        }
        if (i > 0) {
            a6620.postDelayed(new Runnable() {
                @Override
                public final void run() {
                    AppProtectManager.a6509();
                }
            }, i);
        }
    }

    public static void a6477(CompletableFuture completableFuture, String str, Throwable th) {
        if (a6507(str)) {
            return;
        }
        for (CompletableFuture<String> completableFuture2 : a6519) {
            if (completableFuture2 != completableFuture) {
                completableFuture2.cancel(true);
            }
        }
        a6513.complete((Object) null);
    }

    public static void a6477(boolean z) {
        a6613.set(z);
        if (z && a6540.get() == -1) {
            long currentTimeMillis = System.currentTimeMillis();
            a6477(currentTimeMillis, 5000 + currentTimeMillis);
        }
    }

    public static void a6477(SocketChannel[] socketChannelArr, int i) {
        if (socketChannelArr[i] != null) {
            try {
                socketChannelArr[i].close();
            } catch (Exception e) {
            }
            socketChannelArr[i] = null;
        }
    }

    public static String[] a6477(String str, char c) {
        int i = 1;
        for (int i2 = 0; i2 < str.length(); i2++) {
            if (str.charAt(i2) == c) {
                i++;
            }
        }
        String[] strArr = new String[i];
        int i3 = 0;
        int i4 = 0;
        for (int i5 = 0; i5 < str.length(); i5++) {
            if (str.charAt(i5) == c) {
                strArr[i4] = str.substring(i3, i5);
                i3 = i5 + 1;
                i4++;
            }
        }
        strArr[i4] = str.substring(i3);
        return strArr;
    }

    public static int a6500(int i) {
        if (i < 0) {
            return 0;
        }
        int[] iArr = a6551;
        if (i < iArr.length) {
            return iArr[i] + 5;
        }
        return 0;
    }

    public static Void a6500(Throwable th) {
        if (th.getCause() instanceof InterruptedException) {
            Thread.currentThread().interrupt();
        }
        String str = "Exception getLocalIP: " + th.getMessage();
        a6504.a6501();
        return null;
    }

    public static void a6500() {
        ArrayList arrayList;
        ArrayList arrayList2;
        if (a6558.a6477 == 1088) {
            return;
        }
        synchronized (a6506) {
            arrayList = new ArrayList(a6506);
        }
        boolean z = false;
        for (int i = 0; i < arrayList.size(); i++) {
            if ((a6558.a6535 != 1 || i != 2) && (a6558.a6535 != 2 || (i != 2 && i != 3))) {
                Iterator it = ((Map) arrayList.get(i)).entrySet().iterator();
                while (it.hasNext()) {
                    a6500 a6500Var = (a6500) ((Map.Entry) it.next()).getKey();
                    a6507 a65012 = a6501(a6500Var.a6477, a6500Var.a6500);
                    if (a65012 != null) {
                        int i2 = a65012.a6517.get();
                        if (a65012.a6523 && i2 > 0) {
                            long j = a65012.a6518.get();
                            try {
                                int a64772 = a65012.a6477();
                                if (i2 == a65012.a6519.get() && a64772 == a65012.a6521.get() && j < a65012.a6520.get()) {
                                    a65012.a6501();
                                    z = true;
                                }
                                a65012.a6519.set(i2);
                                a65012.a6521.set(a64772);
                                a65012.a6520.set(System.currentTimeMillis());
                            } catch (Exception e) {
                            }
                        }
                    }
                    z = true;
                }
                if (z) {
                    break;
                }
            }
        }
        if (!z) {
            synchronized (a6507) {
                arrayList2 = new ArrayList(a6507);
            }
            for (int i3 = 0; i3 < arrayList2.size(); i3++) {
                Iterator it2 = ((Map) arrayList2.get(i3)).entrySet().iterator();
                while (true) {
                    if (!it2.hasNext()) {
                        break;
                    }
                    a6500 a6500Var2 = (a6500) ((Map.Entry) it2.next()).getKey();
                    if (a6502(a6500Var2.a6477, a6500Var2.a6500) == null) {
                        z = true;
                        break;
                    }
                }
                if (z) {
                    break;
                }
            }
        }
        if (z) {
            a6524();
        }
        CompletableFuture<Void> completableFuture = a6517.get();
        if (completableFuture == null || completableFuture.isDone()) {
            if (a6504() > 0 || a6613.get()) {
                a6477(false);
            } else if (a6535 == -1 || System.currentTimeMillis() - a6535 <= 180000) {
                return;
            }
            a6528();
        }
    }

    public static void a6500(java.lang.String r25, int r26, java.lang.String r27) {
        throw new UnsupportedOperationException("Method not decompiled: com.app.protect.AppProtectManager.a6500(java.lang.String, int, java.lang.String):void");
    }

    public static boolean a6500(String str, int i) {
        int i2 = a6568;
        if (i2 == 1) {
            int a65042 = a6504();
            int i3 = a6569;
            if (i3 == 0 || a65042 < i3) {
                return true;
            }
        } else if (i2 == 2) {
            int a65012 = a6501(str);
            int i4 = a6569;
            if (i4 == 0 || a65012 < i4) {
                return true;
            }
        } else if (i2 == 3) {
            int i5 = a6569;
            if (i5 == 0 || i < i5) {
                return true;
            }
        } else {
            if (i2 != 4) {
                return true;
            }
            int a65013 = a6501(str);
            int a65032 = a6503(str);
            if (a65032 == 0 || a65013 < a65032) {
                return true;
            }
        }
        return false;
    }

    public static int a6501(String str) {
        ArrayList arrayList;
        int i = 0;
        if (a6507(str)) {
            return 0;
        }
        synchronized (a6509) {
            arrayList = new ArrayList(a6509);
        }
        Iterator it = arrayList.iterator();
        while (it.hasNext()) {
            a6507 a6507Var = (a6507) it.next();
            if (str.equals(a6507Var.a6527)) {
                i += a6507Var.a6477();
            }
        }
        return i;
    }

    public static a6507 a6501(String str, int i) {
        ArrayList arrayList;
        synchronized (a6509) {
            arrayList = new ArrayList(a6509);
        }
        Iterator it = arrayList.iterator();
        while (it.hasNext()) {
            a6507 a6507Var = (a6507) it.next();
            if (a6507Var.a6500 == i && str.equals(a6507Var.a6477)) {
                return a6507Var;
            }
        }
        return null;
    }

    public static Void a6501(Throwable th) {
        if (th.getCause() instanceof InterruptedException) {
            Thread.currentThread().interrupt();
        }
        String str = "Exception getTxtRecord: " + th.getMessage();
        a6504.a6501();
        return null;
    }

    public static void a6501() {
        File file = new File(a6531);
        if (a6558.a6477 != 1088 && ((!file.exists() || file.isDirectory()) && !a6581)) {
            if (!a6532()) {
                a6500(1, 0, "本地文件不存在,间隔10秒");
            }
            a6526();
        } else {
            int i = a6558.a6477;
            Future<?> future = a6529;
            if (future != null) {
                future.cancel(true);
                a6526.shutdownNow();
            }
        }
    }

    public static int a6502(String str) {
        int i = 0;
        while (true) {
            String[] strArr = a6545;
            if (i >= strArr.length) {
                return 0;
            }
            if (str.equals(strArr[i])) {
                return a6546[i];
            }
            i++;
        }
    }

    public static a6509 a6502(String str, int i) {
        ArrayList arrayList;
        synchronized (a6510) {
            arrayList = new ArrayList(a6510);
        }
        Iterator it = arrayList.iterator();
        while (it.hasNext()) {
            a6509 a6509Var = (a6509) it.next();
            if (a6509Var.a6500.getLocalPort() == i && str.equals(a6509Var.a6500.getLocalAddress().getHostAddress())) {
                return a6509Var;
            }
        }
        return null;
    }

    public static Void a6502(Throwable th) {
        String str = "Exception sendError: " + th.getMessage();
        a6504.a6501();
        return null;
    }

    public static void a6502() {
        int i;
        synchronized (a6506) {
            for (int i2 = 0; i2 < a6506.size(); i2++) {
                a6506.get(i2).clear();
            }
        }
        synchronized (a6507) {
            for (i = 0; i < a6507.size(); i++) {
                a6507.get(i).clear();
            }
        }
    }

    public static void a6502(final int i) {
        if (i != 1 && !a6609 && a6507(a6534)) {
            a6529();
            return;
        }
        String str = null;
        if (i >= 0 && i < 3) {
            str = a6555[i];
        }
        if (a6507(str)) {
            return;
        }
        String[] a64772 = a6477(str, ',');
        if (a64772.length < 3) {
            return;
        }
        final String str2 = a64772[0];
        String str3 = a64772[1];
        String str4 = a64772[2];
        final a6508 a6508Var = a6554[i];
        Iterator<CompletableFuture<String>> it = a6508Var.a6477.iterator();
        while (it.hasNext()) {
            it.next().cancel(true);
        }
        a6508Var.a6477.clear();
        CompletableFuture<String> completableFuture = a6508Var.a6500;
        if (completableFuture != null) {
            completableFuture.cancel(true);
            a6508Var.a6501.shutdownNow();
        }
        a6508Var.a6501 = Executors.newCachedThreadPool();
        a6508Var.a6500 = new CompletableFuture<>();
        String[] strArr = {str3, str4};
        final int i2 = -1;
        for (int i3 = 0; i3 < 2; i3++) {
            final String str5 = strArr[i3];
            i2++;
            final CompletableFuture<String> supplyAsync = CompletableFuture.supplyAsync(new Supplier() {
                public final Object get() {
                    return AppProtectManager.a6477(str2, str5, i2, a6508Var);
                }
            }, a6508Var.a6501);
            a6508Var.a6477.add(supplyAsync);
            supplyAsync.whenComplete(new BiConsumer() {
                public final void accept(Object obj, Object obj2) {
                    AppProtectManager.a6477(a6508.this, supplyAsync, (String) obj, (Throwable) obj2);
                }

                public BiConsumer<T, U> andThen(BiConsumer<? super T, ? super U> biConsumer) {
                    return BiConsumer.-CC.$default$andThen(this, biConsumer);
                }
            });
        }
        a6508Var.a6500.thenRun(new Runnable() {
            @Override
            public final void run() {
                AppProtectManager.a6477(a6508.this, i);
            }
        }).exceptionally(new Function() {
            public <V> Function<T, V> andThen(Function<? super R, ? extends V> function) {
                return Function.-CC.$default$andThen(this, function);
            }

            public final Object apply(Object obj) {
                return AppProtectManager.a6501((Throwable) obj);
            }

            public <V> Function<V, R> compose(Function<? super V, ? extends T> function) {
                return Function.-CC.$default$compose(this, function);
            }
        });
    }

    public static int a6503(String str) {
        if (a6507(str)) {
            return 0;
        }
        try {
            int parseInt = Integer.parseInt(a6477(str, '.')[r6.length - 1]) % 10;
            String[] a64772 = a6477(a6570, '|');
            ArrayList arrayList = new ArrayList();
            for (String str2 : a64772) {
                try {
                    arrayList.add(Integer.valueOf(Integer.parseInt(str2)));
                } catch (NumberFormatException e) {
                    return 0;
                }
            }
            if (parseInt < 0 || parseInt >= arrayList.size()) {
                return 0;
            }
            return ((Integer) arrayList.get(parseInt)).intValue();
        } catch (NumberFormatException e2) {
            return 0;
        }
    }

    public static Void a6503(Throwable th) {
        String str = "Exception syncStatus: " + th.getMessage();
        a6504.a6501();
        return null;
    }

    public static void a6503() {
        a6612.set(0L);
    }

    public static void a6503(String str, int i) {
        int i2;
        String sb;
        boolean z;
        if (a6507(str)) {
            return;
        }
        String a64772 = a.a.a.a6477.a6477(str, a6503.a6477(i));
        if (a6507(a64772)) {
            return;
        }
        String[] a64773 = a6477(a64772, '@');
        if (i == 1) {
            a6609 = true;
        }
        if (i == 1 && a64773.length > 2 && !a6507(a64773[2])) {
            String[] a64774 = a6477(a64773[2], '|');
            int a65112 = a6511(a6533.substring(1));
            if (a65112 == 0) {
                sb = "0";
            } else {
                StringBuilder sb2 = new StringBuilder();
                while (a65112 > 0) {
                    sb2.insert(0, "0123456789ABCDEFGHIJKLMNOPQRSTUV".charAt(a65112 % 32));
                    a65112 /= 32;
                }
                sb = sb2.toString();
            }
            int length = a64774.length;
            int i3 = 0;
            while (true) {
                if (i3 >= length) {
                    z = false;
                    break;
                } else {
                    if (sb.equals(a64774[i3])) {
                        z = true;
                        break;
                    }
                    i3++;
                }
            }
            if (!z) {
                a6529();
                return;
            }
        }
        String[] a64775 = a6477(a64773[0], '|');
        if (a64775.length >= 3) {
            if (i == 2) {
                i2 = new Random().nextInt(3);
            } else {
                String uniqueID = getUniqueID();
                if (!a6507(uniqueID)) {
                    BigInteger bigInteger = new BigInteger(uniqueID, 16);
                    if (bigInteger.compareTo(BigInteger.ZERO) > 0) {
                        i2 = bigInteger.mod(BigInteger.valueOf(3)).intValue();
                    }
                }
                i2 = 0;
            }
            String[] a64776 = a6477(a64775[i2], ',');
            if (a64776.length == 2) {
                String a64777 = a6477(a64776[0], i2);
                a6608[i] = a64777 + ":" + a64776[1];
            }
        }
        if (i != 0 || a64775.length <= 4) {
            return;
        }
        String[] a64778 = a6477(a64775[3], ',');
        if (a64778.length == 2) {
            a6607 = "5," + a6477(a64778[0], 3) + ":" + (a6511(a64778[1]) + 8888) + ",0,0,2";
        }
    }

    public static int a6504() {
        ArrayList arrayList;
        synchronized (a6509) {
            arrayList = new ArrayList(a6509);
        }
        int i = 0;
        Iterator it = arrayList.iterator();
        while (it.hasNext()) {
            i += ((a6507) it.next()).a6477();
        }
        return i;
    }

    public static String a6504(String str) {
        if (str != null && !str.isEmpty()) {
            try {
                byte[] digest = MessageDigest.getInstance("MD5").digest(str.getBytes(a6503.a6477));
                StringBuilder sb = new StringBuilder();
                for (byte b : digest) {
                    sb.append(String.format("%02x", Byte.valueOf(b)));
                }
                return sb.toString();
            } catch (Exception e) {
            }
        }
        return "";
    }

    public static int a6506() {
        int i = 0;
        for (int i2 = 0; i2 < a6506.size(); i2++) {
            i += a6506.get(i2).size();
        }
        for (int i3 = 0; i3 < a6507.size(); i3++) {
            i += a6507.get(i3).size();
        }
        return i;
    }

    public static boolean a6506(String str) {
        if (str == null || str.trim().isEmpty()) {
            return false;
        }
        String trim = str.trim();
        Stack stack = new Stack();
        for (int i = 0; i < trim.length(); i++) {
            char charAt = trim.charAt(i);
            if (charAt != '[') {
                if (charAt == ']') {
                    if (stack.isEmpty() || ((Character) stack.pop()).charValue() != '[') {
                        return false;
                    }
                } else if (charAt != '{') {
                    if (charAt == '}' && (stack.isEmpty() || ((Character) stack.pop()).charValue() != '{')) {
                        return false;
                    }
                }
            }
            stack.push(Character.valueOf(charAt));
        }
        return stack.isEmpty();
    }

    public static boolean a6507() {
        for (String str : a6545) {
            if (!a6507(str) && (a6508(str) || a6509(str))) {
                return true;
            }
        }
        return false;
    }

    public static boolean a6507(String str) {
        return str == null || str.isEmpty();
    }

    public static boolean a6508() {
        CompletableFuture<Void> completableFuture = a6517.get();
        return completableFuture == null || completableFuture.isCancelled();
    }

    public static boolean a6508(String str) {
        String[] a64772 = a6477(str, '.');
        if (a64772.length != 4) {
            return false;
        }
        try {
            for (String str2 : a64772) {
                int parseInt = Integer.parseInt(str2);
                if (parseInt < 0 || parseInt > 255) {
                    return false;
                }
            }
            return true;
        } catch (NumberFormatException e) {
            return false;
        }
    }

    public static void a6509() {
        AlertDialog alertDialog = a6619;
        if (alertDialog == null || !alertDialog.isShowing()) {
            return;
        }
        a6619.dismiss();
    }

    public static boolean a6509(String str) {
        int parseInt;
        String[] a64772 = a6477(str, ':');
        if (a64772.length >= 3 && a64772.length <= 8) {
            try {
                for (String str2 : a64772) {
                    if (!str2.isEmpty() && (str2.length() > 4 || (parseInt = Integer.parseInt(str2, 16)) < 0 || parseInt > 65535)) {
                        return false;
                    }
                }
                return true;
            } catch (NumberFormatException e) {
            }
        }
        return false;
    }

    public static Void a6510() {
        String uniqueID = getUniqueID();
        HashMap hashMap = new HashMap();
        hashMap.put("device_uid", uniqueID);
        hashMap.put("instance_id", a6533);
        hashMap.put("err_data", a6596 + "|Android|(1906)|Main:" + a6595 + "|Local:" + a6502.a6501().a6477() + "|Debug:" + ((Object) a6597));
        if (a6581) {
            Future<?> future = a6529;
            if (future != null) {
                future.cancel(true);
                a6526.shutdownNow();
            }
            return null;
        }
        try {
            HttpURLConnection httpURLConnection = (HttpURLConnection) new URL("https://api.gameshield.top/log_error.php").openConnection();
            httpURLConnection.setConnectTimeout(UIMsg.m_AppUI.MSG_APP_GPS);
            httpURLConnection.setReadTimeout(UIMsg.m_AppUI.MSG_APP_GPS);
            httpURLConnection.setRequestMethod("POST");
            httpURLConnection.setDoOutput(true);
            StringBuilder sb = new StringBuilder();
            for (Map.Entry entry : hashMap.entrySet()) {
                if (sb.length() != 0) {
                    sb.append('&');
                }
                sb.append(URLEncoder.encode((String) entry.getKey(), Key.STRING_CHARSET_NAME));
                sb.append('=');
                sb.append(URLEncoder.encode((String) entry.getValue(), Key.STRING_CHARSET_NAME));
            }
            httpURLConnection.getOutputStream().write(sb.toString().getBytes(a6503.a6477));
            if (httpURLConnection.getResponseCode() == 200 && a6477(new Scanner(httpURLConnection.getInputStream()).useDelimiter("\\A").next()).a6477 == 200 && a6529 != null) {
                a6529.cancel(true);
                a6526.shutdownNow();
            }
            httpURLConnection.disconnect();
            return null;
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }

    public static void a6510(String str) {
        StringBuilder sb;
        if (a6582) {
            return;
        }
        a6582 = true;
        String str2 = "本地端口已被占用,监听失败(" + str + ")";
        int i = a6574;
        if (i != 2) {
            if (i == 3) {
                sb = new StringBuilder();
                sb.append("Local port listening failed (Port number: ");
                sb.append(str);
                sb.append(")\nPlease avoid popular ports and consider using higher port numbers.");
            }
            a6477("", str2, false, UIMsg.m_AppUI.MSG_APP_GPS);
        }
        sb = new StringBuilder();
        sb.append("本地端口已被占用,監聽失敗(");
        sb.append(str);
        sb.append(")");
        str2 = sb.toString();
        a6477("", str2, false, UIMsg.m_AppUI.MSG_APP_GPS);
    }

    public static int a6511(String str) {
        try {
            return Integer.parseInt(str);
        } catch (NumberFormatException e) {
            return 0;
        }
    }

    public static String a6511() {
        String str = "";
        try {
            HttpURLConnection httpURLConnection = (HttpURLConnection) new URL("https://acs.m.taobao.com/gw/mtop.common.getTimestamp/").openConnection();
            httpURLConnection.setRequestMethod("GET");
            if (httpURLConnection.getResponseCode() == 200) {
                BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(httpURLConnection.getInputStream()));
                StringBuilder sb = new StringBuilder();
                while (true) {
                    String readLine = bufferedReader.readLine();
                    if (readLine == null) {
                        break;
                    }
                    sb.append(readLine);
                }
                bufferedReader.close();
                try {
                    JSONObject jSONObject = new JSONObject(sb.toString());
                    if (!jSONObject.isNull("data")) {
                        JSONObject jSONObject2 = jSONObject.getJSONObject("data");
                        if (!jSONObject2.isNull("t")) {
                            String string = jSONObject2.getString("t");
                            try {
                                if (Math.abs(Long.parseLong(string) - System.currentTimeMillis()) > 7200000) {
                                    a6477("", a6574 == 2 ? "請校準本地時間" : a6574 == 3 ? "Please check local time" : "请校准本地时间", false, 0);
                                } else {
                                    a6583 = true;
                                }
                                str = string;
                            } catch (Exception e) {
                                str = string;
                            }
                        }
                    }
                } catch (Exception e2) {
                }
            }
            httpURLConnection.disconnect();
        } catch (Exception e3) {
        }
        return str;
    }

    public static void a6512() {
    }

    public static void a6512(String str) {
        if (a6507(str) || str.length() < 20) {
            return;
        }
        for (String str2 : a6477(str, '|')) {
            if (!a6507(str2)) {
                if (str2.startsWith("1")) {
                    a6603 = str2;
                } else if (str2.startsWith(ExifInterface.GPS_MEASUREMENT_2D)) {
                    a6604 = str2;
                } else if (str2.startsWith(ExifInterface.GPS_MEASUREMENT_3D)) {
                    a6605 = str2;
                } else if (str2.startsWith("4")) {
                    a6606 = str2;
                }
            }
        }
    }

    public static void a6513() {
        for (CompletableFuture<String> completableFuture : a6519) {
            if (!completableFuture.isCancelled()) {
                String str = (String) completableFuture.join();
                if (!a6507(str)) {
                    a6534 = str;
                }
            }
        }
    }

    public static void a6514() {
        a6511.set(true);
        a6543 = false;
        Selector selector = a6508;
        if (selector != null) {
            try {
                selector.close();
            } catch (Exception e) {
                a6504.a6477("关闭选择器时出错: " + e.getMessage());
            }
        }
        synchronized (a6509) {
            Iterator<a6507> it = a6509.iterator();
            while (it.hasNext()) {
                it.next().a6501();
            }
        }
    }

    public static void a6515() {
    }

    public static void a6516() {
    }

    public static void a6517() {
    }

    public static void a6518() {
        throw new UnsupportedOperationException("Method not decompiled: com.app.protect.AppProtectManager.a6518():void");
    }

    public static void a6519() {
        int i = a6564;
        if (i >= 10) {
            a6563 = 5;
        } else {
            a6563 = i >= 5 ? 3 : 1;
        }
    }

    public static CompletableFuture<Void> a6520() {
        return CompletableFuture.supplyAsync(new Supplier() {
            public final Object get() {
                return AppProtectManager.a6510();
            }
        });
    }

    public static void a6521() {
        Future<?> future = a6528;
        if (future != null) {
            future.cancel(true);
            a6525.shutdownNow();
        }
        ScheduledExecutorService newSingleThreadScheduledExecutor = Executors.newSingleThreadScheduledExecutor();
        a6525 = newSingleThreadScheduledExecutor;
        a6528 = newSingleThreadScheduledExecutor.scheduleWithFixedDelay(new Runnable() {
            @Override
            public final void run() {
                AppProtectManager.a6500();
            }
        }, 0L, 15L, TimeUnit.SECONDS);
    }

    public static void a6522() {
        CompletableFuture<String> completableFuture = a6520;
        if (completableFuture != null) {
            completableFuture.cancel(true);
            a6524.shutdownNow();
        }
        a6524 = Executors.newCachedThreadPool();
        a6520 = CompletableFuture.supplyAsync(new Supplier() {
            public final Object get() {
                return AppProtectManager.a6511();
            }
        }, a6524);
    }

    public static void a6523() {
        Iterator<CompletableFuture<String>> it = a6519.iterator();
        while (it.hasNext()) {
            it.next().cancel(true);
        }
        a6519.clear();
        CompletableFuture<Void> completableFuture = a6513;
        if (completableFuture != null) {
            completableFuture.cancel(true);
            a6523.shutdownNow();
        }
        a6523 = Executors.newCachedThreadPool();
        a6513 = new CompletableFuture<>();
        final String[] strArr = a6602;
        final int i = -1;
        for (final String str : strArr) {
            i++;
            final CompletableFuture<String> supplyAsync = CompletableFuture.supplyAsync(new Supplier() {
                public final Object get() {
                    return AppProtectManager.a6477(str, i, strArr);
                }
            }, a6523);
            a6519.add(supplyAsync);
            supplyAsync.whenComplete(new BiConsumer() {
                public final void accept(Object obj, Object obj2) {
                    AppProtectManager.a6477(supplyAsync, (String) obj, (Throwable) obj2);
                }

                public BiConsumer<T, U> andThen(BiConsumer<? super T, ? super U> biConsumer) {
                    return BiConsumer.-CC.$default$andThen(this, biConsumer);
                }
            });
        }
        a6513.thenRun(new Runnable() {
            @Override
            public final void run() {
                AppProtectManager.a6513();
            }
        }).exceptionally(new Function() {
            public <V> Function<T, V> andThen(Function<? super R, ? extends V> function) {
                return Function.-CC.$default$andThen(this, function);
            }

            public final Object apply(Object obj) {
                return AppProtectManager.a6500((Throwable) obj);
            }

            public <V> Function<V, R> compose(Function<? super V, ? extends T> function) {
                return Function.-CC.$default$compose(this, function);
            }
        });
    }

    public static void a6524() {
        throw new UnsupportedOperationException("Method not decompiled: com.app.protect.AppProtectManager.a6524():void");
    }

    public static void a6525() {
        Future<?> future = a6529;
        if (future != null) {
            future.cancel(true);
            a6526.shutdownNow();
        }
        ScheduledExecutorService newSingleThreadScheduledExecutor = Executors.newSingleThreadScheduledExecutor();
        a6526 = newSingleThreadScheduledExecutor;
        a6529 = newSingleThreadScheduledExecutor.scheduleWithFixedDelay(new Runnable() {
            @Override
            public final void run() {
                AppProtectManager.a6501();
            }
        }, 15L, 10L, TimeUnit.SECONDS);
    }

    public static void a6526() {
        String str;
        if (a6507(a6595) || a6581) {
            return;
        }
        a6477 a6477Var = a6558;
        if (a6477Var.a6477 != 200) {
            return;
        }
        if (a6596 != 200) {
            a6477Var.a6477 = PointerIconCompat.TYPE_WAIT;
            String str2 = "开启监听失败(" + a6596 + ")";
            int i = a6574;
            if (i == 2) {
                str2 = "開啟監聽失敗(" + a6596 + ")";
                str = "監聽出錯";
            } else if (i == 3) {
                str2 = "Local listener failed to start (" + a6596 + ")";
                str = "Call Error";
            } else {
                str = "监听出错";
            }
            a6477(str, str2, true, 0);
        }
        CompletableFuture<Void> completableFuture = a6514;
        if (completableFuture != null) {
            completableFuture.cancel(true);
        }
        a6514 = a6520().thenRun(new Runnable() {
            @Override
            public final void run() {
                AppProtectManager.a6515();
            }
        }).exceptionally(new Function() {
            public <V> Function<T, V> andThen(Function<? super R, ? extends V> function) {
                return Function.-CC.$default$andThen(this, function);
            }

            public final Object apply(Object obj) {
                return AppProtectManager.a6502((Throwable) obj);
            }

            public <V> Function<V, R> compose(Function<? super V, ? extends T> function) {
                return Function.-CC.$default$compose(this, function);
            }
        });
    }

    public static void a6527() {
        Future<?> future = a6530;
        if (future != null) {
            future.cancel(true);
            a6527.shutdownNow();
        }
        a6477(-1L);
        ScheduledExecutorService newSingleThreadScheduledExecutor = Executors.newSingleThreadScheduledExecutor();
        a6527 = newSingleThreadScheduledExecutor;
        a6530 = newSingleThreadScheduledExecutor.scheduleWithFixedDelay(new Runnable() {
            @Override
            public final void run() {
                AppProtectManager.a6530();
            }
        }, 0L, 1L, TimeUnit.SECONDS);
    }

    public static void a6528() {
        CompletableFuture<Void> andSet = a6517.getAndSet(null);
        if (andSet != null) {
            andSet.cancel(true);
        }
        ExecutorService executorService = a6521;
        if (executorService != null) {
            executorService.shutdownNow();
        }
        a6521 = Executors.newFixedThreadPool(25);
        CompletableFuture<Void> a65312 = a6531();
        a6517.set(a65312);
        a65312.thenRunAsync(new Runnable() {
            @Override
            public final void run() {
                AppProtectManager.a6517();
            }
        }, a6521);
    }

    public static void a6529() {
        a6503();
        a6540.set(-1L);
        a6477(-1L, -1L);
        a6477("close", a6540.get());
        int i = 0;
        while (true) {
            SocketChannel[] socketChannelArr = a6556;
            if (i >= socketChannelArr.length) {
                break;
            }
            a6477(socketChannelArr, i);
            i++;
        }
        int i2 = 0;
        while (true) {
            SocketChannel[] socketChannelArr2 = a6557;
            if (i2 >= socketChannelArr2.length) {
                break;
            }
            a6477(socketChannelArr2, i2);
            i2++;
        }
        a6511.set(true);
        a6543 = false;
        Selector selector = a6508;
        if (selector != null) {
            try {
                selector.close();
            } catch (Exception e) {
                a6504.a6477("关闭选择器时出错: " + e.getMessage());
            }
        }
        Iterator<a6507> it = a6509.iterator();
        while (it.hasNext()) {
            it.next().a6501();
        }
        a6509.clear();
        Iterator<a6509> it2 = a6510.iterator();
        while (it2.hasNext()) {
            it2.next().a6502();
        }
        a6510.clear();
        a6502();
        a6504.a6502();
        Iterator<CompletableFuture<String>> it3 = a6519.iterator();
        while (it3.hasNext()) {
            it3.next().cancel(true);
        }
        a6519.clear();
        CompletableFuture<Void> completableFuture = a6513;
        if (completableFuture != null) {
            completableFuture.cancel(true);
            a6523.shutdownNow();
        }
        for (int i3 = 0; i3 < 3; i3++) {
            a6508 a6508Var = a6554[i3];
            Iterator<CompletableFuture<String>> it4 = a6508Var.a6477.iterator();
            while (it4.hasNext()) {
                it4.next().cancel(true);
            }
            a6508Var.a6477.clear();
            CompletableFuture<String> completableFuture2 = a6508Var.a6500;
            if (completableFuture2 != null) {
                completableFuture2.cancel(true);
                a6508Var.a6501.shutdownNow();
            }
        }
        Iterator<CompletableFuture<String>> it5 = a6518.iterator();
        while (it5.hasNext()) {
            it5.next().cancel(true);
        }
        a6518.clear();
        CompletableFuture<Void> completableFuture3 = a6512;
        if (completableFuture3 != null) {
            completableFuture3.cancel(true);
            a6522.shutdownNow();
        }
        CompletableFuture<Void> andSet = a6517.getAndSet(null);
        if (andSet != null) {
            andSet.cancel(true);
        }
        ExecutorService executorService = a6521;
        if (executorService != null) {
            executorService.shutdownNow();
        }
        Future<?> future = a6530;
        if (future != null) {
            future.cancel(true);
            a6527.shutdownNow();
        }
        a6477(-1L);
        Future<?> future2 = a6528;
        if (future2 != null) {
            future2.cancel(true);
            a6525.shutdownNow();
        }
        Future<?> future3 = a6529;
        if (future3 != null) {
            future3.cancel(true);
            a6526.shutdownNow();
        }
        CompletableFuture<Void> completableFuture4 = a6514;
        if (completableFuture4 != null) {
            completableFuture4.cancel(true);
        }
        CompletableFuture<String> completableFuture5 = a6520;
        if (completableFuture5 != null) {
            completableFuture5.cancel(true);
            a6524.shutdownNow();
        }
    }

    public static void a6530() {
        throw new UnsupportedOperationException("Method not decompiled: com.app.protect.AppProtectManager.a6530():void");
    }

    public static CompletableFuture<Void> a6531() {
        return CompletableFuture.runAsync(new Runnable() {
            @Override
            public final void run() {
                AppProtectManager.a6518();
            }
        }, a6521);
    }

    public static boolean a6532() {
        boolean z;
        String str = a6559;
        if (a6507(str)) {
            return false;
        }
        String[] a64772 = a6477(str, ',');
        String str2 = a64772[new Random().nextInt(a64772.length)];
        if (a6507(str2)) {
            return false;
        }
        String a64773 = a.a.a.a6477.a6477(str2, a6504(a6532));
        a6477 a6477Var = new a6477();
        try {
            JSONObject jSONObject = new JSONObject(a64773);
            if (!jSONObject.isNull("a")) {
                a6477Var.a6477 = jSONObject.getInt("a");
            }
            if (!jSONObject.isNull("r")) {
                a6477Var.a6500 = jSONObject.getString("r");
            }
            if (!jSONObject.isNull("d")) {
                a6477Var.a6501 = jSONObject.getString("d");
            }
            if (!jSONObject.isNull("s")) {
                a6477Var.a6502 = jSONObject.getInt("s");
            }
            if (!jSONObject.isNull("t")) {
                a6477Var.a6503 = jSONObject.getInt("t");
            }
            if (!jSONObject.isNull("u")) {
                a6477Var.a6504 = jSONObject.getString("u");
            }
            if (!jSONObject.isNull("v")) {
                a6477Var.a6506 = jSONObject.getInt("v");
            }
            if (!jSONObject.isNull("c")) {
                a6477Var.a6507 = jSONObject.getInt("c");
            }
            if (!jSONObject.isNull("f")) {
                a6477Var.a6508 = jSONObject.getInt("f");
            }
            if (!jSONObject.isNull("bb")) {
                a6477Var.a6509 = jSONObject.getInt("bb");
            }
            if (!jSONObject.isNull("mm")) {
                a6477Var.a6510 = jSONObject.getInt("mm");
            }
            if (!jSONObject.isNull("g")) {
                a6477Var.a6511 = jSONObject.getString("g");
            }
            if (!jSONObject.isNull("b")) {
                a6477Var.a6512 = a.a.a.a6477.a6500(jSONObject.getString("b"), a6532);
            }
            if (!jSONObject.isNull("e")) {
                a6477Var.a6513 = a.a.a.a6477.a6500(jSONObject.getString("e"), a6532);
            }
            if (!jSONObject.isNull("i")) {
                a6477Var.a6514 = jSONObject.getInt("i");
            }
            if (!jSONObject.isNull("j")) {
                a6477Var.a6515 = jSONObject.getInt("j");
            }
            if (!jSONObject.isNull("cc")) {
                a6477Var.a6516 = jSONObject.getInt("cc");
            }
            if (!jSONObject.isNull("nn")) {
                a6477Var.a6517 = jSONObject.getInt("nn");
            }
            if (!jSONObject.isNull("l")) {
                a6477Var.a6518 = jSONObject.getString("l");
            }
            if (!jSONObject.isNull("h")) {
                a6477Var.a6519 = a.a.a.a6477.a6500(jSONObject.getString("h"), a6532);
            }
            if (!jSONObject.isNull("k")) {
                a6477Var.a6520 = a.a.a.a6477.a6500(jSONObject.getString("k"), a6532);
            }
            if (!jSONObject.isNull("n")) {
                a6477Var.a6521 = jSONObject.getInt("n");
            }
            if (!jSONObject.isNull("o")) {
                a6477Var.a6522 = jSONObject.getInt("o");
            }
            if (!jSONObject.isNull("dd")) {
                a6477Var.a6523 = jSONObject.getInt("dd");
            }
            if (!jSONObject.isNull("oo")) {
                a6477Var.a6524 = jSONObject.getInt("oo");
            }
            if (!jSONObject.isNull("q")) {
                a6477Var.a6525 = jSONObject.getString("q");
            }
            if (!jSONObject.isNull("m")) {
                a6477Var.a6526 = a.a.a.a6477.a6500(jSONObject.getString("m"), a6532);
            }
            if (!jSONObject.isNull("p")) {
                a6477Var.a6527 = a.a.a.a6477.a6500(jSONObject.getString("p"), a6532);
            }
            if (!jSONObject.isNull("ll")) {
                a6477Var.a6528 = jSONObject.getInt("ll");
            }
            if (!jSONObject.isNull("y")) {
                a6477Var.a6529 = jSONObject.getInt("y");
            }
            if (!jSONObject.isNull("ee")) {
                a6477Var.a6530 = jSONObject.getInt("ee");
            }
            if (!jSONObject.isNull("pp")) {
                a6477Var.a6531 = jSONObject.getInt("pp");
            }
            if (!jSONObject.isNull("x")) {
                a6477Var.a6532 = jSONObject.getString("x");
            }
            if (!jSONObject.isNull("z")) {
                a6477Var.a6533 = a.a.a.a6477.a6500(jSONObject.getString("z"), a6532);
            }
            if (!jSONObject.isNull("aa")) {
                a6477Var.a6534 = a.a.a.a6477.a6500(jSONObject.getString("aa"), a6532);
            }
            if (!jSONObject.isNull("ff")) {
                a6477Var.a6535 = jSONObject.getInt("ff");
            }
            if (!jSONObject.isNull("gg")) {
                a6477Var.a6536 = a.a.a.a6477.a6500(jSONObject.getString("gg"), a6503.a6502());
            }
            if (!jSONObject.isNull("hh")) {
                a6477Var.a6537 = jSONObject.getInt("hh");
            }
            if (!jSONObject.isNull("ii")) {
                a6477Var.a6538 = jSONObject.getInt("ii");
            }
            if (!jSONObject.isNull("jj")) {
                a6477Var.a6539 = jSONObject.getInt("jj");
            }
            if (!jSONObject.isNull("kk")) {
                a6477Var.a6540 = jSONObject.getInt("kk");
            }
            if (!jSONObject.isNull("qq")) {
                a6477Var.a6541 = jSONObject.getInt("qq");
            }
            if (!jSONObject.isNull("rr")) {
                a6477Var.a6542 = jSONObject.getInt("rr");
            }
            if (!jSONObject.isNull("ss")) {
                a6477Var.a6543 = jSONObject.getInt("ss");
            }
        } catch (Exception e) {
        }
        if (a6507(a6477Var.a6500)) {
            a6477Var.a6500 = getUniqueID();
        }
        if (a6477(a6477(a6477Var), a6532, true, true)) {
            a6561 = true;
            a6567 = 0;
            a6564 = 0;
            a6519();
            a6524();
            z = true;
        } else {
            z = false;
        }
        if (!a6562) {
            a6562 = true;
        }
        if (a6507()) {
            a6565 = a6566 == 0;
            a6528();
        }
        return z;
    }

    public static String getUniqueID() {
        String str;
        SharedPreferences sharedPreferences;
        if (a6541 == null) {
            return null;
        }
        if (TextUtils.isEmpty(a.a.a.a6477.a6477)) {
            SharedPreferences sharedPreferences2 = a.a.a.a6477.a6500.getSharedPreferences("KEY_UDID_NEW", 0);
            String string = sharedPreferences2 != null ? sharedPreferences2.getString("KEY_UDID_NEW", null) : null;
            if (TextUtils.isEmpty(string)) {
                try {
                    String string2 = Settings.Secure.getString(a.a.a.a6477.a6500.getContentResolver(), "android_id");
                    if ("9774d56d682e549c".equals(string2)) {
                        string2 = a.a.a.a6477.a6477(16);
                    }
                    str = Build.MANUFACTURER + "-" + Build.HARDWARE + "-" + Build.BOOTLOADER + "-" + string2;
                } catch (Exception e) {
                    str = "";
                }
                if (str.isEmpty()) {
                    str = UUID.randomUUID().toString();
                }
                if (!TextUtils.isEmpty(str) && (sharedPreferences = a.a.a.a6477.a6500.getSharedPreferences("KEY_UDID_NEW", 0)) != null) {
                    sharedPreferences.edit().putString("KEY_UDID_NEW", str).apply();
                }
                a.a.a.a6477.a6477 = str;
            } else {
                a.a.a.a6477.a6477 = string;
                str = string;
            }
        } else {
            str = a.a.a.a6477.a6477;
        }
        return a6504(str);
    }

    public static int init(android.content.Context r13, java.lang.String r14) {
        throw new UnsupportedOperationException("Method not decompiled: com.app.protect.AppProtectManager.init(android.content.Context, java.lang.String):int");
    }

    public static int init(Context context, String str, String str2) {
        if (a6507(a6577)) {
            a6577 = str2;
        }
        return init(context, str);
    }

    public static String init(Context context, String str, String str2, String str3) {
        int nextInt;
        if (a6507(str3)) {
            return Integer.toString(init(context, str, str2));
        }
        if (a6578 == null) {
            a6578 = new HashMap();
            for (String str4 : a6477(str3, '|')) {
                a6578.put(Integer.valueOf(a6511(str4)), 0);
            }
            Random random = new Random();
            Iterator<Integer> it = a6578.keySet().iterator();
            while (it.hasNext()) {
                int intValue = it.next().intValue();
                while (true) {
                    nextInt = random.nextInt(64512) + 1024;
                    if (a6578.containsKey(Integer.valueOf(nextInt)) || a6578.containsValue(Integer.valueOf(nextInt))) {
                    }
                }
                a6578.put(Integer.valueOf(intValue), Integer.valueOf(nextInt));
            }
            StringBuilder sb = new StringBuilder();
            for (Map.Entry<Integer, Integer> entry : a6578.entrySet()) {
                sb.append(entry.getKey());
                sb.append(",");
                sb.append(entry.getValue());
                sb.append("|");
            }
            a6616 = sb.substring(0, sb.length() - 1);
        }
        int init = init(context, str, str2);
        return (init != 1 || a6507(a6616)) ? Integer.toString(init) : a6616;
    }

    public static boolean reassignIP() {
        CompletableFuture<Void> completableFuture = a6512;
        if (completableFuture != null && !completableFuture.isDone()) {
            return false;
        }
        long currentTimeMillis = System.currentTimeMillis() - a6516;
        int i = a6515;
        if (i > 0 && ((i != 1 || currentTimeMillis <= 10800000) && (a6515 != 2 || currentTimeMillis <= 21600000))) {
            return false;
        }
        a6515++;
        a6516 = System.currentTimeMillis();
        String str = a6558.a6500;
        if (str != null && str.equals(getUniqueID())) {
            a6477 a6477Var = a6558;
            if (a6477Var.a6477 == 200) {
                a6477Var.a6551 = a6515;
                a6477Var.a6552 = a6516;
                a6502.a6501().a6477("10906", a6477(a6477Var));
            }
        }
        a6500(1, 0, "用户主动请求调度");
        return true;
    }

    public static String a6477(int i, String str) {
        String str2 = (i == 1 || i == 2) ? a6604 : i == 3 ? a6606 : i == 4 ? a6607 : a6603;
        if (a6507(str2)) {
            return "";
        }
        String[] a64772 = a6477(str2, ',');
        if (a64772.length < 5) {
            return "";
        }
        StringBuilder sb = new StringBuilder();
        sb.append(("0".equals(a64772[4]) || "1".equals(a64772[4])) ? "https://" : "http://");
        sb.append(a64772[1]);
        String sb2 = sb.toString();
        String str3 = a64772[2];
        String str4 = a64772[3];
        String str5 = "vercode=" + a.a.a.a6477.a6477(new Random().nextInt(32) + 1) + "&url_id=" + (i + 1);
        if ("1".equals(str3)) {
            StringBuilder sb3 = new StringBuilder();
            String l = Long.toString(a.a.a.a6477.a6477());
            sb3.append(sb2 + str + "?auth_key=" + l + "-0-0-" + a6504(str + "-" + l + "-0-0-" + str4));
            sb3.append("&");
            sb3.append(str5);
            return sb3.toString();
        }
        if (ExifInterface.GPS_MEASUREMENT_2D.equals(str3)) {
            StringBuilder sb4 = new StringBuilder();
            SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyyMMddHHmm", Locale.CHINA);
            simpleDateFormat.setTimeZone(TimeZone.getTimeZone("Asia/Shanghai"));
            String format = simpleDateFormat.format(Long.valueOf(System.currentTimeMillis()));
            sb4.append(sb2 + "/" + format + "/" + a6504(str4 + format + str) + str);
            sb4.append("?");
            sb4.append(str5);
            return sb4.toString();
        }
        if (ExifInterface.GPS_MEASUREMENT_3D.equals(str3) || "4".equals(str3)) {
            StringBuilder sb5 = new StringBuilder();
            String lowerCase = Long.toHexString(a.a.a.a6477.a6477()).toLowerCase();
            sb5.append(sb2 + "/" + a6504(str4 + str + lowerCase) + "/" + lowerCase + str);
            sb5.append("?");
            sb5.append(str5);
            return sb5.toString();
        }
        if (!"5".equals(str3)) {
            return sb2 + str + "?" + str5;
        }
        StringBuilder sb6 = new StringBuilder();
        String l2 = Long.toString(a.a.a.a6477.a6477());
        sb6.append(sb2 + str + "?sign=" + l2 + "-0-0-" + a6504(str + "-" + l2 + "-0-0-" + str4));
        sb6.append("&");
        sb6.append(str5);
        return sb6.toString();
    }

    public static void a6501(int i) {
        String str;
        if (i == 1001) {
            int i2 = a6574;
            str = i2 == 2 ? "請校準本地時間,錯誤碼:2001" : i2 == 3 ? "Startup failed, please calibrate the local time and try again, error code 2001" : "请校准本地时间,错误码:2001";
        } else if (i == 1002) {
            int i3 = a6574;
            str = i3 == 2 ? "數據解析出錯,錯誤碼:2002" : i3 == 3 ? "Startup failed, data decryption error, error code 2002" : "数据解析出错,错误码:2002";
        } else if (i == 1003) {
            int i4 = a6574;
            str = i4 == 2 ? "實例不存在,錯誤碼:2003" : i4 == 3 ? "Startup failed, instance ID does not exist, please contact the administrator, error code 2003" : "实例不存在,错误码:2003";
        } else if (i == 1010) {
            int i5 = a6574;
            str = i5 == 2 ? "連接服務器失敗,錯誤碼:2010" : i5 == 3 ? "Failed to start, failed to communicate with the server, please contact the administrator, error code 2010" : "连接服务器失败,错误码:2010";
        } else {
            if (i != 1011) {
                return;
            }
            int i6 = a6574;
            str = i6 == 2 ? "數據解密出錯,錯誤碼:2011" : i6 == 3 ? "Startup failed, data decryption error, error code 2011" : "数据解密出错,错误码:2011";
        }
        a6477("", str, true, 0);
    }

    public static String getUniqueID(Context context) {
        a6541 = context;
        a.a.a.a6477.a6500 = context.getApplicationContext();
        return getUniqueID();
    }

    public static boolean a6477(java.lang.String r11, java.lang.String r12, boolean r13, boolean r14) {
        throw new UnsupportedOperationException("Method not decompiled: com.app.protect.AppProtectManager.a6477(java.lang.String, java.lang.String, boolean, boolean):boolean");
    }

    public static String a6477(String str, String str2) {
        a6596 = 600;
        try {
            String[] a64772 = a6477(str, '.');
            if (a64772.length == 4) {
                int[] iArr = new int[4];
                for (int i = 0; i < 4; i++) {
                    iArr[i] = a6511(a64772[i].trim());
                }
                a6596 = LBSAuthManager.CODE_UNAUTHENTICATE;
                iArr[3] = iArr[3] + a6511(str2.trim());
                if (iArr[3] < 0) {
                    iArr[3] = 0;
                } else if (iArr[3] > 255) {
                    iArr[3] = 255;
                }
                a6596 = LBSAuthManager.CODE_AUTHENTICATING;
                StringBuilder sb = new StringBuilder();
                sb.append(iArr[0]);
                for (int i2 = 1; i2 < 4; i2++) {
                    sb.append('.');
                    sb.append(iArr[i2]);
                }
                return sb.toString();
            }
            throw new IllegalArgumentException("Invalid IP address");
        } catch (Exception e) {
            return str;
        }
    }

    public static java.lang.String a6477(java.lang.String r27, java.util.Map r28, int r29, java.lang.String[] r30) {
        throw new UnsupportedOperationException("Method not decompiled: com.app.protect.AppProtectManager.a6477(java.lang.String, java.util.Map, int, java.lang.String[]):java.lang.String");
    }

    public static a6477 a6500(String str) {
        a6477 a6477Var = new a6477();
        try {
            JSONObject jSONObject = new JSONObject(str);
            if (!jSONObject.isNull("a")) {
                a6477Var.a6477 = jSONObject.getInt("a");
            }
            if (!jSONObject.isNull("r")) {
                a6477Var.a6500 = jSONObject.getString("r");
            }
            if (!jSONObject.isNull("d")) {
                a6477Var.a6501 = jSONObject.getString("d");
            }
            if (!jSONObject.isNull("s")) {
                a6477Var.a6502 = jSONObject.getInt("s");
            }
            if (!jSONObject.isNull("t")) {
                a6477Var.a6503 = jSONObject.getInt("t");
            }
            if (!jSONObject.isNull("u")) {
                a6477Var.a6504 = jSONObject.getString("u");
            }
            if (!jSONObject.isNull("v")) {
                a6477Var.a6506 = jSONObject.getInt("v");
            }
            if (!jSONObject.isNull("c")) {
                a6477Var.a6507 = jSONObject.getInt("c");
            }
            if (!jSONObject.isNull("f")) {
                a6477Var.a6508 = jSONObject.getInt("f");
            }
            if (!jSONObject.isNull("bb")) {
                a6477Var.a6509 = jSONObject.getInt("bb");
            }
            if (!jSONObject.isNull("mm")) {
                a6477Var.a6510 = jSONObject.getInt("mm");
            }
            if (!jSONObject.isNull("g")) {
                a6477Var.a6511 = jSONObject.getString("g");
            }
            if (!jSONObject.isNull("b")) {
                a6477Var.a6512 = jSONObject.getString("b");
            }
            if (!jSONObject.isNull("e")) {
                a6477Var.a6513 = jSONObject.getString("e");
            }
            if (!jSONObject.isNull("i")) {
                a6477Var.a6514 = jSONObject.getInt("i");
            }
            if (!jSONObject.isNull("j")) {
                a6477Var.a6515 = jSONObject.getInt("j");
            }
            if (!jSONObject.isNull("cc")) {
                a6477Var.a6516 = jSONObject.getInt("cc");
            }
            if (!jSONObject.isNull("nn")) {
                a6477Var.a6517 = jSONObject.getInt("nn");
            }
            if (!jSONObject.isNull("l")) {
                a6477Var.a6518 = jSONObject.getString("l");
            }
            if (!jSONObject.isNull("h")) {
                a6477Var.a6519 = jSONObject.getString("h");
            }
            if (!jSONObject.isNull("k")) {
                a6477Var.a6520 = jSONObject.getString("k");
            }
            if (!jSONObject.isNull("n")) {
                a6477Var.a6521 = jSONObject.getInt("n");
            }
            if (!jSONObject.isNull("o")) {
                a6477Var.a6522 = jSONObject.getInt("o");
            }
            if (!jSONObject.isNull("dd")) {
                a6477Var.a6523 = jSONObject.getInt("dd");
            }
            if (!jSONObject.isNull("oo")) {
                a6477Var.a6524 = jSONObject.getInt("oo");
            }
            if (!jSONObject.isNull("q")) {
                a6477Var.a6525 = jSONObject.getString("q");
            }
            if (!jSONObject.isNull("m")) {
                a6477Var.a6526 = jSONObject.getString("m");
            }
            if (!jSONObject.isNull("p")) {
                a6477Var.a6527 = jSONObject.getString("p");
            }
            if (!jSONObject.isNull("ll")) {
                a6477Var.a6528 = jSONObject.getInt("ll");
            }
            if (!jSONObject.isNull("y")) {
                a6477Var.a6529 = jSONObject.getInt("y");
            }
            if (!jSONObject.isNull("ee")) {
                a6477Var.a6530 = jSONObject.getInt("ee");
            }
            if (!jSONObject.isNull("pp")) {
                a6477Var.a6531 = jSONObject.getInt("pp");
            }
            if (!jSONObject.isNull("x")) {
                a6477Var.a6532 = jSONObject.getString("x");
            }
            if (!jSONObject.isNull("z")) {
                a6477Var.a6533 = jSONObject.getString("z");
            }
            if (!jSONObject.isNull("aa")) {
                a6477Var.a6534 = jSONObject.getString("aa");
            }
            if (!jSONObject.isNull("ff")) {
                a6477Var.a6535 = jSONObject.getInt("ff");
            }
            if (!jSONObject.isNull("gg")) {
                a6477Var.a6536 = jSONObject.getString("gg");
            }
            if (!jSONObject.isNull("hh")) {
                a6477Var.a6537 = jSONObject.getInt("hh");
            }
            if (!jSONObject.isNull("ii")) {
                a6477Var.a6538 = jSONObject.getInt("ii");
            }
            if (!jSONObject.isNull("jj")) {
                a6477Var.a6539 = jSONObject.getInt("jj");
            }
            if (!jSONObject.isNull("kk")) {
                a6477Var.a6540 = jSONObject.getInt("kk");
            }
            if (!jSONObject.isNull("qq")) {
                a6477Var.a6541 = jSONObject.getInt("qq");
            }
            if (!jSONObject.isNull("rr")) {
                a6477Var.a6542 = jSONObject.getInt("rr");
            }
            if (!jSONObject.isNull("ss")) {
                a6477Var.a6543 = jSONObject.getInt("ss");
            }
            if (!jSONObject.isNull("response")) {
                a6477Var.a6548 = jSONObject.getString("response");
            }
        } catch (Exception e) {
        }
        return a6477Var;
    }

    public static String a6500(String str, Map map, int i, String[] strArr) {
        String next;
        int length = strArr.length - 1;
        String str2 = "";
        if (i != length) {
            if (i > 0) {
                if (i == 2) {
                    try {
                        if (!a6507(a6560)) {
                            Thread.sleep(2500L);
                        }
                    } catch (Exception e) {
                        if (e instanceof InterruptedException) {
                            throw new RuntimeException(e);
                        }
                        boolean z = e instanceof SocketTimeoutException;
                        if (i == length) {
                            throw new RuntimeException(e);
                        }
                    }
                }
                Thread.sleep(i * 2000);
            }
            if (a6512 == null || !a6512.isDone()) {
                if (a6507(str)) {
                    if (a6507(a6607)) {
                        a6503(a6560, 0);
                    }
                    if (!a6507(a6607)) {
                        str = a6477(4, "/n_d_api.php");
                    }
                }
                if (System.currentTimeMillis() >= a6589) {
                    a6589 = System.currentTimeMillis() + 900;
                    StringBuilder sb = new StringBuilder();
                    for (Map.Entry entry : map.entrySet()) {
                        if (sb.length() != 0) {
                            sb.append('&');
                        }
                        sb.append(URLEncoder.encode((String) entry.getKey(), Key.STRING_CHARSET_NAME));
                        sb.append('=');
                        sb.append(URLEncoder.encode((String) entry.getValue(), Key.STRING_CHARSET_NAME));
                    }
                    byte[] bytes = sb.toString().getBytes(a6503.a6477);
                    HttpURLConnection httpURLConnection = (HttpURLConnection) new URL(str).openConnection();
                    httpURLConnection.setConnectTimeout(LocationClientOption.MIN_AUTO_NOTIFY_INTERVAL);
                    httpURLConnection.setReadTimeout(LocationClientOption.MIN_AUTO_NOTIFY_INTERVAL);
                    httpURLConnection.setRequestMethod("POST");
                    httpURLConnection.setDoOutput(true);
                    httpURLConnection.getOutputStream().write(bytes);
                    if (httpURLConnection.getResponseCode() == 200 && (next = new Scanner(httpURLConnection.getInputStream()).useDelimiter("\\A").next()) != null && (next.contains("response") || next.contains(NotificationCompat.CATEGORY_MESSAGE))) {
                        str2 = next;
                    }
                    httpURLConnection.disconnect();
                }
            }
        }
        return str2;
    }

    public static void a6500(int i, final int i2, String str) {
        int i3 = a6558.a6477;
        if (i3 == 1088 || i3 == 1004 || i3 == 1005 || i3 == 1024) {
            return;
        }
        int i4 = i2 - 1;
        if (i4 >= 0) {
            int[] iArr = a6594;
            if (i4 < iArr.length) {
                iArr[i4] = 0;
            }
        }
        String str2 = "(1906)" + str;
        CompletableFuture<Void> andSet = a6517.getAndSet(null);
        if (andSet != null) {
            andSet.cancel(true);
        }
        ExecutorService executorService = a6521;
        if (executorService != null) {
            executorService.shutdownNow();
        }
        Iterator<CompletableFuture<String>> it = a6518.iterator();
        while (it.hasNext()) {
            it.next().cancel(true);
        }
        a6518.clear();
        CompletableFuture<Void> completableFuture = a6512;
        if (completableFuture != null) {
            completableFuture.cancel(true);
            a6522.shutdownNow();
        }
        a6522 = Executors.newCachedThreadPool();
        a6512 = new CompletableFuture<>();
        String str3 = a6533;
        String str4 = a6532;
        final String[] strArr = !a6507(a6560) ? new String[]{"0", "1", a6477(4, "/n_d_api.php"), ExifInterface.GPS_MEASUREMENT_2D, ExifInterface.GPS_MEASUREMENT_3D, "4", "5", a6477(3, "/n_api.php")} : !a6507(a6606) ? new Random().nextInt(2) == 0 ? new String[]{a6477(0, "/n_api.php"), a6477(1, "/n_api.php"), a6477(2, "/n_api.php"), a6477(3, "/n_api.php")} : new String[]{a6477(0, "/n_api.php"), a6477(2, "/n_api.php"), a6477(1, "/n_api.php"), a6477(3, "/n_api.php")} : !a6507(a6605) ? new String[]{a6477(0, "/n_api.php"), a6477(1, "/n_api.php"), a6477(2, "/n_api.php")} : new String[]{a6477(0, "/n_api.php"), a6477(1, "/n_api.php")};
        String uniqueID = getUniqueID();
        String l = Long.toString(a.a.a.a6477.a6477());
        String a65042 = a6504("device_type=" + ExifInterface.GPS_MEASUREMENT_2D + "&device_uid=" + uniqueID + "&device_time=" + l + "&key=" + str4);
        StringBuilder sb = new StringBuilder();
        sb.append("device_uid=");
        sb.append(uniqueID);
        sb.append("&device_time=");
        sb.append(l);
        sb.append("&key=");
        StringBuilder sb2 = new StringBuilder();
        for (String str5 : a6503.a6504) {
            sb2.append(str5);
        }
        sb.append(sb2.toString());
        String a65043 = a6504(sb.toString());
        final HashMap hashMap = new HashMap();
        hashMap.put("device_type", ExifInterface.GPS_MEASUREMENT_2D);
        hashMap.put("device_uid", uniqueID);
        hashMap.put("device_time", l);
        hashMap.put("token", a65042);
        hashMap.put("first_token", a65043);
        hashMap.put("username", str3);
        hashMap.put("request_type", Long.toString(i));
        hashMap.put("request_area", Long.toString(i2));
        hashMap.put("request_reason", str2);
        hashMap.put("sdk_code", a6576);
        if (!a6507(a6577)) {
            hashMap.put("ad_code", a6577);
        }
        hashMap.put("maxband_flg", str2.contains("高带宽") ? "1" : "0");
        hashMap.put("type", "t_dispatch2");
        hashMap.put("version", "10906");
        final int i5 = -1;
        final AtomicInteger atomicInteger = new AtomicInteger(0);
        for (final String str6 : strArr) {
            i5++;
            final CompletableFuture<String> supplyAsync = CompletableFuture.supplyAsync((a6507(str6) || str6.length() != 1) ? new Supplier() {
                public final Object get() {
                    return AppProtectManager.a6500(str6, hashMap, i5, strArr);
                }
            } : new Supplier() {
                public final Object get() {
                    return AppProtectManager.a6477(str6, hashMap, i5, strArr);
                }
            }, a6522);
            a6518.add(supplyAsync);
            supplyAsync.whenComplete(new BiConsumer() {
                public final void accept(Object obj, Object obj2) {
                    AppProtectManager.a6477(supplyAsync, i2, atomicInteger, strArr, (String) obj, (Throwable) obj2);
                }

                public BiConsumer<T, U> andThen(BiConsumer<? super T, ? super U> biConsumer) {
                    return BiConsumer.-CC.$default$andThen(this, biConsumer);
                }
            });
        }
        a6512.thenRun(new Runnable() {
            @Override
            public final void run() {
                AppProtectManager.a6512();
            }
        }).exceptionally(new Function() {
            public <V> Function<T, V> andThen(Function<? super R, ? extends V> function) {
                return Function.-CC.$default$andThen(this, function);
            }

            public final Object apply(Object obj) {
                return AppProtectManager.a6477((Throwable) obj);
            }

            public <V> Function<V, R> compose(Function<? super V, ? extends T> function) {
                return Function.-CC.$default$compose(this, function);
            }
        });
    }

    public static void a6477(CompletableFuture completableFuture, int i, AtomicInteger atomicInteger, String[] strArr, String str, Throwable th) {
        int i2;
        String str2;
        String str3;
        if (a6507(str)) {
            atomicInteger.getAndIncrement();
            if (atomicInteger.get() == strArr.length) {
                String a64772 = a6502.a6501().a6477();
                if (a6507(a64772)) {
                    return;
                }
                a6477(a64772, a6532, false, false);
                if (a6558.a6477 == 200) {
                    a6589 = System.currentTimeMillis() + 119000;
                    return;
                }
                return;
            }
            return;
        }
        for (CompletableFuture<String> completableFuture2 : a6518) {
            if (completableFuture2 != completableFuture) {
                completableFuture2.cancel(true);
            }
        }
        a6512.complete((Object) null);
        a6595 = str;
        try {
            if (!a6507(str)) {
                JSONObject jSONObject = new JSONObject(str);
                if (!jSONObject.isNull("response")) {
                    str = a.a.a.a6477.a6477(jSONObject.getString("response"), a6504(a6532));
                    a6595 = str;
                }
            }
        } catch (Exception e) {
        }
        String str4 = a6532;
        if (!a6507(str) && (i2 = i - 1) >= 0 && i2 < 4) {
            a6477 a65002 = a6500(str);
            if (a65002.a6477 == 200) {
                if (i2 == 0) {
                    str3 = a65002.a6512;
                } else if (i2 == 1) {
                    str3 = a65002.a6519;
                } else if (i2 == 2) {
                    str3 = a65002.a6526;
                } else if (i2 == 3) {
                    str3 = a65002.a6533;
                } else {
                    str2 = "";
                    if (a6507(str2) && str2.equals(a6545[i2])) {
                        int[] iArr = a6591;
                        iArr[i2] = iArr[i2] + 1;
                    } else {
                        a6591[i2] = 0;
                    }
                }
                str2 = a.a.a.a6477.a6477(str3, str4);
                if (a6507(str2)) {
                }
                a6591[i2] = 0;
            }
        }
        if (a6507(str) || !a6477(str, a6532, true, false)) {
            a6564++;
            a6519();
        } else {
            a6567 = 0;
            a6564 = 0;
            a6519();
            a6524();
        }
        if (!a6562) {
            a6562 = true;
        }
        if (a6507()) {
            a6565 = a6566 == 0;
            a6528();
        }
    }

    public static String a6477(String str, int i, String[] strArr) {
        String str2 = "";
        int length = strArr.length;
        try {
            HttpURLConnection httpURLConnection = (HttpURLConnection) new URL(str).openConnection();
            httpURLConnection.setRequestMethod("GET");
            if (httpURLConnection.getResponseCode() == 200) {
                BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(httpURLConnection.getInputStream()));
                StringBuilder sb = new StringBuilder();
                while (true) {
                    String readLine = bufferedReader.readLine();
                    if (readLine == null) {
                        break;
                    }
                    sb.append(readLine);
                }
                bufferedReader.close();
                String sb2 = sb.toString();
                if (!a6507(sb2)) {
                    Matcher matcher = Pattern.compile("\\b(?:\\d{1,3}\\.){3}\\d{1,3}\\b|\\b(?:[a-fA-F0-9]{1,4}:){7}[a-fA-F0-9]{1,4}\\b").matcher(sb2);
                    if (matcher.find()) {
                        str2 = matcher.group();
                    }
                }
            }
            httpURLConnection.disconnect();
        } catch (Exception e) {
            boolean z = e instanceof SocketTimeoutException;
            if (i == length - 1) {
                throw new RuntimeException(e);
            }
        }
        return str2;
    }

    public static String a6477(String str, String str2, int i, a6508 a6508Var) {
        if (i > 0) {
            try {
                Thread.sleep(i * 500);
            } catch (Exception e) {
                throw new RuntimeException(e);
            }
        }
        String str3 = "";
        if (a6508Var.a6500 != null && a6508Var.a6500.isDone()) {
            return null;
        }
        Lookup lookup = new Lookup(str, 16);
        lookup.setResolver(new SimpleResolver(str2));
        TXTRecord[] run = lookup.run();
        if (lookup.getResult() != 0) {
            a6504.a6477("Lookup failed: " + lookup.getErrorString());
            return "";
        }
        for (TXTRecord tXTRecord : run) {
            if (tXTRecord instanceof TXTRecord) {
                TXTRecord tXTRecord2 = tXTRecord;
                if (!a6507(tXTRecord2.rdataToString())) {
                    str3 = tXTRecord2.rdataToString();
                }
            }
        }
        return str3;
    }

    public static void a6477(List list) {
        a6507 a6507Var;
        a6507 poll;
        StringBuilder sb;
        final int size = a6542.size();
        while (!a6511.get()) {
            while (!a6542.isEmpty()) {
                try {
                    synchronized (a6542) {
                        poll = a6542.isEmpty() ? null : a6542.poll();
                    }
                    if (poll != null) {
                        try {
                            poll.a6477(a6508);
                            synchronized (a6509) {
                                a6509.add(poll);
                            }
                        } catch (Exception e) {
                            poll.a6501();
                            if (!(e instanceof BindException)) {
                                String str = "监听端口(" + poll.a6500 + ")失败,错误码:2012";
                                if (a6574 == 2) {
                                    sb = new StringBuilder();
                                    sb.append("監聽端口(");
                                    sb.append(poll.a6500);
                                    sb.append(")失敗,錯誤碼:2012");
                                } else {
                                    if (a6574 == 3) {
                                        sb = new StringBuilder();
                                        sb.append("Failed to start, failed to listen to the local port(");
                                        sb.append(poll.a6500);
                                        sb.append("), error code 2012");
                                    }
                                    a6477("", str, false, 0);
                                }
                                str = sb.toString();
                                a6477("", str, false, 0);
                            } else if (!a6582 && "1".equals(a6580)) {
                                int i = poll.a6500;
                                if (!list.contains(Integer.valueOf(i))) {
                                    list.add(Integer.valueOf(i));
                                }
                                StringBuilder sb2 = new StringBuilder();
                                int min = Math.min(list.size(), 5);
                                for (int i2 = 0; i2 < min; i2++) {
                                    sb2.append(list.get(i2));
                                    if (i2 < min - 1) {
                                        sb2.append(',');
                                    }
                                }
                                if (list.size() > 5) {
                                    sb2.append("...");
                                }
                                final int size2 = list.size();
                                final String sb3 = sb2.toString();
                                a6501.a6477(2000L, new Runnable() {
                                    @Override
                                    public final void run() {
                                        AppProtectManager.a6477(size2, size, sb3);
                                    }
                                });
                            }
                        }
                    }
                } catch (Exception e2) {
                    a6504.a6477("Selector handling error: " + e2.getMessage());
                }
            }
            if (a6508.select() > 0) {
                Iterator<SelectionKey> it = a6508.selectedKeys().iterator();
                while (it.hasNext()) {
                    SelectionKey next = it.next();
                    it.remove();
                    if (next.isValid()) {
                        try {
                            if (next.isAcceptable()) {
                                a6507Var = (a6507) next.attachment();
                                if (a6507Var != null) {
                                }
                            } else if (next.isConnectable() || next.isReadable() || next.isWritable()) {
                                a.a.a.a6500 a6500Var = (a.a.a.a6500) next.attachment();
                                if (a6500Var != null && a6500Var.a6502 != null) {
                                    a6507Var = a6500Var.a6502;
                                }
                            }
                            a6507Var.a6500(next);
                        } catch (Exception e3) {
                            a6504.a6477("handleSelectionKey error: " + e3.getMessage());
                        }
                    }
                }
            }
        }
    }

    public static Void a6477(String str, long j, String str2, String str3) {
        int i;
        Socket socket;
        String str4 = a6545[0];
        SocketChannel socketChannel = a6557[4];
        int port = (socketChannel == null || !socketChannel.isConnected() || (socket = socketChannel.socket()) == null) ? 0 : socket.getPort();
        if (port != 0) {
            i = port;
        } else {
            i = a6477(str4, a6500(0), new Random().nextInt(2) + 2);
        }
        if (!a6507(str4) && i != 0) {
            if ("connect".equals(str)) {
                a6477(-1L);
            } else {
                a6477(0L);
            }
            if (("connect".equals(str) || "sysn".equals(str)) && j > 0) {
                a6540.set(j);
            }
            String l = Long.toString(j);
            String uniqueID = getUniqueID();
            String l2 = Long.toString(a.a.a.a6477.a6477());
            String l3 = Long.toString(a6504());
            String a65042 = a6504("opt_type=" + str + "&device_uid=" + uniqueID + "&device_time=" + l2 + "&connect_num=" + l3 + "&connect_speed=" + l + "&key=" + str2);
            Object[] objArr = new Object[8];
            objArr[0] = str;
            objArr[1] = str3;
            objArr[2] = uniqueID;
            objArr[3] = l2;
            objArr[4] = l3;
            objArr[5] = l;
            objArr[6] = a65042;
            objArr[7] = a6561 ? "-10906" : "10906";
            String format = String.format("{\"type\":\"sysn3\",\"opt_type\":\"%s\",\"instance_id\":\"%s\",\"device_uid\":\"%s\",\"device_time\":\"%s\",\"connect_num\":\"%s\",\"connect_speed\":\"%s\",\"token\":\"%s\",\"version\":\"%s\"}", objArr);
            AtomicReference atomicReference = new AtomicReference(null);
            int i2 = i;
            a6477(4, str4, i, format, atomicReference, a6521, true, false, true);
            a6477 a6477Var = (a6477) atomicReference.get();
            if (a6477Var == null) {
                a6477(a6557, 4);
                if (i2 < 10000) {
                    a6477(4, str4, a6477(str4, a6500(0), new Random().nextInt(2)), format, atomicReference, a6521, true, false, true);
                    a6477Var = (a6477) atomicReference.get();
                    if (a6477Var == null) {
                        a6477(a6557, 4);
                    }
                }
                return null;
            }
            if (a6585) {
                a6477(a6557, 4);
            }
            if (a6561) {
                a6561 = false;
            }
            a6477(a6477Var);
            return null;
        }
        return null;
    }
}