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

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


package com.tencent.mtt.hippy.qb.update;

import android.text.TextUtils;
import com.taf.JceOutputStream;
import com.tencent.common.utils.FileUtils;
import com.tencent.common.wup.INetworkDetectCallback;
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.mtt.ContextHolder;
import com.tencent.mtt.base.preload.facade.IQbPreloadService;
import com.tencent.mtt.base.wup.WUPRequest;
import com.tencent.mtt.hippy.qb.HippyConstants;
import com.tencent.mtt.hippy.qb.QBHippyEngineAdapter;
import com.tencent.mtt.hippy.qb.update.MTT.GetJsBundleReq;
import com.tencent.mtt.hippy.qb.update.MTT.GetJsBundleRsp;
import com.tencent.mtt.hippy.qb.update.MTT.JsBundleModule;
import com.tencent.mtt.hippy.qb.update.MTT.JsModuleInfo;
import com.tencent.mtt.twsdk.log.Logs;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Map;

public class HippyUpdateProcess implements INetworkDetectCallback, IWUPRequestCallBack {
    private static final String TAG = "HippyUpdateProcess";
    private boolean firstUpdate;
    HippyUpdateCallback mReactUpdateCallback = null;
    public static HashSet<String> sRequestedModules = new HashSet<>();
    public static ArrayList<JsModuleInfo> moduleInfos = new ArrayList<>();

    public HippyUpdateProcess() {
    }

    public HippyUpdateProcess(boolean z) {
        this.firstUpdate = z;
    }

