QQ浏览器 v12.2.3.7053版本的 MD5 值为:8285ab3059e5c8b521a264dfbc5c3685

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


package com.tencent.mtt.browser.push.service;

import MTT.PushReportMsg;
import MTT.ReportPushMsgReq;
import android.text.TextUtils;
import com.taf.JceInputStream;
import com.taf.JceOutputStream;
import com.taf.JceSynchronizedPool;
import com.tencent.common.utils.DesUtils;
import com.tencent.common.utils.FileUtils;
import com.tencent.common.utils.QBKeyStore;
import com.tencent.common.utils.StringUtils;
import com.tencent.common.wup.IWUPRequestCallBack;
import com.tencent.common.wup.WUPRequestBase;
import com.tencent.common.wup.WUPResponseBase;
import com.tencent.common.wup.WUPTaskProxy;
import com.tencent.common.wup.extension.WUPStatClient;
import com.tencent.common.wup.extension.WUPStatRequest;
import com.tencent.mtt.ContextHolder;
import com.tencent.mtt.base.wup.GUIDManager;
import com.tencent.mtt.base.wup.WUPRequest;
import com.tencent.mtt.browser.push.service.PushMsgStatRecords;
import com.tencent.mtt.operation.event.EventLog;
import com.tencent.mtt.twsdk.qbinfo.QUAUtils;
import java.io.Closeable;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.File;
import java.nio.ByteBuffer;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;

public class PushStatManager implements IWUPRequestCallBack {

    private static PushStatManager f44126d;

    private boolean f44129c = false;

    public HashMap<String, PushReportMsg> f44127a = new HashMap<>();

    private HashMap<String, PushReportMsg> f44128b = new HashMap<>();

    private PushStatManager() {
        e();
    }

    public static PushStatManager a() {
        if (f44126d == null) {
            synchronized (PushStatManager.class) {
                if (f44126d == null) {
                    f44126d = new PushStatManager();
                }
            }
        }
        return f44126d;
    }

    private void a(PushReportMsg pushReportMsg) {
        GUIDManager a2 = GUIDManager.a();
        byte[] c2 = a2.c();
        if (a2.b(c2)) {
            EventLog.a("PushTips", "push数据上报", "doRealTimePushStat guid空", PushServerConfigs.a(ContextHolder.getAppContext()) ? "测试环境" : "正式环境", "allenhan");
            return;
        }
        EventLog.a("PushTips", "push数据上报", "doRealTimePushStat", PushServerConfigs.a(ContextHolder.getAppContext()) ? "测试环境" : "正式环境", "allenhan");
        ReportPushMsgReq reportPushMsgReq = new ReportPushMsgReq();
        reportPushMsgReq.vGuid = c2;
        ArrayList<PushReportMsg> arrayList = new ArrayList<>();
        arrayList.add(pushReportMsg);
        reportPushMsgReq.vtReportMsg = arrayList;
        try {
            byte[] a3 = DesUtils.a(QBKeyStore.a(13), reportPushMsgReq.toByteArray(), 1);
            WUPStatRequest wUPStatRequest = new WUPStatRequest("pushreport", "reportMsgStatus");
            wUPStatRequest.setUrl(PushServerConfigs.a(ContextHolder.getAppContext()) ? "http://101.226.212.176:80" : "http://report.imtt.qq.com");
            wUPStatRequest.setIsFromService(true);
            wUPStatRequest.setClassLoader(PushStatManager.class.getClassLoader());
            wUPStatRequest.put("vtData", a3);
            WUPStatClient.a().a(wUPStatRequest);
        } catch (Exception unused) {
        }
    }

    static File b() {
        return new File(FileUtils.e(), "statservice.dat");
    }

