OurPlay v5.5.9版本的 MD5 值为:d4e139798f4c2243a1145c8af5e21046

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


package com.excelliance.kxqp.gs.util;

import android.app.Application;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.os.Build;
import android.os.Bundle;
import android.os.Process;
import android.text.TextUtils;
import android.util.Log;
import android.util.SparseArray;
import com.android.spush.util.WebActionRouter;
import com.excelliance.kxqp.GameUtil;
import com.excelliance.kxqp.bean.AppExtraBean;
import com.excelliance.kxqp.gs.bean.DownloadAreaBean;
import com.excelliance.kxqp.gs.bean.LastSaveProxyInfo;
import com.excelliance.kxqp.gs.bean.LoginAreaBean;
import com.excelliance.kxqp.gs.bean.ReginBean;
import com.excelliance.kxqp.gs.bean.SwitchProxyRequest;
import com.excelliance.kxqp.gs.provider.SearchProvider;
import com.excelliance.kxqp.gs.service.ProxyDelayService;
import com.excelliance.kxqp.platforms.ExcellianceAppInfo;
import com.excelliance.staticslio.StatisticsManager;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.json.JSONException;
import org.json.JSONObject;

public class bt {

    public static boolean f11927a = true;

    public static final String f11928b = null;
    public static int c = 2;
    public static int d = 1;
    public static boolean e;
    public static long f;
    public static String g;

    private bt() {
    }

    public static bt a() {
        return a.f11929a;
    }

    public static class a {

        private static bt f11929a = new bt();
    }

    private boolean b() {
        String lowerCase = Build.BRAND.toLowerCase();
        String lowerCase2 = Build.MANUFACTURER.toLowerCase();
        String lowerCase3 = Build.MODEL.toLowerCase();
        Log.d("ProcessManager", "brand: " + lowerCase + " manufacturer: " + lowerCase2 + " model: " + lowerCase3);
        return TextUtils.equals("doov", lowerCase) && TextUtils.equals("doov", lowerCase2) && TextUtils.equals("doov v11", lowerCase3);
    }

    public void a(Context context, String str, String str2, String str3, String str4, String str5, LoginAreaBean loginAreaBean, String str6, int i, boolean z, String str7, DownloadAreaBean downloadAreaBean) {
        a(context, str, str2, str3, str4, str5, com.excelliance.kxqp.gs.k.b.a().g(), loginAreaBean, str6, i, z, str7, downloadAreaBean);
    }