    public static void build19JsbundleRequest() {
        if (moduleInfos.size() > 0) {
            return;
        }
        ArrayList<JsModuleInfo> arrayList = new ArrayList<>();
        HashMap hashMap = new HashMap();
        hashMap.put("advergame", "https://softimtt.myapp.com/browser/browser/rn/tmp/advergame.1546053080088.zip");
        hashMap.put("AudioApp", "https://hippy.imtt.qq.com//resources/static/onlinepack/zip/AudioApp.1584092404216.zip");
        hashMap.put("circle", "https://hippy.imtt.qq.com//resources/static/onlinepack/zip/circle.1588745651655.zip");
        hashMap.put("circleUserCenter", "https://hippy.imtt.qq.com//resources/static/onlinepack/zip/circleUserCenter.1589963032113.zip");
        hashMap.put("collection", "https://hippy.imtt.qq.com/resources/static/handpack/zip/collection.1588043324536.zip");
        hashMap.put("commentpage", "https://hippy.imtt.qq.com/resources/static/onlinepack/zip/commentpage.1565748582119.zip");
        hashMap.put("community", "https://hippy.imtt.qq.com/resources/static/handpack/zip/community.1591091245012.zip");
        hashMap.put("course", "https://hippy.imtt.qq.com/resources/static/handpack/zip/course.1588144773864.zip");
        hashMap.put("dobby", "https://hippy.imtt.qq.com/resources/static/onlinepack/zip/dobby.1574047115426.zip");
        hashMap.put("dobbyRecord", "https://softimtt.myapp.com/browser/browser/rn/tmp/dobbyRecord.1552383001651.zip");
        hashMap.put("download", "https://hippy.imtt.qq.com/resources/static/onlinepack/zip/download.1566974653299.zip");
        hashMap.put("dynamictab", "https://hippy.imtt.qq.com/resources/static/onlinepack/zip/dynamictab.1589383753984.zip");
        hashMap.put("explorecamera", "https://hippy.imtt.qq.com/resources/static/onlinepack/zip/explorecamera.1573471216665.zip");
        hashMap.put("exploreimage", "https://softimtt.myapp.com/browser/browser/rn/tmp/exploreimage.1546851513389.zip");
        hashMap.put("feedschannel", "https://hippy.imtt.qq.com/resources/static/onlinepack/zip/feedschannel.1589205575247.zip");
        hashMap.put("feedstestchannel", "https://hippy.imtt.qq.com/resources/static/onlinepack/zip/feedstestchannel.1582709727902.zip");
        hashMap.put("fun", "https://hippy.imtt.qq.com/resources/static/handpack/zip/fun.1591363725122.zip");
        hashMap.put("gameads", "https://softimtt.myapp.com/browser/browser/rn/tmp/gameads.1545305692709.zip");
        hashMap.put("gameCenter", "https://hippy.imtt.qq.com//resources/static/onlinepack/zip/gameCenter.1586846814353.zip");
        hashMap.put("historyCovers", "https://hippy.imtt.qq.com/resources/static/handpack/zip/historyCovers.1588127935347.zip");
        hashMap.put("ImageReaderAD", "https://hippy.imtt.qq.com//resources/static/onlinepack/zip/ImageReaderAD.1591009559385.zip");
        hashMap.put("installFinish", "https://hippy.imtt.qq.com//resources/static/onlinepack/zip/installFinish.1589334688580.zip");
        hashMap.put("kdAlbum", "https://hippy.imtt.qq.com/resources/static/handpack/zip/kdAlbum.1575538889706.zip");
        hashMap.put("kdPostDetail", "https://hippy.imtt.qq.com/resources/static/handpack/zip/kdPostDetail.1587911565128.zip");
        hashMap.put("market", "https://hippy.imtt.qq.com//resources/static/onlinepack/zip/market.1589164238432.zip");
        hashMap.put("minigame", "https://softimtt.myapp.com/browser/browser/rn/tmp/minigame.1541388499954.zip");
        hashMap.put("MoAudio", "https://softimtt.myapp.com/browser/browser/rn/tmp/MoAudio.1532418893046.zip");
        hashMap.put("nfa_game_act", "https://hippy.imtt.qq.com//resources/static/onlinepack/zip/nfa_game_act.1590995849012.zip");
        hashMap.put("nfa_game_ad", "https://hippy.imtt.qq.com/resources/static/onlinepack/zip/nfa_game_ad.1583138460531.zip");
        hashMap.put(QBHippyEngineAdapter.NOVEL_BUNDLE_NAME, "https://hippy.imtt.qq.com/resources/static/handpack/zip/novelReader.1591254072654.zip");
        hashMap.put("nowcenter", "https://hippy.imtt.qq.com//resources/static/onlinepack/zip/nowcenter.1585193548485.zip");
        hashMap.put("nowportal", "https://hippy.imtt.qq.com/resources/static/onlinepack/zip/nowportal.1568972355731.zip");
        hashMap.put("nowtablist", "https://hippy.imtt.qq.com/resources/static/onlinepack/zip/nowtablist.1575424955264.zip");
        hashMap.put("publisher", "https://hippy.imtt.qq.com//resources/static/onlinepack/zip/publisher.1589033646851.zip");
        hashMap.put("qbtopic", "https://hippy.imtt.qq.com/resources/static/onlinepack/zip/qbtopic.1590550737557.zip");
        hashMap.put("QBUserCenter", "https://hippy.imtt.qq.com//resources/static/onlinepack/zip/QBUserCenter.1591343080927.zip");
        hashMap.put("share-center", "https://softimtt.myapp.com/browser/browser/rn/tmp/share-center.1557904388391.zip");
        hashMap.put("SmartAssistant", "https://hippy.imtt.qq.com//resources/static/onlinepack/zip/SmartAssistant.1590414135580.zip");
        hashMap.put("sports", "https://hippy.imtt.qq.com/resources/static/handpack/zip/sports.1589352411818.zip");
        hashMap.put("ugcfloat", "https://hippy.imtt.qq.com/resources/static/onlinepack/zip/ugcfloat.1590996129869.zip");
        hashMap.put("verticalSearchNovel", "https://hippy.imtt.qq.com/resources/static/handpack/zip/verticalSearchNovel.1575548825305.zip");
        hashMap.put(IQbPreloadService.QB_PRELOAD_MODULE_VIDEOFLOAT, "https://hippy.imtt.qq.com/resources/static/onlinepack/zip/videofloat.1591010095827.zip");
        hashMap.put("videoportal", "https://softimtt.myapp.com/browser/browser/rn/tmp/videoportal.1536587522448.zip");
        hashMap.put("weather", "https://hippy.imtt.qq.com//resources/static/onlinepack/zip/weather.1589331299147.zip");
        for (Map.Entry entry : hashMap.entrySet()) {
            JsModuleInfo jsModuleInfo = new JsModuleInfo();
            jsModuleInfo.sModuleName = (String) entry.getKey();
            arrayList.add(jsModuleInfo);
        }
        GetJsBundleReq getJsBundleReq = new GetJsBundleReq();
        getJsBundleReq.vstModuleInfos = arrayList;
        getJsBundleReq.sAppKey = "0000";
        getJsBundleReq.sSdkVersion = HippyConstants.HIPPY_SDK_VERSION;
        WUPRequest wUPRequest = new WUPRequest("qbhippy", "getJsBundle");
        wUPRequest.put("stReq", getJsBundleReq);
        new JsBundleModule().sModuleName = "wup";
        wUPRequest.setRequestCallBack(new IWUPRequestCallBack() {
            @Override
            public void onWUPTaskFail(WUPRequestBase wUPRequestBase) {
                Logs.b(HippyUpdateProcess.TAG, "request 19 jsbundle onWUPTaskFail:" + wUPRequestBase.getErrorCode());
            }

            @Override
            public void onWUPTaskSuccess(WUPRequestBase wUPRequestBase, WUPResponseBase wUPResponseBase) {
                GetJsBundleRsp getJsBundleRsp = (GetJsBundleRsp) wUPResponseBase.get("stRsp");
                if (getJsBundleRsp == null || getJsBundleRsp.iStatus != 0 || getJsBundleRsp.vstJsBundleModules.size() < 1) {
                    return;
                }
                ArrayList<JsBundleModule> arrayList2 = getJsBundleRsp.vstJsBundleModules;
                JceOutputStream jceOutputStream = new JceOutputStream(0);
                getJsBundleRsp.writeTo(jceOutputStream);
                File file = new File("/sdcard/", "commonjs19.conf");
                if (!file.exists()) {
                    try {
                        file.createNewFile();
                    } catch (IOException unused) {
                    }
                }
                Logs.b(HippyUpdateProcess.TAG, "request 19 jsbundle onWUPTaskSuccess");
                FileUtils.a(file, jceOutputStream.copyByteArray());
            }
        });
        WUPTaskProxy.send(wUPRequest);
    }

