手机管家 v7.2.0版本的 MD5 值为:dd92ba71696e35a4b841cd1b5de53cd3

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


package tcs;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import com.tencent.kingkong.database.SQLiteDatabase;
import com.tencent.server.base.l;
import com.tencent.tmsecurelite.base.TmsConst;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import meri.service.conch.ConchService;
import tcs.ahi;
import tcs.aic;
import tcs.bjr;
import tmsdk.common.TMSDKContext;

public class bjs {
    private static final String[] fQs = {"pmir.3g.qq.com", "uploadserver.3g.qq.com"};
    private static bjs fQx;
    private bjr fQt;
    private a fQu;
    private Handler fQw;
    private boolean fQv = false;
    private ahi.b fQy = null;

    public static bjs Vb() {
        if (fQx == null) {
            synchronized (bjs.class) {
                if (fQx == null) {
                    fQx = new bjs();
                }
            }
        }
        return fQx;
    }

    private bjs() {
        this.fQw = null;
        this.fQw = new Handler(((aig) bir.pC(4)).ez("HostMonitor")) {
            @Override
            public void handleMessage(Message message) {
                boolean z;
                switch (message.what) {
                    case 2:
                        if (bjq.UY().UZ()) {
                            bjs.this.fQw.sendEmptyMessage(3);
                            return;
                        }
                        if (((qq) bir.pC(11)).KL()) {
                            bjs.this.startWatching();
                            return;
                        } else {
                            if (bjs.this.fQy == null) {
                                bjs.this.fQy = new ahi.b() {
                                    @Override
                                    public void a(int i, Intent intent) {
                                        switch (i) {
                                            case 1005:
                                                if (intent.getIntExtra(ahi.bsO, 2) == 0) {
                                                    bjs.this.fQw.sendEmptyMessage(2);
                                                    return;
                                                }
                                                return;
                                            default:
                                                return;
                                        }
                                    }
                                };
                                ((ahi) bir.pC(8)).a(1005, bjs.this.fQy);
                                return;
                            }
                            return;
                        }
                    case 3:
                        bjs.this.stopWatching();
                        return;
                    case 4:
                        try {
                            ConchService conchService = (ConchService) bir.pC(17);
                            ConchService.ConchPushInfo conchPushInfo = (ConchService.ConchPushInfo) message.obj;
                            akm akmVar = (akm) agn.a(conchPushInfo.ckr.aBg, new akm(), false);
                            boolean z2 = com.tencent.tcuser.util.a.nd(akmVar.bsa.get(0)) != 0;
                            bjq.UY().bK(!z2);
                            if (!z2) {
                                bjs.this.fQw.sendEmptyMessage(3);
                                conchService.a(conchPushInfo, 3, 1);
                                return;
                            }
                            if (akmVar.bsa.size() == 1) {
                                bjs.this.fQw.sendEmptyMessage(2);
                                conchService.a(conchPushInfo, 3, 1);
                                return;
                            }
                            pz pzVar = new pz();
                            pzVar.ib = akmVar.bsa.size() > 1 ? akmVar.bsa.get(1) : SQLiteDatabase.KeyEmpty;
                            pzVar.ic = akmVar.bsa.size() > 2 ? akmVar.bsa.get(2) : SQLiteDatabase.KeyEmpty;
                            pzVar.ie = akmVar.bsa.size() > 3 ? akmVar.bsa.get(3) : SQLiteDatabase.KeyEmpty;
                            qa qaVar = new qa();
                            qaVar.ig = new ArrayList<>();
                            qaVar.ig.add(pzVar);
                            qa b = bjs.this.b(qaVar);
                            if (b != null && b.ig != null) {
                                Iterator<pz> it = b.ig.iterator();
                                while (it.hasNext()) {
                                    pz next = it.next();
                                    if (next != null && ("1".equals(next.f44if) || "0".equals(next.f44if))) {
                                        z = true;
                                        conchService.a(conchPushInfo, 3, !z ? 1 : 2);
                                        return;
                                    }
                                }
                            }
                            z = false;
                            conchService.a(conchPushInfo, 3, !z ? 1 : 2);
                            return;
                        } catch (Exception e) {
                            return;
                        }
                    case 5:
                        if (!bjq.UY().UZ()) {
                            bjs.this.stopWatching();
                            try {
                                bjs.this.aI(bjs.a(bjs.this.Vc()));
                            } catch (Exception e2) {
                            }
                            bjs.this.fQw.sendEmptyMessage(2);
                            return;
                        }
                        bjs.this.fQw.sendEmptyMessage(3);
                        return;
                    default:
                        return;
                }
            }
        };
        com.tencent.server.back.b.aSv().a(new l.b() {
            @Override
            public ArrayList<Integer> Rb() {
                ArrayList<Integer> arrayList = new ArrayList<>();
                arrayList.add(64);
                return arrayList;
            }

            @Override
            public int l(int i, Bundle bundle, Bundle bundle2) {
                switch (i) {
                    case 64:
                        if (bundle != null) {
                            try {
                                qa qaVar = (qa) bundle.getSerializable(meri.pluginsdk.d.bss);
                                if (qaVar != null) {
                                    qa b = bjs.this.b(qaVar);
                                    if (bundle2 == null) {
                                        bundle2 = new Bundle();
                                    }
                                    if (b != null) {
                                        qaVar = b;
                                    }
                                    bundle2.putSerializable("ret", qaVar);
                                    return 0;
                                }
                                return 0;
                            } catch (Exception e) {
                                return 0;
                            }
                        }
                        return 0;
                    default:
                        return 0;
                }
            }
        });
    }