    public void a(Context context, String str, String str2, String str3, String str4, String str5, int i, LoginAreaBean loginAreaBean, String str6, int i2, boolean z, String str7, DownloadAreaBean downloadAreaBean) {
        int i3;
        String str8;
        String str9;
        LoginAreaBean.DownloadPort downloadPort;
        String str10;
        DownloadAreaBean.DownloadPort downloadPort2;
        String str11;
        DownloadAreaBean.DownloadPort downloadPort3;
        String str12;
        String str13;
        String str14;
        DownloadAreaBean.DownloadPort downloadPort4;
        LoginAreaBean.DownloadPort downloadPort5;
        int i4;
        ProxyDelayService.a("ProcessManager", "initProcess: -------启动进程 downloadAreaBean:" + downloadAreaBean);
        az.d("ProcessManager", "initProcess: , localPort:" + str5 + ", pkg = " + str7 + ",ip:" + str + ", loginAreaBean = " + loginAreaBean);
        StringBuilder sb = new StringBuilder();
        sb.append("initProcess: , lport:");
        sb.append(str5);
        sb.append(":");
        sb.append(str6);
        sb.append(", pkg = ");
        sb.append(str7);
        Log.e("ProcessManager", sb.toString());
        String c2 = c(context);
        Log.d("ProcessManager", "Dir: " + c2);
        ArrayList arrayList = new ArrayList();
        arrayList.add(c2);
        arrayList.add("-u");
        arrayList.add("-v");
        arrayList.add("-b");
        arrayList.add("::");
        arrayList.add("-l");
        arrayList.add(str5);
        arrayList.add("-t");
        arrayList.add("1200");
        arrayList.add("-s");
        boolean equals = TextUtils.equals(str5, "11081");
        if (f11927a) {
            try {
                i3 = Integer.parseInt(str5);
            } catch (Exception unused) {
                i3 = 0;
            }
            equals = equals || i3 >= 11091;
        }
        boolean z2 = equals;
        if (i2 == ReginBean.KCP_SUPPORT && z2) {
            arrayList.add("127.0.0.1");
        } else {
            arrayList.add(str);
        }
        arrayList.add("-p");
        if (i2 == ReginBean.KCP_SUPPORT && z2) {
            arrayList.add("11083");
        } else {
            arrayList.add(str2);
        }
        arrayList.add("-k");
        arrayList.add(str3);
        arrayList.add("-m");
        arrayList.add(str4);
        if (i2 == ReginBean.KCP_SUPPORT && z2) {
            arrayList.add("--ut-server");
            arrayList.add(str);
            arrayList.add("--ut-port");
            try {
                i4 = Integer.parseInt(str2);
            } catch (Exception e2) {
                e2.printStackTrace();
                i4 = 0;
            }
            arrayList.add((i4 + 1) + "");
        }
        arrayList.add("-f");
        if (TextUtils.equals(str5, "11080")) {
            arrayList.add("pid_file_main");
        } else if (TextUtils.equals(str5, "11082")) {
            arrayList.add("pid_file_register");
        } else if (f11927a) {
            if (TextUtils.isEmpty(str7)) {
                arrayList.add("pid_file_download");
            } else {
                arrayList.add("pid_file_game_" + str7);
            }
        } else {
            arrayList.add("pid_file_download");
        }
        if (loginAreaBean == null || (downloadPort5 = loginAreaBean.getDownloadPort()) == null || TextUtils.isEmpty(downloadPort5.ip) || TextUtils.isEmpty(downloadPort5.port) || TextUtils.isEmpty(downloadPort5.up) || TextUtils.isEmpty(downloadPort5.key)) {
            str8 = null;
            str9 = null;
            downloadPort = null;
        } else {
            arrayList.add("--si-server");
            arrayList.add(downloadPort5.ip);
            arrayList.add("--si-port");
            arrayList.add(downloadPort5.port);
            arrayList.add("--si-password");
            arrayList.add(downloadPort5.up);
            arrayList.add("--si-method");
            arrayList.add(downloadPort5.key);
            String str15 = downloadPort5.ip;
            downloadPort = downloadPort5;
            str9 = downloadPort5.port;
            str8 = str15;
        }
        if (downloadAreaBean == null || (downloadPort4 = downloadAreaBean.getDownloadPort()) == null || TextUtils.isEmpty(downloadPort4.ip) || TextUtils.isEmpty(downloadPort4.port) || TextUtils.isEmpty(downloadPort4.up) || TextUtils.isEmpty(downloadPort4.key)) {
            str10 = null;
            downloadPort2 = null;
            str11 = null;
        } else {
            arrayList.add("--dl-server");
            arrayList.add(downloadPort4.ip);
            arrayList.add("--dl-port");
            arrayList.add(downloadPort4.port);
            arrayList.add("--dl-password");
            arrayList.add(downloadPort4.up);
            arrayList.add("--dl-method");
            arrayList.add(downloadPort4.key);
            str11 = downloadPort4.ip;
            str10 = downloadPort4.port;
            downloadPort2 = downloadPort4;
        }
        if (z2) {
            String a2 = com.excelliance.kxqp.gs.k.a.a().a(context);
            if (TextUtils.isEmpty(a2)) {
                downloadPort3 = downloadPort2;
            } else {
                downloadPort3 = downloadPort2;
                arrayList.add("--acl");
                arrayList.add(a2);
            }
        } else {
            downloadPort3 = downloadPort2;
            if (TextUtils.equals(str5, "11080")) {
                String a3 = com.excelliance.kxqp.gs.k.g.a().a(context);
                if (!TextUtils.isEmpty(a3)) {
                    arrayList.add("--acl");
                    arrayList.add(a3);
                }
            }
        }
        if (aq.v()) {
            str12 = str10;
            str13 = str11;
            str14 = str9;
        } else {
            arrayList.add("--zms");
            String str16 = context.getFilesDir().getAbsolutePath() + "/";
            str12 = str10;
            StringBuilder sb2 = new StringBuilder();
            str13 = str11;
            sb2.append("initProcess dataPath:");
            sb2.append(str16);
            az.d("ProcessManager", sb2.toString());
            if (TextUtils.equals(str5, "11080")) {
                arrayList.add(str16 + "run_flow_proxy.cfg");
            } else if (TextUtils.equals(str5, "11082")) {
                arrayList.add(str16 + "netproxy3.cfg");
            } else {
                arrayList.add(str16 + "down_flow_proxy.cfg");
            }
            String a4 = bx.a().a(context);
            JSONObject f2 = aq.f(context);
            try {
                f2.put("rid", a4);
                f2.put("isvip", bx.a().o(context) ? 1 : 0);
            } catch (JSONException e3) {
                e3.printStackTrace();
            }
            arrayList.add("--uid");
            String b2 = cn.b(f2.toString());
            StringBuilder sb3 = new StringBuilder();
            str14 = str9;
            sb3.append("encryParams:");
            sb3.append(b2);
            az.d("ProcessManager", sb3.toString());
            arrayList.add(b2);
            String r = GameUtil.getIntance().r(context);
            arrayList.add("--rid");
            arrayList.add(a4 + StatisticsManager.COMMA + r);
            int H = as.H(context);
            az.d("ProcessManager", "preReginVpnType:" + H);
            arrayList.add("--nt");
            if (H == 1) {
                arrayList.add(String.valueOf(2));
            } else {
                arrayList.add(String.valueOf(1));
            }
            if (i == 1) {
                Log.d("ProcessManager", "use abtest");
                arrayList.add("--abtest");
            } else {
                Log.d("ProcessManager", "use abtest no");
            }
        }
        if (z2 && !TextUtils.isEmpty(str7)) {
            AppExtraBean d2 = com.excelliance.kxqp.repository.a.a(context).d(str7);
            az.d("ProcessManager", "initProcess pkg = " + str7 + ", appExtra = " + d2);
            if (d2 != null && !TextUtils.isEmpty(d2.getSsParams())) {
                az.d("ProcessManager", "initProcess ssParams pkg = " + str7 + ", ssParams = " + d2.getSsParams());
                arrayList.add(d2.getSsParams());
            }
        }
        if (z) {
            arrayList.add("--restart");
        }
        com.excelliance.kxqp.wr.a a5 = com.excelliance.kxqp.wr.a.a();
        Log.e("ProcessManager", ":" + str5 + "ip:" + str + " port:" + str2 + " supportKcp:" + i2 + " areaId:" + str6 + " login_ip:" + str8 + " login_port:" + str14 + " killPd:" + z + " thread:" + Thread.currentThread() + " pkg:" + str7 + ", cacc = " + (!TextUtils.isEmpty(str7) ? !a5.f(0, str7) : true) + " download_ip:" + str13 + " download_port:" + str12);
        StringBuilder sb4 = new StringBuilder();
        sb4.append("initProcess: -------启动进程 comm:");
        sb4.append(arrayList.toString());
        sb4.append(" areaId:");
        sb4.append(str6);
        ProxyDelayService.a("ProcessManager", sb4.toString());
        a5.a(arrayList, (Map<String, String>) null, context.getFilesDir().getAbsolutePath(), 0, (Bundle) null);
        ProxyDelayService.a("ProcessManager", "initProcess: -------启动完成");
        if (TextUtils.equals(str5, "11080")) {
            as.k(context, str6);
        }
        if (z2) {
            LastSaveProxyInfo lastSaveProxyInfo = new LastSaveProxyInfo();
            lastSaveProxyInfo.arearId = str6;
            lastSaveProxyInfo.dareaInfo = ay.a(loginAreaBean);
            lastSaveProxyInfo.downloadAreaInfo = ay.a(downloadAreaBean);
            ay.a(context, lastSaveProxyInfo);
            if (!cd.a(str7)) {
                by.a(context, "last_app_bind_proxy").a(str7 + "_areaid", str6);
            }
            LoginAreaBean.bindGameAndDlPort(context, str7, downloadPort);
            DownloadAreaBean.bindGameAndDownloadPort(context, str7, downloadPort3);
            com.excelliance.kxqp.gs.g.c.a().c(str + ":" + str2);
        }
        if (i2 == ReginBean.KCP_SUPPORT && z2) {
            a(context, str, str2);
        }
    }

    public void a(Context context, String str, String str2) {
        String d2 = d(context);
        Log.d("ProcessManager", "Dir: " + d2);
        ArrayList arrayList = new ArrayList();
        arrayList.add(d2);
        arrayList.add("-l");
        arrayList.add("127.0.0.1:11083");
        arrayList.add("-r");
        arrayList.add(str + ":" + str2);
        arrayList.add("--mode");
        arrayList.add("fast3");
        arrayList.add("--mtu");
        arrayList.add("650");
        arrayList.add("--sndwnd");
        arrayList.add("1024");
        arrayList.add("--rcvwnd");
        arrayList.add("1024");
        arrayList.add("--pid");
        arrayList.add("pid_file_kcp");
        Log.d("ProcessManager", "initProcessKcp: -------启动进程 comm:" + arrayList.toString() + " thread:" + Thread.currentThread());
        StringBuilder sb = new StringBuilder();
        sb.append("initProcessKcp: -------启动进程 comm:");
        sb.append(arrayList.toString());
        ProxyDelayService.a("ProcessManager", sb.toString());
        com.excelliance.kxqp.wr.a.a().a(arrayList, (Map<String, String>) null, context.getFilesDir().getAbsolutePath(), 0, (Bundle) null);
        ProxyDelayService.a("ProcessManager", "initProcessKcp: -------启动完成");
    }