    private void processWupTaskSuccess(WUPRequestBase wUPRequestBase, WUPResponseBase wUPResponseBase) {
        Logs.b(TAG, "react update onWUPTaskSuccess");
        GetJsBundleRsp getJsBundleRsp = (GetJsBundleRsp) wUPResponseBase.get("stRsp");
        if (getJsBundleRsp == null || getJsBundleRsp.iStatus != 0 || getJsBundleRsp.vstJsBundleModules.size() < 1) {
            if (this.mReactUpdateCallback != null) {
                Logs.b(TAG, "react update onUpdateFail callback!=null");
                this.mReactUpdateCallback.onUpdateFail();
            } else {
                Logs.b(TAG, "react update onUpdateFail callback==null");
            }
            HippyUpdateMonitor.getInstance().fire("wup更新jsBundle请求成功:服务器没有任何更新");
            return;
        }
        Logs.b(TAG, "react update processDownload succ");
        Iterator<JsBundleModule> it = getJsBundleRsp.vstJsBundleModules.iterator();
        while (it.hasNext()) {
            JsBundleModule next = it.next();
            processDownload(next);
            Logs.b(TAG, "get jsbundle:" + next.sModuleName + ", vn:" + next.sVersionName + ", vc:" + next.iVersionCode + ", updateType:" + next.iUpdateType);
        }
    }

    public WUPRequestBase buildUpdateRequest(String str, HippyUpdateCallback hippyUpdateCallback) {
        Logs.b(TAG, "buildUpdateRequest");
        ArrayList<JsModuleInfo> arrayList = new ArrayList<>();
        arrayList.add(new JsModuleInfo(str, 0, 1));
        WUPRequest wupRequest = getWupRequest(arrayList);
        this.mReactUpdateCallback = hippyUpdateCallback;
        JsBundleModule jsBundleModule = new JsBundleModule();
        jsBundleModule.sModuleName = "wup";
        HippyReportManager.getInstance().reportUpdateToBeacon(null, jsBundleModule, "100");
        return wupRequest;
    }