    private void d() {
        File b2;
        DataOutputStream dataOutputStream;
        HashMap<String, PushReportMsg> hashMap = this.f44127a;
        if (hashMap == null || hashMap.size() <= 0 || (b2 = b()) == null) {
            return;
        }
        try {
            if (!b2.exists()) {
                b2.createNewFile();
            }
            dataOutputStream = new DataOutputStream(FileUtils.j(b2));
            try {
                dataOutputStream.writeUTF(QUAUtils.c().f79953a);
                dataOutputStream.writeShort(this.f44127a.size());
                for (PushReportMsg pushReportMsg : this.f44127a.values()) {
                    JceOutputStream acquireout = JceSynchronizedPool.getInstance().acquireout();
                    pushReportMsg.writeTo(acquireout);
                    byte[] byteArray = acquireout.toByteArray();
                    dataOutputStream.writeShort(byteArray.length);
                    dataOutputStream.write(byteArray, 0, byteArray.length);
                    JceSynchronizedPool.getInstance().releaseOut(acquireout);
                }
            } catch (Exception | OutOfMemoryError unused) {
            } catch (Throwable th) {
                th = th;
                FileUtils.a(dataOutputStream);
                throw th;
            }
        } catch (Exception | OutOfMemoryError unused2) {
            dataOutputStream = null;
        } catch (Throwable th2) {
            th = th2;
            dataOutputStream = null;
        }
        FileUtils.a(dataOutputStream);
    }

    private synchronized void e() {
        File file;
        DataInputStream dataInputStream;
        Throwable th;
        String readUTF;
        if (this.f44127a == null) {
            this.f44127a = new HashMap<>();
        }
        try {
            file = b();
        } catch (Exception unused) {
            file = null;
        }
        if (file != null && file.exists()) {
            try {
                dataInputStream = new DataInputStream(FileUtils.i(file));
                try {
                    readUTF = dataInputStream.readUTF();
                } catch (Exception unused2) {
                } catch (Throwable th2) {
                    th = th2;
                    FileUtils.a((Closeable) dataInputStream);
                    throw th;
                }
            } catch (Exception unused3) {
                dataInputStream = null;
            } catch (Throwable th3) {
                dataInputStream = null;
                th = th3;
            }
            if (!StringUtils.b(readUTF) && Integer.parseInt(readUTF) >= 44) {
                short readShort = dataInputStream.readShort();
                for (int i = 0; i < readShort; i++) {
                    ByteBuffer a2 = FileUtils.a(dataInputStream, dataInputStream.readShort());
                    JceInputStream jceInputStream = new JceInputStream(a2);
                    PushReportMsg pushReportMsg = new PushReportMsg();
                    pushReportMsg.readFrom(jceInputStream);
                    this.f44127a.put(pushReportMsg.iAppId + "key" + pushReportMsg.iMsgId, pushReportMsg);
                    FileUtils.h().a(a2);
                }
                FileUtils.a((Closeable) dataInputStream);
            }
            FileUtils.a((Closeable) dataInputStream);
        }
    }

    private synchronized void f() {
        this.f44129c = true;
    }

    private void g() {
        HashMap<String, PushReportMsg> hashMap = this.f44127a;
        if (hashMap != null) {
            hashMap.clear();
        }
        File b2 = b();
        if (b2 == null || !b2.exists()) {
            return;
        }
        b2.delete();
    }

    public void a(int i, int i2, int i3, byte b2, boolean z, String str) {
        a(i, i2, i3, -1, -1, b2, null, z, str);
    }

    public void a(int i, int i2, int i3, byte b2, boolean z, String str, int i4, int i5) {
        a(i, i2, i3, -1, -1, b2, null, z, str, i4, i5);
    }

    public void a(int i, int i2, int i3, int i4, int i5, byte b2, String str, boolean z, String str2) {
        a(i, i2, i3, i4, i5, b2, str, z, str2, 0, 0);
    }

    public void a(int i, int i2, int i3, int i4, int i5, byte b2, String str, boolean z, String str2, int i6, int i7) {
        if (PushReportStrategy.a().a(i, i2, i3, i5)) {
            PushReportMsg pushReportMsg = new PushReportMsg();
            pushReportMsg.iAppId = i;
            pushReportMsg.iMsgId = i2;
            pushReportMsg.eShowStatus = i3;
            pushReportMsg.eCPosition = i4;
            pushReportMsg.eClickStatus = i5;
            pushReportMsg.cOpenType = b2;
            pushReportMsg.sOpenEvents = str;
            pushReportMsg.sExtraInfo = "";
            pushReportMsg.iTipsNum = i6;
            pushReportMsg.iPosition = i7;
            if (!TextUtils.isEmpty(str2)) {
                pushReportMsg.sExtraInfo = str2;
            }
            pushReportMsg.eFrom = 0;
            b(pushReportMsg, z);
        }
    }