    private String c(Context context) {
        String str = ck.a(context) ? "/libss-local-x8.so" : "/libss-local.so";
        String str2 = context.getApplicationInfo().nativeLibraryDir + str;
        boolean b2 = b();
        File file = new File(str2);
        boolean exists = file.exists();
        Log.d("ProcessManager", String.format("ProcessManager/getNativeLibrary:thread(%s) sslLibFile(%s) exist(%s) nativeLibraryDir(%s)", Thread.currentThread().getName(), file.getAbsolutePath(), Boolean.valueOf(exists), str2));
        if (b2 || !exists) {
            int c2 = by.a(context, "sp_total_info").c("ss_local_update_ver_local", 0);
            File file2 = new File(context.getFilesDir(), str);
            String absolutePath = file2.getAbsolutePath();
            az.d("ProcessManager", "getNativeLibrary2: " + absolutePath);
            if (!file2.exists() || c2 < c) {
                an.a(str, context, absolutePath);
                by.a(context, "sp_total_info").a("ss_local_update_ver_local", c);
            }
            file2.setExecutable(true, false);
            str2 = absolutePath;
        }
        Log.d("ProcessManager", "lib exits: " + new File(str2).exists());
        az.d("ProcessManager", "getNativeLibrary3: " + str2);
        return str2;
    }

    private String d(Context context) {
        return bn.e(context);
    }

    public int a(Context context, String str) {
        return b(context, str, (String) null);
    }

    public int b(Context context, String str, String str2) {
        String str3;
        BufferedReader bufferedReader;
        az.d("ProcessManager", "getProcessPid:localPort = " + str + ", pkg = " + str2);
        Integer num = -1;
        File filesDir = context.getFilesDir();
        if (!filesDir.exists() || filesDir.isFile()) {
            Log.d("ProcessManager", "getProcessPid: -------not exist -----");
            return num.intValue();
        }
        if (TextUtils.equals(str, "11080")) {
            str3 = filesDir.getAbsolutePath() + "/pid_file_main";
        } else if (TextUtils.equals(str, "11081")) {
            if (f11927a) {
                if (TextUtils.isEmpty(str2)) {
                    str3 = filesDir.getAbsolutePath() + "/pid_file_download";
                } else {
                    str3 = filesDir.getAbsolutePath() + "/pid_file_game_" + str2;
                }
            } else {
                str3 = filesDir.getAbsolutePath() + "/pid_file_download";
            }
        } else if (TextUtils.equals(str, "11083")) {
            str3 = filesDir.getAbsolutePath() + "/pid_file_kcp";
        } else {
            str3 = filesDir.getAbsolutePath() + "/pid_file_register";
        }
        Log.d("ProcessManager", "getProcessPid: -------" + str3);
        File file = new File(str3);
        BufferedReader bufferedReader2 = null;
        if (file.exists()) {
            try {
                if (file.isFile()) {
                    try {
                        bufferedReader = new BufferedReader(new FileReader(file));
                    } catch (IOException e2) {
                        e = e2;
                    }
                    try {
                        String readLine = bufferedReader.readLine();
                        if (!TextUtils.isEmpty(readLine) && cd.c(readLine)) {
                            num = Integer.valueOf(readLine);
                        }
                        Log.i("ProcessManager", "getProcessPid: ------------process_pid: " + num);
                        try {
                            bufferedReader.close();
                        } catch (IOException e3) {
                            e3.printStackTrace();
                        }
                        return num.intValue();
                    } catch (IOException e4) {
                        e = e4;
                        bufferedReader2 = bufferedReader;
                        e.printStackTrace();
                        if (bufferedReader2 != null) {
                            try {
                                bufferedReader2.close();
                            } catch (IOException e5) {
                                e5.printStackTrace();
                            }
                        }
                        return num.intValue();
                    } catch (Throwable unused) {
                        if (bufferedReader != null) {
                            try {
                                bufferedReader.close();
                            } catch (IOException e6) {
                                e6.printStackTrace();
                            }
                        }
                        return num.intValue();
                    }
                }
            } catch (Throwable unused2) {
                bufferedReader = null;
            }
        }
        az.e("ProcessManager", "getProcessPid: not exists localPort = " + str + ", pidDir = " + str3);
        return num.intValue();
    }

    public void a(int i) {
        az.d("ProcessManager", "killProcess: ----1111 execPid:" + i);
        Process.sendSignal(i, 15);
        az.d("ProcessManager", "killProcess: ----2222");
    }

    public boolean a(int i, String str, String str2) {
        if (f11927a && !TextUtils.isEmpty(str) && !bs.n(str) && !bs.o(str) && str2 == null) {
            az.d("ProcessManager", String.format("ProcessManager/startRootNet:thread(%s) default packageName(%s) netProxy(%s)", Thread.currentThread().getName(), str, str2));
            Application b2 = com.zero.support.core.b.b();
            if (b2 != null) {
                str2 = as.a(b2) + "netproxy2_" + str + ".cfg";
            }
        }
        boolean a2 = com.excelliance.kxqp.wr.a.a().a(i, str, str2);
        Log.d("ProcessManager", String.format("ProcessManager/startRootNet:thread(%s) packageName(%s) netProxy(%s) reback(%s)", Thread.currentThread().getName(), str, str2, Boolean.valueOf(a2)));
        return a2;
    }

    public void a(String str, boolean z) {
        az.i("ProcessManager", "ProcessManager/setProxyMode() called with: thread = [" + Thread.currentThread() + "], libName = [" + str + "], globalOrNoProxy = [" + z + "]");
        a(0, str, z ? f11928b : "");
    }

    public void a(Context context, String str, boolean z) {
        String str2;
        az.i("ProcessManager", "ProcessManager/setProxyModeSpecial() called with: thread = [" + Thread.currentThread() + "], libName = [" + str + "], globalOrNoProxy = [" + z + "]");
        if (z) {
            str2 = as.a(context) + "netproxy1.cfg";
        } else {
            str2 = "";
        }
        a(0, str, str2);
    }

    public void a(String str, String str2) {
        az.i("ProcessManager", "ProcessManager/setProxyWithFile() called with: thread = [" + Thread.currentThread() + "], libName = [" + str + "], file = [" + str2 + "]");
        a(0, str, str2);
    }

    public void a(String str) {
        az.i("ProcessManager", "ProcessManager/disableApp() called with: thread = [" + Thread.currentThread() + "], pkgName = [" + str + "]");
        com.excelliance.kxqp.wr.a.a().a(0, str, 1, false);
        a(str, false);
    }