    public WUPRequest buildUpdateRequest() {
        ArrayList<JsModuleInfo> arrayList = new ArrayList<>();
        File[] listFiles = HippyFileUtils.getBundlesDir().listFiles();
        if (listFiles != null) {
            for (File file : listFiles) {
                int preModuleVersion = HippyUpdateConfig.getInstance().getPreModuleVersion(file.getName(), -1);
                if (preModuleVersion == -1) {
                    preModuleVersion = HippyUpdateConfig.getInstance().getModuleVersion(file.getName(), -1);
                }
                if (preModuleVersion > 0) {
                    UpdateHelper.getInstance().cacheVersion(file.getName(), preModuleVersion + "");
                    arrayList.add(new JsModuleInfo(file.getName(), preModuleVersion, 0));
                    sRequestedModules.add(file.getName());
                    Logs.b(TAG, "buildUpdateRequest: file" + file.getName() + ", version:" + preModuleVersion);
                    HippyUpdateMonitor.getInstance().fire("构建" + file.getName() + "模块更新请求version:" + preModuleVersion);
                }
            }
        }
        WUPRequest wupRequest = getWupRequest(arrayList);
        JsBundleModule jsBundleModule = new JsBundleModule();
        jsBundleModule.sModuleName = "wup";
        HippyReportManager.getInstance().reportUpdateToBeacon(null, jsBundleModule, "100");
        Logs.b(TAG, "buildUpdateRequest succ");
        return wupRequest;
    }

    public WUPRequest getWupRequest(ArrayList<JsModuleInfo> arrayList) {
        GetJsBundleReq getJsBundleReq = new GetJsBundleReq();
        getJsBundleReq.vstModuleInfos = arrayList;
        getJsBundleReq.sAppKey = TextUtils.equals(ContextHolder.getAppContext().getPackageName(), "com.tencent.mtt") ? "0000" : "kuaibao";
        if (arrayList != null) {
            Iterator<JsModuleInfo> it = arrayList.iterator();
            while (it.hasNext()) {
                Logs.b(TAG, "getWupRequest:" + it.next().sModuleName);
            }
        }
        getJsBundleReq.sSdkVersion = HippyConstants.HIPPY_SDK_VERSION;
        WUPRequest wUPRequest = new WUPRequest("qbhippy", "getJsBundle");
        wUPRequest.put("stReq", getJsBundleReq);
        wUPRequest.setNetworkDetectCallback(this);
        wUPRequest.setRequestCallBack(this);
        return wUPRequest;
    }

    @Override
    public void onDetectResult(WUPRequestBase wUPRequestBase, boolean z) {
        JsBundleModule jsBundleModule = new JsBundleModule();
        jsBundleModule.sModuleName = "wup";
        if (z) {
            HashMap<String, String> hashMap = new HashMap<>();
            hashMap.put("extraData", wUPRequestBase.getFailedReason());
            hashMap.put("errorCode", wUPRequestBase.getErrorCode() + "");
            HippyReportManager.getInstance().reportUpdateToBeacon(null, jsBundleModule, "102", hashMap);
        } else {
            HippyReportManager.getInstance().reportUpdateToBeacon(null, jsBundleModule, "101");
        }
        Logs.b(TAG, "onDetectResult result:" + z + ", " + wUPRequestBase.getErrorCode());
    }

    @Override
    public void onWUPTaskFail(WUPRequestBase wUPRequestBase) {
        Logs.b(TAG, " react update onWUPTaskFail:" + wUPRequestBase.getErrorCode());
        HippyUpdateCallback hippyUpdateCallback = this.mReactUpdateCallback;
        if (hippyUpdateCallback != null) {
            hippyUpdateCallback.onUpdateFail();
        }
        HippyUpdateMonitor.getInstance().fire("wup更新jsBundle请求失败:ErrorCode" + wUPRequestBase.getErrorCode());
    }

    @Override
    public void onWUPTaskSuccess(WUPRequestBase wUPRequestBase, WUPResponseBase wUPResponseBase) {
        processWupTaskSuccess(wUPRequestBase, wUPResponseBase);
    }

    void processDownload(JsBundleModule jsBundleModule) {
        if (jsBundleModule.stDiffPkg == null || TextUtils.isEmpty(jsBundleModule.stDiffPkg.sUrl)) {
            Logs.b(TAG, jsBundleModule.sModuleName + " processDownload: total");
            new HippyUpdateTotal(jsBundleModule).process(this.firstUpdate, this.mReactUpdateCallback);
            return;
        }
        Logs.b(TAG, jsBundleModule.sModuleName + " processDownload: diff");
        new HippyUpdateDiff(jsBundleModule).process(this.firstUpdate, this.mReactUpdateCallback);
    }

    public void setUpdateCallback(HippyUpdateCallback hippyUpdateCallback) {
        this.mReactUpdateCallback = hippyUpdateCallback;
    }
}