    public void vr() {
        if (!bjq.UY().UZ()) {
            this.fQw.sendEmptyMessageDelayed(5, 1800000L);
            this.fQw.sendEmptyMessage(2);
        }
    }

    public void e(ConchService.ConchPushInfo conchPushInfo) {
        if (conchPushInfo != null) {
            Message obtain = Message.obtain();
            obtain.what = 4;
            obtain.obj = conchPushInfo;
            this.fQw.sendMessage(obtain);
        }
    }

    public void startWatching() {
        if (!this.fQv) {
            this.fQv = true;
            if (this.fQt == null) {
                this.fQu = new a();
                this.fQt = new bjr(this.fQu);
            }
            this.fQt.startWatching();
        }
    }

    public void stopWatching() {
        if (this.fQv) {
            this.fQv = false;
            if (this.fQt != null) {
                this.fQt.stopWatching();
            }
        }
    }

    public class a implements bjr.a {
        private a() {
        }

        @Override
        public void Va() {
            bjs.this.fQw.removeMessages(5);
            bjs.this.fQw.sendEmptyMessageDelayed(5, 3000L);
        }
    }

    public qa b(qa qaVar) {
        String lowerCase;
        boolean z;
        boolean z2;
        stopWatching();
        try {
            ArrayList arrayList = new ArrayList();
            Map<String, String> Vd = Vd();
            boolean z3 = false;
            if (qaVar != null && qaVar.ig != null) {
                Iterator<pz> it = qaVar.ig.iterator();
                while (it.hasNext()) {
                    pz next = it.next();
                    if (Integer.parseInt(next.ib) == 4098 || Integer.parseInt(next.ib) == 3) {
                        a(Vd, next.ic.toLowerCase(), arrayList);
                        if (!z3) {
                            z2 = true;
                            z3 = z2;
                        }
                    }
                    z2 = z3;
                    z3 = z2;
                }
                Iterator<pz> it2 = qaVar.ig.iterator();
                while (it2.hasNext()) {
                    pz next2 = it2.next();
                    if ((Integer.parseInt(next2.ib) == 4097 || Integer.parseInt(next2.ib) == 2) && (lowerCase = next2.ic.toLowerCase()) != null && lowerCase.length() > 0) {
                        String lowerCase2 = next2.ie.toLowerCase();
                        if (lowerCase2 == null || lowerCase2.length() == 0) {
                            lowerCase2 = "127.0.0.1";
                            next2.ie = "127.0.0.1";
                        }
                        Vd.put(lowerCase, lowerCase2);
                        if (!z3) {
                            z = true;
                            z3 = z;
                        }
                    }
                    z = z3;
                    z3 = z;
                }
                Iterator<pz> it3 = qaVar.ig.iterator();
                while (it3.hasNext()) {
                    pz next3 = it3.next();
                    if (Integer.parseInt(next3.ib) == 1) {
                        List<bjt> b = b(Vd, next3.ic.toLowerCase());
                        if (b != null && b.size() > 0) {
                            next3.f44if = "1";
                        } else {
                            next3.f44if = "-1";
                        }
                    }
                }
            }
            if (z3) {
                e(Vd);
                Map<String, String> Vd2 = Vd();
                Iterator<pz> it4 = qaVar.ig.iterator();
                while (it4.hasNext()) {
                    pz next4 = it4.next();
                    if (Integer.parseInt(next4.ib) == 4098 || Integer.parseInt(next4.ib) == 3) {
                        String lowerCase3 = next4.ic.toLowerCase();
                        Iterator<String> it5 = Vd2.keySet().iterator();
                        while (it5.hasNext()) {
                            try {
                                if (it5.next().matches(lowerCase3)) {
                                    next4.f44if = "-1";
                                } else {
                                    next4.f44if = "0";
                                }
                            } catch (Exception e) {
                            }
                        }
                    }
                }
                Iterator<pz> it6 = qaVar.ig.iterator();
                while (it6.hasNext()) {
                    pz next5 = it6.next();
                    if (Integer.parseInt(next5.ib) == 4097 || Integer.parseInt(next5.ib) == 2) {
                        if (Vd2.keySet().contains(next5.ic.toLowerCase())) {
                            next5.f44if = "0";
                        } else {
                            next5.f44if = "-1";
                        }
                    }
                }
            }
        } catch (Exception e2) {
        }
        startWatching();
        return qaVar;
    }