    public void b(String str) {
        az.i("ProcessManager", "ProcessManager/enableProxy() called with: thread = [" + Thread.currentThread() + "], pkgName = [" + str + "]");
        com.excelliance.kxqp.wr.a.a().a(0, str, 0, false);
        a(str, true);
    }

    public void b(Context context, String str) {
        az.i("ProcessManager", "ProcessManager/enableProxySpecial() called with: thread = [" + Thread.currentThread() + "], pkgName = [" + str + "]");
        com.excelliance.kxqp.wr.a.a().a(0, str, 0, false);
        a(context, str, true);
    }

    public void c(String str) {
        az.i("ProcessManager", "ProcessManager/disableProxyTemporarily() called with: thread = [" + Thread.currentThread() + "], libName = [" + str + "]");
        com.excelliance.kxqp.wr.a.a().a(0, str, 1, true);
    }

    public boolean d(String str) {
        return com.excelliance.kxqp.wr.a.a().f(0, str);
    }

    public static void a(Context context, boolean z, boolean z2, boolean z3, String str, String str2) {
        Log.d("ProcessManager", "c " + z + "t: " + z2 + " killOnlyGp:" + z3);
        a(context, z, str, str2);
        a((z2 && com.excelliance.kxqp.gs.d.h.b(context)) || com.excelliance.kxqp.bitmap.ui.b.b.a(), z3);
        if (z) {
            return;
        }
        a(context);
    }

    public static void a(boolean z, boolean z2) {
        com.excelliance.kxqp.wr.a a2 = com.excelliance.kxqp.wr.a.a();
        az.d("ProcessManager", "killGoogleAffinity:" + z + " killOnlyGp:" + z2);
        if (z2) {
            try {
                a2.a(0, "com.excean.android.vending");
                a2.a(0, "com.google.android.gms");
                a2.a(0, "com.google.android.gsf");
                if (Build.VERSION.SDK_INT < 26) {
                    a2.a(0, "com.google.android.gsf.login");
                }
                if (Build.VERSION.SDK_INT > 18) {
                    if (Build.VERSION.SDK_INT < 29) {
                        a2.a(0, "com.google.android.backuptransport");
                    }
                } else {
                    a2.a(0, "com.google.android.backup");
                }
                a2.a(0, "com.google.android.instantapps.supervisor");
                a2.a(0, "com.google.android.play.games");
                a2.a(0, "com.exce.wv");
                a2.a(0, "com.excean.android.browser");
                return;
            } catch (Exception e2) {
                e2.printStackTrace();
                Log.e("ProcessManager", "ProcessManager/killGoogleAffinity run:" + e2.toString());
                return;
            }
        }
        if (z) {
            try {
                a2.a(0, "com.excean.android.vending");
                a2.a(0, "com.google.android.gms");
                a2.a(0, "com.google.android.gsf");
                a2.a(0, "com.android.vending");
                a2.a(0, "com.excean.android.browser");
                if (Build.VERSION.SDK_INT < 26) {
                    a2.a(0, "com.google.android.gsf.login");
                }
                if (Build.VERSION.SDK_INT > 18) {
                    if (Build.VERSION.SDK_INT < 29) {
                        a2.a(0, "com.google.android.backuptransport");
                    }
                } else {
                    a2.a(0, "com.google.android.backup");
                }
                a2.a(0, "com.google.android.instantapps.supervisor");
                a2.a(0, "com.google.android.play.games");
                a2.a(0, "com.exce.wv");
            } catch (Exception e3) {
                e3.printStackTrace();
                Log.e("ProcessManager", "ProcessManager/killGoogleAffinity run:" + e3.toString());
            }
        }
    }

    public static void a(Context context) {
        bt a2 = a();
        int a3 = a2.a(context, "11080");
        az.i("ProcessManager", "ProcessManager/killProxyProcess:---switchProcess: -----processPid: " + a3);
        if (a3 != -1) {
            a2.a(a3);
        }
        int a4 = a2.a(context, "11081");
        az.i("ProcessManager", "ProcessManager/killProxyProcess:---switchProcess: downloadPid:" + a4);
        if (a4 != -1) {
            a2.a(a4);
        }
        int a5 = a2.a(context, "11083");
        az.i("ProcessManager", "ProcessManager/killProxyProcess:---switchProcess: kcpPid:" + a5);
        if (a5 != -1) {
            a2.a(a5);
        }
        if (f11927a) {
            e(context);
        }
    }

    public static void c(Context context, String str) {
        bt a2 = a();
        int a3 = a2.a(context, str);
        az.d("ProcessManager", "ProcessManager/killProxyProcess:processPid: " + a3);
        if (a3 != -1) {
            a2.a(a3);
        }
    }

    public static void b(Context context) {
        Log.d("ProcessManager", String.format("ProcessManager/forbiddenCnProxy:thread(%s)", Thread.currentThread().getName()));
        c(context, "11080");
        c(context, "11083");
        a(com.excelliance.kxqp.gs.d.h.b(context), false);
        e("");
    }

    private static void e(String str) {
        Log.d("ProcessManager", String.format("ProcessManager/setProxyConfig:thread(%s) config(%s)", Thread.currentThread().getName(), str));
        bt a2 = a();
        a2.a(0, bs.a(5), str);
        a2.a(0, bs.a(3), str);
        a2.a(0, bs.a(6), str);
        a2.a(0, bs.a(4), str);
        a2.a(0, bs.a(7), str);
        a2.a(0, bs.a(2), str);
        a2.a(0, bs.a(1), str);
        a2.a(0, bs.a(11), str);
        a2.a(0, bs.a(0), str);
        a2.a(0, "com.excean.android.browser", str);
    }

