安全中心 v4.9.2版本的 MD5 值为:d64c0ec7920c532fa6e6d9bb001cf9bf

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


package com.meri.service.daemon;

import android.accounts.Account;
import android.accounts.AccountManager;
import android.app.job.JobInfo;
import android.app.job.JobScheduler;
import android.content.ComponentName;
import android.content.ContentResolver;
import android.content.Context;
import android.content.Intent;
import android.content.pm.ResolveInfo;
import android.net.LocalSocket;
import android.net.LocalSocketAddress;
import android.net.Uri;
import android.net.wifi.WifiInfo;
import android.net.wifi.WifiManager;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.os.HandlerThread;
import android.os.Process;
import android.text.TextUtils;
import android.util.SparseArray;
import android.util.SparseIntArray;
import com.meri.service.feature.FeatureTunnelDB;
import com.meri.service.monitor.JobSchedulerService;
import com.meri.service.permission.f;
import com.tencent.kingkong.database.SQLiteDatabase;
import com.tencent.qqpimsecure.dao.h;
import com.tencent.qqpimsecure.model.w;
import com.tencent.server.base.QQSecureApplication;
import com.tencent.server.base.p;
import com.tencent.tcuser.util.Encode;
import com.tencent.tmsecurelite.commom.DataEntityKeyConst;
import com.tencent.tmsecurelite.networkmgr.NetworkMgrConst;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.concurrent.locks.ReentrantReadWriteLock;
import meri.pluginsdk.d;
import org.apache.http.protocol.HTTP;
import tcs.aaf;
import tcs.aaz;
import tcs.adj;
import tcs.ahi;
import tcs.aic;
import tcs.aig;
import tcs.ajy;
import tcs.ake;
import tcs.anr;
import tcs.auv;
import tcs.azv;
import tcs.ba;
import tcs.bdh;
import tcs.bgh;
import tcs.bgm;
import tcs.bgv;
import tcs.lo;
import tcs.qf;
import tcs.qz;
import tcs.rf;
import tcs.rl;
import tcs.sm;
import tcs.sn;
import tcs.te;
import tcs.tv;
import tcs.ub;
import tcs.uc;
import tcs.uf;
import tcs.yz;
import tmsdk.common.TMSDKContext;
import tmsdk.common.internal.utils.i;
import tmsdk.common.tcc.TccCryptor;

public class a {
    private static int fGc = 3;
    private static String fGd = null;
    static volatile long fGe = -1;
    static volatile long bSu = -1;
    private static Handler fGf = null;
    private static int fGg = -1;
    private static int fGh = -1;
    private static String fGi = null;
    private static ReentrantReadWriteLock fDq = new ReentrantReadWriteLock();

    static boolean RD() {
        return Rh();
    }

    static Handler RE() {
        return getHandler();
    }

    static boolean RF() {
        return Rf();
    }

    static int RH() {
        int i = fGc;
        fGc = i - 1;
        return i;
    }

    static long RJ() {
        return Rw();
    }

    static String RK() {
        return Ro();
    }

    private static Handler getHandler() {
        if (fGf == null) {
            synchronized (a.class) {
                if (fGf == null) {
                    HandlerThread s = ((aig) bgm.nL(4)).s("MeriDaemonHandler", 5);
                    s.start();
                    fGf = new Handler(s.getLooper());
                }
            }
        }
        return fGf;
    }

    public static void vr() {
        Rm();
        m(false, false);
    }

    private static String Rb() {
        return Build.VERSION.SDK_INT >= 21 ? "xdm_50" : "xdm";
    }

    public static synchronized void m(final boolean z, final boolean z2) {
        synchronized (a.class) {
            if (!sn.CQ()) {
                getHandler().post(new Runnable() {
                    @Override
                    public void run() {
                        a.Ri();
                        if (!z && a.RD()) {
                            a.RE().postDelayed(new Runnable() {
                                @Override
                                public void run() {
                                    a.m(true, z2);
                                }
                            }, aaz.cCG);
                            return;
                        }
                        if (!a.RF()) {
                            if (a.fGc > 0) {
                                a.RH();
                                a.RE().postDelayed(new Runnable() {
                                    @Override
                                    public void run() {
                                        a.m(false, z2);
                                    }
                                }, 2000L);
                                return;
                            }
                            return;
                        }
                        a.Rc();
                        if (a.fGe <= 0) {
                            ahi.b bVar = new ahi.b() {
                                @Override
                                public void a(int i, Intent intent) {
                                    a.Rd();
                                }
                            };
                            ahi ahiVar = (ahi) bgm.nL(8);
                            ahiVar.a(1026, bVar);
                            ahiVar.a(1013, bVar);
                            ahiVar.a(1031, bVar);
                            ahiVar.a(1054, bVar);
                            ahiVar.a(1015, bVar);
                        }
                        boolean RD = a.RD();
                        if (RD) {
                            a.fGe = System.currentTimeMillis();
                        }
                        if (z2) {
                            if (RD) {
                                yz.a(bgh.PQ().kH(), ba.dBi, "1", 4);
                            } else {
                                yz.a(bgh.PQ().kH(), ba.dBi, "0", 4);
                            }
                        }
                    }
                });
            }
        }
    }