    public void a(int i, int i2, int i3, int i4, boolean z, String str) {
        a(i, i2, -1, i3, i4, (byte) -1, null, z, str);
    }

    public void a(int i, int i2, int i3, boolean z, String str) {
        a(i, i2, i3, (byte) 0, z, str);
    }

    public void a(int i, int i2, boolean z, String str) {
        a(i, i2, -1, 4, 1, (byte) -1, null, z, str);
    }

    public synchronized void a(PushReportMsg pushReportMsg, boolean z) {
        if (pushReportMsg != null) {
            if (pushReportMsg.iAppId >= 0 && pushReportMsg.iMsgId >= 0) {
                if (z) {
                    PushReportMsg pushReportMsg2 = new PushReportMsg();
                    pushReportMsg2.iAppId = pushReportMsg.iAppId;
                    pushReportMsg2.iMsgId = pushReportMsg.iMsgId;
                    pushReportMsg2.eShowStatus = pushReportMsg.eShowStatus;
                    pushReportMsg2.cReportbit = pushReportMsg.cReportbit;
                    pushReportMsg2.eClickStatus = pushReportMsg.eClickStatus;
                    pushReportMsg2.eCPosition = pushReportMsg.eCPosition;
                    pushReportMsg2.iTipsNum = pushReportMsg.iTipsNum;
                    pushReportMsg2.iPosition = pushReportMsg.iPosition;
                    pushReportMsg2.cOpenType = pushReportMsg.cOpenType;
                    pushReportMsg2.sExtraInfo = pushReportMsg.sExtraInfo;
                    pushReportMsg2.eFrom = pushReportMsg.eFrom;
                    a(pushReportMsg2);
                } else {
                    HashMap<String, PushReportMsg> hashMap = this.f44127a;
                    if (this.f44129c) {
                        hashMap = this.f44128b;
                    }
                    String str = pushReportMsg.iAppId + "key" + pushReportMsg.iMsgId;
                    PushReportMsg pushReportMsg3 = hashMap.get(str);
                    if (pushReportMsg3 == null) {
                        PushReportMsg pushReportMsg4 = new PushReportMsg();
                        pushReportMsg4.iAppId = pushReportMsg.iAppId;
                        pushReportMsg4.iMsgId = pushReportMsg.iMsgId;
                        pushReportMsg4.eShowStatus = pushReportMsg.eShowStatus;
                        pushReportMsg4.cReportbit = pushReportMsg.cReportbit;
                        pushReportMsg4.eClickStatus = pushReportMsg.eClickStatus;
                        pushReportMsg4.eCPosition = pushReportMsg.eCPosition;
                        pushReportMsg4.iTipsNum = pushReportMsg.iTipsNum;
                        pushReportMsg4.iPosition = pushReportMsg.iPosition;
                        pushReportMsg4.cOpenType = pushReportMsg.cOpenType;
                        pushReportMsg4.sExtraInfo = pushReportMsg.sExtraInfo;
                        pushReportMsg4.eFrom = pushReportMsg.eFrom;
                        this.f44127a.put(str, pushReportMsg4);
                    } else {
                        pushReportMsg3.eShowStatus = pushReportMsg.eShowStatus;
                        pushReportMsg3.eClickStatus = pushReportMsg.eClickStatus;
                        pushReportMsg3.eCPosition = pushReportMsg.eCPosition;
                        pushReportMsg3.iTipsNum = pushReportMsg.iTipsNum;
                        pushReportMsg3.iPosition = pushReportMsg.iPosition;
                        pushReportMsg3.cReportbit = pushReportMsg.cReportbit;
                        pushReportMsg3.sExtraInfo = pushReportMsg.sExtraInfo;
                    }
                    d();
                }
            }
        }
    }