    public qa Vc() {
        return (qa) tmsdk.common.internal.utils.z.a(com.tencent.server.base.d.agJ(), tmsdk.common.module.update.e.lb, tmsdk.common.module.update.e.ms(jb.Vf), new qa(), "UTF-8");
    }

    public static List<bjt> a(qa qaVar) {
        ArrayList arrayList = new ArrayList();
        ArrayList arrayList2 = new ArrayList();
        Map<String, String> Vd = Vd();
        LinkedHashMap linkedHashMap = new LinkedHashMap(Vd);
        int size = Vd.size();
        for (String str : fQs) {
            b(Vd, str.toLowerCase(), arrayList2);
        }
        if (qaVar != null && qaVar.ig != null) {
            Iterator<pz> it = qaVar.ig.iterator();
            while (it.hasNext()) {
                pz next = it.next();
                if (Integer.parseInt(next.ib) == 3) {
                    a(Vd, next.ic.toLowerCase(), arrayList2);
                } else if (Integer.parseInt(next.ib) == 1) {
                    arrayList.addAll(b(Vd, next.ic.toLowerCase()));
                }
            }
        }
        if (Vd.size() < size) {
            e(Vd);
            arrayList.addAll(a(arrayList2, linkedHashMap));
        }
        return arrayList;
    }

    private static List<bjt> a(List<String> list, Map<String, String> map) {
        ArrayList arrayList = new ArrayList();
        Map<String, String> Vd = Vd();
        int currentTimeMillis = (int) (System.currentTimeMillis() / 1000);
        for (String str : list) {
            if (Vd.keySet().contains(str)) {
                arrayList.add(new bjt(str, map.get(str), currentTimeMillis, -1));
            } else {
                arrayList.add(new bjt(str, map.get(str), currentTimeMillis, 0));
            }
        }
        return arrayList;
    }

    private static void a(Map<String, String> map, String str, List<String> list) {
        for (String str2 : new HashSet(map.keySet())) {
            try {
                if (str2.matches(str)) {
                    map.remove(str2);
                    list.add(str2);
                }
            } catch (Exception e) {
            }
        }
    }

    private static List<bjt> b(Map<String, String> map, String str) {
        ArrayList arrayList = new ArrayList();
        int currentTimeMillis = (int) (System.currentTimeMillis() / 1000);
        for (Map.Entry<String, String> entry : map.entrySet()) {
            try {
                String key = entry.getKey();
                if (key.matches(str)) {
                    arrayList.add(new bjt(key, entry.getValue(), currentTimeMillis, 1));
                }
            } catch (Exception e) {
            }
        }
        return arrayList;
    }

    private static void b(Map<String, String> map, String str, List<String> list) {
        for (String str2 : new HashSet(map.keySet())) {
            if (str2.contains(str)) {
                map.remove(str2);
                list.add(str2);
            }
        }
    }

    private static Map<String, String> Vd() {
        BufferedReader bufferedReader;
        LinkedHashMap linkedHashMap = new LinkedHashMap();
        File file = new File("/system/etc/hosts");
        if (file.exists()) {
            ((qq) bir.pC(11)).T(-1, "chmod 755 /system/etc/hosts");
            BufferedReader bufferedReader2 = null;
            try {
                bufferedReader = new BufferedReader(new FileReader(file));
                while (true) {
                    try {
                        String readLine = bufferedReader.readLine();
                        if (readLine == null) {
                            break;
                        }
                        String trim = readLine.trim();
                        if (!SQLiteDatabase.KeyEmpty.equals(trim) && !trim.startsWith("#")) {
                            int indexOf = trim.indexOf("#");
                            if (indexOf > 0) {
                                trim = trim.substring(0, indexOf).trim();
                            }
                            String[] split = trim.toLowerCase().split("\\s+");
                            if (split.length == 2 || split.length == 3) {
                                linkedHashMap.put(split[1], split[0]);
                            }
                        }
                    } catch (Exception e) {
                        if (bufferedReader != null) {
                            try {
                                bufferedReader.close();
                            } catch (Exception e2) {
                            }
                        }
                        return linkedHashMap;
                    } catch (Throwable th) {
                        bufferedReader2 = bufferedReader;
                        th = th;
                        if (bufferedReader2 != null) {
                            try {
                                bufferedReader2.close();
                            } catch (Exception e3) {
                            }
                        }
                        throw th;
                    }
                }
                if (bufferedReader != null) {
                    try {
                        bufferedReader.close();
                    } catch (Exception e4) {
                    }
                }
            } catch (Exception e5) {
                bufferedReader = null;
            } catch (Throwable th2) {
                th = th2;
            }
        }
        return linkedHashMap;
    }

