Search in sources :

Example 1 with JsVersionInfoBean

use of com.benmu.framework.model.JsVersionInfoBean in project WeexErosFramework by bmfe.

the class VersionManager method checkBundleUpdate.

public void checkBundleUpdate(Context context, String url, boolean isDiff, StringCallback callback) {
    HashMap<String, String> params = new HashMap<>();
    params.put("appName", BMWXEnvironment.mPlatformConfig.getAppName());
    params.put("android", BaseCommonUtil.getVersionName(context));
    String versionInfo = SharePreferenceUtil.getDownLoadVersion(context);
    if (TextUtils.isEmpty(versionInfo)) {
        versionInfo = SharePreferenceUtil.getVersion(context);
    }
    if (TextUtils.isEmpty(versionInfo)) {
        versionInfo = "";
    } else {
        ParseManager parseManager = ManagerFactory.getManagerService(ParseManager.class);
        JsVersionInfoBean jsVersionInfoBean = parseManager.parseObject(versionInfo, JsVersionInfoBean.class);
        if (jsVersionInfoBean == null) {
            versionInfo = "";
        } else {
            versionInfo = jsVersionInfoBean.getJsVersion();
        }
    }
    if (TextUtils.isEmpty(versionInfo)) {
        return;
    }
    params.put("jsVersion", versionInfo);
    params.put("isDiff", isDiff ? "1" : "0");
    AxiosManager axiosManager = ManagerFactory.getManagerService(AxiosManager.class);
    axiosManager.get(url, params, null, callback, url, 0);
}
Also used : HashMap(java.util.HashMap) JsVersionInfoBean(com.benmu.framework.model.JsVersionInfoBean)

Example 2 with JsVersionInfoBean

use of com.benmu.framework.model.JsVersionInfoBean in project WeexErosFramework by bmfe.

the class AppUtils method getJsVersion.

public static String getJsVersion(Context context) {
    String jsVersion = SharePreferenceUtil.getVersion(context);
    if (TextUtils.isEmpty(jsVersion)) {
        AssetsUtil.AssetsJsVersion assetsVersionInfo = AssetsUtil.getAssetsVersionInfo(context);
        if (assetsVersionInfo != null) {
            ParseManager parseManager = ManagerFactory.getManagerService(ParseManager.class);
            SharePreferenceUtil.setVersion(context, parseManager.toJsonString(assetsVersionInfo));
        }
        return assetsVersionInfo == null ? "" : assetsVersionInfo.getJsVersion();
    }
    ParseManager parseManager = ManagerFactory.getManagerService(ParseManager.class);
    JsVersionInfoBean jsVersionInfoBean = parseManager.parseObject(jsVersion, JsVersionInfoBean.class);
    return jsVersionInfoBean == null ? "" : jsVersionInfoBean.getJsVersion();
}
Also used : JsVersionInfoBean(com.benmu.framework.model.JsVersionInfoBean) ParseManager(com.benmu.framework.manager.impl.ParseManager)

Example 3 with JsVersionInfoBean

use of com.benmu.framework.model.JsVersionInfoBean in project WeexErosFramework by bmfe.

the class VersionManager method isCover.

private boolean isCover(Context context) {
    AssetsUtil.AssetsJsVersion assetsVersionInfo = AssetsUtil.getAssetsVersionInfo(context);
    String downloadVersion = SharePreferenceUtil.getDownLoadVersion(context);
    ParseManager parseManager = ManagerFactory.getManagerService(ParseManager.class);
    JsVersionInfoBean compareVersion = null;
    if (TextUtils.isEmpty(downloadVersion)) {
        String currentVersion = SharePreferenceUtil.getVersion(context);
        compareVersion = parseManager.parseObject(currentVersion, JsVersionInfoBean.class);
    } else {
        compareVersion = parseManager.parseObject(downloadVersion, JsVersionInfoBean.class);
    }
    return isCoverByAssetsZip(context, new JsVersionInfoBean(assetsVersionInfo.getJsVersion(), assetsVersionInfo.getAndroid(), assetsVersionInfo.getTimestamp()), compareVersion);
}
Also used : AssetsUtil(com.benmu.framework.utils.AssetsUtil) JsVersionInfoBean(com.benmu.framework.model.JsVersionInfoBean)

Example 4 with JsVersionInfoBean

use of com.benmu.framework.model.JsVersionInfoBean in project WeexErosFramework by bmfe.

the class VersionChecker method checkZipValidate.

/**
 * MD5 效验
 */
private boolean checkZipValidate(File file) {
    if (file.exists()) {
        byte[] json = FileManager.extractZip(file, "md5.json");
        try {
            Md5MapperModel mapper = ManagerFactory.getManagerService(ParseManager.class).parseObject(new String(json, "UTF-8"), Md5MapperModel.class);
            // 校验文件正确性
            List<Md5MapperModel.Item> lists = mapper.getFilesMd5();
            // 按照md5值从小到大排列
            Collections.sort(lists);
            // 所有md5想加得到总的md5
            String total = "";
            for (Md5MapperModel.Item item : lists) {
                total = total + item.getMd5();
            }
            String finalMd5 = Md5Util.getMd5code(total);
            // 比较md5是否正确
            newVersion = new JsVersionInfoBean(mapper.getJsVersion(), mapper.getAndroid(), mapper.getTimestamp());
            return mapper.getJsVersion().equals(finalMd5);
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        }
    }
    return false;
}
Also used : Md5MapperModel(com.benmu.framework.model.Md5MapperModel) UnsupportedEncodingException(java.io.UnsupportedEncodingException) JsVersionInfoBean(com.benmu.framework.model.JsVersionInfoBean) ParseManager(com.benmu.framework.manager.impl.ParseManager)

Aggregations

JsVersionInfoBean (com.benmu.framework.model.JsVersionInfoBean)4 ParseManager (com.benmu.framework.manager.impl.ParseManager)2 Md5MapperModel (com.benmu.framework.model.Md5MapperModel)1 AssetsUtil (com.benmu.framework.utils.AssetsUtil)1 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1 HashMap (java.util.HashMap)1