    public static void Rc() {
        OutputStream outputStream;
        String fz;
        String format;
        OutputStream outputStream2;
        if (sn.CQ()) {
            return;
        }
        String a = i.a(com.tencent.server.base.d.agJ(), Rb(), (String) null);
        ProcessBuilder processBuilder = new ProcessBuilder(new String[0]);
        processBuilder.command("sh");
        OutputStream outputStream3 = null;
        try {
            try {
                String packageName = com.tencent.server.base.d.agJ().getPackageName();
                if (TextUtils.isEmpty(packageName)) {
                    packageName = "com.anguanjia.security";
                }
                if (!"com.anguanjia.security".equalsIgnoreCase(packageName)) {
                    com.tencent.server.base.d.n(new RuntimeException("APP_PACKAGE_NAME invalid: " + packageName));
                }
                String eu = uf.eu(TMSDKContext.getStrFromEnvMap(TMSDKContext.CON_LC));
                String eu2 = uf.eu(TMSDKContext.getStrFromEnvMap(TMSDKContext.CON_SOFTVERSION));
                String eu3 = uf.eu(ajy.i(com.tencent.server.base.d.agJ()));
                String eu4 = uf.eu(ajy.k(com.tencent.server.base.d.agJ()));
                String eu5 = uf.eu(TMSDKContext.getStrFromEnvMap(TMSDKContext.CON_CHANNEL));
                String eu6 = uf.eu(ub.X(com.tencent.server.base.d.agJ()));
                int intFromEnvMap = TMSDKContext.getIntFromEnvMap(TMSDKContext.CON_SUB_PLATFORM);
                int i = tv.W(com.tencent.server.base.d.agJ()) ? 1 : 0;
                int KF = uc.KF();
                int intFromEnvMap2 = TMSDKContext.getIntFromEnvMap(TMSDKContext.CON_BUILD);
                String eu7 = uf.eu(ajy.kP());
                String VR = ub.VR();
                int aaY = f.aaY();
                int myUid = Process.myUid();
                int i2 = ake.cOE ? 0 : 1;
                int i3 = ake.cOy ? 1 : 0;
                fGd = packageName + "_xdm_" + myUid;
                String str = TMSDKContext.getApplicaionContext().getPackageName() + "_" + TMSDKContext.getStrFromEnvMap(TMSDKContext.CON_ATHENA_NAME) + "_" + myUid;
                String bX = bX(com.tencent.server.base.d.agJ());
                String Rj = Rj();
                int RR = b.RR();
                fz = w.nI().fz();
                if (TextUtils.isEmpty(fz)) {
                    fz = w.nI().fA();
                }
                if (TextUtils.isEmpty(fz)) {
                    fz = ((aic) bgm.nL(5)).getGuid();
                }
                Object[] objArr = new Object[25];
                objArr[0] = a;
                objArr[1] = !TextUtils.isEmpty(eu) ? eu : "0";
                objArr[2] = !TextUtils.isEmpty(packageName) ? packageName : "0";
                objArr[3] = !TextUtils.isEmpty(eu2) ? eu2 : "0";
                objArr[4] = !TextUtils.isEmpty(eu3) ? eu3 : "0";
                objArr[5] = !TextUtils.isEmpty(eu4) ? eu4 : "0";
                objArr[6] = Integer.valueOf(aaY);
                objArr[7] = eu5;
                objArr[8] = !TextUtils.isEmpty(fz) ? fz : "0";
                objArr[9] = !TextUtils.isEmpty(eu6) ? eu6 : "0";
                objArr[10] = Integer.valueOf(myUid);
                objArr[11] = fGd;
                objArr[12] = str;
                objArr[13] = bX;
                objArr[14] = Rj;
                objArr[15] = Integer.valueOf(RR);
                objArr[16] = Integer.valueOf(i2);
                objArr[17] = Integer.valueOf(i3);
                objArr[18] = 2;
                objArr[19] = Integer.valueOf(intFromEnvMap);
                objArr[20] = Integer.valueOf(i);
                objArr[21] = Integer.valueOf(KF);
                objArr[22] = Integer.valueOf(intFromEnvMap2);
                objArr[23] = eu7;
                objArr[24] = VR;
                format = String.format("chmod 755 %s\n%s\nexit\n", a, String.format("exec %s %s %s %s %s %s %d %s %s %s %d %s %s %s %s %d %d %d %d %d %d %d %d %s %s", objArr));
                processBuilder.redirectErrorStream(true);
                outputStream2 = processBuilder.start().getOutputStream();
            } catch (Exception e) {
                outputStream = null;
            }
            try {
                outputStream2.write(format.getBytes());
                outputStream2.flush();
                if (TextUtils.isEmpty(fz)) {
                    ((lo) bgm.nL(5)).c(new azv() {
                        @Override
                        public void E(int i4, String str2) {
                            if (i4 == 0) {
                                a.G("guid", str2);
                            }
                        }
                    });
                }
                if (outputStream2 != null) {
                    try {
                        outputStream2.close();
                    } catch (Exception e2) {
                    }
                }
            } catch (Exception e3) {
                outputStream = outputStream2;
                if (outputStream != null) {
                    try {
                        outputStream.close();
                    } catch (Exception e4) {
                    }
                }
            }
        } catch (Throwable th) {
            if (0 != 0) {
                try {
                    outputStream3.close();
                } catch (Exception e5) {
                }
            }
            throw th;
        }
    }

    public static void Rd() {
        if (!sn.CQ()) {
            getHandler().postDelayed(new Runnable() {
                @Override
                public void run() {
                    int i;
                    if (a.fGe > 0) {
                        if (com.tencent.server.base.d.kL()) {
                            i = 60000;
                        } else {
                            i = 300000;
                        }
                        long currentTimeMillis = System.currentTimeMillis();
                        if (a.bSu <= 0 || Math.abs(currentTimeMillis - a.bSu) >= i) {
                            a.bSu = currentTimeMillis;
                            if (!a.RD()) {
                                a.m(true, true);
                            } else {
                                yz.c(bgh.PQ().kH(), ba.dAS, 2);
                            }
                        }
                    }
                }
            }, anr.dZK);
        }
    }

    private static synchronized boolean Rf() {
        boolean z;
        synchronized (a.class) {
            try {
                ArrayList<Integer> Rg = Rg();
                if (Rg != null && Rg.size() > 0) {
                    Iterator<Integer> it = Rg.iterator();
                    while (it.hasNext()) {
                        Process.killProcess(it.next().intValue());
                    }
                }
                z = !Rh();
            } catch (Exception e) {
                z = false;
            }
        }
        return z;
    }