    public static void a(Context context, boolean z, String str, String str2) {
        boolean z2;
        boolean z3;
        boolean z4;
        AppExtraBean d2;
        Log.d("ProcessManager", String.format("ProcessManager/switchProxyConfig:thread(%s) connect(%s), pkg(%s), localPort(%s)", Thread.currentThread().getName(), Boolean.valueOf(z), str, str2));
        if (z) {
            an.a(context, "netproxy1.cfg", "11080", context.getPackageName(), false);
            String str3 = "netproxy2.cfg";
            String str4 = "11081";
            if (!f11927a || TextUtils.isEmpty(str)) {
                z2 = false;
                z3 = false;
                z4 = true;
            } else {
                if (!TextUtils.isEmpty(str2)) {
                    if (Integer.parseInt(str2) < Integer.parseInt("11091")) {
                        z4 = false;
                        d2 = com.excelliance.kxqp.repository.a.a(context).d(str);
                        if (d2 == null && d2.isAccelerate()) {
                            str3 = "netproxy2_" + str + ".cfg";
                            if (TextUtils.isEmpty(str2)) {
                                Log.e("ProcessManager", String.format("ProcessManager/switchProxyConfig:thread(%s) connect(%s), pkg(%s), empty localPort(%s)", Thread.currentThread().getName(), Boolean.valueOf(z), str, str2));
                            } else {
                                str4 = str2;
                            }
                            z2 = true;
                            z3 = true;
                        } else {
                            z2 = false;
                            z3 = false;
                        }
                    }
                }
                z4 = true;
                d2 = com.excelliance.kxqp.repository.a.a(context).d(str);
                if (d2 == null) {
                }
                z2 = false;
                z3 = false;
            }
            Log.d("ProcessManager", String.format("ProcessManager/switchProxyConfig:thread(%s) connect pkg(%s), needInitGame(%s), proxyPort(%s), gameConfig(%s)", Thread.currentThread().getName(), str, Boolean.valueOf(z4), str4, str3));
            if (z4) {
                an.a(context, str3, str4, context.getPackageName(), z2);
            }
            if (!f11927a || !z3 || TextUtils.isEmpty(str) || bs.n(str) || bs.o(str)) {
                return;
            }
            a().a(str, as.a(context) + "netproxy2_" + str + ".cfg");
            return;
        }
        String a2 = as.a(context);
        if (TextUtils.isEmpty(a2)) {
            return;
        }
        File file = new File(a2);
        File file2 = new File(file, "netproxy1.cfg");
        String str5 = "netproxy2.cfg";
        if (f11927a && !TextUtils.isEmpty(str)) {
            str5 = "netproxy2_" + str + ".cfg";
        }
        File file3 = new File(file, str5);
        an.c(file2.getAbsolutePath());
        an.c(file3.getAbsolutePath());
    }

    private static String d(Context context, String str) {
        String str2;
        int i;
        ArrayList arrayList = new ArrayList();
        if (!TextUtils.isEmpty(str)) {
            a().b(context, "11081", str);
            ArrayList<Integer> j = GameUtil.getIntance().j(context, "libss-local.so");
            if (j != null && j.size() > 0) {
                for (int i2 = 0; i2 < j.size(); i2++) {
                    int intValue = j.get(i2).intValue();
                    String a2 = a(context, intValue);
                    if (!TextUtils.isEmpty(a2)) {
                        if (a(context, intValue, str)) {
                            Log.e("ProcessManager", "getAvailableLocalPortForGame pkg = " + str + ",use running localPort:" + a2);
                            return a2;
                        }
                        arrayList.add(a2);
                    }
                }
            }
            int parseInt = Integer.parseInt("11091");
            int i3 = parseInt + 100;
            while (true) {
                if (parseInt >= i3) {
                    str2 = null;
                    break;
                }
                boolean z = false;
                for (int i4 = 0; i4 < arrayList.size(); i4++) {
                    try {
                        i = Integer.parseInt((String) arrayList.get(i4));
                    } catch (Exception unused) {
                        i = 0;
                    }
                    if (parseInt == i) {
                        z = true;
                    }
                }
                if (!z) {
                    str2 = String.valueOf(parseInt);
                    break;
                }
                parseInt++;
            }
        } else {
            str2 = "11081";
        }
        Log.e("ProcessManager", "getAvailableLocalPortForGame pkg = " + str + ", localPort:" + str2);
        return str2;
    }

    public static boolean a(Context context, String str, String str2, String str3, LoginAreaBean loginAreaBean, DownloadAreaBean downloadAreaBean) {
        BufferedReader bufferedReader;
        String str4;
        String str5;
        String str6;
        String str7;
        String str8;
        String str9;
        boolean z;
        String str10;
        String str11;
        String str12;
        String str13;
        boolean z2;
        StringBuilder sb;
        az.d("ProcessManager", "isProxyRunningForGame pkg = " + str + ",ip:" + str2 + ",port = " + str3);
        int b2 = a().b(context, "11081", str);
        if (b2 != -1) {
            try {
                bufferedReader = new BufferedReader(new InputStreamReader(Runtime.getRuntime().exec("cat /proc/" + b2 + "/cmdline").getInputStream(), "UTF-8"));
                try {
                    try {
                        sb = new StringBuilder();
                        sb.append((char) 0);
                        str4 = null;
                        str5 = null;
                        str6 = null;
                        str7 = null;
                        str8 = null;
                        str9 = null;
                        z = false;
                    } catch (Exception e2) {
                        e = e2;
                        str4 = null;
                        str5 = null;
                        str6 = null;
                        str7 = null;
                        str8 = null;
                        str9 = null;
                        z = false;
                        e.printStackTrace();
                    }
                } catch (Throwable th) {
                    th = th;
                    if (bufferedReader != null) {
                        try {
                            bufferedReader.close();
                        } catch (Exception unused) {
                        }
                    }
                    throw th;
                }
            } catch (Exception e3) {
                e = e3;
                bufferedReader = null;
            } catch (Throwable th2) {
                th = th2;
                bufferedReader = null;
                if (bufferedReader != null) {
                }
                throw th;
            }
            while (true) {
                try {
                    String readLine = bufferedReader.readLine();
                    if (readLine != null) {
                        z = true;
                        String replaceAll = readLine.replaceAll(sb.toString(), " ");
                        int indexOf = replaceAll.indexOf("-l ");
                        int indexOf2 = indexOf >= 0 ? replaceAll.indexOf(" -", indexOf) : -1;
                        if (indexOf > 0 && indexOf2 > indexOf) {
                            replaceAll.substring(indexOf + 3, indexOf2);
                        }
                        int indexOf3 = replaceAll.indexOf("-s ");
                        int indexOf4 = indexOf3 >= 0 ? replaceAll.indexOf(" -", indexOf3) : -1;
                        if (indexOf3 > 0 && indexOf4 > indexOf3) {
                            str4 = replaceAll.substring(indexOf3 + 3, indexOf4);
                        }
                        int indexOf5 = replaceAll.indexOf("-p ");
                        int indexOf6 = indexOf5 >= 0 ? replaceAll.indexOf(" -", indexOf5) : -1;
                        if (indexOf5 > 0 && indexOf6 > indexOf5) {
                            str5 = replaceAll.substring(indexOf5 + 3, indexOf6);
                        }
                        int indexOf7 = replaceAll.indexOf("--dl-server ");
                        int indexOf8 = indexOf7 >= 0 ? replaceAll.indexOf(" --", indexOf7) : -1;
                        if (indexOf7 > 0 && indexOf8 > indexOf7) {
                            str6 = replaceAll.substring(indexOf7 + 12, indexOf8);
                        }
                        int indexOf9 = replaceAll.indexOf("--dl-port ");
                        int indexOf10 = indexOf9 >= 0 ? replaceAll.indexOf(" --", indexOf9) : -1;
                        if (indexOf9 > 0 && indexOf10 > indexOf9) {
                            str7 = replaceAll.substring(indexOf9 + 10, indexOf10);
                        }
                        int indexOf11 = replaceAll.indexOf("--si-server ");
                        int indexOf12 = indexOf11 >= 0 ? replaceAll.indexOf(" --", indexOf11) : -1;
                        if (indexOf11 > 0 && indexOf12 > indexOf11) {
                            str8 = replaceAll.substring(indexOf11 + 12, indexOf12);
                        }
                        int indexOf13 = replaceAll.indexOf("--si-port ");
                        int indexOf14 = indexOf13 >= 0 ? replaceAll.indexOf(" --", indexOf13) : -1;
                        if (indexOf13 > 0 && indexOf14 > indexOf13) {
                            str9 = replaceAll.substring(indexOf13 + 10, indexOf14);
                        }
                    }
                } catch (Exception e4) {
                    e = e4;
                    e.printStackTrace();
                }
                try {
                    break;
                } catch (Exception unused2) {
                    LoginAreaBean.DownloadPort downloadPort = loginAreaBean != null ? loginAreaBean.getDownloadPort() : null;
                    DownloadAreaBean.DownloadPort downloadPort2 = downloadAreaBean != null ? downloadAreaBean.getDownloadPort() : null;
                    if (downloadPort != null) {
                        str11 = !TextUtils.isEmpty(downloadPort.ip) ? downloadPort.ip : null;
                        str10 = (TextUtils.isEmpty(downloadPort.port) || TextUtils.equals(downloadPort.port, "0")) ? null : downloadPort.port;
                    } else {
                        str10 = null;
                        str11 = null;
                    }
                    if (downloadPort2 != null) {
                        str13 = !TextUtils.isEmpty(downloadPort2.ip) ? downloadPort2.ip : null;
                        str12 = (TextUtils.isEmpty(downloadPort2.port) || TextUtils.equals(downloadPort2.port, "0")) ? null : downloadPort2.port;
                    } else {
                        str12 = null;
                        str13 = null;
                    }
                    if ((!TextUtils.isEmpty(str2) && !TextUtils.isEmpty(str3) && (!TextUtils.equals(str2, str4) || !TextUtils.equals(str3, str5))) || !TextUtils.equals(str6, str13) || !TextUtils.equals(str7, str12) || !TextUtils.equals(str8, str11) || !TextUtils.equals(str9, str10)) {
                        az.d("ProcessManager", "isProxyRunningForGame proxy config changed pkg = " + str);
                        z2 = false;
                        az.d("ProcessManager", "isProxyRunningForGame final pkg = " + str + ", running = " + z2);
                        return z2;
                    }
                    z2 = z;
                    az.d("ProcessManager", "isProxyRunningForGame final pkg = " + str + ", running = " + z2);
                    return z2;
                }
            }
            bufferedReader.close();
        } else {
            az.d("ProcessManager", "isProxyRunningForGame not running pkg = " + str);
        }
        z2 = false;
        az.d("ProcessManager", "isProxyRunningForGame final pkg = " + str + ", running = " + z2);
        return z2;
    }