    synchronized void a(boolean z) {
        if (z) {
            g();
        }
        this.f44129c = false;
        if (this.f44128b != null && !this.f44128b.isEmpty()) {
            if (this.f44127a.isEmpty()) {
                this.f44127a.putAll(this.f44128b);
            } else {
                for (Map.Entry<String, PushReportMsg> entry : this.f44128b.entrySet()) {
                    String key = entry.getKey();
                    PushReportMsg value = entry.getValue();
                    PushReportMsg pushReportMsg = this.f44127a.get(key);
                    if (pushReportMsg == null) {
                        this.f44127a.put(key, value);
                    } else {
                        if (value.eClickStatus != -1) {
                            pushReportMsg.eClickStatus = value.eClickStatus;
                        }
                        if (value.eCPosition != -1) {
                            pushReportMsg.eCPosition = value.eCPosition;
                        }
                        if (value.eShowStatus != -1) {
                            pushReportMsg.eShowStatus = value.eShowStatus;
                        }
                        pushReportMsg.cReportbit = (byte) (value.cReportbit | pushReportMsg.cReportbit);
                    }
                }
            }
            this.f44128b.clear();
        }
    }

    public synchronized void b(PushReportMsg pushReportMsg, boolean z) {
        if (pushReportMsg != null) {
            if (pushReportMsg.iAppId >= 0 && pushReportMsg.iMsgId >= 0) {
                if (pushReportMsg.eShowStatus != -1 && pushReportMsg.eClickStatus != -1) {
                    throw new IllegalArgumentException("");
                }
                if (z) {
                    PushReportMsg pushReportMsg2 = new PushReportMsg();
                    pushReportMsg2.iAppId = pushReportMsg.iAppId;
                    pushReportMsg2.iMsgId = pushReportMsg.iMsgId;
                    pushReportMsg2.sExtraInfo = pushReportMsg.sExtraInfo;
                    PushMsgStatRecords.PushMsgStatInfo a2 = PushMsgStatRecords.a().a(pushReportMsg.iAppId, pushReportMsg.iMsgId);
                    if (a2 != null) {
                        pushReportMsg2.sMsgStatstcType = a2.f44075c;
                        pushReportMsg2.cMsgType = a2.f44076d;
                    }
                    if (pushReportMsg.eShowStatus != -1) {
                        pushReportMsg2.eShowStatus = pushReportMsg.eShowStatus;
                        pushReportMsg2.cReportbit = (byte) 2;
                    } else if (pushReportMsg.eClickStatus != -1) {
                        pushReportMsg2.eClickStatus = pushReportMsg.eClickStatus;
                        pushReportMsg2.eCPosition = pushReportMsg.eCPosition;
                        pushReportMsg2.iTipsNum = pushReportMsg.iTipsNum;
                        pushReportMsg2.iPosition = pushReportMsg.iPosition;
                        pushReportMsg2.cReportbit = (byte) 4;
                    } else {
                        pushReportMsg2.cReportbit = (byte) 1;
                    }
                    pushReportMsg2.eFrom = 0;
                    a(pushReportMsg2);
                } else {
                    HashMap<String, PushReportMsg> hashMap = this.f44127a;
                    if (this.f44129c) {
                        hashMap = this.f44128b;
                    }
                    String str = pushReportMsg.iAppId + "key" + pushReportMsg.iMsgId;
                    PushReportMsg pushReportMsg3 = hashMap.get(str);
                    if (pushReportMsg3 == null) {
                        pushReportMsg3 = new PushReportMsg();
                        pushReportMsg3.iAppId = pushReportMsg.iAppId;
                        pushReportMsg3.iMsgId = pushReportMsg.iMsgId;
                        pushReportMsg3.sExtraInfo = pushReportMsg.sExtraInfo;
                        PushMsgStatRecords.PushMsgStatInfo a3 = PushMsgStatRecords.a().a(pushReportMsg.iAppId, pushReportMsg.iMsgId);
                        if (a3 != null) {
                            pushReportMsg3.sMsgStatstcType = a3.f44075c;
                            pushReportMsg3.cMsgType = a3.f44076d;
                        }
                        this.f44127a.put(str, pushReportMsg3);
                        if (pushReportMsg.eShowStatus != -1) {
                            pushReportMsg3.eShowStatus = pushReportMsg.eShowStatus;
                            pushReportMsg3.cReportbit = (byte) 2;
                        } else if (pushReportMsg.eClickStatus != -1) {
                            pushReportMsg3.eClickStatus = pushReportMsg.eClickStatus;
                            pushReportMsg3.eCPosition = pushReportMsg.eCPosition;
                            pushReportMsg3.iTipsNum = pushReportMsg.iTipsNum;
                            pushReportMsg3.iPosition = pushReportMsg.iPosition;
                            pushReportMsg3.cReportbit = (byte) 4;
                        } else {
                            pushReportMsg3.cReportbit = (byte) 1;
                        }
                        pushReportMsg3.eFrom = 0;
                    } else {
                        pushReportMsg3.sExtraInfo = pushReportMsg.sExtraInfo;
                        if (pushReportMsg.eShowStatus != -1) {
                            pushReportMsg3.eShowStatus = pushReportMsg.eShowStatus;
                            pushReportMsg3.cReportbit = (byte) (pushReportMsg3.cReportbit | 2);
                        } else if (pushReportMsg.eClickStatus != -1) {
                            pushReportMsg3.eClickStatus = pushReportMsg.eClickStatus;
                            pushReportMsg3.eCPosition = pushReportMsg.eCPosition;
                            pushReportMsg3.iTipsNum = pushReportMsg.iTipsNum;
                            pushReportMsg3.iPosition = pushReportMsg.iPosition;
                            pushReportMsg3.cReportbit = (byte) (pushReportMsg3.cReportbit | 4);
                        }
                    }
                    if (pushReportMsg.cOpenType != -1) {
                        pushReportMsg3.cOpenType = pushReportMsg.cOpenType;
                    }
                    d();
                }
            }
        }
    }