    private static ArrayList<Integer> Rg() {
        String[] split;
        int i;
        String[] split2;
        String[] split3;
        String[] split4;
        String[] split5;
        ArrayList<Integer> arrayList = new ArrayList<>();
        try {
            String c = c(new String[]{"pgrep", Rb()}, null);
            if (TextUtils.isEmpty(c)) {
                c = c(new String[]{"pidof", Rb()}, null);
            }
            if (!TextUtils.isEmpty(c) && (split5 = c.split("\n")) != null && split5.length > 0) {
                for (String str : split5) {
                    try {
                        arrayList.add(Integer.valueOf(Integer.valueOf(str).intValue()));
                    } catch (Exception e) {
                    }
                }
            }
            if (arrayList.size() <= 0) {
                String c2 = c(new String[]{"sh", "-c", "ps | grep " + Rb()}, null);
                if (TextUtils.isEmpty(c2)) {
                    c2 = c(new String[]{NetworkMgrConst.key_province_str, Rb()}, null);
                }
                if (!TextUtils.isEmpty(c2) && c2.indexOf(Rb()) >= 0 && (split = c2.split("\n")) != null && split.length > 0) {
                    String c3 = c(new String[]{"sh", "-c", NetworkMgrConst.key_province_str}, null);
                    if (c3 == null || (split3 = c3.split("\n")) == null || split3.length <= 0 || (split4 = split3[0].split(" ")) == null || split4.length <= 0) {
                        i = -1;
                    } else {
                        int i2 = 0;
                        int i3 = 0;
                        while (true) {
                            if (i2 >= split4.length) {
                                i = i3;
                                break;
                            }
                            String str2 = split4[i2];
                            if (str2 != null && str2.trim().length() > 0) {
                                i3++;
                                if (str2.equalsIgnoreCase("pid")) {
                                    i = i3;
                                    break;
                                }
                            }
                            i2++;
                        }
                    }
                    if (i != -1) {
                        for (String str3 : split) {
                            if (str3 != null && str3.contains("com.tencent.qqpimsecure") && (split2 = str3.split(" ")) != null && split2.length > i) {
                                int i4 = 0;
                                for (String str4 : split2) {
                                    if (str4 != null && str4.trim().length() > 0 && (i4 = i4 + 1) == i) {
                                        try {
                                            arrayList.add(Integer.valueOf(Integer.valueOf(str4).intValue()));
                                        } catch (Exception e2) {
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        } catch (Throwable th) {
        }
        return arrayList;
    }

    private static boolean Rh() {
        String c = c(new String[]{"sh", "-c", "ps | grep " + Rb()}, null);
        if (c == null || c.length() == 0) {
            c = c(new String[]{NetworkMgrConst.key_province_str, Rb()}, null);
        }
        return c != null && c.indexOf(Rb()) >= 0 && c.indexOf("com.tencent.qqpimsecure") >= 0;
    }

    public static boolean nQ(int i) {
        boolean z;
        boolean z2;
        long currentTimeMillis = System.currentTimeMillis();
        long RT = b.RT();
        if (i == 1) {
            if (currentTimeMillis > RT && currentTimeMillis - RT < 30000) {
                z = false;
                if (z) {
                    long RL = b.RL();
                    if (i == 1) {
                        b.aG(currentTimeMillis);
                    }
                    int RM = b.RM();
                    if (RM < 0) {
                        RM = 0;
                    }
                    if (i == 1) {
                        if (!tmsdk.common.internal.utils.f.f(RL, currentTimeMillis)) {
                            RM = 0;
                        }
                        RM++;
                        b.oe(RM);
                    }
                    int i2 = RM;
                    long j = -1;
                    if (currentTimeMillis >= 0 && RL >= 0) {
                        j = currentTimeMillis - RL;
                    }
                    if (j > 0) {
                        if (i2 <= 10 || i2 > 20) {
                            if (i2 <= 20 || i2 > 50) {
                                if (i2 > 50 && j < adj.exk) {
                                    z2 = false;
                                    if (i == 1 && i2 > 10 && z2) {
                                        b.oe(0);
                                    }
                                }
                                z2 = z;
                                if (i == 1) {
                                    b.oe(0);
                                }
                            } else {
                                if (j < 30000) {
                                    z2 = false;
                                    if (i == 1) {
                                    }
                                }
                                z2 = z;
                                if (i == 1) {
                                }
                            }
                        } else {
                            if (j < 20000) {
                                z2 = false;
                                if (i == 1) {
                                }
                            }
                            z2 = z;
                            if (i == 1) {
                            }
                        }
                        if (!z2) {
                            String str = "[" + (z2 ? 0 : -1) + "]";
                            if (i == 0) {
                                sm.hE(d.c.cDx);
                                sm.hE("com.anguanjia.security");
                                sm.hE("com.anguanjia.security:fore");
                            } else if (i == 1) {
                                sm.hE(d.c.cDx);
                                sm.hE("com.anguanjia.security:fore");
                                sm.hE("com.anguanjia.security");
                            }
                            sm.killProcess(Process.myPid());
                        }
                        return z2;
                    }
                }
                z2 = z;
                if (!z2) {
                }
                return z2;
            }
        } else if (i == 0) {
            b.aH(0L);
        }
        z = true;
        if (z) {
        }
        z2 = z;
        if (!z2) {
        }
        return z2;
    }

    private static String c(String[] strArr, String str) {
        InputStream inputStream;
        Throwable th;
        StringBuilder sb = new StringBuilder();
        InputStream inputStream2 = null;
        try {
            try {
                ProcessBuilder processBuilder = new ProcessBuilder(strArr);
                if (str != null) {
                    processBuilder.directory(new File(str));
                }
                processBuilder.redirectErrorStream(false);
                InputStream inputStream3 = processBuilder.start().getInputStream();
                try {
                    byte[] bArr = new byte[256];
                    while (true) {
                        int read = inputStream3.read(bArr);
                        if (read == -1) {
                            break;
                        }
                        sb.append(new String(bArr, 0, read));
                    }
                    if (inputStream3 != null) {
                        try {
                            inputStream3.close();
                        } catch (IOException e) {
                        }
                    }
                } catch (Throwable th2) {
                    inputStream = inputStream3;
                    th = th2;
                    if (inputStream == null) {
                        throw th;
                    }
                    try {
                        inputStream.close();
                        throw th;
                    } catch (IOException e2) {
                        throw th;
                    }
                }
            } catch (Throwable th3) {
                inputStream = null;
                th = th3;
            }
        } catch (Exception e3) {
            if (0 != 0) {
                try {
                    inputStream2.close();
                } catch (IOException e4) {
                }
            }
        }
        return sb.toString();
    }

    public static void nR(int i) {
        FileOutputStream fileOutputStream;
        Throwable th;
        if (!sn.CQ()) {
            FileOutputStream fileOutputStream2 = null;
            try {
                String str = com.tencent.server.base.d.agJ().getFilesDir().toString() + File.separator + "j_dd_fl.dat";
                File file = new File(str);
                if (file.exists()) {
                    file.delete();
                }
                fileOutputStream = new FileOutputStream(str);
                try {
                    fileOutputStream.write((SQLiteDatabase.KeyEmpty + i + "\n").getBytes(HTTP.UTF_8));
                    fileOutputStream.flush();
                    if (fileOutputStream != null) {
                        try {
                            fileOutputStream.close();
                        } catch (Exception e) {
                        }
                    }
                } catch (Exception e2) {
                    fileOutputStream2 = fileOutputStream;
                    if (fileOutputStream2 != null) {
                        try {
                            fileOutputStream2.close();
                        } catch (Exception e3) {
                        }
                    }
                } catch (Throwable th2) {
                    th = th2;
                    if (fileOutputStream != null) {
                        try {
                            fileOutputStream.close();
                        } catch (Exception e4) {
                        }
                    }
                    throw th;
                }
            } catch (Exception e5) {
            } catch (Throwable th3) {
                fileOutputStream = null;
                th = th3;
            }
        }
    }

    public static void Ri() {
        if (!new File(com.tencent.server.base.d.agJ().getFilesDir().toString() + File.separator + "x_rb_j_al_ct_2.dat").exists()) {
            nS(2);
        }
    }

    public static void nS(int i) {
        FileOutputStream fileOutputStream;
        Throwable th;
        FileOutputStream fileOutputStream2 = null;
        try {
            String str = com.tencent.server.base.d.agJ().getFilesDir().toString() + File.separator + "x_rb_j_al_ct_2.dat";
            File file = new File(str);
            if (file.exists()) {
                file.delete();
            }
            fileOutputStream = new FileOutputStream(str);
            try {
                fileOutputStream.write((SQLiteDatabase.KeyEmpty + i + "\n").getBytes(HTTP.UTF_8));
                fileOutputStream.flush();
                if (fileOutputStream != null) {
                    try {
                        fileOutputStream.close();
                    } catch (Exception e) {
                    }
                }
            } catch (Exception e2) {
                fileOutputStream2 = fileOutputStream;
                if (fileOutputStream2 != null) {
                    try {
                        fileOutputStream2.close();
                    } catch (Exception e3) {
                    }
                }
            } catch (Throwable th2) {
                th = th2;
                if (fileOutputStream != null) {
                    try {
                        fileOutputStream.close();
                    } catch (Exception e4) {
                    }
                }
                throw th;
            }
        } catch (Exception e5) {
        } catch (Throwable th3) {
            fileOutputStream = null;
            th = th3;
        }
    }

    private static String Rj() {
        if (Build.VERSION.SDK_INT >= 17) {
            return String.format("\"%s --user 0\"", "am startservice -n com.tencent.qqpimsecure/com.tencent.server.back.DaemonService");
        }
        return String.format("\"%s \"", "am startservice -n com.tencent.qqpimsecure/com.tencent.server.back.DaemonService");
    }

    private static String bW(Context context) {
        String guid = ((te) qf.i(te.class)).getGuid();
        String i = ((qz) bgm.nL(12)).i(context);
        WifiInfo connectionInfo = ((WifiManager) context.getSystemService("wifi")).getConnectionInfo();
        String str = SQLiteDatabase.KeyEmpty;
        if (connectionInfo != null) {
            str = connectionInfo.getMacAddress();
        }
        com.tencent.qqpimsecure.service.i uM = com.tencent.qqpimsecure.service.i.uM();
        return String.format("http://m.qq.com/wap/survey/index.jsp?value=%s\\&ts=%d", com.tencent.tcuser.util.a.u(TccCryptor.encrypt(context, String.format("bid=971&guid=%s&imei=%s&mac=%s&version=%s&buildno=%s&ua=%s&osversion=%s", guid, i, str, uM.uR(), uM.uN(), Build.MODEL, Build.VERSION.RELEASE).getBytes(), "j*5#L(0f$RGHR(&*fqnOi".getBytes())), Integer.valueOf((int) System.currentTimeMillis()));
    }

    private static String bX(Context context) {
        Intent intent = new Intent("android.intent.action.VIEW");
        intent.setData(Uri.parse("http://m.qq.com/wap/survey/index.jsp?value=%s\\&ts=%d"));
        List<ResolveInfo> queryIntentActivities = ((qz) bgm.nL(12)).queryIntentActivities(intent, 32);
        if (queryIntentActivities.size() > 0) {
            ResolveInfo resolveInfo = queryIntentActivities.get(0);
            String format = String.format("am start -n %s -a android.intent.action.VIEW -d", resolveInfo.activityInfo.packageName + "/" + resolveInfo.activityInfo.name);
            if (format != null) {
                String bW = bW(context);
                if (Build.VERSION.SDK_INT >= 17) {
                    return String.format("\"%s %s %s\"", format, bW, "--user 0");
                }
                return String.format("\"%s %s\"", format, bW);
            }
        }
        return "0";
    }

    public static void aG(int i, int i2) {
        if (!sn.CQ()) {
            ArrayList arrayList = new ArrayList();
            arrayList.add(Integer.valueOf(i2));
            a(i, arrayList, null);
        }
    }

    public static void aa(int i, String str) {
        if (!sn.CQ()) {
            ArrayList arrayList = new ArrayList();
            arrayList.add(str);
            a(i, null, arrayList);
        }
    }

    private static void a(final int i, final ArrayList<Integer> arrayList, final ArrayList<String> arrayList2) {
        final int Tb = com.meri.service.feature.a.Tb();
        getHandler().post(new Runnable() {
            @Override
            public void run() {
                FileOutputStream fileOutputStream;
                Throwable th;
                StringBuilder sb = new StringBuilder();
                sb.append(i);
                sb.append("|");
                sb.append(Tb);
                sb.append("|");
                String P = com.meri.service.feature.a.P(arrayList);
                if (TextUtils.isEmpty(P)) {
                    P = "NA";
                }
                sb.append(P);
                sb.append("|");
                String Q = com.meri.service.feature.a.Q(arrayList2);
                if (TextUtils.isEmpty(Q)) {
                    Q = "NA";
                }
                sb.append(Q);
                sb.append("|");
                FileOutputStream fileOutputStream2 = null;
                try {
                    try {
                        Context agJ = com.tencent.server.base.d.agJ();
                        String str = SQLiteDatabase.KeyEmpty + sb.toString() + "\n";
                        FileOutputStream openFileOutput = agJ.openFileOutput("x_rp_dt_j.dat", 32768);
                        try {
                            openFileOutput.write(str.getBytes(HTTP.UTF_8));
                            openFileOutput.flush();
                            if (openFileOutput != null) {
                                try {
                                    openFileOutput.close();
                                } catch (Exception e) {
                                }
                            }
                        } catch (Throwable th2) {
                            fileOutputStream = openFileOutput;
                            th = th2;
                            if (fileOutputStream != null) {
                                try {
                                    fileOutputStream.close();
                                    throw th;
                                } catch (Exception e2) {
                                    throw th;
                                }
                            }
                            throw th;
                        }
                    } catch (Throwable th3) {
                        fileOutputStream = null;
                        th = th3;
                    }
                } catch (Exception e3) {
                    if (0 != 0) {
                        try {
                            fileOutputStream2.close();
                        } catch (Exception e4) {
                        }
                    }
                }
            }
        });
    }

    public static void Rk() {
        FileInputStream fileInputStream;
        File file;
        BufferedReader bufferedReader;
        Throwable th;
        FileInputStream fileInputStream2;
        File file2;
        int size;
        int i;
        int i2;
        BufferedReader bufferedReader2 = null;
        if (sn.CQ()) {
            return;
        }
        SparseArray sparseArray = new SparseArray();
        try {
            file = new File(com.tencent.server.base.d.agJ().getFilesDir().toString() + File.separator + "x_nt_dt.dat");
            try {
                if (file.exists()) {
                    fileInputStream = new FileInputStream(file);
                    try {
                        bufferedReader = new BufferedReader(new InputStreamReader(fileInputStream));
                        while (true) {
                            try {
                                try {
                                    String readLine = bufferedReader.readLine();
                                    if (readLine == null) {
                                        break;
                                    }
                                    String[] split = readLine.split("\\|");
                                    if (split.length == 4) {
                                        try {
                                            i2 = Integer.valueOf(split[0]).intValue();
                                            i = Integer.valueOf(split[1]).intValue();
                                        } catch (Exception e) {
                                            i = 0;
                                            i2 = 0;
                                        }
                                        if (i2 == 261406 && i != 0) {
                                            try {
                                                int intValue = Integer.valueOf(split[2]).intValue();
                                                int oo = com.meri.service.feature.a.oo(i);
                                                SparseIntArray sparseIntArray = (SparseIntArray) sparseArray.get(oo);
                                                SparseIntArray sparseIntArray2 = sparseIntArray == null ? new SparseIntArray() : sparseIntArray;
                                                int i3 = sparseIntArray2.get(intValue);
                                                if (i3 < 0) {
                                                    i3 = 0;
                                                }
                                                sparseIntArray2.put(intValue, i3 + 1);
                                                sparseArray.put(oo, sparseIntArray2);
                                            } catch (Exception e2) {
                                            }
                                        }
                                    }
                                } catch (Exception e3) {
                                    bufferedReader2 = bufferedReader;
                                    fileInputStream2 = fileInputStream;
                                    file2 = file;
                                    if (bufferedReader2 != null) {
                                        try {
                                            bufferedReader2.close();
                                        } catch (Exception e4) {
                                        }
                                    }
                                    if (fileInputStream2 != null) {
                                        try {
                                            fileInputStream2.close();
                                        } catch (Exception e5) {
                                        }
                                    }
                                    if (file2 != null && file2.exists()) {
                                        try {
                                            file2.delete();
                                        } catch (Exception e6) {
                                        }
                                    }
                                    size = sparseArray.size();
                                    if (size <= 0) {
                                    }
                                }
                            } catch (Throwable th2) {
                                th = th2;
                                if (bufferedReader != null) {
                                    try {
                                        bufferedReader.close();
                                    } catch (Exception e7) {
                                    }
                                }
                                if (fileInputStream != null) {
                                    try {
                                        fileInputStream.close();
                                    } catch (Exception e8) {
                                    }
                                }
                                if (file == null) {
                                    throw th;
                                }
                                if (!file.exists()) {
                                    throw th;
                                }
                                try {
                                    file.delete();
                                    throw th;
                                } catch (Exception e9) {
                                    throw th;
                                }
                            }
                        }
                    } catch (Exception e10) {
                        fileInputStream2 = fileInputStream;
                        file2 = file;
                    } catch (Throwable th3) {
                        bufferedReader = null;
                        th = th3;
                    }
                } else {
                    bufferedReader = null;
                    fileInputStream = null;
                }
                if (bufferedReader != null) {
                    try {
                        bufferedReader.close();
                    } catch (Exception e11) {
                    }
                }
                if (fileInputStream != null) {
                    try {
                        fileInputStream.close();
                    } catch (Exception e12) {
                    }
                }
                if (file != null && file.exists()) {
                    try {
                        file.delete();
                    } catch (Exception e13) {
                    }
                }
            } catch (Exception e14) {
                fileInputStream2 = null;
                file2 = file;
            } catch (Throwable th4) {
                fileInputStream = null;
                th = th4;
                bufferedReader = null;
            }
        } catch (Exception e15) {
            fileInputStream2 = null;
            file2 = null;
        } catch (Throwable th5) {
            fileInputStream = null;
            file = null;
            bufferedReader = null;
            th = th5;
        }
        try {
            size = sparseArray.size();
            if (size <= 0) {
                for (int i4 = 0; i4 < size; i4++) {
                    ArrayList arrayList = new ArrayList();
                    int keyAt = sparseArray.keyAt(i4);
                    SparseIntArray sparseIntArray3 = (SparseIntArray) sparseArray.valueAt(i4);
                    int size2 = sparseIntArray3.size();
                    for (int i5 = 0; i5 < size2; i5++) {
                        arrayList.add(SQLiteDatabase.KeyEmpty + sparseIntArray3.keyAt(i5) + ":" + sparseIntArray3.valueAt(i5));
                    }
                    FeatureTunnelDB.b bVar = new FeatureTunnelDB.b();
                    bVar.SS = ba.dBk;
                    bVar.fHi = keyAt;
                    bVar.count = 1;
                    bVar.fHk = com.meri.service.feature.a.Q(arrayList);
                    bVar.fHl = 1;
                    bVar.azW = 0;
                    bVar.bir = 1;
                    bVar.w = 1;
                    FeatureTunnelDB.Tz().b(bVar);
                }
            }
        } catch (Exception e16) {
        }
    }

    public static void Rl() {
        if (!sn.CQ()) {
            getHandler().post(new Runnable() {
                @Override
                public void run() {
                    C0009a.C0010a c0010a = new C0009a.C0010a();
                    c0010a.type = 1;
                    C0009a.a(c0010a, true);
                }
            });
        }
    }

    public static void G(final String str, final Object obj) {
        if (!sn.CQ() && !TextUtils.isEmpty(str) && obj != null) {
            getHandler().post(new Runnable() {
                @Override
                public void run() {
                    StringBuilder sb = new StringBuilder();
                    sb.append(str);
                    sb.append("|");
                    if (obj instanceof Integer) {
                        int intValue = ((Integer) obj).intValue();
                        sb.append("0");
                        sb.append("|");
                        sb.append(intValue);
                    } else if (obj instanceof String) {
                        String str2 = (String) obj;
                        sb.append("1");
                        sb.append("|");
                        sb.append(str2);
                    }
                    C0009a.C0010a c0010a = new C0009a.C0010a();
                    c0010a.type = 2;
                    c0010a.data = sb.toString().getBytes();
                    C0009a.a(c0010a, true);
                }
            });
        }
    }

    static class C0009a {

        public static final class C0010a {
            public byte[] data;
            public int size;
            public int type;

            C0010a() {
            }

            void writeToStream(OutputStream outputStream) throws IOException {
                this.size = this.data != null ? this.data.length : 0;
                byte[] bArr = new byte[8];
                System.arraycopy(com.tencent.tcuser.util.a.er(this.type), 0, bArr, 0, 4);
                System.arraycopy(com.tencent.tcuser.util.a.er(this.size), 0, bArr, 4, 4);
                outputStream.write(bArr);
                if (this.data != null && this.data.length > 0) {
                    outputStream.write(this.data);
                }
                outputStream.flush();
            }
        }

        public static final class b {
            public int cqG;
            public byte[] data;
            public int size;

            b() {
            }

            void o(InputStream inputStream) throws IOException {
                int i = 0;
                byte[] bArr = new byte[8];
                if (inputStream.read(bArr) == 8) {
                    byte[] bArr2 = new byte[4];
                    byte[] bArr3 = new byte[4];
                    System.arraycopy(bArr, 0, bArr2, 0, 4);
                    System.arraycopy(bArr, 4, bArr3, 0, 4);
                    this.cqG = com.tencent.tcuser.util.a.v(bArr2);
                    this.size = com.tencent.tcuser.util.a.v(bArr3);
                    try {
                        if (this.size > 0) {
                            byte[] bArr4 = new byte[this.size];
                            while (true) {
                                int read = inputStream.read(bArr4, i, this.size - i);
                                if (read <= 0) {
                                    break;
                                } else {
                                    i += read;
                                }
                            }
                            if (i == this.size) {
                                this.data = bArr4;
                                return;
                            }
                            return;
                        }
                        this.data = new byte[0];
                    } catch (Error e) {
                    }
                }
            }
        }

        static b a(C0010a c0010a, boolean z) {
            InputStream inputStream;
            InputStream inputStream2;
            OutputStream outputStream;
            b bVar;
            OutputStream outputStream2 = null;
            if (c0010a == null || TextUtils.isEmpty(a.fGd)) {
                return null;
            }
            LocalSocket localSocket = new LocalSocket();
            try {
                localSocket.connect(new LocalSocketAddress(a.fGd));
                localSocket.setSoTimeout(30000);
                try {
                    bVar = new b();
                    inputStream = localSocket.getInputStream();
                    try {
                        OutputStream outputStream3 = localSocket.getOutputStream();
                        try {
                            c0010a.writeToStream(outputStream3);
                            bVar.o(inputStream);
                            if (outputStream3 != null) {
                                try {
                                    outputStream3.close();
                                } catch (Exception e) {
                                }
                            }
                            if (inputStream != null) {
                                try {
                                    inputStream.close();
                                } catch (Exception e2) {
                                }
                            }
                            try {
                                localSocket.close();
                            } catch (Exception e3) {
                            }
                        } catch (Exception e4) {
                            inputStream2 = inputStream;
                            outputStream = outputStream3;
                            if (outputStream != null) {
                                try {
                                    outputStream.close();
                                } catch (Exception e5) {
                                }
                            }
                            if (inputStream2 != null) {
                                try {
                                    inputStream2.close();
                                } catch (Exception e6) {
                                }
                            }
                            try {
                                localSocket.close();
                                bVar = null;
                            } catch (Exception e7) {
                                bVar = null;
                            }
                            return bVar;
                        } catch (Throwable th) {
                            th = th;
                            outputStream2 = outputStream3;
                            if (outputStream2 != null) {
                                try {
                                    outputStream2.close();
                                } catch (Exception e8) {
                                }
                            }
                            if (inputStream != null) {
                                try {
                                    inputStream.close();
                                } catch (Exception e9) {
                                }
                            }
                            try {
                                localSocket.close();
                                throw th;
                            } catch (Exception e10) {
                                throw th;
                            }
                        }
                    } catch (Exception e11) {
                        inputStream2 = inputStream;
                        outputStream = null;
                    } catch (Throwable th2) {
                        th = th2;
                    }
                } catch (Exception e12) {
                    inputStream2 = null;
                    outputStream = null;
                } catch (Throwable th3) {
                    th = th3;
                    inputStream = null;
                }
                return bVar;
            } catch (Exception e13) {
                if (!z || a.RD()) {
                    return null;
                }
                a.Rc();
                try {
                    Thread.sleep(200L);
                } catch (Exception e14) {
                }
                return a(c0010a, false);
            }
        }
    }

    private static void Rm() {
        fGg = b.RO();
        getHandler().postDelayed(new Runnable() {
            @Override
            public void run() {
                b.og(1);
            }
        }, 2000L);
        Rv();
    }

    public static int aH(int i, int i2) {
        if (!((1048575 & i) == 0 ? i > 1048576 : false)) {
            com.tencent.server.base.d.bN("InvalidBootReasonException\nmain: " + i + ", sub: " + i2, null);
            return -1;
        }
        if (i2 < 0 || i2 >= 1048576) {
            com.tencent.server.base.d.bN("InvalidBootReasonException\nmain: " + i + ", sub: " + i2, null);
            return i + 0;
        }
        return i + i2;
    }

    public static int nT(int i) {
        return (-1048576) & i;
    }

    private static int Rn() {
        try {
            fDq.readLock().lock();
            return fGh;
        } finally {
            fDq.readLock().unlock();
        }
    }

    private static void nV(int i) {
        try {
            fDq.writeLock().lock();
            fGh = i;
        } finally {
            fDq.writeLock().unlock();
        }
    }

    public static void me(String str) {
        fGi = str;
    }

    private static String Ro() {
        return fGi;
    }

    public static int k(String str, String str2, String str3) {
        int i;
        try {
            if (!TextUtils.isEmpty(str)) {
                if (!TextUtils.isEmpty(str3)) {
                    try {
                        i = Integer.valueOf(str3).intValue();
                    } catch (Exception e) {
                        i = -1;
                    }
                    if (i > 0 && i <= 999999) {
                        return i;
                    }
                }
                if (str.contains("wechat") || str.contains(aaf.b.dnj)) {
                    return 201;
                }
                if (str.contains(rl.b.dcY) || str.contains("com.tencent.mobileqq")) {
                    return 202;
                }
                if (str.contains("yyb") || str.contains("myapp_m") || str.contains("com.tencent.android.qqdownloader")) {
                    return 203;
                }
                if (str.contains("com.tencent.mtt")) {
                    return 204;
                }
                if (str.contains("com.meizu.safe")) {
                    return 205;
                }
                if (str.contains("com.mycheering.apps")) {
                    return 206;
                }
            }
        } catch (Exception e2) {
        }
        return 0;
    }

    public static void a(final int i, final int i2, final String str, final int i3, final String str2, final String str3, final boolean z) {
        if (com.tencent.server.base.d.aTO() != 1) {
            getHandler().post(new Runnable() {
                @Override
                public void run() {
                    int i4 = i;
                    int i5 = i2;
                    String str4 = str;
                    String str5 = str2;
                    String str6 = str3;
                    int i6 = i3;
                    boolean z2 = z;
                    Bundle bundle = new Bundle();
                    bundle.putInt("flag", 2);
                    bundle.putInt(meri.pluginsdk.d.ewm, i4);
                    bundle.putString(meri.pluginsdk.d.ewn, str4);
                    bundle.putString(meri.pluginsdk.d.ewo, str5);
                    bundle.putString(meri.pluginsdk.d.ewp, str6);
                    bundle.putBoolean(meri.pluginsdk.d.ewq, z2);
                    bundle.putInt(meri.pluginsdk.d.eBh, i6);
                    bundle.putInt(meri.pluginsdk.d.eBi, i5);
                    com.tencent.server.fore.d.aVu().v(8219, bundle);
                }
            });
            return;
        }
        int Rn = Rn();
        long currentTimeMillis = System.currentTimeMillis() - QQSecureApplication.bbZ;
        if (Rn > 0 && currentTimeMillis > 3000) {
            if (i == 3145728 || i == 6291456 || i == 7340032 || i == 8388608 || i == 9437184 || i == 10485760) {
                getHandler().postDelayed(new Runnable() {
                    @Override
                    public void run() {
                        int i4;
                        int i5 = 4;
                        try {
                            int i6 = i;
                            switch (i6) {
                                case 6291456:
                                    i5 = a.k(str, str2, str3);
                                    i4 = i6;
                                    break;
                                case 7340032:
                                    if ("shortcut".equals(str)) {
                                        i5 = a.k(str, str2, str3);
                                        if (i5 != 0) {
                                            i4 = 3145728;
                                            break;
                                        } else {
                                            i5 = 2;
                                            i4 = 3145728;
                                            break;
                                        }
                                    } else if ("sysmms".equals(str)) {
                                        i5 = 3;
                                        i4 = 3145728;
                                        break;
                                    } else if (!"reboot".equals(str)) {
                                        if ("wifiset".equals(str)) {
                                            i5 = 5;
                                            i4 = 3145728;
                                            break;
                                        } else {
                                            i4 = "daemon".equals(str) ? 10485760 : i6;
                                            i5 = a.k(str, str2, str3);
                                            break;
                                        }
                                    } else {
                                        i4 = 3145728;
                                        break;
                                    }
                                default:
                                    i5 = 0;
                                    i4 = i6;
                                    break;
                            }
                            if (i2 > 0) {
                                i5 = i2;
                            }
                            if (!a.nW(i4)) {
                                int aH = a.aH(i4, i5);
                                ArrayList arrayList = new ArrayList();
                                arrayList.add(SQLiteDatabase.KeyEmpty + i4);
                                arrayList.add(SQLiteDatabase.KeyEmpty + aH);
                                arrayList.add("0");
                                arrayList.add(SQLiteDatabase.KeyEmpty + QQSecureApplication.bbZ);
                                arrayList.add(SQLiteDatabase.KeyEmpty + QQSecureApplication.hDm);
                                arrayList.add("2");
                                yz.b(bgh.PQ().kH(), ba.cjQ, arrayList, 4);
                            }
                        } catch (Exception e) {
                        }
                    }
                }, 20000L);
                return;
            }
            return;
        }
        getHandler().postDelayed(new Runnable() {
            @Override
            public void run() {
                int i4 = 3;
                int i5 = i;
                switch (i5) {
                    case 4194304:
                        String str4 = str;
                        if (!"android.net.wifi.WIFI_STATE_CHANGED".equals(str4) && !"android.net.wifi.STATE_CHANGE".equals(str4)) {
                            if (!"android.bluetooth.adapter.action.STATE_CHANGED".equals(str4)) {
                                if (!"android.net.conn.CONNECTIVITY_CHANGE".equals(str4) && !"android.intent.action.ANY_DATA_STATE".equals(str4)) {
                                    if (!"android.intent.action.USER_PRESENT".equals(str4)) {
                                        if (auv.g.d.SMS_RECEIVED_ACTION.equals(str4) || "android.provider.Telephony.GSM_SMS_RECEIVED".equals(str4)) {
                                            i4 = 6;
                                            break;
                                        } else if ("android.intent.action.TIME_SET".equals(str4) || "android.intent.action.DATE_CHANGED".equals(str4)) {
                                            i4 = 8;
                                            break;
                                        } else {
                                            if ("android.intent.action.MEDIA_UNMOUNTED".equals(str4) || "android.intent.action.MEDIA_REMOVED".equals(str4) || "android.intent.action.MEDIA_CHECKING".equals(str4) || "android.intent.action.MEDIA_EJECT".equals(str4)) {
                                                i4 = 7;
                                                break;
                                            }
                                            i4 = 0;
                                            break;
                                        }
                                    } else {
                                        i4 = 5;
                                        break;
                                    }
                                } else {
                                    i4 = 4;
                                    break;
                                }
                            }
                        } else {
                            i4 = 2;
                            break;
                        }
                        break;
                    case 6291456:
                        i4 = a.k(str, str2, str3);
                        break;
                    case 7340032:
                        if ("shortcut".equals(str)) {
                            i4 = a.k(str, str2, str3);
                            if (i4 != 0) {
                                i5 = 3145728;
                                break;
                            } else {
                                i4 = 2;
                                i5 = 3145728;
                                break;
                            }
                        } else if (!"sysmms".equals(str)) {
                            if (!"reboot".equals(str)) {
                                if (!"wifiset".equals(str)) {
                                    i5 = "daemon".equals(str) ? 10485760 : i5;
                                    i4 = a.k(str, str2, str3);
                                    break;
                                } else {
                                    i4 = 5;
                                    i5 = 3145728;
                                    break;
                                }
                            } else {
                                i4 = 4;
                                i5 = 3145728;
                                break;
                            }
                        } else {
                            i5 = 3145728;
                            break;
                        }
                    default:
                        i4 = 0;
                        break;
                }
                if (i2 > 0) {
                    i4 = i2;
                }
                a.aI(i5, i4);
                a.me(SQLiteDatabase.KeyEmpty + (TextUtils.isEmpty(str) ? "NA" : str) + ";" + i3 + ";" + (TextUtils.isEmpty(str2) ? "NA" : str2) + ";" + (TextUtils.isEmpty(str3) ? "NA" : str3));
            }
        }, z ? 1000 : 1);
    }

    public static void k(final int i, final int i2, boolean z) {
        if (com.tencent.server.base.d.aTO() != 1) {
            getHandler().post(new Runnable() {
                @Override
                public void run() {
                    Bundle bundle = new Bundle();
                    bundle.putInt("flag", 1);
                    bundle.putInt(meri.pluginsdk.d.ewm, i);
                    bundle.putInt(meri.pluginsdk.d.ewn, i2);
                    com.tencent.server.fore.d.aVu().v(8219, bundle);
                }
            });
            return;
        }
        int Rn = Rn();
        long currentTimeMillis = System.currentTimeMillis() - QQSecureApplication.bbZ;
        if (Rn > 0 && currentTimeMillis > 3000) {
            if (i == 3145728 || i == 6291456 || i == 7340032 || i == 8388608 || i == 9437184 || i == 10485760) {
                getHandler().postDelayed(new Runnable() {
                    @Override
                    public void run() {
                        try {
                            int i3 = i;
                            int i4 = i2;
                            if (!a.nW(i3)) {
                                int aH = a.aH(i3, i4);
                                ArrayList arrayList = new ArrayList();
                                arrayList.add(SQLiteDatabase.KeyEmpty + i3);
                                arrayList.add(SQLiteDatabase.KeyEmpty + aH);
                                arrayList.add("0");
                                arrayList.add(SQLiteDatabase.KeyEmpty + QQSecureApplication.bbZ);
                                arrayList.add(SQLiteDatabase.KeyEmpty + QQSecureApplication.hDm);
                                arrayList.add("2");
                                yz.b(bgh.PQ().kH(), ba.cjQ, arrayList, 4);
                            }
                        } catch (Exception e) {
                        }
                    }
                }, 20000L);
                return;
            }
            return;
        }
        getHandler().postDelayed(new Runnable() {
            @Override
            public void run() {
                a.aI(i, i2);
            }
        }, z ? 1000 : 1);
    }

    public static boolean nW(int i) {
        boolean z = false;
        try {
            if (p.aTY().getInt("bb", 1) != 2) {
                int i2 = p.aTY().getInt("bc", 0);
                int oo = com.meri.service.feature.a.oo(com.meri.service.feature.a.Tb());
                p.aTY().C("bc", oo);
                if (oo != i2) {
                    p.aTY().V("bd", SQLiteDatabase.KeyEmpty + i + ";");
                } else {
                    String string = p.aTY().getString("bd", null);
                    if (!TextUtils.isEmpty(string) && string.contains(SQLiteDatabase.KeyEmpty + i + ";")) {
                        z = true;
                    }
                    if (!z) {
                        p.aTY().V("bd", SQLiteDatabase.KeyEmpty + string + i + ";");
                    }
                }
            }
        } catch (Throwable th) {
        }
        return z;
    }

    public static void aI(int i, int i2) {
        int Rn = Rn();
        long currentTimeMillis = System.currentTimeMillis() - QQSecureApplication.bbZ;
        if (Rn <= 0 || (currentTimeMillis <= 3000 && nT(Rn) != 3145728 && i == 3145728)) {
            long j = QQSecureApplication.hDm;
            if (i == 4194304 && j < rf.cNk) {
                i = 5242880;
            }
            int aH = aH(i, i2);
            nV(aH);
            b.oj(aH);
            bgv.SI().ok(i2);
        }
    }

    public static int Rq() {
        int Rn = Rn();
        if (Rn <= 0) {
            int RX = b.RX();
            nV(RX);
            return RX;
        }
        return Rn;
    }

    public static boolean Rs() {
        return Rn() < 0;
    }

    public static boolean Rt() {
        int nT = nT(Rn());
        if (3145728 == nT || 5242880 == nT) {
            return true;
        }
        return false;
    }

    private static void Rv() {
        getHandler().postDelayed(new Runnable() {
            @Override
            public void run() {
                int i;
                String[] split;
                int Rq = a.Rq();
                int nT = a.nT(Rq);
                int i2 = a.fGg;
                if (i2 <= 0) {
                    if (b.RN()) {
                        i2 = 2;
                    } else {
                        i2 = 999;
                        b.bG(true);
                    }
                }
                if (i2 == 1) {
                    i2 = 3;
                }
                int i3 = 0;
                long RJ = a.RJ();
                long RZ = b.RZ();
                if (RJ != RZ) {
                    b.aI(RJ);
                    if (RZ > 0) {
                        i3 = 1;
                    }
                }
                ArrayList arrayList = new ArrayList();
                arrayList.add(SQLiteDatabase.KeyEmpty + nT);
                arrayList.add(SQLiteDatabase.KeyEmpty + Rq);
                arrayList.add(SQLiteDatabase.KeyEmpty + i2);
                arrayList.add(SQLiteDatabase.KeyEmpty + QQSecureApplication.bbZ);
                arrayList.add(SQLiteDatabase.KeyEmpty + QQSecureApplication.hDm);
                arrayList.add(SQLiteDatabase.KeyEmpty + i3);
                yz.b(bgh.PQ().kH(), ba.cjQ, arrayList, 22);
                if (i3 > 0) {
                    yz.b(bgh.PQ().kH(), ba.eBE, arrayList, 22);
                    long j = QQSecureApplication.hDm;
                    if (j >= 0 && j <= rf.cNk) {
                        h.mu().bn(true);
                    } else {
                        h.mu().bn(false);
                    }
                }
                switch (i2) {
                    case 1:
                    case 3:
                        i = ba.dan;
                        break;
                    case 2:
                        i = ba.dam;
                        break;
                    case 4:
                        i = ba.dao;
                        break;
                    case 5:
                        i = ba.dap;
                        break;
                    case 6:
                    default:
                        i = 0;
                        break;
                    case 7:
                        i = ba.afw;
                        yz.a(bgh.PQ().kH(), ba.dAD, 1, 1);
                        break;
                    case 8:
                        i = ba.afw;
                        yz.a(bgh.PQ().kH(), ba.dAE, 1, 1);
                        if (p.aTY().getBoolean("ac", false)) {
                            String Sb = b.Sb();
                            if (!TextUtils.isEmpty(Sb)) {
                                com.tencent.server.base.d.bN("InvisbleAnrException\n" + Sb, null);
                                b.mi(SQLiteDatabase.KeyEmpty);
                                break;
                            }
                        }
                        break;
                }
                if (i > 0) {
                    yz.a(bgh.PQ().kH(), i, 1, 1);
                }
                int RP = b.RP();
                if (RP > 0) {
                    b.oh(0);
                    yz.a(bgh.PQ().kH(), ba.afx, RP, 1);
                }
                boolean z = false;
                String str = "System";
                switch (nT) {
                    case 3145728:
                        str = "User";
                        break;
                    case 4194304:
                        str = "Revive";
                        break;
                    case 5242880:
                        str = DataEntityKeyConst.AutoBoot_BOOL;
                        break;
                    case 6291456:
                        str = "TmsLite";
                        break;
                    case 7340032:
                        str = "OutJump";
                        z = true;
                        break;
                    case 8388608:
                        str = "Xdm";
                        break;
                    case 9437184:
                        str = "Bdm";
                        break;
                    case 10485760:
                        str = "Catfish";
                        break;
                }
                if (z) {
                    try {
                        ArrayList arrayList2 = new ArrayList();
                        arrayList2.add(str);
                        String RK = a.RK();
                        if (RK != null && (split = RK.split(";")) != null && split.length > 0) {
                            for (String str2 : split) {
                                arrayList2.add(str2);
                            }
                        }
                        arrayList2.add(SQLiteDatabase.KeyEmpty + QQSecureApplication.bbZ);
                        yz.b(bgh.PQ().kH(), ba.bfO, arrayList2, 22);
                    } catch (Exception e) {
                    }
                }
            }
        }, 10000L);
    }

    public static long nX(int i) {
        BufferedReader bufferedReader;
        long j = 0;
        BufferedReader bufferedReader2 = null;
        try {
            bufferedReader = new BufferedReader(new InputStreamReader(new FileInputStream("/proc/" + i + "/stat")), 1000);
        } catch (Exception e) {
            bufferedReader = null;
        } catch (Throwable th) {
            th = th;
        }
        try {
            String readLine = bufferedReader.readLine();
            bufferedReader.close();
            if (readLine != null && readLine.length() > 0) {
                j = Long.parseLong(readLine.split(" ")[21]);
            }
            if (bufferedReader != null) {
                try {
                    bufferedReader.close();
                } catch (IOException e2) {
                }
            }
        } catch (Exception e3) {
            if (bufferedReader != null) {
                try {
                    bufferedReader.close();
                } catch (IOException e4) {
                }
            }
            return j;
        } catch (Throwable th2) {
            th = th2;
            bufferedReader2 = bufferedReader;
            if (bufferedReader2 != null) {
                try {
                    bufferedReader2.close();
                } catch (IOException e5) {
                }
            }
            throw th;
        }
        return j;
    }

    private static long Rw() {
        long j;
        int i;
        if (sn.CQ()) {
            return 0L;
        }
        try {
            ArrayList arrayList = new ArrayList();
            arrayList.add("system_server");
            List<Encode.ProcessInfo> aE = Encode.aE(arrayList);
            int i2 = 0;
            while (true) {
                int i3 = i2;
                if (i3 >= aE.size()) {
                    i = -1;
                    break;
                }
                if (!"system_server".equalsIgnoreCase(aE.get(i3).name)) {
                    i2 = i3 + 1;
                } else {
                    i = aE.get(i3).pid;
                    break;
                }
            }
            j = i + nX(i);
        } catch (Throwable th) {
            j = 0;
        }
        return j;
    }

    public static void Rx() {
        if (Build.VERSION.SDK_INT >= 21) {
            try {
                Context agJ = com.tencent.server.base.d.agJ();
                JobScheduler jobScheduler = (JobScheduler) agJ.getSystemService("jobscheduler");
                JobInfo.Builder builder = new JobInfo.Builder(1, new ComponentName(agJ.getPackageName(), JobSchedulerService.class.getName()));
                builder.setPeriodic(14400000L);
                builder.setPersisted(true);
                jobScheduler.schedule(builder.build());
            } catch (Exception e) {
            }
        }
    }

    public static int Ry() {
        return fGg;
    }

    public static void Rz() {
        String str = null;
        try {
            boolean z = p.aTY().getBoolean("ap", true);
            Context agJ = com.tencent.server.base.d.agJ();
            AccountManager accountManager = AccountManager.get(agJ);
            Account[] accountsByType = accountManager.getAccountsByType("com.anguanjia.security");
            if (accountsByType == null || accountsByType.length <= 0) {
                if (z) {
                    Account account = new Account(agJ.getString(bdh.h.flA), "com.anguanjia.security");
                    w.nI().vK();
                    try {
                        str = w.nI().fz();
                    } catch (Exception e) {
                    }
                    if (TextUtils.isEmpty(str)) {
                        str = "qqpimsecure";
                    }
                    if (accountManager.addAccountExplicitly(account, str, null)) {
                        ContentResolver.setIsSyncable(account, "com.anguanjia.security.SyncProvider", 1);
                        ContentResolver.setSyncAutomatically(account, "com.anguanjia.security.SyncProvider", true);
                    }
                    if (Build.VERSION.SDK_INT >= 8) {
                        ContentResolver.addPeriodicSync(account, "com.anguanjia.security.SyncProvider", new Bundle(), 43200L);
                        return;
                    }
                    return;
                }
                return;
            }
            if (!z && Build.VERSION.SDK_INT >= 22) {
                accountManager.removeAccountExplicitly(accountsByType[0]);
            }
        } catch (Throwable th) {
            com.tencent.server.base.d.n(th);
        }
    }
}