    private static String a(Context context, int i) {
        Object obj;
        BufferedReader bufferedReader;
        ?? r6 = 0;
        r6 = 0;
        r6 = 0;
        BufferedReader bufferedReader2 = null;
        r6 = 0;
        try {
            if (i > 0) {
                try {
                    bufferedReader = new BufferedReader(new InputStreamReader(Runtime.getRuntime().exec("cat /proc/" + i + "/cmdline").getInputStream()));
                } catch (Exception e2) {
                    e = e2;
                    obj = null;
                }
                try {
                    StringBuilder sb = new StringBuilder();
                    sb.append((char) 0);
                    while (true) {
                        String readLine = bufferedReader.readLine();
                        if (readLine != null) {
                            String replaceAll = readLine.replaceAll(sb.toString(), " ");
                            int indexOf = replaceAll.indexOf("-l ");
                            int indexOf2 = indexOf >= 0 ? replaceAll.indexOf(" -", indexOf) : -1;
                            if (indexOf > 0 && indexOf2 > indexOf) {
                                r6 = replaceAll.substring(indexOf + 3, indexOf2);
                            }
                        } else {
                            try {
                                break;
                            } catch (Exception unused) {
                            }
                        }
                    }
                    bufferedReader.close();
                    r6 = r6;
                } catch (Exception e3) {
                    e = e3;
                    obj = r6;
                    bufferedReader2 = bufferedReader;
                    e.printStackTrace();
                    if (bufferedReader2 != null) {
                        try {
                            bufferedReader2.close();
                        } catch (Exception unused2) {
                        }
                    }
                    r6 = obj;
                    az.d("ProcessManager", "getLocalPortFromPid pid = " + i + ", localPort:" + r6);
                    return r6;
                } catch (Throwable th) {
                    th = th;
                    r6 = bufferedReader;
                    if (r6 != 0) {
                        try {
                            r6.close();
                        } catch (Exception unused3) {
                        }
                    }
                    throw th;
                }
            }
            az.d("ProcessManager", "getLocalPortFromPid pid = " + i + ", localPort:" + r6);
            return r6;
        } catch (Throwable th2) {
            th = th2;
        }
    }

    private static boolean a(Context context, int i, String str) {
        Object obj;
        BufferedReader bufferedReader;
        boolean z = false;
        if (i != -1) {
            ?? r1 = 0;
            r1 = 0;
            r1 = 0;
            BufferedReader bufferedReader2 = null;
            try {
                try {
                    bufferedReader = new BufferedReader(new InputStreamReader(Runtime.getRuntime().exec("cat /proc/" + i + "/cmdline").getInputStream(), "UTF-8"));
                } catch (Throwable th) {
                    th = th;
                }
            } catch (Exception e2) {
                e = e2;
                obj = null;
            }
            try {
                StringBuilder sb = new StringBuilder();
                sb.append((char) 0);
                while (true) {
                    String readLine = bufferedReader.readLine();
                    if (readLine != null) {
                        String replaceAll = readLine.replaceAll(sb.toString(), " ");
                        int indexOf = replaceAll.indexOf("-f ");
                        int indexOf2 = indexOf >= 0 ? replaceAll.indexOf(" -", indexOf) : -1;
                        if (indexOf > 0 && indexOf2 > indexOf) {
                            r1 = replaceAll.substring(indexOf + 3, indexOf2);
                        }
                    } else {
                        try {
                            break;
                        } catch (Exception unused) {
                        }
                    }
                }
                bufferedReader.close();
                r1 = r1;
            } catch (Exception e3) {
                e = e3;
                obj = r1;
                bufferedReader2 = bufferedReader;
                e.printStackTrace();
                if (bufferedReader2 != null) {
                    try {
                        bufferedReader2.close();
                    } catch (Exception unused2) {
                    }
                }
                r1 = obj;
                if (r1 != 0) {
                }
                az.d("ProcessManager", "isPidGameProxy pkg = " + str + ", pid = " + i + ", running = " + z);
                return z;
            } catch (Throwable th2) {
                th = th2;
                r1 = bufferedReader;
                if (r1 != 0) {
                    try {
                        r1.close();
                    } catch (Exception unused3) {
                    }
                }
                throw th;
            }
            if (r1 != 0) {
                if (r1.contains("pid_file_game_" + str)) {
                    z = true;
                }
            }
        } else {
            az.d("ProcessManager", "isPidGameProxy not running pkg = " + str);
        }
        az.d("ProcessManager", "isPidGameProxy pkg = " + str + ", pid = " + i + ", running = " + z);
        return z;
    }