    private static void e(Map<String, String> map) {
        File file = new File(TMSDKContext.getApplicaionContext().getFilesDir(), "temp_hosts");
        file.delete();
        for (Map.Entry<String, String> entry : map.entrySet()) {
            e(file, entry.getValue() + " " + entry.getKey() + "\n");
        }
        qq qqVar = (qq) bir.pC(11);
        ArrayList arrayList = new ArrayList();
        arrayList.add("mount -o remount rw /system\n");
        arrayList.add("rm /system/etc/hosts\n");
        arrayList.add("cat " + file.getAbsolutePath() + " > /system/etc/hosts\n");
        qqVar.g(-1, arrayList);
        file.delete();
    }

    private static void e(File file, String str) {
        FileOutputStream fileOutputStream;
        FileOutputStream fileOutputStream2 = null;
        try {
            fileOutputStream = new FileOutputStream(file, true);
            try {
                fileOutputStream.write(str.getBytes());
                if (fileOutputStream != null) {
                    try {
                        fileOutputStream.close();
                    } catch (IOException e) {
                    }
                }
            } catch (Exception e2) {
                if (fileOutputStream != null) {
                    try {
                        fileOutputStream.close();
                    } catch (IOException e3) {
                    }
                }
            } catch (Throwable th) {
                fileOutputStream2 = fileOutputStream;
                th = th;
                if (fileOutputStream2 != null) {
                    try {
                        fileOutputStream2.close();
                    } catch (IOException e4) {
                    }
                }
                throw th;
            }
        } catch (Exception e5) {
            fileOutputStream = null;
        } catch (Throwable th2) {
            th = th2;
        }
    }

    public void aI(List<bjt> list) {
        if (list != null && list.size() != 0) {
            Context applicaionContext = TMSDKContext.getApplicaionContext();
            ArrayList b = tmsdk.common.internal.utils.i.b(applicaionContext, "hst", "hst.dat", new bjt());
            if (b != null && b.size() <= 2000) {
                list.addAll(b);
            }
            tmsdk.common.internal.utils.i.a(applicaionContext, list, "hst", "hst.dat");
        }
    }

    public static void Ve() {
        final Context agJ = com.tencent.server.base.d.agJ();
        ArrayList b = tmsdk.common.internal.utils.i.b(agJ, "hst", "hst.dat", new bjt());
        if (b != null) {
            final ArrayList arrayList = new ArrayList();
            Iterator it = b.iterator();
            while (it.hasNext()) {
                vi a2 = a((bjt) it.next());
                if (a2 != null) {
                    arrayList.add(a2);
                }
            }
            sz JY = ((te) qf.i(te.class)).JY();
            td tdVar = new td(1, new tb(TmsConst.ModuleKey, "reportStatusCheck"));
            HashMap<String, Object> hashMap = new HashMap<>(3);
            hashMap.put("phonetype", JY.JM());
            hashMap.put("userinfo", JY.JO());
            hashMap.put("status", arrayList);
            tdVar.cfF = hashMap;
            if (tdVar != null) {
                ((aic) bir.pC(5)).a(tdVar, new aic.a() {
                    @Override
                    public void a(int i, td tdVar2) {
                        if (i == 0) {
                            agJ.deleteFile("hst.dat");
                        }
                    }
                });
            }
        }
    }

    private static vi a(bjt bjtVar) {
        if (bjtVar == null) {
            return null;
        }
        vi viVar = new vi();
        viVar.a(new ne(new ArrayList()));
        viVar.bH(6);
        viVar.H(bjtVar.time);
        viVar.cE(bjtVar.fQD);
        viVar.setMemo(bjtVar.fQC + " " + bjtVar.RX);
        return viVar;
    }
}