    public synchronized void c() {
        if (this.f44127a != null && !this.f44127a.isEmpty()) {
            GUIDManager a2 = GUIDManager.a();
            byte[] c2 = a2.c();
            if (a2.b(c2)) {
                EventLog.a("PushTips", "push数据上报", "doPushReport guid空", PushServerConfigs.a(ContextHolder.getAppContext()) ? "测试环境" : "正式环境", "allenhan");
                return;
            }
            EventLog.a("PushTips", "push数据上报", "doPushReport", PushServerConfigs.a(ContextHolder.getAppContext()) ? "测试环境" : "正式环境", "allenhan");
            f();
            ReportPushMsgReq reportPushMsgReq = new ReportPushMsgReq();
            reportPushMsgReq.vGuid = c2;
            ArrayList<PushReportMsg> arrayList = new ArrayList<>(this.f44127a.values());
            Iterator<PushReportMsg> it = arrayList.iterator();
            while (it.hasNext()) {
                it.next();
            }
            reportPushMsgReq.vtReportMsg = arrayList;
            try {
                byte[] a3 = DesUtils.a(QBKeyStore.a(13), reportPushMsgReq.toByteArray(), 1);
                WUPRequest wUPRequest = new WUPRequest("pushreport", "reportMsgStatus", this);
                wUPRequest.setUrl(PushServerConfigs.a(ContextHolder.getAppContext()) ? "http://101.226.212.176:80" : "http://report.imtt.qq.com");
                wUPRequest.setIsFromService(true);
                wUPRequest.put("vtData", a3);
                WUPTaskProxy.send(wUPRequest);
            } catch (Exception unused) {
            }
        }
    }

    @Override
    public void onWUPTaskFail(WUPRequestBase wUPRequestBase) {
        a(false);
    }

    @Override
    public void onWUPTaskSuccess(WUPRequestBase wUPRequestBase, WUPResponseBase wUPResponseBase) {
        a(wUPResponseBase.isSuccess());
    }
}