    private static void e(Context context, String str) {
        boolean z;
        int b2;
        az.d("ProcessManager", "recycleUnusedProxy pkg = " + str);
        com.excelliance.kxqp.wr.a a2 = com.excelliance.kxqp.wr.a.a();
        List<ExcellianceAppInfo> b3 = com.excelliance.kxqp.repository.a.a(context).b();
        if (b3 == null || b3.size() <= 0) {
            return;
        }
        bt a3 = a();
        SparseArray<HashMap> d2 = a2.d(0);
        for (ExcellianceAppInfo excellianceAppInfo : b3) {
            if (excellianceAppInfo != null && !bs.n(excellianceAppInfo.getAppPackageName()) && !bs.o(excellianceAppInfo.getAppPackageName()) && !TextUtils.equals(excellianceAppInfo.getAppPackageName(), str)) {
                int i = 0;
                while (true) {
                    if (i >= d2.size()) {
                        z = false;
                        break;
                    }
                    String obj = d2.get(d2.keyAt(i)).get(WebActionRouter.KEY_PKG).toString();
                    az.d("ProcessManager", "recycleUnusedProxy running packageName = " + obj);
                    if (TextUtils.equals(obj, excellianceAppInfo.getAppPackageName())) {
                        az.d("ProcessManager", "recycleUnusedProxy found packageName = " + obj);
                        z = true;
                        break;
                    }
                    i++;
                }
                if (!z && (b2 = a3.b(context, "11081", excellianceAppInfo.getAppPackageName())) != -1 && a(context, b2, excellianceAppInfo.getAppPackageName())) {
                    az.d("ProcessManager", "recycleUnusedProxy to recycle proxy appInfo package = " + excellianceAppInfo.getAppPackageName() + ", pid = " + b2);
                    a3.a(b2);
                }
            }
        }
    }

    private static void e(Context context) {
        bt a2 = a();
        ArrayList<Integer> j = GameUtil.getIntance().j(context, "libss-local.so");
        if (j == null || j.size() <= 0) {
            return;
        }
        for (int i = 0; i < j.size(); i++) {
            int intValue = j.get(i).intValue();
            if (intValue > 0) {
                a2.a(intValue);
            }
        }
    }

    public static boolean a(SwitchProxyRequest switchProxyRequest) {
        AppExtraBean d2;
        Log.d("ProcessManager", String.format("ProcessManager/switchProcess:thread(%s) localPort(%s) killGoogleAffinity(%s) dAreaBean(%s) areaId(%s) ip(%s) port(%s)", Thread.currentThread().getName(), switchProxyRequest.localPort(), Boolean.valueOf(switchProxyRequest.killGoogleAffinity()), switchProxyRequest.dAreaBean(), switchProxyRequest.reginBean().id, switchProxyRequest.reginBean().ip, switchProxyRequest.reginBean().port));
        if (TextUtils.isEmpty(switchProxyRequest.pkgName()) && !TextUtils.isEmpty(g) && f > 0 && Math.abs(System.currentTimeMillis() - f) < 2500) {
            Log.d("ProcessManager", String.format("ProcessManager/switchProcess:thread(%s) skip the initilization of proxy following game started localPort(%s) killGoogleAffinity(%s) dAreaBean(%s) areaId(%s) ip(%s) port(%s)", Thread.currentThread().getName(), switchProxyRequest.localPort(), Boolean.valueOf(switchProxyRequest.killGoogleAffinity()), switchProxyRequest.dAreaBean(), switchProxyRequest.reginBean().id, switchProxyRequest.reginBean().ip, switchProxyRequest.reginBean().port));
            return true;
        }
        if (TextUtils.equals(switchProxyRequest.localPort(), "11081")) {
            if (!TextUtils.isEmpty(switchProxyRequest.pkgName())) {
                f = System.currentTimeMillis();
            } else {
                f = 0L;
            }
            g = switchProxyRequest.pkgName();
        }
        if (f11927a && !TextUtils.isEmpty(switchProxyRequest.pkgName()) && (d2 = com.excelliance.kxqp.repository.a.a(switchProxyRequest.context()).d(switchProxyRequest.pkgName())) != null && !d2.isAccelerate()) {
            Log.d("ProcessManager", String.format("ProcessManager/switchProcess:thread(%s) ignore non-accelerate game localPort(%s) pkgName(%s)", Thread.currentThread().getName(), switchProxyRequest.localPort(), switchProxyRequest.pkgName()));
            return true;
        }
        b(switchProxyRequest);
        bt a2 = a();
        Log.d("ProcessManager", String.format("ProcessManager/switchProcess:thread(%s) localPort(%s) killGoogleAffinity(%s) dAreaBean(%s) ", Thread.currentThread().getName(), switchProxyRequest.localPort(), Boolean.valueOf(switchProxyRequest.killGoogleAffinity()), switchProxyRequest.dAreaBean()));
        if (TextUtils.equals(switchProxyRequest.localPort(), "11080")) {
            String str = as.a(switchProxyRequest.context()) + "netproxy1.cfg";
            a2.a(0, bs.a(8), "");
            a2.a(0, bs.a(5), str);
            a2.a(0, bs.a(3), str);
            a2.a(0, bs.a(6), str);
            a2.a(0, bs.a(4), str);
            a2.a(0, bs.a(7), str);
            a2.a(0, bs.a(2), str);
            a2.a(0, bs.a(1), str);
            a2.a(0, bs.a(0), str);
            String str2 = as.a(switchProxyRequest.context()) + "netproxy2.cfg";
            if (f11927a && !TextUtils.isEmpty(switchProxyRequest.pkgName())) {
                str2 = as.a(switchProxyRequest.context()) + "netproxy2_" + switchProxyRequest.pkgName() + ".cfg";
            }
            a2.a(0, "com.excean.android.browser", str2);
            SearchProvider.a(switchProxyRequest.context());
            return a2.a(0, bs.a(11), str);
        }
        String a3 = as.a(switchProxyRequest.context());
        String str3 = a3 + "netproxy2.cfg";
        String str4 = null;
        if (f11927a && !TextUtils.isEmpty(switchProxyRequest.pkgName())) {
            str3 = a3 + "netproxy2_" + switchProxyRequest.pkgName() + ".cfg";
            str4 = switchProxyRequest.pkgName();
        }
        return a2.a(0, str4, str3);
    }

    private void a(Context context, ReginBean reginBean, String str) {
        Log.d("ProcessManager", "saveIpAndPort ip: " + reginBean.ip + " port: " + reginBean.port + " areaId:" + reginBean.id + " pkg:" + str);
        by a2 = by.a(context, "sp_config_vpn_regin_id");
        StringBuilder sb = new StringBuilder();
        sb.append(reginBean.ip);
        sb.append(":");
        sb.append(reginBean.port);
        a2.a("sp_key_config_vpn_ip_and_port", sb.toString());
        a2.a("sp_key_config_vpn_game_all_info", ay.a(reginBean));
        if (!cd.a(str) && bs.a(str) == -1) {
            by.a(context, "last_app_bind_proxy").a(str, reginBean.ip + ":" + reginBean.port);
        }
        Intent intent = new Intent(context.getPackageName() + ".action.upload.ip.port");
        intent.setComponent(new ComponentName(context.getPackageName(), "com.android.ggapsvc.LBService"));
        intent.putExtra("ip_port", reginBean.ip + ":" + reginBean.port);
        try {
            context.startService(intent);
        } catch (Exception e2) {
            e2.printStackTrace();
        }
    }

    private void b(Context context, ReginBean reginBean, String str) {
        Log.d("ProcessManager", "saveIpAndPortForGp ip: " + reginBean.ip + " port: " + reginBean.port + " areaId:" + reginBean.id + " pkg:" + str);
        by a2 = by.a(context, "sp_config_vpn_regin_id");
        StringBuilder sb = new StringBuilder();
        sb.append(reginBean.ip);
        sb.append(":");
        sb.append(reginBean.port);
        a2.a("sp_key_config_vpn_id_and_port_for_gp", sb.toString());
        a2.a("sp_key_config_vpn_special_all_info", ay.a(reginBean));
        if (!cd.a(str) && bs.a(str) == -1) {
            by.a(context, "last_app_bind_proxy").a(str + "_gp", reginBean.ip + ":" + reginBean.port);
        }
        Intent intent = new Intent(context.getPackageName() + ".action.upload.ip.port.for.gp");
        intent.setComponent(new ComponentName(context.getPackageName(), "com.android.ggapsvc.LBService"));
        intent.putExtra("ip_port", reginBean.ip + ":" + reginBean.port);
        try {
            context.startService(intent);
        } catch (Exception e2) {
            e2.printStackTrace();
        }
    }

    private static void b(SwitchProxyRequest switchProxyRequest) {
        int a2;
        boolean z = false;
        Log.d("ProcessManager", String.format("ProcessManager/prepareProcessConfig:thread(%s) killOnlyGp(%s), killGoogleAffinity(%s)", Thread.currentThread().getName(), Boolean.valueOf(switchProxyRequest.killGp()), Boolean.valueOf(switchProxyRequest.killGoogleAffinity())));
        bt a3 = a();
        if (f11927a && !TextUtils.isEmpty(switchProxyRequest.pkgName())) {
            e(switchProxyRequest.context(), switchProxyRequest.pkgName());
        }
        if (switchProxyRequest.killGoogleAffinity()) {
            int b2 = a3.b(switchProxyRequest.context(), switchProxyRequest.localPort(), switchProxyRequest.pkgName());
            if (f11927a && switchProxyRequest.localPort().equals("11081") && !TextUtils.isEmpty(switchProxyRequest.pkgName())) {
                z = a(switchProxyRequest.context(), switchProxyRequest.pkgName(), switchProxyRequest.reginBean().ip, switchProxyRequest.reginBean().port, switchProxyRequest.dAreaBean(), switchProxyRequest.downLoadBean());
            }
            az.d("ProcessManager", "prepareProcessConfig to kill localPort: " + switchProxyRequest.localPort() + ", pkgName:" + switchProxyRequest.pkgName() + ", processPid = " + b2 + ", alreadyRunning = " + z);
            if (b2 != -1 && !z) {
                a3.a(b2);
            }
            if (switchProxyRequest.localPort().equals("11081") && switchProxyRequest.reginBean().isSupportKcp() && (a2 = a3.a(switchProxyRequest.context(), "11083")) != -1) {
                a3.a(a2);
            }
        }
        String localPort = switchProxyRequest.localPort();
        if (f11927a && switchProxyRequest.localPort().equals("11081") && !TextUtils.isEmpty(switchProxyRequest.pkgName())) {
            localPort = d(switchProxyRequest.context(), switchProxyRequest.pkgName());
        }
        a(switchProxyRequest.context(), true, switchProxyRequest.killGoogleAffinity(), switchProxyRequest.killGp(), switchProxyRequest.pkgName(), localPort);
        az.d("ProcessManager", "prepareProcessConfig proxyLocalPort: " + localPort + ", alreadyRunning = " + z);
        StringBuilder sb = new StringBuilder();
        sb.append("prepareProcessConfig ip: ");
        sb.append(switchProxyRequest.reginBean());
        az.d("ProcessManager", sb.toString());
        Log.d("ProcessManager", "prepareProcessConfig ip: " + switchProxyRequest.reginBean().ip + " port: " + switchProxyRequest.reginBean().port + " areaId::" + switchProxyRequest.reginBean().id + " killTouristGoogle:" + switchProxyRequest.killGoogleAffinity() + " killOnlyGp:" + switchProxyRequest.killGp() + " thread:" + Thread.currentThread() + " pkg:" + switchProxyRequest.pkgName() + " isTempVip:" + switchProxyRequest.tempUseVip());
        if (!z) {
            a3.a(switchProxyRequest.context(), switchProxyRequest.reginBean().ip, switchProxyRequest.reginBean().port, switchProxyRequest.reginBean().pwd, switchProxyRequest.reginBean().key, localPort, switchProxyRequest.dAreaBean(), switchProxyRequest.reginBean().id, switchProxyRequest.reginBean().supportKcp, switchProxyRequest.killGoogleAffinity(), switchProxyRequest.pkgName(), switchProxyRequest.downLoadBean());
        }
        if (TextUtils.equals(switchProxyRequest.localPort(), "11081")) {
            if (switchProxyRequest.tempUseVip()) {
                switchProxyRequest.reginBean().isTempUseVip = ReginBean.IS_TEMP_USE_VIP;
            }
            a3.a(switchProxyRequest.context(), switchProxyRequest.reginBean(), switchProxyRequest.pkgName());
        } else if (TextUtils.equals(switchProxyRequest.localPort(), "11080")) {
            if (switchProxyRequest.tempUseVip()) {
                switchProxyRequest.reginBean().isTempUseVip = ReginBean.IS_TEMP_USE_VIP;
            }
            a3.b(switchProxyRequest.context(), switchProxyRequest.reginBean(), switchProxyRequest.pkgName());
        }